summaryrefslogtreecommitdiff
path: root/EDK/Foundation
diff options
context:
space:
mode:
Diffstat (limited to 'EDK/Foundation')
-rw-r--r--EDK/Foundation/Core/Dxe/ArchProtocol/ArchProtocolLib.cif38
-rw-r--r--EDK/Foundation/Core/Dxe/ArchProtocol/ArchProtocolLib.inf65
-rw-r--r--EDK/Foundation/Core/Dxe/ArchProtocol/ArchProtocolLib.mak69
-rw-r--r--EDK/Foundation/Core/Dxe/ArchProtocol/ArchProtocolLib.sdl26
-rw-r--r--EDK/Foundation/Core/Dxe/ArchProtocol/Bds/Bds.c27
-rw-r--r--EDK/Foundation/Core/Dxe/ArchProtocol/Bds/Bds.h100
-rw-r--r--EDK/Foundation/Core/Dxe/ArchProtocol/Capsule/Capsule.c27
-rw-r--r--EDK/Foundation/Core/Dxe/ArchProtocol/Capsule/Capsule.h33
-rw-r--r--EDK/Foundation/Core/Dxe/ArchProtocol/Cpu/Cpu.c28
-rw-r--r--EDK/Foundation/Core/Dxe/ArchProtocol/Cpu/Cpu.h361
-rw-r--r--EDK/Foundation/Core/Dxe/ArchProtocol/Metronome/Metronome.c27
-rw-r--r--EDK/Foundation/Core/Dxe/ArchProtocol/Metronome/Metronome.h109
-rw-r--r--EDK/Foundation/Core/Dxe/ArchProtocol/MonotonicCounter/MonotonicCounter.c27
-rw-r--r--EDK/Foundation/Core/Dxe/ArchProtocol/MonotonicCounter/MonotonicCounter.h35
-rw-r--r--EDK/Foundation/Core/Dxe/ArchProtocol/RealTimeClock/RealTimeClock.c27
-rw-r--r--EDK/Foundation/Core/Dxe/ArchProtocol/RealTimeClock/RealTimeClock.h43
-rw-r--r--EDK/Foundation/Core/Dxe/ArchProtocol/Reset/Reset.c27
-rw-r--r--EDK/Foundation/Core/Dxe/ArchProtocol/Reset/Reset.h40
-rw-r--r--EDK/Foundation/Core/Dxe/ArchProtocol/Runtime/Runtime.c29
-rw-r--r--EDK/Foundation/Core/Dxe/ArchProtocol/Runtime/Runtime.h114
-rw-r--r--EDK/Foundation/Core/Dxe/ArchProtocol/Security/Security.c28
-rw-r--r--EDK/Foundation/Core/Dxe/ArchProtocol/Security/Security.h146
-rw-r--r--EDK/Foundation/Core/Dxe/ArchProtocol/StatusCode/StatusCode.c29
-rw-r--r--EDK/Foundation/Core/Dxe/ArchProtocol/StatusCode/StatusCode.h100
-rw-r--r--EDK/Foundation/Core/Dxe/ArchProtocol/Timer/Timer.c27
-rw-r--r--EDK/Foundation/Core/Dxe/ArchProtocol/Timer/Timer.h260
-rw-r--r--EDK/Foundation/Core/Dxe/ArchProtocol/Variable/Variable.c29
-rw-r--r--EDK/Foundation/Core/Dxe/ArchProtocol/Variable/Variable.h41
-rw-r--r--EDK/Foundation/Core/Dxe/ArchProtocol/VariableWrite/VariableWrite.c30
-rw-r--r--EDK/Foundation/Core/Dxe/ArchProtocol/VariableWrite/VariableWrite.h41
-rw-r--r--EDK/Foundation/Core/Dxe/ArchProtocol/WatchdogTimer/WatchdogTimer.c27
-rw-r--r--EDK/Foundation/Core/Dxe/ArchProtocol/WatchdogTimer/WatchdogTimer.h206
-rw-r--r--EDK/Foundation/Core/Dxe/Dispatcher/Dispatcher.c1203
-rw-r--r--EDK/Foundation/Core/Dxe/Dispatcher/dependency.c451
-rw-r--r--EDK/Foundation/Core/Dxe/DxeMain.cif53
-rw-r--r--EDK/Foundation/Core/Dxe/DxeMain.inf111
-rw-r--r--EDK/Foundation/Core/Dxe/DxeMain/DxeMain.c1010
-rw-r--r--EDK/Foundation/Core/Dxe/DxeMain/DxeProtocolNotify.c319
-rw-r--r--EDK/Foundation/Core/Dxe/Event/event.c845
-rw-r--r--EDK/Foundation/Core/Dxe/Event/exec.h209
-rw-r--r--EDK/Foundation/Core/Dxe/Event/execdata.c50
-rw-r--r--EDK/Foundation/Core/Dxe/Event/timer.c386
-rw-r--r--EDK/Foundation/Core/Dxe/Event/tpl.c198
-rw-r--r--EDK/Foundation/Core/Dxe/FwVol/Ffs.c266
-rw-r--r--EDK/Foundation/Core/Dxe/FwVol/FwVol.c556
-rw-r--r--EDK/Foundation/Core/Dxe/FwVol/FwVolAttrib.c99
-rw-r--r--EDK/Foundation/Core/Dxe/FwVol/FwVolDriver.h487
-rw-r--r--EDK/Foundation/Core/Dxe/FwVol/FwVolRead.c520
-rw-r--r--EDK/Foundation/Core/Dxe/FwVol/FwVolWrite.c60
-rw-r--r--EDK/Foundation/Core/Dxe/FwVolBlock/FwVolBlock.c621
-rw-r--r--EDK/Foundation/Core/Dxe/FwVolBlock/FwVolBlock.h334
-rw-r--r--EDK/Foundation/Core/Dxe/Gcd/gcd.c2509
-rw-r--r--EDK/Foundation/Core/Dxe/Gcd/gcd.h54
-rw-r--r--EDK/Foundation/Core/Dxe/Hand/DriverSupport.c860
-rw-r--r--EDK/Foundation/Core/Dxe/Hand/Notify.c335
-rw-r--r--EDK/Foundation/Core/Dxe/Hand/hand.h339
-rw-r--r--EDK/Foundation/Core/Dxe/Hand/handle.c1716
-rw-r--r--EDK/Foundation/Core/Dxe/Hand/locate.c743
-rw-r--r--EDK/Foundation/Core/Dxe/Ia32/Processor.h27
-rw-r--r--EDK/Foundation/Core/Dxe/Image/Image.c1626
-rw-r--r--EDK/Foundation/Core/Dxe/Image/Image.h399
-rw-r--r--EDK/Foundation/Core/Dxe/Image/ImageFile.c646
-rw-r--r--EDK/Foundation/Core/Dxe/Include/DxeCore.h2535
-rw-r--r--EDK/Foundation/Core/Dxe/Include/Library.h531
-rw-r--r--EDK/Foundation/Core/Dxe/Ipf/Processor.h27
-rw-r--r--EDK/Foundation/Core/Dxe/Library/Library.c878
-rw-r--r--EDK/Foundation/Core/Dxe/Mem/Page.c1648
-rw-r--r--EDK/Foundation/Core/Dxe/Mem/imem.h214
-rw-r--r--EDK/Foundation/Core/Dxe/Mem/memdata.c41
-rw-r--r--EDK/Foundation/Core/Dxe/Mem/pool.c613
-rw-r--r--EDK/Foundation/Core/Dxe/Misc/DebugImageInfo.c262
-rw-r--r--EDK/Foundation/Core/Dxe/Misc/DebugImageInfo.h129
-rw-r--r--EDK/Foundation/Core/Dxe/Misc/DebugMask.c400
-rw-r--r--EDK/Foundation/Core/Dxe/Misc/DebugMask.h122
-rw-r--r--EDK/Foundation/Core/Dxe/Misc/InstallConfigurationTable.c230
-rw-r--r--EDK/Foundation/Core/Dxe/Misc/SetWatchdogTimer.c84
-rw-r--r--EDK/Foundation/Core/Dxe/Misc/Stall.c79
-rw-r--r--EDK/Foundation/Core/Dxe/SectionExtraction/CoreSectionExtraction.c1387
-rw-r--r--EDK/Foundation/Core/Dxe/x64/Processor.h27
-rw-r--r--EDK/Foundation/Core/Pei/BootMode/BootMode.c108
-rw-r--r--EDK/Foundation/Core/Pei/DebugMask/DebugMask.c156
-rw-r--r--EDK/Foundation/Core/Pei/Dependency/dependency.c268
-rw-r--r--EDK/Foundation/Core/Pei/Dependency/dependency.h38
-rw-r--r--EDK/Foundation/Core/Pei/Dispatcher/Dispatcher.c593
-rw-r--r--EDK/Foundation/Core/Pei/FwVol/FwVol.c484
-rw-r--r--EDK/Foundation/Core/Pei/Hob/Hob.c191
-rw-r--r--EDK/Foundation/Core/Pei/Ia32/SwitchCoreStacks.asm87
-rw-r--r--EDK/Foundation/Core/Pei/Image/Image.c277
-rw-r--r--EDK/Foundation/Core/Pei/Include/PeiCore.h1275
-rw-r--r--EDK/Foundation/Core/Pei/Memory/MemoryServices.c395
-rw-r--r--EDK/Foundation/Core/Pei/PeiMain.cif24
-rw-r--r--EDK/Foundation/Core/Pei/PeiMain.inf82
-rw-r--r--EDK/Foundation/Core/Pei/PeiMain/PeiMain.c321
-rw-r--r--EDK/Foundation/Core/Pei/Ppi/Ppi.c667
-rw-r--r--EDK/Foundation/Core/Pei/Reset/Reset.c73
-rw-r--r--EDK/Foundation/Core/Pei/Security/Security.c194
-rw-r--r--EDK/Foundation/Core/Pei/StatusCode/StatusCode.c102
-rw-r--r--EDK/Foundation/Cpu/Itanium/CpuIa64Lib.cif12
-rw-r--r--EDK/Foundation/Cpu/Itanium/CpuIa64Lib.mak71
-rw-r--r--EDK/Foundation/Cpu/Itanium/CpuIa64Lib.sdl25
-rw-r--r--EDK/Foundation/Cpu/Itanium/CpuIa64Lib/CpuIA64Lib.inf38
-rw-r--r--EDK/Foundation/Cpu/Itanium/CpuIa64Lib/IPF/CpuIa64.s33
-rw-r--r--EDK/Foundation/Cpu/Itanium/Include/CpuIa64.h39
-rw-r--r--EDK/Foundation/Cpu/Pentium/CpuIA32Lib.cif15
-rw-r--r--EDK/Foundation/Cpu/Pentium/CpuIA32Lib.mak102
-rw-r--r--EDK/Foundation/Cpu/Pentium/CpuIA32Lib.sdl26
-rw-r--r--EDK/Foundation/Cpu/Pentium/CpuIA32Lib/CpuIA32Lib.inf43
-rw-r--r--EDK/Foundation/Cpu/Pentium/CpuIA32Lib/EfiCpuVersion.c73
-rw-r--r--EDK/Foundation/Cpu/Pentium/CpuIA32Lib/IA32/CpuIA32.asm234
-rw-r--r--EDK/Foundation/Cpu/Pentium/CpuIA32Lib/IA32/IA32Type.inc34
-rw-r--r--EDK/Foundation/Cpu/Pentium/CpuIA32Lib/x64/Cpu.asm215
-rw-r--r--EDK/Foundation/Cpu/Pentium/Include/CpuIA32.h372
-rw-r--r--EDK/Foundation/EdkHeaders.cif125
-rw-r--r--EDK/Foundation/Efi/Guid/Acpi/Acpi.c35
-rw-r--r--EDK/Foundation/Efi/Guid/Acpi/Acpi.h44
-rw-r--r--EDK/Foundation/Efi/Guid/DebugImageInfoTable/DebugImageInfoTable.c28
-rw-r--r--EDK/Foundation/Efi/Guid/DebugImageInfoTable/DebugImageInfoTable.h63
-rw-r--r--EDK/Foundation/Efi/Guid/EfiGuidLib.cif30
-rw-r--r--EDK/Foundation/Efi/Guid/EfiGuidLib.inf59
-rw-r--r--EDK/Foundation/Efi/Guid/EfiGuidLib.mak72
-rw-r--r--EDK/Foundation/Efi/Guid/EfiGuidLib.sdl26
-rw-r--r--EDK/Foundation/Efi/Guid/EventGroup/EventGroup.c30
-rw-r--r--EDK/Foundation/Efi/Guid/EventGroup/EventGroup.h45
-rw-r--r--EDK/Foundation/Efi/Guid/GlobalVariable/GlobalVariable.c27
-rw-r--r--EDK/Foundation/Efi/Guid/GlobalVariable/GlobalVariable.h32
-rw-r--r--EDK/Foundation/Efi/Guid/Gpt/Gpt.c38
-rw-r--r--EDK/Foundation/Efi/Guid/Gpt/Gpt.h47
-rw-r--r--EDK/Foundation/Efi/Guid/HardwareErrorVariable/HardwareErrorVariable.c27
-rw-r--r--EDK/Foundation/Efi/Guid/HardwareErrorVariable/HardwareErrorVariable.h32
-rw-r--r--EDK/Foundation/Efi/Guid/Mps/Mps.c33
-rw-r--r--EDK/Foundation/Efi/Guid/Mps/Mps.h38
-rw-r--r--EDK/Foundation/Efi/Guid/PcAnsi/PcAnsi.c34
-rw-r--r--EDK/Foundation/Efi/Guid/PcAnsi/PcAnsi.h50
-rw-r--r--EDK/Foundation/Efi/Guid/SalSystemTable/SalSystemTable.c30
-rw-r--r--EDK/Foundation/Efi/Guid/SalSystemTable/SalSystemTable.h34
-rw-r--r--EDK/Foundation/Efi/Guid/SmBios/SmBios.c31
-rw-r--r--EDK/Foundation/Efi/Guid/SmBios/SmBios.h70
-rw-r--r--EDK/Foundation/Efi/Include/EfiApi.h1114
-rw-r--r--EDK/Foundation/Efi/Include/EfiDevicePath.h568
-rw-r--r--EDK/Foundation/Efi/Include/EfiError.h70
-rw-r--r--EDK/Foundation/Efi/Include/EfiHii.h1473
-rw-r--r--EDK/Foundation/Efi/Include/EfiImage.h703
-rw-r--r--EDK/Foundation/Efi/Include/EfiTypes.h292
-rw-r--r--EDK/Foundation/Efi/Include/Pxe.h58
-rw-r--r--EDK/Foundation/Efi/Protocol/AbsolutePointer/AbsolutePointer.c29
-rw-r--r--EDK/Foundation/Efi/Protocol/AbsolutePointer/AbsolutePointer.h117
-rw-r--r--EDK/Foundation/Efi/Protocol/AcpiTable/AcpiTable.c29
-rw-r--r--EDK/Foundation/Efi/Protocol/AcpiTable/AcpiTable.h112
-rw-r--r--EDK/Foundation/Efi/Protocol/Arp/Arp.c29
-rw-r--r--EDK/Foundation/Efi/Protocol/Arp/Arp.h136
-rw-r--r--EDK/Foundation/Efi/Protocol/AuthenticationInfo/AuthenticationInfo.c30
-rw-r--r--EDK/Foundation/Efi/Protocol/AuthenticationInfo/AuthenticationInfo.h106
-rw-r--r--EDK/Foundation/Efi/Protocol/Bis/Bis.c27
-rw-r--r--EDK/Foundation/Efi/Protocol/Bis/Bis.h233
-rw-r--r--EDK/Foundation/Efi/Protocol/BlockIO/BlockIO.c31
-rw-r--r--EDK/Foundation/Efi/Protocol/BlockIO/BlockIO.h213
-rw-r--r--EDK/Foundation/Efi/Protocol/BusSpecificDriverOverride/BusSpecificDriverOverride.c31
-rw-r--r--EDK/Foundation/Efi/Protocol/BusSpecificDriverOverride/BusSpecificDriverOverride.h54
-rw-r--r--EDK/Foundation/Efi/Protocol/ComponentName/ComponentName.c29
-rw-r--r--EDK/Foundation/Efi/Protocol/ComponentName/ComponentName.h137
-rw-r--r--EDK/Foundation/Efi/Protocol/ComponentName2/ComponentName2.c29
-rw-r--r--EDK/Foundation/Efi/Protocol/ComponentName2/ComponentName2.h136
-rw-r--r--EDK/Foundation/Efi/Protocol/DebugPort/DebugPort.c27
-rw-r--r--EDK/Foundation/Efi/Protocol/DebugPort/DebugPort.h98
-rw-r--r--EDK/Foundation/Efi/Protocol/DebugSupport/DebugSupport.c27
-rw-r--r--EDK/Foundation/Efi/Protocol/DebugSupport/DebugSupport.h594
-rw-r--r--EDK/Foundation/Efi/Protocol/Decompress/Decompress.c27
-rw-r--r--EDK/Foundation/Efi/Protocol/Decompress/Decompress.h140
-rw-r--r--EDK/Foundation/Efi/Protocol/DeviceIO/DeviceIO.c31
-rw-r--r--EDK/Foundation/Efi/Protocol/DeviceIO/DeviceIO.h132
-rw-r--r--EDK/Foundation/Efi/Protocol/DevicePath/DevicePath.c32
-rw-r--r--EDK/Foundation/Efi/Protocol/DevicePath/DevicePath.h67
-rw-r--r--EDK/Foundation/Efi/Protocol/DevicePathFromText/DevicePathFromText.c27
-rw-r--r--EDK/Foundation/Efi/Protocol/DevicePathFromText/DevicePathFromText.h82
-rw-r--r--EDK/Foundation/Efi/Protocol/DevicePathToText/DevicePathToText.c27
-rw-r--r--EDK/Foundation/Efi/Protocol/DevicePathToText/DevicePathToText.h95
-rw-r--r--EDK/Foundation/Efi/Protocol/DevicePathUtilities/DevicePathUtilities.c27
-rw-r--r--EDK/Foundation/Efi/Protocol/DevicePathUtilities/DevicePathUtilities.h225
-rw-r--r--EDK/Foundation/Efi/Protocol/Dhcp4/Dhcp4.c41
-rw-r--r--EDK/Foundation/Efi/Protocol/Dhcp4/Dhcp4.h235
-rw-r--r--EDK/Foundation/Efi/Protocol/DiskIO/DiskIo.c31
-rw-r--r--EDK/Foundation/Efi/Protocol/DiskIO/DiskIo.h111
-rw-r--r--EDK/Foundation/Efi/Protocol/DriverBinding/DriverBinding.c29
-rw-r--r--EDK/Foundation/Efi/Protocol/DriverBinding/DriverBinding.h130
-rw-r--r--EDK/Foundation/Efi/Protocol/DriverConfiguration/DriverConfiguration.c30
-rw-r--r--EDK/Foundation/Efi/Protocol/DriverConfiguration/DriverConfiguration.h211
-rw-r--r--EDK/Foundation/Efi/Protocol/DriverConfiguration2/DriverConfiguration2.c30
-rw-r--r--EDK/Foundation/Efi/Protocol/DriverConfiguration2/DriverConfiguration2.h201
-rw-r--r--EDK/Foundation/Efi/Protocol/DriverDiagnostics/DriverDiagnostics.c30
-rw-r--r--EDK/Foundation/Efi/Protocol/DriverDiagnostics/DriverDiagnostics.h138
-rw-r--r--EDK/Foundation/Efi/Protocol/DriverDiagnostics2/DriverDiagnostics2.c30
-rw-r--r--EDK/Foundation/Efi/Protocol/DriverDiagnostics2/DriverDiagnostics2.h135
-rw-r--r--EDK/Foundation/Efi/Protocol/DriverSupportedEfiVersion/DriverSupportedEfiVersion.c30
-rw-r--r--EDK/Foundation/Efi/Protocol/DriverSupportedEfiVersion/DriverSupportedEfiVersion.h47
-rw-r--r--EDK/Foundation/Efi/Protocol/Ebc/Ebc.c28
-rw-r--r--EDK/Foundation/Efi/Protocol/Ebc/Ebc.h183
-rw-r--r--EDK/Foundation/Efi/Protocol/EdidActive/EdidActive.c29
-rw-r--r--EDK/Foundation/Efi/Protocol/EdidActive/EdidActive.h39
-rw-r--r--EDK/Foundation/Efi/Protocol/EdidDiscovered/EdidDiscovered.c30
-rw-r--r--EDK/Foundation/Efi/Protocol/EdidDiscovered/EdidDiscovered.h40
-rw-r--r--EDK/Foundation/Efi/Protocol/EdidOverride/EdidOverride.c30
-rw-r--r--EDK/Foundation/Efi/Protocol/EdidOverride/EdidOverride.h78
-rw-r--r--EDK/Foundation/Efi/Protocol/EfiNetworkInterfaceIdentifier/EfiNetworkInterfaceIdentifier.c40
-rw-r--r--EDK/Foundation/Efi/Protocol/EfiNetworkInterfaceIdentifier/EfiNetworkInterfaceIdentifier.h102
-rw-r--r--EDK/Foundation/Efi/Protocol/EfiProtocolLib.cif165
-rw-r--r--EDK/Foundation/Efi/Protocol/EfiProtocolLib.inf194
-rw-r--r--EDK/Foundation/Efi/Protocol/EfiProtocolLib.mak69
-rw-r--r--EDK/Foundation/Efi/Protocol/EfiProtocolLib.sdl26
-rw-r--r--EDK/Foundation/Efi/Protocol/FileInfo/FileInfo.c27
-rw-r--r--EDK/Foundation/Efi/Protocol/FileInfo/FileInfo.h58
-rw-r--r--EDK/Foundation/Efi/Protocol/FileSystemInfo/FileSystemInfo.c27
-rw-r--r--EDK/Foundation/Efi/Protocol/FileSystemInfo/FileSystemInfo.h51
-rw-r--r--EDK/Foundation/Efi/Protocol/FileSystemVolumeLabelInfo/FileSystemVolumeLabelInfo.c34
-rw-r--r--EDK/Foundation/Efi/Protocol/FileSystemVolumeLabelInfo/FileSystemVolumeLabelInfo.h38
-rw-r--r--EDK/Foundation/Efi/Protocol/FormBrowser2/FormBrowser2.c27
-rw-r--r--EDK/Foundation/Efi/Protocol/FormBrowser2/FormBrowser2.h136
-rw-r--r--EDK/Foundation/Efi/Protocol/GraphicsOutput/GraphicsOutput.c29
-rw-r--r--EDK/Foundation/Efi/Protocol/GraphicsOutput/GraphicsOutput.h206
-rw-r--r--EDK/Foundation/Efi/Protocol/Hash/Hash.c40
-rw-r--r--EDK/Foundation/Efi/Protocol/Hash/Hash.h161
-rw-r--r--EDK/Foundation/Efi/Protocol/HiiConfigAccess/HiiConfigAccess.c27
-rw-r--r--EDK/Foundation/Efi/Protocol/HiiConfigAccess/HiiConfigAccess.h147
-rw-r--r--EDK/Foundation/Efi/Protocol/HiiConfigRouting/HiiConfigRouting.c27
-rw-r--r--EDK/Foundation/Efi/Protocol/HiiConfigRouting/HiiConfigRouting.h314
-rw-r--r--EDK/Foundation/Efi/Protocol/HiiDatabase/HiiDatabase.c29
-rw-r--r--EDK/Foundation/Efi/Protocol/HiiDatabase/HiiDatabase.h454
-rw-r--r--EDK/Foundation/Efi/Protocol/HiiFont/HiiFont.c29
-rw-r--r--EDK/Foundation/Efi/Protocol/HiiFont/HiiFont.h289
-rw-r--r--EDK/Foundation/Efi/Protocol/HiiImage/HiiImage.c29
-rw-r--r--EDK/Foundation/Efi/Protocol/HiiImage/HiiImage.h256
-rw-r--r--EDK/Foundation/Efi/Protocol/HiiPackageList/HiiPackageList.c27
-rw-r--r--EDK/Foundation/Efi/Protocol/HiiPackageList/HiiPackageList.h36
-rw-r--r--EDK/Foundation/Efi/Protocol/HiiString/HiiString.c29
-rw-r--r--EDK/Foundation/Efi/Protocol/HiiString/HiiString.h253
-rw-r--r--EDK/Foundation/Efi/Protocol/IScsiInitiatorName/IScsiInitiatorName.c27
-rw-r--r--EDK/Foundation/Efi/Protocol/IScsiInitiatorName/IScsiInitiatorName.h98
-rw-r--r--EDK/Foundation/Efi/Protocol/Ip4/Ip4.c41
-rw-r--r--EDK/Foundation/Efi/Protocol/Ip4/Ip4.h241
-rw-r--r--EDK/Foundation/Efi/Protocol/Ip4Config/Ip4Config.c29
-rw-r--r--EDK/Foundation/Efi/Protocol/Ip4Config/Ip4Config.h72
-rw-r--r--EDK/Foundation/Efi/Protocol/LoadFile/LoadFile.c33
-rw-r--r--EDK/Foundation/Efi/Protocol/LoadFile/LoadFile.h87
-rw-r--r--EDK/Foundation/Efi/Protocol/LoadFile2/LoadFile2.c30
-rw-r--r--EDK/Foundation/Efi/Protocol/LoadFile2/LoadFile2.h84
-rw-r--r--EDK/Foundation/Efi/Protocol/LoadedImage/LoadedImage.c30
-rw-r--r--EDK/Foundation/Efi/Protocol/LoadedImage/LoadedImage.h73
-rw-r--r--EDK/Foundation/Efi/Protocol/LoadedImageDevicePath/LoadedImageDevicePath.c32
-rw-r--r--EDK/Foundation/Efi/Protocol/LoadedImageDevicePath/LoadedImageDevicePath.h44
-rw-r--r--EDK/Foundation/Efi/Protocol/ManagedNetwork/ManagedNetwork.c29
-rw-r--r--EDK/Foundation/Efi/Protocol/ManagedNetwork/ManagedNetwork.h164
-rw-r--r--EDK/Foundation/Efi/Protocol/Mtftp4/Mtftp4.c39
-rw-r--r--EDK/Foundation/Efi/Protocol/Mtftp4/Mtftp4.h308
-rw-r--r--EDK/Foundation/Efi/Protocol/PciIo/PciIo.c30
-rw-r--r--EDK/Foundation/Efi/Protocol/PciIo/PciIo.h275
-rw-r--r--EDK/Foundation/Efi/Protocol/PciRootBridgeIo/PciRootBridgeIo.c32
-rw-r--r--EDK/Foundation/Efi/Protocol/PciRootBridgeIo/PciRootBridgeIo.h220
-rw-r--r--EDK/Foundation/Efi/Protocol/PlatformDriverOverride/PlatformDriverOverride.c31
-rw-r--r--EDK/Foundation/Efi/Protocol/PlatformDriverOverride/PlatformDriverOverride.h74
-rw-r--r--EDK/Foundation/Efi/Protocol/PlatformToDriverConfiguration/PlatformToDriverConfiguration.c31
-rw-r--r--EDK/Foundation/Efi/Protocol/PlatformToDriverConfiguration/PlatformToDriverConfiguration.h173
-rw-r--r--EDK/Foundation/Efi/Protocol/PxeBaseCode/PxeBaseCode.c27
-rw-r--r--EDK/Foundation/Efi/Protocol/PxeBaseCode/PxeBaseCode.h386
-rw-r--r--EDK/Foundation/Efi/Protocol/PxeBaseCodeCallBack/PxeBaseCodeCallBack.c29
-rw-r--r--EDK/Foundation/Efi/Protocol/PxeBaseCodeCallBack/PxeBaseCodeCallBack.h82
-rw-r--r--EDK/Foundation/Efi/Protocol/ScsiIo/ScsiIo.c26
-rw-r--r--EDK/Foundation/Efi/Protocol/ScsiIo/ScsiIo.h256
-rw-r--r--EDK/Foundation/Efi/Protocol/ScsiPassThru/ScsiPassThru.c27
-rw-r--r--EDK/Foundation/Efi/Protocol/ScsiPassThru/ScsiPassThru.h332
-rw-r--r--EDK/Foundation/Efi/Protocol/ScsiPassThruExt/ScsiPassThruExt.c28
-rw-r--r--EDK/Foundation/Efi/Protocol/ScsiPassThruExt/ScsiPassThruExt.h365
-rw-r--r--EDK/Foundation/Efi/Protocol/SerialIO/SerialIo.c30
-rw-r--r--EDK/Foundation/Efi/Protocol/SerialIO/SerialIo.h296
-rw-r--r--EDK/Foundation/Efi/Protocol/ServiceBinding/ServiceBinding.h88
-rw-r--r--EDK/Foundation/Efi/Protocol/SimpleFileSystem/SimpleFileSystem.c33
-rw-r--r--EDK/Foundation/Efi/Protocol/SimpleFileSystem/SimpleFileSystem.h375
-rw-r--r--EDK/Foundation/Efi/Protocol/SimpleNetwork/SimpleNetwork.c34
-rw-r--r--EDK/Foundation/Efi/Protocol/SimpleNetwork/SimpleNetwork.h639
-rw-r--r--EDK/Foundation/Efi/Protocol/SimplePointer/SimplePointer.c29
-rw-r--r--EDK/Foundation/Efi/Protocol/SimplePointer/SimplePointer.h76
-rw-r--r--EDK/Foundation/Efi/Protocol/SimpleTextIn/SimpleTextIn.c30
-rw-r--r--EDK/Foundation/Efi/Protocol/SimpleTextIn/SimpleTextIn.h136
-rw-r--r--EDK/Foundation/Efi/Protocol/SimpleTextInputEx/SimpleTextInputEx.c31
-rw-r--r--EDK/Foundation/Efi/Protocol/SimpleTextInputEx/SimpleTextInputEx.h255
-rw-r--r--EDK/Foundation/Efi/Protocol/SimpleTextOut/SimpleTextOut.c30
-rw-r--r--EDK/Foundation/Efi/Protocol/SimpleTextOut/SimpleTextOut.h423
-rw-r--r--EDK/Foundation/Efi/Protocol/TapeIo/TapeIo.c28
-rw-r--r--EDK/Foundation/Efi/Protocol/TapeIo/TapeIo.h263
-rw-r--r--EDK/Foundation/Efi/Protocol/Tcp4/Tcp4.c30
-rw-r--r--EDK/Foundation/Efi/Protocol/Tcp4/Tcp4.h247
-rw-r--r--EDK/Foundation/Efi/Protocol/Udp4/Udp4.c29
-rw-r--r--EDK/Foundation/Efi/Protocol/Udp4/Udp4.h214
-rw-r--r--EDK/Foundation/Efi/Protocol/UgaDraw/UgaDraw.c29
-rw-r--r--EDK/Foundation/Efi/Protocol/UgaDraw/UgaDraw.h181
-rw-r--r--EDK/Foundation/Efi/Protocol/UgaIo/UgaIo.c29
-rw-r--r--EDK/Foundation/Efi/Protocol/UgaIo/UgaIo.h236
-rw-r--r--EDK/Foundation/Efi/Protocol/UnicodeCollation/UnicodeCollation.c27
-rw-r--r--EDK/Foundation/Efi/Protocol/UnicodeCollation/UnicodeCollation.h211
-rw-r--r--EDK/Foundation/Efi/Protocol/UnicodeCollation2/UnicodeCollation2.c27
-rw-r--r--EDK/Foundation/Efi/Protocol/UnicodeCollation2/UnicodeCollation2.h211
-rw-r--r--EDK/Foundation/Efi/Protocol/UsbHostController/UsbHostController.c30
-rw-r--r--EDK/Foundation/Efi/Protocol/UsbHostController/UsbHostController.h411
-rw-r--r--EDK/Foundation/Efi/Protocol/UsbIo/UsbIo.c30
-rw-r--r--EDK/Foundation/Efi/Protocol/UsbIo/UsbIo.h205
-rw-r--r--EDK/Foundation/Framework/Guid/AcpiTableStorage/AcpiTableStorage.c28
-rw-r--r--EDK/Foundation/Framework/Guid/AcpiTableStorage/AcpiTableStorage.h32
-rw-r--r--EDK/Foundation/Framework/Guid/Apriori/Apriori.c29
-rw-r--r--EDK/Foundation/Framework/Guid/Apriori/Apriori.h34
-rw-r--r--EDK/Foundation/Framework/Guid/DataHubRecords/DataHubRecords.c51
-rw-r--r--EDK/Foundation/Framework/Guid/DataHubRecords/DataHubRecords.h112
-rw-r--r--EDK/Foundation/Framework/Guid/DataHubRecords/DataHubSubClass.h73
-rw-r--r--EDK/Foundation/Framework/Guid/DataHubRecords/DataHubSubClassCache.h161
-rw-r--r--EDK/Foundation/Framework/Guid/DataHubRecords/DataHubSubClassMemory.h431
-rw-r--r--EDK/Foundation/Framework/Guid/DataHubRecords/DataHubSubClassMisc.h1260
-rw-r--r--EDK/Foundation/Framework/Guid/DataHubRecords/DataHubSubClassProcessor.h492
-rw-r--r--EDK/Foundation/Framework/Guid/DxeServices/DxeServices.c27
-rw-r--r--EDK/Foundation/Framework/Guid/DxeServices/DxeServices.h32
-rw-r--r--EDK/Foundation/Framework/Guid/EdkFrameworkGuidLib.cif39
-rw-r--r--EDK/Foundation/Framework/Guid/EdkFrameworkGuidLib.inf64
-rw-r--r--EDK/Foundation/Framework/Guid/EdkFrameworkGuidLib.mak73
-rw-r--r--EDK/Foundation/Framework/Guid/EdkFrameworkGuidLib.sdl26
-rw-r--r--EDK/Foundation/Framework/Guid/FirmwareFileSystem/FirmwareFileSystem.c30
-rw-r--r--EDK/Foundation/Framework/Guid/FirmwareFileSystem/FirmwareFileSystem.h34
-rw-r--r--EDK/Foundation/Framework/Guid/FirmwareFileSystem2/FirmwareFileSystem2.c27
-rw-r--r--EDK/Foundation/Framework/Guid/FirmwareFileSystem2/FirmwareFileSystem2.h33
-rw-r--r--EDK/Foundation/Framework/Guid/FrameworkDevicePath/FrameworkDevicePath.c27
-rw-r--r--EDK/Foundation/Framework/Guid/FrameworkDevicePath/FrameworkDevicePath.h29
-rw-r--r--EDK/Foundation/Framework/Guid/Hob/Hob.c29
-rw-r--r--EDK/Foundation/Framework/Guid/Hob/Hob.h34
-rw-r--r--EDK/Foundation/Framework/Guid/MemoryAllocationHob/MemoryAllocationHob.c31
-rw-r--r--EDK/Foundation/Framework/Guid/MemoryAllocationHob/MemoryAllocationHob.h38
-rw-r--r--EDK/Foundation/Framework/Guid/PeiApriori/PeiApriori.c26
-rw-r--r--EDK/Foundation/Framework/Guid/PeiApriori/PeiApriori.h36
-rw-r--r--EDK/Foundation/Framework/Guid/SmramMemoryReserve/SmramMemoryReserve.c28
-rw-r--r--EDK/Foundation/Framework/Guid/SmramMemoryReserve/SmramMemoryReserve.h70
-rw-r--r--EDK/Foundation/Framework/Guid/StatusCodeDataTypeId/StatusCodeDataTypeId.c47
-rw-r--r--EDK/Foundation/Framework/Guid/StatusCodeDataTypeId/StatusCodeDataTypeId.h389
-rw-r--r--EDK/Foundation/Framework/Include/BootMode.h38
-rw-r--r--EDK/Foundation/Framework/Include/EfiBootScript.h234
-rw-r--r--EDK/Foundation/Framework/Include/EfiCapsule.h142
-rw-r--r--EDK/Foundation/Framework/Include/EfiDependency.h52
-rw-r--r--EDK/Foundation/Framework/Include/EfiFirmwareFileSystem.h131
-rw-r--r--EDK/Foundation/Framework/Include/EfiFirmwareVolume.h47
-rw-r--r--EDK/Foundation/Framework/Include/EfiFirmwareVolumeHeader.h215
-rw-r--r--EDK/Foundation/Framework/Include/EfiImageFormat.h279
-rw-r--r--EDK/Foundation/Framework/Include/EfiInternalFormRepresentation.h431
-rw-r--r--EDK/Foundation/Framework/Include/EfiPciCfg.h81
-rw-r--r--EDK/Foundation/Framework/Include/EfiSmbus.h70
-rw-r--r--EDK/Foundation/Framework/Include/EfiStatusCode.h961
-rw-r--r--EDK/Foundation/Framework/Include/EfiVariable.h34
-rw-r--r--EDK/Foundation/Framework/Include/PeiApi.h632
-rw-r--r--EDK/Foundation/Framework/Include/PeiHob.h253
-rw-r--r--EDK/Foundation/Framework/Include/TianoSpecApi.h590
-rw-r--r--EDK/Foundation/Framework/Include/TianoSpecDevicePath.h32
-rw-r--r--EDK/Foundation/Framework/Include/TianoSpecError.h41
-rw-r--r--EDK/Foundation/Framework/Include/TianoSpecTypes.h75
-rw-r--r--EDK/Foundation/Framework/Ppi/BlockIo/BlockIo.c29
-rw-r--r--EDK/Foundation/Framework/Ppi/BlockIo/BlockIo.h88
-rw-r--r--EDK/Foundation/Framework/Ppi/BootInRecoveryMode/BootInRecoveryMode.c29
-rw-r--r--EDK/Foundation/Framework/Ppi/BootInRecoveryMode/BootInRecoveryMode.h34
-rw-r--r--EDK/Foundation/Framework/Ppi/BootMode/BootMode.c29
-rw-r--r--EDK/Foundation/Framework/Ppi/BootMode/BootMode.h34
-rw-r--r--EDK/Foundation/Framework/Ppi/BootScriptExecuter/BootScriptExecuter.c29
-rw-r--r--EDK/Foundation/Framework/Ppi/BootScriptExecuter/BootScriptExecuter.h50
-rw-r--r--EDK/Foundation/Framework/Ppi/CpuIo/CpuIo.c29
-rw-r--r--EDK/Foundation/Framework/Ppi/CpuIo/CpuIo.h250
-rw-r--r--EDK/Foundation/Framework/Ppi/Decompress/Decompress.c28
-rw-r--r--EDK/Foundation/Framework/Ppi/Decompress/Decompress.h49
-rw-r--r--EDK/Foundation/Framework/Ppi/DeviceRecoveryModule/DeviceRecoveryModule.c30
-rw-r--r--EDK/Foundation/Framework/Ppi/DeviceRecoveryModule/DeviceRecoveryModule.h68
-rw-r--r--EDK/Foundation/Framework/Ppi/DxeIpl/DxeIpl.c29
-rw-r--r--EDK/Foundation/Framework/Ppi/DxeIpl/DxeIpl.h51
-rw-r--r--EDK/Foundation/Framework/Ppi/EcpPciCfg/EcpPciCfg.c28
-rw-r--r--EDK/Foundation/Framework/Ppi/EcpPciCfg/EcpPciCfg.h50
-rw-r--r--EDK/Foundation/Framework/Ppi/EdkFrameworkPpiLib.cif74
-rw-r--r--EDK/Foundation/Framework/Ppi/EdkFrameworkPpiLib.inf91
-rw-r--r--EDK/Foundation/Framework/Ppi/EdkFrameworkPpiLib.mak70
-rw-r--r--EDK/Foundation/Framework/Ppi/EdkFrameworkPpiLib.sdl26
-rw-r--r--EDK/Foundation/Framework/Ppi/EndOfPeiSignal/EndOfPeiSignal.c29
-rw-r--r--EDK/Foundation/Framework/Ppi/EndOfPeiSignal/EndOfPeiSignal.h35
-rw-r--r--EDK/Foundation/Framework/Ppi/FindFv/FindFv.c29
-rw-r--r--EDK/Foundation/Framework/Ppi/FindFv/FindFv.h51
-rw-r--r--EDK/Foundation/Framework/Ppi/FirmwareVolume/FirmwareVolume.c30
-rw-r--r--EDK/Foundation/Framework/Ppi/FirmwareVolume/FirmwareVolume.h112
-rw-r--r--EDK/Foundation/Framework/Ppi/FirmwareVolumeInfo/FirmwareVolumeInfo.c28
-rw-r--r--EDK/Foundation/Framework/Ppi/FirmwareVolumeInfo/FirmwareVolumeInfo.h46
-rw-r--r--EDK/Foundation/Framework/Ppi/GuidedSectionExtraction/GuidedSectionExtraction.c29
-rw-r--r--EDK/Foundation/Framework/Ppi/GuidedSectionExtraction/GuidedSectionExtraction.h42
-rw-r--r--EDK/Foundation/Framework/Ppi/LoadFile/LoadFile.c29
-rw-r--r--EDK/Foundation/Framework/Ppi/LoadFile/LoadFile.h48
-rw-r--r--EDK/Foundation/Framework/Ppi/LoadFile2/LoadFile2.c29
-rw-r--r--EDK/Foundation/Framework/Ppi/LoadFile2/LoadFile2.h49
-rw-r--r--EDK/Foundation/Framework/Ppi/MemoryDiscovered/MemoryDiscovered.c29
-rw-r--r--EDK/Foundation/Framework/Ppi/MemoryDiscovered/MemoryDiscovered.h34
-rw-r--r--EDK/Foundation/Framework/Ppi/PciCfg/PciCfg.c28
-rw-r--r--EDK/Foundation/Framework/Ppi/PciCfg/PciCfg.h65
-rw-r--r--EDK/Foundation/Framework/Ppi/PciCfg2/PciCfg2.c28
-rw-r--r--EDK/Foundation/Framework/Ppi/PciCfg2/PciCfg2.h67
-rw-r--r--EDK/Foundation/Framework/Ppi/RecoveryModule/RecoveryModule.c29
-rw-r--r--EDK/Foundation/Framework/Ppi/RecoveryModule/RecoveryModule.h45
-rw-r--r--EDK/Foundation/Framework/Ppi/Reset/Reset.c28
-rw-r--r--EDK/Foundation/Framework/Ppi/Reset/Reset.h54
-rw-r--r--EDK/Foundation/Framework/Ppi/S3Resume/S3Resume.c29
-rw-r--r--EDK/Foundation/Framework/Ppi/S3Resume/S3Resume.h44
-rw-r--r--EDK/Foundation/Framework/Ppi/SecPlatformInformation/SecPlatformInformation.c29
-rw-r--r--EDK/Foundation/Framework/Ppi/SecPlatformInformation/SecPlatformInformation.h57
-rw-r--r--EDK/Foundation/Framework/Ppi/SectionExtraction/SectionExtraction.c28
-rw-r--r--EDK/Foundation/Framework/Ppi/SectionExtraction/SectionExtraction.h59
-rw-r--r--EDK/Foundation/Framework/Ppi/Security/Security.c28
-rw-r--r--EDK/Foundation/Framework/Ppi/Security/Security.h48
-rw-r--r--EDK/Foundation/Framework/Ppi/Security2/Security2.c28
-rw-r--r--EDK/Foundation/Framework/Ppi/Security2/Security2.h50
-rw-r--r--EDK/Foundation/Framework/Ppi/Smbus/Smbus.c29
-rw-r--r--EDK/Foundation/Framework/Ppi/Smbus/Smbus.h115
-rw-r--r--EDK/Foundation/Framework/Ppi/Smbus2/Smbus2.c29
-rw-r--r--EDK/Foundation/Framework/Ppi/Smbus2/Smbus2.h96
-rw-r--r--EDK/Foundation/Framework/Ppi/Stall/Stall.c28
-rw-r--r--EDK/Foundation/Framework/Ppi/Stall/Stall.h47
-rw-r--r--EDK/Foundation/Framework/Ppi/StatusCode/StatusCode.c29
-rw-r--r--EDK/Foundation/Framework/Ppi/StatusCode/StatusCode.h49
-rw-r--r--EDK/Foundation/Framework/Ppi/Variable/Variable.c29
-rw-r--r--EDK/Foundation/Framework/Ppi/Variable/Variable.h69
-rw-r--r--EDK/Foundation/Framework/Ppi/Variable2/Variable2.c29
-rw-r--r--EDK/Foundation/Framework/Ppi/Variable2/Variable2.h61
-rw-r--r--EDK/Foundation/Framework/Protocol/AcpiS3Save/AcpiS3Save.c28
-rw-r--r--EDK/Foundation/Framework/Protocol/AcpiS3Save/AcpiS3Save.h68
-rw-r--r--EDK/Foundation/Framework/Protocol/AcpiSupport/AcpiSupport.c29
-rw-r--r--EDK/Foundation/Framework/Protocol/AcpiSupport/AcpiSupport.h128
-rw-r--r--EDK/Foundation/Framework/Protocol/BootScriptSave/BootScriptSave.c28
-rw-r--r--EDK/Foundation/Framework/Protocol/BootScriptSave/BootScriptSave.h75
-rw-r--r--EDK/Foundation/Framework/Protocol/CpuIo/CpuIo.c28
-rw-r--r--EDK/Foundation/Framework/Protocol/CpuIo/CpuIo.h93
-rw-r--r--EDK/Foundation/Framework/Protocol/DataHub/DataHub.c32
-rw-r--r--EDK/Foundation/Framework/Protocol/DataHub/DataHub.h125
-rw-r--r--EDK/Foundation/Framework/Protocol/EdkFrameworkProtocolLib.cif87
-rw-r--r--EDK/Foundation/Framework/Protocol/EdkFrameworkProtocolLib.inf117
-rw-r--r--EDK/Foundation/Framework/Protocol/EdkFrameworkProtocolLib.mak68
-rw-r--r--EDK/Foundation/Framework/Protocol/EdkFrameworkProtocolLib.sdl26
-rw-r--r--EDK/Foundation/Framework/Protocol/ExitPmAuth/ExitPmAuth.c35
-rw-r--r--EDK/Foundation/Framework/Protocol/ExitPmAuth/ExitPmAuth.h40
-rw-r--r--EDK/Foundation/Framework/Protocol/FirmwareVolume/FirmwareVolume.c31
-rw-r--r--EDK/Foundation/Framework/Protocol/FirmwareVolume/FirmwareVolume.h334
-rw-r--r--EDK/Foundation/Framework/Protocol/FirmwareVolume2/FirmwareVolume2.c30
-rw-r--r--EDK/Foundation/Framework/Protocol/FirmwareVolume2/FirmwareVolume2.h195
-rw-r--r--EDK/Foundation/Framework/Protocol/FirmwareVolumeBlock/FirmwareVolumeBlock.c35
-rw-r--r--EDK/Foundation/Framework/Protocol/FirmwareVolumeBlock/FirmwareVolumeBlock.h270
-rw-r--r--EDK/Foundation/Framework/Protocol/FormBrowser/FormBrowser.c31
-rw-r--r--EDK/Foundation/Framework/Protocol/FormBrowser/FormBrowser.h97
-rw-r--r--EDK/Foundation/Framework/Protocol/FormCallback/FormCallback.c31
-rw-r--r--EDK/Foundation/Framework/Protocol/FormCallback/FormCallback.h120
-rw-r--r--EDK/Foundation/Framework/Protocol/Hii/Hii.c30
-rw-r--r--EDK/Foundation/Framework/Protocol/Hii/Hii.h618
-rw-r--r--EDK/Foundation/Framework/Protocol/IdeControllerInit/IdeControllerInit.c30
-rw-r--r--EDK/Foundation/Framework/Protocol/IdeControllerInit/IdeControllerInit.h348
-rw-r--r--EDK/Foundation/Framework/Protocol/IncompatiblePciDeviceSupport/IncompatiblePciDeviceSupport.c34
-rw-r--r--EDK/Foundation/Framework/Protocol/IncompatiblePciDeviceSupport/IncompatiblePciDeviceSupport.h55
-rw-r--r--EDK/Foundation/Framework/Protocol/Legacy8259/Legacy8259.c31
-rw-r--r--EDK/Foundation/Framework/Protocol/Legacy8259/Legacy8259.h317
-rw-r--r--EDK/Foundation/Framework/Protocol/LegacyBios/LegacyBios.c30
-rw-r--r--EDK/Foundation/Framework/Protocol/LegacyBios/LegacyBios.h714
-rw-r--r--EDK/Foundation/Framework/Protocol/LegacyBiosPlatform/LegacyBiosPlatform.c31
-rw-r--r--EDK/Foundation/Framework/Protocol/LegacyBiosPlatform/LegacyBiosPlatform.h349
-rw-r--r--EDK/Foundation/Framework/Protocol/LegacyInterrupt/LegacyInterrupt.c31
-rw-r--r--EDK/Foundation/Framework/Protocol/LegacyInterrupt/LegacyInterrupt.h136
-rw-r--r--EDK/Foundation/Framework/Protocol/LegacyRegion/LegacyRegion.c31
-rw-r--r--EDK/Foundation/Framework/Protocol/LegacyRegion/LegacyRegion.h82
-rw-r--r--EDK/Foundation/Framework/Protocol/PciHostBridgeResourceAllocation/PciHostBridgeResourceAllocation.c31
-rw-r--r--EDK/Foundation/Framework/Protocol/PciHostBridgeResourceAllocation/PciHostBridgeResourceAllocation.h364
-rw-r--r--EDK/Foundation/Framework/Protocol/PciHotPlugInit/PciHotPlugInit.c30
-rw-r--r--EDK/Foundation/Framework/Protocol/PciHotPlugInit/PciHotPlugInit.h97
-rw-r--r--EDK/Foundation/Framework/Protocol/PciPlatform/PciPlatform.c26
-rw-r--r--EDK/Foundation/Framework/Protocol/PciPlatform/PciPlatform.h211
-rw-r--r--EDK/Foundation/Framework/Protocol/SectionExtraction/SectionExtraction.c28
-rw-r--r--EDK/Foundation/Framework/Protocol/SectionExtraction/SectionExtraction.h83
-rw-r--r--EDK/Foundation/Framework/Protocol/SecurityPolicy/SecurityPolicy.c28
-rw-r--r--EDK/Foundation/Framework/Protocol/SecurityPolicy/SecurityPolicy.h33
-rw-r--r--EDK/Foundation/Framework/Protocol/Smbus/Smbus.c31
-rw-r--r--EDK/Foundation/Framework/Protocol/Smbus/Smbus.h108
-rw-r--r--EDK/Foundation/Framework/Protocol/SmmAccess/SmmAccess.c30
-rw-r--r--EDK/Foundation/Framework/Protocol/SmmAccess/SmmAccess.h92
-rw-r--r--EDK/Foundation/Framework/Protocol/SmmBase/SmmBase.c38
-rw-r--r--EDK/Foundation/Framework/Protocol/SmmBase/SmmBase.h797
-rw-r--r--EDK/Foundation/Framework/Protocol/SmmControl/SmmControl.c30
-rw-r--r--EDK/Foundation/Framework/Protocol/SmmControl/SmmControl.h79
-rw-r--r--EDK/Foundation/Framework/Protocol/SmmCpuState/CpuSaveState.h150
-rw-r--r--EDK/Foundation/Framework/Protocol/SmmCpuState/SmmCpuState.c30
-rw-r--r--EDK/Foundation/Framework/Protocol/SmmCpuState/SmmCpuState.h43
-rw-r--r--EDK/Foundation/Framework/Protocol/SmmGpiDispatch/SmmGpiDispatch.c31
-rw-r--r--EDK/Foundation/Framework/Protocol/SmmGpiDispatch/SmmGpiDispatch.h152
-rw-r--r--EDK/Foundation/Framework/Protocol/SmmIchnDispatch/SmmIchnDispatch.c31
-rw-r--r--EDK/Foundation/Framework/Protocol/SmmIchnDispatch/SmmIchnDispatch.h199
-rw-r--r--EDK/Foundation/Framework/Protocol/SmmPeriodicTimerDispatch/SmmPeriodicTimerDispatch.c34
-rw-r--r--EDK/Foundation/Framework/Protocol/SmmPeriodicTimerDispatch/SmmPeriodicTimerDispatch.h224
-rw-r--r--EDK/Foundation/Framework/Protocol/SmmPowerButtonDispatch/SmmPowerButtonDispatch.c34
-rw-r--r--EDK/Foundation/Framework/Protocol/SmmPowerButtonDispatch/SmmPowerButtonDispatch.h153
-rw-r--r--EDK/Foundation/Framework/Protocol/SmmStandbyButtonDispatch/SmmStandbyButtonDispatch.c34
-rw-r--r--EDK/Foundation/Framework/Protocol/SmmStandbyButtonDispatch/SmmStandbyButtonDispatch.h153
-rw-r--r--EDK/Foundation/Framework/Protocol/SmmStatusCode/SmmStatusCode.c30
-rw-r--r--EDK/Foundation/Framework/Protocol/SmmStatusCode/SmmStatusCode.h58
-rw-r--r--EDK/Foundation/Framework/Protocol/SmmSwDispatch/SmmSwDispatch.c30
-rw-r--r--EDK/Foundation/Framework/Protocol/SmmSwDispatch/SmmSwDispatch.h151
-rw-r--r--EDK/Foundation/Framework/Protocol/SmmSxDispatch/SmmSxDispatch.c30
-rw-r--r--EDK/Foundation/Framework/Protocol/SmmSxDispatch/SmmSxDispatch.h170
-rw-r--r--EDK/Foundation/Framework/Protocol/SmmUsbDispatch/SmmUsbDispatch.c31
-rw-r--r--EDK/Foundation/Framework/Protocol/SmmUsbDispatch/SmmUsbDispatch.h149
-rw-r--r--EDK/Foundation/Guid/AlternateFvBlock/AlternateFvBlock.c28
-rw-r--r--EDK/Foundation/Guid/AlternateFvBlock/AlternateFvBlock.h32
-rw-r--r--EDK/Foundation/Guid/Bmp/Bmp.c29
-rw-r--r--EDK/Foundation/Guid/Bmp/Bmp.h62
-rw-r--r--EDK/Foundation/Guid/BootState/BootState.c30
-rw-r--r--EDK/Foundation/Guid/BootState/BootState.h38
-rw-r--r--EDK/Foundation/Guid/Capsule/Capsule.c29
-rw-r--r--EDK/Foundation/Guid/Capsule/Capsule.h40
-rw-r--r--EDK/Foundation/Guid/CompatibleMemoryTested/CompatibleMemoryTested.c28
-rw-r--r--EDK/Foundation/Guid/CompatibleMemoryTested/CompatibleMemoryTested.h32
-rw-r--r--EDK/Foundation/Guid/ConsoleInDevice/ConsoleInDevice.c27
-rw-r--r--EDK/Foundation/Guid/ConsoleInDevice/ConsoleInDevice.h29
-rw-r--r--EDK/Foundation/Guid/ConsoleOutDevice/ConsoleOutDevice.c27
-rw-r--r--EDK/Foundation/Guid/ConsoleOutDevice/ConsoleOutDevice.h29
-rw-r--r--EDK/Foundation/Guid/EdkGuidLib.cif68
-rw-r--r--EDK/Foundation/Guid/EdkGuidLib.inf98
-rw-r--r--EDK/Foundation/Guid/EdkGuidLib.mak73
-rw-r--r--EDK/Foundation/Guid/EdkGuidLib.sdl26
-rw-r--r--EDK/Foundation/Guid/EfiShell/EfiShell.c31
-rw-r--r--EDK/Foundation/Guid/EfiShell/EfiShell.h34
-rw-r--r--EDK/Foundation/Guid/EventLegacyBios/EventLegacyBios.c23
-rw-r--r--EDK/Foundation/Guid/EventLegacyBios/EventLegacyBios.h28
-rw-r--r--EDK/Foundation/Guid/FastBootExceptionInfo/FastBootExceptionInfo.c27
-rw-r--r--EDK/Foundation/Guid/FastBootExceptionInfo/FastBootExceptionInfo.h44
-rw-r--r--EDK/Foundation/Guid/FlashMapHob/FlashMapHob.c29
-rw-r--r--EDK/Foundation/Guid/FlashMapHob/FlashMapHob.h33
-rw-r--r--EDK/Foundation/Guid/GenericVariable/GenericVariable.c27
-rw-r--r--EDK/Foundation/Guid/GenericVariable/GenericVariable.h32
-rw-r--r--EDK/Foundation/Guid/HotPlugDevice/HotPlugDevice.c27
-rw-r--r--EDK/Foundation/Guid/HotPlugDevice/HotPlugDevice.h28
-rw-r--r--EDK/Foundation/Guid/IoBaseHob/IoBaseHob.c29
-rw-r--r--EDK/Foundation/Guid/IoBaseHob/IoBaseHob.h30
-rw-r--r--EDK/Foundation/Guid/MemoryTypeInformation/MemoryTypeInformation.c29
-rw-r--r--EDK/Foundation/Guid/MemoryTypeInformation/MemoryTypeInformation.h37
-rw-r--r--EDK/Foundation/Guid/PciExpressBaseAddress/PciExpressBaseAddress.c28
-rw-r--r--EDK/Foundation/Guid/PciExpressBaseAddress/PciExpressBaseAddress.h46
-rw-r--r--EDK/Foundation/Guid/PciHotPlugDevice/PciHotplugDevice.c29
-rw-r--r--EDK/Foundation/Guid/PciHotPlugDevice/PciHotplugDevice.h30
-rw-r--r--EDK/Foundation/Guid/PciOptionRomTable/PciOptionRomTable.c27
-rw-r--r--EDK/Foundation/Guid/PciOptionRomTable/PciOptionRomTable.h48
-rw-r--r--EDK/Foundation/Guid/PeiFlushInstructionCache/PeiFlushInstructionCache.c29
-rw-r--r--EDK/Foundation/Guid/PeiFlushInstructionCache/PeiFlushInstructionCache.h44
-rw-r--r--EDK/Foundation/Guid/PeiPeCoffLoader/PeiPeCoffLoader.c28
-rw-r--r--EDK/Foundation/Guid/PeiPeCoffLoader/PeiPeCoffLoader.h119
-rw-r--r--EDK/Foundation/Guid/PeiPerformanceHob/PeiPerformanceHob.c28
-rw-r--r--EDK/Foundation/Guid/PeiPerformanceHob/PeiPerformanceHob.h55
-rw-r--r--EDK/Foundation/Guid/PeiTransferControl/PeiTransferControl.c28
-rw-r--r--EDK/Foundation/Guid/PeiTransferControl/PeiTransferControl.h53
-rw-r--r--EDK/Foundation/Guid/PrimaryConsoleInDevice/PrimaryConsoleInDevice.c28
-rw-r--r--EDK/Foundation/Guid/PrimaryConsoleInDevice/PrimaryConsoleInDevice.h29
-rw-r--r--EDK/Foundation/Guid/PrimaryConsoleOutDevice/PrimaryConsoleOutDevice.c26
-rw-r--r--EDK/Foundation/Guid/PrimaryConsoleOutDevice/PrimaryConsoleOutDevice.h28
-rw-r--r--EDK/Foundation/Guid/PrimaryStandardErrorDevice/PrimaryStandardErrorDevice.c26
-rw-r--r--EDK/Foundation/Guid/PrimaryStandardErrorDevice/PrimaryStandardErrorDevice.h28
-rw-r--r--EDK/Foundation/Guid/StandardErrorDevice/StandardErrorDevice.c27
-rw-r--r--EDK/Foundation/Guid/StandardErrorDevice/StandardErrorDevice.h29
-rw-r--r--EDK/Foundation/Guid/StatusCode/StatusCode.c28
-rw-r--r--EDK/Foundation/Guid/StatusCode/StatusCode.h33
-rw-r--r--EDK/Foundation/Guid/StatusCodeCallerId/StatusCodeCallerId.c27
-rw-r--r--EDK/Foundation/Guid/StatusCodeCallerId/StatusCodeCallerId.h37
-rw-r--r--EDK/Foundation/Guid/SystemNvDataGuid/SystemNvDataGuid.c32
-rw-r--r--EDK/Foundation/Guid/SystemNvDataGuid/SystemNvDataGuid.h45
-rw-r--r--EDK/Foundation/Include/Ebc/EfiBind.h129
-rw-r--r--EDK/Foundation/Include/Ebc/EfiPeOptionalHeader.h46
-rw-r--r--EDK/Foundation/Include/Ebc/TianoBind.h30
-rw-r--r--EDK/Foundation/Include/EfiCommon.h53
-rw-r--r--EDK/Foundation/Include/EfiCompNameSupport.h120
-rw-r--r--EDK/Foundation/Include/EfiDebug.h170
-rw-r--r--EDK/Foundation/Include/EfiDepex.h54
-rw-r--r--EDK/Foundation/Include/EfiFlashMap.h111
-rw-r--r--EDK/Foundation/Include/EfiPci.h64
-rw-r--r--EDK/Foundation/Include/EfiPerf.h211
-rw-r--r--EDK/Foundation/Include/EfiPxe.h1816
-rw-r--r--EDK/Foundation/Include/EfiSpec.h51
-rw-r--r--EDK/Foundation/Include/EfiStdArg.h75
-rw-r--r--EDK/Foundation/Include/EfiTpm.h144
-rw-r--r--EDK/Foundation/Include/EfiVariable.h78
-rw-r--r--EDK/Foundation/Include/EfiWorkingBlockHeader.h47
-rw-r--r--EDK/Foundation/Include/FastBootDataDef.h56
-rw-r--r--EDK/Foundation/Include/Ia32/EfiBind.h266
-rw-r--r--EDK/Foundation/Include/Ia32/EfiPeOptionalHeader.h38
-rw-r--r--EDK/Foundation/Include/Ia32/TianoBind.h102
-rw-r--r--EDK/Foundation/Include/IndustryStandard/Acpi.h31
-rw-r--r--EDK/Foundation/Include/IndustryStandard/Acpi1_0.h299
-rw-r--r--EDK/Foundation/Include/IndustryStandard/Acpi2_0.h513
-rw-r--r--EDK/Foundation/Include/IndustryStandard/Acpi3_0.h691
-rw-r--r--EDK/Foundation/Include/IndustryStandard/AcpiCommon.h98
-rw-r--r--EDK/Foundation/Include/IndustryStandard/AlertStandardFormatTable.h123
-rw-r--r--EDK/Foundation/Include/IndustryStandard/DMARemappingReportingTable.h203
-rw-r--r--EDK/Foundation/Include/IndustryStandard/HighPrecisionEventTimerTable.h62
-rw-r--r--EDK/Foundation/Include/IndustryStandard/IScsiBootFirmwareTable.h146
-rw-r--r--EDK/Foundation/Include/IndustryStandard/LegacyBiosMpTable.h283
-rw-r--r--EDK/Foundation/Include/IndustryStandard/MemoryMappedConfigurationSpaceAccessTable.h56
-rw-r--r--EDK/Foundation/Include/IndustryStandard/SdramSpd.h73
-rw-r--r--EDK/Foundation/Include/IndustryStandard/ServerProcessorManagementInterfaceTable.h80
-rw-r--r--EDK/Foundation/Include/IndustryStandard/Smbios.h691
-rw-r--r--EDK/Foundation/Include/IndustryStandard/Tpm12.h1964
-rw-r--r--EDK/Foundation/Include/IndustryStandard/WatchdogDescriptionTable.h94
-rw-r--r--EDK/Foundation/Include/IndustryStandard/atapi.h331
-rw-r--r--EDK/Foundation/Include/IndustryStandard/pci.h31
-rw-r--r--EDK/Foundation/Include/IndustryStandard/pci22.h555
-rw-r--r--EDK/Foundation/Include/IndustryStandard/pci23.h41
-rw-r--r--EDK/Foundation/Include/IndustryStandard/pci30.h52
-rw-r--r--EDK/Foundation/Include/IndustryStandard/scsi.h314
-rw-r--r--EDK/Foundation/Include/IndustryStandard/usb.h344
-rw-r--r--EDK/Foundation/Include/Ipf/EfiBind.h239
-rw-r--r--EDK/Foundation/Include/Ipf/EfiPeOptionalHeader.h37
-rw-r--r--EDK/Foundation/Include/Ipf/IpfDefines.h556
-rw-r--r--EDK/Foundation/Include/Ipf/IpfMacro.i66
-rw-r--r--EDK/Foundation/Include/Ipf/PalApi.h133
-rw-r--r--EDK/Foundation/Include/Ipf/SalApi.h724
-rw-r--r--EDK/Foundation/Include/Ipf/TianoBind.h30
-rw-r--r--EDK/Foundation/Include/Pei/Pei.h58
-rw-r--r--EDK/Foundation/Include/Pei/PeiBind.h162
-rw-r--r--EDK/Foundation/Include/Pei/PeiDebug.h111
-rw-r--r--EDK/Foundation/Include/Tiano.h56
-rw-r--r--EDK/Foundation/Include/TianoApi.h46
-rw-r--r--EDK/Foundation/Include/TianoCommon.h51
-rw-r--r--EDK/Foundation/Include/TianoDevicePath.h130
-rw-r--r--EDK/Foundation/Include/TianoError.h30
-rw-r--r--EDK/Foundation/Include/TianoHii.h124
-rw-r--r--EDK/Foundation/Include/TianoTypes.h48
-rw-r--r--EDK/Foundation/Include/x64/EfiBind.h225
-rw-r--r--EDK/Foundation/Include/x64/EfiPeOptionalHeader.h42
-rw-r--r--EDK/Foundation/Include/x64/TianoBind.h30
-rw-r--r--EDK/Foundation/Library/CompilerStub/CompilerStub.cif12
-rw-r--r--EDK/Foundation/Library/CompilerStub/CompilerStub.mak79
-rw-r--r--EDK/Foundation/Library/CompilerStub/CompilerStub.sdl26
-rw-r--r--EDK/Foundation/Library/CompilerStub/CompilerStubLib.inf54
-rw-r--r--EDK/Foundation/Library/CompilerStub/memcpy.c46
-rw-r--r--EDK/Foundation/Library/CompilerStub/memset.c45
-rw-r--r--EDK/Foundation/Library/CustomizedDecompress/CustomizedDecompress.c122
-rw-r--r--EDK/Foundation/Library/CustomizedDecompress/CustomizedDecompress.cif12
-rw-r--r--EDK/Foundation/Library/CustomizedDecompress/CustomizedDecompress.h113
-rw-r--r--EDK/Foundation/Library/CustomizedDecompress/CustomizedDecompress.inf39
-rw-r--r--EDK/Foundation/Library/CustomizedDecompress/CustomizedDecompress.mak69
-rw-r--r--EDK/Foundation/Library/CustomizedDecompress/CustomizedDecompress.sdl25
-rw-r--r--EDK/Foundation/Library/Dxe/EfiDriverLib/Debug.c173
-rw-r--r--EDK/Foundation/Library/Dxe/EfiDriverLib/DevicePath.c551
-rw-r--r--EDK/Foundation/Library/Dxe/EfiDriverLib/DxeDriverLib.c56
-rw-r--r--EDK/Foundation/Library/Dxe/EfiDriverLib/Ebc/PerformancePrimitives.c52
-rw-r--r--EDK/Foundation/Library/Dxe/EfiDriverLib/EfiDriverLib.c506
-rw-r--r--EDK/Foundation/Library/Dxe/EfiDriverLib/EfiDriverLib.cif32
-rw-r--r--EDK/Foundation/Library/Dxe/EfiDriverLib/EfiDriverLib.inf90
-rw-r--r--EDK/Foundation/Library/Dxe/EfiDriverLib/EfiDriverLib.mak75
-rw-r--r--EDK/Foundation/Library/Dxe/EfiDriverLib/EfiDriverLib.sdl26
-rw-r--r--EDK/Foundation/Library/Dxe/EfiDriverLib/EfiDriverModelLib.c444
-rw-r--r--EDK/Foundation/Library/Dxe/EfiDriverLib/EfiGetConfigTable.c61
-rw-r--r--EDK/Foundation/Library/Dxe/EfiDriverLib/EfiLibAllocate.c233
-rw-r--r--EDK/Foundation/Library/Dxe/EfiDriverLib/Event.c371
-rw-r--r--EDK/Foundation/Library/Dxe/EfiDriverLib/GetImage.c220
-rw-r--r--EDK/Foundation/Library/Dxe/EfiDriverLib/Handle.c176
-rw-r--r--EDK/Foundation/Library/Dxe/EfiDriverLib/HobLib.inf47
-rw-r--r--EDK/Foundation/Library/Dxe/EfiDriverLib/IA32/PerformancePrimitives.c47
-rw-r--r--EDK/Foundation/Library/Dxe/EfiDriverLib/Ipf/PerformancePrimitives.s61
-rw-r--r--EDK/Foundation/Library/Dxe/EfiDriverLib/LibGlobalDs.c32
-rw-r--r--EDK/Foundation/Library/Dxe/EfiDriverLib/LibGlobalErrorLevel.c34
-rw-r--r--EDK/Foundation/Library/Dxe/EfiDriverLib/LibGlobalSt.c34
-rw-r--r--EDK/Foundation/Library/Dxe/EfiDriverLib/Lock.c159
-rw-r--r--EDK/Foundation/Library/Dxe/EfiDriverLib/Perf.c946
-rw-r--r--EDK/Foundation/Library/Dxe/EfiDriverLib/ReportStatusCode.c130
-rw-r--r--EDK/Foundation/Library/Dxe/EfiDriverLib/x64/PerformancePrimitives.c47
-rw-r--r--EDK/Foundation/Library/Dxe/EfiIfrSupportLib/EfiIfrSupportLib.cif15
-rw-r--r--EDK/Foundation/Library/Dxe/EfiIfrSupportLib/EfiIfrSupportLib.inf52
-rw-r--r--EDK/Foundation/Library/Dxe/EfiIfrSupportLib/EfiIfrSupportLib.mak69
-rw-r--r--EDK/Foundation/Library/Dxe/EfiIfrSupportLib/EfiIfrSupportLib.sdl26
-rw-r--r--EDK/Foundation/Library/Dxe/EfiIfrSupportLib/IfrCommon.c1031
-rw-r--r--EDK/Foundation/Library/Dxe/EfiIfrSupportLib/IfrLibrary.h1299
-rw-r--r--EDK/Foundation/Library/Dxe/EfiIfrSupportLib/IfrOnTheFly.c974
-rw-r--r--EDK/Foundation/Library/Dxe/EfiIfrSupportLib/IfrOpCodeCreation.c615
-rw-r--r--EDK/Foundation/Library/Dxe/EfiIfrSupportLib/IfrVariable.c488
-rw-r--r--EDK/Foundation/Library/Dxe/EfiScriptLib/EfiScriptLib.c712
-rw-r--r--EDK/Foundation/Library/Dxe/EfiScriptLib/EfiScriptLib.cif11
-rw-r--r--EDK/Foundation/Library/Dxe/EfiScriptLib/EfiScriptLib.inf45
-rw-r--r--EDK/Foundation/Library/Dxe/EfiScriptLib/EfiScriptLib.mak70
-rw-r--r--EDK/Foundation/Library/Dxe/EfiScriptLib/EfiScriptLib.sdl26
-rw-r--r--EDK/Foundation/Library/Dxe/Graphics/Ascii/GraphicsAscii.cif9
-rw-r--r--EDK/Foundation/Library/Dxe/Graphics/Ascii/PrintWidth.h88
-rw-r--r--EDK/Foundation/Library/Dxe/Graphics/Ascii/Sprint.c144
-rw-r--r--EDK/Foundation/Library/Dxe/Graphics/Graphics.c617
-rw-r--r--EDK/Foundation/Library/Dxe/Graphics/Graphics.inf51
-rw-r--r--EDK/Foundation/Library/Dxe/Graphics/GraphicsLib.cif18
-rw-r--r--EDK/Foundation/Library/Dxe/Graphics/GraphicsLib.mak70
-rw-r--r--EDK/Foundation/Library/Dxe/Graphics/GraphicsLib.sdl26
-rw-r--r--EDK/Foundation/Library/Dxe/Graphics/Print.c973
-rw-r--r--EDK/Foundation/Library/Dxe/Graphics/Print.h37
-rw-r--r--EDK/Foundation/Library/Dxe/Graphics/Unicode/GraphicsUnicode.cif9
-rw-r--r--EDK/Foundation/Library/Dxe/Graphics/Unicode/PrintWidth.h34
-rw-r--r--EDK/Foundation/Library/Dxe/Graphics/Unicode/Sprint.c147
-rw-r--r--EDK/Foundation/Library/Dxe/GraphicsLite/Ascii/GraphicsLiteAscii.cif9
-rw-r--r--EDK/Foundation/Library/Dxe/GraphicsLite/Ascii/PrintWidth.h88
-rw-r--r--EDK/Foundation/Library/Dxe/GraphicsLite/Ascii/Sprint.c144
-rw-r--r--EDK/Foundation/Library/Dxe/GraphicsLite/Graphics.c617
-rw-r--r--EDK/Foundation/Library/Dxe/GraphicsLite/Graphics.inf51
-rw-r--r--EDK/Foundation/Library/Dxe/GraphicsLite/GraphicsLite.cif18
-rw-r--r--EDK/Foundation/Library/Dxe/GraphicsLite/GraphicsLite.mak70
-rw-r--r--EDK/Foundation/Library/Dxe/GraphicsLite/GraphicsLite.sdl26
-rw-r--r--EDK/Foundation/Library/Dxe/GraphicsLite/Print.c519
-rw-r--r--EDK/Foundation/Library/Dxe/GraphicsLite/Print.h37
-rw-r--r--EDK/Foundation/Library/Dxe/GraphicsLite/Unicode/GraphicsLiteUnicode.cif9
-rw-r--r--EDK/Foundation/Library/Dxe/GraphicsLite/Unicode/PrintWidth.h35
-rw-r--r--EDK/Foundation/Library/Dxe/GraphicsLite/Unicode/Sprint.c147
-rw-r--r--EDK/Foundation/Library/Dxe/Include/Ebc/ProcDep.h26
-rw-r--r--EDK/Foundation/Library/Dxe/Include/EfiCombinationLib.h294
-rw-r--r--EDK/Foundation/Library/Dxe/Include/EfiCommonLib.h1359
-rw-r--r--EDK/Foundation/Library/Dxe/Include/EfiDriverLib.h1231
-rw-r--r--EDK/Foundation/Library/Dxe/Include/EfiHobLib.h299
-rw-r--r--EDK/Foundation/Library/Dxe/Include/EfiMgmtModeRuntimeLib.h429
-rw-r--r--EDK/Foundation/Library/Dxe/Include/EfiPrintLib.h326
-rw-r--r--EDK/Foundation/Library/Dxe/Include/EfiRegTableLib.h205
-rw-r--r--EDK/Foundation/Library/Dxe/Include/EfiRuntimeLib.h1691
-rw-r--r--EDK/Foundation/Library/Dxe/Include/EfiScriptLib.h570
-rw-r--r--EDK/Foundation/Library/Dxe/Include/EfiSmmDriverLib.h226
-rw-r--r--EDK/Foundation/Library/Dxe/Include/EfiUiLib.h205
-rw-r--r--EDK/Foundation/Library/Dxe/Include/EfiWinNtLib.h75
-rw-r--r--EDK/Foundation/Library/Dxe/Include/GetImage.h104
-rw-r--r--EDK/Foundation/Library/Dxe/Include/GraphicsLib.h181
-rw-r--r--EDK/Foundation/Library/Dxe/Include/Ia32/CpuFuncs.h260
-rw-r--r--EDK/Foundation/Library/Dxe/Include/Ia32/ProcDep.h26
-rw-r--r--EDK/Foundation/Library/Dxe/Include/Ia32EfiRuntimeDriverLib.h111
-rw-r--r--EDK/Foundation/Library/Dxe/Include/Ipf/CpuFuncs.h93
-rw-r--r--EDK/Foundation/Library/Dxe/Include/Ipf/EsalRuntimeLib.h1305
-rw-r--r--EDK/Foundation/Library/Dxe/Include/Ipf/ProcDep.h119
-rw-r--r--EDK/Foundation/Library/Dxe/Include/Ipf/SalDriverLib.h1454
-rw-r--r--EDK/Foundation/Library/Dxe/Include/LinkedList.h310
-rw-r--r--EDK/Foundation/Library/Dxe/Include/RtDevicePath.h231
-rw-r--r--EDK/Foundation/Library/Dxe/Include/SmmRuntimeLib.h75
-rw-r--r--EDK/Foundation/Library/Dxe/Include/x64/CpuFuncs.h262
-rw-r--r--EDK/Foundation/Library/Dxe/Include/x64/ProcDep.h29
-rw-r--r--EDK/Foundation/Library/Dxe/Print/Ascii/PrintAscii.cif9
-rw-r--r--EDK/Foundation/Library/Dxe/Print/Ascii/PrintWidth.h88
-rw-r--r--EDK/Foundation/Library/Dxe/Print/Ascii/Sprint.c144
-rw-r--r--EDK/Foundation/Library/Dxe/Print/BoxDraw.c212
-rw-r--r--EDK/Foundation/Library/Dxe/Print/Print.c596
-rw-r--r--EDK/Foundation/Library/Dxe/Print/Print.h37
-rw-r--r--EDK/Foundation/Library/Dxe/Print/PrintLib.cif19
-rw-r--r--EDK/Foundation/Library/Dxe/Print/PrintLib.inf50
-rw-r--r--EDK/Foundation/Library/Dxe/Print/PrintLib.mak70
-rw-r--r--EDK/Foundation/Library/Dxe/Print/PrintLib.sdl26
-rw-r--r--EDK/Foundation/Library/Dxe/Print/StdErr.c287
-rw-r--r--EDK/Foundation/Library/Dxe/Print/Unicode/PrintUnicode.cif9
-rw-r--r--EDK/Foundation/Library/Dxe/Print/Unicode/PrintWidth.h35
-rw-r--r--EDK/Foundation/Library/Dxe/Print/Unicode/Sprint.c147
-rw-r--r--EDK/Foundation/Library/Dxe/PrintLite/Ascii/PrintLiteAscii.cif9
-rw-r--r--EDK/Foundation/Library/Dxe/PrintLite/Ascii/PrintWidth.h88
-rw-r--r--EDK/Foundation/Library/Dxe/PrintLite/Ascii/Sprint.c142
-rw-r--r--EDK/Foundation/Library/Dxe/PrintLite/BoxDraw.c212
-rw-r--r--EDK/Foundation/Library/Dxe/PrintLite/Print.c194
-rw-r--r--EDK/Foundation/Library/Dxe/PrintLite/Print.h37
-rw-r--r--EDK/Foundation/Library/Dxe/PrintLite/PrintLib.inf51
-rw-r--r--EDK/Foundation/Library/Dxe/PrintLite/PrintLibLite.cif19
-rw-r--r--EDK/Foundation/Library/Dxe/PrintLite/PrintLibLite.mak70
-rw-r--r--EDK/Foundation/Library/Dxe/PrintLite/PrintLibLite.sdl26
-rw-r--r--EDK/Foundation/Library/Dxe/PrintLite/StdErr.c287
-rw-r--r--EDK/Foundation/Library/Dxe/PrintLite/Unicode/PrintLiteUnicode.cif9
-rw-r--r--EDK/Foundation/Library/Dxe/PrintLite/Unicode/PrintWidth.h35
-rw-r--r--EDK/Foundation/Library/Dxe/PrintLite/Unicode/Sprint.c147
-rw-r--r--EDK/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiEfiIfrSupportLib.cif15
-rw-r--r--EDK/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiEfiIfrSupportLib.inf49
-rw-r--r--EDK/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiEfiIfrSupportLib.mak70
-rw-r--r--EDK/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiEfiIfrSupportLib.sdl26
-rw-r--r--EDK/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrCommon.c762
-rw-r--r--EDK/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrForm.c2249
-rw-r--r--EDK/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrLibrary.h1370
-rw-r--r--EDK/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrOpCodeCreation.c638
-rw-r--r--EDK/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrString.c729
-rw-r--r--EDK/Foundation/Library/Dxe/hob/hob.c542
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/EntryPoints/EdkIIGlueDxeDriverEntryPoint.c592
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/EntryPoints/EdkIIGluePeimEntryPoint.c180
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/EntryPoints/EdkIIGlueSmmDriverEntryPoint.c493
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Include/AutoGen.h37
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueBaseTypes.h90
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueDefinitionChangesBase.h118
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueDefinitionChangesDxe.h95
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueDefinitionChangesPeim.h165
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueDependencies.h698
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Include/DxeDepex.h34
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueBase.h98
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueConfig.h173
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueDxe.h256
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueInclude.cif64
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Include/EdkIIGluePeim.h114
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueUefi.h178
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Include/Ia32/EdkIIGlueProcessorBind.h41
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueBaseLib.h5109
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueBaseMemoryLib.h391
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueCacheMaintenanceLib.h224
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDebugLib.h575
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDevicePathLib.h269
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDxeRuntimeDriverLib.h451
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDxeServicesTableLib.h32
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDxeSmmDriverEntryPoint.h147
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueFirmwarePerformanceLib.h155
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueHiiLib.h55
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueHobLib.h384
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueIoLib.h2326
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueMemoryAllocationLib.h637
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePciCf8Lib.h1055
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePciExpressLib.h1023
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePciLib.h1019
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeCoffGetEntryPointLib.h93
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeCoffLib.h227
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeiServicesLib.h361
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeiServicesTablePointerLib.h41
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeimEntryPoint.h111
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePostCodeLib.h165
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePrintLib.h481
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueReportStatusCodeLib.h659
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueResourcePublicationLib.h50
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueSmbusLib.h394
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueTimerLib.h130
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiBootServicesTableLib.h41
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiDecompressLib.h113
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiDriverEntryPoint.h162
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiDriverModelLib.h52
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiLib.h590
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiRuntimeServicesTableLib.h31
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcd.h42
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdBaseLib.h52
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdDebugLib.h50
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdIoLib.h42
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdPciExpressLib.h40
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdPerformanceLib.h47
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdPostCodeLib.h40
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdReportStatusCodeLib.h40
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdTimerLib.h40
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Include/PeimDepex.h34
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Include/x64/EdkIIGlueProcessorBind.h41
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf76
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseCacheMaintenanceLib/EdkIIGlueBaseCacheMaintenanceLib.cif11
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseCacheMaintenanceLib/EdkIIGlueBaseCacheMaintenanceLib.mak90
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseCacheMaintenanceLib/EdkIIGlueBaseCacheMaintenanceLib.sdl26
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseCacheMaintenanceLib/x86Cache.c254
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseDebugLibNull/BaseDebugLibNull.inf77
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseDebugLibNull/DebugLib.c236
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseDebugLibNull/EdkIIGlueBaseDebugLibNull.cif11
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseDebugLibNull/EdkIIGlueBaseDebugLibNull.mak83
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseDebugLibNull/EdkIIGlueBaseDebugLibNull.sdl26
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf77
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/EdkIIGlueBaseIoLibIntrinsic.cif13
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/EdkIIGlueBaseIoLibIntrinsic.mak95
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/EdkIIGlueBaseIoLibIntrinsic.sdl26
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/IoHighLevel.c2280
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/IoLib.c74
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/IoLibMsc.c436
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/ARShiftU64.c49
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/BaseLib.inf335
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/BaseLibInternal.h586
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/BitField.c861
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Cpu.c75
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/CpuDeadLoop.c42
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/DivS64x64Remainder.c54
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/DivU64x32.c50
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/DivU64x32Remainder.c54
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/DivU64x64Remainder.c53
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/EdkIIGlueBaseLib.cif47
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/EdkIIGlueBaseLib.mak106
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/EdkIIGlueBaseLib.sdl25
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/EdkIIGlueBaseLibIA32.cif121
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/EdkIIGlueBaseLibX64.cif108
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/GetPowerOfTwo32.c48
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/GetPowerOfTwo64.c49
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/HighBitSet32.c49
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/HighBitSet64.c51
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ARShiftU64.asm44
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuBreakpoint.asm39
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuFlushTlb.asm39
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuId.asm64
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuIdEx.asm66
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuPause.asm39
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuSleep.asm38
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DisableInterrupts.asm38
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DisablePaging32.asm55
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DivS64x64Remainder.c60
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DivU64x32.asm44
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DivU64x32Remainder.asm49
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DivU64x64Remainder.asm90
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/EnableDisableInterrupts.asm39
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/EnableInterrupts.asm38
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/EnablePaging32.asm55
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/EnablePaging64.asm66
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/FlushCacheLine.asm40
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/FxRestore.asm40
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/FxSave.asm40
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/InterlockedCompareExchange32.asm43
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/InterlockedCompareExchange64.asm45
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/InterlockedDecrement.asm40
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/InterlockedIncrement.asm40
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/InternalSwitchStack.c60
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Invd.asm38
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/LRotU64.asm47
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/LShiftU64.asm44
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/LongJump.asm44
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ModU64x32.asm43
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Monitor.asm43
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/MultU64x32.asm41
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/MultU64x64.asm45
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Mwait.asm41
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Non-existing.c66
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/RRotU64.asm47
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/RShiftU64.asm44
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadCr0.asm38
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadCr2.asm38
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadCr3.asm38
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadCr4.asm38
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadCs.asm38
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr0.asm38
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr1.asm38
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr2.asm38
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr3.asm38
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr4.asm38
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr5.asm38
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr6.asm38
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr7.asm38
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDs.asm38
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadEflags.asm39
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadEs.asm38
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadFs.asm38
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadGdtr.asm39
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadGs.asm38
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadIdtr.asm39
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadLdtr.asm38
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm0.asm43
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm1.asm43
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm2.asm43
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm3.asm43
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm4.asm43
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm5.asm43
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm6.asm43
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm7.asm43
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMsr64.asm39
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadPmc.asm39
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadSs.asm38
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadTr.asm38
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadTsc.asm38
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/SetJump.asm49
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/SwapBytes64.asm41
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Thunk16.asm241
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Wbinvd.asm38
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteCr0.asm39
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteCr2.asm39
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteCr3.asm39
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteCr4.asm39
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr0.asm39
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr1.asm39
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr2.asm39
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr3.asm39
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr4.asm39
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr5.asm39
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr6.asm39
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr7.asm39
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteGdtr.asm39
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteIdtr.asm39
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteLdtr.asm39
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm0.asm39
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm1.asm39
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm2.asm39
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm3.asm39
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm4.asm39
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm5.asm39
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm6.asm39
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm7.asm39
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMsr64.asm42
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LRotU32.c50
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LRotU64.c50
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LShiftU64.c49
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LinkedList.c473
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LongJump.c85
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LowBitSet32.c52
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LowBitSet64.c54
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Math64.c371
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/ModU64x32.c50
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/MultS64x64.c49
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/MultU64x32.c51
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/MultU64x64.c51
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/RRotU32.c50
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/RRotU64.c50
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/RShiftU64.c49
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SetJump.c43
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/String.c974
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SwapBytes16.c44
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SwapBytes32.c47
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SwapBytes64.c44
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SwitchStack.c58
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Synchronization.c438
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Unaligned.c228
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuBreakpoint.asm36
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuFlushTlb.asm37
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuId.asm60
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuIdEx.asm62
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuPause.asm36
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuSleep.asm36
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/DisableInterrupts.asm36
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/DisablePaging64.asm64
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/EnableDisableInterrupts.asm37
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/EnableInterrupts.asm36
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/EnablePaging64.asm62
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/FlushCacheLine.asm37
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/FxRestore.asm36
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/FxSave.asm36
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/InterlockedCompareExchange32.asm39
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/InterlockedCompareExchange64.asm39
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/InterlockedDecrement.asm37
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/InterlockedIncrement.asm37
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Invd.asm36
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/LongJump.asm44
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Monitor.asm41
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Mwait.asm39
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Non-existing.c116
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadCr0.asm36
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadCr2.asm36
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadCr3.asm36
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadCr4.asm36
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadCs.asm36
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr0.asm36
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr1.asm36
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr2.asm36
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr3.asm36
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr4.asm36
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr5.asm36
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr6.asm36
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr7.asm36
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDs.asm36
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadEflags.asm37
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadEs.asm36
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadFs.asm36
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadGdtr.asm36
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadGs.asm36
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadIdtr.asm36
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadLdtr.asm36
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm0.asm36
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm1.asm36
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm2.asm36
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm3.asm36
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm4.asm36
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm5.asm36
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm6.asm36
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm7.asm36
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMsr64.asm38
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadPmc.asm38
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadSs.asm36
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadTr.asm36
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadTsc.asm38
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/SetJump.asm52
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/SwitchStack.asm45
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Thunk16.asm251
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Wbinvd.asm36
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteCr0.asm37
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteCr2.asm37
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteCr3.asm37
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteCr4.asm37
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr0.asm37
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr1.asm37
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr2.asm37
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr3.asm37
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr4.asm37
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr5.asm37
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr6.asm37
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr7.asm37
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteGdtr.asm36
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteIdtr.asm36
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteLdtr.asm36
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm0.asm36
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm1.asm36
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm2.asm36
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm3.asm36
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm4.asm36
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm5.asm36
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm6.asm36
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm7.asm36
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMsr64.asm39
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86DisablePaging32.c71
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86DisablePaging64.c68
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86EnablePaging32.c74
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86EnablePaging64.c70
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86FxRestore.c54
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86FxSave.c53
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86GetInterruptState.c47
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86MemoryFence.c39
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86Msr.c657
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86ReadGdtr.c44
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86ReadIdtr.c44
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86Thunk.c250
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86WriteGdtr.c44
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86WriteIdtr.c44
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/BaseMemoryLib.inf119
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/BaseMemoryLibInternal.h227
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/CompareMemWrapper.c63
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/CopyMem.c65
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/CopyMemWrapper.c58
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ebc/CopyMem.c65
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ebc/MemLibGeneric.c261
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ebc/SetMem.c55
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/EdkIIGlueBaseMemoryLib.cif57
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/EdkIIGlueBaseMemoryLib.mak142
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/EdkIIGlueBaseMemoryLib.sdl26
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/CompareMem.asm54
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/CopyMem.asm63
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/EdkIIGlueBaseMemoryLibIA32.cif18
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/ScanMem16.asm53
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/ScanMem32.asm53
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/ScanMem64.asm62
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/ScanMem8.asm53
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/SetMem.asm45
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/SetMem16.asm45
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/SetMem32.asm45
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/SetMem64.asm49
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/ZeroMem.asm50
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ipf/CopyMem.c65
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ipf/MemLibGeneric.c261
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ipf/SetMem.c55
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/MemLibGeneric.c261
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/MemLibGuid.c130
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ScanMem16Wrapper.c63
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ScanMem32Wrapper.c63
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ScanMem64Wrapper.c62
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ScanMem8Wrapper.c57
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMem.c55
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMem16Wrapper.c61
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMem32Wrapper.c61
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMem64Wrapper.c62
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMemWrapper.c52
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/CompareMem.asm52
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/CopyMem.asm61
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/EdkIIGlueBaseMemoryLibX64.cif18
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/ScanMem16.asm51
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/ScanMem32.asm51
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/ScanMem64.asm51
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/ScanMem8.asm51
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/SetMem.asm44
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/SetMem16.asm44
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/SetMem32.asm44
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/SetMem64.asm43
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/ZeroMem.asm47
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ZeroMemWrapper.c47
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciCf8Lib/BasePciCf8Lib.inf79
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciCf8Lib/EdkIIGlueBasePciCf8Lib.cif11
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciCf8Lib/EdkIIGlueBasePciCf8Lib.mak85
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciCf8Lib/EdkIIGlueBasePciCf8Lib.sdl26
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciCf8Lib/PciLib.c1468
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciExpressLib/BasePciExpressLib.inf79
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciExpressLib/EdkIIGlueBasePciExpressLib.cif11
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciExpressLib/EdkIIGlueBasePciExpressLib.mak85
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciExpressLib/EdkIIGlueBasePciExpressLib.sdl26
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciExpressLib/PciLib.c1377
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibCf8/BasePciLibCf8.inf79
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibCf8/EdkIIGlueBasePciLibCf8.cif11
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibCf8/EdkIIGlueBasePciLibCf8.mak80
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibCf8/EdkIIGlueBasePciLibCf8.sdl26
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibCf8/PciLib.c1076
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibPciExpress/BasePciLibPciExpress.inf79
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibPciExpress/EdkIIGlueBasePciLibPciExpress.cif11
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibPciExpress/EdkIIGlueBasePciLibPciExpress.mak80
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibPciExpress/EdkIIGlueBasePciLibPciExpress.sdl26
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibPciExpress/PciLib.c1076
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf82
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffGetEntryPointLib/EdkIIGlueBasePeCoffGetEntryPointLib.cif11
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffGetEntryPointLib/EdkIIGlueBasePeCoffGetEntryPointLib.mak80
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffGetEntryPointLib/EdkIIGlueBasePeCoffGetEntryPointLib.sdl26
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffGetEntryPointLib/PeCoffGetEntryPoint.c222
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/BasePeCoff.c1357
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/BasePeCoffLib.inf81
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/BasePeCoffLibInternals.h131
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/EdkIIGlueBasePeCoffLib.cif14
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/EdkIIGlueBasePeCoffLib.mak100
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/EdkIIGlueBasePeCoffLib.sdl26
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/Ia32/PeCoffLoaderEx.c98
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/X64/PeCoffLoaderEx.c97
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibDebug/BasePostCodeLibDebug.inf79
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibDebug/EdkIIGlueBasePostCodeLibDebug.cif11
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibDebug/EdkIIGlueBasePostCodeLibDebug.mak80
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibDebug/EdkIIGlueBasePostCodeLibDebug.sdl26
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibDebug/PostCode.c132
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibPort80/BasePostCodeLibPort80.inf79
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibPort80/EdkIIGlueBasePostCodeLibPort80.cif11
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibPort80/EdkIIGlueBasePostCodeLibPort80.mak87
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibPort80/EdkIIGlueBasePostCodeLibPort80.sdl26
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibPort80/PostCode.c132
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/BasePrintLib.inf80
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/EdkIIGlueBasePrintLib.cif13
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/EdkIIGlueBasePrintLib.mak80
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/EdkIIGlueBasePrintLib.sdl26
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/PrintLib.c1061
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/PrintLibInternal.c215
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/PrintLibInternal.h181
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibLocalApic/BaseTimerLibLocalApic.inf79
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibLocalApic/EdkIIGlueBaseTimerLibLocalApic.cif11
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibLocalApic/EdkIIGlueBaseTimerLibLocalApic.mak87
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibLocalApic/EdkIIGlueBaseTimerLibLocalApic.sdl26
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibLocalApic/x86TimerLib.c293
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibTsc/BaseTimerLibTsc.inf78
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibTsc/EdkIIGlueBaseTimerLibTsc.cif11
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibTsc/EdkIIGlueBaseTimerLibTsc.mak78
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibTsc/EdkIIGlueBaseTimerLibTsc.sdl26
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibTsc/TimerLibTsc.c46
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c892
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf76
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/EdkIIGlueBaseUefiDecompressLib.cif11
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/EdkIIGlueBaseUefiDecompressLib.mak80
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/EdkIIGlueBaseUefiDecompressLib.sdl26
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/DxeDebugLibReportStatusCode/DebugLib.c322
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/DxeDebugLibReportStatusCode/DxeDebugLibReportStatusCode.inf88
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/DxeDebugLibReportStatusCode/EdkIIGlueDxeDebugLibReportStatusCode.cif11
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/DxeDebugLibReportStatusCode/EdkIIGlueDxeDebugLibReportStatusCode.mak80
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/DxeDebugLibReportStatusCode/EdkIIGlueDxeDebugLibReportStatusCode.sdl26
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/DxeFirmwarePerformanceLib/EdkIIGlueDxeFirmwarePerformanceLib.c638
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/DxeFirmwarePerformanceLib/EdkIIGlueDxeFirmwarePerformanceLib.cif11
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/DxeFirmwarePerformanceLib/EdkIIGlueDxeFirmwarePerformanceLib.inf81
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/DxeFirmwarePerformanceLib/EdkIIGlueDxeFirmwarePerformanceLib.mak68
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/DxeFirmwarePerformanceLib/EdkIIGlueDxeFirmwarePerformanceLib.sdl24
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/DxeHobLib/DxeHobLib.inf82
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/DxeHobLib/EdkIIGlueDxeHobLib.cif11
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/DxeHobLib/EdkIIGlueDxeHobLib.mak80
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/DxeHobLib/EdkIIGlueDxeHobLib.sdl26
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/DxeHobLib/HobLib.c501
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/DxeMemoryAllocationLib/DxeMemoryAllocationLib.inf79
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/DxeMemoryAllocationLib/EdkIIGlueDxeMemoryAllocationLib.cif11
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/DxeMemoryAllocationLib/EdkIIGlueDxeMemoryAllocationLib.mak80
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/DxeMemoryAllocationLib/EdkIIGlueDxeMemoryAllocationLib.sdl26
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/DxeMemoryAllocationLib/MemoryAllocationLib.c1079
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf92
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/DxeReportStatusCodeLib/EdkIIGlueDxeReportStatusCodeLib.cif11
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/DxeReportStatusCodeLib/EdkIIGlueDxeReportStatusCodeLib.mak91
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/DxeReportStatusCodeLib/EdkIIGlueDxeReportStatusCodeLib.sdl26
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c605
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/DxeServicesTableLib/DxeServicesTableLib.c60
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/DxeServicesTableLib/DxeServicesTableLib.inf77
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/DxeServicesTableLib/EdkIIGlueDxeServicesTableLib.cif11
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/DxeServicesTableLib/EdkIIGlueDxeServicesTableLib.mak80
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/DxeServicesTableLib/EdkIIGlueDxeServicesTableLib.sdl26
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/DxeSmbusLib.c107
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/DxeSmbusLib.inf80
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/DxeSmbusLibInternal.h67
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/EdkIIGlueDxeSmbusLib.cif13
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/EdkIIGlueDxeSmbusLib.mak80
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/EdkIIGlueDxeSmbusLib.sdl26
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/SmbusLib.c475
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Common/RuntimeLib.c261
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Common/RuntimeService.c481
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/EdkDxeRuntimeDriverLib.inf83
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/EdkIIGlueEdkDxeRuntimeDriverLib.cif13
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/EdkIIGlueEdkDxeRuntimeDriverLib.mak103
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/EdkIIGlueEdkDxeRuntimeDriverLib.sdl26
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/RuntimeLibInternal.h35
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/HiiLib/EdkIIGlueHiiLib.cif11
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/HiiLib/EdkIIGlueHiiLib.mak80
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/HiiLib/EdkIIGlueHiiLib.sdl26
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/HiiLib/HiiLib.c75
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/HiiLib/HiiLib.inf77
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDebugLibReportStatusCode/DebugLib.c336
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDebugLibReportStatusCode/EdkIIGluePeiDebugLibReportStatusCode.cif11
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDebugLibReportStatusCode/EdkIIGluePeiDebugLibReportStatusCode.mak80
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDebugLibReportStatusCode/EdkIIGluePeiDebugLibReportStatusCode.sdl26
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDebugLibReportStatusCode/PeiDebugLibReportStatusCode.inf90
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDxePostCodeLibReportStatusCode/EdkIIGluePeiDxePostCodeLibReportStatusCode.cif11
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDxePostCodeLibReportStatusCode/EdkIIGluePeiDxePostCodeLibReportStatusCode.mak80
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDxePostCodeLibReportStatusCode/EdkIIGluePeiDxePostCodeLibReportStatusCode.sdl26
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDxePostCodeLibReportStatusCode/PeiDxePostCodeLibReportStatusCode.inf81
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDxePostCodeLibReportStatusCode/PostCode.c161
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/PeiFirmwarePerformanceLib/EdkIIGluePeiFirmwarePerformanceLib.c452
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/PeiFirmwarePerformanceLib/EdkIIGluePeiFirmwarePerformanceLib.cif11
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/PeiFirmwarePerformanceLib/EdkIIGluePeiFirmwarePerformanceLib.inf77
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/PeiFirmwarePerformanceLib/EdkIIGluePeiFirmwarePerformanceLib.mak74
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/PeiFirmwarePerformanceLib/EdkIIGluePeiFirmwarePerformanceLib.sdl24
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/PeiHobLib/EdkIIGluePeiHobLib.cif11
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/PeiHobLib/EdkIIGluePeiHobLib.mak80
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/PeiHobLib/EdkIIGluePeiHobLib.sdl26
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/PeiHobLib/HobLib.c573
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/PeiHobLib/PeiHobLib.inf81
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/PeiMemoryAllocationLib/EdkIIGluePeiMemoryAllocationLib.cif11
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/PeiMemoryAllocationLib/EdkIIGluePeiMemoryAllocationLib.mak80
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/PeiMemoryAllocationLib/EdkIIGluePeiMemoryAllocationLib.sdl26
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/PeiMemoryAllocationLib/MemoryAllocationLib.c1080
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf85
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/PeiReportStatusCodeLib/EdkIIGluePeiReportStatusCodeLib.cif11
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/PeiReportStatusCodeLib/EdkIIGluePeiReportStatusCodeLib.mak89
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/PeiReportStatusCodeLib/EdkIIGluePeiReportStatusCodeLib.sdl26
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/PeiReportStatusCodeLib/PeiReportStatusCodeLib.inf92
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/PeiReportStatusCodeLib/ReportStatusCodeLib.c527
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/PeiResourcePublicationLib/EdkIIGluePeiResourcePublicationLib.cif11
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/PeiResourcePublicationLib/EdkIIGluePeiResourcePublicationLib.mak80
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/PeiResourcePublicationLib/EdkIIGluePeiResourcePublicationLib.sdl26
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/PeiResourcePublicationLib/PeiResourcePublicationLib.c57
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/PeiResourcePublicationLib/PeiResourcePublicationLib.inf79
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesLib/EdkIIGluePeiServicesLib.cif11
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesLib/EdkIIGluePeiServicesLib.mak88
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesLib/EdkIIGluePeiServicesLib.sdl26
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesLib/PeiServicesLib.c470
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesLib/PeiServicesLib.inf82
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLib/EdkIIGluePeiServicesTablePointerLib.cif11
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLib/EdkIIGluePeiServicesTablePointerLib.mak80
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLib/EdkIIGluePeiServicesTablePointerLib.sdl26
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLib/PeiServicesTablePointer.c66
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf77
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibMm7/EdkIIGluePeiServicesTablePointerLibMm7.cif11
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibMm7/EdkIIGluePeiServicesTablePointerLibMm7.mak80
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibMm7/EdkIIGluePeiServicesTablePointerLibMm7.sdl26
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibMm7/PeiServicesTablePointer.c84
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibMm7/PeiServicesTablePointerLibMm7.inf77
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/EdkIIGluePeiSmbusLib.cif13
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/EdkIIGluePeiSmbusLib.mak80
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/EdkIIGluePeiSmbusLib.sdl26
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/PeiSmbusLib.c104
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/PeiSmbusLib.inf84
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/PeiSmbusLibInternal.h68
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/SmbusLib.c475
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/SmmFirmwarePerformanceLib/EdkIIGlueSmmFirmwarePerformanceLib.cif11
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/SmmFirmwarePerformanceLib/EdkIIGlueSmmFirmwarePerformanceLib.inf81
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/SmmFirmwarePerformanceLib/EdkIIGlueSmmFirmwarePerformanceLib.mak79
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/SmmFirmwarePerformanceLib/EdkIIGlueSmmFirmwarePerformanceLib.sdl25
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/SmmFirmwarePerformanceLib/EdkIIGlueSmmPerformanceLib.c261
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/SmmRuntimeDxeReportStatusCodeLib/EdkIIGlueSmmRuntimeDxeReportStatusCodeLib.cif13
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/SmmRuntimeDxeReportStatusCodeLib/EdkIIGlueSmmRuntimeDxeReportStatusCodeLib.mak88
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/SmmRuntimeDxeReportStatusCodeLib/EdkIIGlueSmmRuntimeDxeReportStatusCodeLib.sdl26
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/SmmRuntimeDxeReportStatusCodeLib/ReportStatusCodeLib.c557
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/SmmRuntimeDxeReportStatusCodeLib/ReportStatusCodeLibInternal.h128
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/SmmRuntimeDxeReportStatusCodeLib/SmmRuntimeDxeReportStatusCodeLib.inf96
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/SmmRuntimeDxeReportStatusCodeLib/SmmRuntimeDxeSupport.c698
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/UefiBootServicesTableLib/EdkIIGlueUefiBootServicesTableLib.cif11
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/UefiBootServicesTableLib/EdkIIGlueUefiBootServicesTableLib.mak80
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/UefiBootServicesTableLib/EdkIIGlueUefiBootServicesTableLib.sdl26
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.c67
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf75
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDevicePathLib/EdkIIGlueUefiDevicePathLib.cif11
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDevicePathLib/EdkIIGlueUefiDevicePathLib.mak80
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDevicePathLib/EdkIIGlueUefiDevicePathLib.sdl26
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDevicePathLib/UefiDevicePathLib.c533
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDevicePathLib/UefiDevicePathLib.inf83
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDriverModelLib/EdkIIGlueUefiDriverModelLib.cif11
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDriverModelLib/EdkIIGlueUefiDriverModelLib.mak80
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDriverModelLib/EdkIIGlueUefiDriverModelLib.sdl26
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDriverModelLib/UefiDriverModelLib.c431
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDriverModelLib/UefiDriverModelLib.inf65
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/UefiLib/Console.c288
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/UefiLib/EdkIIGlueUefiLib.cif13
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/UefiLib/EdkIIGlueUefiLib.mak80
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/UefiLib/EdkIIGlueUefiLib.sdl26
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/UefiLib/UefiLib.c948
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/UefiLib/UefiLib.inf87
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/UefiLib/UefiNotTiano.c366
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/UefiRuntimeServicesTableLib/EdkIIGlueUefiRuntimeServicesTableLib.cif11
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/UefiRuntimeServicesTableLib/EdkIIGlueUefiRuntimeServicesTableLib.mak80
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/UefiRuntimeServicesTableLib/EdkIIGlueUefiRuntimeServicesTableLib.sdl26
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.c52
-rw-r--r--EDK/Foundation/Library/EdkIIGlueLib/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf76
-rw-r--r--EDK/Foundation/Library/EfiCommonLib/EfiCommonLib.cif36
-rw-r--r--EDK/Foundation/Library/EfiCommonLib/EfiCommonLib.inf85
-rw-r--r--EDK/Foundation/Library/EfiCommonLib/EfiCommonLib.mak123
-rw-r--r--EDK/Foundation/Library/EfiCommonLib/EfiCommonLib.sdl31
-rw-r--r--EDK/Foundation/Library/EfiCommonLib/EfiCompareGuid.c59
-rw-r--r--EDK/Foundation/Library/EfiCommonLib/EfiCompareMem.c76
-rw-r--r--EDK/Foundation/Library/EfiCommonLib/EfiCopyMem.c69
-rw-r--r--EDK/Foundation/Library/EfiCommonLib/EfiSetMem.c65
-rw-r--r--EDK/Foundation/Library/EfiCommonLib/EfiZeroMem.c57
-rw-r--r--EDK/Foundation/Library/EfiCommonLib/Ia32/DivU64x32.asm99
-rw-r--r--EDK/Foundation/Library/EfiCommonLib/Ia32/EfiCopyMem.asm183
-rw-r--r--EDK/Foundation/Library/EfiCommonLib/Ia32/EfiCopyMemSSE2.asm169
-rw-r--r--EDK/Foundation/Library/EfiCommonLib/Ia32/EfiSetMem.asm154
-rw-r--r--EDK/Foundation/Library/EfiCommonLib/Ia32/EfiSetMemSSE2.asm158
-rw-r--r--EDK/Foundation/Library/EfiCommonLib/Ia32/EfiZeroMem.asm138
-rw-r--r--EDK/Foundation/Library/EfiCommonLib/Ia32/EfiZeroMemSSE2.asm127
-rw-r--r--EDK/Foundation/Library/EfiCommonLib/Ia32/GetPowerOfTwo.asm67
-rw-r--r--EDK/Foundation/Library/EfiCommonLib/Ia32/LShiftU64.asm86
-rw-r--r--EDK/Foundation/Library/EfiCommonLib/Ia32/Log2.asm87
-rw-r--r--EDK/Foundation/Library/EfiCommonLib/Ia32/MultU64x32.asm74
-rw-r--r--EDK/Foundation/Library/EfiCommonLib/Ia32/Power10U64.asm72
-rw-r--r--EDK/Foundation/Library/EfiCommonLib/Ia32/RShiftU64.asm86
-rw-r--r--EDK/Foundation/Library/EfiCommonLib/Math.c216
-rw-r--r--EDK/Foundation/Library/EfiCommonLib/Misc.c385
-rw-r--r--EDK/Foundation/Library/EfiCommonLib/PostCode.c62
-rw-r--r--EDK/Foundation/Library/EfiCommonLib/ReportStatusCode.c333
-rw-r--r--EDK/Foundation/Library/EfiCommonLib/String.c802
-rw-r--r--EDK/Foundation/Library/EfiCommonLib/ValueToString.c213
-rw-r--r--EDK/Foundation/Library/EfiCommonLib/linkedlist.c356
-rw-r--r--EDK/Foundation/Library/EfiCommonLib/x64/EfiCopyMemRep4.asm65
-rw-r--r--EDK/Foundation/Library/Pei/Hob/PeiHobLib.c721
-rw-r--r--EDK/Foundation/Library/Pei/Hob/PeiHobLib.cif11
-rw-r--r--EDK/Foundation/Library/Pei/Hob/PeiHobLib.inf51
-rw-r--r--EDK/Foundation/Library/Pei/Hob/PeiHobLib.mak69
-rw-r--r--EDK/Foundation/Library/Pei/Hob/PeiHobLib.sdl26
-rw-r--r--EDK/Foundation/Library/Pei/Include/PeiLib.h1455
-rw-r--r--EDK/Foundation/Library/Pei/Include/peihoblib.h346
-rw-r--r--EDK/Foundation/Library/Pei/PeiLib/Debug.c158
-rw-r--r--EDK/Foundation/Library/Pei/PeiLib/Decompress.c1140
-rw-r--r--EDK/Foundation/Library/Pei/PeiLib/FindFv.c157
-rw-r--r--EDK/Foundation/Library/Pei/PeiLib/Hob/Hob.c517
-rw-r--r--EDK/Foundation/Library/Pei/PeiLib/Ipf/PeCoffLoaderEx.c268
-rw-r--r--EDK/Foundation/Library/Pei/PeiLib/Ipf/PeCoffLoaderEx.h87
-rw-r--r--EDK/Foundation/Library/Pei/PeiLib/Ipf/PeiServicePointer.c109
-rw-r--r--EDK/Foundation/Library/Pei/PeiLib/Ipf/PerformancePrimitives.s61
-rw-r--r--EDK/Foundation/Library/Pei/PeiLib/Ipf/SwitchStack.s122
-rw-r--r--EDK/Foundation/Library/Pei/PeiLib/Ipf/asm.h35
-rw-r--r--EDK/Foundation/Library/Pei/PeiLib/Ipf/efijump.h112
-rw-r--r--EDK/Foundation/Library/Pei/PeiLib/Ipf/ia_64gen.h214
-rw-r--r--EDK/Foundation/Library/Pei/PeiLib/Ipf/math.c139
-rw-r--r--EDK/Foundation/Library/Pei/PeiLib/Ipf/pioflush.s106
-rw-r--r--EDK/Foundation/Library/Pei/PeiLib/Ipf/processor.c118
-rw-r--r--EDK/Foundation/Library/Pei/PeiLib/Ipf/setjmp.s325
-rw-r--r--EDK/Foundation/Library/Pei/PeiLib/PeCoffLoader.c1491
-rw-r--r--EDK/Foundation/Library/Pei/PeiLib/PeiLib.c714
-rw-r--r--EDK/Foundation/Library/Pei/PeiLib/PeiLib.cif23
-rw-r--r--EDK/Foundation/Library/Pei/PeiLib/PeiLib.inf95
-rw-r--r--EDK/Foundation/Library/Pei/PeiLib/PeiLib.mak141
-rw-r--r--EDK/Foundation/Library/Pei/PeiLib/PeiLib.sdl31
-rw-r--r--EDK/Foundation/Library/Pei/PeiLib/PeiLibIA32.cif14
-rw-r--r--EDK/Foundation/Library/Pei/PeiLib/PeiLibIPF.cif19
-rw-r--r--EDK/Foundation/Library/Pei/PeiLib/PeiLibx64.cif15
-rw-r--r--EDK/Foundation/Library/Pei/PeiLib/Perf.c362
-rw-r--r--EDK/Foundation/Library/Pei/PeiLib/Print/Print.c739
-rw-r--r--EDK/Foundation/Library/Pei/PeiLib/Print/Print.h38
-rw-r--r--EDK/Foundation/Library/Pei/PeiLib/ia32/PeCoffLoaderEx.c93
-rw-r--r--EDK/Foundation/Library/Pei/PeiLib/ia32/PeCoffLoaderEx.h85
-rw-r--r--EDK/Foundation/Library/Pei/PeiLib/ia32/PeiServicePointer.c153
-rw-r--r--EDK/Foundation/Library/Pei/PeiLib/ia32/PerformancePrimitives.c47
-rw-r--r--EDK/Foundation/Library/Pei/PeiLib/ia32/Processor.c140
-rw-r--r--EDK/Foundation/Library/Pei/PeiLib/ia32/ProcessorAsms.Asm223
-rw-r--r--EDK/Foundation/Library/Pei/PeiLib/ia32/efijump.h34
-rw-r--r--EDK/Foundation/Library/Pei/PeiLib/x64/EfiJump.h42
-rw-r--r--EDK/Foundation/Library/Pei/PeiLib/x64/Math.c117
-rw-r--r--EDK/Foundation/Library/Pei/PeiLib/x64/PeCoffLoaderEx.c87
-rw-r--r--EDK/Foundation/Library/Pei/PeiLib/x64/PeCoffLoaderEx.h85
-rw-r--r--EDK/Foundation/Library/Pei/PeiLib/x64/PeiServicePointer.c99
-rw-r--r--EDK/Foundation/Library/Pei/PeiLib/x64/PerformancePrimitives.c34
-rw-r--r--EDK/Foundation/Library/Pei/PeiLib/x64/Processor.c149
-rw-r--r--EDK/Foundation/Library/Pei/PeiLib/x64/ProcessorAsms.Asm186
-rw-r--r--EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Debug.c154
-rw-r--r--EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/EfiRuntimeLib.cif32
-rw-r--r--EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/EfiRuntimeLib.inf78
-rw-r--r--EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/EfiRuntimeLib.mak101
-rw-r--r--EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/EfiRuntimeLib.sdl26
-rw-r--r--EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Event.c353
-rw-r--r--EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/GetImage.c221
-rw-r--r--EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Io.c249
-rw-r--r--EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ipf/EsalLib.s149
-rw-r--r--EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ipf/Fvb.c332
-rw-r--r--EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ipf/IpfCpuCache.s88
-rw-r--r--EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ipf/Lock.c170
-rw-r--r--EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ipf/RuntimeLib.c1317
-rw-r--r--EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/LibGlobals.c37
-rw-r--r--EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/RtDevicePath.c649
-rw-r--r--EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/ia32/Fvb.c617
-rw-r--r--EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/ia32/IoLib.c130
-rw-r--r--EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/ia32/Lock.c177
-rw-r--r--EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/ia32/PlatformIoLib.c407
-rw-r--r--EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/ia32/RuntimeLib.c840
-rw-r--r--EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/x64/Fvb.c620
-rw-r--r--EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/x64/IoLib.c130
-rw-r--r--EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/x64/Lock.c177
-rw-r--r--EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/x64/PlatformIoLib.c409
-rw-r--r--EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/x64/RuntimeLib.c808
-rw-r--r--EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/x64/RuntimeLibAsm.asm37
-rw-r--r--EDK/Foundation/Ppi/BaseMemoryTest/BaseMemoryTest.c28
-rw-r--r--EDK/Foundation/Ppi/BaseMemoryTest/BaseMemoryTest.h58
-rw-r--r--EDK/Foundation/Ppi/DebugMask/DebugMask.c30
-rw-r--r--EDK/Foundation/Ppi/DebugMask/DebugMask.h46
-rw-r--r--EDK/Foundation/Ppi/EdkPpiLib.cif20
-rw-r--r--EDK/Foundation/Ppi/EdkPpiLib.inf51
-rw-r--r--EDK/Foundation/Ppi/EdkPpiLib.mak69
-rw-r--r--EDK/Foundation/Ppi/EdkPpiLib.sdl26
-rw-r--r--EDK/Foundation/Ppi/FlashMap/FlashMap.c28
-rw-r--r--EDK/Foundation/Ppi/FlashMap/FlashMap.h59
-rw-r--r--EDK/Foundation/Ppi/PeiInMemory/PeiInMemory.c33
-rw-r--r--EDK/Foundation/Ppi/PeiInMemory/PeiInMemory.h29
-rw-r--r--EDK/Foundation/Ppi/StatusCodeMemory/StatusCodeMemory.c28
-rw-r--r--EDK/Foundation/Ppi/StatusCodeMemory/StatusCodeMemory.h53
-rw-r--r--EDK/Foundation/Protocol/ConsoleControl/ConsoleControl.c29
-rw-r--r--EDK/Foundation/Protocol/ConsoleControl/ConsoleControl.h122
-rw-r--r--EDK/Foundation/Protocol/CustomizedDecompress/CustomizedDecompress.c28
-rw-r--r--EDK/Foundation/Protocol/CustomizedDecompress/CustomizedDecompress.h139
-rw-r--r--EDK/Foundation/Protocol/DebugAssert/DebugAssert.c30
-rw-r--r--EDK/Foundation/Protocol/DebugAssert/DebugAssert.h89
-rw-r--r--EDK/Foundation/Protocol/DebugMask/DebugMask.c33
-rw-r--r--EDK/Foundation/Protocol/DebugMask/DebugMask.h72
-rw-r--r--EDK/Foundation/Protocol/DiskInfo/DiskInfo.c30
-rw-r--r--EDK/Foundation/Protocol/DiskInfo/DiskInfo.h174
-rw-r--r--EDK/Foundation/Protocol/EdkProtocolLib.cif78
-rw-r--r--EDK/Foundation/Protocol/EdkProtocolLib.inf112
-rw-r--r--EDK/Foundation/Protocol/EdkProtocolLib.mak72
-rw-r--r--EDK/Foundation/Protocol/EdkProtocolLib.sdl26
-rw-r--r--EDK/Foundation/Protocol/EdkProtocolLibIPF.cif11
-rw-r--r--EDK/Foundation/Protocol/EfiOEMBadging/EfiOEMBadging.c30
-rw-r--r--EDK/Foundation/Protocol/EfiOEMBadging/EfiOEMBadging.h79
-rw-r--r--EDK/Foundation/Protocol/ExtendedSalBootService/ExtendedSalBootService.c27
-rw-r--r--EDK/Foundation/Protocol/ExtendedSalBootService/ExtendedSalBootService.h118
-rw-r--r--EDK/Foundation/Protocol/ExtendedSalGuid/ExtendedSalGuid.c74
-rw-r--r--EDK/Foundation/Protocol/ExtendedSalGuid/ExtendedSalGuid.h283
-rw-r--r--EDK/Foundation/Protocol/FastBootException/FastBootException.c27
-rw-r--r--EDK/Foundation/Protocol/FastBootException/FastBootException.h41
-rw-r--r--EDK/Foundation/Protocol/FaultTolerantWriteLite/FaultTolerantWriteLite.c29
-rw-r--r--EDK/Foundation/Protocol/FaultTolerantWriteLite/FaultTolerantWriteLite.h88
-rw-r--r--EDK/Foundation/Protocol/FirmwarePerformance/FirmwarePerformance.c27
-rw-r--r--EDK/Foundation/Protocol/FirmwarePerformance/FirmwarePerformance.h213
-rw-r--r--EDK/Foundation/Protocol/FirmwareVolumeDispatch/FirmwareVolumeDispatch.c32
-rw-r--r--EDK/Foundation/Protocol/FirmwareVolumeDispatch/FirmwareVolumeDispatch.h35
-rw-r--r--EDK/Foundation/Protocol/Fpdt/Fpdt.c31
-rw-r--r--EDK/Foundation/Protocol/Fpdt/Fpdt.h56
-rw-r--r--EDK/Foundation/Protocol/FvbExtension/FvbExtension.c29
-rw-r--r--EDK/Foundation/Protocol/FvbExtension/FvbExtension.h53
-rw-r--r--EDK/Foundation/Protocol/GenericMemoryTest/GenericMemoryTest.c29
-rw-r--r--EDK/Foundation/Protocol/GenericMemoryTest/GenericMemoryTest.h154
-rw-r--r--EDK/Foundation/Protocol/GuidedSectionExtraction/GuidedSectionExtraction.c35
-rw-r--r--EDK/Foundation/Protocol/GuidedSectionExtraction/GuidedSectionExtraction.h73
-rw-r--r--EDK/Foundation/Protocol/IsaAcpi/IsaAcpi.c30
-rw-r--r--EDK/Foundation/Protocol/IsaAcpi/IsaAcpi.h177
-rw-r--r--EDK/Foundation/Protocol/IsaIo/IsaIo.c30
-rw-r--r--EDK/Foundation/Protocol/IsaIo/IsaIo.h176
-rw-r--r--EDK/Foundation/Protocol/LoadPe32Image/LoadPe32Image.c27
-rw-r--r--EDK/Foundation/Protocol/LoadPe32Image/LoadPe32Image.h64
-rw-r--r--EDK/Foundation/Protocol/NicIp4Config/NicIp4Config.c37
-rw-r--r--EDK/Foundation/Protocol/NicIp4Config/NicIp4Config.h118
-rw-r--r--EDK/Foundation/Protocol/PciHotPlugRequest/PciHotPlugRequest.c27
-rw-r--r--EDK/Foundation/Protocol/PciHotPlugRequest/PciHotPlugRequest.h55
-rw-r--r--EDK/Foundation/Protocol/Performance/Performance.c27
-rw-r--r--EDK/Foundation/Protocol/Performance/Performance.h103
-rw-r--r--EDK/Foundation/Protocol/PlatformMemTest/PlatformMemTest.c30
-rw-r--r--EDK/Foundation/Protocol/PlatformMemTest/PlatformMemTest.h261
-rw-r--r--EDK/Foundation/Protocol/Print/Print.c29
-rw-r--r--EDK/Foundation/Protocol/Print/Print.h51
-rw-r--r--EDK/Foundation/Protocol/Ps2Policy/Ps2Policy.c28
-rw-r--r--EDK/Foundation/Protocol/Ps2Policy/Ps2Policy.h50
-rw-r--r--EDK/Foundation/Protocol/PxeDhcp4/PxeDhcp4.c28
-rw-r--r--EDK/Foundation/Protocol/PxeDhcp4/PxeDhcp4.h350
-rw-r--r--EDK/Foundation/Protocol/PxeDhcp4Callback/PxeDhcp4CallBack.c28
-rw-r--r--EDK/Foundation/Protocol/PxeDhcp4Callback/PxeDhcp4CallBack.h86
-rw-r--r--EDK/Foundation/Protocol/TcgService/TcgService.c31
-rw-r--r--EDK/Foundation/Protocol/TcgService/TcgService.h177
-rw-r--r--EDK/Foundation/Protocol/Tcp/Tcp.c29
-rw-r--r--EDK/Foundation/Protocol/Tcp/Tcp.h110
-rw-r--r--EDK/Foundation/Protocol/TianoDecompress/TianoDecompress.c28
-rw-r--r--EDK/Foundation/Protocol/TianoDecompress/TianoDecompress.h139
-rw-r--r--EDK/Foundation/Protocol/UgaSplash/UgaSplash.c29
-rw-r--r--EDK/Foundation/Protocol/UgaSplash/UgaSplash.h45
-rw-r--r--EDK/Foundation/Protocol/UsbAtapi/usbatapi.c31
-rw-r--r--EDK/Foundation/Protocol/UsbAtapi/usbatapi.h83
-rw-r--r--EDK/Foundation/Protocol/VariableStore/VariableStore.c36
-rw-r--r--EDK/Foundation/Protocol/VariableStore/VariableStore.h105
-rw-r--r--EDK/Foundation/Protocol/VgaMiniPort/VgaMiniPort.c28
-rw-r--r--EDK/Foundation/Protocol/VgaMiniPort/VgaMiniPort.h70
-rw-r--r--EDK/Foundation/Protocol/VirtualMemoryAccess/VirtualMemoryAccess.c27
-rw-r--r--EDK/Foundation/Protocol/VirtualMemoryAccess/VirtualMemoryAccess.h64
1544 files changed, 236059 insertions, 0 deletions
diff --git a/EDK/Foundation/Core/Dxe/ArchProtocol/ArchProtocolLib.cif b/EDK/Foundation/Core/Dxe/ArchProtocol/ArchProtocolLib.cif
new file mode 100644
index 0000000..de96301
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/ArchProtocol/ArchProtocolLib.cif
@@ -0,0 +1,38 @@
+<component>
+ name = "ArchProtocolLib"
+ category = ModulePart
+ LocalRoot = "EDK\Foundation\Core\Dxe\ArchProtocol"
+ RefName = "ArchProtocolLib"
+[files]
+"ArchProtocolLib.sdl"
+"ArchProtocolLib.mak"
+"Bds\Bds.c"
+"Bds\Bds.h"
+"Capsule\Capsule.c"
+"Capsule\Capsule.h"
+"Cpu\Cpu.c"
+"Cpu\Cpu.h"
+"Metronome\Metronome.c"
+"Metronome\Metronome.h"
+"MonotonicCounter\MonotonicCounter.c"
+"MonotonicCounter\MonotonicCounter.h"
+"RealTimeClock\RealTimeClock.c"
+"RealTimeClock\RealTimeClock.h"
+"Reset\Reset.c"
+"Reset\Reset.h"
+"Runtime\Runtime.c"
+"Runtime\Runtime.h"
+"Security\Security.c"
+"Security\Security.h"
+"StatusCode\StatusCode.c"
+"StatusCode\StatusCode.h"
+"Timer\Timer.c"
+"Timer\Timer.h"
+"Variable\Variable.c"
+"Variable\Variable.h"
+"VariableWrite\VariableWrite.c"
+"VariableWrite\VariableWrite.h"
+"WatchdogTimer\WatchdogTimer.c"
+"WatchdogTimer\WatchdogTimer.h"
+"ArchProtocolLib.inf"
+<endComponent>
diff --git a/EDK/Foundation/Core/Dxe/ArchProtocol/ArchProtocolLib.inf b/EDK/Foundation/Core/Dxe/ArchProtocol/ArchProtocolLib.inf
new file mode 100644
index 0000000..705c606
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/ArchProtocol/ArchProtocolLib.inf
@@ -0,0 +1,65 @@
+#/*++
+#
+# Copyright (c) 2004 - 2006, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# ArchProtocolLib.inf
+#
+# Abstract:
+#
+# Component description file for the Architectural Protocol Library.
+#
+#--*/
+
+[defines]
+BASE_NAME = ArchProtocolLib
+COMPONENT_TYPE = LIBRARY
+
+[sources.common]
+ Bds\Bds.c
+ Bds\Bds.h
+ Capsule\Capsule.c
+ Capsule\Capsule.h
+ Cpu\Cpu.c
+ Cpu\Cpu.h
+ Metronome\Metronome.c
+ Metronome\Metronome.h
+ MonotonicCounter\MonotonicCounter.c
+ MonotonicCounter\MonotonicCounter.h
+ RealTimeClock\RealTimeClock.c
+ RealTimeClock\RealTimeClock.h
+ Reset\Reset.c
+ Reset\Reset.h
+ Runtime\Runtime.c
+ Runtime\Runtime.h
+ Security\Security.c
+ Security\Security.h
+ StatusCode\StatusCode.c
+ StatusCode\StatusCode.h
+ Timer\Timer.c
+ Timer\Timer.h
+ Variable\Variable.c
+ Variable\Variable.h
+ VariableWrite\VariableWrite.c
+ VariableWrite\VariableWrite.h
+ WatchdogTimer\WatchdogTimer.c
+ WatchdogTimer\WatchdogTimer.h
+
+[includes.common]
+ $(EDK_SOURCE)\Foundation\Efi
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+
+[nmake.common]
diff --git a/EDK/Foundation/Core/Dxe/ArchProtocol/ArchProtocolLib.mak b/EDK/Foundation/Core/Dxe/ArchProtocol/ArchProtocolLib.mak
new file mode 100644
index 0000000..5a37110
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/ArchProtocol/ArchProtocolLib.mak
@@ -0,0 +1,69 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/ArchProtocolLib/ArchProtocolLib.mak 1 1/20/12 4:12a Jeffch $
+#
+# $Revision: 1 $
+#
+# $Date: 1/20/12 4:12a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/ArchProtocolLib/ArchProtocolLib.mak $
+#
+# 1 1/20/12 4:12a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 9/27/11 6:34a Wesleychen
+# Intel EDK initially releases.
+#
+# 2 9/02/09 3:06a Iminglin
+# EIP24919
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: ArchProtocolLib.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+$(ARCHPROTOCOLLIB) : ArchProtocolLib
+
+$(BUILD_DIR)\ArchProtocolLib.lib : ArchProtocolLib
+
+ArchProtocolLib : $(BUILD_DIR)\ArchProtocolLib.mak ArchProtocolLibBin
+
+$(BUILD_DIR)\ArchProtocolLib.mak : $(ArchProtocolLib_DIR)\$(@B).cif $(ArchProtocolLib_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(ArchProtocolLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+ArchProtocolLibBin :
+ $(MAKE) /$(MAKEFLAGS) $(EDK_DEFAULTS)\
+ /f $(BUILD_DIR)\ArchProtocolLib.mak all\
+ TYPE=LIBRARY \
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#********************************************************************** \ No newline at end of file
diff --git a/EDK/Foundation/Core/Dxe/ArchProtocol/ArchProtocolLib.sdl b/EDK/Foundation/Core/Dxe/ArchProtocol/ArchProtocolLib.sdl
new file mode 100644
index 0000000..f758364
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/ArchProtocol/ArchProtocolLib.sdl
@@ -0,0 +1,26 @@
+TOKEN
+ Name = "ArchProtocolLib_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable ArchProtocolLib support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "ARCHPROTOCOLLIB"
+ Value = "$(BUILD_DIR)\ArchProtocolLib.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "ArchProtocolLib_DIR"
+End
+
+MODULE
+ Help = "Includes ArchProtocolLib.mak to Project"
+ File = "ArchProtocolLib.mak"
+End
+
diff --git a/EDK/Foundation/Core/Dxe/ArchProtocol/Bds/Bds.c b/EDK/Foundation/Core/Dxe/ArchProtocol/Bds/Bds.c
new file mode 100644
index 0000000..5bd71bf
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/ArchProtocol/Bds/Bds.c
@@ -0,0 +1,27 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Bds.c
+
+Abstract:
+
+ Boot Device Selection Architectural Protocol GUID as defined in Tiano
+
+--*/
+
+#include "Tiano.h"
+#include EFI_ARCH_PROTOCOL_DEFINITION (Bds)
+
+EFI_GUID gEfiBdsArchProtocolGuid = EFI_BDS_ARCH_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiBdsArchProtocolGuid, "BDS", "BDS Arch Protocol");
diff --git a/EDK/Foundation/Core/Dxe/ArchProtocol/Bds/Bds.h b/EDK/Foundation/Core/Dxe/ArchProtocol/Bds/Bds.h
new file mode 100644
index 0000000..a1282df
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/ArchProtocol/Bds/Bds.h
@@ -0,0 +1,100 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Bds.h
+
+Abstract:
+
+ Boot Device Selection Architectural Protocol as defined in Tiano
+
+ When the DXE core is done it calls the BDS via this protocol.
+
+--*/
+
+#ifndef _ARCH_PROTOCOL_BDS_H_
+#define _ARCH_PROTOCOL_BDS_H_
+
+//
+// Global ID for the BDS Architectural Protocol
+//
+#define EFI_BDS_ARCH_PROTOCOL_GUID \
+ { 0x665E3FF6, 0x46CC, 0x11d4, 0x9A, 0x38, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D }
+
+//
+// Declare forward reference for the BDS Architectural Protocol
+//
+EFI_FORWARD_DECLARATION (EFI_BDS_ARCH_PROTOCOL);
+
+typedef
+VOID
+(EFIAPI *EFI_BDS_ENTRY) (
+ IN EFI_BDS_ARCH_PROTOCOL * This
+ );
+/*++
+
+Routine Description:
+
+ This function uses policy data from the platform to determine what operating
+ system or system utility should be loaded and invoked. This function call
+ also optionally make the use of user input to determine the operating system
+ or system utility to be loaded and invoked. When the DXE Core has dispatched
+ all the drivers on the dispatch queue, this function is called. This
+ function will attempt to connect the boot devices required to load and invoke
+ the selected operating system or system utility. During this process,
+ additional firmware volumes may be discovered that may contain addition DXE
+ drivers that can be dispatched by the DXE Core. If a boot device cannot be
+ fully connected, this function calls the DXE Service Dispatch() to allow the
+ DXE drivers from any newly discovered firmware volumes to be dispatched.
+ Then the boot device connection can be attempted again. If the same boot
+ device connection operation fails twice in a row, then that boot device has
+ failed, and should be skipped. This function should never return.
+
+Arguments:
+
+ This - The EFI_BDS_ARCH_PROTOCOL instance.
+
+Returns:
+
+ None.
+
+--*/
+
+//
+// Interface stucture for the BDS Architectural Protocol
+//
+typedef struct _EFI_BDS_ARCH_PROTOCOL {
+ EFI_BDS_ENTRY Entry;
+} EFI_BDS_ARCH_PROTOCOL;
+
+/*++
+
+ Protocol Description:
+ The EFI_BDS_ARCH_PROTOCOL transfers control from DXE to an operating
+ system or a system utility. If there are not enough drivers initialized
+ when this protocol is used to access the required boot device(s), then
+ this protocol should add drivers to the dispatch queue and return control
+ back to the dispatcher. Once the required boot devices are available, then
+ the boot device can be used to load and invoke an OS or a system utility.
+
+ Parameters:
+
+ Entry - The entry point to BDS. This call does not take any parameters,
+ and the return value can be ignored. If it returns, then the
+ dispatcher must be invoked again, if it never returns, then an
+ operating system or a system utility have been invoked.
+
+--*/
+
+extern EFI_GUID gEfiBdsArchProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Core/Dxe/ArchProtocol/Capsule/Capsule.c b/EDK/Foundation/Core/Dxe/ArchProtocol/Capsule/Capsule.c
new file mode 100644
index 0000000..42673a2
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/ArchProtocol/Capsule/Capsule.c
@@ -0,0 +1,27 @@
+/*++
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Capsule.c
+
+Abstract:
+
+ Capsule Architectural Protocol is used to produce the UEFI 2.0 capsule runtime services
+
+--*/
+
+#include "Tiano.h"
+#include EFI_ARCH_PROTOCOL_DEFINITION (Capsule)
+
+EFI_GUID gEfiCapsuleArchProtocolGuid = EFI_CAPSULE_ARCH_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiCapsuleArchProtocolGuid, "Capsule", "Capsule Arch Protocol");
diff --git a/EDK/Foundation/Core/Dxe/ArchProtocol/Capsule/Capsule.h b/EDK/Foundation/Core/Dxe/ArchProtocol/Capsule/Capsule.h
new file mode 100644
index 0000000..2e11f83
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/ArchProtocol/Capsule/Capsule.h
@@ -0,0 +1,33 @@
+/*++
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Capsule.h
+
+Abstract:
+
+ Capsule Architectural Protocol is newly added to produce UEFI2.0 capsule runtime services.
+
+--*/
+
+#ifndef _ARCH_PROTOCOL_CAPSULE_ARCH_H_
+#define _ARCH_PROTOCOL_CAPSULE_ARCH_H_
+
+//
+// Global ID for the Capsule Architectural Protocol
+//
+#define EFI_CAPSULE_ARCH_PROTOCOL_GUID \
+ { 0x5053697e, 0x2cbc, 0x4819, 0x90, 0xd9, 0x5, 0x80, 0xde, 0xee, 0x57, 0x54 }
+
+extern EFI_GUID gEfiCapsuleArchProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Core/Dxe/ArchProtocol/Cpu/Cpu.c b/EDK/Foundation/Core/Dxe/ArchProtocol/Cpu/Cpu.c
new file mode 100644
index 0000000..40dbb06
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/ArchProtocol/Cpu/Cpu.c
@@ -0,0 +1,28 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Cpu.c
+
+Abstract:
+
+ CPU Architectural Protocol GUID as defined in Tiano
+
+
+--*/
+
+#include "Tiano.h"
+#include EFI_ARCH_PROTOCOL_DEFINITION (Cpu)
+
+EFI_GUID gEfiCpuArchProtocolGuid = EFI_CPU_ARCH_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiCpuArchProtocolGuid, "CPU", "CPU Arch Protocol");
diff --git a/EDK/Foundation/Core/Dxe/ArchProtocol/Cpu/Cpu.h b/EDK/Foundation/Core/Dxe/ArchProtocol/Cpu/Cpu.h
new file mode 100644
index 0000000..fdc426b
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/ArchProtocol/Cpu/Cpu.h
@@ -0,0 +1,361 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Cpu.h
+
+Abstract:
+
+ CPU Architectural Protocol as defined in Tiano
+
+ This code abstracts the DXE core from processor implementation details.
+
+--*/
+
+#ifndef _ARCH_PROTOCOL_CPU_H_
+#define _ARCH_PROTOCOL_CPU_H_
+
+#include EFI_PROTOCOL_DEFINITION (DebugSupport)
+
+#define EFI_CPU_ARCH_PROTOCOL_GUID \
+ { 0x26baccb1, 0x6f42, 0x11d4, 0xbc, 0xe7, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 }
+
+EFI_FORWARD_DECLARATION (EFI_CPU_ARCH_PROTOCOL);
+
+typedef enum {
+ EfiCpuFlushTypeWriteBackInvalidate,
+ EfiCpuFlushTypeWriteBack,
+ EfiCpuFlushTypeInvalidate,
+ EfiCpuMaxFlushType
+} EFI_CPU_FLUSH_TYPE;
+
+typedef enum {
+ EfiCpuInit,
+ EfiCpuMaxInitType
+} EFI_CPU_INIT_TYPE;
+
+typedef
+VOID
+(*EFI_CPU_INTERRUPT_HANDLER) (
+ IN EFI_EXCEPTION_TYPE InterruptType,
+ IN EFI_SYSTEM_CONTEXT SystemContext
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_CPU_FLUSH_DATA_CACHE) (
+ IN EFI_CPU_ARCH_PROTOCOL * This,
+ IN EFI_PHYSICAL_ADDRESS Start,
+ IN UINT64 Length,
+ IN EFI_CPU_FLUSH_TYPE FlushType
+ );
+
+/*++
+
+Routine Description:
+
+ This function flushes the range of addresses from Start to Start+Length
+ from the processor's data cache. If Start is not aligned to a cache line
+ boundary, then the bytes before Start to the preceding cache line boundary
+ are also flushed. If Start+Length is not aligned to a cache line boundary,
+ then the bytes past Start+Length to the end of the next cache line boundary
+ are also flushed. The FlushType of EfiCpuFlushTypeWriteBackInvalidate must be
+ supported. If the data cache is fully coherent with all DMA operations, then
+ this function can just return EFI_SUCCESS. If the processor does not support
+ flushing a range of the data cache, then the entire data cache can be flushed.
+
+Arguments:
+
+ This - The EFI_CPU_ARCH_PROTOCOL instance.
+ Start - The beginning physical address to flush from the processor's data
+ cache.
+ Length - The number of bytes to flush from the processor's data cache. This
+ function may flush more bytes than Length specifies depending upon
+ the granularity of the flush operation that the processor supports.
+ FlushType - Specifies the type of flush operation to perform.
+
+Returns:
+
+ EFI_SUCCESS - The address range from Start to Start+Length was flushed from
+ the processor's data cache.
+ EFI_UNSUPPORTEDT - The processor does not support the cache flush type specified
+ by FlushType.
+ EFI_DEVICE_ERROR - The address range from Start to Start+Length could not be flushed
+ from the processor's data cache.
+
+--*/
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_CPU_ENABLE_INTERRUPT) (
+ IN EFI_CPU_ARCH_PROTOCOL * This
+ );
+
+/*++
+
+Routine Description:
+
+ This function enables interrupt processing by the processor.
+
+Arguments:
+
+ This - The EFI_CPU_ARCH_PROTOCOL instance.
+
+Returns:
+
+ EFI_SUCCESS - Interrupts are enabled on the processor.
+ EFI_DEVICE_ERROR - Interrupts could not be enabled on the processor.
+
+--*/
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_CPU_DISABLE_INTERRUPT) (
+ IN EFI_CPU_ARCH_PROTOCOL * This
+ );
+
+/*++
+
+Routine Description:
+
+ This function disables interrupt processing by the processor.
+
+Arguments:
+
+ This - The EFI_CPU_ARCH_PROTOCOL instance.
+
+Returns:
+
+ EFI_SUCCESS - Interrupts are disabled on the processor.
+ EFI_DEVICE_ERROR - Interrupts could not be disabled on the processor.
+
+--*/
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_CPU_GET_INTERRUPT_STATE) (
+ IN EFI_CPU_ARCH_PROTOCOL * This,
+ OUT BOOLEAN *State
+ );
+
+/*++
+
+Routine Description:
+
+ This function retrieves the processor's current interrupt state a returns it in
+ State. If interrupts are currently enabled, then TRUE is returned. If interrupts
+ are currently disabled, then FALSE is returned.
+
+Arguments:
+
+ This - The EFI_CPU_ARCH_PROTOCOL instance.
+ State - A pointer to the processor's current interrupt state. Set to TRUE if
+ interrupts are enabled and FALSE if interrupts are disabled.
+Returns:
+
+ EFI_SUCCESS - The processor's current interrupt state was returned in State.
+ EFI_INVALID_PARAMETER - State is NULL.
+
+--*/
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_CPU_INIT) (
+ IN EFI_CPU_ARCH_PROTOCOL * This,
+ IN EFI_CPU_INIT_TYPE InitType
+ );
+
+/*++
+
+Routine Description:
+
+ This function generates an INIT on the processor. If this function succeeds, then the
+ processor will be reset, and control will not be returned to the caller. If InitType is
+ not supported by this processor, or the processor cannot programmatically generate an
+ INIT without help from external hardware, then EFI_UNSUPPORTED is returned. If an error
+ occurs attempting to generate an INIT, then EFI_DEVICE_ERROR is returned.
+
+Arguments:
+
+ This - The EFI_CPU_ARCH_PROTOCOL instance.
+ InitType - The type of processor INIT to perform.
+
+Returns:
+
+ EFI_SUCCESS - The processor INIT was performed. This return code should never be seen.
+ EFI_UNSUPPORTED - The processor INIT operation specified by InitType is not supported
+ by this processor.
+ EFI_DEVICE_ERROR - The processor INIT failed.
+
+--*/
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_CPU_REGISTER_INTERRUPT_HANDLER) (
+ IN EFI_CPU_ARCH_PROTOCOL * This,
+ IN EFI_EXCEPTION_TYPE InterruptType,
+ IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler
+ );
+
+/*++
+
+Routine Description:
+
+ This function registers and enables the handler specified by InterruptHandler for a processor
+ interrupt or exception type specified by InterruptType. If InterruptHandler is NULL, then the
+ handler for the processor interrupt or exception type specified by InterruptType is uninstalled.
+ The installed handler is called once for each processor interrupt or exception.
+
+Arguments:
+
+ This - The EFI_CPU_ARCH_PROTOCOL instance.
+ InterruptType - A pointer to the processor's current interrupt state. Set to TRUE if interrupts
+ are enabled and FALSE if interrupts are disabled.
+ InterruptHandler - A pointer to a function of type EFI_CPU_INTERRUPT_HANDLER that is called
+ when a processor interrupt occurs. If this parameter is NULL, then the handler
+ will be uninstalled.
+Returns:
+
+ EFI_SUCCESS - The handler for the processor interrupt was successfully installed or uninstalled.
+ EFI_ALREADY_STARTED - InterruptHandler is not NULL, and a handler for InterruptType was
+ previously installed.
+ EFI_INVALID_PARAMETER - InterruptHandler is NULL, and a handler for InterruptType was not
+ previously installed.
+ EFI_UNSUPPORTED - The interrupt specified by InterruptType is not supported.
+
+--*/
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_CPU_GET_TIMER_VALUE) (
+ IN EFI_CPU_ARCH_PROTOCOL * This,
+ IN UINT32 TimerIndex,
+ OUT UINT64 *TimerValue,
+ OUT UINT64 *TimerPeriod OPTIONAL
+ );
+
+/*++
+
+Routine Description:
+
+ This function reads the processor timer specified by TimerIndex and returns it in TimerValue.
+
+Arguments:
+
+ This - The EFI_CPU_ARCH_PROTOCOL instance.
+ TimerIndex - Specifies which processor timer is to be returned in TimerValue. This parameter
+ must be between 0 and NumberOfTimers-1.
+ TimerValue - Pointer to the returned timer value.
+ TimerPeriod - A pointer to the amount of time that passes in femtoseconds for each increment
+ of TimerValue.
+Returns:
+
+ EFI_SUCCESS - The processor timer value specified by TimerIndex was returned in TimerValue.
+ EFI_DEVICE_ERROR - An error occurred attempting to read one of the processor's timers.
+ EFI_INVALID_PARAMETER - TimerValue is NULL or TimerIndex is not valid.
+ EFI_UNSUPPORTED - The processor does not have any readable timers.
+
+--*/
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_CPU_SET_MEMORY_ATTRIBUTES) (
+ IN EFI_CPU_ARCH_PROTOCOL * This,
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length,
+ IN UINT64 Attributes
+ );
+
+/*++
+
+Routine Description:
+
+ This function modifies the attributes for the memory region specified by BaseAddress and
+ Length from their current attributes to the attributes specified by Attributes.
+
+Arguments:
+
+ This - The EFI_CPU_ARCH_PROTOCOL instance.
+ BaseAddress - The physical address that is the start address of a memory region.
+ Length - The size in bytes of the memory region.
+ Attributes - The bit mask of attributes to set for the memory region.
+
+Returns:
+
+ EFI_SUCCESS - The attributes were set for the memory region.
+ EFI_ACCESS_DENIED - The attributes for the memory resource range specified by
+ BaseAddress and Length cannot be modified.
+ EFI_INVALID_PARAMETER - Length is zero.
+ EFI_OUT_OF_RESOURCES - There are not enough system resources to modify the attributes of
+ the memory resource range.
+ EFI_UNSUPPORTED - The processor does not support one or more bytes of the memory
+ resource range specified by BaseAddress and Length.
+ The bit mask of attributes is not support for the memory resource
+ range specified by BaseAddress and Length.
+
+--*/
+
+typedef struct _EFI_CPU_ARCH_PROTOCOL {
+ EFI_CPU_FLUSH_DATA_CACHE FlushDataCache;
+ EFI_CPU_ENABLE_INTERRUPT EnableInterrupt;
+ EFI_CPU_DISABLE_INTERRUPT DisableInterrupt;
+ EFI_CPU_GET_INTERRUPT_STATE GetInterruptState;
+ EFI_CPU_INIT Init;
+ EFI_CPU_REGISTER_INTERRUPT_HANDLER RegisterInterruptHandler;
+ EFI_CPU_GET_TIMER_VALUE GetTimerValue;
+ EFI_CPU_SET_MEMORY_ATTRIBUTES SetMemoryAttributes;
+ UINT32 NumberOfTimers;
+ UINT32 DmaBufferAlignment;
+} EFI_CPU_ARCH_PROTOCOL;
+
+/*++
+
+Protocol Description:
+
+ The EFI_CPU_ARCH_PROTOCOL is used to abstract processor-specific functions from the DXE
+ Foundation. This includes flushing caches, enabling and disabling interrupts, hooking interrupt
+ vectors and exception vectors, reading internal processor timers, resetting the processor, and
+ determining the processor frequency.
+
+Parameters:
+
+ FlushDataCache - Flushes a range of the processor's data cache. If the processor does
+ not contain a data cache, or the data cache is fully coherent, then this
+ function can just return EFI_SUCCESS. If the processor does not support
+ flushing a range of addresses from the data cache, then the entire data
+ cache must be flushed.
+ EnableInterrupt - Enables interrupt processing by the processor.
+ DisableInterrupt - Disables interrupt processing by the processor.
+ GetInterruptState - Retrieves the processor's current interrupt state.
+ Init - Generates an INIT on the processor. If a processor cannot programmatically
+ generate an INIT without help from external hardware, then this function
+ returns EFI_UNSUPPORTED.
+ RegisterInterruptHandler - Associates an interrupt service routine with one of the processor's interrupt
+ vectors. This function is typically used by the EFI_TIMER_ARCH_PROTOCOL to
+ hook the timer interrupt in a system. It can also be used by the debugger to
+ hook exception vectors.
+ GetTimerValue - Returns the value of one of the processor's internal timers.
+ SetMemoryAttributes - Attempts to set the attributes of a memory region.
+ NumberOfTimers - The number of timers that are available in a processor. The value in this
+ field is a constant that must not be modified after the CPU Architectural
+ Protocol is installed. All consumers must treat this as a read-only field.
+ DmaBufferAlignment - The size, in bytes, of the alignment required for DMA buffer allocations.
+ This is typically the size of the largest data cache line in the platform.
+ The value in this field is a constant that must not be modified after the
+ CPU Architectural Protocol is installed. All consumers must treat this as
+ a read-only field.
+
+--*/
+
+extern EFI_GUID gEfiCpuArchProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Core/Dxe/ArchProtocol/Metronome/Metronome.c b/EDK/Foundation/Core/Dxe/ArchProtocol/Metronome/Metronome.c
new file mode 100644
index 0000000..a09a0d5
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/ArchProtocol/Metronome/Metronome.c
@@ -0,0 +1,27 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Metronome.c
+
+Abstract:
+
+ Metronome Architectural Protocol as defined in Tiano
+
+--*/
+
+#include "Tiano.h"
+#include EFI_ARCH_PROTOCOL_DEFINITION (Metronome)
+
+EFI_GUID gEfiMetronomeArchProtocolGuid = EFI_METRONOME_ARCH_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiMetronomeArchProtocolGuid, "Metronome", "Metronome Arch Protocol");
diff --git a/EDK/Foundation/Core/Dxe/ArchProtocol/Metronome/Metronome.h b/EDK/Foundation/Core/Dxe/ArchProtocol/Metronome/Metronome.h
new file mode 100644
index 0000000..c254d9b
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/ArchProtocol/Metronome/Metronome.h
@@ -0,0 +1,109 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Metronome.h
+
+Abstract:
+
+ Metronome Architectural Protocol as defined in DXE CIS
+
+ This code abstracts the DXE core to provide delay services.
+
+--*/
+
+#ifndef _ARCH_PROTOCOL_METRONOME_H_
+#define _ARCH_PROTOCOL_METRONOME_H_
+
+//
+// Global ID for the Metronome Architectural Protocol
+//
+#define EFI_METRONOME_ARCH_PROTOCOL_GUID \
+ { 0x26baccb2, 0x6f42, 0x11d4, 0xbc, 0xe7, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 }
+
+//
+// Declare forward reference for the Metronome Architectural Protocol
+//
+EFI_FORWARD_DECLARATION (EFI_METRONOME_ARCH_PROTOCOL);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_METRONOME_WAIT_FOR_TICK) (
+ IN EFI_METRONOME_ARCH_PROTOCOL *This,
+ IN UINT32 TickNumber
+ );
+/*++
+
+Routine Description:
+
+ The WaitForTick() function waits for the number of ticks specified by
+ TickNumber from a known time source in the platform. If TickNumber of
+ ticks are detected, then EFI_SUCCESS is returned. The actual time passed
+ between entry of this function and the first tick is between 0 and
+ TickPeriod 100 nS units. If you want to guarantee that at least TickPeriod
+ time has elapsed, wait for two ticks. This function waits for a hardware
+ event to determine when a tick occurs. It is possible for interrupt
+ processing, or exception processing to interrupt the execution of the
+ WaitForTick() function. Depending on the hardware source for the ticks, it
+ is possible for a tick to be missed. This function cannot guarantee that
+ ticks will not be missed. If a timeout occurs waiting for the specified
+ number of ticks, then EFI_TIMEOUT is returned.
+
+Arguments:
+
+ This - The EFI_METRONOME_ARCH_PROTOCOL instance.
+
+ TickNumber - Number of ticks to wait.
+
+Returns:
+
+ EFI_SUCCESS - The wait for the number of ticks specified by TickNumber
+ succeeded.
+
+ EFI_TIMEOUT - A timeout occurred waiting for the specified number of ticks.
+
+--*/
+
+//
+// Interface stucture for the Metronome Architectural Protocol
+//
+typedef struct _EFI_METRONOME_ARCH_PROTOCOL {
+ EFI_METRONOME_WAIT_FOR_TICK WaitForTick;
+ UINT32 TickPeriod;
+} EFI_METRONOME_ARCH_PROTOCOL;
+
+/*++
+
+ Protocol Description:
+ This protocol provides access to a known time source in the platform to the
+ core. The core uses this known time source to produce core services that
+ require calibrated delays.
+
+ Parameters:
+
+ WaitForTick - Waits for a specified number of ticks from a known time source
+ in the platform. The actual time passed between entry of this
+ function and the first tick is between 0 and TickPeriod 100 nS
+ units. If you want to guarantee that at least TickPeriod time
+ has elapsed, wait for two ticks.
+
+ TickPeriod - The period of platform's known time source in 100 nS units.
+ This value on any platform must be at least 10 uS, and must not
+ exceed 200 uS. The value in this field is a constant that must
+ not be modified after the Metronome architectural protocol is
+ installed. All consumers must treat this as a read-only field.
+
+--*/
+
+extern EFI_GUID gEfiMetronomeArchProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Core/Dxe/ArchProtocol/MonotonicCounter/MonotonicCounter.c b/EDK/Foundation/Core/Dxe/ArchProtocol/MonotonicCounter/MonotonicCounter.c
new file mode 100644
index 0000000..54d9ca4
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/ArchProtocol/MonotonicCounter/MonotonicCounter.c
@@ -0,0 +1,27 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ MonotonicCounter.c
+
+Abstract:
+
+ Monotonic Counter Architectural Protocol GUID as defined in the DXE CIS
+
+--*/
+
+#include "Tiano.h"
+#include EFI_ARCH_PROTOCOL_DEFINITION(MonotonicCounter)
+
+EFI_GUID gEfiMonotonicCounterArchProtocolGuid = EFI_MONTONIC_COUNTER_ARCH_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiMonotonicCounterArchProtocolGuid, "Monotonic Counter", "Monotonic Counter Arch Protocol");
diff --git a/EDK/Foundation/Core/Dxe/ArchProtocol/MonotonicCounter/MonotonicCounter.h b/EDK/Foundation/Core/Dxe/ArchProtocol/MonotonicCounter/MonotonicCounter.h
new file mode 100644
index 0000000..39e68aa
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/ArchProtocol/MonotonicCounter/MonotonicCounter.h
@@ -0,0 +1,35 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ MonotonicCounter.h
+
+Abstract:
+
+ Monotonic Counter Architectural Protocol as defined in DXE CIS
+
+ This code provides the services required to access the systems monotonic counter
+
+--*/
+
+#ifndef _ARCH_PROTOCOL_MONTONIC_COUNTER_H_
+#define _ARCH_PROTOCOL_MONTONIC_COUNTER_H_
+
+//
+// Global ID for the Monotonic Counter Architectural Protocol
+//
+#define EFI_MONTONIC_COUNTER_ARCH_PROTOCOL_GUID \
+ {0x1da97072, 0xbddc, 0x4b30, 0x99, 0xf1, 0x72, 0xa0, 0xb5, 0x6f, 0xff, 0x2a}
+
+extern EFI_GUID gEfiMonotonicCounterArchProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Core/Dxe/ArchProtocol/RealTimeClock/RealTimeClock.c b/EDK/Foundation/Core/Dxe/ArchProtocol/RealTimeClock/RealTimeClock.c
new file mode 100644
index 0000000..1109957
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/ArchProtocol/RealTimeClock/RealTimeClock.c
@@ -0,0 +1,27 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ RealTimeClock.c
+
+Abstract:
+
+ Real Time clock Architectural Protocol GUID as defined in Tiano
+
+--*/
+
+#include "Tiano.h"
+#include EFI_ARCH_PROTOCOL_DEFINITION (RealTimeClock)
+
+EFI_GUID gEfiRealTimeClockArchProtocolGuid = EFI_REAL_TIME_CLOCK_ARCH_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiRealTimeClockArchProtocolGuid, "RTC", "Real Time Clock Arch Protocol");
diff --git a/EDK/Foundation/Core/Dxe/ArchProtocol/RealTimeClock/RealTimeClock.h b/EDK/Foundation/Core/Dxe/ArchProtocol/RealTimeClock/RealTimeClock.h
new file mode 100644
index 0000000..9b98c15
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/ArchProtocol/RealTimeClock/RealTimeClock.h
@@ -0,0 +1,43 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ RealTimeClock.h
+
+Abstract:
+
+ Real Time clock Architectural Protocol as defined in Tiano
+
+ This code abstracts time and data functions. Used to provide
+ Time and date related EFI runtime services.
+
+ The GetTime (), SetTime (), GetWakeupTime (), and SetWakeupTime () EFI 1.0
+ services are added to the EFI system table and the
+ EFI_REAL_TIME_CLOCK_ARCH_PROTOCOL_GUID protocol is registered with a NULL
+ pointer.
+
+ No CRC of the EFI system table is required, as it is done in the DXE core.
+
+--*/
+
+#ifndef _ARCH_PROTOCOL_REAL_TIME_CLOCK_H_
+#define _ARCH_PROTOCOL_REAL_TIME_CLOCK_H_
+
+//
+// Global ID for the Real Time Clock Architectural Protocol
+//
+#define EFI_REAL_TIME_CLOCK_ARCH_PROTOCOL_GUID \
+ { 0x27CFAC87, 0x46CC, 0x11d4, 0x9A, 0x38, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D }
+
+extern EFI_GUID gEfiRealTimeClockArchProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Core/Dxe/ArchProtocol/Reset/Reset.c b/EDK/Foundation/Core/Dxe/ArchProtocol/Reset/Reset.c
new file mode 100644
index 0000000..13896f6
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/ArchProtocol/Reset/Reset.c
@@ -0,0 +1,27 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Reset.c
+
+Abstract:
+
+ Reset Architectural Protocol GUID as defined in Tiano
+
+--*/
+
+#include "Tiano.h"
+#include EFI_ARCH_PROTOCOL_DEFINITION (Reset)
+
+EFI_GUID gEfiResetArchProtocolGuid = EFI_RESET_ARCH_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiResetArchProtocolGuid, "Reset", "Reset Arch Protocol");
diff --git a/EDK/Foundation/Core/Dxe/ArchProtocol/Reset/Reset.h b/EDK/Foundation/Core/Dxe/ArchProtocol/Reset/Reset.h
new file mode 100644
index 0000000..d26b661
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/ArchProtocol/Reset/Reset.h
@@ -0,0 +1,40 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Reset.h
+
+Abstract:
+
+ Reset Architectural Protocol as defined in the DXE CIS
+
+ Used to provide ResetSystem runtime services
+
+ The ResetSystem () EFI 1.0 service is added to the EFI system table and the
+ EFI_RESET_ARCH_PROTOCOL_GUID protocol is registered with a NULL pointer.
+
+ No CRC of the EFI system table is required, as it is done in the DXE core.
+
+--*/
+
+#ifndef _ARCH_PROTOCOL_RESET_H_
+#define _ARCH_PROTOCOL_RESET_H_
+
+//
+// Global ID for the Reset Architectural Protocol
+//
+#define EFI_RESET_ARCH_PROTOCOL_GUID \
+ { 0x27CFAC88, 0x46CC, 0x11d4, 0x9A, 0x38, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D }
+
+extern EFI_GUID gEfiResetArchProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Core/Dxe/ArchProtocol/Runtime/Runtime.c b/EDK/Foundation/Core/Dxe/ArchProtocol/Runtime/Runtime.c
new file mode 100644
index 0000000..4f58708
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/ArchProtocol/Runtime/Runtime.c
@@ -0,0 +1,29 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Runtime.c
+
+Abstract:
+
+ Runtime Architectural Protocol as defined in Tiano
+
+ This code is used to produce the EFI 1.0 runtime virtual switch over
+
+--*/
+
+#include "Tiano.h"
+#include EFI_ARCH_PROTOCOL_DEFINITION (Runtime)
+
+EFI_GUID gEfiRuntimeArchProtocolGuid = EFI_RUNTIME_ARCH_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiRuntimeArchProtocolGuid, "Runtime", "Runtime Arch Protocol");
diff --git a/EDK/Foundation/Core/Dxe/ArchProtocol/Runtime/Runtime.h b/EDK/Foundation/Core/Dxe/ArchProtocol/Runtime/Runtime.h
new file mode 100644
index 0000000..28f0b41
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/ArchProtocol/Runtime/Runtime.h
@@ -0,0 +1,114 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Runtime.h
+
+Abstract:
+
+ Runtime Architectural Protocol as defined in DXE CIS.
+
+
+ This code is used to produce the EFI runtime services that are callable
+ only in physical mode.
+
+ This driver must add SetVirtualAddressMap () and ConvertPointer () to
+ the EFI system table. This driver is not responcible for CRCing the
+ EFI system table.
+
+ This driver will add EFI_RUNTIME_ARCH_PROTOCOL_GUID protocol with a
+ pointer to the Runtime Arch Protocol instance structure. The protocol
+ member functions are used by the DXE core to export information needed
+ by this driver to produce the runtime transition of runtime drivers from
+ physical mode calling to virtual mode calling.
+
+--*/
+
+#ifndef _ARCH_PROTOCOL_RUNTIME_H_
+#define _ARCH_PROTOCOL_RUNTIME_H_
+
+#include "LinkedList.h"
+
+//
+// Global ID for the Runtime Architectural Protocol
+//
+#define EFI_RUNTIME_ARCH_PROTOCOL_GUID \
+ { 0xb7dfb4e1, 0x52f, 0x449f, 0x87, 0xbe, 0x98, 0x18, 0xfc, 0x91, 0xb7, 0x33 }
+
+EFI_FORWARD_DECLARATION (EFI_RUNTIME_ARCH_PROTOCOL);
+
+typedef struct _EFI_RUNTIME_IMAGE_ENTRY {
+ VOID *ImageBase;
+ UINT64 ImageSize;
+ VOID *RelocationData;
+ EFI_HANDLE Handle;
+ EFI_LIST_ENTRY Link;
+} EFI_RUNTIME_IMAGE_ENTRY;
+
+typedef struct _EFI_RUNTIME_EVENT_ENTRY {
+ UINT32 Type;
+ EFI_TPL NotifyTpl;
+ EFI_EVENT_NOTIFY NotifyFunction;
+ VOID *NotifyContext;
+ EFI_EVENT *Event;
+ EFI_LIST_ENTRY Link;
+} EFI_RUNTIME_EVENT_ENTRY;
+
+//
+// Interface stucture for the Runtime Architectural Protocol
+//
+typedef struct _EFI_RUNTIME_ARCH_PROTOCOL {
+ EFI_LIST_ENTRY ImageHead;
+ EFI_LIST_ENTRY EventHead;
+ UINTN MemoryDescriptorSize;
+ UINT32 MemoryDesciptorVersion;
+ UINTN MemoryMapSize;
+ EFI_MEMORY_DESCRIPTOR *MemoryMapPhysical;
+ EFI_MEMORY_DESCRIPTOR *MemoryMapVirtual;
+ BOOLEAN VirtualMode;
+ BOOLEAN AtRuntime;
+} EFI_RUNTIME_ARCH_PROTOCOL;
+/*++
+
+Protocol Description:
+
+ Allows the runtime functionality of the DXE Foundation to be contained in a
+ separate driver. It also provides hooks for the DXE Foundation to export
+ information that is needed at runtime. As such, this protocol allows the DXE
+ Foundation to manage runtime drivers and events. This protocol also implies
+ that the runtime services required to transition to virtual mode,
+ SetVirtualAddressMap() and ConvertPointer(), have been registered into the
+ EFI Runtime Table in the EFI System Partition. This protocol must be produced
+ by a runtime DXE driver and may only be consumed by the DXE Foundation.
+
+Parameters:
+
+ ImageHead - A list of type EFI_RUNTIME_IMAGE_ENTRY.
+ EventHead - A list of type EFI_RUNTIME_EVENT_ENTRY.
+ MemoryDescriptorSize - Size of a memory descriptor that is return by
+ GetMemoryMap().
+ MemoryDescriptorVersion - Version of a memory descriptor that is return by
+ GetMemoryMap().
+ MemoryMapSize - Size of the memory map in bytes contained in
+ MemoryMapPhysical and MemoryMapVirtual.
+ MemoryMapPhysical - Pointer to a runtime buffer that contains a copy of the
+ memory map returned via GetMemoryMap().
+ MemoryMapVirtual - Pointer to MemoryMapPhysical that is updated to virtual mode
+ after SetVirtualAddressMap().
+ VirtualMode - Boolean that is TRUE if SetVirtualAddressMap() has been called.
+ AtRuntime - Boolean that is TRUE if ExitBootServices () has been called.
+
+--*/
+
+extern EFI_GUID gEfiRuntimeArchProtocolGuid;
+
+#endif \ No newline at end of file
diff --git a/EDK/Foundation/Core/Dxe/ArchProtocol/Security/Security.c b/EDK/Foundation/Core/Dxe/ArchProtocol/Security/Security.c
new file mode 100644
index 0000000..0b84bd5
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/ArchProtocol/Security/Security.c
@@ -0,0 +1,28 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Security.c
+
+Abstract:
+
+ Security Architectural Protocol GUID as defined in DXE CIS
+
+--*/
+
+#include "Tiano.h"
+#include EFI_ARCH_PROTOCOL_DEFINITION(Security)
+
+EFI_GUID gEfiSecurityArchProtocolGuid = EFI_SECURITY_ARCH_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiSecurityArchProtocolGuid, "Security", "Security Arch Protocol");
+
diff --git a/EDK/Foundation/Core/Dxe/ArchProtocol/Security/Security.h b/EDK/Foundation/Core/Dxe/ArchProtocol/Security/Security.h
new file mode 100644
index 0000000..96ced0a
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/ArchProtocol/Security/Security.h
@@ -0,0 +1,146 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Security.h
+
+Abstract:
+
+ Security Architectural Protocol as defined in the DXE CIS
+
+ Used to provide Security services. Specifically, dependening upon the
+ authentication state of a discovered driver in a Firmware Volume, the
+ portable DXE Core Dispatcher will call into the Security Architectural
+ Protocol (SAP) with the authentication state of the driver.
+
+ This call-out allows for OEM-specific policy decisions to be made, such
+ as event logging for attested boots, locking flash in response to discovering
+ an unsigned driver or failed signature check, or other exception response.
+
+ The SAP can also change system behavior by having the DXE core put a driver
+ in the Schedule-On-Request (SOR) state. This will allow for later disposition
+ of the driver by platform agent, such as Platform BDS.
+
+--*/
+
+#ifndef _ARCH_PROTOCOL_SECURITY_H_
+#define _ARCH_PROTOCOL_SECURITY_H_
+
+//
+// Global ID for the Security Code Architectural Protocol
+//
+#define EFI_SECURITY_ARCH_PROTOCOL_GUID \
+ { 0xA46423E3, 0x4617, 0x49f1, 0xB9, 0xFF, 0xD1, 0xBF, 0xA9, 0x11, 0x58, 0x39 }
+
+EFI_FORWARD_DECLARATION (EFI_SECURITY_ARCH_PROTOCOL);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SECURITY_FILE_AUTHENTICATION_STATE) (
+ IN EFI_SECURITY_ARCH_PROTOCOL *This,
+ IN UINT32 AuthenticationStatus,
+ IN EFI_DEVICE_PATH_PROTOCOL *File
+ )
+/*++
+
+Routine Description:
+
+ The EFI_SECURITY_ARCH_PROTOCOL (SAP) is used to abstract platform-specific
+ policy from the DXE core response to an attempt to use a file that returns a
+ given status for the authentication check from the section extraction protocol.
+
+ The possible responses in a given SAP implementation may include locking
+ flash upon failure to authenticate, attestation logging for all signed drivers,
+ and other exception operations. The File parameter allows for possible logging
+ within the SAP of the driver.
+
+ If File is NULL, then EFI_INVALID_PARAMETER is returned.
+
+ If the file specified by File with an authentication status specified by
+ AuthenticationStatus is safe for the DXE Core to use, then EFI_SUCCESS is returned.
+
+ If the file specified by File with an authentication status specified by
+ AuthenticationStatus is not safe for the DXE Core to use under any circumstances,
+ then EFI_ACCESS_DENIED is returned.
+
+ If the file specified by File with an authentication status specified by
+ AuthenticationStatus is not safe for the DXE Core to use right now, but it
+ might be possible to use it at a future time, then EFI_SECURITY_VIOLATION is
+ returned.
+
+Arguments:
+
+ This - The EFI_SECURITY_ARCH_PROTOCOL instance.
+
+ AuthenticationStatus - This is the authentication type returned from the Section
+ Extraction protocol. See the Section Extraction Protocol
+ Specification for details on this type.
+
+ File - This is a pointer to the device path of the file that is
+ being dispatched. This will optionally be used for logging.
+
+Returns:
+
+ EFI_SUCCESS - The file specified by File did authenticate, and the
+ platform policy dictates that the DXE Core may use File.
+
+ EFI_INVALID_PARAMETER - Driver is NULL.
+
+ EFI_SECURITY_VIOLATION - The file specified by File did not authenticate, and
+ the platform policy dictates that File should be placed
+ in the untrusted state. A file may be promoted from
+ the untrusted to the trusted state at a future time
+ with a call to the Trust() DXE Service.
+
+ EFI_ACCESS_DENIED - The file specified by File did not authenticate, and
+ the platform policy dictates that File should not be
+ used for any purpose.
+
+--*/
+;
+
+//
+// Interface stucture for the Timer Architectural Protocol
+//
+typedef struct _EFI_SECURITY_ARCH_PROTOCOL {
+ EFI_SECURITY_FILE_AUTHENTICATION_STATE FileAuthenticationState;
+} EFI_SECURITY_ARCH_PROTOCOL;
+/*++
+
+ Protocol Description:
+
+ The EFI_SECURITY_ARCH_PROTOCOL is used to abstract platform-specific policy
+ from the DXE core. This includes locking flash upon failure to authenticate,
+ attestation logging, and other exception operations.
+
+ The driver that produces the EFI_SECURITY_ARCH_PROTOCOL may also optionally
+ install the EFI_SECURITY_POLICY_PROTOCOL_GUID onto a new handle with a NULL
+ interface. The existence of this GUID in the protocol database means that
+ the GUIDed Section Extraction Protocol should authenticate the contents of
+ an Authentication Section. The expectation is that the GUIDed Section
+ Extraction protocol will look for the existence of the EFI_SECURITY_POLICY_
+ PROTOCOL_GUID in the protocol database. If it exists, then the publication
+ thereof is taken as an injunction to attempt an authentication of any section
+ wrapped in an Authentication Section. See the Firmware File System
+ Specification for details on the GUIDed Section Extraction Protocol and
+ Authentication Sections.
+
+ Parameters:
+
+ FileAuthenticationState - This service is called upon fault with respect to
+ the authentication of a section of a file.
+
+--*/
+
+extern EFI_GUID gEfiSecurityArchProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Core/Dxe/ArchProtocol/StatusCode/StatusCode.c b/EDK/Foundation/Core/Dxe/ArchProtocol/StatusCode/StatusCode.c
new file mode 100644
index 0000000..1c0890c
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/ArchProtocol/StatusCode/StatusCode.c
@@ -0,0 +1,29 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ StatusCode.c
+
+Abstract:
+
+ Status code Architectural Protocol as defined in Tiano
+
+ This code abstracts Status Code reporting.
+
+--*/
+
+#include "Tiano.h"
+#include EFI_ARCH_PROTOCOL_DEFINITION (StatusCode)
+
+EFI_GUID gEfiStatusCodeRuntimeProtocolGuid = EFI_STATUS_CODE_RUNTIME_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiStatusCodeRuntimeProtocolGuid, "Status Code", "Status Code Arch Protocol"); \ No newline at end of file
diff --git a/EDK/Foundation/Core/Dxe/ArchProtocol/StatusCode/StatusCode.h b/EDK/Foundation/Core/Dxe/ArchProtocol/StatusCode/StatusCode.h
new file mode 100644
index 0000000..3346d87
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/ArchProtocol/StatusCode/StatusCode.h
@@ -0,0 +1,100 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ StatusCode.h
+
+Abstract:
+
+ Status code Architectural Protocol as defined in the DXE CIS
+
+ This code abstracts Status Code reporting.
+
+ The StatusCode () Tiano service is added to the EFI system table and the
+ EFI_STATUS_CODE_ARCH_PROTOCOL_GUID protocol is registered with a NULL
+ pointer.
+
+ No CRC of the EFI system table is required, as it is done in the DXE core.
+
+--*/
+
+#ifndef __STATUS_CODE_RUNTIME_PROTOCOL_H__
+#define __STATUS_CODE_RUNTIME_PROTOCOL_H__
+
+#define EFI_STATUS_CODE_RUNTIME_PROTOCOL_GUID \
+ { 0xd2b2b828, 0x826, 0x48a7, 0xb3, 0xdf, 0x98, 0x3c, 0x0, 0x60, 0x24, 0xf0}
+
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+typedef
+EFI_STATUS
+(EFIAPI *EFI_REPORT_STATUS_CODE) (
+ IN EFI_STATUS_CODE_TYPE Type,
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN UINT32 Instance,
+ IN EFI_GUID *CallerId OPTIONAL,
+ IN EFI_STATUS_CODE_DATA *Data OPTIONAL
+ )
+/*++
+Routine Description:
+
+ Provides an interface that a software module can call to report a status code.
+
+Arguments:
+
+ Type - Indicates the type of status code being reported.
+
+ Value - Describes the current status of a hardware or software entity.
+ This included information about the class and subclass that is
+ used to classify the entity as well as an operation.
+
+ Instance - The enumeration of a hardware or software entity within
+ the system. Valid instance numbers start with 1.
+
+ CallerId - This optional parameter may be used to identify the caller.
+ This parameter allows the status code driver to apply different
+ rules to different callers.
+
+ Data - This optional parameter may be used to pass additional data.
+
+Returns:
+
+ EFI_SUCCESS - The function completed successfully
+
+ EFI_DEVICE_ERROR - The function should not be completed due to a device error.
+
+--*/
+;
+#endif
+
+//
+// Interface stucture for the STATUS CODE Architectural Protocol
+//
+typedef struct _EFI_STATUS_CODE_PROTOCOL {
+ EFI_REPORT_STATUS_CODE ReportStatusCode;
+} EFI_STATUS_CODE_PROTOCOL;
+
+/*++
+// Protocol Description:
+//
+// Provides the service required to report a status code to the platform firmware.
+// This protocol must be produced by a runtime DXE driver and may be consumed
+// only by the DXE Foundation.
+//
+// Parameter:
+//
+// ReportStatusCode - Emit a status code.
+--*/
+
+
+extern EFI_GUID gEfiStatusCodeRuntimeProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Core/Dxe/ArchProtocol/Timer/Timer.c b/EDK/Foundation/Core/Dxe/ArchProtocol/Timer/Timer.c
new file mode 100644
index 0000000..b2946f8
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/ArchProtocol/Timer/Timer.c
@@ -0,0 +1,27 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Timer.c
+
+Abstract:
+
+ Timer Architectural Protocol GUID as defined in Tiano
+
+--*/
+
+#include "Tiano.h"
+#include EFI_ARCH_PROTOCOL_DEFINITION (Timer)
+
+EFI_GUID gEfiTimerArchProtocolGuid = EFI_TIMER_ARCH_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiTimerArchProtocolGuid, "Timer", "Timer Arch Protocol");
diff --git a/EDK/Foundation/Core/Dxe/ArchProtocol/Timer/Timer.h b/EDK/Foundation/Core/Dxe/ArchProtocol/Timer/Timer.h
new file mode 100644
index 0000000..2e5c80d
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/ArchProtocol/Timer/Timer.h
@@ -0,0 +1,260 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Timer.h
+
+Abstract:
+
+ Timer Architectural Protocol as defined in the DXE CIS
+
+ This code is used to provide the timer tick for the DXE core.
+
+--*/
+
+#ifndef _ARCH_PROTOCOL_TIMER_H_
+#define _ARCH_PROTOCOL_TIMER_H_
+
+//
+// Global ID for the Timer Architectural Protocol
+//
+#define EFI_TIMER_ARCH_PROTOCOL_GUID \
+ { 0x26baccb3, 0x6f42, 0x11d4, 0xbc, 0xe7, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 }
+
+//
+// Declare forward reference for the Timer Architectural Protocol
+//
+EFI_FORWARD_DECLARATION (EFI_TIMER_ARCH_PROTOCOL);
+
+typedef
+VOID
+(EFIAPI *EFI_TIMER_NOTIFY) (
+ IN UINT64 Time
+ );
+/*++
+
+Routine Description:
+
+ This function of this type is called when a timer interrupt fires. This
+ function executes at TPL_HIGH_LEVEL. The DXE Core will register a funtion
+ of tyis type to be called for the timer interrupt, so it can know how much
+ time has passed. This information is used to signal timer based events.
+
+Arguments:
+
+ Time - Time since the last timer interrupt in 100 ns units. This will
+ typically be TimerPeriod, but if a timer interrupt is missed, and the
+ EFI_TIMER_ARCH_PROTOCOL driver can detect missed interrupts, then Time
+ will contain the actual amount of time since the last interrupt.
+
+Returns:
+
+ None.
+
+--*/
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TIMER_REGISTER_HANDLER) (
+ IN EFI_TIMER_ARCH_PROTOCOL *This,
+ IN EFI_TIMER_NOTIFY NotifyFunction
+);
+/*++
+
+Routine Description:
+
+ This function registers the handler NotifyFunction so it is called every time
+ the timer interrupt fires. It also passes the amount of time since the last
+ handler call to the NotifyFunction. If NotifyFunction is NULL, then the
+ handler is unregistered. If the handler is registered, then EFI_SUCCESS is
+ returned. If the CPU does not support registering a timer interrupt handler,
+ then EFI_UNSUPPORTED is returned. If an attempt is made to register a handler
+ when a handler is already registered, then EFI_ALREADY_STARTED is returned.
+ If an attempt is made to unregister a handler when a handler is not registered,
+ then EFI_INVALID_PARAMETER is returned. If an error occurs attempting to
+ register the NotifyFunction with the timer interrupt, then EFI_DEVICE_ERROR
+ is returned.
+
+Arguments:
+
+ This - The EFI_TIMER_ARCH_PROTOCOL instance.
+
+ NotifyFunction - The function to call when a timer interrupt fires. This
+ function executes at TPL_HIGH_LEVEL. The DXE Core will
+ register a handler for the timer interrupt, so it can know
+ how much time has passed. This information is used to
+ signal timer based events. NULL will unregister the handler.
+
+Returns:
+
+ EFI_SUCCESS - The timer handler was registered.
+
+ EFI_UNSUPPORTED - The platform does not support timer interrupts.
+
+ EFI_ALREADY_STARTED - NotifyFunction is not NULL, and a handler is already
+ registered.
+
+ EFI_INVALID_PARAMETER - NotifyFunction is NULL, and a handler was not
+ previously registered.
+
+ EFI_DEVICE_ERROR - The timer handler could not be registered.
+
+--*/
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TIMER_SET_TIMER_PERIOD) (
+ IN EFI_TIMER_ARCH_PROTOCOL *This,
+ IN UINT64 TimerPeriod
+ );
+/*++
+
+Routine Description:
+
+ This function adjusts the period of timer interrupts to the value specified
+ by TimerPeriod. If the timer period is updated, then the selected timer
+ period is stored in EFI_TIMER.TimerPeriod, and EFI_SUCCESS is returned. If
+ the timer hardware is not programmable, then EFI_UNSUPPORTED is returned.
+ If an error occurs while attempting to update the timer period, then the
+ timer hardware will be put back in its state prior to this call, and
+ EFI_DEVICE_ERROR is returned. If TimerPeriod is 0, then the timer interrupt
+ is disabled. This is not the same as disabling the CPU's interrupts.
+ Instead, it must either turn off the timer hardware, or it must adjust the
+ interrupt controller so that a CPU interrupt is not generated when the timer
+ interrupt fires.
+
+Arguments:
+
+ This - The EFI_TIMER_ARCH_PROTOCOL instance.
+
+ TimerPeriod - The rate to program the timer interrupt in 100 nS units. If
+ the timer hardware is not programmable, then EFI_UNSUPPORTED is
+ returned. If the timer is programmable, then the timer period
+ will be rounded up to the nearest timer period that is supported
+ by the timer hardware. If TimerPeriod is set to 0, then the
+ timer interrupts will be disabled.
+
+Returns:
+
+ EFI_SUCCESS - The timer period was changed.
+
+ EFI_UNSUPPORTED - The platform cannot change the period of the timer interrupt.
+
+ EFI_DEVICE_ERROR - The timer period could not be changed due to a device error.
+
+--*/
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TIMER_GET_TIMER_PERIOD) (
+ IN EFI_TIMER_ARCH_PROTOCOL *This,
+ OUT UINT64 *TimerPeriod
+ );
+/*++
+
+Routine Description:
+
+ This function retrieves the period of timer interrupts in 100 ns units,
+ returns that value in TimerPeriod, and returns EFI_SUCCESS. If TimerPeriod
+ is NULL, then EFI_INVALID_PARAMETER is returned. If a TimerPeriod of 0 is
+ returned, then the timer is currently disabled.
+
+Arguments:
+
+ This - The EFI_TIMER_ARCH_PROTOCOL instance.
+
+ TimerPeriod - A pointer to the timer period to retrieve in 100 ns units. If
+ 0 is returned, then the timer is currently disabled.
+
+Returns:
+
+ EFI_SUCCESS - The timer period was returned in TimerPeriod.
+
+ EFI_INVALID_PARAMETER - TimerPeriod is NULL.
+
+--*/
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TIMER_GENERATE_SOFT_INTERRUPT) (
+ IN EFI_TIMER_ARCH_PROTOCOL *This
+ );
+/*++
+
+Routine Description:
+
+ This function generates a soft timer interrupt. If the platform does not support soft
+ timer interrupts, then EFI_UNSUPPORTED is returned. Otherwise, EFI_SUCCESS is returned.
+ If a handler has been registered through the EFI_TIMER_ARCH_PROTOCOL.RegisterHandler()
+ service, then a soft timer interrupt will be generated. If the timer interrupt is
+ enabled when this service is called, then the registered handler will be invoked. The
+ registered handler should not be able to distinguish a hardware-generated timer
+ interrupt from a software-generated timer interrupt.
+
+Arguments:
+
+ This - The EFI_TIMER_ARCH_PROTOCOL instance.
+
+Returns:
+
+ EFI_SUCCESS - The soft timer interrupt was generated.
+
+ EFI_UNSUPPORTEDT - The platform does not support the generation of soft timer interrupts.
+
+--*/
+
+//
+// Interface stucture for the Timer Architectural Protocol
+//
+typedef struct _EFI_TIMER_ARCH_PROTOCOL {
+ EFI_TIMER_REGISTER_HANDLER RegisterHandler;
+ EFI_TIMER_SET_TIMER_PERIOD SetTimerPeriod;
+ EFI_TIMER_GET_TIMER_PERIOD GetTimerPeriod;
+ EFI_TIMER_GENERATE_SOFT_INTERRUPT GenerateSoftInterrupt;
+} EFI_TIMER_ARCH_PROTOCOL;
+
+/*++
+
+ Protocol Description:
+ This protocol provides the services to initialize a periodic timer
+ interrupt, and to register a handler that is called each time the timer
+ interrupt fires. It may also provide a service to adjust the rate of the
+ periodic timer interrupt. When a timer interrupt occurs, the handler is
+ passed the amount of time that has passed since the previous timer
+ interrupt.
+
+ Parameters:
+
+ RegisterHandler - Registers a handler that will be called each time the
+ timer interrupt fires. TimerPeriod defines the minimum
+ time between timer interrupts, so TimerPeriod will also
+ be the minimum time between calls to the registered
+ handler.
+
+ SetTimerPeriod - Sets the period of the timer interrupt in 100 nS units.
+ This function is optional, and may return EFI_UNSUPPORTED.
+ If this function is supported, then the timer period will
+ be rounded up to the nearest supported timer period.
+
+ GetTimerPeriod - Retrieves the period of the timer interrupt in 100 nS units.
+
+ GenerateSoftInterrupt -
+ Generates a soft timer interrupt that simulates the firing of
+ the timer interrupt. This service can be used to invoke the
+ registered handler if the timer interrupt has been masked for
+ a period of time.
+
+--*/
+
+extern EFI_GUID gEfiTimerArchProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Core/Dxe/ArchProtocol/Variable/Variable.c b/EDK/Foundation/Core/Dxe/ArchProtocol/Variable/Variable.c
new file mode 100644
index 0000000..5ff0e9b
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/ArchProtocol/Variable/Variable.c
@@ -0,0 +1,29 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Variable.c
+
+Abstract:
+
+ Variable Architectural Protocol as defined in Tiano
+
+ This code is used to produce the EFI 1.0 runtime variable services
+
+--*/
+
+#include "Tiano.h"
+#include EFI_ARCH_PROTOCOL_DEFINITION (Variable)
+
+EFI_GUID gEfiVariableArchProtocolGuid = EFI_VARIABLE_ARCH_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiVariableArchProtocolGuid, "Variable", "Variable Arch Protocol");
diff --git a/EDK/Foundation/Core/Dxe/ArchProtocol/Variable/Variable.h b/EDK/Foundation/Core/Dxe/ArchProtocol/Variable/Variable.h
new file mode 100644
index 0000000..8d9d4df
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/ArchProtocol/Variable/Variable.h
@@ -0,0 +1,41 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Variable.h
+
+Abstract:
+
+ Variable Architectural Protocol as defined in the DXE CIS
+
+ This code is used to produce the EFI 1.0 runtime variable services
+
+ The GetVariable (), GetNextVariableName (), and SetVariable () EFI 1.0
+ services are added to the EFI system table and the
+ EFI_VARIABLE_ARCH_PROTOCOL_GUID protocol is registered with a NULL pointer.
+
+ No CRC of the EFI system table is required, as it is done in the DXE core.
+
+--*/
+
+#ifndef _ARCH_PROTOCOL_VARIABLE_ARCH_H_
+#define _ARCH_PROTOCOL_VARIABLE_ARCH_H_
+
+//
+// Global ID for the Variable Architectural Protocol
+//
+#define EFI_VARIABLE_ARCH_PROTOCOL_GUID \
+ { 0x1e5668e2, 0x8481, 0x11d4, 0xbc, 0xf1, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 }
+
+extern EFI_GUID gEfiVariableArchProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Core/Dxe/ArchProtocol/VariableWrite/VariableWrite.c b/EDK/Foundation/Core/Dxe/ArchProtocol/VariableWrite/VariableWrite.c
new file mode 100644
index 0000000..7daf743
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/ArchProtocol/VariableWrite/VariableWrite.c
@@ -0,0 +1,30 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ VariableWrite.c
+
+Abstract:
+
+ Variable Write Architectural Protocol as defined in DXE CIS
+
+ This code is used to indicate the EFI 1.0 runtime variable services
+ support writting to variables.
+
+--*/
+
+#include "Tiano.h"
+#include EFI_ARCH_PROTOCOL_DEFINITION (VariableWrite)
+
+EFI_GUID gEfiVariableWriteArchProtocolGuid = EFI_VARIABLE_WRITE_ARCH_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiVariableWriteArchProtocolGuid, "VariableWrite", "Variable Write Arch Protocol");
diff --git a/EDK/Foundation/Core/Dxe/ArchProtocol/VariableWrite/VariableWrite.h b/EDK/Foundation/Core/Dxe/ArchProtocol/VariableWrite/VariableWrite.h
new file mode 100644
index 0000000..7629b09
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/ArchProtocol/VariableWrite/VariableWrite.h
@@ -0,0 +1,41 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ VariableWrite.h
+
+Abstract:
+
+ Variable Write Architectural Protocol as defined in the DXE CIS
+
+ This code is used to produce the EFI 1.0 runtime variable services
+
+ The GetVariable (), GetNextVariableName (), and SetVariable () EFI 1.0
+ services are added to the EFI system table and the
+ EFI_VARIABLE_WRITE_ARCH_PROTOCOL_GUID protocol is registered with a NULL pointer.
+
+ No CRC of the EFI system table is required, as it is done in the DXE core.
+
+--*/
+
+#ifndef _ARCH_PROTOCOL_VARIABLE_WRITE_ARCH_H_
+#define _ARCH_PROTOCOL_VARIABLE_WRITE_ARCH_H_
+
+//
+// Global ID for the Variable Write Architectural Protocol
+//
+#define EFI_VARIABLE_WRITE_ARCH_PROTOCOL_GUID \
+ { 0x6441f818, 0x6362, 0x4e44, 0xb5, 0x70, 0x7d, 0xba, 0x31, 0xdd, 0x24, 0x53 }
+
+extern EFI_GUID gEfiVariableWriteArchProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Core/Dxe/ArchProtocol/WatchdogTimer/WatchdogTimer.c b/EDK/Foundation/Core/Dxe/ArchProtocol/WatchdogTimer/WatchdogTimer.c
new file mode 100644
index 0000000..d6ee113
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/ArchProtocol/WatchdogTimer/WatchdogTimer.c
@@ -0,0 +1,27 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ WatchdogTimer.c
+
+Abstract:
+
+ Watchdog Timer Architectural Protocol GUID as defined in Tiano
+
+--*/
+
+#include "Tiano.h"
+#include EFI_ARCH_PROTOCOL_DEFINITION (WatchdogTimer)
+
+EFI_GUID gEfiWatchdogTimerArchProtocolGuid = EFI_WATCHDOG_TIMER_ARCH_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiWatchdogTimerArchProtocolGuid, "Watchdog Timer", "Watchdog Timer Arch Protocol");
diff --git a/EDK/Foundation/Core/Dxe/ArchProtocol/WatchdogTimer/WatchdogTimer.h b/EDK/Foundation/Core/Dxe/ArchProtocol/WatchdogTimer/WatchdogTimer.h
new file mode 100644
index 0000000..6586594
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/ArchProtocol/WatchdogTimer/WatchdogTimer.h
@@ -0,0 +1,206 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ WatchdogTimer.h
+
+Abstract:
+
+ Watchdog Timer Architectural Protocol as defined in the DXE CIS
+
+ Used to provide system watchdog timer services
+
+--*/
+
+#ifndef _ARCH_PROTOCOL_WATCHDOG_TIMER_H_
+#define _ARCH_PROTOCOL_WATCHDOG_TIMER_H_
+
+//
+// Global ID for the Watchdog Timer Architectural Protocol
+//
+#define EFI_WATCHDOG_TIMER_ARCH_PROTOCOL_GUID \
+ { 0x665E3FF5, 0x46CC, 0x11d4, 0x9A, 0x38, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D }
+
+//
+// Declare forward reference for the Timer Architectural Protocol
+//
+EFI_FORWARD_DECLARATION (EFI_WATCHDOG_TIMER_ARCH_PROTOCOL);
+
+typedef
+VOID
+(EFIAPI *EFI_WATCHDOG_TIMER_NOTIFY) (
+ IN UINT64 Time
+ );
+/*++
+
+Routine Description:
+
+ A function of this type is called when the watchdog timer fires if a
+ handler has been registered.
+
+Arguments:
+
+ Time - The time in 100 ns units that has passed since the watchdog
+ timer was armed. For the notify function to be called, this
+ must be greater than TimerPeriod.
+
+Returns:
+
+ None.
+
+--*/
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_WATCHDOG_TIMER_REGISTER_HANDLER) (
+ IN EFI_WATCHDOG_TIMER_ARCH_PROTOCOL *This,
+ IN EFI_WATCHDOG_TIMER_NOTIFY NotifyFunction
+ );
+/*++
+
+Routine Description:
+
+ This function registers a handler that is to be invoked when the watchdog
+ timer fires. By default, the EFI_WATCHDOG_TIMER protocol will call the
+ Runtime Service ResetSystem() when the watchdog timer fires. If a
+ NotifyFunction is registered, then the NotifyFunction will be called before
+ the Runtime Service ResetSystem() is called. If NotifyFunction is NULL, then
+ the watchdog handler is unregistered. If a watchdog handler is registered,
+ then EFI_SUCCESS is returned. If an attempt is made to register a handler
+ when a handler is already registered, then EFI_ALREADY_STARTED is returned.
+ If an attempt is made to uninstall a handler when a handler is not installed,
+ then return EFI_INVALID_PARAMETER.
+
+Arguments:
+
+ This - The EFI_WATCHDOG_TIMER_ARCH_PROTOCOL instance.
+
+ NotifyFunction - The function to call when the watchdog timer fires. If this
+ is NULL, then the handler will be unregistered.
+
+Returns:
+
+ EFI_SUCCESS - The watchdog timer handler was registered or
+ unregistered.
+
+ EFI_ALREADY_STARTED - NotifyFunction is not NULL, and a handler is already
+ registered.
+
+ EFI_INVALID_PARAMETER - NotifyFunction is NULL, and a handler was not
+ previously registered.
+
+--*/
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_WATCHDOG_TIMER_SET_TIMER_PERIOD) (
+ IN EFI_WATCHDOG_TIMER_ARCH_PROTOCOL *This,
+ IN UINT64 TimerPeriod
+ );
+/*++
+
+Routine Description:
+
+ This function sets the amount of time to wait before firing the watchdog
+ timer to TimerPeriod 100 nS units. If TimerPeriod is 0, then the watchdog
+ timer is disabled.
+
+Arguments:
+
+ This - The EFI_WATCHDOG_TIMER_ARCH_PROTOCOL instance.
+
+ TimerPeriod - The amount of time in 100 nS units to wait before the watchdog
+ timer is fired. If TimerPeriod is zero, then the watchdog
+ timer is disabled.
+
+Returns:
+
+ EFI_SUCCESS - The watchdog timer has been programmed to fire in Time
+ 100 nS units.
+
+ EFI_DEVICE_ERROR - A watchdog timer could not be programmed due to a device
+ error.
+
+--*/
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_WATCHDOG_TIMER_GET_TIMER_PERIOD) (
+ IN EFI_WATCHDOG_TIMER_ARCH_PROTOCOL *This,
+ OUT UINT64 *TimerPeriod
+ );
+/*++
+
+Routine Description:
+
+ This function retrieves the amount of time the system will wait before firing
+ the watchdog timer. This period is returned in TimerPeriod, and EFI_SUCCESS
+ is returned. If TimerPeriod is NULL, then EFI_INVALID_PARAMETER is returned.
+
+Arguments:
+
+ This - The EFI_WATCHDOG_TIMER_ARCH_PROTOCOL instance.
+
+ TimerPeriod - A pointer to the amount of time in 100 nS units that the system
+ will wait before the watchdog timer is fired. If TimerPeriod of
+ zero is returned, then the watchdog timer is disabled.
+
+Returns:
+
+ EFI_SUCCESS - The amount of time that the system will wait before
+ firing the watchdog timer was returned in TimerPeriod.
+
+ EFI_INVALID_PARAMETER - TimerPeriod is NULL.
+
+--*/
+
+//
+// Interface stucture for the Watchdog Timer Architectural Protocol
+//
+typedef struct _EFI_WATCHDOG_TIMER_ARCH_PROTOCOL {
+ EFI_WATCHDOG_TIMER_REGISTER_HANDLER RegisterHandler;
+ EFI_WATCHDOG_TIMER_SET_TIMER_PERIOD SetTimerPeriod;
+ EFI_WATCHDOG_TIMER_GET_TIMER_PERIOD GetTimerPeriod;
+} EFI_WATCHDOG_TIMER_ARCH_PROTOCOL;
+
+/*++
+
+ Protocol Description:
+ This protocol provides the services required to implement the Boot Service
+ SetWatchdogTimer(). It provides a service to set the amount of time to wait
+ before firing the watchdog timer, and it also provides a service to register
+ a handler that is invoked when the watchdog timer fires. This protocol can
+ implement the watchdog timer by using the event and timer Boot Services, or
+ it can make use of custom hardware. When the watchdog timer fires, control
+ will be passed to a handler if one has been registered. If no handler has
+ been registered, or the registered handler returns, then the system will be
+ reset by calling the Runtime Service ResetSystem().
+
+ Parameters:
+
+ RegisterHandler - Registers a handler that is invoked when the watchdog
+ timer fires.
+
+ SetTimerPeriod - Sets the amount of time in 100 ns units to wait before the
+ watchdog timer is fired. If this function is supported,
+ then the watchdog timer period will be rounded up to the
+ nearest supported watchdog timer period.
+
+ GetTimerPeriod - Retrieves the amount of time in 100 ns units that the
+ system will wait before the watchdog timer is fired.
+
+--*/
+
+extern EFI_GUID gEfiWatchdogTimerArchProtocolGuid;
+
+#endif
+
diff --git a/EDK/Foundation/Core/Dxe/Dispatcher/Dispatcher.c b/EDK/Foundation/Core/Dxe/Dispatcher/Dispatcher.c
new file mode 100644
index 0000000..fa23df7
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/Dispatcher/Dispatcher.c
@@ -0,0 +1,1203 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Dispatcher.c
+
+Abstract:
+
+ Tiano DXE Dispatcher.
+
+ Step #1 - When a FV protocol is added to the system every driver in the FV
+ is added to the mDiscoveredList. The SOR, Before, and After Depex are
+ pre-processed as drivers are added to the mDiscoveredList. If an Apriori
+ file exists in the FV those drivers are addeded to the
+ mScheduledQueue. The mFvHandleList is used to make sure a
+ FV is only processed once.
+
+ Step #2 - Dispatch. Remove driver from the mScheduledQueue and load and
+ start it. After mScheduledQueue is drained check the
+ mDiscoveredList to see if any item has a Depex that is ready to
+ be placed on the mScheduledQueue.
+
+ Step #3 - Adding to the mScheduledQueue requires that you process Before
+ and After dependencies. This is done recursively as the call to add
+ to the mScheduledQueue checks for Before and recursively adds
+ all Befores. It then addes the item that was passed in and then
+ processess the After dependecies by recursively calling the routine.
+
+ Dispatcher Rules:
+ The rules for the dispatcher are in chapter 10 of the DXE CIS. Figure 10-3
+ is the state diagram for the DXE dispatcher
+
+ Depex - Dependency Expresion.
+ SOR - Schedule On Request - Don't schedule if this bit is set.
+
+--*/
+
+#include "Tiano.h"
+#include "DxeCore.h"
+#include "FwVolBlock.h"
+#include EFI_GUID_DEFINITION (Apriori)
+
+//
+// The Driver List contains one copy of every driver that has been discovered.
+// Items are never removed from the driver list. List of EFI_CORE_DRIVER_ENTRY
+//
+EFI_LIST_ENTRY mDiscoveredList = INITIALIZE_LIST_HEAD_VARIABLE (mDiscoveredList);
+
+//
+// Queue of drivers that are ready to dispatch. This queue is a subset of the
+// mDiscoveredList.list of EFI_CORE_DRIVER_ENTRY.
+//
+EFI_LIST_ENTRY mScheduledQueue = INITIALIZE_LIST_HEAD_VARIABLE (mScheduledQueue);
+
+//
+// List of handles who's Fv's have been parsed and added to the mFwDriverList.
+//
+EFI_LIST_ENTRY mFvHandleList = INITIALIZE_LIST_HEAD_VARIABLE (mFvHandleList); // list of KNOWN_HANDLE
+
+//
+// Lock for mDiscoveredList, mScheduledQueue, mDispatcherRunning.
+//
+EFI_LOCK mDispatcherLock = EFI_INITIALIZE_LOCK_VARIABLE (EFI_TPL_HIGH_LEVEL);
+
+
+//
+// Flag for the DXE Dispacher. TRUE if dispatcher is execuing.
+//
+BOOLEAN mDispatcherRunning = FALSE;
+
+//
+// Module globals to manage the FwVol registration notification event
+//
+EFI_EVENT mFwVolEvent;
+VOID *mFwVolEventRegistration;
+
+//
+// List of file types supported by dispatcher
+//
+static EFI_FV_FILETYPE mDxeFileTypes[] = {
+ EFI_FV_FILETYPE_DRIVER,
+ EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER,
+ EFI_FV_FILETYPE_DXE_CORE,
+ EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE
+};
+
+typedef struct {
+ MEDIA_FW_VOL_FILEPATH_DEVICE_PATH File;
+ EFI_DEVICE_PATH_PROTOCOL End;
+} FV_FILEPATH_DEVICE_PATH;
+
+FV_FILEPATH_DEVICE_PATH mFvDevicePath;
+//
+// Function Prototypes
+//
+VOID
+CoreInsertOnScheduledQueueWhileProcessingBeforeAndAfter (
+ IN EFI_CORE_DRIVER_ENTRY *InsertedDriverEntry
+ );
+
+VOID
+EFIAPI
+CoreFwVolEventProtocolNotify (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ );
+
+EFI_DEVICE_PATH_PROTOCOL *
+CoreFvToDevicePath (
+ IN EFI_FIRMWARE_VOLUME_PROTOCOL *Fv,
+ IN EFI_HANDLE FvHandle,
+ IN EFI_GUID *DriverName
+ );
+
+STATIC
+EFI_STATUS
+CoreAddToDriverList (
+ IN EFI_FIRMWARE_VOLUME_PROTOCOL *Fv,
+ IN EFI_HANDLE FvHandle,
+ IN EFI_GUID *DriverName
+ );
+
+STATIC
+EFI_STATUS
+CoreProcessFvImageFile (
+ IN EFI_FIRMWARE_VOLUME_PROTOCOL *Fv,
+ IN EFI_HANDLE FvHandle,
+ IN EFI_GUID *DriverName
+ );
+
+
+VOID
+CoreAcquireDispatcherLock (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Enter critical section by gaining lock on mDispatcherLock
+
+Arguments:
+
+ None
+
+Returns:
+
+ None
+
+--*/
+
+{
+ CoreAcquireLock (&mDispatcherLock);
+}
+
+VOID
+CoreReleaseDispatcherLock (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Exit critical section by releasing lock on mDispatcherLock
+
+Arguments:
+
+ None
+
+Returns:
+
+ None
+
+--*/
+{
+ CoreReleaseLock (&mDispatcherLock);
+}
+
+
+EFI_STATUS
+CoreGetDepexSectionAndPreProccess (
+ IN EFI_CORE_DRIVER_ENTRY *DriverEntry
+ )
+/*++
+
+Routine Description:
+
+ Read Depex and pre-process the Depex for Before and After. If Section Extraction
+ protocol returns an error via ReadSection defer the reading of the Depex.
+
+Arguments:
+
+ DriverEntry - Driver to work on.
+
+Returns:
+
+ EFI_SUCCESS - Depex read and preprossesed
+
+ EFI_PROTOCOL_ERROR - The section extraction protocol returned an error and
+ Depex reading needs to be retried.
+
+ Other Error - DEPEX not found.
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_SECTION_TYPE SectionType;
+ UINT32 AuthenticationStatus;
+ EFI_FIRMWARE_VOLUME_PROTOCOL *Fv;
+
+
+ Fv = DriverEntry->Fv;
+
+ //
+ // Grab Depex info, it will never be free'ed.
+ //
+ SectionType = EFI_SECTION_DXE_DEPEX;
+ Status = Fv->ReadSection (
+ DriverEntry->Fv,
+ &DriverEntry->FileName,
+ SectionType,
+ 0,
+ &DriverEntry->Depex,
+ (UINTN *)&DriverEntry->DepexSize,
+ &AuthenticationStatus
+ );
+ if (EFI_ERROR (Status)) {
+ if (Status == EFI_PROTOCOL_ERROR) {
+ //
+ // The section extraction protocol failed so set protocol error flag
+ //
+ DriverEntry->DepexProtocolError = TRUE;
+ } else {
+ //
+ // If no Depex assume EFI 1.1 driver model
+ //
+ DriverEntry->Depex = NULL;
+ DriverEntry->Dependent = TRUE;
+ DriverEntry->DepexProtocolError = FALSE;
+ }
+ } else {
+ //
+ // Set Before, After, and Unrequested state information based on Depex
+ // Driver will be put in Dependent or Unrequested state
+ //
+ CorePreProcessDepex (DriverEntry);
+ DriverEntry->DepexProtocolError = FALSE;
+ }
+
+ return Status;
+}
+
+EFI_DXESERVICE
+EFI_STATUS
+EFIAPI
+CoreSchedule (
+ IN EFI_HANDLE FirmwareVolumeHandle,
+ IN EFI_GUID *DriverName
+ )
+/*++
+
+Routine Description:
+
+ Check every driver and locate a matching one. If the driver is found, the Unrequested
+ state flag is cleared.
+
+Arguments:
+
+ FirmwareVolumeHandle - The handle of the Firmware Volume that contains the firmware
+ file specified by DriverName.
+
+ DriverName - The Driver name to put in the Dependent state.
+
+Returns:
+
+ EFI_SUCCESS - The DriverName was found and it's SOR bit was cleared
+
+ EFI_NOT_FOUND - The DriverName does not exist or it's SOR bit was not set.
+
+--*/
+{
+ EFI_LIST_ENTRY *Link;
+ EFI_CORE_DRIVER_ENTRY *DriverEntry;
+
+ //
+ // Check every driver
+ //
+ for (Link = mDiscoveredList.ForwardLink; Link != &mDiscoveredList; Link = Link->ForwardLink) {
+ DriverEntry = CR(Link, EFI_CORE_DRIVER_ENTRY, Link, EFI_CORE_DRIVER_ENTRY_SIGNATURE);
+ if (DriverEntry->FvHandle == FirmwareVolumeHandle &&
+ DriverEntry->Unrequested &&
+ EfiCompareGuid (DriverName, &DriverEntry->FileName)) {
+ //
+ // Move the driver from the Unrequested to the Dependent state
+ //
+ CoreAcquireDispatcherLock ();
+ DriverEntry->Unrequested = FALSE;
+ DriverEntry->Dependent = TRUE;
+ CoreReleaseDispatcherLock ();
+
+ return EFI_SUCCESS;
+ }
+ }
+ return EFI_NOT_FOUND;
+}
+
+
+EFI_DXESERVICE
+EFI_STATUS
+EFIAPI
+CoreTrust (
+ IN EFI_HANDLE FirmwareVolumeHandle,
+ IN EFI_GUID *DriverName
+ )
+/*++
+
+Routine Description:
+
+ Convert a driver from the Untrused back to the Scheduled state
+
+Arguments:
+
+ FirmwareVolumeHandle - The handle of the Firmware Volume that contains the firmware
+ file specified by DriverName.
+
+ DriverName - The Driver name to put in the Scheduled state
+
+Returns:
+
+ EFI_SUCCESS - The file was found in the untrusted state, and it was promoted
+ to the trusted state.
+
+ EFI_NOT_FOUND - The file was not found in the untrusted state.
+
+--*/
+{
+ EFI_LIST_ENTRY *Link;
+ EFI_CORE_DRIVER_ENTRY *DriverEntry;
+
+ //
+ // Check every driver
+ //
+ for (Link = mDiscoveredList.ForwardLink; Link != &mDiscoveredList; Link = Link->ForwardLink) {
+ DriverEntry = CR(Link, EFI_CORE_DRIVER_ENTRY, Link, EFI_CORE_DRIVER_ENTRY_SIGNATURE);
+ if (DriverEntry->FvHandle == FirmwareVolumeHandle &&
+ DriverEntry->Untrusted &&
+ EfiCompareGuid (DriverName, &DriverEntry->FileName)) {
+ //
+ // Transition driver from Untrusted to Scheduled state.
+ //
+ CoreAcquireDispatcherLock ();
+ DriverEntry->Untrusted = FALSE;
+ DriverEntry->Scheduled = TRUE;
+ InsertTailList (&mScheduledQueue, &DriverEntry->ScheduledLink);
+ CoreReleaseDispatcherLock ();
+
+ return EFI_SUCCESS;
+ }
+ }
+ return EFI_NOT_FOUND;
+}
+
+
+EFI_DXESERVICE
+EFI_STATUS
+EFIAPI
+CoreDispatcher (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ This is the main Dispatcher for DXE and it exits when there are no more
+ drivers to run. Drain the mScheduledQueue and load and start a PE
+ image for each driver. Search the mDiscoveredList to see if any driver can
+ be placed on the mScheduledQueue. If no drivers are placed on the
+ mScheduledQueue exit the function. On exit it is assumed the Bds()
+ will be called, and when the Bds() exits the Dispatcher will be called
+ again.
+
+Arguments:
+
+ NONE
+
+Returns:
+
+ EFI_ALREADY_STARTED - The DXE Dispatcher is already running
+
+ EFI_NOT_FOUND - No DXE Drivers were dispatched
+
+ EFI_SUCCESS - One or more DXE Drivers were dispatched
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_STATUS ReturnStatus;
+ EFI_LIST_ENTRY *Link;
+ EFI_CORE_DRIVER_ENTRY *DriverEntry;
+ BOOLEAN ReadyToRun;
+ UINT8 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE];
+ EFI_STATUS_CODE_DATA *StatusCodeData;
+ EFI_DEVICE_HANDLE_EXTENDED_DATA *DeviceHandleExtData;
+
+ DeviceHandleExtData = (EFI_DEVICE_HANDLE_EXTENDED_DATA *) Buffer;
+ StatusCodeData = (EFI_STATUS_CODE_DATA *) Buffer;
+ DeviceHandleExtData->DataHeader.HeaderSize = sizeof (EFI_STATUS_CODE_DATA);
+ DeviceHandleExtData->DataHeader.Size =
+ sizeof (EFI_DEVICE_HANDLE_EXTENDED_DATA) -
+ sizeof (EFI_STATUS_CODE_DATA);
+
+ EfiCommonLibCopyMem (
+ &DeviceHandleExtData->DataHeader.Type,
+ &gEfiStatusCodeSpecificDataGuid,
+ sizeof (EFI_GUID)
+ );
+
+ if (mDispatcherRunning) {
+ //
+ // If the dispatcher is running don't let it be restarted.
+ //
+ return EFI_ALREADY_STARTED;
+ }
+
+ mDispatcherRunning = TRUE;
+
+
+ ReturnStatus = EFI_NOT_FOUND;
+ do {
+ //
+ // Drain the Scheduled Queue
+ //
+ while (!IsListEmpty (&mScheduledQueue)) {
+ DriverEntry = CR (
+ mScheduledQueue.ForwardLink,
+ EFI_CORE_DRIVER_ENTRY,
+ ScheduledLink,
+ EFI_CORE_DRIVER_ENTRY_SIGNATURE
+ );
+
+ //
+ // Load the DXE Driver image into memory. If the Driver was transitioned from
+ // Untrused to Scheduled it would have already been loaded so we may need to
+ // skip the LoadImage
+ //
+ if (DriverEntry->ImageHandle == NULL) {
+ Status = CoreLoadImage (
+ FALSE,
+ gDxeCoreImageHandle,
+ DriverEntry->FvFileDevicePath,
+ NULL,
+ 0,
+ &DriverEntry->ImageHandle
+ );
+
+ //
+ // Update the driver state to reflect that it's been loaded
+ //
+ if (EFI_ERROR (Status)) {
+ CoreAcquireDispatcherLock ();
+
+ if (Status == EFI_SECURITY_VIOLATION) {
+ //
+ // Take driver from Scheduled to Untrused state
+ //
+ DriverEntry->Untrusted = TRUE;
+ } else {
+ //
+ // The DXE Driver could not be loaded, and do not attempt to load or start it again.
+ // Take driver from Scheduled to Initialized.
+ //
+ // This case include the Never Trusted state if EFI_ACCESS_DENIED is returned
+ //
+ DriverEntry->Initialized = TRUE;
+ }
+
+ DriverEntry->Scheduled = FALSE;
+ RemoveEntryList (&DriverEntry->ScheduledLink);
+
+ CoreReleaseDispatcherLock ();
+
+ //
+ // If it's an error don't try the StartImage
+ //
+ continue;
+ }
+ }
+
+ CoreAcquireDispatcherLock ();
+
+ DriverEntry->Scheduled = FALSE;
+ DriverEntry->Initialized = TRUE;
+ RemoveEntryList (&DriverEntry->ScheduledLink);
+
+ CoreReleaseDispatcherLock ();
+
+ //
+ // Report Status Code here to notify drivers has
+ // been initialized (INIT_BEGIN)
+ //
+ EfiCommonLibCopyMem (
+ &DeviceHandleExtData->Handle,
+ &DriverEntry->ImageHandle,
+ sizeof (EFI_HANDLE)
+ );
+
+ CoreReportProgressCodeSpecific (EFI_SOFTWARE_DXE_CORE | EFI_SW_PC_INIT_BEGIN, DriverEntry->ImageHandle);
+
+ Status = CoreStartImage (DriverEntry->ImageHandle, NULL, NULL);
+
+ CoreReportProgressCodeSpecific (EFI_SOFTWARE_DXE_CORE | EFI_SW_PC_INIT_END, DriverEntry->ImageHandle);
+
+ ReturnStatus = EFI_SUCCESS;
+ }
+
+ //
+ // Search DriverList for items to place on Scheduled Queue
+ //
+ ReadyToRun = FALSE;
+ for (Link = mDiscoveredList.ForwardLink; Link != &mDiscoveredList; Link = Link->ForwardLink) {
+ DriverEntry = CR (Link, EFI_CORE_DRIVER_ENTRY, Link, EFI_CORE_DRIVER_ENTRY_SIGNATURE);
+
+ if (DriverEntry->DepexProtocolError){
+ //
+ // If Section Extraction Protocol did not let the Depex be read before retry the read
+ //
+ Status = CoreGetDepexSectionAndPreProccess (DriverEntry);
+ }
+
+ if (DriverEntry->Dependent) {
+ if (CoreIsSchedulable (DriverEntry)) {
+ CoreInsertOnScheduledQueueWhileProcessingBeforeAndAfter (DriverEntry);
+ ReadyToRun = TRUE;
+ }
+ }
+ }
+ } while (ReadyToRun);
+
+ mDispatcherRunning = FALSE;
+
+ return ReturnStatus;
+}
+
+
+VOID
+CoreInsertOnScheduledQueueWhileProcessingBeforeAndAfter (
+ IN EFI_CORE_DRIVER_ENTRY *InsertedDriverEntry
+ )
+/*++
+
+Routine Description:
+
+ Insert InsertedDriverEntry onto the mScheduledQueue. To do this you
+ must add any driver with a before dependency on InsertedDriverEntry first.
+ You do this by recursively calling this routine. After all the Befores are
+ processed you can add InsertedDriverEntry to the mScheduledQueue.
+ Then you can add any driver with an After dependency on InsertedDriverEntry
+ by recursively calling this routine.
+
+Arguments:
+
+ InsertedDriverEntry - The driver to insert on the ScheduledLink Queue
+
+Returns:
+
+ NONE
+
+--*/
+{
+ EFI_LIST_ENTRY *Link;
+ EFI_CORE_DRIVER_ENTRY *DriverEntry;
+
+ //
+ // Process Before Dependency
+ //
+ for (Link = mDiscoveredList.ForwardLink; Link != &mDiscoveredList; Link = Link->ForwardLink) {
+ DriverEntry = CR(Link, EFI_CORE_DRIVER_ENTRY, Link, EFI_CORE_DRIVER_ENTRY_SIGNATURE);
+ if (DriverEntry->Before && DriverEntry->Dependent) {
+ if (EfiCompareGuid (&InsertedDriverEntry->FileName, &DriverEntry->BeforeAfterGuid)) {
+ //
+ // Recursively process BEFORE
+ //
+ CoreInsertOnScheduledQueueWhileProcessingBeforeAndAfter (DriverEntry);
+ }
+ }
+ }
+
+ //
+ // Convert driver from Dependent to Scheduled state
+ //
+ CoreAcquireDispatcherLock ();
+
+ InsertedDriverEntry->Dependent = FALSE;
+ InsertedDriverEntry->Scheduled = TRUE;
+ InsertTailList (&mScheduledQueue, &InsertedDriverEntry->ScheduledLink);
+
+ CoreReleaseDispatcherLock ();
+
+ //
+ // Process After Dependency
+ //
+ for (Link = mDiscoveredList.ForwardLink; Link != &mDiscoveredList; Link = Link->ForwardLink) {
+ DriverEntry = CR(Link, EFI_CORE_DRIVER_ENTRY, Link, EFI_CORE_DRIVER_ENTRY_SIGNATURE);
+ if (DriverEntry->After && DriverEntry->Dependent) {
+ if (EfiCompareGuid (&InsertedDriverEntry->FileName, &DriverEntry->BeforeAfterGuid)) {
+ //
+ // Recursively process AFTER
+ //
+ CoreInsertOnScheduledQueueWhileProcessingBeforeAndAfter (DriverEntry);
+ }
+ }
+ }
+}
+
+
+BOOLEAN
+FvHasBeenProcessed (
+ IN EFI_HANDLE FvHandle
+ )
+/*++
+
+Routine Description:
+
+ Return TRUE if the Fv has been processed, FALSE if not.
+
+Arguments:
+
+ FvHandle - The handle of a FV that's being tested
+
+Returns:
+
+ TRUE - Fv protocol on FvHandle has been processed
+
+ FALSE - Fv protocol on FvHandle has not yet been processed
+
+--*/
+{
+ EFI_LIST_ENTRY *Link;
+ KNOWN_HANDLE *KnownHandle;
+
+ for (Link = mFvHandleList.ForwardLink; Link != &mFvHandleList; Link = Link->ForwardLink) {
+ KnownHandle = CR(Link, KNOWN_HANDLE, Link, KNOWN_HANDLE_SIGNATURE);
+ if (KnownHandle->Handle == FvHandle) {
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+
+VOID
+FvIsBeingProcesssed (
+ IN EFI_HANDLE FvHandle
+ )
+/*++
+
+Routine Description:
+
+ Remember that Fv protocol on FvHandle has had it's drivers placed on the
+ mDiscoveredList. This fucntion adds entries on the mFvHandleList. Items are
+ never removed/freed from the mFvHandleList.
+
+Arguments:
+
+ FvHandle - The handle of a FV that has been processed
+
+Returns:
+
+ None
+
+--*/
+{
+ KNOWN_HANDLE *KnownHandle;
+
+ KnownHandle = CoreAllocateBootServicesPool (sizeof (KNOWN_HANDLE));
+ ASSERT (KnownHandle != NULL);
+ if (KnownHandle == NULL) {
+ //
+ // Failed to allocate memory, no recovery path implemented as this is not expected to occur
+ //
+ EFI_DEADLOOP ();
+ }
+
+ KnownHandle->Signature = KNOWN_HANDLE_SIGNATURE;
+ KnownHandle->Handle = FvHandle;
+ InsertTailList (&mFvHandleList, &KnownHandle->Link);
+}
+
+
+
+
+EFI_DEVICE_PATH_PROTOCOL *
+CoreFvToDevicePath (
+ IN EFI_FIRMWARE_VOLUME_PROTOCOL *Fv,
+ IN EFI_HANDLE FvHandle,
+ IN EFI_GUID *DriverName
+ )
+/*++
+
+Routine Description:
+
+ Convert FvHandle and DriverName into an EFI device path
+
+Arguments:
+
+ Fv - Fv protocol, needed to read Depex info out of FLASH.
+
+ FvHandle - Handle for Fv, needed in the EFI_CORE_DRIVER_ENTRY so that the
+ PE image can be read out of the FV at a later time.
+
+ DriverName - Name of driver to add to mDiscoveredList.
+
+Returns:
+
+ Pointer to device path constructed from FvHandle and DriverName
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_DEVICE_PATH_PROTOCOL *FvDevicePath;
+ EFI_DEVICE_PATH_PROTOCOL *FileNameDevicePath;
+
+ //
+ // Remember the device path of the FV
+ //
+ Status = CoreHandleProtocol (FvHandle, &gEfiDevicePathProtocolGuid, &FvDevicePath);
+ if (EFI_ERROR (Status)) {
+ FileNameDevicePath = NULL;
+ } else {
+ //
+ // Build a device path to the file in the FV to pass into gBS->LoadImage
+ //
+ CoreInitializeFwVolDevicepathNode (&mFvDevicePath.File, DriverName);
+ mFvDevicePath.End.Type = EFI_END_ENTIRE_DEVICE_PATH;
+ mFvDevicePath.End.SubType = END_ENTIRE_DEVICE_PATH_SUBTYPE;
+ SetDevicePathNodeLength (&mFvDevicePath.End, sizeof (EFI_DEVICE_PATH_PROTOCOL));
+ FileNameDevicePath = CoreAppendDevicePath (
+ FvDevicePath,
+ (EFI_DEVICE_PATH_PROTOCOL *)&mFvDevicePath
+ );
+ }
+
+ return FileNameDevicePath;
+}
+
+
+
+EFI_STATUS
+CoreAddToDriverList (
+ IN EFI_FIRMWARE_VOLUME_PROTOCOL *Fv,
+ IN EFI_HANDLE FvHandle,
+ IN EFI_GUID *DriverName
+ )
+/*++
+
+Routine Description:
+
+ Add an entry to the mDiscoveredList. Allocate memory to store the DriverEntry,
+ and initilize any state variables. Read the Depex from the FV and store it
+ in DriverEntry. Pre-process the Depex to set the SOR, Before and After state.
+ The Discovered list is never free'ed and contains booleans that represent the
+ other possible DXE driver states.
+
+Arguments:
+
+ Fv - Fv protocol, needed to read Depex info out of FLASH.
+
+ FvHandle - Handle for Fv, needed in the EFI_CORE_DRIVER_ENTRY so that the
+ PE image can be read out of the FV at a later time.
+
+ DriverName - Name of driver to add to mDiscoveredList.
+
+Returns:
+
+ EFI_SUCCESS - If driver was added to the mDiscoveredList.
+
+ EFI_ALREADY_STARTED - The driver has already been started. Only one DriverName
+ may be active in the system at any one time.
+
+--*/
+{
+ EFI_CORE_DRIVER_ENTRY *DriverEntry;
+
+
+ //
+ // Create the Driver Entry for the list. ZeroPool initializes lots of variables to
+ // NULL or FALSE.
+ //
+ DriverEntry = CoreAllocateZeroBootServicesPool (sizeof (EFI_CORE_DRIVER_ENTRY));
+ ASSERT (DriverEntry != NULL);
+ if (DriverEntry == NULL) {
+ //
+ // Failed to allocate memory, no recovery path implemented as this is not expected to occur
+ //
+ EFI_DEADLOOP ();
+ }
+
+ DriverEntry->Signature = EFI_CORE_DRIVER_ENTRY_SIGNATURE;
+ EfiCommonLibCopyMem (&DriverEntry->FileName, DriverName, sizeof (EFI_GUID));
+ DriverEntry->FvHandle = FvHandle;
+ DriverEntry->Fv = Fv;
+ DriverEntry->FvFileDevicePath = CoreFvToDevicePath (Fv, FvHandle, DriverName);
+
+ CoreGetDepexSectionAndPreProccess (DriverEntry);
+
+ CoreAcquireDispatcherLock ();
+
+ InsertTailList (&mDiscoveredList, &DriverEntry->Link);
+
+ CoreReleaseDispatcherLock ();
+
+ return EFI_SUCCESS;
+}
+
+
+
+EFI_STATUS
+CoreProcessFvImageFile (
+ IN EFI_FIRMWARE_VOLUME_PROTOCOL *Fv,
+ IN EFI_HANDLE FvHandle,
+ IN EFI_GUID *DriverName
+ )
+/*++
+
+Routine Description:
+
+ Get the driver from the FV through driver name, and produce a FVB protocol on FvHandle.
+
+Arguments:
+
+ Fv - The FIRMWARE_VOLUME protocol installed on the FV.
+ FvHandle - The handle which FVB protocol installed on.
+ DriverName - The driver guid specified.
+
+Returns:
+
+ EFI_OUT_OF_RESOURCES - No enough memory or other resource.
+
+ EFI_VOLUME_CORRUPTED - Corrupted volume.
+
+ EFI_SUCCESS - Function successfully returned.
+
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_SECTION_TYPE SectionType;
+ UINT32 AuthenticationStatus;
+ VOID *Buffer;
+ UINTN BufferSize;
+
+ //
+ // Read the first (and only the first) firmware volume section
+ //
+ SectionType = EFI_SECTION_FIRMWARE_VOLUME_IMAGE;
+ Buffer = NULL;
+ BufferSize = 0;
+ Status = Fv->ReadSection (
+ Fv,
+ DriverName,
+ SectionType,
+ 0,
+ &Buffer,
+ &BufferSize,
+ &AuthenticationStatus
+ );
+ if (!EFI_ERROR (Status)) {
+ //
+ // Produce a FVB protocol for the file
+ //
+ Status = ProduceFVBProtocolOnBuffer (
+ (EFI_PHYSICAL_ADDRESS) (UINTN) Buffer,
+ (UINT64)BufferSize,
+ FvHandle,
+ NULL
+ );
+ }
+
+ if (EFI_ERROR (Status) && (Buffer != NULL)) {
+ //
+ // ReadSection or Produce FVB failed, Free data buffer
+ //
+ gBS->FreePool (Buffer);
+
+ }
+
+ return Status;
+}
+
+
+VOID
+EFIAPI
+CoreFwVolEventProtocolNotify (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+/*++
+
+Routine Description:
+
+ Event notification that is fired every time a FV dispatch protocol is added.
+ More than one protocol may have been added when this event is fired, so you
+ must loop on CoreLocateHandle () to see how many protocols were added and
+ do the following to each FV:
+
+ If the Fv has already been processed, skip it. If the Fv has not been
+ processed then mark it as being processed, as we are about to process it.
+
+ Read the Fv and add any driver in the Fv to the mDiscoveredList.The
+ mDiscoveredList is never free'ed and contains variables that define
+ the other states the DXE driver transitions to..
+
+ While you are at it read the A Priori file into memory.
+ Place drivers in the A Priori list onto the mScheduledQueue.
+
+Arguments:
+
+ Event - The Event that is being processed, not used.
+
+ Context - Event Context, not used.
+
+Returns:
+
+ None
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_STATUS GetNextFileStatus;
+ EFI_STATUS SecurityStatus;
+ EFI_FIRMWARE_VOLUME_PROTOCOL *Fv;
+ EFI_DEVICE_PATH_PROTOCOL *FvDevicePath;
+ EFI_HANDLE FvHandle;
+ UINTN BufferSize;
+ EFI_GUID NameGuid;
+ UINTN Key;
+ EFI_FV_FILETYPE Type;
+ EFI_FV_FILE_ATTRIBUTES Attributes;
+ UINTN Size;
+ EFI_CORE_DRIVER_ENTRY *DriverEntry;
+ EFI_GUID *AprioriFile;
+ UINTN AprioriEntryCount;
+ UINTN Index;
+ EFI_LIST_ENTRY *Link;
+ UINT32 AuthenticationStatus;
+ UINTN SizeOfBuffer;
+
+
+ while (TRUE) {
+ BufferSize = sizeof (EFI_HANDLE);
+ Status = CoreLocateHandle (
+ ByRegisterNotify,
+ NULL,
+ mFwVolEventRegistration,
+ &BufferSize,
+ &FvHandle
+ );
+ if (EFI_ERROR (Status)) {
+ //
+ // If no more notification events exit
+ //
+ return;
+ }
+
+ if (FvHasBeenProcessed (FvHandle)) {
+ //
+ // This Fv has already been processed so lets skip it!
+ //
+ continue;
+ }
+
+ Status = CoreHandleProtocol (FvHandle, &gEfiFirmwareVolumeDispatchProtocolGuid, &Fv);
+ if (EFI_ERROR (Status)) {
+ //
+ // If no dispatch protocol then skip, but do not marked as being processed as it
+ // may show up later.
+ //
+ continue;
+ }
+
+ //
+ // Since we are about to process this Fv mark it as processed.
+ //
+ FvIsBeingProcesssed (FvHandle);
+
+
+ Status = CoreHandleProtocol (FvHandle, &gEfiFirmwareVolumeProtocolGuid, &Fv);
+ if (EFI_ERROR (Status) || (Fv == NULL)) {
+ //
+ // The Handle has a FirmwareVolumeDispatch protocol and should also contiain
+ // a FirmwareVolume protocol thus we should never get here.
+ //
+ ASSERT (FALSE);
+ continue;
+ }
+
+ Status = CoreHandleProtocol (FvHandle, &gEfiDevicePathProtocolGuid, &FvDevicePath);
+ if (EFI_ERROR (Status)) {
+ //
+ // The Firmware volume doesn't have device path, can't be dispatched.
+ //
+ continue;
+ }
+
+ //
+ // Evaluate the authentication status of the Firmware Volume through
+ // Security Architectural Protocol
+ //
+ if (gSecurity != NULL) {
+ SecurityStatus = gSecurity->FileAuthenticationState (
+ gSecurity,
+ 0,
+ FvDevicePath
+ );
+ if (SecurityStatus != EFI_SUCCESS) {
+ //
+ // Security check failed. The firmware volume should not be used for any purpose.
+ //
+ continue;
+ }
+ }
+
+ //
+ // Discover Drivers in FV and add them to the Discovered Driver List.
+ // Process EFI_FV_FILETYPE_DRIVER type and then EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER
+ // EFI_FV_FILETYPE_DXE_CORE is processed to produce a Loaded Image protocol for the core
+ // EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE is processed to create a Fvb
+ //
+ for (Index = 0; Index < sizeof (mDxeFileTypes)/sizeof (EFI_FV_FILETYPE); Index++) {
+ //
+ // Initialize the search key
+ //
+ Key = 0;
+ do {
+ Type = mDxeFileTypes[Index];
+ GetNextFileStatus = Fv->GetNextFile (
+ Fv,
+ &Key,
+ &Type,
+ &NameGuid,
+ &Attributes,
+ &Size
+ );
+ if (!EFI_ERROR (GetNextFileStatus)) {
+ if (Type == EFI_FV_FILETYPE_DXE_CORE) {
+ //
+ // If this is the DXE core fill in it's DevicePath & DeviceHandle
+ //
+ if (gDxeCoreLoadedImage->FilePath == NULL) {
+ if (EfiCompareGuid (&NameGuid, gDxeCoreFileName)) {
+ CoreInitializeFwVolDevicepathNode (&mFvDevicePath.File, &NameGuid);
+ mFvDevicePath.End.Type = EFI_END_ENTIRE_DEVICE_PATH;
+ mFvDevicePath.End.SubType = END_ENTIRE_DEVICE_PATH_SUBTYPE;
+ SetDevicePathNodeLength (&mFvDevicePath.End, sizeof (EFI_DEVICE_PATH_PROTOCOL));
+
+ gDxeCoreLoadedImage->FilePath = CoreDuplicateDevicePath (
+ (EFI_DEVICE_PATH_PROTOCOL *)&mFvDevicePath
+ );
+ gDxeCoreLoadedImage->DeviceHandle = FvHandle;
+ }
+ }
+ } else if (Type == EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE) {
+ //
+ // Found a firmware volume image. Produce a firmware volume block
+ // protocol for it so it gets dispatched from. This is usually a
+ // capsule.
+ //
+ CoreProcessFvImageFile (Fv, FvHandle, &NameGuid);
+ } else {
+ //
+ // Transition driver from Undiscovered to Discovered state
+ //
+ CoreAddToDriverList (Fv, FvHandle, &NameGuid);
+ }
+ }
+ } while (!EFI_ERROR (GetNextFileStatus));
+ }
+
+ //
+ // Read the array of GUIDs from the Apriori file if it is present in the firmware volume
+ //
+ AprioriFile = NULL;
+ Status = Fv->ReadSection (
+ Fv,
+ &gAprioriGuid,
+ EFI_SECTION_RAW,
+ 0,
+ &AprioriFile,
+ &SizeOfBuffer,
+ &AuthenticationStatus
+ );
+ if (!EFI_ERROR (Status)) {
+ AprioriEntryCount = SizeOfBuffer / sizeof (EFI_GUID);
+ } else {
+ AprioriEntryCount = 0;
+ }
+
+ //
+ // Put drivers on Apriori List on the Scheduled queue. The Discovered List includes
+ // drivers not in the current FV and these must be skipped since the a priori list
+ // is only valid for the FV that it resided in.
+ //
+ CoreAcquireDispatcherLock ();
+
+ for (Index = 0; Index < AprioriEntryCount; Index++) {
+ for (Link = mDiscoveredList.ForwardLink; Link != &mDiscoveredList; Link = Link->ForwardLink) {
+ DriverEntry = CR(Link, EFI_CORE_DRIVER_ENTRY, Link, EFI_CORE_DRIVER_ENTRY_SIGNATURE);
+ if (EfiCompareGuid (&DriverEntry->FileName, &AprioriFile[Index]) &&
+ (FvHandle == DriverEntry->FvHandle)) {
+ DriverEntry->Dependent = FALSE;
+ DriverEntry->Scheduled = TRUE;
+ InsertTailList (&mScheduledQueue, &DriverEntry->ScheduledLink);
+ break;
+ }
+ }
+ }
+
+ CoreReleaseDispatcherLock ();
+
+ //
+ // Free data allocated by Fv->ReadSection ()
+ //
+ gBS->FreePool (AprioriFile);
+ }
+}
+
+
+VOID
+CoreInitializeDispatcher (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Initialize the dispatcher. Initialize the notification function that runs when
+ a FV protocol is added to the system.
+
+Arguments:
+
+ NONE
+
+Returns:
+
+ NONE
+
+--*/
+{
+ mFwVolEvent = CoreCreateProtocolNotifyEvent (
+ &gEfiFirmwareVolumeProtocolGuid,
+ EFI_TPL_CALLBACK,
+ CoreFwVolEventProtocolNotify,
+ NULL,
+ &mFwVolEventRegistration,
+ TRUE
+ );
+}
+
+//
+// Function only used in debug buils
+//
+DEBUG_CODE (
+VOID
+CoreDisplayDiscoveredNotDispatched (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Traverse the discovered list for any drivers that were discovered but not loaded
+ because the dependency experessions evaluated to false
+
+Arguments:
+
+ NONE
+
+Returns:
+
+ NONE
+
+--*/
+{
+ EFI_LIST_ENTRY *Link;
+ EFI_CORE_DRIVER_ENTRY *DriverEntry;
+
+ for (Link = mDiscoveredList.ForwardLink;Link !=&mDiscoveredList; Link = Link->ForwardLink) {
+ DriverEntry = CR(Link, EFI_CORE_DRIVER_ENTRY, Link, EFI_CORE_DRIVER_ENTRY_SIGNATURE);
+ if (DriverEntry->Dependent) {
+ DEBUG ((EFI_D_LOAD, "Driver %g was discovered but not loaded!!\n", &DriverEntry->FileName));
+ }
+ }
+}
+)
diff --git a/EDK/Foundation/Core/Dxe/Dispatcher/dependency.c b/EDK/Foundation/Core/Dxe/Dispatcher/dependency.c
new file mode 100644
index 0000000..b08c5bf
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/Dispatcher/dependency.c
@@ -0,0 +1,451 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ dependency.c
+
+Abstract:
+
+ DXE Dispatcher Dependency Evaluator
+
+ This routine evaluates a dependency expression (DEPENDENCY_EXPRESSION) to determine
+ if a driver can be scheduled for execution. The criteria for
+ schedulability is that the dependency expression is satisfied.
+
+--*/
+
+#include "Tiano.h"
+#include "DxeCore.h"
+#include "EfiDependency.h"
+
+//
+// Global stack used to evaluate dependency expressions
+//
+BOOLEAN *mDepexEvaluationStack = NULL;
+BOOLEAN *mDepexEvaluationStackEnd = NULL;
+BOOLEAN *mDepexEvaluationStackPointer = NULL;
+
+//
+// Worker functions
+//
+
+STATIC
+EFI_STATUS
+GrowDepexStack (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Grow size of the Depex stack
+
+Arguments:
+
+ Stack - Old stack on the way in and new stack on the way out
+
+ StackSize - New size of the stack
+
+Returns:
+
+ EFI_SUCCESS - Stack successfully growed.
+
+ EFI_OUT_OF_RESOURCES - There is not enough system memory to grow the stack.
+
+
+
+--*/
+{
+ BOOLEAN *NewStack;
+ UINTN Size;
+
+ Size = DEPEX_STACK_SIZE_INCREMENT;
+ if (mDepexEvaluationStack != NULL) {
+ Size = Size + (mDepexEvaluationStackEnd - mDepexEvaluationStack);
+ }
+
+ NewStack = CoreAllocateBootServicesPool (Size * sizeof (BOOLEAN));
+ if (NewStack == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ if (mDepexEvaluationStack != NULL) {
+ //
+ // Copy to Old Stack to the New Stack
+ //
+ EfiCommonLibCopyMem (
+ NewStack,
+ mDepexEvaluationStack,
+ (mDepexEvaluationStackEnd - mDepexEvaluationStack) * sizeof (BOOLEAN)
+ );
+
+ //
+ // Free The Old Stack
+ //
+ CoreFreePool (mDepexEvaluationStack);
+ }
+
+ //
+ // Make the Stack pointer point to the old data in the new stack
+ //
+ mDepexEvaluationStackPointer = NewStack + (mDepexEvaluationStackPointer - mDepexEvaluationStack);
+ mDepexEvaluationStack = NewStack;
+ mDepexEvaluationStackEnd = NewStack + Size;
+
+ return EFI_SUCCESS;
+}
+
+
+STATIC
+EFI_STATUS
+PushBool (
+ IN BOOLEAN Value
+ )
+/*++
+
+Routine Description:
+
+ Push an element onto the Boolean Stack
+
+Arguments:
+
+ Value - BOOLEAN to push.
+
+Returns:
+
+ EFI_SUCCESS - The value was pushed onto the stack.
+
+ EFI_OUT_OF_RESOURCES - There is not enough system memory to grow the stack.
+
+--*/
+{
+ EFI_STATUS Status;
+
+ //
+ // Check for a stack overflow condition
+ //
+ if (mDepexEvaluationStackPointer == mDepexEvaluationStackEnd) {
+ //
+ // Grow the stack
+ //
+ Status = GrowDepexStack ();
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ }
+
+ //
+ // Push the item onto the stack
+ //
+ *mDepexEvaluationStackPointer = Value;
+ mDepexEvaluationStackPointer++;
+
+ return EFI_SUCCESS;
+}
+
+
+STATIC
+EFI_STATUS
+PopBool (
+ OUT BOOLEAN *Value
+ )
+/*++
+
+Routine Description:
+
+ Pop an element from the Boolean stack.
+
+Arguments:
+
+ Value - BOOLEAN to pop.
+
+Returns:
+
+ EFI_SUCCESS - The value was popped onto the stack.
+
+ EFI_ACCESS_DENIED - The pop operation underflowed the stack
+
+--*/
+{
+ //
+ // Check for a stack underflow condition
+ //
+ if (mDepexEvaluationStackPointer == mDepexEvaluationStack) {
+ return EFI_ACCESS_DENIED;
+ }
+
+ //
+ // Pop the item off the stack
+ //
+ mDepexEvaluationStackPointer--;
+ *Value = *mDepexEvaluationStackPointer;
+ return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+CorePreProcessDepex (
+ IN EFI_CORE_DRIVER_ENTRY *DriverEntry
+ )
+/*++
+
+Routine Description:
+
+ Preprocess dependency expression and update DriverEntry to reflect the
+ state of Before, After, and SOR dependencies. If DriverEntry->Before
+ or DriverEntry->After is set it will never be cleared. If SOR is set
+ it will be cleared by CoreSchedule(), and then the driver can be
+ dispatched.
+
+Arguments:
+
+ DriverEntry - DriverEntry element to update
+
+Returns:
+
+ EFI_SUCCESS - It always works.
+
+--*/
+{
+ UINT8 *Iterator;
+
+ Iterator = DriverEntry->Depex;
+ if (*Iterator == EFI_DEP_SOR) {
+ DriverEntry->Unrequested = TRUE;
+ } else {
+ DriverEntry->Dependent = TRUE;
+ }
+
+ if (*Iterator == EFI_DEP_BEFORE) {
+ DriverEntry->Before = TRUE;
+ } else if (*Iterator == EFI_DEP_AFTER) {
+ DriverEntry->After = TRUE;
+ }
+
+ if (DriverEntry->Before || DriverEntry->After) {
+ EfiCommonLibCopyMem (&DriverEntry->BeforeAfterGuid, Iterator + 1, sizeof (EFI_GUID));
+ }
+
+ return EFI_SUCCESS;
+}
+
+
+BOOLEAN
+CoreIsSchedulable (
+ IN EFI_CORE_DRIVER_ENTRY *DriverEntry
+ )
+/*++
+
+Routine Description:
+
+ This is the POSTFIX version of the dependency evaluator. This code does
+ not need to handle Before or After, as it is not valid to call this
+ routine in this case. The SOR is just ignored and is a nop in the grammer.
+
+ POSTFIX means all the math is done on top of the stack.
+
+Arguments:
+
+ DriverEntry - DriverEntry element to update
+
+Returns:
+
+ TRUE - If driver is ready to run.
+ FALSE - If driver is not ready to run or some fatal error was found.
+
+--*/
+{
+ EFI_STATUS Status;
+ UINT8 *Iterator;
+ BOOLEAN Operator;
+ BOOLEAN Operator2;
+ EFI_GUID DriverGuid;
+ VOID *Interface;
+
+ if (DriverEntry->After || DriverEntry->Before) {
+ //
+ // If Before or After Depex skip as CoreInsertOnScheduledQueueWhileProcessingBeforeAndAfter ()
+ // processes them.
+ //
+ return FALSE;
+ }
+
+ if (DriverEntry->Depex == NULL) {
+ //
+ // A NULL Depex means treat the driver like an EFI 1.0 thing.
+ //
+ Status = CoreAllEfiServicesAvailable ();
+ if (EFI_ERROR (Status)) {
+ return FALSE;
+ }
+ return TRUE;
+ }
+
+ //
+ // Clean out memory leaks in Depex Boolean stack. Leaks are only caused by
+ // incorrectly formed DEPEX expressions
+ //
+ mDepexEvaluationStackPointer = mDepexEvaluationStack;
+
+
+ Iterator = DriverEntry->Depex;
+
+ while (TRUE) {
+ //
+ // Check to see if we are attempting to fetch dependency expression instructions
+ // past the end of the dependency expression.
+ //
+ if (((UINTN) Iterator - (UINTN) DriverEntry->Depex) >= DriverEntry->DepexSize) {
+ return FALSE;
+ }
+
+ //
+ // Look at the opcode of the dependency expression instruction.
+ //
+ switch (*Iterator) {
+ case EFI_DEP_BEFORE:
+ case EFI_DEP_AFTER:
+ //
+ // For a well-formed Dependency Expression, the code should never get here.
+ // The BEFORE and AFTER are processed prior to this routine's invocation.
+ // If the code flow arrives at this point, there was a BEFORE or AFTER
+ // that were not the first opcodes.
+ //
+ ASSERT (FALSE);
+ case EFI_DEP_SOR:
+ //
+ // These opcodes can only appear once as the first opcode. If it is found
+ // at any other location, then the dependency expression evaluates to FALSE
+ //
+ if (Iterator != DriverEntry->Depex) {
+ return FALSE;
+ }
+ //
+ // Otherwise, it is the first opcode and should be treated as a NOP.
+ //
+ break;
+
+ case EFI_DEP_PUSH:
+ //
+ // Push operator is followed by a GUID. Test to see if the GUID protocol
+ // is installed and push the boolean result on the stack.
+ //
+ EfiCommonLibCopyMem (&DriverGuid, Iterator + 1, sizeof (EFI_GUID));
+
+ Status = CoreLocateProtocol (&DriverGuid, NULL, &Interface);
+
+ if (EFI_ERROR (Status)) {
+ Status = PushBool (FALSE);
+ } else {
+ *Iterator = EFI_DEP_REPLACE_TRUE;
+ Status = PushBool (TRUE);
+ }
+ if (EFI_ERROR (Status)) {
+ return FALSE;
+ }
+
+ Iterator += sizeof (EFI_GUID);
+ break;
+
+ case EFI_DEP_AND:
+ Status = PopBool (&Operator);
+ if (EFI_ERROR (Status)) {
+ return FALSE;
+ }
+
+ Status = PopBool (&Operator2);
+ if (EFI_ERROR (Status)) {
+ return FALSE;
+ }
+
+ Status = PushBool ((BOOLEAN) (Operator && Operator2));
+ if (EFI_ERROR (Status)) {
+ return FALSE;
+ }
+ break;
+
+ case EFI_DEP_OR:
+ Status = PopBool (&Operator);
+ if (EFI_ERROR (Status)) {
+ return FALSE;
+ }
+
+ Status = PopBool (&Operator2);
+ if (EFI_ERROR (Status)) {
+ return FALSE;
+ }
+
+ Status = PushBool ((BOOLEAN) (Operator || Operator2));
+ if (EFI_ERROR (Status)) {
+ return FALSE;
+ }
+ break;
+
+ case EFI_DEP_NOT:
+ Status = PopBool (&Operator);
+ if (EFI_ERROR (Status)) {
+ return FALSE;
+ }
+
+ Status = PushBool ((BOOLEAN) (!Operator));
+ if (EFI_ERROR (Status)) {
+ return FALSE;
+ }
+ break;
+
+ case EFI_DEP_TRUE:
+ Status = PushBool (TRUE);
+ if (EFI_ERROR (Status)) {
+ return FALSE;
+ }
+ break;
+
+ case EFI_DEP_FALSE:
+ Status = PushBool (FALSE);
+ if (EFI_ERROR (Status)) {
+ return FALSE;
+ }
+ break;
+
+ case EFI_DEP_END:
+ Status = PopBool (&Operator);
+ if (EFI_ERROR (Status)) {
+ return FALSE;
+ }
+ return Operator;
+
+ case EFI_DEP_REPLACE_TRUE:
+ Status = PushBool (TRUE);
+ if (EFI_ERROR (Status)) {
+ return FALSE;
+ }
+
+ Iterator += sizeof (EFI_GUID);
+ break;
+
+ default:
+ return FALSE;
+ }
+
+ //
+ // Skip over the Dependency Op Code we just processed in the switch.
+ // The math is done out of order, but it should not matter. That is
+ // we may add in the sizeof (EFI_GUID) before we account for the OP Code.
+ // This is not an issue, since we just need the correct end result. You
+ // need to be careful using Iterator in the loop as it's intermediate value
+ // may be strange.
+ //
+ Iterator++;
+ }
+ return FALSE;
+}
+
diff --git a/EDK/Foundation/Core/Dxe/DxeMain.cif b/EDK/Foundation/Core/Dxe/DxeMain.cif
new file mode 100644
index 0000000..cd1fa6c
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/DxeMain.cif
@@ -0,0 +1,53 @@
+<component>
+ name = "DxeMain"
+ category = ModulePart
+ LocalRoot = "EDK\Foundation\Core\Dxe\"
+ RefName = "DxeMain"
+[files]
+"DxeMain.inf"
+"Dispatcher\dependency.c"
+"Dispatcher\Dispatcher.c"
+"DxeMain\DxeMain.c"
+"DxeMain\DxeProtocolNotify.c"
+"Event\event.c"
+"Event\exec.h"
+"Event\execdata.c"
+"Event\timer.c"
+"Event\tpl.c"
+"FwVol\Ffs.c"
+"FwVol\FwVol.c"
+"FwVol\FwVolAttrib.c"
+"FwVol\FwVolDriver.h"
+"FwVol\FwVolRead.c"
+"FwVol\FwVolWrite.c"
+"FwVolBlock\FwVolBlock.c"
+"FwVolBlock\FwVolBlock.h"
+"Gcd\gcd.c"
+"Gcd\gcd.h"
+"Hand\DriverSupport.c"
+"Hand\hand.h"
+"Hand\handle.c"
+"Hand\locate.c"
+"Hand\Notify.c"
+"Ia32\Processor.h"
+"Image\Image.c"
+"Image\Image.h"
+"Image\ImageFile.c"
+"Include\DxeCore.h"
+"Include\Library.h"
+"Ipf\Processor.h"
+"Library\Library.c"
+"Mem\imem.h"
+"Mem\memdata.c"
+"Mem\Page.c"
+"Mem\pool.c"
+"Misc\DebugImageInfo.c"
+"Misc\DebugImageInfo.h"
+"Misc\DebugMask.c"
+"Misc\DebugMask.h"
+"Misc\InstallConfigurationTable.c"
+"Misc\SetWatchdogTimer.c"
+"Misc\Stall.c"
+"SectionExtraction\CoreSectionExtraction.c"
+"x64\Processor.h"
+<endComponent>
diff --git a/EDK/Foundation/Core/Dxe/DxeMain.inf b/EDK/Foundation/Core/Dxe/DxeMain.inf
new file mode 100644
index 0000000..5f6a047
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/DxeMain.inf
@@ -0,0 +1,111 @@
+#/*++
+#
+# Copyright (c) 2004 - 2005, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# DxeMain.inf
+#
+# Abstract:
+#
+# Component description file for DxeMain.
+#
+--*/
+
+[defines]
+BASE_NAME = DxeMain
+FILE_GUID = 35B898CA-B6A9-49CE-8C72-904735CC49B7
+COMPONENT_TYPE = BS_DRIVER
+
+[sources.common]
+ DxeMain\DxeMain.c
+ DxeMain\DxeProtocolNotify.c
+ Dispatcher\Dispatcher.c
+ Dispatcher\Dependency.c
+ Event\ExecData.c
+ Event\Event.c
+ Event\Exec.h
+ Event\Timer.c
+ Event\Tpl.c
+ FwVol\FwVolDriver.h
+ FwVol\FwVol.c
+ FwVol\Ffs.c
+ FwVol\FwVolAttrib.c
+ FwVol\FwVolRead.c
+ FwVol\FwVolWrite.c
+ FwVolBlock\FwVolBlock.c
+ FwVolBlock\FwVolBlock.h
+ Mem\Imem.h
+ Mem\MemData.c
+ Mem\Page.c
+ Mem\Pool.c
+ Gcd\Gcd.h
+ Gcd\Gcd.c
+ Hand\Hand.h
+ Hand\Handle.c
+ Hand\Locate.c
+ Hand\Notify.c
+ Hand\DriverSupport.c
+ Library\Library.c
+ Misc\InstallConfigurationTable.c
+ Misc\SetWatchdogTimer.c
+ Misc\Stall.c
+ Misc\DebugImageInfo.h
+ Misc\DebugImageInfo.c
+ Misc\DebugMask.h
+ Misc\DebugMask.c
+ Image\Image.h
+ Image\Image.c
+ Image\ImageFile.c
+ SectionExtraction\CoreSectionExtraction.c
+
+[sources.Ia32]
+ Ia32\Processor.h
+
+[sources.Ipf]
+ Ipf\Processor.h
+
+[sources.x64]
+ x64\Processor.h
+
+[includes.common]
+ $(EDK_SOURCE)\Foundation\Framework
+ $(EDK_SOURCE)\Foundation\Efi
+ $(EDK_SOURCE)\Foundation
+ .
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+ $(EDK_SOURCE)\Foundation\Core\Dxe\Hand
+ $(EDK_SOURCE)\Foundation\Core\Dxe\Include
+ $(EDK_SOURCE)\Foundation\Core\Dxe\Misc
+ $(EDK_SOURCE)\Foundation\Core\Dxe\FwVolBlock
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+ $(EDK_SOURCE)\Foundation\Include\Pei
+ $(EDK_SOURCE)\Foundation\Library\Pei\Include
+
+[libraries.common]
+ EdkGuidLib
+ EdkFrameworkGuidLib
+ EfiGuidLib
+ EdkProtocolLib
+ EdkFrameworkProtocolLib
+ EfiProtocolLib
+ EfiCommonLib
+ HobLib
+ ArchProtocolLib
+ EfiDriverLib
+
+[nmake.common]
+ IMAGE_ENTRY_POINT=DxeMain
+ C_PROJ_FLAGS = $(C_PROJ_FLAGS) /Ob0
+
diff --git a/EDK/Foundation/Core/Dxe/DxeMain/DxeMain.c b/EDK/Foundation/Core/Dxe/DxeMain/DxeMain.c
new file mode 100644
index 0000000..4dc53be
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/DxeMain/DxeMain.c
@@ -0,0 +1,1010 @@
+/*++
+
+Copyright (c) 2004 - 2011, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ DxeMain.c
+
+Abstract:
+
+ DXE Core Main Entry Point
+
+--*/
+
+#include "Tiano.h"
+#include "DxeCore.h"
+#include "EfiHobLib.h"
+#include "EfiPerf.h"
+#include "FwVolBlock.h"
+
+
+VOID
+EFIAPI
+DxeMain (
+ IN VOID *HobStart
+ );
+
+EFI_STATUS
+EFIAPI
+CoreEfiNotAvailableYetArg0 (
+ VOID
+ );
+
+EFI_STATUS
+EFIAPI
+CoreEfiNotAvailableYetArg1 (
+ UINTN Arg1
+ );
+
+EFI_STATUS
+EFIAPI
+CoreEfiNotAvailableYetArg2 (
+ UINTN Arg1,
+ UINTN Arg2
+ );
+
+EFI_STATUS
+EFIAPI
+CoreEfiNotAvailableYetArg3 (
+ UINTN Arg1,
+ UINTN Arg2,
+ UINTN Arg3
+ );
+
+EFI_STATUS
+EFIAPI
+CoreEfiNotAvailableYetArg4 (
+ UINTN Arg1,
+ UINTN Arg2,
+ UINTN Arg3,
+ UINTN Arg4
+ );
+
+EFI_STATUS
+EFIAPI
+CoreEfiNotAvailableYetArg5 (
+ UINTN Arg1,
+ UINTN Arg2,
+ UINTN Arg3,
+ UINTN Arg4,
+ UINTN Arg5
+ );
+
+EFI_STATUS
+CoreGetPeiProtocol (
+ IN EFI_GUID *ProtocolGuid,
+ IN VOID **Interface
+ );
+
+PERF_CODE (
+ EFI_STATUS
+ GetTimerValue (
+ OUT UINT64 *TimerValue
+ );
+)
+
+//
+// DXE Core Global Variables for Protocols from PEI
+//
+EFI_DECOMPRESS_PROTOCOL *gEfiDecompress = NULL;
+EFI_TIANO_DECOMPRESS_PROTOCOL *gEfiTianoDecompress = NULL;
+EFI_CUSTOMIZED_DECOMPRESS_PROTOCOL *gEfiCustomizedDecompress = NULL;
+EFI_PEI_FLUSH_INSTRUCTION_CACHE_PROTOCOL *gEfiPeiFlushInstructionCache = NULL;
+EFI_PEI_PE_COFF_LOADER_PROTOCOL *gEfiPeiPeCoffLoader = NULL;
+EFI_PEI_TRANSFER_CONTROL_PROTOCOL *gEfiPeiTransferControl = NULL;
+
+//
+// DXE Core globals for Architecture Protocols
+//
+EFI_SECURITY_ARCH_PROTOCOL *gSecurity = NULL;
+EFI_CPU_ARCH_PROTOCOL *gCpu = NULL;
+EFI_METRONOME_ARCH_PROTOCOL *gMetronome = NULL;
+EFI_TIMER_ARCH_PROTOCOL *gTimer = NULL;
+EFI_BDS_ARCH_PROTOCOL *gBds = NULL;
+EFI_WATCHDOG_TIMER_ARCH_PROTOCOL *gWatchdogTimer = NULL;
+
+//
+// DXE Core Global used to update core loaded image protocol handle
+//
+EFI_GUID *gDxeCoreFileName;
+EFI_LOADED_IMAGE_PROTOCOL *gDxeCoreLoadedImage;
+
+//
+// BugBug: I'n not runtime, but is the PPI?
+//
+EFI_STATUS_CODE_PROTOCOL gStatusCodeInstance = {
+ NULL
+};
+
+EFI_STATUS_CODE_PROTOCOL *gStatusCode = &gStatusCodeInstance;
+
+//
+// DXE Core Module Variables
+//
+
+EFI_BOOT_SERVICES mBootServices = {
+ {
+ EFI_BOOT_SERVICES_SIGNATURE, // Signature
+ EFI_BOOT_SERVICES_REVISION, // Revision
+ sizeof (EFI_BOOT_SERVICES), // HeaderSize
+ 0, // CRC32
+ 0 // Reserved
+ },
+ (EFI_RAISE_TPL) CoreRaiseTpl, // RaiseTPL
+ (EFI_RESTORE_TPL) CoreRestoreTpl, // RestoreTPL
+ (EFI_ALLOCATE_PAGES) CoreAllocatePages, // AllocatePages
+ (EFI_FREE_PAGES) CoreFreePages, // FreePages
+ (EFI_GET_MEMORY_MAP) CoreGetMemoryMap, // GetMemoryMap
+ (EFI_ALLOCATE_POOL) CoreAllocatePool, // AllocatePool
+ (EFI_FREE_POOL) CoreFreePool, // FreePool
+ (EFI_CREATE_EVENT) CoreCreateEvent, // CreateEvent
+ (EFI_SET_TIMER) CoreSetTimer, // SetTimer
+ (EFI_WAIT_FOR_EVENT) CoreWaitForEvent, // WaitForEvent
+ (EFI_SIGNAL_EVENT) CoreSignalEvent, // SignalEvent
+ (EFI_CLOSE_EVENT) CoreCloseEvent, // CloseEvent
+ (EFI_CHECK_EVENT) CoreCheckEvent, // CheckEvent
+ (EFI_INSTALL_PROTOCOL_INTERFACE) CoreInstallProtocolInterface, // InstallProtocolInterface
+ (EFI_REINSTALL_PROTOCOL_INTERFACE) CoreReinstallProtocolInterface, // ReinstallProtocolInterface
+ (EFI_UNINSTALL_PROTOCOL_INTERFACE) CoreUninstallProtocolInterface, // UninstallProtocolInterface
+ (EFI_HANDLE_PROTOCOL) CoreHandleProtocol, // HandleProtocol
+ (VOID *) NULL, // Reserved
+ (EFI_REGISTER_PROTOCOL_NOTIFY) CoreRegisterProtocolNotify, // RegisterProtocolNotify
+ (EFI_LOCATE_HANDLE) CoreLocateHandle, // LocateHandle
+ (EFI_LOCATE_DEVICE_PATH) CoreLocateDevicePath, // LocateDevicePath
+ (EFI_INSTALL_CONFIGURATION_TABLE) CoreInstallConfigurationTable, // InstallConfigurationTable
+ (EFI_IMAGE_LOAD) CoreLoadImage, // LoadImage
+ (EFI_IMAGE_START) CoreStartImage, // StartImage
+ (EFI_EXIT) CoreExit, // Exit
+ (EFI_IMAGE_UNLOAD) CoreUnloadImage, // UnloadImage
+ (EFI_EXIT_BOOT_SERVICES) CoreExitBootServices, // ExitBootServices
+ (EFI_GET_NEXT_MONOTONIC_COUNT) CoreEfiNotAvailableYetArg1, // GetNextMonotonicCount
+ (EFI_STALL) CoreStall, // Stall
+ (EFI_SET_WATCHDOG_TIMER) CoreSetWatchdogTimer, // SetWatchdogTimer
+ (EFI_CONNECT_CONTROLLER) CoreConnectController, // ConnectController
+ (EFI_DISCONNECT_CONTROLLER) CoreDisconnectController, // DisconnectController
+ (EFI_OPEN_PROTOCOL) CoreOpenProtocol, // OpenProtocol
+ (EFI_CLOSE_PROTOCOL) CoreCloseProtocol, // CloseProtocol
+ (EFI_OPEN_PROTOCOL_INFORMATION) CoreOpenProtocolInformation, // OpenProtocolInformation
+ (EFI_PROTOCOLS_PER_HANDLE) CoreProtocolsPerHandle, // ProtocolsPerHandle
+ (EFI_LOCATE_HANDLE_BUFFER) CoreLocateHandleBuffer, // LocateHandleBuffer
+ (EFI_LOCATE_PROTOCOL) CoreLocateProtocol, // LocateProtocol
+ (EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES) CoreInstallMultipleProtocolInterfaces, // InstallMultipleProtocolInterfaces
+ (EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES) CoreUninstallMultipleProtocolInterfaces, // UninstallMultipleProtocolInterfaces
+ (EFI_CALCULATE_CRC32) CoreEfiNotAvailableYetArg3, // CalculateCrc32
+ (EFI_COPY_MEM) EfiCommonLibCopyMem, // CopyMem
+ (EFI_SET_MEM) EfiCommonLibSetMem // SetMem
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+ ,
+ //
+ // UEFI 2.0 Extension to the table
+ //
+ (EFI_CREATE_EVENT_EX) CoreCreateEventEx
+#endif
+};
+
+EFI_DXE_SERVICES mDxeServices = {
+ {
+ EFI_DXE_SERVICES_SIGNATURE, // Signature
+ EFI_DXE_SERVICES_REVISION, // Revision
+ sizeof (EFI_DXE_SERVICES), // HeaderSize
+ 0, // CRC32
+ 0 // Reserved
+ },
+ (EFI_ADD_MEMORY_SPACE) CoreAddMemorySpace, // AddMemorySpace
+ (EFI_ALLOCATE_MEMORY_SPACE) CoreAllocateMemorySpace, // AllocateMemorySpace
+ (EFI_FREE_MEMORY_SPACE) CoreFreeMemorySpace, // FreeMemorySpace
+ (EFI_REMOVE_MEMORY_SPACE) CoreRemoveMemorySpace, // RemoveMemorySpace
+ (EFI_GET_MEMORY_SPACE_DESCRIPTOR) CoreGetMemorySpaceDescriptor, // GetMemorySpaceDescriptor
+ (EFI_SET_MEMORY_SPACE_ATTRIBUTES) CoreSetMemorySpaceAttributes, // SetMemorySpaceAttributes
+ (EFI_GET_MEMORY_SPACE_MAP) CoreGetMemorySpaceMap, // GetMemorySpaceMap
+ (EFI_ADD_IO_SPACE) CoreAddIoSpace, // AddIoSpace
+ (EFI_ALLOCATE_IO_SPACE) CoreAllocateIoSpace, // AllocateIoSpace
+ (EFI_FREE_IO_SPACE) CoreFreeIoSpace, // FreeIoSpace
+ (EFI_REMOVE_IO_SPACE) CoreRemoveIoSpace, // RemoveIoSpace
+ (EFI_GET_IO_SPACE_DESCRIPTOR) CoreGetIoSpaceDescriptor, // GetIoSpaceDescriptor
+ (EFI_GET_IO_SPACE_MAP) CoreGetIoSpaceMap, // GetIoSpaceMap
+ (EFI_DISPATCH) CoreDispatcher, // Dispatch
+ (EFI_SCHEDULE) CoreSchedule, // Schedule
+ (EFI_TRUST) CoreTrust, // Trust
+ (EFI_PROCESS_FIRMWARE_VOLUME) CoreProcessFirmwareVolume, // ProcessFirmwareVolume
+};
+
+EFI_SYSTEM_TABLE mEfiSystemTableTemplate = {
+ {
+ EFI_SYSTEM_TABLE_SIGNATURE, // Signature
+ EFI_SYSTEM_TABLE_REVISION, // Revision
+ sizeof (EFI_SYSTEM_TABLE), // HeaderSize
+ 0, // CRC32
+ 0 // Reserved
+ },
+ NULL, // FirmwareVendor
+ 0, // FirmwareRevision
+ NULL, // ConsoleInHandle
+ NULL, // ConIn
+ NULL, // ConsoleOutHandle
+ NULL, // ConOut
+ NULL, // StandardErrorHandle
+ NULL, // StdErr
+ NULL, // RuntimeServices
+ &mBootServices, // BootServices
+ 0, // NumberOfConfigurationTableEntries
+ NULL // ConfigurationTable
+};
+
+EFI_RUNTIME_SERVICES mEfiRuntimeServicesTableTemplate = {
+ {
+ EFI_RUNTIME_SERVICES_SIGNATURE, // Signature
+ EFI_RUNTIME_SERVICES_REVISION, // Revision
+ sizeof (EFI_RUNTIME_SERVICES), // HeaderSize
+ 0, // CRC32
+ 0 // Reserved
+ },
+ (EFI_GET_TIME) CoreEfiNotAvailableYetArg2, // GetTime
+ (EFI_SET_TIME) CoreEfiNotAvailableYetArg1, // SetTime
+ (EFI_GET_WAKEUP_TIME) CoreEfiNotAvailableYetArg3, // GetWakeupTime
+ (EFI_SET_WAKEUP_TIME) CoreEfiNotAvailableYetArg2, // SetWakeupTime
+ (EFI_SET_VIRTUAL_ADDRESS_MAP) CoreEfiNotAvailableYetArg4, // SetVirtualAddressMap
+ (EFI_CONVERT_POINTER) CoreEfiNotAvailableYetArg2, // ConvertPointer
+ (EFI_GET_VARIABLE) CoreEfiNotAvailableYetArg5, // GetVariable
+ (EFI_GET_NEXT_VARIABLE_NAME) CoreEfiNotAvailableYetArg3, // GetNextVariableName
+ (EFI_SET_VARIABLE) CoreEfiNotAvailableYetArg5, // SetVariable
+ (EFI_GET_NEXT_HIGH_MONO_COUNT) CoreEfiNotAvailableYetArg1, // GetNextHighMonotonicCount
+ (EFI_RESET_SYSTEM) CoreEfiNotAvailableYetArg4, // ResetSystem
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+ (EFI_UPDATE_CAPSULE) CoreEfiNotAvailableYetArg3, // UpdateCapsule
+ (EFI_QUERY_CAPSULE_CAPABILITIES) CoreEfiNotAvailableYetArg4, // QueryCapsuleCapabilities
+ (EFI_QUERY_VARIABLE_INFO) CoreEfiNotAvailableYetArg4 // QueryVariableInfo
+#elif (TIANO_RELEASE_VERSION != 0)
+ (EFI_REPORT_STATUS_CODE) CoreEfiNotAvailableYetArg5 // ReportStatusCode
+#endif
+};
+
+EFI_RUNTIME_ARCH_PROTOCOL gRuntimeTemplate = {
+ INITIALIZE_LIST_HEAD_VARIABLE (gRuntimeTemplate.ImageHead),
+ INITIALIZE_LIST_HEAD_VARIABLE (gRuntimeTemplate.EventHead),
+
+ //
+ // Make sure Size != sizeof (EFI_MEMORY_DESCRIPTOR). This will
+ // prevent people from having pointer math bugs in their code.
+ // now you have to use *DescriptorSize to make things work.
+ //
+ sizeof (EFI_MEMORY_DESCRIPTOR) + sizeof (UINT64) - (sizeof (EFI_MEMORY_DESCRIPTOR) % sizeof (UINT64)),
+ EFI_MEMORY_DESCRIPTOR_VERSION,
+ 0,
+ NULL,
+ NULL,
+ FALSE,
+ FALSE
+};
+
+EFI_RUNTIME_ARCH_PROTOCOL *gRuntime = &gRuntimeTemplate;
+
+//
+// DXE Core Global Variables for the EFI System Table, Boot Services Table,
+// DXE Services Table, and Runtime Services Table
+//
+EFI_BOOT_SERVICES *gBS = &mBootServices;
+EFI_DXE_SERVICES *gDS = &mDxeServices;
+EFI_SYSTEM_TABLE *gST = NULL;
+
+//
+// For debug initialize gRT to template. gRT must be allocated from RT memory
+// but gRT is used for ASSERT () and DEBUG () type macros so lets give it
+// a value that will not cause debug infrastructure to crash early on.
+//
+EFI_RUNTIME_SERVICES *gRT = &mEfiRuntimeServicesTableTemplate;
+EFI_HANDLE gDxeCoreImageHandle;
+
+VOID *mHobStart;
+
+//
+// Main entry point to the DXE Core
+//
+EFI_DXE_ENTRY_POINT (DxeMain)
+
+VOID
+EFIAPI
+DxeMain (
+ IN VOID *HobStart
+ )
+/*++
+
+Routine Description:
+
+ Main entry point to DXE Core.
+
+Arguments:
+
+ HobStart - Pointer to the beginning of the HOB List from PEI
+
+Returns:
+
+ This function should never return
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_HANDLE DecompressHandle;
+ EFI_PHYSICAL_ADDRESS MemoryBaseAddress;
+ UINT64 MemoryLength;
+
+#ifdef FIRMWARE_PERFORMANCE
+ UINT64 Tick;
+
+ GetTimerValue (&Tick);
+#endif
+
+
+ mHobStart = HobStart;
+
+ //
+ // Initialize Memory Services
+ //
+ CoreInitializeMemoryServices (&HobStart, &MemoryBaseAddress, &MemoryLength);
+
+ //
+ // Allocate the EFI System Table and EFI Runtime Service Table from EfiRuntimeServicesData
+ // Use the templates to initialize the contents of the EFI System Table and EFI Runtime Services Table
+ //
+ gST = CoreAllocateRuntimeCopyPool (sizeof (EFI_SYSTEM_TABLE), &mEfiSystemTableTemplate);
+ ASSERT (gST != NULL);
+ if (gST == NULL) {
+ //
+ // Failed to allocate memory for EFI System Table. No recovery path implemented as this is not expected to occur.
+ //
+ EFI_DEADLOOP ();
+ }
+
+ gRT = CoreAllocateRuntimeCopyPool (sizeof (EFI_RUNTIME_SERVICES), &mEfiRuntimeServicesTableTemplate);
+ ASSERT (gRT != NULL);
+
+ gST->RuntimeServices = gRT;
+
+ //
+ // Start the Image Services.
+ //
+ Status = CoreInitializeImageServices (HobStart);
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // Initialize the Global Coherency Domain Services
+ //
+ Status = CoreInitializeGcdServices (&HobStart, MemoryBaseAddress, MemoryLength);
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // The HobStart is relocated in gcd service init. Sync mHobStart variable.
+ //
+ mHobStart = HobStart;
+
+ //
+ // Install the DXE Services Table into the EFI System Tables's Configuration Table
+ //
+ Status = CoreInstallConfigurationTable (&gEfiDxeServicesTableGuid, gDS);
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // Install the HOB List into the EFI System Tables's Configuration Table
+ //
+ Status = CoreInstallConfigurationTable (&gEfiHobListGuid, HobStart);
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // Install Memory Type Information Table into the EFI System Tables's Configuration Table
+ //
+ Status = CoreInstallConfigurationTable (&gEfiMemoryTypeInformationGuid, &gMemoryTypeInformation);
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // Initialize the ReportStatusCode with PEI version, if availible
+ //
+ CoreGetPeiProtocol (&gEfiStatusCodeRuntimeProtocolGuid, (VOID **)&gStatusCode->ReportStatusCode);
+#if ((TIANO_RELEASE_VERSION != 0) && (EFI_SPECIFICATION_VERSION < 0x00020000))
+ if (gStatusCode->ReportStatusCode != NULL) {
+ gRT->ReportStatusCode = gStatusCode->ReportStatusCode;
+ }
+#endif
+
+ //
+ // Report Status Code here for DXE_ENTRY_POINT once it is available
+ //
+ CoreReportProgressCode ((EFI_SOFTWARE_DXE_CORE | EFI_SW_DXE_CORE_PC_ENTRY_POINT));
+
+ //
+ // Create the aligned system table pointer structure that is used by external
+ // debuggers to locate the system table... Also, install debug image info
+ // configuration table.
+ //
+ CoreInitializeDebugImageInfoTable ();
+ CoreNewDebugImageInfoEntry (
+ EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL,
+ gDxeCoreLoadedImage,
+ gDxeCoreImageHandle
+ );
+
+ DEBUG_CODE (
+ DEBUG ((EFI_D_INFO | EFI_D_LOAD, "HOBLIST address in DXE = 0x%x\n", HobStart));
+ )
+ //
+ // Initialize the Event Services
+ //
+ Status = CoreInitializeEventServices ();
+ ASSERT_EFI_ERROR (Status);
+
+
+ //
+ // Get the Protocols that were passed in from PEI to DXE through GUIDed HOBs
+ //
+ // These Protocols are not architectural. This implementation is sharing code between
+ // PEI and DXE in order to save FLASH space. These Protocols could also be implemented
+ // as part of the DXE Core. However, that would also require the DXE Core to be ported
+ // each time a different CPU is used, a different Decompression algorithm is used, or a
+ // different Image type is used. By placing these Protocols in PEI, the DXE Core remains
+ // generic, and only PEI and the Arch Protocols need to be ported from Platform to Platform,
+ // and from CPU to CPU.
+ //
+
+ Status = CoreGetPeiProtocol (&gEfiDecompressProtocolGuid, &gEfiDecompress);
+ if (!EFI_ERROR (Status)) {
+
+ //
+ // Publish the EFI Decompress protocol for use by other DXE components
+ //
+
+ DecompressHandle = NULL;
+ Status = CoreInstallProtocolInterface (
+ &DecompressHandle,
+ &gEfiDecompressProtocolGuid,
+ EFI_NATIVE_INTERFACE,
+ gEfiDecompress
+ );
+ ASSERT_EFI_ERROR (Status);
+ }
+
+ Status = CoreGetPeiProtocol (&gEfiTianoDecompressProtocolGuid, &gEfiTianoDecompress);
+ if (!EFI_ERROR (Status)) {
+
+ //
+ // Publish the Tiano Decompress protocol for use by other DXE components
+ //
+
+ DecompressHandle = NULL;
+ Status = CoreInstallProtocolInterface (
+ &DecompressHandle,
+ &gEfiTianoDecompressProtocolGuid,
+ EFI_NATIVE_INTERFACE,
+ gEfiTianoDecompress
+ );
+ ASSERT_EFI_ERROR (Status);
+ }
+
+ Status = CoreGetPeiProtocol (&gEfiCustomizedDecompressProtocolGuid, &gEfiCustomizedDecompress);
+ if (!EFI_ERROR (Status)) {
+
+ //
+ // Publish the Tiano Decompress protocol for use by other DXE components
+ //
+ DecompressHandle = NULL;
+ Status = CoreInstallProtocolInterface (
+ &DecompressHandle,
+ &gEfiCustomizedDecompressProtocolGuid,
+ EFI_NATIVE_INTERFACE,
+ gEfiCustomizedDecompress
+ );
+ ASSERT_EFI_ERROR (Status);
+ }
+
+ CoreGetPeiProtocol (&gEfiPeiFlushInstructionCacheGuid, &gEfiPeiFlushInstructionCache);
+
+ CoreGetPeiProtocol (&gEfiPeiPeCoffLoaderGuid, &gEfiPeiPeCoffLoader);
+
+ CoreGetPeiProtocol (&gEfiPeiTransferControlGuid, &gEfiPeiTransferControl);
+
+
+ //
+ // Register for the GUIDs of the Architectural Protocols, so the rest of the
+ // EFI Boot Services and EFI Runtime Services tables can be filled in.
+ //
+ CoreNotifyOnArchProtocolInstallation ();
+
+ //
+ // Produce Firmware Volume Protocols, one for each FV in the HOB list.
+ //
+ Status = FwVolBlockDriverInit (gDxeCoreImageHandle, gST);
+ ASSERT_EFI_ERROR (Status);
+
+ Status = FwVolDriverInit (gDxeCoreImageHandle, gST);
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // Produce the Section Extraction Protocol
+ //
+ Status = InitializeSectionExtraction (gDxeCoreImageHandle, gST);
+ ASSERT_EFI_ERROR (Status);
+
+
+ //
+ // Initialize Performance monitoring if enabled in build
+ //
+ PERF_ENABLE (0, gST, Tick);
+
+ PERF_START (0,DXE_TOK, NULL, Tick) ;
+
+ //
+ // Initialize the DXE Dispatcher
+ //
+ PERF_START (0,L"CoreInitializeDispatcher", L"DxeMain", 0) ;
+ CoreInitializeDispatcher ();
+ PERF_END (0,L"CoreInitializeDispatcher", L"DxeMain", 0) ;
+
+ //
+ // Invoke the DXE Dispatcher
+ //
+ PERF_START (0, L"CoreDispatcher", L"DxeMain", 0);
+ CoreDispatcher ();
+ PERF_END (0, L"CoreDispatcher", L"DxeMain", 0);
+
+ //
+ // Display Architectural protocols that were not loaded if this is DEBUG build
+ //
+ DEBUG_CODE (
+ CoreDisplayMissingArchProtocols ();
+ )
+
+ //
+ // Assert if the Architectural Protocols are not present.
+ //
+ ASSERT_EFI_ERROR (CoreAllEfiServicesAvailable ());
+
+ //
+ // Report Status code before transfer control to BDS
+ //
+ CoreReportProgressCode ((EFI_SOFTWARE_DXE_CORE | EFI_SW_DXE_CORE_PC_HANDOFF_TO_NEXT));
+
+ //
+ // Display any drivers that were not dispatched because dependency expression
+ // evaluated to false if this is a debug build
+ //
+ DEBUG_CODE (
+ CoreDisplayDiscoveredNotDispatched ();
+ )
+
+ //
+ // Transfer control to the BDS Architectural Protocol
+ //
+ gBds->Entry (gBds);
+
+ //
+ // BDS should never return
+ //
+ ASSERT (FALSE);
+ EFI_DEADLOOP ();
+}
+
+
+EFI_STATUS
+EFIAPI
+CoreEfiNotAvailableYetArg0 (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Place holder function until all the Boot Services and Runtime Services are available
+
+Arguments:
+
+ None
+
+Returns:
+
+ EFI_NOT_AVAILABLE_YET
+
+--*/
+{
+ //
+ // This function should never be executed. If it does, then the architectural protocols
+ // have not been designed correctly. The EFI_BREAKPOINT() is commented out for now until the
+ // DXE Core and all the Architectural Protocols are complete.
+ //
+
+ return EFI_NOT_AVAILABLE_YET;
+}
+
+EFI_STATUS
+EFIAPI
+CoreEfiNotAvailableYetArg1 (
+ UINTN Arg1
+ )
+/*++
+
+Routine Description:
+
+ Place holder function until all the Boot Services and Runtime Services are available
+
+Arguments:
+
+ Arg1 - Undefined
+
+Returns:
+
+ EFI_NOT_AVAILABLE_YET
+
+--*/
+{
+ //
+ // This function should never be executed. If it does, then the architectural protocols
+ // have not been designed correctly. The EFI_BREAKPOINT() is commented out for now until the
+ // DXE Core and all the Architectural Protocols are complete.
+ //
+
+ return EFI_NOT_AVAILABLE_YET;
+}
+
+EFI_STATUS
+EFIAPI
+CoreEfiNotAvailableYetArg2 (
+ UINTN Arg1,
+ UINTN Arg2
+ )
+/*++
+
+Routine Description:
+
+ Place holder function until all the Boot Services and Runtime Services are available
+
+Arguments:
+
+ Arg1 - Undefined
+
+ Arg2 - Undefined
+
+Returns:
+
+ EFI_NOT_AVAILABLE_YET
+
+--*/
+{
+ //
+ // This function should never be executed. If it does, then the architectural protocols
+ // have not been designed correctly. The EFI_BREAKPOINT() is commented out for now until the
+ // DXE Core and all the Architectural Protocols are complete.
+ //
+
+ return EFI_NOT_AVAILABLE_YET;
+}
+
+EFI_STATUS
+EFIAPI
+CoreEfiNotAvailableYetArg3 (
+ UINTN Arg1,
+ UINTN Arg2,
+ UINTN Arg3
+ )
+/*++
+
+Routine Description:
+
+ Place holder function until all the Boot Services and Runtime Services are available
+
+Arguments:
+
+ Arg1 - Undefined
+
+ Arg2 - Undefined
+
+ Arg3 - Undefined
+
+Returns:
+
+ EFI_NOT_AVAILABLE_YET
+
+--*/
+{
+ //
+ // This function should never be executed. If it does, then the architectural protocols
+ // have not been designed correctly. The EFI_BREAKPOINT() is commented out for now until the
+ // DXE Core and all the Architectural Protocols are complete.
+ //
+
+ return EFI_NOT_AVAILABLE_YET;
+}
+
+EFI_STATUS
+EFIAPI
+CoreEfiNotAvailableYetArg4 (
+ UINTN Arg1,
+ UINTN Arg2,
+ UINTN Arg3,
+ UINTN Arg4
+ )
+/*++
+
+Routine Description:
+
+ Place holder function until all the Boot Services and Runtime Services are available
+
+Arguments:
+
+ Arg1 - Undefined
+
+ Arg2 - Undefined
+
+ Arg3 - Undefined
+
+ Arg4 - Undefined
+
+Returns:
+
+ EFI_NOT_AVAILABLE_YET
+
+--*/
+{
+ //
+ // This function should never be executed. If it does, then the architectural protocols
+ // have not been designed correctly. The EFI_BREAKPOINT() is commented out for now until the
+ // DXE Core and all the Architectural Protocols are complete.
+ //
+
+ return EFI_NOT_AVAILABLE_YET;
+}
+
+EFI_STATUS
+EFIAPI
+CoreEfiNotAvailableYetArg5 (
+ UINTN Arg1,
+ UINTN Arg2,
+ UINTN Arg3,
+ UINTN Arg4,
+ UINTN Arg5
+ )
+/*++
+
+Routine Description:
+
+ Place holder function until all the Boot Services and Runtime Services are available
+
+Arguments:
+
+ Arg1 - Undefined
+
+ Arg2 - Undefined
+
+ Arg3 - Undefined
+
+ Arg4 - Undefined
+
+ Arg5 - Undefined
+
+Returns:
+
+ EFI_NOT_AVAILABLE_YET
+
+--*/
+{
+ //
+ // This function should never be executed. If it does, then the architectural protocols
+ // have not been designed correctly. The EFI_BREAKPOINT() is commented out for now until the
+ // DXE Core and all the Architectural Protocols are complete.
+ //
+
+ return EFI_NOT_AVAILABLE_YET;
+}
+
+
+EFI_STATUS
+CoreGetPeiProtocol (
+ IN EFI_GUID *ProtocolGuid,
+ IN VOID **Interface
+ )
+/*++
+
+Routine Description:
+
+ Searches for a Protocol Interface passed from PEI through a HOB
+
+Arguments:
+
+ ProtocolGuid - The Protocol GUID to search for in the HOB List
+
+ Interface - A pointer to the interface for the Protocol GUID
+
+Returns:
+
+ EFI_SUCCESS - The Protocol GUID was found and its interface is returned in Interface
+
+ EFI_NOT_FOUND - The Protocol GUID was not found in the HOB List
+
+--*/
+{
+ EFI_STATUS Status;
+ VOID *HobList;
+ VOID *Buffer;
+
+ //
+ // Initialize 'Buffer' to NULL before usage.
+ //
+ Buffer = NULL;
+
+ HobList = mHobStart;
+ Status = GetNextGuidHob (&HobList, ProtocolGuid, &Buffer, NULL);
+ if (EFI_ERROR (Status) || (Buffer == NULL)) {
+ //
+ // Failed to find a HOB containing the desired protocol
+ //
+ return Status;
+ }
+
+ ASSERT (Buffer != NULL);
+
+ *Interface = (VOID *)(*(UINTN *)(Buffer));
+
+ return Status;
+}
+
+
+VOID
+CalculateEfiHdrCrc (
+ IN OUT EFI_TABLE_HEADER *Hdr
+ )
+/*++
+
+Routine Description:
+
+ Calcualte the 32-bit CRC in a EFI table using the service provided by the
+ gRuntime service.
+
+Arguments:
+
+ Hdr - Pointer to an EFI standard header
+
+Returns:
+
+ None
+
+--*/
+{
+ UINT32 Crc;
+
+ Hdr->CRC32 = 0;
+
+ //
+ // If gBS->CalculateCrce32 () == CoreEfiNotAvailableYet () then
+ // Crc will come back as zero if we set it to zero here
+ //
+ Crc = 0;
+ gBS->CalculateCrc32 ((UINT8 *)Hdr, Hdr->HeaderSize, &Crc);
+ Hdr->CRC32 = Crc;
+}
+
+
+EFI_BOOTSERVICE
+EFI_STATUS
+EFIAPI
+CoreExitBootServices (
+ IN EFI_HANDLE ImageHandle,
+ IN UINTN MapKey
+ )
+/*++
+
+Routine Description:
+
+ Terminates all boot services.
+
+Arguments:
+
+ ImageHandle - Handle that identifies the exiting image.
+ MapKey - Key to the latest memory map.
+
+Returns:
+
+ EFI_SUCCESS - Boot services have been terminated.
+ EFI_INVALID_PARAMETER - MapKey is incorrect.
+
+--*/
+{
+ EFI_STATUS Status, Status2;
+ EFI_TCG_PLATFORM_PROTOCOL *TcgPlatformProtocol;
+
+ //
+ // Measure invocation of ExitBootServices,
+ // which is defined by TCG_EFI_Platform_1_20_Final Specification
+ //
+ TcgPlatformProtocol = NULL;
+ Status = CoreLocateProtocol (
+ &gEfiTcgPlatformProtocolGuid,
+ NULL,
+ &TcgPlatformProtocol
+ );
+ if (!EFI_ERROR (Status) && (TcgPlatformProtocol != NULL)) {
+ Status = TcgPlatformProtocol->MeasureAction (EFI_EXIT_BOOT_SERVICES_INVOCATION);
+ ASSERT_EFI_ERROR (Status);
+ }
+
+ //
+ // Terminate memory services if the MapKey matches
+ //
+ Status = CoreTerminateMemoryMap (MapKey);
+ if (EFI_ERROR (Status)) {
+ //
+ // Measure failure of ExitBootServices
+ //
+ if (TcgPlatformProtocol != NULL) {
+ Status2 = TcgPlatformProtocol->MeasureAction (EFI_EXIT_BOOT_SERVICES_FAILED);
+ ASSERT_EFI_ERROR (Status2);
+ }
+
+ return Status;
+ }
+
+ //
+ // Disable Timer
+ //
+ gTimer->SetTimerPeriod (gTimer, 0);
+
+
+ //
+ // Notify other drivers that we are exiting boot services.
+ //
+ CoreNotifySignalList (&gEfiEventExitBootServicesGuid);
+
+
+
+ //
+ // Disable CPU Interrupts
+ //
+ gCpu->DisableInterrupt (gCpu);
+
+ //
+ // Report that ExitBootServices() has been called
+ //
+ // We are using gEfiDxeServicesTableGuid as the caller ID for Dxe Core
+ //
+ CoreReportProgressCode ((EFI_SOFTWARE_EFI_BOOT_SERVICE | EFI_SW_BS_PC_EXIT_BOOT_SERVICES));
+
+ //
+ // Clear the non-runtime values of the EFI System Table
+ //
+ gST->BootServices = NULL;
+ gST->ConIn = NULL;
+ gST->ConsoleInHandle = NULL;
+ gST->ConOut = NULL;
+ gST->ConsoleOutHandle = NULL;
+ gST->StdErr = NULL;
+ gST->StandardErrorHandle = NULL;
+
+ //
+ // Recompute the 32-bit CRC of the EFI System Table
+ //
+ CalculateEfiHdrCrc (&gST->Hdr);
+
+ //
+ // Update the AtRuntime field in Runtiem AP.
+ //
+ gRuntime->AtRuntime = TRUE;
+
+ //
+ // Measure success of ExitBootServices
+ //
+ if (TcgPlatformProtocol != NULL) {
+ Status2 = TcgPlatformProtocol->MeasureAction (EFI_EXIT_BOOT_SERVICES_SUCCEEDED);
+ ASSERT_EFI_ERROR (Status2);
+ }
+
+ //
+ // Zero out the Boot Service Table
+ //
+ EfiCommonLibSetMem (gBS, sizeof (EFI_BOOT_SERVICES), 0);
+ gBS = NULL;
+
+ return Status;
+}
diff --git a/EDK/Foundation/Core/Dxe/DxeMain/DxeProtocolNotify.c b/EDK/Foundation/Core/Dxe/DxeMain/DxeProtocolNotify.c
new file mode 100644
index 0000000..15886f9
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/DxeMain/DxeProtocolNotify.c
@@ -0,0 +1,319 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ DxeProtocolNotify.c
+
+Abstract:
+
+ This file deals with Architecture Protocol (AP) registration in
+ the Dxe Core. The mArchProtocols[] array represents a list of
+ events that represent the Architectural Protocols.
+
+--*/
+
+#include "Tiano.h"
+#include "DxeCore.h"
+
+
+//
+// DXE Core Global Variables for all of the Architectural Protocols.
+// If a protocol is installed mArchProtocols[].Present will be TRUE.
+//
+// CoreNotifyOnArchProtocolInstallation () fills in mArchProtocols[].Event
+// and mArchProtocols[].Registration as it creates events for every array
+// entry.
+//
+
+ARCHITECTURAL_PROTOCOL_ENTRY mArchProtocols[] = {
+ { &gEfiSecurityArchProtocolGuid, &gSecurity, NULL, NULL, FALSE},
+ { &gEfiCpuArchProtocolGuid, &gCpu, NULL, NULL, FALSE},
+ { &gEfiMetronomeArchProtocolGuid, &gMetronome, NULL, NULL, FALSE},
+ { &gEfiTimerArchProtocolGuid, &gTimer, NULL, NULL, FALSE},
+ { &gEfiBdsArchProtocolGuid, &gBds, NULL, NULL, FALSE},
+ { &gEfiWatchdogTimerArchProtocolGuid, &gWatchdogTimer, NULL, NULL, FALSE},
+ { &gEfiRuntimeArchProtocolGuid, &gRuntime, NULL, NULL, FALSE},
+ { &gEfiVariableArchProtocolGuid, NULL, NULL, NULL, FALSE},
+ { &gEfiVariableWriteArchProtocolGuid, NULL, NULL, NULL, FALSE},
+ #if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+ { &gEfiCapsuleArchProtocolGuid, NULL, NULL, NULL, FALSE},
+ #endif
+ { &gEfiMonotonicCounterArchProtocolGuid, NULL, NULL, NULL, FALSE},
+ { &gEfiResetArchProtocolGuid, NULL, NULL, NULL, FALSE},
+ { &gEfiStatusCodeRuntimeProtocolGuid, NULL, NULL, NULL, FALSE},
+ { &gEfiRealTimeClockArchProtocolGuid, NULL, NULL, NULL, FALSE},
+ NULL
+};
+
+
+EFI_STATUS
+CoreAllEfiServicesAvailable (
+ VOID
+ )
+/*++
+
+Routine Description:
+ Return TRUE if all AP services are availible.
+
+Arguments:
+ NONE
+
+Returns:
+ EFI_SUCCESS - All AP services are available
+ EFI_NOT_FOUND - At least one AP service is not available
+
+--*/
+{
+ ARCHITECTURAL_PROTOCOL_ENTRY *Entry;
+
+ for (Entry = mArchProtocols; Entry->ProtocolGuid != NULL; Entry++) {
+ if (!Entry->Present) {
+ return EFI_NOT_FOUND;
+ }
+ }
+
+ return EFI_SUCCESS;
+}
+
+
+VOID
+EFIAPI
+GenericArchProtocolNotify (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+/*++
+
+Routine Description:
+ Notification event handler registered by CoreNotifyOnArchProtocolInstallation ().
+ This notify function is registered for every architectural protocol. This handler
+ updates mArchProtocol[] array entry with protocol instance data and sets it's
+ present flag to TRUE. If any constructor is required it is executed. The EFI
+ System Table headers are updated.
+
+Arguments:
+
+ Event - The Event that is being processed, not used.
+
+ Context - Event Context, not used.
+
+Returns:
+
+ None
+
+--*/
+{
+ EFI_STATUS Status;
+ ARCHITECTURAL_PROTOCOL_ENTRY *Entry;
+ VOID *Protocol;
+ BOOLEAN Found;
+ EFI_LIST_ENTRY *Link;
+ EFI_LIST_ENTRY TempLinkNode;
+
+ Found = FALSE;
+ for (Entry = mArchProtocols; Entry->ProtocolGuid != NULL; Entry++) {
+
+ Status = CoreLocateProtocol (Entry->ProtocolGuid, Entry->Registration, &Protocol);
+ if (EFI_ERROR (Status)) {
+ continue;
+ }
+
+ Found = TRUE;
+ Entry->Present = TRUE;
+
+ //
+ // Update protocol global variable if one exists. Entry->Protocol points to a global variable
+ // if one exists in the DXE core for this Architectural Protocol
+ //
+ if (Entry->Protocol != NULL) {
+ *(Entry->Protocol) = Protocol;
+ }
+
+ if (EfiCompareGuid (Entry->ProtocolGuid, &gEfiTimerArchProtocolGuid)) {
+ //
+ // Register the Core timer tick handler with the Timer AP
+ //
+ gTimer->RegisterHandler (gTimer, CoreTimerTick);
+ }
+
+ if (EfiCompareGuid (Entry->ProtocolGuid, &gEfiRuntimeArchProtocolGuid)) {
+ //
+ // When runtime architectural protocol is available, updates CRC32 in the Debug Table
+ //
+ CoreUpdateDebugTableCrc32 ();
+
+ //
+ // Update the Runtime Architectural protocol with the template that the core was
+ // using so there would not need to be a dependency on the Runtime AP
+ //
+
+ //
+ // Copy all the registered Image to new gRuntime protocol
+ //
+ for (Link = gRuntimeTemplate.ImageHead.ForwardLink; Link != &gRuntimeTemplate.ImageHead; Link = TempLinkNode.ForwardLink) {
+ EfiCommonLibCopyMem (&TempLinkNode, Link, sizeof(EFI_LIST_ENTRY));
+ InsertTailList (&gRuntime->ImageHead, Link);
+ }
+ //
+ // Copy all the registered Event to new gRuntime protocol
+ //
+ for (Link = gRuntimeTemplate.EventHead.ForwardLink; Link != &gRuntimeTemplate.EventHead; Link = TempLinkNode.ForwardLink) {
+ EfiCommonLibCopyMem (&TempLinkNode, Link, sizeof(EFI_LIST_ENTRY));
+ InsertTailList (&gRuntime->EventHead, Link);
+ }
+
+ //
+ // Clean up gRuntimeTemplate
+ //
+ gRuntimeTemplate.ImageHead.ForwardLink = &gRuntimeTemplate.ImageHead;
+ gRuntimeTemplate.ImageHead.BackLink = &gRuntimeTemplate.ImageHead;
+ gRuntimeTemplate.EventHead.ForwardLink = &gRuntimeTemplate.EventHead;
+ gRuntimeTemplate.EventHead.BackLink = &gRuntimeTemplate.EventHead;
+ }
+
+ if (EfiCompareGuid (Entry->ProtocolGuid, &gEfiStatusCodeRuntimeProtocolGuid)) {
+ //
+ // Update StatusCode instance used by DXE core
+ //
+ gStatusCode = (EFI_STATUS_CODE_PROTOCOL *) Protocol;
+ }
+ }
+
+ //
+ // It's over kill to do them all every time, but it saves a lot of code.
+ //
+ if (Found) {
+ CalculateEfiHdrCrc (&gRT->Hdr);
+ CalculateEfiHdrCrc (&gBS->Hdr);
+ CalculateEfiHdrCrc (&gST->Hdr);
+ CalculateEfiHdrCrc (&gDS->Hdr);
+ }
+}
+
+
+
+VOID
+CoreNotifyOnArchProtocolInstallation (
+ VOID
+ )
+/*++
+
+Routine Description:
+ Creates an event that is fired everytime a Protocol of a specific type is installed
+
+Arguments:
+ NONE
+
+Returns:
+ NONE
+
+--*/
+{
+ EFI_STATUS Status;
+ ARCHITECTURAL_PROTOCOL_ENTRY *Entry;
+
+ for (Entry = mArchProtocols; Entry->ProtocolGuid != NULL; Entry++) {
+
+ //
+ // Create the event
+ //
+ Status = CoreCreateEvent (
+ EFI_EVENT_NOTIFY_SIGNAL,
+ EFI_TPL_CALLBACK,
+ GenericArchProtocolNotify,
+ NULL,
+ &Entry->Event
+ );
+ ASSERT_EFI_ERROR(Status);
+
+ //
+ // Register for protocol notifactions on this event
+ //
+ Status = CoreRegisterProtocolNotify (
+ Entry->ProtocolGuid,
+ Entry->Event,
+ &Entry->Registration
+ );
+ ASSERT_EFI_ERROR(Status);
+
+ }
+}
+
+#ifdef EFI_DEBUG
+//
+// Following is needed to display missing architectural protocols in debug builds
+//
+typedef struct {
+ EFI_GUID *ProtocolGuid;
+ CHAR16 *GuidString;
+} GUID_TO_STRING_PROTOCOL_ENTRY;
+
+GUID_TO_STRING_PROTOCOL_ENTRY MissingProtocols[] = {
+ { &gEfiSecurityArchProtocolGuid, L"Security" },
+ { &gEfiCpuArchProtocolGuid, L"CPU" },
+ { &gEfiMetronomeArchProtocolGuid, L"Metronome" },
+ { &gEfiTimerArchProtocolGuid, L"Timer" },
+ { &gEfiBdsArchProtocolGuid, L"Bds" },
+ { &gEfiWatchdogTimerArchProtocolGuid, L"Watchdog Timer" },
+ { &gEfiRuntimeArchProtocolGuid, L"Runtime" },
+ { &gEfiVariableArchProtocolGuid, L"Variable" },
+ { &gEfiVariableWriteArchProtocolGuid, L"Variable Write" },
+ #if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+ { &gEfiCapsuleArchProtocolGuid, L"Capsule" },
+ #endif
+ { &gEfiMonotonicCounterArchProtocolGuid, L"Monotonic Counter" },
+ { &gEfiResetArchProtocolGuid, L"Reset" },
+ { &gEfiStatusCodeRuntimeProtocolGuid, L"Status Code" },
+ { &gEfiRealTimeClockArchProtocolGuid, L"Real Time Clock" }
+};
+#endif
+
+DEBUG_CODE (
+VOID
+CoreDisplayMissingArchProtocols (
+ VOID
+ )
+/*++
+
+Routine Description:
+ Displays Architectural protocols that were not loaded and are required for DXE core to function
+ Only used in Debug Builds
+
+Arguments:
+ NONE
+
+Returns:
+ NONE
+
+--*/
+{
+
+
+ GUID_TO_STRING_PROTOCOL_ENTRY *MissingEntry;
+
+ ARCHITECTURAL_PROTOCOL_ENTRY *Entry;
+
+
+ for (Entry = mArchProtocols; Entry->ProtocolGuid != NULL; Entry++) {
+ if (!Entry->Present) {
+ MissingEntry = MissingProtocols;
+ for (MissingEntry = MissingProtocols; TRUE ; MissingEntry++) {
+ if (EfiCompareGuid (Entry->ProtocolGuid, MissingEntry->ProtocolGuid)) {
+ DEBUG ((EFI_D_ERROR, "\n%s Arch Protocol not present!!\n", MissingEntry->GuidString));
+ break;
+ }
+ }
+ }
+
+ }
+}
+)
diff --git a/EDK/Foundation/Core/Dxe/Event/event.c b/EDK/Foundation/Core/Dxe/Event/event.c
new file mode 100644
index 0000000..ee2eefa
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/Event/event.c
@@ -0,0 +1,845 @@
+/*++
+
+Copyright (c) 2004 - 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ event.c
+
+Abstract:
+
+ EFI Event support.
+
+--*/
+
+#include "exec.h"
+#include "hand.h"
+
+//
+// Enumerate the valid types
+//
+UINT32 mEventTable[] = {
+ //
+ // 0x80000200 Timer event with a notification function that is
+ // queue when the event is signaled with SignalEvent()
+ //
+ EFI_EVENT_TIMER | EFI_EVENT_NOTIFY_SIGNAL,
+ //
+ // 0x80000000 Timer event without a notification function. It can be
+ // signaled with SignalEvent() and checked with CheckEvent() or WaitForEvent().
+ //
+ EFI_EVENT_TIMER,
+ //
+ // 0x00000100 Generic event with a notification function that
+ // can be waited on with CheckEvent() or WaitForEvent()
+ //
+ EFI_EVENT_NOTIFY_WAIT,
+ //
+ // 0x00000200 Generic event with a notification function that
+ // is queue when the event is signaled with SignalEvent()
+ //
+ EFI_EVENT_NOTIFY_SIGNAL,
+ //
+ // 0x00000201 ExitBootServicesEvent.
+ //
+ EFI_EVENT_SIGNAL_EXIT_BOOT_SERVICES,
+ //
+ // 0x60000202 SetVirtualAddressMapEvent.
+ //
+ EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE,
+#if (EFI_SPECIFICATION_VERSION < 0x00020000)
+ //
+ // 0x00000203 ReadyToBootEvent.
+ //
+ EFI_EVENT_SIGNAL_READY_TO_BOOT,
+ //
+ // 0x00000204 LegacyBootEvent.
+ //
+ EFI_EVENT_SIGNAL_LEGACY_BOOT,
+ //
+ // 0x00000603 Signal all ReadyToBootEvents.
+ //
+ EFI_EVENT_NOTIFY_SIGNAL_ALL | EFI_EVENT_SIGNAL_READY_TO_BOOT,
+ //
+ // 0x00000604 Signal all LegacyBootEvents.
+ //
+ EFI_EVENT_NOTIFY_SIGNAL_ALL | EFI_EVENT_SIGNAL_LEGACY_BOOT,
+#endif
+ //
+ // 0x00000000 Generic event without a notification function.
+ // It can be signaled with SignalEvent() and checked with CheckEvent()
+ // or WaitForEvent().
+ //
+ 0x00000000,
+ //
+ // 0x80000100 Timer event with a notification function that can be
+ // waited on with CheckEvent() or WaitForEvent()
+ //
+ EFI_EVENT_TIMER | EFI_EVENT_NOTIFY_WAIT,
+};
+
+
+VOID
+CoreAcquireEventLock (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Enter critical section by acquiring the lock on gEventQueueLock.
+
+Arguments:
+
+ None
+
+Returns:
+
+ None
+
+--*/
+{
+ CoreAcquireLock (&gEventQueueLock);
+}
+
+
+VOID
+CoreReleaseEventLock (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Exit critical section by releasing the lock on gEventQueueLock.
+
+Arguments:
+
+ None
+
+Returns:
+
+ None
+
+--*/
+{
+ CoreReleaseLock (&gEventQueueLock);
+}
+
+
+EFI_STATUS
+CoreInitializeEventServices (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Initializes "event" support and populates parts of the System and Runtime Table.
+
+Arguments:
+
+ None
+
+Returns:
+
+ EFI_SUCCESS - Always return success
+
+--*/
+{
+ UINTN Index;
+
+ for (Index=0; Index <= EFI_TPL_HIGH_LEVEL; Index ++) {
+ InitializeListHead (&gEventQueue[Index]);
+ }
+
+ CoreInitializeTimer ();
+
+ return EFI_SUCCESS;
+}
+
+
+VOID
+CoreDispatchEventNotifies (
+ IN EFI_TPL Priority
+ )
+/*++
+
+Routine Description:
+
+ Dispatches all pending events.
+
+Arguments:
+
+ Priority - The task priority level of event notifications to dispatch
+
+Returns:
+
+ None
+
+--*/
+{
+ IEVENT *Event;
+ EFI_LIST_ENTRY *Head;
+
+ CoreAcquireEventLock ();
+ ASSERT (gEventQueueLock.OwnerTpl == Priority);
+ Head = &gEventQueue[Priority];
+
+ //
+ // Dispatch all the pending notifications
+ //
+ while (!IsListEmpty (Head)) {
+
+ Event = CR (Head->ForwardLink, IEVENT, NotifyLink, EVENT_SIGNATURE);
+ RemoveEntryList (&Event->NotifyLink);
+
+ Event->NotifyLink.ForwardLink = NULL;
+
+ //
+ // Only clear the SIGNAL status if it is a SIGNAL type event.
+ // WAIT type events are only cleared in CheckEvent()
+ //
+ if (Event->Type & EFI_EVENT_NOTIFY_SIGNAL) {
+ Event->SignalCount = 0;
+ }
+
+ CoreReleaseEventLock ();
+
+ //
+ // Notify this event
+ //
+ Event->NotifyFunction (Event, Event->NotifyContext);
+
+ //
+ // Check for next pending event
+ //
+ CoreAcquireEventLock ();
+ }
+
+ gEventPending &= ~(1 << Priority);
+ CoreReleaseEventLock ();
+}
+
+
+VOID
+STATIC
+CoreNotifyEvent (
+ IN IEVENT *Event
+ )
+/*++
+
+Routine Description:
+
+ Queues the event's notification function to fire
+
+Arguments:
+
+ Event - The Event to notify
+
+Returns:
+
+ None
+
+--*/
+{
+
+ //
+ // Event database must be locked
+ //
+ ASSERT_LOCKED (&gEventQueueLock);
+
+ //
+ // If the event is queued somewhere, remove it
+ //
+
+ if (Event->NotifyLink.ForwardLink != NULL) {
+ RemoveEntryList (&Event->NotifyLink);
+ Event->NotifyLink.ForwardLink = NULL;
+ }
+
+ //
+ // Queue the event to the pending notification list
+ //
+
+ InsertTailList (&gEventQueue[Event->NotifyTpl], &Event->NotifyLink);
+ gEventPending |= (UINTN)1 << Event->NotifyTpl;
+}
+
+
+
+VOID
+CoreNotifySignalList (
+ IN EFI_GUID *EventGroup
+ )
+/*++
+
+Routine Description:
+
+ Signals all events on the requested list
+
+Arguments:
+
+ SignalType - The list to signal
+
+Returns:
+
+ None
+
+--*/
+{
+ EFI_LIST_ENTRY *Link;
+ EFI_LIST_ENTRY *Head;
+ IEVENT *Event;
+
+ CoreAcquireEventLock ();
+
+ Head = &gEventSignalQueue;
+ for (Link = Head->ForwardLink; Link != Head; Link = Link->ForwardLink) {
+ Event = CR (Link, IEVENT, SignalLink, EVENT_SIGNATURE);
+ if ((Event->ExFlag) && EfiCompareGuid (&Event->EventGroup, EventGroup)) {
+ CoreNotifyEvent (Event);
+ }
+ }
+
+ CoreReleaseEventLock ();
+}
+
+#if (EFI_SPECIFICATION_VERSION < 0x00020000)
+
+static
+VOID
+EFIAPI
+EventNotifySignalAllNullEvent (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+ //
+ // This null event is a size efficent way to enusre that
+ // EFI_EVENT_NOTIFY_SIGNAL_ALL is error checked correctly.
+ // EFI_EVENT_NOTIFY_SIGNAL_ALL is now mapped into
+ // CreateEventEx() and this function is used to make the
+ // old error checking in CreateEvent() for Tiano extensions
+ // function.
+ //
+ return;
+}
+
+#endif
+
+
+EFI_BOOTSERVICE
+EFI_STATUS
+EFIAPI
+CoreCreateEvent (
+ IN UINT32 Type,
+ IN EFI_TPL NotifyTpl,
+ IN EFI_EVENT_NOTIFY NotifyFunction,
+ IN VOID *NotifyContext,
+ OUT EFI_EVENT *Event
+ )
+/*++
+
+Routine Description:
+
+ Creates a general-purpose event structure
+
+Arguments:
+
+ Type - The type of event to create and its mode and attributes
+ NotifyTpl - The task priority level of event notifications
+ NotifyFunction - Pointer to the events notification function
+ NotifyContext - Pointer to the notification functions context; corresponds to
+ parameter "Context" in the notification function
+ Event - Pointer to the newly created event if the call succeeds; undefined otherwise
+
+Returns:
+
+ EFI_SUCCESS - The event structure was created
+ EFI_INVALID_PARAMETER - One of the parameters has an invalid value
+ EFI_OUT_OF_RESOURCES - The event could not be allocated
+
+--*/
+{
+ EFI_GUID *GuidPtr;
+ EFI_EVENT_NOTIFY Function;
+
+ GuidPtr = NULL;
+ Function = NotifyFunction;
+
+#if (EFI_SPECIFICATION_VERSION < 0x00020000)
+ //
+ // Clear EFI_EVENT_NOFITY_SIGNAL_ALL (Tiano extension) as all events in the
+ // EventGroup now have this property. So we need to filter it out.
+ //
+ if (Type & EFI_EVENT_NOTIFY_SIGNAL_ALL) {
+ Type &= ~EFI_EVENT_NOTIFY_SIGNAL_ALL;
+ Function = EventNotifySignalAllNullEvent;
+ }
+
+ //
+ // Map the Tiano extensions Events to CreateEventEx form
+ //
+ if (Type == EFI_EVENT_SIGNAL_READY_TO_BOOT) {
+ GuidPtr = &gEfiEventReadyToBootGuid;
+ } else if (Type == EFI_EVENT_SIGNAL_LEGACY_BOOT) {
+ GuidPtr = &gEfiEventLegacyBootGuid;
+ }
+#endif
+
+ //
+ // Convert EFI 1.10 Events to thier UEFI 2.0 CreateEventEx mapping
+ //
+ if (Type == EFI_EVENT_SIGNAL_EXIT_BOOT_SERVICES) {
+ Type = 0;
+ GuidPtr = &gEfiEventExitBootServicesGuid;
+ } else if (Type == EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE) {
+ Type = 0;
+ GuidPtr = &gEfiEventVirtualAddressChangeGuid;
+ }
+
+ return CoreCreateEventEx (Type, NotifyTpl, Function, NotifyContext, GuidPtr, Event);
+}
+
+EFI_BOOTSERVICE
+EFI_STATUS
+EFIAPI
+CoreCreateEventEx (
+ IN UINT32 Type,
+ IN EFI_TPL NotifyTpl,
+ IN EFI_EVENT_NOTIFY NotifyFunction,
+ IN VOID *NotifyContext,
+ IN CONST EFI_GUID *EventGroup, OPTIONAL
+ OUT EFI_EVENT *Event
+ )
+/*++
+
+Routine Description:
+ Creates a general-purpose event structure
+
+Arguments:
+ Type - The type of event to create and its mode and attributes
+ NotifyTpl - The task priority level of event notifications
+ NotifyFunction - Pointer to the events notification function
+ NotifyContext - Pointer to the notification functions context; corresponds to
+ parameter "Context" in the notification function
+ EventGroup - GUID for EventGroup if NULL act the same as gBS->CreateEvent().
+ Event - Pointer to the newly created event if the call succeeds; undefined otherwise
+
+Returns:
+ EFI_SUCCESS - The event structure was created
+ EFI_INVALID_PARAMETER - One of the parameters has an invalid value
+ EFI_OUT_OF_RESOURCES - The event could not be allocated
+
+--*/
+{
+ EFI_STATUS Status;
+ IEVENT *IEvent;
+ INTN Index;
+
+
+ if ((Event == NULL) || (NotifyTpl == EFI_TPL_APPLICATION)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // For event group, type EFI_EVENT_SIGNAL_EXIT_BOOT_SERVICES and EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE
+ // are not valid
+ //
+ if (EventGroup != NULL) {
+ if ((Type == EFI_EVENT_SIGNAL_EXIT_BOOT_SERVICES) || (Type == EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE)) {
+ return EFI_INVALID_PARAMETER;
+ }
+ }
+
+ //
+ // Check to make sure no reserved flags are set
+ //
+ Status = EFI_INVALID_PARAMETER;
+ for (Index = 0; Index < (sizeof (mEventTable) / sizeof (UINT32)); Index++) {
+ if (Type == mEventTable[Index]) {
+ Status = EFI_SUCCESS;
+ break;
+ }
+ }
+ if(EFI_ERROR (Status)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // Convert Event type for pre-defined Event groups
+ //
+ if (EventGroup != NULL) {
+ if (EfiCompareGuid ((VOID *) EventGroup, &gEfiEventExitBootServicesGuid)) {
+ Type = EFI_EVENT_SIGNAL_EXIT_BOOT_SERVICES;
+ } else if (EfiCompareGuid ((VOID *) EventGroup, &gEfiEventVirtualAddressChangeGuid)) {
+ Type = EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE;
+ }
+ }
+
+ //
+ // If it's a notify type of event, check its parameters
+ //
+ if ((Type & (EFI_EVENT_NOTIFY_WAIT | EFI_EVENT_NOTIFY_SIGNAL))) {
+ //
+ // Check for an invalid NotifyFunction or NotifyTpl
+ //
+ if ((NotifyFunction == NULL) ||
+ (NotifyTpl < EFI_TPL_APPLICATION) ||
+ (NotifyTpl >= EFI_TPL_HIGH_LEVEL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ } else {
+ //
+ // No notification needed, zero ignored values
+ //
+ NotifyTpl = 0;
+ NotifyFunction = NULL;
+ NotifyContext = NULL;
+ }
+
+ //
+ // Allcoate and initialize a new event structure.
+ //
+ Status = CoreAllocatePool (
+ (Type & EFI_EVENT_RUNTIME) ? EfiRuntimeServicesData: EfiBootServicesData,
+ sizeof (IEVENT),
+ (VOID **)&IEvent
+ );
+ if (EFI_ERROR (Status) || (IEvent == NULL)) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ EfiCommonLibSetMem (IEvent, sizeof (IEVENT), 0);
+
+ IEvent->Signature = EVENT_SIGNATURE;
+ IEvent->Type = Type;
+ IEvent->NotifyTpl = NotifyTpl;
+ IEvent->NotifyFunction = NotifyFunction;
+ IEvent->NotifyContext = (VOID *)NotifyContext;
+ if (EventGroup != NULL) {
+ EfiCommonLibCopyMem (&IEvent->EventGroup, (VOID*)EventGroup, sizeof (EFI_GUID));
+ IEvent->ExFlag = TRUE;
+ }
+
+ *Event = IEvent;
+
+ if (Type & EFI_EVENT_RUNTIME) {
+ //
+ // Keep a list of all RT events so we can tell the RT AP.
+ //
+ IEvent->RuntimeData.Type = Type;
+ IEvent->RuntimeData.NotifyTpl = NotifyTpl;
+ IEvent->RuntimeData.NotifyFunction = NotifyFunction;
+ IEvent->RuntimeData.NotifyContext = NotifyContext;
+ IEvent->RuntimeData.Event = (EFI_EVENT *) IEvent;
+ InsertTailList (&gRuntime->EventHead, &IEvent->RuntimeData.Link);
+ }
+
+ CoreAcquireEventLock ();
+
+ if ((Type & EFI_EVENT_NOTIFY_SIGNAL) != 0x00000000) {
+ //
+ // The Event's NotifyFunction must be queued whenever the event is signaled
+ //
+ InsertHeadList (&gEventSignalQueue, &IEvent->SignalLink);
+ }
+
+ CoreReleaseEventLock ();
+
+ //
+ // Done
+ //
+ return EFI_SUCCESS;
+}
+
+EFI_BOOTSERVICE
+EFI_STATUS
+EFIAPI
+CoreSignalEvent (
+ IN EFI_EVENT UserEvent
+ )
+/*++
+
+Routine Description:
+
+ Signals the event. Queues the event to be notified if needed
+
+Arguments:
+
+ UserEvent - The event to signal
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Parameters are not valid.
+
+ EFI_SUCCESS - The event was signaled.
+
+--*/
+{
+ IEVENT *Event;
+
+ Event = UserEvent;
+
+ if (Event == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (Event->Signature != EVENT_SIGNATURE) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ CoreAcquireEventLock ();
+
+ //
+ // If the event is not already signalled, do so
+ //
+
+ if (Event->SignalCount == 0x00000000) {
+ Event->SignalCount ++;
+
+ //
+ // If signalling type is a notify function, queue it
+ //
+ if (Event->Type & EFI_EVENT_NOTIFY_SIGNAL) {
+ if (Event->ExFlag) {
+ //
+ // The CreateEventEx() style requires all members of the Event Group
+ // to be signaled.
+ //
+ CoreReleaseEventLock ();
+ CoreNotifySignalList (&Event->EventGroup);
+ CoreAcquireEventLock ();
+ } else {
+ CoreNotifyEvent (Event);
+ }
+ }
+ }
+
+ CoreReleaseEventLock ();
+ return EFI_SUCCESS;
+}
+
+EFI_BOOTSERVICE
+EFI_STATUS
+EFIAPI
+CoreCheckEvent (
+ IN EFI_EVENT UserEvent
+ )
+/*++
+
+Routine Description:
+
+ Check the status of an event
+
+Arguments:
+
+ UserEvent - The event to check
+
+Returns:
+
+ EFI_SUCCESS - The event is in the signaled state
+ EFI_NOT_READY - The event is not in the signaled state
+ EFI_INVALID_PARAMETER - Event is of type EVT_NOTIFY_SIGNAL
+
+--*/
+
+{
+ IEVENT *Event;
+ EFI_STATUS Status;
+
+ Event = UserEvent;
+
+ if (Event == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (Event->Signature != EVENT_SIGNATURE) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (Event->Type & EFI_EVENT_NOTIFY_SIGNAL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = EFI_NOT_READY;
+
+ if (!Event->SignalCount && (Event->Type & EFI_EVENT_NOTIFY_WAIT)) {
+
+ //
+ // Queue the wait notify function
+ //
+
+ CoreAcquireEventLock ();
+ if (!Event->SignalCount) {
+ CoreNotifyEvent (Event);
+ }
+ CoreReleaseEventLock ();
+ }
+
+ //
+ // If the even looks signalled, get the lock and clear it
+ //
+
+ if (Event->SignalCount) {
+ CoreAcquireEventLock ();
+
+ if (Event->SignalCount) {
+ Event->SignalCount = 0;
+ Status = EFI_SUCCESS;
+ }
+
+ CoreReleaseEventLock ();
+ }
+
+ return Status;
+}
+
+
+EFI_BOOTSERVICE
+EFI_STATUS
+EFIAPI
+CoreWaitForEvent (
+ IN UINTN NumberOfEvents,
+ IN EFI_EVENT *UserEvents,
+ OUT UINTN *UserIndex
+ )
+/*++
+
+Routine Description:
+
+ Stops execution until an event is signaled.
+
+Arguments:
+
+ NumberOfEvents - The number of events in the UserEvents array
+ UserEvents - An array of EFI_EVENT
+ UserIndex - Pointer to the index of the event which satisfied the wait condition
+
+Returns:
+
+ EFI_SUCCESS - The event indicated by Index was signaled.
+ EFI_INVALID_PARAMETER - The event indicated by Index has a notification function or
+ Event was not a valid type
+ EFI_UNSUPPORTED - The current TPL is not TPL_APPLICATION
+
+--*/
+
+{
+ EFI_STATUS Status;
+ UINTN Index;
+
+ //
+ // Can only WaitForEvent at TPL_APPLICATION
+ //
+ if (gEfiCurrentTpl != EFI_TPL_APPLICATION) {
+ return EFI_UNSUPPORTED;
+ }
+
+ for(;;) {
+
+ for(Index = 0; Index < NumberOfEvents; Index++) {
+
+ Status = CoreCheckEvent (UserEvents[Index]);
+
+ //
+ // provide index of event that caused problem
+ //
+ if (Status != EFI_NOT_READY) {
+ *UserIndex = Index;
+ return Status;
+ }
+ }
+
+ //
+ // This was the location of the Idle loop callback in EFI 1.x reference
+ // code. We don't have that concept in this base at this point.
+ //
+ }
+}
+
+EFI_BOOTSERVICE
+EFI_STATUS
+EFIAPI
+CoreCloseEvent (
+ IN EFI_EVENT UserEvent
+ )
+/*++
+
+Routine Description:
+
+ Closes an event and frees the event structure.
+
+Arguments:
+
+ UserEvent - Event to close
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Parameters are not valid.
+
+ EFI_SUCCESS - The event has been closed
+
+--*/
+
+{
+ EFI_STATUS Status;
+ IEVENT *Event;
+
+ Event = UserEvent;
+
+ if (Event == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (Event->Signature != EVENT_SIGNATURE) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // If it's a timer event, make sure it's not pending
+ //
+ if (Event->Type & EFI_EVENT_TIMER) {
+ CoreSetTimer (Event, TimerCancel, 0);
+ }
+
+ CoreAcquireEventLock ();
+
+ //
+ // If the event is queued somewhere, remove it
+ //
+
+ if (Event->RuntimeData.Link.ForwardLink != NULL) {
+ RemoveEntryList (&Event->RuntimeData.Link);
+ }
+
+ if (Event->NotifyLink.ForwardLink != NULL) {
+ RemoveEntryList (&Event->NotifyLink);
+ }
+
+ if (Event->SignalLink.ForwardLink != NULL) {
+ RemoveEntryList (&Event->SignalLink);
+ }
+
+ CoreReleaseEventLock ();
+
+ //
+ // If the event is registered on a protocol notify,
+ // then remove it from the protocol database
+ //
+ CoreUnregisterProtocolNotify (Event);
+
+ Status = CoreFreePool (Event);
+ ASSERT_EFI_ERROR (Status);
+
+ return Status;
+}
diff --git a/EDK/Foundation/Core/Dxe/Event/exec.h b/EDK/Foundation/Core/Dxe/Event/exec.h
new file mode 100644
index 0000000..2abdc90
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/Event/exec.h
@@ -0,0 +1,209 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ exec.h
+
+Abstract:
+
+ EFI Event support
+
+--*/
+
+#ifndef _EXEC_H_
+#define _EXEC_H_
+
+#include "Tiano.h"
+#include "DxeCore.h"
+
+#define VALID_TPL(a) ((a) <= EFI_TPL_HIGH_LEVEL)
+
+//
+// EFI_EVENT
+//
+
+#define EVENT_SIGNATURE EFI_SIGNATURE_32('e','v','n','t')
+typedef struct {
+ UINTN Signature;
+ UINT32 Type;
+ UINT32 SignalCount;
+
+ //
+ // Entry if the event is registered to be signalled
+ //
+
+ EFI_LIST_ENTRY SignalLink;
+
+ //
+ // Notification information for this event
+ //
+
+ EFI_TPL NotifyTpl;
+ EFI_EVENT_NOTIFY NotifyFunction;
+ VOID *NotifyContext;
+ EFI_GUID EventGroup;
+ EFI_LIST_ENTRY NotifyLink;
+ BOOLEAN ExFlag;
+
+ //
+ // A list of all runtime events
+ //
+ EFI_RUNTIME_EVENT_ENTRY RuntimeData;
+
+ //
+ // Information by event type
+ //
+
+ union {
+ //
+ // For timer events
+ //
+ struct {
+ EFI_LIST_ENTRY Link;
+ UINT64 TriggerTime;
+ UINT64 Period;
+ } Timer;
+ } u;
+
+} IEVENT;
+
+//
+// Internal prototypes
+//
+
+VOID
+CoreDispatchEventNotifies (
+ IN EFI_TPL Priority
+ )
+/*++
+
+Routine Description:
+
+ Dispatches all pending events.
+
+Arguments:
+
+ Priority - The task priority level of event notifications to dispatch
+
+Returns:
+
+ None
+
+--*/
+;
+
+
+UINTN
+CoreHighestSetBit (
+ IN UINTN Number
+ )
+/*++
+
+Routine Description:
+
+ Return the highest set bit
+
+Arguments:
+
+ Number - The value to check
+
+Returns:
+
+ Bit position of the highest set bit
+
+--*/
+;
+
+
+BOOLEAN
+GetInterruptState (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Disables CPU interrupts.
+
+Arguments:
+
+ This - Protocol instance structure
+
+ State - Pointer to the CPU's current interrupt state
+
+Returns:
+
+ EFI_SUCCESS - If interrupts were disabled in the CPU.
+
+ EFI_INVALID_PARAMETER - State is NULL.
+
+--*/
+;
+
+//
+// Exported functions
+//
+
+VOID
+CoreEventVirtualAddressFixup (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ A function out of date, should be removed.
+
+Arguments:
+
+ None
+
+Returns:
+
+ None
+
+--*/
+;
+
+
+VOID
+CoreInitializeTimer (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Initializes timer support
+
+Arguments:
+
+ None
+
+Returns:
+
+ None
+
+--*/
+;
+
+//
+// extern data declarations
+//
+
+extern EFI_LOCK gEventQueueLock;
+extern UINTN gEventPending;
+extern EFI_LIST_ENTRY gEventQueue[];
+extern EFI_LIST_ENTRY gEventSignalQueue;
+extern UINT8 gHSB[];
+
+#endif
diff --git a/EDK/Foundation/Core/Dxe/Event/execdata.c b/EDK/Foundation/Core/Dxe/Event/execdata.c
new file mode 100644
index 0000000..284b89b
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/Event/execdata.c
@@ -0,0 +1,50 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ execdata.c
+
+Abstract:
+
+
+
+
+Revision History
+
+--*/
+
+#include "exec.h"
+
+
+//
+// gTpl - Task priority level
+//
+EFI_TPL gEfiCurrentTpl = EFI_TPL_DRIVER;
+
+
+//
+// gEventQueueLock - Protects the event queus
+//
+EFI_LOCK gEventQueueLock = EFI_INITIALIZE_LOCK_VARIABLE (EFI_TPL_HIGH_LEVEL);
+
+//
+// gEventQueue - A list of event's to notify for each priority level
+// gEventPending - A bitmask of the EventQueues that are pending
+//
+EFI_LIST_ENTRY gEventQueue[EFI_TPL_HIGH_LEVEL + 1];
+UINTN gEventPending = 0;
+
+//
+// gEventSignalQueue - A list of events to signal when the EFI operation occurs
+//
+EFI_LIST_ENTRY gEventSignalQueue = INITIALIZE_LIST_HEAD_VARIABLE (gEventSignalQueue);
+
diff --git a/EDK/Foundation/Core/Dxe/Event/timer.c b/EDK/Foundation/Core/Dxe/Event/timer.c
new file mode 100644
index 0000000..28ce124
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/Event/timer.c
@@ -0,0 +1,386 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ timer.c
+
+Abstract:
+
+ EFI Event support
+
+Revision History
+
+--*/
+
+
+#include "exec.h"
+
+//
+// Internal prototypes
+//
+STATIC
+UINT64
+CoreCurrentSystemTime (
+ VOID
+ );
+
+VOID
+EFIAPI
+CoreCheckTimers (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ );
+
+STATIC
+VOID
+CoreInsertEventTimer (
+ IN IEVENT *Event
+ );
+
+//
+// Internal data
+//
+
+static EFI_LIST_ENTRY mEfiTimerList = INITIALIZE_LIST_HEAD_VARIABLE (mEfiTimerList);
+static EFI_LOCK mEfiTimerLock = EFI_INITIALIZE_LOCK_VARIABLE (EFI_TPL_HIGH_LEVEL - 1);
+static EFI_EVENT mEfiCheckTimerEvent;
+
+static EFI_LOCK mEfiSystemTimeLock = EFI_INITIALIZE_LOCK_VARIABLE (EFI_TPL_HIGH_LEVEL);
+static UINT64 mEfiSystemTime = 0;
+
+//
+// Timer functions
+//
+
+VOID
+CoreInitializeTimer (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Initializes timer support
+
+Arguments:
+
+ None
+
+Returns:
+
+ None
+
+--*/
+{
+ EFI_STATUS Status;
+
+ Status = CoreCreateEvent (
+ EFI_EVENT_NOTIFY_SIGNAL,
+ EFI_TPL_HIGH_LEVEL - 1,
+ CoreCheckTimers,
+ NULL,
+ &mEfiCheckTimerEvent
+ );
+ ASSERT_EFI_ERROR (Status);
+}
+
+STATIC
+UINT64
+CoreCurrentSystemTime (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Returns the current system time
+
+Arguments:
+
+ None
+
+Returns:
+
+ Returns the current system time
+
+--*/
+{
+ UINT64 SystemTime;
+
+ CoreAcquireLock (&mEfiSystemTimeLock);
+ SystemTime = mEfiSystemTime;
+ CoreReleaseLock (&mEfiSystemTimeLock);
+ return SystemTime;
+}
+
+VOID
+EFIAPI
+CoreTimerTick (
+ IN UINT64 Duration
+ )
+/*++
+
+Routine Description:
+
+ Called by the platform code to process a tick.
+
+Arguments:
+
+ Duration - The number of 100ns elasped since the last call to TimerTick
+
+Returns:
+
+ None
+
+--*/
+{
+ IEVENT *Event;
+
+ //
+ // Check runtiem flag in case there are ticks while exiting boot services
+ //
+
+ CoreAcquireLock (&mEfiSystemTimeLock);
+
+ //
+ // Update the system time
+ //
+
+ mEfiSystemTime += Duration;
+
+ //
+ // If the head of the list is expired, fire the timer event
+ // to process it
+ //
+
+ if (!IsListEmpty (&mEfiTimerList)) {
+ Event = CR (mEfiTimerList.ForwardLink, IEVENT, u.Timer.Link, EVENT_SIGNATURE);
+
+ if (Event->u.Timer.TriggerTime <= mEfiSystemTime) {
+ CoreSignalEvent (mEfiCheckTimerEvent);
+ }
+ }
+
+ CoreReleaseLock (&mEfiSystemTimeLock);
+}
+
+VOID
+EFIAPI
+CoreCheckTimers (
+ IN EFI_EVENT CheckEvent,
+ IN VOID *Context
+ )
+/*++
+
+Routine Description:
+
+ Checks the sorted timer list against the current system time.
+ Signals any expired event timer.
+
+Arguments:
+
+ CheckEvent - Not used
+
+ Context - Not used
+
+Returns:
+
+ None
+
+--*/
+{
+ UINT64 SystemTime;
+ IEVENT *Event;
+
+ //
+ // Check the timer database for expired timers
+ //
+
+ CoreAcquireLock (&mEfiTimerLock);
+ SystemTime = CoreCurrentSystemTime ();
+
+ while (!IsListEmpty (&mEfiTimerList)) {
+ Event = CR (mEfiTimerList.ForwardLink, IEVENT, u.Timer.Link, EVENT_SIGNATURE);
+
+ //
+ // If this timer is not expired, then we're done
+ //
+
+ if (Event->u.Timer.TriggerTime > SystemTime) {
+ break;
+ }
+
+ //
+ // Remove this timer from the timer queue
+ //
+
+ RemoveEntryList (&Event->u.Timer.Link);
+ Event->u.Timer.Link.ForwardLink = NULL;
+
+ //
+ // Signal it
+ //
+ CoreSignalEvent (Event);
+
+ //
+ // If this is a periodic timer, set it
+ //
+ if (Event->u.Timer.Period) {
+
+ //
+ // Compute the timers new trigger time
+ //
+
+ Event->u.Timer.TriggerTime = Event->u.Timer.TriggerTime + Event->u.Timer.Period;
+
+ //
+ // If that's before now, then reset the timer to start from now
+ //
+ if (Event->u.Timer.TriggerTime <= SystemTime) {
+ Event->u.Timer.TriggerTime = SystemTime;
+ CoreSignalEvent (mEfiCheckTimerEvent);
+ }
+
+ //
+ // Add the timer
+ //
+
+ CoreInsertEventTimer (Event);
+ }
+ }
+
+ CoreReleaseLock (&mEfiTimerLock);
+}
+
+STATIC
+VOID
+CoreInsertEventTimer (
+ IN IEVENT *Event
+ )
+/*++
+
+Routine Description:
+
+ Inserts the timer event
+
+Arguments:
+
+ Event - Points to the internal structure of timer event to be installed
+
+Returns:
+
+ None
+
+--*/
+{
+ UINT64 TriggerTime;
+ EFI_LIST_ENTRY *Link;
+ IEVENT *Event2;
+
+ ASSERT_LOCKED (&mEfiTimerLock);
+
+ //
+ // Get the timer's trigger time
+ //
+
+ TriggerTime = Event->u.Timer.TriggerTime;
+
+ //
+ // Insert the timer into the timer database in assending sorted order
+ //
+
+ for (Link = mEfiTimerList.ForwardLink; Link != &mEfiTimerList; Link = Link->ForwardLink) {
+ Event2 = CR (Link, IEVENT, u.Timer.Link, EVENT_SIGNATURE);
+
+ if (Event2->u.Timer.TriggerTime > TriggerTime) {
+ break;
+ }
+ }
+
+ InsertTailList (Link, &Event->u.Timer.Link);
+}
+
+
+EFI_BOOTSERVICE
+EFI_STATUS
+EFIAPI
+CoreSetTimer (
+ IN EFI_EVENT UserEvent,
+ IN EFI_TIMER_DELAY Type,
+ IN UINT64 TriggerTime
+ )
+/*++
+
+Routine Description:
+
+ Sets the type of timer and the trigger time for a timer event.
+
+Arguments:
+
+ UserEvent - The timer event that is to be signaled at the specified time
+ Type - The type of time that is specified in TriggerTime
+ TriggerTime - The number of 100ns units until the timer expires
+
+Returns:
+
+ EFI_SUCCESS - The event has been set to be signaled at the requested time
+ EFI_INVALID_PARAMETER - Event or Type is not valid
+
+--*/
+{
+ IEVENT *Event;
+
+ Event = UserEvent;
+
+ if (Event == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (Event->Signature != EVENT_SIGNATURE) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (Type < 0 || Type >= TimerTypeMax || !(Event->Type & EFI_EVENT_TIMER)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ CoreAcquireLock (&mEfiTimerLock);
+
+ //
+ // If the timer is queued to the timer database, remove it
+ //
+
+ if (Event->u.Timer.Link.ForwardLink != NULL) {
+ RemoveEntryList (&Event->u.Timer.Link);
+ Event->u.Timer.Link.ForwardLink = NULL;
+ }
+
+ Event->u.Timer.TriggerTime = 0;
+ Event->u.Timer.Period = 0;
+
+ if (Type != TimerCancel) {
+
+ if (Type == TimerPeriodic) {
+ Event->u.Timer.Period = TriggerTime;
+ }
+
+ Event->u.Timer.TriggerTime = CoreCurrentSystemTime () + TriggerTime;
+ CoreInsertEventTimer (Event);
+
+ if (TriggerTime == 0) {
+ CoreSignalEvent (mEfiCheckTimerEvent);
+ }
+ }
+
+ CoreReleaseLock (&mEfiTimerLock);
+ return EFI_SUCCESS;
+}
diff --git a/EDK/Foundation/Core/Dxe/Event/tpl.c b/EDK/Foundation/Core/Dxe/Event/tpl.c
new file mode 100644
index 0000000..3ac99fc
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/Event/tpl.c
@@ -0,0 +1,198 @@
+/*++
+
+Copyright (c) 2004 - 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ tpl.c
+
+Abstract:
+
+ Task priority function
+
+--*/
+
+#include "exec.h"
+
+STATIC
+VOID
+CoreSetInterruptState (
+ IN BOOLEAN Enable
+ )
+/*++
+
+Routine Description:
+
+ Set Interrupt State
+
+Arguments:
+
+ Enable - The state of enable or disable interrupt
+
+Returns:
+
+ None
+
+--*/
+
+{
+ if (gCpu != NULL) {
+ if (Enable) {
+ gCpu->EnableInterrupt(gCpu);
+ } else {
+ gCpu->DisableInterrupt(gCpu);
+ }
+ }
+}
+
+//
+// Return the highest set bit
+//
+UINTN
+CoreHighestSetBit (
+ IN UINTN Number
+ )
+/*++
+
+Routine Description:
+
+ Return the highest set bit
+
+Arguments:
+
+ Number - The value to check
+
+Returns:
+
+ Bit position of the highest set bit
+
+--*/
+{
+ UINTN msb;
+
+ msb = 31;
+ while ((msb > 0) && ((Number & ((UINTN)1 << msb)) == 0)) {
+ msb--;
+ }
+
+ return msb;
+}
+
+
+EFI_BOOTSERVICE
+EFI_TPL
+EFIAPI
+CoreRaiseTpl (
+ IN EFI_TPL NewTpl
+ )
+/*++
+
+Routine Description:
+
+ Raise the task priority level to the new level.
+ High level is implemented by disabling processor interrupts.
+
+Arguments:
+
+ NewTpl - New task priority level
+
+Returns:
+
+ The previous task priority level
+
+--*/
+{
+ EFI_TPL OldTpl;
+
+ OldTpl = gEfiCurrentTpl;
+ ASSERT (OldTpl <= NewTpl);
+ ASSERT (VALID_TPL (NewTpl));
+
+ //
+ // If raising to high level, disable interrupts
+ //
+ if (NewTpl >= EFI_TPL_HIGH_LEVEL && OldTpl < EFI_TPL_HIGH_LEVEL) {
+ CoreSetInterruptState (FALSE);
+ }
+
+ //
+ // Set the new value
+ //
+ gEfiCurrentTpl = NewTpl;
+
+ return OldTpl;
+}
+
+
+EFI_BOOTSERVICE
+VOID
+EFIAPI
+CoreRestoreTpl (
+ IN EFI_TPL NewTpl
+ )
+/*++
+
+Routine Description:
+
+ Lowers the task priority to the previous value. If the new
+ priority unmasks events at a higher priority, they are dispatched.
+
+Arguments:
+
+ NewTpl - New, lower, task priority
+
+Returns:
+
+ None
+
+--*/
+{
+ EFI_TPL OldTpl;
+
+ OldTpl = gEfiCurrentTpl;
+ ASSERT (NewTpl <= OldTpl);
+ ASSERT (VALID_TPL (NewTpl));
+
+ //
+ // If lowering below HIGH_LEVEL, make sure
+ // interrupts are enabled
+ //
+
+ if (OldTpl >= EFI_TPL_HIGH_LEVEL && NewTpl < EFI_TPL_HIGH_LEVEL) {
+ gEfiCurrentTpl = EFI_TPL_HIGH_LEVEL;
+ }
+
+ //
+ // Dispatch any pending events
+ //
+
+ while ((-2 << NewTpl) & gEventPending) {
+ gEfiCurrentTpl = CoreHighestSetBit (gEventPending);
+ if (gEfiCurrentTpl < EFI_TPL_HIGH_LEVEL) {
+ CoreSetInterruptState (TRUE);
+ }
+ CoreDispatchEventNotifies (gEfiCurrentTpl);
+ }
+
+ //
+ // Set the new value
+ //
+
+ gEfiCurrentTpl = NewTpl;
+
+ //
+ // If lowering below HIGH_LEVEL, make sure
+ // interrupts are enabled
+ //
+ if (gEfiCurrentTpl < EFI_TPL_HIGH_LEVEL) {
+ CoreSetInterruptState (TRUE);
+ }
+
+}
diff --git a/EDK/Foundation/Core/Dxe/FwVol/Ffs.c b/EDK/Foundation/Core/Dxe/FwVol/Ffs.c
new file mode 100644
index 0000000..3361ce2
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/FwVol/Ffs.c
@@ -0,0 +1,266 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Ffs.c
+
+Abstract:
+
+ FFS file access utilities.
+
+--*/
+
+
+#include "FwVolDriver.h"
+
+#define PHYSICAL_ADDRESS_TO_POINTER(Address) ((VOID *)((UINTN)(Address)))
+
+
+EFI_FFS_FILE_STATE
+GetFileState (
+ IN UINT8 ErasePolarity,
+ IN EFI_FFS_FILE_HEADER *FfsHeader
+ )
+/*++
+
+Routine Description:
+ Get the FFS file state by checking the highest bit set in the header's state field
+
+Arguments:
+ ErasePolarity - Erase polarity attribute of the firmware volume
+ FfsHeader - Points to the FFS file header
+
+Returns:
+ FFS File state
+
+--*/
+{
+ EFI_FFS_FILE_STATE FileState;
+ UINT8 HighestBit;
+
+ FileState = FfsHeader->State;
+
+ if (ErasePolarity != 0) {
+ FileState = (EFI_FFS_FILE_STATE)~FileState;
+ }
+
+ HighestBit = 0x80;
+ while (HighestBit != 0 && ((HighestBit & FileState) == 0)) {
+ HighestBit >>= 1;
+ }
+
+ return (EFI_FFS_FILE_STATE)HighestBit;
+}
+
+
+BOOLEAN
+IsBufferErased (
+ IN UINT8 ErasePolarity,
+ IN VOID *InBuffer,
+ IN UINTN BufferSize
+ )
+/*++
+
+Routine Description:
+ Check if a block of buffer is erased
+
+Arguments:
+ ErasePolarity - Erase polarity attribute of the firmware volume
+ InBuffer - The buffer to be checked
+ BufferSize - Size of the buffer in bytes
+
+Returns:
+ TRUE - The block of buffer is erased
+ FALSE - The block of buffer is not erased
+
+--*/
+{
+ UINTN Count;
+ UINT8 EraseByte;
+ UINT8 *Buffer;
+
+ if(ErasePolarity == 1) {
+ EraseByte = 0xFF;
+ } else {
+ EraseByte = 0;
+ }
+
+ Buffer = InBuffer;
+ for (Count = 0; Count < BufferSize; Count++) {
+ if (Buffer[Count] != EraseByte) {
+ return FALSE;
+ }
+ }
+
+ return TRUE;
+}
+
+
+BOOLEAN
+VerifyFvHeaderChecksum (
+ IN EFI_FIRMWARE_VOLUME_HEADER *FvHeader
+ )
+/*++
+
+Routine Description:
+ Verify checksum of the firmware volume header
+
+Arguments:
+ FvHeader - Points to the firmware volume header to be checked
+
+Returns:
+ TRUE - Checksum verification passed
+ FALSE - Checksum verification failed
+
+--*/
+{
+ UINT32 Index;
+ UINT32 HeaderLength;
+ UINT16 Checksum;
+ UINT16 *ptr;
+
+ HeaderLength = FvHeader->HeaderLength;
+ ptr = (UINT16 *)FvHeader;
+ Checksum = 0;
+
+ for (Index = 0; Index < HeaderLength / sizeof (UINT16); Index++) {
+ Checksum = (UINT16)(Checksum + ptr[Index]);
+ }
+
+ if (Checksum == 0) {
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+}
+
+
+BOOLEAN
+VerifyHeaderChecksum (
+ IN EFI_FFS_FILE_HEADER *FfsHeader
+ )
+/*++
+
+Routine Description:
+ Verify checksum of the FFS file header
+
+Arguments:
+ FfsHeader - Points to the FFS file header to be checked
+
+Returns:
+ TRUE - Checksum verification passed
+ FALSE - Checksum verification failed
+
+--*/
+{
+ UINT32 Index;
+ UINT8 *ptr;
+ UINT8 HeaderChecksum;
+
+ ptr = (UINT8 *)FfsHeader;
+ HeaderChecksum = 0;
+ for (Index = 0; Index < sizeof(EFI_FFS_FILE_HEADER); Index++) {
+ HeaderChecksum = (UINT8)(HeaderChecksum + ptr[Index]);
+ }
+
+ HeaderChecksum = HeaderChecksum - FfsHeader->State - FfsHeader->IntegrityCheck.Checksum.File;
+
+ if (HeaderChecksum == 0) {
+ return TRUE;
+ } else {
+ return FALSE;
+ }
+}
+
+
+BOOLEAN
+IsValidFfsHeader (
+ IN UINT8 ErasePolarity,
+ IN EFI_FFS_FILE_HEADER *FfsHeader,
+ OUT EFI_FFS_FILE_STATE *FileState
+ )
+/*++
+
+Routine Description:
+ Check if it's a valid FFS file header
+
+Arguments:
+ ErasePolarity - Erase polarity attribute of the firmware volume
+ FfsHeader - Points to the FFS file header to be checked
+ FileState - FFS file state to be returned
+
+Returns:
+ TRUE - Valid FFS file header
+ FALSE - Invalid FFS file header
+
+--*/
+{
+ *FileState = GetFileState (ErasePolarity, FfsHeader);
+
+ switch (*FileState) {
+ case EFI_FILE_HEADER_VALID:
+ case EFI_FILE_DATA_VALID:
+ case EFI_FILE_MARKED_FOR_UPDATE:
+ case EFI_FILE_DELETED:
+ //
+ // Here we need to verify header checksum
+ //
+ return VerifyHeaderChecksum (FfsHeader);
+
+ case EFI_FILE_HEADER_CONSTRUCTION:
+ case EFI_FILE_HEADER_INVALID:
+ default:
+ return FALSE;
+ }
+}
+
+
+BOOLEAN
+IsValidFfsFile (
+ IN UINT8 ErasePolarity,
+ IN EFI_FFS_FILE_HEADER *FfsHeader
+ )
+/*++
+
+Routine Description:
+ Check if it's a valid FFS file.
+ Here we are sure that it has a valid FFS file header since we must call IsValidFfsHeader() first.
+
+Arguments:
+ ErasePolarity - Erase polarity attribute of the firmware volume
+ FfsHeader - Points to the FFS file to be checked
+
+Returns:
+ TRUE - Valid FFS file
+ FALSE - Invalid FFS file
+
+--*/
+{
+ EFI_FFS_FILE_STATE FileState;
+
+ FileState = GetFileState (ErasePolarity, FfsHeader);
+ switch (FileState) {
+
+ case EFI_FILE_DELETED:
+ case EFI_FILE_DATA_VALID:
+ case EFI_FILE_MARKED_FOR_UPDATE:
+ //
+ // Some other vliadation like file content checksum might be done here.
+ // For performance issue, Tiano only do FileState check.
+ //
+ return TRUE;
+
+ default:
+ return FALSE;
+ }
+}
+
diff --git a/EDK/Foundation/Core/Dxe/FwVol/FwVol.c b/EDK/Foundation/Core/Dxe/FwVol/FwVol.c
new file mode 100644
index 0000000..eb0117c
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/FwVol/FwVol.c
@@ -0,0 +1,556 @@
+/*++
+
+Copyright (c) 2004 - 2005, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ FwVol.c
+
+Abstract:
+
+ Firmware File System driver that produce Firmware Volume protocol.
+ Layers on top of Firmware Block protocol to produce a file abstraction
+ of FV based files.
+
+--*/
+
+#include "FwVolDriver.h"
+#include "DxeCore.h"
+
+#define KEYSIZE sizeof (UINTN)
+
+//
+// Protocol notify related globals
+//
+VOID *gEfiFwVolBlockNotifyReg;
+EFI_EVENT gEfiFwVolBlockEvent;
+
+FV_DEVICE mFvDevice = {
+ FV_DEVICE_SIGNATURE,
+ NULL,
+ NULL,
+ {
+ FvGetVolumeAttributes,
+ FvSetVolumeAttributes,
+ FvReadFile,
+ FvReadFileSection,
+ FvWriteFile,
+ FvGetNextFile,
+ KEYSIZE
+ },
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ { NULL, NULL },
+ 0
+};
+
+
+//
+// FFS helper functions
+//
+
+EFI_STATUS
+GetFwVolHeader (
+ IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb,
+ OUT EFI_FIRMWARE_VOLUME_HEADER **FwVolHeader
+ )
+/*++
+
+Routine Description:
+ given the supplied FW_VOL_BLOCK_PROTOCOL, allocate a buffer for output and
+ copy the volume header into it.
+
+Arguments:
+ Fvb - The FW_VOL_BLOCK_PROTOCOL instance from which to read the volume
+ header
+ FwVolHeader - Pointer to pointer to allocated buffer in which the volume
+ header is returned.
+
+Returns:
+ EFI_OUT_OF_RESOURCES - No enough buffer could be allocated.
+ EFI_SUCCESS - Successfully read volume header to the allocated buffer.
+
+--*/
+
+{
+ EFI_STATUS Status;
+ EFI_FIRMWARE_VOLUME_HEADER TempFvh;
+ UINTN FvhLength;
+ UINT8 *Buffer;
+
+
+ //
+ //Determine the real length of FV header
+ //
+ FvhLength = sizeof (EFI_FIRMWARE_VOLUME_HEADER);
+ Status = Fvb->Read (Fvb, 0, 0, &FvhLength, (UINT8 *)&TempFvh);
+
+ //
+ // Allocate a buffer for the caller
+ //
+ *FwVolHeader = CoreAllocateBootServicesPool (TempFvh.HeaderLength);
+ if (*FwVolHeader == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ //
+ // Copy the standard header into the buffer
+ //
+ EfiCommonLibCopyMem (*FwVolHeader, &TempFvh, sizeof (EFI_FIRMWARE_VOLUME_HEADER));
+
+ //
+ // Read the rest of the header
+ //
+ FvhLength = TempFvh.HeaderLength - sizeof (EFI_FIRMWARE_VOLUME_HEADER);
+ Buffer = (UINT8 *)*FwVolHeader + sizeof (EFI_FIRMWARE_VOLUME_HEADER);
+ Status = Fvb->Read (Fvb, 0, sizeof (EFI_FIRMWARE_VOLUME_HEADER), &FvhLength, Buffer);
+ if (EFI_ERROR (Status)) {
+ //
+ // Read failed so free buffer
+ //
+ CoreFreePool (*FwVolHeader);
+ }
+
+ return Status;
+}
+
+
+STATIC
+VOID
+FreeFvDeviceResource (
+ IN FV_DEVICE *FvDevice
+ )
+/*++
+
+Routine Description:
+ Free FvDevice resource when error happens
+
+Arguments:
+ FvDevice - pointer to the FvDevice to be freed.
+
+Returns:
+ None.
+
+--*/
+{
+ FFS_FILE_LIST_ENTRY *FfsFileEntry;
+ EFI_LIST_ENTRY *NextEntry;
+
+ //
+ // Free File List Entry
+ //
+ FfsFileEntry = (FFS_FILE_LIST_ENTRY *)FvDevice->FfsFileListHeader.ForwardLink;
+ while (&FfsFileEntry->Link != &FvDevice->FfsFileListHeader) {
+ NextEntry = (&FfsFileEntry->Link)->ForwardLink;
+
+ if (FfsFileEntry->StreamHandle != 0) {
+ //
+ // Close stream and free resources from SEP
+ //
+ FfsFileEntry->Sep->CloseSectionStream (FfsFileEntry->Sep, FfsFileEntry->StreamHandle);
+ }
+
+ CoreFreePool (FfsFileEntry);
+
+ FfsFileEntry = (FFS_FILE_LIST_ENTRY *)NextEntry;
+ }
+
+
+ //
+ // Free the cache
+ //
+ CoreFreePool (FvDevice->CachedFv);
+
+ //
+ // Free Volume Header
+ //
+ CoreFreePool (FvDevice->FwVolHeader);
+
+ return;
+}
+
+
+EFI_STATUS
+FvCheck (
+ IN OUT FV_DEVICE *FvDevice
+ )
+/*++
+
+Routine Description:
+ Check if a FV is consistent and allocate cache
+
+Arguments:
+ FvDevice - pointer to the FvDevice to be checked.
+
+Returns:
+ EFI_OUT_OF_RESOURCES - No enough buffer could be allocated.
+ EFI_SUCCESS - FV is consistent and cache is allocated.
+ EFI_VOLUME_CORRUPTED - File system is corrupted.
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb;
+ EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;
+ EFI_FVB_ATTRIBUTES FvbAttributes;
+ EFI_FV_BLOCK_MAP_ENTRY *BlockMap;
+ FFS_FILE_LIST_ENTRY *FfsFileEntry;
+ EFI_FFS_FILE_HEADER *FfsHeader;
+ UINT8 *CacheLocation;
+ UINTN LbaOffset;
+ UINTN Index;
+ EFI_LBA LbaIndex;
+ UINTN Size;
+ UINTN FileLength;
+ EFI_FFS_FILE_STATE FileState;
+ UINT8 *TopFvAddress;
+ UINTN TestLength;
+
+
+ Fvb = FvDevice->Fvb;
+ FwVolHeader = FvDevice->FwVolHeader;
+
+ Status = Fvb->GetVolumeAttributes (Fvb, &FvbAttributes);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ //
+ // Size is the size of the FV minus the head. We have already allocated
+ // the header to check to make sure the volume is valid
+ //
+ Size = (UINTN)(FwVolHeader->FvLength - FwVolHeader->HeaderLength);
+ FvDevice->CachedFv = CoreAllocateZeroBootServicesPool (Size);
+ if (FvDevice->CachedFv == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ //
+ // Remember a pointer to the end fo the CachedFv
+ //
+ FvDevice->EndOfCachedFv = FvDevice->CachedFv + Size;
+
+ //
+ // Copy FV minus header into memory using the block map we have all ready
+ // read into memory.
+ //
+ BlockMap = FwVolHeader->FvBlockMap;
+ CacheLocation = FvDevice->CachedFv;
+ LbaIndex = 0;
+ LbaOffset = FwVolHeader->HeaderLength;
+ while ((BlockMap->NumBlocks != 0) || (BlockMap->BlockLength != 0)) {
+
+ for (Index = 0; Index < BlockMap->NumBlocks; Index ++) {
+
+ Size = BlockMap->BlockLength;
+ if (Index == 0) {
+ //
+ // Cache does not include FV Header
+ //
+ Size -= LbaOffset;
+ }
+ Status = Fvb->Read (Fvb,
+ LbaIndex,
+ LbaOffset,
+ &Size,
+ CacheLocation
+ );
+ //
+ // Not check EFI_BAD_BUFFER_SIZE, for Size = BlockMap->BlockLength
+ //
+ if (EFI_ERROR (Status)) {
+ goto Done;
+ }
+
+ //
+ // After we skip Fv Header always read from start of block
+ //
+ LbaOffset = 0;
+
+ LbaIndex++;
+ CacheLocation += Size;
+ }
+ BlockMap++;
+ }
+
+ //
+ // Scan to check the free space & File list
+ //
+ if (FvbAttributes & EFI_FVB_ERASE_POLARITY) {
+ FvDevice->ErasePolarity = 1;
+ } else {
+ FvDevice->ErasePolarity = 0;
+ }
+
+
+ //
+ // go through the whole FV cache, check the consistence of the FV.
+ // Make a linked list off all the Ffs file headers
+ //
+ Status = EFI_SUCCESS;
+ InitializeListHead (&FvDevice->FfsFileListHeader);
+
+ //
+ // Build FFS list
+ //
+ FfsHeader = (EFI_FFS_FILE_HEADER *)FvDevice->CachedFv;
+ TopFvAddress = FvDevice->EndOfCachedFv;
+ while ((UINT8 *)FfsHeader < TopFvAddress) {
+
+ TestLength = TopFvAddress - ((UINT8 *)FfsHeader);
+ if (TestLength > sizeof (EFI_FFS_FILE_HEADER)) {
+ TestLength = sizeof (EFI_FFS_FILE_HEADER);
+ }
+
+ if (IsBufferErased (FvDevice->ErasePolarity, FfsHeader, TestLength)) {
+ //
+ // We have found the free space so we are done!
+ //
+ goto Done;
+ }
+
+ if (!IsValidFfsHeader (FvDevice->ErasePolarity, FfsHeader, &FileState)) {
+ if ((FileState == EFI_FILE_HEADER_INVALID) ||
+ (FileState == EFI_FILE_HEADER_CONSTRUCTION)) {
+ FfsHeader++;
+
+ continue;
+
+ } else {
+ //
+ // File system is corrputed
+ //
+ Status = EFI_VOLUME_CORRUPTED;
+ goto Done;
+ }
+ }
+
+ if (!IsValidFfsFile (FvDevice->ErasePolarity, FfsHeader)) {
+ //
+ // File system is corrupted
+ //
+ Status = EFI_VOLUME_CORRUPTED;
+ goto Done;
+ }
+
+ //
+ // Size[3] is a three byte array, read 4 bytes and throw one away
+ //
+ FileLength = *(UINT32 *)&FfsHeader->Size[0] & 0x00FFFFFF;
+
+ FileState = GetFileState (FvDevice->ErasePolarity, FfsHeader);
+
+ //
+ // check for non-deleted file
+ //
+ if (FileState != EFI_FILE_DELETED) {
+ //
+ // Create a FFS list entry for each non-deleted file
+ //
+ FfsFileEntry = CoreAllocateZeroBootServicesPool (sizeof (FFS_FILE_LIST_ENTRY));
+ if (FfsFileEntry == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Done;
+ }
+
+ FfsFileEntry->FfsHeader = FfsHeader;
+ InsertTailList (&FvDevice->FfsFileListHeader, &FfsFileEntry->Link);
+ }
+
+ FfsHeader = (EFI_FFS_FILE_HEADER *)(((UINT8 *)FfsHeader) + FileLength);
+
+ //
+ // Adjust pointer to the next 8-byte aligned boundry.
+ //
+ FfsHeader = (EFI_FFS_FILE_HEADER *)(((UINTN)FfsHeader + 7) & ~0x07);
+
+ }
+
+Done:
+ if (EFI_ERROR (Status)) {
+ FreeFvDeviceResource (FvDevice);
+ }
+
+ return Status;
+}
+
+
+STATIC
+VOID
+EFIAPI
+NotifyFwVolBlock (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+/*++
+
+Routine Description:
+ This notification function is invoked when an instance of the
+ EFI_FW_VOLUME_BLOCK_PROTOCOL is produced. It layers an instance of the
+ EFI_FIRMWARE_VOLUME_PROTOCOL on the same handle. This is the function where
+ the actual initialization of the EFI_FIRMWARE_VOLUME_PROTOCOL is done.
+
+Arguments:
+ Event - The event that occured
+ Context - For EFI compatiblity. Not used.
+
+Returns:
+
+ None.
+
+--*/
+{
+ EFI_HANDLE Handle;
+ EFI_STATUS Status;
+ UINTN BufferSize;
+ EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb;
+ EFI_FIRMWARE_VOLUME_PROTOCOL *Fv;
+ FV_DEVICE *FvDevice;
+ EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;
+ //
+ // Examine all new handles
+ //
+ for (;;) {
+ //
+ // Get the next handle
+ //
+ BufferSize = sizeof (Handle);
+ Status = CoreLocateHandle (
+ ByRegisterNotify,
+ NULL,
+ gEfiFwVolBlockNotifyReg,
+ &BufferSize,
+ &Handle
+ );
+
+ //
+ // If not found, we're done
+ //
+ if (EFI_NOT_FOUND == Status) {
+ break;
+ }
+
+ if (EFI_ERROR (Status)) {
+ continue;
+ }
+
+ //
+ // Get the FirmwareVolumeBlock protocol on that handle
+ //
+ Status = CoreHandleProtocol (Handle, &gEfiFirmwareVolumeBlockProtocolGuid, &Fvb);
+ ASSERT_EFI_ERROR (Status);
+ if (EFI_ERROR (Status) || (Fvb == NULL)) {
+ return;
+ }
+
+ //
+ // Make sure the Fv Header is O.K.
+ //
+ Status = GetFwVolHeader (Fvb, &FwVolHeader);
+ if (EFI_ERROR (Status) || (FwVolHeader == NULL)) {
+ return;
+ }
+
+ if (!VerifyFvHeaderChecksum (FwVolHeader)) {
+ CoreFreePool (FwVolHeader);
+ continue;
+ }
+
+
+ //
+ // Check to see that the file system is indeed formatted in a way we can
+ // understand it...
+ //
+ if (!EfiCompareGuid (&FwVolHeader->FileSystemGuid, &gEfiFirmwareFileSystemGuid)) {
+ continue;
+ }
+
+ //
+ // Check if there is an FV protocol already installed in that handle
+ //
+ Status = CoreHandleProtocol (Handle, &gEfiFirmwareVolumeProtocolGuid, &Fv);
+ if (!EFI_ERROR (Status)) {
+ //
+ // Update Fv to use a new Fvb
+ //
+ FvDevice = _CR (Fv, FV_DEVICE, Fv);
+ if (FvDevice->Signature == FV_DEVICE_SIGNATURE) {
+ //
+ // Only write into our device structure if it's our device structure
+ //
+ FvDevice->Fvb = Fvb;
+ }
+
+ } else {
+ //
+ // No FwVol protocol on the handle so create a new one
+ //
+ FvDevice = CoreAllocateCopyPool (sizeof (FV_DEVICE), &mFvDevice);
+ if (FvDevice == NULL) {
+ return;
+ }
+
+ FvDevice->Fvb = Fvb;
+ FvDevice->Handle = Handle;
+ FvDevice->FwVolHeader = FwVolHeader;
+ FvDevice->Fv.ParentHandle = Fvb->ParentHandle;
+
+ //
+ // Install an New FV protocol on the existing handle
+ //
+ Status = CoreInstallProtocolInterface (
+ &Handle,
+ &gEfiFirmwareVolumeProtocolGuid,
+ EFI_NATIVE_INTERFACE,
+ &FvDevice->Fv
+ );
+ ASSERT_EFI_ERROR (Status);
+ }
+ }
+
+ return;
+}
+
+
+EFI_STATUS
+EFIAPI
+FwVolDriverInit (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+/*++
+
+Routine Description:
+ This routine is the driver initialization entry point. It initializes the
+ libraries, and registers two notification functions. These notification
+ functions are responsible for building the FV stack dynamically.
+
+Arguments:
+ ImageHandle - The image handle.
+ SystemTable - The system table.
+
+Returns:
+ EFI_SUCCESS - Function successfully returned.
+
+--*/
+{
+ gEfiFwVolBlockEvent = CoreCreateProtocolNotifyEvent (
+ &gEfiFirmwareVolumeBlockProtocolGuid,
+ EFI_TPL_CALLBACK,
+ NotifyFwVolBlock,
+ NULL,
+ &gEfiFwVolBlockNotifyReg,
+ TRUE
+ );
+ return EFI_SUCCESS;
+}
+
diff --git a/EDK/Foundation/Core/Dxe/FwVol/FwVolAttrib.c b/EDK/Foundation/Core/Dxe/FwVol/FwVolAttrib.c
new file mode 100644
index 0000000..690d919
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/FwVol/FwVolAttrib.c
@@ -0,0 +1,99 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ FwVolAttrib.c
+
+Abstract:
+
+ Implements get/set firmware volume attributes
+
+--*/
+
+#include "FwVolDriver.h"
+
+EFI_STATUS
+EFIAPI
+FvGetVolumeAttributes (
+ IN EFI_FIRMWARE_VOLUME_PROTOCOL *This,
+ OUT EFI_FV_ATTRIBUTES *Attributes
+ )
+/*++
+
+Routine Description:
+ Retrieves attributes, insures positive polarity of attribute bits, returns
+ resulting attributes in output parameter
+
+Arguments:
+ This - Calling context
+ Attributes - output buffer which contains attributes
+
+Returns:
+ EFI_SUCCESS - Successfully got volume attributes
+
+--*/
+{
+ EFI_STATUS Status;
+ FV_DEVICE *FvDevice;
+ EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb;
+ EFI_FVB_ATTRIBUTES FvbAttributes;
+
+ FvDevice = FV_DEVICE_FROM_THIS (This);
+ Fvb = FvDevice->Fvb;
+
+ if (FvDevice->CachedFv == NULL) {
+ Status = FvCheck (FvDevice);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ }
+
+ //
+ // First get the Firmware Volume Block Attributes
+ //
+ Status = Fvb->GetVolumeAttributes (Fvb, &FvbAttributes);
+
+ //
+ // Mask out Fvb bits that are not defined in FV
+ //
+ FvbAttributes &= 0xfffff0ff;
+
+ *Attributes = (EFI_FV_ATTRIBUTES)FvbAttributes;
+
+ return Status;
+}
+
+
+EFI_STATUS
+EFIAPI
+FvSetVolumeAttributes (
+ IN EFI_FIRMWARE_VOLUME_PROTOCOL *This,
+ IN OUT EFI_FV_ATTRIBUTES *Attributes
+ )
+/*++
+
+Routine Description:
+ Sets current attributes for volume
+
+Arguments:
+ This - Calling context
+ Attributes - At input, contains attributes to be set. At output contains
+ new value of FV
+
+Returns:
+ EFI_UNSUPPORTED - Could not be set.
+
+--*/
+{
+ return EFI_UNSUPPORTED;
+}
+
diff --git a/EDK/Foundation/Core/Dxe/FwVol/FwVolDriver.h b/EDK/Foundation/Core/Dxe/FwVol/FwVolDriver.h
new file mode 100644
index 0000000..4bd336d
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/FwVol/FwVolDriver.h
@@ -0,0 +1,487 @@
+/*++
+
+Copyright (c) 2004 - 2005, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ FwVolDriver.h
+
+Abstract:
+
+ Firmware File System protocol. Layers on top of Firmware
+ Block protocol to produce a file abstraction of FV based files.
+
+--*/
+
+#ifndef __FWVOL_H
+#define __FWVOL_H
+
+#include "Tiano.h"
+#include "DxeCore.h"
+#include "EfiFirmwareFileSystem.h"
+#include "EfiFirmwareVolumeHeader.h"
+
+//
+// Consumed protocol
+//
+#include EFI_PROTOCOL_DEFINITION (FirmwareVolumeBlock)
+#include EFI_PROTOCOL_DEFINITION (SectionExtraction)
+
+//
+// Consumed GUID
+//
+#include EFI_GUID_DEFINITION (FirmwareFileSystem)
+
+//
+// Produced protocol
+//
+#include EFI_PROTOCOL_DEFINITION (FirmwareVolume)
+
+
+//
+// Used to track all non-deleted files
+//
+typedef struct {
+ EFI_LIST_ENTRY Link;
+ EFI_FFS_FILE_HEADER *FfsHeader;
+ UINTN StreamHandle;
+ EFI_SECTION_EXTRACTION_PROTOCOL *Sep;
+} FFS_FILE_LIST_ENTRY;
+
+typedef struct {
+ UINTN Signature;
+ EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb;
+ EFI_HANDLE Handle;
+ EFI_FIRMWARE_VOLUME_PROTOCOL Fv;
+
+ EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;
+ UINT8 *CachedFv;
+ UINT8 *EndOfCachedFv;
+
+ FFS_FILE_LIST_ENTRY *LastKey;
+
+ EFI_LIST_ENTRY FfsFileListHeader;
+
+ UINT8 ErasePolarity;
+} FV_DEVICE;
+
+#define FV_DEVICE_FROM_THIS(a) CR(a, FV_DEVICE, Fv, FV_DEVICE_SIGNATURE)
+
+
+EFI_STATUS
+EFIAPI
+FvGetVolumeAttributes (
+ IN EFI_FIRMWARE_VOLUME_PROTOCOL *This,
+ OUT EFI_FV_ATTRIBUTES *Attributes
+ )
+/*++
+
+Routine Description:
+ Retrieves attributes, insures positive polarity of attribute bits, returns
+ resulting attributes in output parameter
+
+Arguments:
+ This - Calling context
+ Attributes - output buffer which contains attributes
+
+Returns:
+ EFI_SUCCESS - Successfully got volume attributes
+
+--*/
+;
+
+EFI_STATUS
+EFIAPI
+FvSetVolumeAttributes (
+ IN EFI_FIRMWARE_VOLUME_PROTOCOL *This,
+ IN OUT EFI_FV_ATTRIBUTES *Attributes
+ )
+/*++
+
+Routine Description:
+ Sets current attributes for volume
+
+Arguments:
+ This - Calling context
+ Attributes - At input, contains attributes to be set. At output contains
+ new value of FV
+
+Returns:
+ EFI_UNSUPPORTED - Could not be set.
+--*/
+;
+
+EFI_STATUS
+EFIAPI
+FvGetNextFile (
+ IN EFI_FIRMWARE_VOLUME_PROTOCOL *This,
+ IN OUT VOID *Key,
+ IN OUT EFI_FV_FILETYPE *FileType,
+ OUT EFI_GUID *NameGuid,
+ OUT EFI_FV_FILE_ATTRIBUTES *Attributes,
+ OUT UINTN *Size
+ )
+/*++
+
+Routine Description:
+ Given the input key, search for the next matching file in the volume.
+
+Arguments:
+ This - Indicates the calling context.
+ FileType - FileType is a pointer to a caller allocated
+ EFI_FV_FILETYPE. The GetNextFile() API can filter it's
+ search for files based on the value of *FileType input.
+ A *FileType input of 0 causes GetNextFile() to search for
+ files of all types. If a file is found, the file's type
+ is returned in *FileType. *FileType is not modified if
+ no file is found.
+ Key - Key is a pointer to a caller allocated buffer that
+ contains implementation specific data that is used to
+ track where to begin the search for the next file.
+ The size of the buffer must be at least This->KeySize
+ bytes long. To reinitialize the search and begin from
+ the beginning of the firmware volume, the entire buffer
+ must be cleared to zero. Other than clearing the buffer
+ to initiate a new search, the caller must not modify the
+ data in the buffer between calls to GetNextFile().
+ NameGuid - NameGuid is a pointer to a caller allocated EFI_GUID.
+ If a file is found, the file's name is returned in
+ *NameGuid. *NameGuid is not modified if no file is
+ found.
+ Attributes - Attributes is a pointer to a caller allocated
+ EFI_FV_FILE_ATTRIBUTES. If a file is found, the file's
+ attributes are returned in *Attributes. *Attributes is
+ not modified if no file is found.
+ Size - Size is a pointer to a caller allocated UINTN.
+ If a file is found, the file's size is returned in *Size.
+ *Size is not modified if no file is found.
+
+Returns:
+ EFI_SUCCESS - Successfully find the file.
+ EFI_DEVICE_ERROR - Device error.
+ EFI_ACCESS_DENIED - Fv could not read.
+ EFI_NOT_FOUND - No matching file found.
+ EFI_INVALID_PARAMETER - Invalid parameter
+
+--*/
+;
+
+
+EFI_STATUS
+EFIAPI
+FvReadFile (
+ IN EFI_FIRMWARE_VOLUME_PROTOCOL *This,
+ IN EFI_GUID *NameGuid,
+ IN OUT VOID **Buffer,
+ IN OUT UINTN *BufferSize,
+ OUT EFI_FV_FILETYPE *FoundType,
+ OUT EFI_FV_FILE_ATTRIBUTES *FileAttributes,
+ OUT UINT32 *AuthenticationStatus
+ )
+/*++
+
+Routine Description:
+ Locates a file in the firmware volume and
+ copies it to the supplied buffer.
+
+Arguments:
+ This - Indicates the calling context.
+ NameGuid - Pointer to an EFI_GUID, which is the filename.
+ Buffer - Buffer is a pointer to pointer to a buffer in
+ which the file or section contents or are returned.
+ BufferSize - BufferSize is a pointer to caller allocated
+ UINTN. On input *BufferSize indicates the size
+ in bytes of the memory region pointed to by
+ Buffer. On output, *BufferSize contains the number
+ of bytes required to read the file.
+ FoundType - FoundType is a pointer to a caller allocated
+ EFI_FV_FILETYPE that on successful return from Read()
+ contains the type of file read. This output reflects
+ the file type irrespective of the value of the
+ SectionType input.
+ FileAttributes - FileAttributes is a pointer to a caller allocated
+ EFI_FV_FILE_ATTRIBUTES. On successful return from
+ Read(), *FileAttributes contains the attributes of
+ the file read.
+ AuthenticationStatus - AuthenticationStatus is a pointer to a caller
+ allocated UINTN in which the authentication status
+ is returned.
+Returns:
+ EFI_SUCCESS - Successfully read to memory buffer.
+ EFI_WARN_BUFFER_TOO_SMALL - Buffer too small.
+ EFI_NOT_FOUND - Not found.
+ EFI_DEVICE_ERROR - Device error.
+ EFI_ACCESS_DENIED - Could not read.
+ EFI_INVALID_PARAMETER - Invalid parameter.
+ EFI_OUT_OF_RESOURCES - Not enough buffer to be allocated.
+
+--*/
+;
+
+EFI_STATUS
+EFIAPI
+FvReadFileSection (
+ IN EFI_FIRMWARE_VOLUME_PROTOCOL *This,
+ IN EFI_GUID *NameGuid,
+ IN EFI_SECTION_TYPE SectionType,
+ IN UINTN SectionInstance,
+ IN OUT VOID **Buffer,
+ IN OUT UINTN *BufferSize,
+ OUT UINT32 *AuthenticationStatus
+ )
+/*++
+
+ Routine Description:
+ Locates a section in a given FFS File and
+ copies it to the supplied buffer (not including section header).
+
+ Arguments:
+ This - Indicates the calling context.
+ NameGuid - Pointer to an EFI_GUID, which is the filename.
+ SectionType - Indicates the section type to return.
+ SectionInstance - Indicates which instance of sections with a type of
+ SectionType to return.
+ Buffer - Buffer is a pointer to pointer to a buffer in which
+ the file or section contents or are returned.
+ BufferSize - BufferSize is a pointer to caller allocated UINTN.
+ AuthenticationStatus -AuthenticationStatus is a pointer to a caller
+ allocated UINT32 in which the authentication status
+ is returned.
+
+ Returns:
+ EFI_SUCCESS - Successfully read the file section into buffer.
+ EFI_WARN_BUFFER_TOO_SMALL - Buffer too small.
+ EFI_NOT_FOUND - Section not found.
+ EFI_DEVICE_ERROR - Device error.
+ EFI_ACCESS_DENIED - Could not read.
+ EFI_INVALID_PARAMETER - Invalid parameter.
+
+--*/
+;
+
+EFI_STATUS
+EFIAPI
+FvWriteFile (
+ IN EFI_FIRMWARE_VOLUME_PROTOCOL *This,
+ IN UINT32 NumberOfFiles,
+ IN EFI_FV_WRITE_POLICY WritePolicy,
+ IN EFI_FV_WRITE_FILE_DATA *FileData
+ )
+/*++
+
+ Routine Description:
+ Writes one or more files to the firmware volume.
+
+ Arguments:
+ This - Indicates the calling context.
+ WritePolicy - WritePolicy indicates the level of reliability for
+ the write in the event of a power failure or other
+ system failure during the write operation.
+ FileData - FileData is an pointer to an array of EFI_FV_WRITE_DATA.
+ Each element of FileData[] represents a file to be written.
+
+ Returns:
+ EFI_SUCCESS - Files successfully written to firmware volume
+ EFI_OUT_OF_RESOURCES - Not enough buffer to be allocated.
+ EFI_DEVICE_ERROR - Device error.
+ EFI_WRITE_PROTECTED - Write protected.
+ EFI_NOT_FOUND - Not found.
+ EFI_INVALID_PARAMETER - Invalid parameter.
+ EFI_UNSUPPORTED - This function not supported.
+
+--*/
+;
+
+
+
+//
+//Internal functions
+//
+typedef enum {
+ EfiCheckSumUint8 = 0,
+ EfiCheckSumUint16 = 1,
+ EfiCheckSumUint32 = 2,
+ EfiCheckSumUint64 = 3,
+ EfiCheckSumMaximum = 4
+} EFI_CHECKSUM_TYPE;
+
+
+BOOLEAN
+IsBufferErased (
+ IN UINT8 ErasePolarity,
+ IN VOID *Buffer,
+ IN UINTN BufferSize
+ )
+/*++
+
+Routine Description:
+ Check if a block of buffer is erased
+
+Arguments:
+ ErasePolarity - Erase polarity attribute of the firmware volume
+ Buffer - The buffer to be checked
+ BufferSize - Size of the buffer in bytes
+
+Returns:
+ TRUE - The block of buffer is erased
+ FALSE - The block of buffer is not erased
+
+--*/
+;
+
+EFI_FFS_FILE_STATE
+GetFileState (
+ IN UINT8 ErasePolarity,
+ IN EFI_FFS_FILE_HEADER *FfsHeader
+ )
+/*++
+
+Routine Description:
+ Get the FFS file state by checking the highest bit set in the header's state field
+
+Arguments:
+ ErasePolarity - Erase polarity attribute of the firmware volume
+ FfsHeader - Points to the FFS file header
+
+Returns:
+ FFS File state
+
+--*/
+;
+
+VOID
+SetFileState (
+ IN UINT8 State,
+ IN EFI_FFS_FILE_HEADER *FfsHeader
+ )
+/*++
+
+Routine Description:
+ Set the FFS file state.
+
+Arguments:
+ State - The state to be set.
+ FfsHeader - Points to the FFS file header
+
+Returns:
+ None.
+
+--*/
+;
+
+BOOLEAN
+VerifyFvHeaderChecksum (
+ IN EFI_FIRMWARE_VOLUME_HEADER *FvHeader
+ )
+/*++
+
+Routine Description:
+ Verify checksum of the firmware volume header
+
+Arguments:
+ FvHeader - Points to the firmware volume header to be checked
+
+Returns:
+ TRUE - Checksum verification passed
+ FALSE - Checksum verification failed
+
+--*/
+;
+
+BOOLEAN
+IsValidFfsHeader (
+ IN UINT8 ErasePolarity,
+ IN EFI_FFS_FILE_HEADER *FfsHeader,
+ OUT EFI_FFS_FILE_STATE *FileState
+ )
+/*++
+
+Routine Description:
+ Check if it's a valid FFS file header
+
+Arguments:
+ ErasePolarity - Erase polarity attribute of the firmware volume
+ FfsHeader - Points to the FFS file header to be checked
+ FileState - FFS file state to be returned
+
+Returns:
+ TRUE - Valid FFS file header
+ FALSE - Invalid FFS file header
+
+--*/
+;
+
+BOOLEAN
+IsValidFfsFile (
+ IN UINT8 ErasePolarity,
+ IN EFI_FFS_FILE_HEADER *FfsHeader
+ )
+/*++
+
+Routine Description:
+ Check if it's a valid FFS file.
+ Here we are sure that it has a valid FFS file header since we must call IsValidFfsHeader() first.
+
+Arguments:
+ ErasePolarity - Erase polarity attribute of the firmware volume
+ FfsHeader - Points to the FFS file to be checked
+
+Returns:
+ TRUE - Valid FFS file
+ FALSE - Invalid FFS file
+
+--*/
+;
+
+EFI_STATUS
+GetFwVolHeader (
+ IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb,
+ OUT EFI_FIRMWARE_VOLUME_HEADER **FwVolHeader
+ )
+/*++
+
+Routine Description:
+ given the supplied FW_VOL_BLOCK_PROTOCOL, allocate a buffer for output and
+ copy the volume header into it.
+
+Arguments:
+ Fvb - The FW_VOL_BLOCK_PROTOCOL instance from which to read the volume
+ header
+ FwVolHeader - Pointer to pointer to allocated buffer in which the volume
+ header is returned.
+
+Returns:
+ Status code.
+
+--*/
+;
+
+
+EFI_STATUS
+FvCheck (
+ IN OUT FV_DEVICE *FvDevice
+ )
+/*++
+
+Routine Description:
+ Check if a FV is consistent and allocate cache
+
+Arguments:
+ FvDevice - pointer to the FvDevice to be checked.
+
+Returns:
+ EFI_OUT_OF_RESOURCES - Not enough buffer to be allocated.
+ EFI_SUCCESS - FV is consistent and cache is allocated.
+ EFI_VOLUME_CORRUPTED - File system is corrupted.
+
+--*/
+;
+
+#endif \ No newline at end of file
diff --git a/EDK/Foundation/Core/Dxe/FwVol/FwVolRead.c b/EDK/Foundation/Core/Dxe/FwVol/FwVolRead.c
new file mode 100644
index 0000000..acaffa8
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/FwVol/FwVolRead.c
@@ -0,0 +1,520 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ FwVolRead.c
+
+Abstract:
+
+ Implements read firmware file
+
+--*/
+
+#include "FwVolDriver.h"
+#include "DxeCore.h"
+
+/*++
+
+Required Alignment Alignment Value in FFS Alignment Value in
+(bytes) Attributes Field Firmware Volume Interfaces
+1 0 0
+2 0 1
+4 0 2
+8 0 3
+16 1 4
+128 2 7
+512 3 9
+1 KB 4 10
+4 KB 5 12
+32 KB 6 15
+64 KB 7 16
+
+--*/
+
+UINT8 mFvAttributes[] = {0, 4, 7, 9, 10, 12, 15, 16};
+
+
+STATIC
+EFI_FV_FILE_ATTRIBUTES
+FfsAttributes2FvFileAttributes (
+ IN EFI_FFS_FILE_ATTRIBUTES FfsAttributes
+ )
+/*++
+
+ Routine Description:
+ Convert the FFS File Attributes to FV File Attributes
+
+ Arguments:
+ FfsAttributes - The attributes of UINT8 type.
+
+ Returns:
+ The attributes of EFI_FV_FILE_ATTRIBUTES
+
+--*/
+{
+ FfsAttributes = (EFI_FFS_FILE_ATTRIBUTES)((FfsAttributes & FFS_ATTRIB_DATA_ALIGNMENT) >> 3);
+ ASSERT (FfsAttributes < 8);
+
+ return (EFI_FV_FILE_ATTRIBUTES) mFvAttributes[FfsAttributes];
+}
+
+
+EFI_STATUS
+EFIAPI
+FvGetNextFile (
+ IN EFI_FIRMWARE_VOLUME_PROTOCOL *This,
+ IN OUT VOID *Key,
+ IN OUT EFI_FV_FILETYPE *FileType,
+ OUT EFI_GUID *NameGuid,
+ OUT EFI_FV_FILE_ATTRIBUTES *Attributes,
+ OUT UINTN *Size
+ )
+/*++
+
+Routine Description:
+ Given the input key, search for the next matching file in the volume.
+
+Arguments:
+ This - Indicates the calling context.
+ FileType - FileType is a pointer to a caller allocated
+ EFI_FV_FILETYPE. The GetNextFile() API can filter it's
+ search for files based on the value of *FileType input.
+ A *FileType input of 0 causes GetNextFile() to search for
+ files of all types. If a file is found, the file's type
+ is returned in *FileType. *FileType is not modified if
+ no file is found.
+ Key - Key is a pointer to a caller allocated buffer that
+ contains implementation specific data that is used to
+ track where to begin the search for the next file.
+ The size of the buffer must be at least This->KeySize
+ bytes long. To reinitialize the search and begin from
+ the beginning of the firmware volume, the entire buffer
+ must be cleared to zero. Other than clearing the buffer
+ to initiate a new search, the caller must not modify the
+ data in the buffer between calls to GetNextFile().
+ NameGuid - NameGuid is a pointer to a caller allocated EFI_GUID.
+ If a file is found, the file's name is returned in
+ *NameGuid. *NameGuid is not modified if no file is
+ found.
+ Attributes - Attributes is a pointer to a caller allocated
+ EFI_FV_FILE_ATTRIBUTES. If a file is found, the file's
+ attributes are returned in *Attributes. *Attributes is
+ not modified if no file is found.
+ Size - Size is a pointer to a caller allocated UINTN.
+ If a file is found, the file's size is returned in *Size.
+ *Size is not modified if no file is found.
+
+Returns:
+ EFI_SUCCESS - Successfully find the file.
+ EFI_DEVICE_ERROR - Device error.
+ EFI_ACCESS_DENIED - Fv could not read.
+ EFI_NOT_FOUND - No matching file found.
+ EFI_INVALID_PARAMETER - Invalid parameter
+
+--*/
+{
+ EFI_STATUS Status;
+ FV_DEVICE *FvDevice;
+ EFI_FV_ATTRIBUTES FvAttributes;
+ EFI_FFS_FILE_HEADER *FfsFileHeader;
+ UINTN *KeyValue;
+ EFI_LIST_ENTRY *Link;
+ FFS_FILE_LIST_ENTRY *FfsFileEntry;
+ UINTN FileLength;
+
+ FvDevice = FV_DEVICE_FROM_THIS (This);
+
+ Status = FvGetVolumeAttributes (This, &FvAttributes);
+ if (EFI_ERROR (Status)){
+ return Status;
+ }
+
+ //
+ // Check if read operation is enabled
+ //
+ if ((FvAttributes & EFI_FV_READ_STATUS) == 0) {
+ return EFI_ACCESS_DENIED;
+ }
+
+ if (*FileType > EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE) {
+ //
+ // File type needs to be in 0 - 0x0B
+ //
+ return EFI_INVALID_PARAMETER;
+ }
+
+ KeyValue = (UINTN *)Key;
+ for (;;) {
+ if (*KeyValue == 0) {
+ //
+ // Search for 1st matching file
+ //
+ Link = &FvDevice->FfsFileListHeader;
+ } else {
+ //
+ // Key is pointer to FFsFileEntry, so get next one
+ //
+ Link = (EFI_LIST_ENTRY *)(*KeyValue);
+ }
+
+ if (Link->ForwardLink == &FvDevice->FfsFileListHeader) {
+ //
+ // Next is end of list so we did not find data
+ //
+ return EFI_NOT_FOUND;
+ }
+
+ FfsFileEntry = (FFS_FILE_LIST_ENTRY *)Link->ForwardLink;
+ FfsFileHeader = (EFI_FFS_FILE_HEADER *)FfsFileEntry->FfsHeader;
+
+ //
+ // remember the key
+ //
+ *KeyValue = (UINTN)FfsFileEntry;
+
+ if (FfsFileHeader->Type == EFI_FV_FILETYPE_FFS_PAD) {
+ //
+ // we ignore pad files
+ //
+ continue;
+ }
+
+ if (*FileType == 0) {
+ //
+ // Process all file types so we have a match
+ //
+ break;
+ }
+
+ if (*FileType == FfsFileHeader->Type) {
+ //
+ // Found a matching file type
+ //
+ break;
+ }
+
+ }
+
+ //
+ // Return FileType, NameGuid, and Attributes
+ //
+ *FileType = FfsFileHeader->Type;
+ EfiCommonLibCopyMem (NameGuid, &FfsFileHeader->Name, sizeof (EFI_GUID));
+ *Attributes = FfsAttributes2FvFileAttributes (FfsFileHeader->Attributes);
+
+ //
+ // Read four bytes out of the 3 byte array and throw out extra data
+ //
+ FileLength = *(UINT32 *)&FfsFileHeader->Size[0] & 0x00FFFFFF;
+
+ //
+ // we need to substract the header size
+ //
+ *Size = FileLength - sizeof(EFI_FFS_FILE_HEADER);
+
+ if (FfsFileHeader->Attributes & FFS_ATTRIB_TAIL_PRESENT) {
+ //
+ // If tail is present substract it's size;
+ //
+ *Size -= sizeof(EFI_FFS_FILE_TAIL);
+ }
+
+ return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+EFIAPI
+FvReadFile (
+ IN EFI_FIRMWARE_VOLUME_PROTOCOL *This,
+ IN EFI_GUID *NameGuid,
+ IN OUT VOID **Buffer,
+ IN OUT UINTN *BufferSize,
+ OUT EFI_FV_FILETYPE *FoundType,
+ OUT EFI_FV_FILE_ATTRIBUTES *FileAttributes,
+ OUT UINT32 *AuthenticationStatus
+ )
+/*++
+
+Routine Description:
+ Locates a file in the firmware volume and
+ copies it to the supplied buffer.
+
+Arguments:
+ This - Indicates the calling context.
+ NameGuid - Pointer to an EFI_GUID, which is the filename.
+ Buffer - Buffer is a pointer to pointer to a buffer in
+ which the file or section contents or are returned.
+ BufferSize - BufferSize is a pointer to caller allocated
+ UINTN. On input *BufferSize indicates the size
+ in bytes of the memory region pointed to by
+ Buffer. On output, *BufferSize contains the number
+ of bytes required to read the file.
+ FoundType - FoundType is a pointer to a caller allocated
+ EFI_FV_FILETYPE that on successful return from Read()
+ contains the type of file read. This output reflects
+ the file type irrespective of the value of the
+ SectionType input.
+ FileAttributes - FileAttributes is a pointer to a caller allocated
+ EFI_FV_FILE_ATTRIBUTES. On successful return from
+ Read(), *FileAttributes contains the attributes of
+ the file read.
+ AuthenticationStatus - AuthenticationStatus is a pointer to a caller
+ allocated UINTN in which the authentication status
+ is returned.
+Returns:
+ EFI_SUCCESS - Successfully read to memory buffer.
+ EFI_WARN_BUFFER_TOO_SMALL - Buffer too small.
+ EFI_NOT_FOUND - Not found.
+ EFI_DEVICE_ERROR - Device error.
+ EFI_ACCESS_DENIED - Could not read.
+ EFI_INVALID_PARAMETER - Invalid parameter.
+ EFI_OUT_OF_RESOURCES - Not enough buffer to be allocated.
+
+--*/
+{
+ EFI_STATUS Status;
+ FV_DEVICE *FvDevice;
+ EFI_GUID SearchNameGuid;
+ EFI_FV_FILETYPE LocalFoundType;
+ EFI_FV_FILE_ATTRIBUTES LocalAttributes;
+ UINTN FileSize;
+ UINT8 *SrcPtr;
+ EFI_FFS_FILE_HEADER *FfsHeader;
+ UINTN InputBufferSize;
+
+ if (NULL == NameGuid) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ FvDevice = FV_DEVICE_FROM_THIS (This);
+
+
+ //
+ // Keep looking until we find the matching NameGuid.
+ // The Key is really an FfsFileEntry
+ //
+ FvDevice->LastKey = 0;
+ do {
+ LocalFoundType = 0;
+ Status = FvGetNextFile (
+ This,
+ &FvDevice->LastKey,
+ &LocalFoundType,
+ &SearchNameGuid,
+ &LocalAttributes,
+ &FileSize
+ );
+ if (EFI_ERROR (Status)) {
+ return EFI_NOT_FOUND;
+ }
+ } while (!EfiCompareGuid (&SearchNameGuid, NameGuid));
+
+ //
+ // Get a pointer to the header
+ //
+ FfsHeader = FvDevice->LastKey->FfsHeader;
+
+ //
+ // Remember callers buffer size
+ //
+ InputBufferSize = *BufferSize;
+
+ //
+ // Calculate return values
+ //
+ *FoundType = FfsHeader->Type;
+ *FileAttributes = FfsAttributes2FvFileAttributes (FfsHeader->Attributes);
+ *AuthenticationStatus = 0;
+ *BufferSize = FileSize;
+
+ if (Buffer == NULL) {
+ //
+ // If Buffer is NULL, we only want to get the information colected so far
+ //
+ return EFI_SUCCESS;
+ }
+
+ //
+ // Skip over file header
+ //
+ SrcPtr = ((UINT8 *)FfsHeader) + sizeof (EFI_FFS_FILE_HEADER);
+
+ Status = EFI_SUCCESS;
+ if (*Buffer == NULL) {
+ //
+ // Caller passed in a pointer so allocate buffer for them
+ //
+ *Buffer = CoreAllocateBootServicesPool (FileSize);
+ if (*Buffer == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ } else if (FileSize > InputBufferSize) {
+ //
+ // Callers buffer was not big enough
+ //
+ Status = EFI_WARN_BUFFER_TOO_SMALL;
+ FileSize = InputBufferSize;
+ }
+
+ //
+ // Copy data into callers buffer
+ //
+ EfiCommonLibCopyMem (*Buffer, SrcPtr, FileSize);
+
+ return Status;
+}
+
+
+EFI_STATUS
+EFIAPI
+FvReadFileSection (
+ IN EFI_FIRMWARE_VOLUME_PROTOCOL *This,
+ IN EFI_GUID *NameGuid,
+ IN EFI_SECTION_TYPE SectionType,
+ IN UINTN SectionInstance,
+ IN OUT VOID **Buffer,
+ IN OUT UINTN *BufferSize,
+ OUT UINT32 *AuthenticationStatus
+ )
+/*++
+
+ Routine Description:
+ Locates a section in a given FFS File and
+ copies it to the supplied buffer (not including section header).
+
+ Arguments:
+ This - Indicates the calling context.
+ NameGuid - Pointer to an EFI_GUID, which is the filename.
+ SectionType - Indicates the section type to return.
+ SectionInstance - Indicates which instance of sections with a type of
+ SectionType to return.
+ Buffer - Buffer is a pointer to pointer to a buffer in which
+ the file or section contents or are returned.
+ BufferSize - BufferSize is a pointer to caller allocated UINTN.
+ AuthenticationStatus -AuthenticationStatus is a pointer to a caller
+ allocated UINT32 in which the authentication status
+ is returned.
+
+ Returns:
+ EFI_SUCCESS - Successfully read the file section into buffer.
+ EFI_WARN_BUFFER_TOO_SMALL - Buffer too small.
+ EFI_NOT_FOUND - Section not found.
+ EFI_DEVICE_ERROR - Device error.
+ EFI_ACCESS_DENIED - Could not read.
+ EFI_INVALID_PARAMETER - Invalid parameter.
+
+--*/
+{
+ EFI_STATUS Status;
+ FV_DEVICE *FvDevice;
+ EFI_FV_FILETYPE FileType;
+ EFI_FV_FILE_ATTRIBUTES FileAttributes;
+ UINTN FileSize;
+ UINT8 *FileBuffer;
+ EFI_SECTION_EXTRACTION_PROTOCOL *Sep;
+ FFS_FILE_LIST_ENTRY *FfsEntry;
+
+ if (NULL == NameGuid || Buffer == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ FvDevice = FV_DEVICE_FROM_THIS (This);
+
+ //
+ // Read the whole file into buffer
+ //
+ FileBuffer = NULL;
+ Status = FvReadFile (
+ This,
+ NameGuid,
+ &FileBuffer,
+ &FileSize,
+ &FileType,
+ &FileAttributes,
+ AuthenticationStatus
+ );
+ //
+ // Get the last key used by our call to FvReadFile as it is the FfsEntry for this file.
+ //
+ FfsEntry = (FFS_FILE_LIST_ENTRY *)FvDevice->LastKey;
+
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ //
+ // Check to see that the file actually HAS sections before we go any further.
+ //
+ if (FileType == EFI_FV_FILETYPE_RAW) {
+ Status = EFI_NOT_FOUND;
+ goto Done;
+ }
+
+ //
+ // Use FfsEntry to cache Section Extraction Protocol Inforomation
+ //
+ if (FfsEntry->StreamHandle == 0) {
+ //
+ // Located the protocol
+ //
+ Status = CoreLocateProtocol (&gEfiSectionExtractionProtocolGuid, NULL, &Sep);
+ //
+ // Section Extraction Protocol is part of Dxe Core so this should never fail
+ //
+ ASSERT_EFI_ERROR (Status);
+ if (EFI_ERROR (Status) || (Sep == NULL)) {
+ goto Done;
+ }
+
+ Status = Sep->OpenSectionStream (
+ Sep,
+ FileSize,
+ FileBuffer,
+ &FfsEntry->StreamHandle
+ );
+ if (EFI_ERROR (Status)) {
+ goto Done;
+ }
+
+ FfsEntry->Sep = Sep;
+ } else {
+ //
+ // Get cached copy of Sep
+ //
+ Sep = FfsEntry->Sep;
+ }
+
+ //
+ // If SectionType == 0 We need the whole section stream
+ //
+ Status = Sep->GetSection (
+ Sep,
+ FfsEntry->StreamHandle,
+ (SectionType == 0) ? NULL : &SectionType,
+ NULL,
+ (SectionType == 0) ? 0 : SectionInstance,
+ Buffer,
+ BufferSize,
+ AuthenticationStatus
+ );
+
+ //
+ // Close of stream defered to close of FfsHeader list to allow SEP to cache data
+ //
+
+Done:
+ CoreFreePool (FileBuffer);
+
+ return Status;
+}
+
diff --git a/EDK/Foundation/Core/Dxe/FwVol/FwVolWrite.c b/EDK/Foundation/Core/Dxe/FwVol/FwVolWrite.c
new file mode 100644
index 0000000..1db7305
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/FwVol/FwVolWrite.c
@@ -0,0 +1,60 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ FwVolWrite.c
+
+Abstract:
+
+ Implements write firmware file
+
+--*/
+
+#include "FwVolDriver.h"
+
+
+EFI_STATUS
+EFIAPI
+FvWriteFile (
+ IN EFI_FIRMWARE_VOLUME_PROTOCOL *This,
+ IN UINT32 NumberOfFiles,
+ IN EFI_FV_WRITE_POLICY WritePolicy,
+ IN EFI_FV_WRITE_FILE_DATA *FileData
+ )
+/*++
+
+ Routine Description:
+ Writes one or more files to the firmware volume.
+
+ Arguments:
+ This - Indicates the calling context.
+ NumberOfFiles - Number of files.
+ WritePolicy - WritePolicy indicates the level of reliability for
+ the write in the event of a power failure or other
+ system failure during the write operation.
+ FileData - FileData is an pointer to an array of EFI_FV_WRITE_DATA.
+ Each element of FileData[] represents a file to be written.
+
+ Returns:
+ EFI_SUCCESS - Files successfully written to firmware volume
+ EFI_OUT_OF_RESOURCES - Not enough buffer to be allocated.
+ EFI_DEVICE_ERROR - Device error.
+ EFI_WRITE_PROTECTED - Write protected.
+ EFI_NOT_FOUND - Not found.
+ EFI_INVALID_PARAMETER - Invalid parameter.
+ EFI_UNSUPPORTED - This function not supported.
+
+--*/
+{
+ return EFI_UNSUPPORTED;
+}
+
diff --git a/EDK/Foundation/Core/Dxe/FwVolBlock/FwVolBlock.c b/EDK/Foundation/Core/Dxe/FwVolBlock/FwVolBlock.c
new file mode 100644
index 0000000..ebe3964
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/FwVolBlock/FwVolBlock.c
@@ -0,0 +1,621 @@
+/*++
+
+Copyright (c) 2004 - 2005, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ FwVolBlock.c
+
+Abstract:
+
+ Firmware Volume Block protocol.. Consumes FV hobs and creates
+ appropriate block protocols.
+
+ Also consumes NT_NON_MM_FV envinronment variable and produces appropriate
+ block protocols fro them also... (this is TBD)
+
+--*/
+
+#include "Tiano.h"
+#include "FwVolBlock.h"
+
+
+EFI_FW_VOL_BLOCK_DEVICE mFwVolBlock = {
+ FVB_DEVICE_SIGNATURE,
+ NULL,
+ {
+ {
+ HARDWARE_DEVICE_PATH,
+ HW_MEMMAP_DP,
+ (UINT8)(sizeof (MEMMAP_DEVICE_PATH)),
+ (UINT8)(sizeof (MEMMAP_DEVICE_PATH) >> 8),
+ EfiMemoryMappedIO,
+ (EFI_PHYSICAL_ADDRESS)0,
+ (EFI_PHYSICAL_ADDRESS)0,
+ },
+ {
+ END_DEVICE_PATH_TYPE,
+ END_ENTIRE_DEVICE_PATH_SUBTYPE,
+ END_DEVICE_PATH_LENGTH,
+ 0
+ },
+ },
+ {
+ FwVolBlockGetAttributes,
+ (EFI_FVB_SET_ATTRIBUTES)FwVolBlockSetAttributes,
+ FwVolBlockGetPhysicalAddress,
+ FwVolBlockGetBlockSize,
+ FwVolBlockReadBlock,
+ (EFI_FVB_WRITE)FwVolBlockWriteBlock,
+ (EFI_FVB_ERASE_BLOCKS)FwVolBlockEraseBlock,
+ NULL
+ },
+ 0,
+ NULL,
+ 0,
+ 0
+};
+
+
+
+
+EFI_STATUS
+EFIAPI
+FwVolBlockGetAttributes (
+ IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
+ OUT EFI_FVB_ATTRIBUTES *Attributes
+ )
+/*++
+
+Routine Description:
+ Retrieves Volume attributes. No polarity translations are done.
+
+Arguments:
+ This - Calling context
+ Attributes - output buffer which contains attributes
+
+Returns:
+ EFI_SUCCESS - The firmware volume attributes were returned.
+
+--*/
+{
+ EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;
+
+ FvbDevice = FVB_DEVICE_FROM_THIS (This);
+
+ //
+ // Since we are read only, it's safe to get attributes data from our in-memory copy.
+ //
+ *Attributes = FvbDevice->FvbAttributes;
+
+ return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+EFIAPI
+FwVolBlockSetAttributes (
+ IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
+ IN EFI_FVB_ATTRIBUTES *Attributes
+ )
+/*++
+
+Routine Description:
+ Modifies the current settings of the firmware volume according to the input parameter.
+
+Arguments:
+ This - Calling context
+ Attributes - input buffer which contains attributes
+
+Returns:
+ EFI_SUCCESS - The firmware volume attributes were returned.
+ EFI_INVALID_PARAMETER - The attributes requested are in conflict with the capabilities as
+ declared in the firmware volume header.
+ EFI_UNSUPPORTED - Not supported.
+--*/
+{
+ return EFI_UNSUPPORTED;
+}
+
+
+EFI_STATUS
+EFIAPI
+FwVolBlockEraseBlock (
+ IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
+ ...
+ )
+/*++
+
+Routine Description:
+ The EraseBlock() function erases one or more blocks as denoted by the
+variable argument list. The entire parameter list of blocks must be verified
+prior to erasing any blocks. If a block is requested that does not exist
+within the associated firmware volume (it has a larger index than the last
+block of the firmware volume), the EraseBlock() function must return
+EFI_INVALID_PARAMETER without modifying the contents of the firmware volume.
+
+Arguments:
+ This - Calling context
+ ... - Starting LBA followed by Number of Lba to erase. a -1 to terminate
+ the list.
+
+Returns:
+ EFI_SUCCESS - The erase request was successfully completed.
+ EFI_ACCESS_DENIED - The firmware volume is in the WriteDisabled state.
+ EFI_DEVICE_ERROR - The block device is not functioning correctly and could not be
+ written. The firmware device may have been partially erased.
+ EFI_INVALID_PARAMETER - One or more of the LBAs listed in the variable argument list do
+ EFI_UNSUPPORTED - Not supported.
+
+--*/
+{
+ return EFI_UNSUPPORTED;
+}
+
+
+EFI_STATUS
+EFIAPI
+FwVolBlockReadBlock (
+ IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
+ IN EFI_LBA Lba,
+ IN UINTN Offset,
+ IN OUT UINTN *NumBytes,
+ IN UINT8 *Buffer
+ )
+/*++
+
+Routine Description:
+ Read the specified number of bytes from the block to the input buffer.
+
+Arguments:
+ This - Indicates the calling context.
+ Lba - The starting logical block index to read.
+ Offset - Offset into the block at which to begin reading.
+ NumBytes - Pointer to a UINT32. At entry, *NumBytes contains the
+ total size of the buffer. At exit, *NumBytes contains the
+ total number of bytes actually read.
+ Buffer - Pinter to a caller-allocated buffer that contains the destine
+ for the read.
+
+Returns:
+ EFI_SUCCESS - The firmware volume was read successfully.
+ EFI_BAD_BUFFER_SIZE - The read was attempted across an LBA boundary.
+ EFI_ACCESS_DENIED - Access denied.
+ EFI_DEVICE_ERROR - The block device is malfunctioning and could not be read.
+--*/
+{
+ EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;
+ EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;
+ UINT8 *LbaOffset;
+ UINTN LbaStart;
+ UINTN NumOfBytesRead;
+ UINTN LbaIndex;
+
+ FvbDevice = FVB_DEVICE_FROM_THIS (This);
+
+ //
+ // Check if This FW can be read
+ //
+ if ((FvbDevice->FvbAttributes & EFI_FVB_READ_STATUS) == 0) {
+ return EFI_ACCESS_DENIED;
+ }
+
+ LbaIndex = (UINTN)Lba;
+ if (LbaIndex >= FvbDevice->NumBlocks) {
+ //
+ // Invalid Lba, read nothing.
+ //
+ *NumBytes = 0;
+ return EFI_BAD_BUFFER_SIZE;
+ }
+
+ if (Offset > FvbDevice->LbaCache[LbaIndex].Length) {
+ //
+ // all exceed boundry, read nothing.
+ //
+ *NumBytes = 0;
+ return EFI_BAD_BUFFER_SIZE;
+ }
+
+ NumOfBytesRead = *NumBytes;
+ if (Offset + NumOfBytesRead > FvbDevice->LbaCache[LbaIndex].Length) {
+ //
+ // partial exceed boundry, read data from current postion to end.
+ //
+ NumOfBytesRead = FvbDevice->LbaCache[LbaIndex].Length - Offset;
+ }
+
+ LbaStart = FvbDevice->LbaCache[LbaIndex].Base;
+ FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *)((UINTN)FvbDevice->BaseAddress);
+ LbaOffset = (UINT8 *)FwVolHeader + LbaStart + Offset;
+
+ //
+ // Perform read operation
+ //
+ EfiCommonLibCopyMem (Buffer, LbaOffset, NumOfBytesRead);
+
+ if (NumOfBytesRead == *NumBytes) {
+ return EFI_SUCCESS;
+ }
+
+ *NumBytes = NumOfBytesRead;
+ return EFI_BAD_BUFFER_SIZE;
+}
+
+
+EFI_STATUS
+EFIAPI
+FwVolBlockWriteBlock (
+ IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
+ IN EFI_LBA Lba,
+ IN UINTN Offset,
+ IN OUT UINTN *NumBytes,
+ IN UINT8 *Buffer
+ )
+/*++
+
+Routine Description:
+ Writes the specified number of bytes from the input buffer to the block.
+
+Arguments:
+ This - Indicates the calling context.
+ Lba - The starting logical block index to write to.
+ Offset - Offset into the block at which to begin writing.
+ NumBytes - Pointer to a UINT32. At entry, *NumBytes contains the
+ total size of the buffer. At exit, *NumBytes contains the
+ total number of bytes actually written.
+ Buffer - Pinter to a caller-allocated buffer that contains the source
+ for the write.
+
+Returns:
+ EFI_SUCCESS - The firmware volume was written successfully.
+ EFI_BAD_BUFFER_SIZE - The write was attempted across an LBA boundary. On output,
+ NumBytes contains the total number of bytes actually written.
+ EFI_ACCESS_DENIED - The firmware volume is in the WriteDisabled state.
+ EFI_DEVICE_ERROR - The block device is malfunctioning and could not be written.
+ EFI_UNSUPPORTED - Not supported.
+--*/
+{
+ return EFI_UNSUPPORTED;
+}
+
+
+EFI_STATUS
+EFIAPI
+FwVolBlockGetPhysicalAddress (
+ IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
+ OUT EFI_PHYSICAL_ADDRESS *Address
+ )
+/*++
+
+Routine Description:
+ Get Fvb's base address.
+
+Arguments:
+ This - Indicates the calling context.
+ Address - Fvb device base address.
+
+Returns:
+ EFI_SUCCESS - Successfully got Fvb's base address.
+ EFI_UNSUPPORTED - Not supported.
+--*/
+{
+ EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;
+
+ FvbDevice = FVB_DEVICE_FROM_THIS (This);
+
+ if (FvbDevice->FvbAttributes & EFI_FVB_MEMORY_MAPPED) {
+ *Address = FvbDevice->BaseAddress;
+ return EFI_SUCCESS;
+ }
+
+ return EFI_UNSUPPORTED;
+}
+
+
+EFI_STATUS
+EFIAPI
+FwVolBlockGetBlockSize (
+ IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
+ IN EFI_LBA Lba,
+ OUT UINTN *BlockSize,
+ OUT UINTN *NumberOfBlocks
+ )
+/*++
+
+Routine Description:
+ Retrieves the size in bytes of a specific block within a firmware volume.
+
+Arguments:
+ This - Indicates the calling context.
+ Lba - Indicates the block for which to return the size.
+ BlockSize - Pointer to a caller-allocated UINTN in which the size of the
+ block is returned.
+ NumberOfBlocks - Pointer to a caller-allocated UINTN in which the number of
+ consecutive blocks starting with Lba is returned. All blocks
+ in this range have a size of BlockSize.
+Returns:
+ EFI_SUCCESS - The firmware volume base address is returned.
+ EFI_INVALID_PARAMETER - The requested LBA is out of range.
+--*/
+{
+ UINTN TotalBlocks;
+ EFI_FW_VOL_BLOCK_DEVICE *FvbDevice;
+ EFI_FV_BLOCK_MAP_ENTRY *PtrBlockMapEntry;
+ EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;
+
+ FvbDevice = FVB_DEVICE_FROM_THIS (This);
+
+ //
+ // Do parameter checking
+ //
+ if (Lba >= FvbDevice->NumBlocks) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *)((UINTN)FvbDevice->BaseAddress);
+
+ PtrBlockMapEntry = FwVolHeader->FvBlockMap;
+
+ //
+ // Search the block map for the given block
+ //
+ TotalBlocks = 0;
+ while ((PtrBlockMapEntry->NumBlocks != 0) || (PtrBlockMapEntry->BlockLength !=0 )) {
+ TotalBlocks += PtrBlockMapEntry->NumBlocks;
+ if (Lba < TotalBlocks) {
+ //
+ // We find the range
+ //
+ break;
+ }
+
+ PtrBlockMapEntry++;
+ }
+
+ *BlockSize = PtrBlockMapEntry->BlockLength;
+ *NumberOfBlocks = TotalBlocks - (UINTN)Lba;
+
+ return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+ProduceFVBProtocolOnBuffer (
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length,
+ IN EFI_HANDLE ParentHandle,
+ OUT EFI_HANDLE *FvProtocol OPTIONAL
+ )
+/*++
+
+Routine Description:
+ This routine produces a firmware volume block protocol on a given
+ buffer.
+
+Arguments:
+ BaseAddress - base address of the firmware volume image
+ Length - length of the firmware volume image
+ ParentHandle - handle of parent firmware volume, if this
+ image came from an FV image file in another
+ firmware volume (ala capsules)
+ FvProtocol - Firmware volume block protocol produced.
+
+Returns:
+ EFI_VOLUME_CORRUPTED - Volume corrupted.
+ EFI_OUT_OF_RESOURCES - No enough buffer to be allocated.
+ EFI_SUCCESS - Successfully produced a FVB protocol on given buffer.
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_FW_VOL_BLOCK_DEVICE *FvbDev;
+ EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;
+ UINTN BlockIndex;
+ UINTN BlockIndex2;
+ UINTN LinearOffset;
+ EFI_FV_BLOCK_MAP_ENTRY *PtrBlockMapEntry;
+
+ FwVolHeader = (EFI_FIRMWARE_VOLUME_HEADER *)(UINTN)BaseAddress;
+ //
+ // Validate FV Header, if not as expected, return
+ //
+ if (FwVolHeader->Signature != EFI_FVH_SIGNATURE) {
+ return EFI_VOLUME_CORRUPTED;
+ }
+ //
+ // Allocate EFI_FW_VOL_BLOCK_DEVICE
+ //
+ FvbDev = CoreAllocateCopyPool (sizeof (EFI_FW_VOL_BLOCK_DEVICE), &mFwVolBlock);
+ if (FvbDev == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ FvbDev->BaseAddress = BaseAddress;
+ FvbDev->FvbAttributes = FwVolHeader->Attributes;
+ FvbDev->FwVolBlockInstance.ParentHandle = ParentHandle;
+
+ //
+ // Init the block caching fields of the device
+ // First, count the number of blocks
+ //
+ FvbDev->NumBlocks = 0;
+ for (PtrBlockMapEntry = FwVolHeader->FvBlockMap;
+ PtrBlockMapEntry->NumBlocks != 0;
+ PtrBlockMapEntry++) {
+ FvbDev->NumBlocks += PtrBlockMapEntry->NumBlocks;
+ }
+ //
+ // Second, allocate the cache
+ //
+ FvbDev->LbaCache = CoreAllocateBootServicesPool (FvbDev->NumBlocks * sizeof (LBA_CACHE));
+ if (FvbDev->LbaCache == NULL) {
+ CoreFreePool (FvbDev);
+ return EFI_OUT_OF_RESOURCES;
+ }
+ //
+ // Last, fill in the cache with the linear address of the blocks
+ //
+ BlockIndex = 0;
+ LinearOffset = 0;
+ for (PtrBlockMapEntry = FwVolHeader->FvBlockMap;
+ PtrBlockMapEntry->NumBlocks != 0; PtrBlockMapEntry++) {
+ for (BlockIndex2 = 0; BlockIndex2 < PtrBlockMapEntry->NumBlocks; BlockIndex2++) {
+ FvbDev->LbaCache[BlockIndex].Base = LinearOffset;
+ FvbDev->LbaCache[BlockIndex].Length = PtrBlockMapEntry->BlockLength;
+ LinearOffset += PtrBlockMapEntry->BlockLength;
+ BlockIndex++;
+ }
+ }
+
+ //
+ // Set up the devicepath
+ //
+ FvbDev->DevicePath.MemMapDevPath.StartingAddress = BaseAddress;
+ FvbDev->DevicePath.MemMapDevPath.EndingAddress = BaseAddress + FwVolHeader->FvLength - 1;
+
+ //
+ //
+ // Attach FvVolBlock Protocol to new handle
+ //
+ Status = CoreInstallMultipleProtocolInterfaces (
+ &FvbDev->Handle,
+ &gEfiFirmwareVolumeBlockProtocolGuid, &FvbDev->FwVolBlockInstance,
+ &gEfiDevicePathProtocolGuid, &FvbDev->DevicePath,
+ &gEfiFirmwareVolumeDispatchProtocolGuid, NULL,
+ NULL
+ );
+
+ //
+ // If they want the handle back, set it.
+ //
+ if (FvProtocol != NULL) {
+ *FvProtocol = FvbDev->Handle;
+ }
+
+ return Status;
+}
+
+
+EFI_STATUS
+EFIAPI
+FwVolBlockDriverInit (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+/*++
+
+Routine Description:
+ This routine is the driver initialization entry point. It initializes the
+ libraries, consumes FV hobs and NT_NON_MM_FV environment variable and
+ produces instances of FW_VOL_BLOCK_PROTOCOL as appropriate.
+Arguments:
+ ImageHandle - The image handle.
+ SystemTable - The system table.
+Returns:
+ EFI_SUCCESS - Successfully initialized firmware volume block driver.
+--*/
+{
+ EFI_STATUS Status;
+ VOID *HobList;
+ EFI_PHYSICAL_ADDRESS BaseAddress;
+ UINT64 Length;
+ EFI_STATUS HobStatus;
+
+ //
+ // First walk hobs and create appropriate FVs.
+ //
+ Status = CoreGetConfigTable (&gEfiHobListGuid, &HobList);
+ //
+ // Core Needs Firmware Volumes to function
+ //
+ ASSERT_EFI_ERROR (Status);
+
+ BaseAddress = 0;
+ Length = 0;
+ HobStatus = GetNextFirmwareVolumeHob (
+ &HobList,
+ &BaseAddress,
+ &Length
+ );
+ while (!EFI_ERROR (HobStatus)) {
+ //
+ // Produce an FVB protocol for it
+ //
+ ProduceFVBProtocolOnBuffer (BaseAddress, Length, NULL, NULL);
+ HobStatus = GetNextFirmwareVolumeHob (
+ &HobList,
+ &BaseAddress,
+ &Length
+ );
+ }
+
+ return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+CoreProcessFirmwareVolume (
+ IN VOID *FvHeader,
+ IN UINTN Size,
+ OUT EFI_HANDLE *FVProtocolHandle
+ )
+/*++
+
+Routine Description:
+ This DXE service routine is used to process a firmware volume. In
+ particular, it can be called by BDS to process a single firmware
+ volume found in a capsule.
+
+Arguments:
+ FvHeader - pointer to a firmware volume header
+ Size - the size of the buffer pointed to by FvHeader
+ FVProtocolHandle - the handle on which a firmware volume protocol
+ was produced for the firmware volume passed in.
+
+Returns:
+ EFI_OUT_OF_RESOURCES - if an FVB could not be produced due to lack of
+ system resources
+ EFI_VOLUME_CORRUPTED - if the volume was corrupted
+ EFI_SUCCESS - a firmware volume protocol was produced for the
+ firmware volume
+
+--*/
+{
+ VOID *Ptr;
+ EFI_STATUS Status;
+
+ *FVProtocolHandle = NULL;
+ Status = ProduceFVBProtocolOnBuffer (
+ (EFI_PHYSICAL_ADDRESS) (UINTN) FvHeader,
+ (UINT64)Size,
+ NULL,
+ FVProtocolHandle
+ );
+ //
+ // Since in our implementation we use register-protocol-notify to put a
+ // FV protocol on the FVB protocol handle, we can't directly verify that
+ // the FV protocol was produced. Therefore here we will check the handle
+ // and make sure an FV protocol is on it. This indicates that all went
+ // well. Otherwise we have to assume that the volume was corrupted
+ // somehow.
+ //
+ if (!EFI_ERROR(Status)) {
+ Ptr = NULL;
+ Status = CoreHandleProtocol (*FVProtocolHandle, &gEfiFirmwareVolumeProtocolGuid, &Ptr);
+ if (EFI_ERROR(Status) || (Ptr == NULL)) {
+ return EFI_VOLUME_CORRUPTED;
+ }
+ return EFI_SUCCESS;
+ }
+ return Status;
+}
+
+
diff --git a/EDK/Foundation/Core/Dxe/FwVolBlock/FwVolBlock.h b/EDK/Foundation/Core/Dxe/FwVolBlock/FwVolBlock.h
new file mode 100644
index 0000000..cbf9ffc
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/FwVolBlock/FwVolBlock.h
@@ -0,0 +1,334 @@
+/*++
+
+Copyright (c) 2004 - 2005, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ FwVolBlock.h
+
+Abstract:
+
+ Firmware Volume Block protocol.. Consumes FV hobs and creates
+ appropriate block protocols.
+
+ Also consumes NT_NON_MM_FV envinronment variable and produces appropriate
+ block protocols fro them also... (this is TBD)
+
+--*/
+
+#ifndef _FWVOL_BLOCK_H_
+#define _FWVOL_BLOCK_H_
+
+#include EFI_PROTOCOL_DEFINITION (FirmwareVolumeBlock)
+#include EFI_PROTOCOL_DEFINITION (DevicePath)
+#include "Peihob.h"
+#include "EfiHobLib.h"
+#include "DxeCore.h"
+
+#include EFI_GUID_DEFINITION (Hob)
+
+
+
+#define FVB_DEVICE_SIGNATURE EFI_SIGNATURE_32('_','F','V','B')
+
+typedef struct {
+ UINTN Base;
+ UINTN Length;
+} LBA_CACHE;
+
+typedef struct {
+ MEMMAP_DEVICE_PATH MemMapDevPath;
+ EFI_DEVICE_PATH_PROTOCOL EndDevPath;
+} FV_DEVICE_PATH;
+
+
+typedef struct {
+ UINTN Signature;
+ EFI_HANDLE Handle;
+ FV_DEVICE_PATH DevicePath;
+ EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL FwVolBlockInstance;
+ UINTN NumBlocks;
+ LBA_CACHE *LbaCache;
+ UINT32 FvbAttributes;
+ EFI_PHYSICAL_ADDRESS BaseAddress;
+} EFI_FW_VOL_BLOCK_DEVICE;
+
+#define FVB_DEVICE_FROM_THIS(a) \
+ CR(a, EFI_FW_VOL_BLOCK_DEVICE, FwVolBlockInstance, FVB_DEVICE_SIGNATURE)
+
+
+
+EFI_STATUS
+EFIAPI
+FwVolBlockDriverInit (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+/*++
+
+Routine Description:
+ This routine is the driver initialization entry point. It initializes the
+ libraries, consumes FV hobs and NT_NON_MM_FV environment variable and
+ produces instances of FW_VOL_BLOCK_PROTOCOL as appropriate.
+Arguments:
+ ImageHandle - The image handle.
+ SystemTable - The system table.
+Returns:
+ EFI_SUCCESS - Successfully initialized firmware volume block driver.
+--*/
+;
+
+
+EFI_STATUS
+EFIAPI
+FwVolBlockGetAttributes (
+ IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
+ OUT EFI_FVB_ATTRIBUTES *Attributes
+ )
+/*++
+
+Routine Description:
+ Retrieves Volume attributes. No polarity translations are done.
+
+Arguments:
+ This - Calling context
+ Attributes - output buffer which contains attributes
+
+Returns:
+ EFI_SUCCESS - The firmware volume attributes were returned.
+
+--*/
+;
+
+
+EFI_STATUS
+EFIAPI
+FwVolBlockSetAttributes (
+ IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
+ OUT EFI_FVB_ATTRIBUTES *Attributes
+ )
+/*++
+
+Routine Description:
+ Modifies the current settings of the firmware volume according to the input parameter.
+
+Arguments:
+ This - Calling context
+ Attributes - input buffer which contains attributes
+
+Returns:
+ EFI_SUCCESS - The firmware volume attributes were returned.
+ EFI_INVALID_PARAMETER - The attributes requested are in conflict with the capabilities as
+ declared in the firmware volume header.
+ EFI_UNSUPPORTED - Not supported.
+--*/
+;
+
+
+EFI_STATUS
+EFIAPI
+FwVolBlockEraseBlock (
+ IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
+ ...
+ )
+/*++
+
+Routine Description:
+ The EraseBlock() function erases one or more blocks as denoted by the
+variable argument list. The entire parameter list of blocks must be verified
+prior to erasing any blocks. If a block is requested that does not exist
+within the associated firmware volume (it has a larger index than the last
+block of the firmware volume), the EraseBlock() function must return
+EFI_INVALID_PARAMETER without modifying the contents of the firmware volume.
+
+Arguments:
+ This - Calling context
+ ... - Starting LBA followed by Number of Lba to erase. a -1 to terminate
+ the list.
+
+Returns:
+ EFI_SUCCESS - The erase request was successfully completed.
+ EFI_ACCESS_DENIED - The firmware volume is in the WriteDisabled state.
+ EFI_DEVICE_ERROR - The block device is not functioning correctly and could not be
+ written. The firmware device may have been partially erased.
+ EFI_INVALID_PARAMETER - One or more of the LBAs listed in the variable argument list do
+ EFI_UNSUPPORTED - Not supported.
+
+--*/
+;
+
+
+EFI_STATUS
+EFIAPI
+FwVolBlockReadBlock (
+ IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
+ IN EFI_LBA Lba,
+ IN UINTN Offset,
+ IN OUT UINTN *NumBytes,
+ IN UINT8 *Buffer
+ )
+/*++
+
+Routine Description:
+ Read the specified number of bytes from the block to the input buffer.
+
+Arguments:
+ This - Indicates the calling context.
+ Lba - The starting logical block index to read.
+ Offset - Offset into the block at which to begin reading.
+ NumBytes - Pointer to a UINT32. At entry, *NumBytes contains the
+ total size of the buffer. At exit, *NumBytes contains the
+ total number of bytes actually read.
+ Buffer - Pinter to a caller-allocated buffer that contains the destine
+ for the read.
+
+Returns:
+ EFI_SUCCESS - The firmware volume was read successfully.
+ EFI_BAD_BUFFER_SIZE - The read was attempted across an LBA boundary.
+ EFI_ACCESS_DENIED - Access denied.
+ EFI_DEVICE_ERROR - The block device is malfunctioning and could not be read.
+--*/
+;
+
+
+EFI_STATUS
+EFIAPI
+FwVolBlockWriteBlock (
+ IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
+ IN EFI_LBA Lba,
+ IN UINTN Offset,
+ IN OUT UINTN *NumBytes,
+ IN UINT8 *Buffer
+ )
+/*++
+
+Routine Description:
+ Writes the specified number of bytes from the input buffer to the block.
+
+Arguments:
+ This - Indicates the calling context.
+ Lba - The starting logical block index to write to.
+ Offset - Offset into the block at which to begin writing.
+ NumBytes - Pointer to a UINT32. At entry, *NumBytes contains the
+ total size of the buffer. At exit, *NumBytes contains the
+ total number of bytes actually written.
+ Buffer - Pinter to a caller-allocated buffer that contains the source
+ for the write.
+
+Returns:
+ EFI_SUCCESS - The firmware volume was written successfully.
+ EFI_BAD_BUFFER_SIZE - The write was attempted across an LBA boundary. On output,
+ NumBytes contains the total number of bytes actually written.
+ EFI_ACCESS_DENIED - The firmware volume is in the WriteDisabled state.
+ EFI_DEVICE_ERROR - The block device is malfunctioning and could not be written.
+ EFI_UNSUPPORTED - Not supported.
+--*/
+;
+
+
+EFI_STATUS
+EFIAPI
+FwVolBlockGetPhysicalAddress (
+ IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
+ OUT EFI_PHYSICAL_ADDRESS *Address
+ )
+/*++
+
+Routine Description:
+ Get Fvb's base address.
+
+Arguments:
+ This - Indicates the calling context.
+ Address - Fvb device base address.
+
+Returns:
+ EFI_SUCCESS - Successfully got Fvb's base address.
+ EFI_UNSUPPORTED - Not supported.
+--*/
+;
+
+
+EFI_STATUS
+EFIAPI
+FwVolBlockGetBlockSize (
+ IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *This,
+ IN EFI_LBA Lba,
+ OUT UINTN *BlockSize,
+ OUT UINTN *NumberOfBlocks
+ )
+/*++
+
+Routine Description:
+ Retrieves the size in bytes of a specific block within a firmware volume.
+
+Arguments:
+ This - Indicates the calling context.
+ Lba - Indicates the block for which to return the size.
+ BlockSize - Pointer to a caller-allocated UINTN in which the size of the
+ block is returned.
+ NumberOfBlocks - Pointer to a caller-allocated UINTN in which the number of
+ consecutive blocks starting with Lba is returned. All blocks
+ in this range have a size of BlockSize.
+Returns:
+ EFI_SUCCESS - The firmware volume base address is returned.
+ EFI_INVALID_PARAMETER - The requested LBA is out of range.
+--*/
+;
+
+EFI_STATUS
+FwVolBlockDriverInit (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+/*++
+
+Routine Description:
+ This routine is the driver initialization entry point. It initializes the
+ libraries, consumes FV hobs and NT_NON_MM_FV environment variable and
+ produces instances of FW_VOL_BLOCK_PROTOCOL as appropriate.
+Arguments:
+ ImageHandle - The image handle.
+ SystemTable - The system table.
+Returns:
+ Status code
+
+--*/
+;
+
+EFI_STATUS
+ProduceFVBProtocolOnBuffer (
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length,
+ IN EFI_HANDLE ParentHandle,
+ OUT EFI_HANDLE *FvProtocolHandle OPTIONAL
+ )
+/*++
+
+Routine Description:
+ This routine produces a firmware volume block protocol on a given
+ buffer.
+
+Arguments:
+ BaseAddress - base address of the firmware volume image
+ Length - length of the firmware volume image
+ ParentHandle - handle of parent firmware volume, if this
+ image came from an FV image file in another
+ firmware volume (ala capsules)
+ FvProtocolHandle - Firmware volume block protocol produced.
+
+Returns:
+ EFI_VOLUME_CORRUPTED - Volume corrupted.
+ EFI_OUT_OF_RESOURCES - No enough buffer to be allocated.
+ EFI_SUCCESS - Successfully produced a FVB protocol on given buffer.
+
+--*/
+;
+
+#endif
diff --git a/EDK/Foundation/Core/Dxe/Gcd/gcd.c b/EDK/Foundation/Core/Dxe/Gcd/gcd.c
new file mode 100644
index 0000000..586826b
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/Gcd/gcd.c
@@ -0,0 +1,2509 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ gcd.c
+
+Abstract:
+
+ The file contains the GCD related services in the EFI Boot Services Table.
+ The GCD services are used to manage the memory and I/O regions that
+ are accessible to the CPU that is executing the DXE core.
+
+--*/
+
+#include "gcd.h"
+
+#define MINIMUM_INITIAL_MEMORY_SIZE 0x10000
+
+#define MEMORY_ATTRIBUTE_MASK (EFI_RESOURCE_ATTRIBUTE_PRESENT | \
+ EFI_RESOURCE_ATTRIBUTE_INITIALIZED | \
+ EFI_RESOURCE_ATTRIBUTE_TESTED | \
+ EFI_RESOURCE_ATTRIBUTE_READ_PROTECTED | \
+ EFI_RESOURCE_ATTRIBUTE_WRITE_PROTECTED | \
+ EFI_RESOURCE_ATTRIBUTE_EXECUTION_PROTECTED | \
+ EFI_RESOURCE_ATTRIBUTE_16_BIT_IO | \
+ EFI_RESOURCE_ATTRIBUTE_32_BIT_IO | \
+ EFI_RESOURCE_ATTRIBUTE_64_BIT_IO )
+
+#define TESTED_MEMORY_ATTRIBUTES (EFI_RESOURCE_ATTRIBUTE_PRESENT | \
+ EFI_RESOURCE_ATTRIBUTE_INITIALIZED | \
+ EFI_RESOURCE_ATTRIBUTE_TESTED )
+
+#define INITIALIZED_MEMORY_ATTRIBUTES (EFI_RESOURCE_ATTRIBUTE_PRESENT | \
+ EFI_RESOURCE_ATTRIBUTE_INITIALIZED )
+
+#define PRESENT_MEMORY_ATTRIBUTES (EFI_RESOURCE_ATTRIBUTE_PRESENT)
+
+#define INVALID_CPU_ARCH_ATTRIBUTES 0xffffffff
+
+//
+// Module Variables
+//
+EFI_LOCK mGcdMemorySpaceLock = EFI_INITIALIZE_LOCK_VARIABLE (EFI_TPL_NOTIFY);
+EFI_LOCK mGcdIoSpaceLock = EFI_INITIALIZE_LOCK_VARIABLE (EFI_TPL_NOTIFY);
+EFI_LIST_ENTRY mGcdMemorySpaceMap = INITIALIZE_LIST_HEAD_VARIABLE (mGcdMemorySpaceMap);
+EFI_LIST_ENTRY mGcdIoSpaceMap = INITIALIZE_LIST_HEAD_VARIABLE (mGcdIoSpaceMap);
+
+EFI_GCD_MAP_ENTRY mGcdMemorySpaceMapEntryTemplate = {
+ EFI_GCD_MAP_SIGNATURE,
+ { NULL, NULL },
+ 0,
+ 0,
+ 0,
+ 0,
+ EfiGcdMemoryTypeNonExistent,
+ 0,
+ NULL,
+ NULL
+};
+
+EFI_GCD_MAP_ENTRY mGcdIoSpaceMapEntryTemplate = {
+ EFI_GCD_MAP_SIGNATURE,
+ { NULL, NULL },
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ EfiGcdIoTypeNonExistent,
+ NULL,
+ NULL
+};
+
+GCD_ATTRIBUTE_CONVERSION_ENTRY mAttributeConversionTable[] = {
+ { EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE, EFI_MEMORY_UC, TRUE },
+ { EFI_RESOURCE_ATTRIBUTE_UNCACHED_EXPORTED, EFI_MEMORY_UCE, TRUE },
+ { EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE, EFI_MEMORY_WC, TRUE },
+ { EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE, EFI_MEMORY_WT, TRUE },
+ { EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE, EFI_MEMORY_WB, TRUE },
+ { EFI_RESOURCE_ATTRIBUTE_READ_PROTECTED, EFI_MEMORY_RP, TRUE },
+ { EFI_RESOURCE_ATTRIBUTE_WRITE_PROTECTED, EFI_MEMORY_WP, TRUE },
+ { EFI_RESOURCE_ATTRIBUTE_EXECUTION_PROTECTED, EFI_MEMORY_XP, TRUE },
+ { EFI_RESOURCE_ATTRIBUTE_PRESENT, EFI_MEMORY_PRESENT, FALSE },
+ { EFI_RESOURCE_ATTRIBUTE_INITIALIZED, EFI_MEMORY_INITIALIZED, FALSE },
+ { EFI_RESOURCE_ATTRIBUTE_TESTED, EFI_MEMORY_TESTED, FALSE },
+ { 0, 0, FALSE }
+};
+
+VOID
+CoreAcquireGcdMemoryLock (
+ VOID
+ )
+/*++
+
+Routine Description:
+ Acquire memory lock on mGcdMemorySpaceLock
+
+Arguments:
+ None
+
+Returns:
+ None
+
+--*/
+{
+ CoreAcquireLock (&mGcdMemorySpaceLock);
+}
+
+
+VOID
+CoreReleaseGcdMemoryLock (
+ VOID
+ )
+/*++
+
+Routine Description:
+ Release memory lock on mGcdMemorySpaceLock
+
+Arguments:
+ None
+
+Returns:
+ None
+
+--*/
+{
+ CoreReleaseLock (&mGcdMemorySpaceLock);
+}
+
+
+
+VOID
+CoreAcquireGcdIoLock (
+ VOID
+ )
+/*++
+
+Routine Description:
+ Acquire memory lock on mGcdIoSpaceLock
+
+Arguments:
+ None
+
+Returns:
+ None
+
+--*/
+{
+ CoreAcquireLock (&mGcdIoSpaceLock);
+}
+
+
+VOID
+CoreReleaseGcdIoLock (
+ VOID
+ )
+/*++
+
+Routine Description:
+ Release memory lock on mGcdIoSpaceLock
+
+Arguments:
+ None
+
+Returns:
+ None
+
+--*/
+{
+ CoreReleaseLock (&mGcdIoSpaceLock);
+}
+
+
+
+//
+// GCD Initialization Worker Functions
+//
+UINT64
+AlignValue (
+ IN UINT64 Value,
+ IN UINTN Alignment,
+ IN BOOLEAN RoundUp
+ )
+/*++
+
+Routine Description:
+
+ Aligns a value to the specified boundary.
+
+Arguments:
+
+ Value - 64 bit value to align
+ Alignment - Log base 2 of the boundary to align Value to
+ RoundUp - TRUE if Value is to be rounded up to the nearest aligned boundary.
+ FALSE is Value is to be rounded down to the nearest aligned boundary.
+
+Returns:
+
+ A 64 bit value is the aligned to the value nearest Value with an alignment by Alignment.
+
+--*/
+{
+ UINT64 AlignmentMask;
+
+ AlignmentMask = LShiftU64 (1, Alignment) - 1;
+ if (RoundUp) {
+ Value += AlignmentMask;
+ }
+ return Value & (~AlignmentMask);
+}
+
+UINT64
+PageAlignAddress (
+ IN UINT64 Value
+ )
+/*++
+
+Routine Description:
+
+ Aligns address to the page boundary.
+
+Arguments:
+
+ Value - 64 bit address to align
+
+Returns:
+
+ A 64 bit value is the aligned to the value nearest Value with an alignment by Alignment.
+
+--*/
+{
+ return AlignValue (Value, EFI_PAGE_SHIFT, TRUE);
+}
+
+UINT64
+PageAlignLength (
+ IN UINT64 Value
+ )
+/*++
+
+Routine Description:
+
+ Aligns length to the page boundary.
+
+Arguments:
+
+ Value - 64 bit length to align
+
+Returns:
+
+ A 64 bit value is the aligned to the value nearest Value with an alignment by Alignment.
+
+--*/
+{
+ return AlignValue (Value, EFI_PAGE_SHIFT, FALSE);
+}
+
+//
+// GCD Memory Space Worker Functions
+//
+EFI_STATUS
+CoreAllocateGcdMapEntry (
+ IN OUT EFI_GCD_MAP_ENTRY **TopEntry,
+ IN OUT EFI_GCD_MAP_ENTRY **BottomEntry
+ )
+/*++
+
+Routine Description:
+
+ Allocate pool for two entries.
+
+Arguments:
+
+ TopEntry - An entry of GCD map
+ BottomEntry - An entry of GCD map
+
+Returns:
+
+ EFI_OUT_OF_RESOURCES - No enough buffer to be allocated.
+ EFI_SUCCESS - Both entries successfully allocated.
+
+--*/
+{
+ *TopEntry = CoreAllocateZeroBootServicesPool (sizeof (EFI_GCD_MAP_ENTRY));
+ if (*TopEntry == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ *BottomEntry = CoreAllocateZeroBootServicesPool (sizeof (EFI_GCD_MAP_ENTRY));
+ if (*BottomEntry == NULL) {
+ CoreFreePool (*TopEntry);
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+CoreInsertGcdMapEntry (
+ IN EFI_LIST_ENTRY *Link,
+ IN EFI_GCD_MAP_ENTRY *Entry,
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length,
+ IN EFI_GCD_MAP_ENTRY *TopEntry,
+ IN EFI_GCD_MAP_ENTRY *BottomEntry
+ )
+/*++
+
+Routine Description:
+
+ Internal function. Inserts a new descriptor into a sorted list
+
+Arguments:
+
+ Link - The linked list to insert the range BaseAddress and Length into
+
+ Entry - A pointer to the entry that is inserted
+
+ BaseAddress - The base address of the new range
+
+ Length - The length of the new range in bytes
+
+ TopEntry - Top pad entry to insert if needed.
+
+ BottomEntry - Bottom pad entry to insert if needed.
+
+Returns:
+
+ EFI_SUCCESS - The new range was inserted into the linked list
+
+--*/
+{
+ ASSERT (Length != 0);
+ ASSERT (TopEntry->Signature == 0);
+ ASSERT (BottomEntry->Signature == 0);
+
+ if (BaseAddress > Entry->BaseAddress) {
+ EfiCommonLibCopyMem (BottomEntry, Entry, sizeof (EFI_GCD_MAP_ENTRY));
+ Entry->BaseAddress = BaseAddress;
+ BottomEntry->EndAddress = BaseAddress - 1;
+ InsertTailList (Link, &BottomEntry->Link);
+ }
+
+ if ((BaseAddress + Length - 1) < Entry->EndAddress) {
+ EfiCommonLibCopyMem (TopEntry, Entry, sizeof (EFI_GCD_MAP_ENTRY));
+ TopEntry->BaseAddress = BaseAddress + Length;
+ Entry->EndAddress = BaseAddress + Length - 1;
+ InsertHeadList (Link, &TopEntry->Link);
+ }
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+CoreMergeGcdMapEntry (
+ IN EFI_LIST_ENTRY *Link,
+ IN BOOLEAN Forward,
+ IN EFI_LIST_ENTRY *Map
+ )
+/*++
+
+Routine Description:
+
+ Merge the Gcd region specified by Link and its adjacent entry
+
+Arguments:
+
+ Link - Specify the entry to be merged (with its adjacent entry).
+
+ Forward - Direction (forward or backward).
+
+ Map - Boundary.
+
+Returns:
+
+ EFI_SUCCESS - Successfully returned.
+
+ EFI_UNSUPPORTED - These adjacent regions could not merge.
+
+--*/
+{
+ EFI_LIST_ENTRY *AdjacentLink;
+ EFI_GCD_MAP_ENTRY *Entry;
+ EFI_GCD_MAP_ENTRY *AdjacentEntry;
+
+ //
+ // Get adjacent entry
+ //
+ if (Forward) {
+ AdjacentLink = Link->ForwardLink;
+ } else {
+ AdjacentLink = Link->BackLink;
+ }
+
+ //
+ // If AdjacentLink is the head of the list, then no merge can be performed
+ //
+ if (AdjacentLink == Map) {
+ return EFI_SUCCESS;
+ }
+
+ Entry = CR (Link, EFI_GCD_MAP_ENTRY, Link, EFI_GCD_MAP_SIGNATURE);
+ AdjacentEntry = CR (AdjacentLink, EFI_GCD_MAP_ENTRY, Link, EFI_GCD_MAP_SIGNATURE);
+
+ if (Entry->Capabilities != AdjacentEntry->Capabilities) {
+ return EFI_UNSUPPORTED;
+ }
+ if (Entry->Attributes != AdjacentEntry->Attributes) {
+ return EFI_UNSUPPORTED;
+ }
+ if (Entry->GcdMemoryType != AdjacentEntry->GcdMemoryType) {
+ return EFI_UNSUPPORTED;
+ }
+ if (Entry->GcdIoType != AdjacentEntry->GcdIoType) {
+ return EFI_UNSUPPORTED;
+ }
+ if (Entry->ImageHandle != AdjacentEntry->ImageHandle) {
+ return EFI_UNSUPPORTED;
+ }
+ if (Entry->DeviceHandle != AdjacentEntry->DeviceHandle) {
+ return EFI_UNSUPPORTED;
+ }
+
+ if (Forward) {
+ Entry->EndAddress = AdjacentEntry->EndAddress;
+ } else {
+ Entry->BaseAddress = AdjacentEntry->BaseAddress;
+ }
+ RemoveEntryList (AdjacentLink);
+ CoreFreePool (AdjacentEntry);
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+CoreCleanupGcdMapEntry (
+ IN EFI_GCD_MAP_ENTRY *TopEntry,
+ IN EFI_GCD_MAP_ENTRY *BottomEntry,
+ IN EFI_LIST_ENTRY *StartLink,
+ IN EFI_LIST_ENTRY *EndLink,
+ IN EFI_LIST_ENTRY *Map
+ )
+/*++
+
+Routine Description:
+
+ Merge adjacent entries on total chain.
+
+Arguments:
+
+ TopEntry - Top entry of GCD map.
+
+ BottomEntry - Bottom entry of GCD map.
+
+ StartLink - Start link of the list for this loop.
+
+ EndLink - End link of the list for this loop.
+
+ Map - Boundary.
+
+Returns:
+
+ EFI_SUCCESS - GCD map successfully cleaned up.
+
+--*/
+{
+ EFI_LIST_ENTRY *Link;
+
+ if (TopEntry->Signature == 0) {
+ CoreFreePool (TopEntry);
+ }
+ if (BottomEntry->Signature == 0) {
+ CoreFreePool (BottomEntry);
+ }
+
+ Link = StartLink;
+ while (Link != EndLink->ForwardLink) {
+ CoreMergeGcdMapEntry (Link, FALSE, Map);
+ Link = Link->ForwardLink;
+ }
+ CoreMergeGcdMapEntry (EndLink, TRUE, Map);
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+CoreSearchGcdMapEntry (
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length,
+ OUT EFI_LIST_ENTRY **StartLink,
+ OUT EFI_LIST_ENTRY **EndLink,
+ IN EFI_LIST_ENTRY *Map
+ )
+/*++
+
+Routine Description:
+
+ Search a segment of memory space in GCD map. The result is a range of GCD entry list.
+
+Arguments:
+
+ BaseAddress - The start address of the segment.
+
+ Length - The length of the segment.
+
+ StartLink - The first GCD entry involves this segment of memory space.
+
+ EndLink - The first GCD entry involves this segment of memory space.
+
+ Map - Points to the start entry to search.
+
+Returns:
+
+ EFI_SUCCESS - Successfully found the entry.
+
+ EFI_NOT_FOUND - Not found.
+
+--*/
+{
+ EFI_LIST_ENTRY *Link;
+ EFI_GCD_MAP_ENTRY *Entry;
+
+ ASSERT (Length != 0);
+
+ *StartLink = NULL;
+ *EndLink = NULL;
+
+ Link = Map->ForwardLink;
+ while (Link != Map) {
+ Entry = CR (Link, EFI_GCD_MAP_ENTRY, Link, EFI_GCD_MAP_SIGNATURE);
+ if (BaseAddress >= Entry->BaseAddress && BaseAddress <= Entry->EndAddress) {
+ *StartLink = Link;
+ }
+ if (*StartLink != NULL) {
+ if ((BaseAddress + Length - 1) >= Entry->BaseAddress &&
+ (BaseAddress + Length - 1) <= Entry->EndAddress ) {
+ *EndLink = Link;
+ return EFI_SUCCESS;
+ }
+ }
+ Link = Link->ForwardLink;
+ }
+ return EFI_NOT_FOUND;
+}
+
+UINTN
+CoreCountGcdMapEntry (
+ IN EFI_LIST_ENTRY *Map
+ )
+/*++
+
+Routine Description:
+
+ Count the amount of GCD map entries.
+
+Arguments:
+
+ Map - Points to the start entry to do the count loop.
+
+Returns:
+
+ The count.
+
+--*/
+{
+ UINTN Count;
+ EFI_LIST_ENTRY *Link;
+
+ Count = 0;
+ Link = Map->ForwardLink;
+ while (Link != Map) {
+ Count++;
+ Link = Link->ForwardLink;
+ }
+ return Count;
+}
+
+
+
+UINT64
+ConverToCpuArchAttributes (
+ UINT64 Attributes
+ )
+/*++
+
+Routine Description:
+
+ Return the memory attribute specified by Attributes
+
+Arguments:
+
+ Attributes - A num with some attribute bits on.
+
+Returns:
+
+ The enum value of memory attribute.
+
+--*/
+{
+ if ( (Attributes & EFI_MEMORY_UC) == EFI_MEMORY_UC) {
+ return EFI_MEMORY_UC;
+ }
+
+ if ( (Attributes & EFI_MEMORY_WC ) == EFI_MEMORY_WC) {
+ return EFI_MEMORY_WC;
+ }
+
+ if ( (Attributes & EFI_MEMORY_WT ) == EFI_MEMORY_WT) {
+ return EFI_MEMORY_WT;
+ }
+
+ if ( (Attributes & EFI_MEMORY_WB) == EFI_MEMORY_WB) {
+ return EFI_MEMORY_WB;
+ }
+
+ if ( (Attributes & EFI_MEMORY_WP) == EFI_MEMORY_WP) {
+ return EFI_MEMORY_WP;
+ }
+
+ return INVALID_CPU_ARCH_ATTRIBUTES;
+
+}
+
+
+EFI_STATUS
+CoreConvertSpace (
+ IN UINTN Operation,
+ IN EFI_GCD_MEMORY_TYPE GcdMemoryType,
+ IN EFI_GCD_IO_TYPE GcdIoType,
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length,
+ IN UINT64 Capabilities,
+ IN UINT64 Attributes
+ )
+/*++
+
+Routine Description:
+
+ Do operation on a segment of memory space specified (add, free, remove, change attribute ...).
+
+Arguments:
+
+ Operation - The type of the operation
+
+ GcdMemoryType - Additional information for the operation
+
+ GcdIoType - Additional information for the operation
+
+ BaseAddress - Start address of the segment
+
+ Length - length of the segment
+
+ Capabilities - The alterable attributes of a newly added entry
+
+ Attributes - The attributes needs to be set
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Length is 0 or address (length) not aligned when setting attribute.
+
+ EFI_SUCCESS - Action successfully done.
+
+ EFI_UNSUPPORTED - Could not find the proper descriptor on this segment or
+ set an upsupported attribute.
+
+ EFI_ACCESS_DENIED - Operate on an space non-exist or is used for an image.
+
+ EFI_NOT_FOUND - Free a non-using space or remove a non-exist space, and so on.
+
+ EFI_OUT_OF_RESOURCES - No buffer could be allocated.
+
+Returns:
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_LIST_ENTRY *Map;
+ EFI_LIST_ENTRY *Link;
+ EFI_GCD_MAP_ENTRY *Entry;
+ EFI_GCD_MAP_ENTRY *TopEntry;
+ EFI_GCD_MAP_ENTRY *BottomEntry;
+ EFI_LIST_ENTRY *StartLink;
+ EFI_LIST_ENTRY *EndLink;
+
+ EFI_CPU_ARCH_PROTOCOL *CpuArch;
+ UINT64 CpuArchAttributes;
+
+ if (Length == 0) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Map = NULL;
+ if (Operation & GCD_MEMORY_SPACE_OPERATION) {
+ CoreAcquireGcdMemoryLock ();
+ Map = &mGcdMemorySpaceMap;
+ }
+ if (Operation & GCD_IO_SPACE_OPERATION) {
+ CoreAcquireGcdIoLock ();
+ Map = &mGcdIoSpaceMap;
+ }
+
+ if (Map == NULL) {
+ //
+ // Fail if 'Map' doesn't point to a valid address
+ //
+ Status = EFI_UNSUPPORTED;
+
+ goto Done;
+ }
+
+ //
+ // Search for the list of descriptors that cover the range BaseAddress to BaseAddress+Length
+ //
+ Status = CoreSearchGcdMapEntry (BaseAddress, Length, &StartLink, &EndLink, Map);
+ if (EFI_ERROR (Status) || (StartLink == NULL) || (EndLink == NULL)) {
+ Status = EFI_UNSUPPORTED;
+
+ goto Done;
+ }
+
+ //
+ // Verify that the list of descriptors are unallocated non-existent memory.
+ //
+ Link = StartLink;
+ while (Link != EndLink->ForwardLink) {
+ Entry = CR (Link, EFI_GCD_MAP_ENTRY, Link, EFI_GCD_MAP_SIGNATURE);
+ switch (Operation) {
+ //
+ // Add operations
+ //
+ case GCD_ADD_MEMORY_OPERATION:
+ if (Entry->GcdMemoryType != EfiGcdMemoryTypeNonExistent ||
+ Entry->ImageHandle != NULL ) {
+ Status = EFI_ACCESS_DENIED;
+ goto Done;
+ }
+ break;
+ case GCD_ADD_IO_OPERATION:
+ if (Entry->GcdIoType != EfiGcdIoTypeNonExistent ||
+ Entry->ImageHandle != NULL ) {
+ Status = EFI_ACCESS_DENIED;
+ goto Done;
+ }
+ break;
+ //
+ // Free operations
+ //
+ case GCD_FREE_MEMORY_OPERATION:
+ case GCD_FREE_IO_OPERATION:
+ if (Entry->ImageHandle == NULL) {
+ Status = EFI_NOT_FOUND;
+ goto Done;
+ }
+ break;
+ //
+ // Remove operations
+ //
+ case GCD_REMOVE_MEMORY_OPERATION:
+ if (Entry->GcdMemoryType == EfiGcdMemoryTypeNonExistent) {
+ Status = EFI_NOT_FOUND;
+ goto Done;
+ }
+ if (Entry->ImageHandle != NULL) {
+ Status = EFI_ACCESS_DENIED;
+ goto Done;
+ }
+ break;
+ case GCD_REMOVE_IO_OPERATION:
+ if (Entry->GcdIoType == EfiGcdIoTypeNonExistent) {
+ Status = EFI_NOT_FOUND;
+ goto Done;
+ }
+ if (Entry->ImageHandle != NULL) {
+ Status = EFI_ACCESS_DENIED;
+ goto Done;
+ }
+ break;
+ //
+ // Set attribute operations
+ //
+ case GCD_SET_ATTRIBUTES_MEMORY_OPERATION:
+ if (Attributes & EFI_MEMORY_RUNTIME) {
+ if ((BaseAddress & EFI_PAGE_MASK) != 0 || (Length & EFI_PAGE_MASK) != 0) {
+ Status = EFI_INVALID_PARAMETER;
+
+ goto Done;
+ }
+ }
+ if ((Entry->Capabilities & Attributes) != Attributes) {
+ Status = EFI_UNSUPPORTED;
+ goto Done;
+ }
+ break;
+ }
+ Link = Link->ForwardLink;
+ }
+
+ //
+ // Allocate work space to perform this operation
+ //
+ Status = CoreAllocateGcdMapEntry (&TopEntry, &BottomEntry);
+ if (EFI_ERROR (Status) || (TopEntry == NULL) || (BottomEntry == NULL)) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Done;
+ }
+
+ //
+ //
+ //
+ if (Operation == GCD_SET_ATTRIBUTES_MEMORY_OPERATION) {
+ //
+ // Call CPU Arch Protocol to attempt to set attributes on the range
+ //
+ CpuArchAttributes = ConverToCpuArchAttributes (Attributes);
+ if ( CpuArchAttributes != INVALID_CPU_ARCH_ATTRIBUTES ) {
+ Status = gBS->LocateProtocol (&gEfiCpuArchProtocolGuid, NULL, &CpuArch);
+ if (EFI_ERROR (Status)) {
+ Status = EFI_ACCESS_DENIED;
+ goto Done;
+ }
+
+ Status = CpuArch->SetMemoryAttributes (
+ CpuArch,
+ BaseAddress,
+ Length,
+ CpuArchAttributes
+ );
+ if (EFI_ERROR (Status)) {
+ goto Done;
+ }
+ }
+
+ }
+
+ //
+ // Convert/Insert the list of descriptors from StartLink to EndLink
+ //
+ Link = StartLink;
+ while (Link != EndLink->ForwardLink) {
+ Entry = CR (Link, EFI_GCD_MAP_ENTRY, Link, EFI_GCD_MAP_SIGNATURE);
+ CoreInsertGcdMapEntry (Link, Entry, BaseAddress, Length, TopEntry, BottomEntry);
+ switch (Operation) {
+ //
+ // Add operations
+ //
+ case GCD_ADD_MEMORY_OPERATION:
+ Entry->GcdMemoryType = GcdMemoryType;
+ if (GcdMemoryType == EfiGcdMemoryTypeMemoryMappedIo) {
+ Entry->Capabilities = Capabilities | EFI_MEMORY_RUNTIME | EFI_MEMORY_PORT_IO;
+ } else {
+ Entry->Capabilities = Capabilities | EFI_MEMORY_RUNTIME;
+ }
+ break;
+ case GCD_ADD_IO_OPERATION:
+ Entry->GcdIoType = GcdIoType;
+ break;
+ //
+ // Free operations
+ //
+ case GCD_FREE_MEMORY_OPERATION:
+ case GCD_FREE_IO_OPERATION:
+ Entry->ImageHandle = NULL;
+ Entry->DeviceHandle = NULL;
+ break;
+ //
+ // Remove operations
+ //
+ case GCD_REMOVE_MEMORY_OPERATION:
+ Entry->GcdMemoryType = EfiGcdMemoryTypeNonExistent;
+ Entry->Capabilities = 0;
+ break;
+ case GCD_REMOVE_IO_OPERATION:
+ Entry->GcdIoType = EfiGcdIoTypeNonExistent;
+ break;
+ //
+ // Set attribute operations
+ //
+ case GCD_SET_ATTRIBUTES_MEMORY_OPERATION:
+ Entry->Attributes = Attributes;
+ break;
+ }
+ Link = Link->ForwardLink;
+ }
+
+ //
+ // Cleanup
+ //
+ Status = CoreCleanupGcdMapEntry (TopEntry, BottomEntry, StartLink, EndLink, Map);
+
+Done:
+ if (Operation & GCD_MEMORY_SPACE_OPERATION) {
+ CoreReleaseGcdMemoryLock ();
+ }
+ if (Operation & GCD_IO_SPACE_OPERATION) {
+ CoreReleaseGcdIoLock ();
+ }
+
+ return Status;
+}
+
+EFI_STATUS
+CoreAllocateSpaceCheckEntry (
+ IN UINTN Operation,
+ IN EFI_GCD_MAP_ENTRY *Entry,
+ IN EFI_GCD_MEMORY_TYPE GcdMemoryType,
+ IN EFI_GCD_IO_TYPE GcdIoType
+ )
+/*++
+
+Routine Description:
+
+ Check whether an entry could be used to allocate space.
+
+Arguments:
+
+ Operation - Allocate memory or IO
+
+ Entry - The entry to be tested
+
+ GcdMemoryType - The desired memory type
+
+ GcdIoType - The desired IO type
+
+Returns:
+
+ EFI_NOT_FOUND - The memory type does not match or there's an image handle on the entry.
+
+ EFI_UNSUPPORTED - The operation unsupported.
+
+ EFI_SUCCESS - It's ok for this entry to be used to allocate space.
+
+--*/
+{
+ if (Entry->ImageHandle != NULL) {
+ return EFI_NOT_FOUND;
+ }
+ switch (Operation) {
+ case GCD_ALLOCATE_MEMORY_OPERATION:
+ if (Entry->GcdMemoryType != GcdMemoryType) {
+ return EFI_NOT_FOUND;
+ }
+ break;
+ case GCD_ALLOCATE_IO_OPERATION:
+ if (Entry->GcdIoType != GcdIoType) {
+ return EFI_NOT_FOUND;
+ }
+ break;
+ default:
+ return EFI_UNSUPPORTED;
+ }
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+CoreAllocateSpace (
+ IN UINTN Operation,
+ IN EFI_GCD_ALLOCATE_TYPE GcdAllocateType,
+ IN EFI_GCD_MEMORY_TYPE GcdMemoryType,
+ IN EFI_GCD_IO_TYPE GcdIoType,
+ IN UINTN Alignment,
+ IN UINT64 Length,
+ IN OUT EFI_PHYSICAL_ADDRESS *BaseAddress,
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_HANDLE DeviceHandle OPTIONAL
+ )
+/*++
+
+Routine Description:
+
+ Allocate space on specified address and length.
+
+Arguments:
+
+ Operation - The type of operation (memory or IO)
+ GcdAllocateType - The type of allocate operation
+ GcdMemoryType - The desired memory type
+ GcdIoType - The desired IO type
+ Alignment - Align with 2^Alignment
+ Length - Length to allocate
+ BaseAddress - Base address to allocate
+ ImageHandle - The image handle consume the allocated space.
+ DeviceHandle - The device handle consume the allocated space.
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Invalid parameter.
+ EFI_NOT_FOUND - No descriptor for the desired space exists.
+ EFI_SUCCESS - Space successfully allocated.
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_PHYSICAL_ADDRESS AlignmentMask;
+ EFI_PHYSICAL_ADDRESS MaxAddress;
+ EFI_LIST_ENTRY *Map;
+ EFI_LIST_ENTRY *Link;
+ EFI_LIST_ENTRY *SubLink;
+ EFI_GCD_MAP_ENTRY *Entry;
+ EFI_GCD_MAP_ENTRY *TopEntry;
+ EFI_GCD_MAP_ENTRY *BottomEntry;
+ EFI_LIST_ENTRY *StartLink;
+ EFI_LIST_ENTRY *EndLink;
+ BOOLEAN Found;
+
+ //
+ // Make sure parameters are valid
+ //
+ if (GcdAllocateType < 0 || GcdAllocateType >= EfiGcdMaxAllocateType) {
+ return EFI_INVALID_PARAMETER;
+ }
+ if (GcdMemoryType < 0 || GcdMemoryType >= EfiGcdMemoryTypeMaximum) {
+ return EFI_INVALID_PARAMETER;
+ }
+ if (GcdIoType < 0 || GcdIoType >= EfiGcdIoTypeMaximum) {
+ return EFI_INVALID_PARAMETER;
+ }
+ if (BaseAddress == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+ if (ImageHandle == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+ if (Alignment >= 64) {
+ return EFI_NOT_FOUND;
+ }
+ if (Length == 0) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Map = NULL;
+ if ((Operation & GCD_MEMORY_SPACE_OPERATION) != 0) {
+ CoreAcquireGcdMemoryLock ();
+ Map = &mGcdMemorySpaceMap;
+ }
+ if ((Operation & GCD_IO_SPACE_OPERATION) != 0) {
+ CoreAcquireGcdIoLock ();
+ Map = &mGcdIoSpaceMap;
+ }
+
+ if (Map == NULL) {
+ //
+ // Fail if 'Map' doesn't point to a valid address
+ //
+ Status = EFI_UNSUPPORTED;
+ goto Done;
+ }
+
+ Found = FALSE;
+ StartLink = NULL;
+ EndLink = NULL;
+ //
+ // Compute alignment bit mask
+ //
+ AlignmentMask = LShiftU64 (1, Alignment) - 1;
+
+ if (GcdAllocateType == EfiGcdAllocateAddress) {
+ //
+ // Verify that the BaseAddress passed in is aligned correctly
+ //
+ if ((*BaseAddress & AlignmentMask) != 0) {
+ Status = EFI_NOT_FOUND;
+ goto Done;
+ }
+
+ //
+ // Search for the list of descriptors that cover the range BaseAddress to BaseAddress+Length
+ //
+ Status = CoreSearchGcdMapEntry (*BaseAddress, Length, &StartLink, &EndLink, Map);
+ if (EFI_ERROR (Status) || (StartLink == NULL) || (EndLink == NULL)) {
+ Status = EFI_NOT_FOUND;
+ goto Done;
+ }
+
+ //
+ // Verify that the list of descriptors are unallocated memory matching GcdMemoryType.
+ //
+ Link = StartLink;
+ while (Link != EndLink->ForwardLink) {
+ Entry = CR (Link, EFI_GCD_MAP_ENTRY, Link, EFI_GCD_MAP_SIGNATURE);
+ Link = Link->ForwardLink;
+ Status = CoreAllocateSpaceCheckEntry (Operation, Entry, GcdMemoryType, GcdIoType);
+ if (EFI_ERROR (Status)) {
+ goto Done;
+ }
+ }
+ Found = TRUE;
+ } else {
+
+ Entry = CR (Map->BackLink, EFI_GCD_MAP_ENTRY, Link, EFI_GCD_MAP_SIGNATURE);
+
+ //
+ // Compute the maximum address to use in the search algorithm
+ //
+ if (GcdAllocateType == EfiGcdAllocateMaxAddressSearchBottomUp ||
+ GcdAllocateType == EfiGcdAllocateMaxAddressSearchTopDown) {
+ MaxAddress = *BaseAddress;
+ } else {
+ MaxAddress = Entry->EndAddress;
+ }
+
+ //
+ // Verify that the list of descriptors are unallocated memory matching GcdMemoryType.
+ //
+ if (GcdAllocateType == EfiGcdAllocateMaxAddressSearchTopDown ||
+ GcdAllocateType == EfiGcdAllocateAnySearchTopDown) {
+ Link = Map->BackLink;
+ } else {
+ Link = Map->ForwardLink;
+ }
+ while (Link != Map) {
+ Entry = CR (Link, EFI_GCD_MAP_ENTRY, Link, EFI_GCD_MAP_SIGNATURE);
+
+ if (GcdAllocateType == EfiGcdAllocateMaxAddressSearchTopDown ||
+ GcdAllocateType == EfiGcdAllocateAnySearchTopDown) {
+ Link = Link->BackLink;
+ } else {
+ Link = Link->ForwardLink;
+ }
+
+ Status = CoreAllocateSpaceCheckEntry (Operation, Entry, GcdMemoryType, GcdIoType);
+ if (EFI_ERROR (Status)) {
+ continue;
+ }
+
+ if (GcdAllocateType == EfiGcdAllocateMaxAddressSearchTopDown ||
+ GcdAllocateType == EfiGcdAllocateAnySearchTopDown) {
+ if (Entry->BaseAddress > MaxAddress) {
+ continue;
+ }
+ if (Length > (Entry->EndAddress + 1)) {
+ Status = EFI_NOT_FOUND;
+ goto Done;
+ }
+ if (Entry->EndAddress > MaxAddress) {
+ *BaseAddress = MaxAddress;
+ } else {
+ *BaseAddress = Entry->EndAddress;
+ }
+ *BaseAddress = (*BaseAddress + 1 - Length) & (~AlignmentMask);
+ } else {
+ *BaseAddress = (Entry->BaseAddress + AlignmentMask) & (~AlignmentMask);
+ if ((*BaseAddress + Length - 1) > MaxAddress) {
+ Status = EFI_NOT_FOUND;
+ goto Done;
+ }
+ }
+
+ //
+ // Search for the list of descriptors that cover the range BaseAddress to BaseAddress+Length
+ //
+ Status = CoreSearchGcdMapEntry (*BaseAddress, Length, &StartLink, &EndLink, Map);
+ if (EFI_ERROR (Status) || (StartLink == NULL) || (EndLink == NULL)) {
+ Status = EFI_NOT_FOUND;
+ goto Done;
+ }
+
+ Link = StartLink;
+ //
+ // Verify that the list of descriptors are unallocated memory matching GcdMemoryType.
+ //
+ Found = TRUE;
+ SubLink = StartLink;
+ while (SubLink != EndLink->ForwardLink) {
+ Entry = CR (SubLink, EFI_GCD_MAP_ENTRY, Link, EFI_GCD_MAP_SIGNATURE);
+ Status = CoreAllocateSpaceCheckEntry (Operation, Entry, GcdMemoryType, GcdIoType);
+ if (EFI_ERROR (Status)) {
+ Link = SubLink;
+ Found = FALSE;
+ break;
+ }
+ SubLink = SubLink->ForwardLink;
+ }
+ if (Found) {
+ break;
+ }
+ }
+ }
+ if (!Found) {
+ Status = EFI_NOT_FOUND;
+ goto Done;
+ }
+
+ //
+ // Allocate work space to perform this operation
+ //
+ Status = CoreAllocateGcdMapEntry (&TopEntry, &BottomEntry);
+ if (EFI_ERROR (Status) || (TopEntry == NULL) || (BottomEntry == NULL)) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Done;
+ }
+
+ //
+ // Convert/Insert the list of descriptors from StartLink to EndLink
+ //
+ Link = StartLink;
+ while (Link != EndLink->ForwardLink) {
+ Entry = CR (Link, EFI_GCD_MAP_ENTRY, Link, EFI_GCD_MAP_SIGNATURE);
+ CoreInsertGcdMapEntry (Link, Entry, *BaseAddress, Length, TopEntry, BottomEntry);
+ Entry->ImageHandle = ImageHandle;
+ Entry->DeviceHandle = DeviceHandle;
+ Link = Link->ForwardLink;
+ }
+
+ //
+ // Cleanup
+ //
+ Status = CoreCleanupGcdMapEntry (TopEntry, BottomEntry, StartLink, EndLink, Map);
+
+Done:
+ if ((Operation & GCD_MEMORY_SPACE_OPERATION) != 0) {
+ CoreReleaseGcdMemoryLock ();
+ }
+ if ((Operation & GCD_IO_SPACE_OPERATION) != 0) {
+ CoreReleaseGcdIoLock ();
+ }
+
+ return Status;
+}
+
+
+EFI_STATUS
+CoreInternalAddMemorySpace (
+ IN EFI_GCD_MEMORY_TYPE GcdMemoryType,
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length,
+ IN UINT64 Capabilities
+ )
+/*++
+
+Routine Description:
+
+ Add a segment of memory to GCD map.
+
+Arguments:
+
+ GcdMemoryType - Memory type of the segment.
+
+ BaseAddress - Base address of the segment.
+
+ Length - Length of the segment.
+
+ Capabilities - alterable attributes of the segment.
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Invalid parameters.
+
+ EFI_SUCCESS - Successfully add a segment of memory space.
+
+--*/
+{
+ //
+ // Make sure parameters are valid
+ //
+ if (GcdMemoryType <= EfiGcdMemoryTypeNonExistent || GcdMemoryType >= EfiGcdMemoryTypeMaximum) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ return CoreConvertSpace (GCD_ADD_MEMORY_OPERATION, GcdMemoryType, 0, BaseAddress, Length, Capabilities, 0);
+}
+
+//
+// GCD Core Services
+//
+EFI_STATUS
+CoreAllocateMemorySpace (
+ IN EFI_GCD_ALLOCATE_TYPE GcdAllocateType,
+ IN EFI_GCD_MEMORY_TYPE GcdMemoryType,
+ IN UINTN Alignment,
+ IN UINT64 Length,
+ IN OUT EFI_PHYSICAL_ADDRESS *BaseAddress,
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_HANDLE DeviceHandle OPTIONAL
+ )
+/*++
+
+Routine Description:
+
+ Allocates nonexistent memory, reserved memory, system memory, or memorymapped
+I/O resources from the global coherency domain of the processor.
+
+Arguments:
+
+ GcdAllocateType - The type of allocate operation
+
+ GcdMemoryType - The desired memory type
+
+ Alignment - Align with 2^Alignment
+
+ Length - Length to allocate
+
+ BaseAddress - Base address to allocate
+
+ ImageHandle - The image handle consume the allocated space.
+
+ DeviceHandle - The device handle consume the allocated space.
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Invalid parameter.
+
+ EFI_NOT_FOUND - No descriptor contains the desired space.
+
+ EFI_SUCCESS - Memory space successfully allocated.
+
+--*/
+{
+ return CoreAllocateSpace (
+ GCD_ALLOCATE_MEMORY_OPERATION,
+ GcdAllocateType,
+ GcdMemoryType,
+ 0,
+ Alignment,
+ Length,
+ BaseAddress,
+ ImageHandle,
+ DeviceHandle
+ );
+}
+
+EFI_STATUS
+CoreAddMemorySpace (
+ IN EFI_GCD_MEMORY_TYPE GcdMemoryType,
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length,
+ IN UINT64 Capabilities
+ )
+/*++
+
+Routine Description:
+
+ Adds reserved memory, system memory, or memory-mapped I/O resources to the
+global coherency domain of the processor.
+
+Arguments:
+
+ GcdMemoryType - Memory type of the memory space.
+
+ BaseAddress - Base address of the memory space.
+
+ Length - Length of the memory space.
+
+ Capabilities - alterable attributes of the memory space.
+
+Returns:
+
+ EFI_SUCCESS - Merged this memory space into GCD map.
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_PHYSICAL_ADDRESS PageBaseAddress;
+ UINT64 PageLength;
+
+ Status = CoreInternalAddMemorySpace (GcdMemoryType, BaseAddress, Length, Capabilities);
+
+ if (!EFI_ERROR (Status) && GcdMemoryType == EfiGcdMemoryTypeSystemMemory) {
+
+ PageBaseAddress = PageAlignLength (BaseAddress);
+ PageLength = PageAlignLength (BaseAddress + Length - PageBaseAddress);
+
+ Status = CoreAllocateMemorySpace (
+ EfiGcdAllocateAddress,
+ GcdMemoryType,
+ EFI_PAGE_SHIFT,
+ PageLength,
+ &PageBaseAddress,
+ gDxeCoreImageHandle,
+ NULL
+ );
+
+ if (!EFI_ERROR (Status)) {
+ CoreAddMemoryDescriptor (
+ EfiConventionalMemory,
+ PageBaseAddress,
+ RShiftU64 (PageLength, EFI_PAGE_SHIFT),
+ Capabilities
+ );
+ } else {
+ for (; PageLength != 0; PageLength -= EFI_PAGE_SIZE, PageBaseAddress += EFI_PAGE_SIZE) {
+ Status = CoreAllocateMemorySpace (
+ EfiGcdAllocateAddress,
+ GcdMemoryType,
+ EFI_PAGE_SHIFT,
+ EFI_PAGE_SIZE,
+ &PageBaseAddress,
+ gDxeCoreImageHandle,
+ NULL
+ );
+
+ if (!EFI_ERROR (Status)) {
+ CoreAddMemoryDescriptor (
+ EfiConventionalMemory,
+ PageBaseAddress,
+ 1,
+ Capabilities
+ );
+ }
+ }
+ }
+ }
+ return Status;
+}
+
+EFI_STATUS
+CoreFreeMemorySpace (
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length
+ )
+/*++
+
+Routine Description:
+
+ Frees nonexistent memory, reserved memory, system memory, or memory-mapped
+I/O resources from the global coherency domain of the processor.
+
+Arguments:
+
+ BaseAddress - Base address of the memory space.
+
+ Length - Length of the memory space.
+
+Returns:
+
+ EFI_SUCCESS - Space successfully freed.
+
+--*/
+{
+ return CoreConvertSpace (GCD_FREE_MEMORY_OPERATION, 0, 0, BaseAddress, Length, 0, 0);
+}
+
+EFI_STATUS
+CoreRemoveMemorySpace (
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length
+ )
+/*++
+
+Routine Description:
+
+ Removes reserved memory, system memory, or memory-mapped I/O resources from
+the global coherency domain of the processor.
+
+Arguments:
+
+ BaseAddress - Base address of the memory space.
+
+ Length - Length of the memory space.
+
+Returns:
+
+ EFI_SUCCESS - Successfully remove a segment of memory space.
+
+--*/
+{
+ return CoreConvertSpace (GCD_REMOVE_MEMORY_OPERATION, 0, 0, BaseAddress, Length, 0, 0);
+}
+
+VOID
+BuildMemoryDescriptor (
+ IN OUT EFI_GCD_MEMORY_SPACE_DESCRIPTOR *Descriptor,
+ IN EFI_GCD_MAP_ENTRY *Entry
+ )
+/*++
+
+Routine Description:
+
+ Build a memory descriptor according to an entry.
+
+Arguments:
+
+ Descriptor - The descriptor to be built
+
+ Entry - According to this entry
+
+Returns:
+
+ None
+
+--*/
+{
+ Descriptor->BaseAddress = Entry->BaseAddress;
+ Descriptor->Length = Entry->EndAddress - Entry->BaseAddress + 1;
+ Descriptor->Capabilities = Entry->Capabilities;
+ Descriptor->Attributes = Entry->Attributes;
+ Descriptor->GcdMemoryType = Entry->GcdMemoryType;
+ Descriptor->ImageHandle = Entry->ImageHandle;
+ Descriptor->DeviceHandle = Entry->DeviceHandle;
+}
+
+EFI_STATUS
+CoreGetMemorySpaceDescriptor (
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ OUT EFI_GCD_MEMORY_SPACE_DESCRIPTOR *Descriptor
+ )
+/*++
+
+Routine Description:
+
+ Retrieves the descriptor for a memory region containing a specified address.
+
+Arguments:
+
+ BaseAddress - Specified start address
+
+ Descriptor - Specified length
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Invalid parameter
+
+ EFI_SUCCESS - Successfully get memory space descriptor.
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_LIST_ENTRY *StartLink;
+ EFI_LIST_ENTRY *EndLink;
+ EFI_GCD_MAP_ENTRY *Entry;
+
+ //
+ // Make sure parameters are valid
+ //
+ if (Descriptor == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ CoreAcquireGcdMemoryLock ();
+
+ //
+ // Search for the list of descriptors that contain BaseAddress
+ //
+ Status = CoreSearchGcdMapEntry (BaseAddress, 1, &StartLink, &EndLink, &mGcdMemorySpaceMap);
+ if (EFI_ERROR (Status) || (StartLink == NULL) || (EndLink == NULL)) {
+ Status = EFI_NOT_FOUND;
+ } else {
+ //
+ // Copy the contents of the found descriptor into Descriptor
+ //
+ Entry = CR (StartLink, EFI_GCD_MAP_ENTRY, Link, EFI_GCD_MAP_SIGNATURE);
+ BuildMemoryDescriptor (Descriptor, Entry);
+ }
+
+ CoreReleaseGcdMemoryLock ();
+
+ return Status;
+}
+
+EFI_STATUS
+CoreSetMemorySpaceAttributes (
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length,
+ IN UINT64 Attributes
+ )
+/*++
+
+Routine Description:
+
+ Modifies the attributes for a memory region in the global coherency domain of the
+processor.
+
+Arguments:
+
+ BaseAddress - Specified start address
+
+ Length - Specified length
+
+ Attributes - Specified attributes
+
+Returns:
+
+ EFI_SUCCESS - Successfully set attribute of a segment of memory space.
+
+--*/
+{
+ return CoreConvertSpace (GCD_SET_ATTRIBUTES_MEMORY_OPERATION, 0, 0, BaseAddress, Length, 0, Attributes);
+}
+
+EFI_STATUS
+CoreGetMemorySpaceMap (
+ OUT UINTN *NumberOfDescriptors,
+ OUT EFI_GCD_MEMORY_SPACE_DESCRIPTOR **MemorySpaceMap
+ )
+/*++
+
+Routine Description:
+
+ Returns a map of the memory resources in the global coherency domain of the
+processor.
+
+Arguments:
+
+ NumberOfDescriptors - Number of descriptors.
+
+ MemorySpaceMap - Descriptor array
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Invalid parameter
+
+ EFI_OUT_OF_RESOURCES - No enough buffer to allocate
+
+ EFI_SUCCESS - Successfully get memory space map.
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_LIST_ENTRY *Link;
+ EFI_GCD_MAP_ENTRY *Entry;
+ EFI_GCD_MEMORY_SPACE_DESCRIPTOR *Descriptor;
+
+ //
+ // Make sure parameters are valid
+ //
+ if (NumberOfDescriptors == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+ if (MemorySpaceMap == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ CoreAcquireGcdMemoryLock ();
+
+ //
+ // Count the number of descriptors
+ //
+ *NumberOfDescriptors = CoreCountGcdMapEntry (&mGcdMemorySpaceMap);
+
+ //
+ // Allocate the MemorySpaceMap
+ //
+ *MemorySpaceMap = CoreAllocateBootServicesPool (*NumberOfDescriptors * sizeof (EFI_GCD_MEMORY_SPACE_DESCRIPTOR));
+ if (*MemorySpaceMap == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Done;
+ }
+
+ //
+ // Fill in the MemorySpaceMap
+ //
+ Descriptor = *MemorySpaceMap;
+ Link = mGcdMemorySpaceMap.ForwardLink;
+ while (Link != &mGcdMemorySpaceMap) {
+ Entry = CR (Link, EFI_GCD_MAP_ENTRY, Link, EFI_GCD_MAP_SIGNATURE);
+ BuildMemoryDescriptor (Descriptor, Entry);
+ Descriptor++;
+ Link = Link->ForwardLink;
+ }
+ Status = EFI_SUCCESS;
+
+Done:
+ CoreReleaseGcdMemoryLock ();
+ return Status;
+}
+
+EFI_STATUS
+CoreAddIoSpace (
+ IN EFI_GCD_IO_TYPE GcdIoType,
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length
+ )
+/*++
+
+Routine Description:
+
+ Adds reserved I/O or I/O resources to the global coherency domain of the processor.
+
+Arguments:
+
+ GcdIoType - IO type of the segment.
+
+ BaseAddress - Base address of the segment.
+
+ Length - Length of the segment.
+
+Returns:
+
+ EFI_SUCCESS - Merged this segment into GCD map.
+ EFI_INVALID_PARAMETER - Parameter not valid
+
+--*/
+{
+ //
+ // Make sure parameters are valid
+ //
+ if (GcdIoType <= EfiGcdIoTypeNonExistent || GcdIoType >= EfiGcdIoTypeMaximum) {
+ return EFI_INVALID_PARAMETER;
+ }
+ return CoreConvertSpace (GCD_ADD_IO_OPERATION, 0, GcdIoType, BaseAddress, Length, 0, 0);
+}
+
+EFI_STATUS
+CoreAllocateIoSpace (
+ IN EFI_GCD_ALLOCATE_TYPE GcdAllocateType,
+ IN EFI_GCD_IO_TYPE GcdIoType,
+ IN UINTN Alignment,
+ IN UINT64 Length,
+ IN OUT EFI_PHYSICAL_ADDRESS *BaseAddress,
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_HANDLE DeviceHandle OPTIONAL
+ )
+/*++
+
+Routine Description:
+
+ Allocates nonexistent I/O, reserved I/O, or I/O resources from the global coherency
+domain of the processor.
+
+Arguments:
+
+ GcdAllocateType - The type of allocate operation
+
+ GcdIoType - The desired IO type
+
+ Alignment - Align with 2^Alignment
+
+ Length - Length to allocate
+
+ BaseAddress - Base address to allocate
+
+ ImageHandle - The image handle consume the allocated space.
+
+ DeviceHandle - The device handle consume the allocated space.
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Invalid parameter.
+
+ EFI_NOT_FOUND - No descriptor contains the desired space.
+
+ EFI_SUCCESS - IO space successfully allocated.
+
+--*/
+{
+ return CoreAllocateSpace (
+ GCD_ALLOCATE_IO_OPERATION,
+ GcdAllocateType,
+ 0,
+ GcdIoType,
+ Alignment,
+ Length,
+ BaseAddress,
+ ImageHandle,
+ DeviceHandle
+ );
+}
+
+EFI_STATUS
+CoreFreeIoSpace (
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length
+ )
+/*++
+
+Routine Description:
+
+ Frees nonexistent I/O, reserved I/O, or I/O resources from the global coherency
+domain of the processor.
+
+Arguments:
+
+ BaseAddress - Base address of the segment.
+
+ Length - Length of the segment.
+
+Returns:
+
+ EFI_SUCCESS - Space successfully freed.
+
+--*/
+{
+ return CoreConvertSpace (GCD_FREE_IO_OPERATION, 0, 0, BaseAddress, Length, 0, 0);
+}
+
+EFI_STATUS
+CoreRemoveIoSpace (
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length
+ )
+/*++
+
+Routine Description:
+
+ Removes reserved I/O or I/O resources from the global coherency domain of the
+processor.
+
+Arguments:
+
+ BaseAddress - Base address of the segment.
+
+ Length - Length of the segment.
+
+Returns:
+
+ EFI_SUCCESS - Successfully removed a segment of IO space.
+
+--*/
+{
+ return CoreConvertSpace (GCD_REMOVE_IO_OPERATION, 0, 0, BaseAddress, Length, 0, 0);
+}
+
+VOID
+BuildIoDescriptor (
+ IN EFI_GCD_IO_SPACE_DESCRIPTOR *Descriptor,
+ IN EFI_GCD_MAP_ENTRY *Entry
+ )
+/*++
+
+Routine Description:
+
+ Build a IO descriptor according to an entry.
+
+Arguments:
+
+ Descriptor - The descriptor to be built
+
+ Entry - According to this entry
+
+Returns:
+
+ None
+
+--*/
+{
+ Descriptor->BaseAddress = Entry->BaseAddress;
+ Descriptor->Length = Entry->EndAddress - Entry->BaseAddress + 1;
+ Descriptor->GcdIoType = Entry->GcdIoType;
+ Descriptor->ImageHandle = Entry->ImageHandle;
+ Descriptor->DeviceHandle = Entry->DeviceHandle;
+}
+
+EFI_STATUS
+CoreGetIoSpaceDescriptor (
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ OUT EFI_GCD_IO_SPACE_DESCRIPTOR *Descriptor
+ )
+/*++
+
+Routine Description:
+
+ Retrieves the descriptor for an I/O region containing a specified address.
+
+Arguments:
+
+ BaseAddress - Specified start address
+
+ Descriptor - Specified length
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Descriptor is NULL.
+
+ EFI_SUCCESS - Successfully get the IO space descriptor.
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_LIST_ENTRY *StartLink;
+ EFI_LIST_ENTRY *EndLink;
+ EFI_GCD_MAP_ENTRY *Entry;
+
+ //
+ // Make sure parameters are valid
+ //
+ if (Descriptor == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ CoreAcquireGcdIoLock ();
+
+ //
+ // Search for the list of descriptors that contain BaseAddress
+ //
+ Status = CoreSearchGcdMapEntry (BaseAddress, 1, &StartLink, &EndLink, &mGcdIoSpaceMap);
+ if (EFI_ERROR (Status) || (StartLink == NULL) || (EndLink == NULL)) {
+ Status = EFI_NOT_FOUND;
+ } else {
+ //
+ // Copy the contents of the found descriptor into Descriptor
+ //
+ Entry = CR (StartLink, EFI_GCD_MAP_ENTRY, Link, EFI_GCD_MAP_SIGNATURE);
+ BuildIoDescriptor (Descriptor, Entry);
+ }
+
+ CoreReleaseGcdIoLock ();
+
+ return Status;
+}
+
+EFI_STATUS
+CoreGetIoSpaceMap (
+ OUT UINTN *NumberOfDescriptors,
+ OUT EFI_GCD_IO_SPACE_DESCRIPTOR **IoSpaceMap
+ )
+/*++
+
+Routine Description:
+
+ Returns a map of the I/O resources in the global coherency domain of the processor.
+
+Arguments:
+
+ NumberOfDescriptors - Number of descriptors.
+
+ IoSpaceMap - Descriptor array
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Invalid parameter
+
+ EFI_OUT_OF_RESOURCES - No enough buffer to allocate
+
+ EFI_SUCCESS - Successfully get IO space map.
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_LIST_ENTRY *Link;
+ EFI_GCD_MAP_ENTRY *Entry;
+ EFI_GCD_IO_SPACE_DESCRIPTOR *Descriptor;
+
+ //
+ // Make sure parameters are valid
+ //
+ if (NumberOfDescriptors == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+ if (IoSpaceMap == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ CoreAcquireGcdIoLock ();
+
+ //
+ // Count the number of descriptors
+ //
+ *NumberOfDescriptors = CoreCountGcdMapEntry (&mGcdIoSpaceMap);
+
+ //
+ // Allocate the IoSpaceMap
+ //
+ *IoSpaceMap = CoreAllocateBootServicesPool (*NumberOfDescriptors * sizeof (EFI_GCD_IO_SPACE_DESCRIPTOR));
+ if (*IoSpaceMap == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Done;
+ }
+
+ //
+ // Fill in the IoSpaceMap
+ //
+ Descriptor = *IoSpaceMap;
+ Link = mGcdIoSpaceMap.ForwardLink;
+ while (Link != &mGcdIoSpaceMap) {
+ Entry = CR (Link, EFI_GCD_MAP_ENTRY, Link, EFI_GCD_MAP_SIGNATURE);
+ BuildIoDescriptor (Descriptor, Entry);
+ Descriptor++;
+ Link = Link->ForwardLink;
+ }
+ Status = EFI_SUCCESS;
+
+Done:
+ CoreReleaseGcdIoLock ();
+ return Status;
+}
+
+UINT64
+CoreConvertResourceDescriptorHobAttributesToCapabilities (
+ EFI_GCD_MEMORY_TYPE GcdMemoryType,
+ UINT64 Attributes
+ )
+/*++
+
+Routine Description:
+
+ Converts a Resource Descriptor HOB attributes mask to an EFI Memory Descriptor
+ capabilities mask
+
+Arguments:
+
+ GcdMemoryType - Type of resource in the GCD memory map.
+ Attributes - The attribute mask in the Resource Descriptor HOB.
+
+Returns:
+
+ The capabilities mask for an EFI Memory Descriptor.
+
+--*/
+{
+ UINT64 Capabilities;
+ GCD_ATTRIBUTE_CONVERSION_ENTRY *Conversion;
+
+ //
+ // Convert the Resource HOB Attributes to an EFI Memory Capabilities mask
+ //
+ for (Capabilities = 0, Conversion = mAttributeConversionTable; Conversion->Attribute != 0; Conversion++) {
+ if (Conversion->Memory || (GcdMemoryType != EfiGcdMemoryTypeSystemMemory)) {
+ if (Attributes & Conversion->Attribute) {
+ Capabilities |= Conversion->Capability;
+ }
+ }
+ }
+
+ return Capabilities;
+}
+
+EFI_STATUS
+CoreInitializeMemoryServices (
+ IN VOID **HobStart,
+ OUT EFI_PHYSICAL_ADDRESS *MemoryBaseAddress,
+ OUT UINT64 *MemoryLength
+ )
+/*++
+
+Routine Description:
+
+ External function. Initializes the GCD and memory services based on the memory
+ descriptor HOBs. This function is responsible for priming the GCD map and the
+ memory map, so memory allocations and resource allocations can be made. The first
+ part of this function can not depend on any memory services until at least one
+ memory descriptor is provided to the memory services. Then the memory services
+ can be used to intialize the GCD map.
+
+Arguments:
+
+ HobStart - The start address of the HOB.
+ MemoryBaseAddress - Start address of memory region found to init DXE core.
+ MemoryLength - Length of memory region found to init DXE core.
+
+Returns:
+
+ EFI_SUCCESS - Memory services successfully initialized.
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_PEI_HOB_POINTERS Hob;
+ EFI_MEMORY_TYPE_INFORMATION *EfiMemoryTypeInformation;
+ UINTN DataSize;
+ BOOLEAN Found;
+ EFI_HOB_HANDOFF_INFO_TABLE *PhitHob;
+ EFI_HOB_RESOURCE_DESCRIPTOR *ResourceHob;
+ EFI_HOB_RESOURCE_DESCRIPTOR *PhitResourceHob;
+ EFI_PHYSICAL_ADDRESS BaseAddress;
+ UINT64 Length;
+ UINT64 Attributes;
+ UINT64 Capabilities;
+ EFI_PHYSICAL_ADDRESS MaxMemoryBaseAddress;
+ UINT64 MaxMemoryLength;
+ UINT64 MaxMemoryAttributes;
+ EFI_PHYSICAL_ADDRESS MaxAddress;
+ EFI_PHYSICAL_ADDRESS HighAddress;
+ EFI_HOB_RESOURCE_DESCRIPTOR *MaxResourceHob;
+
+ //
+ // Point at the first HOB. This must be the PHIT HOB.
+ //
+ Hob.Raw = *HobStart;
+ ASSERT (GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_HANDOFF);
+
+ //
+ // Initialize the spin locks and maps in the memory services.
+ // Also fill in the memory services into the EFI Boot Services Table
+ //
+ CoreInitializePool ();
+
+ //
+ // Initialize Local Variables
+ //
+ PhitResourceHob = NULL;
+ MaxResourceHob = NULL;
+ ResourceHob = NULL;
+ BaseAddress = 0;
+ Length = 0;
+ Attributes = 0;
+ MaxMemoryBaseAddress = 0;
+ MaxMemoryLength = 0;
+ MaxMemoryAttributes = 0;
+
+ //
+ // Cache the PHIT HOB for later use
+ //
+ PhitHob = Hob.HandoffInformationTable;
+
+ //
+ // See if a Memory Type Information HOB is available
+ //
+ Status = GetNextGuidHob (&Hob.Raw, &gEfiMemoryTypeInformationGuid, &EfiMemoryTypeInformation, &DataSize);
+ if (!EFI_ERROR (Status) &&
+ EfiMemoryTypeInformation != NULL &&
+ DataSize > 0 &&
+ DataSize < EfiMaxMemoryType * sizeof (EFI_MEMORY_TYPE_INFORMATION)) {
+ gBS->CopyMem (&gMemoryTypeInformation, EfiMemoryTypeInformation, DataSize);
+ }
+
+ //
+ // Find the Resource Descriptor HOB that contains range FreeMemoryBaseAddress..FreeMemoryLength
+ //
+ Length = 0;
+ Found = FALSE;
+ for (Hob.Raw = *HobStart; !END_OF_HOB_LIST(Hob); Hob.Raw = GET_NEXT_HOB(Hob)) {
+
+ if (GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_RESOURCE_DESCRIPTOR) {
+
+ ResourceHob = Hob.ResourceDescriptor;
+
+ if (ResourceHob->ResourceType == EFI_RESOURCE_SYSTEM_MEMORY &&
+ (ResourceHob->ResourceAttribute & MEMORY_ATTRIBUTE_MASK) == TESTED_MEMORY_ATTRIBUTES ) {
+
+ if (PhitHob->EfiFreeMemoryBottom >= ResourceHob->PhysicalStart &&
+ PhitHob->EfiFreeMemoryTop <= (ResourceHob->PhysicalStart + ResourceHob->ResourceLength) ) {
+
+ //
+ // Cache the resource descriptor HOB for the memory region described by the PHIT HOB
+ //
+ PhitResourceHob = ResourceHob;
+ Found = TRUE;
+
+ Attributes = PhitResourceHob->ResourceAttribute;
+ BaseAddress = PageAlignAddress (PhitHob->EfiMemoryTop);
+ Length = PageAlignLength (ResourceHob->PhysicalStart + ResourceHob->ResourceLength - BaseAddress);
+ if (Length < MINIMUM_INITIAL_MEMORY_SIZE) {
+ BaseAddress = PageAlignAddress (PhitHob->EfiFreeMemoryBottom);
+ Length = PageAlignLength (PhitHob->EfiFreeMemoryTop - BaseAddress);
+ if (Length < MINIMUM_INITIAL_MEMORY_SIZE) {
+ BaseAddress = PageAlignAddress (ResourceHob->PhysicalStart);
+ Length = PageAlignLength ((UINT64)*HobStart - BaseAddress);
+ }
+ }
+ break;
+ }
+ }
+ }
+ }
+
+ //
+ // Assert if a resource descriptor HOB for the memory region described by the PHIT was not found
+ //
+ ASSERT (Found);
+
+ //
+ // Search all the resource descriptor HOBs from the highest possible addresses down for a memory
+ // region that is big enough to initialize the DXE core. Always skip the PHIT Resource HOB.
+ // The max address must be within the physically addressible range for the processor.
+ //
+ MaxMemoryLength = 0;
+ MaxAddress = EFI_MAX_ADDRESS;
+ do {
+ HighAddress = 0;
+ Found = FALSE;
+ //
+ // Search for a tested memory region that is below MaxAddress
+ //
+ for (Hob.Raw = *HobStart; !END_OF_HOB_LIST(Hob); Hob.Raw = GET_NEXT_HOB(Hob)) {
+
+ //
+ // See if this is a resource descriptor HOB that does not contain the PHIT.
+ //
+ if (Hob.ResourceDescriptor != PhitResourceHob && GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_RESOURCE_DESCRIPTOR) {
+
+ ResourceHob = Hob.ResourceDescriptor;
+ //
+ // See if this resource descrior HOB describes tested system memory below MaxAddress
+ //
+ if (ResourceHob->ResourceType == EFI_RESOURCE_SYSTEM_MEMORY &&
+ (ResourceHob->ResourceAttribute & MEMORY_ATTRIBUTE_MASK) == TESTED_MEMORY_ATTRIBUTES &&
+ ResourceHob->PhysicalStart + ResourceHob->ResourceLength <= MaxAddress ) {
+
+ //
+ // See if this is the highest tested system memory region below MaxAddress
+ //
+ if (ResourceHob->PhysicalStart > HighAddress) {
+
+ MaxResourceHob = ResourceHob;
+ HighAddress = MaxResourceHob->PhysicalStart;
+ Found = TRUE;
+ }
+ }
+ }
+ }
+ if (Found) {
+ //
+ // Compute the size of the tested memory region below MaxAddrees
+ //
+ MaxMemoryBaseAddress = PageAlignAddress (MaxResourceHob->PhysicalStart);
+ MaxMemoryLength = PageAlignLength (MaxResourceHob->PhysicalStart + MaxResourceHob->ResourceLength - MaxMemoryBaseAddress);
+ MaxMemoryAttributes = MaxResourceHob->ResourceAttribute;
+ }
+ if (ResourceHob != NULL) {
+ MaxAddress = ResourceHob->PhysicalStart;
+ }
+ } while (Found && MaxMemoryLength < MINIMUM_INITIAL_MEMORY_SIZE);
+
+ //
+ //
+ //
+ if ((Length < MINIMUM_INITIAL_MEMORY_SIZE) ||
+ (MaxMemoryBaseAddress > BaseAddress && MaxMemoryLength >= MINIMUM_INITIAL_MEMORY_SIZE) ) {
+ BaseAddress = MaxMemoryBaseAddress;
+ Length = MaxMemoryLength;
+ Attributes = MaxMemoryAttributes;
+ }
+
+ //
+ // If no memory regions are found that are big enough to initialize the DXE core, then ASSERT().
+ //
+ ASSERT (Length >= MINIMUM_INITIAL_MEMORY_SIZE);
+
+ //
+ // Convert the Resource HOB Attributes to an EFI Memory Capabilities mask
+ //
+ Capabilities = CoreConvertResourceDescriptorHobAttributesToCapabilities (EfiGcdMemoryTypeSystemMemory, Attributes);
+
+ //
+ // Declare the very first memory region, so the EFI Memory Services are available.
+ //
+ CoreAddMemoryDescriptor (
+ EfiConventionalMemory,
+ BaseAddress,
+ RShiftU64 (Length, EFI_PAGE_SHIFT),
+ Capabilities
+ );
+
+ *MemoryBaseAddress = BaseAddress;
+ *MemoryLength = Length;
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+CoreInitializeGcdServices (
+ IN VOID **HobStart,
+ IN EFI_PHYSICAL_ADDRESS MemoryBaseAddress,
+ IN UINT64 MemoryLength
+ )
+/*++
+
+Routine Description:
+
+ External function. Initializes the GCD and memory services based on the memory
+ descriptor HOBs. This function is responsible for priming the GCD map and the
+ memory map, so memory allocations and resource allocations can be made. The first
+ part of this function can not depend on any memory services until at least one
+ memory descriptor is provided to the memory services. Then the memory services
+ can be used to intialize the GCD map.
+
+Arguments:
+
+ HobStart - The start address of the HOB
+
+ MemoryBaseAddress - Start address of memory region found to init DXE core.
+
+ MemoryLength - Length of memory region found to init DXE core.
+
+
+Returns:
+
+ EFI_SUCCESS - GCD services successfully initialized.
+
+--*/
+{
+ EFI_PEI_HOB_POINTERS Hob;
+ VOID *NewHobList;
+ EFI_HOB_HANDOFF_INFO_TABLE *PhitHob;
+ UINT8 SizeOfMemorySpace;
+ UINT8 SizeOfIoSpace;
+ EFI_HOB_RESOURCE_DESCRIPTOR *ResourceHob;
+ EFI_PHYSICAL_ADDRESS BaseAddress;
+ UINT64 Length;
+ EFI_STATUS Status;
+ EFI_GCD_MAP_ENTRY *Entry;
+ EFI_GCD_MEMORY_TYPE GcdMemoryType;
+ EFI_GCD_IO_TYPE GcdIoType;
+ EFI_GCD_MEMORY_SPACE_DESCRIPTOR Descriptor;
+ EFI_HOB_MEMORY_ALLOCATION *MemoryHob;
+ EFI_HOB_FIRMWARE_VOLUME *FirmwareVolumeHob;
+ UINTN NumberOfDescriptors;
+ EFI_GCD_MEMORY_SPACE_DESCRIPTOR *MemorySpaceMap;
+ UINTN Index;
+ UINT64 Capabilities;
+
+ //
+ // Cache the PHIT HOB for later use
+ //
+ PhitHob = (EFI_HOB_HANDOFF_INFO_TABLE *)(*HobStart);
+
+ //
+ // Get the number of address lines in the I/O and Memory space for the CPU
+ //
+ Status = GetCpuHobInfo (*HobStart, &SizeOfMemorySpace, &SizeOfIoSpace);
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // Initialize the GCD Memory Space Map
+ //
+ Entry = CoreAllocateCopyPool (sizeof (EFI_GCD_MAP_ENTRY), &mGcdMemorySpaceMapEntryTemplate);
+ ASSERT (Entry != NULL);
+ if (Entry == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ Entry->EndAddress = LShiftU64 (1, SizeOfMemorySpace) - 1;
+
+ InsertHeadList (&mGcdMemorySpaceMap, &Entry->Link);
+
+ //
+ // Initialize the GCD I/O Space Map
+ //
+ Entry = CoreAllocateCopyPool (sizeof (EFI_GCD_MAP_ENTRY), &mGcdIoSpaceMapEntryTemplate);
+ ASSERT (Entry != NULL);
+ if (Entry == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ Entry->EndAddress = LShiftU64 (1, SizeOfIoSpace) - 1;
+
+ InsertHeadList (&mGcdIoSpaceMap, &Entry->Link);
+
+ //
+ // Walk the HOB list and add all resource descriptors to the GCD
+ //
+ for (Hob.Raw = *HobStart; !END_OF_HOB_LIST(Hob); Hob.Raw = GET_NEXT_HOB(Hob)) {
+
+ GcdMemoryType = EfiGcdMemoryTypeNonExistent;
+ GcdIoType = EfiGcdIoTypeNonExistent;
+
+ if (GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_RESOURCE_DESCRIPTOR) {
+
+ ResourceHob = Hob.ResourceDescriptor;
+
+ switch (ResourceHob->ResourceType) {
+ case EFI_RESOURCE_SYSTEM_MEMORY:
+ if ((ResourceHob->ResourceAttribute & MEMORY_ATTRIBUTE_MASK) == TESTED_MEMORY_ATTRIBUTES) {
+ GcdMemoryType = EfiGcdMemoryTypeSystemMemory;
+ }
+ if ((ResourceHob->ResourceAttribute & MEMORY_ATTRIBUTE_MASK) == INITIALIZED_MEMORY_ATTRIBUTES) {
+ GcdMemoryType = EfiGcdMemoryTypeReserved;
+ }
+ if ((ResourceHob->ResourceAttribute & MEMORY_ATTRIBUTE_MASK) == PRESENT_MEMORY_ATTRIBUTES) {
+ GcdMemoryType = EfiGcdMemoryTypeReserved;
+ }
+ break;
+ case EFI_RESOURCE_MEMORY_MAPPED_IO:
+ case EFI_RESOURCE_FIRMWARE_DEVICE:
+ GcdMemoryType = EfiGcdMemoryTypeMemoryMappedIo;
+ break;
+ case EFI_RESOURCE_MEMORY_MAPPED_IO_PORT:
+ case EFI_RESOURCE_MEMORY_RESERVED:
+ GcdMemoryType = EfiGcdMemoryTypeReserved;
+ break;
+ case EFI_RESOURCE_IO:
+ GcdIoType = EfiGcdIoTypeIo;
+ break;
+ case EFI_RESOURCE_IO_RESERVED:
+ GcdIoType = EfiGcdIoTypeReserved;
+ break;
+ }
+
+ if (GcdMemoryType != EfiGcdMemoryTypeNonExistent) {
+
+ //
+ // Convert the Resource HOB Attributes to an EFI Memory Capabilities mask
+ //
+ Capabilities = CoreConvertResourceDescriptorHobAttributesToCapabilities (
+ GcdMemoryType,
+ ResourceHob->ResourceAttribute
+ );
+
+ Status = CoreInternalAddMemorySpace (
+ GcdMemoryType,
+ ResourceHob->PhysicalStart,
+ ResourceHob->ResourceLength,
+ Capabilities
+ );
+ }
+
+ if (GcdIoType != EfiGcdIoTypeNonExistent) {
+ Status = CoreAddIoSpace (
+ GcdIoType,
+ ResourceHob->PhysicalStart,
+ ResourceHob->ResourceLength
+ );
+ }
+ }
+ }
+
+ //
+ // Allocate first memory region from the GCD by the DXE core
+ //
+ Status = CoreAllocateMemorySpace (
+ EfiGcdAllocateAddress,
+ EfiGcdMemoryTypeSystemMemory,
+ 0,
+ MemoryLength,
+ &MemoryBaseAddress,
+ gDxeCoreImageHandle,
+ NULL
+ );
+
+ //
+ // Walk the HOB list and allocate all memory space that is consumed by memory allocation HOBs,
+ // and Firmware Volume HOBs. Also update the EFI Memory Map with the memory allocation HOBs.
+ //
+ for (Hob.Raw = *HobStart; !END_OF_HOB_LIST(Hob); Hob.Raw = GET_NEXT_HOB(Hob)) {
+ if (GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_MEMORY_ALLOCATION) {
+ MemoryHob = Hob.MemoryAllocation;
+ BaseAddress = MemoryHob->AllocDescriptor.MemoryBaseAddress;
+ Status = CoreAllocateMemorySpace (
+ EfiGcdAllocateAddress,
+ EfiGcdMemoryTypeSystemMemory,
+ 0,
+ MemoryHob->AllocDescriptor.MemoryLength,
+ &BaseAddress,
+ gDxeCoreImageHandle,
+ NULL
+ );
+ if (!EFI_ERROR (Status)) {
+ Status = CoreGetMemorySpaceDescriptor (MemoryHob->AllocDescriptor.MemoryBaseAddress, &Descriptor);
+ if (!EFI_ERROR (Status)) {
+ CoreAddMemoryDescriptor (
+ MemoryHob->AllocDescriptor.MemoryType,
+ MemoryHob->AllocDescriptor.MemoryBaseAddress,
+ RShiftU64 (MemoryHob->AllocDescriptor.MemoryLength, EFI_PAGE_SHIFT),
+ Descriptor.Capabilities & (~EFI_MEMORY_RUNTIME)
+ );
+ }
+ }
+ }
+
+ if (GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_FV) {
+ FirmwareVolumeHob = Hob.FirmwareVolume;
+ BaseAddress = FirmwareVolumeHob->BaseAddress;
+ Status = CoreAllocateMemorySpace (
+ EfiGcdAllocateAddress,
+ EfiGcdMemoryTypeMemoryMappedIo,
+ 0,
+ FirmwareVolumeHob->Length,
+ &BaseAddress,
+ gDxeCoreImageHandle,
+ NULL
+ );
+ }
+ }
+
+ //
+ // Relocate HOB List to an allocated pool buffer.
+ //
+ NewHobList = CoreAllocateCopyPool (
+ (UINTN)PhitHob->EfiFreeMemoryBottom - (UINTN)(*HobStart),
+ *HobStart
+ );
+ ASSERT (NewHobList != NULL);
+
+ *HobStart = NewHobList;
+
+ //
+ // Add and allocate the remaining unallocated system memory to the memory services.
+ //
+ Status = CoreGetMemorySpaceMap (&NumberOfDescriptors, &MemorySpaceMap);
+ if (EFI_ERROR (Status) || (MemorySpaceMap == NULL)) {
+ return Status;
+ }
+ for (Index = 0; Index < NumberOfDescriptors; Index++) {
+ if (MemorySpaceMap[Index].GcdMemoryType == EfiGcdMemoryTypeSystemMemory) {
+ if (MemorySpaceMap[Index].ImageHandle == NULL) {
+ BaseAddress = PageAlignAddress (MemorySpaceMap[Index].BaseAddress);
+ Length = PageAlignLength (MemorySpaceMap[Index].BaseAddress + MemorySpaceMap[Index].Length - BaseAddress);
+//
+// EDK Defect Start: EDK836
+//
+// BUG FIX:
+// Skip zero length descriptors
+//
+ if (Length == 0) {
+ continue;
+ }
+//
+// EDK Defect End: EDK836
+//
+ CoreAddMemoryDescriptor (
+ EfiConventionalMemory,
+ BaseAddress,
+ RShiftU64 (Length, EFI_PAGE_SHIFT),
+ MemorySpaceMap[Index].Capabilities & (~EFI_MEMORY_RUNTIME)
+ );
+ Status = CoreAllocateMemorySpace (
+ EfiGcdAllocateAddress,
+ EfiGcdMemoryTypeSystemMemory,
+ 0,
+ Length,
+ &BaseAddress,
+ gDxeCoreImageHandle,
+ NULL
+ );
+ }
+ }
+ }
+ CoreFreePool (MemorySpaceMap);
+
+ return EFI_SUCCESS;
+}
diff --git a/EDK/Foundation/Core/Dxe/Gcd/gcd.h b/EDK/Foundation/Core/Dxe/Gcd/gcd.h
new file mode 100644
index 0000000..13d448d
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/Gcd/gcd.h
@@ -0,0 +1,54 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ gcd.h
+
+Abstract:
+
+Revision History
+
+--*/
+
+#ifndef _GCD_H
+#define _GCD_H
+
+#include "Tiano.h"
+#include "DxeCore.h"
+
+//
+// GCD Operations
+//
+#define GCD_MEMORY_SPACE_OPERATION 0x20
+#define GCD_IO_SPACE_OPERATION 0x40
+
+#define GCD_ADD_MEMORY_OPERATION (GCD_MEMORY_SPACE_OPERATION | 0)
+#define GCD_ALLOCATE_MEMORY_OPERATION (GCD_MEMORY_SPACE_OPERATION | 1)
+#define GCD_FREE_MEMORY_OPERATION (GCD_MEMORY_SPACE_OPERATION | 2)
+#define GCD_REMOVE_MEMORY_OPERATION (GCD_MEMORY_SPACE_OPERATION | 3)
+#define GCD_SET_ATTRIBUTES_MEMORY_OPERATION (GCD_MEMORY_SPACE_OPERATION | 4)
+
+#define GCD_ADD_IO_OPERATION (GCD_IO_SPACE_OPERATION | 0)
+#define GCD_ALLOCATE_IO_OPERATION (GCD_IO_SPACE_OPERATION | 1)
+#define GCD_FREE_IO_OPERATION (GCD_IO_SPACE_OPERATION | 2)
+#define GCD_REMOVE_IO_OPERATION (GCD_IO_SPACE_OPERATION | 3)
+
+//
+// The data structure used to convert from GCD attributes to EFI Memory Map attributes
+//
+typedef struct {
+ UINT64 Attribute;
+ UINT64 Capability;
+ BOOLEAN Memory;
+} GCD_ATTRIBUTE_CONVERSION_ENTRY;
+
+#endif
diff --git a/EDK/Foundation/Core/Dxe/Hand/DriverSupport.c b/EDK/Foundation/Core/Dxe/Hand/DriverSupport.c
new file mode 100644
index 0000000..0597475
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/Hand/DriverSupport.c
@@ -0,0 +1,860 @@
+/*++
+
+Copyright (c) 2004 - 2011, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ DriverSupport.c
+
+Abstract:
+
+ EFI Driver Support Protocol
+
+Revision History
+
+--*/
+
+#include "Tiano.h"
+#include "hand.h"
+#include "EfiPerf.h"
+
+
+//
+// Driver Consumed Protocol Prototypes
+//
+#include EFI_PROTOCOL_DEFINITION(DriverBinding)
+#include EFI_PROTOCOL_DEFINITION(PlatformDriverOverride)
+#include EFI_PROTOCOL_DEFINITION(BusSpecificDriverOverride)
+
+
+
+#ifdef FIRMWARE_PERFORMANCE
+STATIC
+EFI_STATUS
+GetHandleFromDriverBinding (
+ IN EFI_DRIVER_BINDING_PROTOCOL *DriverBindingNeed,
+ OUT EFI_HANDLE *Handle
+ );
+#endif
+
+//
+// Driver Support Function Prototypes
+//
+STATIC
+EFI_STATUS
+CoreConnectSingleController (
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE *DriverImageHandle OPTIONAL,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
+ );
+
+//
+// Driver Support Functions
+//
+
+EFI_BOOTSERVICE11
+EFI_STATUS
+EFIAPI
+CoreConnectController (
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE *DriverImageHandle OPTIONAL,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL,
+ IN BOOLEAN Recursive
+ )
+/*++
+
+Routine Description:
+
+ Connects one or more drivers to a controller.
+
+Arguments:
+
+ ControllerHandle - Handle of the controller to be connected.
+
+ DriverImageHandle - DriverImageHandle A pointer to an ordered list of driver image handles.
+
+ RemainingDevicePath - RemainingDevicePath A pointer to the device path that specifies a child of the
+ controller specified by ControllerHandle.
+
+ Recursive - Whether the function would be called recursively or not.
+
+Returns:
+
+ Status code.
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_STATUS ReturnStatus;
+ IHANDLE *Handle;
+ PROTOCOL_INTERFACE *Prot;
+ EFI_LIST_ENTRY *Link;
+ EFI_LIST_ENTRY *ProtLink;
+ OPEN_PROTOCOL_DATA *OpenData;
+ EFI_DEVICE_PATH_PROTOCOL *AlignedRemainingDevicePath;
+
+ //
+ // Make sure ControllerHandle is valid
+ //
+ Status = CoreValidateHandle (ControllerHandle);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Handle = ControllerHandle;
+
+ //
+ // Connect all drivers to ControllerHandle
+ //
+ AlignedRemainingDevicePath = NULL;
+ if (RemainingDevicePath != NULL) {
+ AlignedRemainingDevicePath = CoreDuplicateDevicePath (RemainingDevicePath);
+ }
+ ReturnStatus = CoreConnectSingleController (
+ ControllerHandle,
+ DriverImageHandle,
+ AlignedRemainingDevicePath
+ );
+ if (AlignedRemainingDevicePath != NULL) {
+ CoreFreePool (AlignedRemainingDevicePath);
+ }
+
+ //
+ // If not recursive, then just return after connecting drivers to ControllerHandle
+ //
+ if (!Recursive) {
+ return ReturnStatus;
+ }
+
+ //
+ // If recursive, then connect all drivers to all of ControllerHandle's children
+ //
+ CoreAcquireProtocolLock ();
+ for (Link = Handle->Protocols.ForwardLink; Link != &Handle->Protocols; Link = Link->ForwardLink) {
+ Prot = CR(Link, PROTOCOL_INTERFACE, Link, PROTOCOL_INTERFACE_SIGNATURE);
+ for (ProtLink = Prot->OpenList.ForwardLink;
+ ProtLink != &Prot->OpenList;
+ ProtLink = ProtLink->ForwardLink) {
+ OpenData = CR (ProtLink, OPEN_PROTOCOL_DATA, Link, OPEN_PROTOCOL_DATA_SIGNATURE);
+ if ((OpenData->Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) {
+ CoreReleaseProtocolLock ();
+ Status = CoreConnectController (
+ OpenData->ControllerHandle,
+ NULL,
+ NULL,
+ TRUE
+ );
+ CoreAcquireProtocolLock ();
+ }
+ }
+ }
+ CoreReleaseProtocolLock ();
+
+ return ReturnStatus;
+}
+
+VOID
+AddSortedDriverBindingProtocol (
+ IN EFI_HANDLE DriverBindingHandle,
+ IN OUT UINTN *NumberOfSortedDriverBindingProtocols,
+ IN OUT EFI_DRIVER_BINDING_PROTOCOL **SortedDriverBindingProtocols,
+ IN UINTN DriverBindingHandleCount,
+ IN OUT EFI_HANDLE *DriverBindingHandleBuffer
+ )
+/*++
+
+Routine Description:
+
+ Add Driver Binding Protocols from Context Driver Image Handles to sorted
+ Driver Binding Protocol list.
+
+Arguments:
+
+ DriverBindingHandle - Handle of the driver binding protocol.
+
+ NumberOfSortedDriverBindingProtocols - Number Of sorted driver binding protocols
+
+ SortedDriverBindingProtocols - The sorted protocol list.
+
+ DriverBindingHandleCount - Driver Binding Handle Count.
+
+ DriverBindingHandleBuffer - The buffer of driver binding protocol to be modified.
+
+Returns:
+
+ None.
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_DRIVER_BINDING_PROTOCOL *DriverBinding;
+ UINTN Index;
+
+ //
+ // Make sure the DriverBindingHandle is valid
+ //
+ Status = CoreValidateHandle (DriverBindingHandle);
+ if (EFI_ERROR (Status)) {
+ return;
+ }
+
+ //
+ // Retrieve the Driver Binding Protocol from DriverBindingHandle
+ //
+ Status = CoreHandleProtocol(
+ DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid,
+ &DriverBinding
+ );
+ //
+ // If DriverBindingHandle does not support the Driver Binding Protocol then return
+ //
+ if (EFI_ERROR (Status) || DriverBinding == NULL) {
+ return;
+ }
+
+ //
+ // See if DriverBinding is already in the sorted list
+ //
+ for (Index = 0; Index < *NumberOfSortedDriverBindingProtocols; Index++) {
+ if (DriverBinding == SortedDriverBindingProtocols[Index]) {
+ return;
+ }
+ }
+
+ //
+ // Add DriverBinding to the end of the list
+ //
+ SortedDriverBindingProtocols[*NumberOfSortedDriverBindingProtocols] = DriverBinding;
+ *NumberOfSortedDriverBindingProtocols = *NumberOfSortedDriverBindingProtocols + 1;
+
+ //
+ // Mark the cooresponding handle in DriverBindingHandleBuffer as used
+ //
+ for (Index = 0; Index < DriverBindingHandleCount; Index++) {
+ if (DriverBindingHandleBuffer[Index] == DriverBindingHandle) {
+ DriverBindingHandleBuffer[Index] = NULL;
+ }
+ }
+}
+
+STATIC
+EFI_STATUS
+CoreConnectSingleController (
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE *ContextDriverImageHandles OPTIONAL,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
+ )
+/*++
+
+Routine Description:
+
+ Connects a controller to a driver.
+
+Arguments:
+
+ ControllerHandle - Handle of the controller to be connected.
+ ContextDriverImageHandles - DriverImageHandle A pointer to an ordered list of driver image handles.
+ RemainingDevicePath - RemainingDevicePath A pointer to the device path that specifies a child
+ of the controller specified by ControllerHandle.
+
+Returns:
+
+ EFI_SUCCESS - One or more drivers were connected to ControllerHandle.
+ EFI_OUT_OF_RESOURCES - No enough system resources to complete the request.
+ EFI_NOT_FOUND - No drivers were connected to ControllerHandle.
+
+--*/
+{
+ EFI_STATUS Status;
+ UINTN Index;
+ EFI_HANDLE DriverImageHandle;
+ UINTN PlatformDriverOverrideHandleCount;
+ EFI_HANDLE *PlatformDriverOverrideHandleBuffer;
+ EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL *PlatformDriverOverride;
+ EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL *BusSpecificDriverOverride;
+ UINTN DriverBindingHandleCount;
+ EFI_HANDLE *DriverBindingHandleBuffer;
+ EFI_DRIVER_BINDING_PROTOCOL *DriverBinding;
+ UINTN NumberOfSortedDriverBindingProtocols;
+ EFI_DRIVER_BINDING_PROTOCOL **SortedDriverBindingProtocols;
+ UINT32 HighestVersion;
+ UINTN HighestIndex;
+ UINTN SortIndex;
+ BOOLEAN OneStarted;
+ BOOLEAN DriverFound;
+
+#ifdef FIRMWARE_PERFORMANCE
+ EFI_HANDLE DriverBindingHandle;
+#endif
+
+ //
+ // Initialize local variables
+ //
+ DriverBindingHandleCount = 0;
+ DriverBindingHandleBuffer = NULL;
+ PlatformDriverOverrideHandleCount = 0;
+ PlatformDriverOverrideHandleBuffer = NULL;
+ NumberOfSortedDriverBindingProtocols = 0;
+ SortedDriverBindingProtocols = NULL;
+
+ //
+ // Get list of all Driver Binding Protocol Instances
+ //
+ Status = CoreLocateHandleBuffer (
+ ByProtocol,
+ &gEfiDriverBindingProtocolGuid,
+ NULL,
+ &DriverBindingHandleCount,
+ &DriverBindingHandleBuffer
+ );
+ if (EFI_ERROR (Status) || (DriverBindingHandleCount == 0)) {
+ return EFI_NOT_FOUND;
+ }
+
+ //
+ // Allocate a duplicate array for the sorted Driver Binding Protocol Instances
+ //
+ SortedDriverBindingProtocols = CoreAllocateBootServicesPool (sizeof (VOID *) * DriverBindingHandleCount);
+ if (SortedDriverBindingProtocols == NULL) {
+ CoreFreePool (DriverBindingHandleBuffer);
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ //
+ // Add Driver Binding Protocols from Context Driver Image Handles first
+ //
+ if (ContextDriverImageHandles != NULL) {
+ for (Index = 0; ContextDriverImageHandles[Index] != NULL; Index++) {
+ AddSortedDriverBindingProtocol (
+ ContextDriverImageHandles[Index],
+ &NumberOfSortedDriverBindingProtocols,
+ SortedDriverBindingProtocols,
+ DriverBindingHandleCount,
+ DriverBindingHandleBuffer
+ );
+ }
+ }
+
+ //
+ // Add the Platform Driver Override Protocol drivers for ControllerHandle next
+ //
+ Status = CoreLocateProtocol (
+ &gEfiPlatformDriverOverrideProtocolGuid,
+ NULL,
+ &PlatformDriverOverride
+ );
+ if (!EFI_ERROR (Status) && (PlatformDriverOverride != NULL)) {
+ DriverImageHandle = NULL;
+ do {
+ Status = PlatformDriverOverride->GetDriver (
+ PlatformDriverOverride,
+ ControllerHandle,
+ &DriverImageHandle
+ );
+ if (!EFI_ERROR (Status)) {
+ AddSortedDriverBindingProtocol (
+ DriverImageHandle,
+ &NumberOfSortedDriverBindingProtocols,
+ SortedDriverBindingProtocols,
+ DriverBindingHandleCount,
+ DriverBindingHandleBuffer
+ );
+ }
+ } while (!EFI_ERROR (Status));
+ }
+
+ //
+ // Get the Bus Specific Driver Override Protocol instance on the Controller Handle
+ //
+ Status = CoreHandleProtocol(
+ ControllerHandle,
+ &gEfiBusSpecificDriverOverrideProtocolGuid,
+ &BusSpecificDriverOverride
+ );
+ if (!EFI_ERROR (Status) && (BusSpecificDriverOverride != NULL)) {
+ DriverImageHandle = NULL;
+ do {
+ Status = BusSpecificDriverOverride->GetDriver (
+ BusSpecificDriverOverride,
+ &DriverImageHandle
+ );
+ if (!EFI_ERROR (Status)) {
+ AddSortedDriverBindingProtocol (
+ DriverImageHandle,
+ &NumberOfSortedDriverBindingProtocols,
+ SortedDriverBindingProtocols,
+ DriverBindingHandleCount,
+ DriverBindingHandleBuffer
+ );
+ }
+ } while (!EFI_ERROR (Status));
+ }
+
+ //
+ // Then add all the remaining Driver Binding Protocols
+ //
+ SortIndex = NumberOfSortedDriverBindingProtocols;
+ for (Index = 0; Index < DriverBindingHandleCount; Index++) {
+ AddSortedDriverBindingProtocol (
+ DriverBindingHandleBuffer[Index],
+ &NumberOfSortedDriverBindingProtocols,
+ SortedDriverBindingProtocols,
+ DriverBindingHandleCount,
+ DriverBindingHandleBuffer
+ );
+ }
+
+ //
+ // Free the Driver Binding Handle Buffer
+ //
+ CoreFreePool (DriverBindingHandleBuffer);
+
+ //
+ // Sort the remaining DriverBinding Protocol based on their Version field from
+ // highest to lowest.
+ //
+ for ( ; SortIndex < DriverBindingHandleCount; SortIndex++) {
+ HighestVersion = SortedDriverBindingProtocols[SortIndex]->Version;
+ HighestIndex = SortIndex;
+ for (Index = SortIndex + 1; Index < DriverBindingHandleCount; Index++) {
+ if (SortedDriverBindingProtocols[Index]->Version > HighestVersion) {
+ HighestVersion = SortedDriverBindingProtocols[Index]->Version;
+ HighestIndex = Index;
+ }
+ }
+ if (SortIndex != HighestIndex) {
+ DriverBinding = SortedDriverBindingProtocols[SortIndex];
+ SortedDriverBindingProtocols[SortIndex] = SortedDriverBindingProtocols[HighestIndex];
+ SortedDriverBindingProtocols[HighestIndex] = DriverBinding;
+ }
+ }
+
+ //
+ // Loop until no more drivers can be started on ControllerHandle
+ //
+ OneStarted = FALSE;
+ do {
+
+ //
+ // Loop through the sorted Driver Binding Protocol Instances in order, and see if
+ // any of the Driver Binding Protocols support the controller specified by
+ // ControllerHandle.
+ //
+ DriverBinding = NULL;
+ DriverFound = FALSE;
+ for (Index = 0; (Index < NumberOfSortedDriverBindingProtocols) && !DriverFound; Index++) {
+ if (SortedDriverBindingProtocols[Index] != NULL) {
+ DriverBinding = SortedDriverBindingProtocols[Index];
+ Status = DriverBinding->Supported(
+ DriverBinding,
+ ControllerHandle,
+ RemainingDevicePath
+ );
+ if (!EFI_ERROR (Status)) {
+ SortedDriverBindingProtocols[Index] = NULL;
+ DriverFound = TRUE;
+
+ //
+ // A driver was found that supports ControllerHandle, so attempt to start the driver
+ // on ControllerHandle.
+ //
+
+#ifdef FIRMWARE_PERFORMANCE
+ GetHandleFromDriverBinding (DriverBinding, &DriverBindingHandle);
+#endif
+
+ PERF_START (DriverBindingHandle, DRIVERBINDING_START_TOK, NULL, 0);
+ Status = DriverBinding->Start (
+ DriverBinding,
+ ControllerHandle,
+ RemainingDevicePath
+ );
+ PERF_END (DriverBindingHandle, DRIVERBINDING_START_TOK, NULL, 0);
+
+ if (!EFI_ERROR (Status)) {
+ //
+ // The driver was successfully started on ControllerHandle, so set a flag
+ //
+ OneStarted = TRUE;
+ }
+ }
+ }
+ }
+ } while (DriverFound);
+
+ //
+ // Free any buffers that were allocated with AllocatePool()
+ //
+ CoreFreePool (SortedDriverBindingProtocols);
+
+ //
+ // If at least one driver was started on ControllerHandle, then return EFI_SUCCESS.
+ //
+ if (OneStarted) {
+ return EFI_SUCCESS;
+ }
+
+ //
+ // If no drivers started and RemainingDevicePath is an End Device Path Node, then return EFI_SUCCESS
+ //
+ if (RemainingDevicePath != NULL) {
+ if (IsDevicePathEnd (RemainingDevicePath)) {
+ return EFI_SUCCESS;
+ }
+ }
+
+ //
+ // Otherwise, no drivers were started on ControllerHandle, so return EFI_NOT_FOUND
+ //
+ return EFI_NOT_FOUND;
+}
+
+EFI_BOOTSERVICE11
+EFI_STATUS
+EFIAPI
+CoreDisconnectController (
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE DriverImageHandle OPTIONAL,
+ IN EFI_HANDLE ChildHandle OPTIONAL
+ )
+/*++
+
+Routine Description:
+
+ Disonnects a controller from a driver
+
+Arguments:
+
+ ControllerHandle - ControllerHandle The handle of the controller from which driver(s)
+ are to be disconnected.
+ DriverImageHandle - DriverImageHandle The driver to disconnect from ControllerHandle.
+ ChildHandle - ChildHandle The handle of the child to destroy.
+
+Returns:
+
+ EFI_SUCCESS - One or more drivers were disconnected from the controller.
+ EFI_SUCCESS - On entry, no drivers are managing ControllerHandle.
+ EFI_SUCCESS - DriverImageHandle is not NULL, and on entry DriverImageHandle is not managing ControllerHandle.
+ EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.
+ EFI_INVALID_PARAMETER - DriverImageHandle is not NULL, and it is not a valid EFI_HANDLE.
+ EFI_INVALID_PARAMETER - ChildHandle is not NULL, and it is not a valid EFI_HANDLE.
+ EFI_OUT_OF_RESOURCES - There are not enough resources available to disconnect any drivers from ControllerHandle.
+ EFI_DEVICE_ERROR - The controller could not be disconnected because of a device error.
+
+--*/
+{
+ EFI_STATUS Status;
+ IHANDLE *Handle;
+ EFI_HANDLE *DriverImageHandleBuffer;
+ EFI_HANDLE *ChildBuffer;
+ UINTN Index;
+ UINTN HandleIndex;
+ UINTN DriverImageHandleCount;
+ UINTN ChildrenToStop;
+ UINTN ChildBufferCount;
+ UINTN StopCount;
+ BOOLEAN Duplicate;
+ BOOLEAN ChildHandleValid;
+ BOOLEAN DriverImageHandleValid;
+ EFI_LIST_ENTRY *Link;
+ EFI_LIST_ENTRY *ProtLink;
+ OPEN_PROTOCOL_DATA *OpenData;
+ PROTOCOL_INTERFACE *Prot;
+ EFI_DRIVER_BINDING_PROTOCOL *DriverBinding;
+
+ //
+ // Make sure ControllerHandle is valid
+ //
+ Status = CoreValidateHandle (ControllerHandle);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ //
+ // Make sure ChildHandle is valid if it is not NULL
+ //
+ if (ChildHandle != NULL) {
+ Status = CoreValidateHandle (ChildHandle);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ }
+
+ Handle = ControllerHandle;
+
+ //
+ // Get list of drivers that are currently managing ControllerHandle
+ //
+ DriverImageHandleBuffer = NULL;
+ DriverImageHandleCount = 1;
+
+ if (DriverImageHandle == NULL) {
+ //
+ // Look at each protocol interface for a match
+ //
+ DriverImageHandleCount = 0;
+
+ CoreAcquireProtocolLock ();
+ for (Link = Handle->Protocols.ForwardLink; Link != &Handle->Protocols; Link = Link->ForwardLink) {
+ Prot = CR(Link, PROTOCOL_INTERFACE, Link, PROTOCOL_INTERFACE_SIGNATURE);
+ for (ProtLink = Prot->OpenList.ForwardLink;
+ ProtLink != &Prot->OpenList;
+ ProtLink = ProtLink->ForwardLink) {
+ OpenData = CR (ProtLink, OPEN_PROTOCOL_DATA, Link, OPEN_PROTOCOL_DATA_SIGNATURE);
+ if ((OpenData->Attributes & EFI_OPEN_PROTOCOL_BY_DRIVER) != 0) {
+ DriverImageHandleCount++;
+ }
+ }
+ }
+ CoreReleaseProtocolLock ();
+
+ //
+ // If there are no drivers managing this controller, then return EFI_SUCCESS
+ //
+ if (DriverImageHandleCount == 0) {
+ Status = EFI_SUCCESS;
+ goto Done;
+ }
+
+ DriverImageHandleBuffer = CoreAllocateBootServicesPool (sizeof (EFI_HANDLE) * DriverImageHandleCount);
+ if (DriverImageHandleBuffer == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Done;
+ }
+
+ DriverImageHandleCount = 0;
+
+ CoreAcquireProtocolLock ();
+ for (Link = Handle->Protocols.ForwardLink; Link != &Handle->Protocols; Link = Link->ForwardLink) {
+ Prot = CR(Link, PROTOCOL_INTERFACE, Link, PROTOCOL_INTERFACE_SIGNATURE);
+ for (ProtLink = Prot->OpenList.ForwardLink;
+ ProtLink != &Prot->OpenList;
+ ProtLink = ProtLink->ForwardLink) {
+ OpenData = CR (ProtLink, OPEN_PROTOCOL_DATA, Link, OPEN_PROTOCOL_DATA_SIGNATURE);
+ if ((OpenData->Attributes & EFI_OPEN_PROTOCOL_BY_DRIVER) != 0) {
+ Duplicate = FALSE;
+ for (Index = 0; Index< DriverImageHandleCount; Index++) {
+ if (DriverImageHandleBuffer[Index] == OpenData->AgentHandle) {
+ Duplicate = TRUE;
+ break;
+ }
+ }
+ if (!Duplicate) {
+ DriverImageHandleBuffer[DriverImageHandleCount] = OpenData->AgentHandle;
+ DriverImageHandleCount++;
+ }
+ }
+ }
+ }
+ CoreReleaseProtocolLock ();
+ }
+
+ StopCount = 0;
+ for (HandleIndex = 0; HandleIndex < DriverImageHandleCount; HandleIndex++) {
+
+ if (DriverImageHandleBuffer != NULL) {
+ DriverImageHandle = DriverImageHandleBuffer[HandleIndex];
+ }
+
+ //
+ // Get the Driver Binding Protocol of the driver that is managing this controller
+ //
+ Status = CoreHandleProtocol (
+ DriverImageHandle,
+ &gEfiDriverBindingProtocolGuid,
+ &DriverBinding
+ );
+ if (EFI_ERROR (Status) || (DriverBinding == NULL)) {
+ Status = EFI_INVALID_PARAMETER;
+ goto Done;
+ }
+
+ //
+ // Look at each protocol interface for a match
+ //
+ DriverImageHandleValid = FALSE;
+ ChildBufferCount = 0;
+
+ CoreAcquireProtocolLock ();
+ for (Link = Handle->Protocols.ForwardLink; Link != &Handle->Protocols; Link = Link->ForwardLink) {
+ Prot = CR(Link, PROTOCOL_INTERFACE, Link, PROTOCOL_INTERFACE_SIGNATURE);
+ for (ProtLink = Prot->OpenList.ForwardLink;
+ ProtLink != &Prot->OpenList;
+ ProtLink = ProtLink->ForwardLink) {
+ OpenData = CR (ProtLink, OPEN_PROTOCOL_DATA, Link, OPEN_PROTOCOL_DATA_SIGNATURE);
+ if (OpenData->AgentHandle == DriverImageHandle) {
+ if ((OpenData->Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) {
+ ChildBufferCount++;
+ }
+ if ((OpenData->Attributes & EFI_OPEN_PROTOCOL_BY_DRIVER) != 0) {
+ DriverImageHandleValid = TRUE;
+ }
+ }
+ }
+ }
+ CoreReleaseProtocolLock ();
+
+ if (DriverImageHandleValid) {
+ ChildHandleValid = FALSE;
+ ChildBuffer = NULL;
+ if (ChildBufferCount != 0) {
+ ChildBuffer = CoreAllocateBootServicesPool (sizeof (EFI_HANDLE) * ChildBufferCount);
+ if (ChildBuffer == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Done;
+ }
+
+ ChildBufferCount = 0;
+
+ CoreAcquireProtocolLock ();
+ for (Link = Handle->Protocols.ForwardLink; Link != &Handle->Protocols; Link = Link->ForwardLink) {
+ Prot = CR(Link, PROTOCOL_INTERFACE, Link, PROTOCOL_INTERFACE_SIGNATURE);
+ for (ProtLink = Prot->OpenList.ForwardLink;
+ ProtLink != &Prot->OpenList;
+ ProtLink = ProtLink->ForwardLink) {
+ OpenData = CR (ProtLink, OPEN_PROTOCOL_DATA, Link, OPEN_PROTOCOL_DATA_SIGNATURE);
+ if ((OpenData->AgentHandle == DriverImageHandle) &&
+ ((OpenData->Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0)) {
+ Duplicate = FALSE;
+ for (Index = 0; Index < ChildBufferCount; Index++) {
+ if (ChildBuffer[Index] == OpenData->ControllerHandle) {
+ Duplicate = TRUE;
+ break;
+ }
+ }
+ if (!Duplicate) {
+ ChildBuffer[ChildBufferCount] = OpenData->ControllerHandle;
+ if (ChildHandle == ChildBuffer[ChildBufferCount]) {
+ ChildHandleValid = TRUE;
+ }
+ ChildBufferCount++;
+ }
+ }
+ }
+ }
+ CoreReleaseProtocolLock ();
+ }
+
+ if (ChildHandle == NULL || ChildHandleValid) {
+ ChildrenToStop = 0;
+ Status = EFI_SUCCESS;
+ if (ChildBufferCount > 0) {
+ if (ChildHandle != NULL) {
+ ChildrenToStop = 1;
+ Status = DriverBinding->Stop (DriverBinding, ControllerHandle, ChildrenToStop, &ChildHandle);
+ } else {
+ ChildrenToStop = ChildBufferCount;
+ Status = DriverBinding->Stop (DriverBinding, ControllerHandle, ChildrenToStop, ChildBuffer);
+ }
+ }
+ if (!EFI_ERROR (Status) && ((ChildHandle == NULL) || (ChildBufferCount == ChildrenToStop))) {
+ Status = DriverBinding->Stop (DriverBinding, ControllerHandle, 0, NULL);
+ }
+ if (!EFI_ERROR (Status)) {
+ StopCount++;
+ }
+ }
+
+ if (ChildBuffer != NULL) {
+ CoreFreePool (ChildBuffer);
+ }
+ }
+ }
+
+ if (StopCount > 0) {
+ Status = EFI_SUCCESS;
+ } else {
+ Status = EFI_NOT_FOUND;
+ }
+
+Done:
+
+ if (DriverImageHandleBuffer != NULL) {
+ CoreFreePool (DriverImageHandleBuffer);
+ }
+
+ return Status;
+}
+
+
+
+#ifdef FIRMWARE_PERFORMANCE
+STATIC
+EFI_STATUS
+GetHandleFromDriverBinding (
+ IN EFI_DRIVER_BINDING_PROTOCOL *DriverBindingNeed,
+ OUT EFI_HANDLE *Handle
+ )
+/*++
+
+Routine Description:
+
+ Locate the driver binding handle which a specified driver binding protocol installed on.
+
+Arguments:
+
+ DriverBindingNeed - The specified driver binding protocol.
+
+ Handle - The driver binding handle which the protocol installed on.
+
+
+Returns:
+
+ EFI_NOT_FOUND - Could not find the handle.
+
+ EFI_SUCCESS - Successfully find the associated driver binding handle.
+
+--*/
+ {
+ EFI_STATUS Status ;
+ EFI_DRIVER_BINDING_PROTOCOL *DriverBinding;
+ UINTN DriverBindingHandleCount;
+ EFI_HANDLE *DriverBindingHandleBuffer;
+ UINTN Index;
+
+ DriverBindingHandleCount = 0;
+ DriverBindingHandleBuffer = NULL;
+ *Handle = NULL_HANDLE;
+ Status = gBS->LocateHandleBuffer (
+ ByProtocol,
+ &gEfiDriverBindingProtocolGuid,
+ NULL,
+ &DriverBindingHandleCount,
+ &DriverBindingHandleBuffer
+ );
+ if (EFI_ERROR (Status) || DriverBindingHandleCount == 0) {
+ return EFI_NOT_FOUND;
+ }
+
+ for (Index = 0 ; Index < DriverBindingHandleCount; Index++ ) {
+ Status = gBS->OpenProtocol(
+ DriverBindingHandleBuffer[Index],
+ &gEfiDriverBindingProtocolGuid,
+ &DriverBinding,
+ gDxeCoreImageHandle,
+ NULL,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
+
+ if (!EFI_ERROR (Status) && DriverBinding != NULL) {
+
+ if ( DriverBinding == DriverBindingNeed ) {
+ *Handle = DriverBindingHandleBuffer[Index];
+ CoreFreePool (DriverBindingHandleBuffer);
+ return EFI_SUCCESS ;
+ }
+ }
+ }
+
+ CoreFreePool (DriverBindingHandleBuffer);
+ return EFI_NOT_FOUND ;
+}
+#endif \ No newline at end of file
diff --git a/EDK/Foundation/Core/Dxe/Hand/Notify.c b/EDK/Foundation/Core/Dxe/Hand/Notify.c
new file mode 100644
index 0000000..8b12657
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/Hand/Notify.c
@@ -0,0 +1,335 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ notify.c
+
+Abstract:
+
+ EFI notify infrastructure
+
+
+
+Revision History
+
+--*/
+
+#include "hand.h"
+
+
+
+VOID
+CoreNotifyProtocolEntry (
+ IN PROTOCOL_ENTRY *ProtEntry
+ )
+/*++
+
+Routine Description:
+
+ Signal event for every protocol in protocol entry.
+
+Arguments:
+
+ ProtEntry - Protocol entry
+
+Returns:
+
+--*/
+{
+ PROTOCOL_NOTIFY *ProtNotify;
+ EFI_LIST_ENTRY *Link;
+
+ ASSERT_LOCKED (&gProtocolDatabaseLock);
+
+ for (Link=ProtEntry->Notify.ForwardLink; Link != &ProtEntry->Notify; Link=Link->ForwardLink) {
+ ProtNotify = CR(Link, PROTOCOL_NOTIFY, Link, PROTOCOL_NOTIFY_SIGNATURE);
+ CoreSignalEvent (ProtNotify->Event);
+ }
+}
+
+
+PROTOCOL_INTERFACE *
+CoreRemoveInterfaceFromProtocol (
+ IN IHANDLE *Handle,
+ IN EFI_GUID *Protocol,
+ IN VOID *Interface
+ )
+/*++
+
+Routine Description:
+
+ Removes Protocol from the protocol list (but not the handle list).
+
+Arguments:
+
+ Handle - The handle to remove protocol on.
+
+ Protocol - GUID of the protocol to be moved
+
+ Interface - The interface of the protocol
+
+Returns:
+
+ Protocol Entry
+
+--*/
+{
+ PROTOCOL_INTERFACE *Prot;
+ PROTOCOL_NOTIFY *ProtNotify;
+ PROTOCOL_ENTRY *ProtEntry;
+ EFI_LIST_ENTRY *Link;
+
+ ASSERT_LOCKED (&gProtocolDatabaseLock);
+
+ Prot = CoreFindProtocolInterface (Handle, Protocol, Interface);
+ if (Prot != NULL) {
+
+ ProtEntry = Prot->Protocol;
+
+ //
+ // If there's a protocol notify location pointing to this entry, back it up one
+ //
+
+ for(Link = ProtEntry->Notify.ForwardLink; Link != &ProtEntry->Notify; Link=Link->ForwardLink) {
+ ProtNotify = CR(Link, PROTOCOL_NOTIFY, Link, PROTOCOL_NOTIFY_SIGNATURE);
+
+ if (ProtNotify->Position == &Prot->ByProtocol) {
+ ProtNotify->Position = Prot->ByProtocol.BackLink;
+ }
+ }
+
+ //
+ // Remove the protocol interface entry
+ //
+
+ RemoveEntryList (&Prot->ByProtocol);
+ }
+
+ return Prot;
+}
+
+
+EFI_BOOTSERVICE
+EFI_STATUS
+EFIAPI
+CoreRegisterProtocolNotify (
+ IN EFI_GUID *Protocol,
+ IN EFI_EVENT Event,
+ OUT VOID **Registration
+ )
+/*++
+
+Routine Description:
+
+ Add a new protocol notification record for the request protocol.
+
+Arguments:
+
+ Protocol - The requested protocol to add the notify registration
+
+ Event - The event to signal
+
+ Registration - Returns the registration record
+
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Invalid parameter
+
+ EFI_SUCCESS - Successfully returned the registration record that has been added
+
+--*/
+{
+ PROTOCOL_ENTRY *ProtEntry;
+ PROTOCOL_NOTIFY *ProtNotify;
+ EFI_STATUS Status;
+
+ if ((Protocol == NULL) || (Event == NULL) || (Registration == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ CoreAcquireProtocolLock ();
+
+ ProtNotify = NULL;
+
+ //
+ // Get the protocol entry to add the notification too
+ //
+
+ ProtEntry = CoreFindProtocolEntry (Protocol, TRUE);
+ if (ProtEntry != NULL) {
+
+ //
+ // Allocate a new notification record
+ //
+
+ ProtNotify = CoreAllocateBootServicesPool (sizeof(PROTOCOL_NOTIFY));
+
+ if (ProtNotify != NULL) {
+
+ ProtNotify->Signature = PROTOCOL_NOTIFY_SIGNATURE;
+ ProtNotify->Protocol = ProtEntry;
+ ProtNotify->Event = Event;
+ //
+ // start at the begining
+ //
+ ProtNotify->Position = &ProtEntry->Protocols;
+
+ InsertTailList (&ProtEntry->Notify, &ProtNotify->Link);
+ }
+ }
+
+ CoreReleaseProtocolLock ();
+
+ //
+ // Done. If we have a protocol notify entry, then return it.
+ // Otherwise, we must have run out of resources trying to add one
+ //
+
+ Status = EFI_OUT_OF_RESOURCES;
+ if (ProtNotify != NULL) {
+ *Registration = ProtNotify;
+ Status = EFI_SUCCESS;
+ }
+
+ return Status;
+}
+
+
+EFI_BOOTSERVICE
+EFI_STATUS
+EFIAPI
+CoreReinstallProtocolInterface (
+ IN EFI_HANDLE UserHandle,
+ IN EFI_GUID *Protocol,
+ IN VOID *OldInterface,
+ IN VOID *NewInterface
+ )
+/*++
+
+Routine Description:
+
+ Reinstall a protocol interface on a device handle. The OldInterface for Protocol is replaced by the NewInterface.
+
+Arguments:
+
+ UserHandle - Handle on which the interface is to be reinstalled
+ Protocol - The numeric ID of the interface
+ OldInterface - A pointer to the old interface
+ NewInterface - A pointer to the new interface
+
+
+Returns:
+
+ Status code.
+
+ On EFI_SUCCESS The protocol interface was installed
+ On EFI_NOT_FOUND The OldInterface on the handle was not found
+ On EFI_INVALID_PARAMETER One of the parameters has an invalid value
+
+--*/
+{
+ EFI_STATUS Status;
+ IHANDLE *Handle;
+ PROTOCOL_INTERFACE *Prot;
+ PROTOCOL_ENTRY *ProtEntry;
+
+ Status = CoreValidateHandle (UserHandle);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ if (Protocol == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Handle = (IHANDLE *) UserHandle;
+
+ //
+ // Lock the protocol database
+ //
+ CoreAcquireProtocolLock ();
+
+ //
+ // Check that Protocol exists on UserHandle, and Interface matches the interface in the database
+ //
+ Prot = CoreFindProtocolInterface (UserHandle, Protocol, OldInterface);
+ if (Prot == NULL) {
+ CoreReleaseProtocolLock ();
+ return EFI_NOT_FOUND;
+ }
+
+ //
+ // Attempt to disconnect all drivers that are using the protocol interface that is about to be reinstalled
+ //
+ Status = CoreDisconnectControllersUsingProtocolInterface (
+ UserHandle,
+ Prot
+ );
+ if (EFI_ERROR (Status)) {
+ //
+ // One or more drivers refused to release, so return the error
+ //
+ CoreReleaseProtocolLock ();
+ return Status;
+ }
+
+ //
+ // Remove the protocol interface from the protocol
+ //
+ Prot = CoreRemoveInterfaceFromProtocol (Handle, Protocol, OldInterface);
+
+ if (Prot == NULL) {
+ CoreReleaseProtocolLock ();
+ return EFI_NOT_FOUND;
+ }
+
+ ProtEntry = Prot->Protocol;
+
+ //
+ // Update the interface on the protocol
+ //
+ Prot->Interface = NewInterface;
+
+ //
+ // Add this protocol interface to the tail of the
+ // protocol entry
+ //
+ InsertTailList (&ProtEntry->Protocols, &Prot->ByProtocol);
+
+ //
+ // Update the Key to show that the handle has been created/modified
+ //
+ gHandleDatabaseKey++;
+ Handle->Key = gHandleDatabaseKey;
+
+ //
+ // Release the lock and connect all drivers to UserHandle
+ //
+ CoreReleaseProtocolLock ();
+ Status = CoreConnectController (
+ UserHandle,
+ NULL,
+ NULL,
+ TRUE
+ );
+ CoreAcquireProtocolLock ();
+
+ //
+ // Notify the notification list for this protocol
+ //
+ CoreNotifyProtocolEntry (ProtEntry);
+
+ CoreReleaseProtocolLock ();
+
+ return EFI_SUCCESS;
+}
diff --git a/EDK/Foundation/Core/Dxe/Hand/hand.h b/EDK/Foundation/Core/Dxe/Hand/hand.h
new file mode 100644
index 0000000..d048073
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/Hand/hand.h
@@ -0,0 +1,339 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ hand.h
+
+Abstract:
+
+ EFI internal protocol definitions
+
+
+
+Revision History
+
+--*/
+
+#ifndef _HAND_H_
+#define _HAND_H_
+
+#include "Tiano.h"
+#include "DxeCore.h"
+
+//
+// IHANDLE - contains a list of protocol handles
+//
+
+#define EFI_HANDLE_SIGNATURE EFI_SIGNATURE_32('h','n','d','l')
+typedef struct {
+ UINTN Signature;
+ EFI_LIST_ENTRY AllHandles; // All handles list of IHANDLE
+ EFI_LIST_ENTRY Protocols; // List of PROTOCOL_INTERFACE's for this handle
+ UINTN LocateRequest; //
+ UINT64 Key; // The Handle Database Key value when this handle was last created or modified
+} IHANDLE;
+
+#define ASSERT_IS_HANDLE(a) ASSERT((a)->Signature == EFI_HANDLE_SIGNATURE)
+
+
+//
+// PROTOCOL_ENTRY - each different protocol has 1 entry in the protocol
+// database. Each handler that supports this protocol is listed, along
+// with a list of registered notifies.
+//
+
+#define PROTOCOL_ENTRY_SIGNATURE EFI_SIGNATURE_32('p','r','t','e')
+typedef struct {
+ UINTN Signature;
+ EFI_LIST_ENTRY AllEntries; // All entries
+ EFI_GUID ProtocolID; // ID of the protocol
+ EFI_LIST_ENTRY Protocols; // All protocol interfaces
+ EFI_LIST_ENTRY Notify; // Registerd notification handlers
+} PROTOCOL_ENTRY;
+
+//
+// PROTOCOL_INTERFACE - each protocol installed on a handle is tracked
+// with a protocol interface structure
+//
+
+#define PROTOCOL_INTERFACE_SIGNATURE EFI_SIGNATURE_32('p','i','f','c')
+typedef struct {
+ UINTN Signature;
+ EFI_HANDLE Handle; // Back pointer
+ EFI_LIST_ENTRY Link; // Link on IHANDLE.Protocols
+ EFI_LIST_ENTRY ByProtocol; // Link on PROTOCOL_ENTRY.Protocols
+ PROTOCOL_ENTRY *Protocol; // The protocol ID
+ VOID *Interface; // The interface value
+
+ EFI_LIST_ENTRY OpenList; // OPEN_PROTOCOL_DATA list.
+ UINTN OpenListCount;
+
+ EFI_HANDLE ControllerHandle;
+
+} PROTOCOL_INTERFACE;
+
+#define OPEN_PROTOCOL_DATA_SIGNATURE EFI_SIGNATURE_32('p','o','d','l')
+
+typedef struct {
+ UINTN Signature;
+ EFI_LIST_ENTRY Link;
+
+ EFI_HANDLE AgentHandle;
+ EFI_HANDLE ControllerHandle;
+ UINT32 Attributes;
+ UINT32 OpenCount;
+} OPEN_PROTOCOL_DATA;
+
+
+//
+// PROTOCOL_NOTIFY - used for each register notification for a protocol
+//
+
+#define PROTOCOL_NOTIFY_SIGNATURE EFI_SIGNATURE_32('p','r','t','n')
+typedef struct {
+ UINTN Signature;
+ PROTOCOL_ENTRY *Protocol;
+ EFI_LIST_ENTRY Link; // All notifications for this protocol
+ EFI_EVENT Event; // Event to notify
+ EFI_LIST_ENTRY *Position; // Last position notified
+} PROTOCOL_NOTIFY;
+
+//
+// Internal prototypes
+//
+
+
+PROTOCOL_ENTRY *
+CoreFindProtocolEntry (
+ IN EFI_GUID *Protocol,
+ IN BOOLEAN Create
+ )
+/*++
+
+Routine Description:
+
+ Finds the protocol entry for the requested protocol.
+
+ N.B. The gProtocolDatabaseLock must be owned
+
+Arguments:
+
+ Protocol - The ID of the protocol
+
+ Create - Create a new entry if not found
+
+Returns:
+
+ Protocol entry
+
+--*/
+;
+
+VOID
+CoreNotifyProtocolEntry (
+ IN PROTOCOL_ENTRY *ProtEntry
+ )
+/*++
+
+Routine Description:
+
+ Signal event for every protocol in protocol entry.
+
+Arguments:
+
+ ProtEntry - Protocol entry
+
+Returns:
+
+--*/
+;
+
+PROTOCOL_INTERFACE *
+CoreFindProtocolInterface (
+ IN IHANDLE *Handle,
+ IN EFI_GUID *Protocol,
+ IN VOID *Interface
+ )
+/*++
+
+Routine Description:
+
+ Finds the protocol instance for the requested handle and protocol.
+
+ Note: This function doesn't do parameters checking, it's caller's responsibility
+ to pass in valid parameters.
+
+Arguments:
+
+ Handle - The handle to search the protocol on
+
+ Protocol - GUID of the protocol
+
+ Interface - The interface for the protocol being searched
+
+Returns:
+
+ Protocol instance (NULL: Not found)
+
+--*/
+;
+
+PROTOCOL_INTERFACE *
+CoreRemoveInterfaceFromProtocol (
+ IN IHANDLE *Handle,
+ IN EFI_GUID *Protocol,
+ IN VOID *Interface
+ )
+/*++
+
+Routine Description:
+
+ Removes Protocol from the protocol list (but not the handle list).
+
+Arguments:
+
+ Handle - The handle to remove protocol on.
+
+ Protocol - GUID of the protocol to be moved
+
+ Interface - The interface of the protocol
+
+Returns:
+
+ Protocol Entry
+
+--*/
+;
+
+EFI_STATUS
+CoreUnregisterProtocolNotify (
+ IN EFI_EVENT Event
+ )
+/*++
+
+Routine Description:
+
+ Removes all the events in the protocol database that match Event.
+
+Arguments:
+
+ Event - The event to search for in the protocol database.
+
+Returns:
+
+ EFI_SUCCESS when done searching the entire database.
+
+--*/
+;
+
+EFI_STATUS
+CoreDisconnectControllersUsingProtocolInterface (
+ IN EFI_HANDLE UserHandle,
+ IN PROTOCOL_INTERFACE *Prot
+ )
+/*++
+
+Routine Description:
+
+ Attempts to disconnect all drivers that are using the protocol interface being queried.
+ If failed, reconnect all drivers disconnected.
+
+ Note: This function doesn't do parameters checking, it's caller's responsibility
+ to pass in valid parameters.
+
+Arguments:
+
+ UserHandle - The handle on which the protocol is installed
+ Prot - The protocol to disconnect drivers from
+
+Returns:
+
+ EFI_SUCCESS - Drivers using the protocol interface are all disconnected
+ EFI_ACCESS_DENIED - Failed to disconnect one or all of the drivers
+
+--*/
+;
+
+VOID
+CoreAcquireProtocolLock (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Acquire lock on gProtocolDatabaseLock.
+
+Arguments:
+
+ None
+
+Returns:
+
+ None
+
+--*/
+;
+
+VOID
+CoreReleaseProtocolLock (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Release lock on gProtocolDatabaseLock.
+
+Arguments:
+
+ None
+
+Returns:
+
+ None
+
+--*/
+;
+
+EFI_STATUS
+CoreValidateHandle (
+ IN EFI_HANDLE UserHandle
+ )
+/*++
+
+Routine Description:
+
+ Check whether a handle is a valid EFI_HANDLE
+
+Arguments:
+
+ UserHandle - The handle to check
+
+Returns:
+
+ EFI_INVALID_PARAMETER - The handle is NULL or not a valid EFI_HANDLE.
+
+ EFI_SUCCESS - The handle is valid EFI_HANDLE.
+
+--*/
+;
+
+//
+// Externs
+//
+
+extern EFI_LOCK gProtocolDatabaseLock;
+extern EFI_LIST_ENTRY gHandleList;
+extern UINT64 gHandleDatabaseKey;
+
+#endif
diff --git a/EDK/Foundation/Core/Dxe/Hand/handle.c b/EDK/Foundation/Core/Dxe/Hand/handle.c
new file mode 100644
index 0000000..45874b4
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/Hand/handle.c
@@ -0,0 +1,1716 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ handle.c
+
+Abstract:
+
+ EFI handle & protocol handling
+
+
+
+Revision History
+
+--*/
+
+#include "hand.h"
+#include EFI_PROTOCOL_DEFINITION (DevicePath)
+#include EFI_PROTOCOL_DEFINITION (LoadedImage)
+#include EFI_PROTOCOL_DEFINITION (DebugMask)
+
+//
+// mProtocolDatabase - A list of all protocols in the system. (simple list for now)
+// gHandleList - A list of all the handles in the system
+// gProtocolDatabaseLock - Lock to protect the mProtocolDatabase
+// gHandleDatabaseKey - The Key to show that the handle has been created/modified
+//
+static EFI_LIST_ENTRY mProtocolDatabase = INITIALIZE_LIST_HEAD_VARIABLE (mProtocolDatabase);
+EFI_LIST_ENTRY gHandleList = INITIALIZE_LIST_HEAD_VARIABLE (gHandleList);
+EFI_LOCK gProtocolDatabaseLock = EFI_INITIALIZE_LOCK_VARIABLE (EFI_TPL_NOTIFY);
+UINT64 gHandleDatabaseKey = 0;
+
+
+VOID
+CoreAcquireProtocolLock (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Acquire lock on gProtocolDatabaseLock.
+
+Arguments:
+
+ None
+
+Returns:
+
+ None
+
+--*/
+{
+ CoreAcquireLock (&gProtocolDatabaseLock);
+}
+
+
+VOID
+CoreReleaseProtocolLock (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Release lock on gProtocolDatabaseLock.
+
+Arguments:
+
+ None
+
+Returns:
+
+ None
+
+--*/
+{
+ CoreReleaseLock (&gProtocolDatabaseLock);
+}
+
+
+EFI_STATUS
+CoreValidateHandle (
+ IN EFI_HANDLE UserHandle
+ )
+/*++
+
+Routine Description:
+
+ Check whether a handle is a valid EFI_HANDLE
+
+Arguments:
+
+ UserHandle - The handle to check
+
+Returns:
+
+ EFI_INVALID_PARAMETER - The handle is NULL or not a valid EFI_HANDLE.
+
+ EFI_SUCCESS - The handle is valid EFI_HANDLE.
+
+--*/
+{
+ IHANDLE *Handle;
+
+ Handle = (IHANDLE *)UserHandle;
+ if (Handle == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+ if (Handle->Signature != EFI_HANDLE_SIGNATURE) {
+ return EFI_INVALID_PARAMETER;
+ }
+ return EFI_SUCCESS;
+}
+
+
+PROTOCOL_ENTRY *
+CoreFindProtocolEntry (
+ IN EFI_GUID *Protocol,
+ IN BOOLEAN Create
+ )
+/*++
+
+Routine Description:
+
+ Finds the protocol entry for the requested protocol.
+
+ N.B. The gProtocolDatabaseLock must be owned
+
+Arguments:
+
+ Protocol - The ID of the protocol
+
+ Create - Create a new entry if not found
+
+Returns:
+
+ Protocol entry
+
+--*/
+{
+ EFI_LIST_ENTRY *Link;
+ PROTOCOL_ENTRY *Item;
+ PROTOCOL_ENTRY *ProtEntry;
+
+ ASSERT_LOCKED(&gProtocolDatabaseLock);
+
+ //
+ // Search the database for the matching GUID
+ //
+
+ ProtEntry = NULL;
+ for (Link = mProtocolDatabase.ForwardLink;
+ Link != &mProtocolDatabase;
+ Link = Link->ForwardLink) {
+
+ Item = CR(Link, PROTOCOL_ENTRY, AllEntries, PROTOCOL_ENTRY_SIGNATURE);
+ if (EfiCompareGuid (&Item->ProtocolID, Protocol)) {
+
+ //
+ // This is the protocol entry
+ //
+
+ ProtEntry = Item;
+ break;
+ }
+ }
+
+ //
+ // If the protocol entry was not found and Create is TRUE, then
+ // allocate a new entry
+ //
+ if ((ProtEntry == NULL) && Create) {
+ ProtEntry = CoreAllocateBootServicesPool (sizeof(PROTOCOL_ENTRY));
+
+ if (ProtEntry != NULL) {
+ //
+ // Initialize new protocol entry structure
+ //
+ ProtEntry->Signature = PROTOCOL_ENTRY_SIGNATURE;
+ ProtEntry->ProtocolID = *Protocol;
+ InitializeListHead (&ProtEntry->Protocols);
+ InitializeListHead (&ProtEntry->Notify);
+
+ //
+ // Add it to protocol database
+ //
+ InsertTailList (&mProtocolDatabase, &ProtEntry->AllEntries);
+ }
+ }
+
+ return ProtEntry;
+}
+
+
+PROTOCOL_INTERFACE *
+CoreFindProtocolInterface (
+ IN IHANDLE *Handle,
+ IN EFI_GUID *Protocol,
+ IN VOID *Interface
+ )
+/*++
+
+Routine Description:
+
+ Finds the protocol instance for the requested handle and protocol.
+
+ Note: This function doesn't do parameters checking, it's caller's responsibility
+ to pass in valid parameters.
+
+Arguments:
+
+ Handle - The handle to search the protocol on
+
+ Protocol - GUID of the protocol
+
+ Interface - The interface for the protocol being searched
+
+Returns:
+
+ Protocol instance (NULL: Not found)
+
+--*/
+{
+ PROTOCOL_INTERFACE *Prot;
+ PROTOCOL_ENTRY *ProtEntry;
+ EFI_LIST_ENTRY *Link;
+
+ ASSERT_LOCKED(&gProtocolDatabaseLock);
+ Prot = NULL;
+
+ //
+ // Lookup the protocol entry for this protocol ID
+ //
+
+ ProtEntry = CoreFindProtocolEntry (Protocol, FALSE);
+ if (ProtEntry != NULL) {
+
+ //
+ // Look at each protocol interface for any matches
+ //
+ for (Link = Handle->Protocols.ForwardLink; Link != &Handle->Protocols; Link=Link->ForwardLink) {
+
+ //
+ // If this protocol interface matches, remove it
+ //
+ Prot = CR(Link, PROTOCOL_INTERFACE, Link, PROTOCOL_INTERFACE_SIGNATURE);
+ if (Prot->Interface == Interface && Prot->Protocol == ProtEntry) {
+ break;
+ }
+
+ Prot = NULL;
+ }
+ }
+
+ return Prot;
+}
+
+STATIC
+EFI_STATUS
+CoreUnregisterProtocolNotifyEvent (
+ IN EFI_EVENT Event
+ )
+/*++
+
+Routine Description:
+
+ Removes an event from a register protocol notify list on a protocol.
+
+Arguments:
+
+ Event - The event to search for in the protocol database.
+
+Returns:
+
+ EFI_SUCCESS if the event was found and removed.
+ EFI_NOT_FOUND if the event was not found in the protocl database.
+
+--*/
+{
+ EFI_LIST_ENTRY *Link;
+ PROTOCOL_ENTRY *ProtEntry;
+ EFI_LIST_ENTRY *NotifyLink;
+ PROTOCOL_NOTIFY *ProtNotify;
+
+ CoreAcquireProtocolLock ();
+
+ for ( Link = mProtocolDatabase.ForwardLink;
+ Link != &mProtocolDatabase;
+ Link = Link->ForwardLink) {
+
+ ProtEntry = CR(Link, PROTOCOL_ENTRY, AllEntries, PROTOCOL_ENTRY_SIGNATURE);
+
+ for ( NotifyLink = ProtEntry->Notify.ForwardLink;
+ NotifyLink != &ProtEntry->Notify;
+ NotifyLink = NotifyLink->ForwardLink) {
+
+ ProtNotify = CR(NotifyLink, PROTOCOL_NOTIFY, Link, PROTOCOL_NOTIFY_SIGNATURE);
+
+ if (ProtNotify->Event == Event) {
+ RemoveEntryList(&ProtNotify->Link);
+ CoreFreePool(ProtNotify);
+ CoreReleaseProtocolLock ();
+ return EFI_SUCCESS;
+ }
+ }
+ }
+
+ CoreReleaseProtocolLock ();
+ return EFI_NOT_FOUND;
+}
+
+
+EFI_STATUS
+CoreUnregisterProtocolNotify (
+ IN EFI_EVENT Event
+ )
+/*++
+
+Routine Description:
+
+ Removes all the events in the protocol database that match Event.
+
+Arguments:
+
+ Event - The event to search for in the protocol database.
+
+Returns:
+
+ EFI_SUCCESS when done searching the entire database.
+
+--*/
+{
+ EFI_STATUS Status;
+
+ do {
+ Status = CoreUnregisterProtocolNotifyEvent (Event);
+ } while (!EFI_ERROR (Status));
+
+ return EFI_SUCCESS;
+}
+
+
+EFI_BOOTSERVICE
+EFI_STATUS
+EFIAPI
+CoreInstallProtocolInterface (
+ IN OUT EFI_HANDLE *UserHandle,
+ IN EFI_GUID *Protocol,
+ IN EFI_INTERFACE_TYPE InterfaceType,
+ IN VOID *Interface
+ )
+/*++
+
+Routine Description:
+
+ Wrapper function to CoreInstallProtocolInterfaceNotify. This is the public API which
+ Calls the private one which contains a BOOLEAN parameter for notifications
+
+Arguments:
+
+ UserHandle - The handle to install the protocol handler on,
+ or NULL if a new handle is to be allocated
+
+ Protocol - The protocol to add to the handle
+
+ InterfaceType - Indicates whether Interface is supplied in native form.
+
+ Interface - The interface for the protocol being added
+
+Returns:
+
+ Status code
+
+--*/
+{
+ return CoreInstallProtocolInterfaceNotify (
+ UserHandle,
+ Protocol,
+ InterfaceType,
+ Interface,
+ TRUE
+ );
+}
+
+EFI_STATUS
+CoreInstallProtocolInterfaceNotify (
+ IN OUT EFI_HANDLE *UserHandle,
+ IN EFI_GUID *Protocol,
+ IN EFI_INTERFACE_TYPE InterfaceType,
+ IN VOID *Interface,
+ IN BOOLEAN Notify
+ )
+/*++
+
+Routine Description:
+
+ Installs a protocol interface into the boot services environment.
+
+Arguments:
+
+ UserHandle - The handle to install the protocol handler on,
+ or NULL if a new handle is to be allocated
+
+ Protocol - The protocol to add to the handle
+
+ InterfaceType - Indicates whether Interface is supplied in native form.
+
+ Interface - The interface for the protocol being added
+
+ Notify - indicates whether notify the notification list
+ for this protocol
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Invalid parameter
+
+ EFI_OUT_OF_RESOURCES - No enough buffer to allocate
+
+ EFI_SUCCESS - Protocol interface successfully installed
+
+--*/
+{
+ PROTOCOL_INTERFACE *Prot;
+ PROTOCOL_ENTRY *ProtEntry;
+ IHANDLE *Handle;
+ EFI_STATUS Status;
+ VOID *ExistingInterface;
+
+ DEBUG_CODE (
+ UINTN ErrorLevel;
+ )
+
+ //
+ // returns EFI_INVALID_PARAMETER if InterfaceType is invalid.
+ // Also added check for invalid UserHandle and Protocol pointers.
+ //
+ if (UserHandle == NULL || Protocol == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (InterfaceType != EFI_NATIVE_INTERFACE) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // Print debug message
+ //
+ DEBUG_CODE (
+ if (EfiCompareGuid (Protocol, &gEfiLoadedImageProtocolGuid) ||
+ EfiCompareGuid (Protocol, &gEfiDebugMaskProtocolGuid)) {
+ //
+ // Print these protocols only at EFI_D_INFO level, for cleaner log.
+ // They are installed for every DXE driver.
+ //
+ ErrorLevel = EFI_D_INFO;
+ } else {
+ ErrorLevel = EFI_D_ERROR;
+ }
+ DEBUG ((ErrorLevel, "InstallProtocolInterface: %g %x\n", Protocol, Interface));
+ )
+ Status = EFI_OUT_OF_RESOURCES;
+ Prot = NULL;
+ Handle = NULL;
+
+ ASSERT (NULL != gBS);
+
+ if (*UserHandle != NULL_HANDLE) {
+ Status = CoreHandleProtocol (*UserHandle, Protocol, (VOID **)&ExistingInterface);
+ if (!EFI_ERROR (Status)) {
+ return EFI_INVALID_PARAMETER;
+ }
+ }
+
+ //
+ // Lock the protocol database
+ //
+ CoreAcquireProtocolLock ();
+
+ //
+ // Lookup the Protocol Entry for the requested protocol
+ //
+ ProtEntry = CoreFindProtocolEntry (Protocol, TRUE);
+ if (ProtEntry == NULL) {
+ goto Done;
+ }
+
+ //
+ // Allocate a new protocol interface structure
+ //
+ Prot = CoreAllocateZeroBootServicesPool (sizeof(PROTOCOL_INTERFACE));
+ if (Prot == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Done;
+ }
+
+ //
+ // If caller didn't supply a handle, allocate a new one
+ //
+ Handle = (IHANDLE *)*UserHandle;
+ if (Handle == NULL) {
+ Handle = CoreAllocateZeroBootServicesPool (sizeof(IHANDLE));
+ if (Handle == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Done;
+ }
+
+ //
+ // Initialize new handler structure
+ //
+ Handle->Signature = EFI_HANDLE_SIGNATURE;
+ InitializeListHead (&Handle->Protocols);
+
+ //
+ // Initialize the Key to show that the handle has been created/modified
+ //
+ gHandleDatabaseKey++;
+ Handle->Key = gHandleDatabaseKey;
+
+ //
+ // Add this handle to the list global list of all handles
+ // in the system
+ //
+ InsertTailList (&gHandleList, &Handle->AllHandles);
+ }
+
+ Status = CoreValidateHandle (Handle);
+ if (EFI_ERROR (Status)) {
+ goto Done;
+ }
+
+ //
+ // Each interface that is added must be unique
+ //
+ ASSERT (CoreFindProtocolInterface (Handle, Protocol, Interface) == NULL);
+
+ //
+ // Initialize the protocol interface structure
+ //
+ Prot->Signature = PROTOCOL_INTERFACE_SIGNATURE;
+ Prot->Handle = Handle;
+ Prot->Protocol = ProtEntry;
+ Prot->Interface = Interface;
+
+ //
+ // Initalize OpenProtocol Data base
+ //
+ InitializeListHead (&Prot->OpenList);
+ Prot->OpenListCount = 0;
+
+ //
+ // Add this protocol interface to the head of the supported
+ // protocol list for this handle
+ //
+ InsertHeadList (&Handle->Protocols, &Prot->Link);
+
+ //
+ // Add this protocol interface to the tail of the
+ // protocol entry
+ //
+ InsertTailList (&ProtEntry->Protocols, &Prot->ByProtocol);
+
+ //
+ // Notify the notification list for this protocol
+ //
+ if (Notify) {
+ CoreNotifyProtocolEntry (ProtEntry);
+ }
+ Status = EFI_SUCCESS;
+
+Done:
+ //
+ // Done, unlock the database and return
+ //
+ CoreReleaseProtocolLock ();
+ if (!EFI_ERROR (Status)) {
+ //
+ // Return the new handle back to the caller
+ //
+ *UserHandle = Handle;
+ } else {
+ //
+ // There was an error, clean up
+ //
+ if (Prot != NULL) {
+ CoreFreePool (Prot);
+ }
+ }
+
+ return Status;
+}
+
+
+EFI_BOOTSERVICE11
+EFI_STATUS
+EFIAPI
+CoreInstallMultipleProtocolInterfaces (
+ IN OUT EFI_HANDLE *Handle,
+ ...
+ )
+/*++
+
+Routine Description:
+
+ Installs a list of protocol interface into the boot services environment.
+ This function calls InstallProtocolInterface() in a loop. If any error
+ occures all the protocols added by this function are removed. This is
+ basically a lib function to save space.
+
+Arguments:
+
+ Handle - The handle to install the protocol handlers on,
+ or NULL if a new handle is to be allocated
+ ... - EFI_GUID followed by protocol instance. A NULL terminates the
+ list. The pairs are the arguments to InstallProtocolInterface().
+ All the protocols are added to Handle.
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Handle is NULL.
+
+ EFI_SUCCESS - Protocol interfaces successfully installed.
+
+--*/
+{
+ VA_LIST args;
+ EFI_STATUS Status;
+ EFI_GUID *Protocol;
+ VOID *Interface;
+ EFI_TPL OldTpl;
+ UINTN Index;
+ EFI_HANDLE OldHandle;
+ EFI_HANDLE DeviceHandle;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+
+ if (Handle == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // Syncronize with notifcations.
+ //
+ OldTpl = CoreRaiseTpl (EFI_TPL_NOTIFY);
+ OldHandle = *Handle;
+
+ //
+ // Check for duplicate device path and install the protocol interfaces
+ //
+ VA_START (args, Handle);
+ for (Index = 0, Status = EFI_SUCCESS; !EFI_ERROR (Status); Index++) {
+ //
+ // If protocol is NULL, then it's the end of the list
+ //
+ Protocol = VA_ARG (args, EFI_GUID *);
+ if (Protocol == NULL) {
+ break;
+ }
+
+ Interface = VA_ARG (args, VOID *);
+
+ //
+ // Make sure you are installing on top a device path that has already been added.
+ //
+ if (EfiCompareGuid (Protocol, &gEfiDevicePathProtocolGuid)) {
+ DeviceHandle = NULL;
+ DevicePath = Interface;
+ Status = CoreLocateDevicePath (&gEfiDevicePathProtocolGuid, &DevicePath, &DeviceHandle);
+ if (!EFI_ERROR (Status) && (DeviceHandle != NULL_HANDLE) && IsDevicePathEnd(DevicePath)) {
+ Status = EFI_ALREADY_STARTED;
+ continue;
+ }
+ }
+
+ //
+ // Install it
+ //
+ Status = CoreInstallProtocolInterface (Handle, Protocol, EFI_NATIVE_INTERFACE, Interface);
+ }
+
+ //
+ // If there was an error, remove all the interfaces that were installed without any errors
+ //
+ if (EFI_ERROR (Status)) {
+ //
+ // Reset the va_arg back to the first argument.
+ //
+ VA_START (args, Handle);
+ for (; Index > 1; Index--) {
+ Protocol = VA_ARG (args, EFI_GUID *);
+ Interface = VA_ARG (args, VOID *);
+ CoreUninstallProtocolInterface (*Handle, Protocol, Interface);
+ }
+ *Handle = OldHandle;
+ }
+
+ //
+ // Done
+ //
+ CoreRestoreTpl (OldTpl);
+ return Status;
+}
+
+EFI_STATUS
+CoreDisconnectControllersUsingProtocolInterface (
+ IN EFI_HANDLE UserHandle,
+ IN PROTOCOL_INTERFACE *Prot
+ )
+/*++
+
+Routine Description:
+
+ Attempts to disconnect all drivers that are using the protocol interface being queried.
+ If failed, reconnect all drivers disconnected.
+
+ Note: This function doesn't do parameters checking, it's caller's responsibility
+ to pass in valid parameters.
+
+Arguments:
+
+ UserHandle - The handle on which the protocol is installed
+ Prot - The protocol to disconnect drivers from
+
+Returns:
+
+ EFI_SUCCESS - Drivers using the protocol interface are all disconnected
+ EFI_ACCESS_DENIED - Failed to disconnect one or all of the drivers
+
+--*/
+{
+ EFI_STATUS Status;
+ BOOLEAN ItemFound;
+ EFI_LIST_ENTRY *Link;
+ OPEN_PROTOCOL_DATA *OpenData;
+
+ Status = EFI_SUCCESS;
+
+ //
+ // Attempt to disconnect all drivers from this protocol interface
+ //
+ do {
+ ItemFound = FALSE;
+ for ( Link = Prot->OpenList.ForwardLink;
+ (Link != &Prot->OpenList) && !ItemFound;
+ Link = Link->ForwardLink ) {
+ OpenData = CR (Link, OPEN_PROTOCOL_DATA, Link, OPEN_PROTOCOL_DATA_SIGNATURE);
+ if (OpenData->Attributes & EFI_OPEN_PROTOCOL_BY_DRIVER) {
+ ItemFound = TRUE;
+ CoreReleaseProtocolLock ();
+ Status = CoreDisconnectController (UserHandle, OpenData->AgentHandle, NULL);
+ CoreAcquireProtocolLock ();
+ if (EFI_ERROR (Status)) {
+ ItemFound = FALSE;
+ break;
+ }
+ }
+ }
+ } while (ItemFound);
+
+ if (!EFI_ERROR (Status)) {
+ //
+ // Attempt to remove BY_HANDLE_PROTOOCL and GET_PROTOCOL and TEST_PROTOCOL Open List items
+ //
+ do {
+ ItemFound = FALSE;
+ for ( Link = Prot->OpenList.ForwardLink;
+ (Link != &Prot->OpenList) && !ItemFound;
+ Link = Link->ForwardLink ) {
+ OpenData = CR (Link, OPEN_PROTOCOL_DATA, Link, OPEN_PROTOCOL_DATA_SIGNATURE);
+ if (OpenData->Attributes &
+ (EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL | EFI_OPEN_PROTOCOL_GET_PROTOCOL | EFI_OPEN_PROTOCOL_TEST_PROTOCOL)) {
+ ItemFound = TRUE;
+ RemoveEntryList (&OpenData->Link);
+ Prot->OpenListCount--;
+ CoreFreePool (OpenData);
+ }
+ }
+ } while (ItemFound);
+ }
+
+ //
+ // If there are errors or still has open items in the list, then reconnect all the drivers and return an error
+ //
+ if (EFI_ERROR (Status) || (Prot->OpenListCount > 0)) {
+ CoreReleaseProtocolLock ();
+ CoreConnectController (UserHandle, NULL, NULL, TRUE);
+ CoreAcquireProtocolLock ();
+ Status = EFI_ACCESS_DENIED;
+ }
+
+ return Status;
+}
+
+EFI_BOOTSERVICE
+EFI_STATUS
+EFIAPI
+CoreUninstallProtocolInterface (
+ IN EFI_HANDLE UserHandle,
+ IN EFI_GUID *Protocol,
+ IN VOID *Interface
+ )
+/*++
+
+Routine Description:
+
+ Uninstalls all instances of a protocol:interfacer from a handle.
+ If the last protocol interface is remove from the handle, the
+ handle is freed.
+
+Arguments:
+
+ UserHandle - The handle to remove the protocol handler from
+
+ Protocol - The protocol, of protocol:interface, to remove
+
+ Interface - The interface, of protocol:interface, to remove
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Protocol is NULL.
+
+ EFI_SUCCESS - Protocol interface successfully uninstalled.
+
+--*/
+{
+ EFI_STATUS Status;
+ IHANDLE *Handle;
+ PROTOCOL_INTERFACE *Prot;
+
+ //
+ // Check that Protocol is valid
+ //
+ if (Protocol == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // Check that UserHandle is a valid handle
+ //
+ Status = CoreValidateHandle (UserHandle);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ //
+ // Lock the protocol database
+ //
+ CoreAcquireProtocolLock ();
+
+ //
+ // Check that Protocol exists on UserHandle, and Interface matches the interface in the database
+ //
+ Prot = CoreFindProtocolInterface (UserHandle, Protocol, Interface);
+ if (Prot == NULL) {
+ Status = EFI_NOT_FOUND;
+ goto Done;
+ }
+
+ //
+ // Attempt to disconnect all drivers that are using the protocol interface that is about to be removed
+ //
+ Status = CoreDisconnectControllersUsingProtocolInterface (
+ UserHandle,
+ Prot
+ );
+ if (EFI_ERROR (Status)) {
+ //
+ // One or more drivers refused to release, so return the error
+ //
+ goto Done;
+ }
+
+ //
+ // Remove the protocol interface from the protocol
+ //
+ Status = EFI_NOT_FOUND;
+ Handle = (IHANDLE *)UserHandle;
+ Prot = CoreRemoveInterfaceFromProtocol (Handle, Protocol, Interface);
+
+ if (Prot != NULL) {
+ //
+ // Update the Key to show that the handle has been created/modified
+ //
+ gHandleDatabaseKey++;
+ Handle->Key = gHandleDatabaseKey;
+
+ //
+ // Remove the protocol interface from the handle
+ //
+ RemoveEntryList (&Prot->Link);
+
+ //
+ // Free the memory
+ //
+ Prot->Signature = 0;
+ CoreFreePool (Prot);
+ Status = EFI_SUCCESS;
+ }
+
+ //
+ // If there are no more handlers for the handle, free the handle
+ //
+ if (IsListEmpty (&Handle->Protocols)) {
+ Handle->Signature = 0;
+ RemoveEntryList (&Handle->AllHandles);
+ CoreFreePool (Handle);
+ }
+
+Done:
+ //
+ // Done, unlock the database and return
+ //
+ CoreReleaseProtocolLock ();
+ return Status;
+}
+
+
+EFI_BOOTSERVICE11
+EFI_STATUS
+EFIAPI
+CoreUninstallMultipleProtocolInterfaces (
+ IN EFI_HANDLE Handle,
+ ...
+ )
+/*++
+
+Routine Description:
+
+ Uninstalls a list of protocol interface in the boot services environment.
+ This function calls UnisatllProtocolInterface() in a loop. This is
+ basically a lib function to save space.
+
+Arguments:
+
+ Handle - The handle to uninstall the protocol
+
+ ... - EFI_GUID followed by protocol instance. A NULL terminates the
+ list. The pairs are the arguments to UninstallProtocolInterface().
+ All the protocols are added to Handle.
+
+Returns:
+
+ Status code
+
+--*/
+{
+ EFI_STATUS Status;
+ VA_LIST args;
+ EFI_GUID *Protocol;
+ VOID *Interface;
+ UINTN Index;
+
+ VA_START (args, Handle);
+ for (Index = 0, Status = EFI_SUCCESS; !EFI_ERROR (Status); Index++) {
+ //
+ // If protocol is NULL, then it's the end of the list
+ //
+ Protocol = VA_ARG (args, EFI_GUID *);
+ if (Protocol == NULL) {
+ break;
+ }
+
+ Interface = VA_ARG (args, VOID *);
+
+ //
+ // Uninstall it
+ //
+ Status = CoreUninstallProtocolInterface (Handle, Protocol, Interface);
+ }
+
+ //
+ // If there was an error, add all the interfaces that were
+ // uninstalled without any errors
+ //
+ if (EFI_ERROR (Status)) {
+ //
+ // Reset the va_arg back to the first argument.
+ //
+ VA_START (args, Handle);
+ for (; Index > 1; Index--) {
+ Protocol = VA_ARG(args, EFI_GUID *);
+ Interface = VA_ARG(args, VOID *);
+ CoreInstallProtocolInterface (&Handle, Protocol, EFI_NATIVE_INTERFACE, Interface);
+ }
+ }
+
+ return Status;
+}
+
+PROTOCOL_INTERFACE *
+CoreGetProtocolInterface (
+ IN EFI_HANDLE UserHandle,
+ IN EFI_GUID *Protocol
+ )
+/*++
+
+Routine Description:
+
+ Locate a certain GUID protocol interface in a Handle's protocols.
+
+Arguments:
+
+ UserHandle - The handle to obtain the protocol interface on
+
+ Protocol - The GUID of the protocol
+
+Returns:
+
+ The requested protocol interface for the handle
+
+--*/
+{
+ EFI_STATUS Status;
+ PROTOCOL_ENTRY *ProtEntry;
+ PROTOCOL_INTERFACE *Prot;
+ IHANDLE *Handle;
+ EFI_LIST_ENTRY *Link;
+
+ Status = CoreValidateHandle (UserHandle);
+ if (EFI_ERROR (Status)) {
+ return NULL;
+ }
+
+ Handle = (IHANDLE *)UserHandle;
+
+ //
+ // Look at each protocol interface for a match
+ //
+ for (Link = Handle->Protocols.ForwardLink; Link != &Handle->Protocols; Link = Link->ForwardLink) {
+ Prot = CR(Link, PROTOCOL_INTERFACE, Link, PROTOCOL_INTERFACE_SIGNATURE);
+ ProtEntry = Prot->Protocol;
+ if (EfiCompareGuid (&ProtEntry->ProtocolID, Protocol)) {
+ return Prot;
+ }
+ }
+ return NULL;
+}
+
+EFI_BOOTSERVICE
+EFI_STATUS
+EFIAPI
+CoreHandleProtocol (
+ IN EFI_HANDLE UserHandle,
+ IN EFI_GUID *Protocol,
+ OUT VOID **Interface
+ )
+/*++
+
+Routine Description:
+
+ Queries a handle to determine if it supports a specified protocol.
+
+Arguments:
+
+ UserHandle - The handle being queried.
+
+ Protocol - The published unique identifier of the protocol.
+
+ Interface - Supplies the address where a pointer to the corresponding Protocol
+ Interface is returned.
+
+Returns:
+
+ The requested protocol interface for the handle
+
+--*/
+{
+ return CoreOpenProtocol (
+ UserHandle,
+ Protocol,
+ Interface,
+ gDxeCoreImageHandle,
+ NULL,
+ EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL
+ );
+}
+
+EFI_BOOTSERVICE11
+EFI_STATUS
+EFIAPI
+CoreOpenProtocol (
+ IN EFI_HANDLE UserHandle,
+ IN EFI_GUID *Protocol,
+ OUT VOID **Interface OPTIONAL,
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_HANDLE ControllerHandle,
+ IN UINT32 Attributes
+ )
+/*++
+
+Routine Description:
+
+ Locates the installed protocol handler for the handle, and
+ invokes it to obtain the protocol interface. Usage information
+ is registered in the protocol data base.
+
+Arguments:
+
+ UserHandle - The handle to obtain the protocol interface on
+
+ Protocol - The ID of the protocol
+
+ Interface - The location to return the protocol interface
+
+ ImageHandle - The handle of the Image that is opening the protocol interface
+ specified by Protocol and Interface.
+
+ ControllerHandle - The controller handle that is requiring this interface.
+
+ Attributes - The open mode of the protocol interface specified by Handle
+ and Protocol.
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Protocol is NULL.
+
+ EFI_SUCCESS - Get the protocol interface.
+
+--*/
+{
+ EFI_STATUS Status;
+ PROTOCOL_INTERFACE *Prot;
+ EFI_LIST_ENTRY *Link;
+ OPEN_PROTOCOL_DATA *OpenData;
+ BOOLEAN ByDriver;
+ BOOLEAN Exclusive;
+ BOOLEAN Disconnect;
+ BOOLEAN ExactMatch;
+
+ //
+ // Check for invalid Protocol
+ //
+ if (Protocol == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // Check for invalid Interface
+ //
+ if (Attributes != EFI_OPEN_PROTOCOL_TEST_PROTOCOL) {
+ if (Interface == NULL) {
+ return EFI_INVALID_PARAMETER;
+ } else {
+ *Interface = NULL;
+ }
+ }
+
+ //
+ // Check for invalid UserHandle
+ //
+ Status = CoreValidateHandle (UserHandle);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ //
+ // Check for invalid Attributes
+ //
+ switch (Attributes) {
+ case EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER :
+ Status = CoreValidateHandle (ImageHandle);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ Status = CoreValidateHandle (ControllerHandle);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ if (UserHandle == ControllerHandle) {
+ return EFI_INVALID_PARAMETER;
+ }
+ break;
+ case EFI_OPEN_PROTOCOL_BY_DRIVER :
+ case EFI_OPEN_PROTOCOL_BY_DRIVER | EFI_OPEN_PROTOCOL_EXCLUSIVE :
+ Status = CoreValidateHandle (ImageHandle);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ Status = CoreValidateHandle (ControllerHandle);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ break;
+ case EFI_OPEN_PROTOCOL_EXCLUSIVE :
+ Status = CoreValidateHandle (ImageHandle);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ break;
+ case EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL :
+ case EFI_OPEN_PROTOCOL_GET_PROTOCOL :
+ case EFI_OPEN_PROTOCOL_TEST_PROTOCOL :
+ break;
+ default:
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // Lock the protocol database
+ //
+ CoreAcquireProtocolLock ();
+
+ //
+ // Look at each protocol interface for a match
+ //
+ Prot = CoreGetProtocolInterface (UserHandle, Protocol);
+ if (Prot == NULL) {
+ Status = EFI_UNSUPPORTED;
+ goto Done;
+ }
+
+ //
+ // This is the protocol interface entry for this protocol
+ //
+ if (Attributes != EFI_OPEN_PROTOCOL_TEST_PROTOCOL) {
+ *Interface = Prot->Interface;
+ }
+ Status = EFI_SUCCESS;
+
+ ByDriver = FALSE;
+ Exclusive = FALSE;
+ for ( Link = Prot->OpenList.ForwardLink; Link != &Prot->OpenList; Link = Link->ForwardLink) {
+ OpenData = CR (Link, OPEN_PROTOCOL_DATA, Link, OPEN_PROTOCOL_DATA_SIGNATURE);
+ ExactMatch = (BOOLEAN)((OpenData->AgentHandle == ImageHandle) &&
+ (OpenData->Attributes == Attributes) &&
+ (OpenData->ControllerHandle == ControllerHandle));
+ if (OpenData->Attributes & EFI_OPEN_PROTOCOL_BY_DRIVER) {
+ ByDriver = TRUE;
+ if (ExactMatch) {
+ Status = EFI_ALREADY_STARTED;
+ goto Done;
+ }
+ }
+ if (OpenData->Attributes & EFI_OPEN_PROTOCOL_EXCLUSIVE) {
+ Exclusive = TRUE;
+ } else if (ExactMatch) {
+ OpenData->OpenCount++;
+ Status = EFI_SUCCESS;
+ goto Done;
+ }
+ }
+
+ //
+ // ByDriver TRUE -> A driver is managing (UserHandle, Protocol)
+ // ByDriver FALSE -> There are no drivers managing (UserHandle, Protocol)
+ // Exclusive TRUE -> Something has exclusive access to (UserHandle, Protocol)
+ // Exclusive FALSE -> Nothing has exclusive access to (UserHandle, Protocol)
+ //
+
+ switch (Attributes) {
+ case EFI_OPEN_PROTOCOL_BY_DRIVER :
+ if (Exclusive || ByDriver) {
+ Status = EFI_ACCESS_DENIED;
+ goto Done;
+ }
+ break;
+ case EFI_OPEN_PROTOCOL_BY_DRIVER | EFI_OPEN_PROTOCOL_EXCLUSIVE :
+ case EFI_OPEN_PROTOCOL_EXCLUSIVE :
+ if (Exclusive) {
+ Status = EFI_ACCESS_DENIED;
+ goto Done;
+ }
+ if (ByDriver) {
+ do {
+ Disconnect = FALSE;
+ for ( Link = Prot->OpenList.ForwardLink; (Link != &Prot->OpenList) && (!Disconnect); Link = Link->ForwardLink) {
+ OpenData = CR (Link, OPEN_PROTOCOL_DATA, Link, OPEN_PROTOCOL_DATA_SIGNATURE);
+ if (OpenData->Attributes & EFI_OPEN_PROTOCOL_BY_DRIVER) {
+ Disconnect = TRUE;
+ CoreReleaseProtocolLock ();
+ Status = CoreDisconnectController (UserHandle, OpenData->AgentHandle, NULL);
+ CoreAcquireProtocolLock ();
+ if (EFI_ERROR (Status)) {
+ Status = EFI_ACCESS_DENIED;
+ goto Done;
+ }
+ }
+ }
+ } while (Disconnect);
+ }
+ break;
+ case EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER :
+ case EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL :
+ case EFI_OPEN_PROTOCOL_GET_PROTOCOL :
+ case EFI_OPEN_PROTOCOL_TEST_PROTOCOL :
+ break;
+ }
+
+ if (ImageHandle == NULL) {
+ Status = EFI_SUCCESS;
+ goto Done;
+ }
+ //
+ // Create new entry
+ //
+ OpenData = CoreAllocateBootServicesPool (sizeof(OPEN_PROTOCOL_DATA));
+ if (OpenData == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ } else {
+ OpenData->Signature = OPEN_PROTOCOL_DATA_SIGNATURE;
+ OpenData->AgentHandle = ImageHandle;
+ OpenData->ControllerHandle = ControllerHandle;
+ OpenData->Attributes = Attributes;
+ OpenData->OpenCount = 1;
+ InsertTailList (&Prot->OpenList, &OpenData->Link);
+ Prot->OpenListCount++;
+ Status = EFI_SUCCESS;
+ }
+
+Done:
+ //
+ // Done. Release the database lock are return
+ //
+ CoreReleaseProtocolLock ();
+ return Status;
+}
+
+EFI_BOOTSERVICE11
+EFI_STATUS
+EFIAPI
+CoreCloseProtocol (
+ IN EFI_HANDLE UserHandle,
+ IN EFI_GUID *Protocol,
+ IN EFI_HANDLE AgentHandle,
+ IN EFI_HANDLE ControllerHandle
+ )
+/*++
+
+Routine Description:
+
+ Closes a protocol on a handle that was opened using OpenProtocol().
+
+Arguments:
+
+ UserHandle - The handle for the protocol interface that was previously opened
+ with OpenProtocol(), and is now being closed.
+ Protocol - The published unique identifier of the protocol. It is the caller¡¯s
+ responsibility to pass in a valid GUID.
+ AgentHandle - The handle of the agent that is closing the protocol interface.
+ ControllerHandle - If the agent that opened a protocol is a driver that follows the
+ EFI Driver Model, then this parameter is the controller handle
+ that required the protocol interface. If the agent does not follow
+ the EFI Driver Model, then this parameter is optional and may be NULL.
+
+Returns:
+
+ EFI_SUCCESS - The protocol instance was closed.
+ EFI_INVALID_PARAMETER - Handle, AgentHandle or ControllerHandle is not a valid EFI_HANDLE.
+ EFI_NOT_FOUND - Can not find the specified protocol or AgentHandle.
+
+--*/
+{
+ EFI_STATUS Status;
+ PROTOCOL_INTERFACE *ProtocolInterface;
+ EFI_LIST_ENTRY *Link;
+ OPEN_PROTOCOL_DATA *OpenData;
+
+ //
+ // Check for invalid parameters
+ //
+ Status = CoreValidateHandle (UserHandle);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ Status = CoreValidateHandle (AgentHandle);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ if (ControllerHandle != NULL_HANDLE) {
+ Status = CoreValidateHandle (ControllerHandle);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ }
+ if (Protocol == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // Lock the protocol database
+ //
+ CoreAcquireProtocolLock ();
+
+ //
+ // Look at each protocol interface for a match
+ //
+ Status = EFI_NOT_FOUND;
+ ProtocolInterface = CoreGetProtocolInterface (UserHandle, Protocol);
+ if (ProtocolInterface == NULL) {
+ goto Done;
+ }
+
+ //
+ // Walk the Open data base looking for AgentHandle
+ //
+ Link = ProtocolInterface->OpenList.ForwardLink;
+ while (Link != &ProtocolInterface->OpenList) {
+ OpenData = CR (Link, OPEN_PROTOCOL_DATA, Link, OPEN_PROTOCOL_DATA_SIGNATURE);
+ Link = Link->ForwardLink;
+ if ((OpenData->AgentHandle == AgentHandle) && (OpenData->ControllerHandle == ControllerHandle)) {
+ RemoveEntryList (&OpenData->Link);
+ ProtocolInterface->OpenListCount--;
+ CoreFreePool (OpenData);
+ Status = EFI_SUCCESS;
+ }
+ }
+
+Done:
+ //
+ // Done. Release the database lock and return.
+ //
+ CoreReleaseProtocolLock ();
+ return Status;
+}
+
+
+EFI_BOOTSERVICE11
+EFI_STATUS
+EFIAPI
+CoreOpenProtocolInformation (
+ IN EFI_HANDLE UserHandle,
+ IN EFI_GUID *Protocol,
+ OUT EFI_OPEN_PROTOCOL_INFORMATION_ENTRY **EntryBuffer,
+ OUT UINTN *EntryCount
+ )
+/*++
+
+Routine Description:
+
+ Return information about Opened protocols in the system
+
+Arguments:
+
+ UserHandle - The handle to close the protocol interface on
+
+ Protocol - The ID of the protocol
+
+ EntryBuffer - A pointer to a buffer of open protocol information in the form of
+ EFI_OPEN_PROTOCOL_INFORMATION_ENTRY structures.
+
+ EntryCount - Number of EntryBuffer entries
+
+Returns:
+
+
+--*/
+{
+ EFI_STATUS Status;
+ PROTOCOL_INTERFACE *ProtocolInterface;
+ EFI_LIST_ENTRY *Link;
+ OPEN_PROTOCOL_DATA *OpenData;
+ EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *Buffer;
+ UINTN Count;
+ UINTN Size;
+
+ *EntryBuffer = NULL;
+ *EntryCount = 0;
+
+ //
+ // Lock the protocol database
+ //
+ CoreAcquireProtocolLock ();
+
+ //
+ // Look at each protocol interface for a match
+ //
+ Status = EFI_NOT_FOUND;
+ ProtocolInterface = CoreGetProtocolInterface (UserHandle, Protocol);
+ if (ProtocolInterface == NULL) {
+ goto Done;
+ }
+
+ //
+ // Count the number of Open Entries
+ //
+ for ( Link = ProtocolInterface->OpenList.ForwardLink, Count = 0;
+ (Link != &ProtocolInterface->OpenList) ;
+ Link = Link->ForwardLink ) {
+ Count++;
+ }
+
+ ASSERT (Count == ProtocolInterface->OpenListCount);
+
+ if (Count == 0) {
+ Size = sizeof(EFI_OPEN_PROTOCOL_INFORMATION_ENTRY);
+ } else {
+ Size = Count * sizeof(EFI_OPEN_PROTOCOL_INFORMATION_ENTRY);
+ }
+
+ Buffer = CoreAllocateBootServicesPool (Size);
+ if (Buffer == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Done;
+ }
+
+ Status = EFI_SUCCESS;
+ for ( Link = ProtocolInterface->OpenList.ForwardLink, Count = 0;
+ (Link != &ProtocolInterface->OpenList);
+ Link = Link->ForwardLink, Count++ ) {
+ OpenData = CR (Link, OPEN_PROTOCOL_DATA, Link, OPEN_PROTOCOL_DATA_SIGNATURE);
+
+ Buffer[Count].AgentHandle = OpenData->AgentHandle;
+ Buffer[Count].ControllerHandle = OpenData->ControllerHandle;
+ Buffer[Count].Attributes = OpenData->Attributes;
+ Buffer[Count].OpenCount = OpenData->OpenCount;
+ }
+
+ *EntryBuffer = Buffer;
+ *EntryCount = Count;
+
+Done:
+ //
+ // Done. Release the database lock are return
+ //
+ CoreReleaseProtocolLock ();
+ return Status;
+}
+
+
+EFI_BOOTSERVICE11
+EFI_STATUS
+EFIAPI
+CoreProtocolsPerHandle (
+ IN EFI_HANDLE UserHandle,
+ OUT EFI_GUID ***ProtocolBuffer,
+ OUT UINTN *ProtocolBufferCount
+ )
+/*++
+
+Routine Description:
+
+ Retrieves the list of protocol interface GUIDs that are installed on a handle in a buffer allocated
+ from pool.
+
+Arguments:
+
+ UserHandle - The handle from which to retrieve the list of protocol interface
+ GUIDs.
+
+ ProtocolBuffer - A pointer to the list of protocol interface GUID pointers that are
+ installed on Handle.
+
+ ProtocolBufferCount - A pointer to the number of GUID pointers present in
+ ProtocolBuffer.
+
+Returns:
+ EFI_SUCCESS - The list of protocol interface GUIDs installed on Handle was returned in
+ ProtocolBuffer. The number of protocol interface GUIDs was
+ returned in ProtocolBufferCount.
+ EFI_INVALID_PARAMETER - Handle is NULL.
+ EFI_INVALID_PARAMETER - Handle is not a valid EFI_HANDLE.
+ EFI_INVALID_PARAMETER - ProtocolBuffer is NULL.
+ EFI_INVALID_PARAMETER - ProtocolBufferCount is NULL.
+ EFI_OUT_OF_RESOURCES - There is not enough pool memory to store the results.
+
+--*/
+{
+ EFI_STATUS Status;
+ IHANDLE *Handle;
+ PROTOCOL_INTERFACE *Prot;
+ EFI_LIST_ENTRY *Link;
+ UINTN ProtocolCount;
+ EFI_GUID **Buffer;
+
+ Status = CoreValidateHandle (UserHandle);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Handle = (IHANDLE *)UserHandle;
+
+ if (ProtocolBuffer == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (ProtocolBufferCount == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ *ProtocolBufferCount = 0;
+
+ ProtocolCount = 0;
+
+ CoreAcquireProtocolLock ();
+
+ for (Link = Handle->Protocols.ForwardLink; Link != &Handle->Protocols; Link = Link->ForwardLink) {
+ ProtocolCount++;
+ }
+
+ //
+ // If there are no protocol interfaces installed on Handle, then Handle is not a valid EFI_HANDLE
+ //
+ if (ProtocolCount == 0) {
+ Status = EFI_INVALID_PARAMETER;
+ goto Done;
+ }
+
+ Buffer = CoreAllocateBootServicesPool (sizeof (EFI_GUID *) * ProtocolCount);
+ if (Buffer == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Done;
+ }
+
+ *ProtocolBuffer = Buffer;
+ *ProtocolBufferCount = ProtocolCount;
+
+ for ( Link = Handle->Protocols.ForwardLink, ProtocolCount = 0;
+ Link != &Handle->Protocols;
+ Link = Link->ForwardLink, ProtocolCount++) {
+ Prot = CR(Link, PROTOCOL_INTERFACE, Link, PROTOCOL_INTERFACE_SIGNATURE);
+ Buffer[ProtocolCount] = &(Prot->Protocol->ProtocolID);
+ }
+ Status = EFI_SUCCESS;
+
+Done:
+ CoreReleaseProtocolLock ();
+ return Status;
+}
+
+
+UINT64
+CoreGetHandleDatabaseKey (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ return handle database key.
+
+Arguments:
+
+ None
+
+Returns:
+
+ Handle database key.
+
+--*/
+{
+ return gHandleDatabaseKey;
+}
+
+
+VOID
+CoreConnectHandlesByKey (
+ UINT64 Key
+ )
+/*++
+
+Routine Description:
+
+ Go connect any handles that were created or modified while a image executed.
+
+Arguments:
+
+ Key - The Key to show that the handle has been created/modified
+
+Returns:
+
+ None
+--*/
+{
+ UINTN Count;
+ EFI_LIST_ENTRY *Link;
+ EFI_HANDLE *HandleBuffer;
+ IHANDLE *Handle;
+ UINTN Index;
+
+ //
+ // Lock the protocol database
+ //
+ CoreAcquireProtocolLock ();
+
+ for (Link = gHandleList.ForwardLink, Count = 0; Link != &gHandleList; Link = Link->ForwardLink) {
+ Handle = CR (Link, IHANDLE, AllHandles, EFI_HANDLE_SIGNATURE);
+ if (Handle->Key > Key) {
+ Count++;
+ }
+ }
+
+ HandleBuffer = CoreAllocateBootServicesPool (Count * sizeof (EFI_HANDLE));
+ if (HandleBuffer == NULL) {
+ CoreReleaseProtocolLock ();
+ return;
+ }
+
+ for (Link = gHandleList.ForwardLink, Count = 0; Link != &gHandleList; Link = Link->ForwardLink) {
+ Handle = CR (Link, IHANDLE, AllHandles, EFI_HANDLE_SIGNATURE);
+ if (Handle->Key > Key) {
+ HandleBuffer[Count++] = Handle;
+ }
+ }
+
+ //
+ // Unlock the protocol database
+ //
+ CoreReleaseProtocolLock ();
+
+ //
+ // Connect all handles whose Key value is greater than Key
+ //
+ for (Index = 0; Index < Count; Index++) {
+ CoreConnectController (HandleBuffer[Index], NULL, NULL, TRUE);
+ }
+
+ CoreFreePool(HandleBuffer);
+}
diff --git a/EDK/Foundation/Core/Dxe/Hand/locate.c b/EDK/Foundation/Core/Dxe/Hand/locate.c
new file mode 100644
index 0000000..4cd41e4
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/Hand/locate.c
@@ -0,0 +1,743 @@
+/*++
+
+Copyright (c) 2004 - 2011, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ locate.c
+
+Abstract:
+
+ Locate handle functions
+
+Revision History
+
+--*/
+
+#include "hand.h"
+
+//
+// ProtocolRequest - Last LocateHandle request ID
+//
+UINTN mEfiLocateHandleRequest = 0;
+
+//
+// Internal prototypes
+//
+
+typedef struct {
+ EFI_GUID *Protocol;
+ VOID *SearchKey;
+ EFI_LIST_ENTRY *Position;
+ PROTOCOL_ENTRY *ProtEntry;
+} LOCATE_POSITION;
+
+typedef
+IHANDLE *
+(* CORE_GET_NEXT) (
+ IN OUT LOCATE_POSITION *Position,
+ OUT VOID **Interface
+ );
+
+STATIC
+IHANDLE *
+CoreGetNextLocateAllHandles (
+ IN OUT LOCATE_POSITION *Position,
+ OUT VOID **Interface
+ );
+
+STATIC
+IHANDLE *
+CoreGetNextLocateByRegisterNotify (
+ IN OUT LOCATE_POSITION *Position,
+ OUT VOID **Interface
+ );
+
+STATIC
+IHANDLE *
+CoreGetNextLocateByProtocol (
+ IN OUT LOCATE_POSITION *Position,
+ OUT VOID **Interface
+ );
+
+//
+//
+//
+
+
+
+EFI_BOOTSERVICE
+EFI_STATUS
+EFIAPI
+CoreLocateHandle (
+ IN EFI_LOCATE_SEARCH_TYPE SearchType,
+ IN EFI_GUID *Protocol OPTIONAL,
+ IN VOID *SearchKey OPTIONAL,
+ IN OUT UINTN *BufferSize,
+ OUT EFI_HANDLE *Buffer
+ )
+/*++
+
+Routine Description:
+
+ Locates the requested handle(s) and returns them in Buffer.
+
+Arguments:
+
+ SearchType - The type of search to perform to locate the handles
+
+ Protocol - The protocol to search for
+
+ SearchKey - Dependant on SearchType
+
+ BufferSize - On input the size of Buffer. On output the
+ size of data returned.
+
+ Buffer - The buffer to return the results in
+
+
+Returns:
+
+ EFI_BUFFER_TOO_SMALL - Buffer too small, required buffer size is returned in BufferSize.
+
+ EFI_INVALID_PARAMETER - Invalid parameter
+
+ EFI_SUCCESS - Successfully found the requested handle(s) and returns them in Buffer.
+
+--*/
+{
+ EFI_STATUS Status;
+ LOCATE_POSITION Position;
+ PROTOCOL_NOTIFY *ProtNotify;
+ CORE_GET_NEXT GetNext;
+ UINTN ResultSize;
+ IHANDLE *Handle;
+ IHANDLE **ResultBuffer;
+ VOID *Interface;
+
+ if (BufferSize == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((*BufferSize > 0) && (Buffer == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ GetNext = NULL;
+ //
+ // Set initial position
+ //
+
+ Position.Protocol = Protocol;
+ Position.SearchKey = SearchKey;
+ Position.Position = &gHandleList;
+
+ ResultSize = 0;
+ ResultBuffer = (IHANDLE **) Buffer;
+ Status = EFI_SUCCESS;
+
+ //
+ // Lock the protocol database
+ //
+
+ CoreAcquireProtocolLock ();
+
+ //
+ // Get the search function based on type
+ //
+ switch (SearchType) {
+ case AllHandles:
+ GetNext = CoreGetNextLocateAllHandles;
+ break;
+
+ case ByRegisterNotify:
+ //
+ // Must have SearchKey for locate ByRegisterNotify
+ //
+ if (SearchKey == NULL) {
+ Status = EFI_INVALID_PARAMETER;
+ break;
+ }
+ GetNext = CoreGetNextLocateByRegisterNotify;
+ break;
+
+ case ByProtocol:
+ GetNext = CoreGetNextLocateByProtocol;
+ if (Protocol == NULL) {
+ Status = EFI_INVALID_PARAMETER;
+ break;
+ }
+ //
+ // Look up the protocol entry and set the head pointer
+ //
+ Position.ProtEntry = CoreFindProtocolEntry (Protocol, FALSE);
+ if (Position.ProtEntry == NULL) {
+ Status = EFI_NOT_FOUND;
+ break;
+ }
+ Position.Position = &Position.ProtEntry->Protocols;
+ break;
+
+ default:
+ Status = EFI_INVALID_PARAMETER;
+ break;
+ }
+
+ if (EFI_ERROR(Status) || (GetNext == NULL)) {
+ CoreReleaseProtocolLock ();
+ return Status;
+ }
+
+ //
+ // Enumerate out the matching handles
+ //
+ mEfiLocateHandleRequest += 1;
+ for (; ;) {
+ //
+ // Get the next handle. If no more handles, stop
+ //
+ Handle = GetNext (&Position, &Interface);
+ if (NULL == Handle) {
+ break;
+ }
+
+ //
+ // Increase the resulting buffer size, and if this handle
+ // fits return it
+ //
+ ResultSize += sizeof(Handle);
+ if (ResultSize <= *BufferSize) {
+ *ResultBuffer = Handle;
+ ResultBuffer += 1;
+ }
+ }
+
+ //
+ // If the result is a zero length buffer, then there were no
+ // matching handles
+ //
+ if (ResultSize == 0) {
+ Status = EFI_NOT_FOUND;
+ } else {
+ //
+ // Return the resulting buffer size. If it's larger than what
+ // was passed, then set the error code
+ //
+ if (ResultSize > *BufferSize) {
+ Status = EFI_BUFFER_TOO_SMALL;
+ }
+
+ *BufferSize = ResultSize;
+
+ if (SearchType == ByRegisterNotify && !EFI_ERROR(Status)) {
+ //
+ // If this is a search by register notify and a handle was
+ // returned, update the register notification position
+ //
+ ProtNotify = SearchKey;
+ ProtNotify->Position = ProtNotify->Position->ForwardLink;
+ }
+ }
+
+ CoreReleaseProtocolLock ();
+ return Status;
+}
+
+
+STATIC
+IHANDLE *
+CoreGetNextLocateAllHandles (
+ IN OUT LOCATE_POSITION *Position,
+ OUT VOID **Interface
+ )
+/*++
+
+Routine Description:
+
+ Routine to get the next Handle, when you are searching for all handles.
+
+Arguments:
+
+ Position - Information about which Handle to seach for.
+
+ Interface - Return the interface structure for the matching protocol.
+
+Returns:
+ IHANDLE - An IHANDLE is returned if the next Position is not the end of the
+ list. A NULL_HANDLE is returned if it's the end of the list.
+
+--*/
+{
+ IHANDLE *Handle;
+
+ //
+ // Next handle
+ //
+ Position->Position = Position->Position->ForwardLink;
+
+ //
+ // If not at the end of the list, get the handle
+ //
+ Handle = NULL_HANDLE;
+ *Interface = NULL;
+ if (Position->Position != &gHandleList) {
+ Handle = CR (Position->Position, IHANDLE, AllHandles, EFI_HANDLE_SIGNATURE);
+ }
+
+ return Handle;
+}
+
+
+STATIC
+IHANDLE *
+CoreGetNextLocateByRegisterNotify (
+ IN OUT LOCATE_POSITION *Position,
+ OUT VOID **Interface
+ )
+/*++
+
+Routine Description:
+
+ Routine to get the next Handle, when you are searching for register protocol
+ notifies.
+
+Arguments:
+
+ Position - Information about which Handle to seach for.
+
+ Interface - Return the interface structure for the matching protocol.
+
+Returns:
+ IHANDLE - An IHANDLE is returned if the next Position is not the end of the
+ list. A NULL_HANDLE is returned if it's the end of the list.
+
+--*/
+{
+ IHANDLE *Handle;
+ PROTOCOL_NOTIFY *ProtNotify;
+ PROTOCOL_INTERFACE *Prot;
+ EFI_LIST_ENTRY *Link;
+
+ Handle = NULL_HANDLE;
+ *Interface = NULL;
+ ProtNotify = Position->SearchKey;
+
+ //
+ // If this is the first request, get the next handle
+ //
+ if (ProtNotify != NULL) {
+ ASSERT(ProtNotify->Signature == PROTOCOL_NOTIFY_SIGNATURE);
+ Position->SearchKey = NULL;
+
+ //
+ // If not at the end of the list, get the next handle
+ //
+ Link = ProtNotify->Position->ForwardLink;
+ if (Link != &ProtNotify->Protocol->Protocols) {
+ Prot = CR (Link, PROTOCOL_INTERFACE, ByProtocol, PROTOCOL_INTERFACE_SIGNATURE);
+ Handle = (IHANDLE *) Prot->Handle;
+ *Interface = Prot->Interface;
+ }
+ }
+
+ return Handle;
+}
+
+
+STATIC
+IHANDLE *
+CoreGetNextLocateByProtocol (
+ IN OUT LOCATE_POSITION *Position,
+ OUT VOID **Interface
+ )
+/*++
+
+Routine Description:
+
+ Routine to get the next Handle, when you are searching for a given protocol.
+
+Arguments:
+
+ Position - Information about which Handle to seach for.
+
+ Interface - Return the interface structure for the matching protocol.
+
+Returns:
+ IHANDLE - An IHANDLE is returned if the next Position is not the end of the
+ list. A NULL_HANDLE is returned if it's the end of the list.
+
+--*/
+{
+ IHANDLE *Handle;
+ EFI_LIST_ENTRY *Link;
+ PROTOCOL_INTERFACE *Prot;
+
+ Handle = NULL_HANDLE;
+ *Interface = NULL;
+ for (; ;) {
+ //
+ // Next entry
+ //
+ Link = Position->Position->ForwardLink;
+ Position->Position = Link;
+
+ //
+ // If not at the end, return the handle
+ //
+ if (Link == &Position->ProtEntry->Protocols) {
+ Handle = NULL_HANDLE;
+ break;
+ }
+
+ //
+ // Get the handle
+ //
+ Prot = CR(Link, PROTOCOL_INTERFACE, ByProtocol, PROTOCOL_INTERFACE_SIGNATURE);
+ Handle = (IHANDLE *) Prot->Handle;
+ *Interface = Prot->Interface;
+
+ //
+ // If this handle has not been returned this request, then
+ // return it now
+ //
+ if (Handle->LocateRequest != mEfiLocateHandleRequest) {
+ Handle->LocateRequest = mEfiLocateHandleRequest;
+ break;
+ }
+ }
+
+ return Handle;
+}
+
+
+EFI_BOOTSERVICE
+EFI_STATUS
+EFIAPI
+CoreLocateDevicePath (
+ IN EFI_GUID *Protocol,
+ IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath,
+ OUT EFI_HANDLE *Device
+ )
+/*++
+
+Routine Description:
+
+ Locates the handle to a device on the device path that best matches the specified protocol.
+
+Arguments:
+
+ Protocol - The protocol to search for.
+ DevicePath - On input, a pointer to a pointer to the device path. On output, the device
+ path pointer is modified to point to the remaining part of the devicepath.
+ Device - A pointer to the returned device handle.
+
+Returns:
+
+ EFI_SUCCESS - The resulting handle was returned.
+ EFI_NOT_FOUND - No handles matched the search.
+ EFI_INVALID_PARAMETER - One of the parameters has an invalid value.
+
+--*/
+{
+ INTN SourceSize;
+ INTN Size;
+ INTN BestMatch;
+ UINTN HandleCount;
+ UINTN Index;
+ EFI_STATUS Status;
+ EFI_HANDLE *Handles;
+ EFI_HANDLE Handle;
+ EFI_HANDLE BestDevice;
+ EFI_DEVICE_PATH_PROTOCOL *SourcePath;
+ EFI_DEVICE_PATH_PROTOCOL *TmpDevicePath;
+
+ if (Protocol == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((DevicePath == NULL) || (*DevicePath == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ BestDevice = NULL;
+ SourcePath = *DevicePath;
+ TmpDevicePath = SourcePath;
+ while (!IsDevicePathEnd (TmpDevicePath)) {
+ if (EfiIsDevicePathEndInstance (TmpDevicePath)) {
+ //
+ // If DevicePath is a multi-instance device path,
+ // the function will operate on the first instance
+ //
+ break;
+ }
+ TmpDevicePath = NextDevicePathNode (TmpDevicePath);
+ }
+
+ SourceSize = (UINTN) TmpDevicePath - (UINTN) SourcePath;
+
+ //
+ // Get a list of all handles that support the requested protocol
+ //
+ Status = CoreLocateHandleBuffer (ByProtocol, Protocol, NULL, &HandleCount, &Handles);
+ if (EFI_ERROR (Status) || HandleCount == 0) {
+ return EFI_NOT_FOUND;
+ }
+
+ BestMatch = -1;
+ for(Index = 0; Index < HandleCount; Index += 1) {
+ Handle = Handles[Index];
+ Status = CoreHandleProtocol (Handle, &gEfiDevicePathProtocolGuid, &TmpDevicePath);
+ if (EFI_ERROR (Status)) {
+ //
+ // If this handle doesn't support device path, then skip it
+ //
+ continue;
+ }
+
+ //
+ // Check if DevicePath is first part of SourcePath
+ //
+ Size = CoreDevicePathSize (TmpDevicePath) - sizeof(EFI_DEVICE_PATH_PROTOCOL);
+ if ((Size <= SourceSize) && EfiCompareMem (SourcePath, TmpDevicePath, Size) == 0) {
+ //
+ // If the size is equal to the best match, then we
+ // have a duplice device path for 2 different device
+ // handles
+ //
+ ASSERT (Size != BestMatch);
+
+ //
+ // We've got a match, see if it's the best match so far
+ //
+ if (Size > BestMatch) {
+ BestMatch = Size;
+ BestDevice = Handle;
+ }
+ }
+ }
+
+ CoreFreePool (Handles);
+
+ //
+ // If there wasn't any match, then no parts of the device path was found.
+ // Which is strange since there is likely a "root level" device path in the system.
+ //
+ if (BestMatch == -1) {
+ return EFI_NOT_FOUND;
+ }
+
+ if (Device == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+ *Device = BestDevice;
+
+ //
+ // Return the remaining part of the device path
+ //
+ *DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) (((UINT8 *) SourcePath) + BestMatch);
+ return EFI_SUCCESS;
+}
+
+
+EFI_BOOTSERVICE11
+EFI_STATUS
+EFIAPI
+CoreLocateProtocol (
+ IN EFI_GUID *Protocol,
+ IN VOID *Registration OPTIONAL,
+ OUT VOID **Interface
+ )
+/*++
+
+Routine Description:
+
+ Return the first Protocol Interface that matches the Protocol GUID. If
+ Registration is pasased in return a Protocol Instance that was just add
+ to the system. If Retistration is NULL return the first Protocol Interface
+ you find.
+
+Arguments:
+
+ Protocol - The protocol to search for
+
+ Registration - Optional Registration Key returned from RegisterProtocolNotify()
+
+ Interface - Return the Protocol interface (instance).
+
+Returns:
+
+ EFI_SUCCESS - If a valid Interface is returned
+
+ EFI_INVALID_PARAMETER - Invalid parameter
+
+ EFI_NOT_FOUND - Protocol interface not found
+
+--*/
+{
+ EFI_STATUS Status;
+ LOCATE_POSITION Position;
+ PROTOCOL_NOTIFY *ProtNotify;
+ IHANDLE *Handle;
+
+ if (Interface == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (Protocol == NULL) {
+ return EFI_NOT_FOUND;
+ }
+
+ *Interface = NULL;
+ Status = EFI_SUCCESS;
+
+ //
+ // Set initial position
+ //
+ Position.Protocol = Protocol;
+ Position.SearchKey = Registration;
+ Position.Position = &gHandleList;
+
+ //
+ // Lock the protocol database
+ //
+ CoreAcquireProtocolLock ();
+
+ mEfiLocateHandleRequest += 1;
+
+ if (NULL == Registration) {
+ //
+ // Look up the protocol entry and set the head pointer
+ //
+ Position.ProtEntry = CoreFindProtocolEntry (Protocol, FALSE);
+ if (Position.ProtEntry == NULL) {
+ Status = EFI_NOT_FOUND;
+ goto Done;
+ }
+ Position.Position = &Position.ProtEntry->Protocols;
+
+ Handle = CoreGetNextLocateByProtocol (&Position, Interface);
+ } else {
+ Handle = CoreGetNextLocateByRegisterNotify (&Position, Interface);
+ }
+
+ if (NULL == Handle) {
+ Status = EFI_NOT_FOUND;
+ } else if (NULL != Registration) {
+ //
+ // If this is a search by register notify and a handle was
+ // returned, update the register notification position
+ //
+ ProtNotify = Registration;
+ ProtNotify->Position = ProtNotify->Position->ForwardLink;
+ }
+
+Done:
+ CoreReleaseProtocolLock ();
+ return Status;
+}
+
+
+EFI_BOOTSERVICE11
+EFI_STATUS
+EFIAPI
+CoreLocateHandleBuffer (
+ IN EFI_LOCATE_SEARCH_TYPE SearchType,
+ IN EFI_GUID *Protocol OPTIONAL,
+ IN VOID *SearchKey OPTIONAL,
+ IN OUT UINTN *NumberHandles,
+ OUT EFI_HANDLE **Buffer
+ )
+/*++
+
+Routine Description:
+
+ Function returns an array of handles that support the requested protocol
+ in a buffer allocated from pool. This is a version of CoreLocateHandle()
+ that allocates a buffer for the caller.
+
+Arguments:
+
+ SearchType - Specifies which handle(s) are to be returned.
+ Protocol - Provides the protocol to search by.
+ This parameter is only valid for SearchType ByProtocol.
+ SearchKey - Supplies the search key depending on the SearchType.
+ NumberHandles - The number of handles returned in Buffer.
+ Buffer - A pointer to the buffer to return the requested array of
+ handles that support Protocol.
+
+Returns:
+
+ EFI_SUCCESS - The result array of handles was returned.
+ EFI_NOT_FOUND - No handles match the search.
+ EFI_OUT_OF_RESOURCES - There is not enough pool memory to store the matching results.
+ EFI_INVALID_PARAMETER - Invalid parameter
+
+--*/
+{
+ EFI_STATUS Status;
+ UINTN BufferSize;
+
+ if (NumberHandles == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (Buffer == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ BufferSize = 0;
+ *NumberHandles = 0;
+ *Buffer = NULL;
+ Status = CoreLocateHandle (
+ SearchType,
+ Protocol,
+ SearchKey,
+ &BufferSize,
+ *Buffer
+ );
+ //
+ // LocateHandleBuffer() returns incorrect status code if SearchType is
+ // invalid.
+ //
+ // Add code to correctly handle expected errors from CoreLocateHandle().
+ //
+ if (EFI_ERROR(Status)) {
+ switch (Status) {
+ case EFI_BUFFER_TOO_SMALL:
+ break;
+ case EFI_INVALID_PARAMETER:
+ return Status;
+ default:
+ return EFI_NOT_FOUND;
+ }
+ }
+
+ *Buffer = CoreAllocateBootServicesPool (BufferSize);
+ if (*Buffer == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ Status = CoreLocateHandle (
+ SearchType,
+ Protocol,
+ SearchKey,
+ &BufferSize,
+ *Buffer
+ );
+
+ *NumberHandles = BufferSize/sizeof(EFI_HANDLE);
+ if (EFI_ERROR(Status)) {
+ *NumberHandles = 0;
+ }
+
+ return Status;
+}
+
+
diff --git a/EDK/Foundation/Core/Dxe/Ia32/Processor.h b/EDK/Foundation/Core/Dxe/Ia32/Processor.h
new file mode 100644
index 0000000..0084d4a
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/Ia32/Processor.h
@@ -0,0 +1,27 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+ Processor.h
+
+Abstract:
+ This file contains the IA-32 processor specific definitions
+
+--*/
+
+#ifndef _PROCESSOR_H_
+#define _PROCESSOR_H_
+
+#define EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT (EFI_PAGE_SIZE)
+
+#define DEFAULT_PAGE_ALLOCATION (EFI_PAGE_SIZE)
+
+#endif \ No newline at end of file
diff --git a/EDK/Foundation/Core/Dxe/Image/Image.c b/EDK/Foundation/Core/Dxe/Image/Image.c
new file mode 100644
index 0000000..bdf1783
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/Image/Image.c
@@ -0,0 +1,1626 @@
+/*++
+
+Copyright (c) 2004 - 2012, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Image.c
+
+Abstract:
+
+ Core image handling services
+
+--*/
+
+#include "Image.h"
+#include "EfiHobLib.h"
+#include "EfiPerf.h"
+
+//
+// Module Globals
+//
+
+LOADED_IMAGE_PRIVATE_DATA *mCurrentImage = NULL;
+
+LOAD_PE32_IMAGE_PRIVATE_DATA mLoadPe32PrivateData = {
+ LOAD_PE32_IMAGE_PRIVATE_DATA_SIGNATURE,
+ NULL,
+ CoreLoadImageEx,
+ CoreUnloadImageEx
+};
+
+
+//
+// This code is needed to build the Image handle for the DXE Core
+//
+LOADED_IMAGE_PRIVATE_DATA mCorePrivateImage = {
+ LOADED_IMAGE_PRIVATE_DATA_SIGNATURE, // Signature
+ NULL, // Image handle
+ EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER, // Image type
+ TRUE, // If entrypoint has been called
+ NULL, // EntryPoint
+ {
+ EFI_LOADED_IMAGE_INFORMATION_REVISION, // Revision
+ NULL, // Parent handle
+ NULL, // System handle
+
+ NULL, // Device handle
+ NULL, // File path
+ NULL, // Reserved
+
+ 0, // LoadOptionsSize
+ NULL, // LoadOptions
+
+ NULL, // ImageBase
+ 0, // ImageSize
+ EfiBootServicesCode, // ImageCodeType
+ EfiBootServicesData // ImageDataType
+ },
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
+ NULL, // Loaded Image Device Path
+#endif
+ (EFI_PHYSICAL_ADDRESS)0, // ImageBasePage
+ 0, // NumberOfPages
+ NULL, // FixupData
+ 0, // Tpl
+ EFI_SUCCESS, // Status
+ 0, // ExitDataSize
+ NULL, // ExitData
+ NULL, // JumpContext
+ 0, // Machine
+ NULL, // Ebc
+ NULL, // RuntimeData
+};
+
+
+STATIC
+EFI_STATUS
+EFIAPI
+CoreFlushICache (
+ IN EFI_PHYSICAL_ADDRESS Start,
+ IN UINT64 Length
+ );
+
+EFI_STATUS
+GetTimerValue (
+ OUT UINT64 *TimerValue
+ );
+
+EFI_STATUS
+CoreInitializeImageServices (
+ IN VOID *HobStart
+ )
+/*++
+
+Routine Description:
+
+ Add the Image Services to EFI Boot Services Table and install the protocol
+ interfaces for this image.
+
+Arguments:
+
+ HobStart - The HOB to initialize
+
+Returns:
+
+ Status code.
+
+--*/
+{
+ EFI_STATUS Status;
+ LOADED_IMAGE_PRIVATE_DATA *Image;
+ EFI_PHYSICAL_ADDRESS DxeCoreImageBaseAddress;
+ UINT64 DxeCoreImageLength;
+ VOID *DxeCoreEntryPoint;
+
+
+ //
+ // Searching for image hob
+ //
+ Status = GetDxeCoreHobInfo (
+ HobStart,
+ &DxeCoreImageBaseAddress,
+ &DxeCoreImageLength,
+ &DxeCoreEntryPoint,
+ &gDxeCoreFileName
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // Initialize the fields for an internal driver
+ //
+ Image = &mCorePrivateImage;
+
+ Image->EntryPoint = (EFI_IMAGE_ENTRY_POINT)(UINTN)DxeCoreEntryPoint;
+ Image->ImageBasePage = DxeCoreImageBaseAddress;
+ Image->NumberOfPages = (UINTN)(EFI_SIZE_TO_PAGES((UINTN)(DxeCoreImageLength)));
+ Image->Tpl = gEfiCurrentTpl;
+ Image->Info.SystemTable = gST;
+ Image->Info.ImageBase = (VOID *)(UINTN)DxeCoreImageBaseAddress;
+ Image->Info.ImageSize = DxeCoreImageLength;
+
+ //
+ // Install the protocol interfaces for this image
+ //
+ Status = CoreInstallProtocolInterface (
+ &Image->Handle,
+ &gEfiLoadedImageProtocolGuid,
+ EFI_NATIVE_INTERFACE,
+ &Image->Info
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // Install Debug Mask Protocol
+ //
+ DEBUG_CODE (
+ if (!EFI_ERROR (Status)) {
+ Status = InstallCoreDebugMaskProtocol(Image->Handle);
+ ASSERT_EFI_ERROR (Status);
+ }
+ )
+
+ mCurrentImage = Image;
+
+ //
+ // Fill in DXE globals
+ //
+ gDxeCoreImageHandle = Image->Handle;
+ gDxeCoreLoadedImage = &Image->Info;
+
+ //
+ // Export DXE Core PE Loader functionality
+ //
+ return CoreInstallProtocolInterface (
+ &mLoadPe32PrivateData.Handle,
+ &gEfiLoadPeImageGuid,
+ EFI_NATIVE_INTERFACE,
+ &mLoadPe32PrivateData.Pe32Image
+ );
+}
+
+
+STATIC
+EFI_STATUS
+CoreLoadPeImage (
+ IN BOOLEAN BootPolicy,
+ IN VOID *Pe32Handle,
+ IN LOADED_IMAGE_PRIVATE_DATA *Image,
+ IN EFI_PHYSICAL_ADDRESS DstBuffer OPTIONAL,
+ OUT EFI_PHYSICAL_ADDRESS *EntryPoint OPTIONAL,
+ IN UINT32 Attribute,
+ IN BOOLEAN CrossLoad
+ )
+/*++
+
+Routine Description:
+
+ Loads, relocates, and invokes a PE/COFF image.
+
+Arguments:
+
+ Pe32Handle - The handle of PE32 image.
+ Image - PE image to be loaded.
+ DstBuffer - The buffer to store the image.
+ EntryPoint - A pointer to the entry point.
+ Attribute - The bit mask of attributes to set for the load PE image.
+ CrossLoad - Whether expect to support cross architecture loading.
+
+Returns:
+
+ EFI_SUCCESS - The file was loaded, relocated, and invoked.
+ EFI_OUT_OF_RESOURCES - There was not enough memory to load and relocate the PE/COFF file.
+ EFI_INVALID_PARAMETER - Invalid parameter.
+ EFI_BUFFER_TOO_SMALL - Buffer for image is too small.
+
+--*/
+{
+ EFI_STATUS Status;
+ BOOLEAN DstBufAlocated;
+ UINTN Size;
+ EFI_IMAGE_NT_HEADERS64 *PeHdr;
+ EFI_TCG_PLATFORM_PROTOCOL *TcgPlatformProtocol;
+ IMAGE_FILE_HANDLE *FHandle;
+ BOOLEAN NeedAllocateAddress;
+#ifdef EFI_LOAD_DRIVER_AT_FIXED_OFFSET
+ BOOLEAN OffsetMode;
+ STATIC BOOLEAN PrintTopAddress = TRUE;
+#endif
+
+ DEBUG_CODE (
+ UINTN Index;
+ UINTN StartIndex;
+ CHAR8 EfiFileName[256];
+ )
+
+ EfiCommonLibZeroMem (&(Image->ImageContext), sizeof (Image->ImageContext));
+
+ Image->ImageContext.Handle = Pe32Handle;
+ Image->ImageContext.ImageRead = (EFI_PEI_PE_COFF_LOADER_READ_FILE) CoreReadImageFile;
+
+ //
+ // Get information about the image being loaded.
+ //
+ Status = gEfiPeiPeCoffLoader->GetImageInfo (gEfiPeiPeCoffLoader, &(Image->ImageContext));
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ //
+ // Check the processor architecture of the image
+ //
+ if (!EFI_IMAGE_MACHINE_TYPE_SUPPORTED (Image->ImageContext.Machine)) {
+ if (CrossLoad) {
+ if (!EFI_IMAGE_MACHINE_CROSS_TYPE_SUPPORTED (Image->ImageContext.Machine)) {
+ return EFI_UNSUPPORTED;
+ }
+ } else {
+ return EFI_UNSUPPORTED;
+ }
+ }
+
+ //
+ // Allocate memory of the correct memory type aligned on the required image boundary.
+ //
+ DstBufAlocated = FALSE;
+ if (DstBuffer == 0) {
+ //
+ // Allocate Destination Buffer as caller did not pass it in.
+ //
+
+ if (Image->ImageContext.SectionAlignment > EFI_PAGE_SIZE) {
+ Size = (UINTN) Image->ImageContext.ImageSize + Image->ImageContext.SectionAlignment;
+ } else {
+ Size = (UINTN) Image->ImageContext.ImageSize;
+ }
+
+ Image->NumberOfPages = EFI_SIZE_TO_PAGES (Size);
+ //
+ // Following code is to support load a PE image at fixed offset relative to TOLM
+ //
+#ifdef EFI_LOAD_DRIVER_AT_FIXED_OFFSET
+ {
+ typedef struct {
+ EFI_PHYSICAL_ADDRESS BaseAddress;
+ EFI_PHYSICAL_ADDRESS MaximumAddress;
+ UINT64 CurrentNumberOfPages;
+ UINT64 NumberOfPages;
+ UINTN InformationIndex;
+ BOOLEAN Special;
+ BOOLEAN Runtime;
+ } EFI_MEMORY_TYPE_STAISTICS;
+
+
+ extern EFI_MEMORY_TYPE_STAISTICS mMemoryTypeStatistics[EfiMaxMemoryType + 1];
+ INT32 Offset;
+ UINTN ReadSize = sizeof (UINT32);
+
+ if (PrintTopAddress) {
+ DEBUG ((EFI_D_INFO | EFI_D_LOAD, "Runtime code top address: %lX\n", mMemoryTypeStatistics[EfiRuntimeServicesCode].MaximumAddress + 1));
+ DEBUG ((EFI_D_INFO | EFI_D_LOAD, "Boot time code top address: %lX\n", mMemoryTypeStatistics[EfiBootServicesCode].MaximumAddress + 1));
+ PrintTopAddress = FALSE;
+ }
+ OffsetMode = FALSE;
+ Status = Image->ImageContext.ImageRead (
+ Image->ImageContext.Handle,
+ Image->ImageContext.PeCoffHeaderOffset + 12,
+ &ReadSize,
+ &Offset
+ );
+ if (!EFI_ERROR (Status) && Offset != 0 &&
+ Image->ImageContext.ImageCodeMemoryType != EfiLoaderCode) {
+ OffsetMode = TRUE;
+ Image->ImageContext.ImageAddress = mMemoryTypeStatistics[Image->ImageContext.ImageCodeMemoryType].MaximumAddress + 1 - Offset;
+ }
+ }
+#endif
+
+ //
+ // If the image relocations are stripped, or fixed address/offset feature is valid,
+ // try to load the image to the specified address first.
+ // Otherwise try to load the image at any page if image relocations are available.
+ //
+ NeedAllocateAddress = FALSE;
+ if (Image->ImageContext.RelocationsStripped) {
+ NeedAllocateAddress = TRUE;
+ }
+#ifdef EFI_LOAD_DRIVER_AT_FIXED_ADDRESS
+ NeedAllocateAddress = TRUE;
+#endif
+#ifdef EFI_LOAD_DRIVER_AT_FIXED_OFFSET
+ if (OffsetMode) {
+ NeedAllocateAddress = TRUE;
+ }
+#endif
+ Status = EFI_OUT_OF_RESOURCES;
+ if (NeedAllocateAddress) {
+ Status = CoreAllocatePages (
+ AllocateAddress,
+ Image->ImageContext.ImageCodeMemoryType,
+ Image->NumberOfPages,
+ &Image->ImageContext.ImageAddress
+ );
+#ifdef EFI_LOAD_DRIVER_AT_FIXED_OFFSET
+ if (EFI_ERROR (Status) && OffsetMode) {
+ DEBUG((EFI_D_ERROR, "\nOffset mode load failure!"));
+ }
+#endif
+ }
+ if (EFI_ERROR (Status) && !Image->ImageContext.RelocationsStripped) {
+ Status = CoreAllocatePages (
+ AllocateAnyPages,
+ Image->ImageContext.ImageCodeMemoryType,
+ Image->NumberOfPages,
+ &Image->ImageContext.ImageAddress
+ );
+ }
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ DstBufAlocated = TRUE;
+ } else {
+ //
+ // Caller provided the destination buffer.
+ //
+
+ if (Image->ImageContext.RelocationsStripped && (Image->ImageContext.ImageAddress != DstBuffer)) {
+ //
+ // If the image relocations were stripped, and the caller provided a
+ // destination buffer address that does not match the address that the
+ // image is linked at, then the image cannot be loaded.
+ //
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Size = EFI_SIZE_TO_PAGES ((UINTN) Image->ImageContext.ImageSize + Image->ImageContext.SectionAlignment);
+
+ if ((Image->NumberOfPages != 0) && (Image->NumberOfPages < Size)) {
+ Image->NumberOfPages = Size;
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ Image->NumberOfPages = Size;
+ Image->ImageContext.ImageAddress = DstBuffer;
+ }
+
+ Image->ImageBasePage = Image->ImageContext.ImageAddress;
+ Image->ImageContext.ImageAddress =
+ (Image->ImageContext.ImageAddress + Image->ImageContext.SectionAlignment - 1) &
+ ~((UINTN) Image->ImageContext.SectionAlignment - 1);
+
+ //
+ // Load the image from the file into the allocated memory
+ //
+ Status = gEfiPeiPeCoffLoader->LoadImage (gEfiPeiPeCoffLoader, &(Image->ImageContext));
+ if (EFI_ERROR (Status)) {
+ goto Done;
+ }
+
+ //
+ // If this is a Runtime Driver, then allocate memory for the FixupData that
+ // is used to relocate the image when SetVirtualAddressMap() is called. The
+ // relocation is done by the Runtime AP.
+ //
+ if (Attribute & EFI_LOAD_PE_IMAGE_ATTRIBUTE_RUNTIME_REGISTRATION) {
+ if (Image->ImageContext.ImageType == EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER &&
+ EFI_IMAGE_MACHINE_TYPE_SUPPORTED (Image->ImageContext.Machine)) {
+ Image->ImageContext.FixupData = CoreAllocateRuntimePool ((UINTN)(Image->ImageContext.FixupDataSize));
+ if (Image->ImageContext.FixupData == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Done;
+ }
+ }
+ }
+
+ //
+ // Measure the image before applying fixup
+ //
+ Status = CoreLocateProtocol (
+ &gEfiTcgPlatformProtocolGuid,
+ NULL,
+ &TcgPlatformProtocol
+ );
+ if (!EFI_ERROR (Status) && (TcgPlatformProtocol != NULL)) {
+ PeHdr = (EFI_IMAGE_NT_HEADERS64 *)(UINTN) (
+ Image->ImageContext.ImageAddress +
+ Image->ImageContext.PeCoffHeaderOffset
+ );
+ FHandle = (IMAGE_FILE_HANDLE *)Image->ImageContext.Handle;
+
+ Status = TcgPlatformProtocol->MeasurePeImage (
+ BootPolicy,
+ (EFI_PHYSICAL_ADDRESS)FHandle->Source,
+ FHandle->SourceSize,
+ (UINTN) PeHdr->OptionalHeader.ImageBase,
+ Image->ImageContext.ImageType,
+ Image->Info.DeviceHandle,
+ Image->Info.FilePath
+ );
+
+ ASSERT_EFI_ERROR (Status);
+ }
+
+ //
+ // Relocate the image in memory
+ //
+ Status = gEfiPeiPeCoffLoader->RelocateImage (gEfiPeiPeCoffLoader, &(Image->ImageContext));
+ if (EFI_ERROR (Status)) {
+ goto Done;
+ }
+
+ //
+ // Flush the Instruction Cache
+ //
+ Status = CoreFlushICache (Image->ImageContext.ImageAddress, Image->ImageContext.ImageSize);
+ if (EFI_ERROR (Status)) {
+ goto Done;
+ }
+
+ //
+ // Get the image entry point. If it's an EBC image, then call into the
+ // interpreter to create a thunk for the entry point and use the returned
+ // value for the entry point.
+ //
+ Image->EntryPoint = (EFI_IMAGE_ENTRY_POINT) (UINTN) Image->ImageContext.EntryPoint;
+
+ //
+ // Copy the machine type from the context to the image private data. This
+ // is needed during image unload to know if we should call an EBC protocol
+ // to unload the image.
+ //
+ Image->Machine = Image->ImageContext.Machine;
+ if (Image->ImageContext.Machine == EFI_IMAGE_MACHINE_EBC) {
+ //
+ // Locate the EBC interpreter protocol
+ //
+ Status = CoreLocateProtocol (&gEfiEbcProtocolGuid, NULL, &Image->Ebc);
+ if (EFI_ERROR (Status) || (Image->Ebc == NULL)) {
+ goto Done;
+ }
+
+ //
+ // Register a callback for flushing the instruction cache so that created
+ // thunks can be flushed.
+ //
+ Status = Image->Ebc->RegisterICacheFlush (Image->Ebc, CoreFlushICache);
+ if (EFI_ERROR (Status)) {
+ goto Done;
+ }
+
+ //
+ // Create a thunk for the image's entry point. This will be the new
+ // entry point for the image.
+ //
+ Status = Image->Ebc->CreateThunk (
+ Image->Ebc,
+ Image->Handle,
+ (VOID *)(UINTN)Image->ImageContext.EntryPoint,
+ (VOID **)&Image->EntryPoint
+ );
+ if (EFI_ERROR (Status)) {
+ goto Done;
+ }
+ }
+
+ //
+ // Fill in the image information for the Loaded Image Protocol
+ //
+ Image->Type = Image->ImageContext.ImageType;
+ Image->Info.ImageBase = (VOID *) (UINTN) Image->ImageContext.ImageAddress;
+ Image->Info.ImageSize = Image->ImageContext.ImageSize;
+ Image->Info.ImageCodeType = Image->ImageContext.ImageCodeMemoryType;
+ Image->Info.ImageDataType = Image->ImageContext.ImageDataMemoryType;
+
+ if (Attribute & EFI_LOAD_PE_IMAGE_ATTRIBUTE_RUNTIME_REGISTRATION) {
+ if (Image->ImageContext.ImageType == EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER) {
+ //
+ // Make a list off all the RT images so we can let the RT AP know about them.
+ //
+ Image->RuntimeData = CoreAllocateRuntimePool (sizeof(EFI_RUNTIME_IMAGE_ENTRY));
+ if (Image->RuntimeData == NULL) {
+ goto Done;
+ }
+ Image->RuntimeData->ImageBase = Image->Info.ImageBase;
+ Image->RuntimeData->ImageSize = (UINT64) (Image->Info.ImageSize);
+ Image->RuntimeData->RelocationData = Image->ImageContext.FixupData;
+ Image->RuntimeData->Handle = Image->Handle;
+ InsertTailList (&gRuntime->ImageHead, &Image->RuntimeData->Link);
+ }
+ }
+
+ //
+ // Fill in the entry point of the image if it is available
+ //
+ if (EntryPoint != NULL) {
+ *EntryPoint = Image->ImageContext.EntryPoint;
+ }
+
+ //
+ // Print the load address and the PDB file name if it is available
+ //
+
+ DEBUG_CODE (
+ {
+ DEBUG ((
+ EFI_D_INFO | EFI_D_LOAD,
+ "Loading driver at 0x%x EntryPoint=0x%x ",
+ (UINTN) Image->ImageContext.ImageAddress,
+ (UINTN) Image->ImageContext.EntryPoint
+ ));
+ if (Image->ImageContext.PdbPointer != NULL) {
+ StartIndex = 0;
+ for (Index = 0; Image->ImageContext.PdbPointer[Index] != 0; Index++) {
+ if (Image->ImageContext.PdbPointer[Index] == '\\') {
+ StartIndex = Index + 1;
+ }
+ }
+ //
+ // Copy the PDB file name to our temporary string, and replace .pdb with .efi
+ //
+ for (Index = 0; Index < sizeof (EfiFileName); Index++) {
+ EfiFileName[Index] = Image->ImageContext.PdbPointer[Index + StartIndex];
+ if (EfiFileName[Index] == 0) {
+ EfiFileName[Index] = '.';
+ }
+ if (EfiFileName[Index] == '.') {
+ EfiFileName[Index + 1] = 'e';
+ EfiFileName[Index + 2] = 'f';
+ EfiFileName[Index + 3] = 'i';
+ EfiFileName[Index + 4] = 0;
+ break;
+ }
+ }
+ DEBUG ((EFI_D_INFO | EFI_D_LOAD, "%a", EfiFileName));
+ }
+ DEBUG ((EFI_D_INFO | EFI_D_LOAD, "\n"));
+ }
+ );
+
+ return EFI_SUCCESS;
+
+Done:
+
+ //
+ // Free memory.
+ //
+
+ if (DstBufAlocated) {
+ CoreFreePages (Image->ImageContext.ImageAddress, Image->NumberOfPages);
+ }
+
+ if (Image->ImageContext.FixupData != NULL) {
+ CoreFreePool (Image->ImageContext.FixupData);
+ }
+
+ return Status;
+}
+
+
+LOADED_IMAGE_PRIVATE_DATA *
+CoreLoadedImageInfo (
+ IN EFI_HANDLE ImageHandle
+ )
+/*++
+
+Routine Description:
+
+ Get the image's private data from its handle.
+
+Arguments:
+
+ ImageHandle - The image handle
+
+Returns:
+
+ Return the image private data associated with ImageHandle.
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
+ LOADED_IMAGE_PRIVATE_DATA *Image;
+
+ Status = CoreHandleProtocol (
+ ImageHandle,
+ &gEfiLoadedImageProtocolGuid,
+ &LoadedImage
+ );
+ if (!EFI_ERROR (Status)) {
+ Image = LOADED_IMAGE_PRIVATE_DATA_FROM_THIS (LoadedImage);
+ } else {
+ DEBUG ((EFI_D_LOAD, "CoreLoadedImageInfo: Not an ImageHandle %x\n", ImageHandle));
+ Image = NULL;
+ }
+
+ return Image;
+}
+
+
+EFI_STATUS
+CoreLoadImageCommon (
+ IN BOOLEAN BootPolicy,
+ IN EFI_HANDLE ParentImageHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
+ IN VOID *SourceBuffer OPTIONAL,
+ IN UINTN SourceSize,
+ IN EFI_PHYSICAL_ADDRESS DstBuffer OPTIONAL,
+ IN OUT UINTN *NumberOfPages OPTIONAL,
+ OUT EFI_HANDLE *ImageHandle,
+ OUT EFI_PHYSICAL_ADDRESS *EntryPoint OPTIONAL,
+ IN UINT32 Attribute,
+ IN BOOLEAN CrossLoad
+ )
+/*++
+
+Routine Description:
+
+ Loads an EFI image into memory and returns a handle to the image.
+
+Arguments:
+
+ BootPolicy - If TRUE, indicates that the request originates from the boot manager,
+ and that the boot manager is attempting to load FilePath as a boot selection.
+ ParentImageHandle - The caller's image handle.
+ FilePath - The specific file path from which the image is loaded.
+ SourceBuffer - If not NULL, a pointer to the memory location containing a copy of
+ the image to be loaded.
+ SourceSize - The size in bytes of SourceBuffer.
+ DstBuffer - The buffer to store the image
+ NumberOfPages - If not NULL, on input a pointer to the page number of DstBuffer and on
+ output a pointer to the page number of the image. If this number of DstBuffer
+ is not enough, return EFI_BUFFER_TOO_SMALL and this parameter contain
+ the required number.
+ ImageHandle - Pointer to the returned image handle that is created when the image
+ is successfully loaded.
+ EntryPoint - A pointer to the entry point
+ Attribute - The bit mask of attributes to set for the load PE image
+ CrossLoad - Whether expect to support cross architecture loading
+
+Returns:
+
+ EFI_SUCCESS - The image was loaded into memory.
+ EFI_NOT_FOUND - The FilePath was not found.
+ EFI_INVALID_PARAMETER - One of the parameters has an invalid value.
+ EFI_BUFFER_TOO_SMALL - The buffer is too small
+ EFI_UNSUPPORTED - The image type is not supported, or the device path cannot be
+ parsed to locate the proper protocol for loading the file.
+ EFI_OUT_OF_RESOURCES - Image was not loaded due to insufficient resources.
+--*/
+{
+ LOADED_IMAGE_PRIVATE_DATA *Image;
+ LOADED_IMAGE_PRIVATE_DATA *ParentImage;
+ IMAGE_FILE_HANDLE FHand;
+ EFI_STATUS Status;
+ EFI_STATUS SecurityStatus;
+ EFI_HANDLE DeviceHandle;
+ UINT32 AuthenticationStatus;
+ EFI_DEVICE_PATH_PROTOCOL *OriginalFilePath;
+ EFI_DEVICE_PATH_PROTOCOL *HandleFilePath;
+ UINTN FilePathSize;
+
+ SecurityStatus = EFI_SUCCESS;
+
+ ASSERT (gEfiCurrentTpl < EFI_TPL_NOTIFY);
+ ParentImage = NULL;
+
+ //
+ // The caller must pass in a valid ParentImageHandle
+ //
+ if (ImageHandle == NULL || ParentImageHandle == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ ParentImage = CoreLoadedImageInfo (ParentImageHandle);
+ if (ParentImage == NULL) {
+ DEBUG((EFI_D_LOAD|EFI_D_ERROR, "LoadImageEx: Parent handle not an image handle\n"));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // Get simple read access to the source file
+ //
+ OriginalFilePath = FilePath;
+ Status = CoreOpenImageFile (
+ BootPolicy,
+ SourceBuffer,
+ SourceSize,
+ &FilePath,
+ &DeviceHandle,
+ &FHand,
+ &AuthenticationStatus
+ );
+ if (Status == EFI_ALREADY_STARTED) {
+ Image = NULL;
+ goto Done;
+ } else if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ //
+ // Verify the Authentication Status through the Security Architectural Protocol
+ //
+ if ((gSecurity != NULL) && (OriginalFilePath != NULL)) {
+ SecurityStatus = gSecurity->FileAuthenticationState (
+ gSecurity,
+ AuthenticationStatus,
+ OriginalFilePath
+ );
+ if (EFI_ERROR (SecurityStatus) && SecurityStatus != EFI_SECURITY_VIOLATION) {
+ Status = SecurityStatus;
+ Image = NULL;
+ goto Done;
+ }
+ }
+
+
+ //
+ // Allocate a new image structure
+ //
+ Image = CoreAllocateZeroBootServicesPool (sizeof(LOADED_IMAGE_PRIVATE_DATA));
+ if (Image == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ //
+ // Pull out just the file portion of the DevicePath for the LoadedImage FilePath
+ //
+ FilePath = OriginalFilePath;
+ Status = CoreHandleProtocol (DeviceHandle, &gEfiDevicePathProtocolGuid, &HandleFilePath);
+ if (!EFI_ERROR (Status)) {
+ FilePathSize = CoreDevicePathSize (HandleFilePath) - sizeof(EFI_DEVICE_PATH_PROTOCOL);
+ FilePath = (EFI_DEVICE_PATH_PROTOCOL *) ( ((UINT8 *)FilePath) + FilePathSize );
+ }
+
+ //
+ // Initialize the fields for an internal driver
+ //
+ Image->Signature = LOADED_IMAGE_PRIVATE_DATA_SIGNATURE;
+ Image->Info.SystemTable = gST;
+ Image->Info.DeviceHandle = DeviceHandle;
+ Image->Info.Revision = EFI_LOADED_IMAGE_INFORMATION_REVISION;
+ Image->Info.FilePath = CoreDuplicateDevicePath (FilePath);
+ Image->Info.ParentHandle = ParentImageHandle;
+
+ if (NumberOfPages != NULL) {
+ Image->NumberOfPages = *NumberOfPages ;
+ } else {
+ Image->NumberOfPages = 0 ;
+ }
+
+ //
+ // Install the protocol interfaces for this image
+ // don't fire notifications yet
+ //
+ Status = CoreInstallProtocolInterfaceNotify (
+ &Image->Handle,
+ &gEfiLoadedImageProtocolGuid,
+ EFI_NATIVE_INTERFACE,
+ &Image->Info,
+ FALSE
+ );
+ if (EFI_ERROR (Status)) {
+ goto Done;
+ }
+
+ //
+ // Install Debug Mask Protocol
+ //
+ DEBUG_CODE (
+ Status = InstallDebugMaskProtocol(Image->Handle);
+ ASSERT_EFI_ERROR (Status);
+ )
+
+ //
+ // Load the image. If EntryPoint is Null, it will not be set.
+ //
+ Status = CoreLoadPeImage (BootPolicy, &FHand, Image, DstBuffer, EntryPoint, Attribute, CrossLoad);
+ if (EFI_ERROR (Status)) {
+ if ((Status == EFI_BUFFER_TOO_SMALL) || (Status == EFI_OUT_OF_RESOURCES)) {
+ if (NumberOfPages != NULL) {
+ *NumberOfPages = Image->NumberOfPages;
+ }
+ }
+ goto Done;
+ }
+ if (NumberOfPages != NULL) {
+ *NumberOfPages = Image->NumberOfPages;
+ }
+
+ //
+ // Register the image in the Debug Image Info Table if the attribute is set
+ //
+ if (Attribute & EFI_LOAD_PE_IMAGE_ATTRIBUTE_DEBUG_IMAGE_INFO_TABLE_REGISTRATION) {
+ CoreNewDebugImageInfoEntry (EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL, &Image->Info, Image->Handle);
+ }
+
+ //
+ //Reinstall loaded image protocol to fire any notifications
+ //
+ Status = CoreReinstallProtocolInterface (
+ Image->Handle,
+ &gEfiLoadedImageProtocolGuid,
+ &Image->Info,
+ &Image->Info
+ );
+ if (EFI_ERROR (Status)) {
+ goto Done;
+ }
+
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
+ //
+ // If DevicePath parameter to the LoadImage() is not NULL, then make a copy of DevicePath,
+ // otherwise Loaded Image Device Path Protocol is installed with a NULL interface pointer.
+ //
+ if (OriginalFilePath != NULL) {
+ Image->LoadedImageDevicePath = CoreDuplicateDevicePath (OriginalFilePath);
+ }
+
+ //
+ // Install Loaded Image Device Path Protocol onto the image handle of a PE/COFE image
+ //
+ Status = CoreInstallProtocolInterface (
+ &Image->Handle,
+ &gEfiLoadedImageDevicePathProtocolGuid,
+ EFI_NATIVE_INTERFACE,
+ Image->LoadedImageDevicePath
+ );
+ if (EFI_ERROR (Status)) {
+ goto Done;
+ }
+
+ //
+ // Install HII Package List Protocol onto the image handle
+ //
+ if (Image->ImageContext.HiiResourceData != 0) {
+ Status = CoreInstallProtocolInterface (
+ &Image->Handle,
+ &gEfiHiiPackageListProtocolGuid,
+ EFI_NATIVE_INTERFACE,
+ (VOID *) (UINTN) Image->ImageContext.HiiResourceData
+ );
+ if (EFI_ERROR (Status)) {
+ goto Done;
+ }
+ }
+#endif
+
+ //
+ // Success. Return the image handle
+ //
+ *ImageHandle = Image->Handle;
+
+Done:
+ //
+ // All done accessing the source file
+ // If we allocated the Source buffer, free it
+ //
+ if (FHand.FreeBuffer) {
+ CoreFreePool (FHand.Source);
+ }
+
+ //
+ // There was an error. If there's an Image structure, free it
+ //
+ if (EFI_ERROR (Status)) {
+ if (Image != NULL) {
+ CoreUnloadAndCloseImage (Image, (BOOLEAN)(DstBuffer == 0));
+ *ImageHandle = NULL;
+ }
+ } else if (EFI_ERROR (SecurityStatus)) {
+ Status = SecurityStatus;
+ }
+
+ return Status;
+}
+
+
+EFI_BOOTSERVICE
+EFI_STATUS
+EFIAPI
+CoreLoadImage (
+ IN BOOLEAN BootPolicy,
+ IN EFI_HANDLE ParentImageHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
+ IN VOID *SourceBuffer OPTIONAL,
+ IN UINTN SourceSize,
+ OUT EFI_HANDLE *ImageHandle
+ )
+/*++
+
+Routine Description:
+
+ Loads an EFI image into memory and returns a handle to the image.
+
+Arguments:
+
+ BootPolicy - If TRUE, indicates that the request originates from the boot manager,
+ and that the boot manager is attempting to load FilePath as a boot selection.
+ ParentImageHandle - The caller's image handle.
+ FilePath - The specific file path from which the image is loaded.
+ SourceBuffer - If not NULL, a pointer to the memory location containing a copy of
+ the image to be loaded.
+ SourceSize - The size in bytes of SourceBuffer.
+ ImageHandle - Pointer to the returned image handle that is created when the image
+ is successfully loaded.
+
+Returns:
+
+ EFI_SUCCESS - The image was loaded into memory.
+ EFI_NOT_FOUND - The FilePath was not found.
+ EFI_INVALID_PARAMETER - One of the parameters has an invalid value.
+ EFI_UNSUPPORTED - The image type is not supported, or the device path cannot be
+ parsed to locate the proper protocol for loading the file.
+ EFI_OUT_OF_RESOURCES - Image was not loaded due to insufficient resources.
+--*/
+{
+ EFI_STATUS Status;
+ UINT64 Ticker;
+
+ GetTimerValue (&Ticker);
+
+ Status = CoreLoadImageCommon (
+ BootPolicy,
+ ParentImageHandle,
+ FilePath,
+ SourceBuffer,
+ SourceSize,
+ (EFI_PHYSICAL_ADDRESS)NULL,
+ NULL,
+ ImageHandle,
+ NULL,
+ EFI_LOAD_PE_IMAGE_ATTRIBUTE_RUNTIME_REGISTRATION | EFI_LOAD_PE_IMAGE_ATTRIBUTE_DEBUG_IMAGE_INFO_TABLE_REGISTRATION,
+ FALSE
+ );
+
+ if (!EFI_ERROR (Status)) {
+ PERF_START (0, L"LoadImage", NULL, Ticker);
+ PERF_END (*ImageHandle, L"LoadImage", NULL, 0);
+ } else {
+ PERF_START (0, L"Load Failed", L"CoreLoadImage", Ticker);
+ PERF_END (0, L"Load Failed", L"CoreLoadImage", 0);
+ }
+
+ return Status;
+}
+
+
+EFI_STATUS
+EFIAPI
+CoreLoadImageEx (
+ IN EFI_PE32_IMAGE_PROTOCOL *This,
+ IN EFI_HANDLE ParentImageHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
+ IN VOID *SourceBuffer OPTIONAL,
+ IN UINTN SourceSize,
+ IN EFI_PHYSICAL_ADDRESS DstBuffer OPTIONAL,
+ OUT UINTN *NumberOfPages OPTIONAL,
+ OUT EFI_HANDLE *ImageHandle,
+ OUT EFI_PHYSICAL_ADDRESS *EntryPoint OPTIONAL,
+ IN UINT32 Attribute
+ )
+/*++
+
+Routine Description:
+
+ Loads an EFI image into memory and returns a handle to the image with extended parameters.
+
+Arguments:
+
+ This - Calling context
+ ParentImageHandle - The caller's image handle.
+ FilePath - The specific file path from which the image is loaded.
+ SourceBuffer - If not NULL, a pointer to the memory location containing a copy of
+ the image to be loaded.
+ SourceSize - The size in bytes of SourceBuffer.
+ DstBuffer - The buffer to store the image.
+ NumberOfPages - For input, specifies the space size of the image by caller if not NULL.
+ For output, specifies the actual space size needed.
+ ImageHandle - Image handle for output.
+ EntryPoint - Image entry point for output.
+ Attribute - The bit mask of attributes to set for the load PE image.
+
+Returns:
+
+ EFI_SUCCESS - The image was loaded into memory.
+ EFI_NOT_FOUND - The FilePath was not found.
+ EFI_INVALID_PARAMETER - One of the parameters has an invalid value.
+ EFI_UNSUPPORTED - The image type is not supported, or the device path cannot be
+ parsed to locate the proper protocol for loading the file.
+ EFI_OUT_OF_RESOURCES - Image was not loaded due to insufficient resources.
+--*/
+{
+ return CoreLoadImageCommon (
+ FALSE,
+ ParentImageHandle,
+ FilePath,
+ SourceBuffer,
+ SourceSize,
+ DstBuffer,
+ NumberOfPages,
+ ImageHandle,
+ EntryPoint,
+ Attribute,
+ TRUE
+ );
+}
+
+
+
+EFI_BOOTSERVICE
+EFI_STATUS
+EFIAPI
+CoreStartImage (
+ IN EFI_HANDLE ImageHandle,
+ OUT UINTN *ExitDataSize,
+ OUT CHAR16 **ExitData OPTIONAL
+ )
+/*++
+
+Routine Description:
+
+ Transfer control to a loaded image's entry point.
+
+Arguments:
+
+ ImageHandle - Handle of image to be started.
+
+ ExitDataSize - Pointer of the size to ExitData
+
+ ExitData - Pointer to a pointer to a data buffer that includes a Null-terminated
+ Unicode string, optionally followed by additional binary data. The string
+ is a description that the caller may use to further indicate the reason for
+ the image¡¯s exit.
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Invalid parameter
+
+ EFI_OUT_OF_RESOURCES - No enough buffer to allocate
+
+ EFI_SUCCESS - Successfully transfer control to the image's entry point.
+
+--*/
+{
+ EFI_STATUS Status;
+ LOADED_IMAGE_PRIVATE_DATA *Image;
+ LOADED_IMAGE_PRIVATE_DATA *LastImage;
+ UINT64 HandleDatabaseKey;
+
+ Image = CoreLoadedImageInfo (ImageHandle);
+ if (Image == NULL_HANDLE || Image->Started) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // Cannot start image of an unsupported processor architecture
+ //
+ if (!EFI_IMAGE_MACHINE_TYPE_SUPPORTED (Image->ImageContext.Machine)) {
+ return EFI_UNSUPPORTED;
+ }
+
+ //
+ // Don't profile Objects or invalid start requests
+ //
+ PERF_START (ImageHandle, START_IMAGE_TOK, NULL, 0);
+
+ //
+ // Push the current start image context, and
+ // link the current image to the head. This is the
+ // only image that can call Exit()
+ //
+ HandleDatabaseKey = CoreGetHandleDatabaseKey();
+ LastImage = mCurrentImage;
+ mCurrentImage = Image;
+ Image->Tpl = gEfiCurrentTpl;
+
+ //
+ // Set long jump for Exit() support
+ //
+ Image->JumpContext = CoreAllocateBootServicesPool (gEfiPeiTransferControl->JumpContextSize);
+ if (Image->JumpContext == NULL) {
+ PERF_END (ImageHandle, START_IMAGE_TOK, NULL, 0);
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ Status = gEfiPeiTransferControl->SetJump (gEfiPeiTransferControl, Image->JumpContext);
+ //
+ // The SetJump returns EFI_SUCCESS when LongJump Buffer has been armed
+ // SetJump returns EFI_WARN_RETURN_FROM_LONG_JUMP as a result of the LongJump
+ // All other return values for SetJump are undefined.
+ //
+ if (Status == EFI_SUCCESS) {
+
+ //
+ // Call the image's entry point
+ //
+ Image->Started = TRUE;
+ Image->Status = Image->EntryPoint (ImageHandle, Image->Info.SystemTable);
+
+ //
+ // Add some debug information if the image returned with error.
+ // This make the user aware and check if the driver image have already released
+ // all the resource in this situation.
+ //
+ DEBUG_CODE (
+ if (EFI_ERROR (Image->Status)) {
+ DEBUG ((EFI_D_ERROR, "Error: Image at %08X start failed: %x\n", Image->Info.ImageBase, Image->Status));
+ }
+ )
+
+ //
+ // If the image returns, exit it through Exit()
+ //
+ CoreExit (ImageHandle, Image->Status, 0, NULL);
+ }
+
+ //
+ // Image has completed. Verify the tpl is the same
+ //
+ ASSERT (Image->Tpl == gEfiCurrentTpl);
+ CoreRestoreTpl (Image->Tpl);
+
+ CoreFreePool (Image->JumpContext);
+
+ //
+ // Pop the current start image context
+ //
+ mCurrentImage = LastImage;
+
+ //
+ // Go connect any handles that were created or modified while the image executed.
+ //
+ CoreConnectHandlesByKey (HandleDatabaseKey);
+
+ //
+ // Handle the image's returned ExitData
+ //
+ DEBUG_CODE (
+ if (Image->ExitDataSize != 0 || Image->ExitData != NULL) {
+
+ DEBUG (
+ (EFI_D_LOAD,
+ "StartImage: ExitDataSize %d, ExitData %x",
+ Image->ExitDataSize,
+ Image->ExitData)
+ );
+ if (Image->ExitData != NULL) {
+ DEBUG ((EFI_D_LOAD, " (%hs)", Image->ExitData));
+ }
+ DEBUG ((EFI_D_LOAD, "\n"));
+ }
+ )
+
+ //
+ // Return the exit data to the caller
+ //
+ if (ExitData != NULL && ExitDataSize != NULL) {
+ *ExitDataSize = Image->ExitDataSize;
+ *ExitData = Image->ExitData;
+ } else {
+ //
+ // Caller doesn't want the exit data, free it
+ //
+ CoreFreePool (Image->ExitData);
+ Image->ExitData = NULL;
+ }
+
+ //
+ // Save the Status because Image will get destroyed if it is unloaded.
+ //
+ Status = Image->Status;
+
+ //
+ // If the image returned an error, or if the image is an application
+ // unload it
+ //
+ if (EFI_ERROR (Image->Status) || Image->Type == EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION) {
+ CoreUnloadAndCloseImage (Image, TRUE);
+ }
+
+ //
+ // Done
+ //
+ PERF_END (ImageHandle, START_IMAGE_TOK, NULL, 0);
+ return Status;
+}
+
+
+VOID
+CoreUnloadAndCloseImage (
+ IN LOADED_IMAGE_PRIVATE_DATA *Image,
+ IN BOOLEAN FreePage
+ )
+/*++
+
+Routine Description:
+
+ Unloads EFI image from memory.
+
+Arguments:
+
+ Image - EFI image
+ FreePage - Free allocated pages
+
+Returns:
+
+ None
+
+--*/
+{
+ EFI_STATUS Status;
+ UINTN HandleCount;
+ EFI_HANDLE *HandleBuffer;
+ UINTN HandleIndex;
+ EFI_GUID **ProtocolGuidArray;
+ UINTN ArrayCount;
+ UINTN ProtocolIndex;
+ EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenInfo;
+ UINTN OpenInfoCount;
+ UINTN OpenInfoIndex;
+
+ if (Image->Ebc != NULL) {
+ //
+ // If EBC protocol exists we must perform cleanups for this image.
+ //
+ Image->Ebc->UnloadImage (Image->Ebc, Image->Handle);
+ }
+
+ //
+ // Unload image, free Image->ImageContext->ModHandle
+ //
+ gEfiPeiPeCoffLoader->UnloadImage (&Image->ImageContext);
+
+ //
+ // Free our references to the image handle
+ //
+ if (Image->Handle != NULL_HANDLE) {
+
+ Status = CoreLocateHandleBuffer (
+ AllHandles,
+ NULL,
+ NULL,
+ &HandleCount,
+ &HandleBuffer
+ );
+ if (!EFI_ERROR (Status)) {
+ for (HandleIndex = 0; HandleIndex < HandleCount; HandleIndex++) {
+ Status = CoreProtocolsPerHandle (
+ HandleBuffer[HandleIndex],
+ &ProtocolGuidArray,
+ &ArrayCount
+ );
+ if (!EFI_ERROR (Status)) {
+ for (ProtocolIndex = 0; ProtocolIndex < ArrayCount; ProtocolIndex++) {
+ Status = CoreOpenProtocolInformation (
+ HandleBuffer[HandleIndex],
+ ProtocolGuidArray[ProtocolIndex],
+ &OpenInfo,
+ &OpenInfoCount
+ );
+ if (!EFI_ERROR (Status)) {
+ for (OpenInfoIndex = 0; OpenInfoIndex < OpenInfoCount; OpenInfoIndex++) {
+ if (OpenInfo[OpenInfoIndex].AgentHandle == Image->Handle) {
+ Status = CoreCloseProtocol (
+ HandleBuffer[HandleIndex],
+ ProtocolGuidArray[ProtocolIndex],
+ Image->Handle,
+ OpenInfo[OpenInfoIndex].ControllerHandle
+ );
+ }
+ }
+ if (OpenInfo != NULL) {
+ CoreFreePool(OpenInfo);
+ }
+ }
+ }
+ if (ProtocolGuidArray != NULL) {
+ CoreFreePool(ProtocolGuidArray);
+ }
+ }
+ }
+ if (HandleBuffer != NULL) {
+ CoreFreePool (HandleBuffer);
+ }
+ }
+
+ CoreRemoveDebugImageInfoEntry (Image->Handle);
+
+ Status = CoreUninstallProtocolInterface (
+ Image->Handle,
+ &gEfiLoadedImageProtocolGuid,
+ &Image->Info
+ );
+
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
+ Status = CoreUninstallProtocolInterface (
+ Image->Handle,
+ &gEfiLoadedImageDevicePathProtocolGuid,
+ Image->LoadedImageDevicePath
+ );
+
+ if (Image->LoadedImageDevicePath != NULL) {
+ CoreFreePool (Image->LoadedImageDevicePath);
+ }
+
+ if (Image->ImageContext.HiiResourceData != 0) {
+ Status = CoreUninstallProtocolInterface (
+ Image->Handle,
+ &gEfiHiiPackageListProtocolGuid,
+ (VOID *) (UINTN) Image->ImageContext.HiiResourceData
+ );
+ }
+#endif
+
+ //
+ // Uninstall Debug Mask Protocol
+ //
+ DEBUG_CODE (
+ Status = UninstallDebugMaskProtocol(Image->Handle);
+ ASSERT_EFI_ERROR (Status);
+ )
+
+ }
+
+ if (Image->RuntimeData != NULL) {
+ if (Image->RuntimeData->Link.ForwardLink != NULL) {
+ //
+ // Remove the Image from the Runtime Image list as we are about to Free it!
+ //
+ RemoveEntryList (&Image->RuntimeData->Link);
+ }
+ CoreFreePool (Image->RuntimeData);
+ }
+
+ //
+ // Free the Image from memory
+ //
+ if ((Image->ImageBasePage != 0) && FreePage) {
+ CoreFreePages (Image->ImageBasePage, Image->NumberOfPages);
+ }
+
+ //
+ // Done with the Image structure
+ //
+ if (Image->Info.FilePath != NULL) {
+ CoreFreePool (Image->Info.FilePath);
+ }
+
+ if (Image->FixupData != NULL) {
+ CoreFreePool (Image->FixupData);
+ }
+
+ CoreFreePool (Image);
+}
+
+
+EFI_BOOTSERVICE
+EFI_STATUS
+EFIAPI
+CoreExit (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_STATUS Status,
+ IN UINTN ExitDataSize,
+ IN CHAR16 *ExitData OPTIONAL
+ )
+/*++
+
+Routine Description:
+
+ Terminates the currently loaded EFI image and returns control to boot services.
+
+Arguments:
+
+ ImageHandle - Handle that identifies the image. This parameter is passed to the image
+ on entry.
+ Status - The image¡¯s exit code.
+ ExitDataSize - The size, in bytes, of ExitData. Ignored if ExitStatus is
+ EFI_SUCCESS.
+ ExitData - Pointer to a data buffer that includes a Null-terminated Unicode string,
+ optionally followed by additional binary data. The string is a
+ description that the caller may use to further indicate the reason for
+ the image¡¯s exit.
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Image handle is NULL or it is not current image.
+
+ EFI_SUCCESS - Successfully terminates the currently loaded EFI image.
+
+ EFI_ACCESS_DENIED - Should never reach there.
+
+ EFI_OUT_OF_RESOURCES - Could not allocate pool
+
+--*/
+{
+ LOADED_IMAGE_PRIVATE_DATA *Image;
+
+ Image = CoreLoadedImageInfo (ImageHandle);
+ if (Image == NULL_HANDLE) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (!Image->Started) {
+ //
+ // The image has not been started so just free its resources
+ //
+ CoreUnloadAndCloseImage (Image, TRUE);
+ return EFI_SUCCESS;
+ }
+
+ //
+ // Image has been started, verify this image can exit
+ //
+ if (Image != mCurrentImage) {
+ DEBUG ((EFI_D_LOAD|EFI_D_ERROR, "Exit: Image is not exitable image\n"));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // Set status
+ //
+ Image->Status = Status;
+
+ //
+ // If there's ExitData info, move it
+ //
+ if (ExitData != NULL) {
+ Image->ExitDataSize = ExitDataSize;
+ Image->ExitData = CoreAllocateBootServicesPool (Image->ExitDataSize);
+ if (Image->ExitData == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ EfiCommonLibCopyMem (Image->ExitData, ExitData, Image->ExitDataSize);
+ }
+
+ //
+ // return to StartImage
+ //
+ Status = gEfiPeiTransferControl->LongJump (gEfiPeiTransferControl, Image->JumpContext);
+
+ //
+ // If we return from LongJump, then it is an error
+ //
+ ASSERT (FALSE);
+ return EFI_ACCESS_DENIED;
+}
+
+
+EFI_BOOTSERVICE
+EFI_STATUS
+EFIAPI
+CoreUnloadImage (
+ IN EFI_HANDLE ImageHandle
+ )
+/*++
+
+Routine Description:
+
+ Unloads an image.
+
+Arguments:
+
+ ImageHandle - Handle that identifies the image to be unloaded.
+
+Returns:
+
+ EFI_SUCCESS - The image has been unloaded.
+ EFI_UNSUPPORTED - The image has been sarted, and does not support unload.
+ EFI_INVALID_PARAMPETER - ImageHandle is not a valid image handle.
+
+--*/
+{
+ EFI_STATUS Status;
+ LOADED_IMAGE_PRIVATE_DATA *Image;
+
+ Image = CoreLoadedImageInfo (ImageHandle);
+ if (Image == NULL ) {
+ //
+ // The image handle is not valid
+ //
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (Image->Started) {
+ //
+ // The image has been started, request it to unload.
+ //
+ Status = EFI_UNSUPPORTED;
+ if (Image->Info.Unload != NULL) {
+ Status = Image->Info.Unload (ImageHandle);
+ }
+
+ } else {
+ //
+ // This Image hasn't been started, thus it can be unloaded
+ //
+ Status = EFI_SUCCESS;
+ }
+
+
+ if (!EFI_ERROR (Status)) {
+ //
+ // if the Image was not started or Unloaded O.K. then clean up
+ //
+ CoreUnloadAndCloseImage (Image, TRUE);
+ }
+
+ return Status;
+}
+
+
+EFI_STATUS
+EFIAPI
+CoreUnloadImageEx (
+ IN EFI_PE32_IMAGE_PROTOCOL *This,
+ IN EFI_HANDLE ImageHandle
+ )
+/*++
+
+Routine Description:
+
+ Unload the specified image.
+
+Arguments:
+
+ This - Indicates the calling context.
+
+ ImageHandle - The specified image handle.
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Image handle is NULL.
+
+ EFI_UNSUPPORTED - Attempt to unload an unsupported image.
+
+ EFI_SUCCESS - Image successfully unloaded.
+
+--*/
+{
+ return CoreUnloadImage (ImageHandle);
+}
+
+
+
+//
+// This callback function is used by the EBC interpreter driver to flush the
+// processor instruction cache after creating thunks. We're simply hiding
+// the "this" pointer that must be passed into the real flush function.
+//
+STATIC
+EFI_STATUS
+EFIAPI
+CoreFlushICache (
+ IN EFI_PHYSICAL_ADDRESS Start,
+ IN UINT64 Length
+ )
+/*++
+
+Routine Description:
+
+ flush the processor instruction cache.
+
+Arguments:
+
+ Start - Start adddress in memory to flush.
+
+ Length - Length of memory to flush.
+
+Returns:
+
+--*/
+{
+ return gEfiPeiFlushInstructionCache->Flush (
+ gEfiPeiFlushInstructionCache,
+ Start,
+ Length
+ );
+}
+
+
diff --git a/EDK/Foundation/Core/Dxe/Image/Image.h b/EDK/Foundation/Core/Dxe/Image/Image.h
new file mode 100644
index 0000000..6cee212
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/Image/Image.h
@@ -0,0 +1,399 @@
+/*++
+
+Copyright (c) 2004 - 2008, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Image.h
+
+Abstract:
+
+ EFI image loader
+
+--*/
+
+
+#ifndef _IMAGE_H_
+#define _IMAGE_H_
+
+
+#include "Tiano.h"
+#include "LinkedList.h"
+#include "DxeCore.h"
+
+#include EFI_PROTOCOL_PRODUCER (LoadedImage)
+#include EFI_PROTOCOL_PRODUCER (LoadPe32Image)
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
+#include EFI_PROTOCOL_PRODUCER (LoadedImageDevicePath)
+#include EFI_PROTOCOL_CONSUMER (LoadFile2)
+#include EFI_PROTOCOL_PRODUCER (HiiPackageList)
+#endif
+
+#include EFI_PROTOCOL_CONSUMER (Ebc)
+#include EFI_PROTOCOL_CONSUMER (SimpleFileSystem)
+#include EFI_PROTOCOL_CONSUMER (FileInfo)
+#include EFI_PROTOCOL_CONSUMER (LoadFile)
+#include EFI_PROTOCOL_CONSUMER (FirmwareVolume)
+
+#define LOADED_IMAGE_PRIVATE_DATA_SIGNATURE EFI_SIGNATURE_32('l','d','r','i')
+
+typedef struct {
+ UINTN Signature; // Data Signature
+ EFI_HANDLE Handle; // Image handle
+ UINTN Type; // Image type
+
+ BOOLEAN Started; // If entrypoint has been called
+
+ EFI_IMAGE_ENTRY_POINT EntryPoint; // The image's entry point
+ EFI_LOADED_IMAGE_PROTOCOL Info; // loaded image protocol
+
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
+ EFI_DEVICE_PATH_PROTOCOL *LoadedImageDevicePath; // Loaded Image Device Path Protocl pointer
+#endif
+
+ EFI_PHYSICAL_ADDRESS ImageBasePage; // Location in memory
+ UINTN NumberOfPages; // Number of pages
+
+ CHAR8 *FixupData; // Original fixup data
+
+ EFI_TPL Tpl; // Tpl of started image
+ EFI_STATUS Status; // Status returned by started image
+
+ UINTN ExitDataSize; // Size of ExitData from started image
+ VOID *ExitData; // Pointer to exit data from started image
+ VOID *JumpContext; // Pointer to buffer for context save/retore
+ UINT16 Machine; // Machine type from PE image
+
+ EFI_EBC_PROTOCOL *Ebc; // EBC Protocol pointer
+
+ EFI_RUNTIME_IMAGE_ENTRY *RuntimeData; // Runtime image list
+
+ EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT ImageContext; // PeCoffLoader ImageContext
+} LOADED_IMAGE_PRIVATE_DATA;
+
+#define LOADED_IMAGE_PRIVATE_DATA_FROM_THIS(a) \
+ CR(a, LOADED_IMAGE_PRIVATE_DATA, Info, LOADED_IMAGE_PRIVATE_DATA_SIGNATURE)
+
+
+#define LOAD_PE32_IMAGE_PRIVATE_DATA_SIGNATURE EFI_SIGNATURE_32('l','p','e','i')
+
+typedef struct {
+ UINTN Signature;
+ EFI_HANDLE Handle;
+ EFI_PE32_IMAGE_PROTOCOL Pe32Image;
+} LOAD_PE32_IMAGE_PRIVATE_DATA;
+
+#define LOAD_PE32_IMAGE_PRIVATE_DATA_FROM_THIS(a) \
+ CR(a, LOAD_PE32_IMAGE_PRIVATE_DATA, Pe32Image, LOAD_PE32_IMAGE_PRIVATE_DATA_SIGNATURE)
+
+//
+// Private Data Types
+//
+#define IMAGE_FILE_HANDLE_SIGNATURE EFI_SIGNATURE_32('i','m','g','f')
+typedef struct {
+ UINTN Signature;
+ BOOLEAN FreeBuffer;
+ VOID *Source;
+ UINTN SourceSize;
+} IMAGE_FILE_HANDLE;
+
+
+//
+// Abstractions for reading image contents
+//
+
+EFI_STATUS
+CoreOpenImageFile (
+ IN BOOLEAN BootPolicy,
+ IN VOID *SourceBuffer OPTIONAL,
+ IN UINTN SourceSize,
+ IN OUT EFI_DEVICE_PATH_PROTOCOL **FilePath,
+ OUT EFI_HANDLE *DeviceHandle,
+ IN IMAGE_FILE_HANDLE *ImageFileHandle,
+ OUT UINT32 *AuthenticationStatus
+ )
+/*++
+
+Routine Description:
+
+ Opens a file for (simple) reading. The simple read abstraction
+ will access the file either from a memory copy, from a file
+ system interface, or from the load file interface.
+
+Arguments:
+
+ BootPolicy - Policy for Open Image File.
+ SourceBuffer - Pointer to the memory location containing copy
+ of the image to be loaded.
+ SourceSize - The size in bytes of SourceBuffer.
+ FilePath - The specific file path from which the image is loaded
+ DeviceHandle - Pointer to the return device handle.
+ ImageFileHandle - Pointer to the image file handle.
+ AuthenticationStatus - Pointer to a caller-allocated UINT32 in which the authentication status is returned.
+
+Returns:
+
+ A handle to access the file
+
+--*/
+;
+
+
+EFI_STATUS
+EFIAPI
+CoreReadImageFile (
+ IN VOID *UserHandle,
+ IN UINTN Offset,
+ IN OUT UINTN *ReadSize,
+ OUT VOID *Buffer
+ )
+/*++
+
+Routine Description:
+
+ Read image file (specified by UserHandle) into user specified buffer with specified offset
+ and length.
+
+Arguments:
+
+ UserHandle - Image file handle
+
+ Offset - Offset to the source file
+
+ ReadSize - For input, pointer of size to read;
+ For output, pointer of size actually read.
+
+ Buffer - Buffer to write into
+
+Returns:
+
+ EFI_SUCCESS - Successfully read the specified part of file into buffer.
+
+--*/
+;
+
+VOID
+EFIAPI
+CoreCloseImageFile (
+ IN IMAGE_FILE_HANDLE *ImageFileHandle
+ )
+/*++
+
+Routine Description:
+
+ A function out of date, should be removed.
+
+Arguments:
+
+ ImageFileHandle - Handle of the file to close
+
+Returns:
+
+ None
+
+--*/
+;
+
+//
+// Image processing worker functions
+//
+EFI_STATUS
+CoreDevicePathToInterface (
+ IN EFI_GUID *Protocol,
+ IN OUT EFI_DEVICE_PATH_PROTOCOL **FilePath,
+ OUT VOID **Interface,
+ OUT EFI_HANDLE *Handle
+ )
+/*++
+
+Routine Description:
+
+ Search a handle to a device on a specified device path that supports a specified protocol,
+ interface of that protocol on that handle is another output.
+
+Arguments:
+
+ Protocol - The protocol to search for
+
+ FilePath - The specified device path
+
+ Interface - Interface of the protocol on the handle
+
+ Handle - The handle to the device on the specified device path that supports the protocol.
+
+Returns:
+
+ Status code.
+
+--*/
+;
+
+STATIC
+EFI_STATUS
+CoreLoadPeImage (
+ IN BOOLEAN BootPolicy,
+ IN VOID *Pe32Handle,
+ IN LOADED_IMAGE_PRIVATE_DATA *Image,
+ IN EFI_PHYSICAL_ADDRESS DstBuffer OPTIONAL,
+ OUT EFI_PHYSICAL_ADDRESS *EntryPoint OPTIONAL,
+ IN UINT32 Attribute,
+ IN BOOLEAN CrossLoad
+ )
+/*++
+
+Routine Description:
+
+ Loads, relocates, and invokes a PE/COFF image
+
+Arguments:
+
+ Pe32Handle - The handle of PE32 image
+ Image - PE image to be loaded
+ DstBuffer - The buffer to store the image
+ EntryPoint - A pointer to the entry point
+ Attribute - The bit mask of attributes to set for the load PE image
+ CrossLoad - Whether expect to support cross architecture loading
+
+Returns:
+
+ EFI_SUCCESS - The file was loaded, relocated, and invoked
+
+ EFI_OUT_OF_RESOURCES - There was not enough memory to load and relocate the PE/COFF file
+
+ EFI_INVALID_PARAMETER - Invalid parameter
+
+ EFI_BUFFER_TOO_SMALL - Buffer for image is too small
+
+--*/
+;
+
+LOADED_IMAGE_PRIVATE_DATA *
+CoreLoadedImageInfo (
+ IN EFI_HANDLE ImageHandle
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ ImageHandle - TODO: add argument description
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+
+VOID
+CoreUnloadAndCloseImage (
+ IN LOADED_IMAGE_PRIVATE_DATA *Image,
+ IN BOOLEAN FreePage
+ )
+/*++
+
+Routine Description:
+
+ Unloads EFI image from memory.
+
+Arguments:
+
+ Image - EFI image
+ FreePage - Free allocated pages
+
+Returns:
+
+ None
+
+--*/
+;
+
+
+//
+// Exported Image functions
+//
+
+EFI_STATUS
+EFIAPI
+CoreLoadImageEx (
+ IN EFI_PE32_IMAGE_PROTOCOL *This,
+ IN EFI_HANDLE ParentImageHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
+ IN VOID *SourceBuffer OPTIONAL,
+ IN UINTN SourceSize,
+ IN EFI_PHYSICAL_ADDRESS DstBuffer OPTIONAL,
+ OUT UINTN *NumberOfPages OPTIONAL,
+ OUT EFI_HANDLE *ImageHandle,
+ OUT EFI_PHYSICAL_ADDRESS *EntryPoint OPTIONAL,
+ IN UINT32 Attribute
+ )
+/*++
+
+Routine Description:
+
+ Loads an EFI image into memory and returns a handle to the image with extended parameters.
+
+Arguments:
+
+ ParentImageHandle - The caller's image handle.
+ FilePath - The specific file path from which the image is loaded.
+ SourceBuffer - If not NULL, a pointer to the memory location containing a copy of
+ the image to be loaded.
+ SourceSize - The size in bytes of SourceBuffer.
+ DstBuffer - The buffer to store the image.
+ NumberOfPages - For input, specifies the space size of the image by caller if not NULL.
+ For output, specifies the actual space size needed.
+ ImageHandle - Image handle for output.
+ EntryPoint - Image entry point for output.
+ Attribute - The bit mask of attributes to set for the load PE image.
+
+Returns:
+
+ EFI_SUCCESS - The image was loaded into memory.
+ EFI_NOT_FOUND - The FilePath was not found.
+ EFI_INVALID_PARAMETER - One of the parameters has an invalid value.
+ EFI_UNSUPPORTED - The image type is not supported, or the device path cannot be
+ parsed to locate the proper protocol for loading the file.
+ EFI_OUT_OF_RESOURCES - Image was not loaded due to insufficient resources.
+--*/
+;
+
+EFI_STATUS
+EFIAPI
+CoreUnloadImageEx (
+ IN EFI_PE32_IMAGE_PROTOCOL *This,
+ IN EFI_HANDLE ImageHandle
+ )
+/*++
+
+Routine Description:
+
+ Unload the specified image.
+
+Arguments:
+
+ This - Indicates the calling context.
+
+ ImageHandle - The specified image handle.
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Image handle is NULL.
+
+ EFI_UNSUPPORTED - Attempt to unload an unsupported image.
+
+ EFI_SUCCESS - Image successfully unloaded.
+
+--*/
+;
+#endif
diff --git a/EDK/Foundation/Core/Dxe/Image/ImageFile.c b/EDK/Foundation/Core/Dxe/Image/ImageFile.c
new file mode 100644
index 0000000..462446f
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/Image/ImageFile.c
@@ -0,0 +1,646 @@
+/*++
+
+Copyright (c) 2004 - 2011, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ ImageFile.c
+
+
+Abstract:
+
+
+
+
+Revision History
+
+--*/
+
+#include "Image.h"
+#include "DxeCore.h"
+
+
+VOID
+CoreDevicePathToFileName (
+ IN FILEPATH_DEVICE_PATH *FilePath,
+ OUT CHAR16 **String
+ );
+
+
+
+EFI_STATUS
+CoreOpenImageFile (
+ IN BOOLEAN BootPolicy,
+ IN VOID *SourceBuffer OPTIONAL,
+ IN UINTN SourceSize,
+ IN OUT EFI_DEVICE_PATH_PROTOCOL **FilePath,
+ OUT EFI_HANDLE *DeviceHandle,
+ IN IMAGE_FILE_HANDLE *ImageFileHandle,
+ OUT UINT32 *AuthenticationStatus
+ )
+/*++
+
+Routine Description:
+
+ Opens a file for (simple) reading. The simple read abstraction
+ will access the file either from a memory copy, from a file
+ system interface, or from the load file interface.
+
+Arguments:
+
+ BootPolicy - Policy for Open Image File.
+ SourceBuffer - Pointer to the memory location containing copy
+ of the image to be loaded.
+ SourceSize - The size in bytes of SourceBuffer.
+ FilePath - The specific file path from which the image is loaded
+ DeviceHandle - Pointer to the return device handle.
+ ImageFileHandle - Pointer to the image file handle.
+ AuthenticationStatus - Pointer to a caller-allocated UINT32 in which the authentication status is returned.
+
+Returns:
+
+ EFI_SUCCESS - Image file successfully opened.
+
+ EFI_LOAD_ERROR - If the caller passed a copy of the file, and SourceSize is 0.
+
+ EFI_INVALID_PARAMETER - File path is not valid.
+
+ EFI_NOT_FOUND - File not found.
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_DEVICE_PATH_PROTOCOL *TempFilePath;
+ FILEPATH_DEVICE_PATH *FilePathNode;
+ MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FwVolFilePathNode;
+ EFI_SIMPLE_FILE_SYSTEM_PROTOCOL *Volume;
+ EFI_FILE_HANDLE FileHandle;
+ EFI_FILE_HANDLE LastHandle;
+ EFI_LOAD_FILE_PROTOCOL *LoadFile;
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
+ EFI_LOAD_FILE2_PROTOCOL *LoadFile2;
+#endif
+ EFI_SECTION_TYPE SectionType;
+ UINT8 *Pe32Buffer;
+ UINTN Pe32BufferSize;
+ EFI_FV_FILETYPE Type;
+ EFI_FV_FILE_ATTRIBUTES Attrib;
+ EFI_FILE_INFO *FileInfo;
+ UINTN FileInfoSize;
+ EFI_GUID *NameGuid;
+ FILEPATH_DEVICE_PATH *OriginalFilePathNode;
+#if (PI_SPECIFICATION_VERSION < 0x00010000)
+ EFI_FIRMWARE_VOLUME_PROTOCOL *FwVol;
+#else
+ EFI_FIRMWARE_VOLUME2_PROTOCOL *FwVol;
+#endif
+
+ *AuthenticationStatus = 0;
+ EfiCommonLibZeroMem (ImageFileHandle, sizeof (IMAGE_FILE_HANDLE));
+ ImageFileHandle->Signature = IMAGE_FILE_HANDLE_SIGNATURE;
+
+ //
+ // If the caller passed a copy of the file, then just use it
+ //
+ if (SourceBuffer != NULL) {
+ ImageFileHandle->Source = SourceBuffer;
+ ImageFileHandle->SourceSize = SourceSize;
+ *DeviceHandle = NULL;
+ CoreLocateDevicePath (&gEfiDevicePathProtocolGuid, FilePath, DeviceHandle);
+ if (SourceSize > 0) {
+ Status = EFI_SUCCESS;
+ } else {
+ Status = EFI_LOAD_ERROR;
+ }
+ goto Done;
+ }
+
+ //
+ // Make sure FilePath is valid
+ //
+ if (*FilePath == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // Check to see if it's in a Firmware Volume
+ //
+ FwVolFilePathNode = (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) *FilePath;
+ Status = CoreDevicePathToInterface (
+ #if (PI_SPECIFICATION_VERSION < 0x00010000)
+ &gEfiFirmwareVolumeProtocolGuid,
+ #else
+ &gEfiFirmwareVolume2ProtocolGuid,
+ #endif
+ (EFI_DEVICE_PATH_PROTOCOL **)&FwVolFilePathNode,
+ (VOID*)&FwVol,
+ DeviceHandle
+ );
+ if (!EFI_ERROR (Status) && (FwVol != NULL)) {
+ //
+ // For FwVol File system there is only a single file name that is a GUID.
+ //
+ NameGuid = CoreGetNameGuidFromFwVolDevicePathNode (FwVolFilePathNode);
+ if (NameGuid != NULL) {
+
+ SectionType = EFI_SECTION_PE32;
+ Pe32Buffer = NULL;
+ Status = FwVol->ReadSection (
+ FwVol,
+ &FwVolFilePathNode->NameGuid,
+ SectionType,
+ 0,
+ &Pe32Buffer,
+ &Pe32BufferSize,
+ AuthenticationStatus
+ );
+ if (EFI_ERROR (Status)) {
+ //
+ // Try a raw file, since a PE32 SECTION does not exist
+ //
+ if (Pe32Buffer != NULL) {
+ CoreFreePool (Pe32Buffer);
+ *AuthenticationStatus = 0;
+ }
+ Pe32Buffer = NULL;
+ Status = FwVol->ReadFile (
+ FwVol,
+ &FwVolFilePathNode->NameGuid,
+ &Pe32Buffer,
+ &Pe32BufferSize,
+ &Type,
+ &Attrib,
+ AuthenticationStatus
+ );
+ }
+
+ if (!EFI_ERROR (Status)) {
+ //
+ // One of the reads passed so we are done
+ //
+ ImageFileHandle->Source = Pe32Buffer;
+ ImageFileHandle->SourceSize = Pe32BufferSize;
+ ImageFileHandle->FreeBuffer = TRUE;
+ goto Done;
+ }
+ }
+ }
+
+ //
+ // Attempt to access the file via a file system interface
+ //
+ FilePathNode = (FILEPATH_DEVICE_PATH *) *FilePath;
+ Status = CoreDevicePathToInterface (
+ &gEfiSimpleFileSystemProtocolGuid,
+ (EFI_DEVICE_PATH_PROTOCOL **)&FilePathNode,
+ (VOID*)&Volume,
+ DeviceHandle
+ );
+ if (!EFI_ERROR (Status) && (Volume != NULL)) {
+ //
+ // Open the Volume to get the File System handle
+ //
+ Status = Volume->OpenVolume (Volume, &FileHandle);
+ if (!EFI_ERROR (Status)) {
+ //
+ // Duplicate the device path to avoid the access to unaligned device path node.
+ // Because the device path consists of one or more FILE PATH MEDIA DEVICE PATH
+ // nodes, It assures the fields in device path nodes are 2 byte aligned.
+ //
+ FilePathNode = (FILEPATH_DEVICE_PATH *) CoreDuplicateDevicePath(
+ (EFI_DEVICE_PATH_PROTOCOL *)(UINTN)FilePathNode
+ );
+ if (FilePathNode == NULL) {
+ FileHandle->Close (FileHandle);
+ FileHandle = NULL;
+ Status = EFI_OUT_OF_RESOURCES;
+ } else {
+ OriginalFilePathNode = FilePathNode;
+ //
+ // Parse each MEDIA_FILEPATH_DP node. There may be more than one, since the
+ // directory information and filename can be seperate. The goal is to inch
+ // our way down each device path node and close the previous node
+ //
+ while (!IsDevicePathEnd (&FilePathNode->Header)) {
+ if (DevicePathType (&FilePathNode->Header) != MEDIA_DEVICE_PATH ||
+ DevicePathSubType (&FilePathNode->Header) != MEDIA_FILEPATH_DP) {
+ Status = EFI_UNSUPPORTED;
+ }
+
+ if (EFI_ERROR (Status)) {
+ //
+ // Exit loop on Error
+ //
+ break;
+ }
+
+ LastHandle = FileHandle;
+ FileHandle = NULL;
+ Status = LastHandle->Open (
+ LastHandle,
+ &FileHandle,
+ FilePathNode->PathName,
+ EFI_FILE_MODE_READ,
+ 0
+ );
+
+ //
+ // Close the previous node
+ //
+ LastHandle->Close (LastHandle);
+
+ FilePathNode = (FILEPATH_DEVICE_PATH *) NextDevicePathNode (&FilePathNode->Header);
+ }
+ //
+ // Free the allocated memory pool
+ //
+ CoreFreePool (OriginalFilePathNode);
+ }
+
+ if (!EFI_ERROR (Status)) {
+ //
+ // We have found the file. Now we need to read it. Before we can read the file we need to
+ // figure out how big the file is.
+ //
+ FileInfo = NULL;
+ FileInfoSize = sizeof (EFI_FILE_INFO);
+ while (CoreGrowBuffer (&Status, &FileInfo, FileInfoSize)) {
+ //
+ // Automatically allocate buffer of the correct size and make the call
+ //
+ Status = FileHandle->GetInfo (
+ FileHandle,
+ &gEfiFileInfoGuid,
+ &FileInfoSize,
+ FileInfo
+ );
+ }
+ if (!EFI_ERROR (Status) && (FileInfo != NULL)) {
+ //
+ // Allocate space for the file
+ //
+ ImageFileHandle->Source = CoreAllocateBootServicesPool ((UINTN)FileInfo->FileSize);
+ if (ImageFileHandle->Source != NULL) {
+ //
+ // Read the file into the buffer we allocated
+ //
+ ImageFileHandle->SourceSize = (UINTN)FileInfo->FileSize;
+ ImageFileHandle->FreeBuffer = TRUE;
+ Status = FileHandle->Read (FileHandle, &ImageFileHandle->SourceSize, ImageFileHandle->Source);
+ } else {
+ Status = EFI_OUT_OF_RESOURCES;
+ }
+ //
+ // Close the file since we are done
+ //
+ FileHandle->Close (FileHandle);
+ CoreFreePool (FileInfo);
+ goto Done;
+ }
+
+ if (FileInfo != NULL) {
+ CoreFreePool (FileInfo);
+ }
+ }
+ if (FileHandle != NULL) {
+ FileHandle->Close (FileHandle);
+ }
+ }
+ }
+
+
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
+ //
+ // Try LoadFile2 style
+ //
+ if (!BootPolicy) {
+ TempFilePath = *FilePath;
+ Status = CoreDevicePathToInterface (
+ &gEfiLoadFile2ProtocolGuid,
+ &TempFilePath,
+ (VOID*)&LoadFile2,
+ DeviceHandle
+ );
+ if (!EFI_ERROR (Status) && (LoadFile2 != NULL)) {
+ //
+ // Call LoadFile2 with the correct buffer size
+ //
+ while (CoreGrowBuffer (&Status, &ImageFileHandle->Source, ImageFileHandle->SourceSize)) {
+ Status = LoadFile2->LoadFile (
+ LoadFile2,
+ TempFilePath,
+ BootPolicy,
+ &ImageFileHandle->SourceSize,
+ ImageFileHandle->Source
+ );
+ //
+ // If success or other error happens, stop loop
+ //
+ if (Status != EFI_BUFFER_TOO_SMALL) {
+ break;
+ }
+ }
+
+ if (!EFI_ERROR (Status)) {
+ ImageFileHandle->FreeBuffer = TRUE;
+ goto Done;
+ }
+ }
+ }
+#endif
+
+ //
+ // Try LoadFile style
+ //
+ TempFilePath = *FilePath;
+ Status = CoreDevicePathToInterface (
+ &gEfiLoadFileProtocolGuid,
+ &TempFilePath,
+ (VOID*)&LoadFile,
+ DeviceHandle
+ );
+ if (!EFI_ERROR (Status) && (LoadFile != NULL)) {
+ //
+ // Call LoadFile with the correct buffer size
+ //
+ while (CoreGrowBuffer (&Status, &ImageFileHandle->Source, ImageFileHandle->SourceSize)) {
+ Status = LoadFile->LoadFile (
+ LoadFile,
+ TempFilePath,
+ BootPolicy,
+ &ImageFileHandle->SourceSize,
+ ImageFileHandle->Source
+ );
+ //
+ // If success or other error happens, stop loop
+ //
+ if (Status != EFI_BUFFER_TOO_SMALL) {
+ break;
+ }
+ }
+
+ if (!EFI_ERROR (Status) || Status == EFI_ALREADY_STARTED) {
+ ImageFileHandle->FreeBuffer = TRUE;
+ goto Done;
+ }
+ }
+
+ //
+ // Nothing else to try
+ //
+ DEBUG ((EFI_D_LOAD|EFI_D_WARN, "CoreOpenImageFile: Device did not support a known load protocol\n"));
+ Status = EFI_NOT_FOUND;
+
+Done:
+
+ //
+ // If the file was not accessed, clean up
+ //
+ if (EFI_ERROR (Status) && (Status != EFI_ALREADY_STARTED)) {
+ if (ImageFileHandle->FreeBuffer) {
+ //
+ // Free the source buffer if we allocated it
+ //
+ CoreFreePool (ImageFileHandle->Source);
+ }
+ }
+
+ return Status;
+}
+
+
+
+EFI_STATUS
+EFIAPI
+CoreReadImageFile (
+ IN VOID *UserHandle,
+ IN UINTN Offset,
+ IN OUT UINTN *ReadSize,
+ OUT VOID *Buffer
+ )
+/*++
+
+Routine Description:
+
+ Read image file (specified by UserHandle) into user specified buffer with specified offset
+ and length.
+
+Arguments:
+
+ UserHandle - Image file handle
+
+ Offset - Offset to the source file
+
+ ReadSize - For input, pointer of size to read;
+ For output, pointer of size actually read.
+
+ Buffer - Buffer to write into
+
+Returns:
+
+ EFI_SUCCESS - Successfully read the specified part of file into buffer.
+
+--*/
+{
+ UINTN EndPosition;
+ IMAGE_FILE_HANDLE *FHand;
+
+ FHand = (IMAGE_FILE_HANDLE *)UserHandle;
+ ASSERT (FHand->Signature == IMAGE_FILE_HANDLE_SIGNATURE);
+
+ //
+ // Move data from our local copy of the file
+ //
+ EndPosition = Offset + *ReadSize;
+ if (EndPosition > FHand->SourceSize) {
+ *ReadSize = (UINT32)(FHand->SourceSize - Offset);
+ }
+ if (Offset >= FHand->SourceSize) {
+ *ReadSize = 0;
+ }
+
+ EfiCommonLibCopyMem (Buffer, (CHAR8 *)FHand->Source + Offset, *ReadSize);
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+CoreDevicePathToInterface (
+ IN EFI_GUID *Protocol,
+ IN EFI_DEVICE_PATH_PROTOCOL **FilePath,
+ OUT VOID **Interface,
+ OUT EFI_HANDLE *Handle
+ )
+/*++
+
+Routine Description:
+
+ Search a handle to a device on a specified device path that supports a specified protocol,
+ interface of that protocol on that handle is another output.
+
+Arguments:
+
+ Protocol - The protocol to search for
+
+ FilePath - The specified device path
+
+ Interface - Interface of the protocol on the handle
+
+ Handle - The handle to the device on the specified device path that supports the protocol.
+
+Returns:
+
+ Status code.
+
+--*/
+{
+ EFI_STATUS Status;
+
+ Status = CoreLocateDevicePath (Protocol, FilePath, Handle);
+ if (!EFI_ERROR (Status)) {
+ Status = CoreHandleProtocol (*Handle, Protocol, Interface);
+ }
+ return Status;
+}
+
+
+VOID
+CoreDevicePathToFileName (
+ IN FILEPATH_DEVICE_PATH *FilePath,
+ OUT CHAR16 **String
+ )
+/*++
+
+Routine Description:
+
+ Transfer a device's full path a string.
+
+Arguments:
+
+ FilePath - Device path
+
+ String - The string represent the device's full path
+
+Returns:
+
+ None
+
+--*/
+{
+ UINTN StringSize;
+ FILEPATH_DEVICE_PATH *FilePathNode;
+ CHAR16 *Str;
+
+ *String = NULL;
+ StringSize = 0;
+ FilePathNode = FilePath;
+ while (!IsDevicePathEnd (&FilePathNode->Header)) {
+
+ //
+ // For filesystem access each node should be a filepath component
+ //
+ if (DevicePathType (&FilePathNode->Header) != MEDIA_DEVICE_PATH ||
+ DevicePathSubType (&FilePathNode->Header) != MEDIA_FILEPATH_DP) {
+
+ return;
+ }
+
+ StringSize += EfiStrLen (FilePathNode->PathName);
+
+ FilePathNode = (FILEPATH_DEVICE_PATH *) NextDevicePathNode (&FilePathNode->Header);
+ }
+
+ *String = CoreAllocateBootServicesPool (StringSize);
+ if (*String == NULL) {
+ return;
+ }
+
+ FilePathNode = FilePath;
+ Str = *String;
+ while (!IsDevicePathEnd (&FilePathNode->Header)) {
+ EfiStrCat (Str, FilePathNode->PathName);
+ FilePathNode = (FILEPATH_DEVICE_PATH *) NextDevicePathNode (&FilePathNode->Header);
+ }
+}
+
+
+BOOLEAN
+CoreGrowBuffer (
+ IN OUT EFI_STATUS *Status,
+ IN OUT VOID **Buffer,
+ IN UINTN BufferSize
+ )
+/*++
+
+Routine Description:
+
+ Helper function called as part of the code needed
+ to allocate the proper sized buffer for various
+ EFI interfaces.
+
+Arguments:
+
+ Status - Current status
+
+ Buffer - Current allocated buffer, or NULL
+
+ BufferSize - Current buffer size needed
+
+Returns:
+
+ TRUE - if the buffer was reallocated and the caller
+ should try the API again.
+
+ FALSE - buffer could not be allocated and the caller
+ should not try the API again.
+
+--*/
+{
+ BOOLEAN TryAgain;
+
+ TryAgain = FALSE;
+ //
+ // If this is an initial request, buffer will be null with a new buffer size
+ //
+ if (*Buffer == NULL) {
+ *Status = EFI_BUFFER_TOO_SMALL;
+ }
+
+ if (BufferSize == 0) {
+ return TRUE;
+ }
+
+ //
+ // If the status code is "buffer too small", resize the buffer
+ //
+
+ if (*Status == EFI_BUFFER_TOO_SMALL) {
+ if (*Buffer != NULL) {
+ CoreFreePool (*Buffer);
+ }
+
+ *Buffer = CoreAllocateBootServicesPool (BufferSize);
+ if (*Buffer != NULL) {
+ TryAgain = TRUE;
+ } else {
+ *Status = EFI_OUT_OF_RESOURCES;
+ }
+ }
+
+ //
+ // If there's an error, free the buffer
+ //
+ if ((!TryAgain) && (EFI_ERROR (*Status)) && (*Buffer)) {
+ CoreFreePool (*Buffer);
+ *Buffer = NULL;
+ }
+
+ return TryAgain;
+}
+
diff --git a/EDK/Foundation/Core/Dxe/Include/DxeCore.h b/EDK/Foundation/Core/Dxe/Include/DxeCore.h
new file mode 100644
index 0000000..2587d7c
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/Include/DxeCore.h
@@ -0,0 +1,2535 @@
+/*++
+
+Copyright (c) 2004 - 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ DxeCore.h
+
+Abstract:
+
+Revision History
+
+--*/
+
+#ifndef _DXECORE_H_
+#define _DXECORE_H_
+
+#include EFI_GUID_DEFINITION (PeiFlushInstructionCache)
+#include EFI_GUID_DEFINITION (PeiPeCoffLoader)
+#include EFI_GUID_DEFINITION (PeiTransferControl)
+#include EFI_GUID_DEFINITION (Hob)
+#include EFI_GUID_DEFINITION (StatusCodeDataTypeId)
+#include EFI_GUID_DEFINITION (DxeServices)
+#include EFI_GUID_DEFINITION (MemoryTypeInformation)
+#include EFI_GUID_DEFINITION (StatusCodeCallerId)
+#include EFI_GUID_DEFINITION (EventGroup)
+#include EFI_GUID_DEFINITION (EventLegacyBios)
+#include EFI_GUID_DEFINITION (FrameworkDevicePath)
+#include EFI_ARCH_PROTOCOL_DEFINITION (Cpu)
+#include EFI_ARCH_PROTOCOL_DEFINITION (Metronome)
+#include EFI_ARCH_PROTOCOL_DEFINITION (MonotonicCounter)
+#include EFI_ARCH_PROTOCOL_DEFINITION (Timer)
+#include EFI_ARCH_PROTOCOL_DEFINITION (Bds)
+#include EFI_ARCH_PROTOCOL_DEFINITION (Reset)
+#include EFI_ARCH_PROTOCOL_DEFINITION (RealTimeClock)
+#include EFI_ARCH_PROTOCOL_DEFINITION (Variable)
+#include EFI_ARCH_PROTOCOL_DEFINITION (VariableWrite)
+#include EFI_ARCH_PROTOCOL_DEFINITION (Capsule)
+#include EFI_ARCH_PROTOCOL_DEFINITION (WatchdogTimer)
+#include EFI_ARCH_PROTOCOL_DEFINITION (Runtime)
+#include EFI_ARCH_PROTOCOL_DEFINITION (StatusCode)
+#include EFI_ARCH_PROTOCOL_DEFINITION (Security)
+#include EFI_PROTOCOL_DEFINITION (Decompress)
+#include EFI_PROTOCOL_DEFINITION (TianoDecompress)
+#include EFI_PROTOCOL_DEFINITION (CustomizedDecompress)
+#include EFI_PROTOCOL_DEFINITION (FirmwareVolume)
+#include EFI_PROTOCOL_DEFINITION (FirmwareVolumeDispatch)
+#include EFI_PROTOCOL_DEFINITION (LoadedImage)
+#include EFI_PROTOCOL_DEFINITION (TcgService)
+#include "LinkedList.h"
+#include "DebugImageInfo.h"
+#include "EfiCommonLib.h"
+#include "Library.h"
+#include "Peihob.h"
+#include "EfiHobLib.h"
+#include "DebugMask.h"
+
+
+typedef struct {
+ EFI_GUID *ProtocolGuid;
+ VOID **Protocol;
+ EFI_EVENT Event;
+ VOID *Registration;
+ BOOLEAN Present;
+} ARCHITECTURAL_PROTOCOL_ENTRY;
+
+
+//
+// DXE Dispatcher Data structures
+//
+
+#define KNOWN_HANDLE_SIGNATURE EFI_SIGNATURE_32('k','n','o','w')
+typedef struct {
+ UINTN Signature;
+ EFI_LIST_ENTRY Link; // mFvHandleList
+ EFI_HANDLE Handle;
+} KNOWN_HANDLE;
+
+
+#define EFI_CORE_DRIVER_ENTRY_SIGNATURE EFI_SIGNATURE_32('d','r','v','r')
+typedef struct {
+ UINTN Signature;
+ EFI_LIST_ENTRY Link; // mDriverList
+
+ EFI_LIST_ENTRY ScheduledLink; // mScheduledQueue
+
+ EFI_HANDLE FvHandle;
+ EFI_GUID FileName;
+ EFI_DEVICE_PATH_PROTOCOL *FvFileDevicePath;
+#if (PI_SPECIFICATION_VERSION < 0x00010000)
+ EFI_FIRMWARE_VOLUME_PROTOCOL *Fv;
+#else
+ EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv;
+#endif
+ VOID *Depex;
+ UINTN DepexSize;
+
+ BOOLEAN Before;
+ BOOLEAN After;
+ EFI_GUID BeforeAfterGuid;
+
+ BOOLEAN Dependent;
+ BOOLEAN Unrequested;
+ BOOLEAN Scheduled;
+ BOOLEAN Untrusted;
+ BOOLEAN Initialized;
+ BOOLEAN DepexProtocolError;
+
+ EFI_HANDLE ImageHandle;
+
+} EFI_CORE_DRIVER_ENTRY;
+
+//
+//The data structure of GCD memory map entry
+//
+#define EFI_GCD_MAP_SIGNATURE EFI_SIGNATURE_32('g','c','d','m')
+typedef struct {
+ UINTN Signature;
+ EFI_LIST_ENTRY Link;
+ EFI_PHYSICAL_ADDRESS BaseAddress;
+ UINT64 EndAddress;
+ UINT64 Capabilities;
+ UINT64 Attributes;
+ EFI_GCD_MEMORY_TYPE GcdMemoryType;
+ EFI_GCD_IO_TYPE GcdIoType;
+ EFI_HANDLE ImageHandle;
+ EFI_HANDLE DeviceHandle;
+} EFI_GCD_MAP_ENTRY;
+
+//
+// DXE Core Global Variables
+//
+extern EFI_SYSTEM_TABLE *gST;
+extern EFI_BOOT_SERVICES *gBS;
+extern EFI_RUNTIME_SERVICES *gRT;
+extern EFI_DXE_SERVICES *gDS;
+extern EFI_HANDLE gDxeCoreImageHandle;
+
+extern EFI_DECOMPRESS_PROTOCOL *gEfiDecompress;
+extern EFI_PEI_FLUSH_INSTRUCTION_CACHE_PROTOCOL *gEfiPeiFlushInstructionCache;
+extern EFI_PEI_PE_COFF_LOADER_PROTOCOL *gEfiPeiPeCoffLoader;
+extern EFI_PEI_TRANSFER_CONTROL_PROTOCOL *gEfiPeiTransferControl;
+
+extern EFI_RUNTIME_ARCH_PROTOCOL *gRuntime;
+extern EFI_CPU_ARCH_PROTOCOL *gCpu;
+extern EFI_WATCHDOG_TIMER_ARCH_PROTOCOL *gWatchdogTimer;
+extern EFI_METRONOME_ARCH_PROTOCOL *gMetronome;
+extern EFI_TIMER_ARCH_PROTOCOL *gTimer;
+extern EFI_SECURITY_ARCH_PROTOCOL *gSecurity;
+extern EFI_BDS_ARCH_PROTOCOL *gBds;
+extern EFI_STATUS_CODE_PROTOCOL *gStatusCode;
+
+extern EFI_TPL gEfiCurrentTpl;
+
+extern EFI_GUID *gDxeCoreFileName;
+extern EFI_LOADED_IMAGE_PROTOCOL *gDxeCoreLoadedImage;
+
+extern EFI_MEMORY_TYPE_INFORMATION gMemoryTypeInformation[EfiMaxMemoryType + 1];
+
+extern EFI_RUNTIME_ARCH_PROTOCOL gRuntimeTemplate;
+
+//
+// Service Initialization Functions
+//
+
+
+VOID
+CoreInitializePool (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Called to initialize the pool.
+
+Arguments:
+
+ None
+
+Returns:
+
+ None
+
+--*/
+;
+
+VOID
+CoreAddMemoryDescriptor (
+ IN EFI_MEMORY_TYPE Type,
+ IN EFI_PHYSICAL_ADDRESS Start,
+ IN UINT64 NumberOfPages,
+ IN UINT64 Attribute
+ )
+/*++
+
+Routine Description:
+
+ Called to initialize the memory map and add descriptors to
+ the current descriptor list.
+
+ N.B. The first descriptor that is added must be general usable
+ memory as the addition allocates heap.
+
+Arguments:
+
+ Type - The type of memory to add
+
+ Start - The starting address in the memory range
+ Must be page aligned
+
+ NumberOfPages - The number of pages in the range
+
+ Attribute - Attributes of the memory to add
+
+Returns:
+
+ None. The range is added to the memory map
+
+--*/
+;
+
+VOID
+CoreReleaseGcdMemoryLock (
+ VOID
+ )
+/*++
+
+Routine Description:
+ Release memory lock on mGcdMemorySpaceLock
+
+Arguments:
+ None
+
+Returns:
+ None
+
+--*/
+;
+
+VOID
+CoreAcquireGcdMemoryLock (
+ VOID
+ )
+/*++
+
+Routine Description:
+ Acquire memory lock on mGcdMemorySpaceLock
+
+Arguments:
+ None
+
+Returns:
+ None
+
+--*/
+;
+
+EFI_STATUS
+CoreInitializeMemoryServices (
+ IN VOID **HobStart,
+ IN EFI_PHYSICAL_ADDRESS *MemoryBaseAddress,
+ IN UINT64 *MemoryLength
+ )
+/*++
+
+Routine Description:
+
+ External function. Initializes the GCD and memory services based on the memory
+ descriptor HOBs. This function is responsible for priming the GCD map and the
+ memory map, so memory allocations and resource allocations can be made. The first
+ part of this function can not depend on any memory services until at least one
+ memory descriptor is provided to the memory services. Then the memory services
+ can be used to intialize the GCD map.
+
+Arguments:
+
+ HobStart - The start address of the HOB.
+
+ MemoryBaseAddress - Start address of memory region found to init DXE core.
+
+ MemoryLength - Length of memory region found to init DXE core.
+
+Returns:
+
+ EFI_SUCCESS - Memory services successfully initialized.
+
+--*/
+;
+
+
+EFI_STATUS
+CoreInitializeGcdServices (
+ IN OUT VOID **HobStart,
+ IN EFI_PHYSICAL_ADDRESS MemoryBaseAddress,
+ IN UINT64 MemoryLength
+ )
+/*++
+
+Routine Description:
+
+ External function. Initializes the GCD and memory services based on the memory
+ descriptor HOBs. This function is responsible for priming the GCD map and the
+ memory map, so memory allocations and resource allocations can be made. The first
+ part of this function can not depend on any memory services until at least one
+ memory descriptor is provided to the memory services. Then the memory services
+ can be used to intialize the GCD map. The HobStart will be relocated to a pool
+ buffer.
+
+Arguments:
+
+ HobStart - The start address of the HOB
+
+ MemoryBaseAddress - Start address of memory region found to init DXE core.
+
+ MemoryLength - Length of memory region found to init DXE core.
+
+
+Returns:
+
+ EFI_SUCCESS - GCD services successfully initialized.
+
+--*/
+;
+
+EFI_STATUS
+CoreInitializeEventServices (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Initializes "event" support and populates parts of the System and Runtime Table.
+
+Arguments:
+
+ None
+
+Returns:
+
+ EFI_SUCCESS - Always return success
+
+--*/
+;
+
+EFI_STATUS
+CoreInitializeImageServices (
+ IN VOID *HobStart
+ )
+/*++
+
+Routine Description:
+
+ Add the Image Services to EFI Boot Services Table and install the protocol
+ interfaces for this image.
+
+Arguments:
+
+ HobStart - The HOB to initialize
+
+Returns:
+
+ Status code.
+
+--*/
+;
+
+VOID
+CoreNotifyOnArchProtocolInstallation (
+ VOID
+ )
+/*++
+
+Routine Description:
+ Creates an event that is fired everytime a Protocol of a specific type is installed
+
+Arguments:
+ NONE
+
+Returns:
+ NONE
+
+--*/
+;
+
+EFI_STATUS
+CoreAllEfiServicesAvailable (
+ VOID
+ )
+/*++
+
+Routine Description:
+ Return TRUE if all AP services are availible.
+
+Arguments:
+ NONE
+
+Returns:
+ EFI_SUCCESS - All AP services are available
+ EFI_NOT_FOUND - At least one AP service is not available
+
+--*/
+;
+
+VOID
+CalculateEfiHdrCrc (
+ IN OUT EFI_TABLE_HEADER *Hdr
+ )
+/*++
+
+Routine Description:
+
+ Calcualte the 32-bit CRC in a EFI table using the service provided by the
+ gRuntime service.
+
+Arguments:
+
+ Hdr - Pointer to an EFI standard header
+
+Returns:
+
+ None
+
+--*/
+;
+
+VOID
+EFIAPI
+CoreTimerTick (
+ IN UINT64 Duration
+ )
+/*++
+
+Routine Description:
+
+ Called by the platform code to process a tick.
+
+Arguments:
+
+ Duration - The number of 100ns elasped since the last call to TimerTick
+
+Returns:
+
+ None
+
+--*/
+;
+
+VOID
+CoreInitializeDispatcher (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Initialize the dispatcher. Initialize the notification function that runs when
+ a FV protocol is added to the system.
+
+Arguments:
+
+ NONE
+
+Returns:
+
+ NONE
+
+--*/
+;
+
+BOOLEAN
+CoreIsSchedulable (
+ IN EFI_CORE_DRIVER_ENTRY *DriverEntry
+ )
+/*++
+
+Routine Description:
+
+ This is the POSTFIX version of the dependency evaluator. This code does
+ not need to handle Before or After, as it is not valid to call this
+ routine in this case. The SOR is just ignored and is a nop in the grammer.
+
+ POSTFIX means all the math is done on top of the stack.
+
+Arguments:
+
+ DriverEntry - DriverEntry element to update
+
+Returns:
+
+ TRUE - If driver is ready to run.
+
+ FALSE - If driver is not ready to run or some fatal error was found.
+
+--*/
+;
+
+EFI_STATUS
+CorePreProcessDepex (
+ IN EFI_CORE_DRIVER_ENTRY *DriverEntry
+ )
+/*++
+
+Routine Description:
+
+ Preprocess dependency expression and update DriverEntry to reflect the
+ state of Before, After, and SOR dependencies. If DriverEntry->Before
+ or DriverEntry->After is set it will never be cleared. If SOR is set
+ it will be cleared by CoreSchedule(), and then the driver can be
+ dispatched.
+
+Arguments:
+
+ DriverEntry - DriverEntry element to update
+
+Returns:
+
+ EFI_SUCCESS - It always works.
+
+--*/
+;
+
+EFI_BOOTSERVICE
+EFI_STATUS
+EFIAPI
+CoreExitBootServices (
+ IN EFI_HANDLE ImageHandle,
+ IN UINTN MapKey
+ )
+/*++
+
+Routine Description:
+
+ EFI 1.0 API to terminate Boot Services
+
+Arguments:
+
+ ImageHandle - Handle that represents the identity of the calling image
+
+ MapKey -Key to the latest memory map.
+
+Returns:
+
+ EFI_SUCCESS - Boot Services terminated
+ EFI_INVALID_PARAMETER - MapKey is incorrect.
+
+--*/
+;
+
+EFI_STATUS
+CoreTerminateMemoryMap (
+ IN UINTN MapKey
+ )
+/*++
+
+Routine Description:
+
+ Make sure the memory map is following all the construction rules,
+ it is the last time to check memory map error before exit boot services.
+
+Arguments:
+
+ MapKey - Memory map key
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Memory map not consistent with construction rules.
+
+ EFI_SUCCESS - Valid memory map.
+
+--*/
+;
+
+VOID
+CoreNotifySignalList (
+ IN EFI_GUID *EventGroup
+ )
+/*++
+
+Routine Description:
+
+ Signals all events on the requested list
+
+Arguments:
+
+ SignalType - The list to signal
+
+Returns:
+
+ None
+
+--*/
+;
+
+EFI_BOOTSERVICE
+EFI_STATUS
+EFIAPI
+CoreInstallConfigurationTable (
+ IN EFI_GUID *Guid,
+ IN VOID *Table
+ )
+/*++
+
+Routine Description:
+
+ Boot Service called to add, modify, or remove a system configuration table from
+ the EFI System Table.
+
+Arguments:
+
+ Guid: Pointer to the GUID for the entry to add, update, or remove
+ Table: Pointer to the configuration table for the entry to add, update, or
+ remove, may be NULL.
+
+Returns:
+
+ EFI_SUCCESS Guid, Table pair added, updated, or removed.
+ EFI_INVALID_PARAMETER Input GUID not valid.
+ EFI_NOT_FOUND Attempted to delete non-existant entry
+ EFI_OUT_OF_RESOURCES Not enough memory available
+
+--*/
+;
+
+EFI_BOOTSERVICE
+EFI_TPL
+EFIAPI
+CoreRaiseTpl (
+ IN EFI_TPL NewTpl
+ )
+/*++
+
+Routine Description:
+
+ Raise the task priority level to the new level.
+ High level is implemented by disabling processor interrupts.
+
+Arguments:
+
+ NewTpl - New task priority level
+
+Returns:
+
+ The previous task priority level
+
+--*/
+;
+
+EFI_BOOTSERVICE
+VOID
+EFIAPI
+CoreRestoreTpl (
+ IN EFI_TPL NewTpl
+ )
+/*++
+
+Routine Description:
+
+ Lowers the task priority to the previous value. If the new
+ priority unmasks events at a higher priority, they are dispatched.
+
+Arguments:
+
+ NewTpl - New, lower, task priority
+
+Returns:
+
+ None
+
+--*/
+;
+
+EFI_BOOTSERVICE
+EFI_STATUS
+EFIAPI
+CoreStall (
+ IN UINTN Microseconds
+ )
+/*++
+
+Routine Description:
+
+ Introduces a fine-grained stall.
+
+Arguments:
+
+ Microseconds The number of microseconds to stall execution
+
+Returns:
+
+ EFI_SUCCESS - Execution was stalled for at least the requested amount
+ of microseconds.
+
+ EFI_NOT_AVAILABLE_YET - gMetronome is not available yet
+
+--*/
+;
+
+EFI_BOOTSERVICE
+EFI_STATUS
+EFIAPI
+CoreSetWatchdogTimer (
+ IN UINTN Timeout,
+ IN UINT64 WatchdogCode,
+ IN UINTN DataSize,
+ IN CHAR16 *WatchdogData OPTIONAL
+ )
+/*++
+
+Routine Description:
+
+ Sets the system's watchdog timer.
+
+Arguments:
+
+ Timeout The number of seconds. Zero disables the timer.
+
+ ///////following three parameters are left for platform specific using
+
+ WatchdogCode The numberic code to log. 0x0 to 0xffff are firmware
+ DataSize Size of the optional data
+ WatchdogData Optional Null terminated unicode string followed by binary
+ data.
+
+Returns:
+
+ EFI_SUCCESS Timeout has been set
+ EFI_NOT_AVAILABLE_YET WatchdogTimer is not available yet
+ EFI_UNSUPPORTED System does not have a timer (currently not used)
+ EFI_DEVICE_ERROR Could not complete due to hardware error
+
+--*/
+;
+
+EFI_BOOTSERVICE
+EFI_STATUS
+EFIAPI
+CoreInstallProtocolInterface (
+ IN OUT EFI_HANDLE *UserHandle,
+ IN EFI_GUID *Protocol,
+ IN EFI_INTERFACE_TYPE InterfaceType,
+ IN VOID *Interface
+ )
+/*++
+
+Routine Description:
+
+ Wrapper function to CoreInstallProtocolInterfaceNotify. This is the public API which
+ Calls the private one which contains a BOOLEAN parameter for notifications
+
+Arguments:
+
+ UserHandle - The handle to install the protocol handler on,
+ or NULL if a new handle is to be allocated
+
+ Protocol - The protocol to add to the handle
+
+ InterfaceType - Indicates whether Interface is supplied in native form.
+
+ Interface - The interface for the protocol being added
+
+Returns:
+
+ Status code
+
+--*/
+;
+
+EFI_STATUS
+CoreInstallProtocolInterfaceNotify (
+ IN OUT EFI_HANDLE *UserHandle,
+ IN EFI_GUID *Protocol,
+ IN EFI_INTERFACE_TYPE InterfaceType,
+ IN VOID *Interface,
+ IN BOOLEAN Notify
+ )
+/*++
+
+Routine Description:
+
+ Installs a protocol interface into the boot services environment.
+
+Arguments:
+
+ UserHandle - The handle to install the protocol handler on,
+ or NULL if a new handle is to be allocated
+
+ Protocol - The protocol to add to the handle
+
+ InterfaceType - Indicates whether Interface is supplied in native form.
+
+ Interface - The interface for the protocol being added
+
+ Notify - Whether to notify the notification list for this protocol
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Invalid parameter
+
+ EFI_OUT_OF_RESOURCES - No enough buffer to allocate
+
+ EFI_SUCCESS - Protocol interface successfully installed
+
+--*/
+;
+
+EFI_BOOTSERVICE11
+EFI_STATUS
+EFIAPI
+CoreInstallMultipleProtocolInterfaces (
+ IN OUT EFI_HANDLE *Handle,
+ ...
+ )
+/*++
+
+Routine Description:
+
+ Installs a list of protocol interface into the boot services environment.
+ This function calls InstallProtocolInterface() in a loop. If any error
+ occures all the protocols added by this function are removed. This is
+ basically a lib function to save space.
+
+Arguments:
+
+ Handle - The handle to install the protocol handlers on,
+ or NULL if a new handle is to be allocated
+ ... - EFI_GUID followed by protocol instance. A NULL terminates the
+ list. The pairs are the arguments to InstallProtocolInterface().
+ All the protocols are added to Handle.
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Handle is NULL.
+
+ EFI_SUCCESS - Protocol interfaces successfully installed.
+
+--*/
+;
+
+EFI_BOOTSERVICE11
+EFI_STATUS
+EFIAPI
+CoreUninstallMultipleProtocolInterfaces (
+ IN EFI_HANDLE Handle,
+ ...
+ )
+/*++
+
+Routine Description:
+
+ Uninstalls a list of protocol interface in the boot services environment.
+ This function calls UnisatllProtocolInterface() in a loop. This is
+ basically a lib function to save space.
+
+Arguments:
+
+ Handle - The handle to uninstall the protocol
+
+ ... - EFI_GUID followed by protocol instance. A NULL terminates the
+ list. The pairs are the arguments to UninstallProtocolInterface().
+ All the protocols are added to Handle.
+
+Returns:
+
+ Status code
+
+--*/
+;
+
+EFI_BOOTSERVICE
+EFI_STATUS
+EFIAPI
+CoreReinstallProtocolInterface (
+ IN EFI_HANDLE UserHandle,
+ IN EFI_GUID *Protocol,
+ IN VOID *OldInterface,
+ IN VOID *NewInterface
+ )
+/*++
+
+Routine Description:
+
+ Reinstall a protocol interface on a device handle. The OldInterface for Protocol is replaced by the NewInterface.
+
+Arguments:
+
+ UserHandle - Handle on which the interface is to be reinstalled
+ Protocol - The numeric ID of the interface
+ OldInterface - A pointer to the old interface
+ NewInterface - A pointer to the new interface
+
+
+Returns:
+
+ Status code.
+
+ On EFI_SUCCESS The protocol interface was installed
+ On EFI_NOT_FOUND The OldInterface on the handle was not found
+ On EFI_INVALID_PARAMETER One of the parameters has an invalid value
+
+--*/
+;
+
+EFI_BOOTSERVICE
+EFI_STATUS
+EFIAPI
+CoreUninstallProtocolInterface (
+ IN EFI_HANDLE UserHandle,
+ IN EFI_GUID *Protocol,
+ IN VOID *Interface
+ )
+/*++
+
+Routine Description:
+
+ Uninstalls all instances of a protocol:interfacer from a handle.
+ If the last protocol interface is remove from the handle, the
+ handle is freed.
+
+Arguments:
+
+ UserHandle - The handle to remove the protocol handler from
+
+ Protocol - The protocol, of protocol:interface, to remove
+
+ Interface - The interface, of protocol:interface, to remove
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Protocol is NULL.
+
+ EFI_SUCCESS - Protocol interface successfully uninstalled.
+
+--*/
+;
+
+EFI_BOOTSERVICE
+EFI_STATUS
+EFIAPI
+CoreHandleProtocol (
+ IN EFI_HANDLE UserHandle,
+ IN EFI_GUID *Protocol,
+ OUT VOID **Interface
+ )
+/*++
+
+Routine Description:
+
+ Queries a handle to determine if it supports a specified protocol.
+
+Arguments:
+
+ UserHandle - The handle being queried.
+
+ Protocol - The published unique identifier of the protocol.
+
+ Interface - Supplies the address where a pointer to the corresponding Protocol
+ Interface is returned.
+
+Returns:
+
+ The requested protocol interface for the handle
+
+--*/
+;
+
+EFI_BOOTSERVICE11
+EFI_STATUS
+EFIAPI
+CoreOpenProtocol (
+ IN EFI_HANDLE UserHandle,
+ IN EFI_GUID *Protocol,
+ OUT VOID **Interface OPTIONAL,
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_HANDLE ControllerHandle,
+ IN UINT32 Attributes
+ )
+/*++
+
+Routine Description:
+
+ Locates the installed protocol handler for the handle, and
+ invokes it to obtain the protocol interface. Usage information
+ is registered in the protocol data base.
+
+Arguments:
+
+ UserHandle - The handle to obtain the protocol interface on
+
+ Protocol - The ID of the protocol
+
+ Interface - The location to return the protocol interface
+
+ ImageHandle - The handle of the Image that is opening the protocol interface
+ specified by Protocol and Interface.
+
+ ControllerHandle - The controller handle that is requiring this interface.
+
+ Attributes - The open mode of the protocol interface specified by Handle
+ and Protocol.
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Protocol is NULL.
+
+ EFI_SUCCESS - Get the protocol interface.
+
+--*/
+;
+
+EFI_BOOTSERVICE11
+EFI_STATUS
+EFIAPI
+CoreOpenProtocolInformation (
+ IN EFI_HANDLE UserHandle,
+ IN EFI_GUID *Protocol,
+ OUT EFI_OPEN_PROTOCOL_INFORMATION_ENTRY **EntryBuffer,
+ OUT UINTN *EntryCount
+ )
+/*++
+
+Routine Description:
+
+ Return information about Opened protocols in the system
+
+Arguments:
+
+ UserHandle - The handle to close the protocol interface on
+
+ Protocol - The ID of the protocol
+
+ EntryBuffer - A pointer to a buffer of open protocol information in the form of
+ EFI_OPEN_PROTOCOL_INFORMATION_ENTRY structures.
+
+ EntryCount - Number of EntryBuffer entries
+
+Returns:
+
+
+--*/
+;
+
+EFI_BOOTSERVICE11
+EFI_STATUS
+EFIAPI
+CoreCloseProtocol (
+ IN EFI_HANDLE UserHandle,
+ IN EFI_GUID *Protocol,
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_HANDLE ControllerHandle
+ )
+/*++
+
+Routine Description:
+
+ Close Protocol
+
+Arguments:
+
+ UserHandle - The handle to close the protocol interface on
+
+ Protocol - The ID of the protocol
+
+ ImageHandle - The user of the protocol to close
+
+ ControllerHandle - The user of the protocol to close
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Protocol is NULL.
+
+--*/
+;
+
+EFI_BOOTSERVICE11
+EFI_STATUS
+EFIAPI
+CoreProtocolsPerHandle (
+ IN EFI_HANDLE UserHandle,
+ OUT EFI_GUID ***ProtocolBuffer,
+ OUT UINTN *ProtocolBufferCount
+ )
+/*++
+
+Routine Description:
+
+ Retrieves the list of protocol interface GUIDs that are installed on a handle in a buffer allocated
+ from pool.
+
+Arguments:
+
+ UserHandle - The handle from which to retrieve the list of protocol interface
+ GUIDs.
+
+ ProtocolBuffer - A pointer to the list of protocol interface GUID pointers that are
+ installed on Handle.
+
+ ProtocolBufferCount - A pointer to the number of GUID pointers present in
+ ProtocolBuffer.
+
+Returns:
+ EFI_SUCCESS - The list of protocol interface GUIDs installed on Handle was returned in
+ ProtocolBuffer. The number of protocol interface GUIDs was
+ returned in ProtocolBufferCount.
+ EFI_INVALID_PARAMETER - Handle is NULL.
+ EFI_INVALID_PARAMETER - Handle is not a valid EFI_HANDLE.
+ EFI_INVALID_PARAMETER - ProtocolBuffer is NULL.
+ EFI_INVALID_PARAMETER - ProtocolBufferCount is NULL.
+ EFI_OUT_OF_RESOURCES - There is not enough pool memory to store the results.
+
+--*/
+;
+
+EFI_BOOTSERVICE
+EFI_STATUS
+EFIAPI
+CoreRegisterProtocolNotify (
+ IN EFI_GUID *Protocol,
+ IN EFI_EVENT Event,
+ OUT VOID **Registration
+ )
+/*++
+
+Routine Description:
+
+ Add a new protocol notification record for the request protocol.
+
+Arguments:
+
+ Protocol - The requested protocol to add the notify registration
+
+ Event - The event to signal
+
+ Registration - Returns the registration record
+
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Invalid parameter
+
+ EFI_SUCCESS - Successfully returned the registration record that has been added
+
+--*/
+;
+
+EFI_BOOTSERVICE
+EFI_STATUS
+EFIAPI
+CoreLocateHandle (
+ IN EFI_LOCATE_SEARCH_TYPE SearchType,
+ IN EFI_GUID *Protocol OPTIONAL,
+ IN VOID *SearchKey OPTIONAL,
+ IN OUT UINTN *BufferSize,
+ OUT EFI_HANDLE *Buffer
+ )
+/*++
+
+Routine Description:
+
+ Locates the requested handle(s) and returns them in Buffer.
+
+Arguments:
+
+ SearchType - The type of search to perform to locate the handles
+
+ Protocol - The protocol to search for
+
+ SearchKey - Dependant on SearchType
+
+ BufferSize - On input the size of Buffer. On output the
+ size of data returned.
+
+ Buffer - The buffer to return the results in
+
+
+Returns:
+
+ EFI_BUFFER_TOO_SMALL - Buffer too small, required buffer size is returned in BufferSize.
+
+ EFI_INVALID_PARAMETER - Invalid parameter
+
+ EFI_SUCCESS - Successfully found the requested handle(s) and returns them in Buffer.
+
+--*/
+;
+
+EFI_BOOTSERVICE
+EFI_STATUS
+EFIAPI
+CoreLocateDevicePath (
+ IN EFI_GUID *Protocol,
+ IN OUT EFI_DEVICE_PATH_PROTOCOL **FilePath,
+ OUT EFI_HANDLE *Device
+ )
+/*++
+
+Routine Description:
+
+ Locates the handle to a device on the device path that supports the specified protocol.
+
+Arguments:
+
+ Protocol - The protocol to search for.
+ FilePath - On input, a pointer to a pointer to the device path. On output, the device
+ path pointer is modified to point to the remaining part of the devicepath.
+ Device - A pointer to the returned device handle.
+
+Returns:
+
+ EFI_SUCCESS - The resulting handle was returned.
+ EFI_NOT_FOUND - No handles matched the search.
+ EFI_INVALID_PARAMETER - One of the parameters has an invalid value.
+
+--*/
+;
+
+EFI_BOOTSERVICE11
+EFI_STATUS
+EFIAPI
+CoreLocateHandleBuffer (
+ IN EFI_LOCATE_SEARCH_TYPE SearchType,
+ IN EFI_GUID *Protocol OPTIONAL,
+ IN VOID *SearchKey OPTIONAL,
+ IN OUT UINTN *NumberHandles,
+ OUT EFI_HANDLE **Buffer
+ )
+/*++
+
+Routine Description:
+
+ Function returns an array of handles that support the requested protocol
+ in a buffer allocated from pool. This is a version of CoreLocateHandle()
+ that allocates a buffer for the caller.
+
+Arguments:
+
+ SearchType - Specifies which handle(s) are to be returned.
+ Protocol - Provides the protocol to search by.
+ This parameter is only valid for SearchType ByProtocol.
+ SearchKey - Supplies the search key depending on the SearchType.
+ NumberHandles - The number of handles returned in Buffer.
+ Buffer - A pointer to the buffer to return the requested array of
+ handles that support Protocol.
+
+Returns:
+
+ EFI_SUCCESS - The result array of handles was returned.
+ EFI_NOT_FOUND - No handles match the search.
+ EFI_OUT_OF_RESOURCES - There is not enough pool memory to store the matching results.
+ EFI_INVALID_PARAMETER - Invalid parameter
+
+--*/
+;
+
+EFI_BOOTSERVICE11
+EFI_STATUS
+EFIAPI
+CoreLocateProtocol (
+ IN EFI_GUID *Protocol,
+ IN VOID *Registration OPTIONAL,
+ OUT VOID **Interface
+ )
+/*++
+
+Routine Description:
+
+ Return the first Protocol Interface that matches the Protocol GUID. If
+ Registration is pasased in return a Protocol Instance that was just add
+ to the system. If Retistration is NULL return the first Protocol Interface
+ you find.
+
+Arguments:
+
+ Protocol - The protocol to search for
+
+ Registration - Optional Registration Key returned from RegisterProtocolNotify()
+
+ Interface - Return the Protocol interface (instance).
+
+Returns:
+
+ EFI_SUCCESS - If a valid Interface is returned
+
+ EFI_INVALID_PARAMETER - Invalid parameter
+
+ EFI_NOT_FOUND - Protocol interface not found
+
+--*/
+;
+
+UINT64
+CoreGetHandleDatabaseKey (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ return handle database key.
+
+Arguments:
+
+ None
+
+Returns:
+
+ Handle database key.
+
+--*/
+;
+
+VOID
+CoreConnectHandlesByKey (
+ UINT64 Key
+ )
+/*++
+
+Routine Description:
+
+ Go connect any handles that were created or modified while a image executed.
+
+Arguments:
+
+ Key - The Key to show that the handle has been created/modified
+
+Returns:
+
+ None
+--*/
+;
+
+EFI_BOOTSERVICE11
+EFI_STATUS
+EFIAPI
+CoreConnectController (
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE *DriverImageHandle OPTIONAL,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL,
+ IN BOOLEAN Recursive
+ )
+/*++
+
+Routine Description:
+
+ Connects one or more drivers to a controller.
+
+Arguments:
+
+ ControllerHandle - Handle of the controller to be connected.
+
+ DriverImageHandle - DriverImageHandle A pointer to an ordered list of driver image handles.
+
+ RemainingDevicePath - RemainingDevicePath A pointer to the device path that specifies a child of the
+ controller specified by ControllerHandle.
+
+ Recursive - - Whether the function would be called recursively or not.
+
+Returns:
+
+ Status code.
+
+--*/
+;
+
+EFI_BOOTSERVICE11
+EFI_STATUS
+EFIAPI
+CoreDisconnectController (
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE DriverImageHandle OPTIONAL,
+ IN EFI_HANDLE ChildHandle OPTIONAL
+ )
+/*++
+
+Routine Description:
+
+ Disonnects a controller from a driver
+
+Arguments:
+
+ ControllerHandle - ControllerHandle The handle of the controller from which driver(s)
+ are to be disconnected.
+ DriverImageHandle - DriverImageHandle The driver to disconnect from ControllerHandle.
+ ChildHandle - ChildHandle The handle of the child to destroy.
+
+Returns:
+
+ EFI_SUCCESS - One or more drivers were disconnected from the controller.
+ EFI_SUCCESS - On entry, no drivers are managing ControllerHandle.
+ EFI_SUCCESS - DriverImageHandle is not NULL, and on entry DriverImageHandle is not managing ControllerHandle.
+ EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.
+ EFI_INVALID_PARAMETER - DriverImageHandle is not NULL, and it is not a valid EFI_HANDLE.
+ EFI_INVALID_PARAMETER - ChildHandle is not NULL, and it is not a valid EFI_HANDLE.
+ EFI_OUT_OF_RESOURCES - There are not enough resources available to disconnect any drivers from ControllerHandle.
+ EFI_DEVICE_ERROR - The controller could not be disconnected because of a device error.
+
+--*/
+;
+
+EFI_BOOTSERVICE
+EFI_STATUS
+EFIAPI
+CoreAllocatePages (
+ IN EFI_ALLOCATE_TYPE Type,
+ IN EFI_MEMORY_TYPE MemoryType,
+ IN UINTN NumberOfPages,
+ IN OUT EFI_PHYSICAL_ADDRESS *Memory
+ )
+/*++
+
+Routine Description:
+
+ Allocates pages from the memory map.
+
+Arguments:
+
+ Type - The type of allocation to perform
+
+ MemoryType - The type of memory to turn the allocated pages into
+
+ NumberOfPages - The number of pages to allocate
+
+ Memory - A pointer to receive the base allocated memory address
+
+Returns:
+
+ Status. On success, Memory is filled in with the base address allocated
+
+ EFI_INVALID_PARAMETER - Parameters violate checking rules defined in spec.
+
+ EFI_NOT_FOUND - Could not allocate pages match the requirement.
+
+ EFI_OUT_OF_RESOURCES - No enough pages to allocate.
+
+ EFI_SUCCESS - Pages successfully allocated.
+
+--*/
+;
+
+EFI_BOOTSERVICE
+EFI_STATUS
+EFIAPI
+CoreFreePages (
+ IN EFI_PHYSICAL_ADDRESS Memory,
+ IN UINTN NumberOfPages
+ )
+/*++
+
+Routine Description:
+
+ Frees previous allocated pages.
+
+Arguments:
+
+ Memory - Base address of memory being freed
+
+ NumberOfPages - The number of pages to free
+
+Returns:
+
+ EFI_NOT_FOUND - Could not find the entry that covers the range
+
+ EFI_INVALID_PARAMETER - Address not aligned
+
+ EFI_SUCCESS -Pages successfully freed.
+
+--*/
+;
+
+EFI_BOOTSERVICE
+EFI_STATUS
+EFIAPI
+CoreGetMemoryMap (
+ IN OUT UINTN *MemoryMapSize,
+ IN OUT EFI_MEMORY_DESCRIPTOR *Desc,
+ OUT UINTN *MapKey,
+ OUT UINTN *DescriptorSize,
+ OUT UINT32 *DescriptorVersion
+ )
+/*++
+
+Routine Description:
+
+ Returns the current memory map.
+
+Arguments:
+
+ MemoryMapSize - On input the buffer size of MemoryMap allocated by caller
+ On output the required buffer size to contain the memory map
+
+ Desc - The buffer to return the current memory map
+
+ MapKey - The address to return the current map key
+
+ DescriptorSize - The size in bytes for an individual EFI_MEMORY_DESCRIPTOR
+
+ DescriptorVersion - The version number associated with the EFI_MEMORY_DESCRIPTOR
+
+Returns:
+
+ EFI_SUCCESS The current memory map was returned successfully
+
+ EFI_BUFFER_TOO_SMALL The MemoryMap buffer was too small
+
+ EFI_INVALID_PARAMETER One of the parameters has an invalid value
+
+--*/
+;
+
+EFI_BOOTSERVICE
+EFI_STATUS
+EFIAPI
+CoreAllocatePool (
+ IN EFI_MEMORY_TYPE PoolType,
+ IN UINTN Size,
+ OUT VOID **Buffer
+ )
+/*++
+
+Routine Description:
+
+ Allocate pool of a particular type.
+
+Arguments:
+
+ PoolType - Type of pool to allocate
+
+ Size - The amount of pool to allocate
+
+ Buffer - The address to return a pointer to the allocated pool
+
+Returns:
+
+ EFI_INVALID_PARAMETER - PoolType not valid
+
+ EFI_OUT_OF_RESOURCES - Size exceeds max pool size or allocation failed.
+
+ EFI_SUCCESS - Pool successfully allocated.
+
+--*/
+;
+
+EFI_BOOTSERVICE
+EFI_STATUS
+EFIAPI
+CoreFreePool (
+ IN VOID *Buffer
+ )
+/*++
+
+Routine Description:
+
+ Frees pool.
+
+Arguments:
+
+ Buffer - The allocated pool entry to free
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Buffer is not a valid value.
+
+ EFI_SUCCESS - Pool successfully freed.
+
+--*/
+;
+
+EFI_BOOTSERVICE
+EFI_STATUS
+EFIAPI
+CoreLoadImage (
+ IN BOOLEAN BootPolicy,
+ IN EFI_HANDLE ParentImageHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
+ IN VOID *SourceBuffer OPTIONAL,
+ IN UINTN SourceSize,
+ OUT EFI_HANDLE *ImageHandle
+ )
+/*++
+
+Routine Description:
+
+ Loads an EFI image into memory and returns a handle to the image.
+
+Arguments:
+
+ BootPolicy - If TRUE, indicates that the request originates from the boot manager,
+ and that the boot manager is attempting to load FilePath as a boot selection.
+ ParentImageHandle - The caller's image handle.
+ FilePath - The specific file path from which the image is loaded.
+ SourceBuffer - If not NULL, a pointer to the memory location containing a copy of
+ the image to be loaded.
+ SourceSize - The size in bytes of SourceBuffer.
+ ImageHandle - Pointer to the returned image handle that is created when the image
+ is successfully loaded.
+
+Returns:
+
+ EFI_SUCCESS - The image was loaded into memory.
+ EFI_NOT_FOUND - The FilePath was not found.
+ EFI_INVALID_PARAMETER - One of the parameters has an invalid value.
+ EFI_UNSUPPORTED - The image type is not supported, or the device path cannot be
+ parsed to locate the proper protocol for loading the file.
+ EFI_OUT_OF_RESOURCES - Image was not loaded due to insufficient resources.
+--*/
+;
+
+EFI_BOOTSERVICE
+EFI_STATUS
+EFIAPI
+CoreUnloadImage (
+ IN EFI_HANDLE ImageHandle
+ )
+/*++
+
+Routine Description:
+
+ Unload the specified image.
+
+Arguments:
+
+ ImageHandle - The specified image handle.
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Image handle is NULL.
+
+ EFI_UNSUPPORTED - Attempt to unload an unsupported image.
+
+ EFI_SUCCESS - Image successfully unloaded.
+
+--*/
+;
+
+EFI_BOOTSERVICE
+EFI_STATUS
+EFIAPI
+CoreStartImage (
+ IN EFI_HANDLE ImageHandle,
+ OUT UINTN *ExitDataSize,
+ OUT CHAR16 **ExitData OPTIONAL
+ )
+/*++
+
+Routine Description:
+
+ Transfer control to a loaded image's entry point.
+
+Arguments:
+
+ ImageHandle - Handle of image to be started.
+
+ ExitDataSize - Pointer of the size to ExitData
+
+ ExitData - Pointer to a pointer to a data buffer that includes a Null-terminated
+ Unicode string, optionally followed by additional binary data. The string
+ is a description that the caller may use to further indicate the reason for
+ the image¡¯s exit.
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Invalid parameter
+
+ EFI_OUT_OF_RESOURCES - No enough buffer to allocate
+
+ EFI_SUCCESS - Successfully transfer control to the image's entry point.
+
+--*/
+;
+
+EFI_BOOTSERVICE
+EFI_STATUS
+EFIAPI
+CoreExit (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_STATUS Status,
+ IN UINTN ExitDataSize,
+ IN CHAR16 *ExitData OPTIONAL
+ )
+/*++
+
+Routine Description:
+
+ Terminates the currently loaded EFI image and returns control to boot services.
+
+Arguments:
+
+ ImageHandle - Handle that identifies the image. This parameter is passed to the image
+ on entry.
+ Status - The image¡¯s exit code.
+ ExitDataSize - The size, in bytes, of ExitData. Ignored if ExitStatus is
+ EFI_SUCCESS.
+ ExitData - Pointer to a data buffer that includes a Null-terminated Unicode string,
+ optionally followed by additional binary data. The string is a
+ description that the caller may use to further indicate the reason for
+ the image¡¯s exit.
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Image handle is NULL or it is not current image.
+
+ EFI_SUCCESS - Successfully terminates the currently loaded EFI image.
+
+ EFI_ACCESS_DENIED - Should never reach there.
+
+--*/
+;
+
+EFI_BOOTSERVICE
+EFI_STATUS
+EFIAPI
+CoreCreateEvent (
+ IN UINT32 Type,
+ IN EFI_TPL NotifyTpl,
+ IN EFI_EVENT_NOTIFY NotifyFunction,
+ IN VOID *NotifyContext,
+ OUT EFI_EVENT *pEvent
+ )
+/*++
+
+Routine Description:
+
+ Creates a general-purpose event structure
+
+Arguments:
+
+ Type - The type of event to create and its mode and attributes
+ NotifyTpl - The task priority level of event notifications
+ NotifyFunction - Pointer to the event’s notification function
+ NotifyContext - Pointer to the notification function’s context; corresponds to
+ parameter "Context" in the notification function
+ pEvent - Pointer to the newly created event if the call succeeds; undefined otherwise
+
+Returns:
+
+ EFI_SUCCESS - The event structure was created
+ EFI_INVALID_PARAMETER - One of the parameters has an invalid value
+ EFI_OUT_OF_RESOURCES - The event could not be allocated
+
+--*/
+;
+
+EFI_BOOTSERVICE
+EFI_STATUS
+EFIAPI
+CoreCreateEventEx (
+ IN UINT32 Type,
+ IN EFI_TPL NotifyTpl,
+ IN EFI_EVENT_NOTIFY NotifyFunction,
+ IN VOID *NotifyContext,
+ IN CONST EFI_GUID *EventGroup, OPTIONAL
+ OUT EFI_EVENT *Event
+ )
+/*++
+
+Routine Description:
+ Creates a general-purpose event structure
+
+Arguments:
+ Type - The type of event to create and its mode and attributes
+ NotifyTpl - The task priority level of event notifications
+ NotifyFunction - Pointer to the events notification function
+ NotifyContext - Pointer to the notification functions context; corresponds to
+ parameter "Context" in the notification function
+ EventGrout - GUID for EventGroup if NULL act the same as gBS->CreateEvent().
+ Event - Pointer to the newly created event if the call succeeds; undefined otherwise
+
+Returns:
+ EFI_SUCCESS - The event structure was created
+ EFI_INVALID_PARAMETER - One of the parameters has an invalid value
+ EFI_OUT_OF_RESOURCES - The event could not be allocated
+
+--*/
+;
+
+EFI_BOOTSERVICE
+EFI_STATUS
+EFIAPI
+CoreSetTimer (
+ IN EFI_EVENT Event,
+ IN EFI_TIMER_DELAY Type,
+ IN UINT64 TriggerTime
+ )
+/*++
+
+Routine Description:
+
+ Sets the type of timer and the trigger time for a timer event.
+
+Arguments:
+
+ UserEvent - The timer event that is to be signaled at the specified time
+ Type - The type of time that is specified in TriggerTime
+ TriggerTime - The number of 100ns units until the timer expires
+
+Returns:
+
+ EFI_SUCCESS - The event has been set to be signaled at the requested time
+ EFI_INVALID_PARAMETER - Event or Type is not valid
+
+--*/
+;
+
+EFI_BOOTSERVICE
+EFI_STATUS
+EFIAPI
+CoreSignalEvent (
+ IN EFI_EVENT Event
+ )
+/*++
+
+Routine Description:
+
+ Signals the event. Queues the event to be notified if needed
+
+Arguments:
+
+ Event - The event to signal
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Parameters are not valid.
+
+ EFI_SUCCESS - The event was signaled.
+
+--*/
+;
+
+EFI_BOOTSERVICE
+EFI_STATUS
+EFIAPI
+CoreWaitForEvent (
+ IN UINTN NumberOfEvents,
+ IN EFI_EVENT *UserEvents,
+ OUT UINTN *UserIndex
+ )
+/*++
+
+Routine Description:
+
+ Stops execution until an event is signaled.
+
+Arguments:
+
+ NumberOfEvents - The number of events in the UserEvents array
+ UserEvents - An array of EFI_EVENT
+ UserIndex - Pointer to the index of the event which satisfied the wait condition
+
+Returns:
+
+ EFI_SUCCESS - The event indicated by Index was signaled.
+ EFI_INVALID_PARAMETER - The event indicated by Index has a notification function or
+ Event was not a valid type
+ EFI_UNSUPPORTED - The current TPL is not TPL_APPLICATION
+
+--*/
+;
+
+EFI_BOOTSERVICE
+EFI_STATUS
+EFIAPI
+CoreCloseEvent (
+ IN EFI_EVENT Event
+ )
+/*++
+
+Routine Description:
+
+ Closes an event and frees the event structure.
+
+Arguments:
+
+ UserEvent - Event to close
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Parameters are not valid.
+
+ EFI_SUCCESS - The event has been closed
+
+--*/
+;
+
+EFI_BOOTSERVICE
+EFI_STATUS
+EFIAPI
+CoreCheckEvent (
+ IN EFI_EVENT Event
+ )
+/*++
+
+Routine Description:
+
+ Check the status of an event
+
+Arguments:
+
+ UserEvent - The event to check
+
+Returns:
+
+ EFI_SUCCESS - The event is in the signaled state
+ EFI_NOT_READY - The event is not in the signaled state
+ EFI_INVALID_PARAMETER - Event is of type EVT_NOTIFY_SIGNAL
+
+--*/
+;
+
+EFI_STATUS
+CoreAddMemorySpace (
+ IN EFI_GCD_MEMORY_TYPE GcdMemoryType,
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length,
+ IN UINT64 Capabilities
+ )
+/*++
+
+Routine Description:
+
+ Add a segment of memory space to GCD map and add all available pages in this segment
+ as memory descriptors.
+
+Arguments:
+
+ GcdMemoryType - Memory type of the segment.
+
+ BaseAddress - Base address of the segment.
+
+ Length - Length of the segment.
+
+ Capabilities - alterable attributes of the segment.
+
+Returns:
+
+ EFI_SUCCESS - Merged this segment into GCD map.
+
+--*/
+;
+
+EFI_STATUS
+CoreAllocateMemorySpace (
+ IN EFI_GCD_ALLOCATE_TYPE GcdAllocateType,
+ IN EFI_GCD_MEMORY_TYPE GcdMemoryType,
+ IN UINTN Alignment,
+ IN UINT64 Length,
+ IN OUT EFI_PHYSICAL_ADDRESS *BaseAddress,
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_HANDLE DeviceHandle OPTIONAL
+ )
+/*++
+
+Routine Description:
+
+ Allocate memory space on GCD map.
+
+Arguments:
+
+ GcdAllocateType - The type of allocate operation
+
+ GcdMemoryType - The desired memory type
+
+ Alignment - Align with 2^Alignment
+
+ Length - Length to allocate
+
+ BaseAddress - Base address to allocate
+
+ ImageHandle - The image handle consume the allocated space.
+
+ DeviceHandle - The device handle consume the allocated space.
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Invalid parameter.
+
+ EFI_NOT_FOUND - No descriptor contains the desired space.
+
+ EFI_SUCCESS - Memory space successfully allocated.
+
+--*/
+;
+
+EFI_STATUS
+CoreFreeMemorySpace (
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length
+ )
+/*++
+
+Routine Description:Routine Description:
+
+ Free a segment of memory space in GCD map.
+
+Arguments:
+
+ BaseAddress - Base address of the segment.
+
+ Length - Length of the segment.
+
+Returns:
+
+ EFI_SUCCESS - Space successfully freed.
+
+--*/
+;
+
+EFI_STATUS
+CoreRemoveMemorySpace (
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length
+ )
+/*++
+
+Routine Description:Routine Description:
+
+ Remove a segment of memory space in GCD map.
+
+Arguments:
+
+ BaseAddress - Base address of the segment.
+
+ Length - Length of the segment.
+
+Returns:
+
+ EFI_SUCCESS - Successfully a segment of memory space.
+
+--*/
+;
+
+EFI_STATUS
+CoreGetMemorySpaceDescriptor (
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ OUT EFI_GCD_MEMORY_SPACE_DESCRIPTOR *Descriptor
+ )
+/*++
+
+Routine Description:
+
+ Search all entries in GCD map which contains specified segment and build it to a descriptor.
+
+Arguments:
+
+ BaseAddress - Specified start address
+
+ Descriptor - Specified length
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Invalid parameter
+
+ EFI_SUCCESS - Successfully get memory space descriptor.
+
+--*/
+;
+
+EFI_STATUS
+CoreSetMemorySpaceAttributes (
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length,
+ IN UINT64 Attributes
+ )
+/*++
+
+Routine Description:
+
+ Set memory space with specified attributes.
+
+Arguments:
+
+ BaseAddress - Specified start address
+
+ Length - Specified length
+
+ Attributes - Specified attributes
+
+Returns:
+
+ EFI_SUCCESS - Successfully set attribute of a segment of memory space.
+
+--*/
+;
+
+EFI_STATUS
+CoreGetMemorySpaceMap (
+ OUT UINTN *NumberOfDescriptors,
+ OUT EFI_GCD_MEMORY_SPACE_DESCRIPTOR **MemorySpaceMap
+ )
+/*++
+
+Routine Description:
+
+ Transer all entries of GCD memory map into memory descriptors and pass to caller.
+
+Arguments:
+
+ NumberOfDescriptors - Number of descriptors.
+
+ MemorySpaceMap - Descriptor array
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Invalid parameter
+
+ EFI_OUT_OF_RESOURCES - No enough buffer to allocate
+
+ EFI_SUCCESS - Successfully get memory space map.
+
+--*/
+;
+
+EFI_STATUS
+CoreAddIoSpace (
+ IN EFI_GCD_IO_TYPE GcdIoType,
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length
+ )
+/*++
+
+Routine Description:
+
+ Add a segment of IO space to GCD map.
+
+Arguments:
+
+ GcdIoType - IO type of the segment.
+
+ BaseAddress - Base address of the segment.
+
+ Length - Length of the segment.
+
+Returns:
+
+ EFI_SUCCESS - Merged this segment into GCD map.
+
+--*/
+;
+
+EFI_STATUS
+CoreAllocateIoSpace (
+ IN EFI_GCD_ALLOCATE_TYPE GcdAllocateType,
+ IN EFI_GCD_IO_TYPE GcdIoType,
+ IN UINTN Alignment,
+ IN UINT64 Length,
+ IN OUT EFI_PHYSICAL_ADDRESS *BaseAddress,
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_HANDLE DeviceHandle OPTIONAL
+ )
+/*++
+
+Routine Description:
+
+ Allocate IO space on GCD map.
+
+Arguments:
+
+ GcdAllocateType - The type of allocate operation
+
+ GcdIoType - The desired IO type
+
+ Alignment - Align with 2^Alignment
+
+ Length - Length to allocate
+
+ BaseAddress - Base address to allocate
+
+ ImageHandle - The image handle consume the allocated space.
+
+ DeviceHandle - The device handle consume the allocated space.
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Invalid parameter.
+
+ EFI_NOT_FOUND - No descriptor contains the desired space.
+
+ EFI_SUCCESS - IO space successfully allocated.
+
+--*/
+;
+
+EFI_STATUS
+CoreFreeIoSpace (
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length
+ )
+/*++
+
+Routine Description:Routine Description:
+
+ Free a segment of IO space in GCD map.
+
+Arguments:
+
+ BaseAddress - Base address of the segment.
+
+ Length - Length of the segment.
+
+Returns:
+
+ EFI_SUCCESS - Space successfully freed.
+
+--*/
+;
+
+EFI_STATUS
+CoreRemoveIoSpace (
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length
+ )
+/*++
+
+Routine Description:Routine Description:
+
+ Remove a segment of IO space in GCD map.
+
+Arguments:
+
+ BaseAddress - Base address of the segment.
+
+ Length - Length of the segment.
+
+Returns:
+
+ EFI_SUCCESS - Successfully removed a segment of IO space.
+
+--*/
+;
+
+EFI_STATUS
+CoreGetIoSpaceDescriptor (
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ OUT EFI_GCD_IO_SPACE_DESCRIPTOR *Descriptor
+ )
+/*++
+
+Routine Description:
+
+ Search all entries in GCD map which contains specified segment and build it to a descriptor.
+
+Arguments:
+
+ BaseAddress - Specified start address
+
+ Descriptor - Specified length
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Descriptor is NULL.
+
+ EFI_SUCCESS - Successfully get the IO space descriptor.
+
+--*/
+;
+
+EFI_STATUS
+CoreGetIoSpaceMap (
+ OUT UINTN *NumberOfDescriptors,
+ OUT EFI_GCD_IO_SPACE_DESCRIPTOR **IoSpaceMap
+ )
+/*++
+
+Routine Description:
+
+ Transer all entries of GCD IO map into IO descriptors and pass to caller.
+
+Arguments:
+
+ NumberOfDescriptors - Number of descriptors.
+
+ IoSpaceMap - Descriptor array
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Invalid parameter
+
+ EFI_OUT_OF_RESOURCES - No enough buffer to allocate
+
+ EFI_SUCCESS - Successfully get IO space map.
+
+--*/
+;
+
+EFI_DXESERVICE
+EFI_STATUS
+EFIAPI
+CoreDispatcher (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ This is the main Dispatcher for DXE and it exits when there are no more
+ drivers to run. Drain the mScheduledQueue and load and start a PE
+ image for each driver. Search the mDiscoveredList to see if any driver can
+ be placed on the mScheduledQueue. If no drivers are placed on the
+ mScheduledQueue exit the function. On exit it is assumed the Bds()
+ will be called, and when the Bds() exits the Dispatcher will be called
+ again.
+
+Arguments:
+
+ NONE
+
+Returns:
+
+ EFI_ALREADY_STARTED - The DXE Dispatcher is already running
+
+ EFI_NOT_FOUND - No DXE Drivers were dispatched
+
+ EFI_SUCCESS - One or more DXE Drivers were dispatched
+
+--*/
+;
+EFI_DXESERVICE
+EFI_STATUS
+EFIAPI
+CoreSchedule (
+ IN EFI_HANDLE FirmwareVolumeHandle,
+ IN EFI_GUID *DriverName
+ )
+/*++
+
+Routine Description:
+
+ Check every driver and locate a matching one. If the driver is found, the Unrequested
+ state flag is cleared.
+
+Arguments:
+
+ FirmwareVolumeHandle - The handle of the Firmware Volume that contains the firmware
+ file specified by DriverName.
+
+ DriverName - The Driver name to put in the Dependent state.
+
+Returns:
+
+ EFI_SUCCESS - The DriverName was found and it's SOR bit was cleared
+
+ EFI_NOT_FOUND - The DriverName does not exist or it's SOR bit was not set.
+
+--*/
+;
+
+EFI_DXESERVICE
+EFI_STATUS
+EFIAPI
+CoreTrust (
+ IN EFI_HANDLE FirmwareVolumeHandle,
+ IN EFI_GUID *DriverName
+ )
+/*++
+
+Routine Description:
+
+ Convert a driver from the Untrused back to the Scheduled state
+
+Arguments:
+
+ FirmwareVolumeHandle - The handle of the Firmware Volume that contains the firmware
+ file specified by DriverName.
+
+ DriverName - The Driver name to put in the Scheduled state
+
+Returns:
+
+ EFI_SUCCESS - The file was found in the untrusted state, and it was promoted
+ to the trusted state.
+
+ EFI_NOT_FOUND - The file was not found in the untrusted state.
+
+--*/
+;
+
+BOOLEAN
+CoreGrowBuffer (
+ IN OUT EFI_STATUS *Status,
+ IN OUT VOID **Buffer,
+ IN UINTN BufferSize
+ )
+/*++
+
+Routine Description:
+
+ Helper function called as part of the code needed
+ to allocate the proper sized buffer for various
+ EFI interfaces.
+
+Arguments:
+
+ Status - Current status
+
+ Buffer - Current allocated buffer, or NULL
+
+ BufferSize - Current buffer size needed
+
+Returns:
+
+ TRUE - if the buffer was reallocated and the caller
+ should try the API again.
+
+ FALSE - buffer could not be allocated and the caller
+ should not try the API again.
+
+--*/
+;
+
+EFI_STATUS
+EFIAPI
+FwVolDriverInit (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+/*++
+
+Routine Description:
+ This routine is the driver initialization entry point. It initializes the
+ libraries, and registers two notification functions. These notification
+ functions are responsible for building the FV stack dynamically.
+
+Arguments:
+ ImageHandle - The image handle.
+ SystemTable - The system table.
+
+Returns:
+ EFI_SUCCESS - Function successfully returned.
+
+--*/
+;
+
+EFI_STATUS
+EFIAPI
+InitializeSectionExtraction (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+/*++
+
+Routine Description:
+ Entry point of the section extraction code. Initializes an instance of the
+ section extraction interface and installs it on a new handle.
+
+Arguments:
+ ImageHandle EFI_HANDLE: A handle for the image that is initializing this driver
+ SystemTable EFI_SYSTEM_TABLE: A pointer to the EFI system table
+
+Returns:
+ EFI_SUCCESS: Driver initialized successfully
+ EFI_OUT_OF_RESOURCES: Could not allocate needed resources
+
+--*/
+;
+
+EFI_STATUS
+CoreProcessFirmwareVolume (
+ IN VOID *FvHeader,
+ IN UINTN Size,
+ OUT EFI_HANDLE *FVProtocolHandle
+ )
+/*++
+
+Routine Description:
+ This DXE service routine is used to process a firmware volume. In
+ particular, it can be called by BDS to process a single firmware
+ volume found in a capsule.
+
+Arguments:
+ FvHeader - pointer to a firmware volume header
+ Size - the size of the buffer pointed to by FvHeader
+ FVProtocolHandle - the handle on which a firmware volume protocol
+ was produced for the firmware volume passed in.
+
+Returns:
+ EFI_OUT_OF_RESOURCES - if an FVB could not be produced due to lack of
+ system resources
+ EFI_VOLUME_CORRUPTED - if the volume was corrupted
+ EFI_SUCCESS - a firmware volume protocol was produced for the
+ firmware volume
+
+--*/
+;
+
+//
+//Functions used during debug buils
+//
+DEBUG_CODE (
+ VOID
+ CoreDisplayMissingArchProtocols (
+ VOID
+ )
+ /*++
+
+ Routine Description:
+ Displays Architectural protocols that were not loaded and are required for DXE core to function
+ Only used in Debug Builds
+
+ Arguments:
+ NONE
+
+ Returns:
+ NONE
+
+ --*/;
+
+ VOID
+ CoreDisplayDiscoveredNotDispatched (
+ VOID
+ )
+ /*++
+
+ Routine Description:
+
+ Traverse the discovered list for any drivers that were discovered but not loaded
+ because the dependency experessions evaluated to false
+
+ Arguments:
+
+ NONE
+
+ Returns:
+
+ NONE
+
+ --*/;
+)
+#endif
diff --git a/EDK/Foundation/Core/Dxe/Include/Library.h b/EDK/Foundation/Core/Dxe/Include/Library.h
new file mode 100644
index 0000000..9cd4da2
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/Include/Library.h
@@ -0,0 +1,531 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Library.h
+
+Abstract:
+
+Revision History
+
+--*/
+
+#ifndef _DXE_LIBRARY_H_
+#define _DXE_LIBRARY_H_
+
+typedef struct {
+ EFI_TPL Tpl;
+ EFI_TPL OwnerTpl;
+ UINTN Lock;
+} EFI_LOCK;
+
+
+//
+// Macro to initialize the state of a lock when a lock variable is declared
+//
+#define EFI_INITIALIZE_LOCK_VARIABLE(Tpl) {Tpl,0,0}
+
+VOID
+CoreReportProgressCode (
+ IN EFI_STATUS_CODE_VALUE Value
+ )
+/*++
+
+Routine Description:
+
+ Report status code of type EFI_PROGRESS_CODE by caller ID gEfiDxeServicesTableGuid.
+
+Arguments:
+
+ Value - Describes the class/subclass/operation of the hardware or software entity
+ that the Status Code relates to.
+
+Returns:
+
+ None
+
+--*/
+;
+
+VOID
+CoreReportProgressCodeSpecific (
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN EFI_HANDLE Handle
+ )
+/*++
+
+Routine Description:
+
+ Report status code of type EFI_PROGRESS_CODE by caller ID gEfiDxeServicesTableGuid,
+ with a handle as additional information.
+
+Arguments:
+
+ Value - Describes the class/subclass/operation of the hardware or software entity
+ that the Status Code relates to.
+
+ Handle - Additional information.
+
+Returns:
+
+ None
+
+--*/
+;
+
+VOID
+CoreAcquireLock (
+ IN EFI_LOCK *Lock
+ )
+/*++
+
+Routine Description:
+
+ Raising to the task priority level of the mutual exclusion
+ lock, and then acquires ownership of the lock.
+
+Arguments:
+
+ Lock - The lock to acquire
+
+Returns:
+
+ Lock owned
+
+--*/
+;
+
+EFI_STATUS
+CoreAcquireLockOrFail (
+ IN EFI_LOCK *Lock
+ )
+/*++
+
+Routine Description:
+
+ Initialize a basic mutual exclusion lock. Each lock
+ provides mutual exclusion access at it's task priority
+ level. Since there is no-premption (at any TPL) or
+ multiprocessor support, acquiring the lock only consists
+ of raising to the locks TPL.
+
+Arguments:
+
+ Lock - The EFI_LOCK structure to initialize
+
+Returns:
+
+ EFI_SUCCESS - Lock Owned.
+ EFI_ACCESS_DENIED - Reentrant Lock Acquisition, Lock not Owned.
+
+--*/
+;
+
+VOID
+CoreReleaseLock (
+ IN EFI_LOCK *Lock
+ )
+/*++
+
+Routine Description:
+
+ Releases ownership of the mutual exclusion lock, and
+ restores the previous task priority level.
+
+Arguments:
+
+ Lock - The lock to release
+
+Returns:
+
+ Lock unowned
+
+--*/
+;
+
+//
+// Device Path functions
+//
+
+UINTN
+CoreDevicePathSize (
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ )
+/*++
+
+Routine Description:
+
+ Calculate the size of a whole device path.
+
+Arguments:
+
+ DevicePath - The pointer to the device path data.
+
+Returns:
+
+ Size of device path data structure..
+
+--*/
+;
+
+BOOLEAN
+CoreIsDevicePathMultiInstance (
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ )
+/*++
+
+Routine Description:
+ Return TRUE is this is a multi instance device path.
+
+Arguments:
+ DevicePath - A pointer to a device path data structure.
+
+
+Returns:
+ TRUE - If DevicePath is multi instance. FALSE - If DevicePath is not multi
+ instance.
+
+--*/
+;
+
+
+EFI_DEVICE_PATH_PROTOCOL *
+CoreDuplicateDevicePath (
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ )
+/*++
+
+Routine Description:
+ Duplicate a new device path data structure from the old one.
+
+Arguments:
+ DevicePath - A pointer to a device path data structure.
+
+Returns:
+ A pointer to the new allocated device path data.
+ Caller must free the memory used by DevicePath if it is no longer needed.
+
+--*/
+;
+
+EFI_DEVICE_PATH_PROTOCOL *
+CoreAppendDevicePath (
+ IN EFI_DEVICE_PATH_PROTOCOL *Src1,
+ IN EFI_DEVICE_PATH_PROTOCOL *Node
+ )
+/*++
+
+Routine Description:
+ Function is used to append a Src1 and Src2 together.
+
+Arguments:
+ Src1 - A pointer to a device path data structure.
+
+ Node - A pointer to a device path data structure.
+
+Returns:
+
+ A pointer to the new device path is returned.
+ NULL is returned if space for the new device path could not be allocated from pool.
+ It is up to the caller to free the memory used by Src1 and Src2 if they are no longer needed.
+
+--*/
+;
+
+VOID *
+CoreAllocateBootServicesPool (
+ IN UINTN AllocationSize
+ )
+/*++
+
+Routine Description:
+
+ Allocate pool of type EfiBootServicesData, the size is specified with AllocationSize.
+
+Arguments:
+
+ AllocationSize - Size to allocate.
+
+Returns:
+
+ Pointer of the allocated pool.
+
+--*/
+;
+
+VOID *
+CoreAllocateZeroBootServicesPool (
+ IN UINTN AllocationSize
+ )
+/*++
+
+Routine Description:
+
+ Allocate pool of type EfiBootServicesData and zero it, the size is specified with AllocationSize.
+
+Arguments:
+
+ AllocationSize - Size to allocate.
+
+Returns:
+
+ Pointer of the allocated pool.
+
+--*/
+;
+
+EFI_STATUS
+CoreGetConfigTable (
+ IN EFI_GUID *Guid,
+ IN OUT VOID **Table
+ )
+/*++
+
+Routine Description:
+
+ Find a config table by name in system table's ConfigurationTable.
+
+Arguments:
+
+ Guid - The table name to look for
+
+ Table - Pointer of the config table
+
+Returns:
+
+ EFI_NOT_FOUND - Could not find the table in system table's ConfigurationTable.
+
+ EFI_SUCCESS - Table successfully found.
+
+--*/
+;
+
+VOID *
+CoreAllocateRuntimeCopyPool (
+ IN UINTN AllocationSize,
+ IN VOID *Buffer
+ )
+/*++
+
+Routine Description:
+
+ Allocate pool of specified size with EfiRuntimeServicesData type, and copy specified buffer to this pool.
+
+Arguments:
+
+ AllocationSize - Size to allocate.
+
+ Buffer - Specified buffer that will be copy to the allocated pool
+
+Returns:
+
+ Pointer of the allocated pool.
+
+--*/
+;
+
+VOID *
+CoreAllocateRuntimePool (
+ IN UINTN AllocationSize
+ )
+/*++
+
+Routine Description:
+
+ Allocate pool of type EfiRuntimeServicesData, the size is specified with AllocationSize.
+
+Arguments:
+
+ AllocationSize - Size to allocate.
+
+Returns:
+
+ Pointer of the allocated pool.
+
+--*/
+;
+
+VOID *
+CoreAllocateCopyPool (
+ IN UINTN AllocationSize,
+ IN VOID *Buffer
+ )
+/*++
+
+Routine Description:
+
+ Allocate pool of specified size with EfiBootServicesData type, and copy specified buffer to this pool.
+
+Arguments:
+
+ AllocationSize - Size to allocate.
+
+ Buffer - Specified buffer that will be copy to the allocated pool
+
+Returns:
+
+ Pointer of the allocated pool.
+
+--*/
+;
+
+VOID
+EfiDebugAssert (
+ IN CHAR8 *FileName,
+ IN INTN LineNumber,
+ IN CHAR8 *Description
+ )
+/*++
+
+Routine Description:
+
+ Worker function for ASSERT(). If Error Logging hub is loaded, log DEBUG
+ information; If not, do BREAKPOINT().
+
+Arguments:
+
+ FileName - File name of failing routine.
+
+ LineNumber - Line number of failing ASSERT().
+
+ Description - Descritption, usally the assertion string.
+
+Returns:
+
+ None
+
+--*/
+;
+
+VOID
+EfiDebugPrint (
+ IN UINTN ErrorLevel,
+ IN CHAR8 *Format,
+ ...
+ )
+/*++
+
+Routine Description:
+
+ Wrapper for EfiDebugVPrint ()
+
+Arguments:
+
+ ErrorLevel - If error level is set do the debug print.
+
+ Format - String to use for the print, followed by Print arguments.
+
+ ... - Print arguments.
+
+Returns:
+
+ None
+
+--*/
+;
+
+EFI_EVENT
+CoreCreateProtocolNotifyEvent (
+ IN EFI_GUID *ProtocolGuid,
+ IN EFI_TPL NotifyTpl,
+ IN EFI_EVENT_NOTIFY NotifyFunction,
+ IN VOID *NotifyContext,
+ OUT VOID **Registration,
+ IN BOOLEAN SignalFlag
+ )
+/*++
+
+Routine Description:
+
+ Create a protocol notification event and return it.
+
+Arguments:
+
+ ProtocolGuid - Protocol to register notification event on.
+
+ NotifyTpl - Maximum TPL to signal the NotifyFunction.
+
+ NotifyFuncition - EFI notification routine.
+
+ NotifyContext - Context passed into Event when it is created.
+
+ Registration - Registration key returned from RegisterProtocolNotify().
+
+ SignalFlag - Boolean value to decide whether kick the event after register or not.
+
+Returns:
+
+ The EFI_EVENT that has been registered to be signaled when a ProtocolGuid
+ is added to the system.
+
+--*/
+;
+
+VOID
+EFIAPI
+CoreInitializeFwVolDevicepathNode (
+ IN MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode,
+ IN EFI_GUID *NameGuid
+ )
+/*++
+
+Routine Description:
+
+ Initialize a Firmware Volume (FV) Media Device Path node.
+
+ Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum
+ so as we move to UEFI 2.0 support we must use a mechanism that conforms with
+ the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed
+ device path is defined for PIWG extensions of device path. If the code
+ is compiled to conform with the UEFI 2.0 specification use the new device path
+ else use the old form for backwards compatability.
+
+Arguments:
+
+ FvDevicePathNode - Pointer to a FV device path node to initialize
+ NameGuid - FV file name to use in FvDevicePathNode
+
+--*/
+;
+
+EFI_GUID *
+EFIAPI
+CoreGetNameGuidFromFwVolDevicePathNode (
+ IN MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode
+ )
+/*++
+
+Routine Description:
+
+ Check to see if the Firmware Volume (FV) Media Device Path is valid.
+
+ Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum
+ so as we move to UEFI 2.0 support we must use a mechanism that conforms with
+ the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed
+ device path is defined for PIWG extensions of device path. If the code
+ is compiled to conform with the UEFI 2.0 specification use the new device path
+ else use the old form for backwards compatability. The return value to this
+ function points to a location in FvDevicePathNode and it does not allocate
+ new memory for the GUID pointer that is returned.
+
+Arguments:
+
+ FvDevicePathNode Pointer to FV device path to check
+
+Returns:
+
+ NULL - FvDevicePathNode is not valid.
+ Other - FvDevicePathNode is valid and pointer to NameGuid was returned.
+
+--*/
+;
+#endif
diff --git a/EDK/Foundation/Core/Dxe/Ipf/Processor.h b/EDK/Foundation/Core/Dxe/Ipf/Processor.h
new file mode 100644
index 0000000..8e49d37
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/Ipf/Processor.h
@@ -0,0 +1,27 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+ Processor.h
+
+Abstract:
+ This file contains the Ipf processor specific definitions
+
+--*/
+
+#ifndef _PROCESSOR_H_
+#define _PROCESSOR_H_
+
+#define EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT (EFI_PAGE_SIZE * 2)
+
+#define DEFAULT_PAGE_ALLOCATION (EFI_PAGE_SIZE * 2)
+
+#endif \ No newline at end of file
diff --git a/EDK/Foundation/Core/Dxe/Library/Library.c b/EDK/Foundation/Core/Dxe/Library/Library.c
new file mode 100644
index 0000000..6014656
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/Library/Library.c
@@ -0,0 +1,878 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Library.c
+
+Abstract:
+
+ DXE Core library services.
+
+--*/
+
+#include "Tiano.h"
+#include "DxeCore.h"
+#include "EfiCommonLib.h"
+
+DEBUG_CODE (
+ UINTN mErrorLevel = EFI_DBUG_MASK | EFI_D_LOAD;
+)
+
+EFI_DEVICE_HANDLE_EXTENDED_DATA mStatusCodeData = {
+ sizeof (EFI_STATUS_CODE_DATA),
+ sizeof (EFI_DEVICE_HANDLE_EXTENDED_DATA) - sizeof (EFI_STATUS_CODE_DATA),
+ EFI_STATUS_CODE_SPECIFIC_DATA_GUID,
+ NULL
+};
+
+VOID
+CoreReportProgressCodeSpecific (
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN EFI_HANDLE Handle
+ )
+/*++
+
+Routine Description:
+
+ Report status code of type EFI_PROGRESS_CODE by caller ID gEfiDxeServicesTableGuid,
+ with a handle as additional information.
+
+Arguments:
+
+ Value - Describes the class/subclass/operation of the hardware or software entity
+ that the Status Code relates to.
+
+ Handle - Additional information.
+
+Returns:
+
+ None
+
+--*/
+{
+ mStatusCodeData.DataHeader.Size = sizeof (EFI_DEVICE_HANDLE_EXTENDED_DATA) - sizeof (EFI_STATUS_CODE_DATA);
+ mStatusCodeData.Handle = Handle;
+
+ if ((gStatusCode != NULL) && (gStatusCode->ReportStatusCode != NULL) ) {
+ gStatusCode->ReportStatusCode (
+ EFI_PROGRESS_CODE,
+ Value,
+ 0,
+ &gEfiDxeServicesTableGuid,
+ (EFI_STATUS_CODE_DATA *) &mStatusCodeData
+ );
+ }
+}
+
+VOID
+CoreReportProgressCode (
+ IN EFI_STATUS_CODE_VALUE Value
+ )
+/*++
+
+Routine Description:
+
+ Report status code of type EFI_PROGRESS_CODE by caller ID gEfiDxeServicesTableGuid.
+
+Arguments:
+
+ Value - Describes the class/subclass/operation of the hardware or software entity
+ that the Status Code relates to.
+
+Returns:
+
+ None
+
+--*/
+{
+ if ((gStatusCode != NULL) && (gStatusCode->ReportStatusCode != NULL) ) {
+ gStatusCode->ReportStatusCode (
+ EFI_PROGRESS_CODE,
+ Value,
+ 0,
+ &gEfiDxeServicesTableGuid,
+ NULL
+ );
+ }
+}
+
+
+VOID *
+CoreAllocateBootServicesPool (
+ IN UINTN AllocationSize
+ )
+/*++
+
+Routine Description:
+
+ Allocate pool of type EfiBootServicesData, the size is specified with AllocationSize.
+
+Arguments:
+
+ AllocationSize - Size to allocate.
+
+Returns:
+
+ Pointer of the allocated pool.
+
+--*/
+{
+ VOID *Memory;
+
+ CoreAllocatePool (EfiBootServicesData, AllocationSize, &Memory);
+ return Memory;
+}
+
+
+VOID *
+CoreAllocateZeroBootServicesPool (
+ IN UINTN AllocationSize
+ )
+/*++
+
+Routine Description:
+
+ Allocate pool of type EfiBootServicesData and zero it, the size is specified with AllocationSize.
+
+Arguments:
+
+ AllocationSize - Size to allocate.
+
+Returns:
+
+ Pointer of the allocated pool.
+
+--*/
+{
+ VOID *Memory;
+
+ Memory = CoreAllocateBootServicesPool (AllocationSize);
+ EfiCommonLibSetMem (Memory, (Memory == NULL) ? 0 : AllocationSize, 0);
+ return Memory;
+}
+
+
+VOID *
+CoreAllocateCopyPool (
+ IN UINTN AllocationSize,
+ IN VOID *Buffer
+ )
+/*++
+
+Routine Description:
+
+ Allocate pool of specified size with EfiBootServicesData type, and copy specified buffer to this pool.
+
+Arguments:
+
+ AllocationSize - Size to allocate.
+
+ Buffer - Specified buffer that will be copy to the allocated pool
+
+Returns:
+
+ Pointer of the allocated pool.
+
+--*/
+{
+ VOID *Memory;
+
+ Memory = CoreAllocateBootServicesPool (AllocationSize);
+ EfiCommonLibCopyMem (Memory, Buffer, (Memory == NULL) ? 0 : AllocationSize);
+
+ return Memory;
+}
+
+
+
+VOID *
+CoreAllocateRuntimePool (
+ IN UINTN AllocationSize
+ )
+/*++
+
+Routine Description:
+
+ Allocate pool of type EfiRuntimeServicesData, the size is specified with AllocationSize.
+
+Arguments:
+
+ AllocationSize - Size to allocate.
+
+Returns:
+
+ Pointer of the allocated pool.
+
+--*/
+{
+ VOID *Memory;
+
+ CoreAllocatePool (EfiRuntimeServicesData, AllocationSize, &Memory);
+ return Memory;
+}
+
+VOID *
+CoreAllocateRuntimeCopyPool (
+ IN UINTN AllocationSize,
+ IN VOID *Buffer
+ )
+/*++
+
+Routine Description:
+
+ Allocate pool of specified size with EfiRuntimeServicesData type, and copy specified buffer to this pool.
+
+Arguments:
+
+ AllocationSize - Size to allocate.
+
+ Buffer - Specified buffer that will be copy to the allocated pool
+
+Returns:
+
+ Pointer of the allocated pool.
+
+--*/
+
+{
+ VOID *Memory;
+
+ Memory = CoreAllocateRuntimePool (AllocationSize);
+ EfiCommonLibCopyMem (Memory, Buffer, (Memory == NULL) ? 0 : AllocationSize);
+
+ return Memory;
+}
+
+
+
+//
+// Lock Stuff
+//
+
+
+
+EFI_STATUS
+CoreAcquireLockOrFail (
+ IN EFI_LOCK *Lock
+ )
+/*++
+
+Routine Description:
+
+ Initialize a basic mutual exclusion lock. Each lock
+ provides mutual exclusion access at it's task priority
+ level. Since there is no-premption (at any TPL) or
+ multiprocessor support, acquiring the lock only consists
+ of raising to the locks TPL.
+
+Arguments:
+
+ Lock - The EFI_LOCK structure to initialize
+
+Returns:
+
+ EFI_SUCCESS - Lock Owned.
+ EFI_ACCESS_DENIED - Reentrant Lock Acquisition, Lock not Owned.
+
+--*/
+{
+ if (Lock->Lock != 0) {
+ //
+ // Lock is already owned, so bail out
+ //
+ return EFI_ACCESS_DENIED;
+ }
+
+ Lock->OwnerTpl = CoreRaiseTpl (Lock->Tpl);
+ Lock->Lock += 1;
+
+ return EFI_SUCCESS;
+}
+
+
+VOID
+CoreAcquireLock (
+ IN EFI_LOCK *Lock
+ )
+/*++
+
+Routine Description:
+
+ Raising to the task priority level of the mutual exclusion
+ lock, and then acquires ownership of the lock.
+
+Arguments:
+
+ Lock - The lock to acquire
+
+Returns:
+
+ Lock owned
+
+--*/
+{
+ EFI_STATUS Status;
+
+ Status = CoreAcquireLockOrFail (Lock);
+
+ //
+ // Lock was already locked.
+ //
+ ASSERT_EFI_ERROR (Status);
+}
+
+
+VOID
+CoreReleaseLock (
+ IN EFI_LOCK *Lock
+ )
+/*++
+
+Routine Description:
+
+ Releases ownership of the mutual exclusion lock, and
+ restores the previous task priority level.
+
+Arguments:
+
+ Lock - The lock to release
+
+Returns:
+
+ Lock unowned
+
+--*/
+{
+ EFI_TPL Tpl;
+
+ Tpl = Lock->OwnerTpl;
+
+ ASSERT (Lock->Lock == 1);
+ Lock->Lock -= 1;
+
+ CoreRestoreTpl (Tpl);
+}
+
+
+UINTN
+CoreDevicePathSize (
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ )
+/*++
+
+Routine Description:
+
+ Calculate the size of a whole device path.
+
+Arguments:
+
+ DevicePath - The pointer to the device path data.
+
+Returns:
+
+ Size of device path data structure..
+
+--*/
+{
+ EFI_DEVICE_PATH_PROTOCOL *Start;
+
+ if (DevicePath == NULL) {
+ return 0;
+ }
+
+ //
+ // Search for the end of the device path structure
+ //
+ Start = DevicePath;
+ while (!EfiIsDevicePathEnd (DevicePath)) {
+ DevicePath = EfiNextDevicePathNode (DevicePath);
+ }
+
+ //
+ // Compute the size and add back in the size of the end device path structure
+ //
+ return ((UINTN)DevicePath - (UINTN)Start) + sizeof(EFI_DEVICE_PATH_PROTOCOL);
+}
+
+
+BOOLEAN
+CoreIsDevicePathMultiInstance (
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ )
+/*++
+
+Routine Description:
+ Return TRUE is this is a multi instance device path.
+
+Arguments:
+ DevicePath - A pointer to a device path data structure.
+
+
+Returns:
+ TRUE - If DevicePath is multi instance. FALSE - If DevicePath is not multi
+ instance.
+
+--*/
+{
+ EFI_DEVICE_PATH_PROTOCOL *Node;
+
+ if (DevicePath == NULL) {
+ return FALSE;
+ }
+
+ Node = DevicePath;
+ while (!EfiIsDevicePathEnd (Node)) {
+ if (EfiIsDevicePathEndInstance (Node)) {
+ return TRUE;
+ }
+ Node = EfiNextDevicePathNode (Node);
+ }
+ return FALSE;
+}
+
+
+
+EFI_DEVICE_PATH_PROTOCOL *
+CoreDuplicateDevicePath (
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ )
+/*++
+
+Routine Description:
+ Duplicate a new device path data structure from the old one.
+
+Arguments:
+ DevicePath - A pointer to a device path data structure.
+
+Returns:
+ A pointer to the new allocated device path data.
+ Caller must free the memory used by DevicePath if it is no longer needed.
+
+--*/
+{
+ EFI_DEVICE_PATH_PROTOCOL *NewDevicePath;
+ UINTN Size;
+
+ if (DevicePath == NULL) {
+ return NULL;
+ }
+
+ //
+ // Compute the size
+ //
+ Size = CoreDevicePathSize (DevicePath);
+
+ //
+ // Allocate space for duplicate device path
+ //
+ NewDevicePath = CoreAllocateCopyPool (Size, DevicePath);
+
+ return NewDevicePath;
+}
+
+
+
+EFI_DEVICE_PATH_PROTOCOL *
+CoreAppendDevicePath (
+ IN EFI_DEVICE_PATH_PROTOCOL *Src1,
+ IN EFI_DEVICE_PATH_PROTOCOL *Src2
+ )
+/*++
+
+Routine Description:
+ Function is used to append a Src1 and Src2 together.
+
+Arguments:
+ Src1 - A pointer to a device path data structure.
+
+ Src2 - A pointer to a device path data structure.
+
+Returns:
+
+ A pointer to the new device path is returned.
+ NULL is returned if space for the new device path could not be allocated from pool.
+ It is up to the caller to free the memory used by Src1 and Src2 if they are no longer needed.
+
+--*/
+{
+ UINTN Size;
+ UINTN Size1;
+ UINTN Size2;
+ EFI_DEVICE_PATH_PROTOCOL *NewDevicePath;
+ EFI_DEVICE_PATH_PROTOCOL *SecondDevicePath;
+
+ if (Src1 == NULL && Src2 == NULL) {
+ return NULL;
+ }
+
+ //
+ // Allocate space for the combined device path. It only has one end node of
+ // length EFI_DEVICE_PATH_PROTOCOL
+ //
+ Size1 = CoreDevicePathSize (Src1);
+ Size2 = CoreDevicePathSize (Src2);
+ Size = Size1 + Size2 - sizeof(EFI_DEVICE_PATH_PROTOCOL);
+
+ NewDevicePath = CoreAllocateCopyPool (Size, Src1);
+ if (NewDevicePath != NULL) {
+
+ //
+ // Over write Src1 EndNode and do the copy
+ //
+ SecondDevicePath = (EFI_DEVICE_PATH_PROTOCOL *)((CHAR8 *)NewDevicePath + (Size1 - sizeof(EFI_DEVICE_PATH_PROTOCOL)));
+ EfiCommonLibCopyMem (SecondDevicePath, Src2, Size2);
+ }
+
+ return NewDevicePath;
+}
+
+
+
+EFI_EVENT
+CoreCreateProtocolNotifyEvent (
+ IN EFI_GUID *ProtocolGuid,
+ IN EFI_TPL NotifyTpl,
+ IN EFI_EVENT_NOTIFY NotifyFunction,
+ IN VOID *NotifyContext,
+ OUT VOID **Registration,
+ IN BOOLEAN SignalFlag
+ )
+/*++
+
+Routine Description:
+
+ Create a protocol notification event and return it.
+
+Arguments:
+
+ ProtocolGuid - Protocol to register notification event on.
+
+ NotifyTpl - Maximum TPL to signal the NotifyFunction.
+
+ NotifyFuncition - EFI notification routine.
+
+ NotifyContext - Context passed into Event when it is created.
+
+ Registration - Registration key returned from RegisterProtocolNotify().
+
+ SignalFlag - Boolean value to decide whether kick the event after register or not.
+
+Returns:
+
+ The EFI_EVENT that has been registered to be signaled when a ProtocolGuid
+ is added to the system.
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_EVENT Event;
+
+ //
+ // Create the event
+ //
+
+ Status = CoreCreateEvent (
+ EFI_EVENT_NOTIFY_SIGNAL,
+ NotifyTpl,
+ NotifyFunction,
+ NotifyContext,
+ &Event
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // Register for protocol notifactions on this event
+ //
+
+ Status = CoreRegisterProtocolNotify (
+ ProtocolGuid,
+ Event,
+ Registration
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ if (SignalFlag) {
+ //
+ // Kick the event so we will perform an initial pass of
+ // current installed drivers
+ //
+ CoreSignalEvent (Event);
+ }
+
+ return Event;
+}
+
+/*++
+Routine Description:
+
+ Initialize a Firmware Volume (FV) Media Device Path node.
+
+ Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum
+ so as we move to UEFI 2.0 support we must use a mechanism that conforms with
+ the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed
+ device path is defined for PIWG extensions of device path. If the code
+ is compiled to conform with the UEFI 2.0 specification use the new device path
+ else use the old form for backwards compatability.
+
+Arguments:
+
+ FvDevicePathNode - Pointer to a FV device path node to initialize
+ NameGuid - FV file name to use in FvDevicePathNode
+
+--*/
+VOID
+EFIAPI
+CoreInitializeFwVolDevicepathNode (
+ IN MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode,
+ IN EFI_GUID *NameGuid
+ )
+{
+//
+// EDK Defect Start: EDK848
+//
+#if 1
+//#if (EFI_SPECIFICATION_VERSION < 0x00020000)
+//
+// EDK Defect End: EDK848
+//
+ //
+ // Use old Device Path that conflicts with UEFI
+ //
+ FvDevicePathNode->Header.Type = MEDIA_DEVICE_PATH;
+ FvDevicePathNode->Header.SubType = MEDIA_FV_FILEPATH_DP;
+ SetDevicePathNodeLength (&FvDevicePathNode->Header, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH));
+
+#else
+ //
+ // Use the new Device path that does not conflict with the UEFI
+ //
+ FvDevicePathNode->Piwg.Header.Type = MEDIA_DEVICE_PATH;
+ FvDevicePathNode->Piwg.Header.SubType = MEDIA_VENDOR_DP;
+ SetDevicePathNodeLength (&FvDevicePathNode->Piwg.Header, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH));
+
+ //
+ // Add the GUID for generic PIWG device paths
+ //
+ EfiCommonLibCopyMem (&FvDevicePathNode->Piwg.PiwgSpecificDevicePath, &gEfiFrameworkDevicePathGuid, sizeof(EFI_GUID));
+
+ //
+ // Add in the FW Vol File Path PIWG defined inforation
+ //
+ FvDevicePathNode->Piwg.Type = PIWG_MEDIA_FW_VOL_FILEPATH_DEVICE_PATH_TYPE;
+
+#endif
+ EfiCommonLibCopyMem (&FvDevicePathNode->NameGuid, NameGuid, sizeof(EFI_GUID));
+}
+
+/*++
+
+Routine Description:
+
+ Check to see if the Firmware Volume (FV) Media Device Path is valid.
+
+ Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum
+ so as we move to UEFI 2.0 support we must use a mechanism that conforms with
+ the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed
+ device path is defined for PIWG extensions of device path. If the code
+ is compiled to conform with the UEFI 2.0 specification use the new device path
+ else use the old form for backwards compatability. The return value to this
+ function points to a location in FvDevicePathNode and it does not allocate
+ new memory for the GUID pointer that is returned.
+
+Arguments:
+
+ @param FvDevicePathNode Pointer to FV device path to check
+
+Returns:
+
+ NULL - FvDevicePathNode is not valid.
+ Other - FvDevicePathNode is valid and pointer to NameGuid was returned.
+
+--*/
+EFI_GUID *
+EFIAPI
+CoreGetNameGuidFromFwVolDevicePathNode (
+ IN MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode
+ )
+{
+//
+// EDK Defect Start: EDK848
+//
+#if 1
+//#if (EFI_SPECIFICATION_VERSION < 0x00020000)
+//
+// EDK Defect End: EDK848
+//
+ //
+ // Use old Device Path that conflicts with UEFI
+ //
+ if (DevicePathType (&FvDevicePathNode->Header) == MEDIA_DEVICE_PATH &&
+ DevicePathSubType (&FvDevicePathNode->Header) == MEDIA_FV_FILEPATH_DP) {
+ return &FvDevicePathNode->NameGuid;
+ }
+
+#else
+ //
+ // Use the new Device path that does not conflict with the UEFI
+ //
+ if (DevicePathType (&FvDevicePathNode->Piwg.Header) == MEDIA_DEVICE_PATH &&
+ DevicePathSubType (&FvDevicePathNode->Piwg.Header) == MEDIA_VENDOR_DP) {
+ if (EfiCompareGuid (&gEfiFrameworkDevicePathGuid, &FvDevicePathNode->Piwg.PiwgSpecificDevicePath)) {
+ if (FvDevicePathNode->Piwg.Type == PIWG_MEDIA_FW_VOL_FILEPATH_DEVICE_PATH_TYPE) {
+ return &FvDevicePathNode->NameGuid;
+ }
+ }
+ }
+#endif
+ return NULL;
+}
+
+DEBUG_CODE (
+
+VOID
+EfiDebugAssert (
+ IN CHAR8 *FileName,
+ IN INTN LineNumber,
+ IN CHAR8 *Description
+ )
+/*++
+
+Routine Description:
+
+ Worker function for ASSERT(). If Error Logging hub is loaded, log DEBUG
+ information; If not, do BREAKPOINT().
+
+ We use UINT64 buffers due to IPF alignment concerns.
+
+Arguments:
+
+ FileName - File name of failing routine.
+
+ LineNumber - Line number of failing ASSERT().
+
+ Description - Descritption, usally the assertion string.
+
+Returns:
+
+ None
+
+--*/
+{
+ UINT64 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE];
+
+ EfiDebugAssertWorker (FileName, LineNumber,Description, sizeof (Buffer), Buffer);
+
+ //
+ // Check if our pointers are valid. Can't assert because that would recurse.
+ //
+ if ((gStatusCode != NULL) && (gStatusCode->ReportStatusCode != NULL) ) {
+ gStatusCode->ReportStatusCode (
+ (EFI_ERROR_CODE | EFI_ERROR_UNRECOVERED),
+ (EFI_SOFTWARE_DXE_CORE | EFI_SW_EC_ILLEGAL_SOFTWARE_STATE),
+ 0,
+ &gEfiDxeServicesTableGuid,
+ (EFI_STATUS_CODE_DATA *)Buffer
+ );
+ }
+
+ //
+ // Put break point in module that contained the error.
+ //
+ EFI_BREAKPOINT ();
+}
+
+
+VOID
+EfiDebugVPrint (
+ IN UINTN ErrorLevel,
+ IN CHAR8 *Format,
+ IN VA_LIST Marker
+ )
+/*++
+
+Routine Description:
+
+ Worker function for DEBUG(). If Error Logging hub is loaded, DEBUG
+ information will be logged. If Error Logging hub is not loaded, do nothing.
+
+ We use UINT64 buffers due to IPF alignment concerns.
+
+Arguments:
+
+ ErrorLevel - If error level is set do the debug print.
+
+ Format - String to use for the print, followed by Print arguments.
+
+ Marker - VarArgs
+
+Returns:
+
+ None
+
+--*/
+{
+ UINT64 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE];
+
+ if (!(mErrorLevel & ErrorLevel)) {
+ return;
+ }
+
+ EfiDebugVPrintWorker (ErrorLevel, Format, Marker, sizeof (Buffer), Buffer);
+
+ //
+ // Check if our pointers are valid. Can't assert because that would recurse.
+ //
+ if ((gStatusCode != NULL) && (gStatusCode->ReportStatusCode != NULL) ) {
+ gStatusCode->ReportStatusCode (
+ EFI_DEBUG_CODE,
+ (EFI_SOFTWARE_DXE_CORE | EFI_DC_UNSPECIFIED),
+ 0,
+ &gEfiDxeServicesTableGuid,
+ (EFI_STATUS_CODE_DATA *)Buffer
+ );
+ }
+}
+
+
+VOID
+EfiDebugPrint (
+ IN UINTN ErrorLevel,
+ IN CHAR8 *Format,
+ ...
+ )
+/*++
+
+Routine Description:
+
+ Wrapper for EfiDebugVPrint ()
+
+Arguments:
+
+ ErrorLevel - If error level is set do the debug print.
+
+ Format - String to use for the print, followed by Print arguments.
+
+ ... - Print arguments.
+
+Returns:
+
+ None
+
+--*/
+{
+ VA_LIST Marker;
+
+ VA_START (Marker, Format);
+ EfiDebugVPrint (ErrorLevel, Format, Marker);
+ VA_END (Marker);
+}
+)
diff --git a/EDK/Foundation/Core/Dxe/Mem/Page.c b/EDK/Foundation/Core/Dxe/Mem/Page.c
new file mode 100644
index 0000000..0f79cb3
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/Mem/Page.c
@@ -0,0 +1,1648 @@
+/*++
+
+Copyright (c) 2007 - 2011, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ page.c
+
+Abstract:
+
+ EFI Memory page management
+
+
+Revision History
+
+--*/
+
+#include "imem.h"
+
+#define EFI_DEFAULT_PAGE_ALLOCATION_ALIGNMENT (EFI_PAGE_SIZE)
+
+//
+// Entry for tracking the memory regions for each memory type to help coalesce like memory types
+//
+typedef struct {
+ EFI_PHYSICAL_ADDRESS BaseAddress; // Base address of the coalesce bin if NumberOfPages is not 0, or 0 otherwise
+ EFI_PHYSICAL_ADDRESS MaximumAddress; // Top address of the coalesce bin if NumberOfPages is not 0, or the top address below all bin ranges
+ UINT64 CurrentNumberOfPages; // CurrentNumberOfPages allocated for this memory type
+ UINT64 NumberOfPages; // Number of pages specified in gMemoryTypeInformation
+ UINTN InformationIndex; // Index into gMemoryTypeInformation
+ BOOLEAN Special; // If this type of coalesce bin needs to be filled in memory map
+ BOOLEAN Runtime; // If this type is runtime available
+} EFI_MEMORY_TYPE_STAISTICS;
+
+//
+// MemoryMap - The current memory map
+//
+UINTN mMemoryMapKey = 0;
+
+//
+// mMapStack - space to use as temp storage to build new map descriptors
+// mMapDepth - depth of new descriptor stack
+//
+
+#define MAX_MAP_DEPTH 6
+UINTN mMapDepth = 0;
+MEMORY_MAP mMapStack[MAX_MAP_DEPTH];
+UINTN mFreeMapStack = 0;
+//
+// This list maintain the free memory map list
+//
+EFI_LIST_ENTRY mFreeMemoryMapEntryList = INITIALIZE_LIST_HEAD_VARIABLE (mFreeMemoryMapEntryList);
+BOOLEAN mMemoryTypeInformationInitialized = FALSE;
+
+EFI_MEMORY_TYPE_STAISTICS mMemoryTypeStatistics[EfiMaxMemoryType + 1] = {
+ { 0, EFI_MAX_ADDRESS, 0, 0, EfiMaxMemoryType, TRUE, FALSE }, // EfiReservedMemoryType
+ { 0, EFI_MAX_ADDRESS, 0, 0, EfiMaxMemoryType, FALSE, FALSE }, // EfiLoaderCode
+ { 0, EFI_MAX_ADDRESS, 0, 0, EfiMaxMemoryType, FALSE, FALSE }, // EfiLoaderData
+ { 0, EFI_MAX_ADDRESS, 0, 0, EfiMaxMemoryType, FALSE, FALSE }, // EfiBootServicesCode
+ { 0, EFI_MAX_ADDRESS, 0, 0, EfiMaxMemoryType, FALSE, FALSE }, // EfiBootServicesData
+ { 0, EFI_MAX_ADDRESS, 0, 0, EfiMaxMemoryType, TRUE, TRUE }, // EfiRuntimeServicesCode
+ { 0, EFI_MAX_ADDRESS, 0, 0, EfiMaxMemoryType, TRUE, TRUE }, // EfiRuntimeServicesData
+ { 0, EFI_MAX_ADDRESS, 0, 0, EfiMaxMemoryType, FALSE, FALSE }, // EfiConventionalMemory
+ { 0, EFI_MAX_ADDRESS, 0, 0, EfiMaxMemoryType, FALSE, FALSE }, // EfiUnusableMemory
+ { 0, EFI_MAX_ADDRESS, 0, 0, EfiMaxMemoryType, TRUE, FALSE }, // EfiACPIReclaimMemory
+ { 0, EFI_MAX_ADDRESS, 0, 0, EfiMaxMemoryType, TRUE, FALSE }, // EfiACPIMemoryNVS
+ { 0, EFI_MAX_ADDRESS, 0, 0, EfiMaxMemoryType, FALSE, FALSE }, // EfiMemoryMappedIO
+ { 0, EFI_MAX_ADDRESS, 0, 0, EfiMaxMemoryType, FALSE, FALSE }, // EfiMemoryMappedIOPortSpace
+ { 0, EFI_MAX_ADDRESS, 0, 0, EfiMaxMemoryType, TRUE, TRUE }, // EfiPalCode
+ { 0, EFI_MAX_ADDRESS, 0, 0, EfiMaxMemoryType, FALSE, FALSE } // EfiMaxMemoryType
+};
+
+EFI_PHYSICAL_ADDRESS mDefaultMaximumAddress = EFI_MAX_ADDRESS;
+
+EFI_MEMORY_TYPE_INFORMATION gMemoryTypeInformation[EfiMaxMemoryType + 1] = {
+ { EfiReservedMemoryType, 0 },
+ { EfiLoaderCode, 0 },
+ { EfiLoaderData, 0 },
+ { EfiBootServicesCode, 0 },
+ { EfiBootServicesData, 0 },
+ { EfiRuntimeServicesCode, 0 },
+ { EfiRuntimeServicesData, 0 },
+ { EfiConventionalMemory, 0 },
+ { EfiUnusableMemory, 0 },
+ { EfiACPIReclaimMemory, 0 },
+ { EfiACPIMemoryNVS, 0 },
+ { EfiMemoryMappedIO, 0 },
+ { EfiMemoryMappedIOPortSpace, 0 },
+ { EfiPalCode, 0 },
+ { EfiMaxMemoryType, 0 }
+};
+
+//
+// Internal prototypes
+//
+VOID
+PromoteMemoryResource (
+ VOID
+);
+
+STATIC
+VOID
+CoreAddRange (
+ IN EFI_MEMORY_TYPE Type,
+ IN EFI_PHYSICAL_ADDRESS Start,
+ IN EFI_PHYSICAL_ADDRESS End,
+ IN UINT64 Attribute
+ );
+
+STATIC
+VOID
+CoreFreeMemoryMapStack (
+ VOID
+ );
+
+STATIC
+EFI_STATUS
+CoreConvertPages (
+ IN UINT64 Start,
+ IN UINT64 NumberOfPages,
+ IN EFI_MEMORY_TYPE NewType
+ );
+
+STATIC
+VOID
+RemoveMemoryMapEntry (
+ MEMORY_MAP *Entry
+ );
+
+
+MEMORY_MAP *
+AllocateMemoryMapEntry (
+ );
+
+VOID
+CoreAcquireMemoryLock (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Enter critical section by gaining lock on gMemoryLock
+
+Arguments:
+
+ None
+
+Returns:
+
+ None
+
+--*/
+{
+ CoreAcquireLock (&gMemoryLock);
+}
+
+
+VOID
+CoreReleaseMemoryLock (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Exit critical section by releasing lock on gMemoryLock
+
+Arguments:
+
+ None
+
+Returns:
+
+ None
+
+--*/
+{
+ CoreReleaseLock (&gMemoryLock);
+}
+
+VOID
+PromoteMemoryResource (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Find untested but initialized memory regions in GCD map and convert them to be DXE allocatable.
+
+Arguments:
+
+ None
+
+Returns:
+
+ None
+
+--*/
+{
+ EFI_LIST_ENTRY *Link;
+ EFI_GCD_MAP_ENTRY *Entry;
+
+ DEBUG ((EFI_D_ERROR | EFI_D_PAGE, "Promote the memory resource\n"));
+
+ CoreAcquireGcdMemoryLock ();
+
+ Link = mGcdMemorySpaceMap.ForwardLink;
+ while (Link != &mGcdMemorySpaceMap) {
+
+ Entry = CR (Link, EFI_GCD_MAP_ENTRY, Link, EFI_GCD_MAP_SIGNATURE);
+
+ if (Entry->GcdMemoryType == EfiGcdMemoryTypeReserved &&
+ Entry->EndAddress < EFI_MAX_ADDRESS &&
+ (Entry->Capabilities & (EFI_MEMORY_PRESENT | EFI_MEMORY_INITIALIZED | EFI_MEMORY_TESTED)) ==
+ (EFI_MEMORY_PRESENT | EFI_MEMORY_INITIALIZED)) {
+ //
+ // Update the GCD map
+ //
+ Entry->GcdMemoryType = EfiGcdMemoryTypeSystemMemory;
+ Entry->Capabilities |= EFI_MEMORY_TESTED;
+ Entry->ImageHandle = gDxeCoreImageHandle;
+ Entry->DeviceHandle = NULL;
+
+ //
+ // Add to allocable system memory resource
+ //
+
+ CoreAddRange (
+ EfiConventionalMemory,
+ Entry->BaseAddress,
+ Entry->EndAddress,
+ Entry->Capabilities & ~(EFI_MEMORY_PRESENT | EFI_MEMORY_INITIALIZED | EFI_MEMORY_TESTED | EFI_MEMORY_RUNTIME)
+ );
+ mMemoryTypeStatistics[EfiConventionalMemory].CurrentNumberOfPages += RShiftU64 ((Entry->EndAddress - Entry->BaseAddress + 1), EFI_PAGE_SHIFT);
+ CoreFreeMemoryMapStack ();
+
+ }
+
+ Link = Link->ForwardLink;
+ }
+
+ CoreReleaseGcdMemoryLock ();
+
+ return;
+}
+
+VOID
+CoreAddMemoryDescriptor (
+ IN EFI_MEMORY_TYPE Type,
+ IN EFI_PHYSICAL_ADDRESS Start,
+ IN UINT64 NumberOfPages,
+ IN UINT64 Attribute
+ )
+/*++
+
+Routine Description:
+
+ Called to initialize the memory map and add descriptors to
+ the current descriptor list.
+
+ N.B. The first descriptor that is added must be general usable
+ memory as the addition allocates heap.
+
+Arguments:
+
+ Type - The type of memory to add
+
+ Start - The starting address in the memory range
+ Must be page aligned
+
+ NumberOfPages - The number of pages in the range
+
+ Attribute - Attributes of the memory to add
+
+Returns:
+
+ None. The range is added to the memory map
+
+--*/
+{
+ EFI_PHYSICAL_ADDRESS End;
+ EFI_STATUS Status;
+ UINTN Index;
+ UINTN FreeIndex;
+
+ if ((Start & EFI_PAGE_MASK) != 0) {
+ return;
+ }
+
+ if (Type >= EfiMaxMemoryType && Type <= 0x7fffffff) {
+ return;
+ }
+
+ CoreAcquireMemoryLock ();
+ End = Start + LShiftU64 (NumberOfPages, EFI_PAGE_SHIFT) - 1;
+ CoreAddRange (Type, Start, End, Attribute);
+ mMemoryTypeStatistics[Type].CurrentNumberOfPages += NumberOfPages;
+ CoreFreeMemoryMapStack ();
+ CoreReleaseMemoryLock ();
+
+ //
+ // Check to see if the statistics for the different memory types have already been established
+ //
+ if (mMemoryTypeInformationInitialized) {
+ return;
+ }
+
+ //
+ // Loop through each memory type in the order specified by the gMemoryTypeInformation[] array
+ //
+ for (Index = 0; gMemoryTypeInformation[Index].Type != EfiMaxMemoryType; Index++) {
+ //
+ // Make sure the memory type in the gMemoryTypeInformation[] array is valid
+ //
+ Type = gMemoryTypeInformation[Index].Type;
+ if (Type < 0 || Type > EfiMaxMemoryType) {
+ continue;
+ }
+
+ if (gMemoryTypeInformation[Index].NumberOfPages != 0) {
+ //
+ // Allocate pages for the current memory type from the top of available memory
+ //
+ Status = CoreAllocatePages (
+ AllocateAnyPages,
+ Type,
+ gMemoryTypeInformation[Index].NumberOfPages,
+ &mMemoryTypeStatistics[Type].BaseAddress
+ );
+ if (EFI_ERROR (Status)) {
+ //
+ // If an error occurs allocating the pages for the current memory type, then
+ // free all the pages allocates for the previous memory types and return. This
+ // operation with be retied when/if more memory is added to the system
+ //
+ for (FreeIndex = 0; FreeIndex < Index; FreeIndex++) {
+ //
+ // Make sure the memory type in the gMemoryTypeInformation[] array is valid
+ //
+ Type = gMemoryTypeInformation[FreeIndex].Type;
+ if (Type < 0 || Type > EfiMaxMemoryType) {
+ continue;
+ }
+
+ if (gMemoryTypeInformation[FreeIndex].NumberOfPages != 0) {
+ CoreFreePages (
+ mMemoryTypeStatistics[Type].BaseAddress,
+ gMemoryTypeInformation[FreeIndex].NumberOfPages
+ );
+ mMemoryTypeStatistics[Type].BaseAddress = 0;
+ mMemoryTypeStatistics[Type].MaximumAddress = EFI_MAX_ADDRESS;
+ }
+ }
+ return;
+ }
+
+ //
+ // Compute the address at the top of the current statistics
+ //
+ mMemoryTypeStatistics[Type].MaximumAddress =
+ mMemoryTypeStatistics[Type].BaseAddress +
+ LShiftU64 (gMemoryTypeInformation[Index].NumberOfPages, EFI_PAGE_SHIFT) - 1;
+
+ //
+ // If the current base address is the lowest address so far, then update the default
+ // maximum address
+ //
+ if (mMemoryTypeStatistics[Type].BaseAddress < mDefaultMaximumAddress) {
+ mDefaultMaximumAddress = mMemoryTypeStatistics[Type].BaseAddress - 1;
+ }
+ }
+ }
+
+ //
+ // There was enough system memory for all the the memory types were allocated. So,
+ // those memory areas can be freed for future allocations, and all future memory
+ // allocations can occur within their respective bins
+ //
+ for (Index = 0; gMemoryTypeInformation[Index].Type != EfiMaxMemoryType; Index++) {
+ //
+ // Make sure the memory type in the gMemoryTypeInformation[] array is valid
+ //
+ Type = gMemoryTypeInformation[Index].Type;
+ if (Type < 0 || Type > EfiMaxMemoryType) {
+ continue;
+ }
+
+ if (gMemoryTypeInformation[Index].NumberOfPages != 0) {
+ CoreFreePages (
+ mMemoryTypeStatistics[Type].BaseAddress,
+ gMemoryTypeInformation[Index].NumberOfPages
+ );
+ mMemoryTypeStatistics[Type].NumberOfPages = gMemoryTypeInformation[Index].NumberOfPages;
+ gMemoryTypeInformation[Index].NumberOfPages = 0;
+ }
+ }
+
+ //
+ // If the number of pages reserved for a memory type is 0, then all allocations for that type
+ // should be in the default range.
+ //
+ for (Type = 0; Type < EfiMaxMemoryType; Type++) {
+ for (Index = 0; gMemoryTypeInformation[Index].Type != EfiMaxMemoryType; Index++) {
+ if (Type == (EFI_MEMORY_TYPE)gMemoryTypeInformation[Index].Type) {
+ mMemoryTypeStatistics[Type].InformationIndex = Index;
+ }
+ }
+ if (mMemoryTypeStatistics[Type].MaximumAddress == EFI_MAX_ADDRESS) {
+ mMemoryTypeStatistics[Type].MaximumAddress = mDefaultMaximumAddress;
+ }
+ }
+
+ mMemoryTypeInformationInitialized = TRUE;
+}
+
+
+STATIC
+VOID
+CoreAddRange (
+ IN EFI_MEMORY_TYPE Type,
+ IN EFI_PHYSICAL_ADDRESS Start,
+ IN EFI_PHYSICAL_ADDRESS End,
+ IN UINT64 Attribute
+ )
+/*++
+
+Routine Description:
+
+ Internal function. Adds a ranges to the memory map.
+ The range must not already exist in the map.
+
+Arguments:
+
+ Type - The type of memory range to add
+
+ Start - The starting address in the memory range
+ Must be paged aligned
+
+ End - The last address in the range
+ Must be the last byte of a page
+
+ Attribute - The attributes of the memory range to add
+
+Returns:
+
+ None. The range is added to the memory map
+
+--*/
+{
+ EFI_LIST_ENTRY *Link;
+ MEMORY_MAP *Entry;
+
+ ASSERT ((Start & EFI_PAGE_MASK) == 0);
+ ASSERT (End > Start) ;
+
+ ASSERT_LOCKED (&gMemoryLock);
+
+ DEBUG ((EFI_D_PAGE, "AddRange: %lx-%lx to %d\n", Start, End, (UINTN)Type));
+
+ //
+ // Memory map being altered
+ //
+
+ mMemoryMapKey += 1;
+
+ //
+ // Look for adjoining memory descriptor
+ //
+
+ // Two memory descriptors can only be merged if they have the same Type
+ // and the same Attribute
+ //
+
+ Link = gMemoryMap.ForwardLink;
+ while (Link != &gMemoryMap) {
+ Entry = CR (Link, MEMORY_MAP, Link, MEMORY_MAP_SIGNATURE);
+ Link = Link->ForwardLink;
+
+ if (Entry->Type != Type) {
+ continue;
+ }
+
+ if (Entry->Attribute != Attribute) {
+ continue;
+ }
+
+ if (Entry->End + 1 == Start) {
+
+ Start = Entry->Start;
+ RemoveMemoryMapEntry (Entry);
+
+ } else if (Entry->Start == End + 1) {
+
+ End = Entry->End;
+ RemoveMemoryMapEntry (Entry);
+ }
+ }
+
+ //
+ // Add descriptor
+ //
+
+ mMapStack[mMapDepth].Signature = MEMORY_MAP_SIGNATURE;
+ mMapStack[mMapDepth].FromPages = FALSE;
+ mMapStack[mMapDepth].Type = Type;
+ mMapStack[mMapDepth].Start = Start;
+ mMapStack[mMapDepth].End = End;
+ mMapStack[mMapDepth].VirtualStart = 0;
+ mMapStack[mMapDepth].Attribute = Attribute;
+ InsertTailList (&gMemoryMap, &mMapStack[mMapDepth].Link);
+
+ mMapDepth += 1;
+ ASSERT (mMapDepth < MAX_MAP_DEPTH);
+ return ;
+}
+
+STATIC
+VOID
+CoreFreeMemoryMapStack (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Internal function. Moves any memory descriptors that are on the
+ temporary descriptor stack to heap.
+
+Arguments:
+
+ None
+
+Returns:
+
+ None
+
+--*/
+{
+ MEMORY_MAP *Entry;
+ MEMORY_MAP *Entry2;
+ EFI_LIST_ENTRY *Link2;
+
+ ASSERT_LOCKED (&gMemoryLock);
+
+ //
+ // If already freeing the map stack, then return
+ //
+ if (mFreeMapStack) {
+ return ;
+ }
+
+ //
+ // Move the temporary memory descriptor stack into pool
+ //
+ mFreeMapStack += 1;
+
+ while (mMapDepth) {
+ //
+ // Deque an memory map entry from mFreeMemoryMapEntryList
+ //
+ Entry = AllocateMemoryMapEntry ();
+
+ ASSERT (Entry);
+
+ //
+ // Update to proper entry
+ //
+ mMapDepth -= 1;
+
+ if (mMapStack[mMapDepth].Link.ForwardLink != NULL) {
+
+ //
+ // Move this entry to general memory
+ //
+ RemoveEntryList (&mMapStack[mMapDepth].Link);
+ mMapStack[mMapDepth].Link.ForwardLink = NULL;
+
+ *Entry = mMapStack[mMapDepth];
+ Entry->FromPages = TRUE;
+
+ //
+ // Find insertion location
+ //
+ for (Link2 = gMemoryMap.ForwardLink; Link2 != &gMemoryMap; Link2 = Link2->ForwardLink) {
+ Entry2 = CR (Link2, MEMORY_MAP, Link, MEMORY_MAP_SIGNATURE);
+ if (Entry2->FromPages && Entry2->Start > Entry->Start) {
+ break;
+ }
+ }
+
+ InsertTailList (Link2, &Entry->Link);
+
+ } else {
+ //
+ // This item of mMapStack[mMapDepth] has already been dequeued from gMemoryMap list,
+ // so here no need to move it to memory.
+ //
+ InsertTailList (&mFreeMemoryMapEntryList, &Entry->Link);
+ }
+ }
+
+ mFreeMapStack -= 1;
+}
+
+STATIC
+VOID
+RemoveMemoryMapEntry (
+ MEMORY_MAP *Entry
+ )
+/*++
+
+Routine Description:
+
+ Internal function. Removes a descriptor entry.
+
+Arguments:
+
+ Entry - The entry to remove
+
+Returns:
+
+ None
+
+--*/
+{
+ RemoveEntryList (&Entry->Link);
+ Entry->Link.ForwardLink = NULL;
+
+ if (Entry->FromPages) {
+ //
+ // Insert the free memory map descriptor to the end of mFreeMemoryMapEntryList
+ //
+ InsertTailList (&mFreeMemoryMapEntryList, &Entry->Link);
+ }
+}
+
+MEMORY_MAP *
+AllocateMemoryMapEntry (
+ )
+/*++
+
+Routine Description:
+
+ Internal function. Deque a descriptor entry from the mFreeMemoryMapEntryList.
+ If the list is emtry, then allocate a new page to refuel the list.
+ Please Note this algorithm to allocate the memory map descriptor has a property
+ that the memory allocated for memory entries always grows, and will never really be freed
+ For example, if the current boot uses 2000 memory map entries at the maximum point, but
+ ends up with only 50 at the time the OS is booted, then the memory associated with the 1950
+ memory map entries is still allocated from EfiBootServicesMemory.
+
+Arguments:
+
+ NONE
+
+Returns:
+
+ The Memory map descriptor dequed from the mFreeMemoryMapEntryList
+
+--*/
+{
+ MEMORY_MAP* FreeDescriptorEntries;
+ MEMORY_MAP* Entry;
+ UINTN Index;
+
+ if (IsListEmpty (&mFreeMemoryMapEntryList)) {
+ //
+ // The list is empty, to allocate one page to refuel the list
+ //
+ FreeDescriptorEntries = CoreAllocatePoolPages (EfiBootServicesData, EFI_SIZE_TO_PAGES(DEFAULT_PAGE_ALLOCATION), DEFAULT_PAGE_ALLOCATION);
+ if(FreeDescriptorEntries != NULL) {
+ //
+ // Enque the free memmory map entries into the list
+ //
+ for (Index = 0; Index< DEFAULT_PAGE_ALLOCATION / sizeof(MEMORY_MAP); Index++) {
+ FreeDescriptorEntries[Index].Signature = MEMORY_MAP_SIGNATURE;
+ InsertTailList (&mFreeMemoryMapEntryList, &FreeDescriptorEntries[Index].Link);
+ }
+ } else {
+ return NULL;
+ }
+ }
+ //
+ // dequeue the first descriptor from the list
+ //
+ Entry = CR (mFreeMemoryMapEntryList.ForwardLink, MEMORY_MAP, Link, MEMORY_MAP_SIGNATURE);
+ RemoveEntryList (&Entry->Link);
+
+ return Entry;
+}
+
+STATIC
+EFI_STATUS
+CoreConvertPages (
+ IN UINT64 Start,
+ IN UINT64 NumberOfPages,
+ IN EFI_MEMORY_TYPE NewType
+ )
+/*++
+
+Routine Description:
+
+ Internal function. Converts a memory range to the specified type.
+ The range must exist in the memory map.
+
+Arguments:
+
+ Start - The first address of the range
+ Must be page aligned
+
+ NumberOfPages - The number of pages to convert
+
+ NewType - The new type for the memory range
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Invalid parameter
+
+ EFI_NOT_FOUND - Could not find a descriptor cover the specified range
+ or convertion not allowed.
+
+ EFI_SUCCESS - Successfully converts the memory range to the specified type.
+
+--*/
+{
+
+ UINT64 NumberOfBytes;
+ UINT64 End;
+ UINT64 RangeEnd;
+ UINT64 Attribute;
+ EFI_LIST_ENTRY *Link;
+ MEMORY_MAP *Entry;
+ UINT64 NumberOfRangePages;
+
+ Entry = NULL;
+ NumberOfBytes = LShiftU64 (NumberOfPages, EFI_PAGE_SHIFT);
+ End = Start + NumberOfBytes - 1;
+
+ ASSERT (NumberOfPages);
+ ASSERT ((Start & EFI_PAGE_MASK) == 0);
+ ASSERT (End > Start) ;
+ ASSERT_LOCKED (&gMemoryLock);
+
+ if (NumberOfPages == 0 || (Start & EFI_PAGE_MASK ) || (Start > (Start + NumberOfBytes))) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // Convert the entire range
+ //
+
+ while (Start < End) {
+
+ //
+ // Find the entry that the covers the range
+ //
+ for (Link = gMemoryMap.ForwardLink; Link != &gMemoryMap; Link = Link->ForwardLink) {
+ Entry = CR (Link, MEMORY_MAP, Link, MEMORY_MAP_SIGNATURE);
+
+ if (Entry->Start <= Start && Entry->End > Start) {
+ break;
+ }
+ }
+
+ if ((Link == &gMemoryMap) || (Entry == NULL)) {
+ DEBUG ((EFI_D_ERROR | EFI_D_PAGE, "ConvertPages: failed to find range %lx - %lx\n", Start, End));
+ return EFI_NOT_FOUND;
+ }
+
+ //
+ // Convert range to the end, or to the end of the descriptor
+ // if that's all we've got
+ //
+ RangeEnd = End;
+ if (Entry->End < End) {
+ RangeEnd = Entry->End;
+ }
+
+ DEBUG ((EFI_D_PAGE, "ConvertRange: %lx-%lx to %d\n", Start, RangeEnd, (UINTN)NewType));
+
+ //
+ // Debug code - verify conversion is allowed
+ //
+ if (!(NewType == EfiConventionalMemory ? 1 : 0) ^ (Entry->Type == EfiConventionalMemory ? 1 : 0)) {
+ DEBUG ((EFI_D_ERROR , "ConvertPages: Incompatible memory types\n"));
+ return EFI_NOT_FOUND;
+ }
+
+ //
+ // Update counters for the number of pages allocated to each memory type
+ //
+ NumberOfRangePages = RShiftU64 (RangeEnd - Start + 1, EFI_PAGE_SHIFT);
+ if (Entry->Type >= 0 && Entry->Type < EfiMaxMemoryType) {
+ ASSERT (NumberOfRangePages <= mMemoryTypeStatistics[Entry->Type].CurrentNumberOfPages);
+ mMemoryTypeStatistics[Entry->Type].CurrentNumberOfPages -= NumberOfRangePages;
+ gMemoryTypeInformation[mMemoryTypeStatistics[Entry->Type].InformationIndex].NumberOfPages = (UINT32)mMemoryTypeStatistics[Entry->Type].CurrentNumberOfPages;
+ }
+
+ if (NewType >= 0 && NewType < EfiMaxMemoryType) {
+ mMemoryTypeStatistics[NewType].CurrentNumberOfPages += NumberOfRangePages;
+ gMemoryTypeInformation[mMemoryTypeStatistics[NewType].InformationIndex].NumberOfPages = (UINT32)mMemoryTypeStatistics[NewType].CurrentNumberOfPages;
+ }
+
+ //
+ // Pull range out of descriptor
+ //
+ if (Entry->Start == Start) {
+
+ //
+ // Clip start
+ //
+ Entry->Start = RangeEnd + 1;
+
+ } else if (Entry->End == RangeEnd) {
+
+ //
+ // Clip end
+ //
+ Entry->End = Start - 1;
+
+ } else {
+
+ //
+ // Pull it out of the center, clip current
+ //
+
+ //
+ // Add a new one
+ //
+ mMapStack[mMapDepth].Signature = MEMORY_MAP_SIGNATURE;
+ mMapStack[mMapDepth].FromPages = FALSE;
+ mMapStack[mMapDepth].Type = Entry->Type;
+ mMapStack[mMapDepth].Start = RangeEnd+1;
+ mMapStack[mMapDepth].End = Entry->End;
+
+ //
+ // Inherit Attribute from the Memory Descriptor that is being clipped
+ //
+ mMapStack[mMapDepth].Attribute = Entry->Attribute;
+
+ Entry->End = Start - 1;
+ ASSERT (Entry->Start < Entry->End);
+
+ Entry = &mMapStack[mMapDepth];
+ InsertTailList (&gMemoryMap, &Entry->Link);
+
+ mMapDepth += 1;
+ ASSERT (mMapDepth < MAX_MAP_DEPTH);
+ }
+
+ //
+ // The new range inherits the same Attribute as the Entry
+ //it is being cut out of
+ //
+ Attribute = Entry->Attribute;
+
+ //
+ // If the descriptor is empty, then remove it from the map
+ //
+ if (Entry->Start == Entry->End + 1) {
+ RemoveMemoryMapEntry (Entry);
+ Entry = NULL;
+ }
+
+ //
+ // Add our new range in
+ //
+ CoreAddRange (NewType, Start, RangeEnd, Attribute);
+
+ //
+ // Move any map descriptor stack to general pool
+ //
+ CoreFreeMemoryMapStack ();
+
+ //
+ // Bump the starting address, and convert the next range
+ //
+ Start = RangeEnd + 1;
+ }
+
+ //
+ // Converted the whole range, done
+ //
+
+ return EFI_SUCCESS;
+}
+
+
+STATIC
+UINT64
+CoreFindFreePagesI (
+ IN UINT64 MaxAddress,
+ IN UINT64 NumberOfPages,
+ IN EFI_MEMORY_TYPE NewType,
+ IN UINTN Alignment
+ )
+/*++
+
+Routine Description:
+
+ Internal function. Finds a consecutive free page range below
+ the requested address.
+
+Arguments:
+
+ MaxAddress - The address that the range must be below
+
+ NumberOfPages - Number of pages needed
+
+ NewType - The type of memory the range is going to be turned into
+
+ Alignment - Bits to align with
+
+Returns:
+
+ The base address of the range, or 0 if the range was not found
+
+--*/
+{
+ UINT64 NumberOfBytes;
+ UINT64 Target;
+ UINT64 DescStart;
+ UINT64 DescEnd;
+ UINT64 DescNumberOfBytes;
+ EFI_LIST_ENTRY *Link;
+ MEMORY_MAP *Entry;
+
+ if ((MaxAddress < EFI_PAGE_MASK) ||(NumberOfPages == 0)) {
+ return 0;
+ }
+
+ if ((MaxAddress & EFI_PAGE_MASK) != EFI_PAGE_MASK) {
+
+ //
+ // If MaxAddress is not aligned to the end of a page
+ //
+
+ //
+ // Change MaxAddress to be 1 page lower
+ //
+ MaxAddress -= (EFI_PAGE_MASK + 1);
+
+ //
+ // Set MaxAddress to a page boundary
+ //
+ MaxAddress &= ~EFI_PAGE_MASK;
+
+ //
+ // Set MaxAddress to end of the page
+ //
+ MaxAddress |= EFI_PAGE_MASK;
+ }
+
+ NumberOfBytes = LShiftU64 (NumberOfPages, EFI_PAGE_SHIFT);
+ Target = 0;
+
+ for (Link = gMemoryMap.ForwardLink; Link != &gMemoryMap; Link = Link->ForwardLink) {
+ Entry = CR (Link, MEMORY_MAP, Link, MEMORY_MAP_SIGNATURE);
+
+ //
+ // If it's not a free entry, don't bother with it
+ //
+ if (Entry->Type != EfiConventionalMemory) {
+ continue;
+ }
+
+ DescStart = Entry->Start;
+ DescEnd = Entry->End;
+
+ //
+ // If desc is past max allowed address, skip it
+ //
+ if (DescStart >= MaxAddress) {
+ continue;
+ }
+
+ //
+ // If desc ends past max allowed address, clip the end
+ //
+ if (DescEnd >= MaxAddress) {
+ DescEnd = MaxAddress;
+ }
+
+ DescEnd = ((DescEnd + 1) & (~(Alignment - 1))) - 1;
+
+ //
+ // Compute the number of bytes we can used from this
+ // descriptor, and see it's enough to satisfy the request
+ //
+ DescNumberOfBytes = DescEnd - DescStart + 1;
+
+ if (DescNumberOfBytes >= NumberOfBytes) {
+
+ //
+ // If this is the best match so far remember it
+ //
+ if (DescEnd > Target) {
+ Target = DescEnd;
+ }
+ }
+ }
+
+ //
+ // If this is a grow down, adjust target to be the allocation base
+ //
+ Target -= NumberOfBytes - 1;
+
+ //
+ // If we didn't find a match, return 0
+ //
+ if ((Target & EFI_PAGE_MASK) != 0) {
+ return 0;
+ }
+
+ return Target;
+}
+
+STATIC
+UINT64
+FindFreePages (
+ IN UINT64 MaxAddress,
+ IN UINT64 NoPages,
+ IN EFI_MEMORY_TYPE NewType,
+ IN UINTN Alignment
+ )
+/*++
+
+Routine Description:
+
+ Internal function. Finds a consecutive free page range below
+ the requested address
+
+Arguments:
+
+ MaxAddress - The address that the range must be below
+
+ NoPages - Number of pages needed
+
+ NewType - The type of memory the range is going to be turned into
+
+ Alignment - Bits to align with
+
+Returns:
+
+ The base address of the range, or 0 if the range was not found.
+
+--*/
+{
+ UINT64 NewMaxAddress;
+ UINT64 Start;
+
+ NewMaxAddress = MaxAddress;
+
+ if (NewType >= 0 && NewType < EfiMaxMemoryType && NewMaxAddress >= mMemoryTypeStatistics[NewType].MaximumAddress) {
+ NewMaxAddress = mMemoryTypeStatistics[NewType].MaximumAddress;
+ } else {
+ if (NewMaxAddress > mDefaultMaximumAddress) {
+ NewMaxAddress = mDefaultMaximumAddress;
+ }
+ }
+
+ Start = CoreFindFreePagesI (NewMaxAddress, NoPages, NewType, Alignment);
+ if (!Start) {
+ Start = CoreFindFreePagesI (MaxAddress, NoPages, NewType, Alignment);
+ if (!Start) {
+ //
+ // Here means there may be no enough memory to use, so try to go through
+ // all the memory descript to promote the untested memory directly
+ //
+ PromoteMemoryResource ();
+
+ //
+ // Allocate memory again after the memory resource re-arranged
+ //
+ Start = CoreFindFreePagesI (MaxAddress, NoPages, NewType, Alignment);
+ }
+ }
+
+ return Start;
+}
+
+EFI_BOOTSERVICE
+EFI_STATUS
+EFIAPI
+CoreAllocatePages (
+ IN EFI_ALLOCATE_TYPE Type,
+ IN EFI_MEMORY_TYPE MemoryType,
+ IN UINTN NumberOfPages,
+ IN OUT EFI_PHYSICAL_ADDRESS *Memory
+ )
+/*++
+
+Routine Description:
+
+ Allocates pages from the memory map.
+
+Arguments:
+
+ Type - The type of allocation to perform
+
+ MemoryType - The type of memory to turn the allocated pages into
+
+ NumberOfPages - The number of pages to allocate
+
+ Memory - A pointer to receive the base allocated memory address
+
+Returns:
+
+ Status. On success, Memory is filled in with the base address allocated
+
+ EFI_INVALID_PARAMETER - Parameters violate checking rules defined in spec.
+
+ EFI_NOT_FOUND - Could not allocate pages match the requirement.
+
+ EFI_OUT_OF_RESOURCES - No enough pages to allocate.
+
+ EFI_SUCCESS - Pages successfully allocated.
+
+--*/
+{
+ EFI_STATUS Status;
+ UINT64 Start;
+ UINT64 MaxAddress;
+ UINTN Alignment;
+
+ if (Type < AllocateAnyPages || Type >= (UINTN) MaxAllocateType) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((MemoryType >= EfiMaxMemoryType && MemoryType <= 0x7fffffff) ||
+ MemoryType == EfiConventionalMemory) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Alignment = EFI_DEFAULT_PAGE_ALLOCATION_ALIGNMENT;
+
+ if (MemoryType == EfiACPIReclaimMemory ||
+ MemoryType == EfiACPIMemoryNVS ||
+ MemoryType == EfiRuntimeServicesCode ||
+ MemoryType == EfiRuntimeServicesData) {
+
+ Alignment = EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT;
+ }
+
+ if (Type == AllocateAddress) {
+ if ((*Memory & (Alignment - 1)) != 0) {
+ return EFI_NOT_FOUND;
+ }
+ }
+
+ NumberOfPages += EFI_SIZE_TO_PAGES (Alignment) - 1;
+ NumberOfPages &= ~(EFI_SIZE_TO_PAGES (Alignment) - 1);
+
+ //
+ // If this is for below a particular address, then
+ //
+ Start = *Memory;
+
+ //
+ // The max address is the max natively addressable address for the processor
+ //
+ MaxAddress = EFI_MAX_ADDRESS;
+
+ if (Type == AllocateMaxAddress) {
+ MaxAddress = Start;
+ }
+
+ CoreAcquireMemoryLock ();
+
+ //
+ // If not a specific address, then find an address to allocate
+ //
+ if (Type != AllocateAddress) {
+ Start = FindFreePages (MaxAddress, NumberOfPages, MemoryType, Alignment);
+ if (Start == 0) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Done;
+ }
+ }
+
+ //
+ // Convert pages from FreeMemory to the requested type
+ //
+ Status = CoreConvertPages (Start, NumberOfPages, MemoryType);
+
+Done:
+ CoreReleaseMemoryLock ();
+
+ if (!EFI_ERROR (Status)) {
+ *Memory = Start;
+ }
+
+ return Status;
+}
+
+
+
+EFI_BOOTSERVICE
+EFI_STATUS
+EFIAPI
+CoreFreePages (
+ IN EFI_PHYSICAL_ADDRESS Memory,
+ IN UINTN NumberOfPages
+ )
+/*++
+
+Routine Description:
+
+ Frees previous allocated pages.
+
+Arguments:
+
+ Memory - Base address of memory being freed
+
+ NumberOfPages - The number of pages to free
+
+Returns:
+
+ EFI_NOT_FOUND - Could not find the entry that covers the range
+
+ EFI_INVALID_PARAMETER - Address not aligned
+
+ EFI_SUCCESS -Pages successfully freed.
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_LIST_ENTRY *Link;
+ MEMORY_MAP *Entry;
+ UINTN Alignment;
+
+ //
+ // Free the range
+ //
+ CoreAcquireMemoryLock ();
+
+ //
+ // Find the entry that the covers the range
+ //
+ Entry = NULL;
+ for (Link = gMemoryMap.ForwardLink; Link != &gMemoryMap; Link = Link->ForwardLink) {
+ Entry = CR(Link, MEMORY_MAP, Link, MEMORY_MAP_SIGNATURE);
+ if (Entry->Start <= Memory && Entry->End > Memory) {
+ break;
+ }
+ }
+ if ((Link == &gMemoryMap) || (Entry == NULL)) {
+ Status = EFI_NOT_FOUND;
+ goto Done;
+ }
+
+ Alignment = EFI_DEFAULT_PAGE_ALLOCATION_ALIGNMENT;
+
+ if (Entry->Type == EfiACPIReclaimMemory ||
+ Entry->Type == EfiACPIMemoryNVS ||
+ Entry->Type == EfiRuntimeServicesCode ||
+ Entry->Type == EfiRuntimeServicesData) {
+
+ Alignment = EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT;
+
+ }
+
+ if ((Memory & (Alignment - 1)) != 0) {
+ Status = EFI_INVALID_PARAMETER;
+ goto Done;
+ }
+
+ NumberOfPages += EFI_SIZE_TO_PAGES (Alignment) - 1;
+ NumberOfPages &= ~(EFI_SIZE_TO_PAGES (Alignment) - 1);
+
+ Status = CoreConvertPages (Memory, NumberOfPages, EfiConventionalMemory);
+
+ if (EFI_ERROR (Status)) {
+ goto Done;
+ }
+
+ //
+ // Destroy the contents
+ //
+ if (Memory < EFI_MAX_ADDRESS) {
+ DEBUG_SET_MEMORY ((VOID *)(UINTN)Memory, NumberOfPages << EFI_PAGE_SHIFT);
+ }
+
+ Done:
+ CoreReleaseMemoryLock ();
+
+ return Status;
+}
+
+
+EFI_BOOTSERVICE
+EFI_STATUS
+EFIAPI
+CoreGetMemoryMap (
+ IN OUT UINTN *MemoryMapSize,
+ IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap,
+ OUT UINTN *MapKey,
+ OUT UINTN *DescriptorSize,
+ OUT UINT32 *DescriptorVersion
+ )
+/*++
+
+Routine Description:
+
+ This function returns a copy of the current memory map. The map is an array of
+ memory descriptors, each of which describes a contiguous block of memory.
+
+Arguments:
+
+ MemoryMapSize - A pointer to the size, in bytes, of the MemoryMap buffer. On
+ input, this is the size of the buffer allocated by the caller.
+ On output, it is the size of the buffer returned by the firmware
+ if the buffer was large enough, or the size of the buffer needed
+ to contain the map if the buffer was too small.
+ MemoryMap - A pointer to the buffer in which firmware places the current memory map.
+ MapKey - A pointer to the location in which firmware returns the key for the
+ current memory map.
+ DescriptorSize - A pointer to the location in which firmware returns the size, in
+ bytes, of an individual EFI_MEMORY_DESCRIPTOR.
+ DescriptorVersion - A pointer to the location in which firmware returns the version
+ number associated with the EFI_MEMORY_DESCRIPTOR.
+
+Returns:
+
+ EFI_SUCCESS - The memory map was returned in the MemoryMap buffer.
+ EFI_BUFFER_TOO_SMALL - The MemoryMap buffer was too small. The current buffer size
+ needed to hold the memory map is returned in MemoryMapSize.
+ EFI_INVALID_PARAMETER - One of the parameters has an invalid value.
+
+--*/
+{
+ EFI_STATUS Status;
+ UINTN Size;
+ UINTN BufferSize;
+ UINTN NumberOfRuntimeEntries;
+ EFI_LIST_ENTRY *Link;
+ MEMORY_MAP *Entry;
+ EFI_GCD_MAP_ENTRY *GcdMapEntry;
+ EFI_MEMORY_TYPE Type;
+
+ //
+ // Make sure the parameters are valid
+ //
+ if (MemoryMapSize == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ CoreAcquireGcdMemoryLock ();
+
+ //
+ // Count the number of Reserved and MMIO entries that are marked for runtime use
+ //
+ NumberOfRuntimeEntries = 0;
+ for (Link = mGcdMemorySpaceMap.ForwardLink; Link != &mGcdMemorySpaceMap; Link = Link->ForwardLink) {
+ GcdMapEntry = CR (Link, EFI_GCD_MAP_ENTRY, Link, EFI_GCD_MAP_SIGNATURE);
+ if ((GcdMapEntry->GcdMemoryType == EfiGcdMemoryTypeReserved) ||
+ ((GcdMapEntry->GcdMemoryType == EfiGcdMemoryTypeMemoryMappedIo) && ((GcdMapEntry->Attributes & EFI_MEMORY_RUNTIME) == EFI_MEMORY_RUNTIME))) {
+ NumberOfRuntimeEntries++;
+ }
+ }
+
+ Size = sizeof (EFI_MEMORY_DESCRIPTOR);
+
+ //
+ // Make sure Size != sizeof(EFI_MEMORY_DESCRIPTOR). This will
+ // prevent people from having pointer math bugs in their code.
+ // now you have to use *DescriptorSize to make things work.
+ //
+ Size += sizeof(UINT64) - (Size % sizeof (UINT64));
+
+ if (DescriptorSize != NULL) {
+ *DescriptorSize = Size;
+ }
+
+ if (DescriptorVersion != NULL) {
+ *DescriptorVersion = EFI_MEMORY_DESCRIPTOR_VERSION;
+ }
+
+ CoreAcquireMemoryLock ();
+
+ //
+ // Compute the buffer size needed to fit the entire map
+ //
+ BufferSize = Size * NumberOfRuntimeEntries;
+ for (Link = gMemoryMap.ForwardLink; Link != &gMemoryMap; Link = Link->ForwardLink) {
+ BufferSize += Size;
+ }
+
+ if (*MemoryMapSize < BufferSize) {
+ Status = EFI_BUFFER_TOO_SMALL;
+ goto Done;
+ }
+
+ if (MemoryMap == NULL) {
+ Status = EFI_INVALID_PARAMETER;
+ goto Done;
+ }
+
+ //
+ // Build the map
+ //
+ EfiCommonLibZeroMem (MemoryMap, BufferSize);
+ for (Link = gMemoryMap.ForwardLink; Link != &gMemoryMap; Link = Link->ForwardLink) {
+ Entry = CR (Link, MEMORY_MAP, Link, MEMORY_MAP_SIGNATURE);
+ ASSERT (Entry->VirtualStart == 0);
+
+ //
+ // Convert internal map into an EFI_MEMORY_DESCRIPTOR
+ //
+ MemoryMap->Type = Entry->Type;
+ MemoryMap->PhysicalStart = Entry->Start;
+ MemoryMap->VirtualStart = Entry->VirtualStart;
+ MemoryMap->NumberOfPages = RShiftU64 (Entry->End - Entry->Start + 1, EFI_PAGE_SHIFT);
+ //
+ // If the memory type is EfiConventionalMemory, then determine if the range is part of a
+ // memory type bin and needs to be converted to the same memory type as the rest of the
+ // memory type bin in order to minimize EFI Memory Map changes across reboots. This
+ // improves the chances for a successful S4 resume in the presence of minor page allocation
+ // differences across reboots.
+ //
+ if (MemoryMap->Type == EfiConventionalMemory) {
+ for (Type = (EFI_MEMORY_TYPE) 0; Type < EfiMaxMemoryType; Type++) {
+ if (mMemoryTypeStatistics[Type].Special &&
+ mMemoryTypeStatistics[Type].NumberOfPages > 0 &&
+ Entry->Start >= mMemoryTypeStatistics[Type].BaseAddress &&
+ Entry->End <= mMemoryTypeStatistics[Type].MaximumAddress ) {
+ MemoryMap->Type = Type;
+ }
+ }
+ }
+ MemoryMap->Attribute = Entry->Attribute;
+ if (mMemoryTypeStatistics[MemoryMap->Type].Runtime) {
+ MemoryMap->Attribute |= EFI_MEMORY_RUNTIME;
+ }
+
+ MemoryMap = NextMemoryDescriptor (MemoryMap, Size);
+ }
+
+ for (Link = mGcdMemorySpaceMap.ForwardLink; Link != &mGcdMemorySpaceMap; Link = Link->ForwardLink) {
+ GcdMapEntry = CR (Link, EFI_GCD_MAP_ENTRY, Link, EFI_GCD_MAP_SIGNATURE);
+ if ((GcdMapEntry->GcdMemoryType == EfiGcdMemoryTypeReserved) ||
+ ((GcdMapEntry->GcdMemoryType == EfiGcdMemoryTypeMemoryMappedIo) && ((GcdMapEntry->Attributes & EFI_MEMORY_RUNTIME) == EFI_MEMORY_RUNTIME))) {
+
+ MemoryMap->PhysicalStart = GcdMapEntry->BaseAddress;
+ MemoryMap->VirtualStart = 0;
+ MemoryMap->NumberOfPages = RShiftU64 ((GcdMapEntry->EndAddress - GcdMapEntry->BaseAddress + 1), EFI_PAGE_SHIFT);
+ MemoryMap->Attribute = GcdMapEntry->Attributes & ~EFI_MEMORY_PORT_IO;
+
+ if (GcdMapEntry->GcdMemoryType == EfiGcdMemoryTypeReserved) {
+ MemoryMap->Type = EfiReservedMemoryType;
+ } else if (GcdMapEntry->GcdMemoryType == EfiGcdMemoryTypeMemoryMappedIo) {
+ if ((GcdMapEntry->Attributes & EFI_MEMORY_PORT_IO) == EFI_MEMORY_PORT_IO) {
+ MemoryMap->Type = EfiMemoryMappedIOPortSpace;
+ } else {
+ MemoryMap->Type = EfiMemoryMappedIO;
+ }
+ }
+
+ MemoryMap = NextMemoryDescriptor (MemoryMap, Size);
+ }
+ }
+
+ Status = EFI_SUCCESS;
+
+Done:
+
+ CoreReleaseMemoryLock ();
+
+ CoreReleaseGcdMemoryLock ();
+
+ //
+ // Update the map key finally
+ //
+ if (MapKey != NULL) {
+ *MapKey = mMemoryMapKey;
+ }
+
+ *MemoryMapSize = BufferSize;
+
+ return Status;
+}
+
+VOID *
+CoreAllocatePoolPages (
+ IN EFI_MEMORY_TYPE PoolType,
+ IN UINTN NumberOfPages,
+ IN UINTN Alignment
+ )
+/*++
+
+Routine Description:
+
+ Internal function. Used by the pool functions to allocate pages
+ to back pool allocation requests.
+
+Arguments:
+
+ PoolType - The type of memory for the new pool pages
+
+ NumberOfPages - No of pages to allocate
+
+ Alignment - Bits to align.
+
+Returns:
+
+ The allocated memory, or NULL
+
+--*/
+{
+ EFI_STATUS Status;
+ UINT64 Start;
+
+ //
+ // Find the pages to convert
+ //
+ Start = FindFreePages (EFI_MAX_ADDRESS, NumberOfPages, PoolType, Alignment);
+
+ //
+ // Convert it to boot services data
+ //
+ if (Start == 0) {
+ DEBUG ((EFI_D_ERROR | EFI_D_PAGE, "AllocatePoolPages: failed to allocate %d pages\n", NumberOfPages));
+ } else {
+ Status = CoreConvertPages (Start, NumberOfPages, PoolType);
+ }
+
+ return (VOID *)(UINTN)Start;
+}
+
+VOID
+CoreFreePoolPages (
+ IN EFI_PHYSICAL_ADDRESS Memory,
+ IN UINTN NumberOfPages
+ )
+/*++
+
+Routine Description:
+
+ Internal function. Frees pool pages allocated via AllocatePoolPages ()
+
+Arguments:
+
+ Memory - The base address to free
+
+ NumberOfPages - The number of pages to free
+
+Returns:
+
+ None
+
+--*/
+{
+ CoreConvertPages (Memory, NumberOfPages, EfiConventionalMemory);
+}
+
+
+EFI_STATUS
+CoreTerminateMemoryMap (
+ IN UINTN MapKey
+ )
+/*++
+
+Routine Description:
+
+ Make sure the memory map is following all the construction rules,
+ it is the last time to check memory map error before exit boot services.
+
+Arguments:
+
+ MapKey - Memory map key
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Memory map not consistent with construction rules.
+
+ EFI_SUCCESS - Valid memory map.
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_LIST_ENTRY *Link;
+ MEMORY_MAP *Entry;
+
+ Status = EFI_SUCCESS;
+
+ CoreAcquireMemoryLock ();
+
+ if (MapKey == mMemoryMapKey) {
+
+ //
+ // Make sure the memory map is following all the construction rules
+ // This is the last chance we will be able to display any messages on
+ // the console devices.
+ //
+
+ for (Link = gMemoryMap.ForwardLink; Link != &gMemoryMap; Link = Link->ForwardLink) {
+ Entry = CR(Link, MEMORY_MAP, Link, MEMORY_MAP_SIGNATURE);
+ if (Entry->Attribute & EFI_MEMORY_RUNTIME) {
+ if (Entry->Type == EfiACPIReclaimMemory || Entry->Type == EfiACPIMemoryNVS) {
+ DEBUG((EFI_D_ERROR, "ExitBootServices: ACPI memory entry has RUNTIME attribute set.\n"));
+ CoreReleaseMemoryLock ();
+ return EFI_INVALID_PARAMETER;
+ }
+ if (Entry->Start & (EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT - 1)) {
+ DEBUG((EFI_D_ERROR, "ExitBootServices: A RUNTIME memory entry is not on a proper alignment.\n"));
+ CoreReleaseMemoryLock ();
+ return EFI_INVALID_PARAMETER;
+ }
+ if ((Entry->End + 1) & (EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT - 1)) {
+ DEBUG((EFI_D_ERROR, "ExitBootServices: A RUNTIME memory entry is not on a proper alignment.\n"));
+ CoreReleaseMemoryLock ();
+ return EFI_INVALID_PARAMETER;
+ }
+ }
+ }
+
+ //
+ // The map key they gave us matches what we expect. Fall through and
+ // return success. In an ideal world we would clear out all of
+ // EfiBootServicesCode and EfiBootServicesData. However this function
+ // is not the last one called by ExitBootServices(), so we have to
+ // preserve the memory contents.
+ //
+ } else {
+ Status = EFI_INVALID_PARAMETER;
+ }
+
+ CoreReleaseMemoryLock ();
+
+ return Status;
+}
+
+
+
+
+
+
+
+
diff --git a/EDK/Foundation/Core/Dxe/Mem/imem.h b/EDK/Foundation/Core/Dxe/Mem/imem.h
new file mode 100644
index 0000000..d9029c5
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/Mem/imem.h
@@ -0,0 +1,214 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ imem.h
+
+Abstract:
+
+ Head file to imem.h
+
+
+Revision History
+
+--*/
+
+#ifndef _IMEM_H_
+#define _IMEM_H_
+
+#include "Tiano.h"
+#include "DxeCore.h"
+#include "Processor.h"
+
+//
+// MEMORY_MAP_ENTRY
+//
+
+#define MEMORY_MAP_SIGNATURE EFI_SIGNATURE_32('m','m','a','p')
+typedef struct {
+ UINTN Signature;
+ EFI_LIST_ENTRY Link;
+ BOOLEAN FromPages;
+
+ EFI_MEMORY_TYPE Type;
+ UINT64 Start;
+ UINT64 End;
+
+ UINT64 VirtualStart;
+ UINT64 Attribute;
+} MEMORY_MAP;
+
+//
+// Internal prototypes
+//
+
+VOID *
+CoreAllocatePoolPages (
+ IN EFI_MEMORY_TYPE PoolType,
+ IN UINTN NumberOfPages,
+ IN UINTN Alignment
+ )
+/*++
+
+Routine Description:
+
+ Internal function. Used by the pool functions to allocate pages
+ to back pool allocation requests.
+
+Arguments:
+
+ PoolType - The type of memory for the new pool pages
+
+ NumberOfPages - No of pages to allocate
+
+ Alignment - Bits to align.
+
+Returns:
+
+ The allocated memory, or NULL
+
+--*/
+;
+
+
+VOID
+CoreFreePoolPages (
+ IN EFI_PHYSICAL_ADDRESS Memory,
+ IN UINTN NumberOfPages
+ )
+/*++
+
+Routine Description:
+
+ Internal function. Frees pool pages allocated via AllocatePoolPages ()
+
+Arguments:
+
+ Memory - The base address to free
+
+ NumberOfPages - The number of pages to free
+
+Returns:
+
+ None
+
+--*/
+;
+
+
+VOID *
+CoreAllocatePoolI (
+ IN EFI_MEMORY_TYPE PoolType,
+ IN UINTN Size
+ )
+/*++
+
+Routine Description:
+
+ Internal function to allocate pool of a particular type.
+
+ N.B. Caller must have the memory lock held
+
+
+Arguments:
+
+ PoolType - Type of pool to allocate
+
+ Size - The amount of pool to allocate
+
+Returns:
+
+ The allocate pool, or NULL
+
+--*/
+;
+
+
+EFI_STATUS
+CoreFreePoolI (
+ IN VOID *Buffer
+ )
+/*++
+
+Routine Description:
+
+ Internal function to free a pool entry.
+
+ N.B. Caller must have the memory lock held
+
+
+Arguments:
+
+ Buffer - The allocated pool entry to free
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Buffer not valid
+
+ EFI_SUCCESS - Buffer successfully freed.
+
+--*/
+;
+
+
+VOID
+CoreAcquireMemoryLock (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Enter critical section by gaining lock on gMemoryLock
+
+Arguments:
+
+ None
+
+Returns:
+
+ None
+
+--*/
+;
+
+VOID
+CoreReleaseMemoryLock (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Exit critical section by releasing lock on gMemoryLock
+
+Arguments:
+
+ None
+
+Returns:
+
+ None
+
+--*/
+;
+
+
+//
+// Internal Global data
+//
+
+extern EFI_LOCK gMemoryLock;
+extern EFI_LIST_ENTRY gMemoryMap;
+extern MEMORY_MAP *gMemoryLastConvert;
+extern EFI_LIST_ENTRY mGcdMemorySpaceMap;
+#endif
diff --git a/EDK/Foundation/Core/Dxe/Mem/memdata.c b/EDK/Foundation/Core/Dxe/Mem/memdata.c
new file mode 100644
index 0000000..580b0bd
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/Mem/memdata.c
@@ -0,0 +1,41 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ memdata.c
+
+Abstract:
+
+ Global data used in memory service
+
+
+Revision History
+
+--*/
+
+#include "imem.h"
+
+
+//
+// MemoryLock - synchronizes access to the memory map and pool lists
+//
+EFI_LOCK gMemoryLock = EFI_INITIALIZE_LOCK_VARIABLE (EFI_TPL_NOTIFY);
+
+//
+// MemoryMap - the current memory map
+//
+EFI_LIST_ENTRY gMemoryMap = INITIALIZE_LIST_HEAD_VARIABLE (gMemoryMap);
+
+//
+// MemoryLastConvert - the last memory descriptor used for a conversion request
+//
+MEMORY_MAP *gMemoryLastConvert;
diff --git a/EDK/Foundation/Core/Dxe/Mem/pool.c b/EDK/Foundation/Core/Dxe/Mem/pool.c
new file mode 100644
index 0000000..a13d94d
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/Mem/pool.c
@@ -0,0 +1,613 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ pool.c
+
+Abstract:
+
+ EFI Memory pool management
+
+Revision History
+
+--*/
+
+#include "imem.h"
+
+#define POOL_FREE_SIGNATURE EFI_SIGNATURE_32('p','f','r','0')
+typedef struct {
+ UINT32 Signature;
+ UINT32 Index;
+ EFI_LIST_ENTRY Link;
+} POOL_FREE;
+
+
+#define POOL_HEAD_SIGNATURE EFI_SIGNATURE_32('p','h','d','0')
+typedef struct {
+ UINT32 Signature;
+ UINT32 Size;
+ EFI_MEMORY_TYPE Type;
+ UINTN Reserved;
+ CHAR8 Data[1];
+} POOL_HEAD;
+
+#define SIZE_OF_POOL_HEAD EFI_FIELD_OFFSET(POOL_HEAD,Data)
+
+#define POOL_TAIL_SIGNATURE EFI_SIGNATURE_32('p','t','a','l')
+typedef struct {
+ UINT32 Signature;
+ UINT32 Size;
+} POOL_TAIL;
+
+
+#define POOL_SHIFT 7
+
+#define POOL_OVERHEAD (SIZE_OF_POOL_HEAD + sizeof(POOL_TAIL))
+
+#define HEAD_TO_TAIL(a) \
+ ((POOL_TAIL *) (((CHAR8 *) (a)) + (a)->Size - sizeof(POOL_TAIL)));
+
+
+#define SIZE_TO_LIST(a) ((a) >> POOL_SHIFT)
+#define LIST_TO_SIZE(a) ((a+1) << POOL_SHIFT)
+
+#define MAX_POOL_LIST SIZE_TO_LIST(DEFAULT_PAGE_ALLOCATION)
+#define MAX_POOL_SIZE (EFI_MAX_ADDRESS - POOL_OVERHEAD)
+
+//
+// Globals
+//
+
+#define POOL_SIGNATURE EFI_SIGNATURE_32('p','l','s','t')
+typedef struct {
+ INTN Signature;
+ UINTN Used;
+ EFI_MEMORY_TYPE MemoryType;
+ EFI_LIST_ENTRY FreeList[MAX_POOL_LIST];
+ EFI_LIST_ENTRY Link;
+} POOL;
+
+
+POOL PoolHead[EfiMaxMemoryType];
+EFI_LIST_ENTRY PoolHeadList;
+
+//
+//
+//
+
+VOID
+CoreInitializePool (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Called to initialize the pool.
+
+Arguments:
+
+ None
+
+Returns:
+
+ None
+
+--*/
+{
+ UINTN Type;
+ UINTN Index;
+
+ for (Type=0; Type < EfiMaxMemoryType; Type++) {
+ PoolHead[Type].Signature = 0;
+ PoolHead[Type].Used = 0;
+ PoolHead[Type].MemoryType = Type;
+ for (Index=0; Index < MAX_POOL_LIST; Index++) {
+ InitializeListHead (&PoolHead[Type].FreeList[Index]);
+ }
+ }
+ InitializeListHead (&PoolHeadList);
+}
+
+
+POOL *
+LookupPoolHead (
+ IN EFI_MEMORY_TYPE MemoryType
+ )
+/*++
+
+Routine Description:
+
+ Look up pool head for specified memory type.
+
+Arguments:
+
+ MemoryType - Memory type of which pool head is looked for
+
+Returns:
+
+ Pointer of Corresponding pool head.
+
+--*/
+{
+ EFI_LIST_ENTRY *Link;
+ POOL *Pool;
+ UINTN Index;
+
+ if (MemoryType >= 0 && MemoryType < EfiMaxMemoryType) {
+ return &PoolHead[MemoryType];
+ }
+
+ if (MemoryType < 0) {
+
+ for (Link = PoolHeadList.ForwardLink; Link != &PoolHeadList; Link = Link->ForwardLink) {
+ Pool = CR(Link, POOL, Link, POOL_SIGNATURE);
+ if (Pool->MemoryType == MemoryType) {
+ return Pool;
+ }
+ }
+
+ Pool = CoreAllocatePoolI (EfiBootServicesData, sizeof (POOL));
+ if (Pool == NULL) {
+ return NULL;
+ }
+
+ Pool->Signature = POOL_SIGNATURE;
+ Pool->Used = 0;
+ Pool->MemoryType = MemoryType;
+ for (Index=0; Index < MAX_POOL_LIST; Index++) {
+ InitializeListHead (&Pool->FreeList[Index]);
+ }
+
+ InsertHeadList (&PoolHeadList, &Pool->Link);
+
+ return Pool;
+ }
+
+ return NULL;
+}
+
+
+EFI_BOOTSERVICE
+EFI_STATUS
+EFIAPI
+CoreAllocatePool (
+ IN EFI_MEMORY_TYPE PoolType,
+ IN UINTN Size,
+ OUT VOID **Buffer
+ )
+/*++
+
+Routine Description:
+
+ Allocate pool of a particular type.
+
+Arguments:
+
+ PoolType - Type of pool to allocate
+
+ Size - The amount of pool to allocate
+
+ Buffer - The address to return a pointer to the allocated pool
+
+Returns:
+
+ EFI_INVALID_PARAMETER - PoolType not valid
+
+ EFI_OUT_OF_RESOURCES - Size exceeds max pool size or allocation failed.
+
+ EFI_SUCCESS - Pool successfully allocated.
+
+--*/
+{
+ EFI_STATUS Status;
+
+ //
+ // If it's not a valid type, fail it
+ //
+ if ((PoolType >= EfiMaxMemoryType && PoolType <= 0x7fffffff) ||
+ PoolType == EfiConventionalMemory) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ *Buffer = NULL;
+ //
+ // As we need to reserve memory for other resources, we can't expect to allocate
+ // all memory( EFI_MAX_ADDRESS - POOL_OVERHEAD + 1) using this function,
+ // the following check operation is only used to make sure the allocated pool size will
+ // not rool over from a very large number to a very small number.
+ //
+ if (Size > MAX_POOL_SIZE) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ //
+ // Acquire the memory lock and make the allocation
+ //
+ Status = CoreAcquireLockOrFail (&gMemoryLock);
+ if (EFI_ERROR (Status)) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ *Buffer = CoreAllocatePoolI (PoolType, Size);
+ CoreReleaseMemoryLock ();
+ return (*Buffer != NULL) ? EFI_SUCCESS : EFI_OUT_OF_RESOURCES;
+}
+
+
+VOID *
+CoreAllocatePoolI (
+ IN EFI_MEMORY_TYPE PoolType,
+ IN UINTN Size
+ )
+/*++
+
+Routine Description:
+
+ Internal function to allocate pool of a particular type.
+
+ N.B. Caller must have the memory lock held
+
+
+Arguments:
+
+ PoolType - Type of pool to allocate
+
+ Size - The amount of pool to allocate
+
+Returns:
+
+ The allocate pool, or NULL
+
+--*/
+{
+ POOL *Pool;
+ POOL_FREE *Free;
+ POOL_HEAD *Head;
+ POOL_TAIL *Tail;
+ CHAR8 *NewPage;
+ VOID *Buffer;
+ UINTN Index;
+ UINTN FSize;
+ UINTN offset;
+ UINTN Adjustment;
+ UINTN NoPages;
+
+ ASSERT_LOCKED (&gMemoryLock);
+
+ //
+ // Adjust the size by the pool header & tail overhead
+ //
+
+ //
+ // Adjusting the Size to be of proper alignment so that
+ // we don't get an unaligned access fault later when
+ // pool_Tail is being initialized
+ //
+ ALIGN_VARIABLE (Size, Adjustment);
+
+ Size += POOL_OVERHEAD;
+ Index = SIZE_TO_LIST(Size);
+ Pool = LookupPoolHead (PoolType);
+ if (Pool== NULL) {
+ return NULL;
+ }
+ Head = NULL;
+
+ //
+ // If allocation is over max size, just allocate pages for the request
+ // (slow)
+ //
+ if (Index >= MAX_POOL_LIST) {
+ NoPages = EFI_SIZE_TO_PAGES(Size) + EFI_SIZE_TO_PAGES (DEFAULT_PAGE_ALLOCATION) - 1;
+ NoPages &= ~(EFI_SIZE_TO_PAGES (DEFAULT_PAGE_ALLOCATION) - 1);
+ Head = CoreAllocatePoolPages (PoolType, NoPages, DEFAULT_PAGE_ALLOCATION);
+ goto Done;
+ }
+
+ //
+ // If there's no free pool in the proper list size, go get some more pages
+ //
+ if (IsListEmpty (&Pool->FreeList[Index])) {
+
+ //
+ // Get another page
+ //
+ NewPage = CoreAllocatePoolPages(PoolType, EFI_SIZE_TO_PAGES (DEFAULT_PAGE_ALLOCATION), DEFAULT_PAGE_ALLOCATION);
+ if (NewPage == NULL) {
+ goto Done;
+ }
+
+ //
+ // Carve up new page into free pool blocks
+ //
+ offset = 0;
+ while (offset < DEFAULT_PAGE_ALLOCATION) {
+ ASSERT (Index < MAX_POOL_LIST);
+ FSize = LIST_TO_SIZE(Index);
+
+ while (offset + FSize <= DEFAULT_PAGE_ALLOCATION) {
+ Free = (POOL_FREE *) &NewPage[offset];
+ Free->Signature = POOL_FREE_SIGNATURE;
+ Free->Index = (UINT32)Index;
+ InsertHeadList (&Pool->FreeList[Index], &Free->Link);
+ offset += FSize;
+ }
+
+ Index -= 1;
+ }
+
+ ASSERT (offset == DEFAULT_PAGE_ALLOCATION);
+ Index = SIZE_TO_LIST(Size);
+ }
+
+ //
+ // Remove entry from free pool list
+ //
+ Free = CR (Pool->FreeList[Index].ForwardLink, POOL_FREE, Link, POOL_FREE_SIGNATURE);
+ RemoveEntryList (&Free->Link);
+
+ Head = (POOL_HEAD *) Free;
+
+Done:
+ Buffer = NULL;
+
+ if (Head != NULL) {
+
+ //
+ // If we have a pool buffer, fill in the header & tail info
+ //
+ Head->Signature = POOL_HEAD_SIGNATURE;
+ Head->Size = (UINT32) Size;
+ Head->Type = (EFI_MEMORY_TYPE) PoolType;
+ Tail = HEAD_TO_TAIL (Head);
+ Tail->Signature = POOL_TAIL_SIGNATURE;
+ Tail->Size = (UINT32) Size;
+ Buffer = Head->Data;
+ DEBUG_SET_MEMORY (Buffer, Size - POOL_OVERHEAD);
+
+ DEBUG (
+ (EFI_D_POOL,
+ "AllcocatePoolI: Type %x, Addr %x (len %x) %,d\n",
+ (UINTN)PoolType,
+ Buffer,
+ Size - POOL_OVERHEAD,
+ Pool->Used)
+ );
+
+ //
+ // Account the allocation
+ //
+ Pool->Used += Size;
+
+ } else {
+ DEBUG ((EFI_D_ERROR | EFI_D_POOL, "AllocatePool: failed to allocate %d bytes\n", Size));
+ }
+
+ return Buffer;
+}
+
+
+EFI_BOOTSERVICE
+EFI_STATUS
+EFIAPI
+CoreFreePool (
+ IN VOID *Buffer
+ )
+/*++
+
+Routine Description:
+
+ Frees pool.
+
+Arguments:
+
+ Buffer - The allocated pool entry to free
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Buffer is not a valid value.
+
+ EFI_SUCCESS - Pool successfully freed.
+
+--*/
+{
+ EFI_STATUS Status;
+
+ if (NULL == Buffer) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ CoreAcquireMemoryLock ();
+ Status = CoreFreePoolI (Buffer);
+ CoreReleaseMemoryLock ();
+ return Status;
+}
+
+
+EFI_STATUS
+CoreFreePoolI (
+ IN VOID *Buffer
+ )
+/*++
+
+Routine Description:
+
+ Internal function to free a pool entry.
+
+ N.B. Caller must have the memory lock held
+
+
+Arguments:
+
+ Buffer - The allocated pool entry to free
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Buffer not valid
+
+ EFI_SUCCESS - Buffer successfully freed.
+
+--*/
+{
+ POOL *Pool;
+ POOL_HEAD *Head;
+ POOL_TAIL *Tail;
+ POOL_FREE *Free;
+ UINTN Index;
+ UINTN NoPages;
+ UINTN Size;
+ CHAR8 *NewPage;
+ UINTN FSize;
+ UINTN offset;
+ BOOLEAN AllFree;
+
+ ASSERT(NULL != Buffer);
+ //
+ // Get the head & tail of the pool entry
+ //
+ Head = CR (Buffer, POOL_HEAD, Data, POOL_HEAD_SIGNATURE);
+ ASSERT(NULL != Head);
+
+ if (Head->Signature != POOL_HEAD_SIGNATURE) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Tail = HEAD_TO_TAIL (Head);
+ ASSERT(NULL != Tail);
+
+ //
+ // Debug
+ //
+ ASSERT (Tail->Signature == POOL_TAIL_SIGNATURE);
+ ASSERT (Head->Size == Tail->Size);
+ ASSERT_LOCKED (&gMemoryLock);
+
+ if (Tail->Signature != POOL_TAIL_SIGNATURE) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (Head->Size != Tail->Size) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // Determine the pool type and account for it
+ //
+ Size = Head->Size;
+ Pool = LookupPoolHead (Head->Type);
+ if (Pool == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+ Pool->Used -= Size;
+ DEBUG ((EFI_D_POOL, "FreePool: %x (len %x) %,d\n", Head->Data, (UINTN)Head->Size - POOL_OVERHEAD, Pool->Used));
+
+ //
+ // Determine the pool list
+ //
+ Index = SIZE_TO_LIST(Size);
+ DEBUG_SET_MEMORY (Head, Size);
+
+ //
+ // If it's not on the list, it must be pool pages
+ //
+ if (Index >= MAX_POOL_LIST) {
+
+ //
+ // Return the memory pages back to free memory
+ //
+ NoPages = EFI_SIZE_TO_PAGES(Size) + EFI_SIZE_TO_PAGES (DEFAULT_PAGE_ALLOCATION) - 1;
+ NoPages &= ~(EFI_SIZE_TO_PAGES (DEFAULT_PAGE_ALLOCATION) - 1);
+ CoreFreePoolPages ((EFI_PHYSICAL_ADDRESS) (UINTN) Head, NoPages);
+
+ } else {
+
+ //
+ // Put the pool entry onto the free pool list
+ //
+ Free = (POOL_FREE *) Head;
+ ASSERT(NULL != Free);
+ Free->Signature = POOL_FREE_SIGNATURE;
+ Free->Index = (UINT32)Index;
+ InsertHeadList (&Pool->FreeList[Index], &Free->Link);
+
+ //
+ // See if all the pool entries in the same page as Free are freed pool
+ // entries
+ //
+ NewPage = (CHAR8 *)((UINTN)Free & ~((DEFAULT_PAGE_ALLOCATION) -1));
+ Free = (POOL_FREE *) &NewPage[0];
+ ASSERT(NULL != Free);
+
+ if (Free->Signature == POOL_FREE_SIGNATURE) {
+
+ Index = Free->Index;
+
+ AllFree = TRUE;
+ offset = 0;
+
+ while ((offset < DEFAULT_PAGE_ALLOCATION) && (AllFree)) {
+ FSize = LIST_TO_SIZE(Index);
+ while (offset + FSize <= DEFAULT_PAGE_ALLOCATION) {
+ Free = (POOL_FREE *) &NewPage[offset];
+ ASSERT(NULL != Free);
+ if (Free->Signature != POOL_FREE_SIGNATURE) {
+ AllFree = FALSE;
+ }
+ offset += FSize;
+ }
+ Index -= 1;
+ }
+
+ if (AllFree) {
+
+ //
+ // All of the pool entries in the same page as Free are free pool
+ // entries
+ // Remove all of these pool entries from the free loop lists.
+ //
+ Free = (POOL_FREE *) &NewPage[0];
+ ASSERT(NULL != Free);
+ Index = Free->Index;
+ offset = 0;
+
+ while (offset < DEFAULT_PAGE_ALLOCATION) {
+ FSize = LIST_TO_SIZE(Index);
+ while (offset + FSize <= DEFAULT_PAGE_ALLOCATION) {
+ Free = (POOL_FREE *) &NewPage[offset];
+ ASSERT(NULL != Free);
+ RemoveEntryList (&Free->Link);
+ offset += FSize;
+ }
+ Index -= 1;
+ }
+
+ //
+ // Free the page
+ //
+ CoreFreePoolPages ((EFI_PHYSICAL_ADDRESS) (UINTN)NewPage, EFI_SIZE_TO_PAGES (DEFAULT_PAGE_ALLOCATION));
+ }
+ }
+ }
+
+ //
+ // If this is an OS specific memory type, then check to see if the last
+ // portion of that memory type has been freed. If it has, then free the
+ // list entry for that memory type
+ //
+ if (Pool->MemoryType < 0 && Pool->Used == 0) {
+ RemoveEntryList (&Pool->Link);
+ CoreFreePoolI (Pool);
+ }
+
+ return EFI_SUCCESS;
+}
diff --git a/EDK/Foundation/Core/Dxe/Misc/DebugImageInfo.c b/EDK/Foundation/Core/Dxe/Misc/DebugImageInfo.c
new file mode 100644
index 0000000..c1a81a3
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/Misc/DebugImageInfo.c
@@ -0,0 +1,262 @@
+/*++
+
+Copyright (c) 2004 - 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ DebugImageInfo.c
+
+Abstract:
+
+ Support functions for managing debug image info table when loading and unloading
+ images.
+
+--*/
+
+#include "Tiano.h"
+#include "DxeCore.h"
+#include "DebugImageInfo.h"
+
+
+static EFI_DEBUG_IMAGE_INFO_TABLE_HEADER mDebugInfoTableHeader = {
+ 0, // volatile UINT32 UpdateStatus;
+ 0, // UINT32 TableSize;
+ NULL // EFI_DEBUG_IMAGE_INFO *EfiDebugImageInfoTable;
+};
+
+static EFI_SYSTEM_TABLE_POINTER *mDebugTable = NULL;
+
+
+VOID
+CoreInitializeDebugImageInfoTable (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Creates and initializes the DebugImageInfo Table. Also creates the configuration
+ table and registers it into the system table.
+
+Arguments:
+ None
+
+Returns:
+ NA
+
+Notes:
+ This function allocates memory, frees it, and then allocates memory at an
+ address within the initial allocation. Since this function is called early
+ in DXE core initialization (before drivers are dispatched), this should not
+ be a problem.
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_PHYSICAL_ADDRESS Mem;
+ UINTN NumberOfPages;
+
+ //
+ // Allocate boot services memory for the structure. It's required to be aligned on
+ // a 4M boundary, so allocate a 4M block (plus what we require), free it up, calculate
+ // a 4M aligned address within the memory we just freed, and then allocate memory at that
+ // address for our initial structure.
+ //
+ NumberOfPages = FOUR_MEG_PAGES + EFI_SIZE_TO_PAGES(sizeof (EFI_SYSTEM_TABLE_POINTER));
+
+ Status = CoreAllocatePages (AllocateAnyPages, EfiBootServicesData, NumberOfPages , &Mem);
+ ASSERT_EFI_ERROR (Status);
+ if (EFI_ERROR(Status)) {
+ return;
+ }
+ Status = CoreFreePages (Mem, NumberOfPages);
+ ASSERT_EFI_ERROR (Status);
+ if (EFI_ERROR(Status)) {
+ return;
+ }
+ //
+ // Now get a 4M aligned address within the memory range we were given.
+ // Then allocate memory at that address
+ //
+ Mem = (Mem + FOUR_MEG_MASK) & (~FOUR_MEG_MASK);
+
+ Status = CoreAllocatePages (AllocateAddress, EfiBootServicesData, NumberOfPages - FOUR_MEG_PAGES, &Mem);
+ ASSERT_EFI_ERROR (Status);
+ if (EFI_ERROR(Status)) {
+ return;
+ }
+ //
+ // We now have a 4M aligned page allocated, so fill in the data structure.
+ // Ideally we would update the CRC now as well, but the service may not yet be available.
+ // See comments in the CoreUpdateDebugTableCrc32() function below for details.
+ //
+ mDebugTable = (EFI_SYSTEM_TABLE_POINTER *)(UINTN)Mem;
+ mDebugTable->Signature = EFI_SYSTEM_TABLE_SIGNATURE;
+ mDebugTable->EfiSystemTableBase = (EFI_PHYSICAL_ADDRESS) (UINTN) gST;
+ mDebugTable->Crc32 = 0;
+ Status = CoreInstallConfigurationTable (&gEfiDebugImageInfoTableGuid, &mDebugInfoTableHeader);
+ ASSERT_EFI_ERROR (Status);
+}
+
+VOID
+CoreUpdateDebugTableCrc32 (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Update the CRC32 in the Debug Table.
+ Since the CRC32 service is made available by the Runtime driver, we have to
+ wait for the Runtime Driver to be installed before the CRC32 can be computed.
+ This function is called elsewhere by the core when the runtime architectural
+ protocol is produced.
+
+Arguments:
+ None
+
+Returns:
+ NA
+
+--*/
+{
+ ASSERT(mDebugTable != NULL);
+ mDebugTable->Crc32 = 0;
+ gBS->CalculateCrc32 ((VOID *)mDebugTable, sizeof (EFI_SYSTEM_TABLE_POINTER), &mDebugTable->Crc32);
+}
+
+VOID
+CoreNewDebugImageInfoEntry (
+ IN UINT32 ImageInfoType,
+ IN EFI_LOADED_IMAGE_PROTOCOL *LoadedImage,
+ IN EFI_HANDLE ImageHandle
+ )
+/*++
+
+Routine Description:
+
+ Adds a new DebugImageInfo structure to the DebugImageInfo Table. Re-Allocates
+ the table if it's not large enough to accomidate another entry.
+
+Arguments:
+
+ ImageInfoType - type of debug image information
+ LoadedImage - pointer to the loaded image protocol for the image being loaded
+ ImageHandle - image handle for the image being loaded
+
+Returns:
+ NA
+
+--*/
+{
+ EFI_DEBUG_IMAGE_INFO *Table;
+ EFI_DEBUG_IMAGE_INFO *NewTable;
+ UINTN Index;
+ UINTN MaxTableIndex;
+ UINTN TableSize;
+
+ //
+ // Set the flag indicating that we're in the process of updating the table.
+ //
+ mDebugInfoTableHeader.UpdateStatus |= EFI_DEBUG_IMAGE_INFO_UPDATE_IN_PROGRESS;
+
+ Table = mDebugInfoTableHeader.EfiDebugImageInfoTable;
+ MaxTableIndex = mDebugInfoTableHeader.TableSize;
+
+ for (Index = 0; Index < MaxTableIndex; Index++) {
+ if (Table[Index].NormalImage == NULL) {
+ //
+ // We have found a free entry so exit the loop
+ //
+ break;
+ }
+ }
+ if (Index == MaxTableIndex) {
+ //
+ // Table is full, so re-allocate another page for a larger table...
+ //
+ TableSize = MaxTableIndex * EFI_DEBUG_TABLE_ENTRY_SIZE;
+ NewTable = CoreAllocateZeroBootServicesPool (TableSize + EFI_PAGE_SIZE);
+ if (NewTable == NULL) {
+ mDebugInfoTableHeader.UpdateStatus &= ~EFI_DEBUG_IMAGE_INFO_UPDATE_IN_PROGRESS;
+ return;
+ }
+ //
+ // Copy the old table into the new one
+ //
+ EfiCommonLibCopyMem (NewTable, Table, TableSize);
+ //
+ // Free the old table
+ //
+ CoreFreePool (Table);
+ //
+ // Update the table header
+ //
+ Table = NewTable;
+ mDebugInfoTableHeader.EfiDebugImageInfoTable = NewTable;
+ mDebugInfoTableHeader.TableSize += EFI_PAGE_SIZE / EFI_DEBUG_TABLE_ENTRY_SIZE;
+ }
+ //
+ // Allocate data for new entry
+ //
+ Table[Index].NormalImage = CoreAllocateZeroBootServicesPool (sizeof (EFI_DEBUG_IMAGE_INFO_NORMAL));
+ if (Table[Index].NormalImage != NULL) {
+ //
+ // Update the entry
+ //
+ Table[Index].NormalImage->ImageInfoType = ImageInfoType;
+ Table[Index].NormalImage->LoadedImageProtocolInstance = LoadedImage;
+ Table[Index].NormalImage->ImageHandle = ImageHandle;
+ }
+ mDebugInfoTableHeader.UpdateStatus &= ~EFI_DEBUG_IMAGE_INFO_UPDATE_IN_PROGRESS;
+}
+
+
+VOID
+CoreRemoveDebugImageInfoEntry (
+ EFI_HANDLE ImageHandle
+ )
+/*++
+
+Routine Description:
+
+ Removes and frees an entry from the DebugImageInfo Table.
+
+Arguments:
+
+ ImageHandle - image handle for the image being unloaded
+
+Returns:
+
+ NA
+
+--*/
+{
+ EFI_DEBUG_IMAGE_INFO *Table;
+ UINTN Index;
+
+ mDebugInfoTableHeader.UpdateStatus |= EFI_DEBUG_IMAGE_INFO_UPDATE_IN_PROGRESS;
+
+ Table = mDebugInfoTableHeader.EfiDebugImageInfoTable;
+
+ for (Index = 0; Index < mDebugInfoTableHeader.TableSize; Index++) {
+ if (Table[Index].NormalImage != NULL && Table[Index].NormalImage->ImageHandle == ImageHandle) {
+ //
+ // Found a match. Free up the record, then NULL the pointer to indicate the slot
+ // is free.
+ //
+ CoreFreePool (Table[Index].NormalImage);
+ Table[Index].NormalImage = NULL;
+ break;
+ }
+ }
+ mDebugInfoTableHeader.UpdateStatus &= ~EFI_DEBUG_IMAGE_INFO_UPDATE_IN_PROGRESS;
+}
+
diff --git a/EDK/Foundation/Core/Dxe/Misc/DebugImageInfo.h b/EDK/Foundation/Core/Dxe/Misc/DebugImageInfo.h
new file mode 100644
index 0000000..a4e86e7
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/Misc/DebugImageInfo.h
@@ -0,0 +1,129 @@
+/*++
+
+Copyright (c) 2004 - 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ DebugImageInfo.h
+
+Abstract:
+
+ Support functions for managing debug image info table when loading and unloading
+ images.
+
+--*/
+
+#ifndef __DEBUG_IMAGE_INFO_H__
+#define __DEBUG_IMAGE_INFO_H__
+
+#include EFI_PROTOCOL_DEFINITION(LoadedImage)
+#include EFI_GUID_DEFINITION(DebugImageInfoTable)
+
+#define FOUR_MEG_PAGES 0x400
+#define FOUR_MEG_MASK ((FOUR_MEG_PAGES * EFI_PAGE_SIZE) - 1)
+
+#define EFI_DEBUG_TABLE_ENTRY_SIZE (sizeof (VOID *))
+
+VOID
+CoreInitializeDebugImageInfoTable (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Creates and initializes the DebugImageInfo Table. Also creates the configuration
+ table and registers it into the system table.
+
+Arguments:
+ None
+
+Returns:
+ NA
+
+Notes:
+ This function allocates memory, frees it, and then allocates memory at an
+ address within the initial allocation. Since this function is called early
+ in DXE core initialization (before drivers are dispatched), this should not
+ be a problem.
+
+--*/
+;
+
+VOID
+CoreUpdateDebugTableCrc32 (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Update the CRC32 in the Debug Table.
+ Since the CRC32 service is made available by the Runtime driver, we have to
+ wait for the Runtime Driver to be installed before the CRC32 can be computed.
+ This function is called elsewhere by the core when the runtime architectural
+ protocol is produced.
+
+Arguments:
+ None
+
+Returns:
+ NA
+
+--*/
+;
+
+VOID
+CoreNewDebugImageInfoEntry (
+ UINT32 ImageInfoType,
+ EFI_LOADED_IMAGE_PROTOCOL *LoadedImage,
+ EFI_HANDLE ImageHandle
+ )
+/*++
+
+Routine Description:
+
+ Adds a new DebugImageInfo structure to the DebugImageInfo Table. Re-Allocates
+ the table if it's not large enough to accomidate another entry.
+
+Arguments:
+
+ ImageInfoType - type of debug image information
+ LoadedImage - pointer to the loaded image protocol for the image being loaded
+ ImageHandle - image handle for the image being loaded
+
+Returns:
+ NA
+
+--*/
+;
+
+VOID
+CoreRemoveDebugImageInfoEntry (
+ EFI_HANDLE ImageHandle
+ )
+/*++
+
+Routine Description:
+
+ Removes and frees an entry from the DebugImageInfo Table.
+
+Arguments:
+
+ ImageHandle - image handle for the image being unloaded
+
+Returns:
+
+ NA
+
+--*/
+;
+
+#endif
diff --git a/EDK/Foundation/Core/Dxe/Misc/DebugMask.c b/EDK/Foundation/Core/Dxe/Misc/DebugMask.c
new file mode 100644
index 0000000..c2dee47
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/Misc/DebugMask.c
@@ -0,0 +1,400 @@
+/*++
+
+Copyright (c) 2004 - 2005, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ DebugMask.c
+
+Abstract:
+
+
+--*/
+
+#include "Tiano.h"
+#include "DxeCore.h"
+#include "DebugMask.h"
+#include EFI_GUID_DEFINITION (GlobalVariable)
+
+extern UINTN mErrorLevel;
+static VOID *mVariableReadyNotify;
+
+VOID
+UpdateDebugMask (
+ EFI_EVENT Event,
+ VOID *Context
+ );
+
+EFI_STATUS
+EFIAPI
+GetDebugMask (
+ IN EFI_DEBUG_MASK_PROTOCOL *This, // Calling context
+ IN OUT UINTN *CurrentDebugMask // Ptr to store current debug mask
+ )
+/*++
+
+Routine Description:
+ DebugMask protocol member function.
+ Gets the current debug mask for an image, on which this protocol has been installed.
+
+Arguments:
+
+ This - Indicates calling context
+ CurrentDebugMask - Ptr to store current debug mask
+
+Returns:
+ EFI_SUCCESS - Debug mask is retrieved successfully
+ EFI_INVALID_PARAMETER - CurrentDebugMask is NULL.
+ EFI_UNSUPPORTED - The handle on which this protocol is installed is not an image handle.
+
+--*/
+{
+ DEBUG_MASK_PRIVATE_DATA *Private;
+ //
+ // Check Parameter
+ //
+ if (CurrentDebugMask == NULL){
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // Get Private Data
+ //
+ Private = DEBUG_MASK_PRIVATE_DATA_FROM_THIS(This);
+ *CurrentDebugMask = Private->ImageDebugMask;
+ return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+EFIAPI
+SetDebugMask (
+ IN EFI_DEBUG_MASK_PROTOCOL *This, // Calling context
+ IN UINTN NewDebugMask // New Debug Mask value to set
+ )
+/*++
+
+Routine Description:
+ DebugMask protocol member function.
+ Updates the current debug mask for an image, on which this protocol has been installed.
+
+Arguments:
+
+ This - Calling context
+ NewDebugMask - New Debug Mask value to set
+
+Returns:
+ EFI_SUCCESS - Debug mask is updated with the new value successfully
+ EFI_UNSUPPORTED - The handle on which this protocol is installed is not an image handle.
+
+--*/
+{
+ DEBUG_MASK_PRIVATE_DATA *Private;
+ //
+ // Set Private Data
+ //
+ Private = DEBUG_MASK_PRIVATE_DATA_FROM_THIS(This);
+ Private->ImageDebugMask = NewDebugMask;
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+SetCoreDebugMask (
+ IN EFI_DEBUG_MASK_PROTOCOL *This, // Calling context
+ IN UINTN NewDebugMask // New Debug Mask value to set
+ )
+/*++
+
+Routine Description:
+ DebugMask protocol member function.
+ Updates the current debug mask for core.
+
+Arguments:
+
+ This - Calling context
+ NewDebugMask - New Debug Mask value to set
+
+Returns:
+ EFI_SUCCESS - Debug mask is updated with the new value successfully
+ EFI_UNSUPPORTED - The handle on which this protocol is installed is not an image handle.
+
+--*/
+{
+ mErrorLevel = NewDebugMask;
+ return SetDebugMask(This, NewDebugMask);
+}
+
+EFI_STATUS
+InstallDebugMaskProtocol(
+ IN EFI_HANDLE ImageHandle
+ )
+/*++
+
+Routine Description:
+
+ Install debug mask protocol on an image handle.
+
+Arguments:
+
+ ImageHandle - Image handle which debug mask protocol will install on
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Invalid image handle
+
+ EFI_OUT_OF_RESOURCES - No enough buffer could be allocated
+
+ EFI_SUCCESS - Debug mask protocol successfully installed
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_LOADED_IMAGE_PROTOCOL *LoadImageInterface;
+ DEBUG_MASK_PRIVATE_DATA *DebugMaskPrivate;
+
+ if (ImageHandle == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+ //
+ // Check Image Handle
+ //
+ Status = CoreHandleProtocol (
+ ImageHandle,
+ &gEfiLoadedImageProtocolGuid,
+ (VOID*)&LoadImageInterface
+ );
+
+ if (EFI_ERROR (Status)) {
+ return EFI_INVALID_PARAMETER;
+ }
+ //
+ // Create Pool for Private Data
+ //
+ DebugMaskPrivate = CoreAllocateZeroBootServicesPool (sizeof (DEBUG_MASK_PRIVATE_DATA));
+
+ if (DebugMaskPrivate == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ //
+ // Fill in private data structure
+ //
+ DebugMaskPrivate->Signature = DEBUGMASK_PRIVATE_DATA_SIGNATURE;
+ DebugMaskPrivate->ImageDebugMask = mErrorLevel;
+ DebugMaskPrivate->DebugMaskInterface.Revision = EFI_DEBUG_MASK_REVISION;
+ DebugMaskPrivate->DebugMaskInterface.GetDebugMask = GetDebugMask;
+ DebugMaskPrivate->DebugMaskInterface.SetDebugMask = SetDebugMask;
+ //
+ // Install Debug Mask Protocol in Image Handle
+ //
+ Status = CoreInstallProtocolInterface (
+ &ImageHandle,
+ &gEfiDebugMaskProtocolGuid,
+ EFI_NATIVE_INTERFACE,
+ &(DebugMaskPrivate->DebugMaskInterface)
+ );
+
+ return Status;
+}
+
+EFI_STATUS
+UninstallDebugMaskProtocol(
+ IN EFI_HANDLE ImageHandle
+ )
+/*++
+
+Routine Description:
+
+ Uninstall debug mask protocol on an image handle.
+
+Arguments:
+
+ ImageHandle - Image handle which debug mask protocol will uninstall on
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Invalid image handle
+
+ EFI_SUCCESS - Debug mask protocol successfully uninstalled
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_DEBUG_MASK_PROTOCOL *DebugMaskInterface;
+ DEBUG_MASK_PRIVATE_DATA *DebugMaskPrivate;
+
+ if (ImageHandle == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+ //
+ // Get Protocol from ImageHandle
+ //
+ Status = CoreHandleProtocol (
+ ImageHandle,
+ &gEfiDebugMaskProtocolGuid,
+ (VOID*)&DebugMaskInterface
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ DebugMaskPrivate = DEBUG_MASK_PRIVATE_DATA_FROM_THIS(DebugMaskInterface);
+ //
+ // Remove Protocol from ImageHandle
+ //
+ Status = CoreUninstallProtocolInterface (
+ ImageHandle,
+ &gEfiDebugMaskProtocolGuid,
+ (VOID*)DebugMaskInterface
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ //
+ // Free Private Data Pool
+ //
+ Status = CoreFreePool(DebugMaskPrivate);
+ return Status;
+}
+
+EFI_STATUS
+InstallCoreDebugMaskProtocol(
+ IN EFI_HANDLE ImageHandle
+ )
+/*++
+
+Routine Description:
+
+ Install debug mask protocol on core.
+
+Arguments:
+
+ ImageHandle - Core handle
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Invalid image handle
+
+ EFI_OUT_OF_RESOURCES - No enough buffer could be allocated
+
+ EFI_SUCCESS - Debug mask protocol successfully installed
+
+--*/
+{
+ EFI_DEBUG_MASK_PROTOCOL *DebugMaskInterface;
+ EFI_STATUS Status;
+ EFI_EVENT Event;
+
+ if (ImageHandle == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = InstallDebugMaskProtocol(ImageHandle);
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
+
+ //
+ // Check Image Handle
+ //
+ Status = CoreHandleProtocol (
+ ImageHandle,
+ &gEfiDebugMaskProtocolGuid,
+ (VOID*)&DebugMaskInterface
+ );
+ if (EFI_ERROR(Status) || (DebugMaskInterface == NULL)) {
+ return Status;
+ }
+ DebugMaskInterface->SetDebugMask = SetCoreDebugMask;
+
+ Status = CoreCreateEvent (
+ EFI_EVENT_NOTIFY_SIGNAL,
+ EFI_TPL_CALLBACK,
+ UpdateDebugMask,
+ mVariableReadyNotify,
+ &Event
+ );
+
+ if (!EFI_ERROR (Status)) {
+ Status = CoreRegisterProtocolNotify (
+ &gEfiVariableArchProtocolGuid,
+ Event,
+ &mVariableReadyNotify
+ );
+ }
+
+ return Status;
+}
+
+VOID
+UpdateDebugMask (
+ EFI_EVENT Event,
+ VOID *Context
+ )
+/*++
+
+Routine Description:
+
+ Event callback function to update the debug mask when the variable service is ready.
+
+Arguments:
+
+ Event - The Event
+ Context - The event's context
+
+Returns:
+
+ None
+
+--*/
+{
+ UINTN NoHandles;
+ EFI_STATUS Status;
+ UINTN DebugMask;
+ UINTN Index;
+ UINTN DataSize;
+ EFI_HANDLE *Buffer;
+ EFI_DEBUG_MASK_PROTOCOL *DebugMaskProtocol;
+
+ DataSize = sizeof(UINT32);
+ Status = gRT->GetVariable(
+ L"EFIDebug",
+ &gEfiGlobalVariableGuid,
+ NULL,
+ &DataSize,
+ &DebugMask
+ );
+ if (EFI_ERROR(Status)) {
+ return;
+ }
+
+ Status = CoreLocateHandleBuffer (
+ AllHandles,
+ &gEfiDebugMaskProtocolGuid,
+ NULL,
+ &NoHandles,
+ &Buffer
+ );
+ if (EFI_ERROR(Status)) {
+ return;
+ }
+ for (Index = 0; Index < NoHandles; Index ++) {
+ Status = CoreHandleProtocol (
+ Buffer[Index],
+ &gEfiDebugMaskProtocolGuid,
+ &DebugMaskProtocol
+ );
+ if (EFI_ERROR(Status) || (DebugMaskProtocol == NULL)) {
+ continue;
+ }
+ DebugMaskProtocol->SetDebugMask(DebugMaskProtocol, DebugMask);
+ }
+ CoreFreePool(Buffer);
+}
diff --git a/EDK/Foundation/Core/Dxe/Misc/DebugMask.h b/EDK/Foundation/Core/Dxe/Misc/DebugMask.h
new file mode 100644
index 0000000..18dbef5
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/Misc/DebugMask.h
@@ -0,0 +1,122 @@
+/*++
+
+Copyright (c) 2004 - 2005, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ DebugMask.h
+
+Abstract:
+
+
+--*/
+
+#ifndef __DEBUG_MASK_INFO_H__
+#define __DEBUG_MASK_INFO_H__
+
+#include EFI_PROTOCOL_CONSUMER (DebugMask)
+
+//
+// local type definitions
+//
+#define DEBUGMASK_PRIVATE_DATA_SIGNATURE EFI_SIGNATURE_32('D','M','S','K')
+
+//
+// Private structure used by driver
+//
+typedef struct {
+ UINT32 Signature;
+ UINTN ImageDebugMask;
+ EFI_DEBUG_MASK_PROTOCOL DebugMaskInterface;
+}DEBUG_MASK_PRIVATE_DATA;
+
+#define DEBUG_MASK_PRIVATE_DATA_FROM_THIS(a) \
+ CR(a, DEBUG_MASK_PRIVATE_DATA, DebugMaskInterface, DEBUGMASK_PRIVATE_DATA_SIGNATURE)
+
+//
+// Internal DebugMask Procotol Install/Uninstall Function
+//
+EFI_STATUS
+InstallDebugMaskProtocol (
+ IN EFI_HANDLE ImageHandle
+ )
+/*++
+
+Routine Description:
+
+ Install debug mask protocol on an image handle.
+
+Arguments:
+
+ ImageHandle - Image handle which debug mask protocol will install on
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Invalid image handle
+
+ EFI_OUT_OF_RESOURCES - No enough buffer could be allocated
+
+ EFI_SUCCESS - Debug mask protocol successfully installed
+
+--*/
+;
+
+//
+// Internal DebugMask Procotol Install/Uninstall Function
+//
+EFI_STATUS
+InstallCoreDebugMaskProtocol (
+ IN EFI_HANDLE ImageHandle
+ )
+/*++
+
+Routine Description:
+
+ Install debug mask protocol on Dxe Core.
+
+Arguments:
+
+ ImageHandle - Image handle which debug mask protocol will install on
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Invalid image handle
+
+ EFI_OUT_OF_RESOURCES - No enough buffer could be allocated
+
+ EFI_SUCCESS - Debug mask protocol successfully installed
+
+--*/
+;
+
+EFI_STATUS
+UninstallDebugMaskProtocol (
+ IN EFI_HANDLE ImageHandle
+ )
+/*++
+
+Routine Description:
+
+ Uninstall debug mask protocol on an image handle.
+
+Arguments:
+
+ ImageHandle - Image handle which debug mask protocol will uninstall on
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Invalid image handle
+
+ EFI_SUCCESS - Debug mask protocol successfully uninstalled
+
+--*/
+;
+
+#endif
diff --git a/EDK/Foundation/Core/Dxe/Misc/InstallConfigurationTable.c b/EDK/Foundation/Core/Dxe/Misc/InstallConfigurationTable.c
new file mode 100644
index 0000000..8aea9bc
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/Misc/InstallConfigurationTable.c
@@ -0,0 +1,230 @@
+/*++
+
+Copyright (c) 2004 - 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ InstallConfigurationTable.c
+
+
+Abstract:
+
+ Tiano Miscellaneous Services InstallConfigurationTable service
+
+--*/
+
+#include "Tiano.h"
+#include "DxeCore.h"
+
+#define CONFIG_TABLE_SIZE_INCREASED 0x10
+
+UINTN mSystemTableAllocateSize = 0;
+
+
+EFI_STATUS
+CoreGetConfigTable (
+ IN EFI_GUID *Guid,
+ OUT VOID **Table
+ )
+/*++
+
+Routine Description:
+
+ Find a config table by name in system table's ConfigurationTable.
+
+Arguments:
+
+ Guid - The table name to look for
+
+ Table - Pointer of the config table
+
+Returns:
+
+ EFI_NOT_FOUND - Could not find the table in system table's ConfigurationTable.
+
+ EFI_SUCCESS - Table successfully found.
+
+--*/
+{
+ UINTN Index;
+
+ for (Index = 0; Index < gST->NumberOfTableEntries; Index++) {
+ if (EfiCompareGuid (Guid, &(gST->ConfigurationTable[Index].VendorGuid))) {
+ *Table = gST->ConfigurationTable[Index].VendorTable;
+ return EFI_SUCCESS;
+ }
+ }
+
+ return EFI_NOT_FOUND;
+}
+
+
+EFI_BOOTSERVICE
+EFI_STATUS
+EFIAPI
+CoreInstallConfigurationTable (
+ IN EFI_GUID *Guid,
+ IN VOID *Table
+ )
+/*++
+
+Routine Description:
+
+ Boot Service called to add, modify, or remove a system configuration table from
+ the EFI System Table.
+
+Arguments:
+
+ Guid - Pointer to the GUID for the entry to add, update, or remove
+ Table - Pointer to the configuration table for the entry to add, update, or
+ remove, may be NULL.
+
+Returns:
+
+ EFI_SUCCESS Guid, Table pair added, updated, or removed.
+ EFI_INVALID_PARAMETER Input GUID not valid.
+ EFI_NOT_FOUND Attempted to delete non-existant entry
+ EFI_OUT_OF_RESOURCES Not enough memory available
+
+--*/
+{
+ UINTN Index;
+ EFI_CONFIGURATION_TABLE *EfiConfigurationTable;
+
+ //
+ // If Guid is NULL, then this operation cannot be performed
+ //
+ if (Guid == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ EfiConfigurationTable = gST->ConfigurationTable;
+
+ //
+ // Search all the table for an entry that matches Guid
+ //
+ for (Index = 0; Index < gST->NumberOfTableEntries; Index++) {
+ if (EfiCompareGuid (Guid, &(gST->ConfigurationTable[Index].VendorGuid))) {
+ break;
+ }
+ }
+
+ if (Index < gST->NumberOfTableEntries) {
+ //
+ // A match was found, so this is either a modify or a delete operation
+ //
+ if (Table != NULL) {
+ //
+ // If Table is not NULL, then this is a modify operation.
+ // Modify the table enty and return.
+ //
+ gST->ConfigurationTable[Index].VendorTable = Table;
+
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
+ //
+ // Signal Configuration Table change
+ //
+ CoreNotifySignalList (Guid);
+#endif
+
+ return EFI_SUCCESS;
+ }
+
+ //
+ // A match was found and Table is NULL, so this is a delete operation.
+ //
+ gST->NumberOfTableEntries--;
+
+ //
+ // Copy over deleted entry
+ //
+ EfiCommonLibCopyMem (
+ &(EfiConfigurationTable[Index]),
+ &(gST->ConfigurationTable[Index + 1]),
+ (gST->NumberOfTableEntries - Index) * sizeof (EFI_CONFIGURATION_TABLE)
+ );
+
+ } else {
+
+ //
+ // No matching GUIDs were found, so this is an add operation.
+ //
+
+ if (Table == NULL) {
+ //
+ // If Table is NULL on an add operation, then return an error.
+ //
+ return EFI_NOT_FOUND;
+ }
+
+ //
+ // Assume that Index == gST->NumberOfTableEntries
+ //
+ if ((Index * sizeof (EFI_CONFIGURATION_TABLE)) >= mSystemTableAllocateSize) {
+ //
+ // Allocate a table with one additional entry.
+ //
+ mSystemTableAllocateSize += (CONFIG_TABLE_SIZE_INCREASED * sizeof (EFI_CONFIGURATION_TABLE));
+ EfiConfigurationTable = CoreAllocateRuntimePool (mSystemTableAllocateSize);
+ if (EfiConfigurationTable == NULL) {
+ //
+ // If a new table could not be allocated, then return an error.
+ //
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ if (gST->ConfigurationTable != NULL) {
+ //
+ // Copy the old table to the new table.
+ //
+ EfiCommonLibCopyMem (
+ EfiConfigurationTable,
+ gST->ConfigurationTable,
+ Index * sizeof (EFI_CONFIGURATION_TABLE)
+ );
+
+ //
+ // Free Old Table
+ //
+ CoreFreePool (gST->ConfigurationTable);
+ }
+
+ //
+ // Update System Table
+ //
+ gST->ConfigurationTable = EfiConfigurationTable;
+ }
+
+ //
+ // Fill in the new entry
+ //
+ EfiConfigurationTable[Index].VendorGuid = *Guid;
+ EfiConfigurationTable[Index].VendorTable = Table;
+
+ //
+ // This is an add operation, so increment the number of table entries
+ //
+ gST->NumberOfTableEntries++;
+ }
+
+ //
+ // Fix up the CRC-32 in the EFI System Table
+ //
+ CalculateEfiHdrCrc (&gST->Hdr);
+
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
+ //
+ // Signal Configuration Table change
+ //
+ CoreNotifySignalList (Guid);
+#endif
+
+ return EFI_SUCCESS;
+}
diff --git a/EDK/Foundation/Core/Dxe/Misc/SetWatchdogTimer.c b/EDK/Foundation/Core/Dxe/Misc/SetWatchdogTimer.c
new file mode 100644
index 0000000..2146137
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/Misc/SetWatchdogTimer.c
@@ -0,0 +1,84 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ SetWatchdogTimer.c
+
+Abstract:
+
+ Tiano Miscellaneous Services SetWatchdogTimer service implementation
+
+--*/
+
+#include "Tiano.h"
+#include "DxeCore.h"
+
+#define WATCHDOG_TIMER_CALIBRATE_PER_SECOND 10000000
+
+EFI_BOOTSERVICE
+EFI_STATUS
+EFIAPI
+CoreSetWatchdogTimer (
+ IN UINTN Timeout,
+ IN UINT64 WatchdogCode,
+ IN UINTN DataSize,
+ IN CHAR16 *WatchdogData OPTIONAL
+ )
+/*++
+
+Routine Description:
+
+ Sets the system's watchdog timer.
+
+Arguments:
+
+ Timeout The number of seconds. Zero disables the timer.
+
+ ///////following three parameters are left for platform specific using
+
+ WatchdogCode The numberic code to log. 0x0 to 0xffff are firmware
+ DataSize Size of the optional data
+ WatchdogData Optional Null terminated unicode string followed by binary
+ data.
+
+Returns:
+
+ EFI_SUCCESS Timeout has been set
+ EFI_NOT_AVAILABLE_YET WatchdogTimer is not available yet
+ EFI_UNSUPPORTED System does not have a timer (currently not used)
+ EFI_DEVICE_ERROR Could not complete due to hardware error
+
+--*/
+{
+ EFI_STATUS Status;
+
+ //
+ // Check our architectural protocol
+ //
+ if (gWatchdogTimer == NULL) {
+ return EFI_NOT_AVAILABLE_YET;
+ }
+
+ //
+ // Attempt to set the timeout
+ //
+ Status = gWatchdogTimer->SetTimerPeriod (gWatchdogTimer, MultU64x32 (Timeout, WATCHDOG_TIMER_CALIBRATE_PER_SECOND));
+
+ //
+ // Check for errors
+ //
+ if (EFI_ERROR (Status)) {
+ return EFI_DEVICE_ERROR;
+ }
+
+ return EFI_SUCCESS;
+}
diff --git a/EDK/Foundation/Core/Dxe/Misc/Stall.c b/EDK/Foundation/Core/Dxe/Misc/Stall.c
new file mode 100644
index 0000000..a87f894
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/Misc/Stall.c
@@ -0,0 +1,79 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Stall.c
+
+Abstract:
+
+ Tiano Miscellaneous Services Stall service implementation
+
+--*/
+
+//
+// Include statements
+//
+
+#include "Tiano.h"
+#include "DxeCore.h"
+
+EFI_BOOTSERVICE
+EFI_STATUS
+EFIAPI
+CoreStall (
+ IN UINTN Microseconds
+ )
+/*++
+
+Routine Description:
+
+ Introduces a fine-grained stall.
+
+Arguments:
+
+ Microseconds The number of microseconds to stall execution
+
+Returns:
+
+ EFI_SUCCESS - Execution was stalled for at least the requested amount
+ of microseconds.
+
+ EFI_NOT_AVAILABLE_YET - gMetronome is not available yet
+
+--*/
+{
+ UINT32 Counter;
+ UINTN Remainder;
+
+ if (gMetronome == NULL) {
+ return EFI_NOT_AVAILABLE_YET;
+ }
+
+ //
+ // Calculate the number of ticks by dividing the number of microseconds by
+ // the TickPeriod.
+ // Calcullation is based on 100ns unit.
+ //
+ Counter = (UINT32) DivU64x32 ((Microseconds * 10), (UINTN) gMetronome->TickPeriod, &Remainder);
+
+ //
+ // Call WaitForTick for Counter + 1 ticks to try to guarantee Counter tick
+ // periods, thus attempting to ensure Microseconds of stall time.
+ //
+ if (Remainder != 0) {
+ Counter++;
+ }
+
+ gMetronome->WaitForTick (gMetronome, Counter);
+
+ return EFI_SUCCESS;
+}
diff --git a/EDK/Foundation/Core/Dxe/SectionExtraction/CoreSectionExtraction.c b/EDK/Foundation/Core/Dxe/SectionExtraction/CoreSectionExtraction.c
new file mode 100644
index 0000000..f4e7727
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/SectionExtraction/CoreSectionExtraction.c
@@ -0,0 +1,1387 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ CoreSectionExtraction.c
+
+Abstract:
+
+ Section Extraction Protocol implementation.
+
+ Stream database is implemented as a linked list of section streams,
+ where each stream contains a linked list of children, which may be leaves or
+ encapsulations.
+
+ Children that are encapsulations generate new stream entries
+ when they are created. Streams can also be created by calls to
+ SEP->OpenSectionStream().
+
+ The database is only created far enough to return the requested data from
+ any given stream, or to determine that the requested data is not found.
+
+ If a GUIDed encapsulation is encountered, there are three possiblilites.
+
+ 1) A support protocol is found, in which the stream is simply processed with
+ the support protocol.
+
+ 2) A support protocol is not found, but the data is available to be read
+ without processing. In this case, the database is built up through the
+ recursions to return the data, and a RPN event is set that will enable
+ the stream in question to be refreshed if and when the required section
+ extraction protocol is published.This insures the AuthenticationStatus
+ does not become stale in the cache.
+
+ 3) A support protocol is not found, and the data is not available to be read
+ without it. This results in EFI_PROTOCOL_ERROR.
+
+--*/
+
+#include "Tiano.h"
+#include "DxeCore.h"
+#include "EfiFirmwareFileSystem.h"
+
+//
+// Comsumed protocol
+//
+#include EFI_PROTOCOL_DEFINITION (TianoDecompress)
+#include EFI_PROTOCOL_DEFINITION (GuidedSectionExtraction)
+
+//
+// Produced protocol
+//
+#include EFI_PROTOCOL_DEFINITION (SectionExtraction)
+
+//
+// Local defines and typedefs
+//
+#define CORE_SECTION_CHILD_SIGNATURE EFI_SIGNATURE_32('S','X','C','S')
+#define CHILD_SECTION_NODE_FROM_LINK(Node) \
+ CR (Node, CORE_SECTION_CHILD_NODE, Link, CORE_SECTION_CHILD_SIGNATURE)
+
+typedef struct {
+ UINT32 Signature;
+ EFI_LIST_ENTRY Link;
+ UINT32 Type;
+ UINT32 Size;
+ //
+ // StreamBase + OffsetInStream == pointer to section header in stream. The
+ // stream base is always known when walking the sections within.
+ //
+ UINT32 OffsetInStream;
+ //
+ // Then EncapsulatedStreamHandle below is always 0 if the section is NOT an
+ // encapsulating section. Otherwise, it contains the stream handle
+ // of the encapsulated stream. This handle is ALWAYS produced any time an
+ // encapsulating child is encountered, irrespective of whether the
+ // encapsulated stream is processed further.
+ //
+ UINTN EncapsulatedStreamHandle;
+ EFI_GUID *EncapsulationGuid;
+} CORE_SECTION_CHILD_NODE;
+
+#define CORE_SECTION_STREAM_SIGNATURE EFI_SIGNATURE_32('S','X','S','S')
+#define STREAM_NODE_FROM_LINK(Node) \
+ CR (Node, CORE_SECTION_STREAM_NODE, Link, CORE_SECTION_STREAM_SIGNATURE)
+
+typedef struct {
+ UINT32 Signature;
+ EFI_LIST_ENTRY Link;
+ UINTN StreamHandle;
+ UINT8 *StreamBuffer;
+ UINTN StreamLength;
+ EFI_LIST Children;
+ //
+ // Authentication status is from GUIDed encapsulations.
+ //
+ UINT32 AuthenticationStatus;
+} CORE_SECTION_STREAM_NODE;
+
+#define NULL_STREAM_HANDLE 0
+
+typedef struct {
+ CORE_SECTION_CHILD_NODE *ChildNode;
+ CORE_SECTION_STREAM_NODE *ParentStream;
+ VOID *Registration;
+ EFI_EVENT Event;
+} RPN_EVENT_CONTEXT;
+
+
+
+//
+// Local prototypes
+//
+
+STATIC
+BOOLEAN
+ChildIsType (
+ IN CORE_SECTION_STREAM_NODE *Stream,
+ IN CORE_SECTION_CHILD_NODE *Child,
+ IN EFI_SECTION_TYPE SearchType,
+ IN EFI_GUID *SectionDefinitionGuid
+ );
+
+STATIC
+VOID
+EFIAPI
+NotifyGuidedExtraction (
+ IN EFI_EVENT Event,
+ IN VOID *RpnContext
+ );
+
+STATIC
+EFI_STATUS
+EFIAPI
+CreateGuidedExtractionRpnEvent (
+ IN CORE_SECTION_STREAM_NODE *ParentStream,
+ IN CORE_SECTION_CHILD_NODE *ChildNode
+ );
+
+EFI_STATUS
+EFIAPI
+OpenSectionStream (
+ IN EFI_SECTION_EXTRACTION_PROTOCOL *This,
+ IN UINTN SectionStreamLength,
+ IN VOID *SectionStream,
+ OUT UINTN *SectionStreamHandle
+ );
+
+EFI_STATUS
+EFIAPI
+GetSection (
+ IN EFI_SECTION_EXTRACTION_PROTOCOL *This,
+ IN UINTN SectionStreamHandle,
+ IN EFI_SECTION_TYPE *SectionType,
+ IN EFI_GUID *SectionDefinitionGuid,
+ IN UINTN SectionInstance,
+ IN VOID **Buffer,
+ IN OUT UINTN *BufferSize,
+ OUT UINT32 *AuthenticationStatus
+ );
+
+EFI_STATUS
+EFIAPI
+CloseSectionStream (
+ IN EFI_SECTION_EXTRACTION_PROTOCOL *This,
+ IN UINTN StreamHandleToClose
+ );
+
+STATIC
+EFI_STATUS
+FindStreamNode (
+ IN UINTN SearchHandle,
+ OUT CORE_SECTION_STREAM_NODE **FoundStream
+ );
+
+STATIC
+EFI_STATUS
+FindChildNode (
+ IN CORE_SECTION_STREAM_NODE *SourceStream,
+ IN EFI_SECTION_TYPE SearchType,
+ IN UINTN *SectionInstance,
+ IN EFI_GUID *SectionDefinitionGuid,
+ OUT CORE_SECTION_CHILD_NODE **FoundChild,
+ OUT CORE_SECTION_STREAM_NODE **FoundStream,
+ OUT UINT32 *AuthenticationStatus
+ );
+
+STATIC
+EFI_STATUS
+CreateChildNode (
+ IN CORE_SECTION_STREAM_NODE *Stream,
+ IN UINT32 ChildOffset,
+ OUT CORE_SECTION_CHILD_NODE **ChildNode
+ );
+
+STATIC
+VOID
+FreeChildNode (
+ IN CORE_SECTION_CHILD_NODE *ChildNode
+ );
+
+STATIC
+EFI_STATUS
+OpenSectionStreamEx (
+ IN UINTN SectionStreamLength,
+ IN VOID *SectionStream,
+ IN BOOLEAN AllocateBuffer,
+ IN UINT32 AuthenticationStatus,
+ OUT UINTN *SectionStreamHandle
+ );
+
+STATIC
+BOOLEAN
+IsValidSectionStream (
+ IN VOID *SectionStream,
+ IN UINTN SectionStreamLength
+ );
+
+//
+// Module globals
+//
+EFI_LIST mStreamRoot = INITIALIZE_LIST_HEAD_VARIABLE (mStreamRoot);
+
+EFI_HANDLE mSectionExtractionHandle = NULL;
+
+EFI_SECTION_EXTRACTION_PROTOCOL mSectionExtraction = {
+ OpenSectionStream,
+ GetSection,
+ CloseSectionStream
+};
+
+
+EFI_STATUS
+EFIAPI
+InitializeSectionExtraction (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+/*++
+
+Routine Description:
+ Entry point of the section extraction code. Initializes an instance of the
+ section extraction interface and installs it on a new handle.
+
+Arguments:
+ ImageHandle EFI_HANDLE: A handle for the image that is initializing this driver
+ SystemTable EFI_SYSTEM_TABLE: A pointer to the EFI system table
+
+Returns:
+ EFI_SUCCESS: Driver initialized successfully
+ EFI_OUT_OF_RESOURCES: Could not allocate needed resources
+
+--*/
+{
+ EFI_STATUS Status;
+
+ //
+ // Install SEP to a new handle
+ //
+ Status = CoreInstallProtocolInterface (
+ &mSectionExtractionHandle,
+ &gEfiSectionExtractionProtocolGuid,
+ EFI_NATIVE_INTERFACE,
+ &mSectionExtraction
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ return Status;
+}
+
+
+EFI_STATUS
+EFIAPI
+OpenSectionStream (
+ IN EFI_SECTION_EXTRACTION_PROTOCOL *This,
+ IN UINTN SectionStreamLength,
+ IN VOID *SectionStream,
+ OUT UINTN *SectionStreamHandle
+ )
+/*++
+
+Routine Description:
+ SEP member function. This function creates and returns a new section stream
+ handle to represent the new section stream.
+
+Arguments:
+ This - Indicates the calling context.
+ SectionStreamLength - Size in bytes of the section stream.
+ SectionStream - Buffer containing the new section stream.
+ SectionStreamHandle - A pointer to a caller allocated UINTN that on output
+ contains the new section stream handle.
+
+Returns:
+ EFI_SUCCESS
+ EFI_OUT_OF_RESOURCES - memory allocation failed.
+ EFI_INVALID_PARAMETER - section stream does not end concident with end of
+ last section.
+
+--*/
+{
+ //
+ // Check to see section stream looks good...
+ //
+ if (!IsValidSectionStream (SectionStream, SectionStreamLength)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ return OpenSectionStreamEx (
+ SectionStreamLength,
+ SectionStream,
+ TRUE,
+ 0,
+ SectionStreamHandle
+ );
+}
+
+
+EFI_STATUS
+EFIAPI
+GetSection (
+ IN EFI_SECTION_EXTRACTION_PROTOCOL *This,
+ IN UINTN SectionStreamHandle,
+ IN EFI_SECTION_TYPE *SectionType,
+ IN EFI_GUID *SectionDefinitionGuid,
+ IN UINTN SectionInstance,
+ IN VOID **Buffer,
+ IN OUT UINTN *BufferSize,
+ OUT UINT32 *AuthenticationStatus
+ )
+/*++
+
+Routine Description:
+ SEP member function. Retrieves requested section from section stream.
+
+Arguments:
+ This: Pointer to SEP instance.
+ SectionStreamHandle: The section stream from which to extract the requested
+ section.
+ SectionType: A pointer to the type of section to search for.
+ SectionDefinitionGuid: If the section type is EFI_SECTION_GUID_DEFINED, then
+ SectionDefinitionGuid indicates which of these types
+ of sections to search for.
+ SectionInstance: Indicates which instance of the requested section to
+ return.
+ Buffer: Double indirection to buffer. If *Buffer is non-null on
+ input, then the buffer is caller allocated. If
+ *Buffer is NULL, then the buffer is callee allocated.
+ In either case, the requried buffer size is returned
+ in *BufferSize.
+ BufferSize: On input, indicates the size of *Buffer if *Buffer is
+ non-null on input. On output, indicates the required
+ size (allocated size if callee allocated) of *Buffer.
+ AuthenticationStatus: Indicates the authentication status of the retrieved
+ section.
+
+Returns:
+ EFI_SUCCESS: Section was retrieved successfully
+ EFI_PROTOCOL_ERROR: A GUID defined section was encountered in the section
+ stream with its EFI_GUIDED_SECTION_PROCESSING_REQUIRED
+ bit set, but there was no corresponding GUIDed Section
+ Extraction Protocol in the handle database. *Buffer is
+ unmodified.
+ EFI_NOT_FOUND: An error was encountered when parsing the SectionStream.
+ This indicates the SectionStream is not correctly
+ formatted.
+ EFI_NOT_FOUND: The requested section does not exist.
+ EFI_OUT_OF_RESOURCES: The system has insufficient resources to process the
+ request.
+ EFI_INVALID_PARAMETER: The SectionStreamHandle does not exist.
+ EFI_WARN_TOO_SMALL: The size of the caller allocated input buffer is
+ insufficient to contain the requested section. The
+ input buffer is filled and contents are section contents
+ are truncated.
+
+--*/
+{
+ CORE_SECTION_STREAM_NODE *StreamNode;
+ EFI_TPL OldTpl;
+ EFI_STATUS Status;
+ CORE_SECTION_CHILD_NODE *ChildNode;
+ CORE_SECTION_STREAM_NODE *ChildStreamNode;
+ UINTN CopySize;
+ UINT32 ExtractedAuthenticationStatus;
+ UINTN Instance;
+ UINT8 *CopyBuffer;
+ UINTN SectionSize;
+
+
+ OldTpl = CoreRaiseTpl (EFI_TPL_NOTIFY);
+ Instance = SectionInstance + 1;
+
+ //
+ // Locate target stream
+ //
+ Status = FindStreamNode (SectionStreamHandle, &StreamNode);
+ if (EFI_ERROR (Status)) {
+ Status = EFI_INVALID_PARAMETER;
+ goto GetSection_Done;
+ }
+
+ //
+ // Found the stream, now locate and return the appropriate section
+ //
+ if (SectionType == NULL) {
+ //
+ // SectionType == NULL means return the WHOLE section stream...
+ //
+ CopySize = StreamNode->StreamLength;
+ CopyBuffer = StreamNode->StreamBuffer;
+ *AuthenticationStatus = StreamNode->AuthenticationStatus;
+ } else {
+ //
+ // There's a requested section type, so go find it and return it...
+ //
+ Status = FindChildNode (
+ StreamNode,
+ *SectionType,
+ &Instance,
+ SectionDefinitionGuid,
+ &ChildNode,
+ &ChildStreamNode,
+ &ExtractedAuthenticationStatus
+ );
+ if (EFI_ERROR (Status) || (ChildNode == NULL)) {
+ goto GetSection_Done;
+ }
+ CopySize = ChildNode->Size - sizeof (EFI_COMMON_SECTION_HEADER);
+ CopyBuffer = ChildStreamNode->StreamBuffer + ChildNode->OffsetInStream + sizeof (EFI_COMMON_SECTION_HEADER);
+ *AuthenticationStatus = ExtractedAuthenticationStatus;
+ }
+
+ SectionSize = CopySize;
+ if (*Buffer != NULL) {
+ //
+ // Caller allocated buffer. Fill to size and return required size...
+ //
+ if (*BufferSize < CopySize) {
+ Status = EFI_WARN_BUFFER_TOO_SMALL;
+ CopySize = *BufferSize;
+ }
+ } else {
+ //
+ // Callee allocated buffer. Allocate buffer and return size.
+ //
+ *Buffer = CoreAllocateBootServicesPool (CopySize);
+ if (*Buffer == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto GetSection_Done;
+ }
+ }
+ EfiCommonLibCopyMem (*Buffer, CopyBuffer, CopySize);
+ *BufferSize = SectionSize;
+
+GetSection_Done:
+ CoreRestoreTpl (OldTpl);
+ return Status;
+}
+
+
+
+EFI_STATUS
+EFIAPI
+CloseSectionStream (
+ IN EFI_SECTION_EXTRACTION_PROTOCOL *This,
+ IN UINTN StreamHandleToClose
+ )
+/*++
+
+Routine Description:
+ SEP member function. Deletes an existing section stream
+
+Arguments:
+ This - Indicates the calling context.
+ StreamHandleToClose - Indicates the stream to close
+
+Returns:
+ EFI_SUCCESS
+ EFI_OUT_OF_RESOURCES - memory allocation failed.
+ EFI_INVALID_PARAMETER - section stream does not end concident with end of
+ last section.
+
+--*/
+{
+ CORE_SECTION_STREAM_NODE *StreamNode;
+ EFI_TPL OldTpl;
+ EFI_STATUS Status;
+ EFI_LIST *Link;
+ CORE_SECTION_CHILD_NODE *ChildNode;
+
+ OldTpl = CoreRaiseTpl (EFI_TPL_NOTIFY);
+
+ //
+ // Locate target stream
+ //
+ Status = FindStreamNode (StreamHandleToClose, &StreamNode);
+ if (!EFI_ERROR (Status)) {
+ //
+ // Found the stream, so close it
+ //
+ RemoveEntryList (&StreamNode->Link);
+ while (!IsListEmpty (&StreamNode->Children)) {
+ Link = GetFirstNode (&StreamNode->Children);
+ ChildNode = CHILD_SECTION_NODE_FROM_LINK (Link);
+ FreeChildNode (ChildNode);
+ }
+ CoreFreePool (StreamNode->StreamBuffer);
+ CoreFreePool (StreamNode);
+ Status = EFI_SUCCESS;
+ } else {
+ Status = EFI_INVALID_PARAMETER;
+ }
+
+ CoreRestoreTpl (OldTpl);
+ return Status;
+}
+
+
+STATIC
+BOOLEAN
+ChildIsType (
+ IN CORE_SECTION_STREAM_NODE *Stream,
+ IN CORE_SECTION_CHILD_NODE *Child,
+ IN EFI_SECTION_TYPE SearchType,
+ IN EFI_GUID *SectionDefinitionGuid
+ )
+/*++
+
+Routine Description:
+ Worker function. Determine if the input stream:child matches the input type.
+
+Arguments:
+ Stream - Indicates the section stream associated with the child
+ Child - Indicates the child to check
+ SearchType - Indicates the type of section to check against for
+ SectionDefinitionGuid - Indicates the GUID to check against if the type is
+ EFI_SECTION_GUID_DEFINED
+Returns:
+ TRUE - The child matches
+ FALSE - The child doesn't match
+
+--*/
+{
+ EFI_GUID_DEFINED_SECTION *GuidedSection;
+
+ if (SearchType == EFI_SECTION_ALL) {
+ return TRUE;
+ }
+ if (Child->Type != SearchType) {
+ return FALSE;
+ }
+
+ //
+ // ReadSection function of the FV protocol (FvReadFileSection) doesn't work for GUID defined sections
+ // (always returns EFI_NOT_FOUND). When this function is called from FvReadFileSection, SectionDefinitionGuid
+ // is always NULL. If SectionDefinitionGuid is NULL, return TRUE (the section type matches).
+ //
+ if (SearchType != EFI_SECTION_GUID_DEFINED || SectionDefinitionGuid == NULL) {
+ return TRUE;
+ }
+ GuidedSection = (EFI_GUID_DEFINED_SECTION * )(Stream->StreamBuffer + Child->OffsetInStream);
+ return EfiCompareGuid (&GuidedSection->SectionDefinitionGuid, SectionDefinitionGuid);
+}
+
+
+STATIC
+EFI_STATUS
+FindChildNode (
+ IN CORE_SECTION_STREAM_NODE *SourceStream,
+ IN EFI_SECTION_TYPE SearchType,
+ IN OUT UINTN *SectionInstance,
+ IN EFI_GUID *SectionDefinitionGuid,
+ OUT CORE_SECTION_CHILD_NODE **FoundChild,
+ OUT CORE_SECTION_STREAM_NODE **FoundStream,
+ OUT UINT32 *AuthenticationStatus
+ )
+/*++
+
+Routine Description:
+ Worker function Recursively searches / builds section stream database
+ looking for requested section.
+
+Arguments:
+ SourceStream - Indicates the section stream in which to do the search.
+ SearchType - Indicates the type of section to search for.
+ SectionInstance - Indicates which instance of section to find. This is
+ an in/out parameter to deal with recursions.
+ SectionDefinitionGuid - Guid of section definition
+ FoundChild - Output indicating the child node that is found.
+ FoundStream - Output indicating which section stream the child was
+ found in. If this stream was generated as a result of
+ an encapsulation section, the streamhandle is visible
+ within the SEP driver only.
+ AuthenticationStatus- Indicates the authentication status of the found section.
+
+Returns:
+ EFI_SUCCESS - Child node was found and returned.
+ EFI_OUT_OF_RESOURCES- Memory allocation failed.
+ EFI_NOT_FOUND - Requested child node does not exist.
+ EFI_PROTOCOL_ERROR - a required GUIDED section extraction protocol does not
+ exist
+
+--*/
+{
+ CORE_SECTION_CHILD_NODE *CurrentChildNode;
+ CORE_SECTION_CHILD_NODE *RecursedChildNode;
+ CORE_SECTION_STREAM_NODE *RecursedFoundStream;
+ UINT32 NextChildOffset;
+ EFI_STATUS ErrorStatus;
+ EFI_STATUS Status;
+
+ CurrentChildNode = NULL;
+ ErrorStatus = EFI_NOT_FOUND;
+
+ if (SourceStream->StreamLength == 0) {
+ return EFI_NOT_FOUND;
+ }
+
+ if (IsListEmpty (&SourceStream->Children) &&
+ SourceStream->StreamLength > sizeof (EFI_COMMON_SECTION_HEADER)) {
+ //
+ // This occurs when a section stream exists, but no child sections
+ // have been parsed out yet. Therefore, extract the first child and add it
+ // to the list of children so we can get started.
+ //
+ Status = CreateChildNode (SourceStream, 0, &CurrentChildNode);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ }
+
+ //
+ // At least one child has been parsed out of the section stream. So, walk
+ // through the sections that have already been parsed out looking for the
+ // requested section, if necessary, continue parsing section stream and
+ // adding children until either the requested section is found, or we run
+ // out of data
+ //
+ CurrentChildNode = CHILD_SECTION_NODE_FROM_LINK (GetFirstNode(&SourceStream->Children));
+
+ for (;;) {
+ if (ChildIsType (SourceStream, CurrentChildNode, SearchType, SectionDefinitionGuid)) {
+ //
+ // The type matches, so check the instance count to see if it's the one we want
+ //
+ (*SectionInstance)--;
+ if (*SectionInstance == 0) {
+ //
+ // Got it!
+ //
+ *FoundChild = CurrentChildNode;
+ *FoundStream = SourceStream;
+ *AuthenticationStatus = SourceStream->AuthenticationStatus;
+ return EFI_SUCCESS;
+ }
+ }
+
+ if (CurrentChildNode->EncapsulatedStreamHandle != NULL_STREAM_HANDLE) {
+ //
+ // If the current node is an encapsulating node, recurse into it...
+ //
+ Status = FindChildNode (
+ (CORE_SECTION_STREAM_NODE *)CurrentChildNode->EncapsulatedStreamHandle,
+ SearchType,
+ SectionInstance,
+ SectionDefinitionGuid,
+ &RecursedChildNode,
+ &RecursedFoundStream,
+ AuthenticationStatus
+ );
+ //
+ // If the status is not EFI_SUCCESS, just save the error code and continue
+ // to find the request child node in the rest stream.
+ //
+ if (*SectionInstance == 0) {
+ ASSERT_EFI_ERROR (Status);
+ *FoundChild = RecursedChildNode;
+ *FoundStream = RecursedFoundStream;
+ return EFI_SUCCESS;
+ } else {
+ ErrorStatus = Status;
+ }
+ }
+
+ if (!IsNodeAtEnd (&SourceStream->Children, &CurrentChildNode->Link)) {
+ //
+ // We haven't found the child node we're interested in yet, but there's
+ // still more nodes that have already been parsed so get the next one
+ // and continue searching..
+ //
+ CurrentChildNode = CHILD_SECTION_NODE_FROM_LINK (GetNextNode (&SourceStream->Children, &CurrentChildNode->Link));
+ } else {
+ //
+ // We've exhausted children that have already been parsed, so see if
+ // there's any more data and continue parsing out more children if there
+ // is.
+ //
+ NextChildOffset = CurrentChildNode->OffsetInStream + CurrentChildNode->Size;
+ //
+ // Round up to 4 byte boundary
+ //
+ NextChildOffset += 3;
+ NextChildOffset &= ~(UINTN)3;
+ if (NextChildOffset <= SourceStream->StreamLength - sizeof (EFI_COMMON_SECTION_HEADER)) {
+ //
+ // There's an unparsed child remaining in the stream, so create a new child node
+ //
+ Status = CreateChildNode (SourceStream, NextChildOffset, &CurrentChildNode);
+ if (EFI_ERROR (Status) || (CurrentChildNode == NULL)) {
+ return Status;
+ }
+ } else {
+ ASSERT (EFI_ERROR (ErrorStatus));
+ return ErrorStatus;
+ }
+ }
+ }
+}
+
+
+STATIC
+EFI_STATUS
+CreateChildNode (
+ IN CORE_SECTION_STREAM_NODE *Stream,
+ IN UINT32 ChildOffset,
+ OUT CORE_SECTION_CHILD_NODE **ChildNode
+ )
+/*++
+
+Routine Description:
+ Worker function. Constructor for new child nodes.
+
+Arguments:
+ Stream - Indicates the section stream in which to add the child.
+ ChildOffset - Indicates the offset in Stream that is the beginning
+ of the child section.
+ ChildNode - Indicates the Callee allocated and initialized child.
+
+Returns:
+ EFI_SUCCESS - Child node was found and returned.
+ EFI_OUT_OF_RESOURCES- Memory allocation failed.
+ EFI_PROTOCOL_ERROR - Encapsulation sections produce new stream handles when
+ the child node is created. If the section type is GUID
+ defined, and the extraction GUID does not exist, and
+ producing the stream requires the GUID, then a protocol
+ error is generated and no child is produced.
+ Values returned by OpenSectionStreamEx.
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_COMMON_SECTION_HEADER *SectionHeader;
+ EFI_COMPRESSION_SECTION *CompressionHeader;
+ EFI_GUID_DEFINED_SECTION *GuidedHeader;
+ EFI_TIANO_DECOMPRESS_PROTOCOL *Decompress;
+ EFI_GUIDED_SECTION_EXTRACTION_PROTOCOL *GuidedExtraction;
+ VOID *NewStreamBuffer;
+ VOID *ScratchBuffer;
+ UINT32 ScratchSize;
+ UINTN NewStreamBufferSize;
+ UINT32 AuthenticationStatus;
+ UINT32 SectionLength;
+
+ CORE_SECTION_CHILD_NODE *Node;
+
+ SectionHeader = (EFI_COMMON_SECTION_HEADER *) (Stream->StreamBuffer + ChildOffset);
+
+ //
+ // Allocate a new node
+ //
+ *ChildNode = CoreAllocateBootServicesPool (sizeof (CORE_SECTION_CHILD_NODE));
+ Node = *ChildNode;
+ if (Node == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ //
+ // Now initialize it
+ //
+ Node->Signature = CORE_SECTION_CHILD_SIGNATURE;
+ Node->Type = SectionHeader->Type;
+ Node->Size = SECTION_SIZE (SectionHeader);
+ Node->OffsetInStream = ChildOffset;
+ Node->EncapsulatedStreamHandle = NULL_STREAM_HANDLE;
+ Node->EncapsulationGuid = NULL;
+
+ //
+ // If it's an encapsulating section, then create the new section stream also
+ //
+ switch (Node->Type) {
+ case EFI_SECTION_COMPRESSION:
+ //
+ // Get the CompressionSectionHeader
+ //
+ ASSERT (Node->Size >= sizeof (EFI_COMPRESSION_SECTION));
+
+ CompressionHeader = (EFI_COMPRESSION_SECTION *) SectionHeader;
+
+ //
+ // Allocate space for the new stream
+ //
+ if (CompressionHeader->UncompressedLength > 0) {
+ NewStreamBufferSize = CompressionHeader->UncompressedLength;
+ NewStreamBuffer = CoreAllocateBootServicesPool (NewStreamBufferSize);
+ if (NewStreamBuffer == NULL) {
+ CoreFreePool (Node);
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ if (CompressionHeader->CompressionType == EFI_NOT_COMPRESSED) {
+ //
+ // stream is not actually compressed, just encapsulated. So just copy it.
+ //
+ EfiCommonLibCopyMem (NewStreamBuffer, CompressionHeader + 1, NewStreamBufferSize);
+ } else if (CompressionHeader->CompressionType == EFI_STANDARD_COMPRESSION ||
+ CompressionHeader->CompressionType == EFI_CUSTOMIZED_COMPRESSION) {
+ //
+ // Decompress the stream
+ //
+ if (CompressionHeader->CompressionType == EFI_STANDARD_COMPRESSION) {
+ Status = CoreLocateProtocol (&gEfiTianoDecompressProtocolGuid, NULL, &Decompress);
+ } else {
+ Status = CoreLocateProtocol (&gEfiCustomizedDecompressProtocolGuid, NULL, &Decompress);
+ }
+
+ ASSERT_EFI_ERROR (Status);
+ if (EFI_ERROR (Status) || (Decompress == NULL)) {
+ //
+ // Failed to locate protocol 'Decompress'
+ //
+ CoreFreePool (Node);
+ CoreFreePool (NewStreamBuffer);
+ return Status;
+ }
+
+ Status = Decompress->GetInfo (
+ Decompress,
+ CompressionHeader + 1,
+ Node->Size - sizeof (EFI_COMPRESSION_SECTION),
+ (UINT32 *)&NewStreamBufferSize,
+ &ScratchSize
+ );
+ ASSERT_EFI_ERROR (Status);
+ ASSERT (NewStreamBufferSize == CompressionHeader->UncompressedLength);
+
+ ScratchBuffer = CoreAllocateBootServicesPool (ScratchSize);
+ if (ScratchBuffer == NULL) {
+ CoreFreePool (Node);
+ CoreFreePool (NewStreamBuffer);
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ Status = Decompress->Decompress (
+ Decompress,
+ CompressionHeader + 1,
+ Node->Size - sizeof (EFI_COMPRESSION_SECTION),
+ NewStreamBuffer,
+ (UINT32)NewStreamBufferSize,
+ ScratchBuffer,
+ ScratchSize
+ );
+ ASSERT_EFI_ERROR (Status);
+ CoreFreePool (ScratchBuffer);
+ }
+ } else {
+ NewStreamBuffer = NULL;
+ NewStreamBufferSize = 0;
+ }
+
+ Status = OpenSectionStreamEx (
+ NewStreamBufferSize,
+ NewStreamBuffer,
+ FALSE,
+ Stream->AuthenticationStatus,
+ &Node->EncapsulatedStreamHandle
+ );
+ if (EFI_ERROR (Status)) {
+ CoreFreePool (Node);
+ CoreFreePool (NewStreamBuffer);
+ return Status;
+ }
+ break;
+
+ case EFI_SECTION_GUID_DEFINED:
+ GuidedHeader = (EFI_GUID_DEFINED_SECTION *) SectionHeader;
+ Node->EncapsulationGuid = &GuidedHeader->SectionDefinitionGuid;
+ Status = CoreLocateProtocol (Node->EncapsulationGuid, NULL, &GuidedExtraction);
+ if (!EFI_ERROR (Status) && (GuidedExtraction != NULL)) {
+ //
+ // NewStreamBuffer is always allocated by ExtractSection... No caller
+ // allocation here.
+ //
+ Status = GuidedExtraction->ExtractSection (
+ GuidedExtraction,
+ GuidedHeader,
+ &NewStreamBuffer,
+ &NewStreamBufferSize,
+ &AuthenticationStatus
+ );
+ if (EFI_ERROR (Status)) {
+ CoreFreePool (*ChildNode);
+ return EFI_PROTOCOL_ERROR;
+ }
+
+ //
+ // Make sure we initialize the new stream with the correct
+ // authentication status for both aggregate and local status fields.
+ //
+ if (GuidedHeader->Attributes & EFI_GUIDED_SECTION_AUTH_STATUS_VALID) {
+ //
+ // OR in the parent stream's aggregate status.
+ //
+ AuthenticationStatus |= Stream->AuthenticationStatus & EFI_AGGREGATE_AUTH_STATUS_ALL;
+ } else {
+ //
+ // since there's no authentication data contributed by the section,
+ // just inherit the full value from our immediate parent.
+ //
+ AuthenticationStatus = Stream->AuthenticationStatus;
+ }
+
+ Status = OpenSectionStreamEx (
+ NewStreamBufferSize,
+ NewStreamBuffer,
+ FALSE,
+ AuthenticationStatus,
+ &Node->EncapsulatedStreamHandle
+ );
+ if (EFI_ERROR (Status)) {
+ CoreFreePool (*ChildNode);
+ CoreFreePool (NewStreamBuffer);
+ return Status;
+ }
+ } else {
+ //
+ // There's no GUIDed section extraction protocol available.
+ //
+ if (GuidedHeader->Attributes & EFI_GUIDED_SECTION_PROCESSING_REQUIRED) {
+ //
+ // If the section REQUIRES an extraction protocol, then we're toast
+ //
+ CoreFreePool (*ChildNode);
+ return EFI_PROTOCOL_ERROR;
+ }
+
+ //
+ // Figure out the proper authentication status
+ //
+ AuthenticationStatus = Stream->AuthenticationStatus;
+ if (GuidedHeader->Attributes & EFI_GUIDED_SECTION_AUTH_STATUS_VALID) {
+ //
+ // The local status of the new stream is contained in
+ // AuthenticaionStatus. This value needs to be ORed into the
+ // Aggregate bits also...
+ //
+
+ //
+ // Clear out and initialize the local status
+ //
+ AuthenticationStatus &= ~EFI_LOCAL_AUTH_STATUS_ALL;
+ AuthenticationStatus |= EFI_LOCAL_AUTH_STATUS_IMAGE_SIGNED | EFI_LOCAL_AUTH_STATUS_NOT_TESTED;
+ //
+ // OR local status into aggregate status
+ //
+ AuthenticationStatus |= AuthenticationStatus >> 16;
+ }
+
+ SectionLength = SECTION_SIZE (GuidedHeader);
+ Status = OpenSectionStreamEx (
+ SectionLength - GuidedHeader->DataOffset,
+ (UINT8 *) GuidedHeader + GuidedHeader->DataOffset,
+ TRUE,
+ AuthenticationStatus,
+ &Node->EncapsulatedStreamHandle
+ );
+ if (EFI_ERROR (Status)) {
+ CoreFreePool (Node);
+ return Status;
+ }
+ }
+
+ if ((AuthenticationStatus & EFI_LOCAL_AUTH_STATUS_ALL) ==
+ (EFI_LOCAL_AUTH_STATUS_IMAGE_SIGNED | EFI_LOCAL_AUTH_STATUS_NOT_TESTED)) {
+ //
+ // Need to register for RPN for when the required GUIDed extraction
+ // protocol becomes available. This will enable us to refresh the
+ // AuthenticationStatus cached in the Stream if it's ever requested
+ // again.
+ //
+ Status = CreateGuidedExtractionRpnEvent (Stream, Node);
+ if (EFI_ERROR (Status)) {
+ CoreFreePool (Node);
+ return Status;
+ }
+ }
+
+ break;
+
+ default:
+
+ //
+ // Nothing to do if it's a leaf
+ //
+ break;
+ }
+
+ //
+ // Last, add the new child node to the stream
+ //
+ InsertTailList (&Stream->Children, &Node->Link);
+
+ return EFI_SUCCESS;
+}
+
+
+STATIC
+EFI_STATUS
+EFIAPI
+CreateGuidedExtractionRpnEvent (
+ IN CORE_SECTION_STREAM_NODE *ParentStream,
+ IN CORE_SECTION_CHILD_NODE *ChildNode
+ )
+/*++
+
+Routine Description:
+ Worker function. Constructor for RPN event if needed to keep AuthenticationStatus
+ cache correct when a missing GUIDED_SECTION_EXTRACTION_PROTOCOL appears...
+
+Arguments:
+ ParentStream - Indicates the parent of the ecnapsulation section (child)
+ ChildNode - Indicates the child node that is the encapsulation section.
+
+Returns:
+ EFI_SUCCESS: Event created successfully
+ EFI_OUT_OF_RESOURCES: Could not allocate needed resources
+
+--*/
+{
+ RPN_EVENT_CONTEXT *Context;
+
+ //
+ // Allocate new event structure and context
+ //
+ Context = CoreAllocateBootServicesPool (sizeof (RPN_EVENT_CONTEXT));
+ ASSERT (Context != NULL);
+ if (Context == NULL) {
+ //
+ // Failed to allocate memory for 'Context'
+ //
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ Context->ChildNode = ChildNode;
+ Context->ParentStream = ParentStream;
+
+ Context->Event = CoreCreateProtocolNotifyEvent (
+ Context->ChildNode->EncapsulationGuid,
+ EFI_TPL_NOTIFY,
+ NotifyGuidedExtraction,
+ Context,
+ &Context->Registration,
+ FALSE
+ );
+ return EFI_SUCCESS;
+}
+
+
+STATIC
+VOID
+EFIAPI
+NotifyGuidedExtraction (
+ IN EFI_EVENT Event,
+ IN VOID *RpnContext
+ )
+/*++
+
+Routine Description:
+ RPN callback function. Removes a stale section stream and re-initializes it
+ with an updated AuthenticationStatus.
+
+Arguments:
+ Event - The event that fired
+ RpnContext - A pointer to the context that allows us to identify
+ the relevent encapsulation...
+
+Returns:
+ None
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_GUID_DEFINED_SECTION *GuidedHeader;
+ EFI_GUIDED_SECTION_EXTRACTION_PROTOCOL *GuidedExtraction;
+ VOID *NewStreamBuffer;
+ UINTN NewStreamBufferSize;
+ UINT32 AuthenticationStatus;
+ RPN_EVENT_CONTEXT *Context;
+
+ Context = RpnContext;
+
+ Status = CloseSectionStream (&mSectionExtraction, Context->ChildNode->EncapsulatedStreamHandle);
+ if (!EFI_ERROR (Status)) {
+ //
+ // The stream closed successfully, so re-open the stream with correct AuthenticationStatus
+ //
+
+ GuidedHeader = (EFI_GUID_DEFINED_SECTION *)
+ (Context->ParentStream->StreamBuffer + Context->ChildNode->OffsetInStream);
+ ASSERT (GuidedHeader->CommonHeader.Type == EFI_SECTION_GUID_DEFINED);
+
+ Status = CoreLocateProtocol (Context->ChildNode->EncapsulationGuid, NULL, &GuidedExtraction);
+ ASSERT_EFI_ERROR (Status);
+ if (EFI_ERROR (Status) || (GuidedExtraction == NULL)) {
+ //
+ // Failed to locate protocol 'GuidedExtraction'
+ //
+ CoreCloseEvent (Event);
+ CoreFreePool (Context);
+ return;
+ }
+
+ Status = GuidedExtraction->ExtractSection (
+ GuidedExtraction,
+ GuidedHeader,
+ &NewStreamBuffer,
+ &NewStreamBufferSize,
+ &AuthenticationStatus
+ );
+ ASSERT_EFI_ERROR (Status);
+ //
+ // OR in the parent stream's aggregagate status.
+ //
+ AuthenticationStatus |= Context->ParentStream->AuthenticationStatus & EFI_AGGREGATE_AUTH_STATUS_ALL;
+ Status = OpenSectionStreamEx (
+ NewStreamBufferSize,
+ NewStreamBuffer,
+ FALSE,
+ AuthenticationStatus,
+ &Context->ChildNode->EncapsulatedStreamHandle
+ );
+ ASSERT_EFI_ERROR (Status);
+ }
+
+ //
+ // If above, the stream did not close successfully, it indicates it's
+ // alread been closed by someone, so just destroy the event and be done with
+ // it.
+ //
+
+ CoreCloseEvent (Event);
+ CoreFreePool (Context);
+}
+
+
+STATIC
+VOID
+FreeChildNode (
+ IN CORE_SECTION_CHILD_NODE *ChildNode
+ )
+/*++
+
+Routine Description:
+ Worker function. Destructor for child nodes.
+
+Arguments:
+ ChildNode - Indicates the node to destroy
+
+Returns:
+ none
+
+--*/
+{
+ ASSERT (ChildNode->Signature == CORE_SECTION_CHILD_SIGNATURE);
+ //
+ // Remove the child from it's list
+ //
+ RemoveEntryList (&ChildNode->Link);
+
+ if (ChildNode->EncapsulatedStreamHandle != NULL_STREAM_HANDLE) {
+ //
+ // If it's an encapsulating section, we close the resulting section stream.
+ // CloseSectionStream will free all memory associated with the stream.
+ //
+ CloseSectionStream (&mSectionExtraction, ChildNode->EncapsulatedStreamHandle);
+ }
+ //
+ // Last, free the child node itself
+ //
+ CoreFreePool (ChildNode);
+}
+
+
+STATIC
+EFI_STATUS
+OpenSectionStreamEx (
+ IN UINTN SectionStreamLength,
+ IN VOID *SectionStream,
+ IN BOOLEAN AllocateBuffer,
+ IN UINT32 AuthenticationStatus,
+ OUT UINTN *SectionStreamHandle
+ )
+/*++
+
+ Routine Description:
+ Worker function. Constructor for section streams.
+
+ Arguments:
+ SectionStreamLength - Size in bytes of the section stream.
+ SectionStream - Buffer containing the new section stream.
+ AllocateBuffer - Indicates whether the stream buffer is to be copied
+ or the input buffer is to be used in place.
+ AuthenticationStatus- Indicates the default authentication status for the
+ new stream.
+ SectionStreamHandle - A pointer to a caller allocated section stream handle.
+
+ Returns:
+ EFI_SUCCESS - Stream was added to stream database.
+ EFI_OUT_OF_RESOURCES - memory allocation failed.
+
+--*/
+{
+ CORE_SECTION_STREAM_NODE *NewStream;
+ EFI_TPL OldTpl;
+
+ //
+ // Allocate a new stream
+ //
+ NewStream = CoreAllocateBootServicesPool (sizeof (CORE_SECTION_STREAM_NODE));
+ if (NewStream == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ if (AllocateBuffer) {
+ //
+ // if we're here, we're double buffering, allocate the buffer and copy the
+ // data in
+ //
+ if (SectionStreamLength > 0) {
+ NewStream->StreamBuffer = CoreAllocateBootServicesPool (SectionStreamLength);
+ if (NewStream->StreamBuffer == NULL) {
+ CoreFreePool (NewStream);
+ return EFI_OUT_OF_RESOURCES;
+ }
+ //
+ // Copy in stream data
+ //
+ EfiCommonLibCopyMem (NewStream->StreamBuffer, SectionStream, SectionStreamLength);
+ } else {
+ //
+ // It's possible to have a zero length section stream.
+ //
+ NewStream->StreamBuffer = NULL;
+ }
+ } else {
+ //
+ // If were here, the caller has supplied the buffer (it's an internal call)
+ // so just assign the buffer. This happens when we open section streams
+ // as a result of expanding an encapsulating section.
+ //
+ NewStream->StreamBuffer = SectionStream;
+ }
+
+ //
+ // Initialize the rest of the section stream
+ //
+ NewStream->Signature = CORE_SECTION_STREAM_SIGNATURE;
+ NewStream->StreamHandle = (UINTN) NewStream;
+ NewStream->StreamLength = SectionStreamLength;
+ InitializeListHead (&NewStream->Children);
+ NewStream->AuthenticationStatus = AuthenticationStatus;
+
+ //
+ // Add new stream to stream list
+ //
+ OldTpl = CoreRaiseTpl (EFI_TPL_NOTIFY);
+ InsertTailList (&mStreamRoot, &NewStream->Link);
+ CoreRestoreTpl (OldTpl);
+
+ *SectionStreamHandle = NewStream->StreamHandle;
+
+ return EFI_SUCCESS;
+}
+
+
+STATIC
+EFI_STATUS
+FindStreamNode (
+ IN UINTN SearchHandle,
+ OUT CORE_SECTION_STREAM_NODE **FoundStream
+ )
+/*++
+
+ Routine Description:
+ Worker function. Search stream database for requested stream handle.
+
+ Arguments:
+ SearchHandle - Indicates which stream to look for.
+ FoundStream - Output pointer to the found stream.
+
+ Returns:
+ EFI_SUCCESS - StreamHandle was found and *FoundStream contains
+ the stream node.
+ EFI_NOT_FOUND - SearchHandle was not found in the stream database.
+
+--*/
+{
+ CORE_SECTION_STREAM_NODE *StreamNode;
+
+ if (!IsListEmpty (&mStreamRoot)) {
+ StreamNode = STREAM_NODE_FROM_LINK (GetFirstNode (&mStreamRoot));
+ for (;;) {
+ if (StreamNode->StreamHandle == SearchHandle) {
+ *FoundStream = StreamNode;
+ return EFI_SUCCESS;
+ } else if (IsNodeAtEnd (&mStreamRoot, &StreamNode->Link)) {
+ break;
+ } else {
+ StreamNode = STREAM_NODE_FROM_LINK (GetNextNode (&mStreamRoot, &StreamNode->Link));
+ }
+ }
+ }
+
+ return EFI_NOT_FOUND;
+}
+
+
+STATIC
+BOOLEAN
+IsValidSectionStream (
+ IN VOID *SectionStream,
+ IN UINTN SectionStreamLength
+ )
+/*++
+
+Routine Description:
+ Check if a stream is valid.
+
+Arguments:
+ SectionStream - The section stream to be checked
+ SectionStreamLength - The length of section stream
+
+Returns:
+ TRUE
+ FALSE
+
+--*/
+{
+ UINTN TotalLength;
+ UINTN SectionLength;
+ EFI_COMMON_SECTION_HEADER *SectionHeader;
+ EFI_COMMON_SECTION_HEADER *NextSectionHeader;
+
+ TotalLength = 0;
+ SectionHeader = (EFI_COMMON_SECTION_HEADER *)SectionStream;
+
+ while (TotalLength < SectionStreamLength) {
+ SectionLength = SECTION_SIZE (SectionHeader);
+ TotalLength += SectionLength;
+
+ if (TotalLength == SectionStreamLength) {
+ return TRUE;
+ }
+
+ //
+ // Move to the next byte following the section...
+ //
+ SectionHeader = (EFI_COMMON_SECTION_HEADER *) ((UINT8 *) SectionHeader + SectionLength);
+
+ //
+ // Figure out where the next section begins
+ //
+ NextSectionHeader = (EFI_COMMON_SECTION_HEADER *) ((UINTN) SectionHeader + 3);
+ NextSectionHeader = (EFI_COMMON_SECTION_HEADER *) ((UINTN) NextSectionHeader & ~(UINTN)3);
+ TotalLength += (UINTN) NextSectionHeader - (UINTN) SectionHeader;
+ SectionHeader = NextSectionHeader;
+ }
+
+ ASSERT (FALSE);
+ return FALSE;
+}
diff --git a/EDK/Foundation/Core/Dxe/x64/Processor.h b/EDK/Foundation/Core/Dxe/x64/Processor.h
new file mode 100644
index 0000000..cdf2992
--- /dev/null
+++ b/EDK/Foundation/Core/Dxe/x64/Processor.h
@@ -0,0 +1,27 @@
+/*++
+
+Copyright (c) 2005, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+ Processor.h
+
+Abstract:
+ This file contains the x64 processor specific definitions
+
+--*/
+
+#ifndef _PROCESSOR_H_
+#define _PROCESSOR_H_
+
+#define EFI_ACPI_RUNTIME_PAGE_ALLOCATION_ALIGNMENT (EFI_PAGE_SIZE)
+
+#define DEFAULT_PAGE_ALLOCATION (EFI_PAGE_SIZE)
+
+#endif
diff --git a/EDK/Foundation/Core/Pei/BootMode/BootMode.c b/EDK/Foundation/Core/Pei/BootMode/BootMode.c
new file mode 100644
index 0000000..782950a
--- /dev/null
+++ b/EDK/Foundation/Core/Pei/BootMode/BootMode.c
@@ -0,0 +1,108 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ BootMode.c
+
+Abstract:
+
+ EFI PEI Core Boot Mode services
+
+
+
+Revision History
+
+--*/
+
+#include "Tiano.h"
+#include "PeiCore.h"
+#include "PeiLib.h"
+
+EFI_STATUS
+EFIAPI
+PeiGetBootMode (
+ IN EFI_PEI_SERVICES **PeiServices,
+ OUT EFI_BOOT_MODE *BootMode
+ )
+/*++
+
+Routine Description:
+
+ This service enables PEIMs to ascertain the present value of the boot mode.
+
+Arguments:
+
+ PeiServices - The PEI core services table.
+ BootMode - A pointer to contain the value of the boot mode.
+
+Returns:
+
+ EFI_SUCCESS - The boot mode was returned successfully.
+ EFI_INVALID_PARAMETER - BootMode is NULL.
+
+--*/
+{
+ PEI_CORE_INSTANCE *PrivateData;
+ EFI_HOB_HANDOFF_INFO_TABLE *HandOffHob;
+
+
+ if (BootMode == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS(PeiServices);
+
+ HandOffHob = (PrivateData->HobList.HandoffInformationTable);
+
+ *BootMode = HandOffHob->BootMode;
+
+
+ return EFI_SUCCESS;
+};
+
+
+EFI_STATUS
+EFIAPI
+PeiSetBootMode (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_BOOT_MODE BootMode
+ )
+/*++
+
+Routine Description:
+
+ This service enables PEIMs to update the boot mode variable.
+
+Arguments:
+
+ PeiServices - The PEI core services table.
+ BootMode - The value of the boot mode to set.
+
+Returns:
+
+ EFI_SUCCESS - The value was successfully updated
+
+--*/
+{
+ PEI_CORE_INSTANCE *PrivateData;
+ EFI_HOB_HANDOFF_INFO_TABLE *HandOffHob;
+
+
+ PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS(PeiServices);
+
+ HandOffHob = (PrivateData->HobList.HandoffInformationTable);
+
+ HandOffHob->BootMode = BootMode;
+
+
+ return EFI_SUCCESS;
+};
diff --git a/EDK/Foundation/Core/Pei/DebugMask/DebugMask.c b/EDK/Foundation/Core/Pei/DebugMask/DebugMask.c
new file mode 100644
index 0000000..a804eda
--- /dev/null
+++ b/EDK/Foundation/Core/Pei/DebugMask/DebugMask.c
@@ -0,0 +1,156 @@
+/*++
+
+Copyright (c) 2009 - 2010, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ DebugMask.c
+
+Abstract:
+
+ Installs DebugMask PPI.
+
+--*/
+
+#include "Tiano.h"
+#include "PeiCore.h"
+#include EFI_PPI_CONSUMER (DebugMask)
+#include EFI_PPI_DEPENDENCY (Variable)
+#include EFI_GUID_DEFINITION (GlobalVariable)
+
+EFI_STATUS
+EFIAPI
+DebugMaskNotifyCallback (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,
+ IN VOID *Ppi
+ );
+
+static EFI_PEI_NOTIFY_DESCRIPTOR mNotifyList = {
+ EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
+ &gPeiReadOnlyVariablePpiGuid,
+ DebugMaskNotifyCallback
+};
+
+VOID
+InstallCoreDebugMaskPpi (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_CORE_INSTANCE *OldCoreData
+ )
+/*++
+
+Routine Description:
+
+ Installs DebugMask PPI.
+
+Arguments:
+
+ PeiServices - The PEI core services table.
+ OldCoreData - Pointer to the old core data.
+ NULL if being run in non-permament memory mode.
+Returns:
+
+ None
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_DEBUG_MASK_PPI *DebugMaskPpi;
+ EFI_PEI_PPI_DESCRIPTOR *DebugMaskPpiDesc;
+
+ if (OldCoreData == NULL) {
+ Status = ((*PeiServices)->AllocatePool) (PeiServices, sizeof (EFI_DEBUG_MASK_PPI), &DebugMaskPpi);
+ if (EFI_ERROR(Status) || (DebugMaskPpi == NULL)) {
+ return;
+ }
+
+ Status = ((*PeiServices)->AllocatePool) (PeiServices, sizeof (EFI_PEI_PPI_DESCRIPTOR), &DebugMaskPpiDesc);
+ if (EFI_ERROR(Status) || (DebugMaskPpiDesc == NULL)) {
+ return;
+ }
+
+ DebugMaskPpiDesc->Flags = EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST;
+ DebugMaskPpiDesc->Guid = &gEfiDebugMaskPpiGuid;
+ DebugMaskPpiDesc->Ppi = DebugMaskPpi;
+
+ DebugMaskPpi->ImageDebugMask = gErrorLevel;
+
+ Status = (**PeiServices).InstallPpi (PeiServices, DebugMaskPpiDesc);
+ ASSERT_PEI_ERROR (PeiServices, Status);
+ if (EFI_ERROR(Status)) {
+ return;
+ }
+
+ PeiNotifyPpi (PeiServices, &mNotifyList);
+ }
+ return;
+}
+
+EFI_STATUS
+EFIAPI
+DebugMaskNotifyCallback (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,
+ IN VOID *Ppi
+ )
+/*++
+
+Routine Description:
+
+ Callback function to update DebugMask value
+
+Arguments:
+
+ PeiServices - The PEI core services table.
+ NotifyDescriptor - The descriptor for the notification event.
+ Ppi - Pointer to the PPI in question.
+
+Returns:
+
+ EFI_SUCCESS - The function is successfully processed.
+
+--*/
+{
+ EFI_STATUS Status;
+ PEI_READ_ONLY_VARIABLE_PPI *VariableServices;
+ UINTN DebugMaskSize;
+ UINT64 DebugMask;
+ EFI_DEBUG_MASK_PPI *DebugMaskPpi;
+
+ //
+ // Locate Variable Ppi
+ //
+ Status = (*PeiServices)->LocatePpi (PeiServices, &gPeiReadOnlyVariablePpiGuid, 0, NULL, &VariableServices);
+
+ if (VariableServices) {
+ //
+ // Get L"EFIDebug" Variable
+ //
+ DebugMaskSize = sizeof (UINT32);
+ Status = VariableServices->PeiGetVariable (
+ PeiServices,
+ L"EFIDebug",
+ &gEfiGlobalVariableGuid,
+ NULL,
+ &DebugMaskSize,
+ &DebugMask
+ );
+
+ if (!EFI_ERROR(Status)) {
+ Status = (*PeiServices)->LocatePpi (PeiServices, &gEfiDebugMaskPpiGuid, 0, NULL, &DebugMaskPpi);
+
+ if (!EFI_ERROR(Status)) {
+ DebugMaskPpi->ImageDebugMask = (UINTN)DebugMask;
+ }
+ }
+ }
+
+ return Status;
+}
diff --git a/EDK/Foundation/Core/Pei/Dependency/dependency.c b/EDK/Foundation/Core/Pei/Dependency/dependency.c
new file mode 100644
index 0000000..ff3b2e4
--- /dev/null
+++ b/EDK/Foundation/Core/Pei/Dependency/dependency.c
@@ -0,0 +1,268 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ dependency.c
+
+Abstract:
+
+ PEI Dispatcher Dependency Evaluator
+
+ This routine evaluates a dependency expression (DEPENDENCY_EXPRESSION) to determine
+ if a driver can be scheduled for execution. The criteria for
+ schedulability is that the dependency expression is satisfied.
+
+--*/
+
+#include "Tiano.h"
+#include "PeiCore.h"
+#include "PeiLib.h"
+#include "EfiDependency.h"
+#include "Dependency.h"
+
+STATIC
+BOOLEAN
+IsPpiInstalled (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EVAL_STACK_ENTRY *Stack
+ )
+/*++
+
+Routine Description:
+
+ This routine determines if a PPI has been installed.
+ The truth value of a GUID is determined by if the PPI has
+ been published and can be queried from the PPI database.
+
+Arguments:
+ PeiServices - The PEI core services table.
+ Stack - Reference to EVAL_STACK_ENTRY that contains PPI GUID to check
+
+Returns:
+
+ True if the PPI is already installed.
+ False if the PPI has yet to be installed.
+
+--*/
+{
+ VOID *PeiInstance;
+ EFI_STATUS Status;
+ EFI_GUID PpiGuid;
+
+ //
+ // If there is no GUID to evaluate, just return current result on stack.
+ //
+ if (Stack->Operator == NULL) {
+ return Stack->Result;
+ }
+
+ //
+ // Copy the Guid into a locale variable so that there are no
+ // possibilities of alignment faults for cross-compilation
+ // environments such as Intel?Itanium(TM).
+ //
+ PeiCoreCopyMem(&PpiGuid, Stack->Operator, sizeof(EFI_GUID));
+
+ //
+ // Check if the PPI is installed.
+ //
+ Status = (**PeiServices).LocatePpi(
+ PeiServices,
+ &PpiGuid, // GUID
+ 0, // INSTANCE
+ NULL, // EFI_PEI_PPI_DESCRIPTOR
+ &PeiInstance // PPI
+ );
+
+ if (EFI_ERROR(Status)) {
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+
+EFI_STATUS
+PeimDispatchReadiness (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN VOID *DependencyExpression,
+ OUT BOOLEAN *Runnable
+ )
+/*++
+
+Routine Description:
+
+ This is the POSTFIX version of the dependency evaluator. When a
+ PUSH [PPI GUID] is encountered, a pointer to the GUID is stored on
+ the evaluation stack. When that entry is poped from the evaluation
+ stack, the PPI is checked if it is installed. This method allows
+ some time savings as not all PPIs must be checked for certain
+ operation types (AND, OR).
+
+Arguments:
+
+ PeiServices - Calling context.
+
+ DependencyExpression - Pointer to a dependency expression. The Grammar adheres to
+ the BNF described above and is stored in postfix notation.
+ Runnable - is True if the driver can be scheduled and False if the driver
+ cannot be scheduled. This is the value that the schedulers
+ should use for deciding the state of the driver.
+
+Returns:
+
+ Status = EFI_SUCCESS if it is a well-formed Grammar
+ EFI_INVALID_PARAMETER if the dependency expression overflows
+ the evaluation stack
+ EFI_INVALID_PARAMETER if the dependency expression underflows
+ the evaluation stack
+ EFI_INVALID_PARAMETER if the dependency expression is not a
+ well-formed Grammar.
+--*/
+{
+ EFI_STATUS Status;
+ DEPENDENCY_EXPRESSION_OPERAND *Iterator;
+ EVAL_STACK_ENTRY *StackPtr;
+ EVAL_STACK_ENTRY EvalStack[MAX_GRAMMAR_SIZE];
+
+ Status = EFI_SUCCESS;
+ Iterator = DependencyExpression;
+ *Runnable = FALSE;
+
+ StackPtr = &EvalStack[0];
+
+ while (TRUE) {
+
+ switch (*(Iterator++)) {
+
+ //
+ // For performance reason we put the frequently used items in front of
+ // the rarely used items
+ //
+
+ case (EFI_DEP_PUSH):
+ //
+ // Check to make sure the dependency grammar doesn't overflow the
+ // EvalStack on the push
+ //
+ if (StackPtr > &EvalStack[MAX_GRAMMAR_SIZE-1]) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // Push the pointer to the PUSH opcode operator (pointer to PPI GUID)
+ // We will evaluate if the PPI is insalled on the POP operation.
+ //
+ StackPtr->Operator = (VOID *) Iterator;
+ Iterator = Iterator + sizeof (EFI_GUID);
+ StackPtr++;
+ break;
+
+ case (EFI_DEP_AND):
+ case (EFI_DEP_OR):
+ //
+ // Check to make sure the dependency grammar doesn't underflow the
+ // EvalStack on the two POPs for the AND operation. Don't need to
+ // check for the overflow on PUSHing the result since we already
+ // did two POPs.
+ //
+ if (StackPtr < &EvalStack[2]) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // Evaluate the first POPed operator only. If the operand is
+ // EFI_DEP_AND and the POPed operator evaluates to FALSE, or the
+ // operand is EFI_DEP_OR and the POPed operator evaluates to TRUE,
+ // we don't need to check the second operator, and the result will be
+ // evaluation of the POPed operator. Otherwise, don't POP the second
+ // operator since it will now evaluate to the final result on the
+ // next operand that causes a POP.
+ //
+ StackPtr--;
+ //
+ // Iterator has increased by 1 after we retrieve the operand, so here we
+ // should get the value pointed by (Iterator - 1), in order to obtain the
+ // same operand.
+ //
+ if (*(Iterator - 1) == EFI_DEP_AND) {
+ if (!(IsPpiInstalled (PeiServices, StackPtr))) {
+ (StackPtr-1)->Result = FALSE;
+ (StackPtr-1)->Operator = NULL;
+ }
+ } else {
+ if (IsPpiInstalled (PeiServices, StackPtr)) {
+ (StackPtr-1)->Result = TRUE;
+ (StackPtr-1)->Operator = NULL;
+ }
+ }
+ break;
+
+ case (EFI_DEP_END):
+ StackPtr--;
+ //
+ // Check to make sure EvalStack is balanced. If not, then there is
+ // an error in the dependency grammar, so return EFI_INVALID_PARAMETER.
+ //
+ if (StackPtr != &EvalStack[0]) {
+ return EFI_INVALID_PARAMETER;
+ }
+ *Runnable = IsPpiInstalled (PeiServices, StackPtr);
+ return EFI_SUCCESS;
+ break;
+
+ case (EFI_DEP_NOT):
+ //
+ // Check to make sure the dependency grammar doesn't underflow the
+ // EvalStack on the POP for the NOT operation. Don't need to
+ // check for the overflow on PUSHing the result since we already
+ // did a POP.
+ //
+ if (StackPtr < &EvalStack[1]) {
+ return EFI_INVALID_PARAMETER;
+ }
+ (StackPtr-1)->Result = (BOOLEAN) !IsPpiInstalled (PeiServices, (StackPtr-1));
+ (StackPtr-1)->Operator = NULL;
+ break;
+
+ case (EFI_DEP_TRUE):
+ case (EFI_DEP_FALSE):
+ //
+ // Check to make sure the dependency grammar doesn't overflow the
+ // EvalStack on the push
+ //
+ if (StackPtr > &EvalStack[MAX_GRAMMAR_SIZE-1]) {
+ return EFI_INVALID_PARAMETER;
+ }
+ //
+ // Iterator has increased by 1 after we retrieve the operand, so here we
+ // should get the value pointed by (Iterator - 1), in order to obtain the
+ // same operand.
+ //
+ if (*(Iterator - 1) == EFI_DEP_TRUE) {
+ StackPtr->Result = TRUE;
+ } else {
+ StackPtr->Result = FALSE;
+ }
+ StackPtr->Operator = NULL;
+ StackPtr++;
+ break;
+
+ default:
+ //
+ // The grammar should never arrive here
+ //
+ return EFI_INVALID_PARAMETER;
+ break;
+ }
+ }
+}
diff --git a/EDK/Foundation/Core/Pei/Dependency/dependency.h b/EDK/Foundation/Core/Pei/Dependency/dependency.h
new file mode 100644
index 0000000..9df008b
--- /dev/null
+++ b/EDK/Foundation/Core/Pei/Dependency/dependency.h
@@ -0,0 +1,38 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ dependency.h
+
+Abstract:
+
+ This module contains data specific to dependency expressions
+ and local function prototypes.
+
+--*/
+
+#ifndef _PEI_DEPENDENCY_H_
+#define _PEI_DEPENDENCY_H_
+
+#define MAX_GRAMMAR_SIZE 256
+
+//
+// type definitions
+//
+typedef UINT8 DEPENDENCY_EXPRESSION_OPERAND;
+
+typedef struct {
+ BOOLEAN Result;
+ VOID *Operator;
+} EVAL_STACK_ENTRY;
+
+#endif
diff --git a/EDK/Foundation/Core/Pei/Dispatcher/Dispatcher.c b/EDK/Foundation/Core/Pei/Dispatcher/Dispatcher.c
new file mode 100644
index 0000000..9c9e499
--- /dev/null
+++ b/EDK/Foundation/Core/Pei/Dispatcher/Dispatcher.c
@@ -0,0 +1,593 @@
+/*++
+
+Copyright (c) 2004 - 2009, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Dispatcher.c
+
+Abstract:
+
+ EFI PEI Core dispatch services
+
+Revision History
+
+--*/
+
+#include "Tiano.h"
+#include "PeiCore.h"
+#include "PeiLib.h"
+#include EFI_GUID_DEFINITION (StatusCodeDataTypeId)
+
+EFI_STATUS
+TransferOldDataToNewDataRange (
+ IN PEI_CORE_INSTANCE *PrivateData,
+ OUT UINTN *PrivateDataInMem
+ );
+
+EFI_GUID gEfiPeiCorePrivateGuid = EFI_PEI_CORE_PRIVATE_GUID;
+
+
+EFI_STATUS
+PeiDispatcher (
+ IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor,
+ IN PEI_CORE_INSTANCE *PrivateData,
+ IN PEI_CORE_DISPATCH_DATA *DispatchData
+ )
+
+/*++
+
+Routine Description:
+
+ Conduct PEIM dispatch.
+
+Arguments:
+
+ PeiStartupDescriptor - Pointer to IN EFI_PEI_STARTUP_DESCRIPTOR
+ PrivateData - Pointer to the private data passed in from caller
+ DispatchData - Pointer to PEI_CORE_DISPATCH_DATA data.
+
+Returns:
+
+ EFI_SUCCESS - Successfully dispatched PEIM.
+ EFI_NOT_FOUND - The dispatch failed.
+
+--*/
+{
+ EFI_STATUS Status;
+ PEI_CORE_TEMP_POINTERS TempPtr;
+ UINTN PrivateDataInMem;
+ BOOLEAN NextFvFound;
+ EFI_FIRMWARE_VOLUME_HEADER *NextFvAddress;
+ EFI_FIRMWARE_VOLUME_HEADER *DefaultFvAddress;
+
+ //
+ // Debug data for uninstalled Peim list
+ //
+ PEI_DEBUG_CODE (
+
+ UINT64 DebugNotDispatchedBitmap;
+ EFI_GUID DebugFoundPeimList[64];
+ UINT8 DebugFoundPeimPoint;
+
+ )
+
+ PEI_REPORT_STATUS_CODE_CODE (
+
+ EFI_DEVICE_HANDLE_EXTENDED_DATA ExtendedData;
+
+ ExtendedData.DataHeader.HeaderSize = (UINT16)sizeof (EFI_STATUS_CODE_DATA);
+ ExtendedData.DataHeader.Size = (UINT16)(sizeof (EFI_DEVICE_HANDLE_EXTENDED_DATA) - ExtendedData.DataHeader.HeaderSize);
+
+ PeiCoreCopyMem (
+ &ExtendedData.DataHeader.Type,
+ &gEfiStatusCodeSpecificDataGuid,
+ sizeof (EFI_GUID)
+ );
+ )
+ //
+ // save the Current FV Address so that we will not process it again if FindFv returns it later
+ //
+ DefaultFvAddress = DispatchData->BootFvAddress;
+
+ //
+ // This is the main dispatch loop. It will search known FVs for PEIMs and
+ // attempt to dispatch them. If any PEIM gets dispatched through a single
+ // pass of the dispatcher, it will start over from the Bfv again to see
+ // if any new PEIMs dependencies got satisfied. With a well ordered
+ // FV where PEIMs are found in the order their dependencies are also
+ // satisfied, this dipatcher should run only once.
+ //
+ for (;;) {
+ //
+ // This is the PEIM search loop. It will scan through all PEIMs it can find
+ // looking for PEIMs to dispatch, and will dipatch them if they have not
+ // already been dispatched and all of their dependencies are met.
+ // If no more PEIMs can be found in this pass through all known FVs,
+ // then it will break out of this loop.
+ //
+ for (;;) {
+
+ Status = FindNextPeim (
+ &PrivateData->PS,
+ DispatchData->CurrentFvAddress,
+ &DispatchData->CurrentPeimAddress
+ );
+
+ //
+ // If we found a PEIM, check if it is dispatched. If so, go to the
+ // next PEIM. If not, dispatch it if its dependencies are satisfied.
+ // If its dependencies are not satisfied, go to the next PEIM.
+ //
+ if (Status == EFI_SUCCESS) {
+
+ PEI_DEBUG_CODE (
+
+ //
+ // Fill list of found Peims for later list of those not installed
+ //
+ PeiCoreCopyMem (
+ &DebugFoundPeimList[DispatchData->CurrentPeim],
+ &DispatchData->CurrentPeimAddress->Name,
+ sizeof (EFI_GUID)
+ );
+
+ )
+
+ if (!Dispatched (
+ DispatchData->CurrentPeim,
+ DispatchData->DispatchedPeimBitMap
+ )) {
+ if (DepexSatisfied (&PrivateData->PS, DispatchData->CurrentPeimAddress)) {
+ Status = PeiLoadImage (
+ &PrivateData->PS,
+ DispatchData->CurrentPeimAddress,
+ &TempPtr.Raw
+ );
+ if (Status == EFI_SUCCESS) {
+
+ //
+ // The PEIM has its dependencies satisfied, and its entry point
+ // has been found, so invoke it.
+ //
+ PEI_PERF_START (
+ &PrivateData->PS,
+ L"PEIM",
+ (EFI_FFS_FILE_HEADER *)(DispatchData->CurrentPeimAddress),
+ 0
+ );
+
+ PEI_REPORT_STATUS_CODE_CODE (
+
+ ExtendedData.Handle = (EFI_HANDLE)DispatchData->CurrentPeimAddress;
+
+ )
+
+ PEI_REPORT_STATUS_CODE_CODE (
+
+ PeiReportStatusCode (
+ &(PrivateData->PS),
+ EFI_PROGRESS_CODE,
+ EFI_SOFTWARE_PEI_CORE | EFI_SW_PC_INIT_BEGIN,
+ 0,
+ NULL,
+ (EFI_STATUS_CODE_DATA *)(&ExtendedData)
+ );
+
+ )
+
+ //
+ // Is this a authentic image
+ //
+ Status = VerifyPeim (
+ &PrivateData->PS,
+ DispatchData->CurrentPeimAddress
+ );
+
+ if (Status != EFI_SECURITY_VIOLATION) {
+
+ Status = TempPtr.PeimEntry (
+ DispatchData->CurrentPeimAddress,
+ &PrivateData->PS
+ );
+ }
+
+ PEI_REPORT_STATUS_CODE_CODE (
+
+ PeiReportStatusCode (
+ &(PrivateData->PS),
+ EFI_PROGRESS_CODE,
+ EFI_SOFTWARE_PEI_CORE | EFI_SW_PC_INIT_END,
+ 0,
+ NULL,
+ (EFI_STATUS_CODE_DATA *)(&ExtendedData)
+ );
+
+ )
+ PEI_PERF_END (&PrivateData->PS, L"PEIM", (EFI_FFS_FILE_HEADER *)(DispatchData->CurrentPeimAddress), 0);
+
+ //
+ // Mark the PEIM as dispatched so we don't attempt to run it again
+ //
+ SetDispatched (
+ &PrivateData->PS,
+ DispatchData->CurrentPeim,
+ &DispatchData->DispatchedPeimBitMap
+ );
+
+ //
+ // Process the Notify list and dispatch any notifies for
+ // newly installed PPIs.
+ //
+ ProcessNotifyList (&PrivateData->PS);
+
+ //
+ // If real system memory was discovered and installed by this
+ // PEIM, switch the stacks to the new memory. Since we are
+ // at dispatch level, only the Core's private data is preserved,
+ // nobody else should have any data on the stack.
+ //
+ if (PrivateData->SwitchStackSignal) {
+ TempPtr.PeiCore = PeiCore;
+ Status = TransferOldDataToNewDataRange (
+ PrivateData,
+ &PrivateDataInMem
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ //
+ //Subtract 0x10 from the 4th parameter indicating the new stack base,
+ //in order to provide buffer protection against possible illegal stack
+ //access that might corrupt the stack.
+ //
+ SwitchCoreStacks (
+ TempPtr.Raw,
+ (UINTN)PeiStartupDescriptor,
+ PrivateDataInMem,
+ (VOID *)((UINTN)PrivateData->StackBase + (UINTN)PrivateData->StackSize - 0x10)
+ );
+ }
+ }
+ }
+ }
+ DispatchData->CurrentPeim++;
+ continue;
+
+ } else {
+
+ //
+ // If we could not find another PEIM in the current FV, go try
+ // the FindFv PPI to look in other FVs for more PEIMs. If we can
+ // not locate the FindFv PPI, or if the FindFv PPI can not find
+ // anymore FVs, then exit the PEIM search loop.
+ //
+ if (DispatchData->FindFv == NULL) {
+ Status = PeiLocatePpi (
+ &PrivateData->PS,
+ &gEfiFindFvPpiGuid,
+ 0,
+ NULL,
+ &DispatchData->FindFv
+ );
+ if (Status != EFI_SUCCESS) {
+ break;
+ }
+ }
+ NextFvFound = FALSE;
+ while (!NextFvFound) {
+ Status = DispatchData->FindFv->FindFv (
+ DispatchData->FindFv,
+ &PrivateData->PS,
+ &DispatchData->CurrentFv,
+ &NextFvAddress
+ );
+ //
+ // if there is no next fv, get out of this loop of finding FVs
+ //
+ if (Status != EFI_SUCCESS) {
+ break;
+ }
+ //
+ // don't process the default Fv again. (we don't know the order in which the hobs were created)
+ //
+ if ((NextFvAddress != DefaultFvAddress) &&
+ (NextFvAddress != DispatchData->CurrentFvAddress)) {
+
+ //
+ // VerifyFv() is currently returns SUCCESS all the time, add code to it to
+ // actually verify the given FV
+ //
+ Status = VerifyFv (NextFvAddress);
+ if (Status == EFI_SUCCESS) {
+ NextFvFound = TRUE;
+ DispatchData->CurrentFvAddress = NextFvAddress;
+ DispatchData->CurrentPeimAddress = NULL;
+ //
+ // current PRIM number (CurrentPeim) must continue as is, don't reset it here
+ //
+ }
+ }
+ }
+ //
+ // if there is no next fv, get out of this loop of dispatching PEIMs
+ //
+ if (!NextFvFound) {
+ break;
+ }
+ //
+ // continue in the inner for(;;) loop with a new FV;
+ //
+ }
+ }
+
+ //
+ // If all the PEIMs that we have found have been dispatched, then
+ // there is nothing left to dispatch and we don't need to go search
+ // through all PEIMs again.
+ //
+ if ((~(DispatchData->DispatchedPeimBitMap) &
+ (LShiftU64 (1, DispatchData->CurrentPeim)-1)) == 0) {
+ break;
+ }
+
+ //
+ // Check if no more PEIMs that depex was satisfied
+ //
+ if (DispatchData->DispatchedPeimBitMap == DispatchData->PreviousPeimBitMap) {
+ break;
+ }
+
+ //
+ // Case when Depex is not satisfied and has to traverse the list again
+ //
+ DispatchData->CurrentPeim = 0;
+ DispatchData->CurrentPeimAddress = 0;
+ DispatchData->PreviousPeimBitMap = DispatchData->DispatchedPeimBitMap;
+
+ //
+ // don't go back to the loop without making sure that the CurrentFvAddress is the
+ // same as the 1st (or default) FV we started with. otherwise we will interpret the bimap wrongly and
+ // mess it up, always start processing the PEIMs from the default FV just like in the first time around.
+ //
+ DispatchData->CurrentFv = 0;
+ DispatchData->CurrentFvAddress = DefaultFvAddress;
+ }
+
+ PEI_DEBUG_CODE (
+
+ DebugFoundPeimPoint = 0;
+ //
+ // Get bitmap of Peims that were not dispatched,
+ //
+
+ DebugNotDispatchedBitmap = ((DispatchData->DispatchedPeimBitMap) ^ (LShiftU64 (1, DispatchData->CurrentPeim)-1));
+ //
+ // Scan bitmap of Peims not installed and print GUIDS
+ //
+ while (DebugNotDispatchedBitmap != 0) {
+ if ((DebugNotDispatchedBitmap & 1) != 0) {
+ PEI_DEBUG (
+ (&PrivateData->PS, EFI_D_INFO,
+ "WARNING -> PEIM Not Dispatched: %g\n",
+ &DebugFoundPeimList[DebugFoundPeimPoint])
+ );
+ }
+ DebugFoundPeimPoint++;
+ DebugNotDispatchedBitmap = RShiftU64 (DebugNotDispatchedBitmap, 1);
+ }
+
+ )
+
+ return EFI_NOT_FOUND;
+}
+
+VOID
+InitializeDispatcherData (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_CORE_INSTANCE *OldCoreData,
+ IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor
+ )
+/*++
+
+Routine Description:
+
+ Initialize the Dispatcher's data members
+
+Arguments:
+
+ PeiServices - The PEI core services table.
+ OldCoreData - Pointer to old core data (before switching stack).
+ NULL if being run in non-permament memory mode.
+ PeiStartupDescriptor - Information and services provided by SEC phase.
+
+Returns:
+
+ None.
+
+--*/
+{
+ PEI_CORE_INSTANCE *PrivateData;
+
+ PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS (PeiServices);
+
+ if (OldCoreData == NULL) {
+ PrivateData->DispatchData.CurrentFvAddress = (EFI_FIRMWARE_VOLUME_HEADER *) PeiStartupDescriptor->BootFirmwareVolume;
+ PrivateData->DispatchData.BootFvAddress = (EFI_FIRMWARE_VOLUME_HEADER *) PeiStartupDescriptor->BootFirmwareVolume;
+ } else {
+
+ //
+ // Current peim has been dispatched, but not count
+ //
+ PrivateData->DispatchData.CurrentPeim = (UINT8)(OldCoreData->DispatchData.CurrentPeim + 1);
+ }
+
+ return;
+}
+
+
+BOOLEAN
+Dispatched (
+ IN UINT8 CurrentPeim,
+ IN UINT64 DispatchedPeimBitMap
+ )
+/*++
+
+Routine Description:
+
+ This routine checks to see if a particular PEIM has been dispatched during
+ the PEI core dispatch.
+
+Arguments:
+ CurrentPeim - The PEIM/FV in the bit array to check.
+ DispatchedPeimBitMap - Bit array, each bit corresponds to a PEIM/FV.
+
+Returns:
+ TRUE - PEIM already dispatched
+ FALSE - Otherwise
+
+--*/
+{
+ return (BOOLEAN)((DispatchedPeimBitMap & LShiftU64 (1, CurrentPeim)) != 0);
+}
+
+VOID
+SetDispatched (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN UINT8 CurrentPeim,
+ OUT UINT64 *DispatchedPeimBitMap
+ )
+/*++
+
+Routine Description:
+
+ This routine sets a PEIM as having been dispatched once its entry
+ point has been invoked.
+
+Arguments:
+
+ PeiServices - The PEI core services table.
+ CurrentPeim - The PEIM/FV in the bit array to check.
+ DispatchedPeimBitMap - Bit array, each bit corresponds to a PEIM/FV.
+
+Returns:
+ None
+
+--*/
+{
+ //
+ // Check if the total number of PEIMs exceed the bitmap.
+ // CurrentPeim is 0-based
+ //
+PEI_DEBUG_CODE (
+ if (CurrentPeim > (sizeof (*DispatchedPeimBitMap) * 8 - 1)) {
+ ASSERT_PEI_ERROR (PeiServices, EFI_OUT_OF_RESOURCES);
+ }
+)
+ *DispatchedPeimBitMap |= LShiftU64 (1, CurrentPeim);
+ return;
+}
+
+BOOLEAN
+DepexSatisfied (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN VOID *CurrentPeimAddress
+ )
+/*++
+
+Routine Description:
+
+ This routine parses the Dependency Expression, if available, and
+ decides if the module can be executed.
+
+Arguments:
+ PeiServices - The PEI Service Table
+ CurrentPeimAddress - Address of the PEIM Firmware File under investigation
+
+Returns:
+ TRUE - Can be dispatched
+ FALSE - Cannot be dispatched
+
+--*/
+{
+ EFI_STATUS Status;
+ INT8 *DepexData;
+ BOOLEAN Runnable;
+
+ Status = PeiFfsFindSectionData (
+ PeiServices,
+ EFI_SECTION_PEI_DEPEX,
+ CurrentPeimAddress,
+ &DepexData
+ );
+ //
+ // If there is no DEPEX, assume the module can be executed
+ //
+ if (EFI_ERROR (Status) || (DepexData == NULL)) {
+ return TRUE;
+ }
+
+ //
+ // Evaluate a given DEPEX
+ //
+ Status = PeimDispatchReadiness (
+ PeiServices,
+ DepexData,
+ &Runnable
+ );
+
+ return Runnable;
+}
+
+
+EFI_STATUS
+TransferOldDataToNewDataRange (
+ IN PEI_CORE_INSTANCE *PrivateData,
+ OUT UINTN *PrivateDataInMem
+ )
+/*++
+
+Routine Description:
+
+ This routine transfers the contents of the pre-permanent memory
+ PEI Core private data to a post-permanent memory data location.
+
+Arguments:
+ PrivateData - Pointer to the current PEI Core private data pre-permanent memory
+ PrivateDataInMem - Pointer to the PrivateData once the private data has been transferred
+ to permanent memory
+
+Returns:
+ EFI_SUCCESS - Successfully transfered
+ EFI_ERROR - Fail to transfer
+
+--*/
+{
+ EFI_STATUS Status;
+
+ Status = PeiBuildHobGuid (
+ &(PrivateData->PS),
+ &gEfiPeiCorePrivateGuid,
+ sizeof (PEI_CORE_INSTANCE),
+ (VOID*)PrivateDataInMem
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ (*PrivateDataInMem) += sizeof (EFI_HOB_GUID_TYPE);
+ PrivateData->PS->CopyMem (
+ (VOID*)(*PrivateDataInMem),
+ (VOID*)PrivateData,
+ sizeof (PEI_CORE_INSTANCE)
+ );
+
+ return EFI_SUCCESS;
+}
+
diff --git a/EDK/Foundation/Core/Pei/FwVol/FwVol.c b/EDK/Foundation/Core/Pei/FwVol/FwVol.c
new file mode 100644
index 0000000..5420d90
--- /dev/null
+++ b/EDK/Foundation/Core/Pei/FwVol/FwVol.c
@@ -0,0 +1,484 @@
+/*++
+
+Copyright (c) 2004 - 2005, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ FwVol.c
+
+Abstract:
+
+ Pei Core Firmware File System service routines.
+
+--*/
+
+#include "Tiano.h"
+#include "EfiImageFormat.h"
+#include "PeiCore.h"
+#include "PeiLib.h"
+
+#define GETOCCUPIEDSIZE(ActualSize, Alignment) \
+ (ActualSize) + (((Alignment) - ((ActualSize) & ((Alignment) - 1))) & ((Alignment) - 1))
+
+STATIC
+EFI_FFS_FILE_STATE
+GetFileState(
+ IN UINT8 ErasePolarity,
+ IN EFI_FFS_FILE_HEADER *FfsHeader
+ )
+/*++
+
+Routine Description:
+
+ Returns the highest bit set of the State field
+
+Arguments:
+
+ ErasePolarity - Erase Polarity as defined by EFI_FVB_ERASE_POLARITY
+ in the Attributes field.
+ FfsHeader - Pointer to FFS File Header.
+
+Returns:
+ Returns the highest bit in the State field
+
+--*/
+{
+ EFI_FFS_FILE_STATE FileState;
+ EFI_FFS_FILE_STATE HighestBit;
+
+ FileState = FfsHeader->State;
+
+ if (ErasePolarity != 0) {
+ FileState = (EFI_FFS_FILE_STATE)~FileState;
+ }
+
+ HighestBit = 0x80;
+ while (HighestBit != 0 && (HighestBit & FileState) == 0) {
+ HighestBit >>= 1;
+ }
+
+ return HighestBit;
+}
+
+STATIC
+UINT8
+CalculateHeaderChecksum (
+ IN EFI_FFS_FILE_HEADER *FileHeader
+ )
+/*++
+
+Routine Description:
+
+ Calculates the checksum of the header of a file.
+
+Arguments:
+
+ FileHeader - Pointer to FFS File Header.
+
+Returns:
+ Checksum of the header.
+
+ The header is zero byte checksum.
+ - Zero means the header is good.
+ - Non-zero means the header is bad.
+
+
+Bugbug: For PEI performance reason, we comments this code at this time.
+--*/
+{
+ UINT8 *ptr;
+ UINTN Index;
+ UINT8 Sum;
+
+ Sum = 0;
+ ptr = (UINT8 *)FileHeader;
+
+ for (Index = 0; Index < sizeof(EFI_FFS_FILE_HEADER) - 3; Index += 4) {
+ Sum = (UINT8)(Sum + ptr[Index]);
+ Sum = (UINT8)(Sum + ptr[Index+1]);
+ Sum = (UINT8)(Sum + ptr[Index+2]);
+ Sum = (UINT8)(Sum + ptr[Index+3]);
+ }
+
+ for (; Index < sizeof(EFI_FFS_FILE_HEADER); Index++) {
+ Sum = (UINT8)(Sum + ptr[Index]);
+ }
+
+ //
+ // State field (since this indicates the different state of file).
+ //
+ Sum = (UINT8)(Sum - FileHeader->State);
+ //
+ // Checksum field of the file is not part of the header checksum.
+ //
+ Sum = (UINT8)(Sum - FileHeader->IntegrityCheck.Checksum.File);
+
+ return Sum;
+}
+
+STATIC
+EFI_STATUS
+PeiFfsFindNextFileEx (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_FV_FILETYPE SearchType,
+ IN EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader,
+ IN OUT EFI_FFS_FILE_HEADER **FileHeader,
+ IN BOOLEAN Flag
+ )
+/*++
+
+Routine Description:
+ Given the input file pointer, search for the next matching file in the
+ FFS volume as defined by SearchType. The search starts from FileHeader inside
+ the Firmware Volume defined by FwVolHeader.
+
+Arguments:
+ PeiServices - Pointer to the PEI Core Services Table.
+ SearchType - Filter to find only files of this type.
+ Type EFI_FV_FILETYPE_ALL causes no filtering to be done.
+ FwVolHeader - Pointer to the FV header of the volume to search.
+ This parameter must point to a valid FFS volume.
+ FileHeader - Pointer to the current file from which to begin searching.
+ This pointer will be updated upon return to reflect the file found.
+ Flag - Indicator for if this is for PEI Dispath search
+Returns:
+ EFI_NOT_FOUND - No files matching the search criteria were found
+ EFI_SUCCESS
+
+--*/
+{
+ EFI_FFS_FILE_HEADER *FfsFileHeader;
+ UINT32 FileLength;
+ UINT32 FileOccupiedSize;
+ UINT32 FileOffset;
+ UINT64 FvLength;
+ UINT8 ErasePolarity;
+ UINT8 FileState;
+
+
+ FvLength = FwVolHeader->FvLength;
+ if (FwVolHeader->Attributes & EFI_FVB_ERASE_POLARITY) {
+ ErasePolarity = 1;
+ } else {
+ ErasePolarity = 0;
+ }
+
+ //
+ // If FileHeader is not specified (NULL) start with the first file in the
+ // firmware volume. Otherwise, start from the FileHeader.
+ //
+ if (*FileHeader == NULL) {
+ FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FwVolHeader + FwVolHeader->HeaderLength);
+ } else {
+ //
+ // Length is 24 bits wide so mask upper 8 bits
+ // FileLength is adjusted to FileOccupiedSize as it is 8 byte aligned.
+ //
+ FileLength = *(UINT32 *)(*FileHeader)->Size & 0x00FFFFFF;
+ FileOccupiedSize = GETOCCUPIEDSIZE(FileLength, 8);
+ FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)*FileHeader + FileOccupiedSize);
+ }
+
+ FileOffset = (UINT32) ((UINT8 *)FfsFileHeader - (UINT8 *)FwVolHeader);
+ PEI_ASSERT (PeiServices, (FileOffset <= 0xFFFFFFFF));
+
+ while (FileOffset < (FvLength - sizeof(EFI_FFS_FILE_HEADER))) {
+ //
+ // Get FileState which is the highest bit of the State
+ //
+ FileState = GetFileState (ErasePolarity, FfsFileHeader);
+
+ switch (FileState) {
+
+ case EFI_FILE_HEADER_INVALID:
+ FileOffset += sizeof(EFI_FFS_FILE_HEADER);
+ FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FfsFileHeader + sizeof(EFI_FFS_FILE_HEADER));
+ break;
+
+ case EFI_FILE_DATA_VALID:
+ case EFI_FILE_MARKED_FOR_UPDATE:
+ if (CalculateHeaderChecksum (FfsFileHeader) == 0) {
+ FileLength = *(UINT32 *)(FfsFileHeader->Size) & 0x00FFFFFF;
+ FileOccupiedSize = GETOCCUPIEDSIZE(FileLength, 8);
+ if (Flag) {
+ if ((FfsFileHeader->Type == EFI_FV_FILETYPE_PEIM) ||
+ (FfsFileHeader->Type == EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER)) {
+
+ *FileHeader = FfsFileHeader;
+
+
+ return EFI_SUCCESS;
+ }
+ } else {
+ if ((SearchType == FfsFileHeader->Type) ||
+ (SearchType == EFI_FV_FILETYPE_ALL)) {
+
+ *FileHeader = FfsFileHeader;
+
+
+ return EFI_SUCCESS;
+ }
+ }
+
+ FileOffset += FileOccupiedSize;
+ FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FfsFileHeader + FileOccupiedSize);
+ } else {
+ PEI_ASSERT (PeiServices, (0));
+ return EFI_NOT_FOUND;
+ }
+ break;
+
+ case EFI_FILE_DELETED:
+ FileLength = *(UINT32 *)(FfsFileHeader->Size) & 0x00FFFFFF;
+ FileOccupiedSize = GETOCCUPIEDSIZE(FileLength, 8);
+ FileOffset += FileOccupiedSize;
+ FfsFileHeader = (EFI_FFS_FILE_HEADER *)((UINT8 *)FfsFileHeader + FileOccupiedSize);
+ break;
+
+ default:
+ return EFI_NOT_FOUND;
+
+ }
+ }
+
+ return EFI_NOT_FOUND;
+}
+
+
+EFI_STATUS
+EFIAPI
+PeiFfsFindSectionData (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_SECTION_TYPE SectionType,
+ IN EFI_FFS_FILE_HEADER *FfsFileHeader,
+ IN OUT VOID **SectionData
+ )
+/*++
+
+Routine Description:
+ Given the input file pointer, search for the next matching section in the
+ FFS volume.
+
+Arguments:
+ PeiServices - Pointer to the PEI Core Services Table.
+ SearchType - Filter to find only sections of this type.
+ FfsFileHeader - Pointer to the current file to search.
+ SectionData - Pointer to the Section matching SectionType in FfsFileHeader.
+ - NULL if section not found
+
+Returns:
+ EFI_NOT_FOUND - No files matching the search criteria were found
+ EFI_SUCCESS
+
+--*/
+{
+ UINT32 FileSize;
+ EFI_COMMON_SECTION_HEADER *Section;
+ UINT32 SectionLength;
+ UINT32 ParsedLength;
+
+
+ //
+ // Size is 24 bits wide so mask upper 8 bits.
+ // Does not include FfsFileHeader header size
+ // FileSize is adjusted to FileOccupiedSize as it is 8 byte aligned.
+ //
+ Section = (EFI_COMMON_SECTION_HEADER *)(FfsFileHeader + 1);
+ FileSize = *(UINT32 *)(FfsFileHeader->Size) & 0x00FFFFFF;
+ FileSize -= sizeof(EFI_FFS_FILE_HEADER);
+
+ *SectionData = NULL;
+ ParsedLength = 0;
+ while (ParsedLength < FileSize) {
+ if (Section->Type == SectionType) {
+ *SectionData = (VOID *)(Section + 1);
+
+
+ return EFI_SUCCESS;
+ }
+ //
+ // Size is 24 bits wide so mask upper 8 bits.
+ // SectionLength is adjusted it is 4 byte aligned.
+ // Go to the next section
+ //
+ SectionLength = *(UINT32 *)Section->Size & 0x00FFFFFF;
+ SectionLength = GETOCCUPIEDSIZE (SectionLength, 4);
+ PEI_ASSERT (PeiServices, SectionLength != 0);
+ ParsedLength += SectionLength;
+ Section = (EFI_COMMON_SECTION_HEADER *)((UINT8 *)Section + SectionLength);
+ }
+
+ return EFI_NOT_FOUND;
+
+}
+
+
+EFI_STATUS
+FindNextPeim (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader,
+ IN OUT EFI_FFS_FILE_HEADER **PeimFileHeader
+ )
+/*++
+
+Routine Description:
+ Given the input file pointer, search for the next matching file in the
+ FFS volume. The search starts from FileHeader inside
+ the Firmware Volume defined by FwVolHeader.
+
+Arguments:
+ PeiServices - Pointer to the PEI Core Services Table.
+
+ FwVolHeader - Pointer to the FV header of the volume to search.
+ This parameter must point to a valid FFS volume.
+
+ PeimFileHeader - Pointer to the current file from which to begin searching.
+ This pointer will be updated upon return to reflect the file found.
+
+Returns:
+ EFI_NOT_FOUND - No files matching the search criteria were found
+ EFI_SUCCESS
+
+--*/
+{
+ return PeiFfsFindNextFileEx (
+ PeiServices,
+ 0,
+ FwVolHeader,
+ PeimFileHeader,
+ TRUE
+ );
+}
+
+EFI_STATUS
+EFIAPI
+PeiFfsFindNextFile (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_FV_FILETYPE SearchType,
+ IN EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader,
+ IN OUT EFI_FFS_FILE_HEADER **FileHeader
+ )
+/*++
+
+Routine Description:
+ Given the input file pointer, search for the next matching file in the
+ FFS volume as defined by SearchType. The search starts from FileHeader inside
+ the Firmware Volume defined by FwVolHeader.
+
+Arguments:
+ PeiServices - Pointer to the PEI Core Services Table.
+
+ SearchType - Filter to find only files of this type.
+ Type EFI_FV_FILETYPE_ALL causes no filtering to be done.
+
+ FwVolHeader - Pointer to the FV header of the volume to search.
+ This parameter must point to a valid FFS volume.
+
+ FileHeader - Pointer to the current file from which to begin searching.
+ This pointer will be updated upon return to reflect the file found.
+
+Returns:
+ EFI_NOT_FOUND - No files matching the search criteria were found
+ EFI_SUCCESS
+
+--*/
+{
+ return PeiFfsFindNextFileEx (
+ PeiServices,
+ SearchType,
+ FwVolHeader,
+ FileHeader,
+ FALSE
+ );
+}
+
+EFI_STATUS
+EFIAPI
+PeiFvFindNextVolume (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN UINTN Instance,
+ IN OUT EFI_FIRMWARE_VOLUME_HEADER **FwVolHeader
+ )
+/*++
+
+Routine Description:
+
+ Return the Firmware Volume instance requested
+
+ BugBug -- Move this to the location of this code to where the
+ other FV and FFS support code lives.
+ Also, update to use FindFV for instances #'s >= 1.
+
+Arguments:
+
+ PeiServices - The PEI core services table.
+ Instance - Instance of FV to find
+ FwVolHeader - Pointer to contain the data to return
+
+Returns:
+ Pointer to the Firmware Volume instance requested
+
+ EFI_INVALID_PARAMETER - FwVolHeader is NULL
+
+ EFI_SUCCESS - Firmware volume instance successfully found.
+
+--*/
+{
+ PEI_CORE_INSTANCE *PrivateData;
+ EFI_STATUS Status;
+ EFI_FIND_FV_PPI *FindFvPpi;
+ UINT8 LocalInstance;
+
+
+ LocalInstance = (UINT8) Instance;
+
+ Status = EFI_SUCCESS;
+ PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS(PeiServices);
+
+ if (FwVolHeader == NULL) {
+
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (Instance == 0) {
+ //
+ // If instance is 0, the first firmware volume must be BFV.
+ //
+ *FwVolHeader = PrivateData->DispatchData.BootFvAddress;
+
+
+ return Status;
+ } else {
+ //
+ // Locate all instances of FindFV
+ // Alternately, could use FV HOBs, but the PPI is cleaner
+ //
+ Status = (**PeiServices).LocatePpi (
+ PeiServices,
+ &gEfiFindFvPpiGuid,
+ 0,
+ NULL,
+ &FindFvPpi
+ );
+
+ if (Status != EFI_SUCCESS) {
+ Status = EFI_NOT_FOUND;
+ } else {
+ Status = FindFvPpi->FindFv (
+ FindFvPpi,
+ PeiServices,
+ &LocalInstance,
+ FwVolHeader
+ );
+
+ }
+ }
+ return Status;
+}
diff --git a/EDK/Foundation/Core/Pei/Hob/Hob.c b/EDK/Foundation/Core/Pei/Hob/Hob.c
new file mode 100644
index 0000000..0d7127c
--- /dev/null
+++ b/EDK/Foundation/Core/Pei/Hob/Hob.c
@@ -0,0 +1,191 @@
+/*++
+
+Copyright (c) 2004 - 2005, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Hob.c
+
+Abstract:
+
+ EFI PEI Core HOB services
+
+--*/
+
+#include "Tiano.h"
+#include "PeiCore.h"
+#include "PeiLib.h"
+
+EFI_STATUS
+EFIAPI
+PeiGetHobList (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN OUT VOID **HobList
+ )
+/*++
+
+Routine Description:
+
+ Gets the pointer to the HOB List.
+
+Arguments:
+
+ PeiServices - The PEI core services table.
+ HobList - Pointer to the HOB List.
+
+Returns:
+
+ EFI_SUCCESS - Get the pointer of HOB List
+ EFI_NOT_AVAILABLE_YET - the HOB List is not yet published
+ EFI_INVALID_PARAMETER - HobList is NULL (in debug mode)
+
+--*/
+{
+ PEI_CORE_INSTANCE *PrivateData;
+
+
+ //
+ // Only check this parameter in debug mode
+ //
+
+ PEI_DEBUG_CODE (
+ if (HobList == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+ )
+
+ PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS(PeiServices);
+
+ *HobList = PrivateData->HobList.Raw;
+
+
+ return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+EFIAPI
+PeiCreateHob (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN UINT16 Type,
+ IN UINT16 Length,
+ IN OUT VOID **Hob
+ )
+/*++
+
+Routine Description:
+
+ Add a new HOB to the HOB List.
+
+Arguments:
+
+ PeiServices - The PEI core services table.
+ Type - Type of the new HOB.
+ Length - Length of the new HOB to allocate.
+ Hob - Pointer to the new HOB.
+
+Returns:
+
+ Status - EFI_SUCCESS
+ - EFI_INVALID_PARAMETER if Hob is NULL
+ - EFI_NOT_AVAILABLE_YET if HobList is still not available.
+ - EFI_OUT_OF_RESOURCES if there is no more memory to grow the Hoblist.
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_HOB_HANDOFF_INFO_TABLE *HandOffHob;
+ EFI_HOB_GENERIC_HEADER *HobEnd;
+ EFI_PHYSICAL_ADDRESS FreeMemory;
+
+
+ Status = PeiGetHobList (PeiServices, Hob);
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
+
+ HandOffHob = *Hob;
+
+ Length = (UINT16)((Length + 0x7) & (~0x7));
+
+ FreeMemory = HandOffHob->EfiFreeMemoryTop -
+ HandOffHob->EfiFreeMemoryBottom;
+
+ if (FreeMemory < Length) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ *Hob = (VOID*) (UINTN) HandOffHob->EfiEndOfHobList;
+ ((EFI_HOB_GENERIC_HEADER*) *Hob)->HobType = Type;
+ ((EFI_HOB_GENERIC_HEADER*) *Hob)->HobLength = Length;
+ ((EFI_HOB_GENERIC_HEADER*) *Hob)->Reserved = 0;
+
+ HobEnd = (EFI_HOB_GENERIC_HEADER*) ((UINTN) *Hob + Length);
+ HandOffHob->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS) (UINTN) HobEnd;
+
+ HobEnd->HobType = EFI_HOB_TYPE_END_OF_HOB_LIST;
+ HobEnd->HobLength = sizeof(EFI_HOB_GENERIC_HEADER);
+ HobEnd->Reserved = 0;
+ HobEnd++;
+ HandOffHob->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS) (UINTN) HobEnd;
+
+
+ return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+PeiCoreBuildHobHandoffInfoTable (
+ IN EFI_BOOT_MODE BootMode,
+ IN EFI_PHYSICAL_ADDRESS MemoryBegin,
+ IN UINT64 MemoryLength
+ )
+/*++
+
+Routine Description:
+
+ Builds a Handoff Information Table HOB
+
+Arguments:
+
+ BootMode - Current Bootmode
+ MemoryBegin - Start Memory Address.
+ MemoryLength - Length of Memory.
+
+Returns:
+
+ EFI_SUCCESS
+
+--*/
+{
+ EFI_HOB_HANDOFF_INFO_TABLE *Hob;
+ EFI_HOB_GENERIC_HEADER *HobEnd;
+
+ Hob = (VOID *)(UINTN)MemoryBegin;
+ HobEnd = (EFI_HOB_GENERIC_HEADER*) (Hob+1);
+ Hob->Header.HobType = EFI_HOB_TYPE_HANDOFF;
+ Hob->Header.HobLength = sizeof(EFI_HOB_HANDOFF_INFO_TABLE);
+ Hob->Header.Reserved = 0;
+
+ HobEnd->HobType = EFI_HOB_TYPE_END_OF_HOB_LIST;
+ HobEnd->HobLength = sizeof(EFI_HOB_GENERIC_HEADER);
+ HobEnd->Reserved = 0;
+
+ Hob->Version = EFI_HOB_HANDOFF_TABLE_VERSION;
+ Hob->BootMode = BootMode;
+
+ Hob->EfiMemoryTop = MemoryBegin + MemoryLength;
+ Hob->EfiMemoryBottom = MemoryBegin;
+ Hob->EfiFreeMemoryTop = MemoryBegin + MemoryLength;
+ Hob->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS) (UINTN) (HobEnd+1);
+ Hob->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS) (UINTN) HobEnd;
+
+ return EFI_SUCCESS;
+}
diff --git a/EDK/Foundation/Core/Pei/Ia32/SwitchCoreStacks.asm b/EDK/Foundation/Core/Pei/Ia32/SwitchCoreStacks.asm
new file mode 100644
index 0000000..655d43f
--- /dev/null
+++ b/EDK/Foundation/Core/Pei/Ia32/SwitchCoreStacks.asm
@@ -0,0 +1,87 @@
+ TITLE SwitchCoreStacks.asm: Core stack switching routine
+
+;------------------------------------------------------------------------------
+;Copyright (c) 2004, Intel Corporation
+;All rights reserved. This program and the accompanying materials
+;are licensed and made available under the terms and conditions of the BSD License
+;which accompanies this distribution. The full text of the license may be found at
+;http://opensource.org/licenses/bsd-license.php
+;
+;THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+;WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+;Module Name:
+;
+; SwitchCoreStacks.asm
+;
+;Abstract:
+;
+; Core stack switching routine, invoked when real system memory is
+; discovered and installed.
+;
+;------------------------------------------------------------------------------
+
+ .686P
+ .XMM
+ .MODEL SMALL
+ .CODE
+
+AsmWriteMm7 PROTO C
+
+AsmWriteMm7 PROC C
+;------------------------------------------------------------------------------
+; VOID
+; EFIAPI
+; AsmWriteMm7 (
+; IN UINT64 Value
+; );
+;------------------------------------------------------------------------------
+ movq mm7, [esp + 4]
+ ret
+AsmWriteMm7 ENDP
+
+SwitchCoreStacks PROTO C EntryPoint: DWORD, Parameter1: DWORD, Parameter2: DWORD, NewStack: DWORD
+
+SwitchCoreStacks PROC C EntryPoint: DWORD, Parameter1: DWORD, Parameter2: DWORD, NewStack: DWORD
+
+;------------------------------------------------------------------------------
+; VOID
+; SwitchCoreStacks (
+; IN VOID *EntryPoint,
+; IN UINTN Parameter1,
+; IN UINTN Parameter2,
+; IN VOID *NewStack
+; )
+;
+; Routine Description:
+;
+; Routine for PEI switching stacks.
+;
+; Arguments:
+;
+; EntryPoint - Entry point with new stack.
+; Parameter1 - First parameter for entry point.
+; Parameter2 - Second parameter for entry point.
+; NewStack - Pointer to new stack.
+;
+; Returns:
+;
+; None
+;
+;----------------------------------------------------
+
+ mov ebx, Parameter1
+ mov edx, Parameter2
+ mov ecx, EntryPoint
+ mov esp, NewStack
+
+ ; First push Parameter2, and then Parameter1.
+ push edx
+ push ebx
+ call ecx
+
+ ret
+
+SwitchCoreStacks ENDP
+
+END
diff --git a/EDK/Foundation/Core/Pei/Image/Image.c b/EDK/Foundation/Core/Pei/Image/Image.c
new file mode 100644
index 0000000..6b67e2d
--- /dev/null
+++ b/EDK/Foundation/Core/Pei/Image/Image.c
@@ -0,0 +1,277 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Image.c
+
+Abstract:
+
+ Pei Core Load Image Support
+
+--*/
+
+#include "Tiano.h"
+#include "PeiCore.h"
+#include "PeiLib.h"
+#include EFI_PPI_DEFINITION (LoadFile)
+
+EFI_STATUS
+PeiLoadImage (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_FFS_FILE_HEADER *PeimFileHeader,
+ OUT VOID **EntryPoint
+ )
+/*++
+
+Routine Description:
+
+ Routine for loading file image.
+
+Arguments:
+
+ PeiServices - The PEI core services table.
+ PeimFileHeader - Pointer to the FFS file header of the image.
+ EntryPoint - Pointer to entry point of specified image file for output.
+
+Returns:
+
+ Status - EFI_SUCCESS - Image is successfully loaded.
+ EFI_NOT_FOUND - Fail to locate necessary PPI
+ Others - Fail to load file.
+
+--*/
+{
+ EFI_STATUS Status;
+ VOID *Pe32Data;
+ EFI_IMAGE_NT_HEADERS *PeHdr;
+ EFI_PEI_FV_FILE_LOADER_PPI *FvLoadFilePpi;
+#ifdef EFI_NT_EMULATOR
+ EFI_PEI_PPI_DESCRIPTOR *PpiDescriptor;
+ NT_PEI_LOAD_FILE_PPI *PeiNtService;
+#endif
+ EFI_PHYSICAL_ADDRESS ImageAddress;
+ UINT64 ImageSize;
+ EFI_PHYSICAL_ADDRESS ImageEntryPoint;
+ EFI_TE_IMAGE_HEADER *TEImageHeader;
+
+ PEI_DEBUG_CODE (ImageAddress = 0;)
+
+ *EntryPoint = NULL;
+ TEImageHeader = NULL;
+ PeHdr = NULL;
+ //
+ // Try to find a PE32 section.
+ //
+ Status = PeiFfsFindSectionData (
+ PeiServices,
+ EFI_SECTION_PE32,
+ PeimFileHeader,
+ &Pe32Data
+ );
+ //
+ // If we didn't find a PE32 section, try to find a TE section.
+ //
+ if (Status != EFI_SUCCESS) {
+ Status = PeiFfsFindSectionData (
+ PeiServices,
+ EFI_SECTION_TE,
+ PeimFileHeader,
+ (VOID **) &TEImageHeader
+ );
+ Pe32Data = (VOID *) TEImageHeader;
+ }
+ if (Status == EFI_SUCCESS) {
+ if (TEImageHeader == NULL) {
+ if (((EFI_IMAGE_DOS_HEADER *) Pe32Data)->e_magic == EFI_IMAGE_DOS_SIGNATURE) {
+ //
+ // DOS image header is present, so read the PE header after the DOS image header
+ //
+ PeHdr = (EFI_IMAGE_NT_HEADERS *) ((UINTN) Pe32Data + (UINTN) ((((EFI_IMAGE_DOS_HEADER *) Pe32Data)->e_lfanew) & 0x0ffff));
+ } else {
+ //
+ // DOS image header is not present, so PE header is at the image base
+ //
+ PeHdr = (EFI_IMAGE_NT_HEADERS *) Pe32Data;
+ }
+ }
+
+#ifdef EFI_NT_EMULATOR
+ Status = (**PeiServices).LocatePpi (
+ PeiServices,
+ &gNtPeiLoadFileGuid,
+ 0,
+ &PpiDescriptor,
+ &PeiNtService
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Status = PeiNtService->PeiLoadFileService (
+ Pe32Data,
+ &ImageAddress,
+ &ImageSize,
+ (UINT64 *) EntryPoint
+ );
+
+ if (EFI_ERROR (Status)) {
+ if (TEImageHeader != NULL) {
+ *EntryPoint = (VOID *)((UINTN) TEImageHeader + sizeof (EFI_TE_IMAGE_HEADER) +
+ TEImageHeader->AddressOfEntryPoint - TEImageHeader->StrippedSize);
+ } else {
+ *EntryPoint = (VOID *) ((UINTN) Pe32Data + (UINTN) (PeHdr->OptionalHeader.AddressOfEntryPoint & 0x0ffffffff));
+ }
+ }
+
+#else
+ ImageAddress = (EFI_PHYSICAL_ADDRESS) (UINTN) Pe32Data;
+ if (TEImageHeader != NULL) {
+ *EntryPoint = (VOID *)((UINTN) TEImageHeader + sizeof (EFI_TE_IMAGE_HEADER) +
+ TEImageHeader->AddressOfEntryPoint - TEImageHeader->StrippedSize);
+ } else {
+ *EntryPoint = (VOID *) ((UINTN) Pe32Data + (UINTN) (PeHdr->OptionalHeader.AddressOfEntryPoint & 0x0ffffffff));
+ }
+#endif
+
+ } else {
+ //
+ // There was not a PE32 section, so assume that it's a Compressed section
+ // and use the LoadFile
+ //
+ Status = PeiLocatePpi (
+ PeiServices,
+ &gPeiFvFileLoaderPpiGuid,
+ 0,
+ NULL,
+ &FvLoadFilePpi
+ );
+
+ if (!EFI_ERROR (Status)) {
+ Status = FvLoadFilePpi->FvLoadFile (
+ FvLoadFilePpi,
+ PeimFileHeader,
+ &ImageAddress,
+ &ImageSize,
+ &ImageEntryPoint
+ );
+
+ if (!EFI_ERROR (Status)) {
+ *EntryPoint = (VOID *) ((UINTN) ImageEntryPoint);
+ PEI_DEBUG_CODE (
+ if (((EFI_IMAGE_DOS_HEADER *) (UINTN) ImageAddress)->e_magic == EFI_IMAGE_DOS_SIGNATURE) {
+ //
+ // DOS image header is present, so read the PE header after the DOS image header
+ //
+ PeHdr = (EFI_IMAGE_NT_HEADERS *) ((UINTN) ImageAddress + (UINTN) ((((EFI_IMAGE_DOS_HEADER *) (UINTN) ImageAddress)->e_lfanew) & 0x0ffff));
+ } else {
+ //
+ // DOS image header is not present, so PE header is at the image base
+ //
+ PeHdr = (EFI_IMAGE_NT_HEADERS *) (UINTN) ImageAddress;
+ }
+ )
+ }
+ }
+ }
+
+ PEI_DEBUG_CODE (
+ {
+ EFI_IMAGE_DATA_DIRECTORY * DirectoryEntry;
+ EFI_IMAGE_DEBUG_DIRECTORY_ENTRY * DebugEntry;
+ UINTN DirCount;
+ UINTN Index;
+ UINTN Index1;
+ BOOLEAN FileNameFound;
+ CHAR8 *AsciiString;
+ CHAR8 AsciiBuffer[512];
+ VOID *CodeViewEntryPointer;
+ INTN TEImageAdjust;
+
+ if (Status == EFI_SUCCESS) {
+ //
+ // Print debug message: Loading PEIM at 0x12345678 EntryPoint=0x12345688 Driver.efi
+ //
+ PEI_DEBUG ((PeiServices, EFI_D_INFO | EFI_D_LOAD, "Loading PEIM at 0x%08x EntryPoint=0x%08x ", (UINTN) ImageAddress, *EntryPoint));
+
+ //
+ // Find the codeview info in the image and display the file name
+ // being loaded.
+ //
+ // Per the PE/COFF spec, you can't assume that a given data directory
+ // is present in the image. You have to check the NumberOfRvaAndSizes in
+ // the optional header to verify a desired directory entry is there.
+ //
+ DebugEntry = NULL;
+ DirectoryEntry = NULL;
+ TEImageAdjust = 0;
+ if (TEImageHeader == NULL) {
+ if (PeHdr->OptionalHeader.NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_DEBUG) {
+ DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *) &(PeHdr->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]);
+ DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *) ((UINTN) ImageAddress + DirectoryEntry->VirtualAddress);
+ }
+ } else {
+ if (TEImageHeader->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress != 0) {
+ DirectoryEntry = &TEImageHeader->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG];
+ TEImageAdjust = sizeof (EFI_TE_IMAGE_HEADER) - TEImageHeader->StrippedSize;
+ DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *)((UINTN) TEImageHeader +
+ TEImageHeader->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress +
+ TEImageAdjust);
+ }
+ }
+
+ if (DebugEntry != NULL && DirectoryEntry != NULL) {
+ for (DirCount = 0; DirCount < DirectoryEntry->Size; DirCount++, DebugEntry++) {
+ if (DebugEntry->Type == EFI_IMAGE_DEBUG_TYPE_CODEVIEW) {
+ if (DebugEntry->SizeOfData > 0) {
+ CodeViewEntryPointer = (VOID *) ((UINTN) DebugEntry->RVA + (UINTN) ImageAddress + (UINTN)TEImageAdjust);
+ switch (* (UINT32 *) CodeViewEntryPointer) {
+ case CODEVIEW_SIGNATURE_NB10:
+ AsciiString = (CHAR8 *) CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY);
+ break;
+
+ case CODEVIEW_SIGNATURE_RSDS:
+ AsciiString = (CHAR8 *) CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY);
+ break;
+
+ default:
+ AsciiString = NULL;
+ break;
+ }
+ if (AsciiString != NULL) {
+ FileNameFound = FALSE;
+ for (Index = 0, Index1 = 0; AsciiString[Index] != 0; Index++) {
+ if (AsciiString[Index] == '\\') {
+ Index1 = Index;
+ FileNameFound = TRUE;
+ }
+ }
+
+ if (FileNameFound) {
+ for (Index = Index1 + 1; AsciiString[Index] != '.'; Index++) {
+ AsciiBuffer[Index - (Index1 + 1)] = AsciiString[Index];
+ }
+ AsciiBuffer[Index - (Index1 + 1)] = 0;
+ PEI_DEBUG ((PeiServices, EFI_D_INFO | EFI_D_LOAD, "%a.efi", AsciiBuffer));
+ break;
+ }
+ }
+ }
+ }
+ }
+ }
+ PEI_DEBUG ((PeiServices, EFI_D_INFO | EFI_D_LOAD, "\n"));
+ }
+ }
+ )
+
+ return Status;
+}
diff --git a/EDK/Foundation/Core/Pei/Include/PeiCore.h b/EDK/Foundation/Core/Pei/Include/PeiCore.h
new file mode 100644
index 0000000..ee8a558
--- /dev/null
+++ b/EDK/Foundation/Core/Pei/Include/PeiCore.h
@@ -0,0 +1,1275 @@
+/*++
+
+Copyright (c) 2004 - 2009, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PeiCore.h
+
+Abstract:
+
+ Definition of Pei Core Structures and Services
+
+Revision History
+
+--*/
+
+#ifndef _PEICORE_H_
+#define _PEICORE_H_
+
+#include "EfiImage.h"
+#include "Pei.h"
+#include "PeiHob.h"
+
+#ifdef EFI64
+#include "SalApi.h"
+#endif
+
+#include "EfiCommonLib.h"
+
+#include EFI_PPI_DEFINITION (FindFv)
+#include EFI_PPI_DEFINITION (DxeIpl)
+#include EFI_PPI_DEFINITION (StatusCode)
+#include EFI_PPI_DEFINITION (Security)
+
+
+#ifdef EFI_NT_EMULATOR
+#include EFI_PPI_DEFINITION (NtPeiLoadFile)
+#endif
+
+extern UINTN gErrorLevel;
+
+//
+//Build private HOB to PEI core to transfer old NEM-range data to new NEM-range
+//
+#define EFI_PEI_CORE_PRIVATE_GUID \
+ {0xd641a0f5, 0xcb7c, 0x4846, 0xa3, 0x80, 0x1d, 0x01, 0xb4, 0xd9, 0xe3, 0xb9}
+
+//
+// Pei Core private data structures
+//
+typedef union _PEI_PPI_LIST_POINTERS {
+ EFI_PEI_PPI_DESCRIPTOR *Ppi;
+ EFI_PEI_NOTIFY_DESCRIPTOR *Notify;
+ VOID *Raw;
+} PEI_PPI_LIST_POINTERS;
+
+#define PEI_STACK_SIZE 0x20000
+
+#define MAX_PPI_DESCRIPTORS 128
+
+typedef struct {
+ INTN PpiListEnd;
+ INTN NotifyListEnd;
+ INTN DispatchListEnd;
+ INTN LastDispatchedInstall;
+ INTN LastDispatchedNotify;
+ PEI_PPI_LIST_POINTERS PpiListPtrs[MAX_PPI_DESCRIPTORS];
+} PEI_PPI_DATABASE;
+
+typedef struct {
+ UINT8 CurrentPeim;
+ UINT8 CurrentFv;
+ UINT64 DispatchedPeimBitMap;
+ UINT64 PreviousPeimBitMap;
+ EFI_FFS_FILE_HEADER *CurrentPeimAddress;
+ EFI_FIRMWARE_VOLUME_HEADER *CurrentFvAddress;
+ EFI_FIRMWARE_VOLUME_HEADER *BootFvAddress;
+ EFI_FIND_FV_PPI *FindFv;
+} PEI_CORE_DISPATCH_DATA;
+
+
+//
+// Pei Core private data structure instance
+//
+
+#define PEI_CORE_HANDLE_SIGNATURE EFI_SIGNATURE_32('P','e','i','C')
+
+typedef struct{
+ UINTN Signature;
+ EFI_PEI_SERVICES *PS; // Point to ServiceTableShadow
+ PEI_PPI_DATABASE PpiData;
+ PEI_CORE_DISPATCH_DATA DispatchData;
+ EFI_PEI_HOB_POINTERS HobList;
+ BOOLEAN SwitchStackSignal;
+ BOOLEAN PeiMemoryInstalled;
+ EFI_PHYSICAL_ADDRESS StackBase;
+ UINT64 StackSize;
+ VOID *BottomOfCarHeap;
+ VOID *TopOfCarHeap;
+ VOID *CpuIo;
+ PEI_SECURITY_PPI *PrivateSecurityPpi;
+ EFI_PEI_SERVICES ServiceTableShadow;
+
+ PEI_DEBUG_CODE (
+ UINTN SizeOfCacheAsRam;
+ VOID *MaxTopOfCarHeap;
+ )
+} PEI_CORE_INSTANCE;
+
+//
+// Pei Core Instance Data Macros
+//
+
+#define PEI_CORE_INSTANCE_FROM_PS_THIS(a) \
+ PEI_CR(a, PEI_CORE_INSTANCE, PS, PEI_CORE_HANDLE_SIGNATURE)
+
+typedef
+EFI_STATUS
+(EFIAPI *PEI_MAIN_ENTRY_POINT) (
+ IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *PEI_CORE_ENTRY_POINT) (
+ IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor,
+ IN PEI_CORE_INSTANCE *OldCoreData
+ );
+
+//
+// Union of temporarily used function pointers (to save stack space)
+//
+typedef union {
+ PEI_CORE_ENTRY_POINT PeiCore;
+ EFI_PEIM_ENTRY_POINT PeimEntry;
+ EFI_PEIM_NOTIFY_ENTRY_POINT PeimNotifyEntry;
+ EFI_DXE_IPL_PPI *DxeIpl;
+ EFI_PEI_PPI_DESCRIPTOR *PpiDescriptor;
+ EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor;
+ VOID *Raw;
+} PEI_CORE_TEMP_POINTERS;
+
+
+//
+// Main PEI entry
+//
+EFI_STATUS
+EFIAPI
+PeiMain (
+ IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor
+ )
+/*++
+
+Routine Description:
+
+ Main entry point to Pei Core.
+
+Arguments:
+
+ PeiStartupDescriptor - Information and services provided by SEC phase.
+
+Returns:
+
+ This function never returns
+
+--*/
+;
+
+
+EFI_STATUS
+EFIAPI
+PeiCore (
+ IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor,
+ IN PEI_CORE_INSTANCE *OldCoreData
+ )
+/*++
+
+Routine Description:
+
+ The entry routine to Pei Core, invoked by PeiMain during transition
+ from SEC to PEI. After switching stack in the PEI core, it will restart
+ with the old core data.
+
+Arguments:
+
+ PeiStartupDescriptor - Information and services provided by SEC phase.
+ OldCoreData - Pointer to old core data that is used to initialize the
+ core's data areas.
+
+Returns:
+
+ This function never returns
+
+--*/
+;
+
+
+//
+// Dispatcher support functions
+//
+
+EFI_STATUS
+PeimDispatchReadiness (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN VOID *DependencyExpression,
+ IN OUT BOOLEAN *Runnable
+ )
+/*++
+
+Routine Description:
+
+ This is the POSTFIX version of the dependency evaluator. When a
+ PUSH [PPI GUID] is encountered, a pointer to the GUID is stored on
+ the evaluation stack. When that entry is poped from the evaluation
+ stack, the PPI is checked if it is installed. This method allows
+ some time savings as not all PPIs must be checked for certain
+ operation types (AND, OR).
+
+Arguments:
+
+ PeiServices - Calling context.
+
+ DependencyExpression - Pointer to a dependency expression. The Grammar adheres to
+ the BNF described above and is stored in postfix notation.
+ Runnable - is True if the driver can be scheduled and False if the driver
+ cannot be scheduled. This is the value that the schedulers
+ should use for deciding the state of the driver.
+
+Returns:
+
+ Status = EFI_SUCCESS if it is a well-formed Grammar
+ EFI_INVALID_PARAMETER if the dependency expression overflows
+ the evaluation stack
+ EFI_INVALID_PARAMETER if the dependency expression underflows
+ the evaluation stack
+ EFI_INVALID_PARAMETER if the dependency expression is not a
+ well-formed Grammar.
+--*/
+;
+
+
+EFI_STATUS
+PeiDispatcher (
+ IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor,
+ IN PEI_CORE_INSTANCE *PrivateData,
+ IN PEI_CORE_DISPATCH_DATA *DispatchData
+ )
+
+/*++
+
+Routine Description:
+
+ Conduct PEIM dispatch.
+
+Arguments:
+
+ PeiStartupDescriptor - Pointer to IN EFI_PEI_STARTUP_DESCRIPTOR
+ PrivateData - Pointer to the private data passed in from caller
+ DispatchData - Pointer to PEI_CORE_DISPATCH_DATA data.
+
+Returns:
+
+ EFI_SUCCESS - Successfully dispatched PEIM.
+ EFI_NOT_FOUND - The dispatch failed.
+
+--*/
+;
+
+
+VOID
+InitializeDispatcherData (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_CORE_INSTANCE *OldCoreData,
+ IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor
+ )
+/*++
+
+Routine Description:
+
+ Initialize the Dispatcher's data members
+
+Arguments:
+
+ PeiServices - The PEI core services table.
+ OldCoreData - Pointer to old core data (before switching stack).
+ NULL if being run in non-permament memory mode.
+ PeiStartupDescriptor - Information and services provided by SEC phase.
+
+
+Returns:
+
+ None
+
+--*/
+;
+
+
+EFI_STATUS
+FindNextPeim (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader,
+ IN OUT EFI_FFS_FILE_HEADER **PeimFileHeader
+ )
+/*++
+
+Routine Description:
+ Given the input file pointer, search for the next matching file in the
+ FFS volume. The search starts from FileHeader inside
+ the Firmware Volume defined by FwVolHeader.
+
+Arguments:
+ PeiServices - Pointer to the PEI Core Services Table.
+
+ FwVolHeader - Pointer to the FV header of the volume to search.
+ This parameter must point to a valid FFS volume.
+
+ PeimFileHeader - Pointer to the current file from which to begin searching.
+ This pointer will be updated upon return to reflect the file found.
+
+Returns:
+ EFI_NOT_FOUND - No files matching the search criteria were found
+ EFI_SUCCESS
+
+--*/
+;
+
+BOOLEAN
+Dispatched (
+ IN UINT8 CurrentPeim,
+ IN UINT64 DispatchedPeimBitMap
+ )
+/*++
+
+Routine Description:
+
+ This routine checks to see if a particular PEIM has been dispatched during
+ the PEI core dispatch.
+
+Arguments:
+ CurrentPeim - The PEIM/FV in the bit array to check.
+ DispatchedPeimBitMap - Bit array, each bit corresponds to a PEIM/FV.
+
+Returns:
+ TRUE if PEIM already dispatched
+ FALSE if not
+
+--*/
+;
+
+VOID
+SetDispatched (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN UINT8 CurrentPeim,
+ OUT UINT64 *DispatchedPeimBitMap
+ )
+/*++
+
+Routine Description:
+
+ This routine sets a PEIM as having been dispatched once its entry
+ point has been invoked.
+
+Arguments:
+
+ PeiServices - The PEI core services table.
+ CurrentPeim - The PEIM/FV in the bit array to check.
+ DispatchedPeimBitMap - Bit array, each bit corresponds to a PEIM/FV.
+
+Returns:
+ None
+
+--*/
+;
+
+BOOLEAN
+DepexSatisfied (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN VOID *CurrentPeimAddress
+ )
+/*++
+
+Routine Description:
+
+ This routine parses the Dependency Expression, if available, and
+ decides if the module can be executed.
+
+Arguments:
+ PeiServices - The PEI Service Table
+ CurrentPeimAddress - Address of the PEIM Firmware File under investigation
+
+Returns:
+ TRUE - Can be dispatched
+ FALSE - Cannot be dispatched
+
+--*/
+;
+
+VOID
+SwitchCoreStacks (
+ IN VOID *EntryPoint,
+ IN UINTN Parameter1,
+ IN UINTN Parameter2,
+ IN VOID *NewStack
+ )
+/*++
+
+Routine Description:
+
+ Routine for PEI switching stacks.
+
+Arguments:
+
+ EntryPoint - Entry point with new stack.
+ Parameter1 - First parameter for entry point.
+ Parameter2 - Second parameter for entry point.
+ NewStack - Pointer to new stack.
+
+Returns:
+
+ None
+
+--*/
+;
+
+
+#ifdef EFI64
+ //
+ // In Ipf we should make special changes for the PHIT pointers to support
+ // recovery boot in cache mode.
+ //
+#define SWITCH_TO_CACHE_MODE(CoreData) SwitchToCacheMode(CoreData)
+#define CACHE_MODE_ADDRESS_MASK 0x7FFFFFFFFFFFFFFF
+VOID
+SwitchToCacheMode (
+ IN PEI_CORE_INSTANCE *CoreData
+)
+/*++
+
+Routine Description:
+
+ Switch the PHIT pointers to cache mode after InstallPeiMemory in CAR.
+
+Arguments:
+
+ CoreData - The PEI core Private Data
+
+Returns:
+
+--*/
+;
+
+#else
+
+#define SWITCH_TO_CACHE_MODE(CoreData)
+
+#endif
+
+//
+// PPI support functions
+//
+VOID
+InitializePpiServices (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_CORE_INSTANCE *OldCoreData
+ )
+/*++
+
+Routine Description:
+
+ Initialize PPI services.
+
+Arguments:
+
+ PeiServices - The PEI core services table.
+ OldCoreData - Pointer to the PEI Core data.
+ NULL if being run in non-permament memory mode.
+
+Returns:
+ Nothing
+
+--*/
+;
+
+VOID
+ConvertPpiPointers (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_HOB_HANDOFF_INFO_TABLE *OldHandOffHob,
+ IN EFI_HOB_HANDOFF_INFO_TABLE *NewHandOffHob
+ )
+/*++
+
+Routine Description:
+
+ Migrate the Hob list from the CAR stack to PEI installed memory.
+
+Arguments:
+
+ PeiServices - The PEI core services table.
+ OldHandOffHob - The old handoff HOB list.
+ NewHandOffHob - The new handoff HOB list.
+
+Returns:
+
+--*/
+;
+
+EFI_STATUS
+EFIAPI
+PeiInstallPpi (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PEI_PPI_DESCRIPTOR *PpiList
+ )
+/*++
+
+Routine Description:
+
+ Install PPI services.
+
+Arguments:
+
+ PeiServices - Pointer to the PEI Service Table
+ PpiList - Pointer to a list of PEI PPI Descriptors.
+
+Returns:
+
+ EFI_SUCCESS - if all PPIs in PpiList are successfully installed.
+ EFI_INVALID_PARAMETER - if PpiList is NULL pointer
+ EFI_INVALID_PARAMETER - if any PPI in PpiList is not valid
+ EFI_OUT_OF_RESOURCES - if there is no more memory resource to install PPI
+
+--*/
+;
+
+EFI_STATUS
+EFIAPI
+PeiReInstallPpi (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PEI_PPI_DESCRIPTOR *OldPpi,
+ IN EFI_PEI_PPI_DESCRIPTOR *NewPpi
+ )
+/*++
+
+Routine Description:
+
+ Re-Install PPI services.
+
+Arguments:
+
+ PeiServices - Pointer to the PEI Service Table
+ OldPpi - Pointer to the old PEI PPI Descriptors.
+ NewPpi - Pointer to the new PEI PPI Descriptors.
+
+Returns:
+
+ EFI_SUCCESS - if the operation was successful
+ EFI_INVALID_PARAMETER - if OldPpi or NewPpi is NULL
+ EFI_INVALID_PARAMETER - if NewPpi is not valid
+ EFI_NOT_FOUND - if the PPI was not in the database
+
+--*/
+;
+
+EFI_STATUS
+EFIAPI
+PeiLocatePpi (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_GUID *Guid,
+ IN UINTN Instance,
+ IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor,
+ IN OUT VOID **Ppi
+ )
+/*++
+
+Routine Description:
+
+ Locate a given named PPI.
+
+Arguments:
+
+ PeiServices - Pointer to the PEI Service Table
+ Guid - Pointer to GUID of the PPI.
+ Instance - Instance Number to discover.
+ PpiDescriptor - Pointer to reference the found descriptor. If not NULL,
+ returns a pointer to the descriptor (includes flags, etc)
+ Ppi - Pointer to reference the found PPI
+
+Returns:
+
+ Status - EFI_SUCCESS if the PPI is in the database
+ EFI_NOT_FOUND if the PPI is not in the database
+--*/
+;
+
+EFI_STATUS
+EFIAPI
+PeiNotifyPpi (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyList
+ )
+/*++
+
+Routine Description:
+
+ Install a notification for a given PPI.
+
+Arguments:
+
+ PeiServices - Pointer to the PEI Service Table
+ NotifyList - Pointer to list of Descriptors to notify upon.
+
+Returns:
+
+ Status - EFI_SUCCESS if successful
+ EFI_OUT_OF_RESOURCES if no space in the database
+ EFI_INVALID_PARAMETER if not a good decriptor
+
+--*/
+;
+
+VOID
+ProcessNotifyList (
+ IN EFI_PEI_SERVICES **PeiServices
+ )
+/*++
+
+Routine Description:
+
+ Process the Notify List at dispatch level.
+
+Arguments:
+
+ PeiServices - Pointer to the PEI Service Table
+
+Returns:
+
+--*/
+;
+
+VOID
+DispatchNotify (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN UINTN NotifyType,
+ IN INTN InstallStartIndex,
+ IN INTN InstallStopIndex,
+ IN INTN NotifyStartIndex,
+ IN INTN NotifyStopIndex
+ )
+/*++
+
+Routine Description:
+
+ Dispatch notifications.
+
+Arguments:
+
+ PeiServices - Pointer to the PEI Service Table
+ NotifyType - Type of notify to fire.
+ InstallStartIndex - Install Beginning index.
+ InstallStopIndex - Install Ending index.
+ NotifyStartIndex - Notify Beginning index.
+ NotifyStopIndex - Notify Ending index.
+
+Returns: None
+
+--*/
+;
+
+//
+// Boot mode support functions
+//
+EFI_STATUS
+EFIAPI
+PeiGetBootMode (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN OUT EFI_BOOT_MODE *BootMode
+ )
+/*++
+
+Routine Description:
+
+ This service enables PEIMs to ascertain the present value of the boot mode.
+
+Arguments:
+
+ PeiServices - The PEI core services table.
+ BootMode - A pointer to contain the value of the boot mode.
+
+Returns:
+
+ EFI_SUCCESS - The boot mode was returned successfully.
+ EFI_INVALID_PARAMETER - BootMode is NULL.
+
+--*/
+;
+
+EFI_STATUS
+EFIAPI
+PeiSetBootMode (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_BOOT_MODE BootMode
+ )
+/*++
+
+Routine Description:
+
+ This service enables PEIMs to update the boot mode variable.
+
+Arguments:
+
+ PeiServices - The PEI core services table.
+ BootMode - The value of the boot mode to set.
+
+Returns:
+
+ EFI_SUCCESS - The value was successfully updated
+
+--*/
+;
+
+//
+// Security support functions
+//
+VOID
+InitializeSecurityServices (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_CORE_INSTANCE *OldCoreData
+ )
+/*++
+
+Routine Description:
+
+ Initialize the security services.
+
+Arguments:
+
+ PeiServices - The PEI core services table.
+ OldCoreData - Pointer to the old core data.
+ NULL if being run in non-permament memory mode.
+Returns:
+
+ None
+
+--*/
+;
+
+//
+// DebugMask support functions
+//
+VOID
+InstallCoreDebugMaskPpi (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_CORE_INSTANCE *OldCoreData
+ )
+/*++
+
+Routine Description:
+
+ Install DebugMask PPI.
+
+Arguments:
+
+ PeiServices - The PEI core services table.
+ OldCoreData - Pointer to the old core data.
+ NULL if being run in non-permanent memory mode.
+Returns:
+
+ None
+
+--*/
+;
+
+EFI_STATUS
+VerifyFv (
+ IN EFI_FIRMWARE_VOLUME_HEADER *CurrentFvAddress
+ )
+/*++
+
+Routine Description:
+
+ Provide a callout to the OEM FV verification service.
+
+Arguments:
+
+ CurrentFvAddress - Pointer to the FV under investigation.
+
+Returns:
+
+ Status - EFI_SUCCESS
+
+--*/
+;
+
+
+EFI_STATUS
+VerifyPeim (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_FFS_FILE_HEADER *CurrentPeimAddress
+ )
+/*++
+
+Routine Description:
+
+ Provide a callout to the security verification service.
+
+Arguments:
+
+ PeiServices - The PEI core services table.
+ CurrentPeimAddress - Pointer to the Firmware File under investigation.
+
+Returns:
+
+ EFI_SUCCESS - Image is OK
+ EFI_SECURITY_VIOLATION - Image is illegal
+
+--*/
+;
+
+
+EFI_STATUS
+EFIAPI
+PeiGetHobList (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN OUT VOID **HobList
+ )
+/*++
+
+Routine Description:
+
+ Gets the pointer to the HOB List.
+
+Arguments:
+
+ PeiServices - The PEI core services table.
+ HobList - Pointer to the HOB List.
+
+Returns:
+
+ EFI_SUCCESS - Get the pointer of HOB List
+ EFI_NOT_AVAILABLE_YET - the HOB List is not yet published
+ EFI_INVALID_PARAMETER - HobList is NULL (in debug mode)
+
+--*/
+;
+
+EFI_STATUS
+EFIAPI
+PeiCreateHob (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN UINT16 Type,
+ IN UINT16 Length,
+ IN OUT VOID **Hob
+ )
+/*++
+
+Routine Description:
+
+ Add a new HOB to the HOB List.
+
+Arguments:
+
+ PeiServices - The PEI core services table.
+ Type - Type of the new HOB.
+ Length - Length of the new HOB to allocate.
+ Hob - Pointer to the new HOB.
+
+Returns:
+
+ Status - EFI_SUCCESS
+ - EFI_INVALID_PARAMETER if Hob is NULL
+ - EFI_NOT_AVAILABLE_YET if HobList is still not available.
+ - EFI_OUT_OF_RESOURCES if there is no more memory to grow the Hoblist.
+
+--*/
+;
+
+EFI_STATUS
+PeiCoreBuildHobHandoffInfoTable (
+ IN EFI_BOOT_MODE BootMode,
+ IN EFI_PHYSICAL_ADDRESS MemoryBegin,
+ IN UINT64 MemoryLength
+ )
+/*++
+
+Routine Description:
+
+ Builds a Handoff Information Table HOB
+
+Arguments:
+
+ BootMode - Current Bootmode
+ MemoryBegin - Start Memory Address.
+ MemoryLength - Length of Memory.
+
+Returns:
+
+ EFI_SUCCESS
+
+--*/
+;
+
+
+//
+// FFS Fw Volume support functions
+//
+EFI_STATUS
+EFIAPI
+PeiFfsFindNextFile (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN UINT8 SearchType,
+ IN EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader,
+ IN OUT EFI_FFS_FILE_HEADER **FileHeader
+ )
+/*++
+
+Routine Description:
+ Given the input file pointer, search for the next matching file in the
+ FFS volume as defined by SearchType. The search starts from FileHeader inside
+ the Firmware Volume defined by FwVolHeader.
+
+Arguments:
+ PeiServices - Pointer to the PEI Core Services Table.
+
+ SearchType - Filter to find only files of this type.
+ Type EFI_FV_FILETYPE_ALL causes no filtering to be done.
+
+ FwVolHeader - Pointer to the FV header of the volume to search.
+ This parameter must point to a valid FFS volume.
+
+ FileHeader - Pointer to the current file from which to begin searching.
+ This pointer will be updated upon return to reflect the file found.
+
+Returns:
+ EFI_NOT_FOUND - No files matching the search criteria were found
+ EFI_SUCCESS
+
+--*/
+;
+
+EFI_STATUS
+EFIAPI
+PeiFfsFindSectionData (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_SECTION_TYPE SectionType,
+ IN EFI_FFS_FILE_HEADER *FfsFileHeader,
+ IN OUT VOID **SectionData
+ )
+/*++
+
+Routine Description:
+ Given the input file pointer, search for the next matching section in the
+ FFS volume.
+
+Arguments:
+ PeiServices - Pointer to the PEI Core Services Table.
+ SearchType - Filter to find only sections of this type.
+ FfsFileHeader - Pointer to the current file to search.
+ SectionData - Pointer to the Section matching SectionType in FfsFileHeader.
+ - NULL if section not found
+
+Returns:
+ EFI_NOT_FOUND - No files matching the search criteria were found
+ EFI_SUCCESS
+
+--*/
+;
+
+EFI_STATUS
+EFIAPI
+PeiFvFindNextVolume (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN UINTN Instance,
+ IN OUT EFI_FIRMWARE_VOLUME_HEADER **FwVolHeader
+ )
+/*++
+
+Routine Description:
+
+ Return the BFV location
+
+ BugBug -- Move this to the location of this code to where the
+ other FV and FFS support code lives.
+ Also, update to use FindFV for instances #'s >= 1.
+
+Arguments:
+
+ PeiServices - The PEI core services table.
+ Instance - Instance of FV to find
+ FwVolHeader - Pointer to contain the data to return
+
+Returns:
+ Pointer to the Firmware Volume instance requested
+
+ EFI_INVALID_PARAMETER - FwVolHeader is NULL
+
+ EFI_SUCCESS - Firmware volume instance successfully found.
+
+--*/
+;
+
+//
+// Memory support functions
+//
+VOID
+InitializeMemoryServices (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor,
+ IN PEI_CORE_INSTANCE *OldCoreData
+ )
+/*++
+
+Routine Description:
+
+ Initialize the memory services.
+
+Arguments:
+
+ PeiServices - The PEI core services table.
+ PeiStartupDescriptor - Information and services provided by SEC phase.
+ OldCoreData - Pointer to the PEI Core data.
+ NULL if being run in non-permament memory mode.
+
+Returns:
+
+ None
+
+--*/
+;
+
+EFI_STATUS
+EFIAPI
+PeiInstallPeiMemory (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PHYSICAL_ADDRESS MemoryBegin,
+ IN UINT64 MemoryLength
+ )
+/*++
+
+Routine Description:
+
+ Install the permanent memory is now available.
+ Creates HOB (PHIT and Stack).
+
+Arguments:
+
+ PeiServices - The PEI core services table.
+ MemoryBegin - Start of memory address.
+ MemoryLength - Length of memory.
+
+Returns:
+
+ Status - EFI_SUCCESS
+
+--*/
+;
+
+EFI_STATUS
+EFIAPI
+PeiAllocatePages (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_MEMORY_TYPE MemoryType,
+ IN UINTN Pages,
+ OUT EFI_PHYSICAL_ADDRESS *Memory
+ )
+/*++
+
+Routine Description:
+
+ Memory allocation service on permanent memory,
+ not usable prior to the memory installation.
+
+Arguments:
+
+ PeiServices - The PEI core services table.
+ Type - Type of allocation.
+ MemoryType - Type of memory to allocate.
+ Pages - Number of pages to allocate.
+ Memory - Pointer of memory allocated.
+
+Returns:
+
+ Status - EFI_SUCCESS The allocation was successful
+ EFI_INVALID_PARAMETER Only AllocateAnyAddress is supported.
+ EFI_NOT_AVAILABLE_YET Called with permanent memory not available
+ EFI_OUT_OF_RESOURCES There is not enough HOB heap to satisfy the requirement
+ to allocate the number of pages.
+
+--*/
+;
+
+EFI_STATUS
+EFIAPI
+PeiAllocatePool (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN UINTN Size,
+ OUT VOID **Buffer
+ )
+/*++
+
+Routine Description:
+
+ Memory allocation service on the CAR.
+
+Arguments:
+
+ PeiServices - The PEI core services table.
+
+ Size - Amount of memory required
+
+ Buffer - Address of pointer to the buffer
+
+Returns:
+
+ Status - EFI_SUCCESS The allocation was successful
+ EFI_OUT_OF_RESOURCES There is not enough heap to satisfy the requirement
+ to allocate the requested size.
+
+--*/
+;
+
+VOID
+EFIAPI
+PeiCoreCopyMem (
+ IN VOID *Destination,
+ IN VOID *Source,
+ IN UINTN Length
+ )
+/*++
+
+Routine Description:
+
+ Copy Length bytes from Source to Destination.
+
+Arguments:
+
+ Destination - Target of copy
+
+ Source - Place to copy from
+
+ Length - Number of bytes to copy
+
+Returns:
+
+ None
+
+--*/
+;
+
+VOID
+EFIAPI
+PeiCoreSetMem (
+ IN VOID *Buffer,
+ IN UINTN Size,
+ IN UINT8 Value
+ )
+/*++
+
+Routine Description:
+
+ Set Size bytes at Buffer address with Value
+
+Arguments:
+
+ Buffer - Target of set
+
+ Size - Amount of memory to set
+
+ Value - Value to place in memory
+
+Returns:
+
+ None
+
+--*/
+;
+
+EFI_STATUS
+PeiLoadImage (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_FFS_FILE_HEADER *PeimFileHeader,
+ OUT VOID **EntryPoint
+ )
+/*++
+
+Routine Description:
+
+ Get entry point of a Peim file.
+
+Arguments:
+
+ PeiServices - Calling context.
+
+ PeimFileHeader - Peim file's header.
+
+ EntryPoint - Entry point of that Peim file.
+
+Returns:
+
+ Status code.
+
+--*/
+;
+
+
+EFI_STATUS
+EFIAPI
+PeiReportStatusCode (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_STATUS_CODE_TYPE CodeType,
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN UINT32 Instance,
+ IN EFI_GUID *CallerId,
+ IN EFI_STATUS_CODE_DATA *Data OPTIONAL
+ )
+/*++
+
+Routine Description:
+
+ Core version of the Status Code reporter
+
+Arguments:
+
+ PeiServices - The PEI core services table.
+
+ CodeType - Type of Status Code.
+
+ Value - Value to output for Status Code.
+
+ Instance - Instance Number of this status code.
+
+ CallerId - ID of the caller of this status code.
+
+ Data - Optional data associated with this status code.
+
+Returns:
+
+ Status - EFI_SUCCESS if status code is successfully reported
+ - EFI_NOT_AVAILABLE_YET if StatusCodePpi has not been installed
+
+--*/
+;
+
+
+EFI_STATUS
+EFIAPI
+PeiCoreResetSystem (
+ IN EFI_PEI_SERVICES **PeiServices
+ )
+/*++
+
+Routine Description:
+
+ Core version of the Reset System
+
+Arguments:
+
+ PeiServices - The PEI core services table.
+
+Returns:
+
+ Status - EFI_NOT_AVAILABLE_YET. PPI not available yet.
+ - EFI_DEVICE_ERROR. Did not reset system.
+
+ Otherwise, resets the system.
+
+--*/
+;
+
+#endif
diff --git a/EDK/Foundation/Core/Pei/Memory/MemoryServices.c b/EDK/Foundation/Core/Pei/Memory/MemoryServices.c
new file mode 100644
index 0000000..1e25179
--- /dev/null
+++ b/EDK/Foundation/Core/Pei/Memory/MemoryServices.c
@@ -0,0 +1,395 @@
+/*++
+
+Copyright (c) 2004 - 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ MemoryServices.c
+
+Abstract:
+
+ EFI PEI Core memory services
+
+--*/
+
+#include "Tiano.h"
+#include "PeiApi.h"
+#include "PeiCore.h"
+#include "PeiLib.h"
+
+VOID
+InitializeMemoryServices (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor,
+ IN PEI_CORE_INSTANCE *OldCoreData
+ )
+/*++
+
+Routine Description:
+
+ Initialize the memory services.
+
+Arguments:
+
+ PeiServices - The PEI core services table.
+ PeiStartupDescriptor - Information and services provided by SEC phase.
+ OldCoreData - Pointer to the PEI Core data.
+ NULL if being run in non-permament memory mode.
+
+Returns:
+
+ None
+
+--*/
+{
+ PEI_CORE_INSTANCE *PrivateData;
+ UINT64 SizeOfCarHeap;
+
+ PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS (PeiServices);
+ PrivateData->SwitchStackSignal = FALSE;
+
+ if (OldCoreData == NULL) {
+
+ PrivateData->PeiMemoryInstalled = FALSE;
+
+ PrivateData->BottomOfCarHeap = (VOID *) (((UINTN)(VOID *)(&PrivateData))
+ & (~((PeiStartupDescriptor->SizeOfCacheAsRam) - 1)));
+ PrivateData->TopOfCarHeap = (VOID *)((UINTN)(PrivateData->BottomOfCarHeap) + PeiStartupDescriptor->SizeOfCacheAsRam);
+ //
+ // SizeOfCarHeap is 1/2 (arbitrary) of CacheAsRam Size.
+ //
+ SizeOfCarHeap = (UINT64) PeiStartupDescriptor->SizeOfCacheAsRam;
+ SizeOfCarHeap = RShiftU64 (SizeOfCarHeap, 1);
+
+ PEI_DEBUG_CODE (
+ {
+ PrivateData->SizeOfCacheAsRam = PeiStartupDescriptor->SizeOfCacheAsRam;
+ PrivateData->MaxTopOfCarHeap = (VOID *) ((UINTN) PrivateData->BottomOfCarHeap + (UINTN) SizeOfCarHeap);
+ }
+ )
+
+ PrivateData->HobList.Raw = PrivateData->BottomOfCarHeap;
+
+ PeiCoreBuildHobHandoffInfoTable (
+ BOOT_WITH_FULL_CONFIGURATION,
+ (EFI_PHYSICAL_ADDRESS) (UINTN) PrivateData->BottomOfCarHeap,
+ (UINTN) SizeOfCarHeap
+ );
+ //
+ // Copy PeiServices from ROM to Cache in PrivateData
+ //
+ PeiCoreCopyMem (&(PrivateData->ServiceTableShadow), *PeiServices, sizeof (EFI_PEI_SERVICES));
+
+ //
+ // Set PS to point to ServiceTableShadow in Cache
+ //
+ PrivateData->PS = &(PrivateData->ServiceTableShadow);
+ } else {
+ //
+ // Set PS to point to ServiceTableShadow in Cache one time after the
+ // stack switched to main memory
+ //
+ PrivateData->PS = &(PrivateData->ServiceTableShadow);
+}
+
+ return;
+}
+
+EFI_STATUS
+EFIAPI
+PeiInstallPeiMemory (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PHYSICAL_ADDRESS MemoryBegin,
+ IN UINT64 MemoryLength
+ )
+/*++
+
+Routine Description:
+
+ Install the permanent memory is now available.
+ Creates HOB (PHIT and Stack).
+
+Arguments:
+
+ PeiServices - The PEI core services table.
+ MemoryBegin - Start of memory address.
+ MemoryLength - Length of memory.
+
+Returns:
+
+ Status - EFI_SUCCESS
+
+--*/
+{
+ PEI_CORE_INSTANCE *PrivateData;
+ EFI_HOB_HANDOFF_INFO_TABLE *OldHandOffHob;
+ EFI_HOB_HANDOFF_INFO_TABLE *NewHandOffHob;
+ UINT64 PeiStackSize;
+ UINT64 EfiFreeMemorySize;
+ EFI_PHYSICAL_ADDRESS PhysicalAddressOfOldHob;
+
+ PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS (PeiServices);
+
+ PrivateData->SwitchStackSignal = TRUE;
+ PrivateData->PeiMemoryInstalled = TRUE;
+
+ PrivateData->StackBase = MemoryBegin;
+
+ PeiStackSize = RShiftU64 (MemoryLength, 1);
+ if (PEI_STACK_SIZE > PeiStackSize) {
+ PrivateData->StackSize = PeiStackSize;
+ } else {
+ PrivateData->StackSize = PEI_STACK_SIZE;
+ }
+
+ OldHandOffHob = PrivateData->HobList.HandoffInformationTable;
+
+ PrivateData->HobList.Raw = (VOID *)((UINTN)(MemoryBegin + PrivateData->StackSize));
+ NewHandOffHob = PrivateData->HobList.HandoffInformationTable;
+ PhysicalAddressOfOldHob = (EFI_PHYSICAL_ADDRESS) (UINTN) OldHandOffHob;
+
+ EfiFreeMemorySize = OldHandOffHob->EfiFreeMemoryBottom - PhysicalAddressOfOldHob;
+
+ PeiCoreCopyMem (
+ NewHandOffHob,
+ OldHandOffHob,
+ (UINTN)EfiFreeMemorySize
+ );
+
+ NewHandOffHob->EfiMemoryTop = MemoryBegin + MemoryLength;
+ NewHandOffHob->EfiFreeMemoryTop = NewHandOffHob->EfiMemoryTop;
+ NewHandOffHob->EfiMemoryBottom = MemoryBegin;
+
+ NewHandOffHob->EfiFreeMemoryBottom = (UINTN)NewHandOffHob + EfiFreeMemorySize;
+
+ NewHandOffHob->EfiEndOfHobList = (UINTN)NewHandOffHob +
+ (OldHandOffHob->EfiEndOfHobList -
+ PhysicalAddressOfOldHob);
+
+ ConvertPpiPointers (PeiServices, OldHandOffHob, NewHandOffHob);
+
+ PeiBuildHobStack (PeiServices, PrivateData->StackBase, PrivateData->StackSize);
+
+ PEI_DEBUG_CODE (
+ {
+ PEI_DEBUG ((PeiServices, EFI_D_INFO, "HOBLIST address before memory init = 0x%08x\n", OldHandOffHob));
+ PEI_DEBUG ((PeiServices, EFI_D_INFO, "HOBLIST address after memory init = 0x%08x\n", NewHandOffHob));
+ }
+ )
+
+ return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+EFIAPI
+PeiAllocatePages (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_MEMORY_TYPE MemoryType,
+ IN UINTN Pages,
+ OUT EFI_PHYSICAL_ADDRESS *Memory
+ )
+/*++
+
+Routine Description:
+
+ Memory allocation service on permanent memory,
+ not usable prior to the memory installation.
+
+Arguments:
+
+ PeiServices - The PEI core services table.
+ MemoryType - Type of memory to allocate.
+ Pages - Number of pages to allocate.
+ Memory - Pointer of memory allocated.
+
+Returns:
+
+ Status - EFI_SUCCESS The allocation was successful
+ EFI_INVALID_PARAMETER Only AllocateAnyAddress is supported.
+ EFI_NOT_AVAILABLE_YET Called with permanent memory not available
+ EFI_OUT_OF_RESOURCES There is not enough HOB heap to satisfy the requirement
+ to allocate the number of pages.
+
+--*/
+{
+ PEI_CORE_INSTANCE *PrivateData;
+ EFI_PEI_HOB_POINTERS Hob;
+ EFI_PHYSICAL_ADDRESS Offset;
+ EFI_STATUS Status;
+
+ PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS (PeiServices);
+
+ //
+ // Check if Hob already available
+ //
+ if (!PrivateData->PeiMemoryInstalled) {
+ return EFI_NOT_AVAILABLE_YET;
+ }
+
+ Hob.Raw = PrivateData->HobList.Raw;
+
+ //
+ // Check to see if on 4k boundary
+ //
+ Offset = Hob.HandoffInformationTable->EfiFreeMemoryTop & 0xFFF;
+
+ //
+ // If not aligned, make the allocation aligned.
+ //
+ if (Offset != 0) {
+ Hob.HandoffInformationTable->EfiFreeMemoryTop -= Offset;
+ }
+
+ //
+ // Verify that there is sufficient memory to satisfy the allocation
+ //
+ if (Hob.HandoffInformationTable->EfiFreeMemoryTop - ((Pages * EFI_PAGE_SIZE) + sizeof (EFI_HOB_MEMORY_ALLOCATION)) <
+ Hob.HandoffInformationTable->EfiFreeMemoryBottom) {
+ PEI_DEBUG_CODE (
+ {
+ PEI_DEBUG ((PeiServices, EFI_D_ERROR, "PeiAllocatePages fail: Pages - 0x%08x\n", Pages));
+ PEI_DEBUG ((PeiServices, EFI_D_ERROR, " FreeMemoryTop - 0x%08x\n", (UINTN)Hob.HandoffInformationTable->EfiFreeMemoryTop));
+ PEI_DEBUG ((PeiServices, EFI_D_ERROR, " FreeMemoryBottom - 0x%08x\n", (UINTN)Hob.HandoffInformationTable->EfiFreeMemoryBottom));
+ }
+ )
+ return EFI_OUT_OF_RESOURCES;
+ } else {
+ //
+ // Update the PHIT to reflect the memory usage
+ //
+ Hob.HandoffInformationTable->EfiFreeMemoryTop -= Pages * EFI_PAGE_SIZE;
+
+ //
+ // Update the value for the caller
+ //
+ *Memory = Hob.HandoffInformationTable->EfiFreeMemoryTop;
+
+ //
+ // Create a memory allocation HOB.
+ //
+ Status = PeiBuildHobMemoryAllocation (
+ PeiServices,
+ Hob.HandoffInformationTable->EfiFreeMemoryTop,
+ Pages * EFI_PAGE_SIZE + Offset,
+ NULL,
+ MemoryType
+ );
+
+ return Status;
+ }
+}
+
+
+EFI_STATUS
+EFIAPI
+PeiAllocatePool (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN UINTN Size,
+ OUT VOID **Buffer
+ )
+/*++
+
+Routine Description:
+
+ Memory allocation service on the CAR.
+
+Arguments:
+
+ PeiServices - The PEI core services table.
+
+ Size - Amount of memory required
+
+ Buffer - Address of pointer to the buffer
+
+Returns:
+
+ Status - EFI_SUCCESS The allocation was successful
+ EFI_OUT_OF_RESOURCES There is not enough heap to satisfy the requirement
+ to allocate the requested size.
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_HOB_MEMORY_POOL *Hob;
+
+
+ Status = PeiCreateHob (
+ PeiServices,
+ EFI_HOB_TYPE_PEI_MEMORY_POOL,
+ (UINT16)(sizeof (EFI_HOB_MEMORY_POOL) + Size),
+ &Hob
+ );
+ *Buffer = Hob+1;
+
+
+ return Status;
+}
+
+VOID
+EFIAPI
+PeiCoreCopyMem (
+ IN VOID *Destination,
+ IN VOID *Source,
+ IN UINTN Length
+ )
+/*++
+
+Routine Description:
+
+ Copy Length bytes from Source to Destination.
+
+Arguments:
+
+ Destination - Target of copy
+
+ Source - Place to copy from
+
+ Length - Number of bytes to copy
+
+Returns:
+
+ None
+
+--*/
+{
+ EfiCommonLibCopyMem (Destination, Source, Length);
+}
+
+VOID
+EFIAPI
+PeiCoreSetMem (
+ IN VOID *Buffer,
+ IN UINTN Size,
+ IN UINT8 Value
+ )
+/*++
+
+Routine Description:
+
+ Set Size bytes at Buffer address with Value
+
+Arguments:
+
+ Buffer - Target of set
+
+ Size - Amount of memory to set
+
+ Value - Value to place in memory
+
+Returns:
+
+ None
+
+--*/
+{
+ EfiCommonLibSetMem (Buffer, Size, Value);
+}
+
diff --git a/EDK/Foundation/Core/Pei/PeiMain.cif b/EDK/Foundation/Core/Pei/PeiMain.cif
new file mode 100644
index 0000000..9a527fd
--- /dev/null
+++ b/EDK/Foundation/Core/Pei/PeiMain.cif
@@ -0,0 +1,24 @@
+<component>
+ name = "PeiMain"
+ category = ModulePart
+ LocalRoot = "EDK\Foundation\Core\Pei\"
+ RefName = "PeiMain"
+[files]
+"PeiMain.inf"
+"BootMode\BootMode.c"
+"Dependency\dependency.c"
+"Dependency\dependency.h"
+"Dispatcher\Dispatcher.c"
+"FwVol\FwVol.c"
+"Hob\Hob.c"
+"Ia32\SwitchCoreStacks.asm"
+"Image\Image.c"
+"Include\PeiCore.h"
+"Memory\MemoryServices.c"
+"PeiMain\PeiMain.c"
+"Ppi\Ppi.c"
+"Reset\Reset.c"
+"Security\Security.c"
+"StatusCode\StatusCode.c"
+"DebugMask\DebugMask.c"
+<endComponent>
diff --git a/EDK/Foundation/Core/Pei/PeiMain.inf b/EDK/Foundation/Core/Pei/PeiMain.inf
new file mode 100644
index 0000000..bf707cc
--- /dev/null
+++ b/EDK/Foundation/Core/Pei/PeiMain.inf
@@ -0,0 +1,82 @@
+#/*++
+#
+# Copyright (c) 2004 - 2005, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# PeiMain.inf
+#
+# Abstract:
+#
+# Component description file for PeiMain module
+#
+#--*/
+
+[defines]
+BASE_NAME = PeiMain
+FILE_GUID = 52C05B14-0B98-496c-BC3B-04B50211D680
+COMPONENT_TYPE = PEI_CORE
+
+[sources.common]
+ Include\PeiCore.h
+ BootMode\BootMode.c
+ DebugMask\DebugMask.c
+ Dependency\Dependency.c
+ Dispatcher\Dispatcher.c
+ FwVol\FwVol.c
+ Hob\Hob.c
+ Image\Image.c
+ Memory\MemoryServices.c
+ PeiMain\PeiMain.c
+ Ppi\Ppi.c
+ Reset\Reset.c
+ Security\Security.c
+ StatusCode\StatusCode.c
+
+[sources.ia32]
+ ia32\SwitchCoreStacks.asm
+[sources.x64]
+ x64\SwitchCoreStacks.asm
+
+[sources.ipf]
+ ipf\SwitchToCacheMode.c
+ ipf\IpfCpuCore.s
+ ipf\IpfCpuCore.i
+
+[includes.common]
+ $(EDK_SOURCE)\Foundation
+ $(EDK_SOURCE)\Sample\Platform\Nt32
+ $(EDK_SOURCE)\Foundation\Framework
+ $(EDK_SOURCE)\Foundation\Efi
+ .
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+ $(EDK_SOURCE)\Foundation\Include\Pei
+ $(EDK_SOURCE)\Foundation\Library\Pei\Include
+ $(EDK_SOURCE)\Foundation\Core\Pei\Include
+ $(EDK_SOURCE)\Framework
+
+[libraries.common]
+ EdkPpiLib
+ EdkFrameworkPpiLib
+ EdkFrameworkGuidLib
+ PeiHobLib
+ PeiLib
+ EfiGuidLib
+
+[libraries.ia32.nt32]
+ EdkNt32PpiLib
+
+[nmake.common]
+ IMAGE_ENTRY_POINT=PeiMain
diff --git a/EDK/Foundation/Core/Pei/PeiMain/PeiMain.c b/EDK/Foundation/Core/Pei/PeiMain/PeiMain.c
new file mode 100644
index 0000000..692944c
--- /dev/null
+++ b/EDK/Foundation/Core/Pei/PeiMain/PeiMain.c
@@ -0,0 +1,321 @@
+/*++
+
+Copyright (c) 2004 - 2011, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PeiMain.c
+
+Abstract:
+
+ Pei Core Main Entry Point
+
+Revision History
+
+--*/
+
+#include "Tiano.h"
+#include "PeiCore.h"
+#include "PeiLib.h"
+#include EFI_PPI_DEFINITION (MemoryDiscovered)
+#include EFI_PPI_DEFINITION (FindFv)
+#include EFI_GUID_DEFINITION (StatusCodeDataTypeId)
+#include EFI_GUID_DEFINITION (StatusCode)
+
+//
+//CAR is filled with this initial value during SEC phase
+//
+#define INIT_CAR_VALUE 0x5AA55AA5
+
+#ifdef FIRMWARE_PERFORMANCE
+
+EFI_STATUS
+GetTimerValue (
+ OUT UINT64 *TimerValue
+ );
+
+#endif
+
+static EFI_PEI_PPI_DESCRIPTOR mMemoryDiscoveredPpi = {
+ (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
+ &gPeiMemoryDiscoveredPpiGuid,
+ NULL
+};
+
+//
+// Pei Core Module Variables
+//
+//
+static EFI_PEI_SERVICES mPS = {
+ {
+ PEI_SERVICES_SIGNATURE,
+ PEI_SERVICES_REVISION,
+ sizeof (EFI_PEI_SERVICES),
+ 0,
+ 0
+ },
+ PeiInstallPpi,
+ PeiReInstallPpi,
+ PeiLocatePpi,
+ PeiNotifyPpi,
+
+ PeiGetBootMode,
+ PeiSetBootMode,
+
+ PeiGetHobList,
+ PeiCreateHob,
+
+ PeiFvFindNextVolume,
+ PeiFfsFindNextFile,
+ PeiFfsFindSectionData,
+
+ PeiInstallPeiMemory,
+ PeiAllocatePages,
+ PeiAllocatePool,
+ PeiCoreCopyMem,
+ PeiCoreSetMem,
+
+ PeiReportStatusCode,
+
+ PeiCoreResetSystem
+};
+
+VOID
+EFIAPI
+AsmWriteMm7 (
+ IN UINT64 Value
+ );
+
+EFI_STATUS
+EFIAPI
+PeiCore (
+ IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor,
+ IN PEI_CORE_INSTANCE *OldCoreData
+ );
+
+//
+// Main entry point to the PEI Core
+//
+EFI_PEI_CORE_ENTRY_POINT (PeiMain)
+
+EFI_STATUS
+EFIAPI
+PeiMain (
+ IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor
+ )
+/*++
+
+Routine Description:
+
+ Main entry point to Pei Core.
+
+Arguments:
+
+ PeiStartupDescriptor - Information and services provided by SEC phase.
+
+Returns:
+
+ This function never returns
+
+--*/
+{
+ return PeiCore (PeiStartupDescriptor, NULL);
+}
+
+EFI_STATUS
+EFIAPI
+PeiCore (
+ IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor,
+ IN PEI_CORE_INSTANCE *OldCoreData
+ )
+/*++
+
+Routine Description:
+
+ The entry routine to Pei Core, invoked by PeiMain during transition
+ from SEC to PEI. After switching stack in the PEI core, it will restart
+ with the old core data.
+
+Arguments:
+
+ PeiStartupDescriptor - Information and services provided by SEC phase.
+ OldCoreData - Pointer to old core data that is used to initialize the
+ core's data areas.
+
+Returns:
+
+ This function never returns
+ EFI_NOT_FOUND - Never reach
+
+--*/
+{
+ PEI_CORE_INSTANCE PrivateData;
+ EFI_STATUS Status;
+ PEI_CORE_TEMP_POINTERS TempPtr;
+ PEI_CORE_DISPATCH_DATA *DispatchData;
+
+
+#ifdef FIRMWARE_PERFORMANCE
+ UINT64 mTick;
+
+ mTick = 0;
+ if (OldCoreData == NULL) {
+ GetTimerValue (&mTick);
+ }
+#endif
+
+
+ //
+ // For IPF in CAR mode the real memory access is uncached,in InstallPeiMemory()
+ // the 63-bit of address is set to 1.
+ //
+ SWITCH_TO_CACHE_MODE (OldCoreData);
+
+ if (OldCoreData != NULL) {
+ PeiCoreCopyMem (&PrivateData, OldCoreData, sizeof (PEI_CORE_INSTANCE));
+ } else {
+ PeiCoreSetMem (&PrivateData, sizeof (PEI_CORE_INSTANCE), 0);
+ }
+
+ PrivateData.Signature = PEI_CORE_HANDLE_SIGNATURE;
+ PrivateData.PS = &mPS;
+
+ //
+ // Mm7 stored PeiServicesTablePointer in EdkII Glue Library
+ // Update Mm7 now
+ //
+#if (defined(EFI32)) || (defined(EFIX64))
+ AsmWriteMm7 ((UINT64)(UINTN)(&PrivateData.PS));
+#endif
+
+ InitializeMemoryServices (&PrivateData.PS, PeiStartupDescriptor, OldCoreData);
+
+ InitializePpiServices (&PrivateData.PS, OldCoreData);
+
+ InitializeSecurityServices (&PrivateData.PS, OldCoreData);
+
+ PEI_DEBUG_CODE (
+ InstallCoreDebugMaskPpi (&PrivateData.PS, OldCoreData);
+ )
+
+ InitializeDispatcherData (&PrivateData.PS, OldCoreData, PeiStartupDescriptor);
+
+ if (OldCoreData != NULL) {
+
+ PEI_PERF_END (&PrivateData.PS,L"PreMem", NULL, 0);
+ PEI_PERF_START (&PrivateData.PS,L"PostMem", NULL, 0);
+
+ //
+ // The following code dumps out interesting cache as RAM usage information
+ // so we can keep tabs on how the cache as RAM is being utilized. The
+ // PEI_DEBUG_CODE macro is used to prevent this code from being compiled
+ // on a debug build.
+ //
+ PEI_DEBUG_CODE (
+ {
+ UINTN *StackPointer;
+ UINTN StackValue;
+
+ StackValue = INIT_CAR_VALUE;
+ for (StackPointer = (UINTN *) OldCoreData->MaxTopOfCarHeap;
+ ((UINTN) StackPointer < ((UINTN) OldCoreData->BottomOfCarHeap + OldCoreData->SizeOfCacheAsRam))
+ && StackValue == INIT_CAR_VALUE;
+ StackPointer++) {
+ StackValue = *StackPointer;
+ }
+
+ PEI_DEBUG ((&PrivateData.PS, EFI_D_INFO, "Total Cache as RAM: %d bytes.\n", OldCoreData->SizeOfCacheAsRam));
+ PEI_DEBUG (
+ (
+ &PrivateData.PS, EFI_D_INFO, " CAR stack ever used: %d bytes.\n",
+ ((UINTN) OldCoreData->TopOfCarHeap - (UINTN) StackPointer)
+ )
+ );
+ PEI_DEBUG (
+ (
+ &PrivateData.PS, EFI_D_INFO, " CAR heap used: %d bytes.\n",
+ ((UINTN) OldCoreData->HobList.HandoffInformationTable->EfiFreeMemoryBottom -
+ (UINTN) OldCoreData->HobList.Raw)
+ )
+ );
+ }
+ )
+
+ //
+ // Alert any listeners that there is permanent memory available
+ //
+ PEI_PERF_START (&PrivateData.PS,L"DisMem", NULL, 0);
+ Status = PeiInstallPpi (&PrivateData.PS, &mMemoryDiscoveredPpi);
+ PEI_PERF_END (&PrivateData.PS,L"DisMem", NULL, 0);
+
+ } else {
+
+ //
+ // Report Status Code EFI_SW_PC_INIT
+ //
+ PEI_REPORT_STATUS_CODE (
+ &(PrivateData.PS),
+ EFI_PROGRESS_CODE,
+ EFI_SOFTWARE_PEI_CORE | EFI_SW_PC_INIT,
+ 0,
+ NULL,
+ NULL
+ );
+
+ //
+ // If first pass, start performance measurement.
+ //
+ PEI_PERF_START (&PrivateData.PS,L"PreMem", NULL, mTick);
+
+ //
+ // If SEC provided any PPI services to PEI, install them.
+ //
+ if (PeiStartupDescriptor->DispatchTable != NULL) {
+ Status = PeiInstallPpi (&PrivateData.PS, PeiStartupDescriptor->DispatchTable);
+
+ ASSERT_PEI_ERROR (&PrivateData.PS, Status);
+ }
+ }
+
+ DispatchData = &PrivateData.DispatchData;
+
+ //
+ // Call PEIM dispatcher
+ //
+ PeiDispatcher (PeiStartupDescriptor, &PrivateData, DispatchData);
+
+ //
+ // Check if InstallPeiMemory service was called.
+ //
+ PEI_ASSERT(&PrivateData.PS, PrivateData.PeiMemoryInstalled == TRUE);
+
+ PEI_PERF_END (&PrivateData.PS, L"PostMem", NULL, 0);
+
+ Status = PeiLocatePpi (
+ &PrivateData.PS,
+ &gEfiDxeIplPpiGuid,
+ 0,
+ NULL,
+ &TempPtr.DxeIpl
+ );
+ ASSERT_PEI_ERROR (&PrivateData.PS, Status);
+
+ PEI_DEBUG ((&PrivateData.PS, EFI_D_INFO, "DXE IPL Entry\n"));
+ Status = TempPtr.DxeIpl->Entry (
+ TempPtr.DxeIpl,
+ &PrivateData.PS,
+ PrivateData.HobList
+ );
+
+ ASSERT_PEI_ERROR (&PrivateData.PS, Status);
+
+ return EFI_NOT_FOUND;
+}
+
diff --git a/EDK/Foundation/Core/Pei/Ppi/Ppi.c b/EDK/Foundation/Core/Pei/Ppi/Ppi.c
new file mode 100644
index 0000000..ceb2ab2
--- /dev/null
+++ b/EDK/Foundation/Core/Pei/Ppi/Ppi.c
@@ -0,0 +1,667 @@
+/*++
+
+Copyright (c) 2004 - 2005, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Ppi.c
+
+Abstract:
+
+ EFI PEI Core PPI services
+
+Revision History
+
+--*/
+
+#include "Tiano.h"
+#include "PeiCore.h"
+#include "PeiLib.h"
+
+VOID
+InitializePpiServices (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_CORE_INSTANCE *OldCoreData
+ )
+/*++
+
+Routine Description:
+
+ Initialize PPI services.
+
+Arguments:
+
+ PeiServices - The PEI core services table.
+ OldCoreData - Pointer to the PEI Core data.
+ NULL if being run in non-permament memory mode.
+
+Returns:
+ Nothing
+
+--*/
+{
+ PEI_CORE_INSTANCE *PrivateData;
+
+ if (OldCoreData == NULL) {
+ PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS(PeiServices);
+
+ PrivateData->PpiData.NotifyListEnd = MAX_PPI_DESCRIPTORS-1;
+ PrivateData->PpiData.DispatchListEnd = MAX_PPI_DESCRIPTORS-1;
+ PrivateData->PpiData.LastDispatchedNotify = MAX_PPI_DESCRIPTORS-1;
+ }
+
+ return;
+}
+
+VOID
+ConvertPpiPointers (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_HOB_HANDOFF_INFO_TABLE *OldHandOffHob,
+ IN EFI_HOB_HANDOFF_INFO_TABLE *NewHandOffHob
+ )
+/*++
+
+Routine Description:
+
+ Convert PPI pointers after the Hob list was migrated from the CAR stack
+ to PEI installed memory.
+
+Arguments:
+
+ PeiServices - The PEI core services table.
+ OldHandOffHob - The old handoff HOB list.
+ NewHandOffHob - The new handoff HOB list.
+
+Returns:
+
+ None.
+
+--*/
+{
+ PEI_CORE_INSTANCE *PrivateData;
+ UINT8 Index;
+ PEI_PPI_LIST_POINTERS *PpiPointer;
+ UINTN Fixup;
+
+ PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS(PeiServices);
+
+ Fixup = (UINTN)NewHandOffHob - (UINTN)OldHandOffHob;
+
+ for (Index = 0; Index < MAX_PPI_DESCRIPTORS; Index++) {
+ if (Index < PrivateData->PpiData.PpiListEnd ||
+ Index > PrivateData->PpiData.NotifyListEnd) {
+ PpiPointer = &PrivateData->PpiData.PpiListPtrs[Index];
+
+ if (((UINTN)PpiPointer->Raw < (UINTN)OldHandOffHob->EfiFreeMemoryBottom) &&
+ ((UINTN)PpiPointer->Raw >= (UINTN)OldHandOffHob)) {
+ //
+ // Convert the pointer to the PEIM descriptor from the old HOB heap
+ // to the relocated HOB heap.
+ //
+ PpiPointer->Raw = (VOID *) ((UINTN)PpiPointer->Raw + Fixup);
+
+ //
+ // Only when the PEIM descriptor is in the old HOB should it be necessary
+ // to try to convert the pointers in the PEIM descriptor
+ //
+
+ if (((UINTN)PpiPointer->Ppi->Guid < (UINTN)OldHandOffHob->EfiFreeMemoryBottom) &&
+ ((UINTN)PpiPointer->Ppi->Guid >= (UINTN)OldHandOffHob)) {
+ //
+ // Convert the pointer to the GUID in the PPI or NOTIFY descriptor
+ // from the old HOB heap to the relocated HOB heap.
+ //
+ PpiPointer->Ppi->Guid = (VOID *) ((UINTN)PpiPointer->Ppi->Guid + Fixup);
+ }
+
+ //
+ // Assume that no code is located in the temporary memory, so the pointer to
+ // the notification function in the NOTIFY descriptor needs not be converted.
+ //
+ if (Index < PrivateData->PpiData.PpiListEnd &&
+ (UINTN)PpiPointer->Ppi->Ppi < (UINTN)OldHandOffHob->EfiFreeMemoryBottom &&
+ (UINTN)PpiPointer->Ppi->Ppi >= (UINTN)OldHandOffHob) {
+ //
+ // Convert the pointer to the PPI interface structure in the PPI descriptor
+ // from the old HOB heap to the relocated HOB heap.
+ //
+ PpiPointer->Ppi->Ppi = (VOID *) ((UINTN)PpiPointer->Ppi->Ppi+ Fixup);
+ }
+ }
+ }
+ }
+}
+
+
+EFI_STATUS
+EFIAPI
+PeiInstallPpi (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PEI_PPI_DESCRIPTOR *PpiList
+ )
+/*++
+
+Routine Description:
+
+ Install PPI services.
+
+Arguments:
+
+ PeiServices - Pointer to the PEI Service Table
+ PpiList - Pointer to a list of PEI PPI Descriptors.
+
+Returns:
+
+ EFI_SUCCESS - if all PPIs in PpiList are successfully installed.
+ EFI_INVALID_PARAMETER - if PpiList is NULL pointer
+ EFI_INVALID_PARAMETER - if any PPI in PpiList is not valid
+ EFI_OUT_OF_RESOURCES - if there is no more memory resource to install PPI
+
+--*/
+{
+ PEI_CORE_INSTANCE *PrivateData;
+ INTN Index;
+ INTN LastCallbackInstall;
+
+
+ if (PpiList == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS(PeiServices);
+
+ Index = PrivateData->PpiData.PpiListEnd;
+ LastCallbackInstall = Index;
+
+ //
+ // This is loop installs all PPI descriptors in the PpiList. It is terminated
+ // by the EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST being set in the last
+ // EFI_PEI_PPI_DESCRIPTOR in the list.
+ //
+
+ for (;;) {
+ //
+ // Since PpiData is used for NotifyList and InstallList, max resource
+ // is reached if the Install reaches the NotifyList
+ //
+ if (Index == PrivateData->PpiData.NotifyListEnd + 1) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ //
+ // Check if it is a valid PPI.
+ // If not, rollback list to exclude all in this list.
+ // Try to indicate which item failed.
+ //
+ if ((PpiList->Flags & EFI_PEI_PPI_DESCRIPTOR_PPI) == 0) {
+ PrivateData->PpiData.PpiListEnd = LastCallbackInstall;
+ PEI_DEBUG((PeiServices, EFI_D_INFO, "ERROR -> InstallPpi: %g %x\n", PpiList->Guid, PpiList->Ppi));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ PEI_DEBUG((PeiServices, EFI_D_INFO, "Install PPI: %g\n", PpiList->Guid));
+ PrivateData->PpiData.PpiListPtrs[Index].Ppi = PpiList;
+ PrivateData->PpiData.PpiListEnd++;
+
+ //
+ // Continue until the end of the PPI List.
+ //
+ if ((PpiList->Flags & EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) ==
+ EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) {
+ break;
+ }
+ PpiList++;
+ Index++;
+ }
+
+ //
+ // Dispatch any callback level notifies for newly installed PPIs.
+ //
+ DispatchNotify (
+ PeiServices,
+ EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK,
+ LastCallbackInstall,
+ PrivateData->PpiData.PpiListEnd,
+ PrivateData->PpiData.DispatchListEnd,
+ PrivateData->PpiData.NotifyListEnd
+ );
+
+
+ return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+EFIAPI
+PeiReInstallPpi (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PEI_PPI_DESCRIPTOR *OldPpi,
+ IN EFI_PEI_PPI_DESCRIPTOR *NewPpi
+ )
+/*++
+
+Routine Description:
+
+ Re-Install PPI services.
+
+Arguments:
+
+ PeiServices - Pointer to the PEI Service Table
+ OldPpi - Pointer to the old PEI PPI Descriptors.
+ NewPpi - Pointer to the new PEI PPI Descriptors.
+
+Returns:
+
+ EFI_SUCCESS - if the operation was successful
+ EFI_INVALID_PARAMETER - if OldPpi or NewPpi is NULL
+ EFI_INVALID_PARAMETER - if NewPpi is not valid
+ EFI_NOT_FOUND - if the PPI was not in the database
+
+--*/
+{
+ PEI_CORE_INSTANCE *PrivateData;
+ INTN Index;
+
+
+ if ((OldPpi == NULL) || (NewPpi == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((NewPpi->Flags & EFI_PEI_PPI_DESCRIPTOR_PPI) == 0) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS(PeiServices);
+
+ //
+ // Find the old PPI instance in the database. If we can not find it,
+ // return the EFI_NOT_FOUND error.
+ //
+ for (Index = 0; Index < PrivateData->PpiData.PpiListEnd; Index++) {
+ if (OldPpi == PrivateData->PpiData.PpiListPtrs[Index].Ppi) {
+ break;
+ }
+ }
+ if (Index == PrivateData->PpiData.PpiListEnd) {
+ return EFI_NOT_FOUND;
+ }
+
+ //
+ // Remove the old PPI from the database, add the new one.
+ //
+ PEI_DEBUG((PeiServices, EFI_D_INFO, "Reinstall PPI: %g\n", NewPpi->Guid));
+ PrivateData->PpiData.PpiListPtrs[Index].Ppi = NewPpi;
+
+ //
+ // Dispatch any callback level notifies for the newly installed PPI.
+ //
+ DispatchNotify (
+ PeiServices,
+ EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK,
+ Index,
+ Index+1,
+ PrivateData->PpiData.DispatchListEnd,
+ PrivateData->PpiData.NotifyListEnd
+ );
+
+
+ return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+EFIAPI
+PeiLocatePpi (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_GUID *Guid,
+ IN UINTN Instance,
+ IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor,
+ IN OUT VOID **Ppi
+ )
+/*++
+
+Routine Description:
+
+ Locate a given named PPI.
+
+Arguments:
+
+ PeiServices - Pointer to the PEI Service Table
+ Guid - Pointer to GUID of the PPI.
+ Instance - Instance Number to discover.
+ PpiDescriptor - Pointer to reference the found descriptor. If not NULL,
+ returns a pointer to the descriptor (includes flags, etc)
+ Ppi - Pointer to reference the found PPI
+
+Returns:
+
+ Status - EFI_SUCCESS if the PPI is in the database
+ EFI_NOT_FOUND if the PPI is not in the database
+--*/
+{
+ PEI_CORE_INSTANCE *PrivateData;
+ INTN Index;
+ EFI_GUID *CheckGuid;
+ EFI_PEI_PPI_DESCRIPTOR *TempPtr;
+
+
+ PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS(PeiServices);
+
+ //
+ // Search the data base for the matching instance of the GUIDed PPI.
+ //
+ for (Index = 0; Index < PrivateData->PpiData.PpiListEnd; Index++) {
+ TempPtr = PrivateData->PpiData.PpiListPtrs[Index].Ppi;
+ CheckGuid = TempPtr->Guid;
+
+ //
+ // Don't use CompareGuid function here for performance reasons.
+ // Instead we compare the GUID as INT32 at a time and branch
+ // on the first failed comparison.
+ //
+ if ((((INT32 *)Guid)[0] == ((INT32 *)CheckGuid)[0]) &&
+ (((INT32 *)Guid)[1] == ((INT32 *)CheckGuid)[1]) &&
+ (((INT32 *)Guid)[2] == ((INT32 *)CheckGuid)[2]) &&
+ (((INT32 *)Guid)[3] == ((INT32 *)CheckGuid)[3])) {
+ if (Instance == 0) {
+
+ if (PpiDescriptor != NULL) {
+ *PpiDescriptor = TempPtr;
+ }
+
+ if (Ppi != NULL) {
+ *Ppi = TempPtr->Ppi;
+ }
+
+
+ return EFI_SUCCESS;
+ }
+ Instance--;
+ }
+ }
+
+ return EFI_NOT_FOUND;
+}
+
+
+EFI_STATUS
+EFIAPI
+PeiNotifyPpi (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyList
+ )
+/*++
+
+Routine Description:
+
+ Install a notification for a given PPI.
+
+Arguments:
+
+ PeiServices - Pointer to the PEI Service Table
+ NotifyList - Pointer to list of Descriptors to notify upon.
+
+Returns:
+
+ Status - EFI_SUCCESS if successful
+ EFI_OUT_OF_RESOURCES if no space in the database
+ EFI_INVALID_PARAMETER if not a good decriptor
+
+--*/
+{
+ PEI_CORE_INSTANCE *PrivateData;
+ INTN Index;
+ INTN NotifyIndex;
+ INTN LastCallbackNotify;
+ EFI_PEI_NOTIFY_DESCRIPTOR *NotifyPtr;
+ UINTN NotifyDispatchCount;
+
+
+ NotifyDispatchCount = 0;
+
+ if (NotifyList == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS(PeiServices);
+
+ Index = PrivateData->PpiData.NotifyListEnd;
+ LastCallbackNotify = Index;
+
+ //
+ // This is loop installs all Notify descriptors in the NotifyList. It is
+ // terminated by the EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST being set in the last
+ // EFI_PEI_NOTIFY_DESCRIPTOR in the list.
+ //
+
+ for (;;) {
+ //
+ // Since PpiData is used for NotifyList and InstallList, max resource
+ // is reached if the Install reaches the PpiList
+ //
+ if (Index == PrivateData->PpiData.PpiListEnd - 1) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ //
+ // If some of the PPI data is invalid restore original Notify PPI database value
+ //
+ if ((NotifyList->Flags & EFI_PEI_PPI_DESCRIPTOR_NOTIFY_TYPES) == 0) {
+ PrivateData->PpiData.NotifyListEnd = LastCallbackNotify;
+ PEI_DEBUG((PeiServices, EFI_D_INFO, "ERROR -> InstallNotify: %g %x\n", NotifyList->Guid, NotifyList->Notify));
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((NotifyList->Flags & EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH) != 0) {
+ NotifyDispatchCount ++;
+ }
+
+ PrivateData->PpiData.PpiListPtrs[Index].Notify = NotifyList;
+
+ PrivateData->PpiData.NotifyListEnd--;
+ PEI_DEBUG((PeiServices, EFI_D_INFO, "Register PPI Notify: %g\n", NotifyList->Guid));
+ if ((NotifyList->Flags & EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) ==
+ EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST) {
+ break;
+ }
+ //
+ // Go the next descriptor. Remember the NotifyList moves down.
+ //
+ NotifyList++;
+ Index--;
+ }
+
+ //
+ // If there is Dispatch Notify PPI installed put them on the bottom
+ //
+ if (NotifyDispatchCount > 0) {
+ for (NotifyIndex = LastCallbackNotify; NotifyIndex > PrivateData->PpiData.NotifyListEnd; NotifyIndex--) {
+ if ((PrivateData->PpiData.PpiListPtrs[NotifyIndex].Notify->Flags & EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH) != 0) {
+ NotifyPtr = PrivateData->PpiData.PpiListPtrs[NotifyIndex].Notify;
+
+ for (Index = NotifyIndex; Index < PrivateData->PpiData.DispatchListEnd; Index++){
+ PrivateData->PpiData.PpiListPtrs[Index].Notify = PrivateData->PpiData.PpiListPtrs[Index + 1].Notify;
+ }
+ PrivateData->PpiData.PpiListPtrs[Index].Notify = NotifyPtr;
+ PrivateData->PpiData.DispatchListEnd--;
+ }
+ }
+
+ LastCallbackNotify -= NotifyDispatchCount;
+ }
+
+ //
+ // Dispatch any callback level notifies for all previously installed PPIs.
+ //
+ DispatchNotify (
+ PeiServices,
+ EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK,
+ 0,
+ PrivateData->PpiData.PpiListEnd,
+ LastCallbackNotify,
+ PrivateData->PpiData.NotifyListEnd
+ );
+
+
+ return EFI_SUCCESS;
+}
+
+
+VOID
+ProcessNotifyList (
+ IN EFI_PEI_SERVICES **PeiServices
+ )
+/*++
+
+Routine Description:
+
+ Process the Notify List at dispatch level.
+
+Arguments:
+
+ PeiServices - Pointer to the PEI Service Table
+
+Returns:
+
+--*/
+
+{
+ PEI_CORE_INSTANCE *PrivateData;
+ INTN TempValue;
+
+ PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS(PeiServices);
+
+
+ while (TRUE) {
+ //
+ // Check if the PEIM that was just dispatched resulted in any
+ // Notifies getting installed. If so, go process any dispatch
+ // level Notifies that match the previouly installed PPIs.
+ // Use "while" instead of "if" since DispatchNotify can modify
+ // DispatchListEnd (with NotifyPpi) so we have to iterate until the same.
+ //
+ while (PrivateData->PpiData.LastDispatchedNotify != PrivateData->PpiData.DispatchListEnd) {
+ TempValue = PrivateData->PpiData.DispatchListEnd;
+ DispatchNotify (
+ PeiServices,
+ EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH,
+ 0,
+ PrivateData->PpiData.LastDispatchedInstall,
+ PrivateData->PpiData.LastDispatchedNotify,
+ PrivateData->PpiData.DispatchListEnd
+ );
+ PrivateData->PpiData.LastDispatchedNotify = TempValue;
+ }
+
+
+ //
+ // Check if the PEIM that was just dispatched resulted in any
+ // PPIs getting installed. If so, go process any dispatch
+ // level Notifies that match the installed PPIs.
+ // Use "while" instead of "if" since DispatchNotify can modify
+ // PpiListEnd (with InstallPpi) so we have to iterate until the same.
+ //
+ while (PrivateData->PpiData.LastDispatchedInstall != PrivateData->PpiData.PpiListEnd) {
+ TempValue = PrivateData->PpiData.PpiListEnd;
+ DispatchNotify (
+ PeiServices,
+ EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH,
+ PrivateData->PpiData.LastDispatchedInstall,
+ PrivateData->PpiData.PpiListEnd,
+ MAX_PPI_DESCRIPTORS-1,
+ PrivateData->PpiData.DispatchListEnd
+ );
+ PrivateData->PpiData.LastDispatchedInstall = TempValue;
+ }
+
+ if (PrivateData->PpiData.LastDispatchedNotify == PrivateData->PpiData.DispatchListEnd) {
+ break;
+ }
+ }
+ return;
+}
+
+VOID
+DispatchNotify (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN UINTN NotifyType,
+ IN INTN InstallStartIndex,
+ IN INTN InstallStopIndex,
+ IN INTN NotifyStartIndex,
+ IN INTN NotifyStopIndex
+ )
+/*++
+
+Routine Description:
+
+ Dispatch notifications.
+
+Arguments:
+
+ PeiServices - Pointer to the PEI Service Table
+ NotifyType - Type of notify to fire.
+ InstallStartIndex - Install Beginning index.
+ InstallStopIndex - Install Ending index.
+ NotifyStartIndex - Notify Beginning index.
+ NotifyStopIndex - Notify Ending index.
+
+Returns: None
+
+--*/
+
+{
+ PEI_CORE_INSTANCE *PrivateData;
+ INTN Index1;
+ INTN Index2;
+ EFI_GUID *SearchGuid;
+ EFI_GUID *CheckGuid;
+ EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor;
+
+ PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS(PeiServices);
+
+ //
+ // Remember that Installs moves up and Notifies moves down.
+ //
+ for (Index1 = NotifyStartIndex; Index1 > NotifyStopIndex; Index1--) {
+ NotifyDescriptor = PrivateData->PpiData.PpiListPtrs[Index1].Notify;
+
+ CheckGuid = NotifyDescriptor->Guid;
+
+ for (Index2 = InstallStartIndex; Index2 < InstallStopIndex; Index2++) {
+ SearchGuid = PrivateData->PpiData.PpiListPtrs[Index2].Ppi->Guid;
+ //
+ // Don't use CompareGuid function here for performance reasons.
+ // Instead we compare the GUID as INT32 at a time and branch
+ // on the first failed comparison.
+ //
+ if ((((INT32 *)SearchGuid)[0] == ((INT32 *)CheckGuid)[0]) &&
+ (((INT32 *)SearchGuid)[1] == ((INT32 *)CheckGuid)[1]) &&
+ (((INT32 *)SearchGuid)[2] == ((INT32 *)CheckGuid)[2]) &&
+ (((INT32 *)SearchGuid)[3] == ((INT32 *)CheckGuid)[3])) {
+ PEI_DEBUG (
+ (
+ PeiServices,
+ EFI_D_INFO,
+ "Notify: PPI Guid: %g, Peim notify entry point: %x\n",
+ SearchGuid,
+ NotifyDescriptor->Notify
+ )
+ );
+ NotifyDescriptor->Notify (
+ PeiServices,
+ NotifyDescriptor,
+ (PrivateData->PpiData.PpiListPtrs[Index2].Ppi)->Ppi
+ );
+ }
+ }
+ }
+
+ return;
+}
+
diff --git a/EDK/Foundation/Core/Pei/Reset/Reset.c b/EDK/Foundation/Core/Pei/Reset/Reset.c
new file mode 100644
index 0000000..8cb752c
--- /dev/null
+++ b/EDK/Foundation/Core/Pei/Reset/Reset.c
@@ -0,0 +1,73 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Reset.c
+
+Abstract:
+
+ Pei Core Reset System Support
+
+Revision History
+
+--*/
+
+#include "Tiano.h"
+#include "PeiCore.h"
+#include "PeiLib.h"
+
+#include EFI_PPI_DEFINITION (Reset)
+
+EFI_STATUS
+EFIAPI
+PeiCoreResetSystem (
+ IN EFI_PEI_SERVICES **PeiServices
+ )
+/*++
+
+Routine Description:
+
+ Core version of the Reset System
+
+Arguments:
+
+ PeiServices - The PEI core services table.
+
+Returns:
+
+ Status - EFI_NOT_AVAILABLE_YET. PPI not available yet.
+ - EFI_DEVICE_ERROR. Did not reset system.
+
+ Otherwise, resets the system.
+
+--*/
+{
+ EFI_STATUS Status;
+ PEI_RESET_PPI *ResetPpi;
+
+ Status = PeiLocatePpi (
+ PeiServices,
+ &gPeiResetPpiGuid,
+ 0,
+ NULL,
+ &ResetPpi
+ );
+
+ //
+ // LocatePpi returns EFI_NOT_FOUND on error
+ //
+ if (!EFI_ERROR (Status)) {
+ return ResetPpi->ResetSystem (PeiServices);
+ }
+ return EFI_NOT_AVAILABLE_YET;
+}
+
diff --git a/EDK/Foundation/Core/Pei/Security/Security.c b/EDK/Foundation/Core/Pei/Security/Security.c
new file mode 100644
index 0000000..928e21a
--- /dev/null
+++ b/EDK/Foundation/Core/Pei/Security/Security.c
@@ -0,0 +1,194 @@
+/*++
+
+Copyright (c) 2004 - 2005, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Security.c
+
+Abstract:
+
+ EFI PEI Core Security services
+
+--*/
+
+#include "Tiano.h"
+#include "PeiCore.h"
+#include EFI_PPI_DEFINITION (Security)
+
+EFI_STATUS
+EFIAPI
+SecurityPpiNotifyCallback (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,
+ IN VOID *Ppi
+ );
+
+static EFI_PEI_NOTIFY_DESCRIPTOR mNotifyList = {
+ EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST,
+ &gPeiSecurityPpiGuid,
+ SecurityPpiNotifyCallback
+};
+
+VOID
+InitializeSecurityServices (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_CORE_INSTANCE *OldCoreData
+ )
+/*++
+
+Routine Description:
+
+ Initialize the security services.
+
+Arguments:
+
+ PeiServices - The PEI core services table.
+ OldCoreData - Pointer to the old core data.
+ NULL if being run in non-permament memory mode.
+Returns:
+
+ None
+
+--*/
+{
+ if (OldCoreData == NULL) {
+ PeiNotifyPpi (PeiServices, &mNotifyList);
+ }
+ return;
+}
+
+EFI_STATUS
+EFIAPI
+SecurityPpiNotifyCallback (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,
+ IN VOID *Ppi
+ )
+/*++
+
+Routine Description:
+
+ Provide a callback for when the security PPI is installed.
+
+Arguments:
+
+ PeiServices - The PEI core services table.
+ NotifyDescriptor - The descriptor for the notification event.
+ Ppi - Pointer to the PPI in question.
+
+Returns:
+
+ EFI_SUCCESS - The function is successfully processed.
+
+--*/
+{
+ PEI_CORE_INSTANCE *PrivateData;
+
+ //
+ // Get PEI Core private data
+ //
+ PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS (PeiServices);
+
+ //
+ // If there isn't a security PPI installed, use the one from notification
+ //
+ if (PrivateData->PrivateSecurityPpi == NULL) {
+ PrivateData->PrivateSecurityPpi = (PEI_SECURITY_PPI *)Ppi;
+ }
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+VerifyPeim (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_FFS_FILE_HEADER *CurrentPeimAddress
+ )
+/*++
+
+Routine Description:
+
+ Provide a callout to the security verification service.
+
+Arguments:
+
+ PeiServices - The PEI core services table.
+ CurrentPeimAddress - Pointer to the Firmware File under investigation.
+
+Returns:
+
+ EFI_SUCCESS - Image is OK
+ EFI_SECURITY_VIOLATION - Image is illegal
+
+--*/
+{
+ PEI_CORE_INSTANCE *PrivateData;
+ EFI_STATUS Status;
+ UINT32 AuthenticationStatus;
+ BOOLEAN StartCrisisRecovery;
+
+ //
+ // Set a default authentication state
+ //
+ AuthenticationStatus = 0;
+
+ //
+ // get security PPI instance from PEI private data
+ //
+ PrivateData = PEI_CORE_INSTANCE_FROM_PS_THIS (PeiServices);
+
+ if (PrivateData->PrivateSecurityPpi == NULL) {
+ Status = EFI_NOT_FOUND;
+ } else {
+ //
+ // Check to see if the image is OK
+ //
+ Status = PrivateData->PrivateSecurityPpi->AuthenticationState (
+ PeiServices,
+ PrivateData->PrivateSecurityPpi,
+ AuthenticationStatus,
+ CurrentPeimAddress,
+ &StartCrisisRecovery
+ );
+ if (StartCrisisRecovery) {
+ Status = EFI_SECURITY_VIOLATION;
+ }
+ }
+ return Status;
+}
+
+
+EFI_STATUS
+VerifyFv (
+ IN EFI_FIRMWARE_VOLUME_HEADER *CurrentFvAddress
+ )
+/*++
+
+Routine Description:
+
+ Verify a Firmware volume
+
+Arguments:
+
+ CurrentFvAddress - Pointer to the current Firmware Volume under consideration
+
+Returns:
+
+ EFI_SUCCESS - Firmware Volume is legal
+ EFI_SECURITY_VIOLATION - Firmware Volume fails integrity test
+
+--*/
+{
+ //
+ // Right now just pass the test. Future can authenticate and/or check the
+ // FV-header or other metric for goodness of binary.
+ //
+ return EFI_SUCCESS;
+}
diff --git a/EDK/Foundation/Core/Pei/StatusCode/StatusCode.c b/EDK/Foundation/Core/Pei/StatusCode/StatusCode.c
new file mode 100644
index 0000000..26cac94
--- /dev/null
+++ b/EDK/Foundation/Core/Pei/StatusCode/StatusCode.c
@@ -0,0 +1,102 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ StatusCode.c
+
+Abstract:
+
+ Pei Core Status Code Support
+
+Revision History
+
+--*/
+
+#include "Tiano.h"
+#include "PeiCore.h"
+#include "PeiLib.h"
+
+#include EFI_PPI_DEFINITION (StatusCode)
+
+EFI_STATUS
+EFIAPI
+PeiReportStatusCode (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_STATUS_CODE_TYPE CodeType,
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN UINT32 Instance,
+ IN EFI_GUID *CallerId,
+ IN EFI_STATUS_CODE_DATA *Data OPTIONAL
+ )
+/*++
+
+Routine Description:
+
+ Core version of the Status Code reporter
+
+Arguments:
+
+ PeiServices - The PEI core services table.
+
+ CodeType - Type of Status Code.
+
+ Value - Value to output for Status Code.
+
+ Instance - Instance Number of this status code.
+
+ CallerId - ID of the caller of this status code.
+
+ Data - Optional data associated with this status code.
+
+Returns:
+
+ Status - EFI_SUCCESS if status code is successfully reported
+ - EFI_NOT_AVAILABLE_YET if StatusCodePpi has not been installed
+
+--*/
+{
+ EFI_STATUS Status;
+ PEI_STATUS_CODE_PPI *StatusCodePpi;
+
+
+ //
+ //Locate StatusCode Ppi.
+ //
+ Status = PeiLocatePpi (
+ PeiServices,
+ &gPeiStatusCodePpiGuid,
+ 0,
+ NULL,
+ &StatusCodePpi
+ );
+
+ if (!EFI_ERROR (Status)) {
+ Status = StatusCodePpi->ReportStatusCode (
+ PeiServices,
+ CodeType,
+ Value,
+ Instance,
+ CallerId,
+ Data
+ );
+
+
+ return Status;
+
+ }
+
+
+ return EFI_NOT_AVAILABLE_YET;
+}
+
+
+
diff --git a/EDK/Foundation/Cpu/Itanium/CpuIa64Lib.cif b/EDK/Foundation/Cpu/Itanium/CpuIa64Lib.cif
new file mode 100644
index 0000000..faea658
--- /dev/null
+++ b/EDK/Foundation/Cpu/Itanium/CpuIa64Lib.cif
@@ -0,0 +1,12 @@
+<component>
+ name = "CpuIa64Lib"
+ category = ModulePart
+ LocalRoot = "EDK\Foundation\Cpu\Itanium\"
+ RefName = "CpuIa64Lib"
+[files]
+"CpuIa64Lib.sdl"
+"CpuIa64Lib.mak"
+"Include\CpuIa64.h"
+"CpuIa64Lib\IPF\CpuIa64.s"
+"CpuIa64Lib\CpuIA64Lib.inf"
+<endComponent>
diff --git a/EDK/Foundation/Cpu/Itanium/CpuIa64Lib.mak b/EDK/Foundation/Cpu/Itanium/CpuIa64Lib.mak
new file mode 100644
index 0000000..9519e7c
--- /dev/null
+++ b/EDK/Foundation/Cpu/Itanium/CpuIa64Lib.mak
@@ -0,0 +1,71 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/CpuIa64Lib/CpuIa64Lib.mak 1 1/20/12 4:00a Jeffch $
+#
+# $Revision: 1 $
+#
+# $Date: 1/20/12 4:00a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/CpuIa64Lib/CpuIa64Lib.mak $
+#
+# 1 1/20/12 4:00a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 9/27/11 6:23a Wesleychen
+# Intel EDK initially releases.
+#
+# 2 9/02/09 3:08a Iminglin
+# EIP24919
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: CpuIa64Lib.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+!IF "$(PROCESSOR)"=="IPF"
+$(CPUIA64LIB) : CpuIa64Lib
+
+$(BUILD_DIR)\CpuIa64Lib.lib : CpuIa64Lib
+
+CpuIa64Lib : $(BUILD_DIR)\CpuIa64Lib.mak CpuIa64LibBin
+
+$(BUILD_DIR)\CpuIa64Lib.mak : $(CpuIa64Lib_DIR)\$(@B).cif $(CpuIa64Lib_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(CpuIa64Lib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+CpuIa64LibBin :
+ $(MAKE) /$(MAKEFLAGS) $(EDK_DEFAULTS)\
+ /f $(BUILD_DIR)\CpuIa64Lib.mak all\
+ TYPE=LIBRARY
+!ENDIF
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#********************************************************************** \ No newline at end of file
diff --git a/EDK/Foundation/Cpu/Itanium/CpuIa64Lib.sdl b/EDK/Foundation/Cpu/Itanium/CpuIa64Lib.sdl
new file mode 100644
index 0000000..4acc255
--- /dev/null
+++ b/EDK/Foundation/Cpu/Itanium/CpuIa64Lib.sdl
@@ -0,0 +1,25 @@
+TOKEN
+ Name = CpuIa64Lib_SUPPORT
+ Value = 1
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+ Help = "Main switch to enable CpuIa64Lib support in Project"
+End
+
+TOKEN
+ Name = "CPUIA64LIB"
+ Value = "$(BUILD_DIR)\CpuIA64Lib.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "CpuIa64Lib_DIR"
+End
+
+MODULE
+ Help = "Includes CpuIa64Lib.mak to Project"
+ File = "CpuIa64Lib.mak"
+End
diff --git a/EDK/Foundation/Cpu/Itanium/CpuIa64Lib/CpuIA64Lib.inf b/EDK/Foundation/Cpu/Itanium/CpuIa64Lib/CpuIA64Lib.inf
new file mode 100644
index 0000000..79cc2f7
--- /dev/null
+++ b/EDK/Foundation/Cpu/Itanium/CpuIa64Lib/CpuIA64Lib.inf
@@ -0,0 +1,38 @@
+#/*++
+#
+# Copyright (c) 2004 - 2005, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# CpuIA64Lib.inf
+#
+# Abstract:
+#
+# Component description file for the Cpu IA64 library.
+#
+#--*/
+
+[defines]
+BASE_NAME = CpuIA64Lib
+COMPONENT_TYPE = LIBRARY
+
+[sources.common]
+
+[sources.ipf]
+ Ipf\CpuIA64.s
+
+[includes.common]
+ $(EDK_SOURCE)\Foundation\Efi
+ .
+ $(EDK_SOURCE)\Foundation\Cpu\Itanium\Include
+ $(EDK_SOURCE)\Foundation\include
+
+[nmake.common]
+ C_STD_INCLUDE=
diff --git a/EDK/Foundation/Cpu/Itanium/CpuIa64Lib/IPF/CpuIa64.s b/EDK/Foundation/Cpu/Itanium/CpuIa64Lib/IPF/CpuIa64.s
new file mode 100644
index 0000000..1827daa
--- /dev/null
+++ b/EDK/Foundation/Cpu/Itanium/CpuIa64Lib/IPF/CpuIa64.s
@@ -0,0 +1,33 @@
+//****************************************************************************
+//
+// Copyright (c) 2004, Intel Corporation
+// All rights reserved. This program and the accompanying materials
+// are licensed and made available under the terms and conditions of the BSD License
+// which accompanies this distribution. The full text of the license may be found at
+// http://opensource.org/licenses/bsd-license.php
+//
+// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+//
+// Module Name:
+//
+// CpuIA64.s
+//
+// Abstract:
+//
+// Contains basic assembly procedures to support IPF CPU.
+//
+//****************************************************************************
+
+.file "CpuIA64.s"
+
+#include "IpfMacro.i"
+#include "IpfDefines.h"
+
+
+PROCEDURE_ENTRY (EfiReadTsc)
+
+ mov r8 = ar.itc
+ br.ret.dpnt b0;;
+
+PROCEDURE_EXIT (EfiReadTsc) \ No newline at end of file
diff --git a/EDK/Foundation/Cpu/Itanium/Include/CpuIa64.h b/EDK/Foundation/Cpu/Itanium/Include/CpuIa64.h
new file mode 100644
index 0000000..f491e3f
--- /dev/null
+++ b/EDK/Foundation/Cpu/Itanium/Include/CpuIa64.h
@@ -0,0 +1,39 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ CpuIA64.h
+
+Abstract:
+
+--*/
+
+#ifndef _CPU_IA64_H
+#define _CPU_IA64_H
+
+#include "Tiano.h"
+
+UINT64
+EfiReadTsc (
+ VOID
+ )
+/*++
+Routine Description:
+ Read Time stamp
+Arguments:
+ None
+Returns:
+ Return the read data
+--*/
+;
+
+#endif
diff --git a/EDK/Foundation/Cpu/Pentium/CpuIA32Lib.cif b/EDK/Foundation/Cpu/Pentium/CpuIA32Lib.cif
new file mode 100644
index 0000000..dacee8d
--- /dev/null
+++ b/EDK/Foundation/Cpu/Pentium/CpuIA32Lib.cif
@@ -0,0 +1,15 @@
+<component>
+ name = "CpuIA32Lib"
+ category = ModulePart
+ LocalRoot = "EDK\Foundation\Cpu\Pentium\"
+ RefName = "CpuIA32Lib"
+[files]
+"CpuIA32Lib.sdl"
+"CpuIA32Lib.mak"
+"Include\CpuIA32.h"
+"CpuIA32Lib\EfiCpuVersion.c"
+"CpuIA32Lib\x64\Cpu.asm"
+"CpuIA32Lib\CpuIA32Lib.inf"
+"CpuIA32Lib\IA32\CpuIA32.asm"
+"CpuIA32Lib\IA32\IA32Type.inc"
+<endComponent>
diff --git a/EDK/Foundation/Cpu/Pentium/CpuIA32Lib.mak b/EDK/Foundation/Cpu/Pentium/CpuIA32Lib.mak
new file mode 100644
index 0000000..e9e688d
--- /dev/null
+++ b/EDK/Foundation/Cpu/Pentium/CpuIA32Lib.mak
@@ -0,0 +1,102 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/CpuIA32Lib/CpuIA32Lib.mak 1 1/20/12 4:00a Jeffch $
+#
+# $Revision: 1 $
+#
+# $Date: 1/20/12 4:00a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/CpuIA32Lib/CpuIA32Lib.mak $
+#
+# 1 1/20/12 4:00a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 9/27/11 6:22a Wesleychen
+# Intel EDK initially releases.
+#
+# 3 4/29/11 2:30a Iminglin
+# [TAG] EIP59360
+# [Category] Improvement
+# [Description] EDK- link error:unresolved external EfiCpuVersion
+# When a driver uses the function EfiCpuVersion, below link error will
+# happen.
+#
+# error LNK2001: unresolved external symbol EfiCpuVersion
+#
+# [Files] CpuIA32Lib.mak
+#
+# 2 9/02/09 3:10a Iminglin
+# EIP24919
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: CpuIA32Lib.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+
+$(CPUIA32LIB) : CpuIA32Lib
+
+!IF "$(PROCESSOR)"=="IA32"
+CpuIA32Lib_OBJECTS=\
+$$(BUILD_DIR)\$(CpuIA32Lib_DIR)\CpuIA32Lib\IA32\CpuIA32.obj
+!ELSEIF "$(PROCESSOR)"=="x64"
+CpuIA32Lib_OBJECTS_DXE=\
+$$(BUILD_DIR)\$(CpuIA32Lib_DIR)\CpuIA32Lib\x64\Cpu.obj\
+$$(BUILD_DIR)\$(CpuIA32Lib_DIR)\CpuIA32Lib\EfiCpuVersion.obj
+CpuIA32Lib_OBJECTS_PEI=\
+$$(BUILD_DIR)\$(CpuIA32Lib_DIR)\CpuIA32Lib\IA32\CpuIA32.obj
+!ENDIF
+
+CpuIA32Lib : $(BUILD_DIR)\CpuIA32Lib.mak CpuIA32LibBin
+
+$(BUILD_DIR)\CpuIA32Lib.mak : $(CpuIA32Lib_DIR)\$(@B).cif $(CpuIA32Lib_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(CpuIA32Lib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+CpuIA32LibBin :
+!IF "$(PROCESSOR)"=="x64"
+ $(MAKE) /$(MAKEFLAGS) $(EDK_DEFAULTS)\
+ /f $(BUILD_DIR)\CpuIA32Lib.mak all\
+ TYPE=LIBRARY\
+ "OBJECTS=$(CpuIA32Lib_OBJECTS_DXE)"
+ $(MAKE) /$(MAKEFLAGS) $(EDK_DEFAULTS) BUILD_DIR=$(BUILD_DIR)\IA32\
+ /f $(BUILD_DIR)\CpuIA32Lib.mak all\
+ TYPE=PEI_LIBRARY\
+ "OBJECTS=$(CpuIA32Lib_OBJECTS_PEI)"
+!ELSE
+ $(MAKE) /$(MAKEFLAGS) $(EDK_DEFAULTS)\
+ /f $(BUILD_DIR)\CpuIA32Lib.mak all\
+ TYPE=LIBRARY\
+ "OBJECTS=$(CpuIA32Lib_OBJECTS)"
+!ENDIF
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#********************************************************************** \ No newline at end of file
diff --git a/EDK/Foundation/Cpu/Pentium/CpuIA32Lib.sdl b/EDK/Foundation/Cpu/Pentium/CpuIA32Lib.sdl
new file mode 100644
index 0000000..fdab18f
--- /dev/null
+++ b/EDK/Foundation/Cpu/Pentium/CpuIA32Lib.sdl
@@ -0,0 +1,26 @@
+TOKEN
+ Name = "CpuIA32Lib_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable CpuIA32Lib support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "CPUIA32LIB"
+ Value = "$$(LIB_BUILD_DIR)\CpuIA32Lib.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "CpuIA32Lib_DIR"
+End
+
+MODULE
+ Help = "Includes CpuIA32Lib.mak to Project"
+ File = "CpuIA32Lib.mak"
+End
+
diff --git a/EDK/Foundation/Cpu/Pentium/CpuIA32Lib/CpuIA32Lib.inf b/EDK/Foundation/Cpu/Pentium/CpuIA32Lib/CpuIA32Lib.inf
new file mode 100644
index 0000000..7362aab
--- /dev/null
+++ b/EDK/Foundation/Cpu/Pentium/CpuIA32Lib/CpuIA32Lib.inf
@@ -0,0 +1,43 @@
+#/*++
+#
+# Copyright (c) 2004 - 2005, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# CpuIA32Lib.inf
+#
+# Abstract:
+#
+# Component description file for the Cpu IA32 library.
+#
+#--*/
+
+[defines]
+BASE_NAME = CpuIA32Lib
+COMPONENT_TYPE = LIBRARY
+
+[sources.common]
+ EfiCpuVersion.c
+
+[sources.ia32]
+ Ia32\CpuIA32.asm
+
+[sources.x64]
+ x64\Cpu.asm
+[includes.common]
+ $(EDK_SOURCE)\Foundation\Efi
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ .
+ $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include
+ $(EDK_SOURCE)\Foundation\Include
+
+[nmake.common]
+ C_STD_INCLUDE=
diff --git a/EDK/Foundation/Cpu/Pentium/CpuIA32Lib/EfiCpuVersion.c b/EDK/Foundation/Cpu/Pentium/CpuIA32Lib/EfiCpuVersion.c
new file mode 100644
index 0000000..eea033b
--- /dev/null
+++ b/EDK/Foundation/Cpu/Pentium/CpuIA32Lib/EfiCpuVersion.c
@@ -0,0 +1,73 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiCpuVersion.c
+
+Abstract:
+
+ Provide cpu version extract considering extended family & model ID.
+--*/
+
+#include "CpuIA32.h"
+
+VOID
+EfiCpuVersion (
+ IN OUT UINT16 *FamilyId, OPTIONAL
+ IN OUT UINT8 *Model, OPTIONAL
+ IN OUT UINT8 *SteppingId, OPTIONAL
+ IN OUT UINT8 *Processor OPTIONAL
+ )
+/*++
+
+Routine Description:
+ Extract CPU detail version infomation
+
+Arguments:
+ FamilyId - FamilyId, including ExtendedFamilyId
+ Model - Model, including ExtendedModel
+ SteppingId - SteppingId
+ Processor - Processor
+
+--*/
+{
+ EFI_CPUID_REGISTER Register;
+ UINT8 TempFamilyId;
+
+ EfiCpuid (EFI_CPUID_VERSION_INFO, &Register);
+
+ if (SteppingId != NULL) {
+ *SteppingId = (UINT8) (Register.RegEax & 0xF);
+ }
+
+ if (Processor != NULL) {
+ *Processor = (UINT8) ((Register.RegEax >> 12) & 0x3);
+ }
+
+ if (Model != NULL || FamilyId != NULL) {
+ TempFamilyId = (UINT8) ((Register.RegEax >> 8) & 0xF);
+
+ if (Model != NULL) {
+ *Model = (UINT8) ((Register.RegEax >> 4) & 0xF);
+ if (TempFamilyId == 0x6 || TempFamilyId == 0xF) {
+ *Model |= (Register.RegEax >> 12) & 0xF0;
+ }
+ }
+
+ if (FamilyId != NULL) {
+ *FamilyId = TempFamilyId;
+ if (TempFamilyId == 0xF) {
+ *FamilyId = *FamilyId + (UINT16) ((Register.RegEax >> 20) & 0xFF);
+ }
+ }
+ }
+}
diff --git a/EDK/Foundation/Cpu/Pentium/CpuIA32Lib/IA32/CpuIA32.asm b/EDK/Foundation/Cpu/Pentium/CpuIA32Lib/IA32/CpuIA32.asm
new file mode 100644
index 0000000..2a64c66
--- /dev/null
+++ b/EDK/Foundation/Cpu/Pentium/CpuIA32Lib/IA32/CpuIA32.asm
@@ -0,0 +1,234 @@
+TITLE CpuIA32.asm: Assembly code for the IA-32 resources
+
+;*****************************************************************************
+;*
+;* Copyright (c) 2004 - 2006, Intel Corporation
+;* All rights reserved. This program and the accompanying materials
+;* are licensed and made available under the terms and conditions of the BSD License
+;* which accompanies this distribution. The full text of the license may be found at
+;* http://opensource.org/licenses/bsd-license.php
+;*
+;* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+;* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;*
+;* Module Name:
+;*
+;* CpuIA32.asm
+;*
+;* Abstract:
+;*
+;*****************************************************************************
+
+
+ .686P
+ .MODEL FLAT,C
+ .CODE
+
+ INCLUDE IA32Type.inc
+
+
+
+;------------------------------------------------------------------------------
+; VOID
+; EfiHalt (
+; VOID
+; )
+;------------------------------------------------------------------------------
+EfiHalt PROC PUBLIC
+ hlt
+ ret
+EfiHalt ENDP
+
+
+;------------------------------------------------------------------------------
+; VOID
+; EfiWbinvd (
+; VOID
+; )
+;------------------------------------------------------------------------------
+EfiWbinvd PROC PUBLIC
+ wbinvd
+ ret
+EfiWbinvd ENDP
+
+
+;------------------------------------------------------------------------------
+; VOID
+; EfiInvd (
+; VOID
+; )
+;------------------------------------------------------------------------------
+EfiInvd PROC PUBLIC
+ invd
+ ret
+EfiInvd ENDP
+
+;------------------------------------------------------------------------------
+; VOID
+; EfiCpuid (
+; IN UINT32 RegisterInEax,
+; OUT EFI_CPUID_REGISTER *Reg OPTIONAL
+; )
+;------------------------------------------------------------------------------
+EfiCpuid PROC PUBLIC RegisterInEax:UINT32, Reg:PTR EFI_CPUID_REGISTER
+ pushad
+
+ mov eax, RegisterInEax
+ cpuid
+ cmp Reg, 0
+ je _Exit
+ mov edi, DWORD PTR Reg
+ ASSUME edi: PTR EFI_CPUID_REGISTER
+ mov DWORD PTR [edi].RegEax, eax ; Reg->RegEax
+ mov DWORD PTR [edi].RegEbx, ebx ; Reg->RegEbx
+ mov DWORD PTR [edi].RegEcx, ecx ; Reg->RegEcx
+ mov DWORD PTR [edi].RegEdx, edx ; Reg->RegEdx
+
+_Exit:
+ popad
+ ret
+EfiCpuid ENDP
+
+;------------------------------------------------------------------------------
+; UINT64
+; EfiReadMsr (
+; IN UINT32 Index,
+; )
+;------------------------------------------------------------------------------
+EfiReadMsr PROC PUBLIC Index:UINT32
+ push ecx
+ mov ecx, Index
+ rdmsr
+ pop ecx
+ ret
+EfiReadMsr ENDP
+
+;------------------------------------------------------------------------------
+; VOID
+; EfiWriteMsr (
+; IN UINT32 Index,
+; IN UINT64 Value
+; )
+;------------------------------------------------------------------------------
+EfiWriteMsr PROC PUBLIC Index:UINT32, Value:UINT64
+ pushad
+ mov ecx, Index
+ mov eax, DWORD PTR Value[0]
+ mov edx, DWORD PTR Value[4]
+ wrmsr
+ popad
+ ret
+EfiWriteMsr ENDP
+
+
+;------------------------------------------------------------------------------
+; UINT64
+; EfiReadTsc (
+; VOID
+; );
+;------------------------------------------------------------------------------
+EfiReadTsc PROC PUBLIC
+ rdtsc
+ ret
+EfiReadTsc ENDP
+
+;------------------------------------------------------------------------------
+; VOID
+; EfiDisableCache (
+; VOID
+; );
+;------------------------------------------------------------------------------
+EfiDisableCache PROC PUBLIC
+; added a check to see if cache is already disabled. If it is, then skip.
+ push eax
+ mov eax, cr0
+ bswap eax
+ and al, 60h
+ cmp al, 60h
+ je @f
+ wbinvd
+ mov eax, cr0
+ or eax, 060000000h
+ mov cr0, eax
+@@:
+ pop eax
+ ret
+EfiDisableCache ENDP
+
+;------------------------------------------------------------------------------
+; VOID
+; EfiEnableCache (
+; VOID
+; );
+;------------------------------------------------------------------------------
+EfiEnableCache PROC PUBLIC
+ push eax
+ wbinvd
+ mov eax, cr0
+ and eax, 09fffffffh
+ mov cr0, eax
+ pop eax
+ ret
+EfiEnableCache ENDP
+
+;------------------------------------------------------------------------------
+; UINT32
+; EfiGetEflags (
+; VOID
+; );
+;------------------------------------------------------------------------------
+EfiGetEflags PROC PUBLIC
+ pushfd
+ pop eax
+ ret
+EfiGetEflags ENDP
+
+;------------------------------------------------------------------------------
+; VOID
+; EfiDisableInterrupts (
+; VOID
+; );
+;------------------------------------------------------------------------------
+EfiDisableInterrupts PROC PUBLIC
+ cli
+ ret
+EfiDisableInterrupts ENDP
+
+;------------------------------------------------------------------------------
+; VOID
+; EfiEnableInterrupts (
+; VOID
+; );
+;------------------------------------------------------------------------------
+EfiEnableInterrupts PROC PUBLIC
+ sti
+ ret
+EfiEnableInterrupts ENDP
+;------------------------------------------------------------------------------
+; VOID
+; EfiCpuidExt (
+; IN UINT32 RegisterInEax,
+; IN UINT32 CacheLevel,
+; OUT EFI_CPUID_REGISTER *Regs
+; )
+;------------------------------------------------------------------------------
+EfiCpuidExt PROC PUBLIC \
+ RegisterInEax:UINT32, \
+ CacheLevel:UINT32, \
+ Regs:PTR EFI_CPUID_REGISTER
+ pushad
+
+ mov eax, RegisterInEax
+ mov ecx, CacheLevel
+ cpuid
+ mov edi, DWORD PTR Regs
+ ASSUME edi: PTR EFI_CPUID_REGISTER
+ mov DWORD PTR [edi].RegEax, eax ; Reg->RegEax
+ mov DWORD PTR [edi].RegEbx, ebx ; Reg->RegEbx
+ mov DWORD PTR [edi].RegEcx, ecx ; Reg->RegEcx
+ mov DWORD PTR [edi].RegEdx, edx ; Reg->RegEdx
+
+ popad
+ ret
+EfiCpuidExt ENDP
+END
diff --git a/EDK/Foundation/Cpu/Pentium/CpuIA32Lib/IA32/IA32Type.inc b/EDK/Foundation/Cpu/Pentium/CpuIA32Lib/IA32/IA32Type.inc
new file mode 100644
index 0000000..069656e
--- /dev/null
+++ b/EDK/Foundation/Cpu/Pentium/CpuIA32Lib/IA32/IA32Type.inc
@@ -0,0 +1,34 @@
+;
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; IA32Type.inc
+;
+
+UINT8 TYPEDEF BYTE
+UINT16 TYPEDEF WORD
+UINT32 TYPEDEF DWORD
+UINT64 TYPEDEF QWORD
+UINTN TYPEDEF UINT32
+BOOLEAN TYPEDEF UINT8
+EFI_STATUS TYPEDEF UINTN
+
+EFI_PHYSICAL_ADDRESS TYPEDEF UINT64
+
+
+@EFI_CPUID_REGISTER STRUCT 4t
+RegEax DWORD ?
+RegEbx DWORD ?
+RegEcx DWORD ?
+RegEdx DWORD ?
+@EFI_CPUID_REGISTER ENDS
+
+EFI_CPUID_REGISTER TYPEDEF @EFI_CPUID_REGISTER
diff --git a/EDK/Foundation/Cpu/Pentium/CpuIA32Lib/x64/Cpu.asm b/EDK/Foundation/Cpu/Pentium/CpuIA32Lib/x64/Cpu.asm
new file mode 100644
index 0000000..52cab40
--- /dev/null
+++ b/EDK/Foundation/Cpu/Pentium/CpuIA32Lib/x64/Cpu.asm
@@ -0,0 +1,215 @@
+TITLE Cpu.asm: Assembly code for the x64 resources
+
+;------------------------------------------------------------------------------
+;*
+;* Copyright (c) 2005 - 2008, Intel Corporation
+;* All rights reserved. This program and the accompanying materials
+;* are licensed and made available under the terms and conditions of the BSD License
+;* which accompanies this distribution. The full text of the license may be found at
+;* http://opensource.org/licenses/bsd-license.php
+;*
+;* THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+;* WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;*
+;* Module Name:
+;*
+;* Cpu.asm
+;*
+;* Abstract:
+;*
+;------------------------------------------------------------------------------
+
+text SEGMENT
+
+
+;------------------------------------------------------------------------------
+; VOID
+; EfiHalt (
+; VOID
+; )
+;------------------------------------------------------------------------------
+EfiHalt PROC PUBLIC
+ hlt
+ ret
+EfiHalt ENDP
+
+
+;------------------------------------------------------------------------------
+; VOID
+; EfiWbinvd (
+; VOID
+; )
+;------------------------------------------------------------------------------
+EfiWbinvd PROC PUBLIC
+ wbinvd
+ ret
+EfiWbinvd ENDP
+
+
+;------------------------------------------------------------------------------
+; VOID
+; EfiInvd (
+; VOID
+; )
+;------------------------------------------------------------------------------
+EfiInvd PROC PUBLIC
+ invd
+ ret
+EfiInvd ENDP
+
+;------------------------------------------------------------------------------
+; VOID
+; EfiCpuid (
+; IN UINT32 RegisterInEax, // rcx
+; OUT EFI_CPUID_REGISTER *Reg OPTIONAL // rdx
+; )
+;------------------------------------------------------------------------------
+EfiCpuid PROC PUBLIC
+ push rbx
+
+ mov r8, rdx ; r8 = *Reg
+ mov rax, rcx ; RegisterInEax
+ cpuid
+ cmp r8, 0
+ je _Exit
+ mov [r8 + 0], eax ; Reg->RegEax
+ mov [r8 + 4], ebx ; Reg->RegEbx
+ mov [r8 + 8], ecx ; Reg->RegEcx
+ mov [r8 + 12], edx ; Reg->RegEdx
+
+_Exit:
+ pop rbx
+ ret
+EfiCpuid ENDP
+
+;------------------------------------------------------------------------------
+; UINT64
+; EfiReadMsr (
+; IN UINT32 Index, // rcx
+; )
+;------------------------------------------------------------------------------
+EfiReadMsr PROC PUBLIC
+ rdmsr
+ sal rdx, 32 ; edx:eax -> rax
+ or rax, rdx ; rax = edx:eax
+ ret
+EfiReadMsr ENDP
+
+;------------------------------------------------------------------------------
+; VOID
+; EfiWriteMsr (
+; IN UINT32 Index, // rcx
+; IN UINT64 Value // rdx
+; )
+;------------------------------------------------------------------------------
+EfiWriteMsr PROC PUBLIC
+ mov rax, rdx ; rdx = Value
+ sar rdx, 32 ; convert rdx to edx upper 32-bits
+ wrmsr ; wrmsr[ecx] result = edx:eax
+ ret
+EfiWriteMsr ENDP
+
+
+;------------------------------------------------------------------------------
+; UINT64
+; EfiReadTsc (
+; VOID
+; );
+;------------------------------------------------------------------------------
+EfiReadTsc PROC PUBLIC
+ rdtsc
+ shl rax, 32
+ shrd rax, rdx, 32
+ ret
+EfiReadTsc ENDP
+
+;------------------------------------------------------------------------------
+; VOID
+; EfiDisableCache (
+; VOID
+; );
+;------------------------------------------------------------------------------
+EfiDisableCache PROC PUBLIC
+; added a check to see if cache is already disabled. If it is, then skip.
+ mov rax, cr0
+ and rax, 060000000h
+ cmp rax, 0
+ jne @f
+ mov rax, cr0
+ or rax, 060000000h
+ mov cr0, rax
+ wbinvd
+@@:
+ ret
+EfiDisableCache ENDP
+
+;------------------------------------------------------------------------------
+; VOID
+; EfiEnableCache (
+; VOID
+; );
+;------------------------------------------------------------------------------
+EfiEnableCache PROC PUBLIC
+ wbinvd
+ mov rax, cr0
+ and rax, 09fffffffh
+ mov cr0, rax
+ ret
+EfiEnableCache ENDP
+
+;------------------------------------------------------------------------------
+; UINTN
+; EfiGetEflags (
+; VOID
+; );
+;------------------------------------------------------------------------------
+EfiGetEflags PROC PUBLIC
+ pushfq
+ pop rax
+ ret
+EfiGetEflags ENDP
+
+;------------------------------------------------------------------------------
+; VOID
+; EfiDisableInterrupts (
+; VOID
+; );
+;------------------------------------------------------------------------------
+EfiDisableInterrupts PROC PUBLIC
+ cli
+ ret
+EfiDisableInterrupts ENDP
+
+;------------------------------------------------------------------------------
+; VOID
+; EfiEnableInterrupts (
+; VOID
+; );
+;------------------------------------------------------------------------------
+EfiEnableInterrupts PROC PUBLIC
+ sti
+ ret
+EfiEnableInterrupts ENDP
+;------------------------------------------------------------------------------
+; VOID
+; EfiCpuidExt (
+; IN UINT32 RegisterInEax,
+; IN UINT32 CacheLevel,
+; OUT EFI_CPUID_REGISTER *Regs
+; )
+;------------------------------------------------------------------------------
+EfiCpuidExt PROC PUBLIC
+ push rbx
+ mov rax, rcx ; rax = RegisterInEax
+ mov rcx, rdx ; rcx = CacheLevel
+
+ cpuid
+ mov [r8 + 0 ], eax ; Reg->RegEax
+ mov [r8 + 4 ], ebx ; Reg->RegEbx
+ mov [r8 + 8 ], ecx ; Reg->RegEcx
+ mov [r8 + 12], edx ; Reg->RegEdx
+
+ pop rbx
+ ret
+EfiCpuidExt ENDP
+END
diff --git a/EDK/Foundation/Cpu/Pentium/Include/CpuIA32.h b/EDK/Foundation/Cpu/Pentium/Include/CpuIA32.h
new file mode 100644
index 0000000..a399954
--- /dev/null
+++ b/EDK/Foundation/Cpu/Pentium/Include/CpuIA32.h
@@ -0,0 +1,372 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ CpuIA32.h
+
+Abstract:
+
+--*/
+
+#ifndef _CPU_IA32_H
+#define _CPU_IA32_H
+
+#include "Tiano.h"
+
+#define IA32API __cdecl
+
+typedef struct {
+ UINT32 RegEax;
+ UINT32 RegEbx;
+ UINT32 RegEcx;
+ UINT32 RegEdx;
+} EFI_CPUID_REGISTER;
+
+typedef struct {
+ UINT32 HeaderVersion;
+ UINT32 UpdateRevision;
+ UINT32 Date;
+ UINT32 ProcessorId;
+ UINT32 Checksum;
+ UINT32 LoaderRevision;
+ UINT32 ProcessorFlags;
+ UINT32 DataSize;
+ UINT32 TotalSize;
+ UINT8 Reserved[12];
+} EFI_CPU_MICROCODE_HEADER;
+
+typedef struct {
+ UINT32 ExtendedSignatureCount;
+ UINT32 ExtendedTableChecksum;
+ UINT8 Reserved[12];
+} EFI_CPU_MICROCODE_EXTENDED_TABLE_HEADER;
+
+typedef struct {
+ UINT32 ProcessorSignature;
+ UINT32 ProcessorFlag;
+ UINT32 ProcessorChecksum;
+} EFI_CPU_MICROCODE_EXTENDED_TABLE;
+
+typedef struct {
+ UINT32 Stepping : 4;
+ UINT32 Model : 4;
+ UINT32 Family : 4;
+ UINT32 Type : 2;
+ UINT32 Reserved1 : 2;
+ UINT32 ExtendedModel : 4;
+ UINT32 ExtendedFamily : 8;
+ UINT32 Reserved2 : 4;
+} EFI_CPU_VERSION;
+
+#define EFI_CPUID_SIGNATURE 0x0
+#define EFI_CPUID_VERSION_INFO 0x1
+#define EFI_CPUID_CACHE_INFO 0x2
+#define EFI_CPUID_SERIAL_NUMBER 0x3
+#define EFI_CPUID_EXTENDED_FUNCTION 0x80000000
+#define EFI_CPUID_EXTENDED_CPU_SIG 0x80000001
+#define EFI_CPUID_BRAND_STRING1 0x80000002
+#define EFI_CPUID_BRAND_STRING2 0x80000003
+#define EFI_CPUID_BRAND_STRING3 0x80000004
+
+#define EFI_MSR_IA32_PLATFORM_ID 0x17
+#define EFI_MSR_IA32_APIC_BASE 0x1B
+#define EFI_MSR_EBC_HARD_POWERON 0x2A
+#define EFI_MSR_EBC_SOFT_POWERON 0x2B
+#define BINIT_DRIVER_DISABLE 0x40
+#define INTERNAL_MCERR_DISABLE 0x20
+#define INITIATOR_MCERR_DISABLE 0x10
+#define EFI_MSR_EBC_FREQUENCY_ID 0x2C
+#define EFI_MSR_IA32_BIOS_UPDT_TRIG 0x79
+#define EFI_MSR_IA32_BIOS_SIGN_ID 0x8B
+#define EFI_MSR_PSB_CLOCK_STATUS 0xCD
+#define EFI_APIC_GLOBAL_ENABLE 0x800
+#define EFI_MSR_IA32_MISC_ENABLE 0x1A0
+#define LIMIT_CPUID_MAXVAL_ENABLE_BIT 0x00400000
+#define AUTOMATIC_THERMAL_CONTROL_ENABLE_BIT 0x00000008
+#define COMPATIBLE_FPU_OPCODE_ENABLE_BIT 0x00000004
+#define LOGICAL_PROCESSOR_PRIORITY_ENABLE_BIT 0x00000002
+#define FAST_STRING_ENABLE_BIT 0x00000001
+
+#define EFI_CACHE_VARIABLE_MTRR_BASE 0x200
+#define EFI_CACHE_VARIABLE_MTRR_END 0x20F
+#define EFI_CACHE_IA32_MTRR_DEF_TYPE 0x2FF
+#define EFI_CACHE_MTRR_VALID 0x800
+#define EFI_CACHE_FIXED_MTRR_VALID 0x400
+#define EFI_CACHE_VALID_ADDRESS 0xFFFFFF000
+#define EFI_MSR_VALID_MASK 0xFFFFFFFFF
+#define EFI_CACHE_VALID_EXTENDED_ADDRESS 0xFFFFFFFFFF000
+#define EFI_MSR_VALID_EXTENDED_MASK 0xFFFFFFFFFFFFF
+
+#define EFI_IA32_MTRR_FIX64K_00000 0x250
+#define EFI_IA32_MTRR_FIX16K_80000 0x258
+#define EFI_IA32_MTRR_FIX16K_A0000 0x259
+#define EFI_IA32_MTRR_FIX4K_C0000 0x268
+#define EFI_IA32_MTRR_FIX4K_C8000 0x269
+#define EFI_IA32_MTRR_FIX4K_D0000 0x26A
+#define EFI_IA32_MTRR_FIX4K_D8000 0x26B
+#define EFI_IA32_MTRR_FIX4K_E0000 0x26C
+#define EFI_IA32_MTRR_FIX4K_E8000 0x26D
+#define EFI_IA32_MTRR_FIX4K_F0000 0x26E
+#define EFI_IA32_MTRR_FIX4K_F8000 0x26F
+
+#define EFI_IA32_MCG_CAP 0x179
+#define EFI_IA32_MCG_CTL 0x17B
+#define EFI_IA32_MC0_CTL 0x400
+#define EFI_IA32_MC0_STATUS 0x401
+
+#define EFI_IA32_PERF_STATUS 0x198
+#define EFI_IA32_PERF_CTL 0x199
+
+#define EFI_CACHE_UNCACHEABLE 0
+#define EFI_CACHE_WRITECOMBINING 1
+#define EFI_CACHE_WRITETHROUGH 4
+#define EFI_CACHE_WRITEPROTECTED 5
+#define EFI_CACHE_WRITEBACK 6
+
+//
+// Combine f(FamilyId), m(Model), s(SteppingId) to a single 32 bit number
+//
+#define EfiMakeCpuVersion(f, m, s) \
+ (((UINT32) (f) << 16) | ((UINT32) (m) << 8) | ((UINT32) (s)))
+
+VOID
+IA32API
+EfiHalt (
+ VOID
+ )
+;
+
+/*++
+Routine Description:
+ Halt the Cpu
+Arguments:
+ None
+Returns:
+ None
+--*/
+VOID
+IA32API
+EfiWbinvd (
+ VOID
+ )
+;
+
+/*++
+Routine Description:
+ Write back and invalidate the Cpu cache
+Arguments:
+ None
+Returns:
+ None
+--*/
+VOID
+IA32API
+EfiInvd (
+ VOID
+ )
+;
+
+/*++
+Routine Description:
+ Invalidate the Cpu cache
+Arguments:
+ None
+Returns:
+ None
+--*/
+VOID
+IA32API
+EfiCpuid (
+ IN UINT32 RegisterInEax,
+ OUT EFI_CPUID_REGISTER *Regs
+ )
+;
+
+/*++
+Routine Description:
+ Get the Cpu info by excute the CPUID instruction
+Arguments:
+ RegisterInEax: -The input value to put into register EAX
+ Regs: -The Output value
+Returns:
+ None
+--*/
+
+VOID
+IA32API
+EfiCpuidExt (
+ IN UINT32 RegisterInEax,
+ IN UINT32 CacheLevel,
+ OUT EFI_CPUID_REGISTER *Regs
+ )
+/*++
+Routine Description:
+ When RegisterInEax != 4, the functionality is the same as EfiCpuid.
+ When RegisterInEax == 4, the function return the deterministic cache
+ parameters by excuting the CPUID instruction
+Arguments:
+ RegisterInEax: - The input value to put into register EAX
+ CacheLevel: - The deterministic cache level
+ Regs: - The Output value
+Returns:
+ None
+--*/
+;
+
+UINT64
+IA32API
+EfiReadMsr (
+ IN UINT32 Index
+ )
+;
+
+/*++
+Routine Description:
+ Read Cpu MSR
+Arguments:
+ Index: -The index value to select the register
+
+Returns:
+ Return the read data
+--*/
+VOID
+IA32API
+EfiWriteMsr (
+ IN UINT32 Index,
+ IN UINT64 Value
+ )
+;
+
+/*++
+Routine Description:
+ Write Cpu MSR
+Arguments:
+ Index: -The index value to select the register
+ Value: -The value to write to the selected register
+Returns:
+ None
+--*/
+UINT64
+IA32API
+EfiReadTsc (
+ VOID
+ )
+;
+
+/*++
+Routine Description:
+ Read Time stamp
+Arguments:
+ None
+Returns:
+ Return the read data
+--*/
+VOID
+IA32API
+EfiDisableCache (
+ VOID
+ )
+;
+
+/*++
+Routine Description:
+ Writing back and invalidate the cache,then diable it
+Arguments:
+ None
+Returns:
+ None
+--*/
+VOID
+IA32API
+EfiEnableCache (
+ VOID
+ )
+;
+
+/*++
+Routine Description:
+ Invalidate the cache,then Enable it
+Arguments:
+ None
+Returns:
+ None
+--*/
+UINT32
+IA32API
+EfiGetEflags (
+ VOID
+ )
+;
+
+/*++
+Routine Description:
+ Get Eflags
+Arguments:
+ None
+Returns:
+ Return the Eflags value
+--*/
+VOID
+IA32API
+EfiDisableInterrupts (
+ VOID
+ )
+;
+
+/*++
+Routine Description:
+ Disable Interrupts
+Arguments:
+ None
+Returns:
+ None
+--*/
+VOID
+IA32API
+EfiEnableInterrupts (
+ VOID
+ )
+;
+
+/*++
+Routine Description:
+ Enable Interrupts
+Arguments:
+ None
+Returns:
+ None
+--*/
+
+
+VOID
+IA32API
+EfiCpuVersion (
+ IN UINT16 *FamilyId, OPTIONAL
+ IN UINT8 *Model, OPTIONAL
+ IN UINT8 *SteppingId, OPTIONAL
+ IN UINT8 *Processor OPTIONAL
+ )
+/*++
+
+Routine Description:
+ Extract CPU detail version infomation
+
+Arguments:
+ FamilyId - FamilyId, including ExtendedFamilyId
+ Model - Model, including ExtendedModel
+ SteppingId - SteppingId
+ Processor - Processor
+
+--*/
+;
+
+#endif
diff --git a/EDK/Foundation/EdkHeaders.cif b/EDK/Foundation/EdkHeaders.cif
new file mode 100644
index 0000000..7aa6c8f
--- /dev/null
+++ b/EDK/Foundation/EdkHeaders.cif
@@ -0,0 +1,125 @@
+<component>
+ name = "EdkHeaders"
+ category = ModulePart
+ LocalRoot = "EDK\Foundation\"
+ RefName = "EdkHeaders"
+[files]
+"Include\EfiCommon.h"
+"Include\EfiDebug.h"
+"Include\EfiDepex.h"
+"Include\EfiFlashMap.h"
+"Include\EfiPci.h"
+"Include\EfiPerf.h"
+"Include\EfiPxe.h"
+"Include\EfiSpec.h"
+"Include\EfiStdArg.h"
+"Include\EfiTpm.h"
+"Include\EfiVariable.h"
+"Include\EfiWorkingBlockHeader.h"
+"Include\Tiano.h"
+"Include\TianoApi.h"
+"Include\TianoCommon.h"
+"Include\TianoDevicePath.h"
+"Include\TianoError.h"
+"Include\TianoTypes.h"
+"Include\EfiCompNameSupport.h"
+"Include\TianoHii.h"
+"Include\Ebc\EfiBind.h"
+"Include\Ebc\EfiPeOptionalHeader.h"
+"Include\Ebc\TianoBind.h"
+"Include\Ia32\EfiBind.h"
+"Include\Ia32\EfiPeOptionalHeader.h"
+"Include\Ia32\TianoBind.h"
+"Include\IndustryStandard\Acpi.h"
+"Include\IndustryStandard\pci22.h"
+"Include\IndustryStandard\pci23.h"
+"Include\IndustryStandard\pci30.h"
+"Include\IndustryStandard\scsi.h"
+"Include\IndustryStandard\Tpm12.h"
+"Include\IndustryStandard\usb.h"
+"Include\Ipf\EfiBind.h"
+"Include\Ipf\EfiPeOptionalHeader.h"
+"Include\Ipf\IpfDefines.h"
+"Include\Ipf\IpfMacro.i"
+"Include\Ipf\PalApi.h"
+"Include\Ipf\SalApi.h"
+"Include\Ipf\TianoBind.h"
+"Include\Pei\Pei.h"
+"Include\Pei\PeiBind.h"
+"Include\Pei\PeiDebug.h"
+"Include\x64\EfiBind.h"
+"Include\x64\EfiPeOptionalHeader.h"
+"Include\x64\TianoBind.h"
+"EFI\Include\EfiApi.h"
+"EFI\Include\EfiDevicePath.h"
+"EFI\Include\EfiError.h"
+"EFI\Include\EfiImage.h"
+"EFI\Include\EfiTypes.h"
+"EFI\Include\Pxe.h"
+"EFI\Include\EfiHii.h"
+"Framework\Include\BootMode.h"
+"Framework\Include\EfiBootScript.h"
+"Framework\Include\EfiCapsule.h"
+"Framework\Include\EfiDependency.h"
+"Framework\Include\EfiFirmwareFileSystem.h"
+"Framework\Include\EfiFirmwareVolumeHeader.h"
+"Framework\Include\EfiImageFormat.h"
+"Framework\Include\EfiInternalFormRepresentation.h"
+"Framework\Include\EfiSmbus.h"
+"Framework\Include\EfiStatusCode.h"
+"Framework\Include\PeiApi.h"
+"Framework\Include\PeiHob.h"
+"Framework\Include\TianoSpecApi.h"
+"Framework\Include\TianoSpecDevicePath.h"
+"Framework\Include\TianoSpecError.h"
+"Framework\Include\TianoSpecTypes.h"
+"Framework\Include\EfiFirmwareVolume.h"
+"Framework\Include\EfiPciCfg.h"
+"Framework\Include\EfiVariable.h"
+"Library\Dxe\Include\EfiCombinationLib.h"
+"Library\Dxe\Include\EfiCommonLib.h"
+"Library\Dxe\Include\EfiDriverLib.h"
+"Library\Dxe\Include\EfiHobLib.h"
+"Library\Dxe\Include\EfiMgmtModeRuntimeLib.h"
+"Library\Dxe\Include\EfiPrintLib.h"
+"Library\Dxe\Include\EfiRegTableLib.h"
+"Library\Dxe\Include\EfiRuntimeLib.h"
+"Library\Dxe\Include\EfiScriptLib.h"
+"Library\Dxe\Include\EfiSmmDriverLib.h"
+"Library\Dxe\Include\EfiUiLib.h"
+"Library\Dxe\Include\EfiWinNtLib.h"
+"Library\Dxe\Include\GetImage.h"
+"Library\Dxe\Include\GraphicsLib.h"
+"Library\Dxe\Include\Ia32EfiRuntimeDriverLib.h"
+"Library\Dxe\Include\LinkedList.h"
+"Library\Dxe\Include\RtDevicePath.h"
+"Library\Dxe\Include\SmmRuntimeLib.h"
+"Library\Dxe\Include\Ebc\ProcDep.h"
+"Library\Dxe\Include\Ia32\CpuFuncs.h"
+"Library\Dxe\Include\Ia32\ProcDep.h"
+"Library\Dxe\Include\Ipf\CpuFuncs.h"
+"Library\Dxe\Include\Ipf\EsalRuntimeLib.h"
+"Library\Dxe\Include\Ipf\ProcDep.h"
+"Library\Dxe\Include\Ipf\SalDriverLib.h"
+"Library\Dxe\Include\x64\CpuFuncs.h"
+"Library\Dxe\Include\x64\ProcDep.h"
+"Library\Pei\Include\peihoblib.h"
+"Library\Pei\Include\PeiLib.h"
+"Include\IndustryStandard\Acpi1_0.h"
+"Include\IndustryStandard\Acpi2_0.h"
+"Include\IndustryStandard\Acpi3_0.h"
+"Include\IndustryStandard\AcpiCommon.h"
+"Include\IndustryStandard\AlertStandardFormatTable.h"
+"Include\IndustryStandard\atapi.h"
+"Include\IndustryStandard\DMARemappingReportingTable.h"
+"Include\IndustryStandard\HighPrecisionEventTimerTable.h"
+"Include\IndustryStandard\IScsiBootFirmwareTable.h"
+"Include\IndustryStandard\LegacyBiosMpTable.h"
+"Include\IndustryStandard\MemoryMappedConfigurationSpaceAccessTable.h"
+"Include\IndustryStandard\pci.h"
+"Include\IndustryStandard\SdramSpd.h"
+"Include\IndustryStandard\ServerProcessorManagementInterfaceTable.h"
+"Include\IndustryStandard\Smbios.h"
+"Include\IndustryStandard\WatchdogDescriptionTable.h"
+"Include\FastBootDataDef.h"
+<endComponent>
diff --git a/EDK/Foundation/Efi/Guid/Acpi/Acpi.c b/EDK/Foundation/Efi/Guid/Acpi/Acpi.c
new file mode 100644
index 0000000..2d7e68a
--- /dev/null
+++ b/EDK/Foundation/Efi/Guid/Acpi/Acpi.c
@@ -0,0 +1,35 @@
+/*++
+
+Copyright (c) 2004 - 2005, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Acpi.c
+
+Abstract:
+
+ GUIDs used for ACPI entries in the EFI 1.0 system table
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_GUID_DEFINITION (Acpi)
+
+EFI_GUID gEfiAcpiTableGuid = EFI_ACPI_TABLE_GUID;
+
+EFI_GUID_STRING(&gEfiAcpiTableGuid, "ACPI Table", "ACPI 1.0 Table GUID in EFI System Table");
+
+EFI_GUID gEfiAcpi20TableGuid = EFI_ACPI_20_TABLE_GUID;
+
+EFI_GUID_STRING(&gEfiAcpi20TableGuid, "ACPI 2.0 Table", "ACPI 2.0 Table GUID in EFI System Table");
+
+EFI_GUID gEfiAcpi30TableGuid = EFI_ACPI_30_TABLE_GUID;
+
+EFI_GUID_STRING(&gEfiAcpi30TableGuid, "ACPI 3.0 Table", "ACPI 3.0 Table GUID in EFI System Table");
diff --git a/EDK/Foundation/Efi/Guid/Acpi/Acpi.h b/EDK/Foundation/Efi/Guid/Acpi/Acpi.h
new file mode 100644
index 0000000..48565a4
--- /dev/null
+++ b/EDK/Foundation/Efi/Guid/Acpi/Acpi.h
@@ -0,0 +1,44 @@
+/*++
+
+Copyright (c) 2004 - 2005, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Acpi.h
+
+Abstract:
+
+ GUIDs used for ACPI entries in the in the EFI 1.0 system table
+
+ These GUIDs point the ACPI tables as defined in the ACPI specifications.
+ ACPI 2.0 specification defines the ACPI 2.0 GUID. EFI 1.0 defines the
+ ACPI 1.0 GUID.
+
+--*/
+
+#ifndef _ACPI_GUID_H_
+#define _ACPI_GUID_H_
+
+#define EFI_ACPI_TABLE_GUID \
+ { \
+ 0xeb9d2d30, 0x2d88, 0x11d3, 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d \
+ }
+
+#define EFI_ACPI_20_TABLE_GUID \
+ { \
+ 0x8868e871, 0xe4f1, 0x11d3, 0xbc, 0x22, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 \
+ }
+
+#define EFI_ACPI_30_TABLE_GUID EFI_ACPI_20_TABLE_GUID
+
+extern EFI_GUID gEfiAcpiTableGuid;
+extern EFI_GUID gEfiAcpi20TableGuid;
+extern EFI_GUID gEfiAcpi30TableGuid;
+#endif
diff --git a/EDK/Foundation/Efi/Guid/DebugImageInfoTable/DebugImageInfoTable.c b/EDK/Foundation/Efi/Guid/DebugImageInfoTable/DebugImageInfoTable.c
new file mode 100644
index 0000000..98d8ce5
--- /dev/null
+++ b/EDK/Foundation/Efi/Guid/DebugImageInfoTable/DebugImageInfoTable.c
@@ -0,0 +1,28 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ DebugImageInfoTable.c
+
+Abstract:
+
+ GUID used to locate the Debug Image Info table in the EFI 1.0 system table.
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_GUID_DEFINITION (DebugImageInfoTable)
+
+EFI_GUID gEfiDebugImageInfoTableGuid = EFI_DEBUG_IMAGE_INFO_TABLE_GUID;
+
+EFI_GUID_STRING
+ (&gEfiDebugImageInfoTableGuid, "Debug Image Info Table", "Debug Image Info Table GUID in EFI System Table");
diff --git a/EDK/Foundation/Efi/Guid/DebugImageInfoTable/DebugImageInfoTable.h b/EDK/Foundation/Efi/Guid/DebugImageInfoTable/DebugImageInfoTable.h
new file mode 100644
index 0000000..7ae8f18
--- /dev/null
+++ b/EDK/Foundation/Efi/Guid/DebugImageInfoTable/DebugImageInfoTable.h
@@ -0,0 +1,63 @@
+/*++
+
+Copyright (c) 2004 - 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ DebugImageInfoTable.h
+
+Abstract:
+
+ GUID and related data structures used with the Debug Image Info Table.
+
+--*/
+
+#ifndef _DEBUG_IMAGE_INFO_GUID_H_
+#define _DEBUG_IMAGE_INFO_GUID_H_
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (LoadedImage)
+
+#define EFI_DEBUG_IMAGE_INFO_TABLE_GUID \
+ { \
+ 0x49152e77, 0x1ada, 0x4764, 0xb7, 0xa2, 0x7a, 0xfe, 0xfe, 0xd9, 0x5e, 0x8b \
+ }
+
+extern EFI_GUID gEfiDebugImageInfoTableGuid;
+
+#define EFI_DEBUG_IMAGE_INFO_UPDATE_IN_PROGRESS 0x01
+#define EFI_DEBUG_IMAGE_INFO_TABLE_MODIFIED 0x02
+#define EFI_DEBUG_IMAGE_INFO_INITIAL_SIZE (EFI_PAGE_SIZE / sizeof (UINTN))
+#define EFI_DEBUG_IMAGE_INFO_TYPE_NORMAL 0x01
+
+typedef struct {
+ UINT64 Signature;
+ EFI_PHYSICAL_ADDRESS EfiSystemTableBase;
+ UINT32 Crc32;
+} EFI_SYSTEM_TABLE_POINTER;
+
+typedef struct {
+ UINT32 ImageInfoType;
+ EFI_LOADED_IMAGE_PROTOCOL *LoadedImageProtocolInstance;
+ EFI_HANDLE *ImageHandle;
+} EFI_DEBUG_IMAGE_INFO_NORMAL;
+
+typedef union {
+ UINT32 *ImageInfoType;
+ EFI_DEBUG_IMAGE_INFO_NORMAL *NormalImage;
+} EFI_DEBUG_IMAGE_INFO;
+
+typedef struct {
+ volatile UINT32 UpdateStatus;
+ UINT32 TableSize;
+ EFI_DEBUG_IMAGE_INFO *EfiDebugImageInfoTable;
+} EFI_DEBUG_IMAGE_INFO_TABLE_HEADER;
+
+#endif
diff --git a/EDK/Foundation/Efi/Guid/EfiGuidLib.cif b/EDK/Foundation/Efi/Guid/EfiGuidLib.cif
new file mode 100644
index 0000000..097dd83
--- /dev/null
+++ b/EDK/Foundation/Efi/Guid/EfiGuidLib.cif
@@ -0,0 +1,30 @@
+<component>
+ name = "EfiGuidLib"
+ category = ModulePart
+ LocalRoot = "EDK\Foundation\Efi\Guid\"
+ RefName = "EfiGuidLib"
+[files]
+"EfiGuidLib.sdl"
+"EfiGuidLib.mak"
+"Acpi\Acpi.h"
+"Acpi\Acpi.c"
+"DebugImageInfoTable\DebugImageInfoTable.h"
+"DebugImageInfoTable\DebugImageInfoTable.c"
+"EventGroup\EventGroup.h"
+"EventGroup\EventGroup.c"
+"GlobalVariable\GlobalVariable.h"
+"GlobalVariable\GlobalVariable.c"
+"Gpt\Gpt.h"
+"Gpt\Gpt.c"
+"Mps\Mps.h"
+"Mps\Mps.c"
+"PcAnsi\PcAnsi.h"
+"PcAnsi\PcAnsi.c"
+"SalSystemTable\SalSystemTable.h"
+"SalSystemTable\SalSystemTable.c"
+"SmBios\SmBios.h"
+"SmBios\SmBios.c"
+"HardwareErrorVariable\HardwareErrorVariable.c"
+"HardwareErrorVariable\HardwareErrorVariable.h"
+"EfiGuidLib.inf"
+<endComponent>
diff --git a/EDK/Foundation/Efi/Guid/EfiGuidLib.inf b/EDK/Foundation/Efi/Guid/EfiGuidLib.inf
new file mode 100644
index 0000000..1d98480
--- /dev/null
+++ b/EDK/Foundation/Efi/Guid/EfiGuidLib.inf
@@ -0,0 +1,59 @@
+#/*++
+#
+# Copyright (c) 2004 - 2006, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# EfiGuidLib.inf
+#
+# Abstract:
+#
+# Component description file.
+#
+#--*/
+
+[defines]
+BASE_NAME= EfiGuidLib
+COMPONENT_TYPE= LIBRARY
+
+[includes.common]
+ $(EDK_SOURCE)\Foundation\Efi
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+ $(EDK_SOURCE)\Foundation\Include\Pei
+ $(EDK_SOURCE)\Foundation\Library\Pei\Include
+
+[nmake.common]
+
+[sources.common]
+ Acpi\Acpi.h
+ Acpi\Acpi.c
+ DebugImageInfoTable\DebugImageInfoTable.h
+ DebugImageInfoTable\DebugImageInfoTable.c
+ EventGroup\EventGroup.h
+ EventGroup\EventGroup.c
+ GlobalVariable\GlobalVariable.h
+ GlobalVariable\GlobalVariable.c
+ Gpt\Gpt.h
+ Gpt\Gpt.c
+ HardwareErrorVariable\HardwareErrorVariable.h
+ HardwareErrorVariable\HardwareErrorVariable.c
+ Mps\Mps.h
+ Mps\Mps.c
+ PcAnsi\PcAnsi.h
+ PcAnsi\PcAnsi.c
+ SmBios\SmBios.h
+ SmBios\SmBios.c
+[sources.ipf]
+ SalSystemTable\SalSystemTable.h
+ SalSystemTable\SalSystemTable.c \ No newline at end of file
diff --git a/EDK/Foundation/Efi/Guid/EfiGuidLib.mak b/EDK/Foundation/Efi/Guid/EfiGuidLib.mak
new file mode 100644
index 0000000..dc28a86
--- /dev/null
+++ b/EDK/Foundation/Efi/Guid/EfiGuidLib.mak
@@ -0,0 +1,72 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EfiGuidLib/EfiGuidLib.mak 1 1/20/12 4:00a Jeffch $
+#
+# $Revision: 1 $
+#
+# $Date: 1/20/12 4:00a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EfiGuidLib/EfiGuidLib.mak $
+#
+# 1 1/20/12 4:00a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 9/27/11 6:23a Wesleychen
+# Intel EDK initially releases.
+#
+# 2 9/02/09 3:12a Iminglin
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: EfiGuidLib.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+
+$(EFIGUIDLIB) : EfiGuidLib
+
+EfiGuidLib : $(BUILD_DIR)\EfiGuidLib.mak EfiGuidLibBin
+
+$(BUILD_DIR)\EfiGuidLib.mak : $(EfiGuidLib_DIR)\$(@B).cif $(EfiGuidLib_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(EfiGuidLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+EfiGuidLibBin :
+ $(MAKE) /$(MAKEFLAGS) $(EDK_DEFAULTS)\
+ /f $(BUILD_DIR)\EfiGuidLib.mak all\
+ TYPE=LIBRARY
+!IF "$(x64_BUILD)"=="1"
+ $(MAKE) /$(MAKEFLAGS) $(EDK_DEFAULTS) BUILD_DIR=$(BUILD_DIR)\IA32\
+ /f $(BUILD_DIR)\EfiGuidLib.mak all\
+ TYPE=PEI_LIBRARY
+!ENDIF
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#********************************************************************** \ No newline at end of file
diff --git a/EDK/Foundation/Efi/Guid/EfiGuidLib.sdl b/EDK/Foundation/Efi/Guid/EfiGuidLib.sdl
new file mode 100644
index 0000000..e419092
--- /dev/null
+++ b/EDK/Foundation/Efi/Guid/EfiGuidLib.sdl
@@ -0,0 +1,26 @@
+TOKEN
+ Name = "EfiGuidLib_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable EfiGuidLib support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "EFIGUIDLIB"
+ Value = "$$(LIB_BUILD_DIR)\EfiGuidLib.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "EfiGuidLib_DIR"
+End
+
+MODULE
+ Help = "Includes EfiGuidLib.mak to Project"
+ File = "EfiGuidLib.mak"
+End
+
diff --git a/EDK/Foundation/Efi/Guid/EventGroup/EventGroup.c b/EDK/Foundation/Efi/Guid/EventGroup/EventGroup.c
new file mode 100644
index 0000000..592c7ec
--- /dev/null
+++ b/EDK/Foundation/Efi/Guid/EventGroup/EventGroup.c
@@ -0,0 +1,30 @@
+/*++
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiGroup.c
+
+--*/
+#include "Tiano.h"
+
+#include EFI_GUID_DEFINITION (EventGroup)
+
+EFI_GUID gEfiEventExitBootServicesGuid = EFI_EVENT_GROUP_EXIT_BOOT_SERVICES;
+EFI_GUID gEfiEventVirtualAddressChangeGuid = EFI_EVENT_GROUP_VIRTUAL_ADDRESS_CHANGE;
+EFI_GUID gEfiEventMemoryMapChangeGuid = EFI_EVENT_GROUP_MEMORY_MAP_CHANGE;
+EFI_GUID gEfiEventReadyToBootGuid = EFI_EVENT_GROUP_READY_TO_BOOT;
+
+EFI_GUID_STRING (&gEfiEventExitBootServicesGuid, "EventExitBS", "Event Exit Boot Service GUID");
+EFI_GUID_STRING (&gEfiEventVirtualAddressChangeGuid, "EventVirtualAddrChange", "Event Virtual Addr Change GUID");
+EFI_GUID_STRING (&gEfiEventMemoryMapChangeGuid, "EventMemMapChange", "Event Memory Map Change GUID");
+EFI_GUID_STRING (&gEfiEventReadyToBootGuid, "EventReadyToBoot", "Efi Ready To Boot GUID");
+
diff --git a/EDK/Foundation/Efi/Guid/EventGroup/EventGroup.h b/EDK/Foundation/Efi/Guid/EventGroup/EventGroup.h
new file mode 100644
index 0000000..dc78ac4
--- /dev/null
+++ b/EDK/Foundation/Efi/Guid/EventGroup/EventGroup.h
@@ -0,0 +1,45 @@
+/** @file
+ GUIDs for gBS->CreateEventEx Event Groups. Defined in UEFI 2.0.
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ Module Name: EventGroup.h
+
+**/
+
+#ifndef __EVENT_GROUP_GUID__
+#define __EVENT_GROUP_GUID__
+
+
+#define EFI_EVENT_GROUP_EXIT_BOOT_SERVICES \
+ { 0x27abf055, 0xb1b8, 0x4c26, { 0x80, 0x48, 0x74, 0x8f, 0x37, 0xba, 0xa2, 0xdf } }
+
+extern EFI_GUID gEfiEventExitBootServicesGuid;
+
+
+#define EFI_EVENT_GROUP_VIRTUAL_ADDRESS_CHANGE \
+ { 0x13fa7698, 0xc831, 0x49c7, { 0x87, 0xea, 0x8f, 0x43, 0xfc, 0xc2, 0x51, 0x96 } }
+
+extern EFI_GUID gEfiEventVirtualAddressChangeGuid;
+
+
+#define EFI_EVENT_GROUP_MEMORY_MAP_CHANGE \
+ { 0x78bee926, 0x692f, 0x48fd, { 0x9e, 0xdb, 0x1, 0x42, 0x2e, 0xf0, 0xd7, 0xab } }
+
+extern EFI_GUID gEfiEventMemoryMapChangeGuid;
+
+
+#define EFI_EVENT_GROUP_READY_TO_BOOT \
+ { 0x7ce88fb3, 0x4bd7, 0x4679, { 0x87, 0xa8, 0xa8, 0xd8, 0xde, 0xe5, 0x0d, 0x2b } }
+
+extern EFI_GUID gEfiEventReadyToBootGuid;
+
+
+#endif
diff --git a/EDK/Foundation/Efi/Guid/GlobalVariable/GlobalVariable.c b/EDK/Foundation/Efi/Guid/GlobalVariable/GlobalVariable.c
new file mode 100644
index 0000000..dae776d
--- /dev/null
+++ b/EDK/Foundation/Efi/Guid/GlobalVariable/GlobalVariable.c
@@ -0,0 +1,27 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ GlobalVariable.c
+
+Abstract:
+
+ GUID for EFI (NVRAM) Variables. Defined in EFI 1.0.
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_GUID_DEFINITION (GlobalVariable)
+
+EFI_GUID gEfiGlobalVariableGuid = EFI_GLOBAL_VARIABLE_GUID;
+
+EFI_GUID_STRING(&gEfiGlobalVariableGuid, "Efi", "Efi Variable GUID")
diff --git a/EDK/Foundation/Efi/Guid/GlobalVariable/GlobalVariable.h b/EDK/Foundation/Efi/Guid/GlobalVariable/GlobalVariable.h
new file mode 100644
index 0000000..232b893
--- /dev/null
+++ b/EDK/Foundation/Efi/Guid/GlobalVariable/GlobalVariable.h
@@ -0,0 +1,32 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ GlobalVariable.h
+
+Abstract:
+
+ GUID for EFI (NVRAM) Variables. Defined in EFI 1.0.
+
+--*/
+
+#ifndef _GLOBAL_VARIABLE_GUID_H_
+#define _GLOBAL_VARIABLE_GUID_H_
+
+#define EFI_GLOBAL_VARIABLE_GUID \
+ { \
+ 0x8BE4DF61, 0x93CA, 0x11d2, 0xAA, 0x0D, 0x00, 0xE0, 0x98, 0x03, 0x2B, 0x8C \
+ }
+
+extern EFI_GUID gEfiGlobalVariableGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Guid/Gpt/Gpt.c b/EDK/Foundation/Efi/Guid/Gpt/Gpt.c
new file mode 100644
index 0000000..d080ba4
--- /dev/null
+++ b/EDK/Foundation/Efi/Guid/Gpt/Gpt.c
@@ -0,0 +1,38 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Gpt.c
+
+Abstract:
+
+ Guids used for the GPT as defined in EFI 1.0
+
+ GPT defines a new disk partitioning scheme and also describes
+ usage of the legacy Master Boot Record (MBR) partitioning scheme.
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_GUID_DEFINITION (Gpt)
+
+EFI_GUID gEfiPartTypeUnusedGuid = EFI_PART_TYPE_UNUSED_GUID;
+
+EFI_GUID_STRING(&gEfiPartTypeUnusedGuid, "G0", "Null Partition Type GUID");
+
+EFI_GUID gEfiPartTypeSystemPartGuid = EFI_PART_TYPE_EFI_SYSTEM_PART_GUID;
+
+EFI_GUID_STRING(&gEfiPartTypeSystemPartGuid, "ESP", "EFI System Partition GUID");
+
+EFI_GUID gEfiPartTypeLegacyMbrGuid = EFI_PART_TYPE_LEGACY_MBR_GUID;
+
+EFI_GUID_STRING(&gEfiPartTypeLegacyMbrGuid, "Legacy MBR", "Legacy Master Boot Record Partition GUID");
diff --git a/EDK/Foundation/Efi/Guid/Gpt/Gpt.h b/EDK/Foundation/Efi/Guid/Gpt/Gpt.h
new file mode 100644
index 0000000..8cbad57
--- /dev/null
+++ b/EDK/Foundation/Efi/Guid/Gpt/Gpt.h
@@ -0,0 +1,47 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Gpt.h
+
+Abstract:
+
+ Guids used for the GPT as defined in EFI 1.0
+
+ GPT defines a new disk partitioning scheme and also describes
+ usage of the legacy Master Boot Record (MBR) partitioning scheme.
+
+--*/
+
+#ifndef _GPT_GUID_H_
+#define _GPT_GUID_H_
+
+#define EFI_PART_TYPE_UNUSED_GUID \
+ { \
+ 0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 \
+ }
+
+#define EFI_PART_TYPE_EFI_SYSTEM_PART_GUID \
+ { \
+ 0xc12a7328, 0xf81f, 0x11d2, 0xba, 0x4b, 0x00, 0xa0, 0xc9, 0x3e, 0xc9, 0x3b \
+ }
+
+#define EFI_PART_TYPE_LEGACY_MBR_GUID \
+ { \
+ 0x024dee41, 0x33e7, 0x11d3, 0x9d, 0x69, 0x00, 0x08, 0xc7, 0x81, 0xf3, 0x9f \
+ }
+
+extern EFI_GUID gEfiPartTypeUnusedGuid;
+extern EFI_GUID gEfiPartTypeSystemPartGuid;
+extern EFI_GUID gEfiPartTypeLegacyMbrGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Guid/HardwareErrorVariable/HardwareErrorVariable.c b/EDK/Foundation/Efi/Guid/HardwareErrorVariable/HardwareErrorVariable.c
new file mode 100644
index 0000000..48086ba
--- /dev/null
+++ b/EDK/Foundation/Efi/Guid/HardwareErrorVariable/HardwareErrorVariable.c
@@ -0,0 +1,27 @@
+/*++
+
+Copyright (c) 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ HardwareErrorVariable.c
+
+Abstract:
+
+ GUID for hardware error record variables. Defined in UEFI 2.1.
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_GUID_DEFINITION (HardwareErrorVariable)
+
+EFI_GUID gEfiHardwareErrorVariableGuid = EFI_HARDWARE_ERROR_VARIABLE_GUID;
+
+EFI_GUID_STRING(&gEfiHardwareErrorVariableGuid, "HwErr", "Hardware Error Variable GUID") \ No newline at end of file
diff --git a/EDK/Foundation/Efi/Guid/HardwareErrorVariable/HardwareErrorVariable.h b/EDK/Foundation/Efi/Guid/HardwareErrorVariable/HardwareErrorVariable.h
new file mode 100644
index 0000000..920fc8b
--- /dev/null
+++ b/EDK/Foundation/Efi/Guid/HardwareErrorVariable/HardwareErrorVariable.h
@@ -0,0 +1,32 @@
+/*++
+
+Copyright (c) 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ HardwareErrorVariable.h
+
+Abstract:
+
+ GUID for hardware error record variables. Defined in UEFI 2.1.
+
+--*/
+
+#ifndef _HARDWARE_ERROR_VARIABLE_GUID_H_
+#define _HARDWARE_ERROR_VARIABLE_GUID_H_
+
+#define EFI_HARDWARE_ERROR_VARIABLE_GUID \
+ { \
+ 0x414E6BDD, 0xE47B, 0x47cc, {0xB2, 0x44, 0xBB, 0x61, 0x02, 0x0C, 0xF5, 0x16} \
+ }
+
+extern EFI_GUID gEfiHardwareErrorVariableGuid;
+
+#endif \ No newline at end of file
diff --git a/EDK/Foundation/Efi/Guid/Mps/Mps.c b/EDK/Foundation/Efi/Guid/Mps/Mps.c
new file mode 100644
index 0000000..c5aa379
--- /dev/null
+++ b/EDK/Foundation/Efi/Guid/Mps/Mps.c
@@ -0,0 +1,33 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Mps.c
+
+Abstract:
+
+ GUIDs used for MPS entries in the in the EFI 1.0 system table
+
+ These GUIDs point the MPS tables as defined in the MPS 1.4 specifications.
+
+ ACPI is the primary means of exporting MP information to the OS. MPS obly was
+ included to support Itanium-based platform power on. So don't use it if you don't have too.
+
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_GUID_DEFINITION (Mps)
+
+EFI_GUID gEfiMpsTableGuid = EFI_MPS_TABLE_GUID;
+
+EFI_GUID_STRING(&gEfiMpsTableGuid, "MPS Table", "MPS Table GUID in EFI System Table");
diff --git a/EDK/Foundation/Efi/Guid/Mps/Mps.h b/EDK/Foundation/Efi/Guid/Mps/Mps.h
new file mode 100644
index 0000000..654c67b
--- /dev/null
+++ b/EDK/Foundation/Efi/Guid/Mps/Mps.h
@@ -0,0 +1,38 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Mps.h
+
+Abstract:
+
+ GUIDs used for MPS entries in the in the EFI 1.0 system table
+
+ These GUIDs point the MPS tables as defined in the MPS 1.4 specifications.
+
+ ACPI is the primary means of exporting MP information to the OS. MPS obly was
+ included to support Itanium-based platform power on. So don't use it if you don't have too.
+
+
+--*/
+
+#ifndef _MPS_GUID_H_
+#define _MPS_GUID_H_
+
+#define EFI_MPS_TABLE_GUID \
+ { \
+ 0xeb9d2d2f, 0x2d88, 0x11d3, 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d \
+ }
+
+extern EFI_GUID gEfiMpsTableGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Guid/PcAnsi/PcAnsi.c b/EDK/Foundation/Efi/Guid/PcAnsi/PcAnsi.c
new file mode 100644
index 0000000..96d1e00
--- /dev/null
+++ b/EDK/Foundation/Efi/Guid/PcAnsi/PcAnsi.c
@@ -0,0 +1,34 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PcAnsi.c
+
+Abstract:
+
+ Terminal Device Path Vendor Guid. Defined in EFI 1.0.
+
+--*/
+
+#include "EfiSpec.h"
+
+#include EFI_GUID_DEFINITION (PcAnsi)
+
+EFI_GUID gEfiPcAnsiGuid = EFI_PC_ANSI_GUID;
+EFI_GUID gEfiVT100Guid = EFI_VT_100_GUID;
+EFI_GUID gEfiVT100PlusGuid = EFI_VT_100_PLUS_GUID;
+EFI_GUID gEfiVTUTF8Guid = EFI_VT_UTF8_GUID;
+
+EFI_GUID_STRING(&gEfiPcAnsiGuid, "Efi", "Efi PC ANSI Device Path Vendor GUID")
+EFI_GUID_STRING(&gEfiVT100Guid, "Efi", "Efi VT100 Device Path Vendor GUID")
+EFI_GUID_STRING(&gEfiVT100PlusGuid, "Efi", "Efi VT100Plus Device Path Vendor GUID")
+EFI_GUID_STRING(&gEfiVTUTF8Guid, "Efi", "Efi VTUTF8 Device Path Vendor GUID")
diff --git a/EDK/Foundation/Efi/Guid/PcAnsi/PcAnsi.h b/EDK/Foundation/Efi/Guid/PcAnsi/PcAnsi.h
new file mode 100644
index 0000000..d9c1e57
--- /dev/null
+++ b/EDK/Foundation/Efi/Guid/PcAnsi/PcAnsi.h
@@ -0,0 +1,50 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PcAnsi.h
+
+Abstract:
+
+ Terminal Device Path Vendor Guid. Defined in EFI 1.0.
+
+--*/
+
+#ifndef _PC_ANSI_H_
+#define _PC_ANSI_H_
+
+#define EFI_PC_ANSI_GUID \
+ { \
+ 0xe0c14753, 0xf9be, 0x11d2, 0x9a, 0x0c, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d \
+ }
+
+#define EFI_VT_100_GUID \
+ { \
+ 0xdfa66065, 0xb419, 0x11d3, 0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d \
+ }
+
+#define EFI_VT_100_PLUS_GUID \
+ { \
+ 0x7baec70b, 0x57e0, 0x4c76, 0x8e, 0x87, 0x2f, 0x9e, 0x28, 0x08, 0x83, 0x43 \
+ }
+
+#define EFI_VT_UTF8_GUID \
+ { \
+ 0xad15a0d6, 0x8bec, 0x4acf, 0xa0, 0x73, 0xd0, 0x1d, 0xe7, 0x7e, 0x2d, 0x88 \
+ }
+
+extern EFI_GUID gEfiPcAnsiGuid;
+extern EFI_GUID gEfiVT100Guid;
+extern EFI_GUID gEfiVT100PlusGuid;
+extern EFI_GUID gEfiVTUTF8Guid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Guid/SalSystemTable/SalSystemTable.c b/EDK/Foundation/Efi/Guid/SalSystemTable/SalSystemTable.c
new file mode 100644
index 0000000..97bfb66
--- /dev/null
+++ b/EDK/Foundation/Efi/Guid/SalSystemTable/SalSystemTable.c
@@ -0,0 +1,30 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ SalSystemTable.c
+
+Abstract:
+
+ GUIDs used for SAL system table entries in the in the EFI 1.0 system table.
+
+ SAL System Table contains Itanium-based processor centric information about
+ the system.
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_GUID_DEFINITION (SalSystemTable)
+
+EFI_GUID gEfiSalSystemTableGuid = EFI_SAL_SYSTEM_TABLE_GUID;
+
+EFI_GUID_STRING(&gEfiSalSystemTableGuid, "SAL System Table", "SAL System Table GUID in EFI System Table");
diff --git a/EDK/Foundation/Efi/Guid/SalSystemTable/SalSystemTable.h b/EDK/Foundation/Efi/Guid/SalSystemTable/SalSystemTable.h
new file mode 100644
index 0000000..1da4dc0
--- /dev/null
+++ b/EDK/Foundation/Efi/Guid/SalSystemTable/SalSystemTable.h
@@ -0,0 +1,34 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ SalSystemTable.h
+
+Abstract:
+
+ GUIDs used for SAL system table entries in the in the EFI 1.0 system table.
+
+ SAL System Table contains Itanium-based processor centric information about
+ the system.
+
+--*/
+
+#ifndef _SAL_SYSTEM_TABLE_GUID_H_
+
+#define EFI_SAL_SYSTEM_TABLE_GUID \
+ { \
+ 0xeb9d2d32, 0x2d88, 0x11d3, 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d \
+ }
+
+extern EFI_GUID gEfiSalSystemTableGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Guid/SmBios/SmBios.c b/EDK/Foundation/Efi/Guid/SmBios/SmBios.c
new file mode 100644
index 0000000..470e36b
--- /dev/null
+++ b/EDK/Foundation/Efi/Guid/SmBios/SmBios.c
@@ -0,0 +1,31 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ SmBios.c
+
+Abstract:
+
+ GUIDs used to locate the SMBIOS tables in the EFI 1.0 system table.
+
+ This GUID in the system table is the only legal way to search for and
+ locate the SMBIOS tables. Do not search the 0xF0000 segment to find SMBIOS
+ tables.
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_GUID_DEFINITION (Smbios)
+
+EFI_GUID gEfiSmbiosTableGuid = EFI_SMBIOS_TABLE_GUID;
+
+EFI_GUID_STRING(&gEfiSmbiosTableGuid, "SMBIOS Table", "SMBIOS Table GUID in EFI System Table");
diff --git a/EDK/Foundation/Efi/Guid/SmBios/SmBios.h b/EDK/Foundation/Efi/Guid/SmBios/SmBios.h
new file mode 100644
index 0000000..f7297fc
--- /dev/null
+++ b/EDK/Foundation/Efi/Guid/SmBios/SmBios.h
@@ -0,0 +1,70 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ SmBios.h
+
+Abstract:
+
+ GUIDs used to locate the SMBIOS tables in the EFI 1.0 system table.
+
+ This GUID in the system table is the only legal way to search for and
+ locate the SMBIOS tables. Do not search the 0xF0000 segment to find SMBIOS
+ tables.
+
+--*/
+
+#ifndef _SMBIOS_GUID_H_
+#define _SMBIOS_GUID_H_
+
+#define EFI_SMBIOS_TABLE_GUID \
+ { \
+ 0xeb9d2d31, 0x2d88, 0x11d3, 0x9a, 0x16, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d \
+ }
+
+extern EFI_GUID gEfiSmbiosTableGuid;
+
+//
+// Smbios Table Entry Point Structure
+//
+#pragma pack(1)
+typedef struct {
+ UINT8 AnchorString[4];
+ UINT8 EntryPointStructureChecksum;
+ UINT8 EntryPointLength;
+ UINT8 MajorVersion;
+ UINT8 MinorVersion;
+ UINT16 MaxStructureSize;
+ UINT8 EntryPointRevision;
+ UINT8 FormattedArea[5];
+ UINT8 IntermediateAnchorString[5];
+ UINT8 IntermediateChecksum;
+ UINT16 TableLength;
+ UINT32 TableAddress;
+ UINT16 NumberOfSmbiosStructures;
+ UINT8 SmbiosBcdRevision;
+} SMBIOS_TABLE_ENTRY_POINT;
+#pragma pack()
+//
+// The Smbios structure header
+//
+#pragma pack(1)
+typedef struct {
+
+ UINT8 Type;
+ UINT8 Length;
+ UINT16 Handle;
+
+} SMBIOS_STRUCTURE;
+#pragma pack()
+
+#endif
diff --git a/EDK/Foundation/Efi/Include/EfiApi.h b/EDK/Foundation/Efi/Include/EfiApi.h
new file mode 100644
index 0000000..828950c
--- /dev/null
+++ b/EDK/Foundation/Efi/Include/EfiApi.h
@@ -0,0 +1,1114 @@
+/*++
+
+Copyright (c) 2004 - 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiApi.h
+
+Abstract:
+
+ EFI intrinsic definitions. This includes all EFI 1.0 boot and runtime
+ services APIs.
+
+ Drivers and applications are passed in a pointer to the EFI system table.
+ The EFI system table contains pointers to the boot and runtime services
+ tables.
+
+--*/
+
+#ifndef _EFI_API_H_
+#define _EFI_API_H_
+
+#include EFI_PROTOCOL_DEFINITION (DevicePath)
+#include EFI_PROTOCOL_DEFINITION (SimpleTextIn)
+#include EFI_PROTOCOL_DEFINITION (SimpleTextOut)
+
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+#include "EfiCapsule.h"
+#else
+#include "EfiStatusCode.h"
+#endif
+
+//
+// Declare forward referenced data structures
+//
+EFI_FORWARD_DECLARATION (EFI_SYSTEM_TABLE);
+
+//
+// EFI Memory
+//
+typedef
+EFI_BOOTSERVICE
+EFI_STATUS
+(EFIAPI *EFI_ALLOCATE_PAGES) (
+ IN EFI_ALLOCATE_TYPE Type,
+ IN EFI_MEMORY_TYPE MemoryType,
+ IN UINTN NoPages,
+ OUT EFI_PHYSICAL_ADDRESS * Memory
+ );
+
+typedef
+EFI_BOOTSERVICE
+EFI_STATUS
+(EFIAPI *EFI_FREE_PAGES) (
+ IN EFI_PHYSICAL_ADDRESS Memory,
+ IN UINTN NoPages
+ );
+
+typedef
+EFI_BOOTSERVICE
+EFI_STATUS
+(EFIAPI *EFI_GET_MEMORY_MAP) (
+ IN OUT UINTN *MemoryMapSize,
+ IN OUT EFI_MEMORY_DESCRIPTOR * MemoryMap,
+ OUT UINTN *MapKey,
+ OUT UINTN *DescriptorSize,
+ OUT UINT32 *DescriptorVersion
+ );
+
+#define NextMemoryDescriptor(_Ptr, _Size) ((EFI_MEMORY_DESCRIPTOR *) (((UINT8 *) (_Ptr)) + (_Size)))
+#define NEXT_MEMORY_DESCRIPTOR(_Ptr, _Size) NextMemoryDescriptor (_Ptr, _Size)
+
+typedef
+EFI_BOOTSERVICE
+EFI_STATUS
+(EFIAPI *EFI_ALLOCATE_POOL) (
+ IN EFI_MEMORY_TYPE PoolType,
+ IN UINTN Size,
+ OUT VOID **Buffer
+ );
+
+typedef
+EFI_BOOTSERVICE
+EFI_STATUS
+(EFIAPI *EFI_FREE_POOL) (
+ IN VOID *Buffer
+ );
+
+typedef
+EFI_RUNTIMESERVICE
+EFI_STATUS
+(EFIAPI *EFI_SET_VIRTUAL_ADDRESS_MAP) (
+ IN UINTN MemoryMapSize,
+ IN UINTN DescriptorSize,
+ IN UINT32 DescriptorVersion,
+ IN EFI_MEMORY_DESCRIPTOR * VirtualMap
+ );
+
+typedef
+EFI_BOOTSERVICE11
+EFI_STATUS
+(EFIAPI *EFI_CONNECT_CONTROLLER) (
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE * DriverImageHandle OPTIONAL,
+ IN EFI_DEVICE_PATH_PROTOCOL * RemainingDevicePath OPTIONAL,
+ IN BOOLEAN Recursive
+ );
+
+typedef
+EFI_BOOTSERVICE11
+EFI_STATUS
+(EFIAPI *EFI_DISCONNECT_CONTROLLER) (
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE DriverImageHandle, OPTIONAL
+ IN EFI_HANDLE ChildHandle OPTIONAL
+ );
+
+//
+// ConvertPointer DebugDisposition type.
+//
+#define EFI_OPTIONAL_POINTER 0x00000001
+
+typedef
+EFI_RUNTIMESERVICE
+EFI_STATUS
+(EFIAPI *EFI_CONVERT_POINTER) (
+ IN UINTN DebugDisposition,
+ IN OUT VOID **Address
+ );
+
+//
+// EFI Event Types
+//
+#define EFI_EVENT_TIMER 0x80000000
+#define EFI_EVENT_RUNTIME 0x40000000
+#define EFI_EVENT_RUNTIME_CONTEXT 0x20000000
+
+#define EFI_EVENT_NOTIFY_WAIT 0x00000100
+#define EFI_EVENT_NOTIFY_SIGNAL 0x00000200
+
+#define EFI_EVENT_SIGNAL_EXIT_BOOT_SERVICES 0x00000201
+#define EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE 0x60000202
+
+#define EFI_EVENT_EFI_SIGNAL_MASK 0x000000FF
+#define EFI_EVENT_EFI_SIGNAL_MAX 4
+
+typedef
+VOID
+(EFIAPI *EFI_EVENT_NOTIFY) (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ );
+
+typedef
+EFI_BOOTSERVICE
+EFI_STATUS
+(EFIAPI *EFI_CREATE_EVENT) (
+ IN UINT32 Type,
+ IN EFI_TPL NotifyTpl,
+ IN EFI_EVENT_NOTIFY NotifyFunction,
+ IN VOID *NotifyContext,
+ OUT EFI_EVENT * Event
+ );
+
+typedef
+EFI_BOOTSERVICE
+EFI_STATUS
+(EFIAPI *EFI_CREATE_EVENT_EX) (
+ IN UINT32 Type,
+ IN EFI_TPL NotifyTpl OPTIONAL,
+ IN EFI_EVENT_NOTIFY NotifyFunction OPTIONAL,
+ IN CONST VOID *NotifyContext OPTIONAL,
+ IN CONST EFI_GUID *EventGroup OPTIONAL,
+ OUT EFI_EVENT *Event
+ );
+
+typedef enum {
+ TimerCancel,
+ TimerPeriodic,
+ TimerRelative,
+ TimerTypeMax
+} EFI_TIMER_DELAY;
+
+typedef
+EFI_BOOTSERVICE
+EFI_STATUS
+(EFIAPI *EFI_SET_TIMER) (
+ IN EFI_EVENT Event,
+ IN EFI_TIMER_DELAY Type,
+ IN UINT64 TriggerTime
+ );
+
+typedef
+EFI_BOOTSERVICE
+EFI_STATUS
+(EFIAPI *EFI_SIGNAL_EVENT) (
+ IN EFI_EVENT Event
+ );
+
+typedef
+EFI_BOOTSERVICE
+EFI_STATUS
+(EFIAPI *EFI_WAIT_FOR_EVENT) (
+ IN UINTN NumberOfEvents,
+ IN EFI_EVENT * Event,
+ OUT UINTN *Index
+ );
+
+typedef
+EFI_BOOTSERVICE
+EFI_STATUS
+(EFIAPI *EFI_CLOSE_EVENT) (
+ IN EFI_EVENT Event
+ );
+
+typedef
+EFI_BOOTSERVICE
+EFI_STATUS
+(EFIAPI *EFI_CHECK_EVENT) (
+ IN EFI_EVENT Event
+ );
+
+//
+// Task priority level
+//
+#define EFI_TPL_APPLICATION 4
+#define EFI_TPL_CALLBACK 8
+#define EFI_TPL_NOTIFY 16
+#define EFI_TPL_HIGH_LEVEL 31
+
+typedef
+EFI_BOOTSERVICE
+EFI_TPL
+(EFIAPI *EFI_RAISE_TPL) (
+ IN EFI_TPL NewTpl
+ );
+
+typedef
+EFI_BOOTSERVICE
+VOID
+(EFIAPI *EFI_RESTORE_TPL) (
+ IN EFI_TPL OldTpl
+ );
+
+//
+// Variable attributes
+//
+#define EFI_VARIABLE_NON_VOLATILE 0x00000001
+#define EFI_VARIABLE_BOOTSERVICE_ACCESS 0x00000002
+#define EFI_VARIABLE_RUNTIME_ACCESS 0x00000004
+
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
+#define EFI_VARIABLE_HARDWARE_ERROR_RECORD 0x00000008
+#endif
+
+typedef
+EFI_RUNTIMESERVICE
+EFI_STATUS
+(EFIAPI *EFI_GET_VARIABLE) (
+ IN CHAR16 *VariableName,
+ IN EFI_GUID * VendorGuid,
+ OUT UINT32 *Attributes OPTIONAL,
+ IN OUT UINTN *DataSize,
+ OUT VOID *Data
+ );
+
+typedef
+EFI_RUNTIMESERVICE
+EFI_STATUS
+(EFIAPI *EFI_GET_NEXT_VARIABLE_NAME) (
+ IN OUT UINTN *VariableNameSize,
+ IN OUT CHAR16 *VariableName,
+ IN OUT EFI_GUID * VendorGuid
+ );
+
+typedef
+EFI_RUNTIMESERVICE
+EFI_STATUS
+(EFIAPI *EFI_SET_VARIABLE) (
+ IN CHAR16 *VariableName,
+ IN EFI_GUID * VendorGuid,
+ IN UINT32 Attributes,
+ IN UINTN DataSize,
+ IN VOID *Data
+ );
+
+//
+// EFI Time
+//
+typedef struct {
+ UINT32 Resolution;
+ UINT32 Accuracy;
+ BOOLEAN SetsToZero;
+} EFI_TIME_CAPABILITIES;
+
+typedef
+EFI_RUNTIMESERVICE
+EFI_STATUS
+(EFIAPI *EFI_GET_TIME) (
+ OUT EFI_TIME * Time,
+ OUT EFI_TIME_CAPABILITIES * Capabilities OPTIONAL
+ );
+
+typedef
+EFI_RUNTIMESERVICE
+EFI_STATUS
+(EFIAPI *EFI_SET_TIME) (
+ IN EFI_TIME * Time
+ );
+
+typedef
+EFI_RUNTIMESERVICE
+EFI_STATUS
+(EFIAPI *EFI_GET_WAKEUP_TIME) (
+ OUT BOOLEAN *Enabled,
+ OUT BOOLEAN *Pending,
+ OUT EFI_TIME * Time
+ );
+
+typedef
+EFI_RUNTIMESERVICE
+EFI_STATUS
+(EFIAPI *EFI_SET_WAKEUP_TIME) (
+ IN BOOLEAN Enable,
+ IN EFI_TIME * Time OPTIONAL
+ );
+
+//
+// Image Entry prototype
+//
+typedef
+EFI_STATUS
+(EFIAPI *EFI_IMAGE_ENTRY_POINT) (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE * SystemTable
+ );
+
+//
+// Image functions
+//
+typedef
+EFI_BOOTSERVICE
+EFI_STATUS
+(EFIAPI *EFI_IMAGE_LOAD) (
+ IN BOOLEAN BootPolicy,
+ IN EFI_HANDLE ParentImageHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL * FilePath,
+ IN VOID *SourceBuffer OPTIONAL,
+ IN UINTN SourceSize,
+ OUT EFI_HANDLE * ImageHandle
+ );
+
+typedef
+EFI_BOOTSERVICE
+EFI_STATUS
+(EFIAPI *EFI_IMAGE_START) (
+ IN EFI_HANDLE ImageHandle,
+ OUT UINTN *ExitDataSize,
+ OUT CHAR16 **ExitData OPTIONAL
+ );
+
+typedef
+EFI_BOOTSERVICE
+EFI_STATUS
+(EFIAPI *EFI_EXIT) (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_STATUS ExitStatus,
+ IN UINTN ExitDataSize,
+ IN CHAR16 *ExitData OPTIONAL
+ );
+
+typedef
+EFI_BOOTSERVICE
+EFI_STATUS
+(EFIAPI *EFI_IMAGE_UNLOAD) (
+ IN EFI_HANDLE ImageHandle
+ );
+
+typedef
+EFI_BOOTSERVICE
+EFI_STATUS
+(EFIAPI *EFI_EXIT_BOOT_SERVICES) (
+ IN EFI_HANDLE ImageHandle,
+ IN UINTN MapKey
+ );
+
+//
+// Misc
+//
+typedef
+EFI_BOOTSERVICE
+EFI_STATUS
+(EFIAPI *EFI_STALL) (
+ IN UINTN Microseconds
+ );
+
+typedef
+EFI_BOOTSERVICE
+EFI_STATUS
+(EFIAPI *EFI_SET_WATCHDOG_TIMER) (
+ IN UINTN Timeout,
+ IN UINT64 WatchdogCode,
+ IN UINTN DataSize,
+ IN CHAR16 *WatchdogData OPTIONAL
+ );
+
+typedef enum {
+ EfiResetCold,
+ EfiResetWarm,
+ EfiResetShutdown,
+
+#if ((TIANO_RELEASE_VERSION != 0) && (EFI_SPECIFICATION_VERSION < 0x00020000))
+ EfiResetUpdate
+#endif
+
+} EFI_RESET_TYPE;
+
+typedef
+EFI_RUNTIMESERVICE
+VOID
+(EFIAPI *EFI_RESET_SYSTEM) (
+ IN EFI_RESET_TYPE ResetType,
+ IN EFI_STATUS ResetStatus,
+ IN UINTN DataSize,
+ IN CHAR16 *ResetData OPTIONAL
+ );
+
+typedef
+EFI_BOOTSERVICE
+EFI_STATUS
+(EFIAPI *EFI_GET_NEXT_MONOTONIC_COUNT) (
+ OUT UINT64 *Count
+ );
+
+typedef
+EFI_RUNTIMESERVICE
+EFI_STATUS
+(EFIAPI *EFI_GET_NEXT_HIGH_MONO_COUNT) (
+ OUT UINT32 *HighCount
+ );
+
+typedef
+EFI_BOOTSERVICE
+EFI_STATUS
+(EFIAPI *EFI_CALCULATE_CRC32) (
+ IN VOID *Data,
+ IN UINTN DataSize,
+ OUT UINT32 *Crc32
+ );
+
+typedef
+EFI_BOOTSERVICE
+VOID
+(EFIAPI *EFI_COPY_MEM) (
+ IN VOID *Destination,
+ IN VOID *Source,
+ IN UINTN Length
+ );
+
+typedef
+EFI_BOOTSERVICE
+VOID
+(EFIAPI *EFI_SET_MEM) (
+ IN VOID *Buffer,
+ IN UINTN Size,
+ IN UINT8 Value
+ );
+
+//
+// Protocol handler functions
+//
+typedef enum {
+ EFI_NATIVE_INTERFACE
+} EFI_INTERFACE_TYPE;
+
+typedef
+EFI_BOOTSERVICE
+EFI_STATUS
+(EFIAPI *EFI_INSTALL_PROTOCOL_INTERFACE) (
+ IN OUT EFI_HANDLE * Handle,
+ IN EFI_GUID * Protocol,
+ IN EFI_INTERFACE_TYPE InterfaceType,
+ IN VOID *Interface
+ );
+
+typedef
+EFI_BOOTSERVICE11
+EFI_STATUS
+(EFIAPI *EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES) (
+ IN OUT EFI_HANDLE * Handle,
+ ...
+ );
+
+typedef
+EFI_BOOTSERVICE
+EFI_STATUS
+(EFIAPI *EFI_REINSTALL_PROTOCOL_INTERFACE) (
+ IN EFI_HANDLE Handle,
+ IN EFI_GUID * Protocol,
+ IN VOID *OldInterface,
+ IN VOID *NewInterface
+ );
+
+typedef
+EFI_BOOTSERVICE
+EFI_STATUS
+(EFIAPI *EFI_UNINSTALL_PROTOCOL_INTERFACE) (
+ IN EFI_HANDLE Handle,
+ IN EFI_GUID * Protocol,
+ IN VOID *Interface
+ );
+
+typedef
+EFI_BOOTSERVICE11
+EFI_STATUS
+(EFIAPI *EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES) (
+ IN EFI_HANDLE Handle,
+ ...
+ );
+
+typedef
+EFI_BOOTSERVICE
+EFI_STATUS
+(EFIAPI *EFI_HANDLE_PROTOCOL) (
+ IN EFI_HANDLE Handle,
+ IN EFI_GUID * Protocol,
+ OUT VOID **Interface
+ );
+
+#define EFI_OPEN_PROTOCOL_BY_HANDLE_PROTOCOL 0x00000001
+#define EFI_OPEN_PROTOCOL_GET_PROTOCOL 0x00000002
+#define EFI_OPEN_PROTOCOL_TEST_PROTOCOL 0x00000004
+#define EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER 0x00000008
+#define EFI_OPEN_PROTOCOL_BY_DRIVER 0x00000010
+#define EFI_OPEN_PROTOCOL_EXCLUSIVE 0x00000020
+
+//
+// ///////////////////////////////////////////////////////////////////////////////////////////////
+// OpenProtocol() Attribute Values
+/////////////////////////////////////////////////////////////////////////////////////////////////
+// BY_HANDLE_PROTOCOL - Used by EFI 1.0 Drivers and Applications
+// May not actually add an elemnt to the open list in a production build
+//
+// GET_PROTOCOL - Used by EFI 1.1 Drivers to get a protocol interface
+// May not actually add an elemnt to the open list in a production build
+//
+// TEST_PROTOCOL - Used by EFI 1.1 Drivers to test for the existence of a protocol interface
+// The interface is not returned, and it is an optional parameter tham may be NULL.
+// May not actually add an elemnt to the open list in a production build
+//
+// BY_DRIVER - Used by EFI 1.1 Drivers that are able to share a protocol with other
+// agents other than its children. A driver is always able to share
+// a protocol with its children, since the driver is in control of the
+// parent controller's and the child controller's use of the protocol.
+//
+// BY_DRIVER | EXCLUSIVE - Used by EFI 1.1 Drivers that will not share a protocol with any other
+// agents except its children. A driver is always able to share
+// a protocol with its children, since the driver is in control of the
+// parent controller's and the child controller's use of the protocol.
+// This attribute will force all other drivers to disconnect from the protocol
+// before this driver attaches. When this driver closes the handle, the other
+// drivers will reconnect to the protocol.
+//
+//
+// BY_CHILD_CONTROLLER - Used by EFI 1.1 Driver to show that a protocol is consumed by a child
+// of the driver. This is information used by DisconnectController() to
+// determine the list of children that a protocol has. It has
+// no affect on the OpenProtocol()/ClosePrototocol() behavior.
+//
+// EXCLUSIVE - Used by EFI 1.1 Applications to gain exclusive access to a protocol.
+// All drivers are disconnected from the handle while the application has
+// the handle open. These drivers are reconnected when the application
+// closes the handle.
+//
+/////////////////////////////////////////////////////////////////////////////////////////////////
+// OpenProtocol() behavior based on Attribute values
+/////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// OpenProtocol (Handle, Protocol, Interface, ImageHandle, DeviceHandle, Attributes)
+// * EFI_UNSUPPORTED if Protocol does not exist on Handle
+// * EFI_INVALID_PARAMETER if Handle is not a valid handle.
+// * EFI_INVALID_PARAMETER if Protocol is NULL or not a valid GUID
+// * EFI_INVALID_PARAMETER if Interface is NULL
+// * EFI_INVALID_PARAMETER if Attributes is not one of the following values:
+// BY_HANDLE_PROTOCOL
+// GET_PROTOCOL
+// TEST_PROTOCOL
+// BY_CHILD_CONTROLLER
+// BY_DRIVER
+// BY_DRIVER | EXCLUSIVE
+// EXCLUSIVE
+// * EFI_INVALID_PARAMETER if Attributes BY_CHILD_CONTROLLER and ImageHandle is not a valid handle
+// * EFI_INVALID_PARAMETER if Attributes BY_CHILD_CONTROLLER and DeviceHandle is not a valid handle
+// * EFI_INVALID_PARAMETER if Attributes BY_CHILD_CONTROLLER and Handle == DeviceHandle
+// * EFI_INVALID_PARAMETER if Attributes BY_DRIVER and ImageHandle is not a valid handle
+// * EFI_INVALID_PARAMETER if Attributes BY_DRIVER and DeviceHandle is not a valid handle
+// * EFI_INVALID_PARAMETER if Attributes BY_DRIVER | EXCLUSIVE and ImageHandle is not a valid handle
+// * EFI_INVALID_PARAMETER if Attributes BY_DRIVER | EXCLUSIVE and DeviceHandle is not a valid handle
+// * EFI_INVALID_PARAMETER if Attributes EXCLUSIVE and ImageHandle is not a valid handle
+//
+// OpenProtocol() Attributes = BY_HANDLE_PROTOCOL, GET_PROTOCOL, TEST_PROTOCOL, BY_CHILD_CONTROLLER
+// * EFI_SUCCESS if Protocol exists on the Handle
+//
+// OpenProtocol() Attributes = BY_DRIVER
+// * EFI_SUCCESS if there are no items in the Open List for (Handle, Protocol)
+// * EFI_SUCCESS if there are only items in the Open List for (Handle, Protocol)
+// that have the one of the following Attributes
+// BY_HANDLE_PROTOCOL
+// GET_PROTOCOL
+// TEST_PROTOCOL
+// BY_CHILD_CONTROLLER
+// * EFI_ACCESS_DENIED if there are any items in the Open List for (Handle, Protocol)
+// that have the one of the following Attributes
+// BY_DRIVER
+// AND ImageHandle != OpenListItem.IH
+// * EFI_ALREADY_STARTED if there are any items in the Open List for (Handle, Protocol)
+// that have the one of the following Attributes
+// BY_DRIVER
+// AND ImageHandle == OpenListItem.IH
+// * EFI_ACCESS_DENIED if there are any items in the Open List for (Handle, Protocol)
+// that have the one of the following Attributes
+// BY_DRIVER | EXCLUSIVE
+// EXCLUSIVE
+//
+// OpenProtocol() Attributes = BY_DRIVER | EXCLUSIVE
+// * EFI_SUCCESS if there are no items in the Open List for (Handle, Protocol)
+// * EFI_SUCCESS if there are only items in the Open List for (Handle, Protocol)
+// that have the one of the following Attributes
+// BY_HANDLE_PROTOCOL
+// GET_PROTOCOL
+// TEST_PROTOCOL
+// BY_CHILD_CONTROLLER
+// * EFI_SUCCESS if there are any items in the Open List for (Handle, Protocol)
+// that have the one of the following Attributes
+// BY_DRIVER
+// AND the driver is removed by DisconnectController(IH,DH)
+// * EFI_ALREADY_STARTED if there are any items in the Open List for (Handle, Protocol)
+// that have the one of the following Attributes
+// BY_DRIVER | EXCLUSIVE
+// AND ImageHandle == OpenListItem.IH
+// * EFI_ACCESS_DENIED if there are any items in the Open List for (Handle, Protocol)
+// that have the one of the following Attributes
+// BY_DRIVER
+// AND the driver can not be removed by DisconnectController(IH,DH)
+// * EFI_ACCESS_DENIED if there are any items in the Open List for (Handle, Protocol)
+// that have the one of the following Attributes
+// BY_DRIVER | EXCLUSIVE
+// EXCLUSIVE
+//
+// OpenProtocol() Attributes = EXCLUSIVE
+// * EFI_SUCCESS if there are no items in the Open List for (Handle, Protocol)
+// * EFI_SUCCESS if there are only items in the Open List for (Handle, Protocol)
+// that have the one of the following Attributes
+// BY_HANDLE_PROTOCOL
+// GET_PROTOCOL
+// TEST_PROTOCOL
+// BY_CHILD_CONTROLLER
+// * EFI_SUCCESS if there are any items in the Open List for (Handle, Protocol)
+// that have the one of the following Attributes
+// BY_DRIVER
+// AND the driver is removed by DisconnectController(IH,DH)
+// * EFI_ACCESS_DENIED if there are any items in the Open List for (Handle, Protocol)
+// that have the one of the following Attributes
+// BY_DRIVER
+// AND the driver can not be removed by DisconnectController(IH,DH)
+// * EFI_ACCESS_DENIED if there are any items in the Open List for (Handle, Protocol)
+// that have the one of the following Attributes
+// BY_DRIVER | EXCLUSIVE
+// EXCLUSIVE
+//
+/////////////////////////////////////////////////////////////////////////////////////////////////
+// CloseProtocol() Behavior based on the Attributes of the item being closed and the items
+// remaining on the Open List
+/////////////////////////////////////////////////////////////////////////////////////////////////
+// CloseProtocol(Handle, Protocol, ImageHandle, DeviceHandle)
+// CloseProtocol() Attributes of item = BY_HANDLE_PROTOCOL,
+// GET_PROTOCOL
+// TEST_PROTOCOL
+// BY_CHILD_CONTROLLER,
+// BY_DRIVER
+// BY_DRIVER | EXCLUSIVE
+// EXCLUSIVE
+// EFI_NOT_FOUND if Protocol does not exist on Handle
+// EFI_INVALID_PARAMETER if Handle is not a valid handle.
+// EFI_INVALID_PARAMETER if Protocol is NULL or not a valid GUID
+// EFI_INVALID_PARAMETER if ImageHandle is not a valid handle
+// EFI_INVALID_PARAMETER if DeviceHandle is not a valid handle
+// EFI_NOT_FOUND if (ImageHandle, DeviceHandle) is not present in the Open List
+// for (Handle, Protocol)
+// EFI_ACCESS_DENIED if (ImageHandle, DeviceHandle) is present in the Open List
+// for (Handle, Protocol), but the item can not be removed.
+// EFI_SUCCESS if (ImageHandle, DeviceHandle) is present in the Open List
+// for (Handle, Protocol), and the item can be removed.
+//
+/////////////////////////////////////////////////////////////////////////////////////////////////
+// UninstallProtocolInterface() behavior
+/////////////////////////////////////////////////////////////////////////////////////////////////
+//
+// UninstallProtocolInterface (Handle, Protocol, Interface)
+//
+// EFI_INVALID_PARAMETER if Handle is not a valid handle.
+// EFI_INVALID_PARAMETER if Protocol is not a vlaid GUID
+// EFI_NOT_FOUND if Handle doe not support Protocol
+// EFI_NOT_FOUND if the interface for (Handle, Protocol) does not match Interface
+// EFI_ACCESS_DENIED if the list of Open Items for (Handle, Protocol) can not be removed
+// EFI_SUCCESS if the list of Open Items is empty, and Protocol is removed from Handle
+//
+// Algorithm to remove Open Item List:
+//
+// Loop through all Open Item List entries
+// if (OpenItem.Attributes & BY_DRIVER) then
+// DisconnectController (OpenItem.IH, OpenItem.DH)
+// end if
+// end loop
+// Loop through all Open Item List entries
+// if (OpenItem.Attributes & BY_HANDLE_PROTOCOL or GET_PROTOCOL or TEST_PROTOCOL) then
+// CloseProtocol (Handle, Protocol, OpenItem.IH, OpenItem.DH)
+// end if
+// end loop
+// if Open Item List is empty then remove Protocol from Handle and return EFI_SUCCESS
+// if Open Item List is not empty then return EFI_ACCESS_DENIED
+//
+/////////////////////////////////////////////////////////////////////////////////////////////////
+typedef
+EFI_BOOTSERVICE11
+EFI_STATUS
+(EFIAPI *EFI_OPEN_PROTOCOL) (
+ IN EFI_HANDLE Handle,
+ IN EFI_GUID * Protocol,
+ OUT VOID **Interface,
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_HANDLE ControllerHandle, OPTIONAL
+ IN UINT32 Attributes
+ );
+
+typedef
+EFI_BOOTSERVICE11
+EFI_STATUS
+(EFIAPI *EFI_CLOSE_PROTOCOL) (
+ IN EFI_HANDLE Handle,
+ IN EFI_GUID * Protocol,
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_HANDLE DeviceHandle
+ );
+
+typedef struct {
+ EFI_HANDLE AgentHandle;
+ EFI_HANDLE ControllerHandle;
+ UINT32 Attributes;
+ UINT32 OpenCount;
+} EFI_OPEN_PROTOCOL_INFORMATION_ENTRY;
+
+typedef
+EFI_BOOTSERVICE11
+EFI_STATUS
+(EFIAPI *EFI_OPEN_PROTOCOL_INFORMATION) (
+ IN EFI_HANDLE UserHandle,
+ IN EFI_GUID * Protocol,
+ IN EFI_OPEN_PROTOCOL_INFORMATION_ENTRY **EntryBuffer,
+ OUT UINTN *EntryCount
+ );
+
+typedef
+EFI_BOOTSERVICE11
+EFI_STATUS
+(EFIAPI *EFI_PROTOCOLS_PER_HANDLE) (
+ IN EFI_HANDLE UserHandle,
+ OUT EFI_GUID ***ProtocolBuffer,
+ OUT UINTN *ProtocolBufferCount
+ );
+
+typedef
+EFI_BOOTSERVICE
+EFI_STATUS
+(EFIAPI *EFI_REGISTER_PROTOCOL_NOTIFY) (
+ IN EFI_GUID * Protocol,
+ IN EFI_EVENT Event,
+ OUT VOID **Registration
+ );
+
+typedef enum {
+ AllHandles,
+ ByRegisterNotify,
+ ByProtocol
+} EFI_LOCATE_SEARCH_TYPE;
+
+typedef
+EFI_BOOTSERVICE
+EFI_STATUS
+(EFIAPI *EFI_LOCATE_HANDLE) (
+ IN EFI_LOCATE_SEARCH_TYPE SearchType,
+ IN EFI_GUID * Protocol OPTIONAL,
+ IN VOID *SearchKey OPTIONAL,
+ IN OUT UINTN *BufferSize,
+ OUT EFI_HANDLE * Buffer
+ );
+
+typedef
+EFI_BOOTSERVICE
+EFI_STATUS
+(EFIAPI *EFI_LOCATE_DEVICE_PATH) (
+ IN EFI_GUID * Protocol,
+ IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath,
+ OUT EFI_HANDLE * Device
+ );
+
+typedef
+EFI_BOOTSERVICE
+EFI_STATUS
+(EFIAPI *EFI_INSTALL_CONFIGURATION_TABLE) (
+ IN EFI_GUID * Guid,
+ IN VOID *Table
+ );
+
+typedef
+EFI_BOOTSERVICE
+EFI_STATUS
+(EFIAPI *EFI_RESERVED_SERVICE) (
+ VOID
+ );
+
+typedef
+EFI_BOOTSERVICE11
+EFI_STATUS
+(EFIAPI *EFI_LOCATE_HANDLE_BUFFER) (
+ IN EFI_LOCATE_SEARCH_TYPE SearchType,
+ IN EFI_GUID * Protocol OPTIONAL,
+ IN VOID *SearchKey OPTIONAL,
+ IN OUT UINTN *NumberHandles,
+ OUT EFI_HANDLE **Buffer
+ );
+
+typedef
+EFI_BOOTSERVICE11
+EFI_STATUS
+(EFIAPI *EFI_LOCATE_PROTOCOL) (
+ EFI_GUID * Protocol,
+ VOID *Registration, OPTIONAL
+ VOID **Interface
+ );
+
+//
+// Definition of Status Code extended data header
+//
+// HeaderSize The size of the architecture. This is specified to enable
+// the future expansion
+//
+// Size The size of the data in bytes. This does not include the size
+// of the header structure.
+//
+// Type A GUID defining the type of the data
+//
+//
+#if ((TIANO_RELEASE_VERSION != 0) && (EFI_SPECIFICATION_VERSION < 0x00020000))
+
+typedef
+EFI_RUNTIMESERVICE
+EFI_STATUS
+(EFIAPI *EFI_REPORT_STATUS_CODE) (
+ IN EFI_STATUS_CODE_TYPE Type,
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN UINT32 Instance,
+ IN EFI_GUID * CallerId OPTIONAL,
+ IN EFI_STATUS_CODE_DATA * Data OPTIONAL
+ );
+
+#endif
+
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+
+typedef
+EFI_RUNTIMESERVICE
+EFI_STATUS
+(EFIAPI *EFI_UPDATE_CAPSULE) (
+ IN EFI_CAPSULE_HEADER **CapsuleHeaderArray,
+ IN UINTN CapsuleCount,
+ IN EFI_PHYSICAL_ADDRESS ScatterGatherList OPTIONAL
+ );
+
+
+typedef
+EFI_RUNTIMESERVICE
+EFI_STATUS
+(EFIAPI *EFI_QUERY_CAPSULE_CAPABILITIES) (
+ IN EFI_CAPSULE_HEADER **CapsuleHeaderArray,
+ IN UINTN CapsuleCount,
+ OUT UINT64 *MaxiumCapsuleSize,
+ OUT EFI_RESET_TYPE *ResetType
+);
+
+typedef
+EFI_RUNTIMESERVICE
+EFI_STATUS
+(EFIAPI *EFI_QUERY_VARIABLE_INFO) (
+ IN UINT32 Attributes,
+ OUT UINT64 *MaximumVariableStorageSize,
+ OUT UINT64 *RemainingVariableStorageSize,
+ OUT UINT64 *MaximumVariableSize
+ );
+
+#endif
+
+//
+// EFI Runtime Services Table
+//
+#define EFI_RUNTIME_SERVICES_SIGNATURE 0x56524553544e5552
+#define EFI_RUNTIME_SERVICES_REVISION EFI_SPECIFICATION_VERSION
+
+typedef struct {
+ EFI_TABLE_HEADER Hdr;
+
+ //
+ // Time services
+ //
+ EFI_GET_TIME GetTime;
+ EFI_SET_TIME SetTime;
+ EFI_GET_WAKEUP_TIME GetWakeupTime;
+ EFI_SET_WAKEUP_TIME SetWakeupTime;
+
+ //
+ // Virtual memory services
+ //
+ EFI_SET_VIRTUAL_ADDRESS_MAP SetVirtualAddressMap;
+ EFI_CONVERT_POINTER ConvertPointer;
+
+ //
+ // Variable services
+ //
+ EFI_GET_VARIABLE GetVariable;
+ EFI_GET_NEXT_VARIABLE_NAME GetNextVariableName;
+ EFI_SET_VARIABLE SetVariable;
+
+ //
+ // Misc
+ //
+ EFI_GET_NEXT_HIGH_MONO_COUNT GetNextHighMonotonicCount;
+ EFI_RESET_SYSTEM ResetSystem;
+
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+ //
+ // New Boot Service added by UEFI 2.0
+ //
+ EFI_UPDATE_CAPSULE UpdateCapsule;
+ EFI_QUERY_CAPSULE_CAPABILITIES QueryCapsuleCapabilities;
+ EFI_QUERY_VARIABLE_INFO QueryVariableInfo;
+#elif (TIANO_RELEASE_VERSION != 0)
+ //
+ // Tiano extension to EFI 1.10 runtime table
+ // It was moved to a protocol to not conflict with UEFI 2.0
+ // If Tiano is disabled, this item is not enabled for EFI1.10
+ //
+ EFI_REPORT_STATUS_CODE ReportStatusCode;
+#endif
+
+} EFI_RUNTIME_SERVICES;
+
+//
+// EFI Boot Services Table
+//
+#define EFI_BOOT_SERVICES_SIGNATURE 0x56524553544f4f42
+#define EFI_BOOT_SERVICES_REVISION EFI_SPECIFICATION_VERSION
+
+typedef struct {
+ EFI_TABLE_HEADER Hdr;
+
+ //
+ // Task priority functions
+ //
+ EFI_RAISE_TPL RaiseTPL;
+ EFI_RESTORE_TPL RestoreTPL;
+
+ //
+ // Memory functions
+ //
+ EFI_ALLOCATE_PAGES AllocatePages;
+ EFI_FREE_PAGES FreePages;
+ EFI_GET_MEMORY_MAP GetMemoryMap;
+ EFI_ALLOCATE_POOL AllocatePool;
+ EFI_FREE_POOL FreePool;
+
+ //
+ // Event & timer functions
+ //
+ EFI_CREATE_EVENT CreateEvent;
+ EFI_SET_TIMER SetTimer;
+ EFI_WAIT_FOR_EVENT WaitForEvent;
+ EFI_SIGNAL_EVENT SignalEvent;
+ EFI_CLOSE_EVENT CloseEvent;
+ EFI_CHECK_EVENT CheckEvent;
+
+ //
+ // Protocol handler functions
+ //
+ EFI_INSTALL_PROTOCOL_INTERFACE InstallProtocolInterface;
+ EFI_REINSTALL_PROTOCOL_INTERFACE ReinstallProtocolInterface;
+ EFI_UNINSTALL_PROTOCOL_INTERFACE UninstallProtocolInterface;
+ EFI_HANDLE_PROTOCOL HandleProtocol;
+ VOID *Reserved;
+ EFI_REGISTER_PROTOCOL_NOTIFY RegisterProtocolNotify;
+ EFI_LOCATE_HANDLE LocateHandle;
+ EFI_LOCATE_DEVICE_PATH LocateDevicePath;
+ EFI_INSTALL_CONFIGURATION_TABLE InstallConfigurationTable;
+
+ //
+ // Image functions
+ //
+ EFI_IMAGE_LOAD LoadImage;
+ EFI_IMAGE_START StartImage;
+ EFI_EXIT Exit;
+ EFI_IMAGE_UNLOAD UnloadImage;
+ EFI_EXIT_BOOT_SERVICES ExitBootServices;
+
+ //
+ // Misc functions
+ //
+ EFI_GET_NEXT_MONOTONIC_COUNT GetNextMonotonicCount;
+ EFI_STALL Stall;
+ EFI_SET_WATCHDOG_TIMER SetWatchdogTimer;
+
+ //
+ // ////////////////////////////////////////////////////
+ // EFI 1.1 Services
+ //////////////////////////////////////////////////////
+ //
+ // DriverSupport Services
+ //
+ EFI_CONNECT_CONTROLLER ConnectController;
+ EFI_DISCONNECT_CONTROLLER DisconnectController;
+
+ //
+ // Added Open and Close protocol for the new driver model
+ //
+ EFI_OPEN_PROTOCOL OpenProtocol;
+ EFI_CLOSE_PROTOCOL CloseProtocol;
+ EFI_OPEN_PROTOCOL_INFORMATION OpenProtocolInformation;
+
+ //
+ // Added new services to EFI 1.1 as Lib to reduce code size.
+ //
+ EFI_PROTOCOLS_PER_HANDLE ProtocolsPerHandle;
+ EFI_LOCATE_HANDLE_BUFFER LocateHandleBuffer;
+ EFI_LOCATE_PROTOCOL LocateProtocol;
+
+ EFI_INSTALL_MULTIPLE_PROTOCOL_INTERFACES InstallMultipleProtocolInterfaces;
+ EFI_UNINSTALL_MULTIPLE_PROTOCOL_INTERFACES UninstallMultipleProtocolInterfaces;
+
+ //
+ // CRC32 services
+ //
+ EFI_CALCULATE_CRC32 CalculateCrc32;
+
+ //
+ // Memory Utility Services
+ //
+ EFI_COPY_MEM CopyMem;
+ EFI_SET_MEM SetMem;
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+ //
+ // UEFI 2.0 Extension to the table
+ //
+ EFI_CREATE_EVENT_EX CreateEventEx;
+#endif
+
+} EFI_BOOT_SERVICES;
+
+//
+// EFI Configuration Table
+//
+typedef struct {
+ EFI_GUID VendorGuid;
+ VOID *VendorTable;
+} EFI_CONFIGURATION_TABLE;
+
+//
+// EFI System Table
+//
+#define EFI_SYSTEM_TABLE_SIGNATURE 0x5453595320494249
+#define EFI_SYSTEM_TABLE_REVISION EFI_SPECIFICATION_VERSION
+#define EFI_1_02_SYSTEM_TABLE_REVISION ((1 << 16) | 02)
+#define EFI_1_10_SYSTEM_TABLE_REVISION ((1 << 16) | 10)
+#define EFI_2_00_SYSTEM_TABLE_REVISION ((2 << 16) | 00)
+#define EFI_2_10_SYSTEM_TABLE_REVISION ((2 << 16) | 10)
+
+typedef struct _EFI_SYSTEM_TABLE {
+ EFI_TABLE_HEADER Hdr;
+
+ CHAR16 *FirmwareVendor;
+ UINT32 FirmwareRevision;
+
+ EFI_HANDLE ConsoleInHandle;
+ EFI_SIMPLE_TEXT_IN_PROTOCOL *ConIn;
+
+ EFI_HANDLE ConsoleOutHandle;
+ EFI_SIMPLE_TEXT_OUT_PROTOCOL *ConOut;
+
+ EFI_HANDLE StandardErrorHandle;
+ EFI_SIMPLE_TEXT_OUT_PROTOCOL *StdErr;
+
+ EFI_RUNTIME_SERVICES *RuntimeServices;
+ EFI_BOOT_SERVICES *BootServices;
+
+ UINTN NumberOfTableEntries;
+ EFI_CONFIGURATION_TABLE *ConfigurationTable;
+
+} EFI_SYSTEM_TABLE;
+
+#endif
diff --git a/EDK/Foundation/Efi/Include/EfiDevicePath.h b/EDK/Foundation/Efi/Include/EfiDevicePath.h
new file mode 100644
index 0000000..494616c
--- /dev/null
+++ b/EDK/Foundation/Efi/Include/EfiDevicePath.h
@@ -0,0 +1,568 @@
+/*++
+
+Copyright (c) 2004 - 2008, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiDevicePath.h
+
+Abstract:
+
+ EFI Device Path definitions
+
+--*/
+
+#ifndef _EFI_DEVICE_PATH_H
+#define _EFI_DEVICE_PATH_H
+
+
+
+#pragma pack(1)
+
+
+//
+// Device Path defines and macros
+//
+#define EFI_DP_TYPE_MASK 0x7F
+#define EFI_DP_TYPE_UNPACKED 0x80
+#define END_DEVICE_PATH_TYPE 0x7f
+#define END_ENTIRE_DEVICE_PATH_SUBTYPE 0xff
+#define END_INSTANCE_DEVICE_PATH_SUBTYPE 0x01
+#define END_DEVICE_PATH_LENGTH (sizeof(EFI_DEVICE_PATH_PROTOCOL))
+
+#define DP_IS_END_TYPE(a)
+#define DP_IS_END_SUBTYPE(a) ( ((a)->SubType == END_ENTIRE_DEVICE_PATH_SUBTYPE )
+
+#define DevicePathType(a) ( ((a)->Type) & EFI_DP_TYPE_MASK )
+#define DevicePathSubType(a) ( (a)->SubType )
+#define DevicePathNodeLength(a) ( ((a)->Length[0]) | ((a)->Length[1] << 8) )
+#define NextDevicePathNode(a) ( (EFI_DEVICE_PATH_PROTOCOL *) ( ((UINT8 *) (a)) + DevicePathNodeLength(a)))
+#define IsDevicePathEndType(a) ( DevicePathType(a) == END_DEVICE_PATH_TYPE )
+#define IsDevicePathEndSubType(a) ( (a)->SubType == END_ENTIRE_DEVICE_PATH_SUBTYPE )
+#define IsDevicePathEnd(a) ( IsDevicePathEndType(a) && IsDevicePathEndSubType(a) )
+#define IsDevicePathUnpacked(a) ( (a)->Type & EFI_DP_TYPE_UNPACKED )
+
+
+#define SetDevicePathNodeLength(a,l) { \
+ (a)->Length[0] = (UINT8) (l); \
+ (a)->Length[1] = (UINT8) ((l) >> 8); \
+ }
+
+#define SetDevicePathEndNode(a) { \
+ (a)->Type = END_DEVICE_PATH_TYPE; \
+ (a)->SubType = END_ENTIRE_DEVICE_PATH_SUBTYPE; \
+ (a)->Length[0] = sizeof(EFI_DEVICE_PATH_PROTOCOL); \
+ (a)->Length[1] = 0; \
+ }
+
+//
+// Hardware Device Paths
+//
+#define HARDWARE_DEVICE_PATH 0x01
+
+#define HW_PCI_DP 0x01
+typedef struct {
+ EFI_DEVICE_PATH_PROTOCOL Header;
+ UINT8 Function;
+ UINT8 Device;
+} PCI_DEVICE_PATH;
+
+#define HW_PCCARD_DP 0x02
+typedef struct {
+ EFI_DEVICE_PATH_PROTOCOL Header;
+ UINT8 FunctionNumber;
+} PCCARD_DEVICE_PATH;
+
+#define HW_MEMMAP_DP 0x03
+typedef struct {
+ EFI_DEVICE_PATH_PROTOCOL Header;
+ UINT32 MemoryType;
+ EFI_PHYSICAL_ADDRESS StartingAddress;
+ EFI_PHYSICAL_ADDRESS EndingAddress;
+} MEMMAP_DEVICE_PATH;
+
+#define HW_VENDOR_DP 0x04
+typedef struct {
+ EFI_DEVICE_PATH_PROTOCOL Header;
+ EFI_GUID Guid;
+} VENDOR_DEVICE_PATH;
+
+#define HW_CONTROLLER_DP 0x05
+typedef struct {
+ EFI_DEVICE_PATH_PROTOCOL Header;
+ UINT32 Controller;
+} CONTROLLER_DEVICE_PATH;
+
+//
+// ACPI Device Paths
+//
+#define ACPI_DEVICE_PATH 0x02
+
+#define ACPI_DP 0x01
+typedef struct {
+ EFI_DEVICE_PATH_PROTOCOL Header;
+ UINT32 HID;
+ UINT32 UID;
+} ACPI_HID_DEVICE_PATH;
+
+#define ACPI_EXTENDED_DP 0x02
+typedef struct {
+ EFI_DEVICE_PATH_PROTOCOL Header;
+ UINT32 HID;
+ UINT32 UID;
+ UINT32 CID;
+ //
+ // Optional variable length _HIDSTR
+ // Optional variable length _UIDSTR
+ //
+} ACPI_EXTENDED_HID_DEVICE_PATH;
+
+#define ACPI_ADR_DP 0x03
+
+typedef struct {
+ EFI_DEVICE_PATH_PROTOCOL Header;
+ UINT32 ADR;
+} ACPI_ADR_DEVICE_PATH;
+
+#define ACPI_ADR_DISPLAY_TYPE_OTHER 0
+#define ACPI_ADR_DISPLAY_TYPE_VGA 1
+#define ACPI_ADR_DISPLAY_TYPE_TV 2
+#define ACPI_ADR_DISPLAY_TYPE_EXTERNAL_DIGITAL 3
+#define ACPI_ADR_DISPLAY_TYPE_INTERNAL_DIGITAL 4
+
+#define ACPI_DISPLAY_ADR(_DeviceIdScheme, _HeadId, _NonVgaOutput, _BiosCanDetect, _VendorInfo, _Type, _Port, _Index) \
+ ((UINT32) ( (((_DeviceIdScheme) & 0x1) << 31) | \
+ (((_HeadId) & 0x7) << 18) | \
+ (((_NonVgaOutput) & 0x1) << 17) | \
+ (((_BiosCanDetect) & 0x1) << 16) | \
+ (((_VendorInfo) & 0xf) << 12) | \
+ (((_Type) & 0xf) << 8) | \
+ (((_Port) & 0xf) << 4) | \
+ ((_Index) & 0xf) ))
+
+//
+// EISA ID Macro
+// EISA ID Definition 32-bits
+// bits[15:0] - three character compressed ASCII EISA ID.
+// bits[31:16] - binary number
+// Compressed ASCII is 5 bits per character 0b00001 = 'A' 0b11010 = 'Z'
+//
+#define PNP_EISA_ID_CONST 0x41d0
+#define EISA_ID(_Name, _Num) ((UINT32) ((_Name) | (_Num) << 16))
+#define EISA_PNP_ID(_PNPId) (EISA_ID(PNP_EISA_ID_CONST, (_PNPId)))
+#define EFI_PNP_ID(_PNPId) (EISA_ID(PNP_EISA_ID_CONST, (_PNPId)))
+
+#define PNP_EISA_ID_MASK 0xffff
+#define EISA_ID_TO_NUM(_Id) ((_Id) >> 16)
+
+//
+// Messaging Device Paths
+//
+#define MESSAGING_DEVICE_PATH 0x03
+
+#define MSG_ATAPI_DP 0x01
+typedef struct {
+ EFI_DEVICE_PATH_PROTOCOL Header;
+ UINT8 PrimarySecondary;
+ UINT8 SlaveMaster;
+ UINT16 Lun;
+} ATAPI_DEVICE_PATH;
+
+#define MSG_SCSI_DP 0x02
+typedef struct {
+ EFI_DEVICE_PATH_PROTOCOL Header;
+ UINT16 Pun;
+ UINT16 Lun;
+} SCSI_DEVICE_PATH;
+
+#define MSG_FIBRECHANNEL_DP 0x03
+typedef struct {
+ EFI_DEVICE_PATH_PROTOCOL Header;
+ UINT32 Reserved;
+ UINT64 WWN;
+ UINT64 Lun;
+} FIBRECHANNEL_DEVICE_PATH;
+
+#define MSG_1394_DP 0x04
+typedef struct {
+ EFI_DEVICE_PATH_PROTOCOL Header;
+ UINT32 Reserved;
+ UINT64 Guid;
+} F1394_DEVICE_PATH;
+
+#define MSG_USB_DP 0x05
+typedef struct {
+ EFI_DEVICE_PATH_PROTOCOL Header;
+ UINT8 ParentPortNumber;
+ UINT8 InterfaceNumber;
+} USB_DEVICE_PATH;
+
+#define MSG_USB_CLASS_DP 0x0f
+typedef struct {
+ EFI_DEVICE_PATH_PROTOCOL Header;
+ UINT16 VendorId;
+ UINT16 ProductId;
+ UINT8 DeviceClass;
+ UINT8 DeviceSubClass;
+ UINT8 DeviceProtocol;
+} USB_CLASS_DEVICE_PATH;
+
+#define MSG_USB_WWID_DP 0x10
+typedef struct {
+ EFI_DEVICE_PATH_PROTOCOL Header;
+ UINT16 InterfaceNumber;
+ UINT16 VendorId;
+ UINT16 ProductId;
+ //
+ // CHAR16 SerialNumber[];
+ //
+} USB_WWID_DEVICE_PATH;
+
+#define MSG_DEVICE_LOGICAL_UNIT_DP 0x11
+typedef struct {
+ EFI_DEVICE_PATH_PROTOCOL Header;
+ UINT8 Lun;
+} DEVICE_LOGICAL_UNIT_DEVICE_PATH;
+
+#define MSG_SATA_DP 0x12
+typedef struct {
+ EFI_DEVICE_PATH_PROTOCOL Header;
+ UINT16 HBAPortNumber;
+ UINT16 PortMultiplierPortNumber;
+ UINT16 Lun;
+} SATA_DEVICE_PATH;
+
+#define SATA_HBA_DIRECT_CONNECT_FLAG 0x8000
+
+#define MSG_I2O_DP 0x06
+typedef struct {
+ EFI_DEVICE_PATH_PROTOCOL Header;
+ UINT32 Tid;
+} I2O_DEVICE_PATH;
+
+#define MSG_MAC_ADDR_DP 0x0b
+typedef struct {
+ EFI_DEVICE_PATH_PROTOCOL Header;
+ EFI_MAC_ADDRESS MacAddress;
+ UINT8 IfType;
+} MAC_ADDR_DEVICE_PATH;
+
+#define MSG_IPv4_DP 0x0c
+typedef struct {
+ EFI_DEVICE_PATH_PROTOCOL Header;
+ EFI_IPv4_ADDRESS LocalIpAddress;
+ EFI_IPv4_ADDRESS RemoteIpAddress;
+ UINT16 LocalPort;
+ UINT16 RemotePort;
+ UINT16 Protocol;
+ BOOLEAN StaticIpAddress;
+} IPv4_DEVICE_PATH;
+
+#define MSG_IPv6_DP 0x0d
+typedef struct {
+ EFI_DEVICE_PATH_PROTOCOL Header;
+ EFI_IPv6_ADDRESS LocalIpAddress;
+ EFI_IPv6_ADDRESS RemoteIpAddress;
+ UINT16 LocalPort;
+ UINT16 RemotePort;
+ UINT16 Protocol;
+ BOOLEAN StaticIpAddress;
+} IPv6_DEVICE_PATH;
+
+#define MSG_INFINIBAND_DP 0x09
+typedef struct {
+ EFI_DEVICE_PATH_PROTOCOL Header;
+ UINT32 ResourceFlags;
+ UINT8 PortGid[16];
+ UINT64 ServiceId;
+ UINT64 TargetPortId;
+ UINT64 DeviceId;
+} INFINIBAND_DEVICE_PATH;
+
+#define INFINIBAND_RESOURCE_FLAG_IOC_SERVICE 0x01
+#define INFINIBAND_RESOURCE_FLAG_EXTENDED_BOOT_ENVIRONMENT 0x02
+#define INFINIBAND_RESOURCE_FLAG_CONSOLE_PROTOCOL 0x04
+#define INFINIBAND_RESOURCE_FLAG_STORAGE_PROTOCOL 0x08
+#define INFINIBAND_RESOURCE_FLAG_NETWORK_PROTOCOL 0x10
+
+#define MSG_UART_DP 0x0e
+typedef struct {
+ EFI_DEVICE_PATH_PROTOCOL Header;
+ UINT32 Reserved;
+ UINT64 BaudRate;
+ UINT8 DataBits;
+ UINT8 Parity;
+ UINT8 StopBits;
+} UART_DEVICE_PATH;
+
+//
+// Use VENDOR_DEVICE_PATH struct
+//
+#define MSG_VENDOR_DP 0x0a
+
+#define DEVICE_PATH_MESSAGING_PC_ANSI \
+ { 0xe0c14753, 0xf9be, 0x11d2, 0x9a, 0x0c, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d }
+
+#define DEVICE_PATH_MESSAGING_VT_100 \
+ { 0xdfa66065, 0xb419, 0x11d3, 0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d }
+
+#define DEVICE_PATH_MESSAGING_VT_100_PLUS \
+ { 0x7baec70b, 0x57e0, 0x4c76, 0x8e, 0x87, 0x2f, 0x9e, 0x28, 0x08, 0x83, 0x43 }
+
+#define DEVICE_PATH_MESSAGING_VT_UTF8 \
+ { 0xad15a0d6, 0x8bec, 0x4acf, 0xa0, 0x73, 0xd0, 0x1d, 0xe7, 0x7e, 0x2d, 0x88 }
+
+#define DEVICE_PATH_MESSAGING_UART_FLOW_CONTROL \
+ { 0x37499a9d, 0x542f, 0x4c89, 0xa0, 0x26, 0x35, 0xda, 0x14, 0x20, 0x94, 0xe4 }
+
+typedef struct {
+ EFI_DEVICE_PATH_PROTOCOL Header;
+ EFI_GUID Guid;
+ UINT32 FlowControlMap;
+} UART_FLOW_CONTROL_DEVICE_PATH;
+
+#define DEVICE_PATH_MESSAGING_SAS \
+ { 0xd487ddb4, 0x008b, 0x11d9, 0xaf, 0xdc, 0x00, 0x10, 0x83, 0xff, 0xca, 0x4d }
+
+typedef struct {
+ EFI_DEVICE_PATH_PROTOCOL Header;
+ EFI_GUID Guid;
+ UINT32 Reserved;
+ UINT64 SasAddress;
+ UINT64 Lun;
+ UINT16 DeviceTopology;
+ UINT16 RelativeTargetPort;
+} SAS_DEVICE_PATH;
+
+#define MSG_ISCSI_DP 0x13
+typedef struct {
+ EFI_DEVICE_PATH_PROTOCOL Header;
+ UINT16 NetworkProtocol;
+ UINT16 LoginOption;
+ UINT64 Lun;
+ UINT16 TargetPortalGroupTag;
+ // CHAR8 iSCSI Target Name
+} ISCSI_DEVICE_PATH;
+
+#define ISCSI_LOGIN_OPTION_NO_HEADER_DIGEST 0x0000
+#define ISCSI_LOGIN_OPTION_HEADER_DIGEST_USING_CRC32C 0x0002
+#define ISCSI_LOGIN_OPTION_NO_DATA_DIGEST 0x0000
+#define ISCSI_LOGIN_OPTION_DATA_DIGEST_USING_CRC32C 0x0008
+#define ISCSI_LOGIN_OPTION_AUTHMETHOD_CHAP 0x0000
+#define ISCSI_LOGIN_OPTION_AUTHMETHOD_NON 0x1000
+#define ISCSI_LOGIN_OPTION_CHAP_BI 0x0000
+#define ISCSI_LOGIN_OPTION_CHAP_UNI 0x2000
+
+//
+// Media Device Path
+//
+#define MEDIA_DEVICE_PATH 0x04
+
+#define MEDIA_HARDDRIVE_DP 0x01
+typedef struct {
+ EFI_DEVICE_PATH_PROTOCOL Header;
+ UINT32 PartitionNumber;
+ UINT64 PartitionStart;
+ UINT64 PartitionSize;
+ UINT8 Signature[16];
+ UINT8 MBRType;
+ UINT8 SignatureType;
+} HARDDRIVE_DEVICE_PATH;
+
+#define MBR_TYPE_PCAT 0x01
+#define MBR_TYPE_EFI_PARTITION_TABLE_HEADER 0x02
+
+#define SIGNATURE_TYPE_MBR 0x01
+#define SIGNATURE_TYPE_GUID 0x02
+
+#define MEDIA_CDROM_DP 0x02
+typedef struct {
+ EFI_DEVICE_PATH_PROTOCOL Header;
+ UINT32 BootEntry;
+ UINT64 PartitionStart;
+ UINT64 PartitionSize;
+} CDROM_DEVICE_PATH;
+
+//
+// Use VENDOR_DEVICE_PATH struct
+//
+#define MEDIA_VENDOR_DP 0x03
+
+#define MEDIA_FILEPATH_DP 0x04
+typedef struct {
+ EFI_DEVICE_PATH_PROTOCOL Header;
+ CHAR16 PathName[1];
+} FILEPATH_DEVICE_PATH;
+
+#define SIZE_OF_FILEPATH_DEVICE_PATH EFI_FIELD_OFFSET(FILEPATH_DEVICE_PATH,PathName)
+
+#define MEDIA_PROTOCOL_DP 0x05
+typedef struct {
+ EFI_DEVICE_PATH_PROTOCOL Header;
+ EFI_GUID Protocol;
+} MEDIA_PROTOCOL_DEVICE_PATH;
+
+#define MEDIA_FV_DP 0x07
+typedef struct {
+ EFI_DEVICE_PATH_PROTOCOL Header;
+ EFI_GUID NameGuid;
+} MEDIA_FW_VOL_DEVICE_PATH;
+
+#define MEDIA_FV_FILEPATH_DP 0x06
+typedef struct {
+ EFI_DEVICE_PATH_PROTOCOL Header;
+ EFI_GUID NameGuid;
+} MEDIA_FW_VOL_FILEPATH_DEVICE_PATH;
+
+#define MEDIA_RELATIVE_OFFSET_RANGE_DP 0x08
+typedef struct {
+ EFI_DEVICE_PATH_PROTOCOL Header;
+ UINT64 StartingOffset;
+ UINT64 EndingOffset;
+} MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH;
+
+//
+// BBS Device Path
+//
+#define BBS_DEVICE_PATH 0x05
+#define BBS_BBS_DP 0x01
+typedef struct {
+ EFI_DEVICE_PATH_PROTOCOL Header;
+ UINT16 DeviceType;
+ UINT16 StatusFlag;
+ CHAR8 String[1];
+} BBS_BBS_DEVICE_PATH;
+
+//
+// DeviceType definitions - from BBS specification
+//
+#define BBS_TYPE_FLOPPY 0x01
+#define BBS_TYPE_HARDDRIVE 0x02
+#define BBS_TYPE_CDROM 0x03
+#define BBS_TYPE_PCMCIA 0x04
+#define BBS_TYPE_USB 0x05
+#define BBS_TYPE_EMBEDDED_NETWORK 0x06
+#define BBS_TYPE_BEV 0x80
+#define BBS_TYPE_UNKNOWN 0xFF
+
+#define UNKNOWN_DEVICE_GUID \
+ { 0xcf31fac5, 0xc24e, 0x11d2, 0x85, 0xf3, 0x0, 0xa0, 0xc9, 0x3e, 0xc9, 0x3b }
+
+typedef struct {
+ VENDOR_DEVICE_PATH DevicePath;
+ UINT8 LegacyDriveLetter;
+} UNKNOWN_DEVICE_VENDOR_DEVICE_PATH;
+
+
+//
+// Union of all possible Device Paths and pointers to Device Paths
+//
+
+typedef union {
+ EFI_DEVICE_PATH_PROTOCOL DevPath;
+ PCI_DEVICE_PATH Pci;
+ PCCARD_DEVICE_PATH PcCard;
+ MEMMAP_DEVICE_PATH MemMap;
+ VENDOR_DEVICE_PATH Vendor;
+
+ UNKNOWN_DEVICE_VENDOR_DEVICE_PATH UnknownVendor;
+
+ CONTROLLER_DEVICE_PATH Controller;
+ ACPI_HID_DEVICE_PATH Acpi;
+ ACPI_EXTENDED_HID_DEVICE_PATH ExtendedAcpi;
+
+ ATAPI_DEVICE_PATH Atapi;
+ SCSI_DEVICE_PATH Scsi;
+ FIBRECHANNEL_DEVICE_PATH FibreChannel;
+ SATA_DEVICE_PATH Sata;
+
+ F1394_DEVICE_PATH F1394;
+ USB_DEVICE_PATH Usb;
+ USB_CLASS_DEVICE_PATH UsbClass;
+ USB_WWID_DEVICE_PATH UsbWwid;
+ DEVICE_LOGICAL_UNIT_DEVICE_PATH LogicUnit;
+ I2O_DEVICE_PATH I2O;
+ MAC_ADDR_DEVICE_PATH MacAddr;
+ IPv4_DEVICE_PATH Ipv4;
+ IPv6_DEVICE_PATH Ipv6;
+ INFINIBAND_DEVICE_PATH InfiniBand;
+ UART_DEVICE_PATH Uart;
+ UART_FLOW_CONTROL_DEVICE_PATH UartFlowControl;
+ SAS_DEVICE_PATH Sas;
+ ISCSI_DEVICE_PATH Iscsi;
+ HARDDRIVE_DEVICE_PATH HardDrive;
+ CDROM_DEVICE_PATH CD;
+
+ FILEPATH_DEVICE_PATH FilePath;
+ MEDIA_PROTOCOL_DEVICE_PATH MediaProtocol;
+
+ MEDIA_FW_VOL_DEVICE_PATH PiwgFirmwareVolume;
+ MEDIA_FW_VOL_FILEPATH_DEVICE_PATH PiwgFirmwareFile;
+ MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH
+ Offset;
+
+ BBS_BBS_DEVICE_PATH Bbs;
+} EFI_DEV_PATH;
+
+
+
+typedef union {
+ EFI_DEVICE_PATH_PROTOCOL *DevPath;
+ PCI_DEVICE_PATH *Pci;
+ PCCARD_DEVICE_PATH *PcCard;
+ MEMMAP_DEVICE_PATH *MemMap;
+ VENDOR_DEVICE_PATH *Vendor;
+
+ UNKNOWN_DEVICE_VENDOR_DEVICE_PATH *UnknownVendor;
+
+ CONTROLLER_DEVICE_PATH *Controller;
+ ACPI_HID_DEVICE_PATH *Acpi;
+ ACPI_EXTENDED_HID_DEVICE_PATH *ExtendedAcpi;
+
+ ATAPI_DEVICE_PATH *Atapi;
+ SCSI_DEVICE_PATH *Scsi;
+ FIBRECHANNEL_DEVICE_PATH *FibreChannel;
+ SATA_DEVICE_PATH *Sata;
+
+ F1394_DEVICE_PATH *F1394;
+ USB_DEVICE_PATH *Usb;
+ USB_CLASS_DEVICE_PATH *UsbClass;
+ USB_WWID_DEVICE_PATH *UsbWwid;
+ DEVICE_LOGICAL_UNIT_DEVICE_PATH *LogicUnit;
+ I2O_DEVICE_PATH *I2O;
+ MAC_ADDR_DEVICE_PATH *MacAddr;
+ IPv4_DEVICE_PATH *Ipv4;
+ IPv6_DEVICE_PATH *Ipv6;
+ INFINIBAND_DEVICE_PATH *InfiniBand;
+ UART_DEVICE_PATH *Uart;
+ UART_FLOW_CONTROL_DEVICE_PATH *UartFlowControl;
+
+ SAS_DEVICE_PATH *Sas;
+ ISCSI_DEVICE_PATH *Iscsi;
+
+ HARDDRIVE_DEVICE_PATH *HardDrive;
+ CDROM_DEVICE_PATH *CD;
+
+ FILEPATH_DEVICE_PATH *FilePath;
+ MEDIA_PROTOCOL_DEVICE_PATH *MediaProtocol;
+
+ MEDIA_FW_VOL_DEVICE_PATH *PiwgFirmwareVolume;
+ MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *PiwgFirmwareFile;
+ MEDIA_RELATIVE_OFFSET_RANGE_DEVICE_PATH
+ *Offset;
+
+ BBS_BBS_DEVICE_PATH *Bbs;
+ UINT8 *Raw;
+} EFI_DEV_PATH_PTR;
+
+#pragma pack()
+
+
+#endif
diff --git a/EDK/Foundation/Efi/Include/EfiError.h b/EDK/Foundation/Efi/Include/EfiError.h
new file mode 100644
index 0000000..0efab6b
--- /dev/null
+++ b/EDK/Foundation/Efi/Include/EfiError.h
@@ -0,0 +1,70 @@
+/*++
+
+Copyright (c) 2004 - 2008, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiError.h
+
+Abstract:
+
+ EFI error levels and thier associated defines
+
+--*/
+
+#ifndef _EFI_ERROR_H_
+#define _EFI_ERROR_H_
+
+//
+// Set the upper bit to indicate EFI Error.
+//
+#define EFIERR(a) (EFI_MAX_BIT | (a))
+
+#define EFIWARN(a) (a)
+#define EFI_ERROR(a) (((INTN) (a)) < 0)
+
+#define EFI_SUCCESS 0
+#define EFI_LOAD_ERROR EFIERR (1)
+#define EFI_INVALID_PARAMETER EFIERR (2)
+#define EFI_UNSUPPORTED EFIERR (3)
+#define EFI_BAD_BUFFER_SIZE EFIERR (4)
+#define EFI_BUFFER_TOO_SMALL EFIERR (5)
+#define EFI_NOT_READY EFIERR (6)
+#define EFI_DEVICE_ERROR EFIERR (7)
+#define EFI_WRITE_PROTECTED EFIERR (8)
+#define EFI_OUT_OF_RESOURCES EFIERR (9)
+#define EFI_VOLUME_CORRUPTED EFIERR (10)
+#define EFI_VOLUME_FULL EFIERR (11)
+#define EFI_NO_MEDIA EFIERR (12)
+#define EFI_MEDIA_CHANGED EFIERR (13)
+#define EFI_NOT_FOUND EFIERR (14)
+#define EFI_ACCESS_DENIED EFIERR (15)
+#define EFI_NO_RESPONSE EFIERR (16)
+#define EFI_NO_MAPPING EFIERR (17)
+#define EFI_TIMEOUT EFIERR (18)
+#define EFI_NOT_STARTED EFIERR (19)
+#define EFI_ALREADY_STARTED EFIERR (20)
+#define EFI_ABORTED EFIERR (21)
+#define EFI_ICMP_ERROR EFIERR (22)
+#define EFI_TFTP_ERROR EFIERR (23)
+#define EFI_PROTOCOL_ERROR EFIERR (24)
+#define EFI_INCOMPATIBLE_VERSION EFIERR (25)
+#define EFI_SECURITY_VIOLATION EFIERR (26)
+#define EFI_CRC_ERROR EFIERR (27)
+#define EFI_END_OF_MEDIA EFIERR (28)
+#define EFI_END_OF_FILE EFIERR (31)
+#define EFI_INVALID_LANGUAGE EFIERR (32)
+
+#define EFI_WARN_UNKNOWN_GLYPH EFIWARN (1)
+#define EFI_WARN_DELETE_FAILURE EFIWARN (2)
+#define EFI_WARN_WRITE_FAILURE EFIWARN (3)
+#define EFI_WARN_BUFFER_TOO_SMALL EFIWARN (4)
+
+#endif
diff --git a/EDK/Foundation/Efi/Include/EfiHii.h b/EDK/Foundation/Efi/Include/EfiHii.h
new file mode 100644
index 0000000..c05358b
--- /dev/null
+++ b/EDK/Foundation/Efi/Include/EfiHii.h
@@ -0,0 +1,1473 @@
+/*++
+
+Copyright (c) 2007 - 2009, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiHii.h
+
+Abstract:
+
+ Hii relative definitions, such as Hii package, IFR OpCode etc
+
+Revision History
+
+--*/
+
+#ifndef _EFI_HII_H_
+#define _EFI_HII_H_
+
+#include "EfiCommon.h"
+#include EFI_PROTOCOL_DEFINITION (DevicePath)
+
+typedef VOID *EFI_HII_HANDLE;
+typedef CHAR16 *EFI_STRING;
+typedef UINT16 EFI_QUESTION_ID;
+typedef UINT16 EFI_IMAGE_ID;
+typedef UINT16 EFI_STRING_ID;
+typedef UINT16 EFI_FORM_ID;
+typedef UINT16 EFI_VARSTORE_ID;
+typedef UINT16 EFI_DEFAULT_ID;
+typedef UINT32 EFI_HII_FONT_STYLE;
+
+//
+// Type defined for backward compatible with Framework HII
+//
+typedef EFI_STRING_ID STRING_REF;
+
+#pragma pack(1)
+
+//
+// HII package list
+//
+typedef struct {
+ EFI_GUID PackageListGuid;
+ UINT32 PackageLength;
+} EFI_HII_PACKAGE_LIST_HEADER;
+
+typedef struct {
+ UINT32 Length:24;
+ UINT32 Type:8;
+} EFI_HII_PACKAGE_HEADER;
+
+#define EFI_HII_PACKAGE_TYPE_ALL 0x00
+#define EFI_HII_PACKAGE_TYPE_GUID 0x01
+#define EFI_HII_PACKAGE_FORMS 0x02
+#define EFI_HII_PACKAGE_STRINGS 0x04
+#define EFI_HII_PACKAGE_FONTS 0x05
+#define EFI_HII_PACKAGE_IMAGES 0x06
+#define EFI_HII_PACKAGE_SIMPLE_FONTS 0x07
+#define EFI_HII_PACKAGE_DEVICE_PATH 0x08
+#define EFI_HII_PACKAGE_KEYBOARD_LAYOUT 0x09
+#define EFI_HII_PACKAGE_END 0xDF
+#define EFI_HII_PACKAGE_TYPE_SYSTEM_BEGIN 0xE0
+#define EFI_HII_PACKAGE_TYPE_SYSTEM_END 0xFF
+
+//
+// Simplified Font Package
+//
+
+#define EFI_GLYPH_HEIGHT 19
+#define EFI_GLYPH_WIDTH 8
+//
+// Contents of EFI_NARROW_GLYPH.Attributes
+//
+#define EFI_GLYPH_NON_SPACING 0x01
+#define EFI_GLYPH_WIDE 0x02
+
+typedef struct {
+ CHAR16 UnicodeWeight;
+ UINT8 Attributes;
+ UINT8 GlyphCol1[EFI_GLYPH_HEIGHT];
+} EFI_NARROW_GLYPH;
+
+typedef struct {
+ CHAR16 UnicodeWeight;
+ UINT8 Attributes;
+ UINT8 GlyphCol1[EFI_GLYPH_HEIGHT];
+ UINT8 GlyphCol2[EFI_GLYPH_HEIGHT];
+ UINT8 Pad[3];
+} EFI_WIDE_GLYPH;
+
+typedef struct _EFI_HII_SIMPLE_FONT_PACKAGE_HDR {
+ EFI_HII_PACKAGE_HEADER Header;
+ UINT16 NumberOfNarrowGlyphs;
+ UINT16 NumberOfWideGlyphs;
+ // EFI_NARROW_GLYPH NarrowGlyphs[];
+ // EFI_WIDE_GLYPH WideGlyphs[];
+} EFI_HII_SIMPLE_FONT_PACKAGE_HDR;
+
+//
+// Font Package
+//
+
+#define EFI_HII_FONT_STYLE_NORMAL 0x00000000
+#define EFI_HII_FONT_STYLE_BOLD 0x00000001
+#define EFI_HII_FONT_STYLE_ITALIC 0x00000002
+#define EFI_HII_FONT_STYLE_EMBOSS 0x00010000
+#define EFI_HII_FONT_STYLE_OUTLINE 0x00020000
+#define EFI_HII_FONT_STYLE_SHADOW 0x00040000
+#define EFI_HII_FONT_STYLE_UNDERLINE 0x00080000
+#define EFI_HII_FONT_STYLE_DBL_UNDER 0x00100000
+
+typedef struct _EFI_HII_GLYPH_INFO {
+ UINT16 Width;
+ UINT16 Height;
+ INT16 OffsetX;
+ INT16 OffsetY;
+ INT16 AdvanceX;
+} EFI_HII_GLYPH_INFO;
+
+typedef struct _EFI_HII_FONT_PACKAGE_HDR {
+ EFI_HII_PACKAGE_HEADER Header;
+ UINT32 HdrSize;
+ UINT32 GlyphBlockOffset;
+ EFI_HII_GLYPH_INFO Cell;
+ EFI_HII_FONT_STYLE FontStyle;
+ CHAR16 FontFamily[1];
+} EFI_HII_FONT_PACKAGE_HDR;
+
+#define EFI_HII_GIBT_END 0x00
+#define EFI_HII_GIBT_GLYPH 0x10
+#define EFI_HII_GIBT_GLYPHS 0x11
+#define EFI_HII_GIBT_GLYPH_DEFAULT 0x12
+#define EFI_HII_GIBT_GLYPHS_DEFAULT 0x13
+#define EFI_HII_GIBT_DUPLICATE 0x20
+#define EFI_HII_GIBT_SKIP2 0x21
+#define EFI_HII_GIBT_SKIP1 0x22
+#define EFI_HII_GIBT_DEFAULTS 0x23
+#define EFI_HII_GIBT_EXT1 0x30
+#define EFI_HII_GIBT_EXT2 0x31
+#define EFI_HII_GIBT_EXT4 0x32
+
+typedef struct _EFI_HII_GLYPH_BLOCK {
+ UINT8 BlockType;
+} EFI_HII_GLYPH_BLOCK;
+
+typedef struct _EFI_HII_GIBT_DEFAULTS_BLOCK {
+ EFI_HII_GLYPH_BLOCK Header;
+ EFI_HII_GLYPH_INFO Cell;
+} EFI_HII_GIBT_DEFAULTS_BLOCK;
+
+typedef struct _EFI_HII_GIBT_DUPLICATE_BLOCK {
+ EFI_HII_GLYPH_BLOCK Header;
+ CHAR16 CharValue;
+} EFI_HII_GIBT_DUPLICATE_BLOCK;
+
+typedef struct _EFI_GLYPH_GIBT_END_BLOCK {
+ EFI_HII_GLYPH_BLOCK Header;
+} EFI_GLYPH_GIBT_END_BLOCK;
+
+typedef struct _EFI_HII_GIBT_EXT1_BLOCK {
+ EFI_HII_GLYPH_BLOCK Header;
+ UINT8 BlockType2;
+ UINT8 Length;
+} EFI_HII_GIBT_EXT1_BLOCK;
+
+typedef struct _EFI_HII_GIBT_EXT2_BLOCK {
+ EFI_HII_GLYPH_BLOCK Header;
+ UINT8 BlockType2;
+ UINT16 Length;
+} EFI_HII_GIBT_EXT2_BLOCK;
+
+typedef struct _EFI_HII_GIBT_EXT4_BLOCK {
+ EFI_HII_GLYPH_BLOCK Header;
+ UINT8 BlockType2;
+ UINT32 Length;
+} EFI_HII_GIBT_EXT4_BLOCK;
+
+typedef struct _EFI_HII_GIBT_GLYPH_BLOCK {
+ EFI_HII_GLYPH_BLOCK Header;
+ EFI_HII_GLYPH_INFO Cell;
+ UINT8 BitmapData[1]; // the number of bytes per bitmap can be calculated by ((Cell.Width+7)/8)*Cell.Height
+} EFI_HII_GIBT_GLYPH_BLOCK;
+
+typedef struct _EFI_HII_GIBT_GLYPHS_BLOCK {
+ EFI_HII_GLYPH_BLOCK Header;
+ EFI_HII_GLYPH_INFO Cell;
+ UINT16 Count;
+ UINT8 BitmapData[1]; // the number of bytes per bitmap can be calculated by ((Cell.Width+7)/8)*Cell.Height
+} EFI_HII_GIBT_GLYPHS_BLOCK;
+
+typedef struct _EFI_HII_GIBT_GLYPH_DEFAULT_BLOCK {
+ EFI_HII_GLYPH_BLOCK Header;
+ UINT8 BitmapData[1]; // the number of bytes per bitmap can be calculated by ((Global.Cell.Width+7)/8)*Global.Cell.Height
+} EFI_HII_GIBT_GLYPH_DEFAULT_BLOCK;
+
+typedef struct _EFI_HII_GIBT_GLYPHS_DEFAULT_BLOCK {
+ EFI_HII_GLYPH_BLOCK Header;
+ UINT16 Count;
+ UINT8 BitmapData[1]; // the number of bytes per bitmap can be calculated by ((Global.Cell.Width+7)/8)*Global.Cell.Height
+} EFI_HII_GIBT_GLYPHS_DEFAULT_BLOCK;
+
+typedef struct _EFI_HII_GIBT_SKIP1_BLOCK {
+ EFI_HII_GLYPH_BLOCK Header;
+ UINT8 SkipCount;
+} EFI_HII_GIBT_SKIP1_BLOCK;
+
+typedef struct _EFI_HII_GIBT_SKIP2_BLOCK {
+ EFI_HII_GLYPH_BLOCK Header;
+ UINT16 SkipCount;
+} EFI_HII_GIBT_SKIP2_BLOCK;
+
+//
+// Device Path Package
+//
+typedef struct _EFI_HII_DEVICE_PATH_PACKAGE {
+ EFI_HII_PACKAGE_HEADER Header;
+ // EFI_DEVICE_PATH_PROTOCOL DevicePath[];
+} EFI_HII_DEVICE_PATH_PACKAGE;
+
+//
+// GUID Package
+//
+typedef struct _EFI_HII_GUID_PACKAGE_HDR {
+ EFI_HII_PACKAGE_HEADER Header;
+ EFI_GUID Guid;
+ // Data per GUID definition may follow
+} EFI_HII_GUID_PACKAGE_HDR;
+
+//
+// String Package
+//
+
+#define UEFI_CONFIG_LANG "x-UEFI"
+#define UEFI_CONFIG_LANG_2 "x-i-UEFI"
+
+typedef struct _EFI_HII_STRING_PACKAGE_HDR {
+ EFI_HII_PACKAGE_HEADER Header;
+ UINT32 HdrSize;
+ UINT32 StringInfoOffset;
+ CHAR16 LanguageWindow[16];
+ EFI_STRING_ID LanguageName;
+ CHAR8 Language[1];
+} EFI_HII_STRING_PACKAGE_HDR;
+
+typedef struct {
+ UINT8 BlockType;
+} EFI_HII_STRING_BLOCK;
+
+#define EFI_HII_SIBT_END 0x00
+#define EFI_HII_SIBT_STRING_SCSU 0x10
+#define EFI_HII_SIBT_STRING_SCSU_FONT 0x11
+#define EFI_HII_SIBT_STRINGS_SCSU 0x12
+#define EFI_HII_SIBT_STRINGS_SCSU_FONT 0x13
+#define EFI_HII_SIBT_STRING_UCS2 0x14
+#define EFI_HII_SIBT_STRING_UCS2_FONT 0x15
+#define EFI_HII_SIBT_STRINGS_UCS2 0x16
+#define EFI_HII_SIBT_STRINGS_UCS2_FONT 0x17
+#define EFI_HII_SIBT_DUPLICATE 0x20
+#define EFI_HII_SIBT_SKIP2 0x21
+#define EFI_HII_SIBT_SKIP1 0x22
+#define EFI_HII_SIBT_EXT1 0x30
+#define EFI_HII_SIBT_EXT2 0x31
+#define EFI_HII_SIBT_EXT4 0x32
+#define EFI_HII_SIBT_FONT 0x40
+
+typedef struct _EFI_HII_SIBT_DUPLICATE_BLOCK {
+ EFI_HII_STRING_BLOCK Header;
+ EFI_STRING_ID StringId;
+} EFI_HII_SIBT_DUPLICATE_BLOCK;
+
+typedef struct _EFI_HII_SIBT_END_BLOCK {
+ EFI_HII_STRING_BLOCK Header;
+} EFI_HII_SIBT_END_BLOCK;
+
+typedef struct _EFI_HII_SIBT_EXT1_BLOCK {
+ EFI_HII_STRING_BLOCK Header;
+ UINT8 BlockType2;
+ UINT8 Length;
+} EFI_HII_SIBT_EXT1_BLOCK;
+
+typedef struct _EFI_HII_SIBT_EXT2_BLOCK {
+ EFI_HII_STRING_BLOCK Header;
+ UINT8 BlockType2;
+ UINT16 Length;
+} EFI_HII_SIBT_EXT2_BLOCK;
+
+typedef struct _EFI_HII_SIBT_EXT4_BLOCK {
+ EFI_HII_STRING_BLOCK Header;
+ UINT8 BlockType2;
+ UINT32 Length;
+} EFI_HII_SIBT_EXT4_BLOCK;
+
+typedef struct _EFI_HII_SIBT_FONT_BLOCK {
+ EFI_HII_SIBT_EXT2_BLOCK Header;
+ UINT8 FontId;
+ UINT16 FontSize;
+ EFI_HII_FONT_STYLE FontStyle;
+ CHAR16 FontName[1];
+} EFI_HII_SIBT_FONT_BLOCK;
+
+typedef struct _EFI_HII_SIBT_SKIP1_BLOCK {
+ EFI_HII_STRING_BLOCK Header;
+ UINT8 SkipCount;
+} EFI_HII_SIBT_SKIP1_BLOCK;
+
+typedef struct _EFI_HII_SIBT_SKIP2_BLOCK {
+ EFI_HII_STRING_BLOCK Header;
+ UINT16 SkipCount;
+} EFI_HII_SIBT_SKIP2_BLOCK;
+
+typedef struct _EFI_HII_SIBT_STRING_SCSU_BLOCK {
+ EFI_HII_STRING_BLOCK Header;
+ UINT8 StringText[1];
+} EFI_HII_SIBT_STRING_SCSU_BLOCK;
+
+typedef struct _EFI_HII_SIBT_STRING_SCSU_FONT_BLOCK {
+ EFI_HII_STRING_BLOCK Header;
+ UINT8 FontIdentifier;
+ UINT8 StringText[1];
+} EFI_HII_SIBT_STRING_SCSU_FONT_BLOCK;
+
+typedef struct _EFI_HII_SIBT_STRINGS_SCSU_BLOCK {
+ EFI_HII_STRING_BLOCK Header;
+ UINT16 StringCount;
+ UINT8 StringText[1];
+} EFI_HII_SIBT_STRINGS_SCSU_BLOCK;
+
+typedef struct _EFI_HII_SIBT_STRINGS_SCSU_FONT_BLOCK {
+ EFI_HII_STRING_BLOCK Header;
+ UINT8 FontIdentifier;
+ UINT16 StringCount;
+ UINT8 StringText[1];
+} EFI_HII_SIBT_STRINGS_SCSU_FONT_BLOCK;
+
+typedef struct _EFI_HII_SIBT_STRING_UCS2_BLOCK {
+ EFI_HII_STRING_BLOCK Header;
+ CHAR16 StringText[1];
+} EFI_HII_SIBT_STRING_UCS2_BLOCK;
+
+typedef struct _EFI_HII_SIBT_STRING_UCS2_FONT_BLOCK {
+ EFI_HII_STRING_BLOCK Header;
+ UINT8 FontIdentifier;
+ CHAR16 StringText[1];
+} EFI_HII_SIBT_STRING_UCS2_FONT_BLOCK;
+
+typedef struct _EFI_HII_SIBT_STRINGS_UCS2_BLOCK {
+ EFI_HII_STRING_BLOCK Header;
+ UINT16 StringCount;
+ CHAR16 StringText[1];
+} EFI_HII_SIBT_STRINGS_UCS2_BLOCK;
+
+typedef struct _EFI_HII_SIBT_STRINGS_UCS2_FONT_BLOCK {
+ EFI_HII_STRING_BLOCK Header;
+ UINT8 FontIdentifier;
+ UINT16 StringCount;
+ CHAR16 StringText[1];
+} EFI_HII_SIBT_STRINGS_UCS2_FONT_BLOCK;
+
+//
+// Image Packages
+//
+
+typedef struct _EFI_HII_IMAGE_PACKAGE_HDR {
+ EFI_HII_PACKAGE_HEADER Header;
+ UINT32 ImageInfoOffset;
+ UINT32 PaletteInfoOffset;
+} EFI_HII_IMAGE_PACKAGE_HDR;
+
+typedef struct _EFI_HII_IMAGE_BLOCK {
+ UINT8 BlockType;
+} EFI_HII_IMAGE_BLOCK;
+
+#define EFI_HII_IIBT_END 0x00
+#define EFI_HII_IIBT_IMAGE_1BIT 0x10
+#define EFI_HII_IIBT_IMAGE_1BIT_TRANS 0x11
+#define EFI_HII_IIBT_IMAGE_4BIT 0x12
+#define EFI_HII_IIBT_IMAGE_4BIT_TRANS 0x13
+#define EFI_HII_IIBT_IMAGE_8BIT 0x14
+#define EFI_HII_IIBT_IMAGE_8BIT_TRANS 0x15
+#define EFI_HII_IIBT_IMAGE_24BIT 0x16
+#define EFI_HII_IIBT_IMAGE_24BIT_TRANS 0x17
+#define EFI_HII_IIBT_IMAGE_JPEG 0x18
+#define EFI_HII_IIBT_DUPLICATE 0x20
+#define EFI_HII_IIBT_SKIP2 0x21
+#define EFI_HII_IIBT_SKIP1 0x22
+#define EFI_HII_IIBT_EXT1 0x30
+#define EFI_HII_IIBT_EXT2 0x31
+#define EFI_HII_IIBT_EXT4 0x32
+
+typedef struct _EFI_HII_IIBT_END_BLOCK {
+ EFI_HII_IMAGE_BLOCK Header;
+} EFI_HII_IIBT_END_BLOCK;
+
+typedef struct _EFI_HII_IIBT_EXT1_BLOCK {
+ EFI_HII_IMAGE_BLOCK Header;
+ UINT8 BlockType2;
+ UINT8 Length;
+} EFI_HII_IIBT_EXT1_BLOCK;
+
+typedef struct _EFI_HII_IIBT_EXT2_BLOCK {
+ EFI_HII_IMAGE_BLOCK Header;
+ UINT8 BlockType2;
+ UINT16 Length;
+} EFI_HII_IIBT_EXT2_BLOCK;
+
+typedef struct _EFI_HII_IIBT_EXT4_BLOCK {
+ EFI_HII_IMAGE_BLOCK Header;
+ UINT8 BlockType2;
+ UINT32 Length;
+} EFI_HII_IIBT_EXT4_BLOCK;
+
+typedef struct _EFI_HII_IIBT_IMAGE_1BIT_BASE {
+ UINT16 Width;
+ UINT16 Height;
+ UINT8 Data[1];
+} EFI_HII_IIBT_IMAGE_1BIT_BASE;
+
+typedef struct _EFI_HII_IIBT_IMAGE_1BIT_BLOCK {
+ EFI_HII_IMAGE_BLOCK Header;
+ UINT8 PaletteIndex;
+ EFI_HII_IIBT_IMAGE_1BIT_BASE Bitmap;
+} EFI_HII_IIBT_IMAGE_1BIT_BLOCK;
+
+typedef struct _EFI_HII_IIBT_IMAGE_1BIT_TRANS_BLOCK {
+ EFI_HII_IMAGE_BLOCK Header;
+ UINT8 PaletteIndex;
+ EFI_HII_IIBT_IMAGE_1BIT_BASE Bitmap;
+} EFI_HII_IIBT_IMAGE_1BIT_TRANS_BLOCK;
+
+typedef struct _EFI_HII_RGB_PIXEL {
+ UINT8 b;
+ UINT8 g;
+ UINT8 r;
+} EFI_HII_RGB_PIXEL;
+
+typedef struct _EFI_HII_IIBT_IMAGE_24BIT_BASE {
+ UINT16 Width;
+ UINT16 Height;
+ EFI_HII_RGB_PIXEL Bitmap[1];
+} EFI_HII_IIBT_IMAGE_24BIT_BASE;
+
+typedef struct _EFI_HII_IIBT_IMAGE_24BIT_BLOCK {
+ EFI_HII_IMAGE_BLOCK Header;
+ EFI_HII_IIBT_IMAGE_24BIT_BASE Bitmap;
+} EFI_HII_IIBT_IMAGE_24BIT_BLOCK;
+
+typedef struct _EFI_HII_IIBT_IMAGE_24BIT_TRANS_BLOCK {
+ EFI_HII_IMAGE_BLOCK Header;
+ EFI_HII_IIBT_IMAGE_24BIT_BASE Bitmap;
+} EFI_HII_IIBT_IMAGE_24BIT_TRANS_BLOCK;
+
+typedef struct _EFI_HII_IIBT_IMAGE_4BIT_BASE {
+ UINT16 Width;
+ UINT16 Height;
+ UINT8 Data[1];
+} EFI_HII_IIBT_IMAGE_4BIT_BASE;
+
+typedef struct _EFI_HII_IIBT_IMAGE_4BIT_BLOCK {
+ EFI_HII_IMAGE_BLOCK Header;
+ UINT8 PaletteIndex;
+ EFI_HII_IIBT_IMAGE_4BIT_BASE Bitmap;
+} EFI_HII_IIBT_IMAGE_4BIT_BLOCK;
+
+typedef struct _EFI_HII_IIBT_IMAGE_4BIT_TRANS_BLOCK {
+ EFI_HII_IMAGE_BLOCK Header;
+ UINT8 PaletteIndex;
+ EFI_HII_IIBT_IMAGE_4BIT_BASE Bitmap;
+} EFI_HII_IIBT_IMAGE_4BIT_TRANS_BLOCK;
+
+typedef struct _EFI_HII_IIBT_IMAGE_8BIT_BASE {
+ UINT16 Width;
+ UINT16 Height;
+ UINT8 Data[1];
+} EFI_HII_IIBT_IMAGE_8BIT_BASE;
+
+typedef struct _EFI_HII_IIBT_IMAGE_8BIT_PALETTE_BLOCK {
+ EFI_HII_IMAGE_BLOCK Header;
+ UINT8 PaletteIndex;
+ EFI_HII_IIBT_IMAGE_8BIT_BASE Bitmap;
+} EFI_HII_IIBT_IMAGE_8BIT_BLOCK;
+
+typedef struct _EFI_HII_IIBT_IMAGE_8BIT_TRANS_BLOCK {
+ EFI_HII_IMAGE_BLOCK Header;
+ UINT8 PaletteIndex;
+ EFI_HII_IIBT_IMAGE_8BIT_BASE Bitmap;
+} EFI_HII_IIBT_IMAGE_8BIT_TRAN_BLOCK;
+
+typedef struct _EFI_HII_IIBT_DUPLICATE_BLOCK {
+ EFI_HII_IMAGE_BLOCK Header;
+ EFI_IMAGE_ID ImageId;
+} EFI_HII_IIBT_DUPLICATE_BLOCK;
+
+typedef struct _EFI_HII_IIBT_JPEG_BLOCK {
+ EFI_HII_IMAGE_BLOCK Header;
+ UINT32 Size;
+ UINT8 Data[1];
+} EFI_HII_IIBT_JPEG_BLOCK;
+
+typedef struct _EFI_HII_IIBT_SKIP1_BLOCK {
+ EFI_HII_IMAGE_BLOCK Header;
+ UINT8 SkipCount;
+} EFI_HII_IIBT_SKIP1_BLOCK;
+
+typedef struct _EFI_HII_IIBT_SKIP2_BLOCK {
+ EFI_HII_IMAGE_BLOCK Header;
+ UINT16 SkipCount;
+} EFI_HII_IIBT_SKIP2_BLOCK;
+
+typedef struct _EFI_HII_IMAGE_PALETTE_INFO_HEADER {
+ UINT16 PaletteCount;
+} EFI_HII_IMAGE_PALETTE_INFO_HEADER;
+
+typedef struct _EFI_HII_IMAGE_PALETTE_INFO {
+ UINT16 PaletteSize;
+ EFI_HII_RGB_PIXEL PaletteValue[1];
+} EFI_HII_IMAGE_PALETTE_INFO;
+
+//
+// Forms Package
+//
+
+typedef struct _EFI_HII_FORM_PACKAGE {
+ EFI_HII_PACKAGE_HEADER Header;
+ // EFI_IFR_OP_HEADER OpCodeHeader;
+ // More op-codes follow
+} EFI_HII_FORM_PACKAGE;
+
+typedef struct {
+ UINT8 Hour;
+ UINT8 Minute;
+ UINT8 Second;
+} EFI_HII_TIME;
+
+typedef struct {
+ UINT16 Year;
+ UINT8 Month;
+ UINT8 Day;
+} EFI_HII_DATE;
+
+typedef union {
+ UINT8 u8;
+ UINT16 u16;
+ UINT32 u32;
+ UINT64 u64;
+ BOOLEAN b;
+ EFI_HII_TIME time;
+ EFI_HII_DATE date;
+ EFI_STRING_ID string;
+} EFI_IFR_TYPE_VALUE;
+
+#define EFI_IFR_FORM_OP 0x01
+#define EFI_IFR_SUBTITLE_OP 0x02
+#define EFI_IFR_TEXT_OP 0x03
+#define EFI_IFR_IMAGE_OP 0x04
+#define EFI_IFR_ONE_OF_OP 0x05
+#define EFI_IFR_CHECKBOX_OP 0x06
+#define EFI_IFR_NUMERIC_OP 0x07
+#define EFI_IFR_PASSWORD_OP 0x08
+#define EFI_IFR_ONE_OF_OPTION_OP 0x09
+#define EFI_IFR_SUPPRESS_IF_OP 0x0A
+#define EFI_IFR_LOCKED_OP 0x0B
+#define EFI_IFR_ACTION_OP 0x0C
+#define EFI_IFR_RESET_BUTTON_OP 0x0D
+#define EFI_IFR_FORM_SET_OP 0x0E
+#define EFI_IFR_REF_OP 0x0F
+#define EFI_IFR_NO_SUBMIT_IF_OP 0x10
+#define EFI_IFR_INCONSISTENT_IF_OP 0x11
+#define EFI_IFR_EQ_ID_VAL_OP 0x12
+#define EFI_IFR_EQ_ID_ID_OP 0x13
+#define EFI_IFR_EQ_ID_LIST_OP 0x14
+#define EFI_IFR_AND_OP 0x15
+#define EFI_IFR_OR_OP 0x16
+#define EFI_IFR_NOT_OP 0x17
+#define EFI_IFR_RULE_OP 0x18
+#define EFI_IFR_GRAY_OUT_IF_OP 0x19
+#define EFI_IFR_DATE_OP 0x1A
+#define EFI_IFR_TIME_OP 0x1B
+#define EFI_IFR_STRING_OP 0x1C
+#define EFI_IFR_REFRESH_OP 0x1D
+#define EFI_IFR_DISABLE_IF_OP 0x1E
+#define EFI_IFR_TO_LOWER_OP 0x20
+#define EFI_IFR_TO_UPPER_OP 0x21
+#define EFI_IFR_ORDERED_LIST_OP 0x23
+#define EFI_IFR_VARSTORE_OP 0x24
+#define EFI_IFR_VARSTORE_NAME_VALUE_OP 0x25
+#define EFI_IFR_VARSTORE_EFI_OP 0x26
+#define EFI_IFR_VARSTORE_DEVICE_OP 0x27
+#define EFI_IFR_VERSION_OP 0x28
+#define EFI_IFR_END_OP 0x29
+#define EFI_IFR_MATCH_OP 0x2A
+#define EFI_IFR_EQUAL_OP 0x2F
+#define EFI_IFR_NOT_EQUAL_OP 0x30
+#define EFI_IFR_GREATER_THAN_OP 0x31
+#define EFI_IFR_GREATER_EQUAL_OP 0x32
+#define EFI_IFR_LESS_THAN_OP 0x33
+#define EFI_IFR_LESS_EQUAL_OP 0x34
+#define EFI_IFR_BITWISE_AND_OP 0x35
+#define EFI_IFR_BITWISE_OR_OP 0x36
+#define EFI_IFR_BITWISE_NOT_OP 0x37
+#define EFI_IFR_SHIFT_LEFT_OP 0x38
+#define EFI_IFR_SHIFT_RIGHT_OP 0x39
+#define EFI_IFR_ADD_OP 0x3A
+#define EFI_IFR_SUBTRACT_OP 0x3B
+#define EFI_IFR_MULTIPLY_OP 0x3C
+#define EFI_IFR_DIVIDE_OP 0x3D
+#define EFI_IFR_MODULO_OP 0x3E
+#define EFI_IFR_RULE_REF_OP 0x3F
+#define EFI_IFR_QUESTION_REF1_OP 0x40
+#define EFI_IFR_QUESTION_REF2_OP 0x41
+#define EFI_IFR_UINT8_OP 0x42
+#define EFI_IFR_UINT16_OP 0x43
+#define EFI_IFR_UINT32_OP 0x44
+#define EFI_IFR_UINT64_OP 0x45
+#define EFI_IFR_TRUE_OP 0x46
+#define EFI_IFR_FALSE_OP 0x47
+#define EFI_IFR_TO_UINT_OP 0x48
+#define EFI_IFR_TO_STRING_OP 0x49
+#define EFI_IFR_TO_BOOLEAN_OP 0x4A
+#define EFI_IFR_MID_OP 0x4B
+#define EFI_IFR_FIND_OP 0x4C
+#define EFI_IFR_TOKEN_OP 0x4D
+#define EFI_IFR_STRING_REF1_OP 0x4E
+#define EFI_IFR_STRING_REF2_OP 0x4F
+#define EFI_IFR_CONDITIONAL_OP 0x50
+#define EFI_IFR_QUESTION_REF3_OP 0x51
+#define EFI_IFR_ZERO_OP 0x52
+#define EFI_IFR_ONE_OP 0x53
+#define EFI_IFR_ONES_OP 0x54
+#define EFI_IFR_UNDEFINED_OP 0x55
+#define EFI_IFR_LENGTH_OP 0x56
+#define EFI_IFR_DUP_OP 0x57
+#define EFI_IFR_THIS_OP 0x58
+#define EFI_IFR_SPAN_OP 0x59
+#define EFI_IFR_VALUE_OP 0x5A
+#define EFI_IFR_DEFAULT_OP 0x5B
+#define EFI_IFR_DEFAULTSTORE_OP 0x5C
+#define EFI_IFR_CATENATE_OP 0x5E
+#define EFI_IFR_GUID_OP 0x5F
+
+typedef struct _EFI_IFR_OP_HEADER {
+ UINT8 OpCode;
+ UINT8 Length:7;
+ UINT8 Scope:1;
+} EFI_IFR_OP_HEADER;
+
+typedef struct _EFI_IFR_STATEMENT_HEADER {
+ EFI_STRING_ID Prompt;
+ EFI_STRING_ID Help;
+} EFI_IFR_STATEMENT_HEADER;
+
+typedef struct _EFI_IFR_QUESTION_HEADER {
+ EFI_IFR_STATEMENT_HEADER Header;
+ EFI_QUESTION_ID QuestionId;
+ EFI_VARSTORE_ID VarStoreId;
+ union {
+ EFI_STRING_ID VarName;
+ UINT16 VarOffset;
+ } VarStoreInfo;
+ UINT8 Flags;
+} EFI_IFR_QUESTION_HEADER;
+
+#define EFI_IFR_FLAG_READ_ONLY 0x01
+#define EFI_IFR_FLAG_CALLBACK 0x04
+#define EFI_IFR_FLAG_RESET_REQUIRED 0x10
+#define EFI_IFR_FLAG_OPTIONS_ONLY 0x80
+
+typedef struct _EFI_IFR_DEFAULTSTORE {
+ EFI_IFR_OP_HEADER Header;
+ EFI_STRING_ID DefaultName;
+ UINT16 DefaultId;
+} EFI_IFR_DEFAULTSTORE;
+
+#define EFI_HII_DEFAULT_CLASS_STANDARD 0x0000
+#define EFI_HII_DEFAULT_CLASS_MANUFACTURING 0x0001
+#define EFI_HII_DEFAULT_CLASS_SAFE 0x0002
+#define EFI_HII_DEFAULT_CLASS_PLATFORM_BEGIN 0x4000
+#define EFI_HII_DEFAULT_CLASS_PLATFORM_END 0x7fff
+#define EFI_HII_DEFAULT_CLASS_HARDWARE_BEGIN 0x8000
+#define EFI_HII_DEFAULT_CLASS_HARDWARE_END 0xbfff
+#define EFI_HII_DEFAULT_CLASS_FIRMWARE_BEGIN 0xc000
+#define EFI_HII_DEFAULT_CLASS_FIRMWARE_END 0xffff
+
+typedef struct _EFI_IFR_VARSTORE {
+ EFI_IFR_OP_HEADER Header;
+ EFI_GUID Guid;
+ EFI_VARSTORE_ID VarStoreId;
+ UINT16 Size;
+ UINT8 Name[1];
+} EFI_IFR_VARSTORE;
+
+typedef struct _EFI_IFR_VARSTORE_EFI {
+ EFI_IFR_OP_HEADER Header;
+ EFI_VARSTORE_ID VarStoreId;
+ EFI_GUID Guid;
+ UINT32 Attributes;
+} EFI_IFR_VARSTORE_EFI;
+
+typedef struct _EFI_IFR_VARSTORE_NAME_VALUE {
+ EFI_IFR_OP_HEADER Header;
+ EFI_VARSTORE_ID VarStoreId;
+ EFI_GUID Guid;
+} EFI_IFR_VARSTORE_NAME_VALUE;
+
+typedef struct _EFI_IFR_FORM_SET {
+ EFI_IFR_OP_HEADER Header;
+ EFI_GUID Guid;
+ EFI_STRING_ID FormSetTitle;
+ EFI_STRING_ID Help;
+ UINT8 Flags;
+ EFI_GUID ClassGuid[1];
+} EFI_IFR_FORM_SET;
+
+#define EFI_HII_PLATFORM_SETUP_FORMSET_GUID \
+ { 0x93039971, 0x8545, 0x4b04, { 0xb4, 0x5e, 0x32, 0xeb, 0x83, 0x26, 0x4, 0xe } }
+
+typedef struct _EFI_IFR_END {
+ EFI_IFR_OP_HEADER Header;
+} EFI_IFR_END;
+
+typedef struct _EFI_IFR_FORM {
+ EFI_IFR_OP_HEADER Header;
+ UINT16 FormId;
+ EFI_STRING_ID FormTitle;
+} EFI_IFR_FORM;
+
+typedef struct _EFI_IFR_IMAGE {
+ EFI_IFR_OP_HEADER Header;
+ EFI_IMAGE_ID Id;
+} EFI_IFR_IMAGE;
+
+typedef struct _EFI_IFR_LOCKED {
+ EFI_IFR_OP_HEADER Header;
+} EFI_IFR_LOCKED;
+
+typedef struct _EFI_IFR_RULE {
+ EFI_IFR_OP_HEADER Header;
+ UINT8 RuleId;
+} EFI_IFR_RULE;
+
+typedef struct _EFI_IFR_DEFAULT {
+ EFI_IFR_OP_HEADER Header;
+ UINT16 DefaultId;
+ UINT8 Type;
+ EFI_IFR_TYPE_VALUE Value;
+} EFI_IFR_DEFAULT;
+
+typedef struct _EFI_IFR_VALUE {
+ EFI_IFR_OP_HEADER Header;
+} EFI_IFR_VALUE;
+
+typedef struct _EFI_IFR_SUBTITLE {
+ EFI_IFR_OP_HEADER Header;
+ EFI_IFR_STATEMENT_HEADER Statement;
+ UINT8 Flags;
+} EFI_IFR_SUBTITLE;
+
+#define EFI_IFR_FLAGS_HORIZONTAL 0x01
+
+typedef struct _EFI_IFR_CHECKBOX {
+ EFI_IFR_OP_HEADER Header;
+ EFI_IFR_QUESTION_HEADER Question;
+ UINT8 Flags;
+} EFI_IFR_CHECKBOX;
+
+#define EFI_IFR_CHECKBOX_DEFAULT 0x01
+#define EFI_IFR_CHECKBOX_DEFAULT_MFG 0x02
+
+typedef struct _EFI_IFR_TEXT {
+ EFI_IFR_OP_HEADER Header;
+ EFI_IFR_STATEMENT_HEADER Statement;
+ EFI_STRING_ID TextTwo;
+} EFI_IFR_TEXT;
+
+typedef struct _EFI_IFR_REF {
+ EFI_IFR_OP_HEADER Header;
+ EFI_IFR_QUESTION_HEADER Question;
+ EFI_FORM_ID FormId;
+} EFI_IFR_REF;
+
+typedef struct _EFI_IFR_REF2 {
+ EFI_IFR_OP_HEADER Header;
+ EFI_IFR_QUESTION_HEADER Question;
+ EFI_FORM_ID FormId;
+ EFI_QUESTION_ID QuestionId;
+} EFI_IFR_REF2;
+
+typedef struct _EFI_IFR_REF3 {
+ EFI_IFR_OP_HEADER Header;
+ EFI_IFR_QUESTION_HEADER Question;
+ EFI_FORM_ID FormId;
+ EFI_QUESTION_ID QuestionId;
+ EFI_GUID FormSetId;
+} EFI_IFR_REF3;
+
+typedef struct _EFI_IFR_REF4 {
+ EFI_IFR_OP_HEADER Header;
+ EFI_IFR_QUESTION_HEADER Question;
+ EFI_FORM_ID FormId;
+ EFI_QUESTION_ID QuestionId;
+ EFI_GUID FormSetId;
+ EFI_STRING_ID DevicePath;
+} EFI_IFR_REF4;
+
+typedef struct _EFI_IFR_RESET_BUTTON {
+ EFI_IFR_OP_HEADER Header;
+ EFI_IFR_STATEMENT_HEADER Statement;
+ EFI_DEFAULT_ID DefaultId;
+} EFI_IFR_RESET_BUTTON;
+
+typedef struct _EFI_IFR_ACTION {
+ EFI_IFR_OP_HEADER Header;
+ EFI_IFR_QUESTION_HEADER Question;
+ EFI_STRING_ID QuestionConfig;
+} EFI_IFR_ACTION;
+
+typedef struct _EFI_IFR_ACTION_1 {
+ EFI_IFR_OP_HEADER Header;
+ EFI_IFR_QUESTION_HEADER Question;
+} EFI_IFR_ACTION_1;
+
+typedef struct _EFI_IFR_DATE {
+ EFI_IFR_OP_HEADER Header;
+ EFI_IFR_QUESTION_HEADER Question;
+ UINT8 Flags;
+} EFI_IFR_DATE;
+
+#define EFI_QF_DATE_YEAR_SUPPRESS 0x01
+#define EFI_QF_DATE_MONTH_SUPPRESS 0x02
+#define EFI_QF_DATE_DAY_SUPPRESS 0x04
+
+#define EFI_QF_DATE_STORAGE 0x30
+#define QF_DATE_STORAGE_NORMAL 0x00
+#define QF_DATE_STORAGE_TIME 0x10
+#define QF_DATE_STORAGE_WAKEUP 0x20
+
+typedef union {
+ struct {
+ UINT8 MinValue;
+ UINT8 MaxValue;
+ UINT8 Step;
+ } u8;
+ struct {
+ UINT16 MinValue;
+ UINT16 MaxValue;
+ UINT16 Step;
+ } u16;
+ struct {
+ UINT32 MinValue;
+ UINT32 MaxValue;
+ UINT32 Step;
+ } u32;
+ struct {
+ UINT64 MinValue;
+ UINT64 MaxValue;
+ UINT64 Step;
+ } u64;
+} MINMAXSTEP_DATA;
+
+typedef struct _EFI_IFR_NUMERIC {
+ EFI_IFR_OP_HEADER Header;
+ EFI_IFR_QUESTION_HEADER Question;
+ UINT8 Flags;
+ MINMAXSTEP_DATA data;
+} EFI_IFR_NUMERIC;
+
+#define EFI_IFR_NUMERIC_SIZE 0x03
+#define EFI_IFR_NUMERIC_SIZE_1 0x00
+#define EFI_IFR_NUMERIC_SIZE_2 0x01
+#define EFI_IFR_NUMERIC_SIZE_4 0x02
+#define EFI_IFR_NUMERIC_SIZE_8 0x03
+
+#define EFI_IFR_DISPLAY 0x30
+#define EFI_IFR_DISPLAY_INT_DEC 0x00
+#define EFI_IFR_DISPLAY_UINT_DEC 0x10
+#define EFI_IFR_DISPLAY_UINT_HEX 0x20
+
+typedef struct _EFI_IFR_ONE_OF {
+ EFI_IFR_OP_HEADER Header;
+ EFI_IFR_QUESTION_HEADER Question;
+ UINT8 Flags;
+ MINMAXSTEP_DATA data;
+} EFI_IFR_ONE_OF;
+
+typedef struct _EFI_IFR_STRING {
+ EFI_IFR_OP_HEADER Header;
+ EFI_IFR_QUESTION_HEADER Question;
+ UINT8 MinSize;
+ UINT8 MaxSize;
+ UINT8 Flags;
+} EFI_IFR_STRING;
+
+#define EFI_IFR_STRING_MULTI_LINE 0x01
+
+typedef struct _EFI_IFR_PASSWORD {
+ EFI_IFR_OP_HEADER Header;
+ EFI_IFR_QUESTION_HEADER Question;
+ UINT16 MinSize;
+ UINT16 MaxSize;
+} EFI_IFR_PASSWORD;
+
+typedef struct _EFI_IFR_ORDERED_LIST {
+ EFI_IFR_OP_HEADER Header;
+ EFI_IFR_QUESTION_HEADER Question;
+ UINT8 MaxContainers;
+ UINT8 Flags;
+} EFI_IFR_ORDERED_LIST;
+
+#define EFI_IFR_UNIQUE_SET 0x01
+#define EFI_IFR_NO_EMPTY_SET 0x02
+
+typedef struct _EFI_IFR_TIME {
+ EFI_IFR_OP_HEADER Header;
+ EFI_IFR_QUESTION_HEADER Question;
+ UINT8 Flags;
+} EFI_IFR_TIME;
+
+#define QF_TIME_HOUR_SUPPRESS 0x01
+#define QF_TIME_MINUTE_SUPPRESS 0x02
+#define QF_TIME_SECOND_SUPPRESS 0x04
+
+#define QF_TIME_STORAGE 0x30
+#define QF_TIME_STORAGE_NORMAL 0x00
+#define QF_TIME_STORAGE_TIME 0x10
+#define QF_TIME_STORAGE_WAKEUP 0x20
+
+typedef struct _EFI_IFR_DISABLE_IF {
+ EFI_IFR_OP_HEADER Header;
+} EFI_IFR_DISABLE_IF;
+
+typedef struct _EFI_IFR_SUPPRESS_IF {
+ EFI_IFR_OP_HEADER Header;
+} EFI_IFR_SUPPRESS_IF;
+
+typedef struct _EFI_IFR_GRAY_OUT_IF {
+ EFI_IFR_OP_HEADER Header;
+} EFI_IFR_GRAY_OUT_IF;
+
+typedef struct _EFI_IFR_INCONSISTENT_IF {
+ EFI_IFR_OP_HEADER Header;
+ EFI_STRING_ID Error;
+} EFI_IFR_INCONSISTENT_IF;
+
+typedef struct _EFI_IFR_NO_SUBMIT_IF {
+ EFI_IFR_OP_HEADER Header;
+ EFI_STRING_ID Error;
+} EFI_IFR_NO_SUBMIT_IF;
+
+typedef struct _EFI_IFR_REFRESH {
+ EFI_IFR_OP_HEADER Header;
+ UINT8 RefreshInterval;
+} EFI_IFR_REFRESH;
+
+typedef struct _EFI_IFR_VARSTORE_DEVICE {
+ EFI_IFR_OP_HEADER Header;
+ EFI_STRING_ID DevicePath;
+} EFI_IFR_VARSTORE_DEVICE;
+
+typedef struct _EFI_IFR_ONE_OF_OPTION {
+ EFI_IFR_OP_HEADER Header;
+ EFI_STRING_ID Option;
+ UINT8 Flags;
+ UINT8 Type;
+ EFI_IFR_TYPE_VALUE Value;
+} EFI_IFR_ONE_OF_OPTION;
+
+#define EFI_IFR_TYPE_NUM_SIZE_8 0x00
+#define EFI_IFR_TYPE_NUM_SIZE_16 0x01
+#define EFI_IFR_TYPE_NUM_SIZE_32 0x02
+#define EFI_IFR_TYPE_NUM_SIZE_64 0x03
+#define EFI_IFR_TYPE_BOOLEAN 0x04
+#define EFI_IFR_TYPE_TIME 0x05
+#define EFI_IFR_TYPE_DATE 0x06
+#define EFI_IFR_TYPE_STRING 0x07
+#define EFI_IFR_TYPE_OTHER 0x08
+
+#define EFI_IFR_OPTION_DEFAULT 0x10
+#define EFI_IFR_OPTION_DEFAULT_MFG 0x20
+
+typedef struct _EFI_IFR_GUID {
+ EFI_IFR_OP_HEADER Header;
+ EFI_GUID Guid;
+ //Optional Data Follows
+} EFI_IFR_GUID;
+
+typedef struct _EFI_IFR_DUP {
+ EFI_IFR_OP_HEADER Header;
+} EFI_IFR_DUP;
+
+typedef struct _EFI_IFR_EQ_ID_ID {
+ EFI_IFR_OP_HEADER Header;
+ EFI_QUESTION_ID QuestionId1;
+ EFI_QUESTION_ID QuestionId2;
+} EFI_IFR_EQ_ID_ID;
+
+typedef struct _EFI_IFR_EQ_ID_VAL {
+ EFI_IFR_OP_HEADER Header;
+ EFI_QUESTION_ID QuestionId;
+ UINT16 Value;
+} EFI_IFR_EQ_ID_VAL;
+
+typedef struct _EFI_IFR_EQ_ID_LIST {
+ EFI_IFR_OP_HEADER Header;
+ EFI_QUESTION_ID QuestionId;
+ UINT16 ListLength;
+ UINT16 ValueList[1];
+} EFI_IFR_EQ_ID_LIST;
+
+typedef struct _EFI_IFR_QUESTION_REF1 {
+ EFI_IFR_OP_HEADER Header;
+ EFI_QUESTION_ID QuestionId;
+} EFI_IFR_QUESTION_REF1;
+
+typedef struct _EFI_IFR_UINT8 {
+ EFI_IFR_OP_HEADER Header;
+ UINT8 Value;
+} EFI_IFR_UINT8;
+
+typedef struct _EFI_IFR_UINT16 {
+ EFI_IFR_OP_HEADER Header;
+ UINT16 Value;
+} EFI_IFR_UINT16;
+
+typedef struct _EFI_IFR_QUESTION_REF2 {
+ EFI_IFR_OP_HEADER Header;
+} EFI_IFR_QUESTION_REF2;
+
+typedef struct _EFI_IFR_UINT32 {
+ EFI_IFR_OP_HEADER Header;
+ UINT32 Value;
+} EFI_IFR_UINT32;
+
+typedef struct _EFI_IFR_UINT64 {
+ EFI_IFR_OP_HEADER Header;
+ UINT64 Value;
+} EFI_IFR_UINT64;
+
+typedef struct _EFI_IFR_QUESTION_REF3 {
+ EFI_IFR_OP_HEADER Header;
+} EFI_IFR_QUESTION_REF3;
+
+typedef struct _EFI_IFR_QUESTION_REF3_2 {
+ EFI_IFR_OP_HEADER Header;
+ EFI_STRING_ID DevicePath;
+} EFI_IFR_QUESTION_REF3_2;
+
+typedef struct _EFI_IFR_QUESTION_REF3_3 {
+ EFI_IFR_OP_HEADER Header;
+ EFI_STRING_ID DevicePath;
+ EFI_GUID Guid;
+} EFI_IFR_QUESTION_REF3_3;
+
+typedef struct _EFI_IFR_RULE_REF {
+ EFI_IFR_OP_HEADER Header;
+ UINT8 RuleId;
+} EFI_IFR_RULE_REF;
+
+typedef struct _EFI_IFR_STRING_REF1 {
+ EFI_IFR_OP_HEADER Header;
+ EFI_STRING_ID StringId;
+} EFI_IFR_STRING_REF1;
+
+typedef struct _EFI_IFR_STRING_REF2 {
+ EFI_IFR_OP_HEADER Header;
+} EFI_IFR_STRING_REF2;
+
+typedef struct _EFI_IFR_THIS {
+ EFI_IFR_OP_HEADER Header;
+} EFI_IFR_THIS;
+
+typedef struct _EFI_IFR_TRUE {
+ EFI_IFR_OP_HEADER Header;
+} EFI_IFR_TRUE;
+
+typedef struct _EFI_IFR_FALSE {
+ EFI_IFR_OP_HEADER Header;
+} EFI_IFR_FALSE;
+
+typedef struct _EFI_IFR_ONE {
+ EFI_IFR_OP_HEADER Header;
+} EFI_IFR_ONE;
+
+typedef struct _EFI_IFR_ONES {
+ EFI_IFR_OP_HEADER Header;
+} EFI_IFR_ONES;
+
+typedef struct _EFI_IFR_ZERO {
+ EFI_IFR_OP_HEADER Header;
+} EFI_IFR_ZERO;
+
+typedef struct _EFI_IFR_UNDEFINED {
+ EFI_IFR_OP_HEADER Header;
+} EFI_IFR_UNDEFINED;
+
+typedef struct _EFI_IFR_VERSION {
+ EFI_IFR_OP_HEADER Header;
+} EFI_IFR_VERSION;
+
+typedef struct _EFI_IFR_LENGTH {
+ EFI_IFR_OP_HEADER Header;
+} EFI_IFR_LENGTH;
+
+typedef struct _EFI_IFR_NOT {
+ EFI_IFR_OP_HEADER Header;
+} EFI_IFR_NOT;
+
+typedef struct _EFI_IFR_BITWISE_NOT {
+ EFI_IFR_OP_HEADER Header;
+} EFI_IFR_BITWISE_NOT;
+
+typedef struct _EFI_IFR_TO_BOOLEAN {
+ EFI_IFR_OP_HEADER Header;
+} EFI_IFR_TO_BOOLEAN;
+
+#define EFI_IFR_STRING_UNSIGNED_DEC 0
+#define EFI_IFR_STRING_SIGNED_DEC 1
+#define EFI_IFR_STRING_LOWERCASE_HEX 2
+#define EFI_IFR_STRING_UPPERCASE_HEX 3
+
+#define EFI_IFR_STRING_ASCII 0
+#define EFI_IFR_STRING_UNICODE 8
+
+typedef struct _EFI_IFR_TO_STRING {
+ EFI_IFR_OP_HEADER Header;
+ UINT8 Format;
+} EFI_IFR_TO_STRING;
+
+typedef struct _EFI_IFR_TO_UINT {
+ EFI_IFR_OP_HEADER Header;
+} EFI_IFR_TO_UINT;
+
+typedef struct _EFI_IFR_TO_UPPER {
+ EFI_IFR_OP_HEADER Header;
+} EFI_IFR_TO_UPPER;
+
+typedef struct _EFI_IFR_TO_LOWER {
+ EFI_IFR_OP_HEADER Header;
+} EFI_IFR_TO_LOWER;
+
+typedef struct _EFI_IFR_ADD {
+ EFI_IFR_OP_HEADER Header;
+} EFI_IFR_ADD;
+
+typedef struct _EFI_IFR_AND {
+ EFI_IFR_OP_HEADER Header;
+} EFI_IFR_AND;
+
+typedef struct _EFI_IFR_BITWISE_AND {
+ EFI_IFR_OP_HEADER Header;
+} EFI_IFR_BITWISE_AND;
+
+typedef struct _EFI_IFR_BITWISE_OR {
+ EFI_IFR_OP_HEADER Header;
+} EFI_IFR_BITWISE_OR;
+
+typedef struct _EFI_IFR_CATENATE {
+ EFI_IFR_OP_HEADER Header;
+} EFI_IFR_CATENATE;
+
+typedef struct _EFI_IFR_DIVIDE {
+ EFI_IFR_OP_HEADER Header;
+} EFI_IFR_DIVIDE;
+
+typedef struct _EFI_IFR_EQUAL {
+ EFI_IFR_OP_HEADER Header;
+} EFI_IFR_EQUAL;
+
+typedef struct _EFI_IFR_GREATER_EQUAL {
+ EFI_IFR_OP_HEADER Header;
+} EFI_IFR_GREATER_EQUAL;
+
+typedef struct _EFI_IFR_GREATER_THAN {
+ EFI_IFR_OP_HEADER Header;
+} EFI_IFR_GREATER_THAN;
+
+typedef struct _EFI_IFR_LESS_EQUAL {
+ EFI_IFR_OP_HEADER Header;
+} EFI_IFR_LESS_EQUAL;
+
+typedef struct _EFI_IFR_LESS_THAN {
+ EFI_IFR_OP_HEADER Header;
+} EFI_IFR_LESS_THAN;
+
+typedef struct _EFI_IFR_MATCH {
+ EFI_IFR_OP_HEADER Header;
+} EFI_IFR_MATCH;
+
+typedef struct _EFI_IFR_MULTIPLY {
+ EFI_IFR_OP_HEADER Header;
+} EFI_IFR_MULTIPLY;
+
+typedef struct _EFI_IFR_MODULO {
+ EFI_IFR_OP_HEADER Header;
+} EFI_IFR_MODULO;
+
+typedef struct _EFI_IFR_NOT_EQUAL {
+ EFI_IFR_OP_HEADER Header;
+} EFI_IFR_NOT_EQUAL;
+
+typedef struct _EFI_IFR_OR {
+ EFI_IFR_OP_HEADER Header;
+} EFI_IFR_OR;
+
+typedef struct _EFI_IFR_SHIFT_LEFT {
+ EFI_IFR_OP_HEADER Header;
+} EFI_IFR_SHIFT_LEFT;
+
+typedef struct _EFI_IFR_SHIFT_RIGHT {
+ EFI_IFR_OP_HEADER Header;
+} EFI_IFR_SHIFT_RIGHT;
+
+typedef struct _EFI_IFR_SUBTRACT {
+ EFI_IFR_OP_HEADER Header;
+} EFI_IFR_SUBTRACT;
+
+typedef struct _EFI_IFR_CONDITIONAL {
+ EFI_IFR_OP_HEADER Header;
+} EFI_IFR_CONDITIONAL;
+
+#define EFI_IFR_FF_CASE_SENSITIVE 0x00
+#define EFI_IFR_FF_CASE_INSENSITIVE 0x01
+
+typedef struct _EFI_IFR_FIND {
+ EFI_IFR_OP_HEADER Header;
+ UINT8 Format;
+} EFI_IFR_FIND;
+
+typedef struct _EFI_IFR_MID {
+ EFI_IFR_OP_HEADER Header;
+} EFI_IFR_MID;
+
+typedef struct _EFI_IFR_TOKEN {
+ EFI_IFR_OP_HEADER Header;
+} EFI_IFR_TOKEN;
+
+#define EFI_IFR_FLAGS_FIRST_MATCHING 0x00
+#define EFI_IFR_FLAGS_FIRST_NON_MATCHING 0x01
+
+typedef struct _EFI_IFR_SPAN {
+ EFI_IFR_OP_HEADER Header;
+ UINT8 Flags;
+} EFI_IFR_SPAN;
+
+//
+// Keyboard Package
+//
+
+typedef enum {
+ EfiKeyLCtrl,
+ EfiKeyA0,
+ EfiKeyLAlt,
+ EfiKeySpaceBar,
+ EfiKeyA2,
+ EfiKeyA3,
+ EfiKeyA4,
+ EfiKeyRCtrl,
+ EfiKeyLeftArrow,
+ EfiKeyDownArrow,
+ EfiKeyRightArrow,
+ EfiKeyZero,
+ EfiKeyPeriod,
+ EfiKeyEnter,
+ EfiKeyLShift,
+ EfiKeyB0,
+ EfiKeyB1,
+ EfiKeyB2,
+ EfiKeyB3,
+ EfiKeyB4,
+ EfiKeyB5,
+ EfiKeyB6,
+ EfiKeyB7,
+ EfiKeyB8,
+ EfiKeyB9,
+ EfiKeyB10,
+ EfiKeyRShift,
+ EfiKeyUpArrow,
+ EfiKeyOne,
+ EfiKeyTwo,
+ EfiKeyThree,
+ EfiKeyCapsLock,
+ EfiKeyC1,
+ EfiKeyC2,
+ EfiKeyC3,
+ EfiKeyC4,
+ EfiKeyC5,
+ EfiKeyC6,
+ EfiKeyC7,
+ EfiKeyC8,
+ EfiKeyC9,
+ EfiKeyC10,
+ EfiKeyC11,
+ EfiKeyC12,
+ EfiKeyFour,
+ EfiKeyFive,
+ EfiKeySix,
+ EfiKeyPlus,
+ EfiKeyTab,
+ EfiKeyD1,
+ EfiKeyD2,
+ EfiKeyD3,
+ EfiKeyD4,
+ EfiKeyD5,
+ EfiKeyD6,
+ EfiKeyD7,
+ EfiKeyD8,
+ EfiKeyD9,
+ EfiKeyD10,
+ EfiKeyD11,
+ EfiKeyD12,
+ EfiKeyD13,
+ EfiKeyDel,
+ EfiKeyEnd,
+ EfiKeyPgDn,
+ EfiKeySeven,
+ EfiKeyEight,
+ EfiKeyNine,
+ EfiKeyE0,
+ EfiKeyE1,
+ EfiKeyE2,
+ EfiKeyE3,
+ EfiKeyE4,
+ EfiKeyE5,
+ EfiKeyE6,
+ EfiKeyE7,
+ EfiKeyE8,
+ EfiKeyE9,
+ EfiKeyE10,
+ EfiKeyE11,
+ EfiKeyE12,
+ EfiKeyBackSpace,
+ EfiKeyIns,
+ EfiKeyHome,
+ EfiKeyPgUp,
+ EfiKeyNLck,
+ EfiKeySlash,
+ EfiKeyAsterisk,
+ EfiKeyMinus,
+ EfiKeyEsc,
+ EfiKeyF1,
+ EfiKeyF2,
+ EfiKeyF3,
+ EfiKeyF4,
+ EfiKeyF5,
+ EfiKeyF6,
+ EfiKeyF7,
+ EfiKeyF8,
+ EfiKeyF9,
+ EfiKeyF10,
+ EfiKeyF11,
+ EfiKeyF12,
+ EfiKeyPrint,
+ EfiKeySLck,
+ EfiKeyPause
+} EFI_KEY;
+
+typedef struct {
+ EFI_KEY Key;
+ CHAR16 Unicode;
+ CHAR16 ShiftedUnicode;
+ CHAR16 AltGrUnicode;
+ CHAR16 ShiftedAltGrUnicode;
+ UINT16 Modifier;
+ UINT16 AffectedAttribute;
+} EFI_KEY_DESCRIPTOR;
+
+//
+// A key which is affected by all the standard shift modifiers.
+// Most keys would be expected to have this bit active.
+//
+#define EFI_AFFECTED_BY_STANDARD_SHIFT 0x0001
+//
+// This key is affected by the caps lock so that if a keyboard driver
+// would need to disambiguate between a key which had a "1" defined
+// versus a "a" character. Having this bit turned on would tell
+// the keyboard driver to use the appropriate shifted state or not.
+//
+#define EFI_AFFECTED_BY_CAPS_LOCK 0x0002
+//
+// Similar to the case of CAPS lock, if this bit is active, the key
+// is affected by the num lock being turned on.
+//
+#define EFI_AFFECTED_BY_NUM_LOCK 0x0004
+
+typedef struct {
+ UINT16 LayoutLength;
+ EFI_GUID Guid;
+ UINT32 LayoutDescriptorStringOffset;
+ UINT8 DescriptorCount;
+ // EFI_KEY_DESCRIPTOR Descriptors[];
+} EFI_HII_KEYBOARD_LAYOUT;
+
+typedef struct {
+ EFI_HII_PACKAGE_HEADER Header;
+ UINT16 LayoutCount;
+ // EFI_HII_KEYBOARD_LAYOUT Layout[];
+} EFI_HII_KEYBOARD_PACKAGE_HDR;
+
+//typedef struct {
+// CHAR16 Language[]; // RFC4646 Language Code
+// CHAR16 Space;
+// CHAR16 DescriptionString[];
+//} EFI_DESCRIPTION_STRING;
+
+//typedef struct {
+// UINT16 DescriptionCount;
+// EFI_DESCRIPTION_STRING DescriptionString[];
+//} EFI_DESCRIPTION_STRING_BUNDLE;
+
+//
+// Modifier values
+//
+#define EFI_NULL_MODIFIER 0x0000
+#define EFI_LEFT_CONTROL_MODIFIER 0x0001
+#define EFI_RIGHT_CONTROL_MODIFIER 0x0002
+#define EFI_LEFT_ALT_MODIFIER 0x0003
+#define EFI_RIGHT_ALT_MODIFIER 0x0004
+#define EFI_ALT_GR_MODIFIER 0x0005
+#define EFI_INSERT_MODIFIER 0x0006
+#define EFI_DELETE_MODIFIER 0x0007
+#define EFI_PAGE_DOWN_MODIFIER 0x0008
+#define EFI_PAGE_UP_MODIFIER 0x0009
+#define EFI_HOME_MODIFIER 0x000A
+#define EFI_END_MODIFIER 0x000B
+#define EFI_LEFT_SHIFT_MODIFIER 0x000C
+#define EFI_RIGHT_SHIFT_MODIFIER 0x000D
+#define EFI_CAPS_LOCK_MODIFIER 0x000E
+#define EFI_NUM_LOCK_MODIFIER 0x000F
+#define EFI_LEFT_ARROW_MODIFIER 0x0010
+#define EFI_RIGHT_ARROW_MODIFIER 0x0011
+#define EFI_DOWN_ARROW_MODIFIER 0x0012
+#define EFI_UP_ARROW_MODIFIER 0x0013
+#define EFI_NS_KEY_MODIFIER 0x0014
+#define EFI_NS_KEY_DEPENDENCY_MODIFIER 0x0015
+#define EFI_FUNCTION_KEY_ONE_MODIFIER 0x0016
+#define EFI_FUNCTION_KEY_TWO_MODIFIER 0x0017
+#define EFI_FUNCTION_KEY_THREE_MODIFIER 0x0018
+#define EFI_FUNCTION_KEY_FOUR_MODIFIER 0x0019
+#define EFI_FUNCTION_KEY_FIVE_MODIFIER 0x001A
+#define EFI_FUNCTION_KEY_SIX_MODIFIER 0x001B
+#define EFI_FUNCTION_KEY_SEVEN_MODIFIER 0x001C
+#define EFI_FUNCTION_KEY_EIGHT_MODIFIER 0x001D
+#define EFI_FUNCTION_KEY_NINE_MODIFIER 0x001E
+#define EFI_FUNCTION_KEY_TEN_MODIFIER 0x001F
+#define EFI_FUNCTION_KEY_ELEVEN_MODIFIER 0x0020
+#define EFI_FUNCTION_KEY_TWELVE_MODIFIER 0x0021
+
+//
+// Keys that have multiple control functions based on modifier
+// settings are handled in the keyboard driver implementation.
+// For instance PRINT_KEY might have a modifier held down and
+// is still a nonprinting character, but might have an alternate
+// control function like SYSREQUEST
+//
+#define EFI_PRINT_MODIFIER 0x0022
+#define EFI_SYS_REQUEST_MODIFIER 0x0023
+#define EFI_SCROLL_LOCK_MODIFIER 0x0024
+#define EFI_PAUSE_MODIFIER 0x0025
+#define EFI_BREAK_MODIFIER 0x0026
+
+#define EFI_LEFT_LOGO_MODIFIER 0x0027
+#define EFI_RIGHT_LOGO_MODIFIER 0x0028
+#define EFI_MENU_MODIFIER 0x0029
+
+#pragma pack()
+
+#endif
diff --git a/EDK/Foundation/Efi/Include/EfiImage.h b/EDK/Foundation/Efi/Include/EfiImage.h
new file mode 100644
index 0000000..0d1f579
--- /dev/null
+++ b/EDK/Foundation/Efi/Include/EfiImage.h
@@ -0,0 +1,703 @@
+/*++
+
+Copyright (c) 2004 - 2008, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiImage.h
+
+Abstract:
+
+ EFI image format for PE32+. Please note some data structures are different
+ for IA-32 and Itanium-based images, look for UINTN and the #ifdef EFI_IA64
+
+ BugBug: Fix text - doc as defined in MSFT EFI specification
+
+--*/
+
+#ifndef _EFI_IMAGE_H_
+#define _EFI_IMAGE_H_
+
+//
+// PE32+ Subsystem type for EFI images
+//
+#define EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION 10
+#define EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER 11
+#define EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER 12
+
+//
+// BugBug: Need to get a real answer for this problem. This is not in the
+// PE specification.
+//
+// A SAL runtime driver does not get fixed up when a transition to
+// virtual mode is made. In all other cases it should be treated
+// like a EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER image
+//
+#define EFI_IMAGE_SUBSYSTEM_SAL_RUNTIME_DRIVER 13
+
+//
+// PE32+ Machine type for EFI images
+//
+#define EFI_IMAGE_MACHINE_IA32 0x014c
+#define EFI_IMAGE_MACHINE_IA64 0x0200
+#define EFI_IMAGE_MACHINE_X64 0x8664
+//
+// #define EFI_IMAGE_MACHINE_FCODE 0xfc0d
+//
+#define EFI_IMAGE_MACHINE_EBC 0x0EBC
+
+#define EFI_IMAGE_DOS_SIGNATURE 0x5A4D // MZ
+#define EFI_IMAGE_OS2_SIGNATURE 0x454E // NE
+#define EFI_IMAGE_OS2_SIGNATURE_LE 0x454C // LE
+#define EFI_IMAGE_NT_SIGNATURE 0x00004550 // PE00
+#define EFI_IMAGE_EDOS_SIGNATURE 0x44454550 // PEED
+//
+// PE images can start with an optional DOS header, so if an image is run
+// under DOS it can print an error message.
+//
+typedef struct {
+ UINT16 e_magic; // Magic number
+ UINT16 e_cblp; // Bytes on last page of file
+ UINT16 e_cp; // Pages in file
+ UINT16 e_crlc; // Relocations
+ UINT16 e_cparhdr; // Size of header in paragraphs
+ UINT16 e_minalloc; // Minimum extra paragraphs needed
+ UINT16 e_maxalloc; // Maximum extra paragraphs needed
+ UINT16 e_ss; // Initial (relative) SS value
+ UINT16 e_sp; // Initial SP value
+ UINT16 e_csum; // Checksum
+ UINT16 e_ip; // Initial IP value
+ UINT16 e_cs; // Initial (relative) CS value
+ UINT16 e_lfarlc; // File address of relocation table
+ UINT16 e_ovno; // Overlay number
+ UINT16 e_res[4]; // Reserved words
+ UINT16 e_oemid; // OEM identifier (for e_oeminfo)
+ UINT16 e_oeminfo; // OEM information; e_oemid specific
+ UINT16 e_res2[10]; // Reserved words
+ UINT32 e_lfanew; // File address of new exe header
+} EFI_IMAGE_DOS_HEADER;
+
+//
+// File header format.
+//
+typedef struct {
+ UINT16 Machine;
+ UINT16 NumberOfSections;
+ UINT32 TimeDateStamp;
+ UINT32 PointerToSymbolTable;
+ UINT32 NumberOfSymbols;
+ UINT16 SizeOfOptionalHeader;
+ UINT16 Characteristics;
+} EFI_IMAGE_FILE_HEADER;
+
+#define EFI_IMAGE_SIZEOF_FILE_HEADER 20
+
+#define EFI_IMAGE_FILE_RELOCS_STRIPPED 0x0001 // Relocation info stripped from file.
+#define EFI_IMAGE_FILE_EXECUTABLE_IMAGE 0x0002 // File is executable (i.e. no unresolved externel references).
+#define EFI_IMAGE_FILE_LINE_NUMS_STRIPPED 0x0004 // Line nunbers stripped from file.
+#define EFI_IMAGE_FILE_LOCAL_SYMS_STRIPPED 0x0008 // Local symbols stripped from file.
+#define EFI_IMAGE_FILE_BYTES_REVERSED_LO 0x0080 // Bytes of machine word are reversed.
+#define EFI_IMAGE_FILE_32BIT_MACHINE 0x0100 // 32 bit word machine.
+#define EFI_IMAGE_FILE_DEBUG_STRIPPED 0x0200 // Debugging info stripped from file in .DBG file
+#define EFI_IMAGE_FILE_SYSTEM 0x1000 // System File.
+#define EFI_IMAGE_FILE_DLL 0x2000 // File is a DLL.
+#define EFI_IMAGE_FILE_BYTES_REVERSED_HI 0x8000 // Bytes of machine word are reversed.
+#define EFI_IMAGE_FILE_MACHINE_UNKNOWN 0
+#define EFI_IMAGE_FILE_MACHINE_I386 0x14c // Intel 386.
+#define EFI_IMAGE_FILE_MACHINE_R3000 0x162 // MIPS* little-endian, 0540 big-endian
+#define EFI_IMAGE_FILE_MACHINE_R4000 0x166 // MIPS* little-endian
+#define EFI_IMAGE_FILE_MACHINE_ALPHA 0x184 // Alpha_AXP*
+#define EFI_IMAGE_FILE_MACHINE_POWERPC 0x1F0 // IBM* PowerPC Little-Endian
+#define EFI_IMAGE_FILE_MACHINE_TAHOE 0x7cc // Intel EM machine
+//
+// * Other names and brands may be claimed as the property of others.
+//
+//
+// Directory format.
+//
+typedef struct {
+ UINT32 VirtualAddress;
+ UINT32 Size;
+} EFI_IMAGE_DATA_DIRECTORY;
+
+#define EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES 16
+
+typedef struct {
+ UINT16 Magic;
+ UINT8 MajorLinkerVersion;
+ UINT8 MinorLinkerVersion;
+ UINT32 SizeOfCode;
+ UINT32 SizeOfInitializedData;
+ UINT32 SizeOfUninitializedData;
+ UINT32 AddressOfEntryPoint;
+ UINT32 BaseOfCode;
+ UINT32 BaseOfData;
+ UINT32 BaseOfBss;
+ UINT32 GprMask;
+ UINT32 CprMask[4];
+ UINT32 GpValue;
+} EFI_IMAGE_ROM_OPTIONAL_HEADER;
+
+#define EFI_IMAGE_ROM_OPTIONAL_HDR_MAGIC 0x107
+#define EFI_IMAGE_SIZEOF_ROM_OPTIONAL_HEADER sizeof (EFI_IMAGE_ROM_OPTIONAL_HEADER)
+
+typedef struct {
+ EFI_IMAGE_FILE_HEADER FileHeader;
+ EFI_IMAGE_ROM_OPTIONAL_HEADER OptionalHeader;
+} EFI_IMAGE_ROM_HEADERS;
+
+//
+// ATTENTION!!! EFI_IMAGE_OPTIONAL_HEADER32 and EFI_IMAGE_OPTIONAL_HEADER64
+// are for use ONLY by tools. All proper EFI code MUST use
+// EFI_IMAGE_OPTIONAL_HEADER ONLY!!!
+//
+#define EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC 0x10b
+
+typedef struct {
+ //
+ // Standard fields.
+ //
+ UINT16 Magic;
+ UINT8 MajorLinkerVersion;
+ UINT8 MinorLinkerVersion;
+ UINT32 SizeOfCode;
+ UINT32 SizeOfInitializedData;
+ UINT32 SizeOfUninitializedData;
+ UINT32 AddressOfEntryPoint;
+ UINT32 BaseOfCode;
+ UINT32 BaseOfData;
+ //
+ // NT additional fields.
+ //
+ UINT32 ImageBase;
+ UINT32 SectionAlignment;
+ UINT32 FileAlignment;
+ UINT16 MajorOperatingSystemVersion;
+ UINT16 MinorOperatingSystemVersion;
+ UINT16 MajorImageVersion;
+ UINT16 MinorImageVersion;
+ UINT16 MajorSubsystemVersion;
+ UINT16 MinorSubsystemVersion;
+ UINT32 Win32VersionValue;
+ UINT32 SizeOfImage;
+ UINT32 SizeOfHeaders;
+ UINT32 CheckSum;
+ UINT16 Subsystem;
+ UINT16 DllCharacteristics;
+ UINT32 SizeOfStackReserve;
+ UINT32 SizeOfStackCommit;
+ UINT32 SizeOfHeapReserve;
+ UINT32 SizeOfHeapCommit;
+ UINT32 LoaderFlags;
+ UINT32 NumberOfRvaAndSizes;
+ EFI_IMAGE_DATA_DIRECTORY DataDirectory[EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES];
+} EFI_IMAGE_OPTIONAL_HEADER32;
+
+//
+// ATTENTION!!! EFI_IMAGE_OPTIONAL_HEADER32 and EFI_IMAGE_OPTIONAL_HEADER64
+// are for use ONLY by tools. All proper EFI code MUST use
+// EFI_IMAGE_OPTIONAL_HEADER ONLY!!!
+//
+#define EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC 0x20b
+
+typedef struct {
+ //
+ // Standard fields.
+ //
+ UINT16 Magic;
+ UINT8 MajorLinkerVersion;
+ UINT8 MinorLinkerVersion;
+ UINT32 SizeOfCode;
+ UINT32 SizeOfInitializedData;
+ UINT32 SizeOfUninitializedData;
+ UINT32 AddressOfEntryPoint;
+ UINT32 BaseOfCode;
+ //
+ // NT additional fields.
+ //
+ UINT64 ImageBase;
+ UINT32 SectionAlignment;
+ UINT32 FileAlignment;
+ UINT16 MajorOperatingSystemVersion;
+ UINT16 MinorOperatingSystemVersion;
+ UINT16 MajorImageVersion;
+ UINT16 MinorImageVersion;
+ UINT16 MajorSubsystemVersion;
+ UINT16 MinorSubsystemVersion;
+ UINT32 Win32VersionValue;
+ UINT32 SizeOfImage;
+ UINT32 SizeOfHeaders;
+ UINT32 CheckSum;
+ UINT16 Subsystem;
+ UINT16 DllCharacteristics;
+ UINT64 SizeOfStackReserve;
+ UINT64 SizeOfStackCommit;
+ UINT64 SizeOfHeapReserve;
+ UINT64 SizeOfHeapCommit;
+ UINT32 LoaderFlags;
+ UINT32 NumberOfRvaAndSizes;
+ EFI_IMAGE_DATA_DIRECTORY DataDirectory[EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES];
+} EFI_IMAGE_OPTIONAL_HEADER64;
+
+//
+// ATTENTION!!! EFI_IMAGE_NT_HEADERS32 and EFI_IMAGE_HEADERS64 are for use ONLY
+// by tools. All proper EFI code MUST use EFI_IMAGE_NT_HEADERS ONLY!!!
+//
+typedef struct {
+ UINT32 Signature;
+ EFI_IMAGE_FILE_HEADER FileHeader;
+ EFI_IMAGE_OPTIONAL_HEADER32 OptionalHeader;
+} EFI_IMAGE_NT_HEADERS32;
+
+#define EFI_IMAGE_SIZEOF_NT_OPTIONAL32_HEADER sizeof (EFI_IMAGE_NT_HEADERS32)
+
+typedef struct {
+ UINT32 Signature;
+ EFI_IMAGE_FILE_HEADER FileHeader;
+ EFI_IMAGE_OPTIONAL_HEADER64 OptionalHeader;
+} EFI_IMAGE_NT_HEADERS64;
+
+#define EFI_IMAGE_SIZEOF_NT_OPTIONAL64_HEADER sizeof (EFI_IMAGE_NT_HEADERS64)
+
+//
+// Include processor specific definition of EFI_IMAGE_OPTIONAL_HEADER so the
+// type name EFI_IMAGE_OPTIONAL_HEADER is appropriate to the build. Same for
+// EFI_IMAGE_NT_HEADERS. These definitions MUST be used by ALL EFI code.
+//
+#include "EfiPeOptionalHeader.h"
+
+#define EFI_IMAGE_FIRST_SECTION(ntheader) \
+ ( \
+ (EFI_IMAGE_SECTION_HEADER *) \
+ ( \
+ (UINT32) ntheader + \
+ FIELD_OFFSET (EFI_IMAGE_NT_HEADERS, OptionalHeader) + \
+ ((EFI_IMAGE_NT_HEADERS *) (ntheader))->FileHeader.SizeOfOptionalHeader \
+ ) \
+ )
+
+//
+// Subsystem Values
+//
+#define EFI_IMAGE_SUBSYSTEM_UNKNOWN 0
+#define EFI_IMAGE_SUBSYSTEM_NATIVE 1
+#define EFI_IMAGE_SUBSYSTEM_WINDOWS_GUI 2
+#define EFI_IMAGE_SUBSYSTEM_WINDOWS_CUI 3.
+#define EFI_IMAGE_SUBSYSTEM_OS2_CUI 5
+#define EFI_IMAGE_SUBSYSTEM_POSIX_CUI 7
+
+//
+// Directory Entries
+//
+#define EFI_IMAGE_DIRECTORY_ENTRY_EXPORT 0
+#define EFI_IMAGE_DIRECTORY_ENTRY_IMPORT 1
+#define EFI_IMAGE_DIRECTORY_ENTRY_RESOURCE 2
+#define EFI_IMAGE_DIRECTORY_ENTRY_EXCEPTION 3
+#define EFI_IMAGE_DIRECTORY_ENTRY_SECURITY 4
+#define EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC 5
+#define EFI_IMAGE_DIRECTORY_ENTRY_DEBUG 6
+#define EFI_IMAGE_DIRECTORY_ENTRY_COPYRIGHT 7
+#define EFI_IMAGE_DIRECTORY_ENTRY_GLOBALPTR 8
+#define EFI_IMAGE_DIRECTORY_ENTRY_TLS 9
+#define EFI_IMAGE_DIRECTORY_ENTRY_LOAD_CONFIG 10
+
+//
+// Section header format.
+//
+#define EFI_IMAGE_SIZEOF_SHORT_NAME 8
+
+typedef struct {
+ UINT8 Name[EFI_IMAGE_SIZEOF_SHORT_NAME];
+ union {
+ UINT32 PhysicalAddress;
+ UINT32 VirtualSize;
+ } Misc;
+ UINT32 VirtualAddress;
+ UINT32 SizeOfRawData;
+ UINT32 PointerToRawData;
+ UINT32 PointerToRelocations;
+ UINT32 PointerToLinenumbers;
+ UINT16 NumberOfRelocations;
+ UINT16 NumberOfLinenumbers;
+ UINT32 Characteristics;
+} EFI_IMAGE_SECTION_HEADER;
+
+#define EFI_IMAGE_SIZEOF_SECTION_HEADER 40
+
+#define EFI_IMAGE_SCN_TYPE_NO_PAD 0x00000008 // Reserved.
+#define EFI_IMAGE_SCN_CNT_CODE 0x00000020
+#define EFI_IMAGE_SCN_CNT_INITIALIZED_DATA 0x00000040
+#define EFI_IMAGE_SCN_CNT_UNINITIALIZED_DATA 0x00000080
+
+#define EFI_IMAGE_SCN_LNK_OTHER 0x00000100 // Reserved.
+#define EFI_IMAGE_SCN_LNK_INFO 0x00000200 // Section contains comments or some other type of information.
+#define EFI_IMAGE_SCN_LNK_REMOVE 0x00000800 // Section contents will not become part of image.
+#define EFI_IMAGE_SCN_LNK_COMDAT 0x00001000
+
+#define EFI_IMAGE_SCN_ALIGN_1BYTES 0x00100000
+#define EFI_IMAGE_SCN_ALIGN_2BYTES 0x00200000
+#define EFI_IMAGE_SCN_ALIGN_4BYTES 0x00300000
+#define EFI_IMAGE_SCN_ALIGN_8BYTES 0x00400000
+#define EFI_IMAGE_SCN_ALIGN_16BYTES 0x00500000
+#define EFI_IMAGE_SCN_ALIGN_32BYTES 0x00600000
+#define EFI_IMAGE_SCN_ALIGN_64BYTES 0x00700000
+
+#define EFI_IMAGE_SCN_MEM_DISCARDABLE 0x02000000
+#define EFI_IMAGE_SCN_MEM_NOT_CACHED 0x04000000
+#define EFI_IMAGE_SCN_MEM_NOT_PAGED 0x08000000
+#define EFI_IMAGE_SCN_MEM_SHARED 0x10000000
+#define EFI_IMAGE_SCN_MEM_EXECUTE 0x20000000
+#define EFI_IMAGE_SCN_MEM_READ 0x40000000
+#define EFI_IMAGE_SCN_MEM_WRITE 0x80000000
+
+//
+// Symbol format.
+//
+#define EFI_IMAGE_SIZEOF_SYMBOL 18
+
+//
+// Section values.
+//
+// Symbols have a section number of the section in which they are
+// defined. Otherwise, section numbers have the following meanings:
+//
+#define EFI_IMAGE_SYM_UNDEFINED (UINT16) 0 // Symbol is undefined or is common.
+#define EFI_IMAGE_SYM_ABSOLUTE (UINT16) -1 // Symbol is an absolute value.
+#define EFI_IMAGE_SYM_DEBUG (UINT16) -2 // Symbol is a special debug item.
+//
+// Type (fundamental) values.
+//
+#define EFI_IMAGE_SYM_TYPE_NULL 0 // no type.
+#define EFI_IMAGE_SYM_TYPE_VOID 1 //
+#define EFI_IMAGE_SYM_TYPE_CHAR 2 // type character.
+#define EFI_IMAGE_SYM_TYPE_SHORT 3 // type short integer.
+#define EFI_IMAGE_SYM_TYPE_INT 4
+#define EFI_IMAGE_SYM_TYPE_LONG 5
+#define EFI_IMAGE_SYM_TYPE_FLOAT 6
+#define EFI_IMAGE_SYM_TYPE_DOUBLE 7
+#define EFI_IMAGE_SYM_TYPE_STRUCT 8
+#define EFI_IMAGE_SYM_TYPE_UNION 9
+#define EFI_IMAGE_SYM_TYPE_ENUM 10 // enumeration.
+#define EFI_IMAGE_SYM_TYPE_MOE 11 // member of enumeration.
+#define EFI_IMAGE_SYM_TYPE_BYTE 12
+#define EFI_IMAGE_SYM_TYPE_WORD 13
+#define EFI_IMAGE_SYM_TYPE_UINT 14
+#define EFI_IMAGE_SYM_TYPE_DWORD 15
+
+//
+// Type (derived) values.
+//
+#define EFI_IMAGE_SYM_DTYPE_NULL 0 // no derived type.
+#define EFI_IMAGE_SYM_DTYPE_POINTER 1
+#define EFI_IMAGE_SYM_DTYPE_FUNCTION 2
+#define EFI_IMAGE_SYM_DTYPE_ARRAY 3
+
+//
+// Storage classes.
+//
+#define EFI_IMAGE_SYM_CLASS_END_OF_FUNCTION (UINT8) -1
+#define EFI_IMAGE_SYM_CLASS_NULL 0
+#define EFI_IMAGE_SYM_CLASS_AUTOMATIC 1
+#define EFI_IMAGE_SYM_CLASS_EXTERNAL 2
+#define EFI_IMAGE_SYM_CLASS_STATIC 3
+#define EFI_IMAGE_SYM_CLASS_REGISTER 4
+#define EFI_IMAGE_SYM_CLASS_EXTERNAL_DEF 5
+#define EFI_IMAGE_SYM_CLASS_LABEL 6
+#define EFI_IMAGE_SYM_CLASS_UNDEFINED_LABEL 7
+#define EFI_IMAGE_SYM_CLASS_MEMBER_OF_STRUCT 8
+#define EFI_IMAGE_SYM_CLASS_ARGUMENT 9
+#define EFI_IMAGE_SYM_CLASS_STRUCT_TAG 10
+#define EFI_IMAGE_SYM_CLASS_MEMBER_OF_UNION 11
+#define EFI_IMAGE_SYM_CLASS_UNION_TAG 12
+#define EFI_IMAGE_SYM_CLASS_TYPE_DEFINITION 13
+#define EFI_IMAGE_SYM_CLASS_UNDEFINED_STATIC 14
+#define EFI_IMAGE_SYM_CLASS_ENUM_TAG 15
+#define EFI_IMAGE_SYM_CLASS_MEMBER_OF_ENUM 16
+#define EFI_IMAGE_SYM_CLASS_REGISTER_PARAM 17
+#define EFI_IMAGE_SYM_CLASS_BIT_FIELD 18
+#define EFI_IMAGE_SYM_CLASS_BLOCK 100
+#define EFI_IMAGE_SYM_CLASS_FUNCTION 101
+#define EFI_IMAGE_SYM_CLASS_END_OF_STRUCT 102
+#define EFI_IMAGE_SYM_CLASS_FILE 103
+#define EFI_IMAGE_SYM_CLASS_SECTION 104
+#define EFI_IMAGE_SYM_CLASS_WEAK_EXTERNAL 105
+
+//
+// type packing constants
+//
+#define EFI_IMAGE_N_BTMASK 017
+#define EFI_IMAGE_N_TMASK 060
+#define EFI_IMAGE_N_TMASK1 0300
+#define EFI_IMAGE_N_TMASK2 0360
+#define EFI_IMAGE_N_BTSHFT 4
+#define EFI_IMAGE_N_TSHIFT 2
+
+//
+// Communal selection types.
+//
+#define EFI_IMAGE_COMDAT_SELECT_NODUPLICATES 1
+#define EFI_IMAGE_COMDAT_SELECT_ANY 2
+#define EFI_IMAGE_COMDAT_SELECT_SAME_SIZE 3
+#define EFI_IMAGE_COMDAT_SELECT_EXACT_MATCH 4
+#define EFI_IMAGE_COMDAT_SELECT_ASSOCIATIVE 5
+
+#define EFI_IMAGE_WEAK_EXTERN_SEARCH_NOLIBRARY 1
+#define EFI_IMAGE_WEAK_EXTERN_SEARCH_LIBRARY 2
+#define EFI_IMAGE_WEAK_EXTERN_SEARCH_ALIAS 3
+
+//
+// Relocation format.
+//
+typedef struct {
+ UINT32 VirtualAddress;
+ UINT32 SymbolTableIndex;
+ UINT16 Type;
+} EFI_IMAGE_RELOCATION;
+
+#define EFI_IMAGE_SIZEOF_RELOCATION 10
+
+//
+// I386 relocation types.
+//
+#define EFI_IMAGE_REL_I386_ABSOLUTE 0 // Reference is absolute, no relocation is necessary
+#define EFI_IMAGE_REL_I386_DIR16 01 // Direct 16-bit reference to the symbols virtual address
+#define EFI_IMAGE_REL_I386_REL16 02 // PC-relative 16-bit reference to the symbols virtual address
+#define EFI_IMAGE_REL_I386_DIR32 06 // Direct 32-bit reference to the symbols virtual address
+#define EFI_IMAGE_REL_I386_DIR32NB 07 // Direct 32-bit reference to the symbols virtual address, base not included
+#define EFI_IMAGE_REL_I386_SEG12 011 // Direct 16-bit reference to the segment-selector bits of a 32-bit virtual address
+#define EFI_IMAGE_REL_I386_SECTION 012
+#define EFI_IMAGE_REL_I386_SECREL 013
+#define EFI_IMAGE_REL_I386_REL32 024 // PC-relative 32-bit reference to the symbols virtual address
+//
+// Based relocation format.
+//
+typedef struct {
+ UINT32 VirtualAddress;
+ UINT32 SizeOfBlock;
+} EFI_IMAGE_BASE_RELOCATION;
+
+#define EFI_IMAGE_SIZEOF_BASE_RELOCATION 8
+
+//
+// Based relocation types.
+//
+#define EFI_IMAGE_REL_BASED_ABSOLUTE 0
+#define EFI_IMAGE_REL_BASED_HIGH 1
+#define EFI_IMAGE_REL_BASED_LOW 2
+#define EFI_IMAGE_REL_BASED_HIGHLOW 3
+#define EFI_IMAGE_REL_BASED_HIGHADJ 4
+#define EFI_IMAGE_REL_BASED_MIPS_JMPADDR 5
+#define EFI_IMAGE_REL_BASED_IA64_IMM64 9
+#define EFI_IMAGE_REL_BASED_DIR64 10
+
+//
+// Line number format.
+//
+typedef struct {
+ union {
+ UINT32 SymbolTableIndex; // Symbol table index of function name if Linenumber is 0.
+ UINT32 VirtualAddress; // Virtual address of line number.
+ } Type;
+ UINT16 Linenumber; // Line number.
+} EFI_IMAGE_LINENUMBER;
+
+#define EFI_IMAGE_SIZEOF_LINENUMBER 6
+
+//
+// Archive format.
+//
+#define EFI_IMAGE_ARCHIVE_START_SIZE 8
+#define EFI_IMAGE_ARCHIVE_START "!<arch>\n"
+#define EFI_IMAGE_ARCHIVE_END "`\n"
+#define EFI_IMAGE_ARCHIVE_PAD "\n"
+#define EFI_IMAGE_ARCHIVE_LINKER_MEMBER "/ "
+#define EFI_IMAGE_ARCHIVE_LONGNAMES_MEMBER "// "
+
+typedef struct {
+ UINT8 Name[16]; // File member name - `/' terminated.
+ UINT8 Date[12]; // File member date - decimal.
+ UINT8 UserID[6]; // File member user id - decimal.
+ UINT8 GroupID[6]; // File member group id - decimal.
+ UINT8 Mode[8]; // File member mode - octal.
+ UINT8 Size[10]; // File member size - decimal.
+ UINT8 EndHeader[2]; // String to end header.
+} EFI_IMAGE_ARCHIVE_MEMBER_HEADER;
+
+#define EFI_IMAGE_SIZEOF_ARCHIVE_MEMBER_HDR 60
+
+//
+// DLL support.
+//
+//
+// Export Format
+//
+typedef struct {
+ UINT32 Characteristics;
+ UINT32 TimeDateStamp;
+ UINT16 MajorVersion;
+ UINT16 MinorVersion;
+ UINT32 Name;
+ UINT32 Base;
+ UINT32 NumberOfFunctions;
+ UINT32 NumberOfNames;
+ UINT32 AddressOfFunctions;
+ UINT32 AddressOfNames;
+ UINT32 AddressOfNameOrdinals;
+} EFI_IMAGE_EXPORT_DIRECTORY;
+
+//
+// Import Format
+//
+typedef struct {
+ UINT16 Hint;
+ UINT8 Name[1];
+} EFI_IMAGE_IMPORT_BY_NAME;
+
+typedef struct {
+ union {
+ UINT32 Function;
+ UINT32 Ordinal;
+ EFI_IMAGE_IMPORT_BY_NAME *AddressOfData;
+ } u1;
+} EFI_IMAGE_THUNK_DATA;
+
+#define EFI_IMAGE_ORDINAL_FLAG 0x80000000
+#define EFI_IMAGE_SNAP_BY_ORDINAL(Ordinal) ((Ordinal & EFI_IMAGE_ORDINAL_FLAG) != 0)
+#define EFI_IMAGE_ORDINAL(Ordinal) (Ordinal & 0xffff)
+
+typedef struct {
+ UINT32 Characteristics;
+ UINT32 TimeDateStamp;
+ UINT32 ForwarderChain;
+ UINT32 Name;
+ EFI_IMAGE_THUNK_DATA *FirstThunk;
+} EFI_IMAGE_IMPORT_DESCRIPTOR;
+
+//
+// Debug Format
+//
+#define EFI_IMAGE_DEBUG_TYPE_CODEVIEW 2
+
+typedef struct {
+ UINT32 Characteristics;
+ UINT32 TimeDateStamp;
+ UINT16 MajorVersion;
+ UINT16 MinorVersion;
+ UINT32 Type;
+ UINT32 SizeOfData;
+ UINT32 RVA;
+ UINT32 FileOffset;
+} EFI_IMAGE_DEBUG_DIRECTORY_ENTRY;
+
+#define CODEVIEW_SIGNATURE_NB10 0x3031424E // "NB10"
+typedef struct {
+ UINT32 Signature; // "NB10"
+ UINT32 Unknown;
+ UINT32 Unknown2;
+ UINT32 Unknown3;
+ //
+ // Filename of .PDB goes here
+ //
+} EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY;
+
+#define CODEVIEW_SIGNATURE_RSDS 0x53445352 // "RSDS"
+typedef struct {
+ UINT32 Signature; // "RSDS"
+ UINT32 Unknown;
+ UINT32 Unknown2;
+ UINT32 Unknown3;
+ UINT32 Unknown4;
+ UINT32 Unknown5;
+ //
+ // Filename of .PDB goes here
+ //
+} EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY;
+
+//
+// Resource Format
+//
+typedef struct {
+ UINT32 Characteristics;
+ UINT32 TimeDateStamp;
+ UINT16 MajorVersion;
+ UINT16 MinorVersion;
+ UINT16 NumberOfNamedEntries;
+ UINT16 NumberOfIdEntries;
+// EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY DirectoryEntries[];
+} EFI_IMAGE_RESOURCE_DIRECTORY;
+
+typedef struct {
+ union {
+ struct {
+ UINT32 NameOffset:31;
+ UINT32 NameIsString:1;
+ } s;
+ UINT32 Id;
+ } u1;
+ union {
+ UINT32 OffsetToData;
+ struct {
+ UINT32 OffsetToDirectory:31;
+ UINT32 DataIsDirectory:1;
+ } s;
+ } u2;
+} EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY;
+
+typedef struct {
+ UINT16 Length;
+ CHAR16 String[1];
+} EFI_IMAGE_RESOURCE_DIRECTORY_STRING;
+
+typedef struct {
+ UINT32 OffsetToData;
+ UINT32 Size;
+ UINT32 CodePage;
+ UINT32 Reserved;
+} EFI_IMAGE_RESOURCE_DATA_ENTRY;
+
+//
+// Header format for TE images
+//
+typedef struct {
+ UINT16 Signature; // signature for TE format = "VZ"
+ UINT16 Machine; // from the original file header
+ UINT8 NumberOfSections; // from the original file header
+ UINT8 Subsystem; // from original optional header
+ UINT16 StrippedSize; // how many bytes we removed from the header
+ UINT32 AddressOfEntryPoint; // offset to entry point -- from original optional header
+ UINT32 BaseOfCode; // from original image -- required for ITP debug
+ UINT64 ImageBase; // from original file header
+ EFI_IMAGE_DATA_DIRECTORY DataDirectory[2]; // only base relocation and debug directory
+} EFI_TE_IMAGE_HEADER;
+
+#define EFI_TE_IMAGE_HEADER_SIGNATURE 0x5A56 // "VZ"
+//
+// Data directory indexes in our TE image header
+//
+#define EFI_TE_IMAGE_DIRECTORY_ENTRY_BASERELOC 0
+#define EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG 1
+
+//
+// Union of PE32, PE32+, and TE headers
+//
+typedef union {
+ EFI_IMAGE_NT_HEADERS32 Pe32;
+ EFI_IMAGE_NT_HEADERS64 Pe32Plus;
+ EFI_TE_IMAGE_HEADER Te;
+} EFI_IMAGE_OPTIONAL_HEADER_UNION;
+
+typedef union {
+ EFI_IMAGE_NT_HEADERS32 *Pe32;
+ EFI_IMAGE_NT_HEADERS64 *Pe32Plus;
+ EFI_TE_IMAGE_HEADER *Te;
+ EFI_IMAGE_OPTIONAL_HEADER_UNION *Union;
+} EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION;
+
+#endif
diff --git a/EDK/Foundation/Efi/Include/EfiTypes.h b/EDK/Foundation/Efi/Include/EfiTypes.h
new file mode 100644
index 0000000..240127e
--- /dev/null
+++ b/EDK/Foundation/Efi/Include/EfiTypes.h
@@ -0,0 +1,292 @@
+/*++
+
+Copyright (c) 2004 - 2008, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiTypes.h
+
+Abstract:
+
+ EFI defined types. Use these types when ever possible!
+
+--*/
+
+#ifndef _EFI_TYPES_H_
+#define _EFI_TYPES_H_
+
+//
+// EFI Data Types based on ANSI C integer types in EfiBind.h
+//
+typedef uint8_t BOOLEAN;
+typedef intn_t INTN;
+typedef uintn_t UINTN;
+typedef int8_t INT8;
+typedef uint8_t UINT8;
+typedef int16_t INT16;
+typedef uint16_t UINT16;
+typedef int32_t INT32;
+typedef uint32_t UINT32;
+typedef int64_t INT64;
+typedef uint64_t UINT64;
+typedef uint8_t CHAR8;
+typedef uint16_t CHAR16;
+typedef UINT64 EFI_LBA;
+
+//
+// Modifiers for EFI Data Types used to self document code.
+// Please see EFI coding convention for proper usage.
+//
+#ifndef IN
+//
+// Some other envirnments use this construct, so #ifndef to prevent
+// mulitple definition.
+//
+#define IN
+#define OUT
+#define OPTIONAL
+#endif
+#define UNALIGNED
+
+//
+// Modifiers for EFI Runtime and Boot Services
+//
+#define EFI_RUNTIMESERVICE
+#define EFI_BOOTSERVICE
+
+//
+// Boot Service add in EFI 1.1
+//
+#define EFI_BOOTSERVICE11
+
+//
+// Modifiers to absract standard types to aid in debug of problems
+//
+#define CONST const
+#define STATIC static
+#define VOID void
+#define VOLATILE volatile
+
+//
+// Modifier to ensure that all protocol member functions and EFI intrinsics
+// use the correct C calling convention. All protocol member functions and
+// EFI intrinsics are required to modify thier member functions with EFIAPI.
+//
+#define EFIAPI _EFIAPI
+
+//
+// EFI Constants. They may exist in other build structures, so #ifndef them.
+//
+#ifndef TRUE
+#define TRUE ((BOOLEAN) (1 == 1))
+#endif
+
+#ifndef FALSE
+#define FALSE ((BOOLEAN) (0 == 1))
+#endif
+
+#ifndef NULL
+#define NULL ((VOID *) 0)
+#endif
+//
+// EFI Data Types derived from other EFI data types.
+//
+typedef UINTN EFI_STATUS;
+
+typedef VOID *EFI_HANDLE;
+#define NULL_HANDLE ((VOID *) 0)
+
+typedef VOID *EFI_EVENT;
+typedef UINTN EFI_TPL;
+
+typedef struct {
+ UINT32 Data1;
+ UINT16 Data2;
+ UINT16 Data3;
+ UINT8 Data4[8];
+} EFI_GUID;
+
+typedef union {
+ EFI_GUID Guid;
+ UINT8 Raw[16];
+} EFI_GUID_UNION;
+
+//
+// EFI Time Abstraction:
+// Year: 2000 - 20XX
+// Month: 1 - 12
+// Day: 1 - 31
+// Hour: 0 - 23
+// Minute: 0 - 59
+// Second: 0 - 59
+// Nanosecond: 0 - 999,999,999
+// TimeZone: -1440 to 1440 or 2047
+//
+typedef struct {
+ UINT16 Year;
+ UINT8 Month;
+ UINT8 Day;
+ UINT8 Hour;
+ UINT8 Minute;
+ UINT8 Second;
+ UINT8 Pad1;
+ UINT32 Nanosecond;
+ INT16 TimeZone;
+ UINT8 Daylight;
+ UINT8 Pad2;
+} EFI_TIME;
+
+//
+// Bit definitions for EFI_TIME.Daylight
+//
+#define EFI_TIME_ADJUST_DAYLIGHT 0x01
+#define EFI_TIME_IN_DAYLIGHT 0x02
+
+//
+// Value definition for EFI_TIME.TimeZone
+//
+#define EFI_UNSPECIFIED_TIMEZONE 0x07FF
+
+//
+// Networking
+//
+typedef struct {
+ UINT8 Addr[4];
+} EFI_IPv4_ADDRESS;
+
+typedef struct {
+ UINT8 Addr[16];
+} EFI_IPv6_ADDRESS;
+
+typedef struct {
+ UINT8 Addr[32];
+} EFI_MAC_ADDRESS;
+
+typedef union {
+ UINT32 Addr[4];
+ EFI_IPv4_ADDRESS v4;
+ EFI_IPv6_ADDRESS v6;
+} EFI_IP_ADDRESS;
+
+typedef enum {
+ EfiReservedMemoryType,
+ EfiLoaderCode,
+ EfiLoaderData,
+ EfiBootServicesCode,
+ EfiBootServicesData,
+ EfiRuntimeServicesCode,
+ EfiRuntimeServicesData,
+ EfiConventionalMemory,
+ EfiUnusableMemory,
+ EfiACPIReclaimMemory,
+ EfiACPIMemoryNVS,
+ EfiMemoryMappedIO,
+ EfiMemoryMappedIOPortSpace,
+ EfiPalCode,
+ EfiMaxMemoryType
+} EFI_MEMORY_TYPE;
+
+typedef enum {
+ AllocateAnyPages,
+ AllocateMaxAddress,
+ AllocateAddress,
+ MaxAllocateType
+} EFI_ALLOCATE_TYPE;
+
+typedef struct {
+ UINT64 Signature;
+ UINT32 Revision;
+ UINT32 HeaderSize;
+ UINT32 CRC32;
+ UINT32 Reserved;
+} EFI_TABLE_HEADER;
+
+//
+// possible caching types for the memory range
+//
+#define EFI_MEMORY_UC 0x0000000000000001
+#define EFI_MEMORY_WC 0x0000000000000002
+#define EFI_MEMORY_WT 0x0000000000000004
+#define EFI_MEMORY_WB 0x0000000000000008
+#define EFI_MEMORY_UCE 0x0000000000000010
+
+//
+// physical memory protection on range
+//
+#define EFI_MEMORY_WP 0x0000000000001000
+#define EFI_MEMORY_RP 0x0000000000002000
+#define EFI_MEMORY_XP 0x0000000000004000
+
+//
+// range requires a runtime mapping
+//
+#define EFI_MEMORY_RUNTIME 0x8000000000000000
+
+typedef UINT64 EFI_PHYSICAL_ADDRESS;
+typedef UINT64 EFI_VIRTUAL_ADDRESS;
+
+#define EFI_MEMORY_DESCRIPTOR_VERSION 1
+typedef struct {
+ UINT32 Type;
+ UINT32 Pad;
+ EFI_PHYSICAL_ADDRESS PhysicalStart;
+ EFI_VIRTUAL_ADDRESS VirtualStart;
+ UINT64 NumberOfPages;
+ UINT64 Attribute;
+} EFI_MEMORY_DESCRIPTOR;
+
+//
+// The EFI memory allocation functions work in units of EFI_PAGEs that are
+// 4K. This should in no way be confused with the page size of the processor.
+// An EFI_PAGE is just the quanta of memory in EFI.
+//
+#define EFI_PAGE_SIZE 4096
+#define EFI_PAGE_MASK 0xFFF
+#define EFI_PAGE_SHIFT 12
+
+#define EFI_SIZE_TO_PAGES(a) (((a) >> EFI_PAGE_SHIFT) + (((a) & EFI_PAGE_MASK) ? 1 : 0))
+
+#define EFI_PAGES_TO_SIZE(a) ( (a) << EFI_PAGE_SHIFT)
+
+//
+// ALIGN_POINTER - aligns a pointer to the lowest boundry
+//
+#define ALIGN_POINTER(p, s) ((VOID *) (p + ((s - ((UINTN) p)) & (s - 1))))
+
+//
+// ALIGN_VARIABLE - aligns a variable up to the next natural boundry for int size of a processor
+//
+#define ALIGN_VARIABLE(Value, Adjustment) \
+ (UINTN) Adjustment = 0; \
+ if ((UINTN) Value % sizeof (UINTN)) { \
+ (UINTN) Adjustment = sizeof (UINTN) - ((UINTN) Value % sizeof (UINTN)); \
+ } \
+ Value = (UINTN) Value + (UINTN) Adjustment
+
+//
+// EFI_FIELD_OFFSET - returns the byte offset to a field within a structure
+//
+#define EFI_FIELD_OFFSET(TYPE,Field) ((UINTN)(&(((TYPE *) 0)->Field)))
+
+//
+// CONTAINING_RECORD - returns a pointer to the structure
+// from one of it's elements.
+//
+#define _CR(Record, TYPE, Field) ((TYPE *) ((CHAR8 *) (Record) - (CHAR8 *) &(((TYPE *) 0)->Field)))
+
+//
+// Define macros to build data structure signatures from characters.
+//
+#define EFI_SIGNATURE_16(A, B) ((A) | (B << 8))
+#define EFI_SIGNATURE_32(A, B, C, D) (EFI_SIGNATURE_16 (A, B) | (EFI_SIGNATURE_16 (C, D) << 16))
+#define EFI_SIGNATURE_64(A, B, C, D, E, F, G, H) \
+ (EFI_SIGNATURE_32 (A, B, C, D) | ((UINT64) (EFI_SIGNATURE_32 (E, F, G, H)) << 32))
+
+#endif
diff --git a/EDK/Foundation/Efi/Include/Pxe.h b/EDK/Foundation/Efi/Include/Pxe.h
new file mode 100644
index 0000000..210377f
--- /dev/null
+++ b/EDK/Foundation/Efi/Include/Pxe.h
@@ -0,0 +1,58 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ pxe.h
+
+Abstract:
+
+ PXE 2.1 Common Structures
+
+Revision History
+
+--*/
+
+#ifndef _PXE_H
+#define _PXE_H
+
+//
+// Packet definitions
+//
+typedef struct {
+ UINT8 BootpOpcode;
+ UINT8 BootpHwType;
+ UINT8 BootpHwAddrLen;
+ UINT8 BootpGateHops;
+ UINT32 BootpIdent;
+ UINT16 BootpSeconds;
+ UINT16 BootpFlags;
+ UINT8 BootpCiAddr[4];
+ UINT8 BootpYiAddr[4];
+ UINT8 BootpSiAddr[4];
+ UINT8 BootpGiAddr[4];
+ UINT8 BootpHwAddr[16];
+ UINT8 BootpSrvName[64];
+ UINT8 BootpBootFile[128];
+ UINT32 DhcpMagik;
+ UINT8 DhcpOptions[56];
+} EFI_PXE_BASE_CODE_DHCPV4_PACKET;
+
+typedef union {
+ UINT8 Raw[1472];
+ EFI_PXE_BASE_CODE_DHCPV4_PACKET Dhcpv4;
+
+ //
+ // EFI_PXE_BASE_CODE_DHCPV6_PACKET Dhcpv6;
+ //
+} EFI_PXE_BASE_CODE_PACKET;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/AbsolutePointer/AbsolutePointer.c b/EDK/Foundation/Efi/Protocol/AbsolutePointer/AbsolutePointer.c
new file mode 100644
index 0000000..f023d6a
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/AbsolutePointer/AbsolutePointer.c
@@ -0,0 +1,29 @@
+/*++
+
+Copyright (c) 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ AbsolutePointer.c
+
+Abstract:
+
+ EFI_ABSOLUTE_POINTER_PROTOCOL from the UEFI 2.1 specification.
+
+ This protocol specifies a simple method for accessing absolute pointer devices.
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (AbsolutePointer)
+
+EFI_GUID gEfiAbsolutePointerProtocolGuid = EFI_ABSOLUTE_POINTER_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiAbsolutePointerProtocolGuid, "Absolute Pointer Protocol", "UEFI 2.1 Absolute Pointer Protocol");
diff --git a/EDK/Foundation/Efi/Protocol/AbsolutePointer/AbsolutePointer.h b/EDK/Foundation/Efi/Protocol/AbsolutePointer/AbsolutePointer.h
new file mode 100644
index 0000000..ac0d132
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/AbsolutePointer/AbsolutePointer.h
@@ -0,0 +1,117 @@
+/*++
+
+Copyright (c) 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ AbsolutePointer.h
+
+Abstract:
+
+ EFI_ABSOLUTE_POINTER_PROTOCOL from the UEFI 2.1 specification.
+
+ This protocol specifies a simple method for accessing absolute pointer devices.
+
+--*/
+
+#ifndef __ABSOLUTE_POINTER_H__
+#define __ABSOLUTE_POINTER_H__
+
+#define EFI_ABSOLUTE_POINTER_PROTOCOL_GUID \
+ { \
+ 0x8D59D32B, 0xC655, 0x4AE9, 0x9B, 0x15, 0xF2, 0x59, 0x04, 0x99, 0x2A, 0x43 \
+ }
+
+EFI_FORWARD_DECLARATION (EFI_ABSOLUTE_POINTER_PROTOCOL);
+
+//
+// Data structures
+//
+
+typedef struct {
+ UINT64 AbsoluteMinX;
+ UINT64 AbsoluteMinY;
+ UINT64 AbsoluteMinZ;
+ UINT64 AbsoluteMaxX;
+ UINT64 AbsoluteMaxY;
+ UINT64 AbsoluteMaxZ;
+ UINT32 Attributes;
+} EFI_ABSOLUTE_POINTER_MODE;
+
+typedef struct {
+ UINT64 CurrentX;
+ UINT64 CurrentY;
+ UINT64 CurrentZ;
+ UINT32 ActiveButtons;
+} EFI_ABSOLUTE_POINTER_STATE;
+
+#define EFI_ABSP_SupportsAltActive 0x00000001
+#define EFI_ABSP_SupportsPressureAsZ 0x00000002
+
+#define EFI_ABSP_TouchActive 0x00000001
+#define EFI_ABS_AltActive 0x00000002
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_ABSOLUTE_POINTER_RESET) (
+ IN EFI_ABSOLUTE_POINTER_PROTOCOL *This,
+ IN BOOLEAN ExtendedVerification
+ )
+/*++
+
+ Routine Description:
+ Resets the pointer device hardware.
+
+ Arguments:
+ This - Protocol instance pointer.
+ ExtendedVerification - Driver may perform diagnostics on reset.
+
+ Returns:
+ EFI_SUCCESS - The device was reset.
+ EFI_DEVICE_ERROR - The device is not functioning correctly and could
+ not be reset.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_ABSOLUTE_POINTER_GET_STATE) (
+ IN EFI_ABSOLUTE_POINTER_PROTOCOL *This,
+ IN OUT EFI_ABSOLUTE_POINTER_STATE *State
+ )
+/*++
+
+ Routine Description:
+ Retrieves the current state of a pointer device.
+
+ Arguments:
+ This - Protocol instance pointer.
+ State - A pointer to the state information on the pointer device.
+
+ Returns:
+ EFI_SUCCESS - The state of the pointer device was returned in State..
+ EFI_NOT_READY - The state of the pointer device has not changed since the last call to
+ GetState().
+ EFI_DEVICE_ERROR - A device error occurred while attempting to retrieve the pointer
+ device's current state.
+--*/
+;
+
+typedef struct _EFI_ABSOLUTE_POINTER_PROTOCOL {
+ EFI_ABSOLUTE_POINTER_RESET Reset;
+ EFI_ABSOLUTE_POINTER_GET_STATE GetState;
+ EFI_EVENT WaitForInput;
+ EFI_ABSOLUTE_POINTER_MODE *Mode;
+} EFI_ABSOLUTE_POINTER_PROTOCOL;
+
+extern EFI_GUID gEfiAbsolutePointerProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/AcpiTable/AcpiTable.c b/EDK/Foundation/Efi/Protocol/AcpiTable/AcpiTable.c
new file mode 100644
index 0000000..b2efc7b
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/AcpiTable/AcpiTable.c
@@ -0,0 +1,29 @@
+/*++
+
+Copyright (c) 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ AcpiTable.c
+
+Abstract:
+
+ ACPI Table Protocol from the UEFI 2.1 specification.
+
+ This protocol may be used to install or remove an ACPI table from a platform.
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (AcpiTable)
+
+EFI_GUID gEfiAcpiTableProtocolGuid = EFI_ACPI_TABLE_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiAcpiTableProtocolGuid, "UEFI ACPI Table Protocol", "UEFI ACPI Table Protocol");
diff --git a/EDK/Foundation/Efi/Protocol/AcpiTable/AcpiTable.h b/EDK/Foundation/Efi/Protocol/AcpiTable/AcpiTable.h
new file mode 100644
index 0000000..4cfdf97
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/AcpiTable/AcpiTable.h
@@ -0,0 +1,112 @@
+/*++
+
+Copyright (c) 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ AcpiTable.h
+
+Abstract:
+
+ ACPI Table Protocol from the UEFI 2.1 specification.
+
+ This protocol may be used to install or remove an ACPI table from a platform.
+
+--*/
+
+#ifndef __ACPI_TABLE_H__
+#define __ACPI_TABLE_H__
+
+#include "Acpi.h"
+
+//
+// Global ID for the Acpi Table Protocol
+//
+#define EFI_ACPI_TABLE_PROTOCOL_GUID \
+ { \
+ 0xffe06bdd, 0x6107, 0x46a6, 0x7b, 0xb2, 0x5a, 0x9c, 0x7e, 0xc5, 0x27, 0x5c \
+ }
+
+EFI_FORWARD_DECLARATION (EFI_ACPI_TABLE_PROTOCOL);
+
+#define UEFI_ACPI_TABLE_SIGNATURE EFI_SIGNATURE_32 ('U', 'E', 'F', 'I')
+
+#pragma pack(1)
+
+typedef struct {
+ EFI_ACPI_DESCRIPTION_HEADER Header;
+ EFI_GUID Identifier;
+ UINT16 DataOffset;
+} EFI_ACPI_TABLE;
+
+#pragma pack()
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_ACPI_TABLE_INSTALL_ACPI_TABLE) (
+ IN EFI_ACPI_TABLE_PROTOCOL *This,
+ IN VOID *AcpiTableBuffer,
+ IN UINTN AcpiTableBufferSize,
+ OUT UINTN *TableKey
+ )
+/*++
+
+ Routine Description:
+ Installs an ACPI table into the RSDT/XSDT.
+
+ Arguments:
+ This - Protocol instance pointer.
+ AcpiTableBuffer - A pointer to a buffer containing the ACPI table to be installed.
+ AcpiTableBufferSize - Specifies the size, in bytes, of the AcpiTableBuffer buffer.
+ TableKey - Reurns a key to refer to the ACPI table.
+
+ Returns:
+ EFI_SUCCESS - The table was successfully inserted.
+ EFI_INVALID_PARAMETER - Either AcpiTableBuffer is NULL, TableKey is NULL, or AcpiTableBufferSize
+ and the size field embedded in the ACPI table pointed to by AcpiTableBuffer
+ are not in sync.
+ EFI_OUT_OF_RESOURCES - Insufficient resources exist to complete the request.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_ACPI_TABLE_UNINSTALL_ACPI_TABLE) (
+ IN EFI_ACPI_TABLE_PROTOCOL *This,
+ IN UINTN TableKey
+ )
+/*++
+
+ Routine Description:
+ Removes an ACPI table from the RSDT/XSDT.
+
+ Arguments:
+ This - Protocol instance pointer.
+ TableKey - Specifies the table to uninstall. The key was returned from InstallAcpiTable().
+
+ Returns:
+ EFI_SUCCESS - The table was successfully uninstalled.
+ EFI_NOT_FOUND - TableKey does not refer to a valid key for a table entry.
+
+--*/
+;
+
+//
+// Interface structure for the ACPI Table Protocol
+//
+typedef struct _EFI_ACPI_TABLE_PROTOCOL {
+ EFI_ACPI_TABLE_INSTALL_ACPI_TABLE InstallAcpiTable;
+ EFI_ACPI_TABLE_UNINSTALL_ACPI_TABLE UninstallAcpiTable;
+} EFI_ACPI_TABLE_PROTOCOL;
+
+extern EFI_GUID gEfiAcpiTableProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/Arp/Arp.c b/EDK/Foundation/Efi/Protocol/Arp/Arp.c
new file mode 100644
index 0000000..377e99f
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/Arp/Arp.c
@@ -0,0 +1,29 @@
+/*++
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Arp.c
+
+Abstract:
+
+ UEFI Arp protocol.
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (Arp)
+
+EFI_GUID gEfiArpServiceBindingProtocolGuid = EFI_ARP_SERVICE_BINDING_PROTOCOL_GUID;
+EFI_GUID gEfiArpProtocolGuid = EFI_ARP_PROTOCOL_GUID;
+
+EFI_GUID_STRING (&gEfiArpServiceBindingProtocolGuid, "ARP Service Binding Protocol", "ARP Service Binding Protocol");
+EFI_GUID_STRING (&gEfiArpProtocolGuid, "ARP Protocol", "ARP Protocol");
diff --git a/EDK/Foundation/Efi/Protocol/Arp/Arp.h b/EDK/Foundation/Efi/Protocol/Arp/Arp.h
new file mode 100644
index 0000000..eded0a7
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/Arp/Arp.h
@@ -0,0 +1,136 @@
+/*++
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Arp.h
+
+Abstract:
+
+ UEFI Arp protocol definition.
+
+--*/
+
+#ifndef _ARP_H_
+#define _ARP_H_
+
+#include EFI_PROTOCOL_DEFINITION (ServiceBinding)
+
+#define EFI_ARP_SERVICE_BINDING_PROTOCOL_GUID \
+ { 0xf44c00ee, 0x1f2c, 0x4a00, 0xaa, 0x9, 0x1c, 0x9f, 0x3e, 0x8, 0x0, 0xa3 }
+
+#define EFI_ARP_PROTOCOL_GUID \
+ { 0xf4b427bb, 0xba21, 0x4f16, 0xbc, 0x4e, 0x43, 0xe4, 0x16, 0xab, 0x61, 0x9c }
+
+EFI_FORWARD_DECLARATION (EFI_ARP_PROTOCOL);
+
+typedef struct _EFI_ARP_FIND_DATA {
+UINT32 Size;
+BOOLEAN DenyFlag;
+BOOLEAN StaticFlag;
+UINT16 HwAddressType;
+UINT16 SwAddressType;
+UINT8 HwAddressLength;
+UINT8 SwAddressLength;
+} EFI_ARP_FIND_DATA;
+
+
+//****************************************************
+// EFI_ARP_CONFIG_DATA
+//****************************************************
+typedef struct EFI_ARP_CONFIG_DATA {
+ UINT16 SwAddressType; // Host byte order
+ UINT8 SwAddressLength;
+ VOID *StationAddress; // Network byte order
+ UINT32 EntryTimeOut;
+ UINT32 RetryCount;
+ UINT32 RetryTimeOut;
+} EFI_ARP_CONFIG_DATA;
+
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_ARP_CONFIGURE) (
+ IN EFI_ARP_PROTOCOL *This,
+ IN EFI_ARP_CONFIG_DATA *ConfigData OPTIONAL
+ );
+
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_ARP_ADD) (
+ IN EFI_ARP_PROTOCOL *This,
+ IN BOOLEAN DenyFlag,
+ IN VOID *TargetSwAddress OPTIONAL,
+ IN VOID *TargetHwAddress OPTIONAL,
+ IN UINT32 TimeoutValue,
+ IN BOOLEAN Overwrite
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_ARP_FIND) (
+ IN EFI_ARP_PROTOCOL *This,
+ IN BOOLEAN BySwAddress,
+ IN VOID *AddressBuffer OPTIONAL,
+ OUT UINT32 *EntryLength OPTIONAL,
+ OUT UINT32 *EntryCount OPTIONAL,
+ OUT EFI_ARP_FIND_DATA **Entries OPTIONAL,
+ IN BOOLEAN Refresh
+);
+
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_ARP_DELETE) (
+ IN EFI_ARP_PROTOCOL *This,
+ IN BOOLEAN BySwAddress,
+ IN VOID *AddressBuffer OPTIONAL
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_ARP_FLUSH) (
+ IN EFI_ARP_PROTOCOL *This
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_ARP_REQUEST) (
+ IN EFI_ARP_PROTOCOL *This,
+ IN VOID *TargetSwAddress OPTIONAL,
+ IN EFI_EVENT ResolvedEvent OPTIONAL,
+ OUT VOID *TargetHwAddress
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_ARP_CANCEL) (
+IN EFI_ARP_PROTOCOL *This,
+IN VOID *TargetSwAddress OPTIONAL,
+IN EFI_EVENT ResolvedEvent OPTIONAL
+);
+
+typedef struct _EFI_ARP_PROTOCOL {
+ EFI_ARP_CONFIGURE Configure;
+ EFI_ARP_ADD Add;
+ EFI_ARP_FIND Find;
+ EFI_ARP_DELETE Delete;
+ EFI_ARP_FLUSH Flush;
+ EFI_ARP_REQUEST Request;
+ EFI_ARP_CANCEL Cancel;
+} EFI_ARP_PROTOCOL;
+
+
+extern EFI_GUID gEfiArpServiceBindingProtocolGuid;
+extern EFI_GUID gEfiArpProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/AuthenticationInfo/AuthenticationInfo.c b/EDK/Foundation/Efi/Protocol/AuthenticationInfo/AuthenticationInfo.c
new file mode 100644
index 0000000..da1e861
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/AuthenticationInfo/AuthenticationInfo.c
@@ -0,0 +1,30 @@
+/*++
+
+Copyright (c) 2008, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ AuthenticationInfo.c
+
+Abstract:
+
+ UEFI Authentication Info Protocol.
+
+Revision History:
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (AuthenticationInfo)
+
+EFI_GUID gEfiAuthenticationInfoProtocolGuid = EFI_AUTHENTICATION_INFO_PROTOCOL_GUID;
+
+EFI_GUID_STRING
+ (&gEfiAuthenticationInfoProtocolGuid, "Authentication Info Protocol", "UEFI 2.1 Authentication Info Protocol");
diff --git a/EDK/Foundation/Efi/Protocol/AuthenticationInfo/AuthenticationInfo.h b/EDK/Foundation/Efi/Protocol/AuthenticationInfo/AuthenticationInfo.h
new file mode 100644
index 0000000..94a6fce
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/AuthenticationInfo/AuthenticationInfo.h
@@ -0,0 +1,106 @@
+/*++
+
+Copyright (c) 2008, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PlatformToDriverConfiguration.h
+
+Abstract:
+
+ UEFI Authentication Info Protocol.
+
+Revision History:
+
+--*/
+
+#ifndef _EFI_AUTHENTICATION_INFO_H_
+#define _EFI_AUTHENTICATION_INFO_H_
+
+//
+// Global ID for the Authentication Info Protocol
+//
+#define EFI_AUTHENTICATION_INFO_PROTOCOL_GUID \
+ { \
+ 0x7671d9d0, 0x53db, 0x4173, 0xaa, 0x69, 0x23, 0x27, 0xf2, 0x1f, 0x0b, 0xc7 \
+ }
+
+EFI_FORWARD_DECLARATION (EFI_AUTHENTICATION_INFO_PROTOCOL);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_AUTHENTICATION_INFO_PROTOCOL_GET) (
+ IN EFI_AUTHENTICATION_INFO_PROTOCOL *This,
+ IN EFI_HANDLE *ControllerHandle,
+ OUT VOID *Buffer
+ );
+/*++
+
+ Routine Description:
+ Retrieves the Authentication information associated with a particular
+ controller handle.
+
+ Arguments:
+ This - Pointer to the EFI_AUTHENTICATION_INFO_PROTOCOL instance.
+ ControllerHandle - Handle to the Controller.
+ Buffer - Pointer to the authentication information. This function
+ is responsible for allocating the buffer and it is the
+ caller's responsibility to free buffer when the caller
+ is finished with buffer.
+
+ Returns:
+ EFI_SUCCESS - Successfully retrieved Authentication information
+ for the given ControllerHandle.
+ EFI_NOT_FOUND - No matching Authentication information found for the
+ given ControllerHandle.
+ EFI_DEVICE_ERROR - The Authentication information could not be retrieved
+ due to a hardware error.
+
+--*/
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_AUTHENTICATION_INFO_PROTOCOL_SET) (
+ IN EFI_AUTHENTICATION_INFO_PROTOCOL *This,
+ IN EFI_HANDLE *ControllerHandle,
+ IN VOID *Buffer
+ );
+/*++
+
+ Routine Description:
+ Set the Authentication information for a given controller handle.
+
+ Arguments:
+ This - Pointer to the EFI_AUTHENTICATION_INFO_PROTOCOL instance.
+ ControllerHandle - Handle to the Controller.
+ Buffer - Pointer to the authentication information.
+
+ Returns:
+ EFI_SUCCESS - Successfully set the Authentication node information
+ for the given ControllerHandle.
+ EFI_UNSUPPORTED - If the platform policies do not allow setting of the
+ Authentication information.
+ EFI_DEVICE_ERROR - The authentication node information could not be configured
+ due to a hardware error.
+ EFI_OUT_OF_RESOURCES - Not enough storage is available to hold the data.
+
+--*/
+
+//
+// Interface structure for the Authentication Info Protocol
+//
+typedef struct _EFI_AUTHENTICATION_INFO_PROTOCOL {
+ EFI_AUTHENTICATION_INFO_PROTOCOL_GET Get;
+ EFI_AUTHENTICATION_INFO_PROTOCOL_SET Set;
+} EFI_AUTHENTICATION_INFO_PROTOCOL;
+
+extern EFI_GUID gEfiAuthenticationInfoProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/Bis/Bis.c b/EDK/Foundation/Efi/Protocol/Bis/Bis.c
new file mode 100644
index 0000000..4ec1b97
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/Bis/Bis.c
@@ -0,0 +1,27 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Bis.c
+
+Abstract:
+
+ This file defines the Bis protocol
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (Bis)
+
+EFI_GUID gEfiBisProtocolGuid = EFI_BIS_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiBisProtocolGuid, "BIS Base Protocol", "BIS Base protocol");
diff --git a/EDK/Foundation/Efi/Protocol/Bis/Bis.h b/EDK/Foundation/Efi/Protocol/Bis/Bis.h
new file mode 100644
index 0000000..b7035db
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/Bis/Bis.h
@@ -0,0 +1,233 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Bis.h
+
+Abstract:
+
+ This file defines the BIS protocol.
+
+--*/
+
+#ifndef _BIS_H_
+#define _BIS_H_
+
+#include <EfiSpec.h>
+
+//
+// Basic types
+//
+typedef VOID *BIS_APPLICATION_HANDLE;
+typedef UINT16 BIS_ALG_ID;
+typedef UINT32 BIS_CERT_ID;
+
+//
+// EFI_BIS_DATA type.
+//
+// EFI_BIS_DATA instances obtained from BIS must be freed by calling Free( ).
+//
+typedef struct _EFI_BIS_DATA {
+ UINT32 Length; // Length of Data in 8 bit bytes.
+ UINT8 *Data; // 32 Bit Flat Address of data.
+} EFI_BIS_DATA;
+
+//
+// EFI_BIS_VERSION type.
+//
+typedef struct _EFI_BIS_VERSION {
+ UINT32 Major; // BIS Interface version number.
+ UINT32 Minor; // Build number.
+} EFI_BIS_VERSION;
+
+//
+// ----------------------------------------------------//
+// Use these values to initialize EFI_BIS_VERSION.Major
+// and to interpret results of Initialize.
+// ----------------------------------------------------//
+//
+#define BIS_CURRENT_VERSION_MAJOR BIS_VERSION_1
+#define BIS_VERSION_1 1
+
+//
+// EFI_BIS_SIGNATURE_INFO type.
+//
+typedef struct _EFI_BIS_SIGNATURE_INFO {
+ BIS_CERT_ID CertificateID; // Truncated hash of platform Boot Object
+ // authorization certificate.
+ //
+ BIS_ALG_ID AlgorithmID; // A signature algorithm number.
+ UINT16 KeyLength; // Length of alg. keys in bits.
+} EFI_BIS_SIGNATURE_INFO;
+
+//
+// Currently defined values for EFI_BIS_SIGNATURE_INFO.AlgorithmID.
+// The exact numeric values come from
+// "Common Data Security Architecture (CDSA) Specification".
+//
+#define BIS_ALG_DSA (41) // CSSM_ALGID_DSA
+#define BIS_ALG_RSA_MD5 (42) // CSSM_ALGID_MD5_WITH_RSA
+// Currently defined values for EFI_BIS_SIGNATURE_INFO.CertificateId.
+//
+#define BIS_CERT_ID_DSA BIS_ALG_DSA // CSSM_ALGID_DSA
+#define BIS_CERT_ID_RSA_MD5 BIS_ALG_RSA_MD5 // CSSM_ALGID_MD5_WITH_RSA
+// The following is a mask value that gets applied to the truncated hash of a
+// platform Boot Object Authorization Certificate to create the certificateID.
+// A certificateID must not have any bits set to the value 1 other than bits in
+// this mask.
+//
+#define BIS_CERT_ID_MASK (0xFF7F7FFF)
+
+//
+// Macros for dealing with the EFI_BIS_DATA object obtained
+// from BIS_GetSignatureInfo()
+// BIS_GET_SIGINFO_COUNT - tells how many EFI_BIS_SIGNATURE_INFO
+// elements are contained in a EFI_BIS_DATA struct pointed to
+// by the provided EFI_BIS_DATA*.
+//
+#define BIS_GET_SIGINFO_COUNT(BisDataPtr) ((BisDataPtr)->Length / sizeof (EFI_BIS_SIGNATURE_INFO))
+
+//
+// BIS_GET_SIGINFO_ARRAY - produces a EFI_BIS_SIGNATURE_INFO*
+// from a given EFI_BIS_DATA*.
+//
+#define BIS_GET_SIGINFO_ARRAY(BisDataPtr) ((EFI_BIS_SIGNATURE_INFO *) (BisDataPtr)->Data)
+
+//
+// Binary Value of "X-Intel-BIS-ParameterSet" Attribute.
+// (Value is Base64 encoded in actual signed manifest).
+// {EDD35E31-07B9-11d2-83A3-00A0C91FADCF}
+//
+#define BOOT_OBJECT_AUTHORIZATION_PARMSET_GUIDVALUE \
+ { \
+ 0xedd35e31, 0x7b9, 0x11d2, \
+ { \
+ 0x83, 0xa3, 0x0, 0xa0, 0xc9, 0x1f, 0xad, 0xcf \
+ } \
+ }
+
+//
+// -----------------------------------//
+// EFI_BIS_PROTOCOL
+// -----------------------------------//
+//
+#define EFI_BIS_PROTOCOL_GUID \
+ { \
+ 0x0b64aab0, 0x5429, 0x11d4, 0x98, 0x16, 0x00, 0xa0, 0xc9, 0x1f, 0xad, 0xcf \
+ }
+
+typedef struct _EFI_BIS_PROTOCOL EFI_BIS_PROTOCOL;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_BIS_INITIALIZE) (
+ IN EFI_BIS_PROTOCOL * This, // this
+ OUT BIS_APPLICATION_HANDLE * AppHandle, // Application handle.
+ IN OUT EFI_BIS_VERSION * InterfaceVersion, // ver needed/available.
+ IN EFI_BIS_DATA * TargetAddress // Address of BIS platform.
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_BIS_FREE) (
+ IN BIS_APPLICATION_HANDLE AppHandle, // From Initialize( ).
+ IN EFI_BIS_DATA * ToFree // EFI_BIS_DATA being freed.
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_BIS_SHUTDOWN) (
+ IN BIS_APPLICATION_HANDLE AppHandle // From Initialize( ).
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_BIS_GET_BOOT_OBJECT_AUTHORIZATION_CERTIFICATE) (
+ IN BIS_APPLICATION_HANDLE AppHandle, // From Initialize( ).
+ OUT EFI_BIS_DATA **Certificate // Pointer to certificate.
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_BIS_VERIFY_BOOT_OBJECT) (
+ IN BIS_APPLICATION_HANDLE AppHandle, // From Initialize( ).
+ IN EFI_BIS_DATA * Credentials, // Verification signed manifest.
+ IN EFI_BIS_DATA * DataObject, // Boot object to verify.
+ OUT BOOLEAN *IsVerified // Result of verifcation.
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_BIS_GET_BOOT_OBJECT_AUTHORIZATION_CHECKFLAG) (
+ IN BIS_APPLICATION_HANDLE AppHandle, // From Initialize( ).
+ OUT BOOLEAN *CheckIsRequired // Value of check flag.
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_BIS_GET_BOOT_OBJECT_AUTHORIZATION_UPDATE_TOKEN) (
+ IN BIS_APPLICATION_HANDLE AppHandle, // From Initialize( ).
+ OUT EFI_BIS_DATA **UpdateToken // Value of update token.
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_BIS_UPDATE_BOOT_OBJECT_AUTHORIZATION) (
+ IN BIS_APPLICATION_HANDLE AppHandle, // From Initialize( ).
+ IN EFI_BIS_DATA * RequestCredential, // Update Request Manifest.
+ OUT EFI_BIS_DATA **NewUpdateToken // Next update token.
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_BIS_VERIFY_OBJECT_WITH_CREDENTIAL) (
+ IN BIS_APPLICATION_HANDLE AppHandle, // From Initialize( ).
+ IN EFI_BIS_DATA * Credentials, // Verification signed manifest.
+ IN EFI_BIS_DATA * DataObject, // Boot object to verify.
+ IN EFI_BIS_DATA * SectionName, // Name of credential section to use.
+ IN EFI_BIS_DATA * AuthorityCertificate, // Certificate for credentials.
+ OUT BOOLEAN *IsVerified // Result of verifcation.
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_BIS_GET_SIGNATURE_INFO) (
+ IN BIS_APPLICATION_HANDLE AppHandle, // From Initialize( ).
+ OUT EFI_BIS_DATA **SignatureInfo // Signature info struct.
+ );
+
+#define EFI_BIS_PROTOCOL_REVISION 0x00010000
+
+typedef struct _EFI_BIS_PROTOCOL {
+ //
+ // member vars
+ //
+ UINT64 Revision;
+
+ //
+ // methods
+ //
+ EFI_BIS_INITIALIZE Initialize;
+ EFI_BIS_SHUTDOWN Shutdown;
+ EFI_BIS_FREE Free;
+ EFI_BIS_GET_BOOT_OBJECT_AUTHORIZATION_CERTIFICATE GetBootObjectAuthorizationCertificate;
+ EFI_BIS_GET_BOOT_OBJECT_AUTHORIZATION_CHECKFLAG GetBootObjectAuthorizationCheckFlag;
+ EFI_BIS_GET_BOOT_OBJECT_AUTHORIZATION_UPDATE_TOKEN GetBootObjectAuthorizationUpdateToken;
+ EFI_BIS_GET_SIGNATURE_INFO GetSignatureInfo;
+ EFI_BIS_UPDATE_BOOT_OBJECT_AUTHORIZATION UpdateBootObjectAuthorization;
+ EFI_BIS_VERIFY_BOOT_OBJECT VerifyBootObject;
+ EFI_BIS_VERIFY_OBJECT_WITH_CREDENTIAL VerifyObjectWithCredential;
+} EFI_BIS_PROTOCOL;
+
+extern EFI_GUID gEfiBisProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/BlockIO/BlockIO.c b/EDK/Foundation/Efi/Protocol/BlockIO/BlockIO.c
new file mode 100644
index 0000000..46c9158
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/BlockIO/BlockIO.c
@@ -0,0 +1,31 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ BlockIo.c
+
+Abstract:
+
+ Block IO protocol as defined in the EFI 1.0 specification.
+
+ The Block IO protocol is used to abstract block devices like hard drives,
+ DVD-ROMs and floppy drives.
+
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (BlockIo)
+
+EFI_GUID gEfiBlockIoProtocolGuid = EFI_BLOCK_IO_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiBlockIoProtocolGuid, "BlockIo Protocol", "EFI 1.0 Block IO protocol");
diff --git a/EDK/Foundation/Efi/Protocol/BlockIO/BlockIO.h b/EDK/Foundation/Efi/Protocol/BlockIO/BlockIO.h
new file mode 100644
index 0000000..49748bc
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/BlockIO/BlockIO.h
@@ -0,0 +1,213 @@
+/*++
+
+Copyright (c) 2004 - 2008, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ BlockIo.h
+
+Abstract:
+
+ Block IO protocol as defined in the EFI 1.0 specification.
+
+ The Block IO protocol is used to abstract block devices like hard drives,
+ DVD-ROMs and floppy drives.
+
+
+--*/
+
+#ifndef __BLOCK_IO_H__
+#define __BLOCK_IO_H__
+
+#define EFI_BLOCK_IO_PROTOCOL_GUID \
+ { \
+ 0x964e5b21, 0x6459, 0x11d2, 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b \
+ }
+
+//
+// Forward reference for pure ANSI compatability
+//
+EFI_FORWARD_DECLARATION (EFI_BLOCK_IO_PROTOCOL);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_BLOCK_RESET) (
+ IN EFI_BLOCK_IO_PROTOCOL * This,
+ IN BOOLEAN ExtendedVerification
+ )
+/*++
+
+ Routine Description:
+ Reset the Block Device.
+
+ Arguments:
+ This - Protocol instance pointer.
+ ExtendedVerification - Driver may perform diagnostics on reset.
+
+ Returns:
+ EFI_SUCCESS - The device was reset.
+ EFI_DEVICE_ERROR - The device is not functioning properly and could
+ not be reset.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_BLOCK_READ) (
+ IN EFI_BLOCK_IO_PROTOCOL * This,
+ IN UINT32 MediaId,
+ IN EFI_LBA Lba,
+ IN UINTN BufferSize,
+ OUT VOID *Buffer
+ )
+/*++
+
+ Routine Description:
+ Read BufferSize bytes from Lba into Buffer.
+
+ Arguments:
+ This - Protocol instance pointer.
+ MediaId - Id of the media, changes every time the media is replaced.
+ Lba - The starting Logical Block Address to read from
+ BufferSize - Size of Buffer, must be a multiple of device block size.
+ Buffer - Buffer containing read data
+
+ Returns:
+ EFI_SUCCESS - The data was read correctly from the device.
+ EFI_DEVICE_ERROR - The device reported an error while performing the read.
+ EFI_NO_MEDIA - There is no media in the device.
+ EFI_MEDIA_CHANGED - The MediaId does not matched the current device.
+ EFI_BAD_BUFFER_SIZE - The Buffer was not a multiple of the block size of the
+ device.
+ EFI_INVALID_PARAMETER - The read request contains device addresses that are not
+ valid for the device.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_BLOCK_WRITE) (
+ IN EFI_BLOCK_IO_PROTOCOL * This,
+ IN UINT32 MediaId,
+ IN EFI_LBA Lba,
+ IN UINTN BufferSize,
+ IN VOID *Buffer
+ )
+/*++
+
+ Routine Description:
+ Write BufferSize bytes from Lba into Buffer.
+
+ Arguments:
+ This - Protocol instance pointer.
+ MediaId - Id of the media, changes every time the media is replaced.
+ Lba - The starting Logical Block Address to read from
+ BufferSize - Size of Buffer, must be a multiple of device block size.
+ Buffer - Buffer containing read data
+
+ Returns:
+ EFI_SUCCESS - The data was written correctly to the device.
+ EFI_WRITE_PROTECTED - The device can not be written to.
+ EFI_DEVICE_ERROR - The device reported an error while performing the write.
+ EFI_NO_MEDIA - There is no media in the device.
+ EFI_MEDIA_CHNAGED - The MediaId does not matched the current device.
+ EFI_BAD_BUFFER_SIZE - The Buffer was not a multiple of the block size of the
+ device.
+ EFI_INVALID_PARAMETER - The write request contains a LBA that is not
+ valid for the device.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_BLOCK_FLUSH) (
+ IN EFI_BLOCK_IO_PROTOCOL * This
+ )
+/*++
+
+ Routine Description:
+ Flush the Block Device.
+
+ Arguments:
+ This - Protocol instance pointer.
+
+ Returns:
+ EFI_SUCCESS - All outstanding data was written to the device
+ EFI_DEVICE_ERROR - The device reported an error while writting back the data
+ EFI_NO_MEDIA - There is no media in the device.
+
+--*/
+;
+
+/*++
+
+ Block IO read only mode data and updated only via members of BlockIO
+
+ MediaId - The curent media Id. If the media changes, this value is changed.
+ RemovableMedia - TRUE if the media is removable; otherwise, FALSE.
+ MediaPresent - TRUE if there is a media currently present in the device;
+ othersise, FALSE. THis field shows the media present status
+ as of the most recent ReadBlocks() or WriteBlocks() call.
+ LogicalPartition - TRUE if LBA 0 is the first block of a partition; otherwise
+ FALSE. For media with only one partition this would be TRUE.
+ ReadOnly - TRUE if the media is marked read-only otherwise, FALSE. This
+ field shows the read-only status as of the most recent
+ WriteBlocks () call.
+ WriteCaching - TRUE if the WriteBlock () function caches write data.
+ BlockSize - The intrinsic block size of the device. If the media changes, then
+ this field is updated.
+ IoAlign - Supplies the alignment requirement for any buffer to read or write
+ block(s).
+ LastBlock - The last logical block address on the device. If the media changes,
+ then this field is updated.
+
+--*/
+typedef struct {
+ UINT32 MediaId;
+ BOOLEAN RemovableMedia;
+ BOOLEAN MediaPresent;
+
+ BOOLEAN LogicalPartition;
+ BOOLEAN ReadOnly;
+ BOOLEAN WriteCaching;
+
+ UINT32 BlockSize;
+ UINT32 IoAlign;
+
+ EFI_LBA LastBlock;
+
+ EFI_LBA LowestAlignedLba;
+ UINT32 LogicalBlocksPerPhysicalBlock;
+} EFI_BLOCK_IO_MEDIA;
+
+#define EFI_BLOCK_IO_PROTOCOL_REVISION 0x00010000
+#define EFI_BLOCK_IO_PROTOCOL_REVISION2 0x00020001
+
+#define SIZE_OF_EFI_BLOCK_IO_MEDIA_REV1 ((UINTN)&((EFI_BLOCK_IO_MEDIA *)0)->LastBlock + sizeof(EFI_LBA))
+#define SIZE_OF_EFI_BLOCK_IO_MEDIA_REV2 sizeof(EFI_BLOCK_IO_MEDIA)
+
+typedef struct _EFI_BLOCK_IO_PROTOCOL {
+ UINT64 Revision;
+
+ EFI_BLOCK_IO_MEDIA *Media;
+
+ EFI_BLOCK_RESET Reset;
+ EFI_BLOCK_READ ReadBlocks;
+ EFI_BLOCK_WRITE WriteBlocks;
+ EFI_BLOCK_FLUSH FlushBlocks;
+
+} EFI_BLOCK_IO_PROTOCOL;
+
+extern EFI_GUID gEfiBlockIoProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/BusSpecificDriverOverride/BusSpecificDriverOverride.c b/EDK/Foundation/Efi/Protocol/BusSpecificDriverOverride/BusSpecificDriverOverride.c
new file mode 100644
index 0000000..15a5721
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/BusSpecificDriverOverride/BusSpecificDriverOverride.c
@@ -0,0 +1,31 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ BusSpecificDriverOverride.c
+
+Abstract:
+
+ Bus Specific Driver Override protocol as defined in the EFI 1.1 specification.
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (BusSpecificDriverOverride)
+
+EFI_GUID gEfiBusSpecificDriverOverrideProtocolGuid = EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL_GUID;
+
+EFI_GUID_STRING
+ (
+ &gEfiBusSpecificDriverOverrideProtocolGuid, "Bus Specific Driver Override Protocol",
+ "EFI 1.1 Bus Specific Driver Override Protocol"
+ );
diff --git a/EDK/Foundation/Efi/Protocol/BusSpecificDriverOverride/BusSpecificDriverOverride.h b/EDK/Foundation/Efi/Protocol/BusSpecificDriverOverride/BusSpecificDriverOverride.h
new file mode 100644
index 0000000..36a95ba
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/BusSpecificDriverOverride/BusSpecificDriverOverride.h
@@ -0,0 +1,54 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ BusSpecificDriverOverride.h
+
+Abstract:
+
+ Bus Specific Driver Override protocol as defined in the EFI 1.1 specification.
+
+--*/
+
+#ifndef _EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL_H_
+#define _EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL_H_
+
+//
+// Global ID for the Bus Specific Driver Override Protocol
+//
+#define EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL_GUID \
+ { \
+ 0x3bc1b285, 0x8a15, 0x4a82, 0xaa, 0xbf, 0x4d, 0x7d, 0x13, 0xfb, 0x32, 0x65 \
+ }
+
+EFI_FORWARD_DECLARATION (EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL);
+
+//
+// Prototypes for the Bus Specific Driver Override Protocol
+//
+typedef
+EFI_STATUS
+(EFIAPI *EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_GET_DRIVER) (
+ IN EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL * This,
+ IN OUT EFI_HANDLE * DriverImageHandle
+ );
+
+//
+// Interface structure for the Bus Specific Driver Override Protocol
+//
+typedef struct _EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL {
+ EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_GET_DRIVER GetDriver;
+} EFI_BUS_SPECIFIC_DRIVER_OVERRIDE_PROTOCOL;
+
+extern EFI_GUID gEfiBusSpecificDriverOverrideProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/ComponentName/ComponentName.c b/EDK/Foundation/Efi/Protocol/ComponentName/ComponentName.c
new file mode 100644
index 0000000..14471e1
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/ComponentName/ComponentName.c
@@ -0,0 +1,29 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ ComponentName.c
+
+Abstract:
+
+ EFI Component Name Protocol
+
+Revision History
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (ComponentName)
+
+EFI_GUID gEfiComponentNameProtocolGuid = EFI_COMPONENT_NAME_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiComponentNameProtocolGuid, "Component Name Protocol", "EFI 1.1 Component Name Protocol");
diff --git a/EDK/Foundation/Efi/Protocol/ComponentName/ComponentName.h b/EDK/Foundation/Efi/Protocol/ComponentName/ComponentName.h
new file mode 100644
index 0000000..2b94ce5
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/ComponentName/ComponentName.h
@@ -0,0 +1,137 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ ComponentName.h
+
+Abstract:
+
+ EFI Component Name Protocol
+
+Revision History
+
+--*/
+
+#ifndef _EFI_COMPONENT_NAME_H_
+#define _EFI_COMPONENT_NAME_H_
+
+//
+// Global ID for the Component Name Protocol
+//
+#define EFI_COMPONENT_NAME_PROTOCOL_GUID \
+ { \
+ 0x107a772c, 0xd5e1, 0x11d4, 0x9a, 0x46, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d \
+ }
+
+EFI_FORWARD_DECLARATION (EFI_COMPONENT_NAME_PROTOCOL);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_COMPONENT_NAME_GET_DRIVER_NAME) (
+ IN EFI_COMPONENT_NAME_PROTOCOL * This,
+ IN CHAR8 *Language,
+ OUT CHAR16 **DriverName
+ );
+
+/*++
+
+ Routine Description:
+ Retrieves a Unicode string that is the user readable name of the EFI Driver.
+
+ Arguments:
+ This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
+ Language - A pointer to a three character ISO 639-2 language identifier.
+ This is the language of the driver name that that the caller
+ is requesting, and it must match one of the languages specified
+ in SupportedLanguages. The number of languages supported by a
+ driver is up to the driver writer.
+ DriverName - A pointer to the Unicode string to return. This Unicode string
+ is the name of the driver specified by This in the language
+ specified by Language.
+
+ Returns:
+ EFI_SUCCESS - The Unicode string for the Driver specified by This
+ and the language specified by Language was returned
+ in DriverName.
+ EFI_INVALID_PARAMETER - Language is NULL.
+ EFI_INVALID_PARAMETER - DriverName is NULL.
+ EFI_UNSUPPORTED - The driver specified by This does not support the
+ language specified by Language.
+
+--*/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_COMPONENT_NAME_GET_CONTROLLER_NAME) (
+ IN EFI_COMPONENT_NAME_PROTOCOL * This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
+ );
+
+/*++
+
+ Routine Description:
+ Retrieves a Unicode string that is the user readable name of the controller
+ that is being managed by an EFI Driver.
+
+ Arguments:
+ This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
+ ControllerHandle - The handle of a controller that the driver specified by
+ This is managing. This handle specifies the controller
+ whose name is to be returned.
+ ChildHandle - The handle of the child controller to retrieve the name
+ of. This is an optional parameter that may be NULL. It
+ will be NULL for device drivers. It will also be NULL
+ for a bus drivers that wish to retrieve the name of the
+ bus controller. It will not be NULL for a bus driver
+ that wishes to retrieve the name of a child controller.
+ Language - A pointer to a three character ISO 639-2 language
+ identifier. This is the language of the controller name
+ that that the caller is requesting, and it must match one
+ of the languages specified in SupportedLanguages. The
+ number of languages supported by a driver is up to the
+ driver writer.
+ ControllerName - A pointer to the Unicode string to return. This Unicode
+ string is the name of the controller specified by
+ ControllerHandle and ChildHandle in the language specified
+ by Language from the point of view of the driver specified
+ by This.
+
+ Returns:
+ EFI_SUCCESS - The Unicode string for the user readable name in the
+ language specified by Language for the driver
+ specified by This was returned in DriverName.
+ EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.
+ EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE.
+ EFI_INVALID_PARAMETER - Language is NULL.
+ EFI_INVALID_PARAMETER - ControllerName is NULL.
+ EFI_UNSUPPORTED - The driver specified by This is not currently managing
+ the controller specified by ControllerHandle and
+ ChildHandle.
+ EFI_UNSUPPORTED - The driver specified by This does not support the
+ language specified by Language.
+
+--*/
+
+//
+// Interface structure for the Component Name Protocol
+//
+typedef struct _EFI_COMPONENT_NAME_PROTOCOL {
+ EFI_COMPONENT_NAME_GET_DRIVER_NAME GetDriverName;
+ EFI_COMPONENT_NAME_GET_CONTROLLER_NAME GetControllerName;
+ CHAR8 *SupportedLanguages;
+} EFI_COMPONENT_NAME_PROTOCOL;
+
+extern EFI_GUID gEfiComponentNameProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/ComponentName2/ComponentName2.c b/EDK/Foundation/Efi/Protocol/ComponentName2/ComponentName2.c
new file mode 100644
index 0000000..f47ab5b
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/ComponentName2/ComponentName2.c
@@ -0,0 +1,29 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ ComponentName2.c
+
+Abstract:
+
+ EFI Component Name2 Protocol
+
+Revision History
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (ComponentName2)
+
+EFI_GUID gEfiComponentName2ProtocolGuid = EFI_COMPONENT_NAME2_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiComponentName2ProtocolGuid, "Component Name2 Protocol", "UEFI 2.0 Component Name2 Protocol");
diff --git a/EDK/Foundation/Efi/Protocol/ComponentName2/ComponentName2.h b/EDK/Foundation/Efi/Protocol/ComponentName2/ComponentName2.h
new file mode 100644
index 0000000..b42607b
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/ComponentName2/ComponentName2.h
@@ -0,0 +1,136 @@
+/*++
+
+Copyright (c) 2004 - 2008, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ ComponentName2.h
+
+Abstract:
+
+ UEFI Component Name2 Protocol
+
+Revision History
+
+--*/
+
+#ifndef _EFI_COMPONENT_NAME2_H_
+#define _EFI_COMPONENT_NAME2_H_
+
+//
+// Global ID for the Component Name Protocol
+//
+
+#define EFI_COMPONENT_NAME2_PROTOCOL_GUID \
+ { \
+ 0x6a7a5cff, 0xe8d9, 0x4f70, 0xba, 0xda, 0x75, 0xab, 0x30, 0x25, 0xce, 0x14 \
+ }
+
+EFI_FORWARD_DECLARATION (EFI_COMPONENT_NAME2_PROTOCOL);
+
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_COMPONENT_NAME2_GET_DRIVER_NAME) (
+ IN EFI_COMPONENT_NAME2_PROTOCOL * This,
+ IN CHAR8 *Language,
+ OUT CHAR16 **DriverName
+ );
+
+/*++
+
+ Routine Description:
+ Retrieves a Unicode string that is the user readable name of the EFI Driver.
+
+ Arguments:
+ This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
+ Language - A pointer to a three character RFC 3066 language identifier.
+ This is the language of the driver name that that the caller
+ is requesting, and it must match one of the languages specified
+ in SupportedLanguages. The number of languages supported by a
+ driver is up to the driver writer.
+ DriverName - A pointer to the Unicode string to return. This Unicode string
+ is the name of the driver specified by This in the language
+ specified by Language.
+
+ Returns:
+ EFI_SUCCESS - The Unicode string for the Driver specified by This
+ and the language specified by Language was returned
+ in DriverName.
+ EFI_INVALID_PARAMETER - Language is NULL or DriverName is NULL.
+ EFI_UNSUPPORTED - The driver specified by This does not support the
+ language specified by Language.
+
+--*/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME) (
+ IN EFI_COMPONENT_NAME2_PROTOCOL * This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN CHAR8 *Language,
+ OUT CHAR16 **ControllerName
+ );
+
+/*++
+
+ Routine Description:
+ Retrieves a Unicode string that is the user readable name of the controller
+ that is being managed by an EFI Driver.
+
+ Arguments:
+ This - A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
+ ControllerHandle - The handle of a controller that the driver specified by
+ This is managing. This handle specifies the controller
+ whose name is to be returned.
+ ChildHandle - The handle of the child controller to retrieve the name
+ of. This is an optional parameter that may be NULL. It
+ will be NULL for device drivers. It will also be NULL
+ for a bus drivers that wish to retrieve the name of the
+ bus controller. It will not be NULL for a bus driver
+ that wishes to retrieve the name of a child controller.
+ Language - A pointer to a three character RFC 3066 language
+ identifier. This is the language of the controller name
+ that that the caller is requesting, and it must match one
+ of the languages specified in SupportedLanguages. The
+ number of languages supported by a driver is up to the
+ driver writer.
+ ControllerName - A pointer to the Unicode string to return. This Unicode
+ string is the name of the controller specified by
+ ControllerHandle and ChildHandle in the language specified
+ by Language from the point of view of the driver specified
+ by This.
+
+ Returns:
+ EFI_SUCCESS - The Unicode string for the user readable name in the
+ language specified by Language for the driver
+ specified by This was returned in DriverName.
+ EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE; ChildHandle
+ is not NULL and it is not a valid EFI_HANDLE;Language
+ is NULL;ControllerName is NULL.
+ EFI_UNSUPPORTED - The driver specified by This is not currently managing
+ the controller specified by ControllerHandle and
+ ChildHandle;The driver specified by This does not support the
+ language specified by Language.
+
+--*/
+
+//
+// Interface structure for the Component Name Protocol
+//
+typedef struct _EFI_COMPONENT_NAME2_PROTOCOL {
+ EFI_COMPONENT_NAME2_GET_DRIVER_NAME GetDriverName;
+ EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME GetControllerName;
+ CHAR8 *SupportedLanguages;
+} EFI_COMPONENT_NAME2_PROTOCOL;
+
+extern EFI_GUID gEfiComponentName2ProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/DebugPort/DebugPort.c b/EDK/Foundation/Efi/Protocol/DebugPort/DebugPort.c
new file mode 100644
index 0000000..6efef15
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/DebugPort/DebugPort.c
@@ -0,0 +1,27 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ DebugPort.c
+
+Abstract:
+
+ DebugPort protocol as defined in the EFI 1.1 specification.
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (DebugPort)
+
+EFI_GUID gEfiDebugPortProtocolGuid = EFI_DEBUGPORT_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiDebugPortProtocolGuid, "DebugPort Protocol", "EFI 1.1 DebugPort Protocol");
diff --git a/EDK/Foundation/Efi/Protocol/DebugPort/DebugPort.h b/EDK/Foundation/Efi/Protocol/DebugPort/DebugPort.h
new file mode 100644
index 0000000..6d2e1c9
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/DebugPort/DebugPort.h
@@ -0,0 +1,98 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ DebugPort.h
+
+Abstract:
+
+--*/
+
+#ifndef _DEBUG_PORT_H_
+#define _DEBUG_PORT_H_
+
+#include "EfiApi.h"
+
+//
+// DebugPortIo protocol {EBA4E8D2-3858-41EC-A281-2647BA9660D0}
+//
+#define EFI_DEBUGPORT_PROTOCOL_GUID \
+ { \
+ 0xEBA4E8D2, 0x3858, 0x41EC, 0xA2, 0x81, 0x26, 0x47, 0xBA, 0x96, 0x60, 0xD0 \
+ }
+
+extern EFI_GUID gEfiDebugPortProtocolGuid;
+
+EFI_FORWARD_DECLARATION (EFI_DEBUGPORT_PROTOCOL);
+
+//
+// DebugPort member functions
+//
+typedef
+EFI_STATUS
+(EFIAPI *EFI_DEBUGPORT_RESET) (
+ IN EFI_DEBUGPORT_PROTOCOL * This
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_DEBUGPORT_WRITE) (
+ IN EFI_DEBUGPORT_PROTOCOL * This,
+ IN UINT32 Timeout,
+ IN OUT UINTN *BufferSize,
+ IN VOID *Buffer
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_DEBUGPORT_READ) (
+ IN EFI_DEBUGPORT_PROTOCOL * This,
+ IN UINT32 Timeout,
+ IN OUT UINTN *BufferSize,
+ OUT VOID *Buffer
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_DEBUGPORT_POLL) (
+ IN EFI_DEBUGPORT_PROTOCOL * This
+ );
+
+//
+// DebugPort protocol definition
+//
+typedef struct _EFI_DEBUGPORT_PROTOCOL {
+ EFI_DEBUGPORT_RESET Reset;
+ EFI_DEBUGPORT_WRITE Write;
+ EFI_DEBUGPORT_READ Read;
+ EFI_DEBUGPORT_POLL Poll;
+} EFI_DEBUGPORT_PROTOCOL;
+
+//
+// DEBUGPORT variable definitions...
+//
+#define EFI_DEBUGPORT_VARIABLE_NAME L"DEBUGPORT"
+#define EFI_DEBUGPORT_VARIABLE_GUID EFI_DEBUGPORT_PROTOCOL_GUID
+#define gEfiDebugPortVariableGuid gEfiDebugPortProtocolGuid
+
+//
+// DebugPort device path definitions...
+//
+#define DEVICE_PATH_MESSAGING_DEBUGPORT EFI_DEBUGPORT_PROTOCOL_GUID
+#define gEfiDebugPortDevicePathGuid gEfiDebugPortProtocolGuid
+
+typedef struct {
+ EFI_DEVICE_PATH_PROTOCOL Header;
+ EFI_GUID Guid;
+} DEBUGPORT_DEVICE_PATH;
+
+#endif /* _DEBUG_PORT_H_ */
diff --git a/EDK/Foundation/Efi/Protocol/DebugSupport/DebugSupport.c b/EDK/Foundation/Efi/Protocol/DebugSupport/DebugSupport.c
new file mode 100644
index 0000000..c073f68
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/DebugSupport/DebugSupport.c
@@ -0,0 +1,27 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ DebugSupport.c
+
+Abstract:
+
+ DebugSupport protocol as defined in the EFI 1.1 specification.
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (DebugSupport)
+
+EFI_GUID gEfiDebugSupportProtocolGuid = EFI_DEBUG_SUPPORT_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiDebugSupportProtocolGuid, "DebugSupport Protocol", "EFI 1.1 DebugSupport Protocol");
diff --git a/EDK/Foundation/Efi/Protocol/DebugSupport/DebugSupport.h b/EDK/Foundation/Efi/Protocol/DebugSupport/DebugSupport.h
new file mode 100644
index 0000000..345d232
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/DebugSupport/DebugSupport.h
@@ -0,0 +1,594 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ DebugSupport.h
+
+Abstract:
+
+ DebugSupport protocol and supporting definitions as defined in the EFI 1.1
+ specification.
+
+ The DebugSupport protocol is used by source level debuggers to abstract the
+ processor and handle context save and restore operations.
+
+--*/
+
+#ifndef _DEBUG_SUPPORT_H_
+#define _DEBUG_SUPPORT_H_
+
+#include "EfiApi.h"
+#include "EfiImage.h"
+//
+// Debug Support protocol {2755590C-6F3C-42FA-9EA4-A3BA543CDA25}
+//
+#define EFI_DEBUG_SUPPORT_PROTOCOL_GUID \
+ { \
+ 0x2755590C, 0x6F3C, 0x42FA, 0x9E, 0xA4, 0xA3, 0xBA, 0x54, 0x3C, 0xDA, 0x25 \
+ }
+
+//
+// Debug Support definitions
+//
+typedef INTN EFI_EXCEPTION_TYPE;
+
+//
+// IA-32 processor exception types
+//
+#define EXCEPT_IA32_DIVIDE_ERROR 0
+#define EXCEPT_IA32_DEBUG 1
+#define EXCEPT_IA32_NMI 2
+#define EXCEPT_IA32_BREAKPOINT 3
+#define EXCEPT_IA32_OVERFLOW 4
+#define EXCEPT_IA32_BOUND 5
+#define EXCEPT_IA32_INVALID_OPCODE 6
+#define EXCEPT_IA32_DOUBLE_FAULT 8
+#define EXCEPT_IA32_INVALID_TSS 10
+#define EXCEPT_IA32_SEG_NOT_PRESENT 11
+#define EXCEPT_IA32_STACK_FAULT 12
+#define EXCEPT_IA32_GP_FAULT 13
+#define EXCEPT_IA32_PAGE_FAULT 14
+#define EXCEPT_IA32_FP_ERROR 16
+#define EXCEPT_IA32_ALIGNMENT_CHECK 17
+#define EXCEPT_IA32_MACHINE_CHECK 18
+#define EXCEPT_IA32_SIMD 19
+
+//
+// IA-32 processor context definition
+//
+//
+// FXSAVE_STATE
+// FP / MMX / XMM registers (see fxrstor instruction definition)
+//
+typedef struct {
+ UINT16 Fcw;
+ UINT16 Fsw;
+ UINT16 Ftw;
+ UINT16 Opcode;
+ UINT32 Eip;
+ UINT16 Cs;
+ UINT16 Reserved1;
+ UINT32 DataOffset;
+ UINT16 Ds;
+ UINT8 Reserved2[10];
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+ UINT8 St0Mm0[10], Reserved3[6];
+ UINT8 St1Mm1[10], Reserved4[6];
+ UINT8 St2Mm2[10], Reserved5[6];
+ UINT8 St3Mm3[10], Reserved6[6];
+ UINT8 St4Mm4[10], Reserved7[6];
+ UINT8 St5Mm5[10], Reserved8[6];
+ UINT8 St6Mm6[10], Reserved9[6];
+ UINT8 St7Mm7[10], Reserved10[6];
+ UINT8 Xmm0[16];
+ UINT8 Xmm1[16];
+ UINT8 Xmm2[16];
+ UINT8 Xmm3[16];
+ UINT8 Xmm4[16];
+ UINT8 Xmm5[16];
+ UINT8 Xmm6[16];
+ UINT8 Xmm7[16];
+ UINT8 Reserved11[14 * 16];
+} EFI_FX_SAVE_STATE_IA32;
+#else
+ UINT8 St0Mm0[10], Reserved3[6];
+ UINT8 St0Mm1[10], Reserved4[6];
+ UINT8 St0Mm2[10], Reserved5[6];
+ UINT8 St0Mm3[10], Reserved6[6];
+ UINT8 St0Mm4[10], Reserved7[6];
+ UINT8 St0Mm5[10], Reserved8[6];
+ UINT8 St0Mm6[10], Reserved9[6];
+ UINT8 St0Mm7[10], Reserved10[6];
+ UINT8 Reserved11[22 * 16];
+} EFI_FX_SAVE_STATE;
+#endif
+
+typedef struct {
+ UINT32 ExceptionData;
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+ EFI_FX_SAVE_STATE_IA32 FxSaveState;
+#else
+ EFI_FX_SAVE_STATE FxSaveState;
+#endif
+ UINT32 Dr0;
+ UINT32 Dr1;
+ UINT32 Dr2;
+ UINT32 Dr3;
+ UINT32 Dr6;
+ UINT32 Dr7;
+ UINT32 Cr0;
+ UINT32 Cr1; /* Reserved */
+ UINT32 Cr2;
+ UINT32 Cr3;
+ UINT32 Cr4;
+ UINT32 Eflags;
+ UINT32 Ldtr;
+ UINT32 Tr;
+ UINT32 Gdtr[2];
+ UINT32 Idtr[2];
+ UINT32 Eip;
+ UINT32 Gs;
+ UINT32 Fs;
+ UINT32 Es;
+ UINT32 Ds;
+ UINT32 Cs;
+ UINT32 Ss;
+ UINT32 Edi;
+ UINT32 Esi;
+ UINT32 Ebp;
+ UINT32 Esp;
+ UINT32 Ebx;
+ UINT32 Edx;
+ UINT32 Ecx;
+ UINT32 Eax;
+} EFI_SYSTEM_CONTEXT_IA32;
+
+//
+// X64 processor exception types
+//
+#define EXCEPT_X64_DIVIDE_ERROR 0
+#define EXCEPT_X64_DEBUG 1
+#define EXCEPT_X64_NMI 2
+#define EXCEPT_X64_BREAKPOINT 3
+#define EXCEPT_X64_OVERFLOW 4
+#define EXCEPT_X64_BOUND 5
+#define EXCEPT_X64_INVALID_OPCODE 6
+#define EXCEPT_X64_DOUBLE_FAULT 8
+#define EXCEPT_X64_INVALID_TSS 10
+#define EXCEPT_X64_SEG_NOT_PRESENT 11
+#define EXCEPT_X64_STACK_FAULT 12
+#define EXCEPT_X64_GP_FAULT 13
+#define EXCEPT_X64_PAGE_FAULT 14
+#define EXCEPT_X64_FP_ERROR 16
+#define EXCEPT_X64_ALIGNMENT_CHECK 17
+#define EXCEPT_X64_MACHINE_CHECK 18
+#define EXCEPT_X64_SIMD 19
+
+//
+// X64 processor context definition
+//
+// FXSAVE_STATE
+// FP / MMX / XMM registers (see fxrstor instruction definition)
+//
+typedef struct {
+ UINT16 Fcw;
+ UINT16 Fsw;
+ UINT16 Ftw;
+ UINT16 Opcode;
+ UINT64 Rip;
+ UINT64 DataOffset;
+ UINT8 Reserved1[8];
+ UINT8 St0Mm0[10], Reserved2[6];
+ UINT8 St1Mm1[10], Reserved3[6];
+ UINT8 St2Mm2[10], Reserved4[6];
+ UINT8 St3Mm3[10], Reserved5[6];
+ UINT8 St4Mm4[10], Reserved6[6];
+ UINT8 St5Mm5[10], Reserved7[6];
+ UINT8 St6Mm6[10], Reserved8[6];
+ UINT8 St7Mm7[10], Reserved9[6];
+ UINT8 Xmm0[16];
+ UINT8 Xmm1[16];
+ UINT8 Xmm2[16];
+ UINT8 Xmm3[16];
+ UINT8 Xmm4[16];
+ UINT8 Xmm5[16];
+ UINT8 Xmm6[16];
+ UINT8 Xmm7[16];
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+ //
+ // NOTE: UEFI 2.0 spec definition as follows. It should be updated
+ // after spec update.
+ //
+ UINT8 Reserved11[14 * 16];
+#else
+ UINT8 Xmm8[16];
+ UINT8 Xmm9[16];
+ UINT8 Xmm10[16];
+ UINT8 Xmm11[16];
+ UINT8 Xmm12[16];
+ UINT8 Xmm13[16];
+ UINT8 Xmm14[16];
+ UINT8 Xmm15[16];
+ UINT8 Reserved10[6 * 16];
+#endif
+} EFI_FX_SAVE_STATE_X64;
+
+typedef struct {
+ UINT64 ExceptionData;
+ EFI_FX_SAVE_STATE_X64 FxSaveState;
+ UINT64 Dr0;
+ UINT64 Dr1;
+ UINT64 Dr2;
+ UINT64 Dr3;
+ UINT64 Dr6;
+ UINT64 Dr7;
+ UINT64 Cr0;
+ UINT64 Cr1; /* Reserved */
+ UINT64 Cr2;
+ UINT64 Cr3;
+ UINT64 Cr4;
+ UINT64 Cr8;
+ UINT64 Rflags;
+ UINT64 Ldtr;
+ UINT64 Tr;
+ UINT64 Gdtr[2];
+ UINT64 Idtr[2];
+ UINT64 Rip;
+ UINT64 Gs;
+ UINT64 Fs;
+ UINT64 Es;
+ UINT64 Ds;
+ UINT64 Cs;
+ UINT64 Ss;
+ UINT64 Rdi;
+ UINT64 Rsi;
+ UINT64 Rbp;
+ UINT64 Rsp;
+ UINT64 Rbx;
+ UINT64 Rdx;
+ UINT64 Rcx;
+ UINT64 Rax;
+ UINT64 R8;
+ UINT64 R9;
+ UINT64 R10;
+ UINT64 R11;
+ UINT64 R12;
+ UINT64 R13;
+ UINT64 R14;
+ UINT64 R15;
+} EFI_SYSTEM_CONTEXT_X64;
+
+//
+// IPF processor exception types
+//
+#define EXCEPT_IPF_VHTP_TRANSLATION 0
+#define EXCEPT_IPF_INSTRUCTION_TLB 1
+#define EXCEPT_IPF_DATA_TLB 2
+#define EXCEPT_IPF_ALT_INSTRUCTION_TLB 3
+#define EXCEPT_IPF_ALT_DATA_TLB 4
+#define EXCEPT_IPF_DATA_NESTED_TLB 5
+#define EXCEPT_IPF_INSTRUCTION_KEY_MISSED 6
+#define EXCEPT_IPF_DATA_KEY_MISSED 7
+#define EXCEPT_IPF_DIRTY_BIT 8
+#define EXCEPT_IPF_INSTRUCTION_ACCESS_BIT 9
+#define EXCEPT_IPF_DATA_ACCESS_BIT 10
+#define EXCEPT_IPF_BREAKPOINT 11
+#define EXCEPT_IPF_EXTERNAL_INTERRUPT 12
+//
+// 13 - 19 reserved
+//
+#define EXCEPT_IPF_PAGE_NOT_PRESENT 20
+#define EXCEPT_IPF_KEY_PERMISSION 21
+#define EXCEPT_IPF_INSTRUCTION_ACCESS_RIGHTS 22
+#define EXCEPT_IPF_DATA_ACCESS_RIGHTS 23
+#define EXCEPT_IPF_GENERAL_EXCEPTION 24
+#define EXCEPT_IPF_DISABLED_FP_REGISTER 25
+#define EXCEPT_IPF_NAT_CONSUMPTION 26
+#define EXCEPT_IPF_SPECULATION 27
+//
+// 28 reserved
+//
+#define EXCEPT_IPF_DEBUG 29
+#define EXCEPT_IPF_UNALIGNED_REFERENCE 30
+#define EXCEPT_IPF_UNSUPPORTED_DATA_REFERENCE 31
+#define EXCEPT_IPF_FP_FAULT 32
+#define EXCEPT_IPF_FP_TRAP 33
+#define EXCEPT_IPF_LOWER_PRIVILEGE_TRANSFER_TRAP 34
+#define EXCEPT_IPF_TAKEN_BRANCH 35
+#define EXCEPT_IPF_SINGLE_STEP 36
+//
+// 37 - 44 reserved
+//
+#define EXCEPT_IPF_IA32_EXCEPTION 45
+#define EXCEPT_IPF_IA32_INTERCEPT 46
+#define EXCEPT_IPF_IA32_INTERRUPT 47
+
+//
+// IPF processor context definition
+//
+typedef struct {
+ //
+ // The first reserved field is necessary to preserve alignment for the correct
+ // bits in UNAT and to insure F2 is 16 byte aligned..
+ //
+ UINT64 Reserved;
+ UINT64 R1;
+ UINT64 R2;
+ UINT64 R3;
+ UINT64 R4;
+ UINT64 R5;
+ UINT64 R6;
+ UINT64 R7;
+ UINT64 R8;
+ UINT64 R9;
+ UINT64 R10;
+ UINT64 R11;
+ UINT64 R12;
+ UINT64 R13;
+ UINT64 R14;
+ UINT64 R15;
+ UINT64 R16;
+ UINT64 R17;
+ UINT64 R18;
+ UINT64 R19;
+ UINT64 R20;
+ UINT64 R21;
+ UINT64 R22;
+ UINT64 R23;
+ UINT64 R24;
+ UINT64 R25;
+ UINT64 R26;
+ UINT64 R27;
+ UINT64 R28;
+ UINT64 R29;
+ UINT64 R30;
+ UINT64 R31;
+
+ UINT64 F2[2];
+ UINT64 F3[2];
+ UINT64 F4[2];
+ UINT64 F5[2];
+ UINT64 F6[2];
+ UINT64 F7[2];
+ UINT64 F8[2];
+ UINT64 F9[2];
+ UINT64 F10[2];
+ UINT64 F11[2];
+ UINT64 F12[2];
+ UINT64 F13[2];
+ UINT64 F14[2];
+ UINT64 F15[2];
+ UINT64 F16[2];
+ UINT64 F17[2];
+ UINT64 F18[2];
+ UINT64 F19[2];
+ UINT64 F20[2];
+ UINT64 F21[2];
+ UINT64 F22[2];
+ UINT64 F23[2];
+ UINT64 F24[2];
+ UINT64 F25[2];
+ UINT64 F26[2];
+ UINT64 F27[2];
+ UINT64 F28[2];
+ UINT64 F29[2];
+ UINT64 F30[2];
+ UINT64 F31[2];
+
+ UINT64 Pr;
+
+ UINT64 B0;
+ UINT64 B1;
+ UINT64 B2;
+ UINT64 B3;
+ UINT64 B4;
+ UINT64 B5;
+ UINT64 B6;
+ UINT64 B7;
+
+ //
+ // application registers
+ //
+ UINT64 ArRsc;
+ UINT64 ArBsp;
+ UINT64 ArBspstore;
+ UINT64 ArRnat;
+
+ UINT64 ArFcr;
+
+ UINT64 ArEflag;
+ UINT64 ArCsd;
+ UINT64 ArSsd;
+ UINT64 ArCflg;
+ UINT64 ArFsr;
+ UINT64 ArFir;
+ UINT64 ArFdr;
+
+ UINT64 ArCcv;
+
+ UINT64 ArUnat;
+
+ UINT64 ArFpsr;
+
+ UINT64 ArPfs;
+ UINT64 ArLc;
+ UINT64 ArEc;
+
+ //
+ // control registers
+ //
+ UINT64 CrDcr;
+ UINT64 CrItm;
+ UINT64 CrIva;
+ UINT64 CrPta;
+ UINT64 CrIpsr;
+ UINT64 CrIsr;
+ UINT64 CrIip;
+ UINT64 CrIfa;
+ UINT64 CrItir;
+ UINT64 CrIipa;
+ UINT64 CrIfs;
+ UINT64 CrIim;
+ UINT64 CrIha;
+
+ //
+ // debug registers
+ //
+ UINT64 Dbr0;
+ UINT64 Dbr1;
+ UINT64 Dbr2;
+ UINT64 Dbr3;
+ UINT64 Dbr4;
+ UINT64 Dbr5;
+ UINT64 Dbr6;
+ UINT64 Dbr7;
+
+ UINT64 Ibr0;
+ UINT64 Ibr1;
+ UINT64 Ibr2;
+ UINT64 Ibr3;
+ UINT64 Ibr4;
+ UINT64 Ibr5;
+ UINT64 Ibr6;
+ UINT64 Ibr7;
+
+ //
+ // virtual registers - nat bits for R1-R31
+ //
+ UINT64 IntNat;
+
+} EFI_SYSTEM_CONTEXT_IPF;
+
+//
+// EBC processor exception types
+//
+#define EXCEPT_EBC_UNDEFINED 0
+#define EXCEPT_EBC_DIVIDE_ERROR 1
+#define EXCEPT_EBC_DEBUG 2
+#define EXCEPT_EBC_BREAKPOINT 3
+#define EXCEPT_EBC_OVERFLOW 4
+#define EXCEPT_EBC_INVALID_OPCODE 5 // opcode out of range
+#define EXCEPT_EBC_STACK_FAULT 6
+#define EXCEPT_EBC_ALIGNMENT_CHECK 7
+#define EXCEPT_EBC_INSTRUCTION_ENCODING 8 // malformed instruction
+#define EXCEPT_EBC_BAD_BREAK 9 // BREAK 0 or undefined BREAK
+#define EXCEPT_EBC_STEP 10 // to support debug stepping
+//
+// For coding convenience, define the maximum valid EBC exception.
+//
+#define MAX_EBC_EXCEPTION EXCEPT_EBC_STEP
+
+//
+// EBC processor context definition
+//
+typedef struct {
+ UINT64 R0;
+ UINT64 R1;
+ UINT64 R2;
+ UINT64 R3;
+ UINT64 R4;
+ UINT64 R5;
+ UINT64 R6;
+ UINT64 R7;
+ UINT64 Flags;
+ UINT64 ControlFlags;
+ UINT64 Ip;
+} EFI_SYSTEM_CONTEXT_EBC;
+
+//
+// Universal EFI_SYSTEM_CONTEXT definition
+//
+typedef union {
+ EFI_SYSTEM_CONTEXT_EBC *SystemContextEbc;
+ EFI_SYSTEM_CONTEXT_IA32 *SystemContextIa32;
+ EFI_SYSTEM_CONTEXT_X64 *SystemContextX64;
+ EFI_SYSTEM_CONTEXT_IPF *SystemContextIpf;
+} EFI_SYSTEM_CONTEXT;
+
+//
+// DebugSupport callback function prototypes
+//
+typedef
+VOID
+(*EFI_EXCEPTION_CALLBACK) (
+ IN EFI_EXCEPTION_TYPE ExceptionType,
+ IN OUT EFI_SYSTEM_CONTEXT SystemContext
+ );
+
+typedef
+VOID
+(*EFI_PERIODIC_CALLBACK) (
+ IN OUT EFI_SYSTEM_CONTEXT SystemContext
+ );
+
+//
+// Machine type definition
+//
+typedef enum {
+ IsaIa32 = EFI_IMAGE_MACHINE_IA32,
+ IsaX64 = EFI_IMAGE_MACHINE_X64,
+ IsaIpf = EFI_IMAGE_MACHINE_IA64,
+ IsaEbc = EFI_IMAGE_MACHINE_EBC
+} EFI_INSTRUCTION_SET_ARCHITECTURE;
+
+EFI_FORWARD_DECLARATION (EFI_DEBUG_SUPPORT_PROTOCOL);
+
+//
+// DebugSupport member function definitions
+//
+typedef
+EFI_STATUS
+(EFIAPI *EFI_GET_MAXIMUM_PROCESSOR_INDEX) (
+ IN EFI_DEBUG_SUPPORT_PROTOCOL * This,
+ OUT UINTN *MaxProcessorIndex
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_REGISTER_PERIODIC_CALLBACK) (
+ IN EFI_DEBUG_SUPPORT_PROTOCOL * This,
+ IN UINTN ProcessorIndex,
+ IN EFI_PERIODIC_CALLBACK PeriodicCallback
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_REGISTER_EXCEPTION_CALLBACK) (
+ IN EFI_DEBUG_SUPPORT_PROTOCOL * This,
+ IN UINTN ProcessorIndex,
+ IN EFI_EXCEPTION_CALLBACK ExceptionCallback,
+ IN EFI_EXCEPTION_TYPE ExceptionType
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_INVALIDATE_INSTRUCTION_CACHE) (
+ IN EFI_DEBUG_SUPPORT_PROTOCOL * This,
+ IN UINTN ProcessorIndex,
+ IN VOID *Start,
+ IN UINT64 Length
+ );
+
+//
+// DebugSupport protocol definition
+//
+typedef struct _EFI_DEBUG_SUPPORT_PROTOCOL {
+ EFI_INSTRUCTION_SET_ARCHITECTURE Isa;
+ EFI_GET_MAXIMUM_PROCESSOR_INDEX GetMaximumProcessorIndex;
+ EFI_REGISTER_PERIODIC_CALLBACK RegisterPeriodicCallback;
+ EFI_REGISTER_EXCEPTION_CALLBACK RegisterExceptionCallback;
+ EFI_INVALIDATE_INSTRUCTION_CACHE InvalidateInstructionCache;
+} EFI_DEBUG_SUPPORT_PROTOCOL;
+
+extern EFI_GUID gEfiDebugSupportProtocolGuid;
+
+#endif /* _DEBUG_SUPPORT_H_ */
diff --git a/EDK/Foundation/Efi/Protocol/Decompress/Decompress.c b/EDK/Foundation/Efi/Protocol/Decompress/Decompress.c
new file mode 100644
index 0000000..c91d1f7
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/Decompress/Decompress.c
@@ -0,0 +1,27 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Decompress.c
+
+Abstract:
+
+ The GUID for the EFI Decompress Protocol
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (Decompress)
+
+EFI_GUID gEfiDecompressProtocolGuid = EFI_DECOMPRESS_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiDecompressProtocolGuid, "Decompress", "Decompression Protocol");
diff --git a/EDK/Foundation/Efi/Protocol/Decompress/Decompress.h b/EDK/Foundation/Efi/Protocol/Decompress/Decompress.h
new file mode 100644
index 0000000..73165ad
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/Decompress/Decompress.h
@@ -0,0 +1,140 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Decompress.h
+
+Abstract:
+
+ The Decompress Protocol Interface
+
+--*/
+
+#ifndef _DECOMPRESS_H_
+#define _DECOMPRESS_H_
+
+#define EFI_DECOMPRESS_PROTOCOL_GUID \
+ { \
+ 0xd8117cfe, 0x94a6, 0x11d4, 0x9a, 0x3a, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d \
+ }
+
+EFI_FORWARD_DECLARATION (EFI_DECOMPRESS_PROTOCOL);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_DECOMPRESS_GET_INFO) (
+ IN EFI_DECOMPRESS_PROTOCOL * This,
+ IN VOID *Source,
+ IN UINT32 SourceSize,
+ OUT UINT32 *DestinationSize,
+ OUT UINT32 *ScratchSize
+ );
+
+/*++
+
+Routine Description:
+
+ The GetInfo() function retrieves the size of the uncompressed buffer
+ and the temporary scratch buffer required to decompress the buffer
+ specified by Source and SourceSize. If the size of the uncompressed
+ buffer or the size of the scratch buffer cannot be determined from
+ the compressed data specified by Source and SourceData, then
+ EFI_INVALID_PARAMETER is returned. Otherwise, the size of the uncompressed
+ buffer is returned in DestinationSize, the size of the scratch buffer is
+ returned in ScratchSize, and EFI_SUCCESS is returned.
+
+ The GetInfo() function does not have scratch buffer available to perform
+ a thorough checking of the validity of the source data. It just retrieves
+ the 'Original Size' field from the beginning bytes of the source data and
+ output it as DestinationSize. And ScratchSize is specific to the decompression
+ implementation.
+
+Arguments:
+
+ This - The protocol instance pointer
+ Source - The source buffer containing the compressed data.
+ SourceSize - The size, in bytes, of source buffer.
+ DestinationSize - A pointer to the size, in bytes, of the uncompressed buffer
+ that will be generated when the compressed buffer specified
+ by Source and SourceSize is decompressed.
+ ScratchSize - A pointer to the size, in bytes, of the scratch buffer that
+ is required to decompress the compressed buffer specified by
+ Source and SourceSize.
+
+Returns:
+ EFI_SUCCESS - The size of the uncompressed data was returned in DestinationSize
+ and the size of the scratch buffer was returned in ScratchSize.
+ EFI_INVALID_PARAMETER - The size of the uncompressed data or the size of the scratch
+ buffer cannot be determined from the compressed data specified by
+ Source and SourceData.
+
+--*/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_DECOMPRESS_DECOMPRESS) (
+ IN EFI_DECOMPRESS_PROTOCOL * This,
+ IN VOID *Source,
+ IN UINT32 SourceSize,
+ IN OUT VOID *Destination,
+ IN UINT32 DestinationSize,
+ IN OUT VOID *Scratch,
+ IN UINT32 ScratchSize
+ );
+
+/*++
+
+Routine Description:
+
+ The Decompress() function extracts decompressed data to its original form.
+
+ This protocol is designed so that the decompression algorithm can be
+ implemented without using any memory services. As a result, the
+ Decompress() function is not allowed to call AllocatePool() or
+ AllocatePages() in its implementation. It is the caller's responsibility
+ to allocate and free the Destination and Scratch buffers.
+
+ If the compressed source data specified by Source and SourceSize is
+ sucessfully decompressed into Destination, then EFI_SUCCESS is returned.
+ If the compressed source data specified by Source and SourceSize is not in
+ a valid compressed data format, then EFI_INVALID_PARAMETER is returned.
+
+Arguments:
+
+ This - The protocol instance pointer
+ Source - The source buffer containing the compressed data.
+ SourceSize - The size of source data.
+ Destination - On output, the destination buffer that contains
+ the uncompressed data.
+ DestinationSize - The size of destination buffer. The size of destination
+ buffer needed is obtained from GetInfo().
+ Scratch - A temporary scratch buffer that is used to perform the
+ decompression.
+ ScratchSize - The size of scratch buffer. The size of scratch buffer needed
+ is obtained from GetInfo().
+
+Returns:
+
+ EFI_SUCCESS - Decompression completed successfully, and the uncompressed
+ buffer is returned in Destination.
+ EFI_INVALID_PARAMETER
+ - The source buffer specified by Source and SourceSize is
+ corrupted (not in a valid compressed format).
+
+--*/
+typedef struct _EFI_DECOMPRESS_PROTOCOL {
+ EFI_DECOMPRESS_GET_INFO GetInfo;
+ EFI_DECOMPRESS_DECOMPRESS Decompress;
+} EFI_DECOMPRESS_PROTOCOL;
+
+extern EFI_GUID gEfiDecompressProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/DeviceIO/DeviceIO.c b/EDK/Foundation/Efi/Protocol/DeviceIO/DeviceIO.c
new file mode 100644
index 0000000..27476a7
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/DeviceIO/DeviceIO.c
@@ -0,0 +1,31 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ DeviceIo.c
+
+Abstract:
+
+ Device IO protocol as defined in the EFI 1.0 specification.
+
+ Device IO is used to abstract hardware access to devices. It includes
+ memory mapped IO, IO, PCI Config space, and DMA.
+
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (DeviceIo)
+
+EFI_GUID gEfiDeviceIoProtocolGuid = EFI_DEVICE_IO_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiDeviceIoProtocolGuid, "DeviceIo Protocol", "EFI 1.0 Device IO Protocol");
diff --git a/EDK/Foundation/Efi/Protocol/DeviceIO/DeviceIO.h b/EDK/Foundation/Efi/Protocol/DeviceIO/DeviceIO.h
new file mode 100644
index 0000000..c0a30e3
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/DeviceIO/DeviceIO.h
@@ -0,0 +1,132 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ DeviceIo.h
+
+Abstract:
+
+ Device IO protocol as defined in the EFI 1.0 specification.
+
+ Device IO is used to abstract hardware access to devices. It includes
+ memory mapped IO, IO, PCI Config space, and DMA.
+
+
+--*/
+
+#ifndef _DEVICE_IO_H_
+#define _DEVICE_IO_H_
+
+#define EFI_DEVICE_IO_PROTOCOL_GUID \
+ { \
+ 0xaf6ac311, 0x84c3, 0x11d2, 0x8e, 0x3c, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b \
+ }
+
+EFI_FORWARD_DECLARATION (EFI_DEVICE_IO_PROTOCOL);
+
+typedef enum {
+ IO_UINT8,
+ IO_UINT16,
+ IO_UINT32,
+ IO_UINT64,
+ MMIO_COPY_UINT8,
+ MMIO_COPY_UINT16,
+ MMIO_COPY_UINT32,
+ MMIO_COPY_UINT64
+} EFI_IO_WIDTH;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_DEVICE_IO) (
+ IN EFI_DEVICE_IO_PROTOCOL * This,
+ IN EFI_IO_WIDTH Width,
+ IN UINT64 Address,
+ IN UINTN Count,
+ IN OUT VOID *Buffer
+ );
+
+typedef struct {
+ EFI_DEVICE_IO Read;
+ EFI_DEVICE_IO Write;
+} EFI_IO_ACCESS;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PCI_DEVICE_PATH) (
+ IN EFI_DEVICE_IO_PROTOCOL * This,
+ IN UINT64 Address,
+ IN OUT EFI_DEVICE_PATH_PROTOCOL **PciDevicePath
+ );
+
+typedef enum {
+ EfiBusMasterRead,
+ EfiBusMasterWrite,
+ EfiBusMasterCommonBuffer
+} EFI_IO_OPERATION_TYPE;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_IO_MAP) (
+ IN EFI_DEVICE_IO_PROTOCOL * This,
+ IN EFI_IO_OPERATION_TYPE Operation,
+ IN EFI_PHYSICAL_ADDRESS * HostAddress,
+ IN OUT UINTN *NumberOfBytes,
+ OUT EFI_PHYSICAL_ADDRESS * DeviceAddress,
+ OUT VOID **Mapping
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_IO_UNMAP) (
+ IN EFI_DEVICE_IO_PROTOCOL * This,
+ IN VOID *Mapping
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_IO_ALLOCATE_BUFFER) (
+ IN EFI_DEVICE_IO_PROTOCOL * This,
+ IN EFI_ALLOCATE_TYPE Type,
+ IN EFI_MEMORY_TYPE MemoryType,
+ IN UINTN Pages,
+ IN OUT EFI_PHYSICAL_ADDRESS * HostAddress
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_IO_FLUSH) (
+ IN EFI_DEVICE_IO_PROTOCOL * This
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_IO_FREE_BUFFER) (
+ IN EFI_DEVICE_IO_PROTOCOL * This,
+ IN UINTN Pages,
+ IN EFI_PHYSICAL_ADDRESS HostAddress
+ );
+
+typedef struct _EFI_DEVICE_IO_PROTOCOL {
+ EFI_IO_ACCESS Mem;
+ EFI_IO_ACCESS Io;
+ EFI_IO_ACCESS Pci;
+ EFI_IO_MAP Map;
+ EFI_PCI_DEVICE_PATH PciDevicePath;
+ EFI_IO_UNMAP Unmap;
+ EFI_IO_ALLOCATE_BUFFER AllocateBuffer;
+ EFI_IO_FLUSH Flush;
+ EFI_IO_FREE_BUFFER FreeBuffer;
+} EFI_DEVICE_IO_PROTOCOL;
+
+extern EFI_GUID gEfiDeviceIoProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/DevicePath/DevicePath.c b/EDK/Foundation/Efi/Protocol/DevicePath/DevicePath.c
new file mode 100644
index 0000000..71b58a1
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/DevicePath/DevicePath.c
@@ -0,0 +1,32 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ DevicePath.c
+
+Abstract:
+
+ The device path protocol as defined in EFI 1.0.
+
+ The device path represents a programatic path to a device. It's the view
+ from a software point of view. It also must persist from boot to boot, so
+ it can not contain things like PCI bus numbers that change from boot to boot.
+
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (DevicePath)
+
+EFI_GUID gEfiDevicePathProtocolGuid = EFI_DEVICE_PATH_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiDevicePathProtocolGuid, "Device Path Protocol", "EFI 1.0 Device Path protocol");
diff --git a/EDK/Foundation/Efi/Protocol/DevicePath/DevicePath.h b/EDK/Foundation/Efi/Protocol/DevicePath/DevicePath.h
new file mode 100644
index 0000000..ddca0dc
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/DevicePath/DevicePath.h
@@ -0,0 +1,67 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ DevicePath.h
+
+Abstract:
+
+ The device path protocol as defined in EFI 1.0.
+
+ The device path represents a programatic path to a device. It's the view
+ from a software point of view. It also must persist from boot to boot, so
+ it can not contain things like PCI bus numbers that change from boot to boot.
+
+
+--*/
+
+#ifndef _DEVICE_PATH_H_
+#define _DEVICE_PATH_H_
+
+//
+// Device Path protocol
+//
+#define EFI_DEVICE_PATH_PROTOCOL_GUID \
+ { \
+ 0x9576e91, 0x6d3f, 0x11d2, 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b \
+ }
+
+#pragma pack(push, 1)
+
+typedef struct {
+ UINT8 Type;
+ UINT8 SubType;
+ UINT8 Length[2];
+} EFI_DEVICE_PATH_PROTOCOL;
+
+#pragma pack(pop)
+
+#define EFI_END_ENTIRE_DEVICE_PATH 0xff
+#define EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE 0xff
+#define EFI_END_INSTANCE_DEVICE_PATH 0x01
+#define EFI_END_DEVICE_PATH_LENGTH (sizeof (EFI_DEVICE_PATH_PROTOCOL))
+
+#define EfiDevicePathNodeLength(a) (((a)->Length[0]) | ((a)->Length[1] << 8))
+#define EfiNextDevicePathNode(a) ((EFI_DEVICE_PATH_PROTOCOL *) (((UINT8 *) (a)) + EfiDevicePathNodeLength (a)))
+
+#define EfiDevicePathType(a) (((a)->Type) & 0x7f)
+#define EfiIsDevicePathEndType(a) (EfiDevicePathType (a) == 0x7f)
+
+#define EfiIsDevicePathEndSubType(a) ((a)->SubType == EFI_END_ENTIRE_DEVICE_PATH_SUBTYPE)
+#define EfiIsDevicePathEndInstanceSubType(a) ((a)->SubType == EFI_END_INSTANCE_DEVICE_PATH)
+
+#define EfiIsDevicePathEnd(a) (EfiIsDevicePathEndType (a) && EfiIsDevicePathEndSubType (a))
+#define EfiIsDevicePathEndInstance(a) (EfiIsDevicePathEndType (a) && EfiIsDevicePathEndInstanceSubType (a))
+
+extern EFI_GUID gEfiDevicePathProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/DevicePathFromText/DevicePathFromText.c b/EDK/Foundation/Efi/Protocol/DevicePathFromText/DevicePathFromText.c
new file mode 100644
index 0000000..296fc56
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/DevicePathFromText/DevicePathFromText.c
@@ -0,0 +1,27 @@
+/*++
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ DevicePathFromText.c
+
+Abstract:
+
+ DevicePathFromText protocol as defined in the UEFI 2.0 specification.
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (DevicePathFromText)
+
+EFI_GUID gEfiDevicePathFromTextProtocolGuid = EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiDevicePathFromTextProtocolGuid, "Device Path From Text Protocol", "UEFI 2.0 Device Path From Text Protocol");
diff --git a/EDK/Foundation/Efi/Protocol/DevicePathFromText/DevicePathFromText.h b/EDK/Foundation/Efi/Protocol/DevicePathFromText/DevicePathFromText.h
new file mode 100644
index 0000000..26df267
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/DevicePathFromText/DevicePathFromText.h
@@ -0,0 +1,82 @@
+/*++
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ DevicePathFromText.h
+
+Abstract:
+
+--*/
+
+#ifndef _DEVICE_PATH_FROM_TEXT_PROTOCOL_H_
+#define _DEVICE_PATH_FROM_TEXT_PROTOCOL_H_
+
+//
+// Device Path From Text protocol
+//
+#define EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL_GUID \
+ { \
+ 0x5c99a21, 0xc70f, 0x4ad2, 0x8a, 0x5f, 0x35, 0xdf, 0x33, 0x43, 0xf5, 0x1e \
+ }
+
+typedef
+EFI_DEVICE_PATH_PROTOCOL*
+(EFIAPI *EFI_DEVICE_PATH_FROM_TEXT_NODE) (
+ IN CONST CHAR16 *TextDeviceNode
+ )
+/*++
+
+ Routine Description:
+ Convert text to the binary representation of a device node.
+
+ Arguments:
+ TextDeviceNode - TextDeviceNode points to the text representation of a device
+ node. Conversion starts with the first character and continues
+ until the first non-device node character.
+
+ Returns:
+ A pointer - Pointer to the EFI device node.
+ NULL - if TextDeviceNode is NULL or there was insufficient memory.
+
+--*/
+;
+
+typedef
+EFI_DEVICE_PATH_PROTOCOL*
+(EFIAPI *EFI_DEVICE_PATH_FROM_TEXT_PATH) (
+ IN CONST CHAR16 *TextDevicePath
+ )
+/*++
+
+ Routine Description:
+ Convert text to the binary representation of a device path.
+
+ Arguments:
+ TextDevicePath - TextDevicePath points to the text representation of a device
+ path. Conversion starts with the first character and continues
+ until the first non-device node character.
+
+ Returns:
+ A pointer - Pointer to the allocated device path.
+ NULL - if TextDeviceNode is NULL or there was insufficient memory.
+
+--*/
+;
+
+typedef struct {
+ EFI_DEVICE_PATH_FROM_TEXT_NODE ConvertTextToDeviceNode;
+ EFI_DEVICE_PATH_FROM_TEXT_PATH ConvertTextToDevicePath;
+} EFI_DEVICE_PATH_FROM_TEXT_PROTOCOL;
+
+extern EFI_GUID gEfiDevicePathFromTextProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/DevicePathToText/DevicePathToText.c b/EDK/Foundation/Efi/Protocol/DevicePathToText/DevicePathToText.c
new file mode 100644
index 0000000..72a33a1
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/DevicePathToText/DevicePathToText.c
@@ -0,0 +1,27 @@
+/*++
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ DevicePathToText.c
+
+Abstract:
+
+ DevicePathToText protocol as defined in the UEFI 2.0 specification.
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (DevicePathToText)
+
+EFI_GUID gEfiDevicePathToTextProtocolGuid = EFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiDevicePathToTextProtocolGuid, "Device Path To Text Protocol", "UEFI 2.0 Device Path To Text protocol");
diff --git a/EDK/Foundation/Efi/Protocol/DevicePathToText/DevicePathToText.h b/EDK/Foundation/Efi/Protocol/DevicePathToText/DevicePathToText.h
new file mode 100644
index 0000000..c647af8
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/DevicePathToText/DevicePathToText.h
@@ -0,0 +1,95 @@
+/*++
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ DevicePathToText.h
+
+Abstract:
+
+--*/
+
+
+#ifndef _DEVICE_PATH_TO_TEXT_PROTOCOL_H_
+#define _DEVICE_PATH_TO_TEXT_PROTOCOL_H_
+
+//
+// Device Path To Text protocol
+//
+#define EFI_DEVICE_PATH_TO_TEXT_PROTOCOL_GUID \
+ { \
+ 0x8b843e20, 0x8132, 0x4852, 0x90, 0xcc, 0x55, 0x1a, 0x4e, 0x4a, 0x7f, 0x1c \
+ }
+
+typedef
+CHAR16*
+(EFIAPI *EFI_DEVICE_PATH_TO_TEXT_NODE) (
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode,
+ IN BOOLEAN DisplayOnly,
+ IN BOOLEAN AllowShortcuts
+ )
+/*++
+
+ Routine Description:
+ Convert a device node to its text representation.
+
+ Arguments:
+ DeviceNode - Points to the device node to be converted.
+ DisplayOnly - If DisplayOnly is TRUE, then the shorter text representation
+ of the display node is used, where applicable. If DisplayOnly
+ is FALSE, then the longer text representation of the display node
+ is used.
+ AllowShortcuts - If AllowShortcuts is TRUE, then the shortcut forms of text
+ representation for a device node can be used, where applicable.
+
+ Returns:
+ A pointer - a pointer to the allocated text representation of the device node.
+ NULL - if DeviceNode is NULL or there was insufficient memory.
+
+--*/
+;
+
+typedef
+CHAR16*
+(EFIAPI *EFI_DEVICE_PATH_TO_TEXT_PATH) (
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
+ IN BOOLEAN DisplayOnly,
+ IN BOOLEAN AllowShortcuts
+ )
+/*++
+
+ Routine Description:
+ Convert a device path to its text representation.
+
+ Arguments:
+ DeviceNode - Points to the device path to be converted.
+ DisplayOnly - If DisplayOnly is TRUE, then the shorter text representation
+ of the display node is used, where applicable. If DisplayOnly
+ is FALSE, then the longer text representation of the display node
+ is used.
+ AllowShortcuts - If AllowShortcuts is TRUE, then the shortcut forms of text
+ representation for a device node can be used, where applicable.
+
+ Returns:
+ A pointer - a pointer to the allocated text representation of the device path.
+ NULL - if DeviceNode is NULL or there was insufficient memory.
+
+--*/
+;
+
+typedef struct {
+ EFI_DEVICE_PATH_TO_TEXT_NODE ConvertDeviceNodeToText;
+ EFI_DEVICE_PATH_TO_TEXT_PATH ConvertDevicePathToText;
+} EFI_DEVICE_PATH_TO_TEXT_PROTOCOL;
+
+extern EFI_GUID gEfiDevicePathToTextProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/DevicePathUtilities/DevicePathUtilities.c b/EDK/Foundation/Efi/Protocol/DevicePathUtilities/DevicePathUtilities.c
new file mode 100644
index 0000000..4ecdac1
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/DevicePathUtilities/DevicePathUtilities.c
@@ -0,0 +1,27 @@
+/*++
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ DevicePathUtilities.c
+
+Abstract:
+
+ DevicePathUtilities protocol as defined in the UEFI 2.0 specification.
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (DevicePathUtilities)
+
+EFI_GUID gEfiDevicePathUtilitiesProtocolGuid = EFI_DEVICE_PATH_UTILITIES_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiDevicePathUtilitiesProtocolGuid, "Device Path Utilities Protocol", "UEFI 2.0 Device Path Utilities protocol");
diff --git a/EDK/Foundation/Efi/Protocol/DevicePathUtilities/DevicePathUtilities.h b/EDK/Foundation/Efi/Protocol/DevicePathUtilities/DevicePathUtilities.h
new file mode 100644
index 0000000..2cf8d89
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/DevicePathUtilities/DevicePathUtilities.h
@@ -0,0 +1,225 @@
+/*++
+
+Copyright (c) 2006 - 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ DevicePathUtilities.h
+
+Abstract:
+
+--*/
+
+#ifndef _DEVICE_PATH_UTILITIES_PROTOCOL_H_
+#define _DEVICE_PATH_UTILITIES_PROTOCOL_H_
+
+//
+// Device Path Utilities protocol
+//
+#define EFI_DEVICE_PATH_UTILITIES_PROTOCOL_GUID \
+ { \
+ 0x379be4e, 0xd706, 0x437d, 0xb0, 0x37, 0xed, 0xb8, 0x2f, 0xb7, 0x72, 0xa4 \
+ }
+
+typedef
+UINTN
+(EFIAPI *EFI_DEVICE_PATH_UTILS_GET_DEVICE_PATH_SIZE) (
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ )
+/*++
+
+ Routine Description:
+ Returns the size of the device path, in bytes.
+
+ Arguments:
+ DevicePath - Points to the start of the EFI device path.
+
+ Returns:
+ Size - Size of the specified device path, in bytes, including the end-of-path tag.
+
+--*/
+;
+
+typedef
+EFI_DEVICE_PATH_PROTOCOL*
+(EFIAPI *EFI_DEVICE_PATH_UTILS_DUP_DEVICE_PATH) (
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ )
+/*++
+
+ Routine Description:
+ Create a duplicate of the specified path.
+
+ Arguments:
+ DevicePath - Points to the source EFI device path.
+
+ Returns:
+ Pointer - A pointer to the duplicate device path.
+ NULL - Insufficient memory.
+
+--*/
+;
+
+typedef
+EFI_DEVICE_PATH_PROTOCOL*
+(EFIAPI *EFI_DEVICE_PATH_UTILS_APPEND_PATH) (
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *Src1,
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *Src2
+ )
+/*++
+
+ Routine Description:
+ Create a new path by appending the second device path to the first.
+
+ Arguments:
+ Src1 - Points to the first device path. If NULL, then it is ignored.
+ Src2 - Points to the second device path. If NULL, then it is ignored.
+
+ Returns:
+ Pointer - A pointer to the newly created device path.
+ NULL - Memory could not be allocated
+ or either DevicePath or DeviceNode is NULL.
+
+--*/
+;
+
+typedef
+EFI_DEVICE_PATH_PROTOCOL*
+(EFIAPI *EFI_DEVICE_PATH_UTILS_APPEND_NODE) (
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DeviceNode
+ )
+/*++
+
+ Routine Description:
+ Creates a new path by appending the device node to the device path.
+
+ Arguments:
+ DevicePath - Points to the device path.
+ DeviceNode - Points to the device node.
+
+ Returns:
+ Pointer - A pointer to the allocated device node.
+ NULL - Memory could not be allocated
+ or either DevicePath or DeviceNode is NULL.
+
+--*/
+;
+
+typedef
+EFI_DEVICE_PATH_PROTOCOL*
+(EFIAPI *EFI_DEVICE_PATH_UTILS_APPEND_INSTANCE) (
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathInstance
+ )
+/*++
+
+ Routine Description:
+ Creates a new path by appending the specified device path instance to the specified device path.
+
+ Arguments:
+ DevicePath - Points to the device path. If NULL, then ignored.
+ DevicePathInstance - Points to the device path instance.
+
+ Returns:
+ Pointer - A pointer to the newly created device path
+ NULL - Memory could not be allocated or DevicePathInstance is NULL.
+
+--*/
+;
+
+typedef
+EFI_DEVICE_PATH_PROTOCOL*
+(EFIAPI *EFI_DEVICE_PATH_UTILS_GET_NEXT_INSTANCE) (
+ IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePathInstance,
+ OUT UINTN *DevicePathInstanceSize
+ )
+/*++
+
+ Routine Description:
+ Creates a copy of the current device path instance and returns a pointer to the next device path instance.
+
+ Arguments:
+ DevicePathInstance - On input, this holds the pointer to the current device path
+ instance. On output, this holds the pointer to the next
+ device path instance or NULL if there are no more device
+ path instances in the device path.
+ DevicePathInstanceSize - On output, this holds the size of the device path instance,
+ in bytes or zero, if DevicePathInstance is zero.
+
+ Returns:
+ Pointer - A pointer to the copy of the current device path instance.
+ NULL - DevicePathInstace was NULL on entry or there was insufficient memory.
+
+--*/
+;
+
+typedef
+BOOLEAN
+(EFIAPI *EFI_DEVICE_PATH_UTILS_IS_MULTI_INSTANCE) (
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ )
+/*++
+
+ Routine Description:
+ Returns whether a device path is multi-instance.
+
+ Arguments:
+ DevicePath - Points to the device path. If NULL, then ignored.
+
+ Returns:
+ TRUE - The device path has more than one instance
+ FALSE - The device path is empty or contains only a single instance.
+
+--*/
+;
+
+typedef
+EFI_DEVICE_PATH_PROTOCOL*
+(EFIAPI *EFI_DEVICE_PATH_UTILS_CREATE_NODE) (
+ IN UINT8 NodeType,
+ IN UINT8 NodeSubType,
+ IN UINT16 NodeLength
+ )
+/*++
+
+ Routine Description:
+ Creates a device node
+
+ Arguments:
+ NodeType - NodeType is the device node type (EFI_DEVICE_PATH.Type) for
+ the new device node.
+ NodeSubType - NodeSubType is the device node sub-type
+ EFI_DEVICE_PATH.SubType) for the new device node.
+ NodeLength - NodeLength is the length of the device node
+ (EFI_DEVICE_PATH.Length) for the new device node.
+
+ Returns:
+ Pointer - A pointer to the newly created device node.
+ NULL - NodeLength is less than
+ the size of the header or there was insufficient memory.
+
+--*/
+;
+
+typedef struct {
+ EFI_DEVICE_PATH_UTILS_GET_DEVICE_PATH_SIZE GetDevicePathSize;
+ EFI_DEVICE_PATH_UTILS_DUP_DEVICE_PATH DuplicateDevicePath;
+ EFI_DEVICE_PATH_UTILS_APPEND_PATH AppendDevicePath;
+ EFI_DEVICE_PATH_UTILS_APPEND_NODE AppendDeviceNode;
+ EFI_DEVICE_PATH_UTILS_APPEND_INSTANCE AppendDevicePathInstance;
+ EFI_DEVICE_PATH_UTILS_GET_NEXT_INSTANCE GetNextDevicePathInstance;
+ EFI_DEVICE_PATH_UTILS_IS_MULTI_INSTANCE IsDevicePathMultiInstance;
+ EFI_DEVICE_PATH_UTILS_CREATE_NODE CreateDeviceNode;
+} EFI_DEVICE_PATH_UTILITIES_PROTOCOL;
+
+extern EFI_GUID gEfiDevicePathUtilitiesProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/Dhcp4/Dhcp4.c b/EDK/Foundation/Efi/Protocol/Dhcp4/Dhcp4.c
new file mode 100644
index 0000000..2778ecb
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/Dhcp4/Dhcp4.c
@@ -0,0 +1,41 @@
+/*++
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Dhcp4.c
+
+Abstract:
+
+ UEFI Dynamic Host Configuration Protocol 4.
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (Dhcp4)
+
+EFI_GUID gEfiDhcp4ServiceBindingProtocolGuid
+ = EFI_DHCP4_SERVICE_BINDING_PROTOCOL_GUID;
+
+EFI_GUID gEfiDhcp4ProtocolGuid
+ = EFI_DHCP4_PROTOCOL_GUID;
+
+EFI_GUID_STRING (
+ &gEfiDhcp4ServiceBindingProtocolGuid,
+ "DHCP4 Service Binding Protocol",
+ "DHCP4 Service Binding Protocol"
+ );
+
+EFI_GUID_STRING (
+ &gEfiDhcp4ProtocolGuid,
+ "DHCP4 Protocol",
+ "DHCP4 Protocol"
+ );
diff --git a/EDK/Foundation/Efi/Protocol/Dhcp4/Dhcp4.h b/EDK/Foundation/Efi/Protocol/Dhcp4/Dhcp4.h
new file mode 100644
index 0000000..799b785
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/Dhcp4/Dhcp4.h
@@ -0,0 +1,235 @@
+/*++
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Dhcp4.h
+
+Abstract:
+
+ UEFI Dynamic Host Configuration Protocol 4 Definition
+
+--*/
+
+#ifndef _DHCP4_H_
+#define _DHCP4_H_
+
+#include EFI_PROTOCOL_DEFINITION (ServiceBinding)
+#include EFI_PROTOCOL_DEFINITION (Udp4)
+
+//GUID definitions
+#define EFI_DHCP4_PROTOCOL_GUID \
+ {0x8a219718, 0x4ef5, 0x4761, 0x91, 0xc8, 0xc0, 0xf0, 0x4b, 0xda, 0x9e, 0x56}
+
+#define EFI_DHCP4_SERVICE_BINDING_PROTOCOL_GUID \
+ {0x9d9a39d8, 0xbd42, 0x4a73, 0xa4, 0xd5, 0x8e, 0xe9, 0x4b, 0xe1, 0x13, 0x80}
+
+extern EFI_GUID gEfiDhcp4ProtocolGuid;
+extern EFI_GUID gEfiDhcp4ServiceBindingProtocolGuid;
+
+EFI_FORWARD_DECLARATION (EFI_DHCP4_PROTOCOL);
+
+#pragma pack(1)
+typedef struct {
+ UINT8 OpCode;
+ UINT8 Length;
+ UINT8 Data[1];
+} EFI_DHCP4_PACKET_OPTION;
+
+typedef struct{
+ UINT8 OpCode;
+ UINT8 HwType;
+ UINT8 HwAddrLen;
+ UINT8 Hops;
+ UINT32 Xid;
+ UINT16 Seconds;
+ UINT16 Reserved;
+ EFI_IPv4_ADDRESS ClientAddr;
+ EFI_IPv4_ADDRESS YourAddr;
+ EFI_IPv4_ADDRESS ServerAddr;
+ EFI_IPv4_ADDRESS GwAddr;
+ UINT8 ClientHwAddr[16];
+ CHAR8 ServerName[64];
+ CHAR8 BootFileName[128];
+}EFI_DHCP4_HEADER;
+
+typedef struct {
+ UINT32 Size;
+ UINT32 Length;
+ struct {
+ EFI_DHCP4_HEADER Header;
+ UINT32 Magik;
+ UINT8 Option[1];
+ } Dhcp4;
+} EFI_DHCP4_PACKET;
+#pragma pack()
+
+typedef enum {
+ Dhcp4Stopped = 0x0,
+ Dhcp4Init = 0x1,
+ Dhcp4Selecting = 0x2,
+ Dhcp4Requesting = 0x3,
+ Dhcp4Bound = 0x4,
+ Dhcp4Renewing = 0x5,
+ Dhcp4Rebinding = 0x6,
+ Dhcp4InitReboot = 0x7,
+ Dhcp4Rebooting = 0x8
+} EFI_DHCP4_STATE;
+
+typedef enum{
+ Dhcp4SendDiscover = 0x01,
+ Dhcp4RcvdOffer = 0x02,
+ Dhcp4SelectOffer = 0x03,
+ Dhcp4SendRequest = 0x04,
+ Dhcp4RcvdAck = 0x05,
+ Dhcp4RcvdNak = 0x06,
+ Dhcp4SendDecline = 0x07,
+ Dhcp4BoundCompleted = 0x08,
+ Dhcp4EnterRenewing = 0x09,
+ Dhcp4EnterRebinding = 0x0a,
+ Dhcp4AddressLost = 0x0b,
+ Dhcp4Fail = 0x0c
+} EFI_DHCP4_EVENT;
+
+typedef EFI_STATUS (*EFI_DHCP4_CALLBACK) (
+ IN EFI_DHCP4_PROTOCOL *This,
+ IN VOID *Context,
+ IN EFI_DHCP4_STATE CurrentState,
+ IN EFI_DHCP4_EVENT Dhcp4Event,
+ IN EFI_DHCP4_PACKET *Packet OPTIONAL,
+ OUT EFI_DHCP4_PACKET **NewPacket OPTIONAL
+);
+
+typedef struct {
+ UINT32 DiscoverTryCount;
+ UINT32 *DiscoverTimeout;
+ UINT32 RequestTryCount;
+ UINT32 *RequestTimeout;
+ EFI_IPv4_ADDRESS ClientAddress;
+ EFI_DHCP4_CALLBACK Dhcp4Callback;
+ VOID *CallbackContext;
+ UINT32 OptionCount;
+ EFI_DHCP4_PACKET_OPTION **OptionList;
+}EFI_DHCP4_CONFIG_DATA;
+
+typedef struct {
+ EFI_DHCP4_STATE State;
+ EFI_DHCP4_CONFIG_DATA ConfigData;
+ EFI_IPv4_ADDRESS ClientAddress;
+ EFI_MAC_ADDRESS ClientMacAddress;
+ EFI_IPv4_ADDRESS ServerAddress;
+ EFI_IPv4_ADDRESS RouterAddress;
+ EFI_IPv4_ADDRESS SubnetMask;
+ UINT32 LeaseTime;
+ EFI_DHCP4_PACKET *ReplyPacket;
+ } EFI_DHCP4_MODE_DATA;
+
+typedef struct {
+ EFI_IPv4_ADDRESS ListenAddress;
+ EFI_IPv4_ADDRESS SubnetMask;
+ UINT16 ListenPort;
+} EFI_DHCP4_LISTEN_POINT;
+
+typedef struct {
+ EFI_STATUS Status;
+ EFI_EVENT CompletionEvent;
+ EFI_IPv4_ADDRESS RemoteAddress;
+ UINT16 RemotePort;
+ EFI_IPv4_ADDRESS GatewayAddress;
+ UINT32 ListenPointCount;
+ EFI_DHCP4_LISTEN_POINT *ListenPoints;
+ UINT32 TimeoutValue;
+ EFI_DHCP4_PACKET *Packet;
+ UINT32 ResponseCount;
+ EFI_DHCP4_PACKET *ResponseList;
+} EFI_DHCP4_TRANSMIT_RECEIVE_TOKEN;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_DHCP4_GET_MODE_DATA) (
+ IN EFI_DHCP4_PROTOCOL *This,
+ OUT EFI_DHCP4_MODE_DATA *Dhcp4ModeData
+);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_DHCP4_CONFIGURE) (
+ IN EFI_DHCP4_PROTOCOL *This,
+ IN EFI_DHCP4_CONFIG_DATA *Dhcp4CfgData OPTIONAL
+);
+
+
+typedef EFI_STATUS
+(EFIAPI *EFI_DHCP4_START) (
+ IN EFI_DHCP4_PROTOCOL *This,
+ IN EFI_EVENT CompletionEvent OPTIONAL
+);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_DHCP4_RENEW_REBIND) (
+ IN EFI_DHCP4_PROTOCOL *This,
+ IN BOOLEAN RebindRequest,
+ IN EFI_EVENT CompletionEvent OPTIONAL
+);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_DHCP4_RELEASE) (
+ IN EFI_DHCP4_PROTOCOL *This
+);
+
+typedef EFI_STATUS
+(EFIAPI *EFI_DHCP4_STOP) (
+ IN EFI_DHCP4_PROTOCOL *This
+);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_DHCP4_BUILD) (
+ IN EFI_DHCP4_PROTOCOL *This,
+ IN EFI_DHCP4_PACKET *SeedPacket,
+ IN UINT32 DeleteCount,
+ IN UINT8 *DeleteList OPTIONAL,
+ IN UINT32 AppendCount,
+ IN EFI_DHCP4_PACKET_OPTION *AppendList[] OPTIONAL,
+ OUT EFI_DHCP4_PACKET **NewPacket
+);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_DHCP4_TRANSMIT_RECEIVE) (
+ IN EFI_DHCP4_PROTOCOL *This,
+ IN EFI_DHCP4_TRANSMIT_RECEIVE_TOKEN *Token
+);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_DHCP4_PARSE) (
+ IN EFI_DHCP4_PROTOCOL *This,
+ IN EFI_DHCP4_PACKET *Packet,
+ IN OUT UINT32 *OptionCount,
+ OUT EFI_DHCP4_PACKET_OPTION *PacketOptionList[] OPTIONAL
+);
+
+typedef struct _EFI_DHCP4_PROTOCOL {
+ EFI_DHCP4_GET_MODE_DATA GetModeData;
+ EFI_DHCP4_CONFIGURE Configure;
+ EFI_DHCP4_START Start;
+ EFI_DHCP4_RENEW_REBIND RenewRebind;
+ EFI_DHCP4_RELEASE Release;
+ EFI_DHCP4_STOP Stop;
+ EFI_DHCP4_BUILD Build;
+ EFI_DHCP4_TRANSMIT_RECEIVE TransmitReceive;
+ EFI_DHCP4_PARSE Parse;
+} EFI_DHCP4_PROTOCOL;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/DiskIO/DiskIo.c b/EDK/Foundation/Efi/Protocol/DiskIO/DiskIo.c
new file mode 100644
index 0000000..76ece26
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/DiskIO/DiskIo.c
@@ -0,0 +1,31 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ DiskIo.c
+
+Abstract:
+
+ Disk IO protocol as defined in the EFI 1.0 specification.
+
+ The Disk IO protocol is used to convert block oriented devices into byte
+ oriented devices. The Disk IO protocol is intended to layer on top of the
+ Block IO protocol.
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (DiskIo)
+
+EFI_GUID gEfiDiskIoProtocolGuid = EFI_DISK_IO_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiDiskIoProtocolGuid, "DiskIo Protocol", "EFI 1.0 Disk IO Protocol");
diff --git a/EDK/Foundation/Efi/Protocol/DiskIO/DiskIo.h b/EDK/Foundation/Efi/Protocol/DiskIO/DiskIo.h
new file mode 100644
index 0000000..0fc9760
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/DiskIO/DiskIo.h
@@ -0,0 +1,111 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ DiskIo.h
+
+Abstract:
+
+ Disk IO protocol as defined in the EFI 1.0 specification.
+
+ The Disk IO protocol is used to convert block oriented devices into byte
+ oriented devices. The Disk IO protocol is intended to layer on top of the
+ Block IO protocol.
+
+--*/
+
+#ifndef __DISK_IO_H__
+#define __DISK_IO_H__
+
+#define EFI_DISK_IO_PROTOCOL_GUID \
+ { \
+ 0xce345171, 0xba0b, 0x11d2, 0x8e, 0x4f, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b \
+ }
+
+EFI_FORWARD_DECLARATION (EFI_DISK_IO_PROTOCOL);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_DISK_READ) (
+ IN EFI_DISK_IO_PROTOCOL * This,
+ IN UINT32 MediaId,
+ IN UINT64 Offset,
+ IN UINTN BufferSize,
+ OUT VOID *Buffer
+ )
+/*++
+
+ Routine Description:
+ Read BufferSize bytes from Offset into Buffer.
+
+ Arguments:
+ This - Protocol instance pointer.
+ MediaId - Id of the media, changes every time the media is replaced.
+ Offset - The starting byte offset to read from
+ BufferSize - Size of Buffer
+ Buffer - Buffer containing read data
+
+ Returns:
+ EFI_SUCCESS - The data was read correctly from the device.
+ EFI_DEVICE_ERROR - The device reported an error while performing the read.
+ EFI_NO_MEDIA - There is no media in the device.
+ EFI_MEDIA_CHNAGED - The MediaId does not matched the current device.
+ EFI_INVALID_PARAMETER - The read request contains device addresses that are not
+ valid for the device.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_DISK_WRITE) (
+ IN EFI_DISK_IO_PROTOCOL * This,
+ IN UINT32 MediaId,
+ IN UINT64 Offset,
+ IN UINTN BufferSize,
+ IN VOID *Buffer
+ )
+/*++
+
+ Routine Description:
+ Read BufferSize bytes from Offset into Buffer.
+
+ Arguments:
+ This - Protocol instance pointer.
+ MediaId - Id of the media, changes every time the media is replaced.
+ Offset - The starting byte offset to read from
+ BufferSize - Size of Buffer
+ Buffer - Buffer containing read data
+
+ Returns:
+ EFI_SUCCESS - The data was written correctly to the device.
+ EFI_WRITE_PROTECTED - The device can not be written to.
+ EFI_DEVICE_ERROR - The device reported an error while performing the write.
+ EFI_NO_MEDIA - There is no media in the device.
+ EFI_MEDIA_CHNAGED - The MediaId does not matched the current device.
+ EFI_INVALID_PARAMETER - The write request contains device addresses that are not
+ valid for the device.
+
+--*/
+;
+
+#define EFI_DISK_IO_PROTOCOL_REVISION 0x00010000
+
+typedef struct _EFI_DISK_IO_PROTOCOL {
+ UINT64 Revision;
+ EFI_DISK_READ ReadDisk;
+ EFI_DISK_WRITE WriteDisk;
+} EFI_DISK_IO_PROTOCOL;
+
+extern EFI_GUID gEfiDiskIoProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/DriverBinding/DriverBinding.c b/EDK/Foundation/Efi/Protocol/DriverBinding/DriverBinding.c
new file mode 100644
index 0000000..f994e57
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/DriverBinding/DriverBinding.c
@@ -0,0 +1,29 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ DriverBinding.c
+
+Abstract:
+
+ EFI Controller Driver Protocol
+
+Revision History
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (DriverBinding)
+
+EFI_GUID gEfiDriverBindingProtocolGuid = EFI_DRIVER_BINDING_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiDriverBindingProtocolGuid, "Controller Driver Protocol", "EFI 1.1 Controller Driver Protocol");
diff --git a/EDK/Foundation/Efi/Protocol/DriverBinding/DriverBinding.h b/EDK/Foundation/Efi/Protocol/DriverBinding/DriverBinding.h
new file mode 100644
index 0000000..bff7ecd
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/DriverBinding/DriverBinding.h
@@ -0,0 +1,130 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ DriverBinding.h
+
+Abstract:
+
+ EFI ControllerHandle Driver Protocol
+
+Revision History
+
+--*/
+
+#ifndef _EFI_DRIVER_BINDING_H_
+#define _EFI_DRIVER_BINDING_H_
+
+//
+// Global ID for the ControllerHandle Driver Protocol
+//
+#define EFI_DRIVER_BINDING_PROTOCOL_GUID \
+ { \
+ 0x18a031ab, 0xb443, 0x4d1a, 0xa5, 0xc0, 0xc, 0x9, 0x26, 0x1e, 0x9f, 0x71 \
+ }
+
+EFI_FORWARD_DECLARATION (EFI_DRIVER_BINDING_PROTOCOL);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_DRIVER_BINDING_SUPPORTED) (
+ IN EFI_DRIVER_BINDING_PROTOCOL * This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL * RemainingDevicePath OPTIONAL
+ )
+/*++
+
+ Routine Description:
+ Test to see if this driver supports ControllerHandle.
+
+ Arguments:
+ This - Protocol instance pointer.
+ ControllerHandle - Handle of device to test
+ RemainingDevicePath - Optional parameter use to pick a specific child
+ device to start.
+
+ Returns:
+ EFI_SUCCESS - This driver supports this device
+ EFI_ALREADY_STARTED - This driver is already running on this device
+ other - This driver does not support this device
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_DRIVER_BINDING_START) (
+ IN EFI_DRIVER_BINDING_PROTOCOL * This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL * RemainingDevicePath OPTIONAL
+ )
+/*++
+
+ Routine Description:
+ Start this driver on ControllerHandle.
+
+ Arguments:
+ This - Protocol instance pointer.
+ ControllerHandle - Handle of device to bind driver to
+ RemainingDevicePath - Optional parameter use to pick a specific child
+ device to start.
+
+ Returns:
+ EFI_SUCCESS - This driver is added to ControllerHandle
+ EFI_ALREADY_STARTED - This driver is already running on ControllerHandle
+ other - This driver does not support this device
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_DRIVER_BINDING_STOP) (
+ IN EFI_DRIVER_BINDING_PROTOCOL * This,
+ IN EFI_HANDLE ControllerHandle,
+ IN UINTN NumberOfChildren,
+ IN EFI_HANDLE * ChildHandleBuffer
+ )
+/*++
+
+ Routine Description:
+ Stop this driver on ControllerHandle.
+
+ Arguments:
+ This - Protocol instance pointer.
+ ControllerHandle - Handle of device to stop driver on
+ NumberOfChildren - Number of Handles in ChildHandleBuffer. If number of
+ children is zero stop the entire bus driver.
+ ChildHandleBuffer - List of Child Handles to Stop.
+
+ Returns:
+ EFI_SUCCESS - This driver is removed ControllerHandle
+ other - This driver was not removed from this device
+
+--*/
+;
+
+//
+// Interface structure for the ControllerHandle Driver Protocol
+//
+typedef struct _EFI_DRIVER_BINDING_PROTOCOL {
+ EFI_DRIVER_BINDING_SUPPORTED Supported;
+ EFI_DRIVER_BINDING_START Start;
+ EFI_DRIVER_BINDING_STOP Stop;
+ UINT32 Version;
+ EFI_HANDLE ImageHandle;
+ EFI_HANDLE DriverBindingHandle;
+} EFI_DRIVER_BINDING_PROTOCOL;
+
+extern EFI_GUID gEfiDriverBindingProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/DriverConfiguration/DriverConfiguration.c b/EDK/Foundation/Efi/Protocol/DriverConfiguration/DriverConfiguration.c
new file mode 100644
index 0000000..c029672
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/DriverConfiguration/DriverConfiguration.c
@@ -0,0 +1,30 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ DriverConfiguration.c
+
+Abstract:
+
+ EFI Driver Configuration Protocol
+
+Revision History
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (DriverConfiguration)
+
+EFI_GUID gEfiDriverConfigurationProtocolGuid = EFI_DRIVER_CONFIGURATION_PROTOCOL_GUID;
+
+EFI_GUID_STRING
+ (&gEfiDriverConfigurationProtocolGuid, "Driver Configuration Protocol", "EFI 1.1 Driver Configuration Protocol");
diff --git a/EDK/Foundation/Efi/Protocol/DriverConfiguration/DriverConfiguration.h b/EDK/Foundation/Efi/Protocol/DriverConfiguration/DriverConfiguration.h
new file mode 100644
index 0000000..8620d07
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/DriverConfiguration/DriverConfiguration.h
@@ -0,0 +1,211 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ DriverConfiguration.h
+
+Abstract:
+
+ EFI Driver Configuration Protocol
+
+Revision History
+
+--*/
+
+#ifndef _EFI_DRIVER_CONFIGURATION_H_
+#define _EFI_DRIVER_CONFIGURATION_H_
+
+//
+// Global ID for the Driver Configuration Protocol
+//
+#define EFI_DRIVER_CONFIGURATION_PROTOCOL_GUID \
+ { \
+ 0x107a772b, 0xd5e1, 0x11d4, 0x9a, 0x46, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d \
+ }
+
+EFI_FORWARD_DECLARATION (EFI_DRIVER_CONFIGURATION_PROTOCOL);
+
+typedef enum {
+ EfiDriverConfigurationActionNone = 0,
+ EfiDriverConfigurationActionStopController = 1,
+ EfiDriverConfigurationActionRestartController = 2,
+ EfiDriverConfigurationActionRestartPlatform = 3,
+ EfiDriverConfigurationActionMaximum
+} EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED;
+
+#define EFI_DRIVER_CONFIGURATION_SAFE_DEFAULTS 0x00000000
+#define EFI_DRIVER_CONFIGURATION_MANUFACTURING_DEFAULTS 0x00000001
+#define EFI_DRIVER_CONFIGURATION_CUSTOM_DEFAULTS 0x00000002
+#define EFI_DRIVER_CONFIGURATION_PERORMANCE_DEFAULTS 0x00000003
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_DRIVER_CONFIGURATION_SET_OPTIONS) (
+ IN EFI_DRIVER_CONFIGURATION_PROTOCOL * This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN CHAR8 *Language,
+ OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED * ActionRequired
+ );
+
+/*++
+
+ Routine Description:
+ Allows the user to set controller specific options for a controller that a
+ driver is currently managing.
+
+ Arguments:
+ This - A pointer to the EFI_DRIVER_CONFIGURATION_ PROTOCOL instance.
+ ControllerHandle - The handle of the controller to set options on.
+ ChildHandle - The handle of the child controller to set options on. This
+ is an optional parameter that may be NULL. It will be NULL
+ for device drivers, and for a bus drivers that wish to set
+ options for the bus controller. It will not be NULL for a
+ bus driver that wishes to set options for one of its child
+ controllers.
+ Language - A pointer to a three character ISO 639-2 language identifier.
+ This is the language of the user interface that should be
+ presented to the user, and it must match one of the languages
+ specified in SupportedLanguages. The number of languages
+ supported by a driver is up to the driver writer.
+ ActionRequired - A pointer to the action that the calling agent is required
+ to perform when this function returns. See "Related
+ Definitions" for a list of the actions that the calling
+ agent is required to perform prior to accessing
+ ControllerHandle again.
+
+ Returns:
+ EFI_SUCCESS - The driver specified by This successfully set the
+ configuration options for the controller specified
+ by ControllerHandle..
+ EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.
+ EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE.
+ EFI_INVALID_PARAMETER - ActionRequired is NULL.
+ EFI_UNSUPPORTED - The driver specified by This does not support setting
+ configuration options for the controller specified by
+ ControllerHandle and ChildHandle.
+ EFI_UNSUPPORTED - The driver specified by This does not support the
+ language specified by Language.
+ EFI_DEVICE_ERROR - A device error occurred while attempt to set the
+ configuration options for the controller specified
+ by ControllerHandle and ChildHandle.
+ EFI_OUT_RESOURCES - There are not enough resources available to set the
+ configuration options for the controller specified
+ by ControllerHandle and ChildHandle.
+
+--*/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_DRIVER_CONFIGURATION_OPTIONS_VALID) (
+ IN EFI_DRIVER_CONFIGURATION_PROTOCOL * This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL
+ );
+
+/*++
+
+ Routine Description:
+ Tests to see if a controller's current configuration options are valid.
+
+ Arguments:
+ This - A pointer to the EFI_DRIVER_CONFIGURATION_PROTOCOL instance.
+ ControllerHandle - The handle of the controller to test if it's current
+ configuration options are valid.
+ ChildHandle - The handle of the child controller to test if it's current
+ configuration options are valid. This is an optional
+ parameter that may be NULL. It will be NULL for device
+ drivers. It will also be NULL for a bus drivers that wish
+ to test the configuration options for the bus controller.
+ It will not be NULL for a bus driver that wishes to test
+ configuration options for one of its child controllers.
+
+ Returns:
+ EFI_SUCCESS - The controller specified by ControllerHandle and
+ ChildHandle that is being managed by the driver
+ specified by This has a valid set of configuration
+ options.
+ EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.
+ EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE.
+ EFI_UNSUPPORTED - The driver specified by This is not currently
+ managing the controller specified by ControllerHandle
+ and ChildHandle.
+ EFI_DEVICE_ERROR - The controller specified by ControllerHandle and
+ ChildHandle that is being managed by the driver
+ specified by This has an invalid set of configuration
+ options.
+
+--*/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_DRIVER_CONFIGURATION_FORCE_DEFAULTS) (
+ IN EFI_DRIVER_CONFIGURATION_PROTOCOL * This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN UINT32 DefaultType,
+ OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED * ActionRequired
+ );
+
+/*++
+
+ Routine Description:
+ Forces a driver to set the default configuration options for a controller.
+
+ Arguments:
+ This - A pointer to the EFI_DRIVER_CONFIGURATION_ PROTOCOL instance.
+ ControllerHandle - The handle of the controller to force default configuration options on.
+ ChildHandle - The handle of the child controller to force default configuration options on This is an optional parameter that may be NULL. It will be NULL for device drivers. It will also be NULL for a bus drivers that wish to force default configuration options for the bus controller. It will not be NULL for a bus driver that wishes to force default configuration options for one of its child controllers.
+ DefaultType - The type of default configuration options to force on the controller specified by ControllerHandle and ChildHandle. See Table 9-1 for legal values. A DefaultType of 0x00000000 must be supported by this protocol.
+ ActionRequired - A pointer to the action that the calling agent is required to perform when this function returns. See "Related Definitions" in Section 9.1for a list of the actions that the calling agent is required to perform prior to accessing ControllerHandle again.
+
+ Returns:
+ EFI_SUCCESS - The driver specified by This successfully forced the default configuration options on the controller specified by ControllerHandle and ChildHandle.
+ EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.
+ EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE.
+ EFI_INVALID_PARAMETER - ActionRequired is NULL.
+ EFI_UNSUPPORTED - The driver specified by This does not support forcing the default configuration options on the controller specified by ControllerHandle and ChildHandle.
+ EFI_UNSUPPORTED - The driver specified by This does not support the configuration type specified by DefaultType.
+ EFI_DEVICE_ERROR - A device error occurred while attempt to force the default configuration options on the controller specified by ControllerHandle and ChildHandle.
+ EFI_OUT_RESOURCES - There are not enough resources available to force the default configuration options on the controller specified by ControllerHandle and ChildHandle.
+
+--*/
+
+//
+// Interface structure for the Driver Configuration Protocol
+//
+typedef struct _EFI_DRIVER_CONFIGURATION_PROTOCOL {
+ EFI_DRIVER_CONFIGURATION_SET_OPTIONS SetOptions;
+ EFI_DRIVER_CONFIGURATION_OPTIONS_VALID OptionsValid;
+ EFI_DRIVER_CONFIGURATION_FORCE_DEFAULTS ForceDefaults;
+ CHAR8 *SupportedLanguages;
+} EFI_DRIVER_CONFIGURATION_PROTOCOL;
+
+/*++
+
+ Protocol Description:
+ Used to set configuration options for a controller that an EFI Driver is managing.
+
+ Parameters:
+ SetOptions - Allows the use to set drivers specific configuration
+ options for a controller that the driver is currently
+ managing.
+ OptionsValid - Tests to see if a controller's current configuration
+ options are valid.
+ ForceDefaults - Forces a driver to set the default configuration options
+ for a controller.
+ SupportedLanguages - A Null-terminated ASCII string that contains one or more
+ ISO 639-2 language codes. This is the list of language
+ codes that this protocol supports.
+
+--*/
+extern EFI_GUID gEfiDriverConfigurationProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/DriverConfiguration2/DriverConfiguration2.c b/EDK/Foundation/Efi/Protocol/DriverConfiguration2/DriverConfiguration2.c
new file mode 100644
index 0000000..0e08bf9
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/DriverConfiguration2/DriverConfiguration2.c
@@ -0,0 +1,30 @@
+/*++
+
+Copyright (c) 2008, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ DriverConfiguration.c
+
+Abstract:
+
+ EFI Driver Configuration Protocol
+
+Revision History
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (DriverConfiguration2)
+
+EFI_GUID gEfiDriverConfiguration2ProtocolGuid = EFI_DRIVER_CONFIGURATION2_PROTOCOL_GUID;
+
+EFI_GUID_STRING
+ (&gEfiDriverConfiguration2ProtocolGuid, "Driver Configuration2 Protocol", "UEFI 2.0 Driver Configuration2 Protocol");
diff --git a/EDK/Foundation/Efi/Protocol/DriverConfiguration2/DriverConfiguration2.h b/EDK/Foundation/Efi/Protocol/DriverConfiguration2/DriverConfiguration2.h
new file mode 100644
index 0000000..170ba23
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/DriverConfiguration2/DriverConfiguration2.h
@@ -0,0 +1,201 @@
+/*++
+
+Copyright (c) 2008, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ DriverConfiguration2.h
+
+Abstract:
+
+ EFI Driver Configuration2 Protocol
+
+Revision History
+
+--*/
+
+#ifndef _EFI_DRIVER_CONFIGURATION2_H_
+#define _EFI_DRIVER_CONFIGURATION2_H_
+
+#include EFI_PROTOCOL_DEFINITION (DriverConfiguration)
+
+//
+// Global ID for the Driver Configuration Protocol
+//
+#define EFI_DRIVER_CONFIGURATION2_PROTOCOL_GUID \
+ { \
+ 0xbfd7dc1d, 0x24f1, 0x40d9, 0x82, 0xe7, 0x2e, 0x09, 0xbb, 0x6b, 0x4e, 0xbe \
+ }
+
+EFI_FORWARD_DECLARATION (EFI_DRIVER_CONFIGURATION2_PROTOCOL);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_DRIVER_CONFIGURATION2_SET_OPTIONS) (
+ IN EFI_DRIVER_CONFIGURATION2_PROTOCOL * This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN CHAR8 *Language,
+ OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED * ActionRequired
+ );
+
+/*++
+
+ Routine Description:
+ Allows the user to set controller specific options for a controller that a
+ driver is currently managing.
+
+ Arguments:
+ This - A pointer to the EFI_DRIVER_CONFIGURATION2_PROTOCOL instance.
+ ControllerHandle - The handle of the controller to set options on.
+ ChildHandle - The handle of the child controller to set options on. This
+ is an optional parameter that may be NULL. It will be NULL
+ for device drivers, and for a bus drivers that wish to set
+ options for the bus controller. It will not be NULL for a
+ bus driver that wishes to set options for one of its child
+ controllers.
+ Language - A pointer to a three character RFC 3066 language identifier.
+ This is the language of the user interface that should be
+ presented to the user, and it must match one of the languages
+ specified in SupportedLanguages. The number of languages
+ supported by a driver is up to the driver writer.
+ ActionRequired - A pointer to the action that the calling agent is required
+ to perform when this function returns. See "Related
+ Definitions" for a list of the actions that the calling
+ agent is required to perform prior to accessing
+ ControllerHandle again.
+
+ Returns:
+ EFI_SUCCESS - The driver specified by This successfully set the
+ configuration options for the controller specified
+ by ControllerHandle..
+ EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.
+ EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE.
+ EFI_INVALID_PARAMETER - ActionRequired is NULL.
+ EFI_UNSUPPORTED - The driver specified by This does not support setting
+ configuration options for the controller specified by
+ ControllerHandle and ChildHandle.
+ EFI_UNSUPPORTED - The driver specified by This does not support the
+ language specified by Language.
+ EFI_DEVICE_ERROR - A device error occurred while attempt to set the
+ configuration options for the controller specified
+ by ControllerHandle and ChildHandle.
+ EFI_OUT_RESOURCES - There are not enough resources available to set the
+ configuration options for the controller specified
+ by ControllerHandle and ChildHandle.
+
+--*/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_DRIVER_CONFIGURATION2_OPTIONS_VALID) (
+ IN EFI_DRIVER_CONFIGURATION2_PROTOCOL * This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL
+ );
+
+/*++
+
+ Routine Description:
+ Tests to see if a controller's current configuration options are valid.
+
+ Arguments:
+ This - A pointer to the EFI_DRIVER_CONFIGURATION2_PROTOCOL instance.
+ ControllerHandle - The handle of the controller to test if it's current
+ configuration options are valid.
+ ChildHandle - The handle of the child controller to test if it's current
+ configuration options are valid. This is an optional
+ parameter that may be NULL. It will be NULL for device
+ drivers. It will also be NULL for a bus drivers that wish
+ to test the configuration options for the bus controller.
+ It will not be NULL for a bus driver that wishes to test
+ configuration options for one of its child controllers.
+
+ Returns:
+ EFI_SUCCESS - The controller specified by ControllerHandle and
+ ChildHandle that is being managed by the driver
+ specified by This has a valid set of configuration
+ options.
+ EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.
+ EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE.
+ EFI_UNSUPPORTED - The driver specified by This is not currently
+ managing the controller specified by ControllerHandle
+ and ChildHandle.
+ EFI_DEVICE_ERROR - The controller specified by ControllerHandle and
+ ChildHandle that is being managed by the driver
+ specified by This has an invalid set of configuration
+ options.
+
+--*/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_DRIVER_CONFIGURATION2_FORCE_DEFAULTS) (
+ IN EFI_DRIVER_CONFIGURATION2_PROTOCOL * This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN UINT32 DefaultType,
+ OUT EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED * ActionRequired
+ );
+
+/*++
+
+ Routine Description:
+ Forces a driver to set the default configuration options for a controller.
+
+ Arguments:
+ This - A pointer to the EFI_DRIVER_CONFIGURATION2_PROTOCOL instance.
+ ControllerHandle - The handle of the controller to force default configuration options on.
+ ChildHandle - The handle of the child controller to force default configuration options on This is an optional parameter that may be NULL. It will be NULL for device drivers. It will also be NULL for a bus drivers that wish to force default configuration options for the bus controller. It will not be NULL for a bus driver that wishes to force default configuration options for one of its child controllers.
+ DefaultType - The type of default configuration options to force on the controller specified by ControllerHandle and ChildHandle. See Table 9-1 for legal values. A DefaultType of 0x00000000 must be supported by this protocol.
+ ActionRequired - A pointer to the action that the calling agent is required to perform when this function returns. See "Related Definitions" in Section 9.1for a list of the actions that the calling agent is required to perform prior to accessing ControllerHandle again.
+
+ Returns:
+ EFI_SUCCESS - The driver specified by This successfully forced the default configuration options on the controller specified by ControllerHandle and ChildHandle.
+ EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.
+ EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid EFI_HANDLE.
+ EFI_INVALID_PARAMETER - ActionRequired is NULL.
+ EFI_UNSUPPORTED - The driver specified by This does not support forcing the default configuration options on the controller specified by ControllerHandle and ChildHandle.
+ EFI_UNSUPPORTED - The driver specified by This does not support the configuration type specified by DefaultType.
+ EFI_DEVICE_ERROR - A device error occurred while attempt to force the default configuration options on the controller specified by ControllerHandle and ChildHandle.
+ EFI_OUT_RESOURCES - There are not enough resources available to force the default configuration options on the controller specified by ControllerHandle and ChildHandle.
+
+--*/
+
+//
+// Interface structure for the Driver Configuration Protocol
+//
+typedef struct _EFI_DRIVER_CONFIGURATION2_PROTOCOL {
+ EFI_DRIVER_CONFIGURATION2_SET_OPTIONS SetOptions;
+ EFI_DRIVER_CONFIGURATION2_OPTIONS_VALID OptionsValid;
+ EFI_DRIVER_CONFIGURATION2_FORCE_DEFAULTS ForceDefaults;
+ CHAR8 *SupportedLanguages;
+} EFI_DRIVER_CONFIGURATION2_PROTOCOL;
+
+/*++
+
+ Protocol Description:
+ Used to set configuration options for a controller that an EFI Driver is managing.
+
+ Parameters:
+ SetOptions - Allows the use to set drivers specific configuration
+ options for a controller that the driver is currently
+ managing.
+ OptionsValid - Tests to see if a controller's current configuration
+ options are valid.
+ ForceDefaults - Forces a driver to set the default configuration options
+ for a controller.
+ SupportedLanguages - A Null-terminated ASCII string that contains one or more
+ RFC 3066 language codes. This is the list of language
+ codes that this protocol supports.
+
+--*/
+
+extern EFI_GUID gEfiDriverConfiguration2ProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/DriverDiagnostics/DriverDiagnostics.c b/EDK/Foundation/Efi/Protocol/DriverDiagnostics/DriverDiagnostics.c
new file mode 100644
index 0000000..4d7b8a0
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/DriverDiagnostics/DriverDiagnostics.c
@@ -0,0 +1,30 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ DriverDiagnostics.c
+
+Abstract:
+
+ EFI Driver Diagnostics Protocol
+
+Revision History
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (DriverDiagnostics)
+
+EFI_GUID gEfiDriverDiagnosticsProtocolGuid = EFI_DRIVER_DIAGNOSTICS_PROTOCOL_GUID;
+
+EFI_GUID_STRING
+ (&gEfiDriverDiagnosticsProtocolGuid, "Driver Diagnostics Protocol", "EFI 1.1 Driver Diagnostics Protocol");
diff --git a/EDK/Foundation/Efi/Protocol/DriverDiagnostics/DriverDiagnostics.h b/EDK/Foundation/Efi/Protocol/DriverDiagnostics/DriverDiagnostics.h
new file mode 100644
index 0000000..dfcd299
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/DriverDiagnostics/DriverDiagnostics.h
@@ -0,0 +1,138 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ DriverDiagnostics.h
+
+Abstract:
+
+ EFI Driver Diagnostics Protocol
+
+Revision History
+
+--*/
+
+#ifndef _EFI_DRIVER_DIAGNOSTICS_H_
+#define _EFI_DRIVER_DIAGNOSTICS_H_
+
+//
+// Global ID for the Driver Diagnostics Protocol
+//
+#define EFI_DRIVER_DIAGNOSTICS_PROTOCOL_GUID \
+ { \
+ 0x0784924f, 0xe296, 0x11d4, 0x9a, 0x49, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d \
+ }
+
+EFI_FORWARD_DECLARATION (EFI_DRIVER_DIAGNOSTICS_PROTOCOL);
+
+typedef enum {
+ EfiDriverDiagnosticTypeStandard = 0,
+ EfiDriverDiagnosticTypeExtended = 1,
+ EfiDriverDiagnosticTypeManufacturing= 2,
+ EfiDriverDiagnosticTypeMaximum
+} EFI_DRIVER_DIAGNOSTIC_TYPE;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_DRIVER_DIAGNOSTICS_RUN_DIAGNOSTICS) (
+ IN EFI_DRIVER_DIAGNOSTICS_PROTOCOL * This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN EFI_DRIVER_DIAGNOSTIC_TYPE DiagnosticType,
+ IN CHAR8 *Language,
+ OUT EFI_GUID **ErrorType,
+ OUT UINTN *BufferSize,
+ OUT CHAR16 **Buffer
+ );
+
+/*++
+
+ Routine Description:
+ Runs diagnostics on a controller.
+
+ Arguments:
+ This - A pointer to the EFI_DRIVER_DIAGNOSTICS_PROTOCOL instance.
+ ControllerHandle - The handle of the controller to run diagnostics on.
+ ChildHandle - The handle of the child controller to run diagnostics on
+ This is an optional parameter that may be NULL. It will
+ be NULL for device drivers. It will also be NULL for a
+ bus drivers that wish to run diagnostics on the bus
+ controller. It will not be NULL for a bus driver that
+ wishes to run diagnostics on one of its child controllers.
+ DiagnosticType - Indicates type of diagnostics to perform on the controller
+ specified by ControllerHandle and ChildHandle. See
+ "Related Definitions" for the list of supported types.
+ Language - A pointer to a three character ISO 639-2 language
+ identifier. This is the language in which the optional
+ error message should be returned in Buffer, and it must
+ match one of the languages specified in SupportedLanguages.
+ The number of languages supported by a driver is up to
+ the driver writer.
+ ErrorType - A GUID that defines the format of the data returned in
+ Buffer.
+ BufferSize - The size, in bytes, of the data returned in Buffer.
+ Buffer - A buffer that contains a Null-terminated Unicode string
+ plus some additional data whose format is defined by
+ ErrorType. Buffer is allocated by this function with
+ AllocatePool(), and it is the caller's responsibility
+ to free it with a call to FreePool().
+
+ Returns:
+ EFI_SUCCESS - The controller specified by ControllerHandle and
+ ChildHandle passed the diagnostic.
+ EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.
+ EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid
+ EFI_HANDLE.
+ EFI_INVALID_PARAMETER - Language is NULL.
+ EFI_INVALID_PARAMETER - ErrorType is NULL.
+ EFI_INVALID_PARAMETER - BufferType is NULL.
+ EFI_INVALID_PARAMETER - Buffer is NULL.
+ EFI_UNSUPPORTED - The driver specified by This does not support
+ running diagnostics for the controller specified
+ by ControllerHandle and ChildHandle.
+ EFI_UNSUPPORTED - The driver specified by This does not support the
+ type of diagnostic specified by DiagnosticType.
+ EFI_UNSUPPORTED - The driver specified by This does not support the
+ language specified by Language.
+ EFI_OUT_OF_RESOURCES - There are not enough resources available to complete
+ the diagnostics.
+ EFI_OUT_OF_RESOURCES - There are not enough resources available to return
+ the status information in ErrorType, BufferSize,
+ and Buffer.
+ EFI_DEVICE_ERROR - The controller specified by ControllerHandle and
+ ChildHandle did not pass the diagnostic.
+
+--*/
+
+//
+// Interface structure for the Driver Diagnostics Protocol
+//
+typedef struct _EFI_DRIVER_DIAGNOSTICS_PROTOCOL {
+ EFI_DRIVER_DIAGNOSTICS_RUN_DIAGNOSTICS RunDiagnostics;
+ CHAR8 *SupportedLanguages;
+} EFI_DRIVER_DIAGNOSTICS_PROTOCOL;
+
+/*++
+
+ Protocol Description:
+ Used to perform diagnostics on a controller that an EFI Driver is managing.
+
+ Parameters:
+ RunDiagnostics - Runs diagnostics on a controller.
+ SupportedLanguages - A Null-terminated ASCII string that contains one or more
+ ISO 639-2 language codes. This is the list of language
+ codes that this protocol supports.
+
+--*/
+extern EFI_GUID gEfiDriverDiagnosticsProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/DriverDiagnostics2/DriverDiagnostics2.c b/EDK/Foundation/Efi/Protocol/DriverDiagnostics2/DriverDiagnostics2.c
new file mode 100644
index 0000000..5290af2
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/DriverDiagnostics2/DriverDiagnostics2.c
@@ -0,0 +1,30 @@
+/*++
+
+Copyright (c) 2008, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ DriverDiagnostics2.c
+
+Abstract:
+
+ EFI Driver Diagnostics2 Protocol
+
+Revision History
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (DriverDiagnostics2)
+
+EFI_GUID gEfiDriverDiagnostics2ProtocolGuid = EFI_DRIVER_DIAGNOSTICS2_PROTOCOL_GUID;
+
+EFI_GUID_STRING
+ (&gEfiDriverDiagnostics2ProtocolGuid, "Driver Diagnostics Protocol", "UEFI 2.0 Driver Diagnostics2 Protocol");
diff --git a/EDK/Foundation/Efi/Protocol/DriverDiagnostics2/DriverDiagnostics2.h b/EDK/Foundation/Efi/Protocol/DriverDiagnostics2/DriverDiagnostics2.h
new file mode 100644
index 0000000..3ae7ba2
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/DriverDiagnostics2/DriverDiagnostics2.h
@@ -0,0 +1,135 @@
+/*++
+
+Copyright (c) 2008, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ DriverDiagnostics2.h
+
+Abstract:
+
+ EFI Driver Diagnostics2 Protocol
+
+Revision History
+
+--*/
+
+#ifndef _EFI_DRIVER_DIAGNOSTICS2_H_
+#define _EFI_DRIVER_DIAGNOSTICS2_H_
+
+#include EFI_PROTOCOL_DEFINITION (DriverDiagnostics)
+
+//
+// Global ID for the Driver Diagnostics Protocol
+//
+#define EFI_DRIVER_DIAGNOSTICS2_PROTOCOL_GUID \
+ { \
+ 0x4d330321, 0x025f, 0x4aac, 0x90, 0xd8, 0x5e, 0xd9, 0x0, 0x17, 0x3b, 0x63 \
+ }
+
+EFI_FORWARD_DECLARATION (EFI_DRIVER_DIAGNOSTICS2_PROTOCOL);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_DRIVER_DIAGNOSTICS2_RUN_DIAGNOSTICS) (
+ IN EFI_DRIVER_DIAGNOSTICS2_PROTOCOL * This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN EFI_DRIVER_DIAGNOSTIC_TYPE DiagnosticType,
+ IN CHAR8 *Language,
+ OUT EFI_GUID **ErrorType,
+ OUT UINTN *BufferSize,
+ OUT CHAR16 **Buffer
+ );
+
+/*++
+
+ Routine Description:
+ Runs diagnostics on a controller.
+
+ Arguments:
+ This - A pointer to the EFI_DRIVER_DIAGNOSTICS2_PROTOCOL instance.
+ ControllerHandle - The handle of the controller to run diagnostics on.
+ ChildHandle - The handle of the child controller to run diagnostics on
+ This is an optional parameter that may be NULL. It will
+ be NULL for device drivers. It will also be NULL for a
+ bus drivers that wish to run diagnostics on the bus
+ controller. It will not be NULL for a bus driver that
+ wishes to run diagnostics on one of its child controllers.
+ DiagnosticType - Indicates type of diagnostics to perform on the controller
+ specified by ControllerHandle and ChildHandle. See
+ "Related Definitions" for the list of supported types.
+ Language - A pointer to a NULL-terminated ASCII string array indicating
+ the language. This is the language in which the optional
+ error message should be returned in Buffer, and it must
+ match one of the languages specified in SupportedLanguages.
+ The number of languages supported by a driver is up to
+ the driver writer. Language is specified in RFC 3066
+ language code format.
+ ErrorType - A GUID that defines the format of the data returned in
+ Buffer.
+ BufferSize - The size, in bytes, of the data returned in Buffer.
+ Buffer - A buffer that contains a Null-terminated Unicode string
+ plus some additional data whose format is defined by
+ ErrorType. Buffer is allocated by this function with
+ AllocatePool(), and it is the caller's responsibility
+ to free it with a call to FreePool().
+
+ Returns:
+ EFI_SUCCESS - The controller specified by ControllerHandle and
+ ChildHandle passed the diagnostic.
+ EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.
+ EFI_INVALID_PARAMETER - ChildHandle is not NULL and it is not a valid
+ EFI_HANDLE.
+ EFI_INVALID_PARAMETER - Language is NULL.
+ EFI_INVALID_PARAMETER - ErrorType is NULL.
+ EFI_INVALID_PARAMETER - BufferType is NULL.
+ EFI_INVALID_PARAMETER - Buffer is NULL.
+ EFI_UNSUPPORTED - The driver specified by This does not support
+ running diagnostics for the controller specified
+ by ControllerHandle and ChildHandle.
+ EFI_UNSUPPORTED - The driver specified by This does not support the
+ type of diagnostic specified by DiagnosticType.
+ EFI_UNSUPPORTED - The driver specified by This does not support the
+ language specified by Language.
+ EFI_OUT_OF_RESOURCES - There are not enough resources available to complete
+ the diagnostics.
+ EFI_OUT_OF_RESOURCES - There are not enough resources available to return
+ the status information in ErrorType, BufferSize,
+ and Buffer.
+ EFI_DEVICE_ERROR - The controller specified by ControllerHandle and
+ ChildHandle did not pass the diagnostic.
+
+--*/
+
+//
+// Interface structure for the Driver Diagnostics Protocol
+//
+typedef struct _EFI_DRIVER_DIAGNOSTICS2_PROTOCOL {
+ EFI_DRIVER_DIAGNOSTICS2_RUN_DIAGNOSTICS RunDiagnostics;
+ CHAR8 *SupportedLanguages;
+} EFI_DRIVER_DIAGNOSTICS2_PROTOCOL;
+
+/*++
+
+ Protocol Description:
+ Used to perform diagnostics on a controller that an EFI Driver is managing.
+
+ Parameters:
+ RunDiagnostics - Runs diagnostics on a controller.
+ SupportedLanguages - A Null-terminated ASCII string that contains one or more
+ RFC 3066 language codes. This is the list of language
+ codes that this protocol supports.
+
+--*/
+
+extern EFI_GUID gEfiDriverDiagnostics2ProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/DriverSupportedEfiVersion/DriverSupportedEfiVersion.c b/EDK/Foundation/Efi/Protocol/DriverSupportedEfiVersion/DriverSupportedEfiVersion.c
new file mode 100644
index 0000000..4266a69
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/DriverSupportedEfiVersion/DriverSupportedEfiVersion.c
@@ -0,0 +1,30 @@
+/*++
+
+Copyright (c) 2008, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ DriverSupportedEfiVersion.c
+
+Abstract:
+
+ Driver Supported EFI Version Protocol
+
+Revision History:
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (DriverSupportedEfiVersion)
+
+EFI_GUID gEfiDriverSupportedEfiVersionProtocolGuid = EFI_DRIVER_SUPPORTED_EFI_VERSION_PROTOCOL_GUID;
+
+EFI_GUID_STRING
+ (&gEfiDriverSupportedEfiVersionProtocolGuid, "Driver Supported EFI Version Protocol", "UEFI 2.1 Driver Supported EFI Version Protocol");
diff --git a/EDK/Foundation/Efi/Protocol/DriverSupportedEfiVersion/DriverSupportedEfiVersion.h b/EDK/Foundation/Efi/Protocol/DriverSupportedEfiVersion/DriverSupportedEfiVersion.h
new file mode 100644
index 0000000..6300050
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/DriverSupportedEfiVersion/DriverSupportedEfiVersion.h
@@ -0,0 +1,47 @@
+/*++
+
+Copyright (c) 2008, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ DriverSupportedEfiVersion.h
+
+Abstract:
+
+ Driver Supported EFI Version Protocol
+
+Revision History:
+
+--*/
+
+#ifndef _EFI_DRIVER_SUPPORTED_EFI_VERSION_H_
+#define _EFI_DRIVER_SUPPORTED_EFI_VERSION_H_
+
+//
+// Global ID for the Driver Supported EFI Version Protocol
+//
+#define EFI_DRIVER_SUPPORTED_EFI_VERSION_PROTOCOL_GUID \
+ { \
+ 0x5c198761, 0x16a8, 0x4e69, 0x97, 0x2c, 0x89, 0xd6, 0x79, 0x54, 0xf8, 0x1d \
+ }
+
+EFI_FORWARD_DECLARATION (EFI_DRIVER_SUPPORTED_EFI_VERSION_PROTOCOL);
+
+//
+// Interface structure for the Driver Supported EFI Version Protocol
+//
+typedef struct _EFI_DRIVER_SUPPORTED_EFI_VERSION_PROTOCOL {
+ UINT32 Length;
+ UINT32 FirmwareVersion;
+} EFI_DRIVER_SUPPORTED_EFI_VERSION_PROTOCOL;
+
+extern EFI_GUID gEfiDriverSupportedEfiVersionProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/Ebc/Ebc.c b/EDK/Foundation/Efi/Protocol/Ebc/Ebc.c
new file mode 100644
index 0000000..fa2796a
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/Ebc/Ebc.c
@@ -0,0 +1,28 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Ebc.c
+
+Abstract:
+
+ EBC protocol as defined in the EFI 1.1 specification.
+
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (Ebc)
+
+EFI_GUID gEfiEbcProtocolGuid = EFI_EBC_INTERPRETER_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiEbcProtocolGuid, "EBC Protocol", "EFI 1.1 EBC protocol");
diff --git a/EDK/Foundation/Efi/Protocol/Ebc/Ebc.h b/EDK/Foundation/Efi/Protocol/Ebc/Ebc.h
new file mode 100644
index 0000000..55217ae
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/Ebc/Ebc.h
@@ -0,0 +1,183 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Ebc.h
+
+Abstract:
+
+ Describes the protocol interface to the EBC interpreter.
+
+--*/
+
+#ifndef _EBC_H_
+#define _EBC_H_
+
+#define EFI_EBC_INTERPRETER_PROTOCOL_GUID \
+ { \
+ 0x13AC6DD1, 0x73D0, 0x11D4, 0xB0, 0x6B, 0x00, 0xAA, 0x00, 0xBD, 0x6D, 0xE7 \
+ }
+
+//
+// Define for forward reference.
+//
+EFI_FORWARD_DECLARATION (EFI_EBC_PROTOCOL);
+
+/*++
+
+Routine Description:
+
+ Create a thunk for an image entry point. In short, given the physical address
+ of the entry point for a loaded image, create a thunk that does some
+ fixup of arguments (and perform any other necessary overhead) and then
+ calls the original entry point. The caller can then use the returned pointer
+ to the created thunk as the new entry point to image.
+
+Arguments:
+
+ This - protocol instance pointer
+ ImageHandle - handle to the image. The EBC interpreter may use this to keep
+ track of any resource allocations performed in loading and
+ executing the image.
+ EbcEntryPoint - the entry point for the image (as defined in the file header)
+ Thunk - pointer to thunk pointer where the address of the created
+ thunk is returned.
+
+Returns:
+
+ Standard EFI_STATUS
+
+--*/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_EBC_CREATE_THUNK) (
+ IN EFI_EBC_PROTOCOL * This,
+ IN EFI_HANDLE ImageHandle,
+ IN VOID *EbcEntryPoint,
+ OUT VOID **Thunk
+ );
+
+/*++
+
+Routine Description:
+
+ Perform any cleanup necessary when an image is unloaded. Basically it gives
+ the EBC interpreter the chance to free up any resources allocated during
+ load and execution of an EBC image.
+
+Arguments:
+
+ This - protocol instance pointer
+ ImageHandle - the handle of the image being unloaded.
+
+Returns:
+
+ Standard EFI_STATUS.
+
+--*/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_EBC_UNLOAD_IMAGE) (
+ IN EFI_EBC_PROTOCOL * This,
+ IN EFI_HANDLE ImageHandle
+ );
+
+/*++
+
+Routine Description:
+
+ The I-Cache-flush registration service takes a pointer to a function to
+ call to flush the I-Cache. Here's the prototype for that function pointer.
+
+Arguments:
+
+ Start - physical start address of CPU instruction cache to flush.
+ Length - how many bytes to flush of the instruction cache.
+
+Returns:
+
+ Standard EFI_STATUS.
+
+--*/
+typedef
+EFI_STATUS
+(EFIAPI *EBC_ICACHE_FLUSH) (
+ IN EFI_PHYSICAL_ADDRESS Start,
+ IN UINT64 Length
+ );
+
+/*++
+
+Routine Description:
+
+ This routine is called by the core firmware to provide the EBC driver with
+ a function to call to flush the CPU's instruction cache following creation
+ of a thunk. It is not required.
+
+Arguments:
+
+ This - protocol instance pointer
+ Flush - pointer to the function to call to flush the CPU instruction
+ cache.
+
+Returns:
+
+ Standard EFI_STATUS.
+
+--*/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_EBC_REGISTER_ICACHE_FLUSH) (
+ IN EFI_EBC_PROTOCOL * This,
+ IN EBC_ICACHE_FLUSH Flush
+ );
+
+/*++
+
+Routine Description:
+
+ This routine can be called to get the VM revision. It returns the same
+ value as the EBC BREAK 1 instruction returns.
+
+Arguments:
+
+ This - protocol instance pointer
+ Version - pointer to where to return the VM version
+
+Returns:
+
+ Standard EFI_STATUS.
+
+--*/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_EBC_GET_VERSION) (
+ IN EFI_EBC_PROTOCOL * This,
+ IN OUT UINT64 *Version
+ );
+
+//
+// Prototype for the actual EBC protocol interface
+//
+typedef struct _EFI_EBC_PROTOCOL {
+ EFI_EBC_CREATE_THUNK CreateThunk;
+ EFI_EBC_UNLOAD_IMAGE UnloadImage;
+ EFI_EBC_REGISTER_ICACHE_FLUSH RegisterICacheFlush;
+ EFI_EBC_GET_VERSION GetVersion;
+} EFI_EBC_PROTOCOL;
+
+//
+// Extern the global EBC protocol GUID
+//
+extern EFI_GUID gEfiEbcProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/EdidActive/EdidActive.c b/EDK/Foundation/Efi/Protocol/EdidActive/EdidActive.c
new file mode 100644
index 0000000..c045ce7
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/EdidActive/EdidActive.c
@@ -0,0 +1,29 @@
+/*++
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EdidActive.c
+
+Abstract:
+
+ EDID Active Protocol from the UEFI 2.0 specification.
+
+ Placed on the video output device child handle that are actively displaying output.
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (EdidActive)
+
+EFI_GUID gEfiEdidActiveProtocolGuid = EFI_EDID_ACTIVE_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiEdidActiveProtocolGuid, "EFI EDID Active Protocol", "UEFI EDID Active Protocol");
diff --git a/EDK/Foundation/Efi/Protocol/EdidActive/EdidActive.h b/EDK/Foundation/Efi/Protocol/EdidActive/EdidActive.h
new file mode 100644
index 0000000..912747c
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/EdidActive/EdidActive.h
@@ -0,0 +1,39 @@
+/*++
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EdidActive.h
+
+Abstract:
+
+ EDID Active Protocol from the UEFI 2.0 specification.
+
+ Placed on the video output device child handle that are actively displaying output.
+
+--*/
+
+#ifndef __EDID_ACTIVE_H__
+#define __EDID_ACTIVE_H__
+
+#define EFI_EDID_ACTIVE_PROTOCOL_GUID \
+ { \
+ 0xbd8c1056, 0x9f36, 0x44ec, 0x92, 0xa8, 0xa6, 0x33, 0x7f, 0x81, 0x79, 0x86 \
+ }
+
+typedef struct {
+ UINT32 SizeOfEdid;
+ UINT8 *Edid;
+} EFI_EDID_ACTIVE_PROTOCOL;
+
+extern EFI_GUID gEfiEdidActiveProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/EdidDiscovered/EdidDiscovered.c b/EDK/Foundation/Efi/Protocol/EdidDiscovered/EdidDiscovered.c
new file mode 100644
index 0000000..19e558a
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/EdidDiscovered/EdidDiscovered.c
@@ -0,0 +1,30 @@
+/*++
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EdidDiscovered.c
+
+Abstract:
+
+ EDID Discovered Protocol from the UEFI 2.0 specification.
+
+ This protocol is placed on the video output device child handle and it represents
+ the EDID information being used for output device represented by the child handle.
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (EdidDiscovered)
+
+EFI_GUID gEfiEdidDiscoveredProtocolGuid = EFI_EDID_DISCOVERED_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiEdidDiscoveredProtocolGuid, "EFI EDID Discovered Protocol", "UEFI EDID Discovered Protocol");
diff --git a/EDK/Foundation/Efi/Protocol/EdidDiscovered/EdidDiscovered.h b/EDK/Foundation/Efi/Protocol/EdidDiscovered/EdidDiscovered.h
new file mode 100644
index 0000000..32804ac
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/EdidDiscovered/EdidDiscovered.h
@@ -0,0 +1,40 @@
+/*++
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EdidDiscovered.h
+
+Abstract:
+
+ EDID Discovered Protocol from the UEFI 2.0 specification.
+
+ This protocol is placed on the video output device child handle and it represents
+ the EDID information being used for output device represented by the child handle.
+
+--*/
+
+#ifndef __EDID_DISCOVERED_H__
+#define __EDID_DISCOVERED_H__
+
+#define EFI_EDID_DISCOVERED_PROTOCOL_GUID \
+ { \
+ 0x1c0c34f6, 0xd380, 0x41fa, 0xa0, 0x49, 0x8a, 0xd0, 0x6c,0x1a, 0x66, 0xaa \
+ }
+
+typedef struct {
+ UINT32 SizeOfEdid;
+ UINT8 *Edid;
+} EFI_EDID_DISCOVERED_PROTOCOL;
+
+extern EFI_GUID gEfiEdidDiscoveredProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/EdidOverride/EdidOverride.c b/EDK/Foundation/Efi/Protocol/EdidOverride/EdidOverride.c
new file mode 100644
index 0000000..a828f01
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/EdidOverride/EdidOverride.c
@@ -0,0 +1,30 @@
+/*++
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EdidOverride.c
+
+Abstract:
+
+ EDID Override Protocol from the UEFI 2.0 specification.
+
+ Allow platform to provide EDID information to producer of the Graphics Output
+ protocol.
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (EdidOverride)
+
+EFI_GUID gEfiEdidOverrideProtocolGuid = EFI_EDID_OVERRIDE_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiEdidOverrideProtocolGuid, "EFI EDID Override Protocol", "UEFI EDID Override Protocol");
diff --git a/EDK/Foundation/Efi/Protocol/EdidOverride/EdidOverride.h b/EDK/Foundation/Efi/Protocol/EdidOverride/EdidOverride.h
new file mode 100644
index 0000000..4382eb2
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/EdidOverride/EdidOverride.h
@@ -0,0 +1,78 @@
+/*++
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EdidOverride.h
+
+Abstract:
+
+ EDID Override Protocol from the UEFI 2.0 specification.
+
+ Allow platform to provide EDID information to producer of the Graphics Output
+ protocol.
+
+--*/
+
+#ifndef __EDID_OVERRIDE_H__
+#define __EDID_OVERRIDE_H__
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (EdidDiscovered)
+
+#define EFI_EDID_OVERRIDE_PROTOCOL_GUID \
+ { \
+ 0x48ecb431, 0xfb72, 0x45c0, 0xa9, 0x22, 0xf4, 0x58, 0xfe, 0x4, 0xb, 0xd5 \
+ }
+
+typedef struct _EFI_EDID_OVERRIDE_PROTOCOL EFI_EDID_OVERRIDE_PROTOCOL;
+
+#define EFI_EDID_OVERRIDE_DONT_OVERRIDE 0x01
+#define EFI_EDID_OVERRIDE_ENABLE_HOT_PLUG 0x02
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_EDID_OVERRIDE_PROTOCOL_GET_EDID) (
+ IN EFI_EDID_OVERRIDE_PROTOCOL *This,
+ IN EFI_HANDLE *ChildHandle,
+ OUT UINT32 *Attributes,
+ IN OUT UINTN *EdidSize,
+ IN OUT UINT8 **Edid
+ )
+/*++
+
+ Routine Description:
+ Return the current video mode information.
+
+ Arguments:
+ This - Protocol instance pointer.
+ ChildHandle - A child handle produced by the Graphics Output EFI
+ driver that represents a video output device.
+ Attributes - The attributes associated with ChildHandle video output device.
+ EdidSize - A pointer to the size, in bytes, of the Edid buffer.
+ Edid - A pointer to callee allocated buffer that contains the EDID that
+ should be used for ChildHandle. A value of NULL
+ represents no EDID override for ChildHandle.
+
+ Returns:
+ EFI_SUCCESS - Valid overrides returned for ChildHandle.
+ EFI_UNSUPPORTED - ChildHandle has no overrides.
+
+--*/
+;
+
+typedef struct _EFI_EDID_OVERRIDE_PROTOCOL {
+ EFI_EDID_OVERRIDE_PROTOCOL_GET_EDID GetEdid;
+} EFI_EDID_OVERRIDE_PROTOCOL;
+
+extern EFI_GUID gEfiEdidOverrideProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/EfiNetworkInterfaceIdentifier/EfiNetworkInterfaceIdentifier.c b/EDK/Foundation/Efi/Protocol/EfiNetworkInterfaceIdentifier/EfiNetworkInterfaceIdentifier.c
new file mode 100644
index 0000000..6b0280c
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/EfiNetworkInterfaceIdentifier/EfiNetworkInterfaceIdentifier.c
@@ -0,0 +1,40 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiNetworkInterfaceIdentifier.c
+
+Abstract:
+
+
+Revision History
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (EfiNetworkInterfaceIdentifier)
+
+EFI_GUID gEfiNetworkInterfaceIdentifierProtocolGuid = EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_GUID;
+
+EFI_GUID_STRING
+ (
+ &gEfiNetworkInterfaceIdentifierProtocolGuid, "Network Interface Identifier Protocol",
+ "EFI Network Interface Identifier Protocol"
+ );
+
+EFI_GUID gEfiNetworkInterfaceIdentifierProtocolGuid_31 = EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_GUID_31;
+
+EFI_GUID_STRING
+ (
+ &gEfiNetworkInterfaceIdentifierProtocolGuid_31, "Network Interface Identifier Protocol_31",
+ "EFI1.1 Network Interface Identifier Protocol"
+ );
diff --git a/EDK/Foundation/Efi/Protocol/EfiNetworkInterfaceIdentifier/EfiNetworkInterfaceIdentifier.h b/EDK/Foundation/Efi/Protocol/EfiNetworkInterfaceIdentifier/EfiNetworkInterfaceIdentifier.h
new file mode 100644
index 0000000..b2f1c85
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/EfiNetworkInterfaceIdentifier/EfiNetworkInterfaceIdentifier.h
@@ -0,0 +1,102 @@
+/*++
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module name:
+
+ EfiNetworkInterfaceIdentifier.h
+
+Abstract:
+
+Revision history:
+ 2000-Feb-18 M(f)J GUID updated.
+ Structure order changed for machine word alignment.
+ Added StringId[4] to structure.
+
+ 2000-Feb-14 M(f)J Genesis.
+--*/
+#ifndef _EFI_NETWORKINTERFACEIDENTIFER_H
+#define _EFI_NETWORKINTERFACEIDENTIFER_H
+
+
+#define EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_GUID \
+ { \
+ 0xE18541CD, 0xF755, 0x4f73, 0x92, 0x8D, 0x64, 0x3C, 0x8A, 0x79, 0xB2, 0x29 \
+ }
+#define EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_GUID_31 \
+ { \
+ 0x1ACED566, 0x76ED, 0x4218, 0xBC, 0x81, 0x76, 0x7F, 0x1F, 0x97, 0x7A, 0x89 \
+ }
+
+#define EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_REVISION 0x00010000
+#define EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL_REVISION_31 0x00010001
+
+//
+// Forward reference for pure ANSI compatability
+//
+EFI_FORWARD_DECLARATION (EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL);
+
+typedef enum {
+ EfiNetworkInterfaceUndi = 1
+} EFI_NETWORK_PROTOCOL_TYPE;
+
+typedef struct _EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL {
+
+ UINT64 Revision;
+ //
+ // Revision of the network interface identifier protocol interface.
+ //
+ UINT64 ID;
+ //
+ // Address of the first byte of the identifying structure for this
+ // network interface. This is set to zero if there is no structure.
+ //
+ // For PXE/UNDI this is the first byte of the !PXE structure.
+ //
+ UINT64 ImageAddr;
+ //
+ // Address of the UNrelocated driver/ROM image. This is set
+ // to zero if there is no driver/ROM image.
+ //
+ // For 16-bit UNDI, this is the first byte of the option ROM in
+ // upper memory.
+ //
+ // For 32/64-bit S/W UNDI, this is the first byte of the EFI ROM
+ // image.
+ //
+ // For H/W UNDI, this is set to zero.
+ //
+ UINT32 ImageSize;
+ //
+ // Size of the UNrelocated driver/ROM image of this network interface.
+ // This is set to zero if there is no driver/ROM image.
+ //
+ CHAR8 StringId[4];
+ //
+ // 4 char ASCII string to go in class identifier (option 60) in DHCP
+ // and Boot Server discover packets.
+ // For EfiNetworkInterfaceUndi this field is "UNDI".
+ // For EfiNetworkInterfaceSnp this field is "SNPN".
+ //
+ UINT8 Type;
+ UINT8 MajorVer;
+ UINT8 MinorVer;
+ //
+ // Information to be placed into the PXE DHCP and Discover packets.
+ // This is the network interface type and version number that will
+ // be placed into DHCP option 94 (client network interface identifier).
+ //
+ BOOLEAN Ipv6Supported;
+ UINT8 IfNum; // interface number to be used with pxeid structure
+} EFI_NETWORK_INTERFACE_IDENTIFIER_PROTOCOL;
+
+extern EFI_GUID gEfiNetworkInterfaceIdentifierProtocolGuid;
+extern EFI_GUID gEfiNetworkInterfaceIdentifierProtocolGuid_31;
+
+#endif // _EFI_NII_H
diff --git a/EDK/Foundation/Efi/Protocol/EfiProtocolLib.cif b/EDK/Foundation/Efi/Protocol/EfiProtocolLib.cif
new file mode 100644
index 0000000..eb14560
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/EfiProtocolLib.cif
@@ -0,0 +1,165 @@
+<component>
+ name = "EfiProtocolLib"
+ category = ModulePart
+ LocalRoot = "Edk\Foundation\Efi\Protocol\"
+ RefName = "EfiProtocolLib"
+[files]
+"EfiProtocolLib.sdl"
+"EfiProtocolLib.mak"
+"AbsolutePointer\AbsolutePointer.h"
+"AbsolutePointer\AbsolutePointer.c"
+"AcpiTable\AcpiTable.h"
+"AcpiTable\AcpiTable.c"
+"Arp\Arp.h"
+"Arp\Arp.c"
+"AuthenticationInfo\AuthenticationInfo.h"
+"AuthenticationInfo\AuthenticationInfo.c"
+"Bis\Bis.h"
+"Bis\Bis.c"
+"BlockIO\BlockIO.h"
+"BlockIO\BlockIO.c"
+"BusSpecificDriverOverride\BusSpecificDriverOverride.h"
+"BusSpecificDriverOverride\BusSpecificDriverOverride.c"
+"ComponentName\ComponentName.h"
+"ComponentName\ComponentName.c"
+"ComponentName2\ComponentName2.h"
+"ComponentName2\ComponentName2.c"
+"DebugPort\DebugPort.h"
+"DebugPort\DebugPort.c"
+"DebugSupport\DebugSupport.h"
+"DebugSupport\DebugSupport.c"
+"Decompress\Decompress.h"
+"Decompress\Decompress.c"
+"DeviceIO\DeviceIO.h"
+"DeviceIO\DeviceIO.c"
+"DevicePath\DevicePath.h"
+"DevicePath\DevicePath.c"
+"DevicePathFromText\DevicePathFromText.h"
+"DevicePathFromText\DevicePathFromText.c"
+"DevicePathToText\DevicePathToText.h"
+"DevicePathToText\DevicePathToText.c"
+"DevicePathUtilities\DevicePathUtilities.h"
+"DevicePathUtilities\DevicePathUtilities.c"
+"Dhcp4\Dhcp4.h"
+"Dhcp4\Dhcp4.c"
+"DiskIO\DiskIo.h"
+"DiskIO\DiskIo.c"
+"DriverBinding\DriverBinding.h"
+"DriverBinding\DriverBinding.c"
+"DriverConfiguration\DriverConfiguration.h"
+"DriverConfiguration\DriverConfiguration.c"
+"DriverConfiguration2\DriverConfiguration2.h"
+"DriverConfiguration2\DriverConfiguration2.c"
+"DriverDiagnostics\DriverDiagnostics.h"
+"DriverDiagnostics\DriverDiagnostics.c"
+"DriverDiagnostics2\DriverDiagnostics2.h"
+"DriverDiagnostics2\DriverDiagnostics2.c"
+"DriverSupportedEfiVersion\DriverSupportedEfiVersion.h"
+"DriverSupportedEfiVersion\DriverSupportedEfiVersion.c"
+"Ebc\Ebc.h"
+"Ebc\Ebc.c"
+"EdidActive\EdidActive.h"
+"EdidActive\EdidActive.c"
+"EdidDiscovered\EdidDiscovered.h"
+"EdidDiscovered\EdidDiscovered.c"
+"EdidOverride\EdidOverride.h"
+"EdidOverride\EdidOverride.c"
+"EfiNetworkInterfaceIdentifier\EfiNetworkInterfaceIdentifier.h"
+"EfiNetworkInterfaceIdentifier\EfiNetworkInterfaceIdentifier.c"
+"FileInfo\FileInfo.h"
+"FileInfo\FileInfo.c"
+"FileSystemInfo\FileSystemInfo.h"
+"FileSystemInfo\FileSystemInfo.c"
+"FileSystemVolumeLabelInfo\FileSystemVolumeLabelInfo.h"
+"FileSystemVolumeLabelInfo\FileSystemVolumeLabelInfo.c"
+"FormBrowser2\FormBrowser2.h"
+"FormBrowser2\FormBrowser2.c"
+"GraphicsOutput\GraphicsOutput.h"
+"GraphicsOutput\GraphicsOutput.c"
+"HiiConfigAccess\HiiConfigAccess.h"
+"HiiConfigAccess\HiiConfigAccess.c"
+"HiiConfigRouting\HiiConfigRouting.h"
+"HiiConfigRouting\HiiConfigRouting.c"
+"HiiDatabase\HiiDatabase.h"
+"HiiDatabase\HiiDatabase.c"
+"HiiFont\HiiFont.h"
+"HiiFont\HiiFont.c"
+"HiiImage\HiiImage.h"
+"HiiImage\HiiImage.c"
+"HiiPackageList\HiiPackageList.h"
+"HiiPackageList\HiiPackageList.c"
+"HiiString\HiiString.h"
+"HiiString\HiiString.c"
+"Ip4\Ip4.h"
+"Ip4\Ip4.c"
+"Ip4Config\Ip4Config.h"
+"Ip4Config\Ip4Config.c"
+"LoadedImage\LoadedImage.h"
+"LoadedImage\LoadedImage.c"
+"LoadedImageDevicePath\LoadedImageDevicePath.h"
+"LoadedImageDevicePath\LoadedImageDevicePath.c"
+"LoadFile\LoadFile.h"
+"LoadFile\LoadFile.c"
+"LoadFile2\LoadFile2.h"
+"LoadFile2\LoadFile2.c"
+"ManagedNetwork\ManagedNetwork.h"
+"ManagedNetwork\ManagedNetwork.c"
+"Mtftp4\Mtftp4.h"
+"Mtftp4\Mtftp4.c"
+"PciIo\PciIo.h"
+"PciIo\PciIo.c"
+"PciRootBridgeIo\PciRootBridgeIo.h"
+"PciRootBridgeIo\PciRootBridgeIo.c"
+"PlatformDriverOverride\PlatformDriverOverride.h"
+"PlatformDriverOverride\PlatformDriverOverride.c"
+"PlatformToDriverConfiguration\PlatformToDriverConfiguration.h"
+"PlatformToDriverConfiguration\PlatformToDriverConfiguration.c"
+"PxeBaseCode\PxeBaseCode.h"
+"PxeBaseCode\PxeBaseCode.c"
+"PxeBaseCodeCallBack\PxeBaseCodeCallBack.h"
+"PxeBaseCodeCallBack\PxeBaseCodeCallBack.c"
+"ScsiPassThru\ScsiPassThru.h"
+"ScsiPassThru\ScsiPassThru.c"
+"SerialIO\SerialIo.h"
+"SerialIO\SerialIo.c"
+"SimpleFileSystem\SimpleFileSystem.h"
+"SimpleFileSystem\SimpleFileSystem.c"
+"SimpleNetwork\SimpleNetwork.h"
+"SimpleNetwork\SimpleNetwork.c"
+"SimplePointer\SimplePointer.h"
+"SimplePointer\SimplePointer.c"
+"SimpleTextIn\SimpleTextIn.h"
+"SimpleTextIn\SimpleTextIn.c"
+"SimpleTextInputEx\SimpleTextInputEx.h"
+"SimpleTextInputEx\SimpleTextInputEx.c"
+"SimpleTextOut\SimpleTextOut.h"
+"SimpleTextOut\SimpleTextOut.c"
+"Udp4\Udp4.h"
+"Udp4\Udp4.c"
+"UgaDraw\UgaDraw.h"
+"UgaDraw\UgaDraw.c"
+"UgaIo\UgaIo.h"
+"UgaIo\UgaIo.c"
+"UnicodeCollation\UnicodeCollation.h"
+"UnicodeCollation\UnicodeCollation.c"
+"UnicodeCollation2\UnicodeCollation2.h"
+"UnicodeCollation2\UnicodeCollation2.c"
+"UsbHostController\UsbHostController.h"
+"UsbHostController\UsbHostController.c"
+"UsbIo\UsbIo.h"
+"UsbIo\UsbIo.c"
+"Hash\Hash.h"
+"Hash\Hash.c"
+"ServiceBinding\ServiceBinding.h"
+"ScsiPassThruExt\ScsiPassThruExt.h"
+"ScsiPassThruExt\ScsiPassThruExt.c"
+"ScsiIo\ScsiIo.h"
+"ScsiIo\ScsiIo.c"
+"TapeIo\TapeIo.h"
+"TapeIo\TapeIo.c"
+"Tcp4\Tcp4.h"
+"Tcp4\Tcp4.c"
+"IScsiInitiatorName\IScsiInitiatorName.h"
+"IScsiInitiatorName\IScsiInitiatorName.c"
+"EfiProtocolLib.inf"
+<endComponent>
diff --git a/EDK/Foundation/Efi/Protocol/EfiProtocolLib.inf b/EDK/Foundation/Efi/Protocol/EfiProtocolLib.inf
new file mode 100644
index 0000000..37e06c6
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/EfiProtocolLib.inf
@@ -0,0 +1,194 @@
+#/*++
+#
+# Copyright (c) 2004 - 2008, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# EfiProtocolLib.inf
+#
+# Abstract:
+#
+# Component description file.
+#
+#--*/
+
+[defines]
+BASE_NAME= EfiProtocolLib
+COMPONENT_TYPE= LIBRARY
+
+[includes.common]
+ $(EDK_SOURCE)\Foundation\Efi
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)\Foundation\Include\Pei
+ $(EDK_SOURCE)\Foundation\Library\Pei\Include
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+
+[nmake.common]
+
+[sources.common]
+ AbsolutePointer\AbsolutePointer.h
+ AbsolutePointer\AbsolutePointer.c
+ AcpiTable\AcpiTable.h
+ AcpiTable\AcpiTable.c
+ Arp\Arp.h
+ Arp\Arp.c
+ AuthenticationInfo\AuthenticationInfo.h
+ AuthenticationInfo\AuthenticationInfo.c
+ Bis\Bis.h
+ Bis\Bis.c
+ BlockIo\BlockIo.h
+ BlockIo\BlockIo.c
+ BusSpecificDriverOverride\BusSpecificDriverOverride.h
+ BusSpecificDriverOverride\BusSpecificDriverOverride.c
+ ComponentName\ComponentName.h
+ ComponentName\ComponentName.c
+ ComponentName2\ComponentName2.h
+ ComponentName2\ComponentName2.c
+ DebugPort\DebugPort.h
+ DebugPort\DebugPort.c
+ DebugSupport\DebugSupport.h
+ DebugSupport\DebugSupport.c
+ Decompress\Decompress.h
+ Decompress\Decompress.c
+ DeviceIo\DeviceIo.h
+ DeviceIo\DeviceIo.c
+ DevicePath\DevicePath.h
+ DevicePath\DevicePath.c
+ DevicePathFromText\DevicePathFromText.h
+ DevicePathFromText\DevicePathFromText.c
+ DevicePathToText\DevicePathToText.h
+ DevicePathToText\DevicePathToText.c
+ DevicePathUtilities\DevicePathUtilities.h
+ DevicePathUtilities\DevicePathUtilities.c
+ Dhcp4\Dhcp4.h
+ Dhcp4\Dhcp4.c
+ DiskIo\DiskIo.h
+ DiskIo\DiskIo.c
+ DriverBinding\DriverBinding.h
+ DriverBinding\DriverBinding.c
+ DriverConfiguration\DriverConfiguration.h
+ DriverConfiguration\DriverConfiguration.c
+ DriverConfiguration2\DriverConfiguration2.h
+ DriverConfiguration2\DriverConfiguration2.c
+ DriverDiagnostics\DriverDiagnostics.h
+ DriverDiagnostics\DriverDiagnostics.c
+ DriverDiagnostics2\DriverDiagnostics2.h
+ DriverDiagnostics2\DriverDiagnostics2.c
+ DriverSupportedEfiVersion\DriverSupportedEfiVersion.h
+ DriverSupportedEfiVersion\DriverSupportedEfiVersion.c
+ Ebc\Ebc.h
+ Ebc\Ebc.c
+ EdidActive\EdidActive.h
+ EdidActive\EdidActive.c
+ EdidDiscovered\EdidDiscovered.h
+ EdidDiscovered\EdidDiscovered.c
+ EdidOverride\EdidOverride.h
+ EdidOverride\EdidOverride.c
+ EfiNetworkInterfaceIdentifier\EfiNetworkInterfaceIdentifier.h
+ EfiNetworkInterfaceIdentifier\EfiNetworkInterfaceIdentifier.c
+ FileInfo\FileInfo.h
+ FileInfo\FileInfo.c
+ FileSystemInfo\FileSystemInfo.h
+ FileSystemInfo\FileSystemInfo.c
+ FileSystemVolumeLabelInfo\FileSystemVolumeLabelInfo.h
+ FileSystemVolumeLabelInfo\FileSystemVolumeLabelInfo.c
+ FormBrowser2\FormBrowser2.h
+ FormBrowser2\FormBrowser2.c
+ GraphicsOutput\GraphicsOutput.h
+ GraphicsOutput\GraphicsOutput.c
+ HiiConfigAccess\HiiConfigAccess.h
+ HiiConfigAccess\HiiConfigAccess.c
+ HiiConfigRouting\HiiConfigRouting.h
+ HiiConfigRouting\HiiConfigRouting.c
+ HiiDatabase\HiiDatabase.h
+ HiiDatabase\HiiDatabase.c
+ HiiFont\HiiFont.h
+ HiiFont\HiiFont.c
+ HiiImage\HiiImage.h
+ HiiImage\HiiImage.c
+ HiiPackageList\HiiPackageList.h
+ HiiPackageList\HiiPackageList.c
+ HiiString\HiiString.h
+ HiiString\HiiString.c
+ Ip4\Ip4.h
+ Ip4\Ip4.c
+ Ip4Config\Ip4Config.h
+ Ip4Config\Ip4Config.c
+ LoadedImage\LoadedImage.h
+ LoadedImage\LoadedImage.c
+ LoadedImageDevicePath\LoadedImageDevicePath.h
+ LoadedImageDevicePath\LoadedImageDevicePath.c
+ LoadFile\LoadFile.h
+ LoadFile\LoadFile.c
+ LoadFile2\LoadFile2.h
+ LoadFile2\LoadFile2.c
+ ManagedNetwork\ManagedNetwork.h
+ ManagedNetwork\ManagedNetwork.c
+ Mtftp4\Mtftp4.h
+ Mtftp4\Mtftp4.c
+ PciIo\PciIo.h
+ PciIo\PciIo.c
+ PciRootBridgeIo\PciRootBridgeIo.h
+ PciRootBridgeIo\PciRootBridgeIo.c
+ PlatformDriverOverride\PlatformDriverOverride.h
+ PlatformDriverOverride\PlatformDriverOverride.c
+ PlatformToDriverConfiguration\PlatformToDriverConfiguration.h
+ PlatformToDriverConfiguration\PlatformToDriverConfiguration.c
+ PxeBaseCode\PxeBaseCode.h
+ PxeBaseCode\PxeBaseCode.c
+ PxeBaseCodeCallBack\PxeBaseCodeCallBack.h
+ PxeBaseCodeCallBack\PxeBaseCodeCallBack.c
+ ScsiPassThru\ScsiPassThru.h
+ ScsiPassThru\ScsiPassThru.c
+ SerialIo\SerialIo.h
+ SerialIo\SerialIo.c
+ SimpleFileSystem\SimpleFileSystem.h
+ SimpleFileSystem\SimpleFileSystem.c
+ SimpleNetwork\SimpleNetwork.h
+ SimpleNetwork\SimpleNetwork.c
+ SimplePointer\SimplePointer.h
+ SimplePointer\SimplePointer.c
+ SimpleTextIn\SimpleTextIn.h
+ SimpleTextIn\SimpleTextIn.c
+ SimpleTextInputEx\SimpleTextInputEx.h
+ SimpleTextInputEx\SimpleTextInputEx.c
+ SimpleTextOut\SimpleTextOut.h
+ SimpleTextOut\SimpleTextOut.c
+ Udp4\Udp4.h
+ Udp4\Udp4.c
+ UgaDraw\UgaDraw.h
+ UgaDraw\UgaDraw.c
+ UgaIo\UgaIo.h
+ UgaIo\UgaIo.c
+ UnicodeCollation\UnicodeCollation.h
+ UnicodeCollation\UnicodeCollation.c
+ UnicodeCollation2\UnicodeCollation2.h
+ UnicodeCollation2\UnicodeCollation2.c
+ UsbHostController\UsbHostController.h
+ UsbHostController\UsbHostController.c
+ UsbIo\UsbIo.h
+ UsbIo\UsbIo.c
+ Hash\Hash.h
+ Hash\Hash.c
+ ServiceBinding\ServiceBinding.h
+ ScsiPassThruExt\ScsiPassThruExt.h
+ ScsiPassThruExt\ScsiPassThruExt.c
+ ScsiIo\ScsiIo.h
+ ScsiIo\ScsiIo.c
+ TapeIo\TapeIo.h
+ TapeIo\TapeIo.c
+ Tcp4\Tcp4.h
+ Tcp4\Tcp4.c
+ IScsiInitiatorName\IScsiInitiatorName.h
+ IScsiInitiatorName\IScsiInitiatorName.c \ No newline at end of file
diff --git a/EDK/Foundation/Efi/Protocol/EfiProtocolLib.mak b/EDK/Foundation/Efi/Protocol/EfiProtocolLib.mak
new file mode 100644
index 0000000..b62731d
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/EfiProtocolLib.mak
@@ -0,0 +1,69 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EfiProtocolLib/EfiProtocolLib.mak 1 1/20/12 4:00a Jeffch $
+#
+# $Revision: 1 $
+#
+# $Date: 1/20/12 4:00a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EfiProtocolLib/EfiProtocolLib.mak $
+#
+# 1 1/20/12 4:00a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 9/27/11 6:23a Wesleychen
+# Intel EDK initially releases.
+#
+# 2 9/02/09 3:15a Iminglin
+# EIP24919
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: EfiProtocolLib.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+$(EFIPROTOCOLLIB) : EfiProtocolLib
+
+$(BUILD_DIR)\EfiProtocolLib.lib : EfiProtocolLib
+
+EfiProtocolLib : $(BUILD_DIR)\EfiProtocolLib.mak EfiProtocolLibBin
+
+$(BUILD_DIR)\EfiProtocolLib.mak : $(EfiProtocolLib_DIR)\$(@B).cif $(EfiProtocolLib_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(EfiProtocolLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+EfiProtocolLibBin :
+ $(MAKE) /$(MAKEFLAGS) $(EDK_DEFAULTS)\
+ /f $(BUILD_DIR)\EfiProtocolLib.mak all\
+ TYPE=LIBRARY \
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#********************************************************************** \ No newline at end of file
diff --git a/EDK/Foundation/Efi/Protocol/EfiProtocolLib.sdl b/EDK/Foundation/Efi/Protocol/EfiProtocolLib.sdl
new file mode 100644
index 0000000..862ec65
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/EfiProtocolLib.sdl
@@ -0,0 +1,26 @@
+TOKEN
+ Name = "EfiProtocolLib_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable EfiProtocolLib support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "EFIPROTOCOLLIB"
+ Value = "$(BUILD_DIR)\EfiProtocolLib.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "EfiProtocolLib_DIR"
+End
+
+MODULE
+ Help = "Includes EfiProtocolLib.mak to Project"
+ File = "EfiProtocolLib.mak"
+End
+
diff --git a/EDK/Foundation/Efi/Protocol/FileInfo/FileInfo.c b/EDK/Foundation/Efi/Protocol/FileInfo/FileInfo.c
new file mode 100644
index 0000000..80f4fb0
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/FileInfo/FileInfo.c
@@ -0,0 +1,27 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ FileInfo.c
+
+Abstract:
+
+ FileInfo protocol as defined in the EFI 1.0 specification.
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (FileInfo)
+
+EFI_GUID gEfiFileInfoGuid = EFI_FILE_INFO_ID;
+
+EFI_GUID_STRING(&gEfiFileInfoGuid, "File System Info", "EFI File System Info GUID");
diff --git a/EDK/Foundation/Efi/Protocol/FileInfo/FileInfo.h b/EDK/Foundation/Efi/Protocol/FileInfo/FileInfo.h
new file mode 100644
index 0000000..6ab15bd
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/FileInfo/FileInfo.h
@@ -0,0 +1,58 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ FileInfo.c
+
+Abstract:
+
+ SimpleFileSystem protocol as defined in the EFI 1.0 specification.
+
+ The SimpleFileSystem protocol is the programatic access to the FAT (12,16,32)
+ file system specified in EFI 1.0. It can also be used to abstract any
+ file system other than FAT.
+
+ EFI 1.0 can boot from any valid EFI image contained in a SimpleFileSystem
+
+--*/
+
+#ifndef _FILE_INFO_H_
+#define _FILE_INFO_H_
+
+#define EFI_FILE_INFO_ID \
+ { \
+ 0x9576e92, 0x6d3f, 0x11d2, 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b \
+ }
+
+typedef struct {
+ UINT64 Size;
+ UINT64 FileSize;
+ UINT64 PhysicalSize;
+ EFI_TIME CreateTime;
+ EFI_TIME LastAccessTime;
+ EFI_TIME ModificationTime;
+ UINT64 Attribute;
+ CHAR16 FileName[1];
+} EFI_FILE_INFO;
+
+//
+// The FileName field of the EFI_FILE_INFO data structure is variable length.
+// Whenever code needs to know the size of the EFI_FILE_INFO data structure, it needs to
+// be the size of the data structure without the FileName field. The following macro
+// computes this size correctly no matter how big the FileName array is declared.
+// This is required to make the EFI_FILE_INFO data structure ANSI compilant.
+//
+#define SIZE_OF_EFI_FILE_INFO EFI_FIELD_OFFSET (EFI_FILE_INFO, FileName)
+
+extern EFI_GUID gEfiFileInfoGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/FileSystemInfo/FileSystemInfo.c b/EDK/Foundation/Efi/Protocol/FileSystemInfo/FileSystemInfo.c
new file mode 100644
index 0000000..b3489aa
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/FileSystemInfo/FileSystemInfo.c
@@ -0,0 +1,27 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ FileSystemInfo.c
+
+Abstract:
+
+ FileSystemInfo protocol as defined in the EFI 1.0 specification.
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (FileSystemInfo)
+
+EFI_GUID gEfiFileSystemInfoGuid = EFI_FILE_SYSTEM_INFO_ID_GUID;
+
+EFI_GUID_STRING(&gEfiFileSystemInfoGuid, "File System Info ID", "EFI File System Info ID GUID");
diff --git a/EDK/Foundation/Efi/Protocol/FileSystemInfo/FileSystemInfo.h b/EDK/Foundation/Efi/Protocol/FileSystemInfo/FileSystemInfo.h
new file mode 100644
index 0000000..b84f956
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/FileSystemInfo/FileSystemInfo.h
@@ -0,0 +1,51 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ FileSystemInfo.h
+
+Abstract:
+
+ FileSystemInfo protocol as defined in the EFI 1.0 specification.
+
+
+--*/
+
+#ifndef _FILE_SYSTEM_INFO_H_
+#define _FILE_SYSTEM_INFO_H_
+
+#define EFI_FILE_SYSTEM_INFO_ID_GUID \
+ { \
+ 0x9576e93, 0x6d3f, 0x11d2, 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b \
+ }
+
+typedef struct {
+ UINT64 Size;
+ BOOLEAN ReadOnly;
+ UINT64 VolumeSize;
+ UINT64 FreeSpace;
+ UINT32 BlockSize;
+ CHAR16 VolumeLabel[1];
+} EFI_FILE_SYSTEM_INFO;
+
+//
+// The VolumeLabel field of the EFI_FILE_SYSTEM_INFO data structure is variable length.
+// Whenever code needs to know the size of the EFI_FILE_SYSTEM_INFO data structure, it needs
+// to be the size of the data structure without the VolumeLable field. The following macro
+// computes this size correctly no matter how big the VolumeLable array is declared.
+// This is required to make the EFI_FILE_SYSTEM_INFO data structure ANSI compilant.
+//
+#define SIZE_OF_EFI_FILE_SYSTEM_INFO EFI_FIELD_OFFSET (EFI_FILE_SYSTEM_INFO, VolumeLabel)
+
+extern EFI_GUID gEfiFileSystemInfoGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/FileSystemVolumeLabelInfo/FileSystemVolumeLabelInfo.c b/EDK/Foundation/Efi/Protocol/FileSystemVolumeLabelInfo/FileSystemVolumeLabelInfo.c
new file mode 100644
index 0000000..2f58025
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/FileSystemVolumeLabelInfo/FileSystemVolumeLabelInfo.c
@@ -0,0 +1,34 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ FileSystemVolumeLabelInfo.c
+
+Abstract:
+
+ SimpleFileSystem protocol as defined in the EFI 1.0 specification.
+
+ The SimpleFileSystem protocol is the programatic access to the FAT (12,16,32)
+ file system specified in EFI 1.0. It can also be used to abstract any
+ file system other than FAT.
+
+ EFI 1.0 can boot from any valid EFI image contained in a SimpleFileSystem
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (FileSystemVolumeLabelInfo)
+
+EFI_GUID gEfiFileSystemVolumeLabelInfoIdGuid = EFI_FILE_SYSTEM_VOLUME_LABEL_INFO_ID_GUID;
+
+EFI_GUID_STRING
+ (&gEfiFileSystemVolumeLabelInfoIdGuid, "File System Vol Label ID", "EFI File System Volume Label Info ID GUID");
diff --git a/EDK/Foundation/Efi/Protocol/FileSystemVolumeLabelInfo/FileSystemVolumeLabelInfo.h b/EDK/Foundation/Efi/Protocol/FileSystemVolumeLabelInfo/FileSystemVolumeLabelInfo.h
new file mode 100644
index 0000000..85238bf
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/FileSystemVolumeLabelInfo/FileSystemVolumeLabelInfo.h
@@ -0,0 +1,38 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ FileSystemVolumeLabelInfo.h
+
+Abstract:
+
+ FileSystemVolumeLabelInfo protocol as defined in the EFI 1.0 specification.
+
+--*/
+
+#ifndef _FILE_SYSTEM_VOLUME_LABEL_INFO_H_
+#define _FILE_SYSTEM_VOLUME_LABEL_INFO_H_
+
+#define EFI_FILE_SYSTEM_VOLUME_LABEL_INFO_ID_GUID \
+ { \
+ 0xDB47D7D3, 0xFE81, 0x11d3, 0x9A, 0x35, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D \
+ }
+
+typedef struct {
+ CHAR16 VolumeLabel[1];
+} EFI_FILE_SYSTEM_VOLUME_LABEL_INFO;
+
+#define SIZE_OF_EFI_FILE_SYSTEM_VOLUME_LABEL_INFO EFI_FIELD_OFFSET (EFI_FILE_SYSTEM_VOLUME_LABEL_INFO, VolumeLabel)
+
+extern EFI_GUID gEfiFileSystemVolumeLabelInfoIdGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/FormBrowser2/FormBrowser2.c b/EDK/Foundation/Efi/Protocol/FormBrowser2/FormBrowser2.c
new file mode 100644
index 0000000..43e9333
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/FormBrowser2/FormBrowser2.c
@@ -0,0 +1,27 @@
+/*++
+
+Copyright (c) 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ FormBrowser2.c
+
+Abstract:
+
+ The EFI_FORM_BROWSER2_PROTOCOL is the interface to the UEFI configuration driver.
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (FormBrowser2)
+
+EFI_GUID gEfiFormBrowser2ProtocolGuid = EFI_FORM_BROWSER2_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiFormBrowser2ProtocolGuid, "Form Browser2 Protocol", "Form Browser 2.1 protocol");
diff --git a/EDK/Foundation/Efi/Protocol/FormBrowser2/FormBrowser2.h b/EDK/Foundation/Efi/Protocol/FormBrowser2/FormBrowser2.h
new file mode 100644
index 0000000..2acbfd3
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/FormBrowser2/FormBrowser2.h
@@ -0,0 +1,136 @@
+/*++
+
+Copyright (c) 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ FormBrowser2.h
+
+Abstract:
+
+ The EFI_FORM_BROWSER2_PROTOCOL is the interface to the UEFI configuration driver.
+
+--*/
+
+#ifndef _FORM_BROWSER2_H_
+#define _FORM_BROWSER2_H_
+
+#include "EfiHii.h"
+
+#define EFI_FORM_BROWSER2_PROTOCOL_GUID \
+ { \
+ 0xb9d4c360, 0xbcfb, 0x4f9b, 0x92, 0x98, 0x53, 0xc1, 0x36, 0x98, 0x22, 0x58 \
+ }
+
+//
+// Forward reference for pure ANSI compatability
+//
+EFI_FORWARD_DECLARATION (EFI_FORM_BROWSER2_PROTOCOL);
+
+typedef struct _EFI_FORM_BROWSER2_PROTOCOL EFI_FORM_BROWSER2_PROTOCOL;
+
+typedef struct {
+ UINTN LeftColumn;
+ UINTN RightColumn;
+ UINTN TopRow;
+ UINTN BottomRow;
+} EFI_SCREEN_DESCRIPTOR;
+
+typedef UINTN EFI_BROWSER_ACTION_REQUEST;
+
+#define EFI_BROWSER_ACTION_REQUEST_NONE 0
+#define EFI_BROWSER_ACTION_REQUEST_RESET 1
+#define EFI_BROWSER_ACTION_REQUEST_SUBMIT 2
+#define EFI_BROWSER_ACTION_REQUEST_EXIT 3
+
+//
+// The following types are currently defined:
+//
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SEND_FORM2) (
+ IN CONST EFI_FORM_BROWSER2_PROTOCOL *This,
+ IN EFI_HII_HANDLE *Handles,
+ IN UINTN HandleCount,
+ IN EFI_GUID *FormSetGuid, OPTIONAL
+ IN UINT16 FormId, OPTIONAL
+ IN CONST EFI_SCREEN_DESCRIPTOR *ScreenDimensions, OPTIONAL
+ OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest OPTIONAL
+ )
+/*++
+
+Routine Description:
+ This is the routine which an external caller uses to direct the browser
+ where to obtain it's information.
+
+Arguments:
+ This - A pointer to the EFI_FORM_BROWSER2_PROTOCOL instance.
+ Handles - A pointer to an array of HII handles to display.
+ HandleCount - The number of handles in the array specified by Handle.
+ FormSetGuid - This field points to the EFI_GUID which must match the Guid field in the EFI_IFR_FORM_SET op-code for the specified
+ forms-based package. If FormSetGuid is NULL, then this function will display the first found forms package.
+ FormId - This field specifies which EFI_IFR_FORM to render as the first displayable page.
+ If this field has a value of 0x0000, then the forms browser will render the specified forms in their encoded order.
+ ScreenDimenions - This allows the browser to be called so that it occupies a portion of the physical screen instead of
+ dynamically determining the screen dimensions.
+ ActionRequest - Points to the action recommended by the form.
+
+Returns:
+ EFI_SUCCESS - The function completed successfully.
+ EFI_INVALID_PARAMETER - One of the parameters has an invalid value.
+ EFI_NOT_FOUND - No valid forms could be found to display.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_BROWSER_CALLBACK2) (
+ IN CONST EFI_FORM_BROWSER2_PROTOCOL *This,
+ IN OUT UINTN *ResultsDataSize,
+ IN OUT EFI_STRING ResultsData,
+ IN BOOLEAN RetrieveData,
+ IN CONST EFI_GUID *VariableGuid, OPTIONAL
+ IN CONST CHAR16 *VariableName OPTIONAL
+ )
+/*++
+
+Routine Description:
+ This function is called by a callback handler to retrieve uncommitted state
+ data from the browser.
+
+Arguments:
+ This - A pointer to the EFI_FORM_BROWSER2_PROTOCOL instance.
+ ResultsDataSize - A pointer to the size of the buffer associated with ResultsData.
+ On input, the size in bytes of ResultsData.
+ On output, the size of data returned in ResultsData.
+ ResultsData - A string returned from an IFR browser or equivalent.
+ The results string will have no routing information in them.
+ RetrieveData - A BOOLEAN field which allows an agent to retrieve (if RetrieveData = TRUE)
+ data from the uncommitted browser state information or set
+ (if RetrieveData = FALSE) data in the uncommitted browser state information.
+ VariableGuid - An optional field to indicate the target variable GUID name to use.
+ VariableName - An optional field to indicate the target human-readable variable name.
+
+Returns:
+ EFI_SUCCESS - The results have been distributed or are awaiting distribution.
+ EFI_BUFFER_TOO_SMALL - The ResultsDataSize specified was too small to contain the results data.
+
+--*/
+;
+
+typedef struct _EFI_FORM_BROWSER2_PROTOCOL {
+ EFI_SEND_FORM2 SendForm;
+ EFI_BROWSER_CALLBACK2 BrowserCallback;
+} EFI_FORM_BROWSER2_PROTOCOL;
+
+extern EFI_GUID gEfiFormBrowser2ProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/GraphicsOutput/GraphicsOutput.c b/EDK/Foundation/Efi/Protocol/GraphicsOutput/GraphicsOutput.c
new file mode 100644
index 0000000..a8417a3
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/GraphicsOutput/GraphicsOutput.c
@@ -0,0 +1,29 @@
+/*++
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ GraphicsOutput.c
+
+Abstract:
+
+ Graphics Output Protocol from the UEFI 2.0 specification.
+
+ Abstraction of a very simple graphics device.
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (GraphicsOutput)
+
+EFI_GUID gEfiGraphicsOutputProtocolGuid = EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiGraphicsOutputProtocolGuid, "EFI Graphics Output Protocol", "UEFI Graphics Output Protocol");
diff --git a/EDK/Foundation/Efi/Protocol/GraphicsOutput/GraphicsOutput.h b/EDK/Foundation/Efi/Protocol/GraphicsOutput/GraphicsOutput.h
new file mode 100644
index 0000000..1444e52
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/GraphicsOutput/GraphicsOutput.h
@@ -0,0 +1,206 @@
+/*++
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ GraphicsOutput.h
+
+Abstract:
+
+ Graphics Output Protocol from the UEFI 2.0 specification.
+
+ Abstraction of a very simple graphics device.
+
+--*/
+
+#ifndef __GRAPHICS_OUTPUT_H__
+#define __GRAPHICS_OUTPUT_H__
+
+#include EFI_PROTOCOL_DEFINITION (UgaDraw)
+
+#define EFI_GRAPHICS_OUTPUT_PROTOCOL_GUID \
+ { \
+ 0x9042a9de, 0x23dc, 0x4a38, 0x96, 0xfb, 0x7a, 0xde, 0xd0, 0x80, 0x51, 0x6a \
+ }
+
+typedef struct _EFI_GRAPHICS_OUTPUT_PROTOCOL EFI_GRAPHICS_OUTPUT_PROTOCOL;
+
+typedef struct {
+ UINT32 RedMask;
+ UINT32 GreenMask;
+ UINT32 BlueMask;
+ UINT32 ReservedMask;
+} EFI_PIXEL_BITMASK;
+
+typedef enum {
+ PixelRedGreenBlueReserved8BitPerColor,
+ PixelBlueGreenRedReserved8BitPerColor,
+ PixelBitMask,
+ PixelBltOnly,
+ PixelFormatMax
+} EFI_GRAPHICS_PIXEL_FORMAT;
+
+typedef struct {
+ UINT32 Version;
+ UINT32 HorizontalResolution;
+ UINT32 VerticalResolution;
+ EFI_GRAPHICS_PIXEL_FORMAT PixelFormat;
+ EFI_PIXEL_BITMASK PixelInformation;
+ UINT32 PixelsPerScanLine;
+} EFI_GRAPHICS_OUTPUT_MODE_INFORMATION;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_GRAPHICS_OUTPUT_PROTOCOL_QUERY_MODE) (
+ IN EFI_GRAPHICS_OUTPUT_PROTOCOL *This,
+ IN UINT32 ModeNumber,
+ OUT UINTN *SizeOfInfo,
+ OUT EFI_GRAPHICS_OUTPUT_MODE_INFORMATION **Info
+ )
+/*++
+
+ Routine Description:
+ Return the current video mode information.
+
+ Arguments:
+ This - Protocol instance pointer.
+ ModeNumber - The mode number to return information on.
+ SizeOfInfo - A pointer to the size, in bytes, of the Info buffer.
+ Info - A pointer to callee allocated buffer that returns information about ModeNumber.
+
+ Returns:
+ EFI_SUCCESS - Mode information returned.
+ EFI_DEVICE_ERROR - A hardware error occurred trying to retrieve the video mode.
+ EFI_NOT_STARTED - Video display is not initialized. Call SetMode ()
+ EFI_INVALID_PARAMETER - One of the input args was NULL.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_GRAPHICS_OUTPUT_PROTOCOL_SET_MODE) (
+ IN EFI_GRAPHICS_OUTPUT_PROTOCOL * This,
+ IN UINT32 ModeNumber
+ )
+/*++
+
+ Routine Description:
+ Return the current video mode information.
+
+ Arguments:
+ This - Protocol instance pointer.
+ ModeNumber - The mode number to be set.
+
+ Returns:
+ EFI_SUCCESS - Graphics mode was changed.
+ EFI_DEVICE_ERROR - The device had an error and could not complete the request.
+ EFI_UNSUPPORTED - ModeNumber is not supported by this device.
+
+--*/
+;
+
+typedef EFI_UGA_PIXEL EFI_GRAPHICS_OUTPUT_BLT_PIXEL;
+
+typedef union {
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL Pixel;
+ UINT32 Raw;
+} EFI_GRAPHICS_OUTPUT_BLT_PIXEL_UNION;
+
+typedef enum {
+ EfiBltVideoFill,
+ EfiBltVideoToBltBuffer,
+ EfiBltBufferToVideo,
+ EfiBltVideoToVideo,
+ EfiGraphicsOutputBltOperationMax
+} EFI_GRAPHICS_OUTPUT_BLT_OPERATION;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_GRAPHICS_OUTPUT_PROTOCOL_BLT) (
+ IN EFI_GRAPHICS_OUTPUT_PROTOCOL * This,
+ IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL * BltBuffer, OPTIONAL
+ IN EFI_GRAPHICS_OUTPUT_BLT_OPERATION BltOperation,
+ IN UINTN SourceX,
+ IN UINTN SourceY,
+ IN UINTN DestinationX,
+ IN UINTN DestinationY,
+ IN UINTN Width,
+ IN UINTN Height,
+ IN UINTN Delta OPTIONAL
+ );
+
+/*++
+
+ Routine Description:
+ The following table defines actions for BltOperations:
+ EfiBltVideoFill - Write data from the BltBuffer pixel (SourceX, SourceY)
+ directly to every pixel of the video display rectangle
+ (DestinationX, DestinationY) (DestinationX + Width, DestinationY + Height).
+ Only one pixel will be used from the BltBuffer. Delta is NOT used.
+ EfiBltVideoToBltBuffer - Read data from the video display rectangle
+ (SourceX, SourceY) (SourceX + Width, SourceY + Height) and place it in
+ the BltBuffer rectangle (DestinationX, DestinationY )
+ (DestinationX + Width, DestinationY + Height). If DestinationX or
+ DestinationY is not zero then Delta must be set to the length in bytes
+ of a row in the BltBuffer.
+ EfiBltBufferToVideo - Write data from the BltBuffer rectangle
+ (SourceX, SourceY) (SourceX + Width, SourceY + Height) directly to the
+ video display rectangle (DestinationX, DestinationY)
+ (DestinationX + Width, DestinationY + Height). If SourceX or SourceY is
+ not zero then Delta must be set to the length in bytes of a row in the
+ BltBuffer.
+ EfiBltVideoToVideo - Copy from the video display rectangle (SourceX, SourceY)
+ (SourceX + Width, SourceY + Height) .to the video display rectangle
+ (DestinationX, DestinationY) (DestinationX + Width, DestinationY + Height).
+ The BltBuffer and Delta are not used in this mode.
+
+ Arguments:
+ This - Protocol instance pointer.
+ BltBuffer - Buffer containing data to blit into video buffer. This
+ buffer has a size of Width*Height*sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL)
+ BltOperation - Operation to perform on BlitBuffer and video memory
+ SourceX - X coordinate of source for the BltBuffer.
+ SourceY - Y coordinate of source for the BltBuffer.
+ DestinationX - X coordinate of destination for the BltBuffer.
+ DestinationY - Y coordinate of destination for the BltBuffer.
+ Width - Width of rectangle in BltBuffer in pixels.
+ Height - Hight of rectangle in BltBuffer in pixels.
+ Delta -
+
+ Returns:
+ EFI_SUCCESS - The Blt operation completed.
+ EFI_INVALID_PARAMETER - BltOperation is not valid.
+ EFI_DEVICE_ERROR - A hardware error occured writting to the video
+ buffer.
+
+--*/
+;
+
+typedef struct {
+ UINT32 MaxMode;
+ UINT32 Mode;
+ EFI_GRAPHICS_OUTPUT_MODE_INFORMATION *Info;
+ UINTN SizeOfInfo;
+ EFI_PHYSICAL_ADDRESS FrameBufferBase;
+ UINTN FrameBufferSize;
+} EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE;
+
+typedef struct _EFI_GRAPHICS_OUTPUT_PROTOCOL {
+ EFI_GRAPHICS_OUTPUT_PROTOCOL_QUERY_MODE QueryMode;
+ EFI_GRAPHICS_OUTPUT_PROTOCOL_SET_MODE SetMode;
+ EFI_GRAPHICS_OUTPUT_PROTOCOL_BLT Blt;
+ EFI_GRAPHICS_OUTPUT_PROTOCOL_MODE *Mode;
+} EFI_GRAPHICS_OUTPUT_PROTOCOL;
+
+extern EFI_GUID gEfiGraphicsOutputProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/Hash/Hash.c b/EDK/Foundation/Efi/Protocol/Hash/Hash.c
new file mode 100644
index 0000000..c8871e1
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/Hash/Hash.c
@@ -0,0 +1,40 @@
+/*++
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Hash.c
+
+Abstract:
+ EFI_HASH_SERVICE_BINDING_PROTOCOL as defined in UEFI 2.0.
+ EFI_HASH_PROTOCOL as defined in UEFI 2.0.
+ The EFI Hash Service Binding Protocol is used to locate hashing services support
+ provided by a driver and create and destroy instances of the EFI Hash Protocol
+ so that a multiple drivers can use the underlying hashing services.
+ The EFI Service Binding Protocol defines the generic Service Binding Protocol functions.
+
+Revision History
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (Hash)
+
+EFI_GUID gEfiHashServiceBindingProtocolGuid = EFI_HASH_SERVICE_BINDING_PROTOCOL;
+EFI_GUID gEfiHashProtocolGuid = EFI_HASH_PROTOCOL_GUID;
+EFI_GUID gEfiHashAlgorithmSha1Guid = EFI_HASH_ALGORITHM_SHA1_GUID;
+EFI_GUID gEfiHashAlgorithmSha224Guid = EFI_HASH_ALGORITHM_SHA224_GUID;
+EFI_GUID gEfiHashAlgorithmSha256Guid = EFI_HASH_ALGORITHM_SHA256_GUID;
+EFI_GUID gEfiHashAlgorithmSha384Guid = EFI_HASH_ALGORITHM_SHA384_GUID;
+EFI_GUID gEfiHashAlgorithmSha512Guid = EFI_HASH_ALGORITHM_SHA512_GUID;
+EFI_GUID gEfiHashAlgorithmMD5Guid = EFI_HASH_ALGORTIHM_MD5_GUID;
+
+EFI_GUID_STRING(&gEfiHashProtocolGuid, "Hash protoco", "UEFI 2.0 Hash protocol");
+EFI_GUID_STRING(&gEfiHashServiceBindingProtocolGuid, "Hash service binding protoco", "UEFI 2.0 Hash service binding protocol");
diff --git a/EDK/Foundation/Efi/Protocol/Hash/Hash.h b/EDK/Foundation/Efi/Protocol/Hash/Hash.h
new file mode 100644
index 0000000..2f2ec1b
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/Hash/Hash.h
@@ -0,0 +1,161 @@
+/*++
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Hash.h
+
+Abstract:
+ EFI_HASH_SERVICE_BINDING_PROTOCOL as defined in UEFI 2.0.
+ EFI_HASH_PROTOCOL as defined in UEFI 2.0.
+ The EFI Hash Service Binding Protocol is used to locate hashing services support
+ provided by a driver and create and destroy instances of the EFI Hash Protocol
+ so that a multiple drivers can use the underlying hashing services.
+ The EFI Service Binding Protocol defines the generic Service Binding Protocol functions.
+
+Revision History
+--*/
+
+#ifndef __EFI_HASH_PROTOCOL_H__
+#define __EFI_HASH_PROTOCOL_H__
+
+#define EFI_HASH_SERVICE_BINDING_PROTOCOL \
+ { \
+ 0x42881c98, 0xa4f3, 0x44b0, {0xa3, 0x9d, 0xdf, 0xa1, 0x86, 0x67, 0xd8, 0xcd } \
+ }
+
+#define EFI_HASH_PROTOCOL_GUID \
+ { \
+ 0xc5184932, 0xdba5, 0x46db, {0xa5, 0xba, 0xcc, 0x0b, 0xda, 0x9c, 0x14, 0x35 } \
+ }
+
+#define EFI_HASH_ALGORITHM_SHA1_GUID \
+ { \
+ 0x2ae9d80f, 0x3fb2, 0x4095, {0xb7, 0xb1, 0xe9, 0x31, 0x57, 0xb9, 0x46, 0xb6 } \
+ }
+
+#define EFI_HASH_ALGORITHM_SHA224_GUID \
+ { \
+ 0x8df01a06, 0x9bd5, 0x4bf7, {0xb0, 0x21, 0xdb, 0x4f, 0xd9, 0xcc, 0xf4, 0x5b } \
+ }
+
+#define EFI_HASH_ALGORITHM_SHA256_GUID \
+ { \
+ 0x51aa59de, 0xfdf2, 0x4ea3, {0xbc, 0x63, 0x87, 0x5f, 0xb7, 0x84, 0x2e, 0xe9 } \
+ }
+
+#define EFI_HASH_ALGORITHM_SHA384_GUID \
+ { \
+ 0xefa96432, 0xde33, 0x4dd2, {0xae, 0xe6, 0x32, 0x8c, 0x33, 0xdf, 0x77, 0x7a } \
+ }
+
+#define EFI_HASH_ALGORITHM_SHA512_GUID \
+ { \
+ 0xcaa4381e, 0x750c, 0x4770, {0xb8, 0x70, 0x7a, 0x23, 0xb4, 0xe4, 0x21, 0x30 } \
+ }
+
+#define EFI_HASH_ALGORTIHM_MD5_GUID \
+ { \
+ 0xaf7c79c, 0x65b5, 0x4319, {0xb0, 0xae, 0x44, 0xec, 0x48, 0x4e, 0x4a, 0xd7 } \
+ }
+
+typedef struct _EFI_HASH_PROTOCOL EFI_HASH_PROTOCOL;
+
+typedef UINT8 EFI_MD5_HASH[16];
+typedef UINT8 EFI_SHA1_HASH[20];
+typedef UINT8 EFI_SHA224_HASH[28];
+typedef UINT8 EFI_SHA256_HASH[32];
+typedef UINT8 EFI_SHA384_HASH[48];
+typedef UINT8 EFI_SHA512_HASH[64];
+
+typedef union {
+ EFI_MD5_HASH *Md5Hash;
+ EFI_SHA1_HASH *Sha1Hash;
+ EFI_SHA224_HASH *Sha224Hash;
+ EFI_SHA256_HASH *Sha256Hash;
+ EFI_SHA384_HASH *Sha384Hash;
+ EFI_SHA512_HASH *Sha512Hash;
+} EFI_HASH_OUTPUT;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_HASH_GET_HASH_SIZE) (
+ IN CONST EFI_HASH_PROTOCOL *This,
+ IN CONST EFI_GUID *HashAlgorithm,
+ OUT UINTN *HashSize
+ )
+/*++
+
+ Routine Description:
+ Returns the size of the hash which results from a specific algorithm.
+
+ Arguments:
+ This - Points to this instance of EFI_HASH_PROTOCOL.
+ HashAlgorithm - Points to the EFI_GUID which identifies the algorithm to use.
+ HashSize - Holds the returned size of the algorithm¡¯s hash.
+
+ Returns:
+ EFI_SUCCESS - Hash size returned successfully.
+ EFI_INVALID_PARAMETER - HashSize is NULL
+ EFI_UNSUPPORTED - The algorithm specified by HashAlgorithm is not supported
+ by this driver.
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_HASH_HASH) (
+ IN CONST EFI_HASH_PROTOCOL *This,
+ IN CONST EFI_GUID *HashAlgorithm,
+ IN BOOLEAN Extend,
+ IN CONST UINT8 *Message,
+ IN UINT64 MessageSize,
+ IN OUT EFI_HASH_OUTPUT *Hash
+ )
+/*++
+
+ Routine Description:
+ Returns the size of the hash which results from a specific algorithm.
+
+ Arguments:
+ This - Points to this instance of EFI_HASH_PROTOCOL.
+ HashAlgorithm - Points to the EFI_GUID which identifies the algorithm to use.
+ Extend - Specifies whether to create a new hash (FALSE) or extend the specified
+ existing hash (TRUE).
+ Message - Points to the start of the message.
+ MessageSize - The size of Message, in bytes.
+ Hash - On input, if Extend is TRUE, then this holds the hash to extend. On
+ output, holds the resulting hash computed from the message.
+
+ Returns:
+ EFI_SUCCESS - Hash returned successfully.
+ EFI_INVALID_PARAMETER - Message or Hash is NULL
+ EFI_UNSUPPORTED - The algorithm specified by HashAlgorithm is not supported by this
+ driver. Or extend is TRUE and the algorithm doesn¡¯t support extending the hash.
+
+--*/
+;
+
+struct _EFI_HASH_PROTOCOL {
+ EFI_HASH_GET_HASH_SIZE GetHashSize;
+ EFI_HASH_HASH Hash;
+};
+
+extern EFI_GUID gEfiHashServiceBindingProtocolGuid;
+extern EFI_GUID gEfiHashProtocolGuid;
+extern EFI_GUID gEfiHashAlgorithmSha1Guid;
+extern EFI_GUID gEfiHashAlgorithmSha224Guid;
+extern EFI_GUID gEfiHashAlgorithmSha256Guid;
+extern EFI_GUID gEfiHashAlgorithmSha384Guid;
+extern EFI_GUID gEfiHashAlgorithmSha512Guid;
+extern EFI_GUID gEfiHashAlgorithmMD5Guid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/HiiConfigAccess/HiiConfigAccess.c b/EDK/Foundation/Efi/Protocol/HiiConfigAccess/HiiConfigAccess.c
new file mode 100644
index 0000000..7e41697
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/HiiConfigAccess/HiiConfigAccess.c
@@ -0,0 +1,27 @@
+/*++
+
+Copyright (c) 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ HiiConfigAccess.c
+
+Abstract:
+
+ EFI_HII_CONFIG_ACCESS_PROTOCOL as defined in UEFI 2.1 spec.
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (HiiConfigAccess)
+
+EFI_GUID gEfiHiiConfigAccessProtocolGuid = EFI_HII_CONFIG_ACCESS_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiHiiConfigAccessProtocolGuid, "HII Config Access Protocol", "HII Config Access 2.1 protocol");
diff --git a/EDK/Foundation/Efi/Protocol/HiiConfigAccess/HiiConfigAccess.h b/EDK/Foundation/Efi/Protocol/HiiConfigAccess/HiiConfigAccess.h
new file mode 100644
index 0000000..9398488
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/HiiConfigAccess/HiiConfigAccess.h
@@ -0,0 +1,147 @@
+/*++
+
+Copyright (c) 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ HiiConfigAccess.h
+
+Abstract:
+
+ EFI_HII_CONFIG_ACCESS_PROTOCOL as defined in UEFI 2.1 spec.
+
+--*/
+
+#ifndef _HII_CONFIG_ACCESS_H_
+#define _HII_CONFIG_ACCESS_H_
+
+#include EFI_PROTOCOL_DEFINITION (FormBrowser2)
+
+#define EFI_HII_CONFIG_ACCESS_PROTOCOL_GUID \
+ { \
+ 0x330d4706, 0xf2a0, 0x4e4f, 0xa3, 0x69, 0xb6, 0x6f, 0xa8, 0xd5, 0x43, 0x85 \
+ }
+
+//
+// Forward reference for pure ANSI compatability
+//
+EFI_FORWARD_DECLARATION (EFI_HII_CONFIG_ACCESS_PROTOCOL);
+
+typedef UINTN EFI_BROWSER_ACTION;
+
+#define EFI_BROWSER_ACTION_CHANGING 0
+#define EFI_BROWSER_ACTION_CHANGED 1
+
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_HII_ACCESS_EXTRACT_CONFIG) (
+ IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
+ IN CONST EFI_STRING Request,
+ OUT EFI_STRING *Progress,
+ OUT EFI_STRING *Results
+ )
+/*++
+
+ Routine Description:
+ This function allows a caller to extract the current configuration for one
+ or more named elements from the target driver.
+
+ Arguments:
+ This - Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
+ Request - A null-terminated Unicode string in <ConfigRequest> format.
+ Progress - On return, points to a character in the Request string.
+ Points to the string's null terminator if request was successful.
+ Points to the most recent '&' before the first failing name/value
+ pair (or the beginning of the string if the failure is in the
+ first name/value pair) if the request was not successful.
+ Results - A null-terminated Unicode string in <ConfigAltResp> format which
+ has all values filled in for the names in the Request string.
+ String to be allocated by the called function.
+
+ Returns:
+ EFI_SUCCESS - The Results is filled with the requested values.
+ EFI_OUT_OF_RESOURCES - Not enough memory to store the results.
+ EFI_INVALID_PARAMETER - Request is NULL, illegal syntax, or unknown name.
+ EFI_NOT_FOUND - Routing data doesn't match any storage in this driver.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_HII_ACCESS_ROUTE_CONFIG) (
+ IN EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
+ IN CONST EFI_STRING Configuration,
+ OUT EFI_STRING *Progress
+ )
+/*++
+
+ Routine Description:
+ This function processes the results of changes in configuration.
+
+ Arguments:
+ This - Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
+ Configuration - A null-terminated Unicode string in <ConfigResp> format.
+ Progress - A pointer to a string filled in with the offset of the most
+ recent '&' before the first failing name/value pair (or the
+ beginning of the string if the failure is in the first
+ name/value pair) or the terminating NULL if all was successful.
+
+ Returns:
+ EFI_SUCCESS - The Results is processed successfully.
+ EFI_INVALID_PARAMETER - Configuration is NULL.
+ EFI_NOT_FOUND - Routing data doesn't match any storage in this driver.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_HII_ACCESS_FORM_CALLBACK) (
+ IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This,
+ IN EFI_BROWSER_ACTION Action,
+ IN EFI_QUESTION_ID QuestionId,
+ IN UINT8 Type,
+ IN EFI_IFR_TYPE_VALUE *Value,
+ OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
+ )
+/*++
+
+ Routine Description:
+ This function processes the results of changes in configuration.
+
+ Arguments:
+ This - Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
+ Action - Specifies the type of action taken by the browser.
+ QuestionId - A unique value which is sent to the original exporting driver
+ so that it can identify the type of data to expect.
+ Type - The type of value for the question.
+ Value - A pointer to the data being sent to the original exporting driver.
+ ActionRequest - On return, points to the action requested by the callback function.
+
+ Returns:
+ EFI_SUCCESS - The callback successfully handled the action.
+ EFI_OUT_OF_RESOURCES - Not enough storage is available to hold the variable and its data.
+ EFI_DEVICE_ERROR - The variable could not be saved.
+ EFI_UNSUPPORTED - The specified Action is not supported by the callback.
+
+--*/
+;
+
+typedef struct _EFI_HII_CONFIG_ACCESS_PROTOCOL {
+ EFI_HII_ACCESS_EXTRACT_CONFIG ExtractConfig;
+ EFI_HII_ACCESS_ROUTE_CONFIG RouteConfig;
+ EFI_HII_ACCESS_FORM_CALLBACK Callback;
+} EFI_HII_CONFIG_ACCESS_PROTOCOL;
+
+extern EFI_GUID gEfiHiiConfigAccessProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/HiiConfigRouting/HiiConfigRouting.c b/EDK/Foundation/Efi/Protocol/HiiConfigRouting/HiiConfigRouting.c
new file mode 100644
index 0000000..19a178f
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/HiiConfigRouting/HiiConfigRouting.c
@@ -0,0 +1,27 @@
+/*++
+
+Copyright (c) 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ HiiConfigRouting.c
+
+Abstract:
+
+ EFI_HII_CONFIG_ROUTING_PROTOCOL as defined in UEFI 2.1 spec.
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (HiiConfigRouting)
+
+EFI_GUID gEfiHiiConfigRoutingProtocolGuid = EFI_HII_CONFIG_ROUTING_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiHiiConfigRoutingProtocolGuid, "HII Config Routing Protocol", "HII Config Routing 2.1 protocol");
diff --git a/EDK/Foundation/Efi/Protocol/HiiConfigRouting/HiiConfigRouting.h b/EDK/Foundation/Efi/Protocol/HiiConfigRouting/HiiConfigRouting.h
new file mode 100644
index 0000000..f8bdff8
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/HiiConfigRouting/HiiConfigRouting.h
@@ -0,0 +1,314 @@
+/*++
+
+Copyright (c) 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ HiiConfigRouting.h
+
+Abstract:
+
+ EFI_HII_CONFIG_ROUTING_PROTOCOL as defined in UEFI 2.1 spec.
+
+--*/
+
+#ifndef __EFI_HII_CONFIG_ROUTING_H__
+#define __EFI_HII_CONFIG_ROUTING_H__
+
+#include "EfiHii.h"
+
+#define EFI_HII_CONFIG_ROUTING_PROTOCOL_GUID \
+ { \
+ 0x587e72d7, 0xcc50, 0x4f79, 0x82, 0x09, 0xca, 0x29, 0x1f, 0xc1, 0xa1, 0x0f \
+ }
+
+//
+// Forward reference for pure ANSI compatability
+//
+EFI_FORWARD_DECLARATION (EFI_HII_CONFIG_ROUTING_PROTOCOL);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_HII_EXTRACT_CONFIG) (
+ IN CONST EFI_HII_CONFIG_ROUTING_PROTOCOL *This,
+ IN CONST EFI_STRING Request,
+ OUT EFI_STRING *Progress,
+ OUT EFI_STRING *Results
+ )
+/*++
+
+ Routine Description:
+ This function allows a caller to extract the current configuration
+ for one or more named elements from one or more drivers.
+
+ Arguments:
+ This - A pointer to the EFI_HII_CONFIG_ROUTING_PROTOCOL instance.
+ Request - A null-terminated Unicode string in <MultiConfigRequest> format.
+ Progress - On return, points to a character in the Request string. Points to the string's null
+ terminator if request was successful. Points to the most recent '&' before the first
+ failing name / value pair (or the beginning of the string if the failure is in the first
+ name / value pair) if the request was not successful.
+ Results - Null-terminated Unicode string in <MultiConfigAltResp> format which has all
+ values filled in for the names in the Request string. String to be allocated by the called
+ function.
+
+ Returns:
+ EFI_SUCCESS - The Results string is filled with the values
+ corresponding to all requested names.
+ EFI_OUT_OF_RESOURCES - Not enough memory to store the parts of the results
+ that must be stored awaiting possible future
+ protocols.
+ EFI_NOT_FOUND - Routing data doesn't match any known driver.
+ Progress set to the 'G' in "GUID" of the routing
+ header that doesn't match. Note: There is no
+ requirement that all routing data be validated before
+ any configuration extraction.
+ EFI_INVALID_PARAMETER - For example, passing in a NULL for the Request
+ parameter would result in this type of error. The
+ Progress parameter is set to NULL.
+
+ EFI_INVALID_PARAMETER - Illegal syntax. Progress set to most recent & before
+ the error or the beginning of the string.
+
+ EFI_INVALID_PARAMETER - Unknown name. Progress points to the & before
+ the name in question.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_HII_EXPORT_CONFIG) (
+ IN CONST EFI_HII_CONFIG_ROUTING_PROTOCOL *This,
+ OUT EFI_STRING *Results
+ )
+/*++
+
+ Routine Description:
+ This function allows the caller to request the current configuration for the
+ entirety of the current HII database and returns the data in a null-terminated Unicode string.
+
+ Arguments:
+ This - A pointer to the EFI_HII_CONFIG_ROUTING_PROTOCOL instance.
+ Results - Null-terminated Unicode string in <MultiConfigAltResp> format which has all
+ values filled in for the names in the Request string. String to be allocated by the called
+ function. De-allocation is up to the caller.
+
+ Returns:
+ EFI_SUCCESS - The Results string is filled with the values
+ corresponding to all requested names.
+ EFI_OUT_OF_RESOURCES - Not enough memory to store the parts of the results
+ that must be stored awaiting possible future
+ protocols.
+ EFI_INVALID_PARAMETER - For example, passing in a NULL for the Results
+ parameter would result in this type of error.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_HII_ROUTE_CONFIG) (
+ IN EFI_HII_CONFIG_ROUTING_PROTOCOL *This,
+ IN CONST EFI_STRING Configuration,
+ OUT EFI_STRING *Progress
+ )
+/*++
+
+ Routine Description:
+ This function processes the results of processing forms and routes it to the
+ appropriate handlers or storage.
+
+ Arguments:
+ This - A pointer to the EFI_HII_CONFIG_ROUTING_PROTOCOL instance.
+ Configuration - A null-terminated Unicode string in <MulltiConfigResp> format.
+ Progress - A pointer to a string filled in with the offset of the most recent "&" before the first
+ failing name / value pair (or the beginning of the string if the failure is in the first
+ name / value pair) or the terminating NULL if all was successful.
+
+ Returns:
+ EFI_SUCCESS - The results have been distributed or are awaiting
+ distribution.
+ EFI_OUT_OF_RESOURCES - Not enough memory to store the parts of the results
+ that must be stored awaiting possible future
+ protocols.
+ EFI_INVALID_PARAMETER - Passing in a NULL for the Configuration
+ parameter would result in this type of error.
+ EFI_NOT_FOUND - Target for the specified routing data was not found.
+
+--*/
+;
+
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_HII_BLOCK_TO_CONFIG) (
+ IN CONST EFI_HII_CONFIG_ROUTING_PROTOCOL *This,
+ IN CONST EFI_STRING ConfigRequest,
+ IN CONST UINT8 *Block,
+ IN CONST UINTN BlockSize,
+ OUT EFI_STRING *Config,
+ OUT EFI_STRING *Progress
+ )
+/*++
+
+ Routine Description:
+ This helper function is to be called by drivers to map configuration data stored
+ in byte array ("block") formats such as UEFI Variables into current configuration strings.
+
+ Arguments:
+ This - A pointer to the EFI_HII_CONFIG_ROUTING_PROTOCOL instance.
+ ConfigRequest - A null-terminated Unicode string in <ConfigRequest> format.
+ Block - Array of bytes defining the block's configuration.
+ BlockSize - Length in bytes of Block.
+ Config - Filled-in configuration string. String allocated by the function.
+ Returned only if call is successful.
+ Progress - A pointer to a string filled in with the offset of the most recent "&" before the first
+ failing name / value pair (or the beginning of the string if the failure is in the first
+ name / value pair) or the terminating NULL if all was successful.
+
+ Returns:
+ EFI_SUCCESS - The request succeeded. Progress points to the null
+ terminator at the end of the ConfigRequest
+ string.
+ EFI_OUT_OF_RESOURCES - Not enough memory to allocate Config.
+ Progress points to the first character of
+ ConfigRequest.
+ EFI_INVALID_PARAMETER - Passing in a NULL for the ConfigRequest or
+ Block parameter would result in this type of
+ error. Progress points to the first character of
+ ConfigRequest.
+ EFI_NOT_FOUND - Target for the specified routing data was not found.
+ Progress points to the "G" in "GUID" of the
+ errant routing data.
+ EFI_DEVICE_ERROR - Block not large enough. Progress undefined.
+ EFI_INVALID_PARAMETER - Encountered non <BlockName> formatted string.
+ Block is left updated and Progress points at the "&"
+ preceding the first non-<BlockName>.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_HII_CONFIG_TO_BLOCK) (
+ IN CONST EFI_HII_CONFIG_ROUTING_PROTOCOL *This,
+ IN CONST EFI_STRING ConfigResp,
+ IN OUT UINT8 *Block,
+ IN OUT UINTN *BlockSize,
+ OUT EFI_STRING *Progress
+ )
+/*++
+
+ Routine Description:
+ This helper function is to be called by drivers to map configuration strings
+ to configurations stored in byte array ("block") formats such as UEFI Variables.
+
+ Arguments:
+ This - A pointer to the EFI_HII_CONFIG_ROUTING_PROTOCOL instance.
+ ConfigResp - A null-terminated Unicode string in <ConfigResp> format.
+ Block - A possibly null array of bytes representing the current block.
+ Only bytes referenced in the ConfigResp string in the block are modified.
+ If this parameter is null or if the *BlockSize parameter is (on input)
+ shorter than required by the Configuration string, only the BlockSize
+ parameter is updated and an appropriate status (see below) is returned.
+
+ BlockSize - The length of the Block in units of UINT8. On input, this is the size of the Block.
+ On output, if successful, contains the index of the last modified byte in the Block.
+
+ Progress - On return, points to an element of the ConfigResp string filled in with the offset of
+ the most recent "&" before the first failing name / value pair (or the beginning of the
+ string if the failure is in the first name / value pair) or the terminating NULL if all was
+ successful.
+ Returns:
+ EFI_SUCCESS - The request succeeded. Progress points to the null
+ terminator at the end of the ConfigResp
+ string.
+ EFI_OUT_OF_RESOURCES - Not enough memory to allocate Config.
+ Progress points to the first character of
+ ConfigResp.
+ EFI_INVALID_PARAMETER - Passing in a NULL for the ConfigResp or
+ Block parameter would result in this type of error.
+ Progress points to the first character of
+ ConfigResp.
+ EFI_NOT_FOUND - Target for the specified routing data was not found.
+ Progress points to the "G" in "GUID" of the
+ errant routing data.
+ EFI_INVALID_PARAMETER - Encountered non <BlockName> formatted name /
+ value pair. Block is left updated and
+ Progress points at the "&" preceding the first
+ non-<BlockName>.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI * EFI_HII_GET_ALT_CFG) (
+ IN CONST EFI_HII_CONFIG_ROUTING_PROTOCOL *This,
+ IN CONST EFI_STRING Configuration,
+ IN CONST EFI_GUID *Guid,
+ IN CONST EFI_STRING Name,
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
+ IN CONST UINT16 *AltCfgId,
+ OUT EFI_STRING *AltCfgResp
+ )
+/*++
+
+ Routine Description:
+ This helper function is to be called by drivers to extract portions of
+ a larger configuration string.
+
+ Arguments:
+ This - A pointer to the EFI_HII_CONFIG_ROUTING_PROTOCOL instance.
+ Configuration - A null-terminated Unicode string in <MultiConfigAltResp> format.
+ Guid - A pointer to the GUID value to search for in the
+ routing portion of the ConfigResp string when retrieving
+ the requested data. If Guid is NULL, then all GUID
+ values will be searched for.
+ Name - A pointer to the NAME value to search for in the
+ routing portion of the ConfigResp string when retrieving
+ the requested data. If Name is NULL, then all Name
+ values will be searched for.
+ DevicePath - A pointer to the PATH value to search for in the
+ routing portion of the ConfigResp string when retrieving
+ the requested data. If DevicePath is NULL, then all
+ DevicePath values will be searched for.
+ AltCfgId - A pointer to the ALTCFG value to search for in the
+ routing portion of the ConfigResp string when retrieving
+ the requested data. If this parameter is NULL,
+ then the current setting will be retrieved.
+ AltCfgResp - A pointer to a buffer which will be allocated by the
+ function which contains the retrieved string as requested.
+ This buffer is only allocated if the call was successful.
+
+ Returns:
+ EFI_SUCCESS - The request succeeded. The requested data was extracted
+ and placed in the newly allocated AltCfgResp buffer.
+ EFI_OUT_OF_RESOURCES - Not enough memory to allocate AltCfgResp.
+ EFI_INVALID_PARAMETER - Any parameter is invalid.
+ EFI_NOT_FOUND - Target for the specified routing data was not found.
+
+--*/
+;
+
+
+typedef struct _EFI_HII_CONFIG_ROUTING_PROTOCOL {
+ EFI_HII_EXTRACT_CONFIG ExtractConfig;
+ EFI_HII_EXPORT_CONFIG ExportConfig;
+ EFI_HII_ROUTE_CONFIG RouteConfig;
+ EFI_HII_BLOCK_TO_CONFIG BlockToConfig;
+ EFI_HII_CONFIG_TO_BLOCK ConfigToBlock;
+ EFI_HII_GET_ALT_CFG GetAltConfig;
+} EFI_HII_CONFIG_ROUTING_PROTOCOL;
+
+extern EFI_GUID gEfiHiiConfigRoutingProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/HiiDatabase/HiiDatabase.c b/EDK/Foundation/Efi/Protocol/HiiDatabase/HiiDatabase.c
new file mode 100644
index 0000000..6363d53
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/HiiDatabase/HiiDatabase.c
@@ -0,0 +1,29 @@
+/*++
+
+Copyright (c) 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ HiiDatabase.c
+
+Abstract:
+
+ EFI_HII_DATABASE_PROTOCOL
+
+Revision History
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (HiiDatabase)
+
+EFI_GUID gEfiHiiDatabaseProtocolGuid = EFI_HII_DATABASE_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiHiiDatabaseProtocolGuid, "EFI HII DATABASE Protocol", "UEFI 2.1 HII DATABASE Protocol");
diff --git a/EDK/Foundation/Efi/Protocol/HiiDatabase/HiiDatabase.h b/EDK/Foundation/Efi/Protocol/HiiDatabase/HiiDatabase.h
new file mode 100644
index 0000000..e45c86a
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/HiiDatabase/HiiDatabase.h
@@ -0,0 +1,454 @@
+/*++
+
+Copyright (c) 2007 - 2008, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ HiiDatabase.h
+
+Abstract:
+
+ EFI_HII_DATABASE_PROTOCOL from UEFI 2.1 specification.
+
+ This protocol is a database manager for HII related data structures.
+
+Revision History
+
+--*/
+
+#ifndef __EFI_HII_DATABASE_PROTOCOL_H__
+#define __EFI_HII_DATABASE_PROTOCOL_H__
+
+#include "EfiHii.h"
+
+//
+// Global ID for the Hii Database Protocol.
+//
+
+#define EFI_HII_DATABASE_PROTOCOL_GUID \
+ { \
+ 0xef9fc172, 0xa1b2, 0x4693, 0xb3, 0x27, 0x6d, 0x32, 0xfc, 0x41, 0x60, 0x42 \
+ }
+
+#define EFI_HII_SET_KEYBOARD_LAYOUT_EVENT_GUID \
+ { \
+ 0x14982a4f, 0xb0ed, 0x45b8, 0xa8, 0x11, 0x5a, 0x7a, 0x9b, 0xc2, 0x32, 0xdf \
+ }
+
+EFI_FORWARD_DECLARATION (EFI_HII_DATABASE_PROTOCOL);
+
+typedef UINTN EFI_HII_DATABASE_NOTIFY_TYPE;
+
+#define EFI_HII_DATABASE_NOTIFY_NEW_PACK 0x00000001
+#define EFI_HII_DATABASE_NOTIFY_REMOVE_PACK 0x00000002
+#define EFI_HII_DATABASE_NOTIFY_EXPORT_PACK 0x00000004
+#define EFI_HII_DATABASE_NOTIFY_ADD_PACK 0x00000008
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_HII_DATABASE_NOTIFY) (
+ IN UINT8 PackageType,
+ IN CONST EFI_GUID *PackageGuid,
+ IN CONST EFI_HII_PACKAGE_HEADER *Package,
+ IN EFI_HII_HANDLE Handle,
+ IN EFI_HII_DATABASE_NOTIFY_TYPE NotifyType
+ )
+/*++
+
+ Routine Description:
+ Functions which are registered to receive notification of database events have this prototype. The
+ actual event is encoded in NotifyType. The following table describes how PackageType,
+ PackageGuid, Handle, and Package are used for each of the notification types.
+
+ Arguments:
+ PackageType - Package type of the notification.
+ PackageGuid - If PackageType is EFI_HII_PACKAGE_TYPE_GUID, then this is the pointer to
+ the GUID which must match the Guid field of
+ EFI_HII_GUID_PACKAGE_GUID_HDR. Otherwise, it must be NULL.
+ Package - Points to the package referred to by the notification.
+ Handle - The handle of the package list which contains the specified package.
+ NotifyType - The type of change concerning the database.
+
+ Returns:
+ EFI status code.
+
+--*/
+;
+
+//
+// EFI_HII_DATABASE_PROTOCOL protocol prototypes
+//
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_HII_DATABASE_NEW_PACK) (
+ IN CONST EFI_HII_DATABASE_PROTOCOL *This,
+ IN CONST EFI_HII_PACKAGE_LIST_HEADER *PackageList,
+ IN CONST EFI_HANDLE DriverHandle,
+ OUT EFI_HII_HANDLE *Handle
+ )
+/*++
+
+ Routine Description:
+ This function adds the packages in the package list to the database and returns a handle. If there is a
+ EFI_DEVICE_PATH_PROTOCOL associated with the DriverHandle, then this function will
+ create a package of type EFI_PACKAGE_TYPE_DEVICE_PATH and add it to the package list.
+
+ Arguments:
+ This - A pointer to the EFI_HII_DATABASE_PROTOCOL instance.
+ PackageList - A pointer to an EFI_HII_PACKAGE_LIST_HEADER structure.
+ DriverHandle - Associate the package list with this EFI handle.
+ Handle - A pointer to the EFI_HII_HANDLE instance.
+
+ Returns:
+ EFI_SUCCESS - The package list associated with the Handle
+ was added to the HII database.
+ EFI_OUT_OF_RESOURCES - Unable to allocate necessary resources for the
+ new database contents.
+ EFI_INVALID_PARAMETER - PackageList is NULL or Handle is NULL.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_HII_DATABASE_REMOVE_PACK) (
+ IN CONST EFI_HII_DATABASE_PROTOCOL *This,
+ IN EFI_HII_HANDLE Handle
+ )
+/*++
+
+ Routine Description:
+ This function removes the package list that is associated with a handle Handle
+ from the HII database. Before removing the package, any registered functions
+ with the notification type REMOVE_PACK and the same package type will be called.
+
+ Arguments:
+ This - A pointer to the EFI_HII_DATABASE_PROTOCOL instance.
+ Handle - The handle that was registered to the data that is requested
+ for removal.
+
+ Returns:
+ EFI_SUCCESS - The data associated with the Handle was removed from
+ the HII database.
+ EFI_NOT_FOUND - The specified Handle is not in database.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_HII_DATABASE_UPDATE_PACK) (
+ IN CONST EFI_HII_DATABASE_PROTOCOL *This,
+ IN EFI_HII_HANDLE Handle,
+ IN CONST EFI_HII_PACKAGE_LIST_HEADER *PackageList
+ )
+/*++
+
+ Routine Description:
+ This function updates the existing package list (which has the specified Handle)
+ in the HII databases, using the new package list specified by PackageList.
+
+ Arguments:
+ This - A pointer to the EFI_HII_DATABASE_PROTOCOL instance.
+ Handle - The handle that was registered to the data that is
+ requested to be updated.
+ PackageList - A pointer to an EFI_HII_PACKAGE_LIST_HEADER package.
+
+ Returns:
+ EFI_SUCCESS - The HII database was successfully updated.
+ EFI_OUT_OF_RESOURCES - Unable to allocate enough memory for the updated database.
+ EFI_INVALID_PARAMETER - PackageList was NULL.
+ EFI_NOT_FOUND - The specified Handle is not in database.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_HII_DATABASE_LIST_PACKS) (
+ IN CONST EFI_HII_DATABASE_PROTOCOL *This,
+ IN UINT8 PackageType,
+ IN CONST EFI_GUID *PackageGuid,
+ IN OUT UINTN *HandleBufferLength,
+ OUT EFI_HII_HANDLE *Handle
+ )
+/*++
+
+ Routine Description:
+ This function returns a list of the package handles of the specified type
+ that are currently active in the database. The pseudo-type
+ EFI_HII_PACKAGE_TYPE_ALL will cause all package handles to be listed.
+
+ Arguments:
+ This - A pointer to the EFI_HII_DATABASE_PROTOCOL instance.
+ PackageType - Specifies the package type of the packages to list or
+ EFI_HII_PACKAGE_TYPE_ALL for all packages to be listed.
+ PackageGuid - If PackageType is EFI_HII_PACKAGE_TYPE_GUID, then this
+ is the pointer to the GUID which must match the Guid
+ field of EFI_HII_GUID_PACKAGE_GUID_HDR. Otherwise,
+ it must be NULL.
+ HandleBufferLength - On input, a pointer to the length of the handle buffer.
+ On output, the length of the handle buffer that is
+ required for the handles found.
+ Handle - An array of EFI_HII_HANDLE instances returned.
+
+ Returns:
+ EFI_SUCCESS - The matching handles are outputed successfully.
+ HandleBufferLength is updated with the actual length.
+ EFI_BUFFER_TO_SMALL - The HandleBufferLength parameter indicates that
+ Handle is too small to support the number of handles.
+ HandleBufferLength is updated with a value that will
+ enable the data to fit.
+ EFI_NOT_FOUND - No matching handle could not be found in database.
+ EFI_INVALID_PARAMETER - Handle or HandleBufferLength was NULL.
+ EFI_INVALID_PARAMETER - PackageType is not a EFI_HII_PACKAGE_TYPE_GUID but
+ PackageGuid is not NULL, PackageType is a EFI_HII_
+ PACKAGE_TYPE_GUID but PackageGuid is NULL.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_HII_DATABASE_EXPORT_PACKS) (
+ IN CONST EFI_HII_DATABASE_PROTOCOL *This,
+ IN EFI_HII_HANDLE Handle,
+ IN OUT UINTN *BufferSize,
+ OUT EFI_HII_PACKAGE_LIST_HEADER *Buffer
+ )
+/*++
+
+ Routine Description:
+ This function will export one or all package lists in the database to a buffer.
+ For each package list exported, this function will call functions registered
+ with EXPORT_PACK and then copy the package list to the buffer.
+
+ Arguments:
+ This - A pointer to the EFI_HII_DATABASE_PROTOCOL instance.
+ Handle - An EFI_HII_HANDLE that corresponds to the desired package
+ list in the HII database to export or NULL to indicate
+ all package lists should be exported.
+ BufferSize - On input, a pointer to the length of the buffer.
+ On output, the length of the buffer that is required for
+ the exported data.
+ Buffer - A pointer to a buffer that will contain the results of
+ the export function.
+
+ Returns:
+ EFI_SUCCESS - Package exported.
+ EFI_BUFFER_TO_SMALL - The HandleBufferLength parameter indicates that Handle
+ is too small to support the number of handles.
+ HandleBufferLength is updated with a value that will
+ enable the data to fit.
+ EFI_NOT_FOUND - The specifiecd Handle could not be found in the current
+ database.
+ EFI_INVALID_PARAMETER - Handle or Buffer or BufferSize was NULL.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_HII_DATABASE_REGISTER_NOTIFY) (
+ IN CONST EFI_HII_DATABASE_PROTOCOL *This,
+ IN UINT8 PackageType,
+ IN CONST EFI_GUID *PackageGuid,
+ IN CONST EFI_HII_DATABASE_NOTIFY PackageNotifyFn,
+ IN EFI_HII_DATABASE_NOTIFY_TYPE NotifyType,
+ OUT EFI_HANDLE *NotifyHandle
+ )
+/*++
+
+ Routine Description:
+ This function registers a function which will be called when specified actions related to packages of
+ the specified type occur in the HII database. By registering a function, other HII-related drivers are
+ notified when specific package types are added, removed or updated in the HII database.
+ Each driver or application which registers a notification should use
+ EFI_HII_DATABASE_PROTOCOL.UnregisterPackageNotify() before exiting.
+
+ Arguments:
+ This - A pointer to the EFI_HII_DATABASE_PROTOCOL instance.
+ PackageType - Specifies the package type of the packages to list or
+ EFI_HII_PACKAGE_TYPE_ALL for all packages to be listed.
+ PackageGuid - If PackageType is EFI_HII_PACKAGE_TYPE_GUID, then this is the pointer to
+ the GUID which must match the Guid field of
+ EFI_HII_GUID_PACKAGE_GUID_HDR. Otherwise, it must be NULL.
+ PackageNotifyFn - Points to the function to be called when the event specified by
+ NotificationType occurs.
+ NotifyType - Describes the types of notification which this function will be receiving.
+ NotifyHandle - Points to the unique handle assigned to the registered notification. Can be used in
+ EFI_HII_DATABASE_PROTOCOL.UnregisterPackageNotify() to stop notifications.
+
+ Returns:
+ EFI_SUCCESS - Notification registered successfully.
+ EFI_OUT_OF_RESOURCES - Unable to allocate necessary data structures
+ EFI_INVALID_PARAMETER - NotifyHandle is NULL.
+ EFI_INVALID_PARAMETER - PackageGuid is not NULL when PackageType is not
+ EFI_HII_PACKAGE_TYPE_GUID.
+ EFI_INVALID_PARAMETER - PackageGuid is NULL when PackageType is EFI_HII_PACKAGE_TYPE_GUID.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_HII_DATABASE_UNREGISTER_NOTIFY) (
+ IN CONST EFI_HII_DATABASE_PROTOCOL *This,
+ IN EFI_HANDLE NotificationHandle
+ )
+/*++
+
+ Routine Description:
+ Removes the specified HII database package-related notification.
+
+ Arguments:
+ This - A pointer to the EFI_HII_DATABASE_PROTOCOL instance.
+ NotifyHandle - The handle of the notification function being unregistered.
+
+ Returns:
+ EFI_SUCCESS - Notification is unregistered successfully.
+ EFI_NOT_FOUND - The incoming notification handle does not exist
+ in current hii database.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_HII_FIND_KEYBOARD_LAYOUTS) (
+ IN EFI_HII_DATABASE_PROTOCOL *This,
+ IN OUT UINT16 *KeyGuidBufferLength,
+ OUT EFI_GUID *KeyGuidBuffer
+ )
+/*++
+
+ Routine Description:
+ This routine retrieves an array of GUID values for each keyboard layout that
+ was previously registered in the system.
+
+ Arguments:
+ This - A pointer to the EFI_HII_DATABASE_PROTOCOL instance.
+ KeyGuidBufferLength - On input, a pointer to the length of the keyboard GUID
+ buffer. On output, the length of the handle buffer
+ that is required for the handles found.
+ KeyGuidBuffer - An array of keyboard layout GUID instances returned.
+
+ Returns:
+ EFI_SUCCESS - KeyGuidBuffer was updated successfully.
+ EFI_BUFFER_TOO_SMALL - The KeyGuidBufferLength parameter indicates
+ that KeyGuidBuffer is too small to support the
+ number of GUIDs. KeyGuidBufferLength is
+ updated with a value that will enable the data to fit.
+ EFI_INVALID_PARAMETER - The KeyGuidBuffer or KeyGuidBufferLength was NULL.
+ EFI_NOT_FOUND - There was no keyboard layout.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_HII_GET_KEYBOARD_LAYOUT) (
+ IN EFI_HII_DATABASE_PROTOCOL *This,
+ IN EFI_GUID *KeyGuid,
+ IN OUT UINT16 *KeyboardLayoutLength,
+ OUT EFI_HII_KEYBOARD_LAYOUT *KeyboardLayout
+ )
+/*++
+
+ Routine Description:
+ This routine retrieves the requested keyboard layout. The layout is a physical description of the keys
+ on a keyboard and the character(s) that are associated with a particular set of key strokes.
+
+ Arguments:
+ This - A pointer to the EFI_HII_DATABASE_PROTOCOL instance.
+ KeyGuid - A pointer to the unique ID associated with a given keyboard layout. If KeyGuid is
+ NULL then the current layout will be retrieved.
+ KeyboardLayoutLength - On input, a pointer to the length of the KeyboardLayout buffer.
+ On output, the length of the data placed into KeyboardLayout.
+ KeyboardLayout - A pointer to a buffer containing the retrieved keyboard layout.
+
+ Returns:
+ EFI_SUCCESS - The keyboard layout was retrieved successfully.
+ EFI_NOT_FOUND - The requested keyboard layout was not found.
+ EFI_INVALID_PARAMETER - The KeyboardLayout or KeyboardLayoutLength was NULL.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_HII_SET_KEYBOARD_LAYOUT) (
+ IN EFI_HII_DATABASE_PROTOCOL *This,
+ IN EFI_GUID *KeyGuid
+ )
+/*++
+
+ Routine Description:
+ This routine sets the default keyboard layout to the one referenced by KeyGuid. When this routine
+ is called, an event will be signaled of the EFI_HII_SET_KEYBOARD_LAYOUT_EVENT_GUID
+ group type. This is so that agents which are sensitive to the current keyboard layout being changed
+ can be notified of this change.
+
+ Arguments:
+ This - A pointer to the EFI_HII_DATABASE_PROTOCOL instance.
+ KeyGuid - A pointer to the unique ID associated with a given keyboard layout.
+
+ Returns:
+ EFI_SUCCESS - The current keyboard layout was successfully set.
+ EFI_NOT_FOUND - The referenced keyboard layout was not found, so action was taken.
+ EFI_INVALID_PARAMETER - The KeyGuid was NULL.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_HII_DATABASE_GET_PACK_HANDLE) (
+ IN EFI_HII_DATABASE_PROTOCOL *This,
+ IN EFI_HII_HANDLE PackageListHandle,
+ OUT EFI_HANDLE *DriverHandle
+ )
+/*++
+
+ Routine Description:
+ Return the EFI handle associated with a package list.
+
+ Arguments:
+ This - A pointer to the EFI_HII_DATABASE_PROTOCOL instance.
+ PackageListHandle - An EFI_HII_HANDLE that corresponds to the desired package list in the
+ HIIdatabase.
+ DriverHandle - On return, contains the EFI_HANDLE which was registered with the package list in
+ NewPackageList().
+
+ Returns:
+ EFI_SUCCESS - The DriverHandle was returned successfully.
+ EFI_INVALID_PARAMETER - The PackageListHandle was not valid or DriverHandle was NULL.
+
+--*/
+;
+
+typedef struct _EFI_HII_DATABASE_PROTOCOL {
+ EFI_HII_DATABASE_NEW_PACK NewPackageList;
+ EFI_HII_DATABASE_REMOVE_PACK RemovePackageList;
+ EFI_HII_DATABASE_UPDATE_PACK UpdatePackageList;
+ EFI_HII_DATABASE_LIST_PACKS ListPackageLists;
+ EFI_HII_DATABASE_EXPORT_PACKS ExportPackageLists;
+ EFI_HII_DATABASE_REGISTER_NOTIFY RegisterPackageNotify;
+ EFI_HII_DATABASE_UNREGISTER_NOTIFY UnregisterPackageNotify;
+ EFI_HII_FIND_KEYBOARD_LAYOUTS FindKeyboardLayouts;
+ EFI_HII_GET_KEYBOARD_LAYOUT GetKeyboardLayout;
+ EFI_HII_SET_KEYBOARD_LAYOUT SetKeyboardLayout;
+ EFI_HII_DATABASE_GET_PACK_HANDLE GetPackageListHandle;
+} EFI_HII_DATABASE_PROTOCOL;
+
+extern EFI_GUID gEfiHiiDatabaseProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/HiiFont/HiiFont.c b/EDK/Foundation/Efi/Protocol/HiiFont/HiiFont.c
new file mode 100644
index 0000000..02f79d3
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/HiiFont/HiiFont.c
@@ -0,0 +1,29 @@
+/*++
+
+Copyright (c) 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ HiiFont.c
+
+Abstract:
+
+ EFI_HII_FONT_PROTOCOL
+
+Revision History
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (HiiFont)
+
+EFI_GUID gEfiHiiFontProtocolGuid = EFI_HII_FONT_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiHiiFontProtocolGuid, "EFI HII FONT Protocol", "UEFI 2.1 HII FONT Protocol");
diff --git a/EDK/Foundation/Efi/Protocol/HiiFont/HiiFont.h b/EDK/Foundation/Efi/Protocol/HiiFont/HiiFont.h
new file mode 100644
index 0000000..f86a907
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/HiiFont/HiiFont.h
@@ -0,0 +1,289 @@
+/*++
+
+Copyright (c) 2007 - 2008, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ HiiFont.h
+
+Abstract:
+
+ EFI_HII_FONT_PROTOCOL from UEFI 2.1 specification.
+
+ This protocol provides interfaces to retrieve font information.
+
+Revision History
+
+--*/
+
+#ifndef __EFI_HII_FONT_PROTOCOL_H__
+#define __EFI_HII_FONT_PROTOCOL_H__
+
+#include EFI_PROTOCOL_DEFINITION (GraphicsOutput)
+#include EFI_PROTOCOL_DEFINITION (HiiImage)
+
+//
+// Global ID for the Hii Font Protocol.
+//
+
+#define EFI_HII_FONT_PROTOCOL_GUID \
+ { \
+ 0xe9ca4775, 0x8657, 0x47fc, 0x97, 0xe7, 0x7e, 0xd6, 0x5a, 0x8, 0x43, 0x24 \
+ }
+
+EFI_FORWARD_DECLARATION (EFI_HII_FONT_PROTOCOL);
+
+typedef UINT32 EFI_HII_OUT_FLAGS;
+typedef UINT32 EFI_FONT_INFO_MASK;
+typedef VOID* EFI_FONT_HANDLE;
+
+typedef struct _EFI_HII_ROW_INFO {
+ UINTN StartIndex;
+ UINTN EndIndex;
+ UINTN LineHeight;
+ UINTN LineWidth;
+ UINTN BaselineOffset;
+} EFI_HII_ROW_INFO;
+
+typedef struct {
+ EFI_HII_FONT_STYLE FontStyle;
+ UINT16 FontSize; // character cell height in pixels
+ CHAR16 FontName[1];
+} EFI_FONT_INFO;
+
+typedef struct _EFI_FONT_DISPLAY_INFO {
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL ForegroundColor;
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL BackgroundColor;
+ EFI_FONT_INFO_MASK FontInfoMask;
+ EFI_FONT_INFO FontInfo;
+} EFI_FONT_DISPLAY_INFO;
+
+#define EFI_HII_OUT_FLAG_CLIP 0x00000001
+#define EFI_HII_OUT_FLAG_WRAP 0x00000002
+#define EFI_HII_OUT_FLAG_CLIP_CLEAN_Y 0x00000004
+#define EFI_HII_OUT_FLAG_CLIP_CLEAN_X 0x00000008
+#define EFI_HII_OUT_FLAG_TRANSPARENT 0x00000010
+#define EFI_HII_IGNORE_IF_NO_GLYPH 0x00000020
+#define EFI_HII_IGNORE_LINE_BREAK 0x00000040
+#define EFI_HII_DIRECT_TO_SCREEN 0x00000080
+
+#define EFI_FONT_INFO_SYS_FONT 0x00000001
+#define EFI_FONT_INFO_SYS_SIZE 0x00000002
+#define EFI_FONT_INFO_SYS_STYLE 0x00000004
+#define EFI_FONT_INFO_SYS_FORE_COLOR 0x00000010
+#define EFI_FONT_INFO_SYS_BACK_COLOR 0x00000020
+#define EFI_FONT_INFO_RESIZE 0x00001000
+#define EFI_FONT_INFO_RESTYLE 0x00002000
+#define EFI_FONT_INFO_ANY_FONT 0x00010000
+#define EFI_FONT_INFO_ANY_SIZE 0x00020000
+#define EFI_FONT_INFO_ANY_STYLE 0x00040000
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_HII_STRING_TO_IMAGE) (
+ IN CONST EFI_HII_FONT_PROTOCOL *This,
+ IN EFI_HII_OUT_FLAGS Flags,
+ IN CONST EFI_STRING String,
+ IN CONST EFI_FONT_DISPLAY_INFO *StringInfo OPTIONAL,
+ IN OUT EFI_IMAGE_OUTPUT **Blt,
+ IN UINTN BltX,
+ IN UINTN BltY,
+ OUT EFI_HII_ROW_INFO **RowInfoArray OPTIONAL,
+ OUT UINTN *RowInfoArraySize OPTIONAL,
+ OUT UINTN *ColumnInfoArray OPTIONAL
+ )
+/*++
+
+ Routine Description:
+ Renders a string to a bitmap or to the display.
+
+ Arguments:
+ This - A pointer to the EFI_HII_FONT_PROTOCOL instance.
+ Flags - Describes how the string is to be drawn.
+ String - Points to the null-terminated string to be displayed.
+ StringInfo - Points to the string output information, including the color and font.
+ If NULL, then the string will be output in the default system font and color.
+ Blt - If this points to a non-NULL on entry, this points to the image, which is Width pixels
+ wide and Height pixels high. The string will be drawn onto this image and
+ EFI_HII_OUT_FLAG_CLIP is implied. If this points to a NULL on entry, then a
+ buffer will be allocated to hold the generated image and the pointer updated on exit. It
+ is the caller¡¯s responsibility to free this buffer.
+ BltX,BLTY - Specifies the offset from the left and top edge of the image of the first character cell in
+ the image.
+ RowInfoArray - If this is non-NULL on entry, then on exit, this will point to an allocated buffer
+ containing row information and RowInfoArraySize will be updated to contain the
+ number of elements. This array describes the characters which were at least partially
+ drawn and the heights of the rows. It is the caller¡¯s responsibility to free this buffer.
+ RowInfoArraySize - If this is non-NULL on entry, then on exit it contains the number of elements in
+ RowInfoArray.
+ ColumnInfoArray - If this is non-NULL, then on return it will be filled with the horizontal offset for each
+ character in the string on the row where it is displayed. Non-printing characters will
+ have the offset ~0. The caller is responsible to allocate a buffer large enough so that
+ there is one entry for each character in the string, not including the null-terminator. It
+ is possible when character display is normalized that some character cells overlap.
+
+ Returns:
+ EFI_SUCCESS - The string was successfully rendered.
+ EFI_OUT_OF_RESOURCES - Unable to allocate an output buffer for RowInfoArray or Blt.
+ EFI_INVALID_PARAMETER - The String or Blt was NULL.
+ EFI_INVALID_PARAMETER - Flags were invalid combination.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_HII_STRING_ID_TO_IMAGE) (
+ IN CONST EFI_HII_FONT_PROTOCOL *This,
+ IN EFI_HII_OUT_FLAGS Flags,
+ IN EFI_HII_HANDLE PackageList,
+ IN EFI_STRING_ID StringId,
+ IN CONST CHAR8* Language,
+ IN CONST EFI_FONT_DISPLAY_INFO *StringInfo OPTIONAL,
+ IN OUT EFI_IMAGE_OUTPUT **Blt,
+ IN UINTN BltX,
+ IN UINTN BltY,
+ OUT EFI_HII_ROW_INFO **RowInfoArray OPTIONAL,
+ OUT UINTN *RowInfoArraySize OPTIONAL,
+ OUT UINTN *ColumnInfoArray OPTIONAL
+ )
+/*++
+
+ Routine Description:
+ Render a string to a bitmap or the screen containing the contents of the specified string.
+
+ Arguments:
+ This - A pointer to the EFI_HII_FONT_PROTOCOL instance.
+ Flags - Describes how the string is to be drawn.
+ PackageList - The package list in the HII database to search for the specified string.
+ StringId - The string¡¯s id, which is unique within PackageList.
+ Language - Points to the language for the retrieved string. If NULL, then the current system
+ language is used.
+ StringInfo - Points to the string output information, including the color and font.
+ If NULL, then the string will be output in the default system font and color.
+ Blt - If this points to a non-NULL on entry, this points to the image, which is Width pixels
+ wide and Height pixels high. The string will be drawn onto this image and
+ EFI_HII_OUT_FLAG_CLIP is implied. If this points to a NULL on entry, then a
+ buffer will be allocated to hold the generated image and the pointer updated on exit. It
+ is the caller¡¯s responsibility to free this buffer.
+ BltX,BLTY - Specifies the offset from the left and top edge of the image of the first character cell in
+ the image.
+ RowInfoArray - If this is non-NULL on entry, then on exit, this will point to an allocated buffer
+ containing row information and RowInfoArraySize will be updated to contain the
+ number of elements. This array describes the characters which were at least partially
+ drawn and the heights of the rows. It is the caller¡¯s responsibility to free this buffer.
+ RowInfoArraySize - If this is non-NULL on entry, then on exit it contains the number of elements in
+ RowInfoArray.
+ ColumnInfoArray - If this is non-NULL, then on return it will be filled with the horizontal offset for each
+ character in the string on the row where it is displayed. Non-printing characters will
+ have the offset ~0. The caller is responsible to allocate a buffer large enough so that
+ there is one entry for each character in the string, not including the null-terminator. It
+ is possible when character display is normalized that some character cells overlap.
+
+ Returns:
+ EFI_SUCCESS - The string was successfully rendered.
+ EFI_OUT_OF_RESOURCES - Unable to allocate an output buffer for RowInfoArray or Blt.
+ EFI_INVALID_PARAMETER - The Blt or PackageList was NULL.
+ EFI_INVALID_PARAMETER - Flags were invalid combination.
+ EFI_NOT_FOUND - The specified PackageList is not in the Database or the stringid is not
+ in the specified PackageList.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_HII_GET_GLYPH) (
+ IN CONST EFI_HII_FONT_PROTOCOL *This,
+ IN CHAR16 Char,
+ IN CONST EFI_FONT_DISPLAY_INFO *StringInfo,
+ OUT EFI_IMAGE_OUTPUT **Blt,
+ OUT UINTN *Baseline OPTIONAL
+ )
+/*++
+
+ Routine Description:
+ Convert the glyph for a single character into a bitmap.
+
+ Arguments:
+ This - A pointer to the EFI_HII_FONT_PROTOCOL instance.
+ Char - Character to retrieve.
+ StringInfo - Points to the string font and color information or NULL if the string should use the
+ default system font and color.
+ Blt - Thus must point to a NULL on entry. A buffer will be allocated to hold the output and
+ the pointer updated on exit. It is the caller¡¯s responsibility to free this buffer.
+ Baseline - Number of pixels from the bottom of the bitmap to the baseline.
+
+ Returns:
+ EFI_SUCCESS - Glyph bitmap created.
+ EFI_OUT_OF_RESOURCES - Unable to allocate the output buffer Blt.
+ EFI_WARN_UNKNOWN_GLYPH - The glyph was unknown and was
+ replaced with the glyph for Unicode
+ character 0xFFFD.
+ EFI_INVALID_PARAMETER - Blt is NULL or *Blt is not NULL.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_HII_GET_FONT_INFO) (
+ IN CONST EFI_HII_FONT_PROTOCOL *This,
+ IN OUT EFI_FONT_HANDLE *FontHandle,
+ IN CONST EFI_FONT_DISPLAY_INFO *StringInfoIn, OPTIONAL
+ OUT EFI_FONT_DISPLAY_INFO **StringInfoOut,
+ IN CONST EFI_STRING String OPTIONAL
+ )
+/*++
+
+ Routine Description:
+ This function iterates through fonts which match the specified font, using
+ the specified criteria. If String is non-NULL, then all of the characters in
+ the string must exist in order for a candidate font to be returned.
+
+ Arguments:
+ This - A pointer to the EFI_HII_FONT_PROTOCOL instance.
+ FontHandle - On entry, points to the font handle returned by a previous
+ call to GetFontInfo() or points to NULL to start with the
+ first font. On return, points to the returned font handle or
+ points to NULL if there are no more matching fonts.
+ StringInfoIn - Upon entry, points to the font to return information about.
+ If NULL, then the information about the system default
+ font will be returned.
+ StringInfoOut - Upon return, contains the matching font¡¯s information.
+ If NULL, then no information is returned.
+ It's caller's responsibility to free this buffer.
+ String - Points to the string which will be tested to determine
+ if all characters are available. If NULL, then any font
+ is acceptable.
+
+ Returns:
+ EFI_SUCCESS - Matching font returned successfully.
+ EFI_NOT_FOUND - No matching font was found.
+ EFI_INVALID_PARAMETER - StringInfoIn->FontInfoMask is an invalid combination.
+ EFI_OUT_OF_RESOURCES - There were insufficient resources to complete the request.
+
+--*/
+;
+
+
+//
+// Interface structure for the EFI_HII_FONT_PROTOCOL
+//
+typedef struct _EFI_HII_FONT_PROTOCOL {
+ EFI_HII_STRING_TO_IMAGE StringToImage;
+ EFI_HII_STRING_ID_TO_IMAGE StringIdToImage;
+ EFI_HII_GET_GLYPH GetGlyph;
+ EFI_HII_GET_FONT_INFO GetFontInfo;
+} EFI_HII_FONT_PROTOCOL;
+
+extern EFI_GUID gEfiHiiFontProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/HiiImage/HiiImage.c b/EDK/Foundation/Efi/Protocol/HiiImage/HiiImage.c
new file mode 100644
index 0000000..69ae266
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/HiiImage/HiiImage.c
@@ -0,0 +1,29 @@
+/*++
+
+Copyright (c) 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ HiiImage.c
+
+Abstract:
+
+ EFI_HII_IMAGE_PROTOCOL
+
+Revision History
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (HiiImage)
+
+EFI_GUID gEfiHiiImageProtocolGuid = EFI_HII_IMAGE_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiHiiImageProtocolGuid, "EFI HII IMAGE Protocol", "UEFI 2.1 HII IMAGE Protocol");
diff --git a/EDK/Foundation/Efi/Protocol/HiiImage/HiiImage.h b/EDK/Foundation/Efi/Protocol/HiiImage/HiiImage.h
new file mode 100644
index 0000000..b31cfaa
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/HiiImage/HiiImage.h
@@ -0,0 +1,256 @@
+/*++
+
+Copyright (c) 2007 - 2008, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ HiiImage.h
+
+Abstract:
+
+ EFI_HII_IMAGE_PROTOCOL from UEFI 2.1 specification.
+
+ This protocol provides access to images in the images database.
+
+Revision History
+
+--*/
+
+#ifndef __EFI_HII_IMAGE_PROTOCOL_H__
+#define __EFI_HII_IMAGE_PROTOCOL_H__
+
+#include "EfiHii.h"
+#include EFI_PROTOCOL_DEFINITION (GraphicsOutput)
+
+//
+// Global ID for the Hii Image Protocol.
+//
+#define EFI_HII_IMAGE_PROTOCOL_GUID \
+ { \
+ 0x31a6406a, 0x6bdf, 0x4e46, 0xb2, 0xa2, 0xeb, 0xaa, 0x89, 0xc4, 0x9, 0x20 \
+ }
+
+EFI_FORWARD_DECLARATION (EFI_HII_IMAGE_PROTOCOL);
+
+typedef UINT32 EFI_HII_DRAW_FLAGS;
+
+typedef struct _EFI_IMAGE_INPUT {
+ UINT32 Flags;
+ UINT16 Width;
+ UINT16 Height;
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Bitmap;
+} EFI_IMAGE_INPUT;
+
+#define EFI_IMAGE_TRANSPARENT 0x00000001
+
+typedef struct _EFI_IMAGE_OUTPUT {
+ UINT16 Width;
+ UINT16 Height;
+ union {
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Bitmap;
+ EFI_GRAPHICS_OUTPUT_PROTOCOL *Screen;
+ } Image;
+} EFI_IMAGE_OUTPUT;
+
+#define EFI_HII_DRAW_FLAG_CLIP 0x00000001
+#define EFI_HII_DRAW_FLAG_TRANSPARENT 0x00000030
+#define EFI_HII_DRAW_FLAG_DEFAULT 0x00000000
+#define EFI_HII_DRAW_FLAG_FORCE_TRANS 0x00000010
+#define EFI_HII_DRAW_FLAG_FORCE_OPAQUE 0x00000020
+#define EFI_HII_DIRECT_TO_SCREEN 0x00000080
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_HII_NEW_IMAGE) (
+ IN CONST EFI_HII_IMAGE_PROTOCOL *This,
+ IN EFI_HII_HANDLE PackageList,
+ OUT EFI_IMAGE_ID *ImageId,
+ IN CONST EFI_IMAGE_INPUT *Image
+ )
+/*++
+
+ Routine Description:
+ This function adds the image Image to the group of images owned by PackageList, and returns
+ a new image identifier (ImageId).
+
+ Arguments:
+ This - A pointer to the EFI_HII_IMAGE_PROTOCOL instance.
+ PackageList - Handle of the package list where this image will be added.
+ ImageId - On return, contains the new image id, which is unique within PackageList.
+ Image - Points to the image.
+
+ Returns:
+ EFI_SUCCESS - The new image was added successfully.
+ EFI_NOT_FOUND - The specified PackageList could not be found in database.
+ EFI_OUT_OF_RESOURCES - Could not add the image due to lack of resources.
+ EFI_INVALID_PARAMETER - Image is NULL or ImageId is NULL.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_HII_GET_IMAGE) (
+ IN CONST EFI_HII_IMAGE_PROTOCOL *This,
+ IN EFI_HII_HANDLE PackageList,
+ IN EFI_IMAGE_ID ImageId,
+ OUT EFI_IMAGE_INPUT *Image
+ )
+/*++
+
+ Routine Description:
+ This function retrieves the image specified by ImageId which is associated with
+ the specified PackageList and copies it into the buffer specified by Image.
+
+ Arguments:
+ This - A pointer to the EFI_HII_IMAGE_PROTOCOL instance.
+ PackageList - Handle of the package list where this image will be searched.
+ ImageId - The image¡¯s id,, which is unique within PackageList.
+ Image - Points to the image.
+
+ Returns:
+ EFI_SUCCESS - The new image was returned successfully.
+ EFI_NOT_FOUND - The image specified by ImageId is not available.
+ The specified PackageList is not in the database.
+ EFI_INVALID_PARAMETER - The Image or ImageSize was NULL.
+ EFI_OUT_OF_RESOURCES - The bitmap could not be retrieved because there was not
+ enough memory.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_HII_SET_IMAGE) (
+ IN CONST EFI_HII_IMAGE_PROTOCOL *This,
+ IN EFI_HII_HANDLE PackageList,
+ IN EFI_IMAGE_ID ImageId,
+ IN CONST EFI_IMAGE_INPUT *Image
+ )
+/*++
+
+ Routine Description:
+ This function updates the image specified by ImageId in the specified PackageListHandle to
+ the image specified by Image.
+
+ Arguments:
+ This - A pointer to the EFI_HII_IMAGE_PROTOCOL instance.
+ PackageList - The package list containing the images.
+ ImageId - The image¡¯s id,, which is unique within PackageList.
+ Image - Points to the image.
+
+ Returns:
+ EFI_SUCCESS - The new image was updated successfully.
+ EFI_NOT_FOUND - The image specified by ImageId is not in the database.
+ The specified PackageList is not in the database.
+ EFI_INVALID_PARAMETER - The Image was NULL.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_HII_DRAW_IMAGE) (
+ IN CONST EFI_HII_IMAGE_PROTOCOL *This,
+ IN EFI_HII_DRAW_FLAGS Flags,
+ IN CONST EFI_IMAGE_INPUT *Image,
+ IN OUT EFI_IMAGE_OUTPUT **Blt,
+ IN UINTN BltX,
+ IN UINTN BltY
+ )
+/*++
+
+ Routine Description:
+ This function renders an image to a bitmap or the screen using the specified
+ color and options. It draws the image on an existing bitmap, allocates a new
+ bitmap or uses the screen. The images can be clipped.
+
+ Arguments:
+ This - A pointer to the EFI_HII_IMAGE_PROTOCOL instance.
+ Flags - Describes how the image is to be drawn.
+ Image - Points to the image to be displayed.
+ Blt - If this points to a non-NULL on entry, this points to the
+ image, which is Width pixels wide and Height pixels high.
+ The image will be drawn onto this image and
+ EFI_HII_DRAW_FLAG_CLIP is implied. If this points to a
+ NULL on entry, then a buffer will be allocated to hold
+ the generated image and the pointer updated on exit. It
+ is the caller¡¯s responsibility to free this buffer.
+ BltX, BltY - Specifies the offset from the left and top edge of the
+ output image of the first pixel in the image.
+
+ Returns:
+ EFI_SUCCESS - The image was successfully drawn.
+ EFI_OUT_OF_RESOURCES - Unable to allocate an output buffer for Blt.
+ EFI_INVALID_PARAMETER - The Image or Blt was NULL.
+ EFI_INVALID_PARAMETER - Any combination of Flags is invalid.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_HII_DRAW_IMAGE_ID) (
+ IN CONST EFI_HII_IMAGE_PROTOCOL *This,
+ IN EFI_HII_DRAW_FLAGS Flags,
+ IN EFI_HII_HANDLE PackageList,
+ IN EFI_IMAGE_ID ImageId,
+ IN OUT EFI_IMAGE_OUTPUT **Blt,
+ IN UINTN BltX,
+ IN UINTN BltY
+ )
+
+/*++
+
+ Routine Description:
+ This function renders an image to a bitmap or the screen using the specified
+ color and options. It draws the image on an existing bitmap, allocates a new
+ bitmap or uses the screen. The images can be clipped.
+
+ Arguments:
+ This - A pointer to the EFI_HII_IMAGE_PROTOCOL instance.
+ Flags - Describes how the image is to be drawn.
+ PackageList - The package list in the HII database to search for the
+ specified image.
+ ImageId - The image's id, which is unique within PackageList.
+ Blt - If this points to a non-NULL on entry, this points to the
+ image, which is Width pixels wide and Height pixels high.
+ The image will be drawn onto this image and
+ EFI_HII_DRAW_FLAG_CLIP is implied. If this points to a
+ NULL on entry, then a buffer will be allocated to hold
+ the generated image and the pointer updated on exit. It
+ is the caller¡¯s responsibility to free this buffer.
+ BltX, BltY - Specifies the offset from the left and top edge of the
+ output image of the first pixel in the image.
+
+ Returns:
+ EFI_SUCCESS - The image was successfully drawn.
+ EFI_OUT_OF_RESOURCES - Unable to allocate an output buffer for Blt.
+ EFI_NOT_FOUND - The image specified by ImageId is not in the database.
+ The specified PackageList is not in the database.
+ EFI_INVALID_PARAMETER - The Blt was NULL.
+
+--*/
+;
+
+//
+// Interface structure for the EFI_HII_IMAGE_PROTOCOL
+//
+typedef struct _EFI_HII_IMAGE_PROTOCOL {
+ EFI_HII_NEW_IMAGE NewImage;
+ EFI_HII_GET_IMAGE GetImage;
+ EFI_HII_SET_IMAGE SetImage;
+ EFI_HII_DRAW_IMAGE DrawImage;
+ EFI_HII_DRAW_IMAGE_ID DrawImageId;
+} EFI_HII_IMAGE_PROTOCOL;
+
+extern EFI_GUID gEfiHiiImageProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/HiiPackageList/HiiPackageList.c b/EDK/Foundation/Efi/Protocol/HiiPackageList/HiiPackageList.c
new file mode 100644
index 0000000..276cd02
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/HiiPackageList/HiiPackageList.c
@@ -0,0 +1,27 @@
+/*++
+
+Copyright (c) 2008, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ HiiPackageList.c
+
+Abstract:
+
+ EFI_HII_PACKAGE_LIST_PROTOCOL as defined in UEFI 2.1 spec.
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (HiiPackageList)
+
+EFI_GUID gEfiHiiPackageListProtocolGuid = EFI_HII_PACKAGE_LIST_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiHiiPackageListProtocolGuid, "HII Package List Protocol", "HII Package List 2.1 protocol");
diff --git a/EDK/Foundation/Efi/Protocol/HiiPackageList/HiiPackageList.h b/EDK/Foundation/Efi/Protocol/HiiPackageList/HiiPackageList.h
new file mode 100644
index 0000000..55aec60
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/HiiPackageList/HiiPackageList.h
@@ -0,0 +1,36 @@
+/*++
+
+Copyright (c) 2008, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ HiiPackageList.h
+
+Abstract:
+
+ EFI_HII_PACKAGE_LIST_PROTOCOL as defined in UEFI 2.1 spec.
+
+--*/
+
+#ifndef _HII_PACKAGE_LIST_H_
+#define _HII_PACKAGE_LIST_H_
+
+#include "EfiHii.h"
+
+#define EFI_HII_PACKAGE_LIST_PROTOCOL_GUID \
+ { \
+ 0x6a1ee763, 0xd47a, 0x43b4, 0xaa, 0xbe, 0xef, 0x1d, 0xe2, 0xab, 0x56, 0xfc \
+ }
+
+typedef EFI_HII_PACKAGE_LIST_HEADER * EFI_HII_PACKAGE_LIST_PROTOCOL;
+
+extern EFI_GUID gEfiHiiPackageListProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/HiiString/HiiString.c b/EDK/Foundation/Efi/Protocol/HiiString/HiiString.c
new file mode 100644
index 0000000..adb52b4
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/HiiString/HiiString.c
@@ -0,0 +1,29 @@
+/*++
+
+Copyright (c) 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ HiiString.c
+
+Abstract:
+
+ EFI_HII_STRING_PROTOCOL
+
+Revision History
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (HiiString)
+
+EFI_GUID gEfiHiiStringProtocolGuid = EFI_HII_STRING_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiHiiStringProtocolGuid, "EFI HII STRING Protocol", "UEFI 2.1 HII STRING Protocol");
diff --git a/EDK/Foundation/Efi/Protocol/HiiString/HiiString.h b/EDK/Foundation/Efi/Protocol/HiiString/HiiString.h
new file mode 100644
index 0000000..fdc7c4d
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/HiiString/HiiString.h
@@ -0,0 +1,253 @@
+/*++
+
+Copyright (c) 2007 - 2010, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ HiiString.h
+
+Abstract:
+
+ EFI_HII_STRING_PROTOCOL from UEFI 2.1 specification.
+
+ This protocol provides interfaces to manipulate string data.
+
+Revision History
+
+--*/
+
+#ifndef __EFI_HII_STRING_PROTOCOL_H__
+#define __EFI_HII_STRING_PROTOCOL_H__
+
+#include EFI_PROTOCOL_DEFINITION (HiiFont)
+
+//
+// Global ID for the Hii String Protocol.
+//
+#define EFI_HII_STRING_PROTOCOL_GUID \
+ { \
+ 0xfd96974, 0x23aa, 0x4cdc, 0xb9, 0xcb, 0x98, 0xd1, 0x77, 0x50, 0x32, 0x2a \
+ }
+
+EFI_FORWARD_DECLARATION (EFI_HII_STRING_PROTOCOL);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_HII_NEW_STRING) (
+ IN CONST EFI_HII_STRING_PROTOCOL *This,
+ IN EFI_HII_HANDLE PackageList,
+ OUT EFI_STRING_ID *StringId,
+ IN CONST CHAR8 *Language,
+ IN CONST CHAR16 *LanguageName, OPTIONAL
+ IN CONST EFI_STRING String,
+ IN CONST EFI_FONT_INFO *StringFontInfo OPTIONAL
+ )
+/*++
+
+ Routine Description:
+ This function adds the string String to the group of strings owned by PackageList, with the
+ specified font information StringFontInfo and returns a new string id.
+ The new string identifier is guaranteed to be unique within the package list.
+ That new string identifier is reserved for all languages in the package list.
+
+ Arguments:
+ This - A pointer to the EFI_HII_STRING_PROTOCOL instance.
+ PackageList - Handle of the package list where this string will be added.
+ StringId - On return, contains the new strings id, which is unique within PackageList.
+ Language - Points to the language for the new string.
+ LanguageName - Points to the printable language name to associate with the passed in
+ Language field.If LanguageName is not NULL and the string package header's LanguageName
+ associated with a given Language is not zero, the LanguageName being passed
+ in will be ignored.
+ String - Points to the new null-terminated string.
+ StringFontInfo - Points to the new string¡¯s font information or NULL if the string should have the
+ default system font, size and style.
+
+ Returns:
+ EFI_SUCCESS - The new string was added successfully.
+ EFI_NOT_FOUND - The specified PackageList could not be found in database.
+ EFI_OUT_OF_RESOURCES - Could not add the string due to lack of resources.
+ EFI_INVALID_PARAMETER - String is NULL or StringId is NULL or Language is NULL.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_HII_GET_STRING) (
+ IN CONST EFI_HII_STRING_PROTOCOL *This,
+ IN CONST CHAR8 *Language,
+ IN EFI_HII_HANDLE PackageList,
+ IN EFI_STRING_ID StringId,
+ OUT EFI_STRING String,
+ IN OUT UINTN *StringSize,
+ OUT EFI_FONT_INFO **StringFontInfo OPTIONAL
+ )
+/*++
+
+ Routine Description:
+ This function retrieves the string specified by StringId which is associated
+ with the specified PackageList in the language Language and copies it into
+ the buffer specified by String.
+
+ Arguments:
+ This - A pointer to the EFI_HII_STRING_PROTOCOL instance.
+ Language - Points to the language for the retrieved string.
+ PackageList - The package list in the HII database to search for the
+ specified string.
+ StringId - The string's id, which is unique within PackageList.
+ String - Points to the new null-terminated string.
+ StringSize - On entry, points to the size of the buffer pointed to by
+ String, in bytes. On return,
+ points to the length of the string, in bytes.
+ StringFontInfo - Points to a buffer that will be callee allocated and will
+ have the string's font information into this buffer.
+ The caller is responsible for freeing this buffer.
+ If the parameter is NULL a buffer will not be allocated
+ and the string font information will not be returned.
+
+ Returns:
+ EFI_SUCCESS - The string was returned successfully.
+ EFI_NOT_FOUND - The string specified by StringId is not available.
+ The specified PackageList is not in the database.
+ EFI_INVALID_LANGUAGE - The string specified by StringId is available but
+ not in the specified language.
+ EFI_BUFFER_TOO_SMALL - The buffer specified by StringSize is too small to
+ hold the string.
+ EFI_INVALID_PARAMETER - The String or Language or StringSize was NULL.
+ EFI_OUT_OF_RESOURCES - There were insufficient resources to complete the
+ request.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_HII_SET_STRING) (
+ IN CONST EFI_HII_STRING_PROTOCOL *This,
+ IN EFI_HII_HANDLE PackageList,
+ IN EFI_STRING_ID StringId,
+ IN CONST CHAR8 *Language,
+ IN CONST EFI_STRING String,
+ IN CONST EFI_FONT_INFO *StringFontInfo OPTIONAL
+ )
+/*++
+
+ Routine Description:
+ This function updates the string specified by StringId in the specified PackageList to the text
+ specified by String and, optionally, the font information specified by StringFontInfo.
+
+ Arguments:
+ This - A pointer to the EFI_HII_STRING_PROTOCOL instance.
+ PackageList - The package list containing the strings.
+ StringId - The string¡¯s id, which is unique within PackageList.
+ Language - Points to the language for the updated string.
+ String - Points to the new null-terminated string.
+ StringFontInfo - Points to the string¡¯s font information or NULL if the string font information is not
+ changed.
+
+ Returns:
+ EFI_SUCCESS - The string was updated successfully.
+ EFI_NOT_FOUND - The string specified by StringId is not in the database.
+ The specified PackageList is not in the database.
+ EFI_INVALID_PARAMETER - The String or Language was NULL.
+ EFI_OUT_OF_RESOURCES - The system is out of resources to accomplish the task.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_HII_GET_LANGUAGES) (
+ IN CONST EFI_HII_STRING_PROTOCOL *This,
+ IN EFI_HII_HANDLE PackageList,
+ IN OUT CHAR8 *Languages,
+ IN OUT UINTN *LanguagesSize
+ )
+/*++
+
+ Routine Description:
+ This function returns the list of supported languages, in the format specified
+ in Appendix M of UEFI 2.1 spec.
+
+ Arguments:
+ This - A pointer to the EFI_HII_STRING_PROTOCOL instance.
+ PackageList - The package list to examine.
+ Languages - Points to the buffer to hold the returned string.
+ LanguagesSize - On entry, points to the size of the buffer pointed to by
+ Languages, in bytes. On
+ return, points to the length of Languages, in bytes.
+
+ Returns:
+ EFI_SUCCESS - The languages were returned successfully.
+ EFI_INVALID_PARAMETER - The Languages or LanguagesSize was NULL.
+ EFI_BUFFER_TOO_SMALL - The LanguagesSize is too small to hold the list of
+ supported languages. LanguageSize is updated to
+ contain the required size.
+ EFI_NOT_FOUND - The specified PackageList is not in the database.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_HII_GET_2ND_LANGUAGES) (
+ IN CONST EFI_HII_STRING_PROTOCOL *This,
+ IN EFI_HII_HANDLE PackageList,
+ IN CONST CHAR8 *FirstLanguage,
+ IN OUT CHAR8 *SecondLanguages,
+ IN OUT UINTN *SecondLanguagesSize
+ )
+/*++
+
+ Routine Description:
+ Each string package has associated with it a single primary language and zero
+ or more secondary languages. This routine returns the secondary languages
+ associated with a package list.
+
+ Arguments:
+ This - A pointer to the EFI_HII_STRING_PROTOCOL instance.
+ PackageList - The package list to examine.
+ FirstLanguage - Points to the primary language.
+ SecondaryLanguages - Points to the buffer to hold the returned list of
+ secondary languages for the specified FirstLanguage.
+ If there are no secondary languages, the function
+ returns successfully, but this is set to NULL.
+ SecondaryLanguageSize - On entry, points to the size of the buffer pointed to
+ by SecondLanguages, in bytes. On return, points to
+ the length of SecondLanguages in bytes.
+
+ Returns:
+ EFI_SUCCESS - Secondary languages were correctly returned.
+ EFI_INVALID_PARAMETER - FirstLanguage or SecondLanguages or SecondLanguagesSize was NULL.
+ EFI_BUFFER_TOO_SMALL - The buffer specified by SecondLanguagesSize is
+ too small to hold the returned information.
+ SecondLanguageSize is updated to hold the size of
+ the buffer required.
+ EFI_INVALID_LANGUAGE - The language specified by FirstLanguage is not
+ present in the specified package list.
+ EFI_NOT_FOUND - The specified PackageList is not in the Database.
+
+--*/
+;
+//
+// Interface structure for the EFI_HII_STRING_PROTOCOL
+//
+typedef struct _EFI_HII_STRING_PROTOCOL {
+ EFI_HII_NEW_STRING NewString;
+ EFI_HII_GET_STRING GetString;
+ EFI_HII_SET_STRING SetString;
+ EFI_HII_GET_LANGUAGES GetLanguages;
+ EFI_HII_GET_2ND_LANGUAGES GetSecondaryLanguages;
+} EFI_HII_STRING_PROTOCOL;
+
+extern EFI_GUID gEfiHiiStringProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/IScsiInitiatorName/IScsiInitiatorName.c b/EDK/Foundation/Efi/Protocol/IScsiInitiatorName/IScsiInitiatorName.c
new file mode 100644
index 0000000..38df0ec
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/IScsiInitiatorName/IScsiInitiatorName.c
@@ -0,0 +1,27 @@
+/*++
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ IScsiInitatorName.c
+
+Abstract:
+ EFI_ISCSI_INITIATOR_NAME_PROTOCOL as defined in UEFI 2.0.
+ It rovides the ability to get and set the iSCSI Initiator Name.
+
+Revision History
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (IScsiInitiatorName)
+
+EFI_GUID gEfiIScsiInitiatorNameProtocolGuid = EFI_ISCSI_INITIATOR_NAME_PROTOCOL_GUID;
+EFI_GUID_STRING(&gEfiIScsiInitiatorNameProtocolGuid, "ISCSI Initiator Name Protocol", "UEFI 2.0 ISCSI Initiator Name Protocol"); \ No newline at end of file
diff --git a/EDK/Foundation/Efi/Protocol/IScsiInitiatorName/IScsiInitiatorName.h b/EDK/Foundation/Efi/Protocol/IScsiInitiatorName/IScsiInitiatorName.h
new file mode 100644
index 0000000..c578538
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/IScsiInitiatorName/IScsiInitiatorName.h
@@ -0,0 +1,98 @@
+/*++
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ IScsiInitatorName.h
+
+Abstract:
+ EFI_ISCSI_INITIATOR_NAME_PROTOCOL as defined in UEFI 2.0.
+ It rovides the ability to get and set the iSCSI Initiator Name.
+
+Revision History
+
+--*/
+
+#ifndef __ISCSI_INITIATOR_NAME_H__
+#define __ISCSI_INITIATOR_NAME_H__
+
+#define EFI_ISCSI_INITIATOR_NAME_PROTOCOL_GUID \
+{ \
+ 0x59324945, 0xec44, 0x4c0d, {0xb1, 0xcd, 0x9d, 0xb1, 0x39, 0xdf, 0x7, 0xc } \
+}
+
+typedef struct _EFI_ISCSI_INITIATOR_NAME_PROTOCOL EFI_ISCSI_INITIATOR_NAME_PROTOCOL;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_ISCSI_INITIATOR_NAME_GET) (
+ IN EFI_ISCSI_INITIATOR_NAME_PROTOCOL *This,
+ IN OUT UINTN *BufferSize,
+ OUT VOID *Buffer
+ )
+/*++
+
+ Routine Description:
+ Retrieves the current set value of iSCSI Initiator Name.
+
+ Arguments:
+ This - Pointer to the EFI_ISCSI_INITIATOR_NAME_PROTOCOL instance.
+ BufferSize - Size of the buffer in bytes pointed to by Buffer / Actual size of the
+ variable data buffer.
+ Buffer - Pointer to the buffer for data to be read.
+
+ Returns:
+ EFI_SUCCESS - Data was successfully retrieved into the provided buffer and the
+ BufferSize was sufficient to handle the iSCSI initiator name
+ EFI_BUFFER_TOO_SMALL - BufferSize is too small for the result.
+ EFI_INVALID_PARAMETER - BufferSize or Buffer is NULL.
+ EFI_DEVICE_ERROR - The iSCSI initiator name could not be retrieved due to a hardware error.
+
+--*/
+;
+
+
+
+typedef EFI_STATUS
+(EFIAPI *EFI_ISCSI_INITIATOR_NAME_SET) (
+ IN EFI_ISCSI_INITIATOR_NAME_PROTOCOL *This,
+ IN OUT UINTN *BufferSize,
+ IN VOID *Buffer
+ )
+/*++
+
+ Routine Description:
+ Sets the iSCSI Initiator Name.
+
+ Arguments:
+ This - Pointer to the EFI_ISCSI_INITIATOR_NAME_PROTOCOL instance.
+ BufferSize - Size of the buffer in bytes pointed to by Buffer.
+ Buffer - Pointer to the buffer for data to be written.
+
+ Returns:
+ EFI_SUCCESS - Data was successfully stored by the protocol.
+ EFI_UNSUPPORTED - Platform policies do not allow for data to be written.
+ EFI_INVALID_PARAMETER - BufferSize or Buffer is NULL, or BufferSize exceeds the maximum allowed limit.
+ EFI_DEVICE_ERROR - The data could not be stored due to a hardware error.
+ EFI_OUT_OF_RESOURCES - Not enough storage is available to hold the data.
+ EFI_PROTOCOL_ERROR - Input iSCSI initiator name does not adhere to RFC 3720
+ (and other related protocols)
+
+--*/
+;
+
+struct _EFI_ISCSI_INITIATOR_NAME_PROTOCOL {
+ EFI_ISCSI_INITIATOR_NAME_GET Get;
+ EFI_ISCSI_INITIATOR_NAME_SET Set;
+};
+
+extern EFI_GUID gEfiIScsiInitiatorNameProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/Ip4/Ip4.c b/EDK/Foundation/Efi/Protocol/Ip4/Ip4.c
new file mode 100644
index 0000000..fba749b
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/Ip4/Ip4.c
@@ -0,0 +1,41 @@
+/*++
+
+Copyright (c) 2005 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ Ip4.c
+
+Abstract:
+
+ UEFI IPv4 protocol.
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (Ip4)
+
+EFI_GUID gEfiIp4ServiceBindingProtocolGuid
+ = EFI_IP4_SERVICE_BINDING_PROTOCOL_GUID;
+
+EFI_GUID gEfiIp4ProtocolGuid = EFI_IP4_PROTOCOL_GUID;
+
+EFI_GUID_STRING (
+ &gEfiIp4ServiceBindingProtocolGuid,
+ "IP4 Service Binding Protocol",
+ "IP4 Service Binding Protocol"
+ );
+
+EFI_GUID_STRING (
+ &gEfiIp4ProtocolGuid,
+ "IP4 Protocol",
+ "IP4 Protocol"
+ );
diff --git a/EDK/Foundation/Efi/Protocol/Ip4/Ip4.h b/EDK/Foundation/Efi/Protocol/Ip4/Ip4.h
new file mode 100644
index 0000000..4c06a1c
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/Ip4/Ip4.h
@@ -0,0 +1,241 @@
+/*++
+
+Copyright (c) 2005 - 2011, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Ip4.h
+
+Abstract:
+
+ UEFI IPv4 protocol.
+
+--*/
+
+#ifndef _IP4_H_
+#define _IP4_H_
+
+#include EFI_PROTOCOL_DEFINITION (ManagedNetwork)
+#include EFI_PROTOCOL_DEFINITION (ServiceBinding)
+
+//
+//GUID definitions
+//
+#define EFI_IP4_SERVICE_BINDING_PROTOCOL_GUID \
+ {0xc51711e7, 0xb4bf, 0x404a, 0xbf, 0xb8, 0x0a, 0x04, 0x8e, 0xf1, 0xff, 0xe4}
+
+#define EFI_IP4_PROTOCOL_GUID \
+ {0x41d94cd2, 0x35b6, 0x455a, 0x82, 0x58, 0xd4, 0xe5, 0x13, 0x34, 0xaa, 0xdd}
+
+EFI_FORWARD_DECLARATION (EFI_IP4_PROTOCOL);
+
+typedef struct {
+ EFI_HANDLE InstanceHandle;
+ EFI_IPv4_ADDRESS Ip4Address;
+ EFI_IPv4_ADDRESS SubnetMask;
+} EFI_IP4_ADDRESS_PAIR;
+
+typedef struct {
+ EFI_HANDLE DriverHandle;
+ UINT32 AddressCount;
+ EFI_IP4_ADDRESS_PAIR AddressPairs[1];
+} EFI_IP4_VARIABLE_DATA;
+
+typedef struct {
+ UINT8 DefaultProtocol;
+ BOOLEAN AcceptAnyProtocol;
+ BOOLEAN AcceptIcmpErrors;
+ BOOLEAN AcceptBroadcast;
+ BOOLEAN AcceptPromiscuous;
+ BOOLEAN UseDefaultAddress;
+ EFI_IPv4_ADDRESS StationAddress;
+ EFI_IPv4_ADDRESS SubnetMask;
+ UINT8 TypeOfService;
+ UINT8 TimeToLive;
+ BOOLEAN DoNotFragment;
+ BOOLEAN RawData;
+ UINT32 ReceiveTimeout;
+ UINT32 TransmitTimeout;
+} EFI_IP4_CONFIG_DATA;
+
+
+typedef struct _EFI_IP4_ROUTE_TABLE {
+ EFI_IPv4_ADDRESS SubnetAddress;
+ EFI_IPv4_ADDRESS SubnetMask;
+ EFI_IPv4_ADDRESS GatewayAddress;
+} EFI_IP4_ROUTE_TABLE;
+
+typedef struct _EFI_IP4_ICMP_TYPE {
+ UINT8 Type;
+ UINT8 Code;
+} EFI_IP4_ICMP_TYPE;
+
+typedef struct {
+ BOOLEAN IsStarted;
+ UINT32 MaxPacketSize;
+ EFI_IP4_CONFIG_DATA ConfigData;
+ BOOLEAN IsConfigured;
+
+ UINT32 GroupCount;
+ EFI_IPv4_ADDRESS *GroupTable;
+
+ UINT32 RouteCount;
+ EFI_IP4_ROUTE_TABLE *RouteTable;
+
+ UINT32 IcmpTypeCount;
+ EFI_IP4_ICMP_TYPE *IcmpTypeList;
+} EFI_IP4_MODE_DATA;
+
+#pragma pack(1)
+typedef struct _EFI_IP4_HEADER {
+ UINT8 HeaderLength:4;
+ UINT8 Version:4;
+ UINT8 TypeOfService;
+ UINT16 TotalLength;
+ UINT16 Identification;
+ UINT16 Fragmentation;
+ UINT8 TimeToLive;
+ UINT8 Protocol;
+ UINT16 Checksum;
+ EFI_IPv4_ADDRESS SourceAddress;
+ EFI_IPv4_ADDRESS DestinationAddress;
+} EFI_IP4_HEADER;
+#pragma pack()
+
+typedef struct _EFI_IP4_FRAGMENT_DATA {
+ UINT32 FragmentLength;
+ VOID *FragmentBuffer;
+} EFI_IP4_FRAGMENT_DATA;
+
+
+typedef struct _EFI_IP4_OVERRIDE_DATA {
+ EFI_IPv4_ADDRESS SourceAddress;
+ EFI_IPv4_ADDRESS GatewayAddress;
+
+ UINT8 Protocol;
+ UINT8 TypeOfService;
+ UINT8 TimeToLive;
+ BOOLEAN DoNotFragment;
+} EFI_IP4_OVERRIDE_DATA;
+
+typedef struct _EFI_IP4_TRANSMIT_DATA {
+ EFI_IPv4_ADDRESS DestinationAddress;
+
+ EFI_IP4_OVERRIDE_DATA *OverrideData;
+ UINT32 OptionsLength;
+ VOID *OptionsBuffer;
+
+ UINT32 TotalDataLength;
+ UINT32 FragmentCount;
+ EFI_IP4_FRAGMENT_DATA FragmentTable[1];
+} EFI_IP4_TRANSMIT_DATA;
+
+typedef struct _EFI_IP4_RECEIVE_DATA {
+ EFI_TIME TimeStamp;
+ EFI_EVENT RecycleSignal;
+
+ UINT32 HeaderLength;
+ EFI_IP4_HEADER *Header;
+
+ UINT32 OptionsLength;
+ VOID *Options;
+
+ UINT32 DataLength;
+ UINT32 FragmentCount;
+ EFI_IP4_FRAGMENT_DATA FragmentTable[1];
+} EFI_IP4_RECEIVE_DATA;
+
+typedef struct _EFI_IP4_COMPLETION_TOKEN {
+ EFI_EVENT Event;
+ EFI_STATUS Status;
+
+ union {
+ EFI_IP4_RECEIVE_DATA *RxData;
+ EFI_IP4_TRANSMIT_DATA *TxData;
+ } Packet;
+} EFI_IP4_COMPLETION_TOKEN;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_IP4_GET_MODE_DATA) (
+ IN EFI_IP4_PROTOCOL *This,
+ OUT EFI_IP4_MODE_DATA *Ip4ModeData OPTIONAL,
+ OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL,
+ OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_IP4_CONFIGURE) (
+ IN EFI_IP4_PROTOCOL *This,
+ IN EFI_IP4_CONFIG_DATA *IpConfigData OPTIONAL
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_IP4_GROUPS) (
+ IN EFI_IP4_PROTOCOL *This,
+ IN BOOLEAN JoinFlag,
+ IN EFI_IPv4_ADDRESS *GroupAddress OPTIONAL
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_IP4_ROUTES) (
+ IN EFI_IP4_PROTOCOL *This,
+ IN BOOLEAN DeleteRoute,
+ IN EFI_IPv4_ADDRESS *SubnetAddress,
+ IN EFI_IPv4_ADDRESS *SubnetMask,
+ IN EFI_IPv4_ADDRESS *GatewayAddress
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_IP4_TRANSMIT) (
+ IN EFI_IP4_PROTOCOL *This,
+ IN EFI_IP4_COMPLETION_TOKEN *Token
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_IP4_RECEIVE) (
+ IN EFI_IP4_PROTOCOL *This,
+ IN EFI_IP4_COMPLETION_TOKEN *Token
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_IP4_CANCEL) (
+ IN EFI_IP4_PROTOCOL *This,
+ IN EFI_IP4_COMPLETION_TOKEN *Token OPTIONAL
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_IP4_POLL) (
+ IN EFI_IP4_PROTOCOL *This
+ );
+
+typedef struct _EFI_IP4_PROTOCOL {
+ EFI_IP4_GET_MODE_DATA GetModeData;
+ EFI_IP4_CONFIGURE Configure;
+ EFI_IP4_GROUPS Groups;
+ EFI_IP4_ROUTES Routes;
+ EFI_IP4_TRANSMIT Transmit;
+ EFI_IP4_RECEIVE Receive;
+ EFI_IP4_CANCEL Cancel;
+ EFI_IP4_POLL Poll;
+} EFI_IP4_PROTOCOL;
+
+
+extern EFI_GUID gEfiIp4ServiceBindingProtocolGuid;
+extern EFI_GUID gEfiIp4RegistryDataGuid;
+extern EFI_GUID gEfiIp4ProtocolGuid;
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/Ip4Config/Ip4Config.c b/EDK/Foundation/Efi/Protocol/Ip4Config/Ip4Config.c
new file mode 100644
index 0000000..7ff845b
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/Ip4Config/Ip4Config.c
@@ -0,0 +1,29 @@
+/*++
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Ip4Config.c
+
+Abstract:
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (Ip4Config)
+
+EFI_GUID gEfiIp4ConfigProtocolGuid = EFI_IP4_CONFIG_PROTOCOL_GUID;
+
+EFI_GUID_STRING (
+ &gEfiIp4ConfigProtocolGuid,
+ "Ip4Config Protocol",
+ "Ip4Config Protocol"
+ );
diff --git a/EDK/Foundation/Efi/Protocol/Ip4Config/Ip4Config.h b/EDK/Foundation/Efi/Protocol/Ip4Config/Ip4Config.h
new file mode 100644
index 0000000..c6d4b86
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/Ip4Config/Ip4Config.h
@@ -0,0 +1,72 @@
+/*++
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Ip4Config.h
+
+Abstract:
+
+--*/
+
+#ifndef _IP4CONFIG_H_
+#define _IP4CONFIG_H_
+
+#include EFI_PROTOCOL_DEFINITION (Ip4)
+
+#define EFI_IP4_CONFIG_PROTOCOL_GUID \
+ { 0x3b95aa31, 0x3793, 0x434b, 0x86, 0x67, 0xc8, 0x07, 0x08, 0x92, 0xe0, 0x5e }
+
+EFI_FORWARD_DECLARATION (EFI_IP4_CONFIG_PROTOCOL);
+
+#define IP4_CONFIG_VARIABLE_ATTRIBUTES (EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS)
+
+typedef struct {
+ EFI_IPv4_ADDRESS StationAddress;
+ EFI_IPv4_ADDRESS SubnetMask;
+ UINT32 RouteTableSize;
+ EFI_IP4_ROUTE_TABLE *RouteTable;
+} EFI_IP4_IPCONFIG_DATA;
+
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_IP4_CONFIG_START) (
+ IN EFI_IP4_CONFIG_PROTOCOL *This,
+ IN EFI_EVENT DoneEvent,
+ IN EFI_EVENT ReconfigEvent
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_IP4_CONFIG_STOP) (
+ IN EFI_IP4_CONFIG_PROTOCOL *This
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_IP4_CONFIG_GET_DATA) (
+ IN EFI_IP4_CONFIG_PROTOCOL *This,
+ IN OUT UINTN *ConfigDataSize,
+ OUT EFI_IP4_IPCONFIG_DATA *ConfigData OPTIONAL
+ );
+
+
+typedef struct _EFI_IP4_CONFIG_PROTOCOL {
+ EFI_IP4_CONFIG_START Start;
+ EFI_IP4_CONFIG_STOP Stop;
+ EFI_IP4_CONFIG_GET_DATA GetData;
+} EFI_IP4_CONFIG_PROTOCOL;
+
+
+extern EFI_GUID gEfiIp4ConfigProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/LoadFile/LoadFile.c b/EDK/Foundation/Efi/Protocol/LoadFile/LoadFile.c
new file mode 100644
index 0000000..1fd7adc
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/LoadFile/LoadFile.c
@@ -0,0 +1,33 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ LoadFile.c
+
+Abstract:
+
+ Load File protocol as defined in the EFI 1.0 specification.
+
+ Load file protocol exists to supports the addition of new boot devices,
+ and to support booting from devices that do not map well to file system.
+ Network boot is done via a LoadFile protocol.
+
+ EFI 1.0 can boot from any device that produces a LoadFile protocol.
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (LoadFile)
+
+EFI_GUID gEfiLoadFileProtocolGuid = LOAD_FILE_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiLoadFileProtocolGuid, "LoadFile Protocol", "EFI 1.0 Load File Protocol");
diff --git a/EDK/Foundation/Efi/Protocol/LoadFile/LoadFile.h b/EDK/Foundation/Efi/Protocol/LoadFile/LoadFile.h
new file mode 100644
index 0000000..d530818
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/LoadFile/LoadFile.h
@@ -0,0 +1,87 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ LoadFile.h
+
+Abstract:
+
+ Load File protocol as defined in the EFI 1.0 specification.
+
+ Load file protocol exists to supports the addition of new boot devices,
+ and to support booting from devices that do not map well to file system.
+ Network boot is done via a LoadFile protocol.
+
+ EFI 1.0 can boot from any device that produces a LoadFile protocol.
+
+--*/
+
+#ifndef _LOAD_FILE_H_
+#define _LOAD_FILE_H_
+
+#define LOAD_FILE_PROTOCOL_GUID \
+ { \
+ 0x56EC3091, 0x954C, 0x11d2, 0x8E, 0x3F, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B \
+ }
+
+EFI_FORWARD_DECLARATION (EFI_LOAD_FILE_PROTOCOL);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_LOAD_FILE) (
+ IN EFI_LOAD_FILE_PROTOCOL * This,
+ IN EFI_DEVICE_PATH_PROTOCOL * FilePath,
+ IN BOOLEAN BootPolicy,
+ IN OUT UINTN *BufferSize,
+ IN VOID *Buffer OPTIONAL
+ )
+/*++
+
+ Routine Description:
+ Causes the driver to load a specified file.
+
+ Arguments:
+ This - Protocol instance pointer.
+ FilePath - The device specific path of the file to load.
+ BootPolicy - If TRUE, indicates that the request originates from the
+ boot manager is attempting to load FilePath as a boot
+ selection. If FALSE, then FilePath must match as exact file
+ to be loaded.
+ BufferSize - On input the size of Buffer in bytes. On output with a return
+ code of EFI_SUCCESS, the amount of data transferred to
+ Buffer. On output with a return code of EFI_BUFFER_TOO_SMALL,
+ the size of Buffer required to retrieve the requested file.
+ Buffer - The memory buffer to transfer the file to. IF Buffer is NULL,
+ then no the size of the requested file is returned in
+ BufferSize.
+
+ Returns:
+ EFI_SUCCESS - The file was loaded.
+ EFI_UNSUPPORTED - The device does not support the provided BootPolicy
+ EFI_INVALID_PARAMETER - FilePath is not a valid device path, or
+ BufferSize is NULL.
+ EFI_NO_MEDIA - No medium was present to load the file.
+ EFI_DEVICE_ERROR - The file was not loaded due to a device error.
+ EFI_NO_RESPONSE - The remote system did not respond.
+ EFI_NOT_FOUND - The file was not found
+ EFI_ABORTED - The file load process was manually cancelled.
+
+--*/
+;
+
+typedef struct _EFI_LOAD_FILE_PROTOCOL {
+ EFI_LOAD_FILE LoadFile;
+} EFI_LOAD_FILE_PROTOCOL;
+
+extern EFI_GUID gEfiLoadFileProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/LoadFile2/LoadFile2.c b/EDK/Foundation/Efi/Protocol/LoadFile2/LoadFile2.c
new file mode 100644
index 0000000..7e47b61
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/LoadFile2/LoadFile2.c
@@ -0,0 +1,30 @@
+/*++
+
+Copyright (c) 2008, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ LoadFile2.c
+
+Abstract:
+
+ Load File2 protocol as defined in the UEFI specification.
+
+ Load File2 protocol exists to support to obtain files from arbitrary devices
+ but are not used as boot options.
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (LoadFile2)
+
+EFI_GUID gEfiLoadFile2ProtocolGuid = EFI_LOAD_FILE2_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiLoad2FileProtocolGuid, "LoadFile2 Protocol", "UEFI 2.1 Load File2 Protocol");
diff --git a/EDK/Foundation/Efi/Protocol/LoadFile2/LoadFile2.h b/EDK/Foundation/Efi/Protocol/LoadFile2/LoadFile2.h
new file mode 100644
index 0000000..295cd82
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/LoadFile2/LoadFile2.h
@@ -0,0 +1,84 @@
+/*++
+
+Copyright (c) 2008, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ LoadFile2.h
+
+Abstract:
+
+ Load File2 protocol as defined in the UEFI specification.
+
+ Load File2 protocol exists to support to obtain files from arbitrary devices
+ but are not used as boot options.
+
+--*/
+
+#ifndef _LOAD_FILE2_H_
+#define _LOAD_FILE2_H_
+
+#define EFI_LOAD_FILE2_PROTOCOL_GUID \
+ { \
+ 0x4006c0c1, 0xfcb3, 0x403e, 0x99, 0x6d, 0x4a, 0x6c, 0x87, 0x24, 0xe0, 0x6d \
+ }
+
+EFI_FORWARD_DECLARATION (EFI_LOAD_FILE2_PROTOCOL);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_LOAD_FILE2_LOAD_FILE) (
+ IN EFI_LOAD_FILE2_PROTOCOL * This,
+ IN EFI_DEVICE_PATH_PROTOCOL * FilePath,
+ IN BOOLEAN BootPolicy,
+ IN OUT UINTN *BufferSize,
+ IN VOID *Buffer OPTIONAL
+ )
+/*++
+
+ Routine Description:
+ Causes the driver to load a specified file.
+
+ Arguments:
+ This - Protocol instance pointer.
+ FilePath - The device specific path of the file to load.
+ BootPolicy - Should always be FALSE.
+ BufferSize - On input the size of Buffer in bytes. On output with a return
+ code of EFI_SUCCESS, the amount of data transferred to
+ Buffer. On output with a return code of EFI_BUFFER_TOO_SMALL,
+ the size of Buffer required to retrieve the requested file.
+ Buffer - The memory buffer to transfer the file to. IF Buffer is NULL,
+ then no the size of the requested file is returned in
+ BufferSize.
+
+ Returns:
+ EFI_SUCCESS - The file was loaded.
+ EFI_UNSUPPORTED - BootPolicy is TRUE.
+ EFI_INVALID_PARAMETER - FilePath is not a valid device path, or
+ BufferSize is NULL.
+ EFI_NO_MEDIA - No medium was present to load the file.
+ EFI_DEVICE_ERROR - The file was not loaded due to a device error.
+ EFI_NO_RESPONSE - The remote system did not respond.
+ EFI_NOT_FOUND - The file was not found
+ EFI_ABORTED - The file load process was manually cancelled.
+ EFI_BUFFER_TOO_SMALL - The BufferSize is too small to read the current
+ directory entry. BufferSize has been updated with
+ the size needed to complete the request.
+
+--*/
+;
+
+typedef struct _EFI_LOAD_FILE2_PROTOCOL {
+ EFI_LOAD_FILE2_LOAD_FILE LoadFile;
+} EFI_LOAD_FILE2_PROTOCOL;
+
+extern EFI_GUID gEfiLoadFile2ProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/LoadedImage/LoadedImage.c b/EDK/Foundation/Efi/Protocol/LoadedImage/LoadedImage.c
new file mode 100644
index 0000000..7be2695
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/LoadedImage/LoadedImage.c
@@ -0,0 +1,30 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ LoadedImage.c
+
+Abstract:
+
+ EFI 1.0 Loaded Image Protocol definition.
+
+ Every EFI driver and application is passed an image handle when it is loaded.
+ This image handle will contain a Loaded Image Protocol.
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (LoadedImage)
+
+EFI_GUID gEfiLoadedImageProtocolGuid = EFI_LOADED_IMAGE_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiLoadedImageProtocolGuid, "LoadedImage Protocol", "EFI 1.0 Loaded Image Protocol");
diff --git a/EDK/Foundation/Efi/Protocol/LoadedImage/LoadedImage.h b/EDK/Foundation/Efi/Protocol/LoadedImage/LoadedImage.h
new file mode 100644
index 0000000..78579dc
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/LoadedImage/LoadedImage.h
@@ -0,0 +1,73 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ LoadedImage.h
+
+Abstract:
+
+ EFI 1.0 Loaded image protocol definition.
+
+ Every EFI driver and application is passed an image handle when it is loaded.
+ This image handle will contain a Loaded Image Protocol.
+
+--*/
+
+#ifndef _LOADED_IMAGE_H_
+#define _LOADED_IMAGE_H_
+
+#define EFI_LOADED_IMAGE_PROTOCOL_GUID \
+ { \
+ 0x5B1B31A1, 0x9562, 0x11d2, 0x8E, 0x3F, 0x00, 0xA0, 0xC9, 0x69, 0x72, 0x3B \
+ }
+
+//
+// EFI_SYSTEM_TABLE & EFI_IMAGE_UNLOAD are defined in EfiApi.h
+//
+#define EFI_LOADED_IMAGE_INFORMATION_REVISION 0x1000
+
+typedef struct {
+ UINT32 Revision;
+ EFI_HANDLE ParentHandle;
+ EFI_SYSTEM_TABLE *SystemTable;
+
+ //
+ // Source location of image
+ //
+ EFI_HANDLE DeviceHandle;
+ EFI_DEVICE_PATH_PROTOCOL *FilePath;
+ VOID *Reserved;
+
+ //
+ // Images load options
+ //
+ UINT32 LoadOptionsSize;
+ VOID *LoadOptions;
+
+ //
+ // Location of where image was loaded
+ //
+ VOID *ImageBase;
+ UINT64 ImageSize;
+ EFI_MEMORY_TYPE ImageCodeType;
+ EFI_MEMORY_TYPE ImageDataType;
+
+ //
+ // If the driver image supports a dynamic unload request
+ //
+ EFI_IMAGE_UNLOAD Unload;
+
+} EFI_LOADED_IMAGE_PROTOCOL;
+
+extern EFI_GUID gEfiLoadedImageProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/LoadedImageDevicePath/LoadedImageDevicePath.c b/EDK/Foundation/Efi/Protocol/LoadedImageDevicePath/LoadedImageDevicePath.c
new file mode 100644
index 0000000..6b0570b
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/LoadedImageDevicePath/LoadedImageDevicePath.c
@@ -0,0 +1,32 @@
+/*++
+
+Copyright (c) 2008, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ LoadedImageDevicePath.c
+
+Abstract:
+
+ The Loaded Image Device Path Protocol as defined in UEFI 2.1.
+
+ When installed, the Loaded Image Device Path Protocol specifies the device
+ path that was used when a PE/COFF image was loaded through the EFI Boot
+ Service LoadImage().
+
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (LoadedImageDevicePath)
+
+EFI_GUID gEfiLoadedImageDevicePathProtocolGuid = EFI_LOADED_IMAGE_DEVICE_PATH_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiLoadedImageDevicePathProtocolGuid, "Loaded Image Device Path Protocol", "UEFI 2.1 Loaded Image Device Path protocol");
diff --git a/EDK/Foundation/Efi/Protocol/LoadedImageDevicePath/LoadedImageDevicePath.h b/EDK/Foundation/Efi/Protocol/LoadedImageDevicePath/LoadedImageDevicePath.h
new file mode 100644
index 0000000..7a05f64
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/LoadedImageDevicePath/LoadedImageDevicePath.h
@@ -0,0 +1,44 @@
+/*++
+
+Copyright (c) 2008, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ LoadedImageDevicePath.h
+
+Abstract:
+
+ The Loaded Image Device Path Protocol as defined in UEFI 2.1.
+
+ When installed, the Loaded Image Device Path Protocol specifies the device
+ path that was used when a PE/COFF image was loaded through the EFI Boot
+ Service LoadImage().
+
+
+--*/
+
+#ifndef _LOADED_IMAGE_DEVICE_PATH_H_
+#define _LOADED_IMAGE_DEVICE_PATH_H_
+
+#include EFI_PROTOCOL_DEFINITION (DevicePath)
+
+//
+// Loaded Image Device Path protocol
+//
+#define EFI_LOADED_IMAGE_DEVICE_PATH_PROTOCOL_GUID \
+ { \
+ 0xbc62157e, 0x3e33, 0x4fec, 0x99, 0x20, 0x2d, 0x3b, 0x36, 0xd7, 0x50, 0xdf \
+ }
+
+typedef EFI_DEVICE_PATH_PROTOCOL EFI_LOADED_IMAGE_DEVICE_PATH_PROTOCOL;
+
+extern EFI_GUID gEfiLoadedImageDevicePathProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/ManagedNetwork/ManagedNetwork.c b/EDK/Foundation/Efi/Protocol/ManagedNetwork/ManagedNetwork.c
new file mode 100644
index 0000000..53c461c
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/ManagedNetwork/ManagedNetwork.c
@@ -0,0 +1,29 @@
+/*++
+
+Copyright (c) 2005 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ ManagedNetwork.c
+
+Abstract:
+
+ UEFI Managed Network protocol.
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (ManagedNetwork)
+
+EFI_GUID gEfiManagedNetworkServiceBindingProtocolGuid = EFI_MANAGED_NETWORK_SERVICE_BINDING_PROTOCOL_GUID;
+EFI_GUID gEfiManagedNetworkProtocolGuid = EFI_MANAGED_NETWORK_PROTOCOL_GUID;
+
+EFI_GUID_STRING (&gEfiManagedNetworkServiceBindingProtocolGuid, "Managed Network Service Binding Protocol", "Managed Network Service Binding Protocol");
+EFI_GUID_STRING (&gEfiManagedNetworkProtocolGuid, "Managed Network Protocol", "Managed Network Protocol");
diff --git a/EDK/Foundation/Efi/Protocol/ManagedNetwork/ManagedNetwork.h b/EDK/Foundation/Efi/Protocol/ManagedNetwork/ManagedNetwork.h
new file mode 100644
index 0000000..aa02ac9
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/ManagedNetwork/ManagedNetwork.h
@@ -0,0 +1,164 @@
+/*++
+
+Copyright (c) 2005 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ ManagedNetwork.h
+
+Abstract:
+
+ UEFI Managed Network protocol definition.
+
+--*/
+
+#ifndef _MANAGED_NETWORK_H_
+#define _MANAGED_NETWORK_H_
+
+#include EFI_PROTOCOL_DEFINITION (SimpleNetwork)
+#include EFI_PROTOCOL_DEFINITION (ServiceBinding)
+
+#define EFI_MANAGED_NETWORK_SERVICE_BINDING_PROTOCOL_GUID \
+ { 0xf36ff770, 0xa7e1, 0x42cf, 0x9e, 0xd2, 0x56, 0xf0, 0xf2, 0x71, 0xf4, 0x4c }
+
+#define EFI_MANAGED_NETWORK_PROTOCOL_GUID \
+ { 0x7ab33a91, 0xace5, 0x4326, 0xb5, 0x72, 0xe7, 0xee, 0x33, 0xd3, 0x9f, 0x16 }
+
+EFI_FORWARD_DECLARATION (EFI_MANAGED_NETWORK_PROTOCOL);
+
+typedef struct {
+ UINT32 ReceivedQueueTimeoutValue;
+ UINT32 TransmitQueueTimeoutValue;
+ UINT16 ProtocolTypeFilter;
+ BOOLEAN EnableUnicastReceive;
+ BOOLEAN EnableMulticastReceive;
+ BOOLEAN EnableBroadcastReceive;
+ BOOLEAN EnablePromiscuousReceive;
+ BOOLEAN FlushQueuesOnReset;
+ BOOLEAN EnableReceiveTimestamps;
+ BOOLEAN DisableBackgroundPolling;
+} EFI_MANAGED_NETWORK_CONFIG_DATA;
+
+typedef struct {
+ EFI_TIME Timestamp;
+ EFI_EVENT RecycleEvent;
+ UINT32 PacketLength;
+ UINT32 HeaderLength;
+ UINT32 AddressLength;
+ UINT32 DataLength;
+ BOOLEAN BroadcastFlag;
+ BOOLEAN MulticastFlag;
+ BOOLEAN PromiscuousFlag;
+ UINT16 ProtocolType;
+ VOID *DestinationAddress;
+ VOID *SourceAddress;
+ VOID *MediaHeader;
+ VOID *PacketData;
+} EFI_MANAGED_NETWORK_RECEIVE_DATA;
+
+typedef struct {
+ UINT32 FragmentLength;
+ VOID *FragmentBuffer;
+} EFI_MANAGED_NETWORK_FRAGMENT_DATA;
+
+typedef struct {
+ EFI_MAC_ADDRESS *DestinationAddress;
+ EFI_MAC_ADDRESS *SourceAddress;
+ UINT16 ProtocolType;
+ UINT32 DataLength;
+ UINT16 HeaderLength;
+ UINT16 FragmentCount;
+ EFI_MANAGED_NETWORK_FRAGMENT_DATA FragmentTable[1];
+} EFI_MANAGED_NETWORK_TRANSMIT_DATA;
+
+
+typedef struct {
+ EFI_EVENT Event;
+ EFI_STATUS Status;
+ union {
+ EFI_MANAGED_NETWORK_RECEIVE_DATA *RxData;
+ EFI_MANAGED_NETWORK_TRANSMIT_DATA *TxData;
+ } Packet;
+} EFI_MANAGED_NETWORK_COMPLETION_TOKEN;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_MANAGED_NETWORK_GET_MODE_DATA) (
+ IN EFI_MANAGED_NETWORK_PROTOCOL *This,
+ OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL,
+ OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_MANAGED_NETWORK_CONFIGURE) (
+ IN EFI_MANAGED_NETWORK_PROTOCOL *This,
+ IN EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_MANAGED_NETWORK_MCAST_IP_TO_MAC) (
+ IN EFI_MANAGED_NETWORK_PROTOCOL *This,
+ IN BOOLEAN Ipv6Flag,
+ IN EFI_IP_ADDRESS *IpAddress,
+ OUT EFI_MAC_ADDRESS *MacAddress
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_MANAGED_NETWORK_GROUPS) (
+ IN EFI_MANAGED_NETWORK_PROTOCOL *This,
+ IN BOOLEAN JoinFlag,
+ IN EFI_MAC_ADDRESS *MacAddress OPTIONAL
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_MANAGED_NETWORK_TRANSMIT) (
+ IN EFI_MANAGED_NETWORK_PROTOCOL *This,
+ IN EFI_MANAGED_NETWORK_COMPLETION_TOKEN *Token
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_MANAGED_NETWORK_RECEIVE) (
+ IN EFI_MANAGED_NETWORK_PROTOCOL *This,
+ IN EFI_MANAGED_NETWORK_COMPLETION_TOKEN *Token
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_MANAGED_NETWORK_CANCEL) (
+ IN EFI_MANAGED_NETWORK_PROTOCOL *This,
+ IN EFI_MANAGED_NETWORK_COMPLETION_TOKEN *Token OPTIONAL
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_MANAGED_NETWORK_POLL) (
+ IN EFI_MANAGED_NETWORK_PROTOCOL *This
+ );
+
+typedef struct _EFI_MANAGED_NETWORK_PROTOCOL {
+ EFI_MANAGED_NETWORK_GET_MODE_DATA GetModeData;
+ EFI_MANAGED_NETWORK_CONFIGURE Configure;
+ EFI_MANAGED_NETWORK_MCAST_IP_TO_MAC McastIpToMac;
+ EFI_MANAGED_NETWORK_GROUPS Groups;
+ EFI_MANAGED_NETWORK_TRANSMIT Transmit;
+ EFI_MANAGED_NETWORK_RECEIVE Receive;
+ EFI_MANAGED_NETWORK_CANCEL Cancel;
+ EFI_MANAGED_NETWORK_POLL Poll;
+} EFI_MANAGED_NETWORK_PROTOCOL;
+
+extern EFI_GUID gEfiManagedNetworkServiceBindingProtocolGuid;
+extern EFI_GUID gEfiManagedNetworkProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/Mtftp4/Mtftp4.c b/EDK/Foundation/Efi/Protocol/Mtftp4/Mtftp4.c
new file mode 100644
index 0000000..3c35ad4
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/Mtftp4/Mtftp4.c
@@ -0,0 +1,39 @@
+/*++
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Mtftp4.c
+
+Abstract:
+
+ UEFI Multicast Trivial File Transfer Protocol GUID Declaration.
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (Mtftp4)
+
+EFI_GUID gEfiMtftp4ServiceBindingProtocolGuid = EFI_MTFTP4_SERVICE_BINDING_PROTOCOL_GUID;
+EFI_GUID gEfiMtftp4ProtocolGuid = EFI_MTFTP4_PROTOCOL_GUID;
+
+EFI_GUID_STRING (
+ &gEfiMtftp4ServiceBindingProtocolGuid,
+ "MTFTP4 Service Binding Protocol",
+ "MTFTP4 Service Binding Protocol"
+ );
+
+EFI_GUID_STRING (
+ &gEfiMtftp4ProtocolGuid,
+ "MTFTP4 Protocol",
+ "MTFTP4 Protocol"
+ );
+
diff --git a/EDK/Foundation/Efi/Protocol/Mtftp4/Mtftp4.h b/EDK/Foundation/Efi/Protocol/Mtftp4/Mtftp4.h
new file mode 100644
index 0000000..f18dd0b
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/Mtftp4/Mtftp4.h
@@ -0,0 +1,308 @@
+/*++
+
+Copyright (c) 2006 - 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Mtftp4.h
+
+Abstract:
+
+ UEFI Multicast Trivial File Tranfer Protocol Definition
+
+--*/
+
+#ifndef __EFI_MTFTP4_H__
+#define __EFI_MTFTP4_H__
+
+#include EFI_PROTOCOL_DEFINITION(ServiceBinding)
+
+#define EFI_MTFTP4_SERVICE_BINDING_PROTOCOL_GUID \
+ { 0x2FE800BE, 0x8F01, 0x4aa6, 0x94, 0x6B, 0xD7, 0x13, 0x88, 0xE1, 0x83, 0x3F }
+
+#define EFI_MTFTP4_PROTOCOL_GUID \
+ { 0x78247c57, 0x63db, 0x4708, 0x99, 0xc2, 0xa8, 0xb4, 0xa9, 0xa6, 0x1f, 0x6b }
+
+EFI_FORWARD_DECLARATION (EFI_MTFTP4_PROTOCOL);
+EFI_FORWARD_DECLARATION (EFI_MTFTP4_TOKEN);
+
+extern EFI_GUID gEfiMtftp4ServiceBindingProtocolGuid;
+extern EFI_GUID gEfiMtftp4ProtocolGuid;
+
+
+//
+//MTFTP4 packet opcode definition
+//
+#define EFI_MTFTP4_OPCODE_RRQ 1
+#define EFI_MTFTP4_OPCODE_WRQ 2
+#define EFI_MTFTP4_OPCODE_DATA 3
+#define EFI_MTFTP4_OPCODE_ACK 4
+#define EFI_MTFTP4_OPCODE_ERROR 5
+#define EFI_MTFTP4_OPCODE_OACK 6
+#define EFI_MTFTP4_OPCODE_DIR 7
+#define EFI_MTFTP4_OPCODE_DATA8 8
+#define EFI_MTFTP4_OPCODE_ACK8 9
+
+//
+//MTFTP4 error code definition
+//
+#define EFI_MTFTP4_ERRORCODE_NOT_DEFINED 0
+#define EFI_MTFTP4_ERRORCODE_FILE_NOT_FOUND 1
+#define EFI_MTFTP4_ERRORCODE_ACCESS_VIOLATION 2
+#define EFI_MTFTP4_ERRORCODE_DISK_FULL 3
+#define EFI_MTFTP4_ERRORCODE_ILLEGAL_OPERATION 4
+#define EFI_MTFTP4_ERRORCODE_UNKNOWN_TRANSFER_ID 5
+#define EFI_MTFTP4_ERRORCODE_FILE_ALREADY_EXISTS 6
+#define EFI_MTFTP4_ERRORCODE_NO_SUCH_USER 7
+#define EFI_MTFTP4_ERRORCODE_REQUEST_DENIED 8
+
+
+//
+//MTFTP4 pacekt definition
+//
+#pragma pack(1)
+
+typedef struct {
+ UINT16 OpCode;
+ UINT8 Filename[1];
+} EFI_MTFTP4_REQ_HEADER;
+
+typedef struct {
+ UINT16 OpCode;
+ UINT8 Data[1];
+} EFI_MTFTP4_OACK_HEADER;
+
+typedef struct {
+ UINT16 OpCode;
+ UINT16 Block;
+ UINT8 Data[1];
+} EFI_MTFTP4_DATA_HEADER;
+
+typedef struct {
+ UINT16 OpCode;
+ UINT16 Block[1];
+} EFI_MTFTP4_ACK_HEADER;
+
+typedef struct {
+ UINT16 OpCode;
+ UINT64 Block;
+ UINT8 Data[1];
+} EFI_MTFTP4_DATA8_HEADER;
+
+typedef struct {
+ UINT16 OpCode;
+ UINT64 Block[1];
+} EFI_MTFTP4_ACK8_HEADER;
+
+typedef struct {
+ UINT16 OpCode;
+ UINT16 ErrorCode;
+ UINT8 ErrorMessage[1];
+} EFI_MTFTP4_ERROR_HEADER;
+
+typedef union {
+ UINT16 OpCode;
+ EFI_MTFTP4_REQ_HEADER Rrq;
+ EFI_MTFTP4_REQ_HEADER Wrq;
+ EFI_MTFTP4_OACK_HEADER Oack;
+ EFI_MTFTP4_DATA_HEADER Data;
+ EFI_MTFTP4_ACK_HEADER Ack;
+ EFI_MTFTP4_DATA8_HEADER Data8;
+ EFI_MTFTP4_ACK8_HEADER Ack8;
+ EFI_MTFTP4_ERROR_HEADER Error;
+} EFI_MTFTP4_PACKET;
+
+#pragma pack()
+
+//
+//MTFTP4 option definition
+//
+typedef struct {
+ UINT8 *OptionStr;
+ UINT8 *ValueStr;
+} EFI_MTFTP4_OPTION;
+
+//
+//MTFTP4 config data
+//
+typedef struct {
+ BOOLEAN UseDefaultSetting;
+ EFI_IPv4_ADDRESS StationIp;
+ EFI_IPv4_ADDRESS SubnetMask;
+ UINT16 LocalPort;
+ EFI_IPv4_ADDRESS GatewayIp;
+ EFI_IPv4_ADDRESS ServerIp;
+ UINT16 InitialServerPort;
+ UINT16 TryCount;
+ UINT16 TimeoutValue;
+} EFI_MTFTP4_CONFIG_DATA;
+
+//
+//MTFTP4 Mode data
+//
+typedef struct {
+ EFI_MTFTP4_CONFIG_DATA ConfigData;
+ UINT8 SupportedOptionCount;
+ UINT8 **SupportedOptoins;
+ UINT8 UnsupportedOptionCount;
+ UINT8 **UnsupportedOptoins;
+} EFI_MTFTP4_MODE_DATA;
+
+
+//
+//MTFTP4 override data
+//
+typedef struct {
+ EFI_IPv4_ADDRESS GatewayIp;
+ EFI_IPv4_ADDRESS ServerIp;
+ UINT16 ServerPort;
+ UINT16 TryCount;
+ UINT16 TimeoutValue;
+} EFI_MTFTP4_OVERRIDE_DATA;
+
+
+//
+//Packet checking function
+//
+typedef
+EFI_STATUS
+(EFIAPI *EFI_MTFTP4_CHECK_PACKET)(
+ IN EFI_MTFTP4_PROTOCOL *This,
+ IN EFI_MTFTP4_TOKEN *Token,
+ IN UINT16 PacketLen,
+ IN EFI_MTFTP4_PACKET *Paket
+ );
+
+//
+//Timeout callback funtion
+//
+typedef
+EFI_STATUS
+(EFIAPI *EFI_MTFTP4_TIMEOUT_CALLBACK) (
+ IN EFI_MTFTP4_PROTOCOL *This,
+ IN EFI_MTFTP4_TOKEN *Token
+ );
+
+//
+//Packet needed function
+//
+typedef
+EFI_STATUS
+(EFIAPI *EFI_MTFTP4_PACKET_NEEDED) (
+ IN EFI_MTFTP4_PROTOCOL *This,
+ IN EFI_MTFTP4_TOKEN *Token,
+ IN OUT UINT16 *Length,
+ OUT VOID **Buffer
+ );
+
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_MTFTP4_GET_MODE_DATA) (
+ IN EFI_MTFTP4_PROTOCOL *This,
+ OUT EFI_MTFTP4_MODE_DATA *ModeData
+ );
+
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_MTFTP4_CONFIGURE) (
+ IN EFI_MTFTP4_PROTOCOL *This,
+ IN EFI_MTFTP4_CONFIG_DATA *MtftpConfigData OPTIONAL
+ );
+
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_MTFTP4_GET_INFO) (
+ IN EFI_MTFTP4_PROTOCOL *This,
+ IN EFI_MTFTP4_OVERRIDE_DATA *OverrideData OPTIONAL,
+ IN UINT8 *Filename,
+ IN UINT8 *ModeStr OPTIONAL,
+ IN UINT8 OptionCount,
+ IN EFI_MTFTP4_OPTION *OptionList,
+ OUT UINT32 *PacketLength,
+ OUT EFI_MTFTP4_PACKET **Packet OPTIONAL
+ );
+
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_MTFTP4_PARSE_OPTIONS) (
+ IN EFI_MTFTP4_PROTOCOL *This,
+ IN UINT32 PacketLen,
+ IN EFI_MTFTP4_PACKET *Packet,
+ OUT UINT32 *OptionCount,
+ OUT EFI_MTFTP4_OPTION **OptionList OPTIONAL
+ );
+
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_MTFTP4_READ_FILE) (
+ IN EFI_MTFTP4_PROTOCOL *This,
+ IN EFI_MTFTP4_TOKEN *Token
+ );
+
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_MTFTP4_WRITE_FILE) (
+ IN EFI_MTFTP4_PROTOCOL *This,
+ IN EFI_MTFTP4_TOKEN *Token
+ );
+
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_MTFTP4_READ_DIRECTORY) (
+ IN EFI_MTFTP4_PROTOCOL *This,
+ IN EFI_MTFTP4_TOKEN *Token
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_MTFTP4_POLL) (
+ IN EFI_MTFTP4_PROTOCOL *This
+);
+
+
+typedef struct _EFI_MTFTP4_PROTOCOL {
+ EFI_MTFTP4_GET_MODE_DATA GetModeData;
+ EFI_MTFTP4_CONFIGURE Configure;
+ EFI_MTFTP4_GET_INFO GetInfo;
+ EFI_MTFTP4_PARSE_OPTIONS ParseOptions;
+ EFI_MTFTP4_READ_FILE ReadFile;
+ EFI_MTFTP4_WRITE_FILE WriteFile;
+ EFI_MTFTP4_READ_DIRECTORY ReadDirectory;
+ EFI_MTFTP4_POLL Poll;
+} EFI_MTFTP4_PROTOCOL;
+
+//
+//MTFTP4 token data
+//
+typedef struct _EFI_MTFTP4_TOKEN{
+ IN OUT EFI_STATUS Status;
+ IN EFI_EVENT Event;
+ IN EFI_MTFTP4_OVERRIDE_DATA *OverrideData;
+ IN UINT8 *Filename;
+ IN UINT8 *ModeStr;
+ IN UINT32 OptionCount;
+ IN EFI_MTFTP4_OPTION *OptionList;
+ IN OUT UINT64 BufferSize;
+ IN OUT VOID *Buffer;
+ IN VOID *Context;
+ IN EFI_MTFTP4_CHECK_PACKET CheckPacket;
+ IN EFI_MTFTP4_TIMEOUT_CALLBACK TimeoutCallback;
+ IN EFI_MTFTP4_PACKET_NEEDED PacketNeeded;
+} EFI_MTFTP4_TOKEN;
+
+#endif
+
diff --git a/EDK/Foundation/Efi/Protocol/PciIo/PciIo.c b/EDK/Foundation/Efi/Protocol/PciIo/PciIo.c
new file mode 100644
index 0000000..d6d30cc
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/PciIo/PciIo.c
@@ -0,0 +1,30 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PciIo.c
+
+Abstract:
+
+ EFI PCI I/O Protocol
+
+Revision History
+
+--*/
+
+#include "EfiSpec.h"
+
+#include EFI_PROTOCOL_DEFINITION (PciIo)
+
+EFI_GUID gEfiPciIoProtocolGuid = EFI_PCI_IO_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiPciIoProtocolGuid, "PCI IO Protocol", "EFI 1.1 PCI IO Protocol");
diff --git a/EDK/Foundation/Efi/Protocol/PciIo/PciIo.h b/EDK/Foundation/Efi/Protocol/PciIo/PciIo.h
new file mode 100644
index 0000000..c43f013
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/PciIo/PciIo.h
@@ -0,0 +1,275 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PciIo.h
+
+Abstract:
+
+ EFI PCI I/O Protocol
+
+Revision History
+
+--*/
+
+#ifndef _EFI_PCI_IO_H
+#define _EFI_PCI_IO_H
+
+//
+// Global ID for the PCI I/O Protocol
+//
+#define EFI_PCI_IO_PROTOCOL_GUID \
+ { \
+ 0x4cf5b200, 0x68b8, 0x4ca5, 0x9e, 0xec, 0xb2, 0x3e, 0x3f, 0x50, 0x2, 0x9a \
+ }
+
+EFI_FORWARD_DECLARATION (EFI_PCI_IO_PROTOCOL);
+
+//
+// Prototypes for the PCI I/O Protocol
+//
+typedef enum {
+ EfiPciIoWidthUint8 = 0,
+ EfiPciIoWidthUint16,
+ EfiPciIoWidthUint32,
+ EfiPciIoWidthUint64,
+ EfiPciIoWidthFifoUint8,
+ EfiPciIoWidthFifoUint16,
+ EfiPciIoWidthFifoUint32,
+ EfiPciIoWidthFifoUint64,
+ EfiPciIoWidthFillUint8,
+ EfiPciIoWidthFillUint16,
+ EfiPciIoWidthFillUint32,
+ EfiPciIoWidthFillUint64,
+ EfiPciIoWidthMaximum
+} EFI_PCI_IO_PROTOCOL_WIDTH;
+
+//
+// Complete PCI address generater
+//
+#define EFI_PCI_IO_PASS_THROUGH_BAR 0xff // Special BAR that passes a memory or I/O cycle through unchanged
+#define EFI_PCI_IO_ATTRIBUTE_MASK 0x077f // All the following I/O and Memory cycles
+#define EFI_PCI_IO_ATTRIBUTE_ISA_MOTHERBOARD_IO 0x0001 // I/O cycles 0x0000-0x00FF (10 bit decode)
+#define EFI_PCI_IO_ATTRIBUTE_ISA_IO 0x0002 // I/O cycles 0x0000-0x03FF (10 bit decode)
+#define EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO 0x0004 // I/O cycles 0x3C6, 0x3C8, 0x3C9 (10 bit decode)
+#define EFI_PCI_IO_ATTRIBUTE_VGA_MEMORY 0x0008 // MEM cycles 0xA0000-0xBFFFF (24 bit decode)
+#define EFI_PCI_IO_ATTRIBUTE_VGA_IO 0x0010 // I/O cycles 0x3B0-0x3BB and 0x3C0-0x3DF (10 bit decode)
+#define EFI_PCI_IO_ATTRIBUTE_IDE_PRIMARY_IO 0x0020 // I/O cycles 0x1F0-0x1F7, 0x3F6, 0x3F7 (10 bit decode)
+#define EFI_PCI_IO_ATTRIBUTE_IDE_SECONDARY_IO 0x0040 // I/O cycles 0x170-0x177, 0x376, 0x377 (10 bit decode)
+#define EFI_PCI_IO_ATTRIBUTE_MEMORY_WRITE_COMBINE 0x0080 // Map a memory range so write are combined
+#define EFI_PCI_IO_ATTRIBUTE_IO 0x0100 // Enable the I/O decode bit in the PCI Config Header
+#define EFI_PCI_IO_ATTRIBUTE_MEMORY 0x0200 // Enable the Memory decode bit in the PCI Config Header
+#define EFI_PCI_IO_ATTRIBUTE_BUS_MASTER 0x0400 // Enable the DMA bit in the PCI Config Header
+#define EFI_PCI_IO_ATTRIBUTE_MEMORY_CACHED 0x0800 // Map a memory range so all r/w accesses are cached
+#define EFI_PCI_IO_ATTRIBUTE_MEMORY_DISABLE 0x1000 // Disable a memory range
+#define EFI_PCI_IO_ATTRIBUTE_EMBEDDED_DEVICE 0x2000 // Clear for an add-in PCI Device
+#define EFI_PCI_IO_ATTRIBUTE_EMBEDDED_ROM 0x4000 // Clear for a physical PCI Option ROM accessed through ROM BAR
+#define EFI_PCI_IO_ATTRIBUTE_DUAL_ADDRESS_CYCLE 0x8000 // Clear for PCI controllers that can not genrate a DAC
+//
+// The following definition is added in EFI1.1 spec update and UEFI2.0 spec.
+//
+#define EFI_PCI_IO_ATTRIBUTE_ISA_IO_16 0x10000 // I/O cycles 0x0100-0x03FF (16 bit decode)
+#define EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO_16 0x20000 // I/O cycles 0x3C6, 0x3C8, 0x3C9 (16 bit decode)
+#define EFI_PCI_IO_ATTRIBUTE_VGA_IO_16 0x40000 // I/O cycles 0x3B0-0x3BB and 0x3C0-0x3DF (16 bit decode)
+
+#define EFI_PCI_DEVICE_ENABLE (EFI_PCI_IO_ATTRIBUTE_IO | EFI_PCI_IO_ATTRIBUTE_MEMORY | EFI_PCI_IO_ATTRIBUTE_BUS_MASTER)
+#define EFI_VGA_DEVICE_ENABLE (EFI_PCI_IO_ATTRIBUTE_VGA_PALETTE_IO | EFI_PCI_IO_ATTRIBUTE_VGA_MEMORY | EFI_PCI_IO_ATTRIBUTE_VGA_IO | EFI_PCI_IO_ATTRIBUTE_IO)
+
+//
+// *******************************************************
+// EFI_PCI_IO_PROTOCOL_OPERATION
+// *******************************************************
+//
+typedef enum {
+ EfiPciIoOperationBusMasterRead,
+ EfiPciIoOperationBusMasterWrite,
+ EfiPciIoOperationBusMasterCommonBuffer,
+ EfiPciIoOperationMaximum
+} EFI_PCI_IO_PROTOCOL_OPERATION;
+
+//
+// *******************************************************
+// EFI_PCI_IO_PROTOCOL_ATTRIBUTE_OPERATION
+// *******************************************************
+//
+typedef enum {
+ EfiPciIoAttributeOperationGet,
+ EfiPciIoAttributeOperationSet,
+ EfiPciIoAttributeOperationEnable,
+ EfiPciIoAttributeOperationDisable,
+ EfiPciIoAttributeOperationSupported,
+ EfiPciIoAttributeOperationMaximum
+} EFI_PCI_IO_PROTOCOL_ATTRIBUTE_OPERATION;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PCI_IO_PROTOCOL_POLL_IO_MEM) (
+ IN EFI_PCI_IO_PROTOCOL * This,
+ IN EFI_PCI_IO_PROTOCOL_WIDTH Width,
+ IN UINT8 BarIndex,
+ IN UINT64 Offset,
+ IN UINT64 Mask,
+ IN UINT64 Value,
+ IN UINT64 Delay,
+ OUT UINT64 *Result
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PCI_IO_PROTOCOL_IO_MEM) (
+ IN EFI_PCI_IO_PROTOCOL * This,
+ IN EFI_PCI_IO_PROTOCOL_WIDTH Width,
+ IN UINT8 BarIndex,
+ IN UINT64 Offset,
+ IN UINTN Count,
+ IN OUT VOID *Buffer
+ );
+
+typedef struct {
+ EFI_PCI_IO_PROTOCOL_IO_MEM Read;
+ EFI_PCI_IO_PROTOCOL_IO_MEM Write;
+} EFI_PCI_IO_PROTOCOL_ACCESS;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PCI_IO_PROTOCOL_CONFIG) (
+ IN EFI_PCI_IO_PROTOCOL * This,
+ IN EFI_PCI_IO_PROTOCOL_WIDTH Width,
+ IN UINT32 Offset,
+ IN UINTN Count,
+ IN OUT VOID *Buffer
+ );
+
+typedef struct {
+ EFI_PCI_IO_PROTOCOL_CONFIG Read;
+ EFI_PCI_IO_PROTOCOL_CONFIG Write;
+} EFI_PCI_IO_PROTOCOL_CONFIG_ACCESS;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PCI_IO_PROTOCOL_COPY_MEM) (
+ IN EFI_PCI_IO_PROTOCOL * This,
+ IN EFI_PCI_IO_PROTOCOL_WIDTH Width,
+ IN UINT8 DestBarIndex,
+ IN UINT64 DestOffset,
+ IN UINT8 SrcBarIndex,
+ IN UINT64 SrcOffset,
+ IN UINTN Count
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PCI_IO_PROTOCOL_MAP) (
+ IN EFI_PCI_IO_PROTOCOL * This,
+ IN EFI_PCI_IO_PROTOCOL_OPERATION Operation,
+ IN VOID *HostAddress,
+ IN OUT UINTN *NumberOfBytes,
+ OUT EFI_PHYSICAL_ADDRESS * DeviceAddress,
+ OUT VOID **Mapping
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PCI_IO_PROTOCOL_UNMAP) (
+ IN EFI_PCI_IO_PROTOCOL * This,
+ IN VOID *Mapping
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PCI_IO_PROTOCOL_ALLOCATE_BUFFER) (
+ IN EFI_PCI_IO_PROTOCOL * This,
+ IN EFI_ALLOCATE_TYPE Type,
+ IN EFI_MEMORY_TYPE MemoryType,
+ IN UINTN Pages,
+ OUT VOID **HostAddress,
+ IN UINT64 Attributes
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PCI_IO_PROTOCOL_FREE_BUFFER) (
+ IN EFI_PCI_IO_PROTOCOL * This,
+ IN UINTN Pages,
+ IN VOID *HostAddress
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PCI_IO_PROTOCOL_FLUSH) (
+ IN EFI_PCI_IO_PROTOCOL * This
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PCI_IO_PROTOCOL_GET_LOCATION) (
+ IN EFI_PCI_IO_PROTOCOL * This,
+ OUT UINTN *SegmentNumber,
+ OUT UINTN *BusNumber,
+ OUT UINTN *DeviceNumber,
+ OUT UINTN *FunctionNumber
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PCI_IO_PROTOCOL_ATTRIBUTES) (
+ IN EFI_PCI_IO_PROTOCOL * This,
+ IN EFI_PCI_IO_PROTOCOL_ATTRIBUTE_OPERATION Operation,
+ IN UINT64 Attributes,
+ OUT UINT64 *Result OPTIONAL
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PCI_IO_PROTOCOL_GET_BAR_ATTRIBUTES) (
+ IN EFI_PCI_IO_PROTOCOL * This,
+ IN UINT8 BarIndex,
+ OUT UINT64 *Supports, OPTIONAL
+ OUT VOID **Resources OPTIONAL
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PCI_IO_PROTOCOL_SET_BAR_ATTRIBUTES) (
+ IN EFI_PCI_IO_PROTOCOL * This,
+ IN UINT64 Attributes,
+ IN UINT8 BarIndex,
+ IN OUT UINT64 *Offset,
+ IN OUT UINT64 *Length
+ );
+
+//
+// Interface structure for the PCI I/O Protocol
+//
+typedef struct _EFI_PCI_IO_PROTOCOL {
+ EFI_PCI_IO_PROTOCOL_POLL_IO_MEM PollMem;
+ EFI_PCI_IO_PROTOCOL_POLL_IO_MEM PollIo;
+ EFI_PCI_IO_PROTOCOL_ACCESS Mem;
+ EFI_PCI_IO_PROTOCOL_ACCESS Io;
+ EFI_PCI_IO_PROTOCOL_CONFIG_ACCESS Pci;
+ EFI_PCI_IO_PROTOCOL_COPY_MEM CopyMem;
+ EFI_PCI_IO_PROTOCOL_MAP Map;
+ EFI_PCI_IO_PROTOCOL_UNMAP Unmap;
+ EFI_PCI_IO_PROTOCOL_ALLOCATE_BUFFER AllocateBuffer;
+ EFI_PCI_IO_PROTOCOL_FREE_BUFFER FreeBuffer;
+ EFI_PCI_IO_PROTOCOL_FLUSH Flush;
+ EFI_PCI_IO_PROTOCOL_GET_LOCATION GetLocation;
+ EFI_PCI_IO_PROTOCOL_ATTRIBUTES Attributes;
+ EFI_PCI_IO_PROTOCOL_GET_BAR_ATTRIBUTES GetBarAttributes;
+ EFI_PCI_IO_PROTOCOL_SET_BAR_ATTRIBUTES SetBarAttributes;
+ UINT64 RomSize;
+ VOID *RomImage;
+} EFI_PCI_IO_PROTOCOL;
+
+extern EFI_GUID gEfiPciIoProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/PciRootBridgeIo/PciRootBridgeIo.c b/EDK/Foundation/Efi/Protocol/PciRootBridgeIo/PciRootBridgeIo.c
new file mode 100644
index 0000000..3d8e67a
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/PciRootBridgeIo/PciRootBridgeIo.c
@@ -0,0 +1,32 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PciRootBridgeIo.c
+
+Abstract:
+
+ PCI Root Bridge I/O protocol as defined in the EFI 1.1 specification.
+
+ PCI Root Bridge I/O protocol is used by PCI Bus Driver to perform PCI Memory, PCI I/O,
+ and PCI Configuration cycles on a PCI Root Bridge. It also provides services to perform
+ defferent types of bus mastering DMA
+
+--*/
+
+#include "EfiSpec.h"
+
+#include EFI_PROTOCOL_DEFINITION (PciRootBridgeIo)
+
+EFI_GUID gEfiPciRootBridgeIoProtocolGuid = EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiPciRootBridgeIoProtocolGuid, "PciRootBridgeIo Protocol", "EFI 1.1 Pci Root Bridge IO Protocol");
diff --git a/EDK/Foundation/Efi/Protocol/PciRootBridgeIo/PciRootBridgeIo.h b/EDK/Foundation/Efi/Protocol/PciRootBridgeIo/PciRootBridgeIo.h
new file mode 100644
index 0000000..154eb94
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/PciRootBridgeIo/PciRootBridgeIo.h
@@ -0,0 +1,220 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PciRootBridgeIo.h
+
+Abstract:
+
+ PCI Root Bridge I/O protocol as defined in the EFI 1.1 specification.
+
+ PCI Root Bridge I/O protocol is used by PCI Bus Driver to perform PCI Memory, PCI I/O,
+ and PCI Configuration cycles on a PCI Root Bridge. It also provides services to perform
+ defferent types of bus mastering DMA
+
+--*/
+
+#ifndef _PCI_ROOT_BRIDGE_IO_H_
+#define _PCI_ROOT_BRIDGE_IO_H_
+
+#define EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_GUID \
+ { \
+ 0x2f707ebb, 0x4a1a, 0x11d4, 0x9a, 0x38, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d \
+ }
+
+EFI_FORWARD_DECLARATION (EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL);
+
+typedef enum {
+ EfiPciWidthUint8,
+ EfiPciWidthUint16,
+ EfiPciWidthUint32,
+ EfiPciWidthUint64,
+ EfiPciWidthFifoUint8,
+ EfiPciWidthFifoUint16,
+ EfiPciWidthFifoUint32,
+ EfiPciWidthFifoUint64,
+ EfiPciWidthFillUint8,
+ EfiPciWidthFillUint16,
+ EfiPciWidthFillUint32,
+ EfiPciWidthFillUint64,
+ EfiPciWidthMaximum
+} EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH;
+
+typedef enum {
+ EfiPciOperationBusMasterRead,
+ EfiPciOperationBusMasterWrite,
+ EfiPciOperationBusMasterCommonBuffer,
+ EfiPciOperationBusMasterRead64,
+ EfiPciOperationBusMasterWrite64,
+ EfiPciOperationBusMasterCommonBuffer64,
+ EfiPciOperationMaximum
+} EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_OPERATION;
+
+#define EFI_PCI_ATTRIBUTE_ISA_MOTHERBOARD_IO 0x0001
+#define EFI_PCI_ATTRIBUTE_ISA_IO 0x0002
+#define EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO 0x0004
+#define EFI_PCI_ATTRIBUTE_VGA_MEMORY 0x0008
+#define EFI_PCI_ATTRIBUTE_VGA_IO 0x0010
+#define EFI_PCI_ATTRIBUTE_IDE_PRIMARY_IO 0x0020
+#define EFI_PCI_ATTRIBUTE_IDE_SECONDARY_IO 0x0040
+#define EFI_PCI_ATTRIBUTE_MEMORY_WRITE_COMBINE 0x0080
+#define EFI_PCI_ATTRIBUTE_MEMORY_CACHED 0x0800
+#define EFI_PCI_ATTRIBUTE_MEMORY_DISABLE 0x1000
+#define EFI_PCI_ATTRIBUTE_DUAL_ADDRESS_CYCLE 0x8000
+//
+// The following definition is added in EFI1.1 spec update and UEFI2.0 spec.
+//
+#define EFI_PCI_ATTRIBUTE_ISA_IO_16 0x10000
+#define EFI_PCI_ATTRIBUTE_VGA_PALETTE_IO_16 0x20000
+#define EFI_PCI_ATTRIBUTE_VGA_IO_16 0x40000
+
+#define EFI_PCI_ATTRIBUTE_VALID_FOR_ALLOCATE_BUFFER (EFI_PCI_ATTRIBUTE_MEMORY_WRITE_COMBINE | EFI_PCI_ATTRIBUTE_MEMORY_CACHED | EFI_PCI_ATTRIBUTE_DUAL_ADDRESS_CYCLE)
+
+#define EFI_PCI_ATTRIBUTE_INVALID_FOR_ALLOCATE_BUFFER (~EFI_PCI_ATTRIBUTE_VALID_FOR_ALLOCATE_BUFFER)
+
+#define EFI_PCI_ADDRESS(bus, dev, func, reg) \
+ ((UINT64) ((((UINTN) bus) << 24) + (((UINTN) dev) << 16) + (((UINTN) func) << 8) + ((UINTN) reg)))
+
+typedef struct {
+ UINT8 Register;
+ UINT8 Function;
+ UINT8 Device;
+ UINT8 Bus;
+ UINT32 ExtendedRegister;
+} EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_PCI_ADDRESS;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_POLL_IO_MEM) (
+ IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL * This,
+ IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,
+ IN UINT64 Address,
+ IN UINT64 Mask,
+ IN UINT64 Value,
+ IN UINT64 Delay,
+ OUT UINT64 *Result
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_IO_MEM) (
+ IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL * This,
+ IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,
+ IN UINT64 Address,
+ IN UINTN Count,
+ IN OUT VOID *Buffer
+ );
+
+typedef struct {
+ EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_IO_MEM Read;
+ EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_IO_MEM Write;
+} EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ACCESS;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_COPY_MEM) (
+ IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL * This,
+ IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH Width,
+ IN UINT64 DestAddress,
+ IN UINT64 SrcAddress,
+ IN UINTN Count
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_MAP) (
+ IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL * This,
+ IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_OPERATION Operation,
+ IN VOID *HostAddress,
+ IN OUT UINTN *NumberOfBytes,
+ OUT EFI_PHYSICAL_ADDRESS * DeviceAddress,
+ OUT VOID **Mapping
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_UNMAP) (
+ IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL * This,
+ IN VOID *Mapping
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ALLOCATE_BUFFER) (
+ IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL * This,
+ IN EFI_ALLOCATE_TYPE Type,
+ IN EFI_MEMORY_TYPE MemoryType,
+ IN UINTN Pages,
+ IN OUT VOID **HostAddress,
+ IN UINT64 Attributes
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_FREE_BUFFER) (
+ IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL * This,
+ IN UINTN Pages,
+ IN VOID *HostAddress
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_FLUSH) (
+ IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL * This
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_GET_ATTRIBUTES) (
+ IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL * This,
+ OUT UINT64 *Supports,
+ OUT UINT64 *Attributes
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_SET_ATTRIBUTES) (
+ IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL * This,
+ IN UINT64 Attributes,
+ IN OUT UINT64 *ResourceBase,
+ IN OUT UINT64 *ResourceLength
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_CONFIGURATION) (
+ IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL * This,
+ OUT VOID **Resources
+ );
+
+typedef struct _EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL {
+ EFI_HANDLE ParentHandle;
+ EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_POLL_IO_MEM PollMem;
+ EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_POLL_IO_MEM PollIo;
+ EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ACCESS Mem;
+ EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ACCESS Io;
+ EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ACCESS Pci;
+ EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_COPY_MEM CopyMem;
+ EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_MAP Map;
+ EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_UNMAP Unmap;
+ EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_ALLOCATE_BUFFER AllocateBuffer;
+ EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_FREE_BUFFER FreeBuffer;
+ EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_FLUSH Flush;
+ EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_GET_ATTRIBUTES GetAttributes;
+ EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_SET_ATTRIBUTES SetAttributes;
+ EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_CONFIGURATION Configuration;
+ UINT32 SegmentNumber;
+} EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL;
+
+extern EFI_GUID gEfiPciRootBridgeIoProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/PlatformDriverOverride/PlatformDriverOverride.c b/EDK/Foundation/Efi/Protocol/PlatformDriverOverride/PlatformDriverOverride.c
new file mode 100644
index 0000000..1f03c6d
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/PlatformDriverOverride/PlatformDriverOverride.c
@@ -0,0 +1,31 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PlatformDriverOverride.c
+
+Abstract:
+
+ Platform Driver Override protocol as defined in the EFI 1.1 specification.
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (PlatformDriverOverride)
+
+EFI_GUID gEfiPlatformDriverOverrideProtocolGuid = EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL_GUID;
+
+EFI_GUID_STRING
+ (
+ &gEfiPlatformDriverOverrideProtocolGuid, "Platform Driver Override Protocol",
+ "EFI 1.1 Platform Driver Override Protocol"
+ );
diff --git a/EDK/Foundation/Efi/Protocol/PlatformDriverOverride/PlatformDriverOverride.h b/EDK/Foundation/Efi/Protocol/PlatformDriverOverride/PlatformDriverOverride.h
new file mode 100644
index 0000000..5b285da
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/PlatformDriverOverride/PlatformDriverOverride.h
@@ -0,0 +1,74 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PlatformDriverOverride.h
+
+Abstract:
+
+ Platform Driver Override protocol as defined in the EFI 1.1 specification.
+
+--*/
+
+#ifndef _EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL_H_
+#define _EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL_H_
+
+//
+// Global ID for the Platform Driver Override Protocol
+//
+#define EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL_GUID \
+ { \
+ 0x6b30c738, 0xa391, 0x11d4, 0x9a, 0x3b, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d \
+ }
+
+EFI_FORWARD_DECLARATION (EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL);
+
+//
+// Prototypes for the Platform Driver Override Protocol
+//
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PLATFORM_DRIVER_OVERRIDE_GET_DRIVER) (
+ IN EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL * This,
+ IN EFI_HANDLE ControllerHandle,
+ IN OUT EFI_HANDLE * DriverImageHandle
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PLATFORM_DRIVER_OVERRIDE_GET_DRIVER_PATH) (
+ IN EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL * This,
+ IN EFI_HANDLE ControllerHandle,
+ IN OUT EFI_DEVICE_PATH_PROTOCOL **DriverImagePath
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PLATFORM_DRIVER_OVERRIDE_DRIVER_LOADED) (
+ IN EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL * This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL * DriverImagePath,
+ IN EFI_HANDLE DriverImageHandle
+ );
+
+//
+// Interface structure for the Platform Driver Override Protocol
+//
+typedef struct _EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL {
+ EFI_PLATFORM_DRIVER_OVERRIDE_GET_DRIVER GetDriver;
+ EFI_PLATFORM_DRIVER_OVERRIDE_GET_DRIVER_PATH GetDriverPath;
+ EFI_PLATFORM_DRIVER_OVERRIDE_DRIVER_LOADED DriverLoaded;
+} EFI_PLATFORM_DRIVER_OVERRIDE_PROTOCOL;
+
+extern EFI_GUID gEfiPlatformDriverOverrideProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/PlatformToDriverConfiguration/PlatformToDriverConfiguration.c b/EDK/Foundation/Efi/Protocol/PlatformToDriverConfiguration/PlatformToDriverConfiguration.c
new file mode 100644
index 0000000..36d9e3d
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/PlatformToDriverConfiguration/PlatformToDriverConfiguration.c
@@ -0,0 +1,31 @@
+/*++
+
+Copyright (c) 2008, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PlatformToDriverConfiguration.c
+
+Abstract:
+
+ UEFI Platform to Driver Configuration Protocol
+
+Revision History:
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (PlatformToDriverConfiguration)
+
+EFI_GUID gEfiPlatformToDriverConfigurationProtocolGuid = EFI_PLATFORM_TO_DRIVER_CONFIGURATION_PROTOCOL_GUID;
+EFI_GUID gEfiPlatformToDriverConfigurationClpGuid = EFI_PLATFORM_TO_DRIVER_CONFIGURATION_CLP_GUID;
+
+EFI_GUID_STRING
+ (&gEfiPlatformToDriverConfigurationProtocolGuid, "Platform to Driver Configuration Protocol", "UEFI 2.1 Platform to Driver Configuration Protocol");
diff --git a/EDK/Foundation/Efi/Protocol/PlatformToDriverConfiguration/PlatformToDriverConfiguration.h b/EDK/Foundation/Efi/Protocol/PlatformToDriverConfiguration/PlatformToDriverConfiguration.h
new file mode 100644
index 0000000..c3663ca
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/PlatformToDriverConfiguration/PlatformToDriverConfiguration.h
@@ -0,0 +1,173 @@
+/*++
+
+Copyright (c) 2008, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PlatformToDriverConfiguration.h
+
+Abstract:
+
+ UEFI Platform to Driver Configuration Protocol
+
+Revision History:
+
+--*/
+
+#ifndef _EFI_PLATFORM_TO_DRIVER_CONFIGURATION_H_
+#define _EFI_PLATFORM_TO_DRIVER_CONFIGURATION_H_
+
+//
+// Global ID for the Platform to Driver Configuration Protocol
+//
+#define EFI_PLATFORM_TO_DRIVER_CONFIGURATION_PROTOCOL_GUID \
+ { \
+ 0x642cd590, 0x8059, 0x4c0a, 0xa9, 0x58, 0xc5, 0xec, 0x07, 0xd2, 0x3c, 0x4b \
+ }
+
+#define EFI_PLATFORM_TO_DRIVER_CONFIGURATION_CLP_GUID \
+ { \
+ 0x345ecc0e, 0x0cb6, 0x4b75, 0xbb, 0x57, 0x1b, 0x12, 0x9c, 0x47, 0x33, 0x3e \
+ }
+
+EFI_FORWARD_DECLARATION (EFI_PLATFORM_TO_DRIVER_CONFIGURATION_PROTOCOL);
+
+typedef enum {
+ EfiPlatformConfigurationActionNone = 0,
+ EfiPlatformConfigurationActionStopController = 1,
+ EfiPlatformConfigurationActionRestartController = 2,
+ EfiPlatformConfigurationActionRestartPlatform = 3,
+ EfiPlatformConfigurationActionNvramFailed = 4,
+ EfiPlatformConfigurationActionMaximum
+} EFI_PLATFORM_CONFIGURATION_ACTION;
+
+typedef struct {
+ CHAR8 *CLPCommand;
+ UINT32 CLPCommandLength;
+ CHAR8 *CLPReturnString;
+ UINT32 CLPReturnStringLength;
+ UINT8 CLPCmdStatus;
+ UINT8 CLPErrorValue;
+ UINT16 CLPMsgCode;
+} EFI_CONFIGURE_CLP_PARAMETER_BLK;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PLATFORM_TO_DRIVER_CONFIGURATION_QUERY) (
+ IN EFI_PLATFORM_TO_DRIVER_CONFIGURATION_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle, OPTIONAL
+ IN UINTN *Instance,
+ OUT EFI_GUID **ParameterTypeGuid,
+ OUT VOID **ParameterBlock,
+ OUT UINTN *ParameterBlockSize
+ );
+/*++
+
+ Routine Description:
+ Allows the UEFI driver to query the platform for configuration information
+ needed to complete the drivers Start() operation.
+
+ Arguments:
+ This - A pointer to the EFI_PLATFORM_TO_DRIVER_CONFIGURATION_PROTOCOL instance.
+ ControllerHandle - The handle the platform will return configuration
+ information about.
+ ChildHandle - The handle of the child controller to set options on.
+ This is an optional parameter that may be NULL. It will
+ be NULL for device drivers, and for a bus drivers that
+ wish to set options for the bus controller. It will not
+ be NULL for a bus driver that wishes to set options for
+ one of its child controllers.
+ Instance - Pointer to the Instance value. Zero means return the first
+ query data. The caller should increment this value by one
+ each time to retrieve successive data.
+ ParameterTypeGuid - An EFI_GUID that defines the contents of ParameterBlock.
+ UEFI drivers must use the ParameterTypeGuid to determine
+ how to parse the ParameterBlock. The caller should not
+ attempt to free ParameterTypeGuid.
+ ParameterBlock - The platform returns a pointer to the ParameterBlock
+ structure which contains details about the configuration
+ parameters specific to the ParameterTypeGuid. This structure
+ is defined based on the protocol and may be different for
+ different protocols. UEFI driver decodes this structure
+ and its contents based on ProtocolGuid. ParameterBlock
+ is allocated by the platform and the platform is responsible
+ for freeing the ParameterBlock after Response is called.
+ ParameterBlockSize - The platform returns the size of the ParameterBlock in bytes.
+
+ Returns:
+ EFI_SUCCESS - The platform return parameter information for ControllerHandle.
+ EFI_NOT_FOUND - No more unread Instance exists.
+ EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.
+ EFI_INVALID_PARAMETER - Instance is NULL.
+ EFI_DEVICE_ERROR - A device error occurred while attempting to return
+ parameter block information for the controller specified
+ by ControllerHandle and ChildHandle.
+ EFI_OUT_RESOURCES - There are not enough resources available to set the
+ configuration options for the controller specified
+ by ControllerHandle and ChildHandle.
+
+--*/
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PLATFORM_TO_DRIVER_CONFIGURATION_RESPONSE) (
+ IN EFI_PLATFORM_TO_DRIVER_CONFIGURATION_PROTOCOL *This,
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle OPTIONAL,
+ IN UINTN *Instance,
+ IN EFI_GUID *ParameterTypeGuid,
+ IN VOID *ParameterBlock,
+ IN UINTN ParameterBlockSize ,
+ IN EFI_PLATFORM_CONFIGURATION_ACTION ConfigurationAction
+ );
+/*++
+
+ Routine Description:
+ Tell the platform what actions where taken by the driver after processing
+ the data returned from Query.
+
+ Arguments:
+ This - A pointer to the EFI_PLATFORM_TO_DRIVER_CONFIGURATION_PROTOCOL instance.
+ ControllerHandle - The handle the platform will return configuration
+ information about.
+ ChildHandle - The handle of the child controller to set options on.
+ This is an optional parameter that may be NULL. It will
+ be NULL for device drivers, and for a bus drivers that
+ wish to set options for the bus controller. It will not
+ be NULL for a bus driver that wishes to set options for
+ one of its child controllers.
+ Instance - Instance data returned from Query.
+ ParameterTypeGuid - ParameterTypeGuid returned from Query.
+ ParameterBlock - ParameterBlock returned from Query.
+ ParameterBlockSize - The ParameterBlock size returned from Query.
+ ConfigurationAction- The driver tells the platform what action is required
+ for ParameterBlock to take effect.
+
+ Returns:
+ EFI_SUCCESS - The platform return parameter information for ControllerHandle.
+ EFI_NOT_FOUND - Instance was not found.
+ EFI_INVALID_PARAMETER - ControllerHandle is not a valid EFI_HANDLE.
+ EFI_INVALID_PARAMETER - Instance is zero.
+
+--*/
+
+//
+// Interface structure for the Platform to Driver Configuration Protocol
+//
+typedef struct _EFI_PLATFORM_TO_DRIVER_CONFIGURATION_PROTOCOL {
+ EFI_PLATFORM_TO_DRIVER_CONFIGURATION_QUERY Query;
+ EFI_PLATFORM_TO_DRIVER_CONFIGURATION_RESPONSE Response;
+} EFI_PLATFORM_TO_DRIVER_CONFIGURATION_PROTOCOL;
+
+extern EFI_GUID gEfiPlatformToDriverConfigurationProtocolGuid;
+extern EFI_GUID gEfiPlatformToDriverConfigurationClpGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/PxeBaseCode/PxeBaseCode.c b/EDK/Foundation/Efi/Protocol/PxeBaseCode/PxeBaseCode.c
new file mode 100644
index 0000000..85a1677
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/PxeBaseCode/PxeBaseCode.c
@@ -0,0 +1,27 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+ PxeBaseCode.c
+
+Abstract:
+ PxeBaseCode GUID declaration.
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (PxeBaseCode)
+
+EFI_GUID gEfiPxeBaseCodeProtocolGuid = EFI_PXE_BASE_CODE_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiPxeBaseCodeProtocolGuid, "PXE Base Code Protocol", "EFI PXE Base Code Protocol");
+
+/* EOF - PxeBaseCode.c */
diff --git a/EDK/Foundation/Efi/Protocol/PxeBaseCode/PxeBaseCode.h b/EDK/Foundation/Efi/Protocol/PxeBaseCode/PxeBaseCode.h
new file mode 100644
index 0000000..811892a
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/PxeBaseCode/PxeBaseCode.h
@@ -0,0 +1,386 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+ PxeBaseCode.h
+
+Abstract:
+ EFI PXE Base Code Protocol definitions.
+
+--*/
+#ifndef _EFIPXEBC_H
+#define _EFIPXEBC_H
+
+#include "Pxe.h"
+
+//
+// PXE Base Code protocol
+//
+#define EFI_PXE_BASE_CODE_PROTOCOL_GUID \
+ { \
+ 0x03c4e603, 0xac28, 0x11d3, 0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d \
+ }
+
+EFI_FORWARD_DECLARATION (EFI_PXE_BASE_CODE_PROTOCOL);
+
+//
+// Default IP TTL and ToS.
+//
+#define DEFAULT_TTL 16
+#define DEFAULT_ToS 0
+
+//
+// ICMP error format
+//
+typedef struct {
+ UINT8 Type;
+ UINT8 Code;
+ UINT16 Checksum;
+ union {
+ UINT32 reserved;
+ UINT32 Mtu;
+ UINT32 Pointer;
+ struct {
+ UINT16 Identifier;
+ UINT16 Sequence;
+ } Echo;
+ } u;
+ UINT8 Data[494];
+} EFI_PXE_BASE_CODE_ICMP_ERROR;
+
+//
+// TFTP error format
+//
+typedef struct {
+ UINT8 ErrorCode;
+ CHAR8 ErrorString[127];
+} EFI_PXE_BASE_CODE_TFTP_ERROR;
+
+//
+// IP Receive Filter definitions
+//
+#define EFI_PXE_BASE_CODE_MAX_IPCNT 8
+
+typedef struct {
+ UINT8 Filters;
+ UINT8 IpCnt;
+ UINT16 reserved;
+ EFI_IP_ADDRESS IpList[EFI_PXE_BASE_CODE_MAX_IPCNT];
+} EFI_PXE_BASE_CODE_IP_FILTER;
+
+#define EFI_PXE_BASE_CODE_IP_FILTER_STATION_IP 0x0001
+#define EFI_PXE_BASE_CODE_IP_FILTER_BROADCAST 0x0002
+#define EFI_PXE_BASE_CODE_IP_FILTER_PROMISCUOUS 0x0004
+#define EFI_PXE_BASE_CODE_IP_FILTER_PROMISCUOUS_MULTICAST 0x0008
+
+//
+// ARP Cache definitions
+//
+typedef struct {
+ EFI_IP_ADDRESS IpAddr;
+ EFI_MAC_ADDRESS MacAddr;
+} EFI_PXE_BASE_CODE_ARP_ENTRY;
+
+typedef struct {
+ EFI_IP_ADDRESS IpAddr;
+ EFI_IP_ADDRESS SubnetMask;
+ EFI_IP_ADDRESS GwAddr;
+} EFI_PXE_BASE_CODE_ROUTE_ENTRY;
+
+//
+// UDP definitions
+//
+typedef UINT16 EFI_PXE_BASE_CODE_UDP_PORT;
+
+#define EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_SRC_IP 0x0001
+#define EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_SRC_PORT 0x0002
+#define EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_DEST_IP 0x0004
+#define EFI_PXE_BASE_CODE_UDP_OPFLAGS_ANY_DEST_PORT 0x0008
+#define EFI_PXE_BASE_CODE_UDP_OPFLAGS_USE_FILTER 0x0010
+#define EFI_PXE_BASE_CODE_UDP_OPFLAGS_MAY_FRAGMENT 0x0020
+
+//
+// Discover() definitions
+//
+#define EFI_PXE_BASE_CODE_BOOT_TYPE_BOOTSTRAP 0
+#define EFI_PXE_BASE_CODE_BOOT_TYPE_MS_WINNT_RIS 1
+#define EFI_PXE_BASE_CODE_BOOT_TYPE_INTEL_LCM 2
+#define EFI_PXE_BASE_CODE_BOOT_TYPE_DOSUNDI 3
+#define EFI_PXE_BASE_CODE_BOOT_TYPE_NEC_ESMPRO 4
+#define EFI_PXE_BASE_CODE_BOOT_TYPE_IBM_WSoD 5
+#define EFI_PXE_BASE_CODE_BOOT_TYPE_IBM_LCCM 6
+#define EFI_PXE_BASE_CODE_BOOT_TYPE_CA_UNICENTER_TNG 7
+#define EFI_PXE_BASE_CODE_BOOT_TYPE_HP_OPENVIEW 8
+#define EFI_PXE_BASE_CODE_BOOT_TYPE_ALTIRIS_9 9
+#define EFI_PXE_BASE_CODE_BOOT_TYPE_ALTIRIS_10 10
+#define EFI_PXE_BASE_CODE_BOOT_TYPE_ALTIRIS_11 11
+#define EFI_PXE_BASE_CODE_BOOT_TYPE_NOT_USED_12 12
+#define EFI_PXE_BASE_CODE_BOOT_TYPE_REDHAT_INSTALL 13
+#define EFI_PXE_BASE_CODE_BOOT_TYPE_REDHAT_BOOT 14
+#define EFI_PXE_BASE_CODE_BOOT_TYPE_REMBO 15
+#define EFI_PXE_BASE_CODE_BOOT_TYPE_BEOBOOT 16
+//
+// 17 through 32767 are reserved
+// 32768 through 65279 are for vendor use
+// 65280 through 65534 are reserved
+//
+#define EFI_PXE_BASE_CODE_BOOT_TYPE_PXETEST 65535
+
+#define EFI_PXE_BASE_CODE_BOOT_LAYER_MASK 0x7FFF
+#define EFI_PXE_BASE_CODE_BOOT_LAYER_INITIAL 0x0000
+
+//
+// Discover() server list structure.
+//
+typedef struct {
+ UINT16 Type;
+ BOOLEAN AcceptAnyResponse;
+ UINT8 Reserved;
+ EFI_IP_ADDRESS IpAddr;
+} EFI_PXE_BASE_CODE_SRVLIST;
+
+//
+// Discover() information override structure.
+//
+typedef struct {
+ BOOLEAN UseMCast;
+ BOOLEAN UseBCast;
+ BOOLEAN UseUCast;
+ BOOLEAN MustUseList;
+ EFI_IP_ADDRESS ServerMCastIp;
+ UINT16 IpCnt;
+ EFI_PXE_BASE_CODE_SRVLIST SrvList[1];
+} EFI_PXE_BASE_CODE_DISCOVER_INFO;
+
+//
+// Mtftp() definitions
+//
+typedef enum {
+ EFI_PXE_BASE_CODE_TFTP_FIRST,
+ EFI_PXE_BASE_CODE_TFTP_GET_FILE_SIZE,
+ EFI_PXE_BASE_CODE_TFTP_READ_FILE,
+ EFI_PXE_BASE_CODE_TFTP_WRITE_FILE,
+ EFI_PXE_BASE_CODE_TFTP_READ_DIRECTORY,
+ EFI_PXE_BASE_CODE_MTFTP_GET_FILE_SIZE,
+ EFI_PXE_BASE_CODE_MTFTP_READ_FILE,
+ EFI_PXE_BASE_CODE_MTFTP_READ_DIRECTORY,
+ EFI_PXE_BASE_CODE_MTFTP_LAST
+} EFI_PXE_BASE_CODE_TFTP_OPCODE;
+
+typedef struct {
+ EFI_IP_ADDRESS MCastIp;
+ EFI_PXE_BASE_CODE_UDP_PORT CPort;
+ EFI_PXE_BASE_CODE_UDP_PORT SPort;
+ UINT16 ListenTimeout;
+ UINT16 TransmitTimeout;
+} EFI_PXE_BASE_CODE_MTFTP_INFO;
+
+//
+// PXE Base Code Mode structure
+//
+#define EFI_PXE_BASE_CODE_MAX_ARP_ENTRIES 8
+#define EFI_PXE_BASE_CODE_MAX_ROUTE_ENTRIES 8
+
+typedef struct {
+ BOOLEAN Started;
+ BOOLEAN Ipv6Available;
+ BOOLEAN Ipv6Supported;
+ BOOLEAN UsingIpv6;
+ BOOLEAN BisSupported;
+ BOOLEAN BisDetected;
+ BOOLEAN AutoArp;
+ BOOLEAN SendGUID;
+ BOOLEAN DhcpDiscoverValid;
+ BOOLEAN DhcpAckReceived;
+ BOOLEAN ProxyOfferReceived;
+ BOOLEAN PxeDiscoverValid;
+ BOOLEAN PxeReplyReceived;
+ BOOLEAN PxeBisReplyReceived;
+ BOOLEAN IcmpErrorReceived;
+ BOOLEAN TftpErrorReceived;
+ BOOLEAN MakeCallbacks;
+ UINT8 TTL;
+ UINT8 ToS;
+ EFI_IP_ADDRESS StationIp;
+ EFI_IP_ADDRESS SubnetMask;
+ EFI_PXE_BASE_CODE_PACKET DhcpDiscover;
+ EFI_PXE_BASE_CODE_PACKET DhcpAck;
+ EFI_PXE_BASE_CODE_PACKET ProxyOffer;
+ EFI_PXE_BASE_CODE_PACKET PxeDiscover;
+ EFI_PXE_BASE_CODE_PACKET PxeReply;
+ EFI_PXE_BASE_CODE_PACKET PxeBisReply;
+ EFI_PXE_BASE_CODE_IP_FILTER IpFilter;
+ UINT32 ArpCacheEntries;
+ EFI_PXE_BASE_CODE_ARP_ENTRY ArpCache[EFI_PXE_BASE_CODE_MAX_ARP_ENTRIES];
+ UINT32 RouteTableEntries;
+ EFI_PXE_BASE_CODE_ROUTE_ENTRY RouteTable[EFI_PXE_BASE_CODE_MAX_ROUTE_ENTRIES];
+ EFI_PXE_BASE_CODE_ICMP_ERROR IcmpError;
+ EFI_PXE_BASE_CODE_TFTP_ERROR TftpError;
+} EFI_PXE_BASE_CODE_MODE;
+
+//
+// PXE Base Code Interface Function definitions
+//
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PXE_BASE_CODE_START) (
+ IN EFI_PXE_BASE_CODE_PROTOCOL * This,
+ IN BOOLEAN UseIpv6
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PXE_BASE_CODE_STOP) (
+ IN EFI_PXE_BASE_CODE_PROTOCOL * This
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PXE_BASE_CODE_DHCP) (
+ IN EFI_PXE_BASE_CODE_PROTOCOL * This,
+ IN BOOLEAN SortOffers
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PXE_BASE_CODE_DISCOVER) (
+ IN EFI_PXE_BASE_CODE_PROTOCOL * This,
+ IN UINT16 Type,
+ IN UINT16 *Layer,
+ IN BOOLEAN UseBis,
+ IN OUT EFI_PXE_BASE_CODE_DISCOVER_INFO * Info OPTIONAL
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PXE_BASE_CODE_MTFTP) (
+ IN EFI_PXE_BASE_CODE_PROTOCOL * This,
+ IN EFI_PXE_BASE_CODE_TFTP_OPCODE Operation,
+ IN OUT VOID *BufferPtr OPTIONAL,
+ IN BOOLEAN Overwrite,
+ IN OUT UINT64 *BufferSize,
+ IN UINTN *BlockSize OPTIONAL,
+ IN EFI_IP_ADDRESS * ServerIp,
+ IN UINT8 *Filename,
+ IN EFI_PXE_BASE_CODE_MTFTP_INFO * Info OPTIONAL,
+ IN BOOLEAN DontUseBuffer
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PXE_BASE_CODE_UDP_WRITE) (
+ IN EFI_PXE_BASE_CODE_PROTOCOL * This,
+ IN UINT16 OpFlags,
+ IN EFI_IP_ADDRESS * DestIp,
+ IN EFI_PXE_BASE_CODE_UDP_PORT * DestPort,
+ IN EFI_IP_ADDRESS * GatewayIp, OPTIONAL
+ IN EFI_IP_ADDRESS * SrcIp, OPTIONAL
+ IN OUT EFI_PXE_BASE_CODE_UDP_PORT * SrcPort, OPTIONAL
+ IN UINTN *HeaderSize, OPTIONAL
+ IN VOID *HeaderPtr, OPTIONAL
+ IN UINTN *BufferSize,
+ IN VOID *BufferPtr
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PXE_BASE_CODE_UDP_READ) (
+ IN EFI_PXE_BASE_CODE_PROTOCOL * This,
+ IN UINT16 OpFlags,
+ IN OUT EFI_IP_ADDRESS * DestIp, OPTIONAL
+ IN OUT EFI_PXE_BASE_CODE_UDP_PORT * DestPort, OPTIONAL
+ IN OUT EFI_IP_ADDRESS * SrcIp, OPTIONAL
+ IN OUT EFI_PXE_BASE_CODE_UDP_PORT * SrcPort, OPTIONAL
+ IN UINTN *HeaderSize, OPTIONAL
+ IN VOID *HeaderPtr, OPTIONAL
+ IN OUT UINTN *BufferSize,
+ IN VOID *BufferPtr
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PXE_BASE_CODE_SET_IP_FILTER) (
+ IN EFI_PXE_BASE_CODE_PROTOCOL * This,
+ IN EFI_PXE_BASE_CODE_IP_FILTER * NewFilter
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PXE_BASE_CODE_ARP) (
+ IN EFI_PXE_BASE_CODE_PROTOCOL * This,
+ IN EFI_IP_ADDRESS * IpAddr,
+ IN EFI_MAC_ADDRESS * MacAddr OPTIONAL
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PXE_BASE_CODE_SET_PARAMETERS) (
+ IN EFI_PXE_BASE_CODE_PROTOCOL * This,
+ IN BOOLEAN *NewAutoArp, OPTIONAL
+ IN BOOLEAN *NewSendGUID, OPTIONAL
+ IN UINT8 *NewTTL, OPTIONAL
+ IN UINT8 *NewToS, OPTIONAL
+ IN BOOLEAN *NewMakeCallback OPTIONAL
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PXE_BASE_CODE_SET_STATION_IP) (
+ IN EFI_PXE_BASE_CODE_PROTOCOL * This,
+ IN EFI_IP_ADDRESS * NewStationIp, OPTIONAL
+ IN EFI_IP_ADDRESS * NewSubnetMask OPTIONAL
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PXE_BASE_CODE_SET_PACKETS) (
+ IN EFI_PXE_BASE_CODE_PROTOCOL * This,
+ BOOLEAN *NewDhcpDiscoverValid, OPTIONAL
+ BOOLEAN *NewDhcpAckReceived, OPTIONAL
+ BOOLEAN *NewProxyOfferReceived, OPTIONAL
+ BOOLEAN *NewPxeDiscoverValid, OPTIONAL
+ BOOLEAN *NewPxeReplyReceived, OPTIONAL
+ BOOLEAN *NewPxeBisReplyReceived, OPTIONAL
+ IN EFI_PXE_BASE_CODE_PACKET * NewDhcpDiscover, OPTIONAL
+ IN EFI_PXE_BASE_CODE_PACKET * NewDhcpAck, OPTIONAL
+ IN EFI_PXE_BASE_CODE_PACKET * NewProxyOffer, OPTIONAL
+ IN EFI_PXE_BASE_CODE_PACKET * NewPxeDiscover, OPTIONAL
+ IN EFI_PXE_BASE_CODE_PACKET * NewPxeReply, OPTIONAL
+ IN EFI_PXE_BASE_CODE_PACKET * NewPxeBisReply OPTIONAL
+ );
+
+//
+// PXE Base Code Protocol structure
+//
+#define EFI_PXE_BASE_CODE_INTERFACE_REVISION 0x00010000
+
+typedef struct _EFI_PXE_BASE_CODE_PROTOCOL {
+ UINT64 Revision;
+ EFI_PXE_BASE_CODE_START Start;
+ EFI_PXE_BASE_CODE_STOP Stop;
+ EFI_PXE_BASE_CODE_DHCP Dhcp;
+ EFI_PXE_BASE_CODE_DISCOVER Discover;
+ EFI_PXE_BASE_CODE_MTFTP Mtftp;
+ EFI_PXE_BASE_CODE_UDP_WRITE UdpWrite;
+ EFI_PXE_BASE_CODE_UDP_READ UdpRead;
+ EFI_PXE_BASE_CODE_SET_IP_FILTER SetIpFilter;
+ EFI_PXE_BASE_CODE_ARP Arp;
+ EFI_PXE_BASE_CODE_SET_PARAMETERS SetParameters;
+ EFI_PXE_BASE_CODE_SET_STATION_IP SetStationIp;
+ EFI_PXE_BASE_CODE_SET_PACKETS SetPackets;
+ EFI_PXE_BASE_CODE_MODE *Mode;
+} EFI_PXE_BASE_CODE_PROTOCOL;
+
+extern EFI_GUID gEfiPxeBaseCodeProtocolGuid;
+
+#endif /* _EFIPXEBC_H */
+
+/* EOF - PxeBaseCode.h */
diff --git a/EDK/Foundation/Efi/Protocol/PxeBaseCodeCallBack/PxeBaseCodeCallBack.c b/EDK/Foundation/Efi/Protocol/PxeBaseCodeCallBack/PxeBaseCodeCallBack.c
new file mode 100644
index 0000000..560a73d
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/PxeBaseCodeCallBack/PxeBaseCodeCallBack.c
@@ -0,0 +1,29 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+ PxeBaseCodeCallBack.c
+
+Abstract:
+ PXE BaseCode Callback GUID declaration.
+
+--*/
+
+#include "EfiSpec.h"
+
+#include EFI_PROTOCOL_DEFINITION (PxeBaseCodeCallBack)
+
+EFI_GUID gEfiPxeBaseCodeCallbackProtocolGuid = EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL_GUID;
+
+EFI_GUID_STRING
+ (&gEfiPxeBaseCodeCallbackProtocolGuid, "PXE Base Code Callback Protocol", "EFI PXE Base Code Callback Protocol");
+
+/* EOF - PxeBaseCodeCallBack.c */
diff --git a/EDK/Foundation/Efi/Protocol/PxeBaseCodeCallBack/PxeBaseCodeCallBack.h b/EDK/Foundation/Efi/Protocol/PxeBaseCodeCallBack/PxeBaseCodeCallBack.h
new file mode 100644
index 0000000..6e7c0ab
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/PxeBaseCodeCallBack/PxeBaseCodeCallBack.h
@@ -0,0 +1,82 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+ PxeBaseCodeCallBack.h
+
+Abstract:
+ EFI PXE Base Code CallBack Protocol
+
+--*/
+
+#ifndef _PXE_BASE_CODE_CALLBACK_H_
+#define _PXE_BASE_CODE_CALLBACK_H_
+
+#include "Pxe.h"
+
+//
+// Call Back Definitions
+//
+#define EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL_GUID \
+ { \
+ 0x245dca21, 0xfb7b, 0x11d3, 0x8f, 0x01, 0x00, 0xa0, 0xc9, 0x69, 0x72, 0x3b \
+ }
+
+//
+// Revision Number
+//
+#define EFI_PXE_BASE_CODE_CALLBACK_INTERFACE_REVISION 0x00010000
+
+//
+// Protocol definition
+//
+EFI_FORWARD_DECLARATION (EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL);
+
+typedef enum {
+ EFI_PXE_BASE_CODE_FUNCTION_FIRST,
+ EFI_PXE_BASE_CODE_FUNCTION_DHCP,
+ EFI_PXE_BASE_CODE_FUNCTION_DISCOVER,
+ EFI_PXE_BASE_CODE_FUNCTION_MTFTP,
+ EFI_PXE_BASE_CODE_FUNCTION_UDP_WRITE,
+ EFI_PXE_BASE_CODE_FUNCTION_UDP_READ,
+ EFI_PXE_BASE_CODE_FUNCTION_ARP,
+ EFI_PXE_BASE_CODE_FUNCTION_IGMP,
+ EFI_PXE_BASE_CODE_FUNCTION_TCP_WRITE,
+ EFI_PXE_BASE_CODE_FUNCTION_TCP_READ,
+ EFI_PXE_BASE_CODE_PXE_FUNCTION_LAST
+} EFI_PXE_BASE_CODE_FUNCTION;
+
+typedef enum {
+ EFI_PXE_BASE_CODE_CALLBACK_STATUS_FIRST,
+ EFI_PXE_BASE_CODE_CALLBACK_STATUS_CONTINUE,
+ EFI_PXE_BASE_CODE_CALLBACK_STATUS_ABORT,
+ EFI_PXE_BASE_CODE_CALLBACK_STATUS_LAST
+} EFI_PXE_BASE_CODE_CALLBACK_STATUS;
+
+typedef EFI_PXE_BASE_CODE_CALLBACK_STATUS (EFIAPI *EFI_PXE_CALLBACK)
+ (
+ IN EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL * This,
+ IN EFI_PXE_BASE_CODE_FUNCTION Function,
+ IN BOOLEAN Received,
+ IN UINT32 PacketLen,
+ IN EFI_PXE_BASE_CODE_PACKET * Packet OPTIONAL
+ );
+
+typedef struct _EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL {
+ UINT64 Revision;
+ EFI_PXE_CALLBACK Callback;
+} EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL;
+
+extern EFI_GUID gEfiPxeBaseCodeCallbackProtocolGuid;
+
+#endif /* _EFIPXEBC_H */
+
+/* EOF - PxeBaseCodeCallBack.h */
diff --git a/EDK/Foundation/Efi/Protocol/ScsiIo/ScsiIo.c b/EDK/Foundation/Efi/Protocol/ScsiIo/ScsiIo.c
new file mode 100644
index 0000000..873ff4c
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/ScsiIo/ScsiIo.c
@@ -0,0 +1,26 @@
+/*++
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ ScsiIo.c
+
+Abstract:
+ EFI_SCSI_IO_PROTOCOL as defined in UEFI 2.0.
+
+Revision History
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (ScsiIo)
+
+EFI_GUID gEfiScsiIoProtocolGuid = EFI_SCSI_IO_PROTOCOL_GUID;
+EFI_GUID_STRING(&gEfiScsiIoProtocolGuid, "SCSI IO protoco", "UEFI 2.0 SCSI IO protocol");
diff --git a/EDK/Foundation/Efi/Protocol/ScsiIo/ScsiIo.h b/EDK/Foundation/Efi/Protocol/ScsiIo/ScsiIo.h
new file mode 100644
index 0000000..cdeb117
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/ScsiIo/ScsiIo.h
@@ -0,0 +1,256 @@
+/*++
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ ScsiIo.h
+
+Abstract:
+ EFI_SCSI_IO_PROTOCOL as defined in UEFI 2.0.
+
+Revision History
+
+--*/
+
+#ifndef __EFI_SCSI_IO_PROTOCOL_H__
+#define __EFI_SCSI_IO_PROTOCOL_H__
+
+#define EFI_SCSI_IO_PROTOCOL_GUID \
+ { \
+ 0x932f47e6, 0x2362, 0x4002, {0x80, 0x3e, 0x3c, 0xd5, 0x4b, 0x13, 0x8f, 0x85 } \
+ }
+
+//
+// Forward reference for pure ANSI compatability
+//
+typedef struct _EFI_SCSI_IO_PROTOCOL EFI_SCSI_IO_PROTOCOL;
+
+//
+// SCSI Data Direction definition
+//
+#define EFI_SCSI_IO_DATA_DIRECTION_READ 0
+#define EFI_SCSI_IO_DATA_DIRECTION_WRITE 1
+#define EFI_SCSI_IO_DATA_DIRECTION_BIDIRECTIONAL 2
+
+//
+// SCSI Host Adapter Status definition
+//
+#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_OK 0x00
+#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_TIMEOUT_COMMAND 0x09 // timeout when processing the command
+#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_TIMEOUT 0x0b // timeout when waiting for the command processing
+#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_MESSAGE_REJECT 0x0d // a message reject was received when processing command
+#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_BUS_RESET 0x0e // a bus reset was detected
+#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_PARITY_ERROR 0x0f
+#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_REQUEST_SENSE_FAILED 0x10 // the adapter failed in issuing request sense command
+#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_SELECTION_TIMEOUT 0x11 // selection timeout
+#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_DATA_OVERRUN_UNDERRUN 0x12 // data overrun or data underrun
+#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_BUS_FREE 0x13 // Unexepected bus free
+#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_PHASE_ERROR 0x14 // Target bus phase sequence failure
+#define EFI_SCSI_IO_STATUS_HOST_ADAPTER_OTHER 0x7f
+
+
+//
+// SCSI Target Status definition
+//
+#define EFI_SCSI_IO_STATUS_TARGET_GOOD 0x00
+#define EFI_SCSI_IO_STATUS_TARGET_CHECK_CONDITION 0x02 // check condition
+#define EFI_SCSI_IO_STATUS_TARGET_CONDITION_MET 0x04 // condition met
+#define EFI_SCSI_IO_STATUS_TARGET_BUSY 0x08 // busy
+#define EFI_SCSI_IO_STATUS_TARGET_INTERMEDIATE 0x10 // intermediate
+#define EFI_SCSI_IO_STATUS_TARGET_INTERMEDIATE_CONDITION_MET 0x14 // intermediate-condition met
+#define EFI_SCSI_IO_STATUS_TARGET_RESERVATION_CONFLICT 0x18 // reservation conflict
+#define EFI_SCSI_IO_STATUS_TARGET_COMMOND_TERMINATED 0x22 // command terminated
+#define EFI_SCSI_IO_STATUS_TARGET_QUEUE_FULL 0x28 // queue full
+
+typedef struct {
+ UINT64 Timeout;
+ VOID *InDataBuffer;
+ VOID *OutDataBuffer;
+ VOID *SenseData;
+ VOID *Cdb;
+ UINT32 InTransferLength;
+ UINT32 OutTransferLength;
+ UINT8 CdbLength;
+ UINT8 DataDirection;
+ UINT8 HostAdapterStatus;
+ UINT8 TargetStatus;
+ UINT8 SenseDataLength;
+} EFI_SCSI_IO_SCSI_REQUEST_PACKET;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SCSI_IO_PROTOCOL_GET_DEVICE_TYPE) (
+ IN EFI_SCSI_IO_PROTOCOL *This,
+ OUT UINT8 *DeviceType
+ )
+/*++
+
+ Routine Description:
+ Retrieves the device type information of the SCSI Controller.
+
+ Arguments:
+ This - Protocol instance pointer.
+ DeviceType - A pointer to the device type information
+ retrieved from the SCSI Controller.
+
+ Returns:
+ EFI_SUCCESS - Retrieves the device type information successfully.
+ EFI_INVALID_PARAMETER - The DeviceType is NULL.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SCSI_IO_PROTOCOL_GET_DEVICE_LOCATION) (
+ IN EFI_SCSI_IO_PROTOCOL *This,
+ IN OUT UINT8 **Target,
+ OUT UINT64 *Lun
+ )
+/*++
+
+ Routine Description:
+ Retrieves the device location in the SCSI channel.
+
+ Arguments:
+ This - Protocol instance pointer.
+ Target - A pointer to the Target Array which represents ID of a SCSI device
+ on the SCSI channel.
+ Lun - A pointer to the LUN of the SCSI device on
+ the SCSI channel.
+
+ Returns:
+ EFI_SUCCESS - Retrieves the device location successfully.
+ EFI_INVALID_PARAMETER - The Target or Lun is NULL.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SCSI_IO_PROTOCOL_RESET_BUS) (
+ IN EFI_SCSI_IO_PROTOCOL *This
+ )
+/*++
+
+ Routine Description:
+ Resets the SCSI Bus that the SCSI Controller is attached to.
+
+ Arguments:
+ This - This Protocol instance pointer.
+
+ Returns:
+ EFI_SUCCESS - The SCSI bus is reset successfully.
+ EFI_DEVICE_ERROR - Errors encountered when resetting the SCSI bus.
+ EFI_UNSUPPORTED - The bus reset operation is not supported by the
+ SCSI Host Controller.
+ EFI_TIMEOUT - A timeout occurred while attempting to reset
+ the SCSI bus.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SCSI_IO_PROTOCOL_RESET_DEVICE) (
+ IN EFI_SCSI_IO_PROTOCOL *This
+ )
+/*++
+
+ Routine Description:
+ Resets the SCSI Controller that the device handle specifies.
+
+ Arguments:
+ This - Protocol instance pointer.
+
+ Returns:
+ EFI_SUCCESS - Reset the SCSI controller successfully.
+ EFI_DEVICE_ERROR - Errors are encountered when resetting the
+ SCSI Controller.
+ EFI_UNSUPPORTED - The SCSI bus does not support a device
+ reset operation.
+ EFI_TIMEOUT - A timeout occurred while attempting to
+ reset the SCSI Controller.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SCSI_IO_PROTOCOL_EXEC_SCSI_COMMAND) (
+ IN EFI_SCSI_IO_PROTOCOL *This,
+ IN OUT EFI_SCSI_IO_SCSI_REQUEST_PACKET *Packet,
+ IN EFI_EVENT Event OPTIONAL
+ )
+/*++
+
+ Routine Description:
+ Sends a SCSI Request Packet to the SCSI Controller for execution.
+
+ Arguments:
+ This - Protocol instance pointer.
+ Packet - The SCSI request packet to send to the SCSI
+ Controller specified by the device handle.
+ Event - If the SCSI bus where the SCSI device is attached
+ does not support non-blocking I/O, then Event is
+ ignored, and blocking I/O is performed.
+ If Event is NULL, then blocking I/O is performed.
+ If Event is not NULL and non-blocking I/O is
+ supported, then non-blocking I/O is performed,
+ and Event will be signaled when the SCSI Request
+ Packet completes.
+
+ Returns:
+ EFI_SUCCESS - The SCSI Request Packet was sent by the host
+ successfully, and TransferLength bytes were
+ transferred to/from DataBuffer.See
+ HostAdapterStatus, TargetStatus,
+ SenseDataLength, and SenseData in that order
+ for additional status information.
+ EFI_BAD_BUFFER_SIZE - The SCSI Request Packet was executed,
+ but the entire DataBuffer could not be transferred.
+ The actual number of bytes transferred is returned
+ in TransferLength. See HostAdapterStatus,
+ TargetStatus, SenseDataLength, and SenseData in
+ that order for additional status information.
+ EFI_NOT_READY - The SCSI Request Packet could not be sent because
+ there are too many SCSI Command Packets already
+ queued.The caller may retry again later.
+ EFI_DEVICE_ERROR - A device error occurred while attempting to send
+ the SCSI Request Packet. See HostAdapterStatus,
+ TargetStatus, SenseDataLength, and SenseData in
+ that order for additional status information.
+ EFI_INVALID_PARAMETER - The contents of CommandPacket are invalid.
+ The SCSI Request Packet was not sent, so no
+ additional status information is available.
+ EFI_UNSUPPORTED - The command described by the SCSI Request Packet
+ is not supported by the SCSI initiator(i.e., SCSI
+ Host Controller). The SCSI Request Packet was not
+ sent, so no additional status information is
+ available.
+ EFI_TIMEOUT - A timeout occurred while waiting for the SCSI
+ Request Packet to execute. See HostAdapterStatus,
+ TargetStatus, SenseDataLength, and SenseData in
+ that order for additional status information.
+--*/
+;
+
+struct _EFI_SCSI_IO_PROTOCOL {
+ EFI_SCSI_IO_PROTOCOL_GET_DEVICE_TYPE GetDeviceType;
+ EFI_SCSI_IO_PROTOCOL_GET_DEVICE_LOCATION GetDeviceLocation;
+ EFI_SCSI_IO_PROTOCOL_RESET_BUS ResetBus;
+ EFI_SCSI_IO_PROTOCOL_RESET_DEVICE ResetDevice;
+ EFI_SCSI_IO_PROTOCOL_EXEC_SCSI_COMMAND ExecuteScsiCommand;
+ UINT32 IoAlign;
+};
+
+extern EFI_GUID gEfiScsiIoProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/ScsiPassThru/ScsiPassThru.c b/EDK/Foundation/Efi/Protocol/ScsiPassThru/ScsiPassThru.c
new file mode 100644
index 0000000..5089a42
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/ScsiPassThru/ScsiPassThru.c
@@ -0,0 +1,27 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ ScsiPassThru.c
+
+Abstract:
+
+ SCSI Pass Through protocol.
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (ScsiPassThru)
+
+EFI_GUID gEfiScsiPassThruProtocolGuid = EFI_SCSI_PASS_THRU_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiScsiPassThruProtocolGuid, "SCSI Pass Through Protocol", "EFI 1.0 SCSI Pass Through protocol");
diff --git a/EDK/Foundation/Efi/Protocol/ScsiPassThru/ScsiPassThru.h b/EDK/Foundation/Efi/Protocol/ScsiPassThru/ScsiPassThru.h
new file mode 100644
index 0000000..61463af
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/ScsiPassThru/ScsiPassThru.h
@@ -0,0 +1,332 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ ScsiPassThru.h
+
+Abstract:
+
+ SCSI Pass Through protocol.
+
+--*/
+
+#ifndef __SCSI_PT_H__
+#define __SCSI_PT_H__
+
+#define EFI_SCSI_PASS_THRU_PROTOCOL_GUID \
+ { \
+ 0xa59e8fcf, 0xbda0, 0x43bb, 0x90, 0xb1, 0xd3, 0x73, 0x2e, 0xca, 0xa8, 0x77 \
+ }
+
+//
+// Forward reference for pure ANSI compatability
+//
+EFI_FORWARD_DECLARATION (EFI_SCSI_PASS_THRU_PROTOCOL);
+
+#define EFI_SCSI_PASS_THRU_ATTRIBUTES_PHYSICAL 0x0001
+#define EFI_SCSI_PASS_THRU_ATTRIBUTES_LOGICAL 0x0002
+#define EFI_SCSI_PASS_THRU_ATTRIBUTES_NONBLOCKIO 0x0004
+
+//
+// SCSI Host Adapter Status definition
+//
+#define EFI_SCSI_STATUS_HOST_ADAPTER_OK 0x00
+#define EFI_SCSI_STATUS_HOST_ADAPTER_TIMEOUT_COMMAND 0x09 // timeout when processing the command
+#define EFI_SCSI_STATUS_HOST_ADAPTER_TIMEOUT 0x0b // timeout when waiting for the command processing
+#define EFI_SCSI_STATUS_HOST_ADAPTER_MESSAGE_REJECT 0x0d // a message reject was received when processing command
+#define EFI_SCSI_STATUS_HOST_ADAPTER_BUS_RESET 0x0e // a bus reset was detected
+#define EFI_SCSI_STATUS_HOST_ADAPTER_PARITY_ERROR 0x0f
+#define EFI_SCSI_STATUS_HOST_ADAPTER_REQUEST_SENSE_FAILED 0x10 // the adapter failed in issuing request sense command
+#define EFI_SCSI_STATUS_HOST_ADAPTER_SELECTION_TIMEOUT 0x11 // selection timeout
+#define EFI_SCSI_STATUS_HOST_ADAPTER_DATA_OVERRUN_UNDERRUN 0x12 // data overrun or data underrun
+#define EFI_SCSI_STATUS_HOST_ADAPTER_BUS_FREE 0x13 // Unexepected bus free
+#define EFI_SCSI_STATUS_HOST_ADAPTER_PHASE_ERROR 0x14 // Target bus phase sequence failure
+#define EFI_SCSI_STATUS_HOST_ADAPTER_OTHER 0x7f
+
+//
+// SCSI Target Status definition
+//
+#define EFI_SCSI_STATUS_TARGET_GOOD 0x00
+#define EFI_SCSI_STATUS_TARGET_CHECK_CONDITION 0x02 // check condition
+#define EFI_SCSI_STATUS_TARGET_CONDITION_MET 0x04 // condition met
+#define EFI_SCSI_STATUS_TARGET_BUSY 0x08 // busy
+#define EFI_SCSI_STATUS_TARGET_INTERMEDIATE 0x10 // intermediate
+#define EFI_SCSI_STATUS_TARGET_INTERMEDIATE_CONDITION_MET 0x14 // intermediate-condition met
+#define EFI_SCSI_STATUS_TARGET_RESERVATION_CONFLICT 0x18 // reservation conflict
+#define EFI_SCSI_STATUS_TARGET_COMMOND_TERMINATED 0x22 // command terminated
+#define EFI_SCSI_STATUS_TARGET_QUEUE_FULL 0x28 // queue full
+typedef struct {
+ UINT64 Timeout;
+ VOID *DataBuffer;
+ VOID *SenseData;
+ VOID *Cdb;
+ UINT32 TransferLength;
+ UINT8 CdbLength;
+ UINT8 DataDirection;
+ UINT8 HostAdapterStatus;
+ UINT8 TargetStatus;
+ UINT8 SenseDataLength;
+} EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET;
+
+typedef struct {
+ CHAR16 *ControllerName;
+ CHAR16 *ChannelName;
+ UINT32 AdapterId;
+ UINT32 Attributes;
+ UINT32 IoAlign;
+} EFI_SCSI_PASS_THRU_MODE;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SCSI_PASS_THRU_PASSTHRU) (
+ IN EFI_SCSI_PASS_THRU_PROTOCOL * This,
+ IN UINT32 Target,
+ IN UINT64 Lun,
+ IN OUT EFI_SCSI_PASS_THRU_SCSI_REQUEST_PACKET * Packet,
+ IN EFI_EVENT Event OPTIONAL
+ )
+/*++
+
+ Routine Description:
+ Sends a SCSI Request Packet to a SCSI device that is attached to
+ the SCSI channel. This function supports both blocking I/O and
+ non-blocking I/O. The blocking I/O functionality is required,
+ and the non-blocking I/O functionality is optional.
+
+ Arguments:
+ This - Protocol instance pointer.
+ Target - The Target ID of the SCSI device to
+ send the SCSI Request Packet.
+ Lun - The LUN of the SCSI device to send the
+ SCSI Request Packet.
+ Packet - A pointer to the SCSI Request Packet to send
+ to the SCSI device specified by Target and Lun.
+ Event - If non-blocking I/O is not supported then Event
+ is ignored, and blocking I/O is performed.
+ If Event is NULL, then blocking I/O is performed.
+ If Event is not NULL and non blocking I/O is
+ supported, then non-blocking I/O is performed,
+ and Event will be signaled when the SCSI Request
+ Packet completes
+
+ Returns:
+ EFI_SUCCESSThe - SCSI Request Packet was sent by the host, and
+ TransferLength bytes were transferred to/from
+ DataBuffer.See HostAdapterStatus, TargetStatus,
+ SenseDataLength,and SenseData in that order
+ for additional status information.
+ EFI_BAD_BUFFER_SIZE - The SCSI Request Packet was executed, but the
+ entire DataBuffer could not be transferred.
+ The actual number of bytes transferred is returned
+ in TransferLength. See HostAdapterStatus,
+ TargetStatus, SenseDataLength, and SenseData in
+ that order for additional status information.
+ EFI_NOT_READY - The SCSI Request Packet could not be sent because
+ there are too many SCSI Request Packets already
+ queued. The caller may retry again later.
+ EFI_DEVICE_ERROR - A device error occurred while attempting to send
+ the SCSI Request Packet. See HostAdapterStatus,
+ TargetStatus, SenseDataLength, and SenseData in
+ that order for additional status information.
+ EFI_INVALID_PARAMETER - Target, Lun, or the contents of ScsiRequestPacket
+ are invalid. The SCSI Request Packet was not sent,
+ so no additional status information is available.
+ EFI_UNSUPPORTED - The command described by the SCSI Request Packet
+ is not supported by the host adapter. The SCSI
+ Request Packet was not sent, so no additional
+ status information is available.
+ EFI_TIMEOUT - A timeout occurred while waiting for the SCSI
+ Request Packet to execute. See HostAdapterStatus,
+ TargetStatus, SenseDataLength, and SenseData in
+ that order for additional status information.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SCSI_PASS_THRU_GET_NEXT_DEVICE) (
+ IN EFI_SCSI_PASS_THRU_PROTOCOL * This,
+ IN OUT UINT32 *Target,
+ IN OUT UINT64 *Lun
+ )
+/*++
+
+ Routine Description:
+ Used to retrieve the list of legal Target IDs for SCSI devices
+ on a SCSI channel.
+
+ Arguments:
+ This - Protocol instance pointer.
+ Target - On input, a pointer to the Target ID of a
+ SCSI device present on the SCSI channel.
+ On output, a pointer to the Target ID of
+ the next SCSI device present on a SCSI channel.
+ An input value of 0xFFFFFFFF retrieves the
+ Target ID of the first SCSI device present on
+ a SCSI channel.
+ Lun - On input, a pointer to the LUN of a SCSI device
+ present on the SCSI channel.On output, a pointer
+ to the LUN of the next SCSI device present on a
+ SCSI channel.
+ Returns:
+ EFI_SUCCESS - The Target ID of the next SCSI device on the SCSI
+ channel was returned in Target and Lun.
+ EFI_NOT_FOUND - There are no more SCSI devices on this SCSI channel.
+ EFI_INVALID_PARAMETER - Target is not 0xFFFFFFFF, and Target and Lun were
+ not returned on a previous call to GetNextDevice().
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SCSI_PASS_THRU_BUILD_DEVICE_PATH) (
+ IN EFI_SCSI_PASS_THRU_PROTOCOL * This,
+ IN UINT32 Target,
+ IN UINT64 Lun,
+ IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
+ )
+/*++
+
+ Routine Description:
+ Used to allocate and build a device path node for a SCSI device
+ on a SCSI channel.
+
+ Arguments:
+ This - Protocol instance pointer.
+ Target - The Target ID of the SCSI device for which
+ a device path node is to be allocated and built.
+ Lun - The LUN of the SCSI device for which a device
+ path node is to be allocated and built.
+ DevicePath - A pointer to a single device path node that
+ describes the SCSI device specified by
+ Target and Lun. This function is responsible
+ for allocating the buffer DevicePath with the boot
+ service AllocatePool(). It is the caller's
+ responsibility to free DevicePath when the caller
+ is finished with DevicePath.
+ Returns:
+ EFI_SUCCESS - The device path node that describes the SCSI device
+ specified by Target and Lun was allocated and
+ returned in DevicePath.
+ EFI_NOT_FOUND - The SCSI devices specified by Target and Lun does
+ not exist on the SCSI channel.
+ EFI_INVALID_PARAMETER - DevicePath is NULL.
+ EFI_OUT_OF_RESOURCES - There are not enough resources to allocate
+ DevicePath.
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SCSI_PASS_THRU_GET_TARGET_LUN) (
+ IN EFI_SCSI_PASS_THRU_PROTOCOL * This,
+ IN EFI_DEVICE_PATH_PROTOCOL * DevicePath,
+ OUT UINT32 *Target,
+ OUT UINT64 *Lun
+ )
+/*++
+
+ Routine Description:
+ Used to translate a device path node to a Target ID and LUN.
+
+ Arguments:
+ This - Protocol instance pointer.
+ DevicePath - A pointer to the device path node that
+ describes a SCSI device on the SCSI channel.
+ Target - A pointer to the Target ID of a SCSI device
+ on the SCSI channel.
+ Lun - A pointer to the LUN of a SCSI device on
+ the SCSI channel.
+ Returns:
+ EFI_SUCCESS - DevicePath was successfully translated to a
+ Target ID and LUN, and they were returned
+ in Target and Lun.
+ EFI_INVALID_PARAMETER - DevicePath is NULL.
+ EFI_INVALID_PARAMETER - Target is NULL.
+ EFI_INVALID_PARAMETER - Lun is NULL.
+ EFI_UNSUPPORTED - This driver does not support the device path
+ node type in DevicePath.
+ EFI_NOT_FOUND - A valid translation from DevicePath to a
+ Target ID and LUN does not exist.
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SCSI_PASS_THRU_RESET_CHANNEL) (
+ IN EFI_SCSI_PASS_THRU_PROTOCOL * This
+ )
+/*++
+
+ Routine Description:
+ Resets a SCSI channel.This operation resets all the
+ SCSI devices connected to the SCSI channel.
+
+ Arguments:
+ This - Protocol instance pointer.
+
+ Returns:
+ EFI_SUCCESS - The SCSI channel was reset.
+ EFI_UNSUPPORTED - The SCSI channel does not support
+ a channel reset operation.
+ EFI_DEVICE_ERROR - A device error occurred while
+ attempting to reset the SCSI channel.
+ EFI_TIMEOUT - A timeout occurred while attempting
+ to reset the SCSI channel.
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SCSI_PASS_THRU_RESET_TARGET) (
+ IN EFI_SCSI_PASS_THRU_PROTOCOL * This,
+ IN UINT32 Target,
+ IN UINT64 Lun
+ )
+/*++
+
+ Routine Description:
+ Resets a SCSI device that is connected to a SCSI channel.
+
+ Arguments:
+ This - Protocol instance pointer.
+ Target - The Target ID of the SCSI device to reset.
+ Lun - The LUN of the SCSI device to reset.
+
+ Returns:
+ EFI_SUCCESS - The SCSI device specified by Target and
+ Lun was reset.
+ EFI_UNSUPPORTED - The SCSI channel does not support a target
+ reset operation.
+ EFI_INVALID_PARAMETER - Target or Lun are invalid.
+ EFI_DEVICE_ERROR - A device error occurred while attempting
+ to reset the SCSI device specified by Target
+ and Lun.
+ EFI_TIMEOUT - A timeout occurred while attempting to reset
+ the SCSI device specified by Target and Lun.
+--*/
+;
+
+typedef struct _EFI_SCSI_PASS_THRU_PROTOCOL {
+ EFI_SCSI_PASS_THRU_MODE *Mode;
+ EFI_SCSI_PASS_THRU_PASSTHRU PassThru;
+ EFI_SCSI_PASS_THRU_GET_NEXT_DEVICE GetNextDevice;
+ EFI_SCSI_PASS_THRU_BUILD_DEVICE_PATH BuildDevicePath;
+ EFI_SCSI_PASS_THRU_GET_TARGET_LUN GetTargetLun;
+ EFI_SCSI_PASS_THRU_RESET_CHANNEL ResetChannel;
+ EFI_SCSI_PASS_THRU_RESET_TARGET ResetTarget;
+} EFI_SCSI_PASS_THRU_PROTOCOL;
+
+extern EFI_GUID gEfiScsiPassThruProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/ScsiPassThruExt/ScsiPassThruExt.c b/EDK/Foundation/Efi/Protocol/ScsiPassThruExt/ScsiPassThruExt.c
new file mode 100644
index 0000000..7163ac8
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/ScsiPassThruExt/ScsiPassThruExt.c
@@ -0,0 +1,28 @@
+/*++
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ ScsiPassThruExt.c
+
+Abstract:
+ EFI_EXT_SCSI_PASS_THRU_PROTOCOL as defined in UEFI 2.0.
+
+Revision History
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (ScsiPassThruExt)
+
+EFI_GUID gEfiExtScsiPassThruProtocolGuid = EFI_EXT_SCSI_PASS_THRU_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiExtScsiPassThruProtocolGuid, "Extended Scsi Pass Thru", "UEFI 2.0 Extended SCSI Pass Thru protocol");
diff --git a/EDK/Foundation/Efi/Protocol/ScsiPassThruExt/ScsiPassThruExt.h b/EDK/Foundation/Efi/Protocol/ScsiPassThruExt/ScsiPassThruExt.h
new file mode 100644
index 0000000..0b5178d
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/ScsiPassThruExt/ScsiPassThruExt.h
@@ -0,0 +1,365 @@
+/*++
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ ScsiPassThruExt.h
+
+Abstract:
+ EFI_EXT_SCSI_PASS_THRU_PROTOCOL as defined in UEFI 2.0.
+
+Revision History
+
+--*/
+
+#ifndef __EXT_SCSI_PASS_THROUGH_PROTOCOL_H__
+#define __EXT_SCSI_PASS_THROUGH_PROTOCOL_H__
+
+#define EFI_EXT_SCSI_PASS_THRU_PROTOCOL_GUID \
+ { \
+ 0x143b7632, 0xb81b, 0x4cb7, {0xab, 0xd3, 0xb6, 0x25, 0xa5, 0xb9, 0xbf, 0xfe } \
+ }
+
+typedef struct _EFI_EXT_SCSI_PASS_THRU_PROTOCOL EFI_EXT_SCSI_PASS_THRU_PROTOCOL;
+
+#define TARGET_MAX_BYTES 0x10
+
+#define EFI_EXT_SCSI_PASS_THRU_ATTRIBUTES_PHYSICAL 0x0001
+#define EFI_EXT_SCSI_PASS_THRU_ATTRIBUTES_LOGICAL 0x0002
+#define EFI_EXT_SCSI_PASS_THRU_ATTRIBUTES_NONBLOCKIO 0x0004
+
+//
+// DataDirection
+//
+#define EFI_EXT_SCSI_DATA_DIRECTION_READ 0
+#define EFI_EXT_SCSI_DATA_DIRECTION_WRITE 1
+#define EFI_EXT_SCSI_DATA_DIRECTION_BIDIRECTIONAL 2
+//
+// HostAdapterStatus
+//
+#define EFI_EXT_SCSI_STATUS_HOST_ADAPTER_OK 0x00
+#define EFI_EXT_SCSI_STATUS_HOST_ADAPTER_TIMEOUT_COMMAND 0x09
+#define EFI_EXT_SCSI_STATUS_HOST_ADAPTER_TIMEOUT 0x0b
+#define EFI_EXT_SCSI_STATUS_HOST_ADAPTER_MESSAGE_REJECT 0x0d
+#define EFI_EXT_SCSI_STATUS_HOST_ADAPTER_BUS_RESET 0x0e
+#define EFI_EXT_SCSI_STATUS_HOST_ADAPTER_PARITY_ERROR 0x0f
+#define EFI_EXT_SCSI_STATUS_HOST_ADAPTER_REQUEST_SENSE_FAILED 0x10
+#define EFI_EXT_SCSI_STATUS_HOST_ADAPTER_SELECTION_TIMEOUT 0x11
+#define EFI_EXT_SCSI_STATUS_HOST_ADAPTER_DATA_OVERRUN_UNDERRUN 0x12
+#define EFI_EXT_SCSI_STATUS_HOST_ADAPTER_BUS_FREE 0x13
+#define EFI_EXT_SCSI_STATUS_HOST_ADAPTER_PHASE_ERROR 0x14
+#define EFI_EXT_SCSI_STATUS_HOST_ADAPTER_OTHER 0x7f
+//
+// TargetStatus
+//
+#define EFI_EXT_SCSI_STATUS_TARGET_GOOD 0x00
+#define EFI_EXT_SCSI_STATUS_TARGET_CHECK_CONDITION 0x02
+#define EFI_EXT_SCSI_STATUS_TARGET_CONDITION_MET 0x04
+#define EFI_EXT_SCSI_STATUS_TARGET_BUSY 0x08
+#define EFI_EXT_SCSI_STATUS_TARGET_INTERMEDIATE 0x10
+#define EFI_EXT_SCSI_STATUS_TARGET_INTERMEDIATE_CONDITION_MET 0x14
+#define EFI_EXT_SCSI_STATUS_TARGET_RESERVATION_CONFLICT 0x18
+#define EFI_EXT_SCSI_STATUS_TARGET_TASK_SET_FULL 0x28
+#define EFI_EXT_SCSI_STATUS_TARGET_ACA_ACTIVE 0x30
+#define EFI_EXT_SCSI_STATUS_TARGET_TASK_ABORTED 0x40
+
+typedef struct {
+ UINT32 AdapterId;
+ UINT32 Attributes;
+ UINT32 IoAlign;
+} EFI_EXT_SCSI_PASS_THRU_MODE;
+
+typedef struct {
+ UINT64 Timeout;
+ VOID *InDataBuffer;
+ VOID *OutDataBuffer;
+ VOID *SenseData;
+ VOID *Cdb;
+ UINT32 InTransferLength;
+ UINT32 OutTransferLength;
+ UINT8 CdbLength;
+ UINT8 DataDirection;
+ UINT8 HostAdapterStatus;
+ UINT8 TargetStatus;
+ UINT8 SenseDataLength;
+} EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_EXT_SCSI_PASS_THRU_PASSTHRU) (
+ IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
+ IN UINT8 *Target,
+ IN UINT64 Lun,
+ IN OUT EFI_EXT_SCSI_PASS_THRU_SCSI_REQUEST_PACKET *Packet,
+ IN EFI_EVENT Event OPTIONAL
+ )
+/*++
+
+ Routine Description:
+ Sends a SCSI Request Packet to a SCSI device that is attached to the SCSI channel. This function
+ supports both blocking I/O and nonblocking I/O. The blocking I/O functionality is required, and the
+ nonblocking I/O functionality is optional.
+
+ Arguments:
+ This - A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.
+ Target - The Target is an array of size TARGET_MAX_BYTES and it represents
+ the id of the SCSI device to send the SCSI Request Packet. Each
+ transport driver may chose to utilize a subset of this size to suit the needs
+ of transport target representation. For example, a Fibre Channel driver
+ may use only 8 bytes (WWN) to represent an FC target.
+ Lun - The LUN of the SCSI device to send the SCSI Request Packet.
+ Packet - A pointer to the SCSI Request Packet to send to the SCSI device
+ specified by Target and Lun.
+ Event - If nonblocking I/O is not supported then Event is ignored, and blocking
+ I/O is performed. If Event is NULL, then blocking I/O is performed. If
+ Event is not NULL and non blocking I/O is supported, then
+ nonblocking I/O is performed, and Event will be signaled when the
+ SCSI Request Packet completes.
+
+ Returns:
+ EFI_SUCCESS - The SCSI Request Packet was sent by the host. For bi-directional
+ commands, InTransferLength bytes were transferred from
+ InDataBuffer. For write and bi-directional commands,
+ OutTransferLength bytes were transferred by
+ OutDataBuffer.
+ EFI_BAD_BUFFER_SIZE - The SCSI Request Packet was not executed. The number of bytes that
+ could be transferred is returned in InTransferLength. For write
+ and bi-directional commands, OutTransferLength bytes were
+ transferred by OutDataBuffer.
+ EFI_NOT_READY - The SCSI Request Packet could not be sent because there are too many
+ SCSI Request Packets already queued. The caller may retry again later.
+ EFI_DEVICE_ERROR - A device error occurred while attempting to send the SCSI Request
+ Packet.
+ EFI_INVALID_PARAMETER- Target, Lun, or the contents of ScsiRequestPacket are invalid.
+ EFI_UNSUPPORTED - The command described by the SCSI Request Packet is not supported
+ by the host adapter. This includes the case of Bi-directional SCSI
+ commands not supported by the implementation. The SCSI Request
+ Packet was not sent, so no additional status information is available.
+ EFI_TIMEOUT - A timeout occurred while waiting for the SCSI Request Packet to execute.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_EXT_SCSI_PASS_THRU_GET_NEXT_TARGET_LUN) (
+ IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
+ IN OUT UINT8 **Target,
+ IN OUT UINT64 *Lun
+ )
+/*++
+ Routine Description:
+ Used to retrieve the list of legal Target IDs and LUNs for SCSI devices on a SCSI channel. These
+ can either be the list SCSI devices that are actually present on the SCSI channel, or the list of legal
+ Target Ids and LUNs for the SCSI channel. Regardless, the caller of this function must probe the
+ Target ID and LUN returned to see if a SCSI device is actually present at that location on the SCSI
+ channel.
+
+ Arguments:
+ This - A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance
+ Target - On input, a pointer to the Target ID (an array of size
+ TARGET_MAX_BYTES) of a SCSI device present on the SCSI channel.
+ On output, a pointer to the Target ID (an array of
+ TARGET_MAX_BYTES) of the next SCSI device present on a SCSI
+ channel. An input value of 0xF(all bytes in the array are 0xF) in the
+ Target array retrieves the Target ID of the first SCSI device present on
+ a SCSI channel.
+ Lun - On input, a pointer to the LUN of a SCSI device present on the SCSI
+ channel. On output, a pointer to the LUN of the next SCSI device present
+ on a SCSI channel.
+
+ Returns:
+ EFI_SUCCESS - The Target ID and LUN of the next SCSI device on the SCSI
+ channel was returned in Target and Lun.
+ EFI_INVALID_PARAMETER - Target array is not all 0xF, and Target and Lun were
+ not returned on a previous call to GetNextTargetLun().
+ EFI_NOT_FOUND - There are no more SCSI devices on this SCSI channel.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_EXT_SCSI_PASS_THRU_BUILD_DEVICE_PATH) (
+ IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
+ IN UINT8 *Target,
+ IN UINT64 Lun,
+ IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
+ )
+/*++
+
+ Routine Description:
+ Used to allocate and build a device path node for a SCSI device on a SCSI channel.
+
+ Arguments:
+ This - A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.
+ Target - The Target is an array of size TARGET_MAX_BYTES and it specifies the
+ Target ID of the SCSI device for which a device path node is to be
+ allocated and built. Transport drivers may chose to utilize a subset of
+ this size to suit the representation of targets. For example, a Fibre
+ Channel driver may use only 8 bytes (WWN) in the array to represent a
+ FC target.
+ Lun - The LUN of the SCSI device for which a device path node is to be
+ allocated and built.
+
+ DevicePath - A pointer to a single device path node that describes the SCSI device
+ specified by Target and Lun. This function is responsible for
+ allocating the buffer DevicePath with the boot service
+ AllocatePool(). It is the caller's responsibility to free
+ DevicePath when the caller is finished with DevicePath.
+
+ Returns:
+ EFI_SUCCESS - The device path node that describes the SCSI device specified by
+ Target and Lun was allocated and returned in
+ DevicePath.
+ EFI_INVALID_PARAMETER - DevicePath is NULL.
+ EFI_NOT_FOUND - The SCSI devices specified by Target and Lun does not exist
+ on the SCSI channel.
+ EFI_OUT_OF_RESOURCES - There are not enough resources to allocate DevicePath.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_EXT_SCSI_PASS_THRU_GET_TARGET_LUN) (
+ IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
+ OUT UINT8 **Target,
+ OUT UINT64 *Lun
+ )
+/*++
+
+ Routine Description:
+ Used to translate a device path node to a Target ID and LUN.
+
+ Arguments:
+ This - A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.
+ DevicePath - A pointer to a single device path node that describes the SCSI device
+ on the SCSI channel.
+ Target - A pointer to the Target Array which represents the ID of a SCSI device
+ on the SCSI channel.
+ Lun - A pointer to the LUN of a SCSI device on the SCSI channel.
+
+ Returns:
+ EFI_SUCCESS - DevicePath was successfully translated to a Target ID and
+ LUN, and they were returned in Target and Lun.
+ EFI_INVALID_PARAMETER - DevicePath or Target or Lun is NULL.
+ EFI_NOT_FOUND - A valid translation from DevicePath to a Target ID and LUN
+ does not exist.
+ EFI_UNSUPPORTED - This driver does not support the device path node type in
+ DevicePath.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_EXT_SCSI_PASS_THRU_RESET_CHANNEL) (
+ IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This
+ )
+/*++
+
+ Routine Description:
+ Resets a SCSI channel. This operation resets all the SCSI devices connected to the SCSI channel.
+
+ Arguments:
+ This - A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.
+
+ Returns:
+ EFI_SUCCESS - The SCSI channel was reset.
+ EFI_DEVICE_ERROR - A device error occurred while attempting to reset the SCSI channel.
+ EFI_TIMEOUT - A timeout occurred while attempting to reset the SCSI channel.
+ EFI_UNSUPPORTED - The SCSI channel does not support a channel reset operation.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_EXT_SCSI_PASS_THRU_RESET_TARGET_LUN) (
+ IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
+ IN UINT8 *Target,
+ IN UINT64 Lun
+ )
+/*++
+
+ Routine Description:
+ Resets a SCSI logical unit that is connected to a SCSI channel.
+
+ Arguments:
+ This A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.
+ Target The Target is an array of size TARGET_MAX_BYTE and it represents the
+ target port ID of the SCSI device containing the SCSI logical unit to
+ reset. Transport drivers may chose to utilize a subset of this array to suit
+ the representation of their targets.
+ Lun The LUN of the SCSI device to reset.
+
+ Returns:
+ EFI_SUCCESS - The SCSI device specified by Target and Lun was reset.
+ EFI_INVALID_PARAMETER - Target or Lun is NULL.
+ EFI_TIMEOUT - A timeout occurred while attempting to reset the SCSI device
+ specified by Target and Lun.
+ EFI_UNSUPPORTED - The SCSI channel does not support a target reset operation.
+ EFI_DEVICE_ERROR - A device error occurred while attempting to reset the SCSI device
+ specified by Target and Lun.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_EXT_SCSI_PASS_THRU_GET_NEXT_TARGET) (
+ IN EFI_EXT_SCSI_PASS_THRU_PROTOCOL *This,
+ IN OUT UINT8 **Target
+ )
+/*++
+
+ Routine Description:
+ Used to retrieve the list of legal Target IDs for SCSI devices on a SCSI channel. These can either
+ be the list SCSI devices that are actually present on the SCSI channel, or the list of legal Target IDs
+ for the SCSI channel. Regardless, the caller of this function must probe the Target ID returned to
+ see if a SCSI device is actually present at that location on the SCSI channel.
+
+ Arguments:
+ This - A pointer to the EFI_EXT_SCSI_PASS_THRU_PROTOCOL instance.
+ Target - (TARGET_MAX_BYTES) of a SCSI device present on the SCSI channel.
+ On output, a pointer to the Target ID (an array of
+ TARGET_MAX_BYTES) of the next SCSI device present on a SCSI
+ channel. An input value of 0xF(all bytes in the array are 0xF) in the
+ Target array retrieves the Target ID of the first SCSI device present on a
+ SCSI channel.
+
+ Returns:
+ EFI_SUCCESS - The Target ID of the next SCSI device on the SCSI
+ channel was returned in Target.
+ EFI_INVALID_PARAMETER - Target or Lun is NULL.
+ EFI_TIMEOUT - Target array is not all 0xF, and Target were not
+ returned on a previous call to GetNextTarget().
+ EFI_NOT_FOUND - There are no more SCSI devices on this SCSI channel.
+
+--*/
+;
+
+struct _EFI_EXT_SCSI_PASS_THRU_PROTOCOL {
+ EFI_EXT_SCSI_PASS_THRU_MODE *Mode;
+ EFI_EXT_SCSI_PASS_THRU_PASSTHRU PassThru;
+ EFI_EXT_SCSI_PASS_THRU_GET_NEXT_TARGET_LUN GetNextTargetLun;
+ EFI_EXT_SCSI_PASS_THRU_BUILD_DEVICE_PATH BuildDevicePath;
+ EFI_EXT_SCSI_PASS_THRU_GET_TARGET_LUN GetTargetLun;
+ EFI_EXT_SCSI_PASS_THRU_RESET_CHANNEL ResetChannel;
+ EFI_EXT_SCSI_PASS_THRU_RESET_TARGET_LUN ResetTargetLun;
+ EFI_EXT_SCSI_PASS_THRU_GET_NEXT_TARGET GetNextTarget;
+};
+
+extern EFI_GUID gEfiExtScsiPassThruProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/SerialIO/SerialIo.c b/EDK/Foundation/Efi/Protocol/SerialIO/SerialIo.c
new file mode 100644
index 0000000..efb9d7a
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/SerialIO/SerialIo.c
@@ -0,0 +1,30 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ SerialIo.c
+
+Abstract:
+
+ Serial IO protocol as defined in the EFI 1.0 specification.
+
+ Abstraction of a basic serial device. Targeted at 16550 UART, but
+ could be much more generic.
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (SerialIo)
+
+EFI_GUID gEfiSerialIoProtocolGuid = EFI_SERIAL_IO_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiSerialIoProtocolGuid, "SerialIo Protocol", "EFI 1.0 Serial IO Protocol");
diff --git a/EDK/Foundation/Efi/Protocol/SerialIO/SerialIo.h b/EDK/Foundation/Efi/Protocol/SerialIO/SerialIo.h
new file mode 100644
index 0000000..267d762
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/SerialIO/SerialIo.h
@@ -0,0 +1,296 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ SerialIo.h
+
+Abstract:
+
+ Serial IO protocol as defined in the EFI 1.0 specification.
+
+ Abstraction of a basic serial device. Targeted at 16550 UART, but
+ could be much more generic.
+
+--*/
+
+#ifndef _SERIAL_IO_H_
+#define _SERIAL_IO_H_
+
+#define EFI_SERIAL_IO_PROTOCOL_GUID \
+ { \
+ 0xBB25CF6F, 0xF1D4, 0x11D2, 0x9A, 0x0C, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0xFD \
+ }
+
+EFI_FORWARD_DECLARATION (EFI_SERIAL_IO_PROTOCOL);
+
+//
+// Serial IO Data structures
+//
+typedef enum {
+ DefaultParity,
+ NoParity,
+ EvenParity,
+ OddParity,
+ MarkParity,
+ SpaceParity
+} EFI_PARITY_TYPE;
+
+typedef enum {
+ DefaultStopBits,
+ OneStopBit,
+ OneFiveStopBits,
+ TwoStopBits
+} EFI_STOP_BITS_TYPE;
+
+//
+// define for Control bits, grouped by read only, write only, and read write
+//
+//
+// Read Only
+//
+#define EFI_SERIAL_CLEAR_TO_SEND 0x00000010
+#define EFI_SERIAL_DATA_SET_READY 0x00000020
+#define EFI_SERIAL_RING_INDICATE 0x00000040
+#define EFI_SERIAL_CARRIER_DETECT 0x00000080
+#define EFI_SERIAL_INPUT_BUFFER_EMPTY 0x00000100
+#define EFI_SERIAL_OUTPUT_BUFFER_EMPTY 0x00000200
+
+//
+// Write Only
+//
+#define EFI_SERIAL_REQUEST_TO_SEND 0x00000002
+#define EFI_SERIAL_DATA_TERMINAL_READY 0x00000001
+
+//
+// Read Write
+//
+#define EFI_SERIAL_HARDWARE_LOOPBACK_ENABLE 0x00001000
+#define EFI_SERIAL_SOFTWARE_LOOPBACK_ENABLE 0x00002000
+#define EFI_SERIAL_HARDWARE_FLOW_CONTROL_ENABLE 0x00004000
+
+//
+// Serial IO Member Functions
+//
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SERIAL_RESET) (
+ IN EFI_SERIAL_IO_PROTOCOL * This
+ )
+/*++
+
+ Routine Description:
+ Reset the serial device.
+
+ Arguments:
+ This - Protocol instance pointer.
+
+ Returns:
+ EFI_SUCCESS - The device was reset.
+ EFI_DEVICE_ERROR - The serial device could not be reset.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SERIAL_SET_ATTRIBUTES) (
+ IN EFI_SERIAL_IO_PROTOCOL * This,
+ IN UINT64 BaudRate,
+ IN UINT32 ReceiveFifoDepth,
+ IN UINT32 Timeout,
+ IN EFI_PARITY_TYPE Parity,
+ IN UINT8 DataBits,
+ IN EFI_STOP_BITS_TYPE StopBits
+ )
+/*++
+
+ Routine Description:
+ Sets the baud rate, receive FIFO depth, transmit/receice time out, parity,
+ data buts, and stop bits on a serial device.
+
+ Arguments:
+ This - Protocol instance pointer.
+ BaudRate - The requested baud rate. A BaudRate value of 0 will use the the
+ device's default interface speed.
+ ReveiveFifoDepth - The requested depth of the FIFO on the receive side of the
+ serial interface. A ReceiveFifoDepth value of 0 will use
+ the device's dfault FIFO depth.
+ Timeout - The requested time out for a single character in microseconds.
+ This timeout applies to both the transmit and receive side of the
+ interface. A Timeout value of 0 will use the device's default time
+ out value.
+ Parity - The type of parity to use on this serial device. A Parity value of
+ DefaultParity will use the device's default parity value.
+ DataBits - The number of data bits to use on the serial device. A DataBits
+ vaule of 0 will use the device's default data bit setting.
+ StopBits - The number of stop bits to use on this serial device. A StopBits
+ value of DefaultStopBits will use the device's default number of
+ stop bits.
+
+ Returns:
+ EFI_SUCCESS - The device was reset.
+ EFI_DEVICE_ERROR - The serial device could not be reset.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SERIAL_SET_CONTROL_BITS) (
+ IN EFI_SERIAL_IO_PROTOCOL * This,
+ IN UINT32 Control
+ )
+/*++
+
+ Routine Description:
+ Set the control bits on a serial device
+
+ Arguments:
+ This - Protocol instance pointer.
+ Control - Set the bits of Control that are settable.
+
+ Returns:
+ EFI_SUCCESS - The new control bits were set on the serial device.
+ EFI_UNSUPPORTED - The serial device does not support this operation.
+ EFI_DEVICE_ERROR - The serial device is not functioning correctly.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SERIAL_GET_CONTROL_BITS) (
+ IN EFI_SERIAL_IO_PROTOCOL * This,
+ OUT UINT32 *Control
+ )
+/*++
+
+ Routine Description:
+ Retrieves the status of thecontrol bits on a serial device
+
+ Arguments:
+ This - Protocol instance pointer.
+ Control - A pointer to return the current Control signals from the serial
+ device.
+
+ Returns:
+ EFI_SUCCESS - The control bits were read from the serial device.
+ EFI_DEVICE_ERROR - The serial device is not functioning correctly.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SERIAL_WRITE) (
+ IN EFI_SERIAL_IO_PROTOCOL * This,
+ IN OUT UINTN *BufferSize,
+ IN VOID *Buffer
+ )
+/*++
+
+ Routine Description:
+ Writes data to a serial device.
+
+ Arguments:
+ This - Protocol instance pointer.
+ BufferSize - On input, the size of the Buffer. On output, the amount of
+ data actually written.
+ Buffer - The buffer of data to write
+
+ Returns:
+ EFI_SUCCESS - The data was written.
+ EFI_DEVICE_ERROR - The device reported an error.
+ EFI_TIMEOUT - The data write was stopped due to a timeout.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SERIAL_READ) (
+ IN EFI_SERIAL_IO_PROTOCOL * This,
+ IN OUT UINTN *BufferSize,
+ OUT VOID *Buffer
+ )
+/*++
+
+ Routine Description:
+ Writes data to a serial device.
+
+ Arguments:
+ This - Protocol instance pointer.
+ BufferSize - On input, the size of the Buffer. On output, the amount of
+ data returned in Buffer.
+ Buffer - The buffer to return the data into.
+
+ Returns:
+ EFI_SUCCESS - The data was read.
+ EFI_DEVICE_ERROR - The device reported an error.
+ EFI_TIMEOUT - The data write was stopped due to a timeout.
+
+--*/
+;
+
+/*++
+
+ The data values in SERIAL_IO_MODE are read-only and are updated by the code
+ that produces the SERIAL_IO_PROTOCOL member functions.
+
+ ControlMask - A mask fo the Control bits that the device supports. The device
+ must always support the Input Buffer Empty control bit.
+ TimeOut - If applicable, the number of microseconds to wait before timing out
+ a Read or Write operation.
+ BaudRate - If applicable, the current baud rate setting of the device; otherwise,
+ baud rate has the value of zero to indicate that device runs at the
+ device's designed speed.
+ ReceiveFifoDepth - The number of characters the device will buffer on input
+ DataBits - The number of characters the device will buffer on input
+ Parity - If applicable, this is the EFI_PARITY_TYPE that is computed or
+ checked as each character is transmitted or reveived. If the device
+ does not support parity the value is the default parity value.
+ StopBits - If applicable, the EFI_STOP_BITS_TYPE number of stop bits per
+ character. If the device does not support stop bits the value is
+ the default stop bit values.
+
+--*/
+typedef struct {
+ UINT32 ControlMask;
+
+ //
+ // current Attributes
+ //
+ UINT32 Timeout;
+ UINT64 BaudRate;
+ UINT32 ReceiveFifoDepth;
+ UINT32 DataBits;
+ UINT32 Parity;
+ UINT32 StopBits;
+} EFI_SERIAL_IO_MODE;
+
+#define SERIAL_IO_INTERFACE_REVISION 0x00010000
+
+typedef struct _EFI_SERIAL_IO_PROTOCOL {
+ UINT32 Revision;
+ EFI_SERIAL_RESET Reset;
+ EFI_SERIAL_SET_ATTRIBUTES SetAttributes;
+ EFI_SERIAL_SET_CONTROL_BITS SetControl;
+ EFI_SERIAL_GET_CONTROL_BITS GetControl;
+ EFI_SERIAL_WRITE Write;
+ EFI_SERIAL_READ Read;
+
+ EFI_SERIAL_IO_MODE *Mode;
+} EFI_SERIAL_IO_PROTOCOL;
+
+extern EFI_GUID gEfiSerialIoProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/ServiceBinding/ServiceBinding.h b/EDK/Foundation/Efi/Protocol/ServiceBinding/ServiceBinding.h
new file mode 100644
index 0000000..1a990a5
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/ServiceBinding/ServiceBinding.h
@@ -0,0 +1,88 @@
+/*++
+
+Copyright (c) 2005, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ ServiceBinding.h
+
+Abstract:
+
+ UEFI Service Binding protocol definition.
+
+--*/
+
+#ifndef _EFI_SERVICE_BINDING_H_
+#define _EFI_SERVICE_BINDING_H_
+
+//
+// Forward reference for pure ANSI compatability
+//
+EFI_FORWARD_DECLARATION (EFI_SERVICE_BINDING_PROTOCOL);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SERVICE_BINDING_CREATE_CHILD) (
+ IN EFI_SERVICE_BINDING_PROTOCOL *This,
+ IN OUT EFI_HANDLE *ChildHandle
+ )
+/*++
+
+ Routine Description:
+ Creates a child handle with a set of I/O services.
+
+ Arguments:
+ This - Protocol instance pointer.
+ ChildHandle - Pointer to the handle of the child to create. If it is NULL,
+ then a new handle is created. If it is not NULL, then the
+ I/O services are added to the existing child handle.
+
+ Returns:
+ EFI_SUCCES - The child handle was created with the I/O services.
+ EFI_OUT_OF_RESOURCES - There are not enough resources availabe to create
+ the child.
+ other - The child handle was not created.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SERVICE_BINDING_DESTROY_CHILD) (
+ IN struct _EFI_SERVICE_BINDING_PROTOCOL *This,
+ IN EFI_HANDLE ChildHandle
+ )
+/*++
+
+ Routine Description:
+ Destroys a child handle with a set of I/O services.
+
+ Arguments:
+ This - Protocol instance pointer.
+ ChildHandle - Handle of the child to destroy.
+
+ Returns:
+ EFI_SUCCES - The I/O services were removed from the child handle.
+ EFI_UNSUPPORTED - The child handle does not support the I/O services
+ that are being removed.
+ EFI_INVALID_PARAMETER - Child handle is not a valid EFI Handle.
+ EFI_ACCESS_DENIED - The child handle could not be destroyed because its
+ I/O services are being used.
+ other - The child handle was not destroyed.
+
+--*/
+;
+
+typedef struct _EFI_SERVICE_BINDING_PROTOCOL {
+ EFI_SERVICE_BINDING_CREATE_CHILD CreateChild;
+ EFI_SERVICE_BINDING_DESTROY_CHILD DestroyChild;
+} EFI_SERVICE_BINDING_PROTOCOL;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/SimpleFileSystem/SimpleFileSystem.c b/EDK/Foundation/Efi/Protocol/SimpleFileSystem/SimpleFileSystem.c
new file mode 100644
index 0000000..4cbcd2e
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/SimpleFileSystem/SimpleFileSystem.c
@@ -0,0 +1,33 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ SimpleFileSystem.c
+
+Abstract:
+
+ SimpleFileSystem protocol as defined in the EFI 1.0 specification.
+
+ The SimpleFileSystem protocol is the programatic access to the FAT (12,16,32)
+ file system specified in EFI 1.0. It can also be used to abstract any
+ file system other than FAT.
+
+ EFI 1.0 can boot from any valid EFI image contained in a SimpleFileSystem
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (SimpleFileSystem)
+
+EFI_GUID gEfiSimpleFileSystemProtocolGuid = EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiSimpleFileSystemProtocolGuid, "Filesystem Protocol", "EFI 1.0 Simple FileSystem Protocol");
diff --git a/EDK/Foundation/Efi/Protocol/SimpleFileSystem/SimpleFileSystem.h b/EDK/Foundation/Efi/Protocol/SimpleFileSystem/SimpleFileSystem.h
new file mode 100644
index 0000000..a2ba456
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/SimpleFileSystem/SimpleFileSystem.h
@@ -0,0 +1,375 @@
+/*++
+
+Copyright (c) 2004 - 2008, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ SimpleFileSystem.h
+
+Abstract:
+
+ SimpleFileSystem protocol as defined in the EFI 1.0 specification.
+
+ The SimpleFileSystem protocol is the programatic access to the FAT (12,16,32)
+ file system specified in EFI 1.0. It can also be used to abstract a file
+ system other than FAT.
+
+ EFI 1.0 can boot from any valid EFI image contained in a SimpleFileSystem
+
+--*/
+
+#ifndef _SIMPLE_FILE_SYSTEM_H_
+#define _SIMPLE_FILE_SYSTEM_H_
+
+#define EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_GUID \
+ { \
+ 0x964e5b22, 0x6459, 0x11d2, 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b \
+ }
+
+EFI_FORWARD_DECLARATION (EFI_SIMPLE_FILE_SYSTEM_PROTOCOL);
+EFI_FORWARD_DECLARATION (EFI_FILE);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_VOLUME_OPEN) (
+ IN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL * This,
+ OUT EFI_FILE **Root
+ )
+/*++
+
+ Routine Description:
+ Open the root directory on a volume.
+
+ Arguments:
+ This - Protocol instance pointer.
+ Root - Returns an Open file handle for the root directory
+
+ Returns:
+ EFI_SUCCESS - The device was opened.
+ EFI_UNSUPPORTED - This volume does not suppor the file system.
+ EFI_NO_MEDIA - The device has no media.
+ EFI_DEVICE_ERROR - The device reported an error.
+ EFI_VOLUME_CORRUPTED - The file system structures are corrupted
+ EFI_ACCESS_DENIED - The service denied access to the file
+ EFI_OUT_OF_RESOURCES - The volume was not opened due to lack of resources
+
+--*/
+;
+
+#define EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_REVISION 0x00010000
+
+typedef struct _EFI_SIMPLE_FILE_SYSTEM_PROTOCOL {
+ UINT64 Revision;
+ EFI_VOLUME_OPEN OpenVolume;
+} EFI_SIMPLE_FILE_SYSTEM_PROTOCOL;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_FILE_OPEN) (
+ IN EFI_FILE * File,
+ OUT EFI_FILE **NewHandle,
+ IN CHAR16 *FileName,
+ IN UINT64 OpenMode,
+ IN UINT64 Attributes
+ )
+/*++
+
+ Routine Description:
+ Open the root directory on a volume.
+
+ Arguments:
+ File - Protocol instance pointer.
+ NewHandle - Returns File Handle for FileName
+ FileName - Null terminated string. "\", ".", and ".." are supported
+ OpenMode - Open mode for file.
+ Attributes - Only used for EFI_FILE_MODE_CREATE
+
+ Returns:
+ EFI_SUCCESS - The device was opened.
+ EFI_NOT_FOUND - The specified file could not be found on the device
+ EFI_NO_MEDIA - The device has no media.
+ EFI_MEDIA_CHANGED - The media has changed
+ EFI_DEVICE_ERROR - The device reported an error.
+ EFI_VOLUME_CORRUPTED - The file system structures are corrupted
+ EFI_ACCESS_DENIED - The service denied access to the file
+ EFI_OUT_OF_RESOURCES - The volume was not opened due to lack of resources
+ EFI_VOLUME_FULL - The volume is full.
+
+--*/
+;
+
+//
+// Open modes
+//
+#define EFI_FILE_MODE_READ 0x0000000000000001
+#define EFI_FILE_MODE_WRITE 0x0000000000000002
+#define EFI_FILE_MODE_CREATE 0x8000000000000000
+
+//
+// File attributes
+//
+#define EFI_FILE_READ_ONLY 0x0000000000000001
+#define EFI_FILE_HIDDEN 0x0000000000000002
+#define EFI_FILE_SYSTEM 0x0000000000000004
+#define EFI_FILE_RESERVED 0x0000000000000008
+#define EFI_FILE_DIRECTORY 0x0000000000000010
+#define EFI_FILE_ARCHIVE 0x0000000000000020
+#define EFI_FILE_VALID_ATTR 0x0000000000000037
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_FILE_CLOSE) (
+ IN EFI_FILE * File
+ )
+/*++
+
+ Routine Description:
+ Close the file handle
+
+ Arguments:
+ File - Protocol instance pointer.
+
+ Returns:
+ EFI_SUCCESS- The device was opened.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_FILE_DELETE) (
+ IN EFI_FILE * File
+ )
+/*++
+
+ Routine Description:
+ Close and delete the file handle
+
+ Arguments:
+ File - Protocol instance pointer.
+
+ Returns:
+ EFI_SUCCESS - The device was opened.
+ EFI_WARN_DELETE_FAILURE - The handle was closed but the file was not
+ deleted
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_FILE_READ) (
+ IN EFI_FILE * File,
+ IN OUT UINTN *BufferSize,
+ OUT VOID *Buffer
+ )
+/*++
+
+ Routine Description:
+ Read data from the file.
+
+ Arguments:
+ File - Protocol instance pointer.
+ BufferSize - On input size of buffer, on output amount of data in
+ buffer.
+ Buffer - The buffer in which data is read.
+
+ Returns:
+ EFI_SUCCESS - Data was read.
+ EFI_NO_MEDIA - The device has no media
+ EFI_DEVICE_ERROR - The device reported an error
+ EFI_VOLUME_CORRUPTED - The file system structures are corrupted
+ EFI_BUFFER_TO_SMALL - BufferSize is too small. BufferSize contains
+ required size
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_FILE_WRITE) (
+ IN EFI_FILE * File,
+ IN OUT UINTN *BufferSize,
+ IN VOID *Buffer
+ )
+/*++
+
+ Routine Description:
+ Write data from to the file.
+
+ Arguments:
+ File - Protocol instance pointer.
+ BufferSize - On input size of buffer, on output amount of data in buffer.
+ Buffer - The buffer in which data to write.
+
+ Returns:
+ EFI_SUCCESS - Data was written.
+ EFI_UNSUPPORT - Writes to Open directory are not supported
+ EFI_NO_MEDIA - The device has no media
+ EFI_DEVICE_ERROR - The device reported an error
+ EFI_VOLUME_CORRUPTED - The file system structures are corrupted
+ EFI_WRITE_PROTECTED - The device is write protected
+ EFI_ACCESS_DENIED - The file was open for read only
+ EFI_VOLUME_FULL - The volume is full
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_FILE_SET_POSITION) (
+ IN EFI_FILE * File,
+ IN UINT64 Position
+ )
+/*++
+
+ Routine Description:
+ Set a files current position
+
+ Arguments:
+ File - Protocol instance pointer.
+ Position - Byte possition from the start of the file
+
+ Returns:
+ EFI_SUCCESS - Data was written.
+ EFI_UNSUPPORTED - Seek request for non-zero is not valid on open.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_FILE_GET_POSITION) (
+ IN EFI_FILE * File,
+ OUT UINT64 *Position
+ )
+/*++
+
+ Routine Description:
+ Get a files current position
+
+ Arguments:
+ File - Protocol instance pointer.
+ Position - Byte possition from the start of the file
+
+ Returns:
+ EFI_SUCCESS - Data was written.
+ EFI_UNSUPPORTED - Seek request for non-zero is not valid on open.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_FILE_GET_INFO) (
+ IN EFI_FILE * File,
+ IN EFI_GUID * InformationType,
+ IN OUT UINTN *BufferSize,
+ OUT VOID *Buffer
+ )
+/*++
+
+ Routine Description:
+ Get information about a file
+
+ Arguments:
+ File - Protocol instance pointer.
+ InformationType - Type of info to return in Buffer
+ BufferSize - On input size of buffer, on output amount of data in
+ buffer.
+ Buffer - The buffer to return data.
+
+ Returns:
+ EFI_SUCCESS - Data was returned.
+ EFI_UNSUPPORT - InformationType is not supported
+ EFI_NO_MEDIA - The device has no media
+ EFI_DEVICE_ERROR - The device reported an error
+ EFI_VOLUME_CORRUPTED - The file system structures are corrupted
+ EFI_WRITE_PROTECTED - The device is write protected
+ EFI_ACCESS_DENIED - The file was open for read only
+ EFI_BUFFER_TOO_SMALL - Buffer was too small, required size returned in
+ BufferSize
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_FILE_SET_INFO) (
+ IN EFI_FILE * File,
+ IN EFI_GUID * InformationType,
+ IN UINTN BufferSize,
+ IN VOID *Buffer
+ )
+/*++
+
+ Routine Description:
+ Set information about a file
+
+ Arguments:
+ File - Protocol instance pointer.
+ InformationType - Type of info in Buffer
+ BufferSize - Size of buffer.
+ Buffer - The data to write.
+
+ Returns:
+ EFI_SUCCESS - Data was returned.
+ EFI_UNSUPPORT - InformationType is not supported
+ EFI_NO_MEDIA - The device has no media
+ EFI_DEVICE_ERROR - The device reported an error
+ EFI_VOLUME_CORRUPTED - The file system structures are corrupted
+ EFI_WRITE_PROTECTED - The device is write protected
+ EFI_ACCESS_DENIED - The file was open for read only
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_FILE_FLUSH) (
+ IN EFI_FILE * File
+ )
+/*++
+
+ Routine Description:
+ Flush data back for the file handle
+
+ Arguments:
+ File - Protocol instance pointer.
+
+ Returns:
+ EFI_SUCCESS - Data was written.
+ EFI_UNSUPPORT - Writes to Open directory are not supported
+ EFI_NO_MEDIA - The device has no media
+ EFI_DEVICE_ERROR - The device reported an error
+ EFI_VOLUME_CORRUPTED - The file system structures are corrupted
+ EFI_WRITE_PROTECTED - The device is write protected
+ EFI_ACCESS_DENIED - The file was open for read only
+ EFI_VOLUME_FULL - The volume is full
+
+--*/
+;
+
+#define EFI_FILE_HANDLE_REVISION 0x00010000
+typedef struct _EFI_FILE {
+ UINT64 Revision;
+ EFI_FILE_OPEN Open;
+ EFI_FILE_CLOSE Close;
+ EFI_FILE_DELETE Delete;
+ EFI_FILE_READ Read;
+ EFI_FILE_WRITE Write;
+ EFI_FILE_GET_POSITION GetPosition;
+ EFI_FILE_SET_POSITION SetPosition;
+ EFI_FILE_GET_INFO GetInfo;
+ EFI_FILE_SET_INFO SetInfo;
+ EFI_FILE_FLUSH Flush;
+} EFI_FILE, *EFI_FILE_HANDLE, EFI_FILE_PROTOCOL;
+
+extern EFI_GUID gEfiSimpleFileSystemProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/SimpleNetwork/SimpleNetwork.c b/EDK/Foundation/Efi/Protocol/SimpleNetwork/SimpleNetwork.c
new file mode 100644
index 0000000..74cb94d
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/SimpleNetwork/SimpleNetwork.c
@@ -0,0 +1,34 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ SimpleNetwork.c
+
+Abstract:
+
+ Simple Network protocol as defined in the EFI 1.0 specification.
+
+ Basic network device abstraction.
+
+ Rx - Received
+ Tx - Transmit
+ MCast - MultiCast
+ ...
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (SimpleNetwork)
+
+EFI_GUID gEfiSimpleNetworkProtocolGuid = EFI_SIMPLE_NETWORK_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiSimpleNetworkProtocolGuid, "Simple Network Protocol", "EFI 1.0 Simple Network Protocol");
diff --git a/EDK/Foundation/Efi/Protocol/SimpleNetwork/SimpleNetwork.h b/EDK/Foundation/Efi/Protocol/SimpleNetwork/SimpleNetwork.h
new file mode 100644
index 0000000..15b670e
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/SimpleNetwork/SimpleNetwork.h
@@ -0,0 +1,639 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ SimpleNetwork.h
+
+Abstract:
+
+ Simple Network protocol as defined in the EFI 1.0 specification.
+
+ Basic network device abstraction.
+
+ Rx - Received
+ Tx - Transmit
+ MCast - MultiCast
+ ...
+
+--*/
+
+#ifndef _SIMPLE_NETWORK_H_
+#define _SIMPLE_NETWORK_H_
+
+#define EFI_SIMPLE_NETWORK_PROTOCOL_GUID \
+ { \
+ 0xA19832B9, 0xAC25, 0x11D3, 0x9A, 0x2D, 0x00, 0x90, 0x27, 0x3F, 0xC1, 0x4D \
+ }
+
+EFI_FORWARD_DECLARATION (EFI_SIMPLE_NETWORK_PROTOCOL);
+
+//
+// Simple Network Protocol data structures
+//
+typedef struct {
+ //
+ // Total number of frames received. Includes frames with errors and
+ // dropped frames.
+ //
+ UINT64 RxTotalFrames;
+
+ //
+ // Number of valid frames received and copied into receive buffers.
+ //
+ UINT64 RxGoodFrames;
+
+ //
+ // Number of frames below the minimum length for the media.
+ // This would be <64 for ethernet.
+ //
+ UINT64 RxUndersizeFrames;
+
+ //
+ // Number of frames longer than the maxminum length for the
+ // media. This would be >1500 for ethernet.
+ //
+ UINT64 RxOversizeFrames;
+
+ //
+ // Valid frames that were dropped because receive buffers were full.
+ //
+ UINT64 RxDroppedFrames;
+
+ //
+ // Number of valid unicast frames received and not dropped.
+ //
+ UINT64 RxUnicastFrames;
+
+ //
+ // Number of valid broadcast frames received and not dropped.
+ //
+ UINT64 RxBroadcastFrames;
+
+ //
+ // Number of valid mutlicast frames received and not dropped.
+ //
+ UINT64 RxMulticastFrames;
+
+ //
+ // Number of frames w/ CRC or alignment errors.
+ //
+ UINT64 RxCrcErrorFrames;
+
+ //
+ // Total number of bytes received. Includes frames with errors
+ // and dropped frames.
+ //
+ UINT64 RxTotalBytes;
+
+ //
+ // Transmit statistics.
+ //
+ UINT64 TxTotalFrames;
+ UINT64 TxGoodFrames;
+ UINT64 TxUndersizeFrames;
+ UINT64 TxOversizeFrames;
+ UINT64 TxDroppedFrames;
+ UINT64 TxUnicastFrames;
+ UINT64 TxBroadcastFrames;
+ UINT64 TxMulticastFrames;
+ UINT64 TxCrcErrorFrames;
+ UINT64 TxTotalBytes;
+
+ //
+ // Number of collisions detection on this subnet.
+ //
+ UINT64 Collisions;
+
+ //
+ // Number of frames destined for unsupported protocol.
+ //
+ UINT64 UnsupportedProtocol;
+
+} EFI_NETWORK_STATISTICS;
+
+typedef enum {
+ EfiSimpleNetworkStopped,
+ EfiSimpleNetworkStarted,
+ EfiSimpleNetworkInitialized,
+ EfiSimpleNetworkMaxState
+} EFI_SIMPLE_NETWORK_STATE;
+
+#define EFI_SIMPLE_NETWORK_RECEIVE_UNICAST 0x01
+#define EFI_SIMPLE_NETWORK_RECEIVE_MULTICAST 0x02
+#define EFI_SIMPLE_NETWORK_RECEIVE_BROADCAST 0x04
+#define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS 0x08
+#define EFI_SIMPLE_NETWORK_RECEIVE_PROMISCUOUS_MULTICAST 0x10
+
+#define EFI_SIMPLE_NETWORK_RECEIVE_INTERRUPT 0x01
+#define EFI_SIMPLE_NETWORK_TRANSMIT_INTERRUPT 0x02
+#define EFI_SIMPLE_NETWORK_COMMAND_INTERRUPT 0x04
+#define EFI_SIMPLE_NETWORK_SOFTWARE_INTERRUPT 0x08
+
+#define MAX_MCAST_FILTER_CNT 16
+typedef struct {
+ UINT32 State;
+ UINT32 HwAddressSize;
+ UINT32 MediaHeaderSize;
+ UINT32 MaxPacketSize;
+ UINT32 NvRamSize;
+ UINT32 NvRamAccessSize;
+ UINT32 ReceiveFilterMask;
+ UINT32 ReceiveFilterSetting;
+ UINT32 MaxMCastFilterCount;
+ UINT32 MCastFilterCount;
+ EFI_MAC_ADDRESS MCastFilter[MAX_MCAST_FILTER_CNT];
+ EFI_MAC_ADDRESS CurrentAddress;
+ EFI_MAC_ADDRESS BroadcastAddress;
+ EFI_MAC_ADDRESS PermanentAddress;
+ UINT8 IfType;
+ BOOLEAN MacAddressChangeable;
+ BOOLEAN MultipleTxSupported;
+ BOOLEAN MediaPresentSupported;
+ BOOLEAN MediaPresent;
+} EFI_SIMPLE_NETWORK_MODE;
+
+//
+// Protocol Member Functions
+//
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SIMPLE_NETWORK_START) (
+ IN EFI_SIMPLE_NETWORK_PROTOCOL * This
+ )
+/*++
+
+ Routine Description:
+ Changes the state of a network interface from "stopped" to "started".
+
+ Arguments:
+ This - Protocol instance pointer.
+
+ Returns:
+ EFI_SUCCESS - The network interface was started.
+ EFI_ALREADY_STARTED - The network interface is already in the started state.
+ EFI_INVALID_PARAMETER - One or more of the parameters has an unsupported value.
+ EFI_DEVICE_ERROR - The command could not be sent to the network interface.
+ EFI_UNSUPPORTED - This function is not supported by the network interface.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SIMPLE_NETWORK_STOP) (
+ IN EFI_SIMPLE_NETWORK_PROTOCOL * This
+ )
+/*++
+
+ Routine Description:
+ Changes the state of a network interface from "started" to "stopped".
+
+ Arguments:
+ This - Protocol instance pointer.
+
+ Returns:
+ EFI_SUCCESS - The network interface was stopped.
+ EFI_ALREADY_STARTED - The network interface is already in the stopped state.
+ EFI_INVALID_PARAMETER - One or more of the parameters has an unsupported value.
+ EFI_DEVICE_ERROR - The command could not be sent to the network interface.
+ EFI_UNSUPPORTED - This function is not supported by the network interface.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SIMPLE_NETWORK_INITIALIZE) (
+ IN EFI_SIMPLE_NETWORK_PROTOCOL * This,
+ IN UINTN ExtraRxBufferSize OPTIONAL,
+ IN UINTN ExtraTxBufferSize OPTIONAL
+ )
+/*++
+
+ Routine Description:
+ Resets a network adapter and allocates the transmit and receive buffers
+ required by the network interface; optionally, also requests allocation
+ of additional transmit and receive buffers.
+
+ Arguments:
+ This - Protocol instance pointer.
+ ExtraRxBufferSize - The size, in bytes, of the extra receive buffer space
+ that the driver should allocate for the network interface.
+ Some network interfaces will not be able to use the extra
+ buffer, and the caller will not know if it is actually
+ being used.
+ ExtraTxBufferSize - The size, in bytes, of the extra transmit buffer space
+ that the driver should allocate for the network interface.
+ Some network interfaces will not be able to use the extra
+ buffer, and the caller will not know if it is actually
+ being used.
+
+ Returns:
+ EFI_SUCCESS - The network interface was initialized.
+ EFI_NOT_STARTED - The network interface has not been started
+ EFI_OUT_OF_RESOURCES - There was not enough memory for the transmit and
+ receive buffers. .
+ EFI_INVALID_PARAMETER - One or more of the parameters has an unsupported value.
+ EFI_DEVICE_ERROR - The command could not be sent to the network interface.
+ EFI_UNSUPPORTED - This function is not supported by the network interface.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SIMPLE_NETWORK_RESET) (
+ IN EFI_SIMPLE_NETWORK_PROTOCOL * This,
+ IN BOOLEAN ExtendedVerification
+ )
+/*++
+
+ Routine Description:
+ Resets a network adapter and re-initializes it with the parameters that were
+ provided in the previous call to Initialize().
+
+ Arguments:
+ This - Protocol instance pointer.
+ ExtendedVerification - Indicates that the driver may perform a more
+ exhaustive verification operation of the device
+ during reset.
+
+
+ Returns:
+ EFI_SUCCESS - The network interface was reset.
+ EFI_NOT_STARTED - The network interface has not been started
+ EFI_INVALID_PARAMETER - One or more of the parameters has an unsupported value.
+ EFI_DEVICE_ERROR - The command could not be sent to the network interface.
+ EFI_UNSUPPORTED - This function is not supported by the network interface.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SIMPLE_NETWORK_SHUTDOWN) (
+ IN EFI_SIMPLE_NETWORK_PROTOCOL * This
+ )
+/*++
+
+ Routine Description:
+ Resets a network adapter and leaves it in a state that is safe for
+ another driver to initialize.
+
+ Arguments:
+ This - Protocol instance pointer.
+
+ Returns:
+ EFI_SUCCESS - The network interface was shutdown.
+ EFI_NOT_STARTED - The network interface has not been started
+ EFI_INVALID_PARAMETER - One or more of the parameters has an unsupported value.
+ EFI_DEVICE_ERROR - The command could not be sent to the network interface.
+ EFI_UNSUPPORTED - This function is not supported by the network interface.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SIMPLE_NETWORK_RECEIVE_FILTERS) (
+ IN EFI_SIMPLE_NETWORK_PROTOCOL * This,
+ IN UINT32 Enable,
+ IN UINT32 Disable,
+ IN BOOLEAN ResetMCastFilter,
+ IN UINTN MCastFilterCnt OPTIONAL,
+ IN EFI_MAC_ADDRESS * MCastFilter OPTIONAL
+ )
+/*++
+
+ Routine Description:
+ Manages the multicast receive filters of a network interface.
+
+ Arguments:
+ This - Protocol instance pointer.
+ Enable - A bit mask of receive filters to enable on the network interface.
+ Disable - A bit mask of receive filters to disable on the network interface.
+ ResetMCastFilter - Set to TRUE to reset the contents of the multicast receive
+ filters on the network interface to their default values.
+ McastFilterCnt - Number of multicast HW MAC addresses in the new
+ MCastFilter list. This value must be less than or equal to
+ the MCastFilterCnt field of EFI_SIMPLE_NETWORK_MODE. This
+ field is optional if ResetMCastFilter is TRUE.
+ MCastFilter - A pointer to a list of new multicast receive filter HW MAC
+ addresses. This list will replace any existing multicast
+ HW MAC address list. This field is optional if
+ ResetMCastFilter is TRUE.
+
+ Returns:
+ EFI_SUCCESS - The multicast receive filter list was updated.
+ EFI_NOT_STARTED - The network interface has not been started
+ EFI_INVALID_PARAMETER - One or more of the parameters has an unsupported value.
+ EFI_DEVICE_ERROR - The command could not be sent to the network interface.
+ EFI_UNSUPPORTED - This function is not supported by the network interface.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SIMPLE_NETWORK_STATION_ADDRESS) (
+ IN EFI_SIMPLE_NETWORK_PROTOCOL * This,
+ IN BOOLEAN Reset,
+ IN EFI_MAC_ADDRESS * New OPTIONAL
+ )
+/*++
+
+ Routine Description:
+ Modifies or resets the current station address, if supported.
+
+ Arguments:
+ This - Protocol instance pointer.
+ Reset - Flag used to reset the station address to the network interfaces
+ permanent address.
+ New - New station address to be used for the network interface.
+
+ Returns:
+ EFI_SUCCESS - The network interfaces station address was updated.
+ EFI_NOT_STARTED - The network interface has not been started
+ EFI_INVALID_PARAMETER - One or more of the parameters has an unsupported value.
+ EFI_DEVICE_ERROR - The command could not be sent to the network interface.
+ EFI_UNSUPPORTED - This function is not supported by the network interface.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SIMPLE_NETWORK_STATISTICS) (
+ IN EFI_SIMPLE_NETWORK_PROTOCOL * This,
+ IN BOOLEAN Reset,
+ IN OUT UINTN *StatisticsSize OPTIONAL,
+ OUT EFI_NETWORK_STATISTICS * StatisticsTable OPTIONAL
+ )
+/*++
+
+ Routine Description:
+ Resets or collects the statistics on a network interface.
+
+ Arguments:
+ This - Protocol instance pointer.
+ Reset - Set to TRUE to reset the statistics for the network interface.
+ StatisticsSize - On input the size, in bytes, of StatisticsTable. On
+ output the size, in bytes, of the resulting table of
+ statistics.
+ StatisticsTable - A pointer to the EFI_NETWORK_STATISTICS structure that
+ contains the statistics.
+
+ Returns:
+ EFI_SUCCESS - The statistics were collected from the network interface.
+ EFI_NOT_STARTED - The network interface has not been started.
+ EFI_BUFFER_TOO_SMALL - The Statistics buffer was too small. The current buffer
+ size needed to hold the statistics is returned in
+ StatisticsSize.
+ EFI_INVALID_PARAMETER - One or more of the parameters has an unsupported value.
+ EFI_DEVICE_ERROR - The command could not be sent to the network interface.
+ EFI_UNSUPPORTED - This function is not supported by the network interface.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SIMPLE_NETWORK_MCAST_IP_TO_MAC) (
+ IN EFI_SIMPLE_NETWORK_PROTOCOL * This,
+ IN BOOLEAN IPv6,
+ IN EFI_IP_ADDRESS * IP,
+ OUT EFI_MAC_ADDRESS * MAC
+ )
+/*++
+
+ Routine Description:
+ Converts a multicast IP address to a multicast HW MAC address.
+
+ Arguments:
+ This - Protocol instance pointer.
+ IPv6 - Set to TRUE if the multicast IP address is IPv6 [RFC 2460]. Set
+ to FALSE if the multicast IP address is IPv4 [RFC 791].
+ IP - The multicast IP address that is to be converted to a multicast
+ HW MAC address.
+ MAC - The multicast HW MAC address that is to be generated from IP.
+
+ Returns:
+ EFI_SUCCESS - The multicast IP address was mapped to the multicast
+ HW MAC address.
+ EFI_NOT_STARTED - The network interface has not been started.
+ EFI_BUFFER_TOO_SMALL - The Statistics buffer was too small. The current buffer
+ size needed to hold the statistics is returned in
+ StatisticsSize.
+ EFI_INVALID_PARAMETER - One or more of the parameters has an unsupported value.
+ EFI_DEVICE_ERROR - The command could not be sent to the network interface.
+ EFI_UNSUPPORTED - This function is not supported by the network interface.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SIMPLE_NETWORK_NVDATA) (
+ IN EFI_SIMPLE_NETWORK_PROTOCOL * This,
+ IN BOOLEAN ReadWrite,
+ IN UINTN Offset,
+ IN UINTN BufferSize,
+ IN OUT VOID *Buffer
+ )
+/*++
+
+ Routine Description:
+ Performs read and write operations on the NVRAM device attached to a
+ network interface.
+
+ Arguments:
+ This - Protocol instance pointer.
+ ReadWrite - TRUE for read operations, FALSE for write operations.
+ Offset - Byte offset in the NVRAM device at which to start the read or
+ write operation. This must be a multiple of NvRamAccessSize and
+ less than NvRamSize.
+ BufferSize - The number of bytes to read or write from the NVRAM device.
+ This must also be a multiple of NvramAccessSize.
+ Buffer - A pointer to the data buffer.
+
+ Returns:
+ EFI_SUCCESS - The NVRAM access was performed.
+ EFI_NOT_STARTED - The network interface has not been started.
+ EFI_INVALID_PARAMETER - One or more of the parameters has an unsupported value.
+ EFI_DEVICE_ERROR - The command could not be sent to the network interface.
+ EFI_UNSUPPORTED - This function is not supported by the network interface.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SIMPLE_NETWORK_GET_STATUS) (
+ IN EFI_SIMPLE_NETWORK_PROTOCOL * This,
+ OUT UINT32 *InterruptStatus OPTIONAL,
+ OUT VOID **TxBuf OPTIONAL
+ )
+/*++
+
+ Routine Description:
+ Reads the current interrupt status and recycled transmit buffer status from
+ a network interface.
+
+ Arguments:
+ This - Protocol instance pointer.
+ InterruptStatus - A pointer to the bit mask of the currently active interrupts
+ If this is NULL, the interrupt status will not be read from
+ the device. If this is not NULL, the interrupt status will
+ be read from the device. When the interrupt status is read,
+ it will also be cleared. Clearing the transmit interrupt
+ does not empty the recycled transmit buffer array.
+ TxBuf - Recycled transmit buffer address. The network interface will
+ not transmit if its internal recycled transmit buffer array
+ is full. Reading the transmit buffer does not clear the
+ transmit interrupt. If this is NULL, then the transmit buffer
+ status will not be read. If there are no transmit buffers to
+ recycle and TxBuf is not NULL, * TxBuf will be set to NULL.
+
+ Returns:
+ EFI_SUCCESS - The status of the network interface was retrieved.
+ EFI_NOT_STARTED - The network interface has not been started.
+ EFI_INVALID_PARAMETER - One or more of the parameters has an unsupported value.
+ EFI_DEVICE_ERROR - The command could not be sent to the network interface.
+ EFI_UNSUPPORTED - This function is not supported by the network interface.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SIMPLE_NETWORK_TRANSMIT) (
+ IN EFI_SIMPLE_NETWORK_PROTOCOL * This,
+ IN UINTN HeaderSize,
+ IN UINTN BufferSize,
+ IN VOID *Buffer,
+ IN EFI_MAC_ADDRESS * SrcAddr OPTIONAL,
+ IN EFI_MAC_ADDRESS * DestAddr OPTIONAL,
+ IN UINT16 *Protocol OPTIONAL
+ )
+/*++
+
+ Routine Description:
+ Places a packet in the transmit queue of a network interface.
+
+ Arguments:
+ This - Protocol instance pointer.
+ HeaderSize - The size, in bytes, of the media header to be filled in by
+ the Transmit() function. If HeaderSize is non-zero, then it
+ must be equal to This->Mode->MediaHeaderSize and the DestAddr
+ and Protocol parameters must not be NULL.
+ BufferSize - The size, in bytes, of the entire packet (media header and
+ data) to be transmitted through the network interface.
+ Buffer - A pointer to the packet (media header followed by data) to be
+ transmitted. This parameter cannot be NULL. If HeaderSize is zero,
+ then the media header in Buffer must already be filled in by the
+ caller. If HeaderSize is non-zero, then the media header will be
+ filled in by the Transmit() function.
+ SrcAddr - The source HW MAC address. If HeaderSize is zero, then this parameter
+ is ignored. If HeaderSize is non-zero and SrcAddr is NULL, then
+ This->Mode->CurrentAddress is used for the source HW MAC address.
+ DsetAddr - The destination HW MAC address. If HeaderSize is zero, then this
+ parameter is ignored.
+ Protocol - The type of header to build. If HeaderSize is zero, then this
+ parameter is ignored. See RFC 1700, section "Ether Types", for
+ examples.
+
+ Returns:
+ EFI_SUCCESS - The packet was placed on the transmit queue.
+ EFI_NOT_STARTED - The network interface has not been started.
+ EFI_NOT_READY - The network interface is too busy to accept this transmit
+ request.
+ EFI_BUFFER_TOO_SMALL - The BufferSize parameter is too small.
+ EFI_INVALID_PARAMETER - One or more of the parameters has an unsupported value.
+ EFI_DEVICE_ERROR - The command could not be sent to the network interface.
+ EFI_UNSUPPORTED - This function is not supported by the network interface.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SIMPLE_NETWORK_RECEIVE) (
+ IN EFI_SIMPLE_NETWORK_PROTOCOL * This,
+ OUT UINTN *HeaderSize OPTIONAL,
+ IN OUT UINTN *BufferSize,
+ OUT VOID *Buffer,
+ OUT EFI_MAC_ADDRESS * SrcAddr OPTIONAL,
+ OUT EFI_MAC_ADDRESS * DestAddr OPTIONAL,
+ OUT UINT16 *Protocol OPTIONAL
+ )
+/*++
+
+ Routine Description:
+ Receives a packet from a network interface.
+
+ Arguments:
+ This - Protocol instance pointer.
+ HeaderSize - The size, in bytes, of the media header received on the network
+ interface. If this parameter is NULL, then the media header size
+ will not be returned.
+ BufferSize - On entry, the size, in bytes, of Buffer. On exit, the size, in
+ bytes, of the packet that was received on the network interface.
+ Buffer - A pointer to the data buffer to receive both the media header and
+ the data.
+ SrcAddr - The source HW MAC address. If this parameter is NULL, the
+ HW MAC source address will not be extracted from the media
+ header.
+ DsetAddr - The destination HW MAC address. If this parameter is NULL,
+ the HW MAC destination address will not be extracted from the
+ media header.
+ Protocol - The media header type. If this parameter is NULL, then the
+ protocol will not be extracted from the media header. See
+ RFC 1700 section "Ether Types" for examples.
+
+ Returns:
+ EFI_SUCCESS - The received data was stored in Buffer, and BufferSize has
+ been updated to the number of bytes received.
+ EFI_NOT_STARTED - The network interface has not been started.
+ EFI_NOT_READY - The network interface is too busy to accept this transmit
+ request.
+ EFI_BUFFER_TOO_SMALL - The BufferSize parameter is too small.
+ EFI_INVALID_PARAMETER - One or more of the parameters has an unsupported value.
+ EFI_DEVICE_ERROR - The command could not be sent to the network interface.
+ EFI_UNSUPPORTED - This function is not supported by the network interface.
+
+--*/
+;
+
+#define EFI_SIMPLE_NETWORK_PROTOCOL_REVISION 0x00010000
+
+typedef struct _EFI_SIMPLE_NETWORK_PROTOCOL {
+ UINT64 Revision;
+ EFI_SIMPLE_NETWORK_START Start;
+ EFI_SIMPLE_NETWORK_STOP Stop;
+ EFI_SIMPLE_NETWORK_INITIALIZE Initialize;
+ EFI_SIMPLE_NETWORK_RESET Reset;
+ EFI_SIMPLE_NETWORK_SHUTDOWN Shutdown;
+ EFI_SIMPLE_NETWORK_RECEIVE_FILTERS ReceiveFilters;
+ EFI_SIMPLE_NETWORK_STATION_ADDRESS StationAddress;
+ EFI_SIMPLE_NETWORK_STATISTICS Statistics;
+ EFI_SIMPLE_NETWORK_MCAST_IP_TO_MAC MCastIpToMac;
+ EFI_SIMPLE_NETWORK_NVDATA NvData;
+ EFI_SIMPLE_NETWORK_GET_STATUS GetStatus;
+ EFI_SIMPLE_NETWORK_TRANSMIT Transmit;
+ EFI_SIMPLE_NETWORK_RECEIVE Receive;
+ EFI_EVENT WaitForPacket;
+ EFI_SIMPLE_NETWORK_MODE *Mode;
+} EFI_SIMPLE_NETWORK_PROTOCOL;
+
+extern EFI_GUID gEfiSimpleNetworkProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/SimplePointer/SimplePointer.c b/EDK/Foundation/Efi/Protocol/SimplePointer/SimplePointer.c
new file mode 100644
index 0000000..5b3171d
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/SimplePointer/SimplePointer.c
@@ -0,0 +1,29 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ SimplePointer.c
+
+Abstract:
+
+ Simple Pointer protocol from the EFI 1.1 specification.
+
+ Abstraction of a very simple pointer device like a mice or trackballs.
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (SimplePointer)
+
+EFI_GUID gEfiSimplePointerProtocolGuid = EFI_SIMPLE_POINTER_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiSimplePointerProtocolGuid, "Simple Pointer Protocol", "EFI 1.1 Simple Pointer Protocol");
diff --git a/EDK/Foundation/Efi/Protocol/SimplePointer/SimplePointer.h b/EDK/Foundation/Efi/Protocol/SimplePointer/SimplePointer.h
new file mode 100644
index 0000000..aaa9c4b
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/SimplePointer/SimplePointer.h
@@ -0,0 +1,76 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ SimplePointer.h
+
+Abstract:
+
+ Simple Pointer protocol from the EFI 1.1 specification.
+
+ Abstraction of a very simple pointer device like a mice or tracekballs.
+
+--*/
+
+#ifndef _SIMPLE_POINTER_H_
+#define _SIMPLE_POINTER_H_
+
+#define EFI_SIMPLE_POINTER_PROTOCOL_GUID \
+ { \
+ 0x31878c87, 0xb75, 0x11d5, 0x9a, 0x4f, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d \
+ }
+
+EFI_FORWARD_DECLARATION (EFI_SIMPLE_POINTER_PROTOCOL);
+
+//
+// Data structures
+//
+typedef struct {
+ INT32 RelativeMovementX;
+ INT32 RelativeMovementY;
+ INT32 RelativeMovementZ;
+ BOOLEAN LeftButton;
+ BOOLEAN RightButton;
+} EFI_SIMPLE_POINTER_STATE;
+
+typedef struct {
+ UINT64 ResolutionX;
+ UINT64 ResolutionY;
+ UINT64 ResolutionZ;
+ BOOLEAN LeftButton;
+ BOOLEAN RightButton;
+} EFI_SIMPLE_POINTER_MODE;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SIMPLE_POINTER_RESET) (
+ IN EFI_SIMPLE_POINTER_PROTOCOL * This,
+ IN BOOLEAN ExtendedVerification
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SIMPLE_POINTER_GET_STATE) (
+ IN EFI_SIMPLE_POINTER_PROTOCOL * This,
+ IN OUT EFI_SIMPLE_POINTER_STATE * State
+ );
+
+typedef struct _EFI_SIMPLE_POINTER_PROTOCOL {
+ EFI_SIMPLE_POINTER_RESET Reset;
+ EFI_SIMPLE_POINTER_GET_STATE GetState;
+ EFI_EVENT WaitForInput;
+ EFI_SIMPLE_POINTER_MODE *Mode;
+} EFI_SIMPLE_POINTER_PROTOCOL;
+
+extern EFI_GUID gEfiSimplePointerProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/SimpleTextIn/SimpleTextIn.c b/EDK/Foundation/Efi/Protocol/SimpleTextIn/SimpleTextIn.c
new file mode 100644
index 0000000..56f24f6
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/SimpleTextIn/SimpleTextIn.c
@@ -0,0 +1,30 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ SimpleTextIn.c
+
+Abstract:
+
+ Simple Text In protocol from the EFI 1.0 specification.
+
+ Abstraction of a very simple input device like a keyboard or serial
+ terminal.
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (SimpleTextIn)
+
+EFI_GUID gEfiSimpleTextInProtocolGuid = EFI_SIMPLE_TEXT_IN_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiSimpleTextInProtocolGuid, "Simple Text In Protocol", "EFI 1.0 Simple Text In Protocol");
diff --git a/EDK/Foundation/Efi/Protocol/SimpleTextIn/SimpleTextIn.h b/EDK/Foundation/Efi/Protocol/SimpleTextIn/SimpleTextIn.h
new file mode 100644
index 0000000..6a514de
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/SimpleTextIn/SimpleTextIn.h
@@ -0,0 +1,136 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ SimpleTextIn.h
+
+Abstract:
+
+ Simple Text In protocol from the EFI 1.0 specification.
+
+ Abstraction of a very simple input device like a keyboard or serial
+ terminal.
+
+--*/
+
+#ifndef _SIMPLE_TEXT_IN_H_
+#define _SIMPLE_TEXT_IN_H_
+
+#define EFI_SIMPLE_TEXT_IN_PROTOCOL_GUID \
+ { \
+ 0x387477c1, 0x69c7, 0x11d2, 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b \
+ }
+
+EFI_FORWARD_DECLARATION (EFI_SIMPLE_TEXT_IN_PROTOCOL);
+
+//
+// Data structures
+//
+typedef struct {
+ UINT16 ScanCode;
+ CHAR16 UnicodeChar;
+} EFI_INPUT_KEY;
+
+//
+// Required unicode control chars
+//
+#define CHAR_NULL 0x0000
+#define CHAR_BACKSPACE 0x0008
+#define CHAR_TAB 0x0009
+#define CHAR_LINEFEED 0x000A
+#define CHAR_CARRIAGE_RETURN 0x000D
+
+//
+// EFI Scan codes
+//
+#define SCAN_NULL 0x0000
+#define SCAN_UP 0x0001
+#define SCAN_DOWN 0x0002
+#define SCAN_RIGHT 0x0003
+#define SCAN_LEFT 0x0004
+#define SCAN_HOME 0x0005
+#define SCAN_END 0x0006
+#define SCAN_INSERT 0x0007
+#define SCAN_DELETE 0x0008
+#define SCAN_PAGE_UP 0x0009
+#define SCAN_PAGE_DOWN 0x000A
+#define SCAN_F1 0x000B
+#define SCAN_F2 0x000C
+#define SCAN_F3 0x000D
+#define SCAN_F4 0x000E
+#define SCAN_F5 0x000F
+#define SCAN_F6 0x0010
+#define SCAN_F7 0x0011
+#define SCAN_F8 0x0012
+#define SCAN_F9 0x0013
+#define SCAN_F10 0x0014
+#define SCAN_F11 0x0015
+#define SCAN_F12 0x0016
+#define SCAN_ESC 0x0017
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_INPUT_RESET) (
+ IN EFI_SIMPLE_TEXT_IN_PROTOCOL * This,
+ IN BOOLEAN ExtendedVerification
+ )
+/*++
+
+ Routine Description:
+ Reset the input device and optionaly run diagnostics
+
+ Arguments:
+ This - Protocol instance pointer.
+ ExtendedVerification - Driver may perform diagnostics on reset.
+
+ Returns:
+ EFI_SUCCESS - The device was reset.
+ EFI_DEVICE_ERROR - The device is not functioning properly and could
+ not be reset.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_INPUT_READ_KEY) (
+ IN EFI_SIMPLE_TEXT_IN_PROTOCOL * This,
+ OUT EFI_INPUT_KEY * Key
+ )
+/*++
+
+ Routine Description:
+ Reads the next keystroke from the input device. The WaitForKey Event can
+ be used to test for existance of a keystroke via WaitForEvent () call.
+
+ Arguments:
+ This - Protocol instance pointer.
+ Key - Driver may perform diagnostics on reset.
+
+ Returns:
+ EFI_SUCCESS - The keystroke information was returned.
+ EFI_NOT_READY - There was no keystroke data availiable.
+ EFI_DEVICE_ERROR - The keydtroke information was not returned due to
+ hardware errors.
+
+--*/
+;
+
+typedef struct _EFI_SIMPLE_TEXT_IN_PROTOCOL {
+ EFI_INPUT_RESET Reset;
+ EFI_INPUT_READ_KEY ReadKeyStroke;
+ EFI_EVENT WaitForKey;
+} EFI_SIMPLE_TEXT_IN_PROTOCOL;
+
+extern EFI_GUID gEfiSimpleTextInProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/SimpleTextInputEx/SimpleTextInputEx.c b/EDK/Foundation/Efi/Protocol/SimpleTextInputEx/SimpleTextInputEx.c
new file mode 100644
index 0000000..3a40e77
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/SimpleTextInputEx/SimpleTextInputEx.c
@@ -0,0 +1,31 @@
+/*++
+
+Copyright (c) 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ SimpleTextInputEx.c
+
+Abstract:
+
+ EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL from the UEFI 2.1 specification.
+
+ This protocol defines an extension to the EFI_SIMPLE_TEXT_INPUT_PROTOCOL
+ which exposes much more state and modifier information from the input device,
+ also allows one to register a notification for a particular keystroke.
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (SimpleTextInputEx)
+
+EFI_GUID gEfiSimpleTextInputExProtocolGuid = EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiSimpleTextInputExProtocolGuid, "Simple Text Input Ex Protocol", "UEFI 2.1 Simple Text Input Ex Protocol");
diff --git a/EDK/Foundation/Efi/Protocol/SimpleTextInputEx/SimpleTextInputEx.h b/EDK/Foundation/Efi/Protocol/SimpleTextInputEx/SimpleTextInputEx.h
new file mode 100644
index 0000000..4a04f9c
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/SimpleTextInputEx/SimpleTextInputEx.h
@@ -0,0 +1,255 @@
+/*++
+
+Copyright (c) 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ SimpleTextInputEx.h
+
+Abstract:
+
+ EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL from the UEFI 2.1 specification.
+
+ This protocol defines an extension to the EFI_SIMPLE_TEXT_INPUT_PROTOCOL
+ which exposes much more state and modifier information from the input device,
+ also allows one to register a notification for a particular keystroke.
+
+--*/
+
+#ifndef __SIMPLE_TEXT_INPUT_EX_H__
+#define __SIMPLE_TEXT_INPUT_EX_H__
+
+#include EFI_PROTOCOL_DEFINITION (SimpleTextIn)
+
+#define EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL_GUID \
+ { \
+ 0xdd9e7534, 0x7762, 0x4698, 0x8c, 0x14, 0xf5, 0x85, 0x17, 0xa6, 0x25, 0xaa\
+ }
+
+EFI_FORWARD_DECLARATION (EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL);
+
+//
+// Data structures
+//
+
+typedef UINT8 EFI_KEY_TOGGLE_STATE;
+//
+// Any Shift or Toggle State that is valid should have
+// high order bit set.
+//
+typedef struct EFI_KEY_STATE {
+ UINT32 KeyShiftState;
+ EFI_KEY_TOGGLE_STATE KeyToggleState;
+} EFI_KEY_STATE;
+
+typedef struct {
+ EFI_INPUT_KEY Key;
+ EFI_KEY_STATE KeyState;
+} EFI_KEY_DATA;
+
+//
+// Shift state
+//
+#define EFI_SHIFT_STATE_VALID 0x80000000
+#define EFI_RIGHT_SHIFT_PRESSED 0x00000001
+#define EFI_LEFT_SHIFT_PRESSED 0x00000002
+#define EFI_RIGHT_CONTROL_PRESSED 0x00000004
+#define EFI_LEFT_CONTROL_PRESSED 0x00000008
+#define EFI_RIGHT_ALT_PRESSED 0x00000010
+#define EFI_LEFT_ALT_PRESSED 0x00000020
+#define EFI_RIGHT_LOGO_PRESSED 0x00000040
+#define EFI_LEFT_LOGO_PRESSED 0x00000080
+#define EFI_MENU_KEY_PRESSED 0x00000100
+#define EFI_SYS_REQ_PRESSED 0x00000200
+
+//
+// Toggle state
+//
+#define EFI_TOGGLE_STATE_VALID 0x80
+#define EFI_SCROLL_LOCK_ACTIVE 0x01
+#define EFI_NUM_LOCK_ACTIVE 0x02
+#define EFI_CAPS_LOCK_ACTIVE 0x04
+
+//
+// EFI Scan codes
+//
+#define SCAN_F13 0x0068
+#define SCAN_F14 0x0069
+#define SCAN_F15 0x006A
+#define SCAN_F16 0x006B
+#define SCAN_F17 0x006C
+#define SCAN_F18 0x006D
+#define SCAN_F19 0x006E
+#define SCAN_F20 0x006F
+#define SCAN_F21 0x0070
+#define SCAN_F22 0x0071
+#define SCAN_F23 0x0072
+#define SCAN_F24 0x0073
+#define SCAN_MUTE 0x007F
+#define SCAN_VOLUME_UP 0x0080
+#define SCAN_VOLUME_DOWN 0x0081
+#define SCAN_BRIGHTNESS_UP 0x0100
+#define SCAN_BRIGHTNESS_DOWN 0x0101
+#define SCAN_SUSPEND 0x0102
+#define SCAN_HIBERNATE 0x0103
+#define SCAN_TOGGLE_DISPLAY 0x0104
+#define SCAN_RECOVERY 0x0105
+#define SCAN_EJECT 0x0106
+
+
+//
+// EFI Key Notfication Function
+//
+typedef
+EFI_STATUS
+(EFIAPI *EFI_KEY_NOTIFY_FUNCTION) (
+ IN EFI_KEY_DATA *KeyData
+ )
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_INPUT_RESET_EX) (
+ IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
+ IN BOOLEAN ExtendedVerification
+ )
+/*++
+
+ Routine Description:
+ Reset the input device and optionaly run diagnostics
+
+ Arguments:
+ This - Protocol instance pointer.
+ ExtendedVerification - Driver may perform diagnostics on reset.
+
+ Returns:
+ EFI_SUCCESS - The device was reset.
+ EFI_DEVICE_ERROR - The device is not functioning properly and could
+ not be reset.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_INPUT_READ_KEY_EX) (
+ IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
+ OUT EFI_KEY_DATA *KeyData
+ )
+/*++
+
+ Routine Description:
+ Reads the next keystroke from the input device. The WaitForKey Event can
+ be used to test for existance of a keystroke via WaitForEvent () call.
+
+ Arguments:
+ This - Protocol instance pointer.
+ KeyData - A pointer to a buffer that is filled in with the keystroke
+ state data for the key that was pressed.
+
+ Returns:
+ EFI_SUCCESS - The keystroke information was returned.
+ EFI_NOT_READY - There was no keystroke data availiable.
+ EFI_DEVICE_ERROR - The keystroke information was not returned due to
+ hardware errors.
+ EFI_INVALID_PARAMETER - KeyData is NULL.
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SET_STATE) (
+ IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
+ IN EFI_KEY_TOGGLE_STATE *KeyToggleState
+ )
+/*++
+
+ Routine Description:
+ Set certain state for the input device.
+
+ Arguments:
+ This - Protocol instance pointer.
+ KeyToggleState - A pointer to the EFI_KEY_TOGGLE_STATE to set the
+ state for the input device.
+
+ Returns:
+ EFI_SUCCESS - The device state was set successfully.
+ EFI_DEVICE_ERROR - The device is not functioning correctly and could
+ not have the setting adjusted.
+ EFI_UNSUPPORTED - The device does not have the ability to set its state.
+ EFI_INVALID_PARAMETER - KeyToggleState is NULL.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_REGISTER_KEYSTROKE_NOTIFY) (
+ IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
+ IN EFI_KEY_DATA *KeyData,
+ IN EFI_KEY_NOTIFY_FUNCTION KeyNotificationFunction,
+ OUT EFI_HANDLE *NotifyHandle
+ )
+/*++
+
+ Routine Description:
+ Register a notification function for a particular keystroke for the input device.
+
+ Arguments:
+ This - Protocol instance pointer.
+ KeyData - A pointer to a buffer that is filled in with the keystroke
+ information data for the key that was pressed.
+ KeyNotificationFunction - Points to the function to be called when the key
+ sequence is typed specified by KeyData.
+ NotifyHandle - Points to the unique handle assigned to the registered notification.
+
+ Returns:
+ EFI_SUCCESS - The notification function was registered successfully.
+ EFI_OUT_OF_RESOURCES - Unable to allocate resources for necesssary data structures.
+ EFI_INVALID_PARAMETER - KeyData or NotifyHandle is NULL.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_UNREGISTER_KEYSTROKE_NOTIFY) (
+ IN EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL *This,
+ IN EFI_HANDLE NotificationHandle
+ )
+/*++
+
+ Routine Description:
+ Remove a registered notification function from a particular keystroke.
+
+ Arguments:
+ This - Protocol instance pointer.
+ NotificationHandle - The handle of the notification function being unregistered.
+
+ Returns:
+ EFI_SUCCESS - The notification function was unregistered successfully.
+ EFI_INVALID_PARAMETER - The NotificationHandle is invalid.
+ EFI_NOT_FOUND - Can not find the matching entry in database.
+
+--*/
+;
+
+typedef struct _EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL {
+ EFI_INPUT_RESET_EX Reset;
+ EFI_INPUT_READ_KEY_EX ReadKeyStrokeEx;
+ EFI_EVENT WaitForKeyEx;
+ EFI_SET_STATE SetState;
+ EFI_REGISTER_KEYSTROKE_NOTIFY RegisterKeyNotify;
+ EFI_UNREGISTER_KEYSTROKE_NOTIFY UnregisterKeyNotify;
+} EFI_SIMPLE_TEXT_INPUT_EX_PROTOCOL;
+
+extern EFI_GUID gEfiSimpleTextInputExProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/SimpleTextOut/SimpleTextOut.c b/EDK/Foundation/Efi/Protocol/SimpleTextOut/SimpleTextOut.c
new file mode 100644
index 0000000..cb8b929
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/SimpleTextOut/SimpleTextOut.c
@@ -0,0 +1,30 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ SimpleTextOut.c
+
+Abstract:
+
+ Simple Text Out protocol from the EFI 1.0 specification.
+
+ Abstraction of a very simple text based output device like VGA text mode or
+ a serial terminal.
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (SimpleTextOut)
+
+EFI_GUID gEfiSimpleTextOutProtocolGuid = EFI_SIMPLE_TEXT_OUT_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiSimpleTextOutProtocolGuid, "Simple Text Out Protocol", "EFI 1.0 Simple Text Out Protocol");
diff --git a/EDK/Foundation/Efi/Protocol/SimpleTextOut/SimpleTextOut.h b/EDK/Foundation/Efi/Protocol/SimpleTextOut/SimpleTextOut.h
new file mode 100644
index 0000000..012eef6
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/SimpleTextOut/SimpleTextOut.h
@@ -0,0 +1,423 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ SimpleTextOut.h
+
+Abstract:
+
+ Simple Text Out protocol from the EFI 1.0 specification.
+
+ Abstraction of a very simple text based output device like VGA text mode or
+ a serial terminal. The Simple Text Out protocol instance can represent
+ a single hardware device or a virtual device that is an agregation
+ of multiple physical devices.
+
+--*/
+
+#ifndef _SIMPLE_TEXT_OUT_H_
+#define _SIMPLE_TEXT_OUT_H_
+
+#define EFI_SIMPLE_TEXT_OUT_PROTOCOL_GUID \
+ { \
+ 0x387477c2, 0x69c7, 0x11d2, 0x8e, 0x39, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b \
+ }
+
+EFI_FORWARD_DECLARATION (EFI_SIMPLE_TEXT_OUT_PROTOCOL);
+
+//
+// Define's for required EFI Unicode Box Draw characters
+//
+#define BOXDRAW_HORIZONTAL 0x2500
+#define BOXDRAW_VERTICAL 0x2502
+#define BOXDRAW_DOWN_RIGHT 0x250c
+#define BOXDRAW_DOWN_LEFT 0x2510
+#define BOXDRAW_UP_RIGHT 0x2514
+#define BOXDRAW_UP_LEFT 0x2518
+#define BOXDRAW_VERTICAL_RIGHT 0x251c
+#define BOXDRAW_VERTICAL_LEFT 0x2524
+#define BOXDRAW_DOWN_HORIZONTAL 0x252c
+#define BOXDRAW_UP_HORIZONTAL 0x2534
+#define BOXDRAW_VERTICAL_HORIZONTAL 0x253c
+#define BOXDRAW_DOUBLE_HORIZONTAL 0x2550
+#define BOXDRAW_DOUBLE_VERTICAL 0x2551
+#define BOXDRAW_DOWN_RIGHT_DOUBLE 0x2552
+#define BOXDRAW_DOWN_DOUBLE_RIGHT 0x2553
+#define BOXDRAW_DOUBLE_DOWN_RIGHT 0x2554
+#define BOXDRAW_DOWN_LEFT_DOUBLE 0x2555
+#define BOXDRAW_DOWN_DOUBLE_LEFT 0x2556
+#define BOXDRAW_DOUBLE_DOWN_LEFT 0x2557
+#define BOXDRAW_UP_RIGHT_DOUBLE 0x2558
+#define BOXDRAW_UP_DOUBLE_RIGHT 0x2559
+#define BOXDRAW_DOUBLE_UP_RIGHT 0x255a
+#define BOXDRAW_UP_LEFT_DOUBLE 0x255b
+#define BOXDRAW_UP_DOUBLE_LEFT 0x255c
+#define BOXDRAW_DOUBLE_UP_LEFT 0x255d
+#define BOXDRAW_VERTICAL_RIGHT_DOUBLE 0x255e
+#define BOXDRAW_VERTICAL_DOUBLE_RIGHT 0x255f
+#define BOXDRAW_DOUBLE_VERTICAL_RIGHT 0x2560
+#define BOXDRAW_VERTICAL_LEFT_DOUBLE 0x2561
+#define BOXDRAW_VERTICAL_DOUBLE_LEFT 0x2562
+#define BOXDRAW_DOUBLE_VERTICAL_LEFT 0x2563
+#define BOXDRAW_DOWN_HORIZONTAL_DOUBLE 0x2564
+#define BOXDRAW_DOWN_DOUBLE_HORIZONTAL 0x2565
+#define BOXDRAW_DOUBLE_DOWN_HORIZONTAL 0x2566
+#define BOXDRAW_UP_HORIZONTAL_DOUBLE 0x2567
+#define BOXDRAW_UP_DOUBLE_HORIZONTAL 0x2568
+#define BOXDRAW_DOUBLE_UP_HORIZONTAL 0x2569
+#define BOXDRAW_VERTICAL_HORIZONTAL_DOUBLE 0x256a
+#define BOXDRAW_VERTICAL_DOUBLE_HORIZONTAL 0x256b
+#define BOXDRAW_DOUBLE_VERTICAL_HORIZONTAL 0x256c
+
+//
+// EFI Required Block Elements Code Chart
+//
+#define BLOCKELEMENT_FULL_BLOCK 0x2588
+#define BLOCKELEMENT_LIGHT_SHADE 0x2591
+
+//
+// EFI Required Geometric Shapes Code Chart
+//
+#define GEOMETRICSHAPE_UP_TRIANGLE 0x25b2
+#define GEOMETRICSHAPE_RIGHT_TRIANGLE 0x25ba
+#define GEOMETRICSHAPE_DOWN_TRIANGLE 0x25bc
+#define GEOMETRICSHAPE_LEFT_TRIANGLE 0x25c4
+
+//
+// EFI Required Arrow shapes
+//
+#define ARROW_LEFT 0x2190
+#define ARROW_UP 0x2191
+#define ARROW_RIGHT 0x2192
+#define ARROW_DOWN 0x2193
+
+//
+// EFI Console Colours
+//
+#define EFI_BLACK 0x00
+#define EFI_BLUE 0x01
+#define EFI_GREEN 0x02
+#define EFI_CYAN (EFI_BLUE | EFI_GREEN)
+#define EFI_RED 0x04
+#define EFI_MAGENTA (EFI_BLUE | EFI_RED)
+#define EFI_BROWN (EFI_GREEN | EFI_RED)
+#define EFI_LIGHTGRAY (EFI_BLUE | EFI_GREEN | EFI_RED)
+#define EFI_BRIGHT 0x08
+#define EFI_DARKGRAY (EFI_BRIGHT)
+#define EFI_LIGHTBLUE (EFI_BLUE | EFI_BRIGHT)
+#define EFI_LIGHTGREEN (EFI_GREEN | EFI_BRIGHT)
+#define EFI_LIGHTCYAN (EFI_CYAN | EFI_BRIGHT)
+#define EFI_LIGHTRED (EFI_RED | EFI_BRIGHT)
+#define EFI_LIGHTMAGENTA (EFI_MAGENTA | EFI_BRIGHT)
+#define EFI_YELLOW (EFI_BROWN | EFI_BRIGHT)
+#define EFI_WHITE (EFI_BLUE | EFI_GREEN | EFI_RED | EFI_BRIGHT)
+
+#define EFI_TEXT_ATTR(f, b) ((f) | ((b) << 4))
+
+#define EFI_BACKGROUND_BLACK 0x00
+#define EFI_BACKGROUND_BLUE 0x10
+#define EFI_BACKGROUND_GREEN 0x20
+#define EFI_BACKGROUND_CYAN (EFI_BACKGROUND_BLUE | EFI_BACKGROUND_GREEN)
+#define EFI_BACKGROUND_RED 0x40
+#define EFI_BACKGROUND_MAGENTA (EFI_BACKGROUND_BLUE | EFI_BACKGROUND_RED)
+#define EFI_BACKGROUND_BROWN (EFI_BACKGROUND_GREEN | EFI_BACKGROUND_RED)
+#define EFI_BACKGROUND_LIGHTGRAY (EFI_BACKGROUND_BLUE | EFI_BACKGROUND_GREEN | EFI_BACKGROUND_RED)
+
+//
+// We currently define attributes from 0 - 7F for color manipulations
+// To internally handle the local display characteristics for a particular character, we are defining
+// Bit 7 to signify the local glyph representation for a character. If turned on, glyphs will be
+// pulled from the wide glyph database and will display locally as a wide character (16 X 19 versus 8 X 19)
+// If bit 7 is off, the narrow glyph database will be used. This does NOT affect information that is sent to
+// non-local displays (e.g. serial or LAN consoles).
+//
+#define EFI_WIDE_ATTRIBUTE 0x80
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TEXT_RESET) (
+ IN EFI_SIMPLE_TEXT_OUT_PROTOCOL * This,
+ IN BOOLEAN ExtendedVerification
+ )
+/*++
+
+ Routine Description:
+ Reset the text output device hardware and optionaly run diagnostics
+
+ Arguments:
+ This - Protocol instance pointer.
+ ExtendedVerification - Driver may perform more exhaustive verfication
+ operation of the device during reset.
+
+ Returns:
+ EFI_SUCCESS - The text output device was reset.
+ EFI_DEVICE_ERROR - The text output device is not functioning correctly and
+ could not be reset.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TEXT_OUTPUT_STRING) (
+ IN EFI_SIMPLE_TEXT_OUT_PROTOCOL * This,
+ IN CHAR16 *String
+ )
+/*++
+
+ Routine Description:
+ Write a Unicode string to the output device.
+
+ Arguments:
+ This - Protocol instance pointer.
+ String - The NULL-terminated Unicode string to be displayed on the output
+ device(s). All output devices must also support the Unicode
+ drawing defined in this file.
+
+ Returns:
+ EFI_SUCCESS - The string was output to the device.
+ EFI_DEVICE_ERROR - The device reported an error while attempting to output
+ the text.
+ EFI_UNSUPPORTED - The output device's mode is not currently in a
+ defined text mode.
+ EFI_WARN_UNKNOWN_GLYPH - This warning code indicates that some of the
+ characters in the Unicode string could not be
+ rendered and were skipped.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TEXT_TEST_STRING) (
+ IN EFI_SIMPLE_TEXT_OUT_PROTOCOL * This,
+ IN CHAR16 *String
+ )
+/*++
+
+ Routine Description:
+ Verifies that all characters in a Unicode string can be output to the
+ target device.
+
+ Arguments:
+ This - Protocol instance pointer.
+ String - The NULL-terminated Unicode string to be examined for the output
+ device(s).
+
+ Returns:
+ EFI_SUCCESS - The device(s) are capable of rendering the output string.
+ EFI_UNSUPPORTED - Some of the characters in the Unicode string cannot be
+ rendered by one or more of the output devices mapped
+ by the EFI handle.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TEXT_QUERY_MODE) (
+ IN EFI_SIMPLE_TEXT_OUT_PROTOCOL * This,
+ IN UINTN ModeNumber,
+ OUT UINTN *Columns,
+ OUT UINTN *Rows
+ )
+/*++
+
+ Routine Description:
+ Returns information for an available text mode that the output device(s)
+ supports.
+
+ Arguments:
+ This - Protocol instance pointer.
+ ModeNumber - The mode number to return information on.
+ Columns, Rows - Returns the geometry of the text output device for the
+ requested ModeNumber.
+
+ Returns:
+ EFI_SUCCESS - The requested mode information was returned.
+ EFI_DEVICE_ERROR - The device had an error and could not complete the request.
+ EFI_UNSUPPORTED - The mode number was not valid.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TEXT_SET_MODE) (
+ IN EFI_SIMPLE_TEXT_OUT_PROTOCOL * This,
+ IN UINTN ModeNumber
+ )
+/*++
+
+ Routine Description:
+ Sets the output device(s) to a specified mode.
+
+ Arguments:
+ This - Protocol instance pointer.
+ ModeNumber - The mode number to set.
+
+ Returns:
+ EFI_SUCCESS - The requested text mode was set.
+ EFI_DEVICE_ERROR - The device had an error and could not complete the request.
+ EFI_UNSUPPORTED - The mode number was not valid.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TEXT_SET_ATTRIBUTE) (
+ IN EFI_SIMPLE_TEXT_OUT_PROTOCOL * This,
+ IN UINTN Attribute
+ )
+/*++
+
+ Routine Description:
+ Sets the background and foreground colors for the OutputString () and
+ ClearScreen () functions.
+
+ Arguments:
+ This - Protocol instance pointer.
+ Attribute - The attribute to set. Bits 0..3 are the foreground color, and
+ bits 4..6 are the background color. All other bits are undefined
+ and must be zero. The valid Attributes are defined in this file.
+
+ Returns:
+ EFI_SUCCESS - The attribute was set.
+ EFI_DEVICE_ERROR - The device had an error and could not complete the request.
+ EFI_UNSUPPORTED - The attribute requested is not defined.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TEXT_CLEAR_SCREEN) (
+ IN EFI_SIMPLE_TEXT_OUT_PROTOCOL * This
+ )
+/*++
+
+ Routine Description:
+ Clears the output device(s) display to the currently selected background
+ color.
+
+ Arguments:
+ This - Protocol instance pointer.
+
+ Returns:
+ EFI_SUCCESS - The operation completed successfully.
+ EFI_DEVICE_ERROR - The device had an error and could not complete the request.
+ EFI_UNSUPPORTED - The output device is not in a valid text mode.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TEXT_SET_CURSOR_POSITION) (
+ IN EFI_SIMPLE_TEXT_OUT_PROTOCOL * This,
+ IN UINTN Column,
+ IN UINTN Row
+ )
+/*++
+
+ Routine Description:
+ Sets the current coordinates of the cursor position
+
+ Arguments:
+ This - Protocol instance pointer.
+ Column, Row - the position to set the cursor to. Must be greater than or
+ equal to zero and less than the number of columns and rows
+ by QueryMode ().
+
+ Returns:
+ EFI_SUCCESS - The operation completed successfully.
+ EFI_DEVICE_ERROR - The device had an error and could not complete the request.
+ EFI_UNSUPPORTED - The output device is not in a valid text mode, or the
+ cursor position is invalid for the current mode.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TEXT_ENABLE_CURSOR) (
+ IN EFI_SIMPLE_TEXT_OUT_PROTOCOL * This,
+ IN BOOLEAN Enable
+ )
+/*++
+
+ Routine Description:
+ Makes the cursor visible or invisible
+
+ Arguments:
+ This - Protocol instance pointer.
+ Visible - If TRUE, the cursor is set to be visible. If FALSE, the cursor is
+ set to be invisible.
+
+ Returns:
+ EFI_SUCCESS - The operation completed successfully.
+ EFI_DEVICE_ERROR - The device had an error and could not complete the
+ request, or the device does not support changing
+ the cursor mode.
+ EFI_UNSUPPORTED - The output device is not in a valid text mode.
+
+--*/
+;
+
+/*++
+ Mode Structure pointed to by Simple Text Out protocol.
+
+ MaxMode - The number of modes supported by QueryMode () and SetMode ().
+ Mode - The text mode of the output device(s).
+ Attribute - The current character output attribute
+ CursorColumn - The cursor's column.
+ CursorRow - The cursor's row.
+ CursorVisible - The cursor is currently visbile or not.
+
+--*/
+typedef struct {
+ INT32 MaxMode;
+
+ //
+ // current settings
+ //
+ INT32 Mode;
+ INT32 Attribute;
+ INT32 CursorColumn;
+ INT32 CursorRow;
+ BOOLEAN CursorVisible;
+} EFI_SIMPLE_TEXT_OUTPUT_MODE;
+
+typedef struct _EFI_SIMPLE_TEXT_OUT_PROTOCOL {
+ EFI_TEXT_RESET Reset;
+
+ EFI_TEXT_OUTPUT_STRING OutputString;
+ EFI_TEXT_TEST_STRING TestString;
+
+ EFI_TEXT_QUERY_MODE QueryMode;
+ EFI_TEXT_SET_MODE SetMode;
+ EFI_TEXT_SET_ATTRIBUTE SetAttribute;
+
+ EFI_TEXT_CLEAR_SCREEN ClearScreen;
+ EFI_TEXT_SET_CURSOR_POSITION SetCursorPosition;
+ EFI_TEXT_ENABLE_CURSOR EnableCursor;
+
+ //
+ // Current mode
+ //
+ EFI_SIMPLE_TEXT_OUTPUT_MODE *Mode;
+} EFI_SIMPLE_TEXT_OUT_PROTOCOL;
+
+extern EFI_GUID gEfiSimpleTextOutProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/TapeIo/TapeIo.c b/EDK/Foundation/Efi/Protocol/TapeIo/TapeIo.c
new file mode 100644
index 0000000..bd9c302
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/TapeIo/TapeIo.c
@@ -0,0 +1,28 @@
+/*++
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ TapeIo.c
+
+Abstract:
+ EFI_TAPE_IO_PROTOCOL as defined in the UEFI 2.0.
+ Provide services to control and access a tape device.
+
+Revision History
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (TapeIo)
+
+EFI_GUID gEfiTapeIoProtocolGuid = EFI_TAPE_IO_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiTapeIoProtocolGuid, "Tape IO protoco", "UEFI 2.0 Tape IO protocol");
diff --git a/EDK/Foundation/Efi/Protocol/TapeIo/TapeIo.h b/EDK/Foundation/Efi/Protocol/TapeIo/TapeIo.h
new file mode 100644
index 0000000..5a3159f
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/TapeIo/TapeIo.h
@@ -0,0 +1,263 @@
+/*++
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ TapeIo.h
+
+Abstract:
+ EFI_TAPE_IO_PROTOCOL as defined in the UEFI 2.0.
+ Provide services to control and access a tape device.
+
+Revision History
+
+--*/
+
+#ifndef __EFI_TAPE_IO_PROTOCOL_H__
+#define __EFI_TAPE_IO_PROTOCOL_H__
+
+#define EFI_TAPE_IO_PROTOCOL_GUID \
+ { \
+ 0x1e93e633, 0xd65a, 0x459e, {0xab, 0x84, 0x93, 0xd9, 0xec, 0x26, 0x6d, 0x18 } \
+ }
+
+typedef struct _EFI_TAPE_IO_PROTOCOL EFI_TAPE_IO_PROTOCOL;
+
+typedef struct {
+ UINT64 Signature;
+ UINT32 Revision;
+ UINT32 BootDescSize;
+ UINT32 BootDescCRC;
+ EFI_GUID TapeGUID;
+ EFI_GUID TapeType;
+ EFI_GUID TapeUnique;
+ UINT32 BLLocation;
+ UINT32 BLBlocksize;
+ UINT32 BLFilesize;
+ CHAR8 OSVersion[40];
+ CHAR8 AppVersion[40];
+ CHAR8 CreationDate[10];
+ CHAR8 CreationTime[10];
+ CHAR8 SystemName[256]; // UTF-8
+ CHAR8 TapeTitle[120]; // UTF-8
+ CHAR8 pad[468]; // pad to 1024
+} TAPE_HEADER;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TAPE_READ) (
+ IN EFI_TAPE_IO_PROTOCOL *This,
+ IN OUT UINTN *BufferSize,
+ OUT VOID *Buffer
+ )
+/*++
+
+ Routine Description:
+ Reads from the tape.
+
+ Arguments:
+ This - A pointer to the EFI_TAPE_IO_PROTOCOL instance.
+ BufferSize - Size of the buffer in bytes pointed to by Buffer.
+ Buffer - Pointer to the buffer for data to be read into.
+
+ Returns:
+ EFI_SUCCESS - Data was successfully transferred from the media.
+ EFI_END_OF_FILE - A filemark was encountered which limited the data
+ transferred by the read operation or the head is positioned
+ just after a filemark.
+ EFI_NO_MEDIA - No media is loaded in the device.
+ EFI_NOT_READY - The transfer failed since the device was not ready (e.g. not
+ online). The transfer may be retried at a later time.
+ EFI_UNSUPPORTED - The device does not support this type of transfer.
+ EFI_TIMEOUT - The transfer failed to complete within the timeout specified.
+ EFI_MEDIA_CHANGED - The media in the device was changed since the last access.
+ The transfer was aborted since the current position of the
+ media may be incorrect.
+ EFI_INVALID_PARAMETER - A NULL Buffer was specified with a non-zero
+ BufferSize or the device is operating in fixed block
+ size mode and the BufferSize was not a multiple of
+ device¡¯s fixed block size
+ EFI_DEVICE_ERROR - A device error occurred while attempting to transfer data
+ from the media.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TAPE_WRITE) (
+ IN EFI_TAPE_IO_PROTOCOL *This,
+ IN UINTN *BufferSize,
+ IN VOID *Buffer
+ )
+/*++
+
+ Routine Description:
+ Writes to the tape.
+
+ Arguments:
+ This - A pointer to the EFI_TAPE_IO_PROTOCOL instance.
+ BufferSize - Size of the buffer in bytes pointed to by Buffer.
+ Buffer - Pointer to the buffer for data to be written from.
+
+ Returns:
+ EFI_SUCCESS - Data was successfully transferred to the media.
+ EFI_END_OF_MEDIA - The logical end of media has been reached. Data may have
+ been successfully transferred to the media.
+ EFI_NO_MEDIA - No media is loaded in the device.
+ EFI_NOT_READY - The transfer failed since the device was not ready (e.g. not
+ online). The transfer may be retried at a later time.
+ EFI_UNSUPPORTED - The device does not support this type of transfer.
+ EFI_TIMEOUT - The transfer failed to complete within the timeout specified.
+ EFI_MEDIA_CHANGED - The media in the device was changed since the last access.
+ The transfer was aborted since the current position of the
+ media may be incorrect.
+ EFI_WRITE_PROTECTED - The media in the device is write-protected. The transfer
+ was aborted since a write cannot be completed.
+ EFI_INVALID_PARAMETER - A NULL Buffer was specified with a non-zero
+ BufferSize or the device is operating in fixed block
+ size mode and the BufferSize was not a multiple of
+ device¡¯s fixed block size
+ EFI_DEVICE_ERROR A device error occurred while attempting to transfer data
+ from the media.
+
+--*/
+;
+
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TAPE_REWIND) (
+ IN EFI_TAPE_IO_PROTOCOL *This
+ )
+/*++
+
+ Routine Description:
+ Rewinds the tape.
+
+ Arguments:
+ This - A pointer to the EFI_TAPE_IO_PROTOCOL instance.
+
+ Returns:
+ EFI_SUCCESS - The media was successfully repositioned.
+ EFI_NO_MEDIA - No media is loaded in the device.
+ EFI_NOT_READY - Repositioning the media failed since the device was not
+ ready (e.g. not online). The transfer may be retried at a later time.
+ EFI_UNSUPPORTED - The device does not support this type of media repositioning.
+ EFI_TIMEOUT - Repositioning of the media did not complete within the timeout specified.
+ EFI_DEVICE_ERROR - A device error occurred while attempting to reposition the media.
+
+--*/
+;
+
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TAPE_SPACE) (
+ IN EFI_TAPE_IO_PROTOCOL *This,
+ INTN Direction,
+ UINTN Type
+ )
+/*++
+
+ Routine Description:
+ Positions the tape.
+
+ Arguments:
+ This - A pointer to the EFI_TAPE_IO_PROTOCOL instance.
+ Direction - Direction and number of data blocks or filemarks to space over on media.
+ Type - Type of mark to space over on media.
+
+ Returns:
+ EFI_SUCCESS - The media was successfully repositioned.
+ EFI_END_OF_MEDIA - Beginning or end of media was reached before the
+ indicated number of data blocks or filemarks were found.
+ EFI_NO_MEDIA - No media is loaded in the device.
+ EFI_NOT_READY - The reposition failed since the device was not ready (e.g. not
+ online). The reposition may be retried at a later time.
+ EFI_UNSUPPORTED - The device does not support this type of repositioning.
+ EFI_TIMEOUT - The repositioning failed to complete within the timeout specified.
+ EFI_MEDIA_CHANGED - The media in the device was changed since the last access.
+ Repositioning the media was aborted since the current
+ position of the media may be incorrect.
+ EFI_DEVICE_ERROR - A device error occurred while attempting to reposition the media.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TAPE_WRITEFM) (
+ IN EFI_TAPE_IO_PROTOCOL *This,
+ IN UINTN Count
+ )
+/*++
+
+ Routine Description:
+ Writes filemarks to the media.
+
+ Arguments:
+ This - A pointer to the EFI_TAPE_IO_PROTOCOL instance.
+ Count - Number of filemarks to write to the media.
+
+ Returns:
+ EFI_SUCCESS - Data was successfully transferred from the media.
+ EFI_NO_MEDIA - No media is loaded in the device.
+ EFI_NOT_READY - The transfer failed since the device was not ready (e.g. not
+ online). The transfer may be retried at a later time.
+ EFI_UNSUPPORTED - The device does not support this type of repositioning.
+ EFI_TIMEOUT - The transfer failed to complete within the timeout specified.
+ EFI_MEDIA_CHANGED - The media in the device was changed since the last access.
+ The transfer was aborted since the current position of the
+ media may be incorrect.
+ EFI_DEVICE_ERROR - A device error occurred while attempting to transfer data from the media.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TAPE_RESET) (
+ IN EFI_TAPE_IO_PROTOCOL *This,
+ IN BOOLEAN ExtendedVerification
+ )
+/*++
+
+ Routine Description:
+ Resets the tape device.
+
+ Arguments:
+ This - A pointer to the EFI_TAPE_IO_PROTOCOL instance.
+ ExtendedVerification - Indicates whether the parent bus should also be reset.
+
+ Returns:
+ EFI_SUCCESS - The bus and/or device were successfully reset.
+ EFI_NO_MEDIA - No media is loaded in the device.
+ EFI_NOT_READY - The reset failed since the device and/or bus was not ready.
+ The reset may be retried at a later time.
+ EFI_UNSUPPORTED - The device does not support this type of reset.
+ EFI_TIMEOUT - The reset did not complete within the timeout allowed.
+ EFI_DEVICE_ERROR - A device error occurred while attempting to reset the bus and/or device.
+
+--*/
+;
+
+struct _EFI_TAPE_IO_PROTOCOL {
+ EFI_TAPE_READ TapeRead;
+ EFI_TAPE_WRITE TapeWrite;
+ EFI_TAPE_REWIND TapeRewind;
+ EFI_TAPE_SPACE TapeSpace;
+ EFI_TAPE_WRITEFM TapeWriteFM;
+ EFI_TAPE_RESET TapeReset;
+};
+
+extern EFI_GUID gEfiTapeIoProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/Tcp4/Tcp4.c b/EDK/Foundation/Efi/Protocol/Tcp4/Tcp4.c
new file mode 100644
index 0000000..3d7660e
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/Tcp4/Tcp4.c
@@ -0,0 +1,30 @@
+/*++
+
+Copyright (c) 2005 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Tcp4.c
+
+Abstract:
+
+ UEFI TCPv4 Protocol
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (Tcp4)
+
+EFI_GUID gEfiTcp4ServiceBindingProtocolGuid = EFI_TCP4_SERVICE_BINDING_PROTOCOL_GUID;
+EFI_GUID gEfiTcp4ProtocolGuid = EFI_TCP4_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiTcp4ServiceBindingProtocolGuid, "TCP4 Service Binding Protocol", "TCP4 Service Binding Protocol");
+EFI_GUID_STRING(&gEfiTcp4ProtocolGuid, "TCP4 Protocol", "TCP4 Protocol");
+
diff --git a/EDK/Foundation/Efi/Protocol/Tcp4/Tcp4.h b/EDK/Foundation/Efi/Protocol/Tcp4/Tcp4.h
new file mode 100644
index 0000000..c482d35
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/Tcp4/Tcp4.h
@@ -0,0 +1,247 @@
+/*++
+
+Copyright (c) 2005 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Tcp4.h
+
+Abstract:
+
+ UEFI TCPv4 Protocol Definition
+
+--*/
+
+#ifndef _TCP4_H_
+#define _TCP4_H_
+
+#include EFI_PROTOCOL_DEFINITION (ServiceBinding)
+#include EFI_PROTOCOL_DEFINITION (Ip4)
+
+#define EFI_TCP4_SERVICE_BINDING_PROTOCOL_GUID \
+ { \
+ 0x00720665, 0x67EB, 0x4a99, 0xBA, 0xF7, 0xD3, 0xC3, 0x3A, 0x1C, 0x7C, 0xC9 \
+ }
+
+extern EFI_GUID gEfiTcp4ServiceBindingProtocolGuid;
+
+#define EFI_TCP4_PROTOCOL_GUID \
+ { \
+ 0x65530BC7, 0xA359, 0x410f, 0xB0, 0x10, 0x5A, 0xAD, 0xC7, 0xEC, 0x2B, 0x62 \
+ }
+
+extern EFI_GUID gEfiTcp4ProtocolGuid;
+
+EFI_FORWARD_DECLARATION (EFI_TCP4_PROTOCOL);
+
+typedef struct {
+ EFI_HANDLE InstanceHandle;
+ EFI_IPv4_ADDRESS LocalAddress;
+ UINT16 LocalPort;
+ EFI_IPv4_ADDRESS RemoteAddress;
+ UINT16 RemotePort;
+} EFI_TCP4_SERVICE_POINT;
+
+typedef struct {
+ EFI_HANDLE DriverHandle;
+ UINT32 ServiceCount;
+ EFI_TCP4_SERVICE_POINT Services[1];
+} EFI_TCP4_VARIABLE_DATA;
+
+typedef struct {
+ BOOLEAN UseDefaultAddress;
+ EFI_IPv4_ADDRESS StationAddress;
+ EFI_IPv4_ADDRESS SubnetMask;
+ UINT16 StationPort;
+ EFI_IPv4_ADDRESS RemoteAddress;
+ UINT16 RemotePort;
+ BOOLEAN ActiveFlag;
+} EFI_TCP4_ACCESS_POINT;
+
+typedef struct {
+ UINT32 ReceiveBufferSize;
+ UINT32 SendBufferSize;
+ UINT32 MaxSynBackLog;
+ UINT32 ConnectionTimeout;
+ UINT32 DataRetries;
+ UINT32 FinTimeout;
+ UINT32 TimeWaitTimeout;
+ UINT32 KeepAliveProbes;
+ UINT32 KeepAliveTime;
+ UINT32 KeepAliveInterval;
+ BOOLEAN EnableNagle;
+ BOOLEAN EnableTimeStamp;
+ BOOLEAN EnableWindowScaling;
+ BOOLEAN EnableSelectiveAck;
+ BOOLEAN EnablePathMtuDiscovery;
+} EFI_TCP4_OPTION;
+
+typedef struct {
+ UINT8 TypeOfService;
+ UINT8 TimeToLive;
+ EFI_TCP4_ACCESS_POINT AccessPoint;
+ EFI_TCP4_OPTION *ControlOption;
+} EFI_TCP4_CONFIG_DATA;
+
+typedef enum {
+ Tcp4StateClosed = 0,
+ Tcp4StateListen = 1,
+ Tcp4StateSynSent = 2,
+ Tcp4StateSynReceived= 3,
+ Tcp4StateEstablished= 4,
+ Tcp4StateFinWait1 = 5,
+ Tcp4StateFinWait2 = 6,
+ Tcp4StateClosing = 7,
+ Tcp4StateTimeWait = 8,
+ Tcp4StateCloseWait = 9,
+ Tcp4StateLastAck = 10
+} EFI_TCP4_CONNECTION_STATE;
+
+typedef struct {
+ EFI_EVENT Event;
+ EFI_STATUS Status;
+} EFI_TCP4_COMPLETION_TOKEN;
+
+typedef struct {
+ EFI_TCP4_COMPLETION_TOKEN CompletionToken;
+} EFI_TCP4_CONNECTION_TOKEN;
+
+typedef struct {
+ EFI_TCP4_COMPLETION_TOKEN CompletionToken;
+ EFI_HANDLE NewChildHandle;
+} EFI_TCP4_LISTEN_TOKEN;
+
+typedef struct {
+ UINT32 FragmentLength;
+ VOID *FragmentBuffer;
+} EFI_TCP4_FRAGMENT_DATA;
+
+typedef struct {
+ BOOLEAN UrgentFlag;
+ UINT32 DataLength;
+ UINT32 FragmentCount;
+ EFI_TCP4_FRAGMENT_DATA FragmentTable[1];
+} EFI_TCP4_RECEIVE_DATA;
+
+typedef struct {
+ BOOLEAN Push;
+ BOOLEAN Urgent;
+ UINT32 DataLength;
+ UINT32 FragmentCount;
+ EFI_TCP4_FRAGMENT_DATA FragmentTable[1];
+} EFI_TCP4_TRANSMIT_DATA;
+
+typedef struct {
+ EFI_TCP4_COMPLETION_TOKEN CompletionToken;
+ union {
+ EFI_TCP4_RECEIVE_DATA *RxData;
+ EFI_TCP4_TRANSMIT_DATA *TxData;
+ } Packet;
+} EFI_TCP4_IO_TOKEN;
+
+typedef struct {
+ EFI_TCP4_COMPLETION_TOKEN CompletionToken;
+ BOOLEAN AbortOnClose;
+} EFI_TCP4_CLOSE_TOKEN;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TCP4_GET_MODE_DATA) (
+ IN EFI_TCP4_PROTOCOL *This,
+ OUT EFI_TCP4_CONNECTION_STATE *Tcp4State OPTIONAL,
+ OUT EFI_TCP4_CONFIG_DATA *Tcp4ConfigData OPTIONAL,
+ OUT EFI_IP4_MODE_DATA *Ip4ModeData OPTIONAL,
+ OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL,
+ OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TCP4_CONFIGURE) (
+ IN EFI_TCP4_PROTOCOL *This,
+ IN EFI_TCP4_CONFIG_DATA *TcpConfigData OPTIONAL
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TCP4_ROUTES) (
+ IN EFI_TCP4_PROTOCOL *This,
+ IN BOOLEAN DeleteRoute,
+ IN EFI_IPv4_ADDRESS *SubnetAddress,
+ IN EFI_IPv4_ADDRESS *SubnetMask,
+ IN EFI_IPv4_ADDRESS *GatewayAddress
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TCP4_CONNECT) (
+ IN EFI_TCP4_PROTOCOL *This,
+ IN EFI_TCP4_CONNECTION_TOKEN *ConnectionToken
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TCP4_ACCEPT) (
+ IN EFI_TCP4_PROTOCOL *This,
+ IN EFI_TCP4_LISTEN_TOKEN *ListenToken
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TCP4_TRANSMIT) (
+ IN EFI_TCP4_PROTOCOL *This,
+ IN EFI_TCP4_IO_TOKEN *Token
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TCP4_RECEIVE) (
+ IN EFI_TCP4_PROTOCOL *This,
+ IN EFI_TCP4_IO_TOKEN *Token
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TCP4_CLOSE) (
+ IN EFI_TCP4_PROTOCOL *This,
+ IN EFI_TCP4_CLOSE_TOKEN *CloseToken
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TCP4_CANCEL) (
+ IN EFI_TCP4_PROTOCOL *This,
+ IN EFI_TCP4_COMPLETION_TOKEN *Token OPTIONAL
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TCP4_POLL) (
+ IN EFI_TCP4_PROTOCOL *This
+ );
+
+typedef struct _EFI_TCP4_PROTOCOL {
+ EFI_TCP4_GET_MODE_DATA GetModeData;
+ EFI_TCP4_CONFIGURE Configure;
+ EFI_TCP4_ROUTES Routes;
+ EFI_TCP4_CONNECT Connect;
+ EFI_TCP4_ACCEPT Accept;
+ EFI_TCP4_TRANSMIT Transmit;
+ EFI_TCP4_RECEIVE Receive;
+ EFI_TCP4_CLOSE Close;
+ EFI_TCP4_CANCEL Cancel;
+ EFI_TCP4_POLL Poll;
+} EFI_TCP4_PROTOCOL;
+
+#define EFI_CONNECTION_FIN EFIERR (104)
+#define EFI_CONNECTION_RESET EFIERR (105)
+#define EFI_CONNECTION_REFUSED EFIERR (106)
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/Udp4/Udp4.c b/EDK/Foundation/Efi/Protocol/Udp4/Udp4.c
new file mode 100644
index 0000000..29b97b9
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/Udp4/Udp4.c
@@ -0,0 +1,29 @@
+/*++
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Udp4.c
+
+Abstract:
+
+ UEFI UDPv4 protocol.
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (Udp4)
+
+EFI_GUID gEfiUdp4ServiceBindingProtocolGuid = EFI_UDP4_SERVICE_BINDING_PROTOCOL_GUID;
+EFI_GUID gEfiUdp4ProtocolGuid = EFI_UDP4_PROTOCOL_GUID;
+
+EFI_GUID_STRING (&gEfiUdp4ServiceBindingProtocolGuid, "UDP4 Service Binding Protocol", "UDP4 Service Binding Protocol");
+EFI_GUID_STRING (&gEfiUdp4ProtocolGuid, "UDP4 Protocol", "UDP4 Protocol");
diff --git a/EDK/Foundation/Efi/Protocol/Udp4/Udp4.h b/EDK/Foundation/Efi/Protocol/Udp4/Udp4.h
new file mode 100644
index 0000000..68ad3f8
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/Udp4/Udp4.h
@@ -0,0 +1,214 @@
+/*++
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Udp4.h
+
+Abstract:
+
+--*/
+
+#ifndef _UDP4_H_
+#define _UDP4_H_
+
+#include EFI_PROTOCOL_DEFINITION (ServiceBinding)
+#include EFI_PROTOCOL_DEFINITION (Ip4)
+
+//
+//GUID definitions
+//
+#define EFI_UDP4_SERVICE_BINDING_PROTOCOL_GUID \
+ { 0x83f01464, 0x99bd, 0x45e5, 0xb3, 0x83, 0xaf, 0x63, 0x05, 0xd8, 0xe9, 0xe6 }
+
+#define EFI_UDP4_PROTOCOL_GUID \
+ { 0x3ad9df29, 0x4501, 0x478d, 0xb1, 0xf8, 0x7f, 0x7f, 0xe7, 0x0e, 0x50, 0xf3 }
+
+typedef struct {
+ EFI_HANDLE InstanceHandle;
+ EFI_IPv4_ADDRESS LocalAddress;
+ UINT16 LocalPort;
+ EFI_IPv4_ADDRESS RemoteAddress;
+ UINT16 RemotePort;
+} EFI_UDP4_SERVICE_POINT;
+
+typedef struct {
+ EFI_HANDLE DriverHandle;
+ UINT32 ServiceCount;
+ EFI_UDP4_SERVICE_POINT Services[1];
+} EFI_UDP4_VARIABLE_DATA;
+
+//
+//ICMP error definitions
+//
+#define EFI_NETWORK_UNREACHABLE EFIERR(100)
+#define EFI_HOST_UNREACHABLE EFIERR(101)
+#define EFI_PROTOCOL_UNREACHABLE EFIERR(102)
+#define EFI_PORT_UNREACHABLE EFIERR(103)
+
+EFI_FORWARD_DECLARATION (EFI_UDP4_PROTOCOL);
+
+//*************************************************
+// EFI_UDP4_FRAGMENT_DATA *
+//*************************************************
+typedef struct {
+ UINT32 FragmentLength;
+ VOID *FragmentBuffer;
+} EFI_UDP4_FRAGMENT_DATA;
+
+//*************************************************
+// EFI_UDP4_SESSION_DATA *
+//*************************************************
+typedef struct {
+ EFI_IPv4_ADDRESS SourceAddress;
+ UINT16 SourcePort;
+ EFI_IPv4_ADDRESS DestinationAddress;
+ UINT16 DestinationPort;
+} EFI_UDP4_SESSION_DATA;
+
+//************************************************
+// EFI_UDP4_CONFIG_DATA *
+//************************************************
+typedef struct {
+ //Receiving Filters
+ BOOLEAN AcceptBroadcast;
+ BOOLEAN AcceptPromiscuous;
+ BOOLEAN AcceptAnyPort;
+ BOOLEAN AllowDuplicatePort;
+ //I/O parameters
+ UINT8 TypeOfService;
+ UINT8 TimeToLive;
+ BOOLEAN DoNotFragment;
+ UINT32 ReceiveTimeout;
+ UINT32 TransmitTimeout;
+ //Access Point
+ BOOLEAN UseDefaultAddress;
+ EFI_IPv4_ADDRESS StationAddress;
+ EFI_IPv4_ADDRESS SubnetMask;
+ UINT16 StationPort;
+ EFI_IPv4_ADDRESS RemoteAddress;
+ UINT16 RemotePort;
+} EFI_UDP4_CONFIG_DATA;
+
+//*******************************************************
+// EFI_UDP4_TRANSMIT_DATA *
+//*******************************************************
+typedef struct {
+ EFI_UDP4_SESSION_DATA *UdpSessionData;
+ EFI_IPv4_ADDRESS *GatewayAddress;
+ UINT32 DataLength;
+ UINT32 FragmentCount;
+ EFI_UDP4_FRAGMENT_DATA FragmentTable[1];
+} EFI_UDP4_TRANSMIT_DATA;
+
+//*******************************************************
+// EFI_UDP4_RECEIVE_DATA *
+//*******************************************************
+typedef struct {
+ EFI_TIME TimeStamp;
+ EFI_EVENT RecycleSignal;
+ EFI_UDP4_SESSION_DATA UdpSession;
+ UINT32 DataLength;
+ UINT32 FragmentCount;
+ EFI_UDP4_FRAGMENT_DATA FragmentTable[1];
+} EFI_UDP4_RECEIVE_DATA;
+
+
+//*******************************************************
+// EFI_UDP4_COMPLETION_TOKEN *
+//*******************************************************
+typedef struct {
+ EFI_EVENT Event;
+ EFI_STATUS Status;
+ union {
+ EFI_UDP4_RECEIVE_DATA *RxData;
+ EFI_UDP4_TRANSMIT_DATA *TxData;
+ } Packet;
+} EFI_UDP4_COMPLETION_TOKEN;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_UDP4_GET_MODE_DATA) (
+ IN EFI_UDP4_PROTOCOL *This,
+ OUT EFI_UDP4_CONFIG_DATA *Udp4ConfigData OPTIONAL,
+ OUT EFI_IP4_MODE_DATA *Ip4ModeData OPTIONAL,
+ OUT EFI_MANAGED_NETWORK_CONFIG_DATA *MnpConfigData OPTIONAL,
+ OUT EFI_SIMPLE_NETWORK_MODE *SnpModeData OPTIONAL
+);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_UDP4_CONFIGURE) (
+ IN EFI_UDP4_PROTOCOL *This,
+ IN EFI_UDP4_CONFIG_DATA *UdpConfigData OPTIONAL
+);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_UDP4_GROUPS) (
+ IN EFI_UDP4_PROTOCOL *This,
+ IN BOOLEAN JoinFlag,
+ IN EFI_IPv4_ADDRESS *MulticastAddress OPTIONAL
+);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_UDP4_ROUTES) (
+ IN EFI_UDP4_PROTOCOL *This,
+ IN BOOLEAN DeleteRoute,
+ IN EFI_IPv4_ADDRESS *SubnetAddress,
+ IN EFI_IPv4_ADDRESS *SubnetMask,
+ IN EFI_IPv4_ADDRESS *GatewayAddress
+);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_UDP4_TRANSMIT) (
+ IN EFI_UDP4_PROTOCOL *This,
+ IN EFI_UDP4_COMPLETION_TOKEN *Token
+);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_UDP4_RECEIVE) (
+ IN EFI_UDP4_PROTOCOL *This,
+ IN EFI_UDP4_COMPLETION_TOKEN *Token
+);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_UDP4_CANCEL)(
+ IN EFI_UDP4_PROTOCOL *This,
+ IN EFI_UDP4_COMPLETION_TOKEN *Token OPTIONAL
+);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_UDP4_POLL) (
+ IN EFI_UDP4_PROTOCOL *This
+);
+
+typedef struct _EFI_UDP4_PROTOCOL {
+ EFI_UDP4_GET_MODE_DATA GetModeData;
+ EFI_UDP4_CONFIGURE Configure;
+ EFI_UDP4_GROUPS Groups;
+ EFI_UDP4_ROUTES Routes;
+ EFI_UDP4_TRANSMIT Transmit;
+ EFI_UDP4_RECEIVE Receive;
+ EFI_UDP4_CANCEL Cancel;
+ EFI_UDP4_POLL Poll;
+} EFI_UDP4_PROTOCOL;
+
+extern EFI_GUID gEfiUdp4ServiceBindingProtocolGuid;
+extern EFI_GUID gEfiUdp4ProtocolGuid;
+extern EFI_GUID gEfiUdp4RegistryDataGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/UgaDraw/UgaDraw.c b/EDK/Foundation/Efi/Protocol/UgaDraw/UgaDraw.c
new file mode 100644
index 0000000..a3d335e
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/UgaDraw/UgaDraw.c
@@ -0,0 +1,29 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ UgaDraw.c
+
+Abstract:
+
+ UGA Draw protocol from the EFI 1.1 specification.
+
+ Abstraction of a very simple graphics device.
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (UgaDraw)
+
+EFI_GUID gEfiUgaDrawProtocolGuid = EFI_UGA_DRAW_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiUgaDrawProtocolGuid, "UGA Draw Protocol", "EFI 1.1 UGA Draw Protocol");
diff --git a/EDK/Foundation/Efi/Protocol/UgaDraw/UgaDraw.h b/EDK/Foundation/Efi/Protocol/UgaDraw/UgaDraw.h
new file mode 100644
index 0000000..e322f6b
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/UgaDraw/UgaDraw.h
@@ -0,0 +1,181 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ UgaDraw.h
+
+Abstract:
+
+ UGA Draw protocol from the EFI 1.1 specification.
+
+ Abstraction of a very simple graphics device.
+
+--*/
+
+#ifndef __UGA_DRAW_H__
+#define __UGA_DRAW_H__
+
+#define EFI_UGA_DRAW_PROTOCOL_GUID \
+ { \
+ 0x982c298b, 0xf4fa, 0x41cb, 0xb8, 0x38, 0x77, 0xaa, 0x68, 0x8f, 0xb8, 0x39 \
+ }
+
+typedef struct _EFI_UGA_DRAW_PROTOCOL EFI_UGA_DRAW_PROTOCOL;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_UGA_DRAW_PROTOCOL_GET_MODE) (
+ IN EFI_UGA_DRAW_PROTOCOL * This,
+ OUT UINT32 *HorizontalResolution,
+ OUT UINT32 *VerticalResolution,
+ OUT UINT32 *ColorDepth,
+ OUT UINT32 *RefreshRate
+ )
+/*++
+
+ Routine Description:
+ Return the current video mode information.
+
+ Arguments:
+ This - Protocol instance pointer.
+ HorizontalResolution - Current video horizontal resolution in pixels
+ VerticalResolution - Current video vertical resolution in pixels
+ ColorDepth - Current video color depth in bits per pixel
+ RefreshRate - Current video refresh rate in Hz.
+
+ Returns:
+ EFI_SUCCESS - Mode information returned.
+ EFI_NOT_STARTED - Video display is not initialized. Call SetMode ()
+ EFI_INVALID_PARAMETER - One of the input args was NULL.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_UGA_DRAW_PROTOCOL_SET_MODE) (
+ IN EFI_UGA_DRAW_PROTOCOL * This,
+ IN UINT32 HorizontalResolution,
+ IN UINT32 VerticalResolution,
+ IN UINT32 ColorDepth,
+ IN UINT32 RefreshRate
+ )
+/*++
+
+ Routine Description:
+ Return the current video mode information.
+
+ Arguments:
+ This - Protocol instance pointer.
+ HorizontalResolution - Current video horizontal resolution in pixels
+ VerticalResolution - Current video vertical resolution in pixels
+ ColorDepth - Current video color depth in bits per pixel
+ RefreshRate - Current video refresh rate in Hz.
+
+ Returns:
+ EFI_SUCCESS - Mode information returned.
+ EFI_NOT_STARTED - Video display is not initialized. Call SetMode ()
+
+--*/
+;
+
+typedef struct {
+ UINT8 Blue;
+ UINT8 Green;
+ UINT8 Red;
+ UINT8 Reserved;
+} EFI_UGA_PIXEL;
+
+typedef union {
+ EFI_UGA_PIXEL Pixel;
+ UINT32 Raw;
+} EFI_UGA_PIXEL_UNION;
+
+typedef enum {
+ EfiUgaVideoFill,
+ EfiUgaVideoToBltBuffer,
+ EfiUgaBltBufferToVideo,
+ EfiUgaVideoToVideo,
+ EfiUgaBltMax
+} EFI_UGA_BLT_OPERATION;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_UGA_DRAW_PROTOCOL_BLT) (
+ IN EFI_UGA_DRAW_PROTOCOL * This,
+ IN EFI_UGA_PIXEL * BltBuffer, OPTIONAL
+ IN EFI_UGA_BLT_OPERATION BltOperation,
+ IN UINTN SourceX,
+ IN UINTN SourceY,
+ IN UINTN DestinationX,
+ IN UINTN DestinationY,
+ IN UINTN Width,
+ IN UINTN Height,
+ IN UINTN Delta OPTIONAL
+ );
+
+/*++
+
+ Routine Description:
+ The following table defines actions for BltOperations:
+ EfiUgaVideoFill - Write data from the BltBuffer pixel (SourceX, SourceY)
+ directly to every pixel of the video display rectangle
+ (DestinationX, DestinationY) (DestinationX + Width, DestinationY + Height).
+ Only one pixel will be used from the BltBuffer. Delta is NOT used.
+ EfiUgaVideoToBltBuffer - Read data from the video display rectangle
+ (SourceX, SourceY) (SourceX + Width, SourceY + Height) and place it in
+ the BltBuffer rectangle (DestinationX, DestinationY )
+ (DestinationX + Width, DestinationY + Height). If DestinationX or
+ DestinationY is not zero then Delta must be set to the length in bytes
+ of a row in the BltBuffer.
+ EfiUgaBltBufferToVideo - Write data from the BltBuffer rectangle
+ (SourceX, SourceY) (SourceX + Width, SourceY + Height) directly to the
+ video display rectangle (DestinationX, DestinationY)
+ (DestinationX + Width, DestinationY + Height). If SourceX or SourceY is
+ not zero then Delta must be set to the length in bytes of a row in the
+ BltBuffer.
+ EfiUgaVideoToVideo - Copy from the video display rectangle (SourceX, SourceY)
+ (SourceX + Width, SourceY + Height) .to the video display rectangle
+ (DestinationX, DestinationY) (DestinationX + Width, DestinationY + Height).
+ The BltBuffer and Delta are not used in this mode.
+
+ Arguments:
+ This - Protocol instance pointer.
+ BltBuffer - Buffer containing data to blit into video buffer. This
+ buffer has a size of Width*Height*sizeof(EFI_UGA_PIXEL)
+ BltOperation - Operation to perform on BlitBuffer and video memory
+ SourceX - X coordinate of source for the BltBuffer.
+ SourceY - Y coordinate of source for the BltBuffer.
+ DestinationX - X coordinate of destination for the BltBuffer.
+ DestinationY - Y coordinate of destination for the BltBuffer.
+ Width - Width of rectangle in BltBuffer in pixels.
+ Height - Hight of rectangle in BltBuffer in pixels.
+ Delta -
+
+ Returns:
+ EFI_SUCCESS - The Blt operation completed.
+ EFI_INVALID_PARAMETER - BltOperation is not valid.
+ EFI_DEVICE_ERROR - A hardware error occured writting to the video
+ buffer.
+
+--*/
+;
+
+typedef struct _EFI_UGA_DRAW_PROTOCOL {
+ EFI_UGA_DRAW_PROTOCOL_GET_MODE GetMode;
+ EFI_UGA_DRAW_PROTOCOL_SET_MODE SetMode;
+ EFI_UGA_DRAW_PROTOCOL_BLT Blt;
+} EFI_UGA_DRAW_PROTOCOL;
+
+extern EFI_GUID gEfiUgaDrawProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/UgaIo/UgaIo.c b/EDK/Foundation/Efi/Protocol/UgaIo/UgaIo.c
new file mode 100644
index 0000000..a31d483
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/UgaIo/UgaIo.c
@@ -0,0 +1,29 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ UgaIo.c
+
+Abstract:
+
+ UGA IO protocol from the EFI 1.1 specification.
+
+ Abstraction of a very simple graphics device.
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (UgaIo)
+
+EFI_GUID gEfiUgaIoProtocolGuid = EFI_UGA_IO_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiUgaIoProtocolGuid, "UGA Protocol", "EFI 1.1 UGA Protocol");
diff --git a/EDK/Foundation/Efi/Protocol/UgaIo/UgaIo.h b/EDK/Foundation/Efi/Protocol/UgaIo/UgaIo.h
new file mode 100644
index 0000000..9b74b9a
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/UgaIo/UgaIo.h
@@ -0,0 +1,236 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ UgaIo.h
+
+Abstract:
+
+ UGA IO protocol from the EFI 1.1 specification.
+
+ Abstraction of a very simple graphics device.
+
+--*/
+
+#ifndef __UGA_IO_H__
+#define __UGA_IO_H__
+
+#define EFI_UGA_IO_PROTOCOL_GUID \
+ { \
+ 0x61a4d49e, 0x6f68, 0x4f1b, 0xb9, 0x22, 0xa8, 0x6e, 0xed, 0xb, 0x7, 0xa2 \
+ }
+
+typedef struct _EFI_UGA_IO_PROTOCOL EFI_UGA_IO_PROTOCOL;
+
+typedef UINT32 UGA_STATUS;
+
+typedef enum {
+ UgaDtParentBus = 1,
+ UgaDtGraphicsController,
+ UgaDtOutputController,
+ UgaDtOutputPort,
+ UgaDtOther
+}
+UGA_DEVICE_TYPE, *PUGA_DEVICE_TYPE;
+
+typedef UINT32 UGA_DEVICE_ID, *PUGA_DEVICE_ID;
+
+typedef struct {
+ UGA_DEVICE_TYPE deviceType;
+ UGA_DEVICE_ID deviceId;
+ UINT32 ui32DeviceContextSize;
+ UINT32 ui32SharedContextSize;
+}
+UGA_DEVICE_DATA, *PUGA_DEVICE_DATA;
+
+typedef struct _UGA_DEVICE {
+ VOID *pvDeviceContext;
+ VOID *pvSharedContext;
+ VOID *pvRunTimeContext;
+ struct _UGA_DEVICE *pParentDevice;
+ VOID *pvBusIoServices;
+ VOID *pvStdIoServices;
+ UGA_DEVICE_DATA deviceData;
+}
+UGA_DEVICE, *PUGA_DEVICE;
+
+#ifndef UGA_IO_REQUEST_CODE
+//
+// Prevent conflicts with UGA typedefs.
+//
+typedef enum {
+ UgaIoGetVersion = 1,
+ UgaIoGetChildDevice,
+ UgaIoStartDevice,
+ UgaIoStopDevice,
+ UgaIoFlushDevice,
+ UgaIoResetDevice,
+ UgaIoGetDeviceState,
+ UgaIoSetDeviceState,
+ UgaIoSetPowerState,
+ UgaIoGetMemoryConfiguration,
+ UgaIoSetVideoMode,
+ UgaIoCopyRectangle,
+ UgaIoGetEdidSegment,
+ UgaIoDeviceChannelOpen,
+ UgaIoDeviceChannelClose,
+ UgaIoDeviceChannelRead,
+ UgaIoDeviceChannelWrite,
+ UgaIoGetPersistentDataSize,
+ UgaIoGetPersistentData,
+ UgaIoSetPersistentData,
+ UgaIoGetDevicePropertySize,
+ UgaIoGetDeviceProperty,
+ UgaIoBtPrivateInterface
+}
+UGA_IO_REQUEST_CODE, *PUGA_IO_REQUEST_CODE;
+
+#endif
+
+typedef struct {
+ IN UGA_IO_REQUEST_CODE ioRequestCode;
+ IN VOID *pvInBuffer;
+ IN UINT64 ui64InBufferSize;
+ OUT VOID *pvOutBuffer;
+ IN UINT64 ui64OutBufferSize;
+ OUT UINT64 ui64BytesReturned;
+}
+UGA_IO_REQUEST, *PUGA_IO_REQUEST;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_UGA_IO_PROTOCOL_CREATE_DEVICE) (
+ IN EFI_UGA_IO_PROTOCOL * This,
+ IN UGA_DEVICE * ParentDevice,
+ IN UGA_DEVICE_DATA * DeviceData,
+ IN VOID *RunTimeContext,
+ OUT UGA_DEVICE **Device
+ );
+
+/*++
+
+ Routine Description:
+
+ Dynamically allocate storage for a child UGA_DEVICE .
+
+ Arguments:
+
+ This - The EFI_UGA_IO_PROTOCOL instance. Type EFI_UGA_IO_PROTOCOL is
+ defined in Section 10.7.
+
+ ParentDevice - ParentDevice specifies a pointer to the parent device of Device.
+
+ DeviceData - A pointer to UGA_DEVICE_DATA returned from a call to DispatchService()
+ with a UGA_DEVICE of Parent and an IoRequest of type UgaIoGetChildDevice.
+
+ RuntimeContext - Context to associate with Device.
+
+ Device - The Device returns a dynamically allocated child UGA_DEVICE object
+ for ParentDevice. The caller is responsible for deleting Device.
+
+ Returns:
+
+ EFI_SUCCESS - Device was returned.
+
+ EFI_INVALID_PARAMETER - One of the arguments was not valid.
+
+ EFI_DEVICE_ERROR - The device had an error and could not complete the request.
+
+--*/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_UGA_IO_PROTOCOL_DELETE_DEVICE) (
+ IN EFI_UGA_IO_PROTOCOL * This,
+ IN UGA_DEVICE * Device
+ );
+
+/*++
+
+ Routine Description:
+
+ Delete a dynamically allocated child UGA_DEVICE object that was allocated via
+ CreateDevice() .
+
+ Arguments:
+
+ This - The EFI_UGA_IO_PROTOCOL instance. Type EFI_UGA_IO_PROTOCOL is defined
+ in Section 10.7.
+
+ Device - The Device points to a UGA_DEVICE object that was dynamically
+ allocated via a CreateDevice() call.
+
+ Returns:
+
+ EFI_SUCCESS - Device was deleted.
+
+ EFI_INVALID_PARAMETER - The Device was not allocated via CreateDevice()
+
+--*/
+typedef UGA_STATUS (EFIAPI *PUGA_FW_SERVICE_DISPATCH) (IN PUGA_DEVICE pDevice, IN OUT PUGA_IO_REQUEST pIoRequest);
+
+/*++
+
+ Routine Description:
+
+ This is the main UGA service dispatch routine for all UGA_IO_REQUEST s.
+
+ Arguments:
+
+ pDevice - pDevice specifies a pointer to a device object associated with a
+ device enumerated by a pIoRequest->ioRequestCode of type
+ UgaIoGetChildDevice. The root device for the EFI_UGA_IO_PROTOCOL
+ is represented by pDevice being set to NULL.
+
+ pIoRequest - pIoRequest points to a caller allocated buffer that contains data
+ defined by pIoRequest->ioRequestCode. See Related Definitions for
+ a definition of UGA_IO_REQUEST_CODE s and their associated data
+ structures.
+
+ Returns:
+
+ Varies depending on pIoRequest.
+
+--*/
+typedef struct _EFI_UGA_IO_PROTOCOL {
+ EFI_UGA_IO_PROTOCOL_CREATE_DEVICE CreateDevice;
+ EFI_UGA_IO_PROTOCOL_DELETE_DEVICE DeleteDevice;
+ PUGA_FW_SERVICE_DISPATCH DispatchService;
+} EFI_UGA_IO_PROTOCOL;
+
+extern EFI_GUID gEfiUgaIoProtocolGuid;
+
+//
+// Data structure that is stored in the EFI Configuration Table with the
+// EFI_UGA_IO_PROTOCOL_GUID. The option ROMs listed in this table may have
+// EBC UGA drivers.
+//
+typedef struct {
+ UINT32 Version;
+ UINT32 HeaderSize;
+ UINT32 SizeOfEntries;
+ UINT32 NumberOfEntries;
+} EFI_DRIVER_OS_HANDOFF_HEADER;
+
+typedef enum {
+ EfiUgaDriverFromPciRom,
+ EfiUgaDriverFromSystem,
+ EfiDriverHandoffMax
+} EFI_DRIVER_HANOFF_ENUM;
+
+typedef struct {
+ EFI_DRIVER_HANOFF_ENUM Type;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ VOID *PciRomImage;
+ UINT64 PciRomSize;
+} EFI_DRIVER_OS_HANDOFF;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/UnicodeCollation/UnicodeCollation.c b/EDK/Foundation/Efi/Protocol/UnicodeCollation/UnicodeCollation.c
new file mode 100644
index 0000000..dfe0870
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/UnicodeCollation/UnicodeCollation.c
@@ -0,0 +1,27 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ UnicodeCollation.c
+
+Abstract:
+
+ Unicode Collation protocol that follows the EFI 1.0 specification.
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (UnicodeCollation)
+
+EFI_GUID gEfiUnicodeCollationProtocolGuid = EFI_UNICODE_COLLATION_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiUnicodeCollationProtocolGuid, "Unicode Collation Protocol", "EFI 1.0 Unicode Collation Protocol");
diff --git a/EDK/Foundation/Efi/Protocol/UnicodeCollation/UnicodeCollation.h b/EDK/Foundation/Efi/Protocol/UnicodeCollation/UnicodeCollation.h
new file mode 100644
index 0000000..211d6c4
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/UnicodeCollation/UnicodeCollation.h
@@ -0,0 +1,211 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ UnicodeCollation.h
+
+Abstract:
+
+ Unicode Collation protocol that follows the EFI 1.0 specification.
+
+--*/
+
+#ifndef _UNICODE_COLLATION_H_
+#define _UNICODE_COLLATION_H_
+
+#define EFI_UNICODE_COLLATION_PROTOCOL_GUID \
+ { \
+ 0x1d85cd7f, 0xf43d, 0x11d2, 0x9a, 0xc, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d \
+ }
+
+EFI_FORWARD_DECLARATION (EFI_UNICODE_COLLATION_PROTOCOL);
+
+//
+// Protocol data structures and defines
+//
+#define EFI_UNICODE_BYTE_ORDER_MARK ((CHAR16)(0xfeff))
+#define EFI_UNICODE_BYTE_ORDER_MARK_REVERSE ((CHAR16)(0xfffe))
+
+//
+// Protocol member functions
+//
+typedef
+INTN
+(EFIAPI *EFI_UNICODE_COLLATION_STRICOLL) (
+ IN EFI_UNICODE_COLLATION_PROTOCOL * This,
+ IN CHAR16 *Str1,
+ IN CHAR16 *Str2
+ )
+/*++
+
+ Routine Description:
+ Performs a case-insensitive comparison of two Null-terminated Unicode
+ strings.
+
+ Arguments:
+ This - Protocol instance pointer.
+ Str1 - A pointer to a Null-terminated Unicode string.
+ Str2 - A pointer to a Null-terminated Unicode string.
+
+ Returns:
+ 0 - Str1 is equivalent to Str2
+ > 0 - Str1 is lexically greater than Str2
+ < 0 - Str1 is lexically less than Str2
+
+--*/
+;
+
+typedef
+BOOLEAN
+(EFIAPI *EFI_UNICODE_COLLATION_METAIMATCH) (
+ IN EFI_UNICODE_COLLATION_PROTOCOL * This,
+ IN CHAR16 *String,
+ IN CHAR16 *Pattern
+ )
+/*++
+
+ Routine Description:
+ Performs a case-insensitive comparison of a Null-terminated Unicode
+ pattern string and a Null-terminated Unicode string.
+
+ Arguments:
+ This - Protocol instance pointer.
+ String - A pointer to a Null-terminated Unicode string.
+ Pattern - A pointer to a Null-terminated Unicode pattern string.
+
+ Returns:
+ TRUE - Pattern was found in String.
+ FALSE - Pattern was not found in String.
+
+--*/
+;
+
+typedef
+VOID
+(EFIAPI *EFI_UNICODE_COLLATION_STRLWR) (
+ IN EFI_UNICODE_COLLATION_PROTOCOL * This,
+ IN OUT CHAR16 *Str
+ )
+/*++
+
+ Routine Description:
+ Converts all the Unicode characters in a Null-terminated Unicode string to
+ lower case Unicode characters.
+
+ Arguments:
+ This - Protocol instance pointer.
+ String - A pointer to a Null-terminated Unicode string.
+
+ Returns:
+ NONE
+
+--*/
+;
+
+typedef
+VOID
+(EFIAPI *EFI_UNICODE_COLLATION_STRUPR) (
+ IN EFI_UNICODE_COLLATION_PROTOCOL * This,
+ IN OUT CHAR16 *Str
+ )
+/*++
+
+ Routine Description:
+ Converts all the Unicode characters in a Null-terminated Unicode string to upper
+ case Unicode characters.
+
+ Arguments:
+ This - Protocol instance pointer.
+ String - A pointer to a Null-terminated Unicode string.
+
+ Returns:
+ NONE
+
+--*/
+;
+
+typedef
+VOID
+(EFIAPI *EFI_UNICODE_COLLATION_FATTOSTR) (
+ IN EFI_UNICODE_COLLATION_PROTOCOL * This,
+ IN UINTN FatSize,
+ IN CHAR8 *Fat,
+ OUT CHAR16 *String
+ )
+/*++
+
+ Routine Description:
+ Converts an 8.3 FAT file name in an OEM character set to a Null-terminated
+ Unicode string.
+
+ Arguments:
+ This - Protocol instance pointer.
+ FatSize - The size of the string Fat in bytes.
+ Fat - A pointer to a Null-terminated string that contains an 8.3 file
+ name using an OEM character set.
+ String - A pointer to a Null-terminated Unicode string. The string must
+ be preallocated to hold FatSize Unicode characters.
+ Returns:
+ NONE
+
+--*/
+;
+
+typedef
+BOOLEAN
+(EFIAPI *EFI_UNICODE_COLLATION_STRTOFAT) (
+ IN EFI_UNICODE_COLLATION_PROTOCOL * This,
+ IN CHAR16 *String,
+ IN UINTN FatSize,
+ OUT CHAR8 *Fat
+ )
+/*++
+
+ Routine Description:
+ Converts a Null-terminated Unicode string to legal characters in a FAT
+ filename using an OEM character set.
+
+ Arguments:
+ This - Protocol instance pointer.
+ String - A pointer to a Null-terminated Unicode string. The string must
+ be preallocated to hold FatSize Unicode characters.
+ FatSize - The size of the string Fat in bytes.
+ Fat - A pointer to a Null-terminated string that contains an 8.3 file
+ name using an OEM character set.
+ Returns:
+ TRUE - Fat is a Long File Name
+ FALSE - Fat is an 8.3 file name
+
+--*/
+;
+
+typedef struct _EFI_UNICODE_COLLATION_PROTOCOL {
+ //
+ // general
+ //
+ EFI_UNICODE_COLLATION_STRICOLL StriColl;
+ EFI_UNICODE_COLLATION_METAIMATCH MetaiMatch;
+ EFI_UNICODE_COLLATION_STRLWR StrLwr;
+ EFI_UNICODE_COLLATION_STRUPR StrUpr;
+
+ //
+ // for supporting fat volumes
+ //
+ EFI_UNICODE_COLLATION_FATTOSTR FatToStr;
+ EFI_UNICODE_COLLATION_STRTOFAT StrToFat;
+
+ CHAR8 *SupportedLanguages;
+} EFI_UNICODE_COLLATION_PROTOCOL;
+
+extern EFI_GUID gEfiUnicodeCollationProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/UnicodeCollation2/UnicodeCollation2.c b/EDK/Foundation/Efi/Protocol/UnicodeCollation2/UnicodeCollation2.c
new file mode 100644
index 0000000..3fd5655
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/UnicodeCollation2/UnicodeCollation2.c
@@ -0,0 +1,27 @@
+/*++
+
+Copyright (c) 2008, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ UnicodeCollation2.c
+
+Abstract:
+
+ Unicode Collation2 protocol that follows the UEFI 2.0 specification.
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (UnicodeCollation2)
+
+EFI_GUID gEfiUnicodeCollation2ProtocolGuid = EFI_UNICODE_COLLATION2_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiUnicodeCollation2ProtocolGuid, "Unicode Collation Protocol", "UEFI 2.0 Unicode Collation2 Protocol");
diff --git a/EDK/Foundation/Efi/Protocol/UnicodeCollation2/UnicodeCollation2.h b/EDK/Foundation/Efi/Protocol/UnicodeCollation2/UnicodeCollation2.h
new file mode 100644
index 0000000..b9b150f
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/UnicodeCollation2/UnicodeCollation2.h
@@ -0,0 +1,211 @@
+/*++
+
+Copyright (c) 2008, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ UnicodeCollation2.h
+
+Abstract:
+
+ Unicode Collation2 protocol that follows the UEFI 2.0 specification.
+
+--*/
+
+#ifndef _UNICODE_COLLATION2_H_
+#define _UNICODE_COLLATION2_H_
+
+#define EFI_UNICODE_COLLATION2_PROTOCOL_GUID \
+ { \
+ 0xa4c751fc, 0x23ae, 0x4c3e, 0x92, 0xe9, 0x49, 0x64, 0xcf, 0x63, 0xf3, 0x49 \
+ }
+
+EFI_FORWARD_DECLARATION (EFI_UNICODE_COLLATION2_PROTOCOL);
+
+//
+// Protocol data structures and defines
+//
+#define EFI_UNICODE_BYTE_ORDER_MARK ((CHAR16)(0xfeff))
+#define EFI_UNICODE_BYTE_ORDER_MARK_REVERSE ((CHAR16)(0xfffe))
+
+//
+// Protocol member functions
+//
+typedef
+INTN
+(EFIAPI *EFI_UNICODE_COLLATION2_STRICOLL) (
+ IN EFI_UNICODE_COLLATION2_PROTOCOL * This,
+ IN CHAR16 *Str1,
+ IN CHAR16 *Str2
+ )
+/*++
+
+ Routine Description:
+ Performs a case-insensitive comparison of two Null-terminated Unicode
+ strings.
+
+ Arguments:
+ This - Protocol instance pointer.
+ Str1 - A pointer to a Null-terminated Unicode string.
+ Str2 - A pointer to a Null-terminated Unicode string.
+
+ Returns:
+ 0 - Str1 is equivalent to Str2
+ > 0 - Str1 is lexically greater than Str2
+ < 0 - Str1 is lexically less than Str2
+
+--*/
+;
+
+typedef
+BOOLEAN
+(EFIAPI *EFI_UNICODE_COLLATION2_METAIMATCH) (
+ IN EFI_UNICODE_COLLATION2_PROTOCOL * This,
+ IN CHAR16 *String,
+ IN CHAR16 *Pattern
+ )
+/*++
+
+ Routine Description:
+ Performs a case-insensitive comparison of a Null-terminated Unicode
+ pattern string and a Null-terminated Unicode string.
+
+ Arguments:
+ This - Protocol instance pointer.
+ String - A pointer to a Null-terminated Unicode string.
+ Pattern - A pointer to a Null-terminated Unicode pattern string.
+
+ Returns:
+ TRUE - Pattern was found in String.
+ FALSE - Pattern was not found in String.
+
+--*/
+;
+
+typedef
+VOID
+(EFIAPI *EFI_UNICODE_COLLATION2_STRLWR) (
+ IN EFI_UNICODE_COLLATION2_PROTOCOL * This,
+ IN OUT CHAR16 *Str
+ )
+/*++
+
+ Routine Description:
+ Converts all the Unicode characters in a Null-terminated Unicode string to
+ lower case Unicode characters.
+
+ Arguments:
+ This - Protocol instance pointer.
+ String - A pointer to a Null-terminated Unicode string.
+
+ Returns:
+ NONE
+
+--*/
+;
+
+typedef
+VOID
+(EFIAPI *EFI_UNICODE_COLLATION2_STRUPR) (
+ IN EFI_UNICODE_COLLATION2_PROTOCOL * This,
+ IN OUT CHAR16 *Str
+ )
+/*++
+
+ Routine Description:
+ Converts all the Unicode characters in a Null-terminated Unicode string to upper
+ case Unicode characters.
+
+ Arguments:
+ This - Protocol instance pointer.
+ String - A pointer to a Null-terminated Unicode string.
+
+ Returns:
+ NONE
+
+--*/
+;
+
+typedef
+VOID
+(EFIAPI *EFI_UNICODE_COLLATION2_FATTOSTR) (
+ IN EFI_UNICODE_COLLATION2_PROTOCOL * This,
+ IN UINTN FatSize,
+ IN CHAR8 *Fat,
+ OUT CHAR16 *String
+ )
+/*++
+
+ Routine Description:
+ Converts an 8.3 FAT file name in an OEM character set to a Null-terminated
+ Unicode string.
+
+ Arguments:
+ This - Protocol instance pointer.
+ FatSize - The size of the string Fat in bytes.
+ Fat - A pointer to a Null-terminated string that contains an 8.3 file
+ name using an OEM character set.
+ String - A pointer to a Null-terminated Unicode string. The string must
+ be preallocated to hold FatSize Unicode characters.
+ Returns:
+ NONE
+
+--*/
+;
+
+typedef
+BOOLEAN
+(EFIAPI *EFI_UNICODE_COLLATION2_STRTOFAT) (
+ IN EFI_UNICODE_COLLATION2_PROTOCOL * This,
+ IN CHAR16 *String,
+ IN UINTN FatSize,
+ OUT CHAR8 *Fat
+ )
+/*++
+
+ Routine Description:
+ Converts a Null-terminated Unicode string to legal characters in a FAT
+ filename using an OEM character set.
+
+ Arguments:
+ This - Protocol instance pointer.
+ String - A pointer to a Null-terminated Unicode string. The string must
+ be preallocated to hold FatSize Unicode characters.
+ FatSize - The size of the string Fat in bytes.
+ Fat - A pointer to a Null-terminated string that contains an 8.3 file
+ name using an OEM character set.
+ Returns:
+ TRUE - Fat is a Long File Name
+ FALSE - Fat is an 8.3 file name
+
+--*/
+;
+
+typedef struct _EFI_UNICODE_COLLATION2_PROTOCOL {
+ //
+ // general
+ //
+ EFI_UNICODE_COLLATION2_STRICOLL StriColl;
+ EFI_UNICODE_COLLATION2_METAIMATCH MetaiMatch;
+ EFI_UNICODE_COLLATION2_STRLWR StrLwr;
+ EFI_UNICODE_COLLATION2_STRUPR StrUpr;
+
+ //
+ // for supporting fat volumes
+ //
+ EFI_UNICODE_COLLATION2_FATTOSTR FatToStr;
+ EFI_UNICODE_COLLATION2_STRTOFAT StrToFat;
+
+ CHAR8 *SupportedLanguages;
+} EFI_UNICODE_COLLATION2_PROTOCOL;
+
+extern EFI_GUID gEfiUnicodeCollation2ProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/UsbHostController/UsbHostController.c b/EDK/Foundation/Efi/Protocol/UsbHostController/UsbHostController.c
new file mode 100644
index 0000000..9260c0b
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/UsbHostController/UsbHostController.c
@@ -0,0 +1,30 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ UsbHostController.c
+
+Abstract:
+
+ USB Host Controller protocol.
+
+
+--*/
+
+#include "Tiano.h"
+#include EFI_PROTOCOL_DEFINITION (UsbHostController)
+
+EFI_GUID gEfiUsbHcProtocolGuid = EFI_USB_HC_PROTOCOL_GUID;
+EFI_GUID gEfiUsb2HcProtocolGuid = EFI_USB2_HC_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiUsbHcProtocolGuid, "Usb Host Controller Protocol", "USB 1.1 Host Controller");
+EFI_GUID_STRING(&gEfiUsb2HcProtocolGuid, "Usb2 Host Controller Protocol", "USB 2.0 Host Controller");
diff --git a/EDK/Foundation/Efi/Protocol/UsbHostController/UsbHostController.h b/EDK/Foundation/Efi/Protocol/UsbHostController/UsbHostController.h
new file mode 100644
index 0000000..5a673d8
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/UsbHostController/UsbHostController.h
@@ -0,0 +1,411 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ UsbHostController.h
+
+Abstract:
+
+
+--*/
+
+#ifndef _USB_HOSTCONTROLLER_H_
+#define _USB_HOSTCONTROLLER_H_
+
+#include "usb.h"
+#include EFI_PROTOCOL_DEFINITION (UsbIo)
+
+#define EFI_USB_HC_PROTOCOL_GUID \
+ { \
+ 0xf5089266, 0x1aa0, 0x4953, 0x97, 0xd8, 0x56, 0x2f, 0x8a, 0x73, 0xb5, 0x19 \
+ }
+
+//
+// Forward reference for pure ANSI compatability
+//
+EFI_FORWARD_DECLARATION (EFI_USB_HC_PROTOCOL);
+
+typedef enum {
+ EfiUsbHcStateHalt,
+ EfiUsbHcStateOperational,
+ EfiUsbHcStateSuspend,
+ EfiUsbHcStateMaximum
+} EFI_USB_HC_STATE;
+
+#define EFI_USB_HC_RESET_GLOBAL 0x0001
+#define EFI_USB_HC_RESET_HOST_CONTROLLER 0x0002
+#define EFI_USB_HC_RESET_GLOBAL_WITH_DEBUG 0x0004
+#define EFI_USB_HC_RESET_HOST_WITH_DEBUG 0x0008
+
+//
+// Protocol definitions
+//
+typedef
+EFI_STATUS
+(EFIAPI *EFI_USB_HC_PROTOCOL_RESET) (
+ IN EFI_USB_HC_PROTOCOL * This,
+ IN UINT16 Attributes
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_USB_HC_PROTOCOL_GET_STATE) (
+ IN EFI_USB_HC_PROTOCOL * This,
+ OUT EFI_USB_HC_STATE * State
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_USB_HC_PROTOCOL_SET_STATE) (
+ IN EFI_USB_HC_PROTOCOL * This,
+ IN EFI_USB_HC_STATE State
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_USB_HC_PROTOCOL_CONTROL_TRANSFER) (
+ IN EFI_USB_HC_PROTOCOL * This,
+ IN UINT8 DeviceAddress,
+ IN BOOLEAN IsSlowDevice,
+ IN UINT8 MaximumPacketLength,
+ IN EFI_USB_DEVICE_REQUEST * Request,
+ IN EFI_USB_DATA_DIRECTION TransferDirection,
+ IN OUT VOID *Data OPTIONAL,
+ IN OUT UINTN *DataLength OPTIONAL,
+ IN UINTN TimeOut,
+ OUT UINT32 *TransferResult
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_USB_HC_PROTOCOL_BULK_TRANSFER) (
+ IN EFI_USB_HC_PROTOCOL * This,
+ IN UINT8 DeviceAddress,
+ IN UINT8 EndPointAddress,
+ IN UINT8 MaximumPacketLength,
+ IN OUT VOID *Data,
+ IN OUT UINTN *DataLength,
+ IN OUT UINT8 *DataToggle,
+ IN UINTN TimeOut,
+ OUT UINT32 *TransferResult
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_USB_HC_PROTOCOL_ASYNC_INTERRUPT_TRANSFER) (
+ IN EFI_USB_HC_PROTOCOL * This,
+ IN UINT8 DeviceAddress,
+ IN UINT8 EndPointAddress,
+ IN BOOLEAN IsSlowDevice,
+ IN UINT8 MaxiumPacketLength,
+ IN BOOLEAN IsNewTransfer,
+ IN OUT UINT8 *DataToggle,
+ IN UINTN PollingInterval OPTIONAL,
+ IN UINTN DataLength OPTIONAL,
+ IN EFI_ASYNC_USB_TRANSFER_CALLBACK CallBackFunction OPTIONAL,
+ IN VOID *Context OPTIONAL
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_USB_HC_PROTOCOL_SYNC_INTERRUPT_TRANSFER) (
+ IN EFI_USB_HC_PROTOCOL * This,
+ IN UINT8 DeviceAddress,
+ IN UINT8 EndPointAddress,
+ IN BOOLEAN IsSlowDevice,
+ IN UINT8 MaximumPacketLength,
+ IN OUT VOID *Data,
+ IN OUT UINTN *DataLength,
+ IN OUT UINT8 *DataToggle,
+ IN UINTN TimeOut,
+ OUT UINT32 *TransferResult
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_USB_HC_PROTOCOL_ISOCHRONOUS_TRANSFER) (
+ IN EFI_USB_HC_PROTOCOL * This,
+ IN UINT8 DeviceAddress,
+ IN UINT8 EndPointAddress,
+ IN UINT8 MaximumPacketLength,
+ IN OUT VOID *Data,
+ IN UINTN DataLength,
+ OUT UINT32 *TransferResult
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_USB_HC_PROTOCOL_ASYNC_ISOCHRONOUS_TRANSFER) (
+ IN EFI_USB_HC_PROTOCOL * This,
+ IN UINT8 DeviceAddress,
+ IN UINT8 EndPointAddress,
+ IN UINT8 MaximumPacketLength,
+ IN OUT VOID *Data,
+ IN UINTN DataLength,
+ IN EFI_ASYNC_USB_TRANSFER_CALLBACK IsochronousCallBack,
+ IN VOID *Context OPTIONAL
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_USB_HC_PROTOCOL_GET_ROOTHUB_PORT_NUMBER) (
+ IN EFI_USB_HC_PROTOCOL * This,
+ OUT UINT8 *PortNumber
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_USB_HC_PROTOCOL_GET_ROOTHUB_PORT_STATUS) (
+ IN EFI_USB_HC_PROTOCOL * This,
+ IN UINT8 PortNumber,
+ OUT EFI_USB_PORT_STATUS * PortStatus
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_USB_HC_PROTOCOL_SET_ROOTHUB_PORT_FEATURE) (
+ IN EFI_USB_HC_PROTOCOL * This,
+ IN UINT8 PortNumber,
+ IN EFI_USB_PORT_FEATURE PortFeature
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_USB_HC_PROTOCOL_CLEAR_ROOTHUB_PORT_FEATURE) (
+ IN EFI_USB_HC_PROTOCOL * This,
+ IN UINT8 PortNumber,
+ IN EFI_USB_PORT_FEATURE PortFeature
+ );
+
+typedef struct _EFI_USB_HC_PROTOCOL {
+ EFI_USB_HC_PROTOCOL_RESET Reset;
+ EFI_USB_HC_PROTOCOL_GET_STATE GetState;
+ EFI_USB_HC_PROTOCOL_SET_STATE SetState;
+ EFI_USB_HC_PROTOCOL_CONTROL_TRANSFER ControlTransfer;
+ EFI_USB_HC_PROTOCOL_BULK_TRANSFER BulkTransfer;
+ EFI_USB_HC_PROTOCOL_ASYNC_INTERRUPT_TRANSFER AsyncInterruptTransfer;
+ EFI_USB_HC_PROTOCOL_SYNC_INTERRUPT_TRANSFER SyncInterruptTransfer;
+ EFI_USB_HC_PROTOCOL_ISOCHRONOUS_TRANSFER IsochronousTransfer;
+ EFI_USB_HC_PROTOCOL_ASYNC_ISOCHRONOUS_TRANSFER AsyncIsochronousTransfer;
+ EFI_USB_HC_PROTOCOL_GET_ROOTHUB_PORT_NUMBER GetRootHubPortNumber;
+ EFI_USB_HC_PROTOCOL_GET_ROOTHUB_PORT_STATUS GetRootHubPortStatus;
+ EFI_USB_HC_PROTOCOL_SET_ROOTHUB_PORT_FEATURE SetRootHubPortFeature;
+ EFI_USB_HC_PROTOCOL_CLEAR_ROOTHUB_PORT_FEATURE ClearRootHubPortFeature;
+ UINT16 MajorRevision;
+ UINT16 MinorRevision;
+} EFI_USB_HC_PROTOCOL;
+
+extern EFI_GUID gEfiUsbHcProtocolGuid;
+
+
+#define EFI_USB2_HC_PROTOCOL_GUID \
+ { \
+ 0x3e745226, 0x9818, 0x45b6, 0xa2, 0xac, 0xd7, 0xcd, 0xe, 0x8b, 0xa2, 0xbc \
+ }
+
+//
+// Forward reference for pure ANSI compatability
+//
+EFI_FORWARD_DECLARATION (EFI_USB2_HC_PROTOCOL);
+
+#define EFI_USB_HC_RESET_GLOBAL_WITH_DEBUG 0x0004
+#define EFI_USB_HC_RESET_HOST_WITH_DEBUG 0x0008
+
+typedef struct {
+ UINT8 TranslatorHubAddress;
+ UINT8 TranslatorPortNumber;
+} EFI_USB2_HC_TRANSACTION_TRANSLATOR;
+
+//
+// Protocol definitions
+//
+typedef
+EFI_STATUS
+(EFIAPI *EFI_USB2_HC_PROTOCOL_GET_CAPABILITY) (
+ IN EFI_USB2_HC_PROTOCOL *This,
+ OUT UINT8 *MaxSpeed,
+ OUT UINT8 *PortNumber,
+ OUT UINT8 *Is64BitCapable
+ );
+
+#define EFI_USB_SPEED_FULL 0x0000
+#define EFI_USB_SPEED_LOW 0x0001
+#define EFI_USB_SPEED_HIGH 0x0002
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_USB2_HC_PROTOCOL_RESET) (
+ IN EFI_USB2_HC_PROTOCOL *This,
+ IN UINT16 Attributes
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_USB2_HC_PROTOCOL_GET_STATE) (
+ IN EFI_USB2_HC_PROTOCOL *This,
+ OUT EFI_USB_HC_STATE *State
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_USB2_HC_PROTOCOL_SET_STATE) (
+ IN EFI_USB2_HC_PROTOCOL *This,
+ IN EFI_USB_HC_STATE State
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_USB2_HC_PROTOCOL_CONTROL_TRANSFER) (
+ IN EFI_USB2_HC_PROTOCOL *This,
+ IN UINT8 DeviceAddress,
+ IN UINT8 DeviceSpeed,
+ IN UINTN MaximumPacketLength,
+ IN EFI_USB_DEVICE_REQUEST *Request,
+ IN EFI_USB_DATA_DIRECTION TransferDirection,
+ IN OUT VOID *Data OPTIONAL,
+ IN OUT UINTN *DataLength OPTIONAL,
+ IN UINTN TimeOut,
+ IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,
+ OUT UINT32 *TransferResult
+ );
+
+#define EFI_USB_MAX_BULK_BUFFER_NUM 10
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_USB2_HC_PROTOCOL_BULK_TRANSFER) (
+ IN EFI_USB2_HC_PROTOCOL *This,
+ IN UINT8 DeviceAddress,
+ IN UINT8 EndPointAddress,
+ IN UINT8 DeviceSpeed,
+ IN UINTN MaximumPacketLength,
+ IN UINT8 DataBuffersNumber,
+ IN OUT VOID *Data[EFI_USB_MAX_BULK_BUFFER_NUM],
+ IN OUT UINTN *DataLength,
+ IN OUT UINT8 *DataToggle,
+ IN UINTN TimeOut,
+ IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,
+ OUT UINT32 *TransferResult
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_USB2_HC_PROTOCOL_ASYNC_INTERRUPT_TRANSFER) (
+ IN EFI_USB2_HC_PROTOCOL *This,
+ IN UINT8 DeviceAddress,
+ IN UINT8 EndPointAddress,
+ IN UINT8 DeviceSpeed,
+ IN UINTN MaxiumPacketLength,
+ IN BOOLEAN IsNewTransfer,
+ IN OUT UINT8 *DataToggle,
+ IN UINTN PollingInterval OPTIONAL,
+ IN UINTN DataLength OPTIONAL,
+ IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,
+ IN EFI_ASYNC_USB_TRANSFER_CALLBACK CallBackFunction OPTIONAL,
+ IN VOID *Context OPTIONAL
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_USB2_HC_PROTOCOL_SYNC_INTERRUPT_TRANSFER) (
+ IN EFI_USB2_HC_PROTOCOL *This,
+ IN UINT8 DeviceAddress,
+ IN UINT8 EndPointAddress,
+ IN UINT8 DeviceSpeed,
+ IN UINTN MaximumPacketLength,
+ IN OUT VOID *Data,
+ IN OUT UINTN *DataLength,
+ IN OUT UINT8 *DataToggle,
+ IN UINTN TimeOut,
+ IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,
+ OUT UINT32 *TransferResult
+ );
+
+#define EFI_USB_MAX_ISO_BUFFER_NUM 7
+#define EFI_USB_MAX_ISO_BUFFER_NUM1 2
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_USB2_HC_PROTOCOL_ISOCHRONOUS_TRANSFER) (
+ IN EFI_USB2_HC_PROTOCOL *This,
+ IN UINT8 DeviceAddress,
+ IN UINT8 EndPointAddress,
+ IN UINT8 DeviceSpeed,
+ IN UINTN MaximumPacketLength,
+ IN UINT8 DataBuffersNumber,
+ IN OUT VOID *Data[EFI_USB_MAX_ISO_BUFFER_NUM],
+ IN UINTN DataLength,
+ IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,
+ OUT UINT32 *TransferResult
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_USB2_HC_PROTOCOL_ASYNC_ISOCHRONOUS_TRANSFER) (
+ IN EFI_USB2_HC_PROTOCOL *This,
+ IN UINT8 DeviceAddress,
+ IN UINT8 EndPointAddress,
+ IN UINT8 DeviceSpeed,
+ IN UINTN MaximumPacketLength,
+ IN UINT8 DataBuffersNumber,
+ IN OUT VOID *Data[EFI_USB_MAX_ISO_BUFFER_NUM],
+ IN UINTN DataLength,
+ IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator,
+ IN EFI_ASYNC_USB_TRANSFER_CALLBACK IsochronousCallBack,
+ IN VOID *Context OPTIONAL
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_USB2_HC_PROTOCOL_GET_ROOTHUB_PORT_STATUS) (
+ IN EFI_USB2_HC_PROTOCOL *This,
+ IN UINT8 PortNumber,
+ OUT EFI_USB_PORT_STATUS *PortStatus
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_USB2_HC_PROTOCOL_SET_ROOTHUB_PORT_FEATURE) (
+ IN EFI_USB2_HC_PROTOCOL *This,
+ IN UINT8 PortNumber,
+ IN EFI_USB_PORT_FEATURE PortFeature
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_USB2_HC_PROTOCOL_CLEAR_ROOTHUB_PORT_FEATURE) (
+ IN EFI_USB2_HC_PROTOCOL *This,
+ IN UINT8 PortNumber,
+ IN EFI_USB_PORT_FEATURE PortFeature
+ );
+
+typedef struct _EFI_USB2_HC_PROTOCOL {
+ EFI_USB2_HC_PROTOCOL_GET_CAPABILITY GetCapability;
+ EFI_USB2_HC_PROTOCOL_RESET Reset;
+ EFI_USB2_HC_PROTOCOL_GET_STATE GetState;
+ EFI_USB2_HC_PROTOCOL_SET_STATE SetState;
+ EFI_USB2_HC_PROTOCOL_CONTROL_TRANSFER ControlTransfer;
+ EFI_USB2_HC_PROTOCOL_BULK_TRANSFER BulkTransfer;
+ EFI_USB2_HC_PROTOCOL_ASYNC_INTERRUPT_TRANSFER AsyncInterruptTransfer;
+ EFI_USB2_HC_PROTOCOL_SYNC_INTERRUPT_TRANSFER SyncInterruptTransfer;
+ EFI_USB2_HC_PROTOCOL_ISOCHRONOUS_TRANSFER IsochronousTransfer;
+ EFI_USB2_HC_PROTOCOL_ASYNC_ISOCHRONOUS_TRANSFER AsyncIsochronousTransfer;
+ EFI_USB2_HC_PROTOCOL_GET_ROOTHUB_PORT_STATUS GetRootHubPortStatus;
+ EFI_USB2_HC_PROTOCOL_SET_ROOTHUB_PORT_FEATURE SetRootHubPortFeature;
+ EFI_USB2_HC_PROTOCOL_CLEAR_ROOTHUB_PORT_FEATURE ClearRootHubPortFeature;
+ UINT16 MajorRevision;
+ UINT16 MinorRevision;
+} EFI_USB2_HC_PROTOCOL;
+
+extern EFI_GUID gEfiUsb2HcProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Efi/Protocol/UsbIo/UsbIo.c b/EDK/Foundation/Efi/Protocol/UsbIo/UsbIo.c
new file mode 100644
index 0000000..929eefb
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/UsbIo/UsbIo.c
@@ -0,0 +1,30 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ UsbIo.c
+
+Abstract:
+
+ EFI Usb I/O Protocol
+
+Revision History
+
+--*/
+
+#include "EfiSpec.h"
+
+#include EFI_PROTOCOL_DEFINITION (UsbIo)
+
+EFI_GUID gEfiUsbIoProtocolGuid = EFI_USB_IO_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiUsbIoProtocolGuid, "Usb IO Protocol", "EFI 1.1 Usb IO Protocol");
diff --git a/EDK/Foundation/Efi/Protocol/UsbIo/UsbIo.h b/EDK/Foundation/Efi/Protocol/UsbIo/UsbIo.h
new file mode 100644
index 0000000..1438e49
--- /dev/null
+++ b/EDK/Foundation/Efi/Protocol/UsbIo/UsbIo.h
@@ -0,0 +1,205 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ UsbIo.h
+
+Abstract:
+
+ EFI Usb I/O Protocol
+
+Revision History
+
+--*/
+
+#ifndef _EFI_USB_IO_H
+#define _EFI_USB_IO_H
+
+#include "usb.h"
+
+//
+// Global ID for the USB I/O Protocol
+//
+#define EFI_USB_IO_PROTOCOL_GUID \
+ { \
+ 0x2B2F68D6, 0x0CD2, 0x44cf, 0x8E, 0x8B, 0xBB, 0xA2, 0x0B, 0x1B, 0x5B, 0x75 \
+ }
+
+EFI_FORWARD_DECLARATION (EFI_USB_IO_PROTOCOL);
+
+//
+// Asynchronous USB transfer call back function
+//
+typedef
+EFI_STATUS
+(EFIAPI *EFI_ASYNC_USB_TRANSFER_CALLBACK) (
+ IN VOID *Data,
+ IN UINTN DataLength,
+ IN VOID *Context,
+ IN UINT32 Status
+ );
+
+//
+// Prototype for EFI USB I/O protocol
+//
+typedef
+EFI_STATUS
+(EFIAPI *EFI_USB_IO_CONTROL_TRANSFER) (
+ IN EFI_USB_IO_PROTOCOL * This,
+ IN EFI_USB_DEVICE_REQUEST * Request,
+ IN EFI_USB_DATA_DIRECTION Direction,
+ IN UINT32 Timeout,
+ IN OUT VOID *Data OPTIONAL,
+ IN UINTN DataLength OPTIONAL,
+ OUT UINT32 *Status
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_USB_IO_BULK_TRANSFER) (
+ IN EFI_USB_IO_PROTOCOL * This,
+ IN UINT8 DeviceEndpoint,
+ IN OUT VOID *Data,
+ IN OUT UINTN *DataLength,
+ IN UINTN Timeout,
+ OUT UINT32 *Status
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_USB_IO_ASYNC_INTERRUPT_TRANSFER) (
+ IN EFI_USB_IO_PROTOCOL * This,
+ IN UINT8 DeviceEndpoint,
+ IN BOOLEAN IsNewTransfer,
+ IN UINTN PollingInterval OPTIONAL,
+ IN UINTN DataLength OPTIONAL,
+ IN EFI_ASYNC_USB_TRANSFER_CALLBACK InterruptCallBack OPTIONAL,
+ IN VOID *Context OPTIONAL
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_USB_IO_SYNC_INTERRUPT_TRANSFER) (
+ IN EFI_USB_IO_PROTOCOL * This,
+ IN UINT8 DeviceEndpoint,
+ IN OUT VOID *Data,
+ IN OUT UINTN *DataLength,
+ IN UINTN Timeout,
+ OUT UINT32 *Status
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_USB_IO_ISOCHRONOUS_TRANSFER) (
+ IN EFI_USB_IO_PROTOCOL * This,
+ IN UINT8 DeviceEndpoint,
+ IN OUT VOID *Data,
+ IN UINTN DataLength,
+ OUT UINT32 *Status
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_USB_IO_ASYNC_ISOCHRONOUS_TRANSFER) (
+ IN EFI_USB_IO_PROTOCOL * This,
+ IN UINT8 DeviceEndpoint,
+ IN OUT VOID *Data,
+ IN UINTN DataLength,
+ IN EFI_ASYNC_USB_TRANSFER_CALLBACK IsochronousCallBack,
+ IN VOID *Context OPTIONAL
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_USB_IO_PORT_RESET) (
+ IN EFI_USB_IO_PROTOCOL * This
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_USB_IO_GET_DEVICE_DESCRIPTOR) (
+ IN EFI_USB_IO_PROTOCOL * This,
+ OUT EFI_USB_DEVICE_DESCRIPTOR * DeviceDescriptor
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_USB_IO_GET_CONFIG_DESCRIPTOR) (
+ IN EFI_USB_IO_PROTOCOL * This,
+ OUT EFI_USB_CONFIG_DESCRIPTOR * ConfigurationDescriptor
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_USB_IO_GET_INTERFACE_DESCRIPTOR) (
+ IN EFI_USB_IO_PROTOCOL * This,
+ OUT EFI_USB_INTERFACE_DESCRIPTOR * InterfaceDescriptor
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_USB_IO_GET_ENDPOINT_DESCRIPTOR) (
+ IN EFI_USB_IO_PROTOCOL * This,
+ IN UINT8 EndpointIndex,
+ OUT EFI_USB_ENDPOINT_DESCRIPTOR * EndpointDescriptor
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_USB_IO_GET_STRING_DESCRIPTOR) (
+ IN EFI_USB_IO_PROTOCOL * This,
+ IN UINT16 LangID,
+ IN UINT8 StringID,
+ OUT CHAR16 **String
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_USB_IO_GET_SUPPORTED_LANGUAGE) (
+ IN EFI_USB_IO_PROTOCOL * This,
+ OUT UINT16 **LangIDTable,
+ OUT UINT16 *TableSize
+ );
+
+//
+// Protocol Interface Structure
+//
+typedef struct _EFI_USB_IO_PROTOCOL {
+ //
+ // IO transfer
+ //
+ EFI_USB_IO_CONTROL_TRANSFER UsbControlTransfer;
+ EFI_USB_IO_BULK_TRANSFER UsbBulkTransfer;
+ EFI_USB_IO_ASYNC_INTERRUPT_TRANSFER UsbAsyncInterruptTransfer;
+ EFI_USB_IO_SYNC_INTERRUPT_TRANSFER UsbSyncInterruptTransfer;
+ EFI_USB_IO_ISOCHRONOUS_TRANSFER UsbIsochronousTransfer;
+ EFI_USB_IO_ASYNC_ISOCHRONOUS_TRANSFER UsbAsyncIsochronousTransfer;
+
+ //
+ // Common device request
+ //
+ EFI_USB_IO_GET_DEVICE_DESCRIPTOR UsbGetDeviceDescriptor;
+ EFI_USB_IO_GET_CONFIG_DESCRIPTOR UsbGetConfigDescriptor;
+ EFI_USB_IO_GET_INTERFACE_DESCRIPTOR UsbGetInterfaceDescriptor;
+ EFI_USB_IO_GET_ENDPOINT_DESCRIPTOR UsbGetEndpointDescriptor;
+ EFI_USB_IO_GET_STRING_DESCRIPTOR UsbGetStringDescriptor;
+ EFI_USB_IO_GET_SUPPORTED_LANGUAGE UsbGetSupportedLanguages;
+
+ //
+ // Reset controller's parent port
+ //
+ EFI_USB_IO_PORT_RESET UsbPortReset;
+} EFI_USB_IO_PROTOCOL;
+
+extern EFI_GUID gEfiUsbIoProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Guid/AcpiTableStorage/AcpiTableStorage.c b/EDK/Foundation/Framework/Guid/AcpiTableStorage/AcpiTableStorage.c
new file mode 100644
index 0000000..13c46cd
--- /dev/null
+++ b/EDK/Foundation/Framework/Guid/AcpiTableStorage/AcpiTableStorage.c
@@ -0,0 +1,28 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ AcpiTableStorage.c
+
+Abstract:
+
+ The filename of the Acpi table storage file.
+
+--*/
+
+#include "Tiano.h"
+#include EFI_GUID_DEFINITION (AcpiTableStorage)
+
+EFI_GUID gEfiAcpiTableStorageGuid = EFI_ACPI_TABLE_STORAGE_GUID;
+
+EFI_GUID_STRING (&gEfiAcpiTableStorageGuid, "ACPI Table Storage File Name",
+ "Tiano ACPI 2.0 Table Storage file name GUID");
diff --git a/EDK/Foundation/Framework/Guid/AcpiTableStorage/AcpiTableStorage.h b/EDK/Foundation/Framework/Guid/AcpiTableStorage/AcpiTableStorage.h
new file mode 100644
index 0000000..9c8c065
--- /dev/null
+++ b/EDK/Foundation/Framework/Guid/AcpiTableStorage/AcpiTableStorage.h
@@ -0,0 +1,32 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ AcpiTableStorage.h
+
+Abstract:
+
+ GUID for the ACPI Table Storage filename.
+
+ This GUID is defined in the Tiano ACPI Table Storage EPS.
+
+--*/
+
+#ifndef _ACPI_TABLE_STORAGE_H_
+#define _ACPI_TABLE_STORAGE_H_
+
+#define EFI_ACPI_TABLE_STORAGE_GUID \
+ { 0x7e374e25, 0x8e01, 0x4fee, 0x87, 0xf2, 0x39, 0xc, 0x23, 0xc6, 0x6, 0xcd }
+
+extern EFI_GUID gEfiAcpiTableStorageGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Guid/Apriori/Apriori.c b/EDK/Foundation/Framework/Guid/Apriori/Apriori.c
new file mode 100644
index 0000000..bba2107
--- /dev/null
+++ b/EDK/Foundation/Framework/Guid/Apriori/Apriori.c
@@ -0,0 +1,29 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Apriori.c
+
+Abstract:
+
+ GUID used as an FV filename for A Priori file. The A Priori file contains a
+ list of FV filenames that the DXE dispatcher will schedule reguardless of
+ the dependency grammer.
+
+--*/
+
+#include "Tiano.h"
+#include EFI_GUID_DEFINITION (Apriori)
+
+EFI_GUID gAprioriGuid = EFI_APRIORI_GUID;
+
+EFI_GUID_STRING(&gAprioriGuid, "Apriori File Name", "Apriori File containing FV GUIDs");
diff --git a/EDK/Foundation/Framework/Guid/Apriori/Apriori.h b/EDK/Foundation/Framework/Guid/Apriori/Apriori.h
new file mode 100644
index 0000000..45f0794
--- /dev/null
+++ b/EDK/Foundation/Framework/Guid/Apriori/Apriori.h
@@ -0,0 +1,34 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Apriori.h
+
+Abstract:
+
+ GUID used as an FV filename for A Priori file. The A Priori file contains a
+ list of FV filenames that the DXE dispatcher will schedule reguardless of
+ the dependency grammer.
+
+--*/
+
+#ifndef _APRIORI_GUID_H_
+#define _APRIORI_GUID_H_
+
+#define EFI_APRIORI_GUID \
+ { \
+ 0xfc510ee7, 0xffdc, 0x11d4, 0xbd, 0x41, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 \
+ }
+
+extern EFI_GUID gAprioriGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Guid/DataHubRecords/DataHubRecords.c b/EDK/Foundation/Framework/Guid/DataHubRecords/DataHubRecords.c
new file mode 100644
index 0000000..33cb53e
--- /dev/null
+++ b/EDK/Foundation/Framework/Guid/DataHubRecords/DataHubRecords.c
@@ -0,0 +1,51 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ DataHubRecords.c
+
+Abstract:
+
+ This file defines GUIDs and associated data structures for records
+ posted to the Data Hub.
+ The producers of these records use these definitions to construct
+ records.
+ The consumers of these records use these definitions to retrieve,
+ filter and parse records.
+
+ For more information please look at DataHub.doc
+
+--*/
+
+
+
+#include "Tiano.h"
+#include EFI_GUID_DEFINITION (DataHubRecords)
+
+EFI_GUID gProcessorProducerGuid = EFI_PROCESSOR_PRODUCER_GUID;
+
+EFI_GUID gProcessorSubClassName = EFI_PROCESSOR_SUBCLASS_GUID;
+
+EFI_GUID gCacheSubClassName = EFI_CACHE_SUBCLASS_GUID;
+
+EFI_GUID gMiscProducerGuid = EFI_MISC_PRODUCER_GUID;
+EFI_GUID gMiscSubClassName = EFI_MISC_SUBCLASS_GUID;
+EFI_GUID gEfiMiscSubClassGuid = EFI_MISC_SUBCLASS_GUID;
+
+
+EFI_GUID gMemoryProducerGuid = EFI_MEMORY_PRODUCER_GUID;
+
+EFI_GUID gEfiMemorySubClassGuid = EFI_MEMORY_SUBCLASS_GUID;
+
+
+
+/* eof - DataHubRecords.c */
diff --git a/EDK/Foundation/Framework/Guid/DataHubRecords/DataHubRecords.h b/EDK/Foundation/Framework/Guid/DataHubRecords/DataHubRecords.h
new file mode 100644
index 0000000..fe386be
--- /dev/null
+++ b/EDK/Foundation/Framework/Guid/DataHubRecords/DataHubRecords.h
@@ -0,0 +1,112 @@
+/*++
+
+Copyright (c) 2004 - 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ DataHubRecords.h
+
+Abstract:
+
+ This file defines GUIDs and associated data structures for records
+ posted to the Data Hub.
+ The producers of these records use these definitions to construct
+ records.
+ The consumers of these records use these definitions to retrieve,
+ filter and parse records.
+
+ For more information please look at DataHub.doc
+
+--*/
+
+#ifndef _DATAHUB_RECORDS_H_
+#define _DATAHUB_RECORDS_H_
+
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
+#include "TianoHii.h"
+#else
+#include "EfiInternalFormRepresentation.h"
+#endif
+#include "DataHubSubClass.h"
+#include "DataHubSubClassProcessor.h"
+#include "DataHubSubClassCache.h"
+#include "DataHubSubClassMemory.h"
+#include "DataHubSubClassMisc.h"
+
+/*++
+BEGIN: Processor records definitions
+--*/
+
+extern EFI_GUID gProcessorProducerGuid;
+
+#define EFI_PROCESSOR_PRODUCER_GUID \
+ { 0x1bf06aea, 0x5bec, 0x4a8d, 0x95, 0x76, 0x74, 0x9b, 0x09, 0x56, 0x2d, 0x30 }
+
+
+extern EFI_GUID gProcessorSubClassName;
+
+
+extern EFI_GUID gCacheSubClassName;
+
+
+extern EFI_GUID gMiscSubClassName;
+
+/*++
+END: Processor records definitions
+--*/
+
+
+
+/*++
+BEGIN: Memory records definitions
+--*/
+
+extern EFI_GUID gMemoryProducerGuid;
+
+#define EFI_MEMORY_PRODUCER_GUID \
+ { 0x1d7add6e, 0xb2da, 0x4b0b, 0xb2, 0x9f, 0x49, 0xcb, 0x42, 0xf4, 0x63, 0x56 }
+
+//
+// ... need memory sub classes here...
+//
+extern EFI_GUID gEfiMemorySubClassGuid;
+
+
+
+/*++
+END: Memory records definitions
+--*/
+
+
+/*++
+BEGIN: Misc records definitions
+--*/
+
+extern EFI_GUID gMiscProducerGuid;
+
+#define EFI_MISC_PRODUCER_GUID \
+{ 0x62512c92, 0x63c4, 0x4d80, 0x82, 0xb1, 0xc1, 0xa4, 0xdc, 0x44, 0x80, 0xe5 }
+
+
+
+//
+// ... need misc sub classes here...
+//
+extern EFI_GUID gEfiMiscSubClassGuid;
+
+
+
+
+/*++
+END: Misc records definitions
+--*/
+
+
+#endif
diff --git a/EDK/Foundation/Framework/Guid/DataHubRecords/DataHubSubClass.h b/EDK/Foundation/Framework/Guid/DataHubRecords/DataHubSubClass.h
new file mode 100644
index 0000000..753dc17
--- /dev/null
+++ b/EDK/Foundation/Framework/Guid/DataHubRecords/DataHubSubClass.h
@@ -0,0 +1,73 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ DataHubSubClass.h
+
+Abstract:
+
+ Definitions for data hub data records that contains a sub class header
+
+Revision History
+
+--*/
+
+#ifndef _DATA_HUB_SUBCLASS_H_
+#define _DATA_HUB_SUBCLASS_H_
+
+//
+// Sub Class Header type1
+//
+
+#define EFI_SUBCLASS_INSTANCE_RESERVED 0
+#define EFI_SUBCLASS_INSTANCE_NON_APPLICABLE 0xFFFF //16 bit
+
+typedef struct {
+ UINT32 Version;
+ UINT32 HeaderSize;
+ UINT16 Instance;
+ UINT16 SubInstance;
+ UINT32 RecordType;
+} EFI_SUBCLASS_TYPE1_HEADER;
+
+//
+// EXP data
+//
+
+typedef struct {
+ INT16 Value;
+ INT16 Exponent;
+} EFI_EXP_BASE10_DATA;
+
+typedef struct {
+ UINT16 Value;
+ UINT16 Exponent;
+} EFI_EXP_BASE2_DATA;
+
+//
+// Inter link data that references another data record
+//
+
+typedef struct {
+ EFI_GUID ProducerName;
+ UINT16 Instance;
+ UINT16 SubInstance;
+} EFI_INTER_LINK_DATA;
+
+
+//
+// String Token Definition
+//
+#define EFI_STRING_TOKEN UINT16
+
+
+#endif
diff --git a/EDK/Foundation/Framework/Guid/DataHubRecords/DataHubSubClassCache.h b/EDK/Foundation/Framework/Guid/DataHubRecords/DataHubSubClassCache.h
new file mode 100644
index 0000000..b46a434
--- /dev/null
+++ b/EDK/Foundation/Framework/Guid/DataHubRecords/DataHubSubClassCache.h
@@ -0,0 +1,161 @@
+/*++
+
+Copyright (c) 2004 - 2011, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ DataHubSubClassCache.h
+
+Abstract:
+
+ Definitions for Cache sub class data records
+
+Revision History
+
+--*/
+
+#ifndef _DATAHUB_SUBCLASS_CACHE_H_
+#define _DATAHUB_SUBCLASS_CACHE_H_
+
+#define EFI_CACHE_SUBCLASS_VERSION 0x00010000
+
+#define EFI_CACHE_SUBCLASS_GUID \
+{ 0x7f0013a7, 0xdc79, 0x4b22, 0x80, 0x99, 0x11, 0xf7, 0x5f, 0xdc, 0x82, 0x9d }
+
+typedef EFI_EXP_BASE2_DATA EFI_CACHE_SIZE_DATA;
+
+typedef EFI_EXP_BASE2_DATA EFI_MAXIMUM_CACHE_SIZE_DATA;
+
+typedef EFI_EXP_BASE10_DATA EFI_CACHE_SPEED_DATA;
+
+typedef STRING_REF EFI_CACHE_SOCKET_DATA;
+
+typedef struct {
+ UINT32 Other :1;
+ UINT32 Unknown :1;
+ UINT32 NonBurst :1;
+ UINT32 Burst :1;
+ UINT32 PipelineBurst :1;
+ //
+ // Inconsistent between CacheSubclass 0.9 and SMBIOS specifications here:
+ // In CacheSubclass specification 0.9, the sequence of Asynchronous and Synchronous fileds
+ // are opposite to SMBIOS specification.
+ //
+ UINT32 Asynchronous :1;
+ UINT32 Synchronous :1;
+ UINT32 Reserved :25;
+} EFI_CACHE_SRAM_TYPE_DATA;
+
+typedef enum {
+ EfiCacheErrorOther = 1,
+ EfiCacheErrorUnknown = 2,
+ EfiCacheErrorNone = 3,
+ EfiCacheErrorParity = 4,
+ EfiCacheErrorSingleBit = 5,
+ EfiCacheErrorMultiBit = 6
+} EFI_CACHE_ERROR_TYPE_DATA;
+
+typedef enum {
+ EfiCacheTypeOther = 1,
+ EfiCacheTypeUnknown = 2,
+ EfiCacheTypeInstruction = 3,
+ EfiCacheTypeData = 4,
+ EfiCacheTypeUnified = 5
+} EFI_CACHE_TYPE_DATA;
+
+typedef enum {
+ EfiCacheAssociativityOther = 0x01,
+ EfiCacheAssociativityUnknown = 0x02,
+ EfiCacheAssociativityDirectMapped = 0x03,
+ EfiCacheAssociativity2Way = 0x04,
+ EfiCacheAssociativity4Way = 0x05,
+ EfiCacheAssociativityFully = 0x06,
+ EfiCacheAssociativity8Way = 0x07,
+ EfiCacheAssociativity16Way = 0x08,
+ EfiCacheAssociativity12Way = 0x09,
+ EfiCacheAssociativity24Way = 0x0A,
+ EfiCacheAssociativity32Way = 0x0B,
+ EfiCacheAssociativity48Way = 0x0C,
+ EfiCacheAssociativity64Way = 0x0D
+} EFI_CACHE_ASSOCIATIVITY_DATA;
+
+typedef struct {
+ UINT32 Level :3;
+ UINT32 Socketed :1;
+ UINT32 Reserved2 :1;
+ UINT32 Location :2;
+ UINT32 Enable :1;
+ UINT32 OperationalMode :2;
+ UINT32 Reserved1 :22;
+} EFI_CACHE_CONFIGURATION_DATA;
+
+#define EFI_CACHE_L1 1
+#define EFI_CACHE_L2 2
+#define EFI_CACHE_L3 3
+#define EFI_CACHE_L4 4
+#define EFI_CACHE_LMAX EFI_CACHE_L4
+
+#define EFI_CACHE_SOCKETED 1
+#define EFI_CACHE_NOT_SOCKETED 0
+
+typedef enum {
+ EfiCacheInternal = 0,
+ EfiCacheExternal = 1,
+ EfiCacheReserved = 2,
+ EfiCacheUnknown = 3
+} EFI_CACHE_LOCATION;
+
+#define EFI_CACHE_ENABLED 1
+#define EFI_CACHE_DISABLED 0
+
+typedef enum {
+ EfiCacheWriteThrough = 0,
+ EfiCacheWriteBack = 1,
+ EfiCacheDynamicMode = 2,
+ EfiCacheUnknownMode = 3
+} EFI_CACHE_OPERATIONAL_MODE;
+
+
+
+typedef enum {
+ CacheSizeRecordType = 1,
+ MaximumSizeCacheRecordType = 2,
+ CacheSpeedRecordType = 3,
+ CacheSocketRecordType = 4,
+ CacheSramTypeRecordType = 5,
+ CacheInstalledSramTypeRecordType = 6,
+ CacheErrorTypeRecordType = 7,
+ CacheTypeRecordType = 8,
+ CacheAssociativityRecordType = 9,
+ CacheConfigRecordType = 10
+} EFI_CACHE_VARIABLE_RECORD_TYPE;
+
+
+typedef union {
+ EFI_CACHE_SIZE_DATA CacheSize;
+ EFI_MAXIMUM_CACHE_SIZE_DATA MaximumCacheSize;
+ EFI_CACHE_SPEED_DATA CacheSpeed;
+ EFI_CACHE_SOCKET_DATA CacheSocket;
+ EFI_CACHE_SRAM_TYPE_DATA CacheSramType;
+ EFI_CACHE_SRAM_TYPE_DATA CacheInstalledSramType;
+ EFI_CACHE_ERROR_TYPE_DATA CacheErrorType;
+ EFI_CACHE_TYPE_DATA CacheType;
+ EFI_CACHE_ASSOCIATIVITY_DATA CacheAssociativity;
+ EFI_CACHE_CONFIGURATION_DATA CacheConfig;
+ EFI_CACHE_ASSOCIATION_DATA CacheAssociation;
+} EFI_CACHE_VARIABLE_RECORD;
+
+typedef struct {
+ EFI_SUBCLASS_TYPE1_HEADER DataRecordHeader;
+ EFI_CACHE_VARIABLE_RECORD VariableRecord;
+} EFI_CACHE_DATA_RECORD;
+
+
+#endif
diff --git a/EDK/Foundation/Framework/Guid/DataHubRecords/DataHubSubClassMemory.h b/EDK/Foundation/Framework/Guid/DataHubRecords/DataHubSubClassMemory.h
new file mode 100644
index 0000000..4d3eef7
--- /dev/null
+++ b/EDK/Foundation/Framework/Guid/DataHubRecords/DataHubSubClassMemory.h
@@ -0,0 +1,431 @@
+/*++
+
+Copyright (c) 2004 - 2009, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ DataHubSubClassMemory.h
+
+Abstract:
+
+ Definitions for memory sub class data records
+
+Revision History
+
+--*/
+
+#ifndef _DATAHUB_SUBCLASS_MEMORY_H_
+#define _DATAHUB_SUBCLASS_MEMORY_H_
+
+#include EFI_GUID_DEFINITION (DataHubRecords)
+
+
+#define EFI_MEMORY_SUBCLASS_GUID \
+ {0x4E8F4EBB, 0x64B9, 0x4e05, 0x9B, 0x18, 0x4C, 0xFE, 0x49, 0x23, 0x50, 0x97}
+
+#define EFI_MEMORY_SUBCLASS_VERSION 0x0100
+
+
+#define EFI_MEMORY_SIZE_RECORD_NUMBER 0x00000001
+
+typedef enum _EFI_MEMORY_REGION_TYPE {
+ EfiMemoryRegionMemory = 0x01,
+ EfiMemoryRegionReserved = 0x02,
+ EfiMemoryRegionAcpi = 0x03,
+ EfiMemoryRegionNvs = 0x04
+} EFI_MEMORY_REGION_TYPE;
+
+typedef struct {
+ UINT32 ProcessorNumber;
+ UINT16 StartBusNumber;
+ UINT16 EndBusNumber;
+ EFI_MEMORY_REGION_TYPE MemoryRegionType;
+ EFI_EXP_BASE2_DATA MemorySize;
+ EFI_PHYSICAL_ADDRESS MemoryStartAddress;
+} EFI_MEMORY_SIZE_DATA;
+
+
+#define EFI_MEMORY_ARRAY_LOCATION_RECORD_NUMBER 0x00000002
+
+typedef enum _EFI_MEMORY_ARRAY_LOCATION {
+ EfiMemoryArrayLocationOther = 0x01,
+ EfiMemoryArrayLocationUnknown = 0x02,
+ EfiMemoryArrayLocationSystemBoard = 0x03,
+ EfiMemoryArrayLocationIsaAddonCard = 0x04,
+ EfiMemoryArrayLocationEisaAddonCard = 0x05,
+ EfiMemoryArrayLocationPciAddonCard = 0x06,
+ EfiMemoryArrayLocationMcaAddonCard = 0x07,
+ EfiMemoryArrayLocationPcmciaAddonCard = 0x08,
+ EfiMemoryArrayLocationProprietaryAddonCard = 0x09,
+ EfiMemoryArrayLocationNuBus = 0x0A,
+ EfiMemoryArrayLocationPc98C20AddonCard = 0xA0,
+ EfiMemoryArrayLocationPc98C24AddonCard = 0xA1,
+ EfiMemoryArrayLocationPc98EAddonCard = 0xA2,
+ EfiMemoryArrayLocationPc98LocalBusAddonCard = 0xA3
+} EFI_MEMORY_ARRAY_LOCATION;
+
+typedef enum _EFI_MEMORY_ARRAY_USE {
+ EfiMemoryArrayUseOther = 0x01,
+ EfiMemoryArrayUseUnknown = 0x02,
+ EfiMemoryArrayUseSystemMemory = 0x03,
+ EfiMemoryArrayUseVideoMemory = 0x04,
+ EfiMemoryArrayUseFlashMemory = 0x05,
+ EfiMemoryArrayUseNonVolatileRam = 0x06,
+ EfiMemoryArrayUseCacheMemory = 0x07,
+} EFI_MEMORY_ARRAY_USE;
+
+typedef enum _EFI_MEMORY_ERROR_CORRECTION {
+ EfiMemoryErrorCorrectionOther = 0x01,
+ EfiMemoryErrorCorrectionUnknown = 0x02,
+ EfiMemoryErrorCorrectionNone = 0x03,
+ EfiMemoryErrorCorrectionParity = 0x04,
+ EfiMemoryErrorCorrectionSingleBitEcc = 0x05,
+ EfiMemoryErrorCorrectionMultiBitEcc = 0x06,
+ EfiMemoryErrorCorrectionCrc = 0x07,
+} EFI_MEMORY_ERROR_CORRECTION;
+
+typedef struct {
+ EFI_MEMORY_ARRAY_LOCATION MemoryArrayLocation;
+ EFI_MEMORY_ARRAY_USE MemoryArrayUse;
+ EFI_MEMORY_ERROR_CORRECTION MemoryErrorCorrection;
+ UINT32 MaximumMemoryCapacity;
+ UINT16 NumberMemoryDevices;
+} EFI_MEMORY_ARRAY_LOCATION_DATA;
+
+
+#define EFI_MEMORY_ARRAY_LINK_RECORD_NUMBER 0x00000003
+
+typedef enum _EFI_MEMORY_FORM_FACTOR {
+ EfiMemoryFormFactorOther = 0x01,
+ EfiMemoryFormFactorUnknown = 0x02,
+ EfiMemoryFormFactorSimm = 0x03,
+ EfiMemoryFormFactorSip = 0x04,
+ EfiMemoryFormFactorChip = 0x05,
+ EfiMemoryFormFactorDip = 0x06,
+ EfiMemoryFormFactorZip = 0x07,
+ EfiMemoryFormFactorProprietaryCard = 0x08,
+ EfiMemoryFormFactorDimm = 0x09,
+ EfiMemoryFormFactorTsop = 0x0A,
+ EfiMemoryFormFactorRowOfChips = 0x0B,
+ EfiMemoryFormFactorRimm = 0x0C,
+ EfiMemoryFormFactorSodimm = 0x0D,
+ EfiMemoryFormFactorSrimm = 0x0E,
+ EfiMemoryFormFactorFbDimm = 0x0F
+} EFI_MEMORY_FORM_FACTOR;
+
+typedef enum _EFI_MEMORY_ARRAY_TYPE {
+ EfiMemoryTypeOther = 0x01,
+ EfiMemoryTypeUnknown = 0x02,
+ EfiMemoryTypeDram = 0x03,
+ EfiMemoryTypeEdram = 0x04,
+ EfiMemoryTypeVram = 0x05,
+ EfiMemoryTypeSram = 0x06,
+ EfiMemoryTypeRam = 0x07,
+ EfiMemoryTypeRom = 0x08,
+ EfiMemoryTypeFlash = 0x09,
+ EfiMemoryTypeEeprom = 0x0A,
+ EfiMemoryTypeFeprom = 0x0B,
+ EfiMemoryTypeEprom = 0x0C,
+ EfiMemoryTypeCdram = 0x0D,
+ EfiMemoryType3Dram = 0x0E,
+ EfiMemoryTypeSdram = 0x0F,
+ EfiMemoryTypeSgram = 0x10,
+ EfiMemoryTypeRdram = 0x11,
+ EfiMemoryTypeDdr = 0x12,
+ EfiMemoryTypeDdr2 = 0x13,
+ EfiMemoryTypeDdr2FbDimm = 0x14,
+ EfiMemoryTypeDdr3 = 0x18,
+ EfiMemoryTypeFbd2 = 0x19
+} EFI_MEMORY_ARRAY_TYPE;
+
+typedef struct {
+ UINT32 Reserved :1;
+ UINT32 Other :1;
+ UINT32 Unknown :1;
+ UINT32 FastPaged :1;
+ UINT32 StaticColumn :1;
+ UINT32 PseudoStatic :1;
+ UINT32 Rambus :1;
+ UINT32 Synchronous :1;
+ UINT32 Cmos :1;
+ UINT32 Edo :1;
+ UINT32 WindowDram :1;
+ UINT32 CacheDram :1;
+ UINT32 Nonvolatile :1;
+ UINT32 Reserved1 :19;
+} EFI_MEMORY_TYPE_DETAIL;
+
+typedef enum {
+ EfiMemoryStateEnabled =0,
+ EfiMemoryStateUnknown,
+ EfiMemoryStateUnsupported,
+ EfiMemoryStateError,
+ EfiMemoryStateAbsent,
+ EfiMemoryStateDisabled,
+ EfiMemoryStatePartial
+} EFI_MEMORY_STATE;
+
+typedef struct {
+ EFI_STRING_TOKEN MemoryDeviceLocator;
+ EFI_STRING_TOKEN MemoryBankLocator;
+ EFI_STRING_TOKEN MemoryManufacturer;
+ EFI_STRING_TOKEN MemorySerialNumber;
+ EFI_STRING_TOKEN MemoryAssetTag;
+ EFI_STRING_TOKEN MemoryPartNumber;
+ EFI_INTER_LINK_DATA MemoryArrayLink;
+ EFI_INTER_LINK_DATA MemorySubArrayLink;
+ UINT16 MemoryTotalWidth;
+ UINT16 MemoryDataWidth;
+ UINT64 MemoryDeviceSize;
+ EFI_MEMORY_FORM_FACTOR MemoryFormFactor;
+ UINT8 MemoryDeviceSet;
+ EFI_MEMORY_ARRAY_TYPE MemoryType;
+ EFI_MEMORY_TYPE_DETAIL MemoryTypeDetail;
+ UINT16 MemorySpeed;
+ EFI_MEMORY_STATE MemoryState;
+ UINT8 MemoryAttributes;
+ UINT8 MemoryBankConnections;
+ UINT8 MemoryErrorStatus;
+} EFI_MEMORY_ARRAY_LINK;
+
+
+#define EFI_MEMORY_ARRAY_START_ADDRESS_RECORD_NUMBER 0x00000004
+
+typedef struct {
+ EFI_PHYSICAL_ADDRESS MemoryArrayStartAddress;
+ EFI_PHYSICAL_ADDRESS MemoryArrayEndAddress;
+ EFI_INTER_LINK_DATA PhysicalMemoryArrayLink;
+ UINT16 MemoryArrayPartitionWidth;
+} EFI_MEMORY_ARRAY_START_ADDRESS;
+
+
+#define EFI_MEMORY_DEVICE_START_ADDRESS_RECORD_NUMBER 0x00000005
+
+typedef struct {
+ EFI_PHYSICAL_ADDRESS MemoryDeviceStartAddress;
+ EFI_PHYSICAL_ADDRESS MemoryDeviceEndAddress;
+ EFI_INTER_LINK_DATA PhysicalMemoryDeviceLink;
+ EFI_INTER_LINK_DATA PhysicalMemoryArrayLink;
+ UINT8 MemoryDevicePartitionRowPosition;
+ UINT8 MemoryDeviceInterleavePosition;
+ UINT8 MemoryDeviceInterleaveDataDepth;
+} EFI_MEMORY_DEVICE_START_ADDRESS;
+
+
+//
+// Memory. Channel Device Type - SMBIOS Type 37
+//
+
+#define EFI_MEMORY_CHANNEL_TYPE_RECORD_NUMBER 0x00000006
+
+typedef enum _EFI_MEMORY_CHANNEL_TYPE {
+ EfiMemoryChannelTypeOther = 1,
+ EfiMemoryChannelTypeUnknown = 2,
+ EfiMemoryChannelTypeRambus = 3,
+ EfiMemoryChannelTypeSyncLink = 4
+} EFI_MEMORY_CHANNEL_TYPE;
+
+typedef struct {
+ EFI_MEMORY_CHANNEL_TYPE MemoryChannelType;
+ UINT8 MemoryChannelMaximumLoad;
+ UINT8 MemoryChannelDeviceCount;
+} EFI_MEMORY_CHANNEL_TYPE_DATA;
+
+#define EFI_MEMORY_CHANNEL_DEVICE_RECORD_NUMBER 0x00000007
+
+typedef struct {
+ UINT8 DeviceId;
+ EFI_INTER_LINK_DATA DeviceLink;
+ UINT8 MemoryChannelDeviceLoad;
+} EFI_MEMORY_CHANNEL_DEVICE_DATA;
+
+//
+// Memory. Controller Information - SMBIOS Type 5
+//
+#define EFI_MEMORY_CONTROLLER_INFORMATION_RECORD_NUMBER 0x00000008
+
+typedef enum {
+ EfiErrorDetectingMethodOther = 1,
+ EfiErrorDetectingMethodUnknown = 2,
+ EfiErrorDetectingMethodNone = 3,
+ EfiErrorDetectingMethodParity = 4,
+ EfiErrorDetectingMethod32Ecc = 5,
+ EfiErrorDetectingMethod64Ecc = 6,
+ EfiErrorDetectingMethod128Ecc = 7,
+ EfiErrorDetectingMethodCrc = 8
+} EFI_MEMORY_ERROR_DETECT_METHOD_TYPE;
+
+typedef struct {
+ UINT8 Other :1;
+ UINT8 Unknown :1;
+ UINT8 None :1;
+ UINT8 SingleBitErrorCorrect :1;
+ UINT8 DoubleBitErrorCorrect :1;
+ UINT8 ErrorScrubbing :1;
+ UINT8 Reserved :2;
+} EFI_MEMORY_ERROR_CORRECT_CAPABILITY;
+
+typedef enum {
+ EfiMemoryInterleaveOther = 1,
+ EfiMemoryInterleaveUnknown = 2,
+ EfiMemoryInterleaveOneWay = 3,
+ EfiMemoryInterleaveTwoWay = 4,
+ EfiMemoryInterleaveFourWay = 5,
+ EfiMemoryInterleaveEightWay = 6,
+ EfiMemoryInterleaveSixteenWay = 7
+} EFI_MEMORY_SUPPORT_INTERLEAVE_TYPE;
+
+typedef struct {
+ UINT16 Other :1;
+ UINT16 Unknown :1;
+ UINT16 SeventyNs :1;
+ UINT16 SixtyNs :1;
+ UINT16 FiftyNs :1;
+ UINT16 Reserved :11;
+} EFI_MEMORY_SPEED_TYPE;
+
+typedef struct {
+ UINT16 Other :1;
+ UINT16 Unknown :1;
+ UINT16 Standard :1;
+ UINT16 FastPageMode :1;
+ UINT16 EDO :1;
+ UINT16 Parity :1;
+ UINT16 ECC :1;
+ UINT16 SIMM :1;
+ UINT16 DIMM :1;
+ UINT16 BurstEdo :1;
+ UINT16 SDRAM :1;
+ UINT16 Reserved :5;
+} EFI_MEMORY_SUPPORTED_TYPE;
+
+typedef struct {
+ UINT8 Five :1;
+ UINT8 Three :1;
+ UINT8 Two :1;
+ UINT8 Reserved :5;
+} EFI_MEMORY_MODULE_VOLTAGE_TYPE;
+
+//
+// EFI_MEMORY_CONTROLLER_INFORMATION is obsolete
+// Use EFI_MEMORY_CONTROLLER_INFORMATION_DATA instead
+//
+typedef struct {
+ EFI_MEMORY_ERROR_DETECT_METHOD_TYPE ErrorDetectingMethod;
+ EFI_MEMORY_ERROR_CORRECT_CAPABILITY ErrorCorrectingCapability;
+ EFI_MEMORY_SUPPORT_INTERLEAVE_TYPE MemorySupportedInterleave;
+ EFI_MEMORY_SUPPORT_INTERLEAVE_TYPE MemoryCurrentInterleave;
+ UINT8 MaxMemoryModuleSize;
+ EFI_MEMORY_SPEED_TYPE MemorySpeedType;
+ EFI_MEMORY_SUPPORTED_TYPE MemorySupportedType;
+ EFI_MEMORY_MODULE_VOLTAGE_TYPE MemoryModuleVoltage;
+ UINT8 NumberofMemorySlot;
+ EFI_MEMORY_ERROR_CORRECT_CAPABILITY EnabledCorrectingCapability;
+ UINT16 *MemoryModuleConfigHandles;
+} EFI_MEMORY_CONTROLLER_INFORMATION;
+
+typedef struct {
+ EFI_MEMORY_ERROR_DETECT_METHOD_TYPE ErrorDetectingMethod;
+ EFI_MEMORY_ERROR_CORRECT_CAPABILITY ErrorCorrectingCapability;
+ EFI_MEMORY_SUPPORT_INTERLEAVE_TYPE MemorySupportedInterleave;
+ EFI_MEMORY_SUPPORT_INTERLEAVE_TYPE MemoryCurrentInterleave;
+ UINT8 MaxMemoryModuleSize;
+ EFI_MEMORY_SPEED_TYPE MemorySpeedType;
+ EFI_MEMORY_SUPPORTED_TYPE MemorySupportedType;
+ EFI_MEMORY_MODULE_VOLTAGE_TYPE MemoryModuleVoltage;
+ UINT8 NumberofMemorySlot;
+ EFI_MEMORY_ERROR_CORRECT_CAPABILITY EnabledCorrectingCapability;
+ EFI_INTER_LINK_DATA MemoryModuleConfig[1];
+} EFI_MEMORY_CONTROLLER_INFORMATION_DATA;
+
+//
+// Memory. Error Information - SMBIOS Type 18
+//
+#define EFI_MEMORY_32BIT_ERROR_INFORMATION_RECORD_NUMBER 0x00000009
+
+typedef enum {
+ EfiMemoryErrorOther = 1,
+ EfiMemoryErrorUnknown = 2,
+ EfiMemoryErrorOk = 3,
+ EfiMemoryErrorBadRead = 4,
+ EfiMemoryErrorParity = 5,
+ EfiMemoryErrorSigleBit = 6,
+ EfiMemoryErrorDoubleBit = 7,
+ EfiMemoryErrorMultiBit = 8,
+ EfiMemoryErrorNibble = 9,
+ EfiMemoryErrorChecksum = 10,
+ EfiMemoryErrorCrc = 11,
+ EfiMemoryErrorCorrectSingleBit = 12,
+ EfiMemoryErrorCorrected = 13,
+ EfiMemoryErrorUnCorrectable = 14
+} EFI_MEMORY_ERROR_TYPE;
+
+typedef enum {
+ EfiMemoryGranularityOther = 1,
+ EfiMemoryGranularityOtherUnknown = 2,
+ EfiMemoryGranularityDeviceLevel = 3,
+ EfiMemoryGranularityMemPartitionLevel = 4
+} EFI_MEMORY_ERROR_GRANULARITY_TYPE;
+
+typedef enum {
+ EfiMemoryErrorOperationOther = 1,
+ EfiMemoryErrorOperationUnknown = 2,
+ EfiMemoryErrorOperationRead = 3,
+ EfiMemoryErrorOperationWrite = 4,
+ EfiMemoryErrorOperationPartialWrite = 5
+} EFI_MEMORY_ERROR_OPERATION_TYPE;
+
+typedef struct {
+ EFI_MEMORY_ERROR_TYPE MemoryErrorType;
+ EFI_MEMORY_ERROR_GRANULARITY_TYPE MemoryErrorGranularity;
+ EFI_MEMORY_ERROR_OPERATION_TYPE MemoryErrorOperation;
+ UINT32 VendorSyndrome;
+ UINT32 MemoryArrayErrorAddress;
+ UINT32 DeviceErrorAddress;
+ UINT32 DeviceErrorResolution;
+} EFI_MEMORY_32BIT_ERROR_INFORMATION;
+
+//
+// Memory. Error Information - SMBIOS Type 33
+//
+#define EFI_MEMORY_64BIT_ERROR_INFORMATION_RECORD_NUMBER 0x0000000A
+
+typedef struct {
+ EFI_MEMORY_ERROR_TYPE MemoryErrorType;
+ EFI_MEMORY_ERROR_GRANULARITY_TYPE MemoryErrorGranularity;
+ EFI_MEMORY_ERROR_OPERATION_TYPE MemoryErrorOperation;
+ UINT32 VendorSyndrome;
+ UINT64 MemoryArrayErrorAddress;
+ UINT64 DeviceErrorAddress;
+ UINT32 DeviceErrorResolution;
+} EFI_MEMORY_64BIT_ERROR_INFORMATION;
+
+
+typedef union _EFI_MEMORY_SUBCLASS_RECORDS {
+ EFI_MEMORY_SIZE_DATA SizeData;
+ EFI_MEMORY_ARRAY_LOCATION_DATA ArrayLocationData;
+ EFI_MEMORY_ARRAY_LINK ArrayLink;
+ EFI_MEMORY_ARRAY_START_ADDRESS ArrayStartAddress;
+ EFI_MEMORY_DEVICE_START_ADDRESS DeviceStartAddress;
+ EFI_MEMORY_CHANNEL_TYPE_DATA ChannelTypeData;
+ EFI_MEMORY_CHANNEL_DEVICE_DATA ChannelDeviceData;
+ EFI_MEMORY_CONTROLLER_INFORMATION MemoryControllerInfo;
+ EFI_MEMORY_32BIT_ERROR_INFORMATION Memory32bitErrorInfo;
+ EFI_MEMORY_64BIT_ERROR_INFORMATION Memory64bitErrorInfo;
+} EFI_MEMORY_SUBCLASS_RECORDS;
+
+typedef struct {
+ EFI_SUBCLASS_TYPE1_HEADER Header;
+ EFI_MEMORY_SUBCLASS_RECORDS Record;
+} EFI_MEMORY_SUBCLASS_DRIVER_DATA;
+
+
+
+#endif
diff --git a/EDK/Foundation/Framework/Guid/DataHubRecords/DataHubSubClassMisc.h b/EDK/Foundation/Framework/Guid/DataHubRecords/DataHubSubClassMisc.h
new file mode 100644
index 0000000..368c91c
--- /dev/null
+++ b/EDK/Foundation/Framework/Guid/DataHubRecords/DataHubSubClassMisc.h
@@ -0,0 +1,1260 @@
+/*++
+
+Copyright (c) 2004 - 2009, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ DataHubSubClassMisc.h
+
+Abstract:
+
+ Definitions for Misc sub class data records
+
+Revision History
+
+--*/
+
+#ifndef _DATAHUB_SUBCLASS_MISC_H_
+#define _DATAHUB_SUBCLASS_MISC_H_
+
+#include EFI_GUID_DEFINITION(DataHubRecords)
+
+#define EFI_MISC_SUBCLASS_GUID \
+{ 0x772484B2, 0x7482, 0x4b91, 0x9F, 0x9A, 0xAD, 0x43, 0xF8, 0x1C, 0x58, 0x81 }
+
+#define EFI_MISC_SUBCLASS_VERSION 0x0100
+
+#pragma pack(1)
+//
+//////////////////////////////////////////////////////////////////////////////
+//
+// Last PCI Bus Number
+//
+#define EFI_MISC_LAST_PCI_BUS_RECORD_NUMBER 0x00000001
+
+typedef struct {
+ UINT8 LastPciBus;
+} EFI_MISC_LAST_PCI_BUS;
+
+typedef struct {
+ UINT8 FunctionNum :3;
+ UINT8 DeviceNum :5;
+} EFI_MISC_DEV_FUNC_NUM;
+
+//
+//////////////////////////////////////////////////////////////////////////////
+//
+// Misc. BIOS Vendor - SMBIOS Type 0
+//
+#define EFI_MISC_BIOS_VENDOR_RECORD_NUMBER 0x00000002
+
+typedef struct {
+ UINT32 Reserved1 :2;
+ UINT32 Unknown :1;
+ UINT32 BiosCharacteristicsNotSupported :1;
+ UINT32 IsaIsSupported :1;
+ UINT32 McaIsSupported :1;
+ UINT32 EisaIsSupported :1;
+ UINT32 PciIsSupported :1;
+ UINT32 PcmciaIsSupported :1;
+ UINT32 PlugAndPlayIsSupported :1;
+ UINT32 ApmIsSupported :1;
+ UINT32 BiosIsUpgradable :1;
+ UINT32 BiosShadowingAllowed :1;
+ UINT32 VlVesaIsSupported :1;
+ UINT32 EscdSupportIsAvailable :1;
+ UINT32 BootFromCdIsSupported :1;
+ UINT32 SelectableBootIsSupported :1;
+ UINT32 RomBiosIsSocketed :1;
+ UINT32 BootFromPcmciaIsSupported :1;
+ UINT32 EDDSpecificationIsSupported :1;
+ UINT32 JapaneseNecFloppyIsSupported :1;
+ UINT32 JapaneseToshibaFloppyIsSupported :1;
+ UINT32 Floppy525_360IsSupported :1;
+ UINT32 Floppy525_12IsSupported :1;
+ UINT32 Floppy35_720IsSupported :1;
+ UINT32 Floppy35_288IsSupported :1;
+ UINT32 PrintScreenIsSupported :1;
+ UINT32 Keyboard8042IsSupported :1;
+ UINT32 SerialIsSupported :1;
+ UINT32 PrinterIsSupported :1;
+ UINT32 CgaMonoIsSupported :1;
+ UINT32 NecPc98 :1;
+ UINT32 AcpiIsSupported :1;
+ UINT32 UsbLegacyIsSupported :1;
+ UINT32 AgpIsSupported :1;
+ UINT32 I20BootIsSupported :1;
+ UINT32 Ls120BootIsSupported :1;
+ UINT32 AtapiZipDriveBootIsSupported :1;
+ UINT32 Boot1394IsSupported :1;
+ UINT32 SmartBatteryIsSupported :1;
+ UINT32 BiosBootSpecIsSupported :1;
+ UINT32 FunctionKeyNetworkBootIsSupported :1;
+ UINT32 TargetContentDistributionEnabled :1;
+ UINT32 Reserved :21;
+} EFI_MISC_BIOS_CHARACTERISTICS;
+
+typedef struct {
+ UINT32 BiosReserved :16;
+ UINT32 SystemReserved :16;
+ UINT32 Reserved :32;
+} EFI_MISC_BIOS_CHARACTERISTICS_EXTENSION;
+
+typedef UINT8 EFI_MISC_BIOS_MAJOR_RELEASE;
+typedef UINT8 EFI_MISC_BIOS_MINOR_RELEASE;
+typedef UINT8 EFI_MISC_FIRM_MAJOR_RELEASE;
+typedef UINT8 EFI_MISC_FIRM_MINOR_RELEASE;
+
+typedef struct {
+ STRING_REF BiosVendor;
+ STRING_REF BiosVersion;
+ STRING_REF BiosReleaseDate;
+ EFI_PHYSICAL_ADDRESS BiosStartingAddress;
+ EFI_EXP_BASE2_DATA BiosPhysicalDeviceSize;
+ EFI_MISC_BIOS_CHARACTERISTICS BiosCharacteristics1;
+ EFI_MISC_BIOS_CHARACTERISTICS_EXTENSION BiosCharacteristics2;
+ UINT8 BiosMajorRelease;
+ UINT8 BiosMinorRelease;
+ UINT8 BiosEmbeddedFirmwareMajorRelease;
+ UINT8 BiosEmbeddedFirmwareMinorRelease;
+} EFI_MISC_BIOS_VENDOR;
+
+//
+//////////////////////////////////////////////////////////////////////////////
+//
+// Misc. System Manufacturer - SMBIOS Type 1
+//
+#define EFI_MISC_SYSTEM_MANUFACTURER_RECORD_NUMBER 0x00000003
+
+typedef enum {
+ EfiSystemWakeupTypeReserved = 0,
+ EfiSystemWakeupTypeOther = 1,
+ EfiSystemWakeupTypeUnknown = 2,
+ EfiSystemWakeupTypeApmTimer = 3,
+ EfiSystemWakeupTypeModemRing = 4,
+ EfiSystemWakeupTypeLanRemote = 5,
+ EfiSystemWakeupTypePowerSwitch = 6,
+ EfiSystemWakeupTypePciPme = 7,
+ EfiSystemWakeupTypeAcPowerRestored = 8,
+} EFI_MISC_SYSTEM_WAKEUP_TYPE;
+
+typedef struct {
+ STRING_REF SystemManufacturer;
+ STRING_REF SystemProductName;
+ STRING_REF SystemVersion;
+ STRING_REF SystemSerialNumber;
+ EFI_GUID SystemUuid;
+ EFI_MISC_SYSTEM_WAKEUP_TYPE SystemWakeupType;
+ STRING_REF SystemSKUNumber;
+ STRING_REF SystemFamily;
+} EFI_MISC_SYSTEM_MANUFACTURER;
+
+//
+//////////////////////////////////////////////////////////////////////////////
+//
+// Misc. Base Board Manufacturer - SMBIOS Type 2
+//
+#define EFI_MISC_BASE_BOARD_MANUFACTURER_RECORD_NUMBER 0x00000004
+
+typedef struct {
+ UINT32 Motherboard :1;
+ UINT32 RequiresDaughterCard :1;
+ UINT32 Removable :1;
+ UINT32 Replaceable :1;
+ UINT32 HotSwappable :1;
+ UINT32 Reserved :27;
+} EFI_BASE_BOARD_FEATURE_FLAGS;
+
+typedef enum {
+ EfiBaseBoardTypeUnknown = 1,
+ EfiBaseBoardTypeOther = 2,
+ EfiBaseBoardTypeServerBlade = 3,
+ EfiBaseBoardTypeConnectivitySwitch = 4,
+ EfiBaseBoardTypeSystemManagementModule = 5,
+ EfiBaseBoardTypeProcessorModule = 6,
+ EfiBaseBoardTypeIOModule = 7,
+ EfiBaseBoardTypeMemoryModule = 8,
+ EfiBaseBoardTypeDaughterBoard = 9,
+ EfiBaseBoardTypeMotherBoard = 0xA,
+ EfiBaseBoardTypeProcessorMemoryModule = 0xB,
+ EfiBaseBoardTypeProcessorIOModule = 0xC,
+ EfiBaseBoardTypeInterconnectBoard = 0xD,
+} EFI_BASE_BOARD_TYPE;
+
+typedef struct {
+ STRING_REF BaseBoardManufacturer;
+ STRING_REF BaseBoardProductName;
+ STRING_REF BaseBoardVersion;
+ STRING_REF BaseBoardSerialNumber;
+ STRING_REF BaseBoardAssetTag;
+ STRING_REF BaseBoardChassisLocation;
+ EFI_BASE_BOARD_FEATURE_FLAGS BaseBoardFeatureFlags;
+ EFI_BASE_BOARD_TYPE BaseBoardType;
+ EFI_INTER_LINK_DATA BaseBoardChassisLink;
+ UINT32 BaseBoardNumberLinks;
+ EFI_INTER_LINK_DATA LinkN;
+} EFI_MISC_BASE_BOARD_MANUFACTURER;
+
+//
+//////////////////////////////////////////////////////////////////////////////
+//
+// Misc. System/Chassis Enclosure - SMBIOS Type 3
+//
+#define EFI_MISC_CHASSIS_MANUFACTURER_RECORD_NUMBER 0x00000005
+
+typedef enum {
+ EfiMiscChassisTypeOther = 0x1,
+ EfiMiscChassisTypeUnknown = 0x2,
+ EfiMiscChassisTypeDeskTop = 0x3,
+ EfiMiscChassisTypeLowProfileDesktop = 0x4,
+ EfiMiscChassisTypePizzaBox = 0x5,
+ EfiMiscChassisTypeMiniTower = 0x6,
+ EfiMiscChassisTypeTower = 0x7,
+ EfiMiscChassisTypePortable = 0x8,
+ EfiMiscChassisTypeLapTop = 0x9,
+ EfiMiscChassisTypeNotebook = 0xA,
+ EfiMiscChassisTypeHandHeld = 0xB,
+ EfiMiscChassisTypeDockingStation = 0xC,
+ EfiMiscChassisTypeAllInOne = 0xD,
+ EfiMiscChassisTypeSubNotebook = 0xE,
+ EfiMiscChassisTypeSpaceSaving = 0xF,
+ EfiMiscChassisTypeLunchBox = 0x10,
+ EfiMiscChassisTypeMainServerChassis = 0x11,
+ EfiMiscChassisTypeExpansionChassis = 0x12,
+ EfiMiscChassisTypeSubChassis = 0x13,
+ EfiMiscChassisTypeBusExpansionChassis = 0x14,
+ EfiMiscChassisTypePeripheralChassis = 0x15,
+ EfiMiscChassisTypeRaidChassis = 0x16,
+ EfiMiscChassisTypeRackMountChassis = 0x17,
+ EfiMiscChassisTypeSealedCasePc = 0x18,
+ EfiMiscChassisMultiSystemChassis = 0x19,
+ EfiMiscChassisCompactPCI = 0x1A,
+ EfiMiscChassisAdvancedTCA = 0x1B,
+ EfiMiscChassisBlade = 0x1C,
+ EfiMiscChassisBladeEnclosure = 0x1D
+} EFI_MISC_CHASSIS_TYPE;
+
+typedef struct {
+ UINT32 ChassisType :16;
+ UINT32 ChassisLockPresent:1;
+ UINT32 Reserved :15;
+} EFI_MISC_CHASSIS_STATUS;
+
+typedef enum {
+ EfiChassisStateOther = 1,
+ EfiChassisStateUnknown = 2,
+ EfiChassisStateSafe = 3,
+ EfiChassisStateWarning = 4,
+ EfiChassisStateCritical = 5,
+ EfiChassisStateNonRecoverable = 6,
+} EFI_MISC_CHASSIS_STATE;
+
+typedef enum {
+ EfiChassisSecurityStatusOther = 1,
+ EfiChassisSecurityStatusUnknown = 2,
+ EfiChassisSecurityStatusNone = 3,
+ EfiChassisSecurityStatusExternalInterfaceLockedOut = 4,
+ EfiChassisSecurityStatusExternalInterfaceLockedEnabled = 5,
+} EFI_MISC_CHASSIS_SECURITY_STATE;
+
+typedef struct {
+ UINT32 RecordType :1;
+ UINT32 Type :7;
+ UINT32 Reserved :24;
+} EFI_MISC_ELEMENT_TYPE;
+
+typedef struct {
+ EFI_MISC_ELEMENT_TYPE ChassisElementType;
+ EFI_INTER_LINK_DATA ChassisElementStructure;
+ EFI_BASE_BOARD_TYPE ChassisBaseBoard;
+ UINT32 ChassisElementMinimum;
+ UINT32 ChassisElementMaximum;
+} EFI_MISC_ELEMENTS;
+
+typedef struct {
+ STRING_REF ChassisManufacturer;
+ STRING_REF ChassisVersion;
+ STRING_REF ChassisSerialNumber;
+ STRING_REF ChassisAssetTag;
+ EFI_MISC_CHASSIS_STATUS ChassisType;
+ EFI_MISC_CHASSIS_STATE ChassisBootupState;
+ EFI_MISC_CHASSIS_STATE ChassisPowerSupplyState;
+ EFI_MISC_CHASSIS_STATE ChassisThermalState;
+ EFI_MISC_CHASSIS_SECURITY_STATE ChassisSecurityState;
+ UINT32 ChassisOemDefined;
+ UINT32 ChassisHeight;
+ UINT32 ChassisNumberPowerCords;
+ UINT32 ChassisElementCount;
+ UINT32 ChassisElementRecordLength;//
+ EFI_MISC_ELEMENTS ChassisElements;
+} EFI_MISC_CHASSIS_MANUFACTURER;
+
+//
+//////////////////////////////////////////////////////////////////////////////
+//
+// Misc. Port Connector Information - SMBIOS Type 8
+//
+#define EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_RECORD_NUMBER 0x00000006
+
+typedef enum {
+ EfiPortConnectorTypeNone = 0x0,
+ EfiPortConnectorTypeCentronics = 0x1,
+ EfiPortConnectorTypeMiniCentronics = 0x2,
+ EfiPortConnectorTypeProprietary = 0x3,
+ EfiPortConnectorTypeDB25Male = 0x4,
+ EfiPortConnectorTypeDB25Female = 0x5,
+ EfiPortConnectorTypeDB15Male = 0x6,
+ EfiPortConnectorTypeDB15Female = 0x7,
+ EfiPortConnectorTypeDB9Male = 0x8,
+ EfiPortConnectorTypeDB9Female = 0x9,
+ EfiPortConnectorTypeRJ11 = 0xA,
+ EfiPortConnectorTypeRJ45 = 0xB,
+ EfiPortConnectorType50PinMiniScsi = 0xC,
+ EfiPortConnectorTypeMiniDin = 0xD,
+ EfiPortConnectorTypeMicriDin = 0xE,
+ EfiPortConnectorTypePS2 = 0xF,
+ EfiPortConnectorTypeInfrared = 0x10,
+ EfiPortConnectorTypeHpHil = 0x11,
+ EfiPortConnectorTypeUsb = 0x12,
+ EfiPortConnectorTypeSsaScsi = 0x13,
+ EfiPortConnectorTypeCircularDin8Male = 0x14,
+ EfiPortConnectorTypeCircularDin8Female = 0x15,
+ EfiPortConnectorTypeOnboardIde = 0x16,
+ EfiPortConnectorTypeOnboardFloppy = 0x17,
+ EfiPortConnectorType9PinDualInline = 0x18,
+ EfiPortConnectorType25PinDualInline = 0x19,
+ EfiPortConnectorType50PinDualInline = 0x1A,
+ EfiPortConnectorType68PinDualInline = 0x1B,
+ EfiPortConnectorTypeOnboardSoundInput = 0x1C,
+ EfiPortConnectorTypeMiniCentronicsType14 = 0x1D,
+ EfiPortConnectorTypeMiniCentronicsType26 = 0x1E,
+ EfiPortConnectorTypeHeadPhoneMiniJack = 0x1F,
+ EfiPortConnectorTypeBNC = 0x20,
+ EfiPortConnectorType1394 = 0x21,
+ EfiPortConnectorTypeSasSata = 0x22,
+ EfiPortConnectorTypePC98 = 0xA0,
+ EfiPortConnectorTypePC98Hireso = 0xA1,
+ EfiPortConnectorTypePCH98 = 0xA2,
+ EfiPortConnectorTypePC98Note = 0xA3,
+ EfiPortConnectorTypePC98Full = 0xA4,
+ EfiPortConnectorTypeOther = 0xFF,
+} EFI_MISC_PORT_CONNECTOR_TYPE;
+
+typedef enum {
+ EfiPortTypeNone = 0x0,
+ EfiPortTypeParallelXtAtCompatible = 0x1,
+ EfiPortTypeParallelPortPs2 = 0x2,
+ EfiPortTypeParallelPortEcp = 0x3,
+ EfiPortTypeParallelPortEpp = 0x4,
+ EfiPortTypeParallelPortEcpEpp = 0x5,
+ EfiPortTypeSerialXtAtCompatible = 0x6,
+ EfiPortTypeSerial16450Compatible = 0x7,
+ EfiPortTypeSerial16550Compatible = 0x8,
+ EfiPortTypeSerial16550ACompatible = 0x9,
+ EfiPortTypeScsi = 0xA,
+ EfiPortTypeMidi = 0xB,
+ EfiPortTypeJoyStick = 0xC,
+ EfiPortTypeKeyboard = 0xD,
+ EfiPortTypeMouse = 0xE,
+ EfiPortTypeSsaScsi = 0xF,
+ EfiPortTypeUsb = 0x10,
+ EfiPortTypeFireWire = 0x11,
+ EfiPortTypePcmciaTypeI = 0x12,
+ EfiPortTypePcmciaTypeII = 0x13,
+ EfiPortTypePcmciaTypeIII = 0x14,
+ EfiPortTypeCardBus = 0x15,
+ EfiPortTypeAccessBusPort = 0x16,
+ EfiPortTypeScsiII = 0x17,
+ EfiPortTypeScsiWide = 0x18,
+ EfiPortTypePC98 = 0x19,
+ EfiPortTypePC98Hireso = 0x1A,
+ EfiPortTypePCH98 = 0x1B,
+ EfiPortTypeVideoPort = 0x1C,
+ EfiPortTypeAudioPort = 0x1D,
+ EfiPortTypeModemPort = 0x1E,
+ EfiPortTypeNetworkPort = 0x1F,
+ EfiPortTypeSata = 0x20,
+ EfiPortTypeSas = 0x21,
+ EfiPortType8251Compatible = 0xA0,
+ EfiPortType8251FifoCompatible = 0xA1,
+ EfiPortTypeOther = 0xFF,
+} EFI_MISC_PORT_TYPE;
+
+
+typedef struct {
+ EFI_STRING_TOKEN PortInternalConnectorDesignator;
+ EFI_STRING_TOKEN PortExternalConnectorDesignator;
+ EFI_MISC_PORT_CONNECTOR_TYPE PortInternalConnectorType;
+ EFI_MISC_PORT_CONNECTOR_TYPE PortExternalConnectorType;
+ EFI_MISC_PORT_TYPE PortType;
+ EFI_MISC_PORT_DEVICE_PATH PortPath;
+} EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR;
+
+//
+//////////////////////////////////////////////////////////////////////////////
+//
+// Misc. System Slots - SMBIOS Type 9
+//
+#define EFI_MISC_SYSTEM_SLOT_DESIGNATION_RECORD_NUMBER 0x00000007
+
+typedef enum {
+ EfiSlotTypeOther = 0x1,
+ EfiSlotTypeUnknown = 0x2,
+ EfiSlotTypeIsa = 0x3,
+ EfiSlotTypeMca = 0x4,
+ EfiSlotTypeEisa = 0x5,
+ EfiSlotTypePci = 0x6,
+ EfiSlotTypePcmcia = 0x7,
+ EfiSlotTypeVlVesa = 0x8,
+ EfiSlotTypeProprietary = 0x9,
+ EfiSlotTypeProcessorCardSlot = 0xA,
+ EfiSlotTypeProprietaryMemoryCardSlot = 0xB,
+ EfiSlotTypeIORiserCardSlot = 0xC,
+ EfiSlotTypeNuBus = 0xD,
+ EfiSlotTypePci66MhzCapable = 0xE,
+ EfiSlotTypeAgp = 0xF,
+ EfiSlotTypeApg2X = 0x10,
+ EfiSlotTypeAgp4X = 0x11,
+ EfiSlotTypePciX = 0x12,
+ EfiSlotTypeAgp8X = 0x13,
+ EfiSlotTypePC98C20 = 0xA0,
+ EfiSlotTypePC98C24 = 0xA1,
+ EfiSlotTypePC98E = 0xA2,
+ EfiSlotTypePC98LocalBus = 0xA3,
+ EfiSlotTypePC98Card = 0xA4,
+ EfiSlotTypePciExpress = 0xA5,
+ EfiSlotTypePciExpressX1 = 0xA6,
+ EfiSlotTypePciExpressX2 = 0xA7,
+ EfiSlotTypePciExpressX4 = 0xA8,
+ EfiSlotTypePciExpressX8 = 0xA9,
+ EfiSlotTypePciExpressX16 = 0xAA,
+ EfiSlotTypePciExpressGen2 = 0xAB,
+ EfiSlotTypePciExpressGen2X1 = 0xAC,
+ EfiSlotTypePciExpressGen2X2 = 0xAD,
+ EfiSlotTypePciExpressGen2X4 = 0xAE,
+ EfiSlotTypePciExpressGen2X8 = 0xAF,
+ EfiSlotTypePciExpressGen2X16 = 0xB0
+} EFI_MISC_SLOT_TYPE;
+
+typedef enum {
+ EfiSlotDataBusWidthOther = 1,
+ EfiSlotDataBusWidthUnknown = 2,
+ EfiSlotDataBusWidth8Bit = 3,
+ EfiSlotDataBusWidth16Bit = 4,
+ EfiSlotDataBusWidth32Bit = 5,
+ EfiSlotDataBusWidth64Bit = 6,
+ EfiSlotDataBusWidth128Bit = 7,
+ EfiSlotDataBusWidth1xOrx1 = 8,
+ EfiSlotDataBusWidth2xOrx2 = 9,
+ EfiSlotDataBusWidth4xOrx4 = 0xA,
+ EfiSlotDataBusWidth8xOrx8 = 0xB,
+ EfiSlotDataBusWidth12xOrx12 = 0xC,
+ EfiSlotDataBusWidth16xOrx16 = 0xD,
+ EfiSlotDataBusWidth32xOrx32 = 0xE,
+} EFI_MISC_SLOT_DATA_BUS_WIDTH;
+
+typedef enum {
+ EfiSlotUsageOther = 1,
+ EfiSlotUsageUnknown = 2,
+ EfiSlotUsageAvailable = 3,
+ EfiSlotUsageInUse = 4,
+} EFI_MISC_SLOT_USAGE;
+
+typedef enum {
+ EfiSlotLengthOther = 1,
+ EfiSlotLengthUnknown = 2,
+ EfiSlotLengthShort = 3,
+ EfiSlotLengthLong = 4
+} EFI_MISC_SLOT_LENGTH;
+
+typedef struct {
+ UINT32 CharacteristicsUnknown :1;
+ UINT32 Provides50Volts :1;
+ UINT32 Provides33Volts :1;
+ UINT32 SharedSlot :1;
+ UINT32 PcCard16Supported :1;
+ UINT32 CardBusSupported :1;
+ UINT32 ZoomVideoSupported :1;
+ UINT32 ModemRingResumeSupported:1;
+ UINT32 PmeSignalSupported :1;
+ UINT32 HotPlugDevicesSupported :1;
+ UINT32 SmbusSignalSupported :1;
+ UINT32 Reserved :21;
+} EFI_MISC_SLOT_CHARACTERISTICS;
+
+typedef struct {
+ STRING_REF SlotDesignation;
+ EFI_MISC_SLOT_TYPE SlotType;
+ EFI_MISC_SLOT_DATA_BUS_WIDTH SlotDataBusWidth;
+ EFI_MISC_SLOT_USAGE SlotUsage;
+ EFI_MISC_SLOT_LENGTH SlotLength;
+ UINT16 SlotId;
+ EFI_MISC_SLOT_CHARACTERISTICS SlotCharacteristics;
+ EFI_DEVICE_PATH_PROTOCOL SlotDevicePath;
+ UINT16 SegmentGroupNum;
+ UINT8 BusNum;
+ EFI_MISC_DEV_FUNC_NUM DevFuncNum;
+} EFI_MISC_SYSTEM_SLOT_DESIGNATION;
+
+//
+//////////////////////////////////////////////////////////////////////////////
+//
+// Misc. Onboard Device - SMBIOS Type 10
+//
+#define EFI_MISC_ONBOARD_DEVICE_RECORD_NUMBER 0x00000008
+
+typedef enum {
+ EfiOnBoardDeviceTypeOther = 1,
+ EfiOnBoardDeviceTypeUnknown = 2,
+ EfiOnBoardDeviceTypeVideo = 3,
+ EfiOnBoardDeviceTypeScsiController = 4,
+ EfiOnBoardDeviceTypeEthernet = 5,
+ EfiOnBoardDeviceTypeTokenRing = 6,
+ EfiOnBoardDeviceTypeSound = 7,
+ EfiOnBoardDeviceTypePataController = 8,
+ EfiOnBoardDeviceTypeSataController = 9,
+ EfiOnBoardDeviceTypeSasController = 10
+} EFI_MISC_ONBOARD_DEVICE_TYPE;
+
+typedef struct {
+ UINT32 DeviceType :16;
+ UINT32 DeviceEnabled :1;
+ UINT32 Reserved :15;
+} EFI_MISC_ONBOARD_DEVICE_STATUS;
+
+typedef struct {
+ STRING_REF OnBoardDeviceDescription;
+ EFI_MISC_ONBOARD_DEVICE_STATUS OnBoardDeviceStatus;
+ EFI_DEVICE_PATH_PROTOCOL OnBoardDevicePath;
+} EFI_MISC_ONBOARD_DEVICE;
+
+//
+//////////////////////////////////////////////////////////////////////////////
+//
+// Misc. BIOS Language Information - SMBIOS Type 11
+//
+#define EFI_MISC_OEM_STRING_RECORD_NUMBER 0x00000009
+
+typedef struct {
+ STRING_REF OemStringRef[1];
+} EFI_MISC_OEM_STRING;
+
+//
+//////////////////////////////////////////////////////////////////////////////
+//
+// Misc. System Options - SMBIOS Type 12
+//
+typedef struct {
+ STRING_REF SystemOptionStringRef[1];
+} EFI_MISC_SYSTEM_OPTION_STRING;
+
+#define EFI_MISC_SYSTEM_OPTION_STRING_RECORD_NUMBER 0x0000000A
+
+//
+//////////////////////////////////////////////////////////////////////////////
+//
+// Misc. Number of Installable Languages - SMBIOS Type 13
+//
+#define EFI_MISC_NUMBER_OF_INSTALLABLE_LANGUAGES_RECORD_NUMBER 0x0000000B
+
+typedef struct {
+ UINT32 AbbreviatedLanguageFormat :1;
+ UINT32 Reserved :31;
+} EFI_MISC_LANGUAGE_FLAGS;
+
+typedef struct {
+ UINT16 NumberOfInstallableLanguages;
+ EFI_MISC_LANGUAGE_FLAGS LanguageFlags;
+ UINT16 CurrentLanguageNumber;
+} EFI_MISC_NUMBER_OF_INSTALLABLE_LANGUAGES;
+
+//
+//////////////////////////////////////////////////////////////////////////////
+//
+// Misc. System Language String
+//
+#define EFI_MISC_SYSTEM_LANGUAGE_STRING_RECORD_NUMBER 0x0000000C
+
+typedef struct {
+ UINT16 LanguageId;
+ STRING_REF SystemLanguageString;
+} EFI_MISC_SYSTEM_LANGUAGE_STRING;
+
+//
+//////////////////////////////////////////////////////////////////////////////
+//
+// Misc. Group Associations - SMBIOS Type 14
+//
+#define EFI_MISC_GROUP_NAME_RECORD_NUMBER 0x0000000D
+
+typedef struct {
+ STRING_REF GroupName;
+ UINT16 NumberGroupItems;
+ UINT16 GroupId;
+} EFI_MISC_GROUP_NAME_DATA;
+
+#define EFI_MISC_GROUP_ITEM_SET_RECORD_NUMBER 0x0000000E
+
+typedef struct {
+ EFI_GUID SubClass;
+ EFI_INTER_LINK_DATA GroupLink;
+ UINT16 GroupId;
+ UINT16 GroupElementId;
+ UINT8 ItemType;
+} EFI_MISC_GROUP_ITEM_SET_DATA;
+
+//
+//////////////////////////////////////////////////////////////////////////////
+//
+// Misc. Pointing Device Type - SMBIOS Type 21
+//
+#define EFI_MISC_POINTING_DEVICE_TYPE_RECORD_NUMBER 0x0000000F
+
+typedef enum {
+ EfiPointingDeviceTypeOther = 1,
+ EfiPointingDeviceTypeUnknown = 2,
+ EfiPointingDeviceTypeMouse = 3,
+ EfiPointingDeviceTypeTrackBall = 4,
+ EfiPointingDeviceTypeTrackPoint = 5,
+ EfiPointingDeviceTypeGlidePoint = 6,
+ EfiPointingDeviceTouchPad = 7,
+ EfiPointingDeviceTouchScreen = 8,
+ EfiPointingDeviceOpticalSensor = 9,
+} EFI_MISC_POINTING_DEVICE_TYPE;
+
+typedef enum {
+ EfiPointingDeviceInterfaceOther = 1,
+ EfiPointingDeviceInterfaceUnknown = 2,
+ EfiPointingDeviceInterfaceSerial = 3,
+ EfiPointingDeviceInterfacePs2 = 4,
+ EfiPointingDeviceInterfaceInfrared = 5,
+ EfiPointingDeviceInterfaceHpHil = 6,
+ EfiPointingDeviceInterfaceBusMouse = 7,
+ EfiPointingDeviceInterfaceADB = 8,
+ EfiPointingDeviceInterfaceBusMouseDB9 = 0xA0,
+ EfiPointingDeviceInterfaceBusMouseMicroDin = 0xA1,
+ EfiPointingDeviceInterfaceUsb = 0xA2,
+} EFI_MISC_POINTING_DEVICE_INTERFACE;
+
+typedef struct {
+ EFI_MISC_POINTING_DEVICE_TYPE PointingDeviceType;
+ EFI_MISC_POINTING_DEVICE_INTERFACE PointingDeviceInterface;
+ UINT16 NumberPointingDeviceButtons;
+ EFI_DEVICE_PATH_PROTOCOL PointingDevicePath;
+} EFI_MISC_ONBOARD_DEVICE_TYPE_DATA;
+
+//
+//////////////////////////////////////////////////////////////////////////////
+//
+// Misc. Portable Battery - SMBIOS Type 22
+//
+#define EFI_MISC_PORTABLE_BATTERY_RECORD_NUMBER 0x00000010
+
+typedef enum {
+ EfiPortableBatteryDeviceChemistryOther = 1,
+ EfiPortableBatteryDeviceChemistryUnknown = 2,
+ EfiPortableBatteryDeviceChemistryLeadAcid = 3,
+ EfiPortableBatteryDeviceChemistryNickelCadmium = 4,
+ EfiPortableBatteryDeviceChemistryNickelMetalHydride = 5,
+ EfiPortableBatteryDeviceChemistryLithiumIon = 6,
+ EfiPortableBatteryDeviceChemistryZincAir = 7,
+ EfiPortableBatteryDeviceChemistryLithiumPolymer = 8,
+} EFI_MISC_PORTABLE_BATTERY_DEVICE_CHEMISTRY;
+
+typedef struct {
+ STRING_REF Location;
+ STRING_REF Manufacturer;
+ STRING_REF ManufactureDate;
+ STRING_REF SerialNumber;
+ STRING_REF DeviceName;
+ EFI_MISC_PORTABLE_BATTERY_DEVICE_CHEMISTRY DeviceChemistry;
+ UINT16 DesignCapacity;
+ UINT16 DesignVoltage;
+ STRING_REF SBDSVersionNumber;
+ UINT8 MaximumError;
+ UINT16 SBDSSerialNumber;
+ UINT16 SBDSManufactureDate;
+ STRING_REF SBDSDeviceChemistry;
+ UINT8 DesignCapacityMultiplier;
+ UINT32 OEMSpecific;
+ UINT8 BatteryNumber; // Temporary
+ BOOLEAN Valid; // Is entry valid - Temporary
+} EFI_MISC_PORTABLE_BATTERY;
+
+//
+//////////////////////////////////////////////////////////////////////////////
+//
+// Misc. Reset Capabilities - SMBIOS Type 23
+//
+#define EFI_MISC_RESET_CAPABILITIES_RECORD_NUMBER 0x00000011
+
+typedef struct {
+ UINT32 Status :1;
+ UINT32 BootOption :2;
+ UINT32 BootOptionOnLimit :2;
+ UINT32 WatchdogTimerPresent:1;
+ UINT32 Reserved :26;
+} EFI_MISC_RESET_CAPABILITIES_TYPE;
+
+typedef struct {
+ EFI_MISC_RESET_CAPABILITIES_TYPE ResetCapabilities;
+ UINT16 ResetCount;
+ UINT16 ResetLimit;
+ UINT16 ResetTimerInterval;
+ UINT16 ResetTimeout;
+} EFI_MISC_RESET_CAPABILITIES;
+
+typedef struct {
+ EFI_MISC_RESET_CAPABILITIES ResetCapabilities;
+ UINT16 ResetCount;
+ UINT16 ResetLimit;
+ UINT16 ResetTimerInterval;
+ UINT16 ResetTimeout;
+} EFI_MISC_RESET_CAPABILITIES_DATA;
+
+//
+//////////////////////////////////////////////////////////////////////////////
+//
+// Misc. Hardware Security - SMBIOS Type 24
+//
+#define EFI_MISC_HARDWARE_SECURITY_RECORD_NUMBER 0x00000012
+
+//
+// Backward Compatibility
+//
+#define EFI_MISC_HARDWARE_SECURITY_SETTINGS_DATA_RECORD_NUMBER EFI_MISC_HARDWARE_SECURITY_RECORD_NUMBER
+
+typedef enum {
+ EfiHardwareSecurityStatusDisabled = 0,
+ EfiHardwareSecurityStatusEnabled = 1,
+ EfiHardwareSecurityStatusNotImplemented = 2,
+ EfiHardwareSecurityStatusUnknown = 3
+} EFI_MISC_HARDWARE_SECURITY_STATUS;
+
+typedef struct {
+ EFI_MISC_HARDWARE_SECURITY_STATUS FrontPanelResetStatus :2;
+ EFI_MISC_HARDWARE_SECURITY_STATUS AdministratorPasswordStatus :2;
+ EFI_MISC_HARDWARE_SECURITY_STATUS KeyboardPasswordStatus :2;
+ EFI_MISC_HARDWARE_SECURITY_STATUS PowerOnPasswordStatus :2;
+ EFI_MISC_HARDWARE_SECURITY_STATUS Reserved :24;
+} EFI_MISC_HARDWARE_SECURITY_SETTINGS;
+
+typedef struct {
+ EFI_MISC_HARDWARE_SECURITY_SETTINGS HardwareSecuritySettings;
+} EFI_MISC_HARDWARE_SECURITY_SETTINGS_DATA;
+
+//
+//////////////////////////////////////////////////////////////////////////////
+//
+// Misc. System Power Controls - SMBIOS Type 25
+//
+#define EFI_MISC_SCHEDULED_POWER_ON_MONTH_RECORD_NUMBER 0x00000013
+
+typedef struct {
+ UINT8 ScheduledPoweronMonth;
+ UINT8 ScheduledPoweronDayOfMonth;
+ UINT8 ScheduledPoweronHour;
+ UINT8 ScheduledPoweronMinute;
+ UINT8 ScheduledPoweronSecond;
+} EFI_MISC_SCHEDULED_POWER_ON_MONTH;
+
+//
+//////////////////////////////////////////////////////////////////////////////
+//
+// Misc. Voltage Probe - SMBIOS Type 26
+//
+#define EFI_MISC_VOLTAGE_PROBE_DESCRIPTION_RECORD_NUMBER 0x00000014
+
+typedef struct {
+ UINT32 VoltageProbeSite :5;
+ UINT32 VoltageProbeStatus :3;
+ UINT32 Reserved :24;
+} EFI_MISC_VOLTAGE_PROBE_LOCATION;
+
+typedef struct {
+ STRING_REF VoltageProbeDescription;
+ EFI_MISC_VOLTAGE_PROBE_LOCATION VoltageProbeLocation;
+ UINT16 VoltageProbeMaximumValue;
+ UINT16 VoltageProbeMinimumValue;
+ UINT16 VoltageProbeResolution;
+ UINT16 VoltageProbeTolerance;
+ UINT16 VoltageProbeAccuracy;
+ UINT16 VoltageProbeNominalValue;
+ UINT16 MDLowerNoncriticalThreshold;
+ UINT16 MDUpperNoncriticalThreshold;
+ UINT16 MDLowerCriticalThreshold;
+ UINT16 MDUpperCriticalThreshold;
+ UINT16 MDLowerNonrecoverableThreshold;
+ UINT16 MDUpperNonrecoverableThreshold;
+ UINT32 VoltageProbeOemDefined;
+} EFI_MISC_VOLTAGE_PROBE_DESCRIPTION;
+
+//
+//////////////////////////////////////////////////////////////////////////////
+//
+// Misc. Cooling Device - SMBIOS Type 27
+//
+#define EFI_MISC_COOLING_DEVICE_TEMP_LINK_RECORD_NUMBER 0x00000015
+
+typedef struct {
+ UINT32 CoolingDevice :5;
+ UINT32 CoolingDeviceStatus :3;
+ UINT32 Reserved :24;
+} EFI_MISC_COOLING_DEVICE_TYPE;
+
+typedef struct {
+ EFI_MISC_COOLING_DEVICE_TYPE CoolingDeviceType;
+ EFI_INTER_LINK_DATA CoolingDeviceTemperatureLink;
+ UINT8 CoolingDeviceUnitGroup;
+ UINT16 CoolingDeviceNominalSpeed;
+ UINT32 CoolingDeviceOemDefined;
+} EFI_MISC_COOLING_DEVICE_TEMP_LINK;
+
+//
+//////////////////////////////////////////////////////////////////////////////
+//
+// Misc. Temperature Probe - SMBIOS Type 28
+//
+#define EFI_MISC_TEMPERATURE_PROBE_DESCRIPTION_RECORD_NUMBER 0x00000016
+
+typedef struct {
+ UINT32 TemperatureProbeSite :5;
+ UINT32 TemperatureProbeStatus :3;
+ UINT32 Reserved :24;
+} EFI_MISC_TEMPERATURE_PROBE_LOCATION;
+
+typedef struct {
+ STRING_REF TemperatureProbeDescription;
+ EFI_MISC_TEMPERATURE_PROBE_LOCATION TemperatureProbeLocation;
+ UINT16 TemperatureProbeMaximumValue;
+ UINT16 TemperatureProbeMinimumValue;
+ UINT16 TemperatureProbeResolution;
+ UINT16 TemperatureProbeTolerance;
+ UINT16 TemperatureProbeAccuracy;
+ UINT16 TemperatureProbeNominalValue;
+ UINT16 MDLowerNoncriticalThreshold;
+ UINT16 MDUpperNoncriticalThreshold;
+ UINT16 MDLowerCriticalThreshold;
+ UINT16 MDUpperCriticalThreshold;
+ UINT16 MDLowerNonrecoverableThreshold;
+ UINT16 MDUpperNonrecoverableThreshold;
+ UINT32 TemperatureProbeOemDefined;
+} EFI_MISC_TEMPERATURE_PROBE_DESCRIPTION;
+
+//
+//////////////////////////////////////////////////////////////////////////////
+//
+// Misc. Electrical Current Probe - SMBIOS Type 29
+//
+#define EFI_MISC_ELECTRICAL_CURRENT_PROBE_DESCRIPTION_RECORD_NUMBER 0x00000017
+
+typedef struct {
+ UINT32 ElectricalCurrentProbeSite :5;
+ UINT32 ElectricalCurrentProbeStatus :3;
+ UINT32 Reserved :24;
+} EFI_MISC_ELECTRICAL_CURRENT_PROBE_LOCATION;
+
+typedef struct {
+ STRING_REF ElectricalCurrentProbeDescription;
+ EFI_MISC_ELECTRICAL_CURRENT_PROBE_LOCATION ElectricalCurrentProbeLocation;
+ UINT16 ElectricalCurrentProbeMaximumValue;
+ UINT16 ElectricalCurrentProbeMinimumValue;
+ UINT16 ElectricalCurrentProbeResolution;
+ UINT16 ElectricalCurrentProbeTolerance;
+ UINT16 ElectricalCurrentProbeAccuracy;
+ UINT16 ElectricalCurrentProbeNominalValue;
+ UINT16 MDLowerNoncriticalThreshold;
+ UINT16 MDUpperNoncriticalThreshold;
+ UINT16 MDLowerCriticalThreshold;
+ UINT16 MDUpperCriticalThreshold;
+ UINT16 MDLowerNonrecoverableThreshold;
+ UINT16 MDUpperNonrecoverableThreshold;
+ UINT32 ElectricalCurrentProbeOemDefined;
+} EFI_MISC_ELECTRICAL_CURRENT_PROBE_DESCRIPTION;
+
+//
+//////////////////////////////////////////////////////////////////////////////
+//
+// Misc. Out-of-Band Remote Access - SMBIOS Type 30
+//
+#define EFI_MISC_REMOTE_ACCESS_MANUFACTURER_DESCRIPTION_RECORD_NUMBER 0x00000018
+
+typedef struct {
+ UINT32 InboundConnectionEnabled :1;
+ UINT32 OutboundConnectionEnabled :1;
+ UINT32 Reserved :30;
+} EFI_MISC_REMOTE_ACCESS_CONNECTIONS;
+
+typedef struct {
+ STRING_REF RemoteAccessManufacturerNameDescription;
+ EFI_MISC_REMOTE_ACCESS_CONNECTIONS RemoteAccessConnections;
+} EFI_MISC_REMOTE_ACCESS_MANUFACTURER_DESCRIPTION;
+//
+//////////////////////////////////////////////////////////////////////////////
+//
+// Misc. BIS Entry Point - SMBIOS Type 31
+//
+#define EFI_MISC_BIS_ENTRY_POINT_RECORD_NUMBER 0x00000019
+
+typedef struct {
+ EFI_PHYSICAL_ADDRESS BisEntryPoint;
+} EFI_MISC_BIS_ENTRY_POINT;
+
+//
+//////////////////////////////////////////////////////////////////////////////
+//
+// Misc. Boot Information - SMBIOS Type 32
+//
+#define EFI_MISC_BOOT_INFORMATION_STATUS_RECORD_NUMBER 0x0000001A
+
+typedef enum {
+ EfiBootInformationStatusNoError = 0,
+ EfiBootInformationStatusNoBootableMedia = 1,
+ EfiBootInformationStatusNormalOSFailedLoading = 2,
+ EfiBootInformationStatusFirmwareDetectedFailure = 3,
+ EfiBootInformationStatusOSDetectedFailure = 4,
+ EfiBootInformationStatusUserRequestedBoot = 5,
+ EfiBootInformationStatusSystemSecurityViolation = 6,
+ EfiBootInformationStatusPreviousRequestedImage = 7,
+ EfiBootInformationStatusWatchdogTimerExpired = 8,
+ EfiBootInformationStatusStartReserved = 9,
+ EfiBootInformationStatusStartOemSpecific = 128,
+ EfiBootInformationStatusStartProductSpecific = 192,
+} EFI_MISC_BOOT_INFORMATION_STATUS_TYPE;
+
+typedef struct {
+ EFI_MISC_BOOT_INFORMATION_STATUS_TYPE BootInformationStatus;
+ UINT8 BootInformationData[9];
+} EFI_MISC_BOOT_INFORMATION_STATUS;
+
+//
+//////////////////////////////////////////////////////////////////////////////
+//
+// Misc. Management Device - SMBIOS Type 34
+//
+#define EFI_MISC_MANAGEMENT_DEVICE_DESCRIPTION_RECORD_NUMBER 0x0000001B
+
+typedef enum {
+ EfiManagementDeviceTypeOther = 1,
+ EfiManagementDeviceTypeUnknown = 2,
+ EfiManagementDeviceTypeLm75 = 3,
+ EfiManagementDeviceTypeLm78 = 4,
+ EfiManagementDeviceTypeLm79 = 5,
+ EfiManagementDeviceTypeLm80 = 6,
+ EfiManagementDeviceTypeLm81 = 7,
+ EfiManagementDeviceTypeAdm9240 = 8,
+ EfiManagementDeviceTypeDs1780 = 9,
+ EfiManagementDeviceTypeMaxim1617 = 0xA,
+ EfiManagementDeviceTypeGl518Sm = 0xB,
+ EfiManagementDeviceTypeW83781D = 0xC,
+ EfiManagementDeviceTypeHt82H791 = 0xD
+} EFI_MISC_MANAGEMENT_DEVICE_TYPE;
+
+typedef enum {
+ EfiManagementDeviceAddressTypeOther = 1,
+ EfiManagementDeviceAddressTypeUnknown = 2,
+ EfiManagementDeviceAddressTypeIOPort = 3,
+ EfiManagementDeviceAddressTypeMemory = 4,
+ EfiManagementDeviceAddressTypeSmbus = 5
+} EFI_MISC_MANAGEMENT_DEVICE_ADDRESS_TYPE;
+
+typedef struct {
+ STRING_REF ManagementDeviceDescription;
+ EFI_MISC_MANAGEMENT_DEVICE_TYPE ManagementDeviceType;
+ UINTN ManagementDeviceAddress;
+ EFI_MISC_MANAGEMENT_DEVICE_ADDRESS_TYPE ManagementDeviceAddressType;
+} EFI_MISC_MANAGEMENT_DEVICE_DESCRIPTION;
+
+//
+//////////////////////////////////////////////////////////////////////////////
+//
+// Misc. Management Device Component - SMBIOS Type 35
+//
+#define EFI_MISC_MANAGEMENT_DEVICE_COMPONENT_DESCRIPTION_RECORD_NUMBER 0x0000001C
+
+typedef struct {
+ STRING_REF ManagementDeviceComponentDescription;
+ EFI_INTER_LINK_DATA ManagementDeviceLink;
+ EFI_INTER_LINK_DATA ManagementDeviceComponentLink;
+ EFI_INTER_LINK_DATA ManagementDeviceThresholdLink;
+ UINT8 ComponentType;
+} EFI_MISC_MANAGEMENT_DEVICE_COMPONENT_DESCRIPTION;
+
+//
+//////////////////////////////////////////////////////////////////////////////
+//
+// IPMI Data Record - SMBIOS Type 38
+//
+typedef enum {
+ EfiIpmiOther = 0,
+ EfiIpmiKcs = 1,
+ EfiIpmiSmic = 2,
+ EfiIpmiBt = 3,
+} EFI_MISC_IPMI_INTERFACE_TYPE;
+
+typedef struct {
+ UINT16 IpmiSpecLeastSignificantDigit:4;
+ UINT16 IpmiSpecMostSignificantDigit:4;
+ UINT16 Reserved:8;
+} EFI_MISC_IPMI_SPECIFICATION_REVISION;
+
+typedef struct {
+ EFI_MISC_IPMI_INTERFACE_TYPE IpmiInterfaceType;
+ EFI_MISC_IPMI_SPECIFICATION_REVISION IpmiSpecificationRevision;
+ UINT16 IpmiI2CSlaveAddress;
+ UINT16 IpmiNvDeviceAddress;
+ UINT64 IpmiBaseAddress;
+ EFI_DEVICE_PATH_PROTOCOL IpmiDevicePath;
+} EFI_MISC_IPMI_INTERFACE_TYPE_DATA;
+
+#define EFI_MISC_IPMI_INTERFACE_TYPE_RECORD_NUMBER 0x0000001D
+
+//
+//////////////////////////////////////////////////////////////////////////////
+//
+//System Power supply Record - SMBIOS Type 39
+//
+typedef struct {
+ UINT16 PowerSupplyHotReplaceable :1;
+ UINT16 PowerSupplyPresent :1;
+ UINT16 PowerSupplyUnplugged :1;
+ UINT16 InputVoltageRangeSwitch :4;
+ UINT16 PowerSupplyStatus :3;
+ UINT16 PowerSupplyType :4;
+ UINT16 Reserved :2;
+} POWER_SUPPLY_CHARACTERISTICS;
+
+typedef struct {
+ UINT16 PowerUnitGroup;
+ STRING_REF PowerSupplyLocation;
+ STRING_REF PowerSupplyDeviceName;
+ STRING_REF PowerSupplyManufacturer;
+ STRING_REF PowerSupplySerialNumber;
+ STRING_REF PowerSupplyAssetTagNumber;
+ STRING_REF PowerSupplyModelPartNumber;
+ STRING_REF PowerSupplyRevisionLevel;
+ UINT16 PowerSupplyMaxPowerCapacity;
+ POWER_SUPPLY_CHARACTERISTICS PowerSupplyCharacteristics;
+ EFI_INTER_LINK_DATA PowerSupplyInputVoltageProbeLink;
+ EFI_INTER_LINK_DATA PowerSupplyCoolingDeviceLink;
+ EFI_INTER_LINK_DATA PowerSupplyInputCurrentProbeLink;
+} EFI_MISC_SYSTEM_POWER_SUPPLY;
+
+#define EFI_MISC_SYSTEM_POWER_SUPPLY_RECORD_NUMBER 0x0000001E
+
+//
+//////////////////////////////////////////////////////////////////////////////
+//
+//Additional Information Record - SMBIOS Type 40
+//
+typedef struct {
+ UINT8 EntryLength;
+ UINT8 ReferencedSmbiosType;
+ EFI_INTER_LINK_DATA ReferencedLink;
+ UINT8 ReferencedOffset;
+ STRING_REF EntryString;
+ EFI_PHYSICAL_ADDRESS ValueAddress;
+} EFI_MISC_ADDITIONAL_INFORMATION_ENTRY;
+
+typedef struct {
+ UINT8 NumberOfAdditionalInformationEntries;
+ EFI_PHYSICAL_ADDRESS AdditionalInfoEntriesAddr;
+} EFI_MISC_ADDITIONAL_INFORMATION;
+
+#define EFI_MISC_ADDITIONAL_INFORMATION_RECORD_NUMBER 0x00000022
+
+//
+//////////////////////////////////////////////////////////////////////////////
+//
+//Onboard Devices Extended Infomation Record - SMBIOS Type 41
+//
+typedef struct {
+ UINT8 TypeOfDevice:7;
+ UINT8 DeviceStatus:1;
+} EFI_MISC_DEVICE_TYPE;
+
+typedef struct {
+ STRING_REF ReferenceDesignation;
+ EFI_MISC_DEVICE_TYPE DeviceType;
+ UINT8 DeviceTypeInstance;
+ UINT16 SegmentGroupNum;
+ UINT8 BusNum;
+ EFI_MISC_DEV_FUNC_NUM DevFuncNum;
+} EFI_MISC_ONBOARD_DEVICES_EXTENDED_INFORMATION;
+
+#define EFI_MISC_ONBOARD_DEVICES_EXTENDED_INFORMATION_RECORD_NUMBER 0x00000023
+
+//
+//////////////////////////////////////////////////////////////////////////////
+//
+// Generic Data Record - All SMBIOS Type
+// Put smbios raw data into one datahub record directly. Smbios driver would
+// copy smbios raw data into smbios table but not take any translation.
+//
+typedef struct {
+ UINT8 Type;
+ UINT8 Length;
+ UINT16 Handle;
+} SMBIOS_STRUCTURE_HDR;
+
+typedef struct {
+ SMBIOS_STRUCTURE_HDR Header;
+ UINT8 RawData[1];
+} EFI_MISC_SMBIOS_STRUCT_ENCAPSULATION;
+
+#define EFI_MISC_SMBIOS_STRUCT_ENCAP_RECORD_NUMBER 0x0000001F
+
+//
+//////////////////////////////////////////////////////////////////////////////
+//
+// Misc. System Event Log - SMBIOS Type 15
+//
+#define EFI_MISC_SYSTEM_EVENT_LOG_RECORD_NUMBER 0x00000020
+
+typedef enum {
+ EfiEventLogTypeReserved1 = 0,
+ EfiEventLogTypeSingleBitEccMemoryError = 1,
+ EfiEventLogTypeMultiBitEccMemoryError = 2,
+ EfiEventLogTypeParityMemoryError = 3,
+ EfiEventLogTypeBusTimeOut = 4,
+ EfiEventLogTypeIoChannelCheck = 5,
+ EfiEventLogTypeSoftwareNmi = 6,
+ EfiEventLogTypePostMemoryResize = 7,
+ EfiEventLogTypePostError = 8,
+ EfiEventLogTypePciParityError = 9,
+ EfiEventLogTypePciSystemError = 0xA,
+ EfiEventLogTypeCpuFailure = 0xB,
+ EfiEventLogTypeEisaFailSafeTimerTimeOut = 0xC,
+ EfiEventLogTypeCorrectableMemoryLogDisabled = 0xD,
+ EfiEventLogTypeLoggingDisabled = 0xE,
+ EfiEventLogTypeReserved2 = 0xF,
+ EfiEventLogTypeSystemLimitExceeded = 0x10,
+ EfiEventLogTypeAsynchronousHardwareTimerExpired = 0x11,
+ EfiEventLogTypeSystemConfigurationInformation = 0x12,
+ EfiEventLogTypeHardDiskInformation = 0x13,
+ EfiEventLogTypeSystemReconfigured = 0x14,
+ EfiEventLogTypeUncorrectableCpuComplexError = 0x15,
+ EfiEventLogTypeLogAreaResetCleared = 0x16,
+ EfiEventLogTypeSystemBoot = 0x17,
+ EfiEventLogTypeEndOfLog = 0xFF
+} EFI_MISC_LOG_TYPE;
+
+typedef enum {
+ EfiEventLogDataFormatTypeNone = 0,
+ EfiEventLogDataFormatTypeHandle = 1,
+ EfiEventLogDataFormatTypeMultipleEvent = 2,
+ EfiEventLogDataFormatTypeMultipleEventHandle = 3,
+ EfiEventLogDataFormatTypePostResultsBitmap = 4,
+ EfiEventLogDataFormatTypeSystemManagement = 5,
+ EfiEventLogDataFormatTypeMultipleEventSystemManagement = 6
+} EFI_MISC_VARIABLE_DATA_FORMAT_TYPE;
+
+typedef struct {
+ UINT8 LogType;
+ UINT8 DataFormatType;
+} EFI_MISC_EVENT_LOG_TYPE;
+
+typedef struct {
+ UINT16 LogAreaLength;
+ UINT16 LogHeaderStartOffset;
+ UINT16 LogDataStartOffset;
+ UINT8 AccessMethod;
+ UINT8 LogStatus;
+ UINT32 LogChangeToken;
+ UINT32 AccessMethodAddress;
+ UINT8 LogHeaderFormat;
+ UINT8 NumberOfSupportedLogType;
+ UINT8 LengthOfLogDescriptor;
+ EFI_PHYSICAL_ADDRESS EventLogTypeDescriptors; // Pointer to EFI_MISC_EVENT_LOG_TYPE
+} EFI_MISC_SYSTEM_EVENT_LOG;
+
+//
+// Access Method.
+// 0x00~0x04: as following definition
+// 0x05~0x7f: Available for future assignment.
+// 0x80~0xff: BIOS Vendor/OEM-specific.
+//
+#define ACCESS_INDEXIO_1INDEX8BIT_DATA8BIT 0x00
+#define ACCESS_INDEXIO_2INDEX8BIT_DATA8BIT 0X01
+#define ACCESS_INDEXIO_1INDEX16BIT_DATA8BIT 0X02
+#define ACCESS_MEMORY_MAPPED 0x03
+#define ACCESS_GPNV 0x04
+
+//
+//////////////////////////////////////////////////////////////////////////////
+//
+//Management Device Threshold Data Record - SMBIOS Type 36
+//
+#define EFI_MISC_MANAGEMENT_DEVICE_THRESHOLD_RECORD_NUMBER 0x00000021
+
+typedef struct {
+ UINT16 LowerThresNonCritical;
+ UINT16 UpperThresNonCritical;
+ UINT16 LowerThresCritical;
+ UINT16 UpperThresCritical;
+ UINT16 LowerThresNonRecover;
+ UINT16 UpperThresNonRecover;
+} EFI_MISC_MANAGEMENT_DEVICE_THRESHOLD;
+
+//
+//////////////////////////////////////////////////////////////////////////////
+//
+//
+//
+typedef union {
+ EFI_MISC_LAST_PCI_BUS LastPciBus;
+ EFI_MISC_BIOS_VENDOR MiscBiosVendor;
+ EFI_MISC_SYSTEM_MANUFACTURER MiscSystemManufacturer;
+ EFI_MISC_BASE_BOARD_MANUFACTURER MiscBaseBoardManufacturer;
+ EFI_MISC_CHASSIS_MANUFACTURER MiscChassisManufacturer;
+ EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR MiscPortInternalConnectorDesignator;
+ EFI_MISC_SYSTEM_SLOT_DESIGNATION MiscSystemSlotDesignation;
+ EFI_MISC_ONBOARD_DEVICE MiscOnboardDevice;
+ EFI_MISC_OEM_STRING MiscOemString;
+ EFI_MISC_SYSTEM_OPTION_STRING MiscOptionString;
+ EFI_MISC_NUMBER_OF_INSTALLABLE_LANGUAGES NumberOfInstallableLanguages;
+ EFI_MISC_SYSTEM_LANGUAGE_STRING MiscSystemLanguageString;
+ EFI_MISC_GROUP_NAME_DATA MiscGroupNameData;
+ EFI_MISC_GROUP_ITEM_SET_DATA MiscGroupItemSetData;
+ EFI_MISC_SYSTEM_EVENT_LOG MiscSystemEventLog;
+ EFI_MISC_ONBOARD_DEVICE_TYPE_DATA MiscOnboardDeviceTypeData;
+ EFI_MISC_PORTABLE_BATTERY MiscPortableBattery;
+ EFI_MISC_RESET_CAPABILITIES_DATA MiscResetCapablilitiesData;
+ EFI_MISC_HARDWARE_SECURITY_SETTINGS_DATA MiscHardwareSecuritySettingsData;
+ EFI_MISC_SCHEDULED_POWER_ON_MONTH MiscScheduledPowerOnMonth;
+ EFI_MISC_VOLTAGE_PROBE_DESCRIPTION MiscVoltageProbeDescription;
+ EFI_MISC_COOLING_DEVICE_TEMP_LINK MiscCoolingDeviceTempLink;
+ EFI_MISC_TEMPERATURE_PROBE_DESCRIPTION MiscTemperatureProbeDescription;
+ EFI_MISC_ELECTRICAL_CURRENT_PROBE_DESCRIPTION MiscElectricalCurrentProbeDescription;
+ EFI_MISC_REMOTE_ACCESS_MANUFACTURER_DESCRIPTION MiscRemoteAccessManufacturerDescription;
+ EFI_MISC_BIS_ENTRY_POINT MiscBisEntryPoint;
+ EFI_MISC_BOOT_INFORMATION_STATUS MiscBootInformationStatus;
+ EFI_MISC_MANAGEMENT_DEVICE_DESCRIPTION MiscManagementDeviceDescription;
+ EFI_MISC_MANAGEMENT_DEVICE_COMPONENT_DESCRIPTION MiscManagementDeviceComponentDescription;
+ EFI_MISC_IPMI_INTERFACE_TYPE_DATA MiscIpmiInterfaceTypeData;
+ EFI_MISC_SYSTEM_POWER_SUPPLY MiscPowerSupplyInfo;
+ EFI_MISC_SMBIOS_STRUCT_ENCAPSULATION MiscSmbiosStructEncapsulation;
+ EFI_MISC_MANAGEMENT_DEVICE_THRESHOLD MiscManagementDeviceThreshold;
+ EFI_MISC_ADDITIONAL_INFORMATION MiscAdditionalInformation;
+ EFI_MISC_ONBOARD_DEVICES_EXTENDED_INFORMATION MiscOnBoardDevicesExtendedInformation;
+} EFI_MISC_SUBCLASS_RECORDS;
+
+//
+//
+//
+typedef struct {
+ EFI_SUBCLASS_TYPE1_HEADER Header;
+ EFI_MISC_SUBCLASS_RECORDS Record;
+} EFI_MISC_SUBCLASS_DRIVER_DATA;
+
+#pragma pack()
+
+#endif /* _DATAHUB_SUBCLASS_MISC_H_ */
+/* eof - DataHubSubClassMisc.h */
diff --git a/EDK/Foundation/Framework/Guid/DataHubRecords/DataHubSubClassProcessor.h b/EDK/Foundation/Framework/Guid/DataHubRecords/DataHubSubClassProcessor.h
new file mode 100644
index 0000000..578cb87
--- /dev/null
+++ b/EDK/Foundation/Framework/Guid/DataHubRecords/DataHubSubClassProcessor.h
@@ -0,0 +1,492 @@
+/*++
+
+Copyright (c) 2004 - 2009, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ DataHubSubClassProcessor.h
+
+Abstract:
+
+ Definitions for processor sub class data records
+
+Revision History
+
+--*/
+
+#ifndef _DATAHUB_SUBCLASS_PROCESSOR_H_
+#define _DATAHUB_SUBCLASS_PROCESSOR_H_
+
+#define EFI_PROCESSOR_SUBCLASS_VERSION 0x00010000
+
+#define EFI_PROCESSOR_SUBCLASS_GUID \
+ { 0x26fdeb7e, 0xb8af, 0x4ccf, 0xaa, 0x97, 0x02, 0x63, 0x3c, 0xe4, 0x8c, 0xa7 }
+
+
+typedef EFI_EXP_BASE10_DATA EFI_PROCESSOR_MAX_CORE_FREQUENCY_DATA;
+
+typedef EFI_EXP_BASE10_DATA EFI_PROCESSOR_MAX_FSB_FREQUENCY_DATA;
+
+typedef EFI_EXP_BASE10_DATA EFI_PROCESSOR_CORE_FREQUENCY_DATA;
+
+typedef EFI_EXP_BASE10_DATA *EFI_PROCESSOR_CORE_FREQUENCY_LIST_DATA;
+
+typedef EFI_EXP_BASE10_DATA *EFI_PROCESSOR_FSB_FREQUENCY_LIST_DATA;
+
+typedef EFI_EXP_BASE10_DATA EFI_PROCESSOR_FSB_FREQUENCY_DATA;
+
+typedef STRING_REF EFI_PROCESSOR_VERSION_DATA;
+
+typedef STRING_REF EFI_PROCESSOR_MANUFACTURER_DATA;
+
+typedef STRING_REF EFI_PROCESSOR_SERIAL_NUMBER_DATA;
+
+typedef STRING_REF EFI_PROCESSOR_ASSET_TAG_DATA;
+
+typedef STRING_REF EFI_PROCESSOR_PART_NUMBER_DATA;
+
+typedef struct {
+ UINT32 ProcessorSteppingId:4;
+ UINT32 ProcessorModel: 4;
+ UINT32 ProcessorFamily: 4;
+ UINT32 ProcessorType: 2;
+ UINT32 ProcessorReserved1: 2;
+ UINT32 ProcessorXModel: 4;
+ UINT32 ProcessorXFamily: 8;
+ UINT32 ProcessorReserved2: 4;
+} EFI_PROCESSOR_SIGNATURE;
+
+typedef struct {
+ UINT32 ProcessorBrandIndex :8;
+ UINT32 ProcessorClflush :8;
+ UINT32 ProcessorReserved :8;
+ UINT32 ProcessorDfltApicId :8;
+} EFI_PROCESSOR_MISC_INFO;
+
+typedef struct {
+ UINT32 ProcessorFpu: 1;
+ UINT32 ProcessorVme: 1;
+ UINT32 ProcessorDe: 1;
+ UINT32 ProcessorPse: 1;
+ UINT32 ProcessorTsc: 1;
+ UINT32 ProcessorMsr: 1;
+ UINT32 ProcessorPae: 1;
+ UINT32 ProcessorMce: 1;
+ UINT32 ProcessorCx8: 1;
+ UINT32 ProcessorApic: 1;
+ UINT32 ProcessorReserved1: 1;
+ UINT32 ProcessorSep: 1;
+ UINT32 ProcessorMtrr: 1;
+ UINT32 ProcessorPge: 1;
+ UINT32 ProcessorMca: 1;
+ UINT32 ProcessorCmov: 1;
+ UINT32 ProcessorPat: 1;
+ UINT32 ProcessorPse36: 1;
+ UINT32 ProcessorPsn: 1;
+ UINT32 ProcessorClfsh: 1;
+ UINT32 ProcessorReserved2: 1;
+ UINT32 ProcessorDs: 1;
+ UINT32 ProcessorAcpi: 1;
+ UINT32 ProcessorMmx: 1;
+ UINT32 ProcessorFxsr: 1;
+ UINT32 ProcessorSse: 1;
+ UINT32 ProcessorSse2: 1;
+ UINT32 ProcessorSs: 1;
+ UINT32 ProcessorReserved3: 1;
+ UINT32 ProcessorTm: 1;
+ UINT32 ProcessorReserved4: 2;
+} EFI_PROCESSOR_FEATURE_FLAGS;
+
+typedef struct {
+ EFI_PROCESSOR_SIGNATURE Signature;
+ EFI_PROCESSOR_MISC_INFO MiscInfo;
+ UINT32 Reserved;
+ EFI_PROCESSOR_FEATURE_FLAGS FeatureFlags;
+} EFI_PROCESSOR_ID_DATA;
+
+typedef enum {
+ EfiProcessorOther = 1,
+ EfiProcessorUnknown = 2,
+ EfiCentralProcessor = 3,
+ EfiMathProcessor = 4,
+ EfiDspProcessor = 5,
+ EfiVideoProcessor = 6
+} EFI_PROCESSOR_TYPE_DATA;
+
+typedef enum {
+ EfiProcessorFamilyOther = 1,
+ EfiProcessorFamilyUnknown = 2,
+ EfiProcessorFamily8086 = 3,
+ EfiProcessorFamily80286 = 4,
+ EfiProcessorFamilyIntel386 = 5,
+ EfiProcessorFamilyIntel486 = 6,
+ EfiProcessorFamily8087 = 7,
+ EfiProcessorFamily80287 = 8,
+ EfiProcessorFamily80387 = 9,
+ EfiProcessorFamily80487 = 0x0A,
+ EfiProcessorFamilyPentium = 0x0B,
+ EfiProcessorFamilyPentiumPro = 0x0C,
+ EfiProcessorFamilyPentiumII = 0x0D,
+ EfiProcessorFamilyPentiumMMX = 0x0E,
+ EfiProcessorFamilyCeleron = 0x0F,
+ EfiProcessorFamilyPentiumIIXeon = 0x10,
+ EfiProcessorFamilyPentiumIII = 0x11,
+ EfiProcessorFamilyM1 = 0x12,
+ EfiProcessorFamilyM2 = 0x13,
+ EfiProcessorFamilyM1Reserved2 = 0x14,
+ EfiProcessorFamilyM1Reserved3 = 0x15,
+ EfiProcessorFamilyM1Reserved4 = 0x16,
+ EfiProcessorFamilyM1Reserved5 = 0x17,
+ EfiProcessorFamilyAmdDuron = 0x18,
+ EfiProcessorFamilyK5 = 0x19,
+ EfiProcessorFamilyK6 = 0x1A,
+ EfiProcessorFamilyK6_2 = 0x1B,
+ EfiProcessorFamilyK6_3 = 0x1C,
+ EfiProcessorFamilyAmdAthlon = 0x1D,
+ EfiProcessorFamilyK6_2Plus = 0x1E,
+ EfiProcessorFamilyK5Reserved6 = 0x1F,
+ EfiProcessorFamilyPowerPC = 0x20,
+ EfiProcessorFamilyPowerPC601 = 0x21,
+ EfiProcessorFamilyPowerPC603 = 0x22,
+ EfiProcessorFamilyPowerPC603Plus = 0x23,
+ EfiProcessorFamilyPowerPC604 = 0x24,
+ EfiProcessorFamilyPowerPC620 = 0x25,
+ EfiProcessorFamilyPowerPC704 = 0x26,
+ EfiProcessorFamilyPowerPC750 = 0x27,
+ EfiProcessorFamilyIntelCoreDuo = 0x28,
+ EfiProcessorFamilyIntelCoreDuoMobile = 0x29,
+ EfiProcessorFamilyIntelCoreSoloMobile = 0x2A,
+ EfiProcessorFamilyIntelAtom = 0x2B,
+ EfiProcessorFamilyAlpha2 = 0x30,
+ EfiProcessorFamilyAlpha21064 = 0x31,
+ EfiProcessorFamilyAlpha21066 = 0x32,
+ EfiProcessorFamilyAlpha21164 = 0x33,
+ EfiProcessorFamilyAlpha21164PC = 0x34,
+ EfiProcessorFamilyAlpha21164a = 0x35,
+ EfiProcessorFamilyAlpha21264 = 0x36,
+ EfiProcessorFamilyAlpha21364 = 0x37,
+ EfiProcessorFamilyMips = 0x40,
+ EfiProcessorFamilyMIPSR4000 = 0x41,
+ EfiProcessorFamilyMIPSR4200 = 0x42,
+ EfiProcessorFamilyMIPSR4400 = 0x43,
+ EfiProcessorFamilyMIPSR4600 = 0x44,
+ EfiProcessorFamilyMIPSR10000 = 0x45,
+ EfiProcessorFamilySparc = 0x50,
+ EfiProcessorFamilySuperSparc = 0x51,
+ EfiProcessorFamilymicroSparcII = 0x52,
+ EfiProcessorFamilymicroSparcIIep = 0x53,
+ EfiProcessorFamilyUltraSparc = 0x54,
+ EfiProcessorFamilyUltraSparcII = 0x55,
+ EfiProcessorFamilyUltraSparcIIi = 0x56,
+ EfiProcessorFamilyUltraSparcIII = 0x57,
+ EfiProcessorFamilyUltraSparcIIIi = 0x58,
+ EfiProcessorFamily68040 = 0x60,
+ EfiProcessorFamily68xxx = 0x61,
+ EfiProcessorFamily68000 = 0x62,
+ EfiProcessorFamily68010 = 0x63,
+ EfiProcessorFamily68020 = 0x64,
+ EfiProcessorFamily68030 = 0x65,
+ EfiProcessorFamilyHobbit = 0x70,
+ EfiProcessorFamilyCrusoeTM5000 = 0x78,
+ EfiProcessorFamilyCrusoeTM3000 = 0x79,
+ EfiProcessorFamilyEfficeonTM8000 = 0x7A,
+ EfiProcessorFamilyWeitek = 0x80,
+ EfiProcessorFamilyItanium = 0x82,
+ EfiProcessorFamilyAmdAthlon64 = 0x83,
+ EfiProcessorFamilyAmdOpteron = 0x84,
+ EfiProcessorFamilyAmdSempron = 0x85,
+ EfiProcessorFamilyAmdTurion64Mobile = 0x86,
+ EfiProcessorFamilyDualCoreAmdOpteron = 0x87,
+ EfiProcessorFamilyAmdAthlon64X2DualCore = 0x88,
+ EfiProcessorFamilyAmdTurion64X2Mobile = 0x89,
+ EfiProcessorFamilyQuadCoreAmdOpteron = 0x8A,
+ EfiProcessorFamilyThirdGenerationAmdOpteron = 0x8B,
+ EfiProcessorFamilyAmdPhenomFxQuadCore = 0x8C,
+ EfiProcessorFamilyAmdPhenomX4QuadCore = 0x8D,
+ EfiProcessorFamilyAmdPhenomX2DualCore = 0x8E,
+ EfiProcessorFamilyAmdAthlonX2DualCore = 0x8F,
+ EfiProcessorFamilyPARISC = 0x90,
+ EfiProcessorFamilyPaRisc8500 = 0x91,
+ EfiProcessorFamilyPaRisc8000 = 0x92,
+ EfiProcessorFamilyPaRisc7300LC = 0x93,
+ EfiProcessorFamilyPaRisc7200 = 0x94,
+ EfiProcessorFamilyPaRisc7100LC = 0x95,
+ EfiProcessorFamilyPaRisc7100 = 0x96,
+ EfiProcessorFamilyV30 = 0xA0,
+ EfiProcessorFamilyQuadCoreIntelXeon3200Series = 0xA1,
+ EfiProcessorFamilyDualCoreIntelXeon3000Series = 0xA2,
+ EfiProcessorFamilyQuadCoreIntelXeon5300Series = 0xA3,
+ EfiProcessorFamilyDualCoreIntelXeon5100Series = 0xA4,
+ EfiProcessorFamilyDualCoreIntelXeon5000Series = 0xA5,
+ EfiProcessorFamilyDualCoreIntelXeonLV = 0xA6,
+ EfiProcessorFamilyDualCoreIntelXeonULV = 0xA7,
+ EfiProcessorFamilyDualCoreIntelXeon7100Series = 0xA8,
+ EfiProcessorFamilyQuadCoreIntelXeon5400Series = 0xA9,
+ EfiProcessorFamilyQuadCoreIntelXeon = 0xAA,
+ EfiProcessorFamilyDualCoreIntelXeon5200Series = 0xAB,
+ EfiProcessorFamilyDualCoreIntelXeon7200Series = 0xAC,
+ EfiProcessorFamilyQuadCoreIntelXeon7300Series = 0xAD,
+ EfiProcessorFamilyQuadCoreIntelXeon7400Series = 0xAE,
+ EfiProcessorFamilyMultiCoreIntelXeon7400Series = 0xAF,
+ EfiProcessorFamilyPentiumIIIXeon = 0xB0,
+ EfiProcessorFamilyPentiumIIISpeedStep = 0xB1,
+ EfiProcessorFamilyPentium4 = 0xB2,
+ EfiProcessorFamilyIntelXeon = 0xB3,
+ EfiProcessorFamilyAS400 = 0xB4,
+ EfiProcessorFamilyIntelXeonMP = 0xB5,
+ EfiProcessorFamilyAMDAthlonXP = 0xB6,
+ EfiProcessorFamilyAMDAthlonMP = 0xB7,
+ EfiProcessorFamilyIntelItanium2 = 0xB8,
+ EfiProcessorFamilyIntelPentiumM = 0xB9,
+ EfiProcessorFamilyIntelCeleronD = 0xBA,
+ EfiProcessorFamilyIntelPentiumD = 0xBB,
+ EfiProcessorFamilyIntelPentiumEx = 0xBC,
+ EfiProcessorFamilyIntelCoreSolo = 0xBD, // SMBIOS spec 2.6 correct this value
+ EfiProcessorFamilyReserved = 0xBE,
+ EfiProcessorFamilyIntelCore2 = 0xBF,
+ EfiProcessorFamilyIntelCore2Solo = 0xC0,
+ EfiProcessorFamilyIntelCore2Extreme = 0xC1,
+ EfiProcessorFamilyIntelCore2Quad = 0xC2,
+ EfiProcessorFamilyIntelCore2ExtremeMobile = 0xC3,
+ EfiProcessorFamilyIntelCore2DuoMobile = 0xC4,
+ EfiProcessorFamilyIntelCore2SoloMobile = 0xC5,
+ EfiProcessorFamilyIntelCoreI7 = 0xC6,
+ EfiProcessorFamilyDualCoreIntelCeleron = 0xC7,
+ EfiProcessorFamilyIBM390 = 0xC8,
+ EfiProcessorFamilyG4 = 0xC9,
+ EfiProcessorFamilyG5 = 0xCA,
+ EfiProcessorFamilyG6 = 0xCB,
+ EfiProcessorFamilyzArchitectur = 0xCC,
+ EfiProcessorFamilyViaC7M = 0xD2,
+ EfiProcessorFamilyViaC7D = 0xD3,
+ EfiProcessorFamilyViaC7 = 0xD4,
+ EfiProcessorFamilyViaEden = 0xD5,
+ EfiProcessorFamilyMultiCoreIntelXeon = 0xD6,
+ EfiProcessorFamilyDualCoreIntelXeon3Series = 0xD7,
+ EfiProcessorFamilyQuadCoreIntelXeon3Series = 0xD8,
+ EfiProcessorFamilyDualCoreIntelXeon5Series = 0xDA,
+ EfiProcessorFamilyQuadCoreIntelXeon5Series = 0xDB,
+ EfiProcessorFamilyDualCoreIntelXeon7Series = 0xDD,
+ EfiProcessorFamilyQuadCoreIntelXeon7Series = 0xDE,
+ EfiProcessorFamilyMultiCoreIntelXeon7Series = 0xDF,
+ EfiProcessorFamilyEmbeddedAmdOpteronQuadCore = 0xE6,
+ EfiProcessorFamilyAmdPhenomTripleCore = 0xE7,
+ EfiProcessorFamilyAmdTurionUltraDualCoreMobile = 0xE8,
+ EfiProcessorFamilyAmdTurionDualCoreMobile = 0xE9,
+ EfiProcessorFamilyAmdAthlonDualCore = 0xEA,
+ EfiProcessorFamilyAmdSempronSI = 0xEB,
+ EfiProcessorFamilyi860 = 0xFA,
+ EfiProcessorFamilyi960 = 0xFB,
+ EfiProcessorFamilyIndicatorFamily2 = 0xFE
+} EFI_PROCESSOR_FAMILY_DATA;
+
+typedef enum {
+ EfiProcessorFamilySh3 = 0x104,
+ EfiProcessorFamilySh4 = 0x105,
+ EfiProcessorFamilyArm = 0x118,
+ EfiProcessorFamilyStrongArm = 0x119,
+ EfiProcessorFamily6x86 = 0x12C,
+ EfiProcessorFamilyMediaGx = 0x12D,
+ EfiProcessorFamilyMii = 0x12E,
+ EfiProcessorFamilyWinChip = 0x140,
+ EfiProcessorFamilyDsp = 0x15E,
+ EfiProcessorFamilyVideo = 0x1F4
+} EFI_PROCESSOR_FAMILY2_DATA;
+
+typedef EFI_EXP_BASE10_DATA EFI_PROCESSOR_VOLTAGE_DATA;
+
+typedef EFI_PHYSICAL_ADDRESS EFI_PROCESSOR_APIC_BASE_ADDRESS_DATA;
+
+typedef UINT32 EFI_PROCESSOR_APIC_ID_DATA;
+
+typedef UINT32 EFI_PROCESSOR_APIC_VERSION_NUMBER_DATA;
+
+typedef enum {
+ EfiProcessorIa32Microcode = 1,
+ EfiProcessorIpfPalAMicrocode = 2,
+ EfiProcessorIpfPalBMicrocode = 3
+} EFI_PROCESSOR_MICROCODE_TYPE;
+
+typedef struct {
+ EFI_PROCESSOR_MICROCODE_TYPE ProcessorMicrocodeType;
+ UINT32 ProcessorMicrocodeRevisionNumber;
+} EFI_PROCESSOR_MICROCODE_REVISION_DATA;
+
+typedef struct {
+ UINT32 CpuStatus :3;
+ UINT32 Reserved1 :3;
+ UINT32 SocketPopulated :1;
+ UINT32 Reserved2 :1;
+ UINT32 ApicEnable :1;
+ UINT32 BootApplicationProcessor :1;
+ UINT32 Reserved3 :22;
+} EFI_PROCESSOR_STATUS_DATA;
+
+typedef enum {
+ EfiCpuStatusUnknown = 0,
+ EfiCpuStatusEnabled = 1,
+ EfiCpuStatusDisabledByUser = 2,
+ EfiCpuStatusDisabledbyBios = 3,
+ EfiCpuStatusIdle = 4,
+ EfiCpuStatusOther = 7
+} EFI_CPU_STATUS;
+
+typedef enum {
+ EfiProcessorSocketOther = 1,
+ EfiProcessorSocketUnknown = 2,
+ EfiProcessorSocketDaughterBoard = 3,
+ EfiProcessorSocketZIF = 4,
+ EfiProcessorSocketReplacePiggyBack = 5,
+ EfiProcessorSocketNone = 6,
+ EfiProcessorSocketLIF = 7,
+ EfiProcessorSocketSlot1 = 8,
+ EfiProcessorSocketSlot2 = 9,
+ EfiProcessorSocket370Pin = 0xA,
+ EfiProcessorSocketSlotA = 0xB,
+ EfiProcessorSocketSlotM = 0xC,
+ EfiProcessorSocket423 = 0xD,
+ EfiProcessorSocketA462 = 0xE,
+ EfiProcessorSocket478 = 0xF,
+ EfiProcessorSocket754 = 0x10,
+ EfiProcessorSocket940 = 0x11,
+ EfiProcessorSocket939 = 0x12,
+ EfiProcessorSocketmPGA604 = 0x13,
+ EfiProcessorSocketLGA771 = 0x14,
+ EfiProcessorSocketLGA775 = 0x15,
+ EfiProcessorSocketS1 = 0x16,
+ EfiProcessorSocketAm2 = 0x17,
+ EfiProcessorSocketF = 0x18,
+ EfiProcessorSocketLGA1366 = 0x19
+} EFI_PROCESSOR_SOCKET_TYPE_DATA;
+
+typedef STRING_REF EFI_PROCESSOR_SOCKET_NAME_DATA;
+
+typedef EFI_INTER_LINK_DATA EFI_CACHE_ASSOCIATION_DATA;
+
+typedef enum {
+ EfiProcessorHealthy = 1,
+ EfiProcessorPerfRestricted = 2,
+ EfiProcessorFuncRestricted = 3
+} EFI_PROCESSOR_HEALTH_STATUS;
+
+typedef UINTN EFI_PROCESSOR_PACKAGE_NUMBER_DATA;
+
+typedef UINT8 EFI_PROCESSOR_CORE_COUNT_DATA;
+typedef UINT8 EFI_PROCESSOR_ENABLED_CORE_COUNT_DATA;
+typedef UINT8 EFI_PROCESSOR_THREAD_COUNT_DATA;
+
+typedef EFI_EXP_BASE10_DATA EFI_PROCESSOR_MAX_FSB_FREQUENCY_DATA;
+
+typedef struct {
+ UINT16 Reserved :1;
+ UINT16 Unknown :1;
+ UINT16 Capable64Bit :1;
+ UINT16 Reserved2 :13;
+} EFI_PROCESSOR_CHARACTERISTICS_DATA;
+
+typedef struct {
+ EFI_PROCESSOR_SOCKET_NAME_DATA ProcessorSocketName;
+ EFI_PROCESSOR_TYPE_DATA ProcessorType;
+ EFI_PROCESSOR_FAMILY_DATA ProcessorFamily;
+ EFI_PROCESSOR_MANUFACTURER_DATA ProcessorManufacturer;
+ EFI_PROCESSOR_ID_DATA ProcessorId;
+ EFI_PROCESSOR_VERSION_DATA ProcessorVersion;
+ EFI_PROCESSOR_VOLTAGE_DATA ProcessorVoltage;
+ EFI_PROCESSOR_FSB_FREQUENCY_DATA ProcessorFsbFrequency;
+ EFI_PROCESSOR_MAX_CORE_FREQUENCY_DATA ProcessorMaxCoreFrequency;
+ EFI_PROCESSOR_CORE_FREQUENCY_DATA ProcessorCoreFrequency;
+ EFI_PROCESSOR_STATUS_DATA ProcessorStatus;
+ EFI_PROCESSOR_SOCKET_TYPE_DATA ProcessorSocketType;
+ EFI_CACHE_ASSOCIATION_DATA ProcessorL1LinkData;
+ EFI_CACHE_ASSOCIATION_DATA ProcessorL2LinkData;
+ EFI_CACHE_ASSOCIATION_DATA ProcessorL3LinkData;
+ EFI_PROCESSOR_SERIAL_NUMBER_DATA ProcessorSerialNumber;
+ EFI_PROCESSOR_ASSET_TAG_DATA ProcessorAssetTag;
+ EFI_PROCESSOR_PART_NUMBER_DATA ProcessorPartNumber;
+ EFI_PROCESSOR_CORE_COUNT_DATA ProcessorCoreCount;
+ EFI_PROCESSOR_ENABLED_CORE_COUNT_DATA ProcessorEnabledCoreCount;
+ EFI_PROCESSOR_THREAD_COUNT_DATA ProcessorThreadCount;
+ EFI_PROCESSOR_CHARACTERISTICS_DATA ProcessorCharacteristics;
+ EFI_PROCESSOR_FAMILY2_DATA ProcessorFamily2;
+} EFI_PROCESSOR_SOCKET_DATA;
+
+typedef enum {
+ ProcessorCoreFrequencyRecordType = 1,
+ ProcessorFsbFrequencyRecordType = 2,
+ ProcessorVersionRecordType = 3,
+ ProcessorManufacturerRecordType = 4,
+ ProcessorSerialNumberRecordType = 5,
+ ProcessorIdRecordType = 6,
+ ProcessorTypeRecordType = 7,
+ ProcessorFamilyRecordType = 8,
+ ProcessorVoltageRecordType = 9,
+ ProcessorApicBaseAddressRecordType = 10,
+ ProcessorApicIdRecordType = 11,
+ ProcessorApicVersionNumberRecordType = 12,
+ CpuUcodeRevisionDataRecordType = 13,
+ ProcessorStatusRecordType = 14,
+ ProcessorSocketTypeRecordType = 15,
+ ProcessorSocketNameRecordType = 16,
+ CacheAssociationRecordType = 17,
+ ProcessorMaxCoreFrequencyRecordType = 18,
+ ProcessorAssetTagRecordType = 19,
+ ProcessorMaxFsbFrequencyRecordType = 20,
+ ProcessorPackageNumberRecordType = 21,
+ ProcessorCoreFrequencyListRecordType = 22,
+ ProcessorFsbFrequencyListRecordType = 23,
+ ProcessorHealthStatusRecordType = 24,
+ ProcessorCoreCountRecordType = 25,
+ ProcessorEnabledCoreCountRecordType = 26,
+ ProcessorThreadCountRecordType = 27,
+ ProcessorCharacteristicsRecordType = 28,
+ ProcessorFamily2RecordType = 29,
+ ProcessorPartNumberRecordType = 30,
+ ProcessorSocketRecordType = 31
+} EFI_CPU_VARIABLE_RECORD_TYPE;
+
+typedef union {
+ EFI_PROCESSOR_CORE_FREQUENCY_LIST_DATA ProcessorCoreFrequencyList;
+ EFI_PROCESSOR_FSB_FREQUENCY_LIST_DATA ProcessorFsbFrequencyList;
+ EFI_PROCESSOR_SERIAL_NUMBER_DATA ProcessorSerialNumber;
+ EFI_PROCESSOR_CORE_FREQUENCY_DATA ProcessorCoreFrequency;
+ EFI_PROCESSOR_FSB_FREQUENCY_DATA ProcessorFsbFrequency;
+ EFI_PROCESSOR_MAX_CORE_FREQUENCY_DATA ProcessorMaxCoreFrequency;
+ EFI_PROCESSOR_MAX_FSB_FREQUENCY_DATA ProcessorMaxFsbFrequency;
+ EFI_PROCESSOR_VERSION_DATA ProcessorVersion;
+ EFI_PROCESSOR_MANUFACTURER_DATA ProcessorManufacturer;
+ EFI_PROCESSOR_ID_DATA ProcessorId;
+ EFI_PROCESSOR_TYPE_DATA ProcessorType;
+ EFI_PROCESSOR_FAMILY_DATA ProcessorFamily;
+ EFI_PROCESSOR_VOLTAGE_DATA ProcessorVoltage;
+ EFI_PROCESSOR_APIC_BASE_ADDRESS_DATA ProcessorApicBase;
+ EFI_PROCESSOR_APIC_ID_DATA ProcessorApicId;
+ EFI_PROCESSOR_APIC_VERSION_NUMBER_DATA ProcessorApicVersionNumber;
+ EFI_PROCESSOR_MICROCODE_REVISION_DATA CpuUcodeRevisionData;
+ EFI_PROCESSOR_STATUS_DATA ProcessorStatus;
+ EFI_PROCESSOR_SOCKET_TYPE_DATA ProcessorSocketType;
+ EFI_PROCESSOR_SOCKET_NAME_DATA ProcessorSocketName;
+ EFI_PROCESSOR_ASSET_TAG_DATA ProcessorAssetTag;
+ EFI_PROCESSOR_PART_NUMBER_DATA ProcessorPartNumber;
+ EFI_PROCESSOR_HEALTH_STATUS ProcessorHealthStatus;
+ EFI_PROCESSOR_PACKAGE_NUMBER_DATA ProcessorPackageNumber;
+ EFI_PROCESSOR_CORE_COUNT_DATA ProcessorCoreCount;
+ EFI_PROCESSOR_ENABLED_CORE_COUNT_DATA ProcessorEnabledCoreCount;
+ EFI_PROCESSOR_THREAD_COUNT_DATA ProcessorThreadCount;
+ EFI_PROCESSOR_CHARACTERISTICS_DATA ProcessorCharacteristics;
+ EFI_PROCESSOR_FAMILY2_DATA ProcessorFamily2;
+ EFI_PROCESSOR_SOCKET_DATA ProcessorSocket;
+} EFI_CPU_VARIABLE_RECORD;
+
+typedef struct {
+ EFI_SUBCLASS_TYPE1_HEADER DataRecordHeader;
+ EFI_CPU_VARIABLE_RECORD VariableRecord;
+} EFI_CPU_DATA_RECORD;
+
+#endif
diff --git a/EDK/Foundation/Framework/Guid/DxeServices/DxeServices.c b/EDK/Foundation/Framework/Guid/DxeServices/DxeServices.c
new file mode 100644
index 0000000..8515e04
--- /dev/null
+++ b/EDK/Foundation/Framework/Guid/DxeServices/DxeServices.c
@@ -0,0 +1,27 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ DxeServices.c
+
+Abstract:
+
+ GUID used for the DXE Services Table
+
+--*/
+
+#include "Tiano.h"
+#include EFI_GUID_DEFINITION (DxeServices)
+
+EFI_GUID gEfiDxeServicesTableGuid = EFI_DXE_SERVICES_TABLE_GUID;
+
+EFI_GUID_STRING(&gEfiDxeServicesTableGuid, "DXE Services Table", "DXE Services Table GUID in EFI System Table");
diff --git a/EDK/Foundation/Framework/Guid/DxeServices/DxeServices.h b/EDK/Foundation/Framework/Guid/DxeServices/DxeServices.h
new file mode 100644
index 0000000..6869a29
--- /dev/null
+++ b/EDK/Foundation/Framework/Guid/DxeServices/DxeServices.h
@@ -0,0 +1,32 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ DxeServices.h
+
+Abstract:
+
+ GUID used for the DXE Services Table
+
+--*/
+
+#ifndef _DXE_SERVICES_H_
+#define _DXE_SERVICES_H_
+
+#define EFI_DXE_SERVICES_TABLE_GUID \
+ { \
+ 0x5ad34ba, 0x6f02, 0x4214, 0x95, 0x2e, 0x4d, 0xa0, 0x39, 0x8e, 0x2b, 0xb9 \
+ }
+
+extern EFI_GUID gEfiDxeServicesTableGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Guid/EdkFrameworkGuidLib.cif b/EDK/Foundation/Framework/Guid/EdkFrameworkGuidLib.cif
new file mode 100644
index 0000000..51ff345
--- /dev/null
+++ b/EDK/Foundation/Framework/Guid/EdkFrameworkGuidLib.cif
@@ -0,0 +1,39 @@
+<component>
+ name = "EdkFrameworkGuidLib"
+ category = ModulePart
+ LocalRoot = "Edk\Foundation\Framework\Guid\"
+ RefName = "EdkFrameworkGuidLib"
+[files]
+"EdkFrameworkGuidLib.sdl"
+"EdkFrameworkGuidLib.mak"
+"AcpiTableStorage\AcpiTableStorage.h"
+"AcpiTableStorage\AcpiTableStorage.c"
+"Apriori\Apriori.h"
+"Apriori\Apriori.c"
+"DataHubRecords\DataHubRecords.h"
+"DataHubRecords\DataHubRecords.c"
+"DataHubRecords\DataHubSubClass.h"
+"DataHubRecords\DataHubSubClassCache.h"
+"DataHubRecords\DataHubSubClassMemory.h"
+"DataHubRecords\DataHubSubClassMisc.h"
+"DataHubRecords\DataHubSubClassProcessor.h"
+"DxeServices\DxeServices.h"
+"DxeServices\DxeServices.c"
+"FirmwareFileSystem\FirmwareFileSystem.h"
+"FirmwareFileSystem\FirmwareFileSystem.c"
+"Hob\Hob.h"
+"Hob\Hob.c"
+"MemoryAllocationHob\MemoryAllocationHob.h"
+"MemoryAllocationHob\MemoryAllocationHob.c"
+"SmramMemoryReserve\SmramMemoryReserve.h"
+"SmramMemoryReserve\SmramMemoryReserve.c"
+"StatusCodeDataTypeId\StatusCodeDataTypeId.h"
+"StatusCodeDataTypeId\StatusCodeDataTypeId.c"
+"FrameworkDevicePath\FrameworkDevicePath.h"
+"FrameworkDevicePath\FrameworkDevicePath.c"
+"FirmwareFileSystem2\FirmwareFileSystem2.h"
+"FirmwareFileSystem2\FirmwareFileSystem2.c"
+"PeiApriori\PeiApriori.h"
+"PeiApriori\PeiApriori.c"
+"EdkFrameworkGuidLib.inf"
+<endComponent>
diff --git a/EDK/Foundation/Framework/Guid/EdkFrameworkGuidLib.inf b/EDK/Foundation/Framework/Guid/EdkFrameworkGuidLib.inf
new file mode 100644
index 0000000..fc6fde6
--- /dev/null
+++ b/EDK/Foundation/Framework/Guid/EdkFrameworkGuidLib.inf
@@ -0,0 +1,64 @@
+#/*++
+#
+# Copyright (c) 2004 - 2006, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# EdkFrameworkGuidLib.inf
+#
+# Abstract:
+#
+# Component description file.
+#
+#--*/
+
+[defines]
+BASE_NAME= EdkFrameworkGuidLib
+COMPONENT_TYPE= LIBRARY
+
+[includes.common]
+ $(EDK_SOURCE)\Foundation\Framework
+ $(EDK_SOURCE)\Foundation\Efi
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+ $(EDK_SOURCE)\Foundation\Include\Pei
+ $(EDK_SOURCE)\Foundation\Library\Pei\Include
+
+[includes.Nt32]
+ $(EDK_SOURCE)\Foundation\Include\WinNt
+
+[nmake.common]
+C_STD_INCLUDE=
+[sources.common]
+ AcpiTableStorage\AcpiTableStorage.h
+ AcpiTableStorage\AcpiTableStorage.c
+ Apriori\Apriori.h
+ Apriori\Apriori.c
+ DataHubRecords\DataHubRecords.h
+ DataHubRecords\DataHubRecords.c
+ DxeServices\DxeServices.h
+ DxeServices\DxeServices.c
+ FirmwareFileSystem\FirmwareFileSystem.h
+ FirmwareFileSystem\FirmwareFileSystem.c
+ Hob\Hob.h
+ Hob\Hob.c
+ MemoryAllocationHob\MemoryAllocationHob.c
+ MemoryAllocationHob\MemoryAllocationHob.h
+ SmramMemoryReserve\SmramMemoryReserve.h
+ SmramMemoryReserve\SmramMemoryReserve.c
+ StatusCodeDataTypeId\StatusCodeDataTypeId.h
+ StatusCodeDataTypeId\StatusCodeDataTypeId.c
+ FrameworkDevicePath\FrameworkDevicePath.h
+ FrameworkDevicePath\FrameworkDevicePath.c
+ FirmwareFileSystem2\FirmwareFileSystem2.h
+ FirmwareFileSystem2\FirmwareFileSystem2.c
diff --git a/EDK/Foundation/Framework/Guid/EdkFrameworkGuidLib.mak b/EDK/Foundation/Framework/Guid/EdkFrameworkGuidLib.mak
new file mode 100644
index 0000000..ce0dbdb
--- /dev/null
+++ b/EDK/Foundation/Framework/Guid/EdkFrameworkGuidLib.mak
@@ -0,0 +1,73 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkFrameworkGuidLib/EdkFrameworkGuidLib.mak 1 1/20/12 4:02a Jeffch $
+#
+# $Revision: 1 $
+#
+# $Date: 1/20/12 4:02a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkFrameworkGuidLib/EdkFrameworkGuidLib.mak $
+#
+# 1 1/20/12 4:02a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 9/27/11 6:25a Wesleychen
+# Intel EDK initially releases.
+#
+# 2 9/02/09 3:17a Iminglin
+# EIP24919
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: EdkFrameworkGuidLib.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+
+$(EDKFRAMEWORKGUIDLIB) : EdkFrameworkGuidLib
+
+EdkFrameworkGuidLib : $(BUILD_DIR)\EdkFrameworkGuidLib.mak EdkFrameworkGuidLibBin
+
+$(BUILD_DIR)\EdkFrameworkGuidLib.mak : $(EdkFrameworkGuidLib_DIR)\$(@B).cif $(EdkFrameworkGuidLib_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(EdkFrameworkGuidLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+EdkFrameworkGuidLibBin :
+ $(MAKE) /$(MAKEFLAGS) $(EDK_DEFAULTS)\
+ /f $(BUILD_DIR)\EdkFrameworkGuidLib.mak all\
+ TYPE=LIBRARY
+!IF "$(x64_BUILD)"=="1"
+ $(MAKE) /$(MAKEFLAGS) $(EDK_DEFAULTS) BUILD_DIR=$(BUILD_DIR)\IA32\
+ /f $(BUILD_DIR)\EdkFrameworkGuidLib.mak all\
+ TYPE=PEI_LIBRARY
+!ENDIF
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#********************************************************************** \ No newline at end of file
diff --git a/EDK/Foundation/Framework/Guid/EdkFrameworkGuidLib.sdl b/EDK/Foundation/Framework/Guid/EdkFrameworkGuidLib.sdl
new file mode 100644
index 0000000..b5a4fc3
--- /dev/null
+++ b/EDK/Foundation/Framework/Guid/EdkFrameworkGuidLib.sdl
@@ -0,0 +1,26 @@
+TOKEN
+ Name = "EdkFrameworkGuidLib_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable EdkFrameworkGuidLib support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "EDKFRAMEWORKGUIDLIB"
+ Value = "$$(LIB_BUILD_DIR)\EdkFrameworkGuidLib.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "EdkFrameworkGuidLib_DIR"
+End
+
+MODULE
+ Help = "Includes EdkFrameworkGuidLib.mak to Project"
+ File = "EdkFrameworkGuidLib.mak"
+End
+
diff --git a/EDK/Foundation/Framework/Guid/FirmwareFileSystem/FirmwareFileSystem.c b/EDK/Foundation/Framework/Guid/FirmwareFileSystem/FirmwareFileSystem.c
new file mode 100644
index 0000000..147d8a0
--- /dev/null
+++ b/EDK/Foundation/Framework/Guid/FirmwareFileSystem/FirmwareFileSystem.c
@@ -0,0 +1,30 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ FirmwareFileSystem.c
+
+Abstract:
+
+ Tiano Guid used to define the Firmware File System. See the EFI Firmware
+ File System Specification for more details.
+
+--*/
+
+#include "Tiano.h"
+#include EFI_GUID_DEFINITION (FirmwareFileSystem)
+
+EFI_GUID gEfiFirmwareFileSystemGuid = EFI_FIRMWARE_FILE_SYSTEM_GUID;
+EFI_GUID gEfiFirmwareVolumeTopFileGuid = EFI_FFS_VOLUME_TOP_FILE_GUID;
+
+EFI_GUID_STRING(&gEfiFirmwareFileSystemGuid, "Firmware File System GUID", "EFI Firmware File System GUID");
+EFI_GUID_STRING(&gEfiFirmwareVolumeTopFileGuid, "Firmware Volume Top File GUID", "EFI FFS Volume Top File GUID");
diff --git a/EDK/Foundation/Framework/Guid/FirmwareFileSystem/FirmwareFileSystem.h b/EDK/Foundation/Framework/Guid/FirmwareFileSystem/FirmwareFileSystem.h
new file mode 100644
index 0000000..ba2b34a
--- /dev/null
+++ b/EDK/Foundation/Framework/Guid/FirmwareFileSystem/FirmwareFileSystem.h
@@ -0,0 +1,34 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ FirmwareFileSystem.h
+
+Abstract:
+
+ Tiano Guid used to define the Firmware File System. See the EFI Firmware
+ File System Specification for more details.
+
+--*/
+
+#ifndef _FIRMWARE_FILE_SYSTEM_GUID_H
+#define _FIRMWARE_FILE_SYSTEM_GUID_H
+
+//
+// GUID definitions are in EfiFirmwareFileSystem.h
+//
+#include "EfiFirmwareFileSystem.h"
+
+extern EFI_GUID gEfiFirmwareFileSystemGuid;
+extern EFI_GUID gEfiFirmwareVolumeTopFileGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Guid/FirmwareFileSystem2/FirmwareFileSystem2.c b/EDK/Foundation/Framework/Guid/FirmwareFileSystem2/FirmwareFileSystem2.c
new file mode 100644
index 0000000..39a17c9
--- /dev/null
+++ b/EDK/Foundation/Framework/Guid/FirmwareFileSystem2/FirmwareFileSystem2.c
@@ -0,0 +1,27 @@
+/*++
+
+Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ FirmwareFileSystem2.c
+
+Abstract:
+
+ PI 1.0 spec definition.
+
+--*/
+
+#include "Tiano.h"
+#include EFI_GUID_DEFINITION(FirmwareFileSystem2)
+
+EFI_GUID gEfiFirmwareFileSystem2Guid = EFI_FIRMWARE_FILE_SYSTEM2_GUID;
+EFI_GUID_STRING(&gEfiFirmwareFileSystem2Guid, "FirmwareFileSystem2", "Efi FirmwareFileSystem2")
+
diff --git a/EDK/Foundation/Framework/Guid/FirmwareFileSystem2/FirmwareFileSystem2.h b/EDK/Foundation/Framework/Guid/FirmwareFileSystem2/FirmwareFileSystem2.h
new file mode 100644
index 0000000..ccc566f
--- /dev/null
+++ b/EDK/Foundation/Framework/Guid/FirmwareFileSystem2/FirmwareFileSystem2.h
@@ -0,0 +1,33 @@
+/*++
+
+Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ FirmwareFileSystem2.h
+
+Abstract:
+
+ PI 1.0 spec definition.
+
+--*/
+
+#ifndef __FIRMWARE_FILE_SYSTEM2_GUID_H__
+#define __FIRMWARE_FILE_SYSTEM2_GUID_H__
+
+//
+// GUIDs defined by the FFS specification.
+//
+#define EFI_FIRMWARE_FILE_SYSTEM2_GUID \
+ { 0x8c8ce578, 0x8a3d, 0x4f1c, { 0x99, 0x35, 0x89, 0x61, 0x85, 0xc3, 0x2d, 0xd3 } }
+
+extern EFI_GUID gEfiFirmwareFileSystem2Guid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Guid/FrameworkDevicePath/FrameworkDevicePath.c b/EDK/Foundation/Framework/Guid/FrameworkDevicePath/FrameworkDevicePath.c
new file mode 100644
index 0000000..750e7a2
--- /dev/null
+++ b/EDK/Foundation/Framework/Guid/FrameworkDevicePath/FrameworkDevicePath.c
@@ -0,0 +1,27 @@
+/*++
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ FrameworkDevicePath.c
+
+Abstract:
+
+ GUID used for
+
+--*/
+
+#include "Tiano.h"
+#include EFI_GUID_DEFINITION (FrameworkDevicePath)
+
+EFI_GUID gEfiFrameworkDevicePathGuid = EFI_FRAMEWORK_DEVICE_PATH_GUID;
+
+EFI_GUID_STRING(&gEfiFrameworkDevicePathGuid, "Framework Devic Path", "Framework Device Path GUID");
diff --git a/EDK/Foundation/Framework/Guid/FrameworkDevicePath/FrameworkDevicePath.h b/EDK/Foundation/Framework/Guid/FrameworkDevicePath/FrameworkDevicePath.h
new file mode 100644
index 0000000..ecd25eb
--- /dev/null
+++ b/EDK/Foundation/Framework/Guid/FrameworkDevicePath/FrameworkDevicePath.h
@@ -0,0 +1,29 @@
+/*++
+ This GUID is used to define a vendor specific device path being owned by the
+ Framework specificaitons.
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ Module Name: FrameworkDevicePath.h
+
+ @par Revision Reference:
+ Spec Version 0.9
+
+--*/
+
+#ifndef __FRAMEWORK_DEVICE_PATH_GUID_H__
+#define __FRAMEWORK_DEVICE_PATH_GUID_H__
+
+#define EFI_FRAMEWORK_DEVICE_PATH_GUID \
+ { 0xb7084e63, 0x46b7, 0x4d1a, { 0x86, 0x77, 0xe3, 0x0b, 0x53, 0xdb, 0xf0, 0x50 } }
+
+extern EFI_GUID gEfiFrameworkDevicePathGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Guid/Hob/Hob.c b/EDK/Foundation/Framework/Guid/Hob/Hob.c
new file mode 100644
index 0000000..10dd0bd
--- /dev/null
+++ b/EDK/Foundation/Framework/Guid/Hob/Hob.c
@@ -0,0 +1,29 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Hob.c
+
+Abstract:
+
+ GUIDs used for HOB List in the EFI 1.0 system table
+
+ These GUIDs point the HOB List passed in from PEI to DXE.
+
+--*/
+
+#include "Tiano.h"
+#include EFI_GUID_DEFINITION (Hob)
+
+EFI_GUID gEfiHobListGuid = EFI_HOB_LIST_GUID;
+
+EFI_GUID_STRING(&gEfiHobListGuid, "HOB List", "HOB List GUID in EFI System Table");
diff --git a/EDK/Foundation/Framework/Guid/Hob/Hob.h b/EDK/Foundation/Framework/Guid/Hob/Hob.h
new file mode 100644
index 0000000..a7771fe
--- /dev/null
+++ b/EDK/Foundation/Framework/Guid/Hob/Hob.h
@@ -0,0 +1,34 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Hob.h
+
+Abstract:
+
+ GUIDs used for HOB List entries in the in the EFI 1.0 system table
+
+ These GUIDs point the HOB List passed from PEI to DXE.
+
+--*/
+
+#ifndef _HOB_GUID_H_
+#define _HOB_GUID_H_
+
+#define EFI_HOB_LIST_GUID \
+ { \
+ 0x7739f24c, 0x93d7, 0x11d4, 0x9a, 0x3a, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d \
+ }
+
+extern EFI_GUID gEfiHobListGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Guid/MemoryAllocationHob/MemoryAllocationHob.c b/EDK/Foundation/Framework/Guid/MemoryAllocationHob/MemoryAllocationHob.c
new file mode 100644
index 0000000..84ef72e
--- /dev/null
+++ b/EDK/Foundation/Framework/Guid/MemoryAllocationHob/MemoryAllocationHob.c
@@ -0,0 +1,31 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ MemoryAllocationHob.c
+
+Abstract:
+
+ GUIDs for HOBs used in memory allcation
+
+--*/
+
+#include "Tiano.h"
+#include EFI_GUID_DEFINITION(MemoryAllocationHob)
+
+EFI_GUID gEfiHobMemeryAllocBspStoreGuid = EFI_HOB_MEMORY_ALLOC_BSP_STORE_GUID;
+EFI_GUID gEfiHobMemeryAllocStackGuid = EFI_HOB_MEMORY_ALLOC_STACK_GUID;
+EFI_GUID gEfiHobMemeryAllocModuleGuid = EFI_HOB_MEMORY_ALLOC_MODULE_GUID;
+
+EFI_GUID_STRING(&gEfiHobMemeryAllocBspStoreGuid, "BSP Store HOB", "HOB for BSP Store Memory Allocation");
+EFI_GUID_STRING(&gEfiHobMemeryAllocStackGuid, "Stack HOB", "HOB for Stack Memory Allocation");
+EFI_GUID_STRING(&gEfiHobMemeryAllocModuleGuid, "Memry Allocation Module HOB", "HOB for Memory Allocation Module");
diff --git a/EDK/Foundation/Framework/Guid/MemoryAllocationHob/MemoryAllocationHob.h b/EDK/Foundation/Framework/Guid/MemoryAllocationHob/MemoryAllocationHob.h
new file mode 100644
index 0000000..827e772
--- /dev/null
+++ b/EDK/Foundation/Framework/Guid/MemoryAllocationHob/MemoryAllocationHob.h
@@ -0,0 +1,38 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ MemoryAllocationHob.h
+
+Abstract:
+
+ GUIDs for HOBs used in memory allcation
+
+--*/
+
+#ifndef _HOB__MEMORY_ALLOCATION_GUID_H_
+#define _HOB__MEMORY_ALLOCATION_GUID_H_
+
+#define EFI_HOB_MEMORY_ALLOC_BSP_STORE_GUID \
+ {0x564b33cd, 0xc92a, 0x4593, 0x90, 0xbf, 0x24, 0x73, 0xe4, 0x3c, 0x63, 0x22};
+
+#define EFI_HOB_MEMORY_ALLOC_STACK_GUID \
+ {0x4ed4bf27, 0x4092, 0x42e9, 0x80, 0x7d, 0x52, 0x7b, 0x1d, 0x0, 0xc9, 0xbd}
+
+#define EFI_HOB_MEMORY_ALLOC_MODULE_GUID \
+ {0xf8e21975, 0x899, 0x4f58, 0xa4, 0xbe, 0x55, 0x25, 0xa9, 0xc6, 0xd7, 0x7a}
+
+extern EFI_GUID gEfiHobMemeryAllocBspStoreGuid;
+extern EFI_GUID gEfiHobMemeryAllocStackGuid;
+extern EFI_GUID gEfiHobMemeryAllocModuleGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Guid/PeiApriori/PeiApriori.c b/EDK/Foundation/Framework/Guid/PeiApriori/PeiApriori.c
new file mode 100644
index 0000000..bab1606
--- /dev/null
+++ b/EDK/Foundation/Framework/Guid/PeiApriori/PeiApriori.c
@@ -0,0 +1,26 @@
+/*++
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PeiApriori.c
+
+Abstract:
+
+ PI 1.0 spec definition.
+
+--*/
+
+#include "Tiano.h"
+#include EFI_GUID_DEFINITION(PeiApriori)
+
+EFI_GUID gEfiPeiAprioriGuid = EFI_PEI_APRIORI_FILE_NAME_GUID;
+EFI_GUID_STRING(&gEfiPeiAprioriGuid, "PeiApriori", "Efi PeiApriori")
diff --git a/EDK/Foundation/Framework/Guid/PeiApriori/PeiApriori.h b/EDK/Foundation/Framework/Guid/PeiApriori/PeiApriori.h
new file mode 100644
index 0000000..12a611b
--- /dev/null
+++ b/EDK/Foundation/Framework/Guid/PeiApriori/PeiApriori.h
@@ -0,0 +1,36 @@
+/*++
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PeiApriori.h
+
+Abstract:
+
+ PI 1.0 spec definition.
+
+--*/
+
+#ifndef __PEI_APRIORI_GUID_H__
+#define __PEI_APRIORI_GUID_H__
+
+#include "Tiano.h"
+
+//
+// GUIDs defined by the FFS specification.
+//
+#define EFI_PEI_APRIORI_FILE_NAME_GUID \
+ { 0x1b45cc0a, 0x156a, 0x428a, 0xaf, 0x62, 0x49, 0x86, 0x4d, 0xa0, 0xe6, 0xe6}
+
+
+extern EFI_GUID gEfiPeiAprioriGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Guid/SmramMemoryReserve/SmramMemoryReserve.c b/EDK/Foundation/Framework/Guid/SmramMemoryReserve/SmramMemoryReserve.c
new file mode 100644
index 0000000..221b1a8
--- /dev/null
+++ b/EDK/Foundation/Framework/Guid/SmramMemoryReserve/SmramMemoryReserve.c
@@ -0,0 +1,28 @@
+/*++
+
+Copyright (c) 1999 - 2002, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ SmramMemoryReserve.c
+
+Abstract:
+
+ GUID for use in reserving SMRAM regions.
+
+--*/
+
+#include "Tiano.h"
+#include EFI_GUID_DEFINITION(SmramMemoryReserve)
+
+EFI_GUID gEfiSmmPeiSmramMemoryReserve = EFI_SMM_PEI_SMRAM_MEMORY_RESERVE;
+
+EFI_GUID_STRING(&gEfiSmmPeiSmramMemoryReserve, "SMRAM Memory Reserve", "SMRAM Memory Reserve");
diff --git a/EDK/Foundation/Framework/Guid/SmramMemoryReserve/SmramMemoryReserve.h b/EDK/Foundation/Framework/Guid/SmramMemoryReserve/SmramMemoryReserve.h
new file mode 100644
index 0000000..ff3351b
--- /dev/null
+++ b/EDK/Foundation/Framework/Guid/SmramMemoryReserve/SmramMemoryReserve.h
@@ -0,0 +1,70 @@
+/*++
+
+Copyright (c) 1999 - 2002, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ SmramMemoryReserve.h
+
+Abstract:
+
+ GUID for use in reserving SMRAM regions.
+
+--*/
+
+#ifndef _EFI_SMM_PEI_SMRAM_MEMORY_RESERVE_H_
+#define _EFI_SMM_PEI_SMRAM_MEMORY_RESERVE_H_
+
+#define EFI_SMM_PEI_SMRAM_MEMORY_RESERVE \
+ { \
+ 0x6dadf1d1, 0xd4cc, 0x4910, 0xbb, 0x6e, 0x82, 0xb1, 0xfd, 0x80, 0xff, 0x3d \
+ }
+
+//
+// *******************************************************
+// EFI_SMRAM_DESCRIPTOR
+// *******************************************************
+//
+typedef struct {
+ EFI_PHYSICAL_ADDRESS PhysicalStart; // Phsyical location in DRAM
+ EFI_PHYSICAL_ADDRESS CpuStart; // Address CPU uses to access the SMI handler
+ // May or may not match PhysicalStart
+ //
+ UINT64 PhysicalSize;
+ UINT64 RegionState;
+} EFI_SMRAM_DESCRIPTOR;
+
+//
+// *******************************************************
+// EFI_SMRAM_STATE
+// *******************************************************
+//
+#define EFI_SMRAM_OPEN 0x00000001
+#define EFI_SMRAM_CLOSED 0x00000002
+#define EFI_SMRAM_LOCKED 0x00000004
+#define EFI_CACHEABLE 0x00000008
+#define EFI_ALLOCATED 0x00000010
+#define EFI_NEEDS_TESTING 0x00000020
+#define EFI_NEEDS_ECC_INITIALIZATION 0x00000040
+
+//
+// *******************************************************
+// EFI_SMRAM_HOB_DESCRIPTOR_BLOCK
+// *******************************************************
+//
+typedef struct {
+ UINT32 NumberOfSmmReservedRegions;
+ EFI_SMRAM_DESCRIPTOR Descriptor[1];
+} EFI_SMRAM_HOB_DESCRIPTOR_BLOCK;
+
+extern EFI_GUID gEfiSmmPeiSmramMemoryReserve;
+
+#endif
diff --git a/EDK/Foundation/Framework/Guid/StatusCodeDataTypeId/StatusCodeDataTypeId.c b/EDK/Foundation/Framework/Guid/StatusCodeDataTypeId/StatusCodeDataTypeId.c
new file mode 100644
index 0000000..a5f102a
--- /dev/null
+++ b/EDK/Foundation/Framework/Guid/StatusCodeDataTypeId/StatusCodeDataTypeId.c
@@ -0,0 +1,47 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ StatusCodeDataTypeId.c
+
+Abstract:
+
+ GUID used to identify id for the caller who is initiating the Status Code.
+
+--*/
+
+#include "Tiano.h"
+#include EFI_GUID_DEFINITION (StatusCodeDataTypeId)
+
+//
+// Taken out from StatusCode.C created by PRC
+//
+EFI_GUID gEfiStatusCodeDataTypeStringGuid = EFI_STATUS_CODE_DATA_TYPE_STRING_GUID;
+EFI_GUID gEfiStatusCodeDataTypeDebugGuid = EFI_STATUS_CODE_DATA_TYPE_DEBUG_GUID;
+EFI_GUID gEfiStatusCodeDataTypeAssertGuid = EFI_STATUS_CODE_DATA_TYPE_ASSERT_GUID;
+EFI_GUID gEfiStatusCodeDataTypeExceptionHandlerGuid = EFI_STATUS_CODE_DATA_TYPE_EXCEPTION_HANDLER_GUID;
+EFI_GUID gEfiStatusCodeDataTypeErrorGuid = EFI_STATUS_CODE_DATA_TYPE_ERROR_GUID;
+EFI_GUID gEfiStatusCodeDataTypeProgressCodeGuid = EFI_STATUS_CODE_DATA_TYPE_PROGRESS_CODE_GUID;
+
+EFI_GUID gEfiStatusCodeSpecificDataGuid = EFI_STATUS_CODE_SPECIFIC_DATA_GUID;
+
+EFI_GUID_STRING(&gEfiStatusCodeDataTypeStringGuid, "Status Code", "Data Hub record Data type String");
+EFI_GUID_STRING(&gEfiStatusCodeSpecificDataGuid, "Status Code", "Data Hub record Data type specific ");
+EFI_GUID_STRING(&gEfiStatusCodeDataTypeDebugGuid, "Status Code", "Data Hub record data type Debug");
+EFI_GUID_STRING(&gEfiStatusCodeDataTypeAssertGuid, "Status Code", "Data Hub record data type Assert");
+EFI_GUID_STRING(&gEfiStatusCodeDataTypeErrorGuid, "Status Code", "Data Hub record data type Error");
+EFI_GUID_STRING(&gEfiStatusCodeDataTypeProgressCodeGuid, "Status Code", "Data Hub record data type Progress Code");
+EFI_GUID_STRING
+ (&gEfiStatusCodeDataTypeExceptionHandlerGuid, "Status Code", "Data Hub record Data type Exception handler");
+
+EFI_GUID_STRING
+ (&gEfiStatusCodeSpecificDataGuid, "Status Code Specific Data", "Specific Data for Tiano ReportStatusCode API");
diff --git a/EDK/Foundation/Framework/Guid/StatusCodeDataTypeId/StatusCodeDataTypeId.h b/EDK/Foundation/Framework/Guid/StatusCodeDataTypeId/StatusCodeDataTypeId.h
new file mode 100644
index 0000000..f0afce7
--- /dev/null
+++ b/EDK/Foundation/Framework/Guid/StatusCodeDataTypeId/StatusCodeDataTypeId.h
@@ -0,0 +1,389 @@
+/*++
+
+Copyright (c) 2004 - 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ StatusCodeDataTypeId.h
+
+Abstract:
+
+ GUID used to identify id for the caller who is initiating the Status Code.
+
+--*/
+
+#ifndef _STATUS_CODE_DATA_TYPE_ID_H__
+#define _STATUS_CODE_DATA_TYPE_ID_H__
+
+
+#include "EfiStatusCode.h"
+#include EFI_PROTOCOL_DEFINITION (DebugSupport)
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
+#include EFI_PROTOCOL_DEFINITION (HiiDatabase)
+#else
+#include EFI_PROTOCOL_DEFINITION (Hii)
+#endif
+//
+// The size of string
+//
+#define EFI_STATUS_CODE_DATA_MAX_STRING_SIZE 150
+
+//
+// This is the max data size including all the headers which can be passed
+// as Status Code data. This data should be multiple of 8 byte
+// to avoid any kind of boundary issue. Also, sum of this data size (inclusive
+// of size of EFI_STATUS_CODE_DATA should not exceed the max record size of
+// data hub
+//
+#define EFI_STATUS_CODE_DATA_MAX_SIZE 400
+
+//
+// String Data Type defintion. This is part of Status Code Specification
+//
+#define EFI_STATUS_CODE_DATA_TYPE_STRING_GUID \
+ { \
+ 0x92D11080, 0x496F, 0x4D95, 0xBE, 0x7E, 0x03, 0x74, 0x88, 0x38, 0x2B, 0x0A \
+ }
+
+extern EFI_GUID gEfiStatusCodeDataTypeStringGuid;
+
+//
+// This GUID indicates that the format of the accompanying data depends
+// upon the Status Code Value, but follows this Specification
+//
+#define EFI_STATUS_CODE_SPECIFIC_DATA_GUID \
+ { \
+ 0x335984bd, 0xe805, 0x409a, 0xb8, 0xf8, 0xd2, 0x7e, 0xce, 0x5f, 0xf7, 0xa6 \
+ }
+
+extern EFI_GUID gEfiStatusCodeSpecificDataGuid;
+
+#pragma pack(1)
+
+typedef enum {
+ EfiStringAscii,
+ EfiStringUnicode,
+ EfiStringToken
+} EFI_STRING_TYPE;
+
+//
+// HII string token
+//
+typedef struct {
+EFI_HII_HANDLE Handle;
+STRING_REF Token;
+} EFI_STATUS_CODE_STRING_TOKEN;
+
+typedef union {
+CHAR8 *Ascii;
+CHAR16 *Unicode;
+EFI_STATUS_CODE_STRING_TOKEN Hii;
+} EFI_STATUS_CODE_STRING;
+
+typedef struct {
+ EFI_STATUS_CODE_DATA DataHeader;
+ EFI_STRING_TYPE StringType;
+ EFI_STATUS_CODE_STRING String;
+} EFI_STATUS_CODE_STRING_DATA;
+
+#pragma pack()
+//
+// Debug Assert Data. This is part of Status Code Specification
+//
+#define EFI_STATUS_CODE_DATA_TYPE_ASSERT_GUID \
+ { \
+ 0xDA571595, 0x4D99, 0x487C, 0x82, 0x7C, 0x26, 0x22, 0x67, 0x7D, 0x33, 0x07 \
+ }
+
+extern EFI_GUID gEfiStatusCodeDataTypeAssertGuid;
+
+//
+// Exception Data type (CPU REGS)
+//
+#define EFI_STATUS_CODE_DATA_TYPE_EXCEPTION_HANDLER_GUID \
+ { \
+ 0x3BC2BD12, 0xAD2E, 0x11D5, 0x87, 0xDD, 0x00, 0x06, 0x29, 0x45, 0xC3, 0xB9 \
+ }
+
+extern EFI_GUID gEfiStatusCodeDataTypeExceptionHandlerGuid;
+
+//
+// Debug DataType defintions. User Defined Data Types.
+//
+#define EFI_STATUS_CODE_DATA_TYPE_DEBUG_GUID \
+ { \
+ 0x9A4E9246, 0xD553, 0x11D5, 0x87, 0xE2, 0x00, 0x06, 0x29, 0x45, 0xC3, 0xb9 \
+ }
+
+#pragma pack(1)
+
+typedef struct {
+ UINT32 ErrorLevel;
+ //
+ // 12 * sizeof (UINT64) Var Arg stack
+ //
+ // ascii DEBUG () Format string
+ //
+} EFI_DEBUG_INFO;
+
+#pragma pack()
+
+extern EFI_GUID gEfiStatusCodeDataTypeDebugGuid;
+
+//
+// Progress Code. User Defined Data Type Guid.
+//
+#define EFI_STATUS_CODE_DATA_TYPE_ERROR_GUID \
+ { \
+ 0xAB359CE3, 0x99B3, 0xAE18, 0xC8, 0x9D, 0x95, 0xD3, 0xB0, 0x72, 0xE1, 0x9B \
+ }
+
+extern EFI_GUID gEfiStatusCodeDataTypeErrorGuid;
+
+//
+// declaration for EFI_EXP_DATA. This may change
+//
+typedef UINTN EFI_EXP_DATA;
+
+//
+// Voltage Extended Error Data
+//
+typedef struct {
+ EFI_STATUS_CODE_DATA DataHeader;
+ EFI_EXP_DATA Voltage;
+ EFI_EXP_DATA Threshold;
+} EFI_COMPUTING_UNIT_VOLTAGE_ERROR_DATA;
+
+//
+// Microcode Update Extended Error Data
+//
+typedef struct {
+ EFI_STATUS_CODE_DATA DataHeader;
+ UINT32 Version;
+} EFI_COMPUTING_UNIT_MICROCODE_UPDATE_ERROR_DATA;
+
+//
+// Asynchronous Timer Extended Error Data
+//
+typedef struct {
+ EFI_STATUS_CODE_DATA DataHeader;
+ EFI_EXP_DATA TimerLimit;
+} EFI_COMPUTING_UNIT_TIMER_EXPIRED_ERROR_DATA;
+
+//
+// Host Processor Mismatch Extended Error Data
+//
+typedef struct {
+ EFI_STATUS_CODE_DATA DataHeader;
+ UINT32 Instance;
+ UINT16 Attributes;
+} EFI_HOST_PROCESSOR_MISMATCH_ERROR_DATA;
+
+//
+// EFI_COMPUTING_UNIT_MISMATCH_ATTRIBUTES
+// All other attributes are reserved for future use and
+// must be initialized to 0.
+//
+#define EFI_COMPUTING_UNIT_MISMATCH_SPEED 0x0001
+#define EFI_COMPUTING_UNIT_MISMATCH_FSB_SPEED 0x0002
+#define EFI_COMPUTING_UNIT_MISMATCH_FAMILY 0x0004
+#define EFI_COMPUTING_UNIT_MISMATCH_MODEL 0x0008
+#define EFI_COMPUTING_UNIT_MISMATCH_STEPPING 0x0010
+#define EFI_COMPUTING_UNIT_MISMATCH_CACHE_SIZE 0x0020
+#define EFI_COMPUTING_UNIT_MISMATCH_OEM1 0x1000
+#define EFI_COMPUTING_UNIT_MISMATCH_OEM2 0x2000
+#define EFI_COMPUTING_UNIT_MISMATCH_OEM3 0x4000
+#define EFI_COMPUTING_UNIT_MISMATCH_OEM4 0x8000
+
+//
+// Thermal Extended Error Data
+//
+typedef struct {
+ EFI_STATUS_CODE_DATA DataHeader;
+ EFI_EXP_DATA Temperature;
+ EFI_EXP_DATA Threshold;
+} EFI_COMPUTING_UNIT_THERMAL_ERROR_DATA;
+
+//
+// Processor Disabled Extended Error Data
+//
+typedef struct {
+ EFI_STATUS_CODE_DATA DataHeader;
+ UINT32 Cause;
+ BOOLEAN SoftwareDisabled;
+} EFI_COMPUTING_UNIT_CPU_DISABLED_ERROR_DATA;
+
+typedef enum {
+ EfiInitCacheDataOnly,
+ EfiInitCacheInstrOnly,
+ EfiInitCacheBoth,
+ EfiInitCacheUnspecified
+} EFI_INIT_CACHE_TYPE;
+
+//
+// Embedded cache init extended data
+//
+typedef struct {
+ EFI_STATUS_CODE_DATA DataHeader;
+ UINT32 Level;
+ EFI_INIT_CACHE_TYPE Type;
+} EFI_CACHE_INIT_DATA;
+
+//
+// Memory Extended Error Data
+//
+//
+// Memory Error Granularity Definition
+//
+typedef UINT8 EFI_MEMORY_ERROR_GRANULARITY;
+
+//
+// Memory Error Operation Definition
+//
+typedef UINT8 EFI_MEMORY_ERROR_OPERATION;
+
+typedef struct {
+ EFI_STATUS_CODE_DATA DataHeader;
+ EFI_MEMORY_ERROR_GRANULARITY Granularity;
+ EFI_MEMORY_ERROR_OPERATION Operation;
+ UINTN Syndrome;
+ EFI_PHYSICAL_ADDRESS Address;
+ UINTN Resolution;
+} EFI_MEMORY_EXTENDED_ERROR_DATA;
+
+//
+// Memory Error Granularities
+//
+#define EFI_MEMORY_ERROR_OTHER 0x01
+#define EFI_MEMORY_ERROR_UNKNOWN 0x02
+#define EFI_MEMORY_ERROR_DEVICE 0x03
+#define EFI_MEMORY_ERROR_PARTITION 0x04
+
+//
+// Memory Error Operations
+//
+#define EFI_MEMORY_OPERATION_OTHER 0x01
+#define EFI_MEMORY_OPERATION_UNKNOWN 0x02
+#define EFI_MEMORY_OPERATION_READ 0x03
+#define EFI_MEMORY_OPERATION_WRITE 0x04
+#define EFI_MEMORY_OPERATION_PARTIAL_WRITE 0x05
+
+//
+// Define shorthands to describe Group Operations
+// Many memory init operations are essentially group
+// operations.
+// A shorthand to describe that the operation is performed
+// on multiple devices within the array
+//
+#define EFI_MULTIPLE_MEMORY_DEVICE_OPERATION 0xfffe
+//
+// A shorthand to describe that the operation is performed // on all devices within the array
+//
+#define EFI_ALL_MEMORY_DEVICE_OPERATION 0xffff
+//
+// A shorthand to describe that the operation is performed // on multiple arrays
+//
+#define EFI_MULTIPLE_MEMORY_ARRAY_OPERATION 0xfffe
+//
+// A shorthand to describe that the operation is performed // on all the arrays
+//
+#define EFI_ALL_MEMORY_ARRAY_OPERATION 0xffff
+
+//
+// DIMM number
+//
+#pragma pack(1)
+typedef struct {
+ EFI_STATUS_CODE_DATA DataHeader;
+ UINT16 Array;
+ UINT16 Device;
+} EFI_STATUS_CODE_DIMM_NUMBER;
+#pragma pack()
+//
+// Memory Module Mismatch Extended Error Data
+//
+typedef struct {
+ EFI_STATUS_CODE_DATA DataHeader;
+ EFI_STATUS_CODE_DIMM_NUMBER Instance;
+} EFI_MEMORY_MODULE_MISMATCH_ERROR_DATA;
+
+//
+// Memory Range Extended Data
+//
+typedef struct {
+ EFI_STATUS_CODE_DATA DataHeader;
+ EFI_PHYSICAL_ADDRESS Start;
+ EFI_PHYSICAL_ADDRESS Length;
+} EFI_MEMORY_RANGE_EXTENDED_DATA;
+
+//
+// Device handle Extended Data. Used for many
+// errors and progress codes to point to the device.
+//
+typedef struct {
+ EFI_STATUS_CODE_DATA DataHeader;
+ EFI_HANDLE Handle;
+} EFI_DEVICE_HANDLE_EXTENDED_DATA;
+
+//
+// Resource Allocation Failure Extended Error Data
+//
+typedef struct {
+ EFI_STATUS_CODE_DATA DataHeader;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ UINT32 Bar;
+ VOID *ReqRes;
+ VOID *AllocRes;
+} EFI_RESOURCE_ALLOC_FAILURE_ERROR_DATA;
+
+//
+// Extended Error Data for Assert
+//
+typedef struct {
+ EFI_STATUS_CODE_DATA DataHeader;
+ UINT32 LineNumber;
+ UINT32 FileNameSize;
+ EFI_STATUS_CODE_STRING_DATA *FileName;
+} EFI_DEBUG_ASSERT_DATA;
+
+//
+// System Context Data EBC/IA32/IPF
+//
+typedef union {
+ EFI_SYSTEM_CONTEXT_EBC SystemContextEbc;
+ EFI_SYSTEM_CONTEXT_IA32 SystemContextIa32;
+ EFI_SYSTEM_CONTEXT_IPF SystemContextIpf;
+} EFI_STATUS_CODE_EXCEP_SYSTEM_CONTEXT;
+
+typedef struct {
+ EFI_STATUS_CODE_DATA DataHeader;
+ EFI_STATUS_CODE_EXCEP_SYSTEM_CONTEXT Context;
+} EFI_STATUS_CODE_EXCEP_EXTENDED_DATA;
+
+//
+// Legacy Oprom extended data
+//
+typedef struct {
+ EFI_STATUS_CODE_DATA DataHeader;
+ EFI_HANDLE DeviceHandle;
+ EFI_PHYSICAL_ADDRESS RomImageBase;
+} EFI_LEGACY_OPROM_EXTENDED_DATA;
+
+//
+// Progress Code. User Defined Data Type Guid.
+//
+#define EFI_STATUS_CODE_DATA_TYPE_PROGRESS_CODE_GUID \
+ { \
+ 0xA356AB39, 0x35C4, 0x35DA, 0xB3, 0x7A, 0xF8, 0xEA, 0x9E, 0x8B, 0x36, 0xA3 \
+ }
+
+extern EFI_GUID gEfiStatusCodeDataTypeProgressCodeGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Include/BootMode.h b/EDK/Foundation/Framework/Include/BootMode.h
new file mode 100644
index 0000000..8261641
--- /dev/null
+++ b/EDK/Foundation/Framework/Include/BootMode.h
@@ -0,0 +1,38 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ BootMode.h
+
+Abstract:
+
+ This includes for the Boot mode information.
+
+--*/
+
+#ifndef _EFI_BOOT_MODE_H
+#define _EFI_BOOT_MODE_H
+
+#define BOOT_WITH_FULL_CONFIGURATION 0x00
+#define BOOT_WITH_MINIMAL_CONFIGURATION 0x01
+#define BOOT_ASSUMING_NO_CONFIGURATION_CHANGES 0x02
+#define BOOT_WITH_FULL_CONFIGURATION_PLUS_DIAGNOSTICS 0x03
+#define BOOT_WITH_DEFAULT_SETTINGS 0x04
+#define BOOT_ON_S4_RESUME 0x05
+#define BOOT_ON_S5_RESUME 0x06
+#define BOOT_ON_S2_RESUME 0x10
+#define BOOT_ON_S3_RESUME 0x11
+#define BOOT_ON_FLASH_UPDATE 0x12
+#define BOOT_IN_RECOVERY_MODE 0x20
+#define BOOT_IN_RECOVERY_MODE_MASK 0x40
+#define BOOT_SPECIAL_MASK 0x80
+#endif
diff --git a/EDK/Foundation/Framework/Include/EfiBootScript.h b/EDK/Foundation/Framework/Include/EfiBootScript.h
new file mode 100644
index 0000000..891bc96
--- /dev/null
+++ b/EDK/Foundation/Framework/Include/EfiBootScript.h
@@ -0,0 +1,234 @@
+/*++
+
+Copyright (c) 2004 - 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiBootScript.h
+
+Abstract:
+
+
+
+--*/
+
+#ifndef _EFI_SCRIPT_H_
+#define _EFI_SCRIPT_H_
+
+#include "EfiSmbus.h"
+
+#define EFI_ACPI_S3_RESUME_SCRIPT_TABLE 0x00
+
+//
+// Boot Script Opcode Definitions
+//
+typedef const UINT16 EFI_BOOT_SCRIPT_OPCODE;
+
+#define EFI_BOOT_SCRIPT_IO_WRITE_OPCODE 0x00
+#define EFI_BOOT_SCRIPT_IO_READ_WRITE_OPCODE 0x01
+#define EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE 0x02
+#define EFI_BOOT_SCRIPT_MEM_READ_WRITE_OPCODE 0x03
+#define EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE_OPCODE 0x04
+#define EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE_OPCODE 0x05
+#define EFI_BOOT_SCRIPT_SMBUS_EXECUTE_OPCODE 0x06
+#define EFI_BOOT_SCRIPT_STALL_OPCODE 0x07
+#define EFI_BOOT_SCRIPT_DISPATCH_OPCODE 0x08
+
+//
+// Extensions to boot script definitions
+//
+
+// AMI_OVERRIDE >>> Support PI1.2
+#if defined(PI_SPECIFICATION_VERSION) && (PI_SPECIFICATION_VERSION>=0x0001000A)
+#define EFI_BOOT_SCRIPT_MEM_POLL_OPCODE 0x0E
+#else
+#define EFI_BOOT_SCRIPT_MEM_POLL_OPCODE 0x81 // AMI MEM_POLL_OPCODE_OEM
+#endif
+// AMI_OVERRIDE <<<
+
+#define EFI_BOOT_SCRIPT_INFORMATION_OPCODE 0x0A
+#define EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE_OPCODE 0x0B
+#define EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE_OPCODE 0x0C
+
+#define EFI_BOOT_SCRIPT_TABLE_OPCODE 0xAA
+#define EFI_BOOT_SCRIPT_TERMINATE_OPCODE 0xFF
+
+#pragma pack(1)
+
+//
+// EFI Boot Script Width
+//
+typedef enum {
+ EfiBootScriptWidthUint8,
+ EfiBootScriptWidthUint16,
+ EfiBootScriptWidthUint32,
+ EfiBootScriptWidthUint64,
+ EfiBootScriptWidthFifoUint8,
+ EfiBootScriptWidthFifoUint16,
+ EfiBootScriptWidthFifoUint32,
+ EfiBootScriptWidthFifoUint64,
+ EfiBootScriptWidthFillUint8,
+ EfiBootScriptWidthFillUint16,
+ EfiBootScriptWidthFillUint32,
+ EfiBootScriptWidthFillUint64,
+ EfiBootScriptWidthMaximum
+} EFI_BOOT_SCRIPT_WIDTH;
+
+typedef struct {
+ UINT16 OpCode;
+ UINT8 Length;
+} EFI_BOOT_SCRIPT_GENERIC_HEADER;
+
+typedef struct {
+ UINT16 OpCode;
+ UINT8 Length;
+ UINT16 Version;
+ UINT32 TableLength;
+ UINT16 Reserved[2];
+} EFI_BOOT_SCRIPT_TABLE_HEADER;
+
+typedef struct {
+ UINT16 OpCode;
+ UINT8 Length;
+ UINT32 Width;
+} EFI_BOOT_SCRIPT_COMMON_HEADER;
+
+typedef struct {
+ UINT16 OpCode;
+ UINT8 Length;
+ UINT32 Width;
+ UINT32 Count;
+ UINT64 Address;
+} EFI_BOOT_SCRIPT_IO_WRITE;
+
+typedef struct {
+ UINT16 OpCode;
+ UINT8 Length;
+ UINT32 Width;
+ UINT64 Address;
+} EFI_BOOT_SCRIPT_IO_READ_WRITE;
+
+typedef struct {
+ UINT16 OpCode;
+ UINT8 Length;
+ UINT32 Width;
+ UINT32 Count;
+ UINT64 Address;
+} EFI_BOOT_SCRIPT_MEM_WRITE;
+
+typedef struct {
+ UINT16 OpCode;
+ UINT8 Length;
+ UINT32 Width;
+ UINT64 Address;
+} EFI_BOOT_SCRIPT_MEM_READ_WRITE;
+
+typedef struct {
+ UINT16 OpCode;
+ UINT8 Length;
+ UINT32 Width;
+ UINT32 Count;
+ UINT64 Address;
+} EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE;
+
+typedef struct {
+ UINT16 OpCode;
+ UINT8 Length;
+ UINT32 Width;
+ UINT32 Count;
+ UINT64 Address;
+ UINT16 Segment;
+} EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE;
+
+typedef struct {
+ UINT16 OpCode;
+ UINT8 Length;
+ UINT32 Width;
+ UINT64 Address;
+} EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE;
+
+typedef struct {
+ UINT16 OpCode;
+ UINT8 Length;
+ UINT32 Width;
+ UINT64 Address;
+ UINT16 Segment;
+} EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE;
+
+
+typedef struct {
+ UINT16 OpCode;
+ UINT8 Length;
+ UINT64 SlaveAddress;
+ UINT64 Command;
+ UINT32 Operation;
+ BOOLEAN PecCheck;
+ UINT32 DataSize;
+} EFI_BOOT_SCRIPT_SMBUS_EXECUTE;
+
+typedef struct {
+ UINT16 OpCode;
+ UINT8 Length;
+ UINT64 Duration;
+} EFI_BOOT_SCRIPT_STALL;
+
+typedef struct {
+ UINT16 OpCode;
+ UINT8 Length;
+ EFI_PHYSICAL_ADDRESS EntryPoint;
+} EFI_BOOT_SCRIPT_DISPATCH;
+
+typedef struct {
+ UINT16 OpCode;
+ UINT8 Length;
+ UINT32 Width;
+ UINT64 Address;
+ UINT64 BitMask;
+ UINT64 BitValue;
+ UINT64 Duration;
+ UINT64 LoopTimes;
+} EFI_BOOT_SCRIPT_MEM_POLL;
+
+typedef struct {
+ UINT16 OpCode;
+ UINT8 Length;
+ UINT32 InformationLength;
+ EFI_PHYSICAL_ADDRESS Information;
+} EFI_BOOT_SCRIPT_INFORMATION;
+
+typedef struct {
+ UINT16 OpCode;
+ UINT8 Length;
+} EFI_BOOT_SCRIPT_TERMINATE;
+
+typedef union {
+ EFI_BOOT_SCRIPT_GENERIC_HEADER *Header;
+ EFI_BOOT_SCRIPT_TABLE_HEADER *TableInfo;
+ EFI_BOOT_SCRIPT_IO_WRITE *IoWrite;
+ EFI_BOOT_SCRIPT_IO_READ_WRITE *IoReadWrite;
+ EFI_BOOT_SCRIPT_MEM_WRITE *MemWrite;
+ EFI_BOOT_SCRIPT_MEM_READ_WRITE *MemReadWrite;
+ EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE *PciWrite;
+ EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE *PciReadWrite;
+ EFI_BOOT_SCRIPT_PCI_CONFIG2_WRITE *PciWrite2;
+ EFI_BOOT_SCRIPT_PCI_CONFIG2_READ_WRITE *PciReadWrite2;
+ EFI_BOOT_SCRIPT_SMBUS_EXECUTE *SmbusExecute;
+ EFI_BOOT_SCRIPT_STALL *Stall;
+ EFI_BOOT_SCRIPT_DISPATCH *Dispatch;
+ EFI_BOOT_SCRIPT_MEM_POLL *MemPoll;
+ EFI_BOOT_SCRIPT_INFORMATION *Information;
+ EFI_BOOT_SCRIPT_TERMINATE *Terminate;
+ EFI_BOOT_SCRIPT_COMMON_HEADER *CommonHeader;
+ UINT8 *Raw;
+} BOOT_SCRIPT_POINTERS;
+
+#pragma pack()
+
+#endif
diff --git a/EDK/Foundation/Framework/Include/EfiCapsule.h b/EDK/Foundation/Framework/Include/EfiCapsule.h
new file mode 100644
index 0000000..6cbadec
--- /dev/null
+++ b/EDK/Foundation/Framework/Include/EfiCapsule.h
@@ -0,0 +1,142 @@
+/*++
+
+Copyright (c) 2004 - 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiCapsule.h
+
+Abstract:
+
+ Defines for the EFI Capsule functionality
+
+--*/
+
+#ifndef _EFI_CAPSULE_H_
+#define _EFI_CAPSULE_H_
+
+
+#define CAPSULE_BLOCK_DESCRIPTOR_SIGNATURE EFI_SIGNATURE_32 ('C', 'B', 'D', 'S')
+
+typedef struct {
+ EFI_GUID OemGuid;
+ UINT32 HeaderSize;
+ //
+ // UINT8 OemHdrData[];
+ //
+} EFI_CAPSULE_OEM_HEADER;
+
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+
+#define MAX_SUPPORT_CAPSULE_NUM 50
+#define CAPSULE_FLAGS_PERSIST_ACROSS_RESET 0x00010000
+#define CAPSULE_FLAGS_POPULATE_SYSTEM_TABLE 0x00020000
+
+typedef struct {
+ UINT64 Length;
+ union {
+ EFI_PHYSICAL_ADDRESS DataBlock;
+ EFI_PHYSICAL_ADDRESS ContinuationPointer;
+ } Union;
+} EFI_CAPSULE_BLOCK_DESCRIPTOR;
+
+typedef struct {
+ EFI_GUID CapsuleGuid;
+ UINT32 HeaderSize;
+ UINT32 Flags;
+ UINT32 CapsuleImageSize;
+} EFI_CAPSULE_HEADER;
+
+typedef struct {
+ UINT32 CapsuleArrayNumber;
+ VOID* CapsulePtr[1];
+} EFI_CAPSULE_TABLE;
+
+//
+// This struct is deprecated because VendorTable entries physical address will not be fixed up when
+// transitioning from preboot to runtime phase. So we don't need CapsuleInfoTable to record capsule
+// GUIDs any more for runtime convert.
+//
+typedef struct {
+ UINT32 CapsuleGuidNumber;
+ EFI_GUID CapsuleGuidPtr[1];
+} EFI_CAPSULE_INFO_TABLE;
+
+//
+// This GUID is used for collecting all capsules' Guids who install in ConfigTable.
+// This GUID is deprecated as well.
+//
+#define EFI_CAPSULE_INFO_GUID \
+ { \
+ 0x8B34EAC7, 0x2690, 0x460B, 0x8B, 0xA5, 0xD5, 0xCF, 0x32, 0x83, 0x17, 0x35 \
+ }
+
+#else
+
+typedef struct {
+ EFI_GUID CapsuleGuid;
+ UINT32 HeaderSize;
+ UINT32 Flags;
+ UINT32 CapsuleImageSize;
+ UINT32 SequenceNumber;
+ EFI_GUID InstanceId;
+ UINT32 OffsetToSplitInformation;
+ UINT32 OffsetToCapsuleBody;
+ UINT32 OffsetToOemDefinedHeader;
+ UINT32 OffsetToAuthorInformation;
+ UINT32 OffsetToRevisionInformation;
+ UINT32 OffsetToShortDescription;
+ UINT32 OffsetToLongDescription;
+ UINT32 OffsetToApplicableDevices;
+} EFI_CAPSULE_HEADER;
+
+//
+// An array of these describe the blocks that make up a capsule for
+// a capsule update.
+//
+typedef struct {
+ UINT64 Length; // length of the data block
+ EFI_PHYSICAL_ADDRESS Data; // physical address of the data block
+ UINT32 Signature; // CBDS
+ UINT32 CheckSum; // to sum this structure to 0
+} EFI_CAPSULE_BLOCK_DESCRIPTOR;
+
+#endif
+
+//
+// Bits in the flags field of the capsule header
+//
+#define EFI_CAPSULE_HEADER_FLAG_SETUP 0x00000001 // supports setup changes
+//
+// This is the GUID of the capsule header of the image on disk.
+//
+#define EFI_CAPSULE_GUID \
+ { \
+ 0x3B6686BD, 0x0D76, 0x4030, 0xB7, 0x0E, 0xB5, 0x51, 0x9E, 0x2F, 0xC5, 0xA0 \
+ }
+
+//
+// This is the GUID of the file created by the capsule application that contains
+// the path to the device(s) to update.
+//
+#define EFI_PATH_FILE_NAME_GUID \
+ { \
+ 0x7644C181, 0xFA6E, 0x46DA, 0x80, 0xCB, 0x04, 0xB9, 0x90, 0x40, 0x62, 0xE8 \
+ }
+//
+// This is the GUID of the configuration results file created by the capsule
+// application.
+//
+#define EFI_CONFIG_FILE_NAME_GUID \
+ { \
+ 0x98B8D59B, 0xE8BA, 0x48EE, 0x98, 0xDD, 0xC2, 0x95, 0x39, 0x2F, 0x1E, 0xDB \
+ }
+
+#endif // #ifndef _EFI_CAPSULE_H_
diff --git a/EDK/Foundation/Framework/Include/EfiDependency.h b/EDK/Foundation/Framework/Include/EfiDependency.h
new file mode 100644
index 0000000..14e5405
--- /dev/null
+++ b/EDK/Foundation/Framework/Include/EfiDependency.h
@@ -0,0 +1,52 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiDependency.h
+
+Abstract:
+
+ This module contains data specific to dependency expressions
+ and local function prototypes.
+
+--*/
+
+#ifndef _DEPENDENCY_H_
+#define _DEPENDENCY_H_
+
+//
+//
+// EFI_DEP_BEFORE - If present, it must be the first and only opcode
+// EFI_DEP_AFTER - If present, it must be the first and only opcode
+// EFI_DEP_SOR - If present, it must be the first opcode
+// EFI_DEP_REPLACE_TRUE - Used to dynamically patch the dependecy expression
+// to save time. A EFI_DEP_PUSH is evauated one an
+// replaced with EFI_DEP_REPLACE_TRUE
+//
+#define EFI_DEP_BEFORE 0x00
+#define EFI_DEP_AFTER 0x01
+#define EFI_DEP_PUSH 0x02
+#define EFI_DEP_AND 0x03
+#define EFI_DEP_OR 0x04
+#define EFI_DEP_NOT 0x05
+#define EFI_DEP_TRUE 0x06
+#define EFI_DEP_FALSE 0x07
+#define EFI_DEP_END 0x08
+#define EFI_DEP_SOR 0x09
+#define EFI_DEP_REPLACE_TRUE 0xff
+
+//
+// Define the initial size of the dependency expression evaluation stack
+//
+#define DEPEX_STACK_SIZE_INCREMENT 0x1000
+
+#endif
diff --git a/EDK/Foundation/Framework/Include/EfiFirmwareFileSystem.h b/EDK/Foundation/Framework/Include/EfiFirmwareFileSystem.h
new file mode 100644
index 0000000..0cd16f8
--- /dev/null
+++ b/EDK/Foundation/Framework/Include/EfiFirmwareFileSystem.h
@@ -0,0 +1,131 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiFirmwareFileSystem.h
+
+Abstract:
+
+ This file defines the data structures that comprise the FFS file system.
+
+--*/
+
+#ifndef _EFI_FFS_FILE_SYSTEM_H_
+#define _EFI_FFS_FILE_SYSTEM_H_
+
+#include "EfiImageFormat.h"
+
+//
+// GUIDs defined by the FFS specification.
+//
+#define EFI_FIRMWARE_FILE_SYSTEM_GUID \
+ { \
+ 0x7A9354D9, 0x0468, 0x444a, 0x81, 0xCE, 0x0B, 0xF6, 0x17, 0xD8, 0x90, 0xDF \
+ }
+
+#define EFI_FFS_VOLUME_TOP_FILE_GUID \
+ { \
+ 0x1BA0062E, 0xC779, 0x4582, 0x85, 0x66, 0x33, 0x6A, 0xE8, 0xF7, 0x8F, 0x9 \
+ }
+
+//
+// FFS specific file types
+//
+#define EFI_FV_FILETYPE_FFS_PAD 0xF0
+
+//
+// FFS File Attributes
+//
+#define FFS_ATTRIB_TAIL_PRESENT 0x01
+#define FFS_ATTRIB_RECOVERY 0x02
+#define FFS_ATTRIB_DATA_ALIGNMENT 0x38
+#define FFS_ATTRIB_CHECKSUM 0x40
+//;;## ...AMI_OVERRIDE... Support PI1.x
+#if (PI_SPECIFICATION_VERSION < 0x00010000)
+#define FFS_ATTRIB_HEADER_EXTENSION 0x04
+#else
+//
+// PI 1.0 definition.
+//
+#define FFS_ATTRIB_FIXED 0x04
+#endif
+
+
+//
+// FFS_FIXED_CHECKSUM is the default checksum value used when the
+// FFS_ATTRIB_CHECKSUM attribute bit is clear
+//;;## ...AMI_OVERRIDE... Support PI1.x
+#if (PI_SPECIFICATION_VERSION < 0x00010000)
+#define FFS_FIXED_CHECKSUM 0x5A
+#else
+#define FFS_FIXED_CHECKSUM 0xAA
+#endif
+
+//
+// File state definitions
+//
+#define EFI_FILE_HEADER_CONSTRUCTION 0x01
+#define EFI_FILE_HEADER_VALID 0x02
+#define EFI_FILE_DATA_VALID 0x04
+#define EFI_FILE_MARKED_FOR_UPDATE 0x08
+#define EFI_FILE_DELETED 0x10
+#define EFI_FILE_HEADER_INVALID 0x20
+
+#define EFI_FILE_ALL_STATE_BITS (EFI_FILE_HEADER_CONSTRUCTION | \
+ EFI_FILE_HEADER_VALID | \
+ EFI_FILE_DATA_VALID | \
+ EFI_FILE_MARKED_FOR_UPDATE | \
+ EFI_FILE_DELETED | \
+ EFI_FILE_HEADER_INVALID \
+ )
+
+#define EFI_TEST_FFS_ATTRIBUTES_BIT(FvbAttributes, TestAttributes, Bit) \
+ ( \
+ (BOOLEAN) ( \
+ (FvbAttributes & EFI_FVB_ERASE_POLARITY) ? (((~TestAttributes) & Bit) == Bit) : ((TestAttributes & Bit) == Bit) \
+ ) \
+ )
+
+//
+// FFS file integrity check structure
+//
+typedef UINT16 EFI_FFS_FILE_TAIL;
+
+typedef union {
+ struct {
+ UINT8 Header;
+ UINT8 File;
+ } Checksum;
+//;;## ...AMI_OVERRIDE... Support PI1.x
+#if (PI_SPECIFICATION_VERSION < 0x00010000)
+ UINT16 TailReference;
+#else
+ UINT16 Checksum16;
+#endif
+} EFI_FFS_INTEGRITY_CHECK;
+
+//
+// FFS file header definition
+//
+typedef UINT8 EFI_FFS_FILE_ATTRIBUTES;
+typedef UINT8 EFI_FFS_FILE_STATE;
+
+typedef struct {
+ EFI_GUID Name;
+ EFI_FFS_INTEGRITY_CHECK IntegrityCheck;
+ EFI_FV_FILETYPE Type;
+ EFI_FFS_FILE_ATTRIBUTES Attributes;
+ UINT8 Size[3];
+ EFI_FFS_FILE_STATE State;
+} EFI_FFS_FILE_HEADER;
+
+#endif
diff --git a/EDK/Foundation/Framework/Include/EfiFirmwareVolume.h b/EDK/Foundation/Framework/Include/EfiFirmwareVolume.h
new file mode 100644
index 0000000..a5efb2b
--- /dev/null
+++ b/EDK/Foundation/Framework/Include/EfiFirmwareVolume.h
@@ -0,0 +1,47 @@
+/*++
+
+Copyright (c) 2007 , Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiFirmwareVolume.h
+
+Abstract:
+
+--*/
+
+#ifndef _EFI_FIRMWARE_VOLUME_H_
+#define _EFI_FIRMWARE_VOLUME_H_
+
+ //;;## ...AMI_ADD FILE... Support PI1.x
+
+#define FV_DEVICE_SIGNATURE EFI_SIGNATURE_32 ('_', 'F', 'V', '_')
+#define EFI_FV_FILE_ATTRIB_ALIGNMENT 0x0000001F
+#define EFI_FV_UNRELIABLE_WRITE 0x00000000
+#define EFI_FV_RELIABLE_WRITE 0x00000001
+
+
+//
+// EFI_FV_ATTRIBUTES bit definitions
+//
+typedef UINT64 EFI_FV_ATTRIBUTES;
+typedef UINT32 EFI_FV_FILE_ATTRIBUTES;
+typedef UINT32 EFI_FV_WRITE_POLICY;
+
+
+typedef struct {
+ EFI_GUID *NameGuid;
+ EFI_FV_FILETYPE Type;
+ EFI_FV_FILE_ATTRIBUTES FileAttributes;
+ VOID *Buffer;
+ UINT32 BufferSize;
+} EFI_FV_WRITE_FILE_DATA;
+
+#endif
diff --git a/EDK/Foundation/Framework/Include/EfiFirmwareVolumeHeader.h b/EDK/Foundation/Framework/Include/EfiFirmwareVolumeHeader.h
new file mode 100644
index 0000000..50dc8b4
--- /dev/null
+++ b/EDK/Foundation/Framework/Include/EfiFirmwareVolumeHeader.h
@@ -0,0 +1,215 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiFirmwareVolumeHeader.h
+
+Abstract:
+
+ Defines data structure that is the volume header found at the beginning of
+ all firmware volumes that are either memory mapped, or have an
+ associated FirmwareVolumeBlock protocol.
+
+--*/
+
+#ifndef _EFI_FIRMWARE_VOLUME_HEADER_H_
+#define _EFI_FIRMWARE_VOLUME_HEADER_H_
+
+//
+// Firmware Volume Block Attributes definition
+//
+typedef UINT32 EFI_FVB_ATTRIBUTES;
+
+//
+// Firmware Volume Block Attributes bit definitions
+//
+#define EFI_FVB_READ_DISABLED_CAP 0x00000001
+#define EFI_FVB_READ_ENABLED_CAP 0x00000002
+#define EFI_FVB_READ_STATUS 0x00000004
+
+#define EFI_FVB_WRITE_DISABLED_CAP 0x00000008
+#define EFI_FVB_WRITE_ENABLED_CAP 0x00000010
+#define EFI_FVB_WRITE_STATUS 0x00000020
+
+#define EFI_FVB_LOCK_CAP 0x00000040
+#define EFI_FVB_LOCK_STATUS 0x00000080
+
+#define EFI_FVB_STICKY_WRITE 0x00000200
+#define EFI_FVB_MEMORY_MAPPED 0x00000400
+#define EFI_FVB_ERASE_POLARITY 0x00000800
+
+//;;## ...AMI_OVERRIDE... Support PI1.x
+
+#if (PI_SPECIFICATION_VERSION < 0x00010000)
+
+#define EFI_FVB_ALIGNMENT_CAP 0x00008000
+#define EFI_FVB_ALIGNMENT_2 0x00010000
+#define EFI_FVB_ALIGNMENT_4 0x00020000
+#define EFI_FVB_ALIGNMENT_8 0x00040000
+#define EFI_FVB_ALIGNMENT_16 0x00080000
+#define EFI_FVB_ALIGNMENT_32 0x00100000
+#define EFI_FVB_ALIGNMENT_64 0x00200000
+#define EFI_FVB_ALIGNMENT_128 0x00400000
+#define EFI_FVB_ALIGNMENT_256 0x00800000
+#define EFI_FVB_ALIGNMENT_512 0x01000000
+#define EFI_FVB_ALIGNMENT_1K 0x02000000
+#define EFI_FVB_ALIGNMENT_2K 0x04000000
+#define EFI_FVB_ALIGNMENT_4K 0x08000000
+#define EFI_FVB_ALIGNMENT_8K 0x10000000
+#define EFI_FVB_ALIGNMENT_16K 0x20000000
+#define EFI_FVB_ALIGNMENT_32K 0x40000000
+#define EFI_FVB_ALIGNMENT_64K 0x80000000
+
+#define EFI_FVB_CAPABILITIES (EFI_FVB_READ_DISABLED_CAP | \
+ EFI_FVB_READ_ENABLED_CAP | \
+ EFI_FVB_WRITE_DISABLED_CAP | \
+ EFI_FVB_WRITE_ENABLED_CAP | \
+ EFI_FVB_LOCK_CAP \
+ )
+
+#define EFI_FVB_STATUS (EFI_FVB_READ_STATUS | EFI_FVB_WRITE_STATUS | EFI_FVB_LOCK_STATUS)
+
+
+
+#else
+
+#define EFI_FVB2_READ_LOCK_CAP 0x00001000
+#define EFI_FVB2_READ_LOCK_STATUS 0x00002000
+
+#define EFI_FVB2_WRITE_LOCK_CAP 0x00004000
+#define EFI_FVB2_WRITE_LOCK_STATUS 0x00008000
+
+#define EFI_FVB2_ALIGNMENT 0x001F0000
+#define EFI_FVB2_ALIGNMENT_1 0x00000000
+#define EFI_FVB2_ALIGNMENT_2 0x00010000
+#define EFI_FVB2_ALIGNMENT_4 0x00020000
+#define EFI_FVB2_ALIGNMENT_8 0x00030000
+#define EFI_FVB2_ALIGNMENT_16 0x00040000
+#define EFI_FVB2_ALIGNMENT_32 0x00050000
+#define EFI_FVB2_ALIGNMENT_64 0x00060000
+#define EFI_FVB2_ALIGNMENT_128 0x00070000
+#define EFI_FVB2_ALIGNMENT_256 0x00080000
+#define EFI_FVB2_ALIGNMENT_512 0x00090000
+#define EFI_FVB2_ALIGNMENT_1K 0x000A0000
+#define EFI_FVB2_ALIGNMENT_2K 0x000B0000
+#define EFI_FVB2_ALIGNMENT_4K 0x000C0000
+#define EFI_FVB2_ALIGNMENT_8K 0x000D0000
+#define EFI_FVB2_ALIGNMENT_16K 0x000E0000
+#define EFI_FVB2_ALIGNMENT_32K 0x000F0000
+#define EFI_FVB2_ALIGNMENT_64K 0x00100000
+#define EFI_FVB2_ALIGNMENT_128K 0x00110000
+#define EFI_FVB2_ALIGNMENT_256K 0x00120000
+#define EFI_FVB2_ALIGNMNET_512K 0x00130000
+#define EFI_FVB2_ALIGNMENT_1M 0x00140000
+#define EFI_FVB2_ALIGNMENT_2M 0x00150000
+#define EFI_FVB2_ALIGNMENT_4M 0x00160000
+#define EFI_FVB2_ALIGNMENT_8M 0x00170000
+#define EFI_FVB2_ALIGNMENT_16M 0x00180000
+#define EFI_FVB2_ALIGNMENT_32M 0x00190000
+#define EFI_FVB2_ALIGNMENT_64M 0x001A0000
+#define EFI_FVB2_ALIGNMENT_128M 0x001B0000
+#define EFI_FVB2_ALIGNMENT_256M 0x001C0000
+#define EFI_FVB2_ALIGNMENT_512M 0x001D0000
+#define EFI_FVB2_ALIGNMENT_1G 0x001E0000
+#define EFI_FVB2_ALIGNMENT_2G 0x001F0000
+
+#define EFI_FVB_CAPABILITIES (EFI_FVB_READ_DISABLED_CAP | \
+ EFI_FVB_READ_ENABLED_CAP | \
+ EFI_FVB_WRITE_DISABLED_CAP | \
+ EFI_FVB_WRITE_ENABLED_CAP | \
+ EFI_FVB_LOCK_CAP | \
+ EFI_FVB2_READ_LOCK_CAP | \
+ EFI_FVB2_WRITE_LOCK_CAP )
+
+#define EFI_FVB_STATUS (EFI_FVB_READ_STATUS | EFI_FVB_WRITE_STATUS | \
+ EFI_FVB_LOCK_STATUS | EFI_FVB2_READ_LOCK_STATUS | \
+ EFI_FVB2_WRITE_LOCK_STATUS )
+
+
+
+//
+// Extended Header Header. Located via ExtHeaderOffset.
+// The extended headers follow each other in memory and are
+// terminated by ExtHeaderType EFI_FV_EXT_TYPE_END
+//
+#define EFI_FV_EXT_TYPE_END 0x00
+typedef struct {
+ UINT16 ExtEntrySize;
+ UINT16 ExtEntryType;
+} EFI_FIRMWARE_VOLUME_EXT_ENTRY;
+
+//
+// GUID that maps OEM file types to GUIDs
+//
+#define EFI_FV_EXT_TYPE_OEM_TYPE 0x01
+typedef struct {
+ EFI_FIRMWARE_VOLUME_EXT_ENTRY Hdr;
+ UINT32 TypeMask;
+ EFI_GUID Types[1];
+} EFI_FIRMWARE_VOLUME_EXT_HEADER_OEM_TYPE;
+
+//
+// Unique name of the FV
+//
+typedef struct {
+ EFI_GUID FvName;
+ UINT32 ExtHeaderSize;
+} EFI_FIRMWARE_VOLUME_EXT_HEADER;
+
+
+#endif
+
+//
+// Firmware Volume Header Revision definition
+//
+#define EFI_FVH_REVISION 0x01
+//
+// PI1.0 define Firmware Volume Header Revision to 2
+//
+#define EFI_FVH_PI_REVISION 0x02
+
+//
+// Firmware Volume Header Signature definition
+//
+#define EFI_FVH_SIGNATURE EFI_SIGNATURE_32 ('_', 'F', 'V', 'H')
+
+//
+// Firmware Volume Header Block Map Entry definition
+//
+typedef struct {
+ UINT32 NumBlocks;
+ UINT32 BlockLength;
+} EFI_FV_BLOCK_MAP_ENTRY;
+
+//
+// Firmware Volume Header definition
+//
+typedef struct {
+ UINT8 ZeroVector[16];
+ EFI_GUID FileSystemGuid;
+ UINT64 FvLength;
+ UINT32 Signature;
+ EFI_FVB_ATTRIBUTES Attributes;
+ UINT16 HeaderLength;
+ UINT16 Checksum;
+//;;## ...AMI_OVERRIDE... Support PI1.x
+#if (PI_SPECIFICATION_VERSION < 0x00010000)
+ UINT8 Reserved[3];
+#else
+ UINT16 ExtHeaderOffset;
+ UINT8 Reserved[1];
+#endif
+ UINT8 Revision;
+ EFI_FV_BLOCK_MAP_ENTRY FvBlockMap[1];
+} EFI_FIRMWARE_VOLUME_HEADER;
+
+#endif
diff --git a/EDK/Foundation/Framework/Include/EfiImageFormat.h b/EDK/Foundation/Framework/Include/EfiImageFormat.h
new file mode 100644
index 0000000..de2a4f3
--- /dev/null
+++ b/EDK/Foundation/Framework/Include/EfiImageFormat.h
@@ -0,0 +1,279 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiImageFormat.h
+
+Abstract:
+
+ This file defines the data structures that are architecturally defined for file
+ images loaded via the FirmwareVolume protocol. The Firmware Volume specification
+ is the basis for these definitions.
+
+--*/
+
+#ifndef _EFI_IMAGE_FORMAT_H_
+#define _EFI_IMAGE_FORMAT_H_
+
+//
+// pack all data structures since this is actually a binary format and we cannot
+// allow internal padding in the data structures because of some compilerism..
+//
+#pragma pack(1)
+//
+// ////////////////////////////////////////////////////////////////////////////
+//
+// Architectural file types
+//
+typedef UINT8 EFI_FV_FILETYPE;
+
+#define EFI_FV_FILETYPE_ALL 0x00
+#define EFI_FV_FILETYPE_RAW 0x01
+#define EFI_FV_FILETYPE_FREEFORM 0x02
+#define EFI_FV_FILETYPE_SECURITY_CORE 0x03
+#define EFI_FV_FILETYPE_PEI_CORE 0x04
+#define EFI_FV_FILETYPE_DXE_CORE 0x05
+#define EFI_FV_FILETYPE_PEIM 0x06
+#define EFI_FV_FILETYPE_DRIVER 0x07
+#define EFI_FV_FILETYPE_COMBINED_PEIM_DRIVER 0x08
+#define EFI_FV_FILETYPE_APPLICATION 0x09
+//
+// File type 0x0A is reserved and should not be used
+//
+#define EFI_FV_FILETYPE_FIRMWARE_VOLUME_IMAGE 0x0B
+
+//
+// ////////////////////////////////////////////////////////////////////////////
+//
+// Section types
+//
+typedef UINT8 EFI_SECTION_TYPE;
+
+//
+// ************************************************************
+// The section type EFI_SECTION_ALL is a psuedo type. It is
+// used as a wildcard when retrieving sections. The section
+// type EFI_SECTION_ALL matches all section types.
+// ************************************************************
+//
+#define EFI_SECTION_ALL 0x00
+
+//
+// ************************************************************
+// Encapsulation section Type values
+// ************************************************************
+//
+#define EFI_SECTION_COMPRESSION 0x01
+#define EFI_SECTION_GUID_DEFINED 0x02
+
+//
+// ************************************************************
+// Leaf section Type values
+// ************************************************************
+//
+#define EFI_SECTION_FIRST_LEAF_SECTION_TYPE 0x10
+
+#define EFI_SECTION_PE32 0x10
+#define EFI_SECTION_PIC 0x11
+#define EFI_SECTION_TE 0x12
+#define EFI_SECTION_DXE_DEPEX 0x13
+#define EFI_SECTION_VERSION 0x14
+#define EFI_SECTION_USER_INTERFACE 0x15
+#define EFI_SECTION_COMPATIBILITY16 0x16
+#define EFI_SECTION_FIRMWARE_VOLUME_IMAGE 0x17
+#define EFI_SECTION_FREEFORM_SUBTYPE_GUID 0x18
+#define EFI_SECTION_RAW 0x19
+#define EFI_SECTION_PEI_DEPEX 0x1B
+
+#define EFI_SECTION_LAST_LEAF_SECTION_TYPE 0x1B
+#define EFI_SECTION_LAST_SECTION_TYPE 0x1B
+
+//
+// ////////////////////////////////////////////////////////////////////////////
+//
+// Common section header
+//
+typedef struct {
+ UINT8 Size[3];
+ UINT8 Type;
+} EFI_COMMON_SECTION_HEADER;
+
+#define SECTION_SIZE(SectionHeaderPtr) \
+ ((UINT32) (*((UINT32 *) ((EFI_COMMON_SECTION_HEADER *) SectionHeaderPtr)->Size) & 0x00ffffff))
+
+//
+// ////////////////////////////////////////////////////////////////////////////
+//
+// Compression section
+//
+//
+// CompressionType values
+//
+#define EFI_NOT_COMPRESSED 0x00
+#define EFI_STANDARD_COMPRESSION 0x01
+#define EFI_CUSTOMIZED_COMPRESSION 0x02
+
+typedef struct {
+ EFI_COMMON_SECTION_HEADER CommonHeader;
+ UINT32 UncompressedLength;
+ UINT8 CompressionType;
+} EFI_COMPRESSION_SECTION;
+
+//
+// ////////////////////////////////////////////////////////////////////////////
+//
+// GUID defined section
+//
+typedef struct {
+ EFI_COMMON_SECTION_HEADER CommonHeader;
+ EFI_GUID SectionDefinitionGuid;
+ UINT16 DataOffset;
+ UINT16 Attributes;
+} EFI_GUID_DEFINED_SECTION;
+
+//
+// Bit values for Attributes
+//
+#define EFI_GUIDED_SECTION_PROCESSING_REQUIRED 0x01
+#define EFI_GUIDED_SECTION_AUTH_STATUS_VALID 0x02
+
+//
+// Bit values for AuthenticationStatus
+//
+#define EFI_AGGREGATE_AUTH_STATUS_PLATFORM_OVERRIDE 0x000001
+#define EFI_AGGREGATE_AUTH_STATUS_IMAGE_SIGNED 0x000002
+#define EFI_AGGREGATE_AUTH_STATUS_NOT_TESTED 0x000004
+#define EFI_AGGREGATE_AUTH_STATUS_TEST_FAILED 0x000008
+#define EFI_AGGREGATE_AUTH_STATUS_ALL 0x00000f
+
+#define EFI_LOCAL_AUTH_STATUS_PLATFORM_OVERRIDE 0x010000
+#define EFI_LOCAL_AUTH_STATUS_IMAGE_SIGNED 0x020000
+#define EFI_LOCAL_AUTH_STATUS_NOT_TESTED 0x040000
+#define EFI_LOCAL_AUTH_STATUS_TEST_FAILED 0x080000
+#define EFI_LOCAL_AUTH_STATUS_ALL 0x0f0000
+
+//
+// ////////////////////////////////////////////////////////////////////////////
+//
+// PE32+ section
+//
+typedef struct {
+ EFI_COMMON_SECTION_HEADER CommonHeader;
+} EFI_PE32_SECTION;
+
+//
+// ////////////////////////////////////////////////////////////////////////////
+//
+// PIC section
+//
+typedef struct {
+ EFI_COMMON_SECTION_HEADER CommonHeader;
+} EFI_PIC_SECTION;
+
+//
+// ////////////////////////////////////////////////////////////////////////////
+//
+// PEIM header section
+//
+typedef struct {
+ EFI_COMMON_SECTION_HEADER CommonHeader;
+} EFI_PEIM_HEADER_SECTION;
+
+//
+// ////////////////////////////////////////////////////////////////////////////
+//
+// DEPEX section
+//
+typedef struct {
+ EFI_COMMON_SECTION_HEADER CommonHeader;
+} EFI_DEPEX_SECTION;
+
+//
+// ////////////////////////////////////////////////////////////////////////////
+//
+// Version section
+//
+typedef struct {
+ EFI_COMMON_SECTION_HEADER CommonHeader;
+ UINT16 BuildNumber;
+ INT16 VersionString[1];
+} EFI_VERSION_SECTION;
+
+//
+// ////////////////////////////////////////////////////////////////////////////
+//
+// User interface section
+//
+typedef struct {
+ EFI_COMMON_SECTION_HEADER CommonHeader;
+ INT16 FileNameString[1];
+} EFI_USER_INTERFACE_SECTION;
+
+//
+// ////////////////////////////////////////////////////////////////////////////
+//
+// Code16 section
+//
+typedef struct {
+ EFI_COMMON_SECTION_HEADER CommonHeader;
+} EFI_CODE16_SECTION;
+
+//
+// ////////////////////////////////////////////////////////////////////////////
+//
+// Firmware Volume Image section
+//
+typedef struct {
+ EFI_COMMON_SECTION_HEADER CommonHeader;
+} EFI_FIRMWARE_VOLUME_IMAGE_SECTION;
+
+//
+// ////////////////////////////////////////////////////////////////////////////
+//
+// Freeform subtype GUID section
+//
+typedef struct {
+ EFI_COMMON_SECTION_HEADER CommonHeader;
+ EFI_GUID SubTypeGuid;
+} EFI_FREEFORM_SUBTYPE_GUID_SECTION;
+
+//
+// ////////////////////////////////////////////////////////////////////////////
+//
+// Raw section
+//
+typedef struct {
+ EFI_COMMON_SECTION_HEADER CommonHeader;
+} EFI_RAW_SECTION;
+
+//
+// undo the pragma from the beginning...
+//
+#pragma pack()
+
+typedef union {
+ EFI_COMMON_SECTION_HEADER *CommonHeader;
+ EFI_COMPRESSION_SECTION *CompressionSection;
+ EFI_GUID_DEFINED_SECTION *GuidDefinedSection;
+ EFI_PE32_SECTION *Pe32Section;
+ EFI_PIC_SECTION *PicSection;
+ EFI_PEIM_HEADER_SECTION *PeimHeaderSection;
+ EFI_DEPEX_SECTION *DependencySection;
+ EFI_VERSION_SECTION *VersionSection;
+ EFI_USER_INTERFACE_SECTION *UISection;
+ EFI_CODE16_SECTION *Code16Section;
+ EFI_FIRMWARE_VOLUME_IMAGE_SECTION *FVImageSection;
+ EFI_FREEFORM_SUBTYPE_GUID_SECTION *FreeformSubtypeSection;
+ EFI_RAW_SECTION *RawSection;
+} EFI_FILE_SECTION_POINTER;
+
+#endif
diff --git a/EDK/Foundation/Framework/Include/EfiInternalFormRepresentation.h b/EDK/Foundation/Framework/Include/EfiInternalFormRepresentation.h
new file mode 100644
index 0000000..8b963fd
--- /dev/null
+++ b/EDK/Foundation/Framework/Include/EfiInternalFormRepresentation.h
@@ -0,0 +1,431 @@
+/*++
+
+Copyright (c) 2004 - 2005, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiInternalFormRepresentation.h
+
+Abstract:
+
+ This file defines the encoding for the VFR (Visual Form Representation) language.
+ IFR is primarily consumed by the EFI presentation engine, and produced by EFI
+ internal application and drivers as well as all add-in card option-ROM drivers
+
+--*/
+
+#ifndef _EFI_INTERNAL_FORM_REPRESENTATION_H_
+#define _EFI_INTERNAL_FORM_REPRESENTATION_H_
+
+//
+// The following types are currently defined:
+//
+typedef UINT32 RELOFST;
+typedef UINT16 STRING_REF;
+typedef CHAR16 *EFI_STRING;
+
+//
+// IFR Op codes
+//
+#define EFI_IFR_FORM_OP 0x01
+#define EFI_IFR_SUBTITLE_OP 0x02
+#define EFI_IFR_TEXT_OP 0x03
+#define EFI_IFR_GRAPHIC_OP 0x04
+#define EFI_IFR_ONE_OF_OP 0x05
+#define EFI_IFR_CHECKBOX_OP 0x06
+#define EFI_IFR_NUMERIC_OP 0x07
+#define EFI_IFR_PASSWORD_OP 0x08
+#define EFI_IFR_ONE_OF_OPTION_OP 0x09 // ONEOF OPTION field
+#define EFI_IFR_SUPPRESS_IF_OP 0x0A
+#define EFI_IFR_END_FORM_OP 0x0B
+#define EFI_IFR_HIDDEN_OP 0x0C
+#define EFI_IFR_END_FORM_SET_OP 0x0D
+#define EFI_IFR_FORM_SET_OP 0x0E
+#define EFI_IFR_REF_OP 0x0F
+#define EFI_IFR_END_ONE_OF_OP 0x10
+#define EFI_IFR_END_OP EFI_IFR_END_ONE_OF_OP
+#define EFI_IFR_INCONSISTENT_IF_OP 0x11
+#define EFI_IFR_EQ_ID_VAL_OP 0x12
+#define EFI_IFR_EQ_ID_ID_OP 0x13
+#define EFI_IFR_EQ_ID_LIST_OP 0x14
+#define EFI_IFR_AND_OP 0x15
+#define EFI_IFR_OR_OP 0x16
+#define EFI_IFR_NOT_OP 0x17
+#define EFI_IFR_END_IF_OP 0x18 // for endif of inconsistentif, suppressif, grayoutif
+#define EFI_IFR_GRAYOUT_IF_OP 0x19
+#define EFI_IFR_DATE_OP 0x1A
+#define EFI_IFR_TIME_OP 0x1B
+#define EFI_IFR_STRING_OP 0x1C
+#define EFI_IFR_LABEL_OP 0x1D
+#define EFI_IFR_SAVE_DEFAULTS_OP 0x1E
+#define EFI_IFR_RESTORE_DEFAULTS_OP 0x1F
+#define EFI_IFR_BANNER_OP 0x20
+#define EFI_IFR_INVENTORY_OP 0x21
+#define EFI_IFR_EQ_VAR_VAL_OP 0x22
+#define EFI_IFR_ORDERED_LIST_OP 0x23
+#define EFI_IFR_VARSTORE_OP 0x24
+#define EFI_IFR_VARSTORE_SELECT_OP 0x25
+#define EFI_IFR_VARSTORE_SELECT_PAIR_OP 0x26
+#define EFI_IFR_TRUE_OP 0x27
+#define EFI_IFR_FALSE_OP 0x28
+#define EFI_IFR_GT_OP 0x29
+#define EFI_IFR_GE_OP 0x2A
+#define EFI_IFR_OEM_DEFINED_OP 0x2B
+#define EFI_IFR_LAST_OPCODE EFI_IFR_OEM_DEFINED_OP
+#define EFI_IFR_OEM_OP 0xFE
+#define EFI_IFR_NV_ACCESS_COMMAND 0xFF
+
+//
+// Define values for the flags fields in some VFR opcodes. These are
+// bitmasks.
+//
+#define EFI_IFR_FLAG_DEFAULT 0x01
+#define EFI_IFR_FLAG_MANUFACTURING 0x02
+#define EFI_IFR_FLAG_INTERACTIVE 0x04
+#define EFI_IFR_FLAG_NV_ACCESS 0x08
+#define EFI_IFR_FLAG_RESET_REQUIRED 0x10
+#define EFI_IFR_FLAG_LATE_CHECK 0x20
+
+#define EFI_NON_DEVICE_CLASS 0x00 // Useful when you do not want something in the Device Manager
+#define EFI_DISK_DEVICE_CLASS 0x01
+#define EFI_VIDEO_DEVICE_CLASS 0x02
+#define EFI_NETWORK_DEVICE_CLASS 0x04
+#define EFI_INPUT_DEVICE_CLASS 0x08
+#define EFI_ON_BOARD_DEVICE_CLASS 0x10
+#define EFI_OTHER_DEVICE_CLASS 0x20
+
+#define EFI_SETUP_APPLICATION_SUBCLASS 0x00
+#define EFI_GENERAL_APPLICATION_SUBCLASS 0x01
+#define EFI_FRONT_PAGE_SUBCLASS 0x02
+#define EFI_SINGLE_USE_SUBCLASS 0x03 // Used to display a single entity and then exit
+//
+// Used to flag dynamically created op-codes. This is meaningful to the IFR Library set
+// and the browser since we need to distinguish between compiled NV map data and created data.
+// We do not allow new entries to be created in the NV map dynamically however we still need
+// to display this information correctly. To dynamically create op-codes and assume that their
+// data will be saved, ensure that the NV starting location they refer to is pre-defined in the
+// NV map.
+//
+#define EFI_IFR_FLAG_CREATED 128
+
+#pragma pack(1)
+//
+// IFR Structure definitions
+//
+typedef struct {
+ UINT8 OpCode;
+ UINT8 Length;
+} EFI_IFR_OP_HEADER;
+
+typedef struct {
+ EFI_IFR_OP_HEADER Header;
+ EFI_GUID Guid;
+ STRING_REF FormSetTitle;
+ STRING_REF Help;
+ EFI_PHYSICAL_ADDRESS CallbackHandle;
+ UINT16 Class;
+ UINT16 SubClass;
+ UINT16 NvDataSize; // set once, size of the NV data as defined in the script
+} EFI_IFR_FORM_SET;
+
+typedef struct {
+ EFI_IFR_OP_HEADER Header;
+ UINT16 FormId;
+ STRING_REF FormTitle;
+} EFI_IFR_FORM;
+
+typedef struct {
+ EFI_IFR_OP_HEADER Header;
+ UINT16 LabelId;
+} EFI_IFR_LABEL;
+
+typedef struct {
+ EFI_IFR_OP_HEADER Header;
+ STRING_REF SubTitle;
+} EFI_IFR_SUBTITLE;
+
+typedef struct {
+ EFI_IFR_OP_HEADER Header;
+ STRING_REF Help;
+ STRING_REF Text;
+ STRING_REF TextTwo;
+ UINT8 Flags; // This is included solely for purposes of interactive/dynamic support.
+ UINT16 Key; // Value to be passed to caller to identify this particular op-code
+} EFI_IFR_TEXT;
+
+//
+// goto
+//
+typedef struct {
+ EFI_IFR_OP_HEADER Header;
+ UINT16 FormId;
+ STRING_REF Prompt;
+ STRING_REF Help; // The string Token for the context-help
+ UINT8 Flags; // This is included solely for purposes of interactive/dynamic support.
+ UINT16 Key; // Value to be passed to caller to identify this particular op-code
+} EFI_IFR_REF;
+
+typedef struct {
+ EFI_IFR_OP_HEADER Header;
+} EFI_IFR_END_FORM;
+
+typedef struct {
+ EFI_IFR_OP_HEADER Header;
+} EFI_IFR_END_FORM_SET;
+
+//
+// Also notice that the IFR_ONE_OF and IFR_CHECK_BOX are identical in structure......code assumes this to be true, if this ever
+// changes we need to revisit the InitializeTagStructures code
+//
+typedef struct {
+ EFI_IFR_OP_HEADER Header;
+ UINT16 QuestionId; // The ID designating what the question is about...sucked in from a #define, likely in the form of a variable name
+ UINT8 Width; // The Size of the Data being saved
+ STRING_REF Prompt; // The String Token for the Prompt
+ STRING_REF Help; // The string Token for the context-help
+} EFI_IFR_ONE_OF;
+
+typedef struct {
+ EFI_IFR_OP_HEADER Header;
+ UINT16 QuestionId; // The offset in NV for storage of the data
+ UINT8 MaxEntries; // The maximum number of options in the ordered list (=size of NVStore)
+ STRING_REF Prompt; // The string token for the prompt
+ STRING_REF Help; // The string token for the context-help
+} EFI_IFR_ORDERED_LIST;
+
+typedef struct {
+ EFI_IFR_OP_HEADER Header;
+ UINT16 QuestionId; // The ID designating what the question is about...sucked in from a #define, likely in the form of a variable name
+ UINT8 Width; // The Size of the Data being saved
+ STRING_REF Prompt; // The String Token for the Prompt
+ STRING_REF Help; // The string Token for the context-help
+ UINT8 Flags; // For now, if non-zero, means that it is the default option, - further definition likely
+ UINT16 Key; // Value to be passed to caller to identify this particular op-code
+} EFI_IFR_CHECK_BOX;
+
+typedef struct {
+ EFI_IFR_OP_HEADER Header;
+ STRING_REF Option; // The string token describing the option
+ UINT16 Value; // The value associated with this option that is stored in the NVRAM if chosen
+ UINT8 Flags; // For now, if non-zero, means that it is the default option, - further definition likely above
+ UINT16 Key; // Value to be passed to caller to identify this particular op-code
+} EFI_IFR_ONE_OF_OPTION;
+
+typedef struct {
+ EFI_IFR_OP_HEADER Header;
+ UINT16 QuestionId; // The ID designating what the question is about...sucked in from a #define, likely in the form of a variable name
+ UINT8 Width; // The Size of the Data being saved
+ STRING_REF Prompt; // The String Token for the Prompt
+ STRING_REF Help; // The string Token for the context-help
+ UINT8 Flags; // This is included solely for purposes of interactive/dynamic support.
+ UINT16 Key; // Value to be passed to caller to identify this particular op-code
+ UINT16 Minimum;
+ UINT16 Maximum;
+ UINT16 Step; // If step is 0, then manual input is specified, otherwise, left/right arrow selection is called for
+ UINT16 Default;
+} EFI_IFR_NUMERIC;
+
+//
+// There is an interesting twist with regards to Time and Date. This is one of the few items which can accept input from
+// a user, however may or may not need to use storage in the NVRAM space. The decided method for determining if NVRAM space
+// will be used (only for a TimeOp or DateOp) is: If .QuestionId == 0 && .Width == 0 (normally an impossibility) then use system
+// resources to store the data away and not NV resources. In other words, the setup engine will call gRT->SetTime, and gRT->SetDate
+// for the saving of data, and the values displayed will be from the gRT->GetXXXX series of calls.
+//
+typedef struct {
+ EFI_IFR_NUMERIC Hour;
+ EFI_IFR_NUMERIC Minute;
+ EFI_IFR_NUMERIC Second;
+} EFI_IFR_TIME;
+
+typedef struct {
+ EFI_IFR_NUMERIC Year;
+ EFI_IFR_NUMERIC Month;
+ EFI_IFR_NUMERIC Day;
+} EFI_IFR_DATE;
+
+typedef struct {
+ EFI_IFR_OP_HEADER Header;
+ UINT16 QuestionId; // The ID designating what the question is about...sucked in from a #define, likely in the form of a variable name
+ UINT8 Width; // The Size of the Data being saved -- BUGBUG -- remove someday
+ STRING_REF Prompt; // The String Token for the Prompt
+ STRING_REF Help; // The string Token for the context-help
+ UINT8 Flags; // This is included solely for purposes of interactive/dynamic support.
+ UINT16 Key; // Value to be passed to caller to identify this particular op-code
+ UINT8 MinSize; // Minimum allowable sized password
+ UINT8 MaxSize; // Maximum allowable sized password
+ UINT16 Encoding;
+} EFI_IFR_PASSWORD;
+
+typedef struct {
+ EFI_IFR_OP_HEADER Header;
+ UINT16 QuestionId; // The ID designating what the question is about...sucked in from a #define, likely in the form of a variable name
+ UINT8 Width; // The Size of the Data being saved -- BUGBUG -- remove someday
+ STRING_REF Prompt; // The String Token for the Prompt
+ STRING_REF Help; // The string Token for the context-help
+ UINT8 Flags; // This is included solely for purposes of interactive/dynamic support.
+ UINT16 Key; // Value to be passed to caller to identify this particular op-code
+ UINT8 MinSize; // Minimum allowable sized password
+ UINT8 MaxSize; // Maximum allowable sized password
+} EFI_IFR_STRING;
+
+typedef struct {
+ EFI_IFR_OP_HEADER Header;
+} EFI_IFR_END_ONE_OF;
+
+typedef struct {
+ EFI_IFR_OP_HEADER Header;
+ UINT16 Value;
+ UINT16 Key;
+} EFI_IFR_HIDDEN;
+
+typedef struct {
+ EFI_IFR_OP_HEADER Header;
+ UINT8 Flags;
+} EFI_IFR_SUPPRESS;
+
+typedef struct {
+ EFI_IFR_OP_HEADER Header;
+ UINT8 Flags;
+} EFI_IFR_GRAYOUT;
+
+typedef struct {
+ EFI_IFR_OP_HEADER Header;
+ STRING_REF Popup;
+ UINT8 Flags;
+} EFI_IFR_INCONSISTENT;
+
+typedef struct {
+ EFI_IFR_OP_HEADER Header;
+ UINT16 QuestionId; // offset into variable storage
+ UINT8 Width; // size of variable storage
+ UINT16 Value; // value to compare against
+} EFI_IFR_EQ_ID_VAL;
+
+typedef struct {
+ EFI_IFR_OP_HEADER Header;
+ UINT16 QuestionId; // offset into variable storage
+ UINT8 Width; // size of variable storage
+ UINT16 ListLength;
+ UINT16 ValueList[1];
+} EFI_IFR_EQ_ID_LIST;
+
+typedef struct {
+ EFI_IFR_OP_HEADER Header;
+ UINT16 QuestionId1; // offset into variable storage for first value to compare
+ UINT8 Width; // size of variable storage (must be same for both)
+ UINT16 QuestionId2; // offset into variable storage for second value to compare
+} EFI_IFR_EQ_ID_ID;
+
+typedef struct {
+ EFI_IFR_OP_HEADER Header;
+ UINT16 VariableId; // offset into variable storage
+ UINT16 Value; // value to compare against
+} EFI_IFR_EQ_VAR_VAL;
+
+typedef struct {
+ EFI_IFR_OP_HEADER Header;
+} EFI_IFR_AND;
+
+typedef struct {
+ EFI_IFR_OP_HEADER Header;
+} EFI_IFR_OR;
+
+typedef struct {
+ EFI_IFR_OP_HEADER Header;
+} EFI_IFR_NOT;
+
+typedef struct {
+ EFI_IFR_OP_HEADER Header;
+} EFI_IFR_END_IF;
+
+typedef struct {
+ EFI_IFR_OP_HEADER Header;
+ UINT16 FormId;
+ STRING_REF Prompt;
+ STRING_REF Help;
+ UINT8 Flags;
+ UINT16 Key;
+} EFI_IFR_SAVE_DEFAULTS;
+
+typedef struct {
+ EFI_IFR_OP_HEADER Header;
+ STRING_REF Help;
+ STRING_REF Text;
+ STRING_REF TextTwo; // optional text
+} EFI_IFR_INVENTORY;
+
+typedef struct {
+ EFI_IFR_OP_HEADER Header;
+ EFI_GUID Guid; // GUID for the variable
+ UINT16 VarId; // variable store ID, as referenced elsewhere in the form
+ UINT16 Size; // size of the variable storage
+} EFI_IFR_VARSTORE;
+
+typedef struct {
+ EFI_IFR_OP_HEADER Header;
+ UINT16 VarId; // variable store ID, as referenced elsewhere in the form
+} EFI_IFR_VARSTORE_SELECT;
+
+//
+// Used for the ideqid VFR statement where two variable stores may be referenced in the
+// same VFR statement.
+// A browser should treat this as an EFI_IFR_VARSTORE_SELECT statement and assume that all following
+// IFR opcodes use the VarId as defined here.
+//
+typedef struct {
+ EFI_IFR_OP_HEADER Header;
+ UINT16 VarId; // variable store ID, as referenced elsewhere in the form
+ UINT16 SecondaryVarId; // variable store ID, as referenced elsewhere in the form
+} EFI_IFR_VARSTORE_SELECT_PAIR;
+
+typedef struct {
+ EFI_IFR_OP_HEADER Header;
+} EFI_IFR_TRUE;
+
+typedef struct {
+ EFI_IFR_OP_HEADER Header;
+} EFI_IFR_FALSE;
+
+typedef struct {
+ EFI_IFR_OP_HEADER Header;
+} EFI_IFR_GT;
+
+typedef struct {
+ EFI_IFR_OP_HEADER Header;
+} EFI_IFR_GE;
+
+//
+// Save defaults and restore defaults have same structure
+//
+#define EFI_IFR_RESTORE_DEFAULTS EFI_IFR_SAVE_DEFAULTS
+
+typedef struct {
+ EFI_IFR_OP_HEADER Header;
+ STRING_REF Title; // The string token for the banner title
+ UINT16 LineNumber; // 1-based line number
+ UINT8 Alignment; // left, center, or right-aligned
+} EFI_IFR_BANNER;
+
+typedef struct {
+ EFI_IFR_OP_HEADER Header;
+ UINT16 QuestionId; // Offset into the map
+ UINT8 StorageWidth; // Width of the value
+ CHAR8 Data[1]; // The Data itself
+} EFI_IFR_NV_DATA;
+
+#define EFI_IFR_BANNER_ALIGN_LEFT 0
+#define EFI_IFR_BANNER_ALIGN_CENTER 1
+#define EFI_IFR_BANNER_ALIGN_RIGHT 2
+#define EFI_IFR_BANNER_TIMEOUT 0xFF
+
+#pragma pack()
+
+#endif
diff --git a/EDK/Foundation/Framework/Include/EfiPciCfg.h b/EDK/Foundation/Framework/Include/EfiPciCfg.h
new file mode 100644
index 0000000..f65b163
--- /dev/null
+++ b/EDK/Foundation/Framework/Include/EfiPciCfg.h
@@ -0,0 +1,81 @@
+/*++
+
+Copyright (c) 2007 - 2009, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiPciCfg.h
+
+Abstract:
+
+ Abstract the common fields of PciCfg definition between Framework 0.9x
+ and PI 1.0.
+
+--*/
+
+#ifndef _EFI_PCI_CFG_H_
+#define _EFI_PCI_CFG_H_
+
+//
+// Framework specification 0.9x definition.
+//
+typedef enum {
+ PeiPciCfgWidthUint8 = 0,
+ PeiPciCfgWidthUint16 = 1,
+ PeiPciCfgWidthUint32 = 2,
+ PeiPciCfgWidthUint64 = 3,
+ PeiPciCfgWidthMaximum
+} PEI_PCI_CFG_PPI_WIDTH;
+
+#define PEI_PCI_CFG_ADDRESS(bus, dev, func, reg) ( \
+ (UINT64) ((((UINTN) bus) << 24) + (((UINTN) dev) << 16) + (((UINTN) func) << 8) + ((UINTN) reg)) \
+ ) & 0x00000000ffffffff
+
+//
+// PI 1.0 definition.
+//
+typedef enum {
+ EfiPeiPciCfgWidthUint8 = 0,
+ EfiPeiPciCfgWidthUint16 = 1,
+ EfiPeiPciCfgWidthUint32 = 2,
+ EfiPeiPciCfgWidthUint64 = 3,
+ EfiPeiPciCfgWidthMaximum
+} EFI_PEI_PCI_CFG_PPI_WIDTH;
+
+#define EFI_PEI_PCI_CFG_ADDRESS(bus, dev, func, reg) \
+ (UINT64) ((((UINTN) (bus)) << 24) | \
+ (((UINTN) (dev)) << 16) | \
+ (((UINTN) (func)) << 8) | \
+ ((reg) < 256 ? ((UINTN) (reg)): ((UINT64) (reg) << 32)))
+
+#if (PI_SPECIFICATION_VERSION < 0x00010000)
+
+typedef struct {
+ UINT8 Register;
+ UINT8 Function;
+ UINT8 Device;
+ UINT8 Bus;
+ UINT8 Reserved[4];
+} PEI_PCI_CFG_PPI_PCI_ADDRESS;
+
+typedef PEI_PCI_CFG_PPI_PCI_ADDRESS EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS;
+
+#else
+
+typedef struct {
+ UINT8 Register;
+ UINT8 Function;
+ UINT8 Device;
+ UINT8 Bus;
+ UINT32 ExtendedRegister;
+} EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS;
+#endif
+
+#endif
diff --git a/EDK/Foundation/Framework/Include/EfiSmbus.h b/EDK/Foundation/Framework/Include/EfiSmbus.h
new file mode 100644
index 0000000..425694c
--- /dev/null
+++ b/EDK/Foundation/Framework/Include/EfiSmbus.h
@@ -0,0 +1,70 @@
+/*++
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiSmbus.h
+
+Abstract:
+
+
+
+--*/
+
+#ifndef _EFI_SMBUS_DEFINITION_H_
+#define _EFI_SMBUS_DEFINITION_H_
+
+//
+// EFI Smbus Device Address, Smbus Device Command, Smbus Operation
+//
+typedef struct {
+ UINTN SmbusDeviceAddress : 7;
+} EFI_SMBUS_DEVICE_ADDRESS;
+
+typedef UINTN EFI_SMBUS_DEVICE_COMMAND;
+
+typedef enum _EFI_SMBUS_OPERATION
+{
+ EfiSmbusQuickRead,
+ EfiSmbusQuickWrite,
+ EfiSmbusReceiveByte,
+ EfiSmbusSendByte,
+ EfiSmbusReadByte,
+ EfiSmbusWriteByte,
+ EfiSmbusReadWord,
+ EfiSmbusWriteWord,
+ EfiSmbusReadBlock,
+ EfiSmbusWriteBlock,
+ EfiSmbusProcessCall,
+ EfiSmbusBWBRProcessCall
+} EFI_SMBUS_OPERATION;
+
+//;;## ...AMI_OVERRIDE... Support PI1.x start
+typedef struct {
+ UINT32 VendorSpecificId;
+ UINT16 SubsystemDeviceId;
+ UINT16 SubsystemVendorId;
+ UINT16 Interface;
+ UINT16 DeviceId;
+ UINT16 VendorId;
+ UINT8 VendorRevision;
+ UINT8 DeviceCapabilities;
+} EFI_SMBUS_UDID;
+
+
+typedef struct {
+ EFI_SMBUS_DEVICE_ADDRESS SmbusDeviceAddress;
+ EFI_SMBUS_UDID SmbusDeviceUdid;
+} EFI_SMBUS_DEVICE_MAP;
+//;;## ...AMI_OVERRIDE... Support PI1.x end
+
+
+#endif
diff --git a/EDK/Foundation/Framework/Include/EfiStatusCode.h b/EDK/Foundation/Framework/Include/EfiStatusCode.h
new file mode 100644
index 0000000..cc16c10
--- /dev/null
+++ b/EDK/Foundation/Framework/Include/EfiStatusCode.h
@@ -0,0 +1,961 @@
+/*++
+
+Copyright (c) 2004 - 2011, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiStatusCode.h
+
+Abstract:
+
+ Status Code Definitions, according to Intel Platform Innovation Framework
+ for EFI Status Codes Specification
+ Revision 0.92
+
+ The file is divided into sections for ease of use.
+
+ Section: Contents:
+ 1 General Status Code Definitions
+ 2 Class definitions
+ 3 Computing Unit Subclasses, Progress and Error Codes
+ 4 Peripheral Subclasses, Progress and Error Codes.
+ 5 IO Bus Subclasses, Progress and Error Codes.
+ 6 Software Subclasses, Progress and Error Codes.
+ 7 Debug Codes
+
+--*/
+
+#ifndef _EFI_STATUS_CODE_H_
+#define _EFI_STATUS_CODE_H_
+
+//
+// /////////////////////////////////////////////////////////////////////////////
+// Section 1
+///////////////////////////////////////////////////////////////////////////////
+//
+// Status Code Type Definition
+//
+typedef UINT32 EFI_STATUS_CODE_TYPE;
+
+//
+// A Status Code Type is made up of the code type and severity
+// All values masked by EFI_STATUS_CODE_RESERVED_MASK are
+// reserved for use by this specification.
+//
+#define EFI_STATUS_CODE_TYPE_MASK 0x000000FF
+#define EFI_STATUS_CODE_SEVERITY_MASK 0xFF000000
+#define EFI_STATUS_CODE_RESERVED_MASK 0x00FFFF00
+
+//
+// Definition of code types, all other values masked by
+// EFI_STATUS_CODE_TYPE_MASK are reserved for use by
+// this specification.
+//
+#define EFI_PROGRESS_CODE 0x00000001
+#define EFI_ERROR_CODE 0x00000002
+#define EFI_DEBUG_CODE 0x00000003
+
+//
+// Definitions of severities, all other values masked by
+// EFI_STATUS_CODE_SEVERITY_MASK are reserved for use by
+// this specification.
+//
+#define EFI_ERROR_MINOR 0x40000000
+#define EFI_ERROR_MAJOR 0x80000000
+#define EFI_ERROR_UNRECOVERED 0x90000000
+#define EFI_ERROR_UNCONTAINED 0xA0000000
+
+//
+// Status Code Value Definition
+//
+typedef UINT32 EFI_STATUS_CODE_VALUE;
+
+//
+// A Status Code Value is made up of the class, subclass, and
+// an operation. Classes, subclasses, and operations are defined
+// in the following sections.
+//
+#define EFI_STATUS_CODE_CLASS_MASK 0xFF000000
+#define EFI_STATUS_CODE_SUBCLASS_MASK 0x00FF0000
+#define EFI_STATUS_CODE_OPERATION_MASK 0x0000FFFF
+
+typedef struct {
+ UINT16 HeaderSize;
+ UINT16 Size;
+ EFI_GUID Type;
+} EFI_STATUS_CODE_DATA;
+
+//
+// Data Hub Status Code class record definition
+//
+typedef struct {
+ EFI_STATUS_CODE_TYPE CodeType;
+ EFI_STATUS_CODE_VALUE Value;
+ UINT32 Instance;
+ EFI_GUID CallerId;
+ EFI_STATUS_CODE_DATA Data;
+} DATA_HUB_STATUS_CODE_DATA_RECORD;
+
+//
+// /////////////////////////////////////////////////////////////////////////////
+// Section 2
+///////////////////////////////////////////////////////////////////////////////
+//
+// Class definitions
+// Values of 4-127 are reserved for future use by this
+// specification.
+// Values in the range 128-255 are reserved for OEM use.
+//
+#define EFI_COMPUTING_UNIT 0x00000000
+#define EFI_PERIPHERAL 0x01000000
+#define EFI_IO_BUS 0x02000000
+#define EFI_SOFTWARE 0x03000000
+
+//
+// General partitioning scheme for Progress and Error Codes are
+// 0x0000-0x0FFF - Shared by all sub-classes in a given class
+// 0x1000-0x7FFF - Subclass Specific
+// 0x8000-0xFFFF - OEM specific
+//
+#define EFI_SUBCLASS_SPECIFIC 0x1000
+#define EFI_OEM_SPECIFIC 0x8000
+
+//
+// /////////////////////////////////////////////////////////////////////////////
+// Section 3
+///////////////////////////////////////////////////////////////////////////////
+//
+// Computing Unit Subclass definitions.
+// Values of 7-127 are reserved for future use by this
+// specification.
+// Values of 128-255 are reserved for OEM use.
+//
+#define EFI_COMPUTING_UNIT_UNSPECIFIED (EFI_COMPUTING_UNIT | 0x00000000)
+#define EFI_COMPUTING_UNIT_HOST_PROCESSOR (EFI_COMPUTING_UNIT | 0x00010000)
+#define EFI_COMPUTING_UNIT_FIRMWARE_PROCESSOR (EFI_COMPUTING_UNIT | 0x00020000)
+#define EFI_COMPUTING_UNIT_IO_PROCESSOR (EFI_COMPUTING_UNIT | 0x00030000)
+#define EFI_COMPUTING_UNIT_CACHE (EFI_COMPUTING_UNIT | 0x00040000)
+#define EFI_COMPUTING_UNIT_MEMORY (EFI_COMPUTING_UNIT | 0x00050000)
+#define EFI_COMPUTING_UNIT_CHIPSET (EFI_COMPUTING_UNIT | 0x00060000)
+
+//
+// Computing Unit Class Progress Code definitions.
+// These are shared by all subclasses.
+//
+#define EFI_CU_PC_INIT_BEGIN 0x00000000
+#define EFI_CU_PC_INIT_END 0x00000001
+
+//
+// Computing Unit Unspecified Subclass Progress Code definitions.
+//
+//
+// Computing Unit Host Processor Subclass Progress Code definitions.
+//
+#define EFI_CU_HP_PC_POWER_ON_INIT (EFI_SUBCLASS_SPECIFIC | 0x00000000)
+#define EFI_CU_HP_PC_CACHE_INIT (EFI_SUBCLASS_SPECIFIC | 0x00000001)
+#define EFI_CU_HP_PC_RAM_INIT (EFI_SUBCLASS_SPECIFIC | 0x00000002)
+#define EFI_CU_HP_PC_MEMORY_CONTROLLER_INIT (EFI_SUBCLASS_SPECIFIC | 0x00000003)
+#define EFI_CU_HP_PC_IO_INIT (EFI_SUBCLASS_SPECIFIC | 0x00000004)
+#define EFI_CU_HP_PC_BSP_SELECT (EFI_SUBCLASS_SPECIFIC | 0x00000005)
+#define EFI_CU_HP_PC_BSP_RESELECT (EFI_SUBCLASS_SPECIFIC | 0x00000006)
+#define EFI_CU_HP_PC_AP_INIT (EFI_SUBCLASS_SPECIFIC | 0x00000007)
+#define EFI_CU_HP_PC_SMM_INIT (EFI_SUBCLASS_SPECIFIC | 0x00000008)
+
+//
+// Computing Unit Firmware Processor Subclass Progress Code definitions.
+//
+//
+// Computing Unit IO Processor Subclass Progress Code definitions.
+//
+//
+// Computing Unit Cache Subclass Progress Code definitions.
+//
+#define EFI_CU_CACHE_PC_PRESENCE_DETECT (EFI_SUBCLASS_SPECIFIC | 0x00000000)
+#define EFI_CU_CACHE_PC_CONFIGURATION (EFI_SUBCLASS_SPECIFIC | 0x00000001)
+
+//
+// Computing Unit Memory Subclass Progress Code definitions.
+//
+#define EFI_CU_MEMORY_PC_SPD_READ (EFI_SUBCLASS_SPECIFIC | 0x00000000)
+#define EFI_CU_MEMORY_PC_PRESENCE_DETECT (EFI_SUBCLASS_SPECIFIC | 0x00000001)
+#define EFI_CU_MEMORY_PC_TIMING (EFI_SUBCLASS_SPECIFIC | 0x00000002)
+#define EFI_CU_MEMORY_PC_CONFIGURING (EFI_SUBCLASS_SPECIFIC | 0x00000003)
+#define EFI_CU_MEMORY_PC_OPTIMIZING (EFI_SUBCLASS_SPECIFIC | 0x00000004)
+#define EFI_CU_MEMORY_PC_INIT (EFI_SUBCLASS_SPECIFIC | 0x00000005)
+#define EFI_CU_MEMORY_PC_TEST (EFI_SUBCLASS_SPECIFIC | 0x00000006)
+
+//
+// Computing Unit Chipset Subclass Progress Code definitions.
+//
+//
+// Computing Unit Class Error Code definitions.
+// These are shared by all subclasses.
+//
+#define EFI_CU_EC_NON_SPECIFIC 0x00000000
+#define EFI_CU_EC_DISABLED 0x00000001
+#define EFI_CU_EC_NOT_SUPPORTED 0x00000002
+#define EFI_CU_EC_NOT_DETECTED 0x00000003
+#define EFI_CU_EC_NOT_CONFIGURED 0x00000004
+
+//
+// Computing Unit Unspecified Subclass Error Code definitions.
+//
+//
+// Computing Unit Host Processor Subclass Error Code definitions.
+//
+#define EFI_CU_HP_EC_INVALID_TYPE (EFI_SUBCLASS_SPECIFIC | 0x00000000)
+#define EFI_CU_HP_EC_INVALID_SPEED (EFI_SUBCLASS_SPECIFIC | 0x00000001)
+#define EFI_CU_HP_EC_MISMATCH (EFI_SUBCLASS_SPECIFIC | 0x00000002)
+#define EFI_CU_HP_EC_TIMER_EXPIRED (EFI_SUBCLASS_SPECIFIC | 0x00000003)
+#define EFI_CU_HP_EC_SELF_TEST (EFI_SUBCLASS_SPECIFIC | 0x00000004)
+#define EFI_CU_HP_EC_INTERNAL (EFI_SUBCLASS_SPECIFIC | 0x00000005)
+#define EFI_CU_HP_EC_THERMAL (EFI_SUBCLASS_SPECIFIC | 0x00000006)
+#define EFI_CU_HP_EC_LOW_VOLTAGE (EFI_SUBCLASS_SPECIFIC | 0x00000007)
+#define EFI_CU_HP_EC_HIGH_VOLTAGE (EFI_SUBCLASS_SPECIFIC | 0x00000008)
+#define EFI_CU_HP_EC_CACHE (EFI_SUBCLASS_SPECIFIC | 0x00000009)
+#define EFI_CU_HP_EC_MICROCODE_UPDATE (EFI_SUBCLASS_SPECIFIC | 0x0000000A)
+#define EFI_CU_HP_EC_CORRECTABLE (EFI_SUBCLASS_SPECIFIC | 0x0000000B)
+#define EFI_CU_HP_EC_UNCORRECTABLE (EFI_SUBCLASS_SPECIFIC | 0x0000000C)
+#define EFI_CU_HP_EC_NO_MICROCODE_UPDATE (EFI_SUBCLASS_SPECIFIC | 0x0000000D)
+
+//
+// Computing Unit Firmware Processor Subclass Error Code definitions.
+//
+#define EFI_CU_FP_EC_HARD_FAIL (EFI_SUBCLASS_SPECIFIC | 0x00000000)
+#define EFI_CU_FP_EC_SOFT_FAIL (EFI_SUBCLASS_SPECIFIC | 0x00000001)
+#define EFI_CU_FP_EC_COMM_ERROR (EFI_SUBCLASS_SPECIFIC | 0x00000002)
+
+//
+// Computing Unit IO Processor Subclass Error Code definitions.
+//
+//
+// Computing Unit Cache Subclass Error Code definitions.
+//
+#define EFI_CU_CACHE_EC_INVALID_TYPE (EFI_SUBCLASS_SPECIFIC | 0x00000000)
+#define EFI_CU_CACHE_EC_INVALID_SPEED (EFI_SUBCLASS_SPECIFIC | 0x00000001)
+#define EFI_CU_CACHE_EC_INVALID_SIZE (EFI_SUBCLASS_SPECIFIC | 0x00000002)
+#define EFI_CU_CACHE_EC_MISMATCH (EFI_SUBCLASS_SPECIFIC | 0x00000003)
+
+//
+// Computing Unit Memory Subclass Error Code definitions.
+//
+#define EFI_CU_MEMORY_EC_INVALID_TYPE (EFI_SUBCLASS_SPECIFIC | 0x00000000)
+#define EFI_CU_MEMORY_EC_INVALID_SPEED (EFI_SUBCLASS_SPECIFIC | 0x00000001)
+#define EFI_CU_MEMORY_EC_CORRECTABLE (EFI_SUBCLASS_SPECIFIC | 0x00000002)
+#define EFI_CU_MEMORY_EC_UNCORRECTABLE (EFI_SUBCLASS_SPECIFIC | 0x00000003)
+#define EFI_CU_MEMORY_EC_SPD_FAIL (EFI_SUBCLASS_SPECIFIC | 0x00000004)
+#define EFI_CU_MEMORY_EC_INVALID_SIZE (EFI_SUBCLASS_SPECIFIC | 0x00000005)
+#define EFI_CU_MEMORY_EC_MISMATCH (EFI_SUBCLASS_SPECIFIC | 0x00000006)
+#define EFI_CU_MEMORY_EC_S3_RESUME_FAIL (EFI_SUBCLASS_SPECIFIC | 0x00000007)
+#define EFI_CU_MEMORY_EC_UPDATE_FAIL (EFI_SUBCLASS_SPECIFIC | 0x00000008)
+#define EFI_CU_MEMORY_EC_NONE_DETECTED (EFI_SUBCLASS_SPECIFIC | 0x00000009)
+#define EFI_CU_MEMORY_EC_NONE_USEFUL (EFI_SUBCLASS_SPECIFIC | 0x0000000A)
+
+//
+// Computing Unit Chipset Subclass Error Code definitions.
+//
+
+///////////////////////////////////////////////////////////////////////////////
+// Section 4
+///////////////////////////////////////////////////////////////////////////////
+//
+// Peripheral Subclass definitions.
+// Values of 13-127 are reserved for future use by this
+// specification.
+// Values of 128-255 are reserved for OEM use.
+//
+#define EFI_PERIPHERAL_UNSPECIFIED (EFI_PERIPHERAL | 0x00000000)
+#define EFI_PERIPHERAL_KEYBOARD (EFI_PERIPHERAL | 0x00010000)
+#define EFI_PERIPHERAL_MOUSE (EFI_PERIPHERAL | 0x00020000)
+#define EFI_PERIPHERAL_LOCAL_CONSOLE (EFI_PERIPHERAL | 0x00030000)
+#define EFI_PERIPHERAL_REMOTE_CONSOLE (EFI_PERIPHERAL | 0x00040000)
+#define EFI_PERIPHERAL_SERIAL_PORT (EFI_PERIPHERAL | 0x00050000)
+#define EFI_PERIPHERAL_PARALLEL_PORT (EFI_PERIPHERAL | 0x00060000)
+#define EFI_PERIPHERAL_FIXED_MEDIA (EFI_PERIPHERAL | 0x00070000)
+#define EFI_PERIPHERAL_REMOVABLE_MEDIA (EFI_PERIPHERAL | 0x00080000)
+#define EFI_PERIPHERAL_AUDIO_INPUT (EFI_PERIPHERAL | 0x00090000)
+#define EFI_PERIPHERAL_AUDIO_OUTPUT (EFI_PERIPHERAL | 0x000A0000)
+#define EFI_PERIPHERAL_LCD_DEVICE (EFI_PERIPHERAL | 0x000B0000)
+#define EFI_PERIPHERAL_NETWORK (EFI_PERIPHERAL | 0x000C0000)
+
+//
+// Peripheral Class Progress Code definitions.
+// These are shared by all subclasses.
+//
+#define EFI_P_PC_INIT 0x00000000
+#define EFI_P_PC_RESET 0x00000001
+#define EFI_P_PC_DISABLE 0x00000002
+#define EFI_P_PC_PRESENCE_DETECT 0x00000003
+#define EFI_P_PC_ENABLE 0x00000004
+#define EFI_P_PC_RECONFIG 0x00000005
+#define EFI_P_PC_DETECTED 0x00000006
+
+//
+// Peripheral Class Unspecified Subclass Progress Code definitions.
+//
+//
+// Peripheral Class Keyboard Subclass Progress Code definitions.
+//
+#define EFI_P_KEYBOARD_PC_CLEAR_BUFFER (EFI_SUBCLASS_SPECIFIC | 0x00000000)
+#define EFI_P_KEYBOARD_PC_SELF_TEST (EFI_SUBCLASS_SPECIFIC | 0x00000001)
+
+//
+// Peripheral Class Mouse Subclass Progress Code definitions.
+//
+#define EFI_P_MOUSE_PC_SELF_TEST (EFI_SUBCLASS_SPECIFIC | 0x00000000)
+
+//
+// Peripheral Class Local Console Subclass Progress Code definitions.
+//
+//
+// Peripheral Class Remote Console Subclass Progress Code definitions.
+//
+//
+// Peripheral Class Serial Port Subclass Progress Code definitions.
+//
+#define EFI_P_SERIAL_PORT_PC_CLEAR_BUFFER (EFI_SUBCLASS_SPECIFIC | 0x00000000)
+
+//
+// Peripheral Class Parallel Port Subclass Progress Code definitions.
+//
+//
+// Peripheral Class Fixed Media Subclass Progress Code definitions.
+//
+//
+// Peripheral Class Removable Media Subclass Progress Code definitions.
+//
+//
+// Peripheral Class Audio Input Subclass Progress Code definitions.
+//
+//
+// Peripheral Class Audio Output Subclass Progress Code definitions.
+//
+//
+// Peripheral Class LCD Device Subclass Progress Code definitions.
+//
+//
+// Peripheral Class Network Subclass Progress Code definitions.
+//
+//
+// Peripheral Class Error Code definitions.
+// These are shared by all subclasses.
+//
+#define EFI_P_EC_NON_SPECIFIC 0x00000000
+#define EFI_P_EC_DISABLED 0x00000001
+#define EFI_P_EC_NOT_SUPPORTED 0x00000002
+#define EFI_P_EC_NOT_DETECTED 0x00000003
+#define EFI_P_EC_NOT_CONFIGURED 0x00000004
+#define EFI_P_EC_INTERFACE_ERROR 0x00000005
+#define EFI_P_EC_CONTROLLER_ERROR 0x00000006
+#define EFI_P_EC_INPUT_ERROR 0x00000007
+#define EFI_P_EC_OUTPUT_ERROR 0x00000008
+#define EFI_P_EC_RESOURCE_CONFLICT 0x00000009
+
+//
+// Peripheral Class Unspecified Subclass Error Code definitions.
+//
+//
+// Peripheral Class Keyboard Subclass Error Code definitions.
+//
+#define EFI_P_KEYBOARD_EC_LOCKED (EFI_SUBCLASS_SPECIFIC | 0x00000000)
+#define EFI_P_KEYBOARD_EC_STUCK_KEY (EFI_SUBCLASS_SPECIFIC | 0x00000001)
+
+//
+// Peripheral Class Mouse Subclass Error Code definitions.
+//
+#define EFI_P_MOUSE_EC_LOCKED (EFI_SUBCLASS_SPECIFIC | 0x00000000)
+
+//
+// Peripheral Class Local Console Subclass Error Code definitions.
+//
+//
+// Peripheral Class Remote Console Subclass Error Code definitions.
+//
+//
+// Peripheral Class Serial Port Subclass Error Code definitions.
+//
+//
+// Peripheral Class Parallel Port Subclass Error Code definitions.
+//
+//
+// Peripheral Class Fixed Media Subclass Error Code definitions.
+//
+//
+// Peripheral Class Removable Media Subclass Error Code definitions.
+//
+//
+// Peripheral Class Audio Input Subclass Error Code definitions.
+//
+//
+// Peripheral Class Audio Output Subclass Error Code definitions.
+//
+//
+// Peripheral Class LCD Device Subclass Error Code definitions.
+//
+//
+// Peripheral Class Network Subclass Error Code definitions.
+//
+
+///////////////////////////////////////////////////////////////////////////////
+// Section 5
+///////////////////////////////////////////////////////////////////////////////
+//
+// IO Bus Subclass definitions.
+// Values of 13-127 are reserved for future use by this
+// specification.
+// Values of 128-255 are reserved for OEM use.
+//
+#define EFI_IO_BUS_UNSPECIFIED (EFI_IO_BUS | 0x00000000)
+#define EFI_IO_BUS_PCI (EFI_IO_BUS | 0x00010000)
+#define EFI_IO_BUS_USB (EFI_IO_BUS | 0x00020000)
+#define EFI_IO_BUS_IBA (EFI_IO_BUS | 0x00030000)
+#define EFI_IO_BUS_AGP (EFI_IO_BUS | 0x00040000)
+#define EFI_IO_BUS_PC_CARD (EFI_IO_BUS | 0x00050000)
+#define EFI_IO_BUS_LPC (EFI_IO_BUS | 0x00060000)
+#define EFI_IO_BUS_SCSI (EFI_IO_BUS | 0x00070000)
+#define EFI_IO_BUS_ATA_ATAPI (EFI_IO_BUS | 0x00080000)
+#define EFI_IO_BUS_FC (EFI_IO_BUS | 0x00090000)
+#define EFI_IO_BUS_IP_NETWORK (EFI_IO_BUS | 0x000A0000)
+#define EFI_IO_BUS_SMBUS (EFI_IO_BUS | 0x000B0000)
+#define EFI_IO_BUS_I2C (EFI_IO_BUS | 0x000C0000)
+
+//
+// IO Bus Class Progress Code definitions.
+// These are shared by all subclasses.
+//
+#define EFI_IOB_PC_INIT 0x00000000
+#define EFI_IOB_PC_RESET 0x00000001
+#define EFI_IOB_PC_DISABLE 0x00000002
+#define EFI_IOB_PC_DETECT 0x00000003
+#define EFI_IOB_PC_ENABLE 0x00000004
+#define EFI_IOB_PC_RECONFIG 0x00000005
+#define EFI_IOB_PC_HOTPLUG 0x00000006
+
+//
+// IO Bus Class Unspecified Subclass Progress Code definitions.
+//
+//
+// IO Bus Class PCI Subclass Progress Code definitions.
+//
+#define EFI_IOB_PCI_PC_BUS_ENUM (EFI_SUBCLASS_SPECIFIC | 0x00000000)
+#define EFI_IOB_PCI_PC_RES_ALLOC (EFI_SUBCLASS_SPECIFIC | 0x00000001)
+#define EFI_IOB_PCI_PC_HPC_INIT (EFI_SUBCLASS_SPECIFIC | 0x00000002)
+
+//
+// IO Bus Class USB Subclass Progress Code definitions.
+//
+//
+// IO Bus Class IBA Subclass Progress Code definitions.
+//
+//
+// IO Bus Class AGP Subclass Progress Code definitions.
+//
+//
+// IO Bus Class PC Card Subclass Progress Code definitions.
+//
+//
+// IO Bus Class LPC Subclass Progress Code definitions.
+//
+//
+// IO Bus Class SCSI Subclass Progress Code definitions.
+//
+//
+// IO Bus Class ATA/ATAPI Subclass Progress Code definitions.
+//
+#define EFI_IOB_ATA_BUS_SMART_ENABLE (EFI_SUBCLASS_SPECIFIC | 0x00000000)
+#define EFI_IOB_ATA_BUS_SMART_DISABLE (EFI_SUBCLASS_SPECIFIC | 0x00000001)
+#define EFI_IOB_ATA_BUS_SMART_OVERTHRESHOLD (EFI_SUBCLASS_SPECIFIC | 0x00000002)
+#define EFI_IOB_ATA_BUS_SMART_UNDERTHRESHOLD (EFI_SUBCLASS_SPECIFIC | 0x00000003)
+
+//
+// IO Bus Class FC Subclass Progress Code definitions.
+//
+//
+// IO Bus Class IP Network Subclass Progress Code definitions.
+//
+//
+// IO Bus Class SMBUS Subclass Progress Code definitions.
+//
+//
+// IO Bus Class I2C Subclass Progress Code definitions.
+//
+//
+// IO Bus Class Error Code definitions.
+// These are shared by all subclasses.
+//
+#define EFI_IOB_EC_NON_SPECIFIC 0x00000000
+#define EFI_IOB_EC_DISABLED 0x00000001
+#define EFI_IOB_EC_NOT_SUPPORTED 0x00000002
+#define EFI_IOB_EC_NOT_DETECTED 0x00000003
+#define EFI_IOB_EC_NOT_CONFIGURED 0x00000004
+#define EFI_IOB_EC_INTERFACE_ERROR 0x00000005
+#define EFI_IOB_EC_CONTROLLER_ERROR 0x00000006
+#define EFI_IOB_EC_READ_ERROR 0x00000007
+#define EFI_IOB_EC_WRITE_ERROR 0x00000008
+#define EFI_IOB_EC_RESOURCE_CONFLICT 0x00000009
+
+//
+// IO Bus Class Unspecified Subclass Error Code definitions.
+//
+//
+// IO Bus Class PCI Subclass Error Code definitions.
+//
+#define EFI_IOB_PCI_EC_PERR (EFI_SUBCLASS_SPECIFIC | 0x00000000)
+#define EFI_IOB_PCI_EC_SERR (EFI_SUBCLASS_SPECIFIC | 0x00000001)
+
+//
+// IO Bus Class USB Subclass Error Code definitions.
+//
+//
+// IO Bus Class IBA Subclass Error Code definitions.
+//
+//
+// IO Bus Class AGP Subclass Error Code definitions.
+//
+//
+// IO Bus Class PC Card Subclass Error Code definitions.
+//
+//
+// IO Bus Class LPC Subclass Error Code definitions.
+//
+//
+// IO Bus Class SCSI Subclass Error Code definitions.
+//
+//
+// IO Bus Class ATA/ATAPI Subclass Error Code definitions.
+//
+#define EFI_IOB_ATA_BUS_SMART_NOTSUPPORTED (EFI_SUBCLASS_SPECIFIC | 0x00000000)
+#define EFI_IOB_ATA_BUS_SMART_DISABLED (EFI_SUBCLASS_SPECIFIC | 0x00000001)
+
+//
+// IO Bus Class FC Subclass Error Code definitions.
+//
+//
+// IO Bus Class IP Network Subclass Error Code definitions.
+//
+//
+// IO Bus Class SMBUS Subclass Error Code definitions.
+//
+//
+// IO Bus Class I2C Subclass Error Code definitions.
+//
+
+///////////////////////////////////////////////////////////////////////////////
+// Section 6
+///////////////////////////////////////////////////////////////////////////////
+//
+// Software Subclass definitions.
+// Values of 20-127 are reserved for future use by this
+// specification.
+// Values of 128-255 are reserved for OEM use.
+//
+#define EFI_SOFTWARE_UNSPECIFIED (EFI_SOFTWARE | 0x00000000)
+#define EFI_SOFTWARE_SEC (EFI_SOFTWARE | 0x00010000)
+#define EFI_SOFTWARE_PEI_CORE (EFI_SOFTWARE | 0x00020000)
+#define EFI_SOFTWARE_PEI_MODULE (EFI_SOFTWARE | 0x00030000)
+#define EFI_SOFTWARE_DXE_CORE (EFI_SOFTWARE | 0x00040000)
+#define EFI_SOFTWARE_DXE_BS_DRIVER (EFI_SOFTWARE | 0x00050000)
+#define EFI_SOFTWARE_DXE_RT_DRIVER (EFI_SOFTWARE | 0x00060000)
+#define EFI_SOFTWARE_SMM_DRIVER (EFI_SOFTWARE | 0x00070000)
+#define EFI_SOFTWARE_EFI_APPLICATION (EFI_SOFTWARE | 0x00080000)
+#define EFI_SOFTWARE_EFI_OS_LOADER (EFI_SOFTWARE | 0x00090000)
+#define EFI_SOFTWARE_RT (EFI_SOFTWARE | 0x000A0000)
+#define EFI_SOFTWARE_AL (EFI_SOFTWARE | 0x000B0000)
+#define EFI_SOFTWARE_EBC_EXCEPTION (EFI_SOFTWARE | 0x000C0000)
+#define EFI_SOFTWARE_IA32_EXCEPTION (EFI_SOFTWARE | 0x000D0000)
+#define EFI_SOFTWARE_IPF_EXCEPTION (EFI_SOFTWARE | 0x000E0000)
+#define EFI_SOFTWARE_PEI_SERVICE (EFI_SOFTWARE | 0x000F0000)
+#define EFI_SOFTWARE_EFI_BOOT_SERVICE (EFI_SOFTWARE | 0x00100000)
+#define EFI_SOFTWARE_EFI_RUNTIME_SERVICE (EFI_SOFTWARE | 0x00110000)
+#define EFI_SOFTWARE_EFI_DXE_SERVICE (EFI_SOFTWARE | 0x00120000)
+#define EFI_SOFTWARE_X64_EXCEPTION (EFI_SOFTWARE | 0x00130000)
+
+//
+// Software Class Progress Code definitions.
+// These are shared by all subclasses.
+//
+#define EFI_SW_PC_INIT 0x00000000
+#define EFI_SW_PC_LOAD 0x00000001
+#define EFI_SW_PC_INIT_BEGIN 0x00000002
+#define EFI_SW_PC_INIT_END 0x00000003
+#define EFI_SW_PC_AUTHENTICATE_BEGIN 0x00000004
+#define EFI_SW_PC_AUTHENTICATE_END 0x00000005
+#define EFI_SW_PC_INPUT_WAIT 0x00000006
+#define EFI_SW_PC_USER_SETUP 0x00000007
+
+//
+// Software Class Unspecified Subclass Progress Code definitions.
+//
+//
+// Software Class SEC Subclass Progress Code definitions.
+//
+#define EFI_SW_SEC_PC_ENTRY_POINT (EFI_SUBCLASS_SPECIFIC | 0x00000000)
+#define EFI_SW_SEC_PC_HANDOFF_TO_NEXT (EFI_SUBCLASS_SPECIFIC | 0x00000001)
+
+//
+// Software Class PEI Core Subclass Progress Code definitions.
+//
+#define EFI_SW_PEI_CORE_PC_ENTRY_POINT (EFI_SUBCLASS_SPECIFIC | 0x00000000)
+#define EFI_SW_PEI_CORE_PC_HANDOFF_TO_NEXT (EFI_SUBCLASS_SPECIFIC | 0x00000001)
+#define EFI_SW_PEI_CORE_PC_RETURN_TO_LAST (EFI_SUBCLASS_SPECIFIC | 0x00000002)
+
+//
+// Software Class PEI Module Subclass Progress Code definitions.
+//
+#define EFI_SW_PEIM_PC_RECOVERY_BEGIN (EFI_SUBCLASS_SPECIFIC | 0x00000000)
+#define EFI_SW_PEIM_PC_CAPSULE_LOAD (EFI_SUBCLASS_SPECIFIC | 0x00000001)
+#define EFI_SW_PEIM_PC_CAPSULE_START (EFI_SUBCLASS_SPECIFIC | 0x00000002)
+#define EFI_SW_PEIM_PC_RECOVERY_USER (EFI_SUBCLASS_SPECIFIC | 0x00000003)
+#define EFI_SW_PEIM_PC_RECOVERY_AUTO (EFI_SUBCLASS_SPECIFIC | 0x00000004)
+
+//
+// Software Class DXE Core Subclass Progress Code definitions.
+//
+#define EFI_SW_DXE_CORE_PC_ENTRY_POINT (EFI_SUBCLASS_SPECIFIC | 0x00000000)
+#define EFI_SW_DXE_CORE_PC_HANDOFF_TO_NEXT (EFI_SUBCLASS_SPECIFIC | 0x00000001)
+#define EFI_SW_DXE_CORE_PC_RETURN_TO_LAST (EFI_SUBCLASS_SPECIFIC | 0x00000002)
+#define EFI_SW_DXE_CORE_PC_START_DRIVER (EFI_SUBCLASS_SPECIFIC | 0x00000003)
+
+//
+// Software Class DXE BS Driver Subclass Progress Code definitions.
+//
+#define EFI_SW_DXE_BS_PC_LEGACY_OPROM_INIT (EFI_SUBCLASS_SPECIFIC | 0x00000000)
+#define EFI_SW_DXE_BS_PC_READY_TO_BOOT_EVENT (EFI_SUBCLASS_SPECIFIC | 0x00000001)
+#define EFI_SW_DXE_BS_PC_LEGACY_BOOT_EVENT (EFI_SUBCLASS_SPECIFIC | 0x00000002)
+#define EFI_SW_DXE_BS_PC_EXIT_BOOT_SERVICES_EVENT (EFI_SUBCLASS_SPECIFIC | 0x00000003)
+#define EFI_SW_DXE_BS_PC_VIRTUAL_ADDRESS_CHANGE_EVENT (EFI_SUBCLASS_SPECIFIC | 0x00000004)
+#define EFI_SW_DXE_BS_PC_BEGIN_CONNECTING_DRIVERS (EFI_SUBCLASS_SPECIFIC | 0x00000005)
+#define EFI_SW_DXE_BS_PC_VERIFYING_PASSWORD (EFI_SUBCLASS_SPECIFIC | 0x00000006)
+
+//
+// Software Class DXE RT Driver Subclass Progress Code definitions.
+//
+#define EFI_SW_DXE_RT_PC_S0 (EFI_SUBCLASS_SPECIFIC | 0x00000000)
+#define EFI_SW_DXE_RT_PC_S1 (EFI_SUBCLASS_SPECIFIC | 0x00000001)
+#define EFI_SW_DXE_RT_PC_S2 (EFI_SUBCLASS_SPECIFIC | 0x00000002)
+#define EFI_SW_DXE_RT_PC_S3 (EFI_SUBCLASS_SPECIFIC | 0x00000003)
+#define EFI_SW_DXE_RT_PC_S4 (EFI_SUBCLASS_SPECIFIC | 0x00000004)
+#define EFI_SW_DXE_RT_PC_S5 (EFI_SUBCLASS_SPECIFIC | 0x00000005)
+
+//
+// Software Class SMM Driver Subclass Progress Code definitions.
+//
+//
+// Software Class EFI Application Subclass Progress Code definitions.
+//
+//
+// Software Class EFI OS Loader Subclass Progress Code definitions.
+//
+//
+// Software Class EFI RT Subclass Progress Code definitions.
+//
+#define EFI_SW_RT_PC_ENTRY_POINT (EFI_SUBCLASS_SPECIFIC | 0x00000000)
+#define EFI_SW_RT_PC_HANDOFF_TO_NEXT (EFI_SUBCLASS_SPECIFIC | 0x00000001)
+#define EFI_SW_RT_PC_RETURN_TO_LAST (EFI_SUBCLASS_SPECIFIC | 0x00000002)
+
+//
+// Software Class EFI AL Subclass Progress Code definitions.
+//
+#define EFI_SW_AL_PC_ENTRY_POINT (EFI_SUBCLASS_SPECIFIC | 0x00000000)
+#define EFI_SW_AL_PC_RETURN_TO_LAST (EFI_SUBCLASS_SPECIFIC | 0x00000001)
+
+//
+// Software Class EBC Exception Subclass Progress Code definitions.
+//
+//
+// Software Class IA32 Exception Subclass Progress Code definitions.
+//
+//
+// Software Class X64 Exception Subclass Progress Code definitions.
+//
+//
+// Software Class IPF Exception Subclass Progress Code definitions.
+//
+//
+// Software Class PEI Services Subclass Progress Code definitions.
+//
+#define EFI_SW_PS_PC_INSTALL_PPI (EFI_SUBCLASS_SPECIFIC | 0x00000000)
+#define EFI_SW_PS_PC_REINSTALL_PPI (EFI_SUBCLASS_SPECIFIC | 0x00000001)
+#define EFI_SW_PS_PC_LOCATE_PPI (EFI_SUBCLASS_SPECIFIC | 0x00000002)
+#define EFI_SW_PS_PC_NOTIFY_PPI (EFI_SUBCLASS_SPECIFIC | 0x00000003)
+#define EFI_SW_PS_PC_GET_BOOT_MODE (EFI_SUBCLASS_SPECIFIC | 0x00000004)
+#define EFI_SW_PS_PC_SET_BOOT_MODE (EFI_SUBCLASS_SPECIFIC | 0x00000005)
+#define EFI_SW_PS_PC_GET_HOB_LIST (EFI_SUBCLASS_SPECIFIC | 0x00000006)
+#define EFI_SW_PS_PC_CREATE_HOB (EFI_SUBCLASS_SPECIFIC | 0x00000007)
+#define EFI_SW_PS_PC_FFS_FIND_NEXT_VOLUME (EFI_SUBCLASS_SPECIFIC | 0x00000008)
+#define EFI_SW_PS_PC_FFS_FIND_NEXT_FILE (EFI_SUBCLASS_SPECIFIC | 0x00000009)
+#define EFI_SW_PS_PC_FFS_FIND_SECTION_DATA (EFI_SUBCLASS_SPECIFIC | 0x0000000A)
+#define EFI_SW_PS_PC_INSTALL_PEI_MEMORY (EFI_SUBCLASS_SPECIFIC | 0x0000000B)
+#define EFI_SW_PS_PC_ALLOCATE_PAGES (EFI_SUBCLASS_SPECIFIC | 0x0000000C)
+#define EFI_SW_PS_PC_ALLOCATE_POOL (EFI_SUBCLASS_SPECIFIC | 0x0000000D)
+#define EFI_SW_PS_PC_COPY_MEM (EFI_SUBCLASS_SPECIFIC | 0x0000000E)
+#define EFI_SW_PS_PC_SET_MEM (EFI_SUBCLASS_SPECIFIC | 0x0000000F)
+
+//
+// Software Class EFI Boot Services Subclass Progress Code definitions.
+//
+#define EFI_SW_BS_PC_RAISE_TPL (EFI_SUBCLASS_SPECIFIC | 0x00000000)
+#define EFI_SW_BS_PC_RESTORE_TPL (EFI_SUBCLASS_SPECIFIC | 0x00000001)
+#define EFI_SW_BS_PC_ALLOCATE_PAGES (EFI_SUBCLASS_SPECIFIC | 0x00000002)
+#define EFI_SW_BS_PC_FREE_PAGES (EFI_SUBCLASS_SPECIFIC | 0x00000003)
+#define EFI_SW_BS_PC_GET_MEMORY_MAP (EFI_SUBCLASS_SPECIFIC | 0x00000004)
+#define EFI_SW_BS_PC_ALLOCATE_POOL (EFI_SUBCLASS_SPECIFIC | 0x00000005)
+#define EFI_SW_BS_PC_FREE_POOL (EFI_SUBCLASS_SPECIFIC | 0x00000006)
+#define EFI_SW_BS_PC_CREATE_EVENT (EFI_SUBCLASS_SPECIFIC | 0x00000007)
+#define EFI_SW_BS_PC_SET_TIMER (EFI_SUBCLASS_SPECIFIC | 0x00000008)
+#define EFI_SW_BS_PC_WAIT_FOR_EVENT (EFI_SUBCLASS_SPECIFIC | 0x00000009)
+#define EFI_SW_BS_PC_SIGNAL_EVENT (EFI_SUBCLASS_SPECIFIC | 0x0000000A)
+#define EFI_SW_BS_PC_CLOSE_EVENT (EFI_SUBCLASS_SPECIFIC | 0x0000000B)
+#define EFI_SW_BS_PC_CHECK_EVENT (EFI_SUBCLASS_SPECIFIC | 0x0000000C)
+#define EFI_SW_BS_PC_INSTALL_PROTOCOL_INTERFACE (EFI_SUBCLASS_SPECIFIC | 0x0000000D)
+#define EFI_SW_BS_PC_REINSTALL_PROTOCOL_INTERFACE (EFI_SUBCLASS_SPECIFIC | 0x0000000E)
+#define EFI_SW_BS_PC_UNINSTALL_PROTOCOL_INTERFACE (EFI_SUBCLASS_SPECIFIC | 0x0000000F)
+#define EFI_SW_BS_PC_HANDLE_PROTOCOL (EFI_SUBCLASS_SPECIFIC | 0x00000010)
+#define EFI_SW_BS_PC_PC_HANDLE_PROTOCOL (EFI_SUBCLASS_SPECIFIC | 0x00000011)
+#define EFI_SW_BS_PC_REGISTER_PROTOCOL_NOTIFY (EFI_SUBCLASS_SPECIFIC | 0x00000012)
+#define EFI_SW_BS_PC_LOCATE_HANDLE (EFI_SUBCLASS_SPECIFIC | 0x00000013)
+#define EFI_SW_BS_PC_INSTALL_CONFIGURATION_TABLE (EFI_SUBCLASS_SPECIFIC | 0x00000014)
+#define EFI_SW_BS_PC_LOAD_IMAGE (EFI_SUBCLASS_SPECIFIC | 0x00000015)
+#define EFI_SW_BS_PC_START_IMAGE (EFI_SUBCLASS_SPECIFIC | 0x00000016)
+#define EFI_SW_BS_PC_EXIT (EFI_SUBCLASS_SPECIFIC | 0x00000017)
+#define EFI_SW_BS_PC_UNLOAD_IMAGE (EFI_SUBCLASS_SPECIFIC | 0x00000018)
+#define EFI_SW_BS_PC_EXIT_BOOT_SERVICES (EFI_SUBCLASS_SPECIFIC | 0x00000019)
+#define EFI_SW_BS_PC_GET_NEXT_MONOTONIC_COUNT (EFI_SUBCLASS_SPECIFIC | 0x0000001A)
+#define EFI_SW_BS_PC_STALL (EFI_SUBCLASS_SPECIFIC | 0x0000001B)
+#define EFI_SW_BS_PC_SET_WATCHDOG_TIMER (EFI_SUBCLASS_SPECIFIC | 0x0000001C)
+#define EFI_SW_BS_PC_CONNECT_CONTROLLER (EFI_SUBCLASS_SPECIFIC | 0x0000001D)
+#define EFI_SW_BS_PC_DISCONNECT_CONTROLLER (EFI_SUBCLASS_SPECIFIC | 0x0000001E)
+#define EFI_SW_BS_PC_OPEN_PROTOCOL (EFI_SUBCLASS_SPECIFIC | 0x0000001F)
+#define EFI_SW_BS_PC_CLOSE_PROTOCOL (EFI_SUBCLASS_SPECIFIC | 0x00000020)
+#define EFI_SW_BS_PC_OPEN_PROTOCOL_INFORMATION (EFI_SUBCLASS_SPECIFIC | 0x00000021)
+#define EFI_SW_BS_PC_PROTOCOLS_PER_HANDLE (EFI_SUBCLASS_SPECIFIC | 0x00000022)
+#define EFI_SW_BS_PC_LOCATE_HANDLE_BUFFER (EFI_SUBCLASS_SPECIFIC | 0x00000023)
+#define EFI_SW_BS_PC_LOCATE_PROTOCOL (EFI_SUBCLASS_SPECIFIC | 0x00000024)
+#define EFI_SW_BS_PC_INSTALL_MULTIPLE_INTERFACES (EFI_SUBCLASS_SPECIFIC | 0x00000025)
+#define EFI_SW_BS_PC_UNINSTALL_MULTIPLE_INTERFACES (EFI_SUBCLASS_SPECIFIC | 0x00000026)
+#define EFI_SW_BS_PC_CALCULATE_CRC_32 (EFI_SUBCLASS_SPECIFIC | 0x00000027)
+#define EFI_SW_BS_PC_COPY_MEM (EFI_SUBCLASS_SPECIFIC | 0x00000028)
+#define EFI_SW_BS_PC_SET_MEM (EFI_SUBCLASS_SPECIFIC | 0x00000029)
+
+//
+// Software Class EFI Runtime Services Subclass Progress Code definitions.
+//
+#define EFI_SW_RS_PC_GET_TIME (EFI_SUBCLASS_SPECIFIC | 0x00000000)
+#define EFI_SW_RS_PC_SET_TIME (EFI_SUBCLASS_SPECIFIC | 0x00000001)
+#define EFI_SW_RS_PC_GET_WAKEUP_TIME (EFI_SUBCLASS_SPECIFIC | 0x00000002)
+#define EFI_SW_RS_PC_SET_WAKEUP_TIME (EFI_SUBCLASS_SPECIFIC | 0x00000003)
+#define EFI_SW_RS_PC_SET_VIRTUAL_ADDRESS_MAP (EFI_SUBCLASS_SPECIFIC | 0x00000004)
+#define EFI_SW_RS_PC_CONVERT_POINTER (EFI_SUBCLASS_SPECIFIC | 0x00000005)
+#define EFI_SW_RS_PC_GET_VARIABLE (EFI_SUBCLASS_SPECIFIC | 0x00000006)
+#define EFI_SW_RS_PC_GET_NEXT_VARIABLE_NAME (EFI_SUBCLASS_SPECIFIC | 0x00000007)
+#define EFI_SW_RS_PC_SET_VARIABLE (EFI_SUBCLASS_SPECIFIC | 0x00000008)
+#define EFI_SW_RS_PC_GET_NEXT_HIGH_MONOTONIC_COUNT (EFI_SUBCLASS_SPECIFIC | 0x00000009)
+#define EFI_SW_RS_PC_RESET_SYSTEM (EFI_SUBCLASS_SPECIFIC | 0x0000000A)
+
+//
+// Software Class EFI DXE Services Subclass Progress Code definitions
+//
+#define EFI_SW_DS_PC_ADD_MEMORY_SPACE (EFI_SUBCLASS_SPECIFIC | 0x00000000)
+#define EFI_SW_DS_PC_ALLOCATE_MEMORY_SPACE (EFI_SUBCLASS_SPECIFIC | 0x00000001)
+#define EFI_SW_DS_PC_FREE_MEMORY_SPACE (EFI_SUBCLASS_SPECIFIC | 0x00000002)
+#define EFI_SW_DS_PC_REMOVE_MEMORY_SPACE (EFI_SUBCLASS_SPECIFIC | 0x00000003)
+#define EFI_SW_DS_PC_GET_MEMORY_SPACE_DESCRIPTOR (EFI_SUBCLASS_SPECIFIC | 0x00000004)
+#define EFI_SW_DS_PC_SET_MEMORY_SPACE_ATTRIBUTES (EFI_SUBCLASS_SPECIFIC | 0x00000005)
+#define EFI_SW_DS_PC_GET_MEMORY_SPACE_MAP (EFI_SUBCLASS_SPECIFIC | 0x00000006)
+#define EFI_SW_DS_PC_ADD_IO_SPACE (EFI_SUBCLASS_SPECIFIC | 0x00000007)
+#define EFI_SW_DS_PC_ALLOCATE_IO_SPACE (EFI_SUBCLASS_SPECIFIC | 0x00000008)
+#define EFI_SW_DS_PC_FREE_IO_SPACE (EFI_SUBCLASS_SPECIFIC | 0x00000009)
+#define EFI_SW_DS_PC_REMOVE_IO_SPACE (EFI_SUBCLASS_SPECIFIC | 0x0000000A)
+#define EFI_SW_DS_PC_GET_IO_SPACE_DESCRIPTOR (EFI_SUBCLASS_SPECIFIC | 0x0000000B)
+#define EFI_SW_DS_PC_GET_IO_SPACE_MAP (EFI_SUBCLASS_SPECIFIC | 0x0000000C)
+#define EFI_SW_DS_PC_DISPATCH (EFI_SUBCLASS_SPECIFIC | 0x0000000D)
+#define EFI_SW_DS_PC_SCHEDULE (EFI_SUBCLASS_SPECIFIC | 0x0000000E)
+#define EFI_SW_DS_PC_TRUST (EFI_SUBCLASS_SPECIFIC | 0x0000000F)
+#define EFI_SW_DS_PC_PROCESS_FIRMWARE_VOLUME (EFI_SUBCLASS_SPECIFIC | 0x00000010)
+
+//
+// Software Class Error Code definitions.
+// These are shared by all subclasses.
+//
+#define EFI_SW_EC_NON_SPECIFIC 0x00000000
+#define EFI_SW_EC_LOAD_ERROR 0x00000001
+#define EFI_SW_EC_INVALID_PARAMETER 0x00000002
+#define EFI_SW_EC_UNSUPPORTED 0x00000003
+#define EFI_SW_EC_INVALID_BUFFER 0x00000004
+#define EFI_SW_EC_OUT_OF_RESOURCES 0x00000005
+#define EFI_SW_EC_ABORTED 0x00000006
+#define EFI_SW_EC_ILLEGAL_SOFTWARE_STATE 0x00000007
+#define EFI_SW_EC_ILLEGAL_HARDWARE_STATE 0x00000008
+#define EFI_SW_EC_START_ERROR 0x00000009
+#define EFI_SW_EC_BAD_DATE_TIME 0x0000000A
+#define EFI_SW_EC_CFG_INVALID 0x0000000B
+#define EFI_SW_EC_CFG_CLR_REQUEST 0x0000000C
+#define EFI_SW_EC_CFG_DEFAULT 0x0000000D
+#define EFI_SW_EC_PWD_INVALID 0x0000000E
+#define EFI_SW_EC_PWD_CLR_REQUEST 0x0000000F
+#define EFI_SW_EC_PWD_CLEARED 0x00000010
+#define EFI_SW_EC_EVENT_LOG_FULL 0x00000011
+
+//
+// Software Class Unspecified Subclass Error Code definitions.
+//
+//
+// Software Class SEC Subclass Error Code definitions.
+//
+//
+// Software Class PEI Core Subclass Error Code definitions.
+//
+#define EFI_SW_PEI_CORE_EC_DXE_CORRUPT (EFI_SUBCLASS_SPECIFIC | 0x00000000)
+
+//
+// Software Class PEI Module Subclass Error Code definitions.
+//
+#define EFI_SW_PEIM_EC_NO_RECOVERY_CAPSULE (EFI_SUBCLASS_SPECIFIC | 0x00000000)
+#define EFI_SW_PEIM_EC_INVALID_CAPSULE_DESCRIPTOR (EFI_SUBCLASS_SPECIFIC | 0x00000001)
+
+//
+// Software Class DXE Core Subclass Error Code definitions.
+//
+#define EFI_SW_CSM_LEGACY_ROM_INIT (EFI_SUBCLASS_SPECIFIC | 0x00000000)
+//
+// Software Class DXE Boot Service Driver Subclass Error Code definitions.
+//
+#define EFI_SW_DXE_BS_EC_LEGACY_OPROM_NO_SPACE (EFI_SUBCLASS_SPECIFIC | 0x00000000)
+
+//
+// Software Class DXE Runtime Service Driver Subclass Error Code definitions.
+//
+//
+// Software Class SMM Driver Subclass Error Code definitions.
+//
+//
+// Software Class EFI Application Subclass Error Code definitions.
+//
+//
+// Software Class EFI OS Loader Subclass Error Code definitions.
+//
+//
+// Software Class EFI RT Subclass Error Code definitions.
+//
+//
+// Software Class EFI AL Subclass Error Code definitions.
+//
+//
+// Software Class EBC Exception Subclass Error Code definitions.
+// These exceptions are derived from the debug protocol definitions in the EFI
+// specification.
+//
+#define EFI_SW_EC_EBC_UNDEFINED (EFI_SUBCLASS_SPECIFIC | EXCEPT_EBC_UNDEFINED)
+#define EFI_SW_EC_EBC_DIVIDE_ERROR (EFI_SUBCLASS_SPECIFIC | EXCEPT_EBC_DIVIDE_ERROR)
+#define EFI_SW_EC_EBC_DEBUG (EFI_SUBCLASS_SPECIFIC | EXCEPT_EBC_DEBUG)
+#define EFI_SW_EC_EBC_BREAKPOINT (EFI_SUBCLASS_SPECIFIC | EXCEPT_EBC_BREAKPOINT)
+#define EFI_SW_EC_EBC_OVERFLOW (EFI_SUBCLASS_SPECIFIC | EXCEPT_EBC_OVERFLOW)
+#define EFI_SW_EC_EBC_INVALID_OPCODE (EFI_SUBCLASS_SPECIFIC | EXCEPT_EBC_INVALID_OPCODE)
+#define EFI_SW_EC_EBC_STACK_FAULT (EFI_SUBCLASS_SPECIFIC | EXCEPT_EBC_STACK_FAULT)
+#define EFI_SW_EC_EBC_ALIGNMENT_CHECK (EFI_SUBCLASS_SPECIFIC | EXCEPT_EBC_ALIGNMENT_CHECK)
+#define EFI_SW_EC_EBC_INSTRUCTION_ENCODING (EFI_SUBCLASS_SPECIFIC | EXCEPT_EBC_INSTRUCTION_ENCODING)
+#define EFI_SW_EC_EBC_BAD_BREAK (EFI_SUBCLASS_SPECIFIC | EXCEPT_EBC_BAD_BREAK)
+#define EFI_SW_EC_EBC_STEP (EFI_SUBCLASS_SPECIFIC | EXCEPT_EBC_STEP)
+
+//
+// Software Class IA32 Exception Subclass Error Code definitions.
+// These exceptions are derived from the debug protocol definitions in the EFI
+// specification.
+//
+#define EFI_SW_EC_IA32_DIVIDE_ERROR (EFI_SUBCLASS_SPECIFIC | EXCEPT_IA32_DIVIDE_ERROR)
+#define EFI_SW_EC_IA32_DEBUG (EFI_SUBCLASS_SPECIFIC | EXCEPT_IA32_DEBUG)
+#define EFI_SW_EC_IA32_NMI (EFI_SUBCLASS_SPECIFIC | EXCEPT_IA32_NMI)
+#define EFI_SW_EC_IA32_BREAKPOINT (EFI_SUBCLASS_SPECIFIC | EXCEPT_IA32_BREAKPOINT)
+#define EFI_SW_EC_IA32_OVERFLOW (EFI_SUBCLASS_SPECIFIC | EXCEPT_IA32_OVERFLOW)
+#define EFI_SW_EC_IA32_BOUND (EFI_SUBCLASS_SPECIFIC | EXCEPT_IA32_BOUND)
+#define EFI_SW_EC_IA32_INVALID_OPCODE (EFI_SUBCLASS_SPECIFIC | EXCEPT_IA32_INVALID_OPCODE)
+#define EFI_SW_EC_IA32_DOUBLE_FAULT (EFI_SUBCLASS_SPECIFIC | EXCEPT_IA32_DOUBLE_FAULT)
+#define EFI_SW_EC_IA32_INVALID_TSS (EFI_SUBCLASS_SPECIFIC | EXCEPT_IA32_INVALID_TSS)
+#define EFI_SW_EC_IA32_SEG_NOT_PRESENT (EFI_SUBCLASS_SPECIFIC | EXCEPT_IA32_SEG_NOT_PRESENT)
+#define EFI_SW_EC_IA32_STACK_FAULT (EFI_SUBCLASS_SPECIFIC | EXCEPT_IA32_STACK_FAULT)
+#define EFI_SW_EC_IA32_GP_FAULT (EFI_SUBCLASS_SPECIFIC | EXCEPT_IA32_GP_FAULT)
+#define EFI_SW_EC_IA32_PAGE_FAULT (EFI_SUBCLASS_SPECIFIC | EXCEPT_IA32_PAGE_FAULT)
+#define EFI_SW_EC_IA32_FP_ERROR (EFI_SUBCLASS_SPECIFIC | EXCEPT_IA32_FP_ERROR)
+#define EFI_SW_EC_IA32_ALIGNMENT_CHECK (EFI_SUBCLASS_SPECIFIC | EXCEPT_IA32_ALIGNMENT_CHECK)
+#define EFI_SW_EC_IA32_MACHINE_CHECK (EFI_SUBCLASS_SPECIFIC | EXCEPT_IA32_MACHINE_CHECK)
+#define EFI_SW_EC_IA32_SIMD (EFI_SUBCLASS_SPECIFIC | EXCEPT_IA32_SIMD)
+
+//
+// Software Class X64 Exception Subclass Error Code definitions.
+// These exceptions are derived from the debug protocol definitions in the EFI
+// specification.
+//
+#define EFI_SW_EC_X64_DIVIDE_ERROR (EFI_SUBCLASS_SPECIFIC | EXCEPT_X64_DIVIDE_ERROR)
+#define EFI_SW_EC_X64_DEBUG (EFI_SUBCLASS_SPECIFIC | EXCEPT_X64_DEBUG)
+#define EFI_SW_EC_X64_NMI (EFI_SUBCLASS_SPECIFIC | EXCEPT_X64_NMI)
+#define EFI_SW_EC_X64_BREAKPOINT (EFI_SUBCLASS_SPECIFIC | EXCEPT_X64_BREAKPOINT)
+#define EFI_SW_EC_X64_OVERFLOW (EFI_SUBCLASS_SPECIFIC | EXCEPT_X64_OVERFLOW)
+#define EFI_SW_EC_X64_BOUND (EFI_SUBCLASS_SPECIFIC | EXCEPT_X64_BOUND)
+#define EFI_SW_EC_X64_INVALID_OPCODE (EFI_SUBCLASS_SPECIFIC | EXCEPT_X64_INVALID_OPCODE)
+#define EFI_SW_EC_X64_DOUBLE_FAULT (EFI_SUBCLASS_SPECIFIC | EXCEPT_X64_DOUBLE_FAULT)
+#define EFI_SW_EC_X64_INVALID_TSS (EFI_SUBCLASS_SPECIFIC | EXCEPT_X64_INVALID_TSS)
+#define EFI_SW_EC_X64_SEG_NOT_PRESENT (EFI_SUBCLASS_SPECIFIC | EXCEPT_X64_SEG_NOT_PRESENT)
+#define EFI_SW_EC_X64_STACK_FAULT (EFI_SUBCLASS_SPECIFIC | EXCEPT_X64_STACK_FAULT)
+#define EFI_SW_EC_X64_GP_FAULT (EFI_SUBCLASS_SPECIFIC | EXCEPT_X64_GP_FAULT)
+#define EFI_SW_EC_X64_PAGE_FAULT (EFI_SUBCLASS_SPECIFIC | EXCEPT_X64_PAGE_FAULT)
+#define EFI_SW_EC_X64_FP_ERROR (EFI_SUBCLASS_SPECIFIC | EXCEPT_X64_FP_ERROR)
+#define EFI_SW_EC_X64_ALIGNMENT_CHECK (EFI_SUBCLASS_SPECIFIC | EXCEPT_X64_ALIGNMENT_CHECK)
+#define EFI_SW_EC_X64_MACHINE_CHECK (EFI_SUBCLASS_SPECIFIC | EXCEPT_X64_MACHINE_CHECK)
+#define EFI_SW_EC_X64_SIMD (EFI_SUBCLASS_SPECIFIC | EXCEPT_X64_SIMD)
+
+//
+// Software Class IPF Exception Subclass Error Code definitions.
+// These exceptions are derived from the debug protocol definitions in the EFI
+// specification.
+//
+#define EFI_SW_EC_IPF_ALT_DTLB (EFI_SUBCLASS_SPECIFIC | EXCEPT_IPF_ALT_DTLB)
+#define EFI_SW_EC_IPF_DNESTED_TLB (EFI_SUBCLASS_SPECIFIC | EXCEPT_IPF_DNESTED_TLB)
+#define EFI_SW_EC_IPF_BREAKPOINT (EFI_SUBCLASS_SPECIFIC | EXCEPT_IPF_BREAKPOINT)
+#define EFI_SW_EC_IPF_EXTERNAL_INTERRUPT (EFI_SUBCLASS_SPECIFIC | EXCEPT_IPF_EXTERNAL_INTERRUPT)
+#define EFI_SW_EC_IPF_GEN_EXCEPT (EFI_SUBCLASS_SPECIFIC | EXCEPT_IPF_GEN_EXCEPT)
+#define EFI_SW_EC_IPF_NAT_CONSUMPTION (EFI_SUBCLASS_SPECIFIC | EXCEPT_IPF_NAT_CONSUMPTION)
+#define EFI_SW_EC_IPF_DEBUG_EXCEPT (EFI_SUBCLASS_SPECIFIC | EXCEPT_IPF_DEBUG_EXCEPT)
+#define EFI_SW_EC_IPF_UNALIGNED_ACCESS (EFI_SUBCLASS_SPECIFIC | EXCEPT_IPF_UNALIGNED_ACCESS)
+#define EFI_SW_EC_IPF_FP_FAULT (EFI_SUBCLASS_SPECIFIC | EXCEPT_IPF_FP_FAULT)
+#define EFI_SW_EC_IPF_FP_TRAP (EFI_SUBCLASS_SPECIFIC | EXCEPT_IPF_FP_TRAP)
+#define EFI_SW_EC_IPF_TAKEN_BRANCH (EFI_SUBCLASS_SPECIFIC | EXCEPT_IPF_TAKEN_BRANCH)
+#define EFI_SW_EC_IPF_SINGLE_STEP (EFI_SUBCLASS_SPECIFIC | EXCEPT_IPF_SINGLE_STEP)
+
+//
+// Software Class PEI Service Subclass Error Code definitions.
+//
+//
+// Software Class EFI Boot Service Subclass Error Code definitions.
+//
+//
+// Software Class EFI Runtime Service Subclass Error Code definitions.
+//
+//
+// Software Class EFI DXE Service Subclass Error Code definitions.
+//
+
+///////////////////////////////////////////////////////////////////////////////
+// Section 7
+///////////////////////////////////////////////////////////////////////////////
+//
+// Debug Code definitions for all classes and subclass
+// Only one debug code is defined at this point and should
+// be used for anything that gets sent to debug stream.
+//
+#define EFI_DC_UNSPECIFIED 0x0
+
+//
+// Progress code for S3 suspend start and S3 suspend end is not defined,
+// the following are the implementation specific definition.
+//
+#define PROGRESS_CODE_S3_SUSPEND_START (EFI_SOFTWARE_SMM_DRIVER | (EFI_OEM_SPECIFIC | 0x00000000))
+#define PROGRESS_CODE_S3_SUSPEND_END (EFI_SOFTWARE_SMM_DRIVER | (EFI_OEM_SPECIFIC | 0x00000001))
+
+#endif
diff --git a/EDK/Foundation/Framework/Include/EfiVariable.h b/EDK/Foundation/Framework/Include/EfiVariable.h
new file mode 100644
index 0000000..6879f60
--- /dev/null
+++ b/EDK/Foundation/Framework/Include/EfiVariable.h
@@ -0,0 +1,34 @@
+/*++
+
+Copyright (c) 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiVariable.h
+
+Abstract:
+
+
+
+--*/
+
+#ifndef _EFI_VARIABLE_DEFINITION_H_
+#define _EFI_VARIABLE_DEFINITION_H_
+
+//
+// Variable attributes
+//
+#define EFI_VARIABLE_NON_VOLATILE 0x00000001
+#define EFI_VARIABLE_BOOTSERVICE_ACCESS 0x00000002
+#define EFI_VARIABLE_RUNTIME_ACCESS 0x00000004
+#define EFI_VARIABLE_READ_ONLY 0x00000008
+
+
+#endif
diff --git a/EDK/Foundation/Framework/Include/PeiApi.h b/EDK/Foundation/Framework/Include/PeiApi.h
new file mode 100644
index 0000000..f21b6da
--- /dev/null
+++ b/EDK/Foundation/Framework/Include/PeiApi.h
@@ -0,0 +1,632 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PeiApi.h
+
+Abstract:
+
+ Tiano PEI intrinsic definitions. This includes all Pei Services APIs.
+
+ Peims are passed in a pointer to a pointer to the PEI Services table.
+ The PEI Services table contains pointers to the PEI services exported
+ by the PEI Core.
+
+--*/
+
+#ifndef _PEI_API_H_
+#define _PEI_API_H_
+
+#include "PeiHob.h"
+#include "EfiFirmwareFileSystem.h"
+#include "EfiFirmwareVolumeHeader.h"
+#include EFI_PPI_DEFINITION (FirmwareVolumeInfo) //;;## ...AMI_OVERRIDE... Support PI1.x
+#include EFI_PPI_DEFINITION (FirmwareVolume) //;;## ...AMI_OVERRIDE... Support PI1.x
+#include EFI_PPI_DEFINITION (Decompress) //;;## ...AMI_OVERRIDE... Support PI1.x
+
+
+//
+// Declare forward referenced data structures
+//
+EFI_FORWARD_DECLARATION (EFI_PEI_NOTIFY_DESCRIPTOR);
+EFI_FORWARD_DECLARATION (EFI_PEI_SERVICES);
+
+#include EFI_PPI_DEFINITION (CpuIo)
+#include EFI_PPI_DEFINITION (PciCfg)
+#include EFI_PPI_DEFINITION (PciCfg2)
+#include EFI_PPI_DEFINITION (EcpPciCfg)
+
+//
+// PEI Specification Revision information
+//
+//;;## ...AMI_OVERRIDE... Support PI1.x
+#if (PI_SPECIFICATION_VERSION < 0x00010000)
+#define PEI_SPECIFICATION_MAJOR_REVISION 0
+#define PEI_SPECIFICATION_MINOR_REVISION 91
+#else
+#define PEI_SPECIFICATION_MAJOR_REVISION 1
+#define PEI_SPECIFICATION_MINOR_REVISION 00
+#endif
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEIM_ENTRY_POINT)(IN EFI_FFS_FILE_HEADER * FfsHeader,
+ IN EFI_PEI_SERVICES **PeiServices
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEIM_NOTIFY_ENTRY_POINT) (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PEI_NOTIFY_DESCRIPTOR * NotifyDescriptor,
+ IN VOID *Ppi
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_VERIFICATION) (
+ IN UINTN SectionAddress
+ );
+
+//
+// PEI Ppi Services List Descriptors
+//
+#define EFI_PEI_PPI_DESCRIPTOR_PIC 0x00000001
+#define EFI_PEI_PPI_DESCRIPTOR_PPI 0x00000010
+#define EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK 0x00000020
+#define EFI_PEI_PPI_DESCRIPTOR_NOTIFY_DISPATCH 0x00000040
+#define EFI_PEI_PPI_DESCRIPTOR_NOTIFY_TYPES 0x00000060
+#define EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST 0x80000000
+
+typedef struct {
+ UINTN Flags;
+ EFI_GUID *Guid;
+ VOID *Ppi;
+} EFI_PEI_PPI_DESCRIPTOR;
+
+typedef struct _EFI_PEI_NOTIFY_DESCRIPTOR {
+ UINTN Flags;
+ EFI_GUID *Guid;
+ EFI_PEIM_NOTIFY_ENTRY_POINT Notify;
+} EFI_PEI_NOTIFY_DESCRIPTOR;
+
+//;;## ...AMI_OVERRIDE... Support PI1.x
+#if (PI_SPECIFICATION_VERSION < 0x00010000)
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_INSTALL_PPI) (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PEI_PPI_DESCRIPTOR * PpiList
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_REINSTALL_PPI) (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PEI_PPI_DESCRIPTOR * OldPpi,
+ IN EFI_PEI_PPI_DESCRIPTOR * NewPpi
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_LOCATE_PPI) (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_GUID * Guid,
+ IN UINTN Instance,
+ IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor,
+ IN OUT VOID **Ppi
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_NOTIFY_PPI) (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PEI_NOTIFY_DESCRIPTOR * NotifyList
+ );
+
+//
+// EFI PEI Boot Mode Services
+//
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_GET_BOOT_MODE) (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN OUT EFI_BOOT_MODE * BootMode
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_SET_BOOT_MODE) (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_BOOT_MODE BootMode
+ );
+
+//
+// PEI HOB Services
+//
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_GET_HOB_LIST) (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN OUT VOID **HobList
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_CREATE_HOB) (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN UINT16 Type,
+ IN UINT16 Length,
+ IN OUT VOID **Hob
+ );
+
+//
+// FFS Fw Volume support functions
+//
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_FFS_FIND_NEXT_VOLUME) (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN UINTN Instance,
+ IN OUT EFI_FIRMWARE_VOLUME_HEADER **FwVolHeader
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_FFS_FIND_NEXT_FILE) (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_FV_FILETYPE SearchType,
+ IN EFI_FIRMWARE_VOLUME_HEADER * FwVolHeader,
+ IN OUT EFI_FFS_FILE_HEADER **FileHeader
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_FFS_FIND_SECTION_DATA) (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_SECTION_TYPE SectionType,
+ IN EFI_FFS_FILE_HEADER * FfsFileHeader,
+ IN OUT VOID **SectionData
+ );
+
+//
+// Memory Services
+//
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_INSTALL_PEI_MEMORY) (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PHYSICAL_ADDRESS MemoryBegin,
+ IN UINT64 MemoryLength
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_ALLOCATE_PAGES) (
+
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_MEMORY_TYPE MemoryType,
+ IN UINTN Pages,
+ IN OUT EFI_PHYSICAL_ADDRESS * Memory
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_ALLOCATE_POOL) (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN UINTN Size,
+ OUT VOID **Buffer
+ );
+
+typedef
+VOID
+(EFIAPI *EFI_PEI_COPY_MEM) (
+ IN VOID *Destination,
+ IN VOID *Source,
+ IN UINTN Length
+ );
+
+typedef
+VOID
+(EFIAPI *EFI_PEI_SET_MEM) (
+ IN VOID *Buffer,
+ IN UINTN Size,
+ IN UINT8 Value
+ );
+
+//
+// Status Code
+//
+//
+// Definition of Status Code extended data header
+//
+// HeaderSize The size of the architecture. This is specified to enable
+// the future expansion
+//
+// Size The size of the data in bytes. This does not include the size
+// of the header structure.
+//
+// Type A GUID defining the type of the data
+//
+//
+typedef
+EFI_STATUS
+(EFIAPI *EFI_REPORT_STATUS_CODE) (
+ IN EFI_STATUS_CODE_TYPE Type,
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN UINT32 Instance,
+ IN EFI_GUID * CallerId OPTIONAL,
+ IN EFI_STATUS_CODE_DATA * Data OPTIONAL
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_REPORT_STATUS_CODE) (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_STATUS_CODE_TYPE Type,
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN UINT32 Instance,
+ IN EFI_GUID * CallerId OPTIONAL,
+ IN EFI_STATUS_CODE_DATA * Data OPTIONAL
+ );
+
+//
+// PEI Reset
+//
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_RESET_SYSTEM) (
+ IN EFI_PEI_SERVICES **PeiServices
+ );
+
+
+
+#else
+
+//
+// PEI PPI Services
+//
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_INSTALL_PPI) (
+ IN CONST EFI_PEI_SERVICES **PeiServices,
+ IN CONST EFI_PEI_PPI_DESCRIPTOR * PpiList
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_REINSTALL_PPI) (
+ IN CONST EFI_PEI_SERVICES **PeiServices,
+ IN CONST EFI_PEI_PPI_DESCRIPTOR * OldPpi,
+ IN CONST EFI_PEI_PPI_DESCRIPTOR * NewPpi
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_LOCATE_PPI) (
+ IN CONST EFI_PEI_SERVICES **PeiServices,
+ IN CONST EFI_GUID * Guid,
+ IN UINTN Instance,
+ IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor OPTIONAL,
+ IN OUT VOID **Ppi
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_NOTIFY_PPI) (
+ IN CONST EFI_PEI_SERVICES **PeiServices,
+ IN CONST EFI_PEI_NOTIFY_DESCRIPTOR * NotifyList
+ );
+
+//
+// PEI Boot Mode Services
+//
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_GET_BOOT_MODE) (
+ IN CONST EFI_PEI_SERVICES **PeiServices,
+ IN OUT EFI_BOOT_MODE * BootMode
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_SET_BOOT_MODE) (
+ IN CONST EFI_PEI_SERVICES **PeiServices,
+ IN EFI_BOOT_MODE BootMode
+ );
+
+//
+// PEI HOB Services
+//
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_GET_HOB_LIST) (
+ IN CONST EFI_PEI_SERVICES **PeiServices,
+ IN OUT VOID **HobList
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_CREATE_HOB) (
+ IN CONST EFI_PEI_SERVICES **PeiServices,
+ IN UINT16 Type,
+ IN UINT16 Length,
+ IN OUT VOID **Hob
+ );
+
+
+
+ //
+ // PEI Firmware Volume Services
+ //
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_FFS_FIND_NEXT_VOLUME2) (
+ IN CONST EFI_PEI_SERVICES **PeiServices,
+ IN UINTN Instance,
+ IN OUT EFI_PEI_FV_HANDLE *VolumeHandle
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_FFS_FIND_NEXT_FILE2) (
+ IN CONST EFI_PEI_SERVICES **PeiServices,
+ IN EFI_FV_FILETYPE SearchType,
+ IN CONST EFI_PEI_FV_HANDLE FvHandle,
+ IN OUT EFI_PEI_FILE_HANDLE *FileHandle
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_FFS_FIND_SECTION_DATA2) (
+ IN CONST EFI_PEI_SERVICES **PeiServices,
+ IN EFI_SECTION_TYPE SectionType,
+ IN EFI_PEI_FILE_HANDLE FileHandle,
+ OUT VOID **SectionData
+ );
+
+
+ //
+ // PEI Memory Services
+ //
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_INSTALL_PEI_MEMORY) (
+ IN CONST EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PHYSICAL_ADDRESS MemoryBegin,
+ IN UINT64 MemoryLength
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_ALLOCATE_PAGES) (
+
+ IN CONST EFI_PEI_SERVICES **PeiServices,
+ IN EFI_MEMORY_TYPE MemoryType,
+ IN UINTN Pages,
+ IN OUT EFI_PHYSICAL_ADDRESS * Memory
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_ALLOCATE_POOL) (
+ IN CONST EFI_PEI_SERVICES **PeiServices,
+ IN UINTN Size,
+ OUT VOID **Buffer
+ );
+
+typedef
+VOID
+(EFIAPI *EFI_PEI_COPY_MEM) (
+ IN VOID *Destination,
+ IN VOID *Source,
+ IN UINTN Length
+ );
+
+typedef
+VOID
+(EFIAPI *EFI_PEI_SET_MEM) (
+ IN VOID *Buffer,
+ IN UINTN Size,
+ IN UINT8 Value
+ );
+
+ //
+ // New interfaceas added by the PI 1.0
+ //
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_FFS_FIND_BY_NAME) (
+ IN CONST EFI_GUID *FileName,
+ IN EFI_PEI_FV_HANDLE VolumeHandle,
+ OUT EFI_PEI_FILE_HANDLE *FileHandle
+ );
+
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_FFS_GET_FILE_INFO) (
+ IN EFI_PEI_FILE_HANDLE FileHandle,
+ OUT EFI_FV_FILE_INFO *FileInfo
+ );
+
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_FFS_GET_VOLUME_INFO) (
+ IN EFI_PEI_FV_HANDLE VolumeHandle,
+ OUT EFI_FV_INFO *VolumeInfo
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_REGISTER_FOR_SHADOW) (
+ IN EFI_PEI_FILE_HANDLE FileHandle
+ );
+
+//
+// PEI Status Code Service
+//
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_REPORT_STATUS_CODE) (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_STATUS_CODE_TYPE Type,
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN UINT32 Instance,
+ IN EFI_GUID *CallerId OPTIONAL,
+ IN EFI_STATUS_CODE_DATA *Data OPTIONAL
+ );
+
+//
+// PEI Reset Service
+//
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_RESET_SYSTEM) (
+ IN EFI_PEI_SERVICES **PeiServices
+ );
+
+#endif
+
+
+//
+// EFI PEI Services Table
+//
+#define PEI_SERVICES_SIGNATURE 0x5652455320494550
+#define PEI_SERVICES_REVISION ((PEI_SPECIFICATION_MAJOR_REVISION << 16) | (PEI_SPECIFICATION_MINOR_REVISION))
+typedef PEI_CPU_IO_PPI EFI_PEI_CPU_IO_PPI; //;;## ...AMI_OVERRIDE... Support PI1.x
+
+typedef struct _EFI_PEI_SERVICES {
+ EFI_TABLE_HEADER Hdr;
+
+ //
+ // PPI Functions
+ //
+ EFI_PEI_INSTALL_PPI InstallPpi;
+ EFI_PEI_REINSTALL_PPI ReInstallPpi;
+ EFI_PEI_LOCATE_PPI LocatePpi;
+ EFI_PEI_NOTIFY_PPI NotifyPpi;
+
+ //
+ // Boot Mode Functions
+ //
+ EFI_PEI_GET_BOOT_MODE GetBootMode;
+ EFI_PEI_SET_BOOT_MODE SetBootMode;
+
+ //
+ // HOB Functions
+ //
+ EFI_PEI_GET_HOB_LIST GetHobList;
+ EFI_PEI_CREATE_HOB CreateHob;
+
+ //
+ // Filesystem Functions
+ //
+//;;## ...AMI_OVERRIDE... Support PI1.x
+#if (PI_SPECIFICATION_VERSION < 0x00010000)
+ EFI_PEI_FFS_FIND_NEXT_VOLUME FfsFindNextVolume;
+ EFI_PEI_FFS_FIND_NEXT_FILE FfsFindNextFile;
+ EFI_PEI_FFS_FIND_SECTION_DATA FfsFindSectionData;
+#else
+ EFI_PEI_FFS_FIND_NEXT_VOLUME2 FfsFindNextVolume;
+ EFI_PEI_FFS_FIND_NEXT_FILE2 FfsFindNextFile;
+ EFI_PEI_FFS_FIND_SECTION_DATA2 FfsFindSectionData;
+#endif
+ //
+ // Memory Functions
+ //
+ EFI_PEI_INSTALL_PEI_MEMORY InstallPeiMemory;
+ EFI_PEI_ALLOCATE_PAGES AllocatePages;
+ EFI_PEI_ALLOCATE_POOL AllocatePool;
+ EFI_PEI_COPY_MEM CopyMem;
+ EFI_PEI_SET_MEM SetMem;
+
+ //
+ // Status Code
+ //
+ EFI_PEI_REPORT_STATUS_CODE PeiReportStatusCode;
+
+ //
+ // Reset
+ //
+ EFI_PEI_RESET_SYSTEM PeiResetSystem;
+
+ //
+ // Pointer to PPI interface
+ //
+//;;## ...AMI_OVERRIDE... Support PI1.x start
+#if (PI_SPECIFICATION_VERSION < 0x00010000)
+
+ PEI_CPU_IO_PPI *CpuIo;
+#if defined (SUPPORT_DEPRECATED_PCI_CFG_PPI)
+ PEI_PCI_CFG_PPI *PciCfg;
+#else
+ ECP_PEI_PCI_CFG_PPI *PciCfg;
+#endif
+#else
+ EFI_PEI_CPU_IO_PPI *CpuIo;
+#if defined (SUPPORT_DEPRECATED_PCI_CFG_PPI)
+ EFI_PEI_PCI_CFG2_PPI *PciCfg;
+#else
+ ECP_PEI_PCI_CFG_PPI *PciCfg;
+#endif
+ //
+ // New interfaceas added by the PI 1.0
+ //
+ EFI_PEI_FFS_FIND_BY_NAME FfsFindFileByName;
+ EFI_PEI_FFS_GET_FILE_INFO FfsGetFileInfo;
+ EFI_PEI_FFS_GET_VOLUME_INFO FfsGetVolumeInfo;
+ EFI_PEI_REGISTER_FOR_SHADOW RegisterForShadow;
+#endif
+//;;## ...AMI_OVERRIDE... Support PI1.x end
+} EFI_PEI_SERVICES;
+
+//;;## ...AMI_OVERRIDE... Support PI1.x
+#if (PI_SPECIFICATION_VERSION < 0x00010000)
+
+typedef struct {
+ UINTN BootFirmwareVolume;
+ UINTN SizeOfCacheAsRam;
+ EFI_PEI_PPI_DESCRIPTOR *DispatchTable;
+} EFI_PEI_STARTUP_DESCRIPTOR;
+
+typedef
+EFI_STATUS
+(EFIAPI *PEI_MAIN_ENTRY_POINT) (
+ IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartupDescriptor
+ );
+
+#else
+
+typedef struct _EFI_SEC_PEI_HAND_OFF{
+ UINT16 DataSize;
+ VOID *BootFirmwareVolumeBase;
+ UINTN BootFirmwareVolumeSize;
+ VOID *TemporaryRamBase;
+ UINTN TemporaryRamSize;
+ VOID *PeiTemporaryRamBase;
+ UINTN PeiTemporaryRamSize;
+ VOID *StackBase;
+ UINTN StackSize;
+}EFI_SEC_PEI_HAND_OFF;
+
+typedef
+EFI_STATUS
+(EFIAPI *PEI_MAIN_ENTRY_POINT) (
+ IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData,
+ IN CONST EFI_PEI_PPI_DESCRIPTOR *PpList
+ );
+
+#endif
+
+#endif
diff --git a/EDK/Foundation/Framework/Include/PeiHob.h b/EDK/Foundation/Framework/Include/PeiHob.h
new file mode 100644
index 0000000..a11709b
--- /dev/null
+++ b/EDK/Foundation/Framework/Include/PeiHob.h
@@ -0,0 +1,253 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PeiHob.h
+
+Abstract:
+
+ PEI Hand Off Block (HOB) definition.
+
+ The HOB is a memory data structure used to hand-off system information from
+ PEI to DXE (the next phase).
+
+--*/
+
+#ifndef _PEI_HOB_H_
+#define _PEI_HOB_H_
+
+#include "BootMode.h"
+
+//
+// Every Hob must start with this data structure.
+//
+typedef struct {
+ UINT16 HobType;
+ UINT16 HobLength;
+ UINT32 Reserved;
+} EFI_HOB_GENERIC_HEADER;
+
+//
+// End of HOB List HOB
+//
+#define EFI_HOB_TYPE_END_OF_HOB_LIST 0xffff
+
+//
+// Handoff Information Table HOB
+//
+#define EFI_HOB_TYPE_HANDOFF 0x0001
+
+#define EFI_HOB_HANDOFF_TABLE_VERSION 0x0009
+
+typedef UINT32 EFI_BOOT_MODE;
+
+typedef struct {
+ EFI_HOB_GENERIC_HEADER Header;
+ UINT32 Version;
+ EFI_BOOT_MODE BootMode;
+ EFI_PHYSICAL_ADDRESS EfiMemoryTop;
+ EFI_PHYSICAL_ADDRESS EfiMemoryBottom;
+ EFI_PHYSICAL_ADDRESS EfiFreeMemoryTop;
+ EFI_PHYSICAL_ADDRESS EfiFreeMemoryBottom;
+ EFI_PHYSICAL_ADDRESS EfiEndOfHobList;
+} EFI_HOB_HANDOFF_INFO_TABLE;
+
+//
+// Memory Descriptor HOB
+//
+#define EFI_HOB_TYPE_MEMORY_ALLOCATION 0x0002
+
+typedef struct {
+ EFI_GUID Name;
+ EFI_PHYSICAL_ADDRESS MemoryBaseAddress;
+ UINT64 MemoryLength;
+ EFI_MEMORY_TYPE MemoryType;
+ UINT8 Reserved[4];
+} EFI_HOB_MEMORY_ALLOCATION_HEADER;
+
+typedef struct {
+ EFI_HOB_GENERIC_HEADER Header;
+ EFI_HOB_MEMORY_ALLOCATION_HEADER AllocDescriptor;
+ //
+ // Additional data pertaining to the "Name" Guid memory
+ // may go here.
+ //
+} EFI_HOB_MEMORY_ALLOCATION;
+
+typedef struct {
+ EFI_HOB_GENERIC_HEADER Header;
+ EFI_HOB_MEMORY_ALLOCATION_HEADER AllocDescriptor;
+} EFI_HOB_MEMORY_ALLOCATION_BSP_STORE;
+
+typedef struct {
+ EFI_HOB_GENERIC_HEADER Header;
+ EFI_HOB_MEMORY_ALLOCATION_HEADER AllocDescriptor;
+} EFI_HOB_MEMORY_ALLOCATION_STACK;
+
+typedef struct {
+ EFI_HOB_GENERIC_HEADER Header;
+ EFI_HOB_MEMORY_ALLOCATION_HEADER MemoryAllocationHeader;
+ EFI_GUID ModuleName;
+ EFI_PHYSICAL_ADDRESS EntryPoint;
+} EFI_HOB_MEMORY_ALLOCATION_MODULE;
+
+#define EFI_HOB_TYPE_RESOURCE_DESCRIPTOR 0x0003
+
+typedef UINT32 EFI_RESOURCE_TYPE;
+
+#define EFI_RESOURCE_SYSTEM_MEMORY 0
+#define EFI_RESOURCE_MEMORY_MAPPED_IO 1
+#define EFI_RESOURCE_IO 2
+#define EFI_RESOURCE_FIRMWARE_DEVICE 3
+#define EFI_RESOURCE_MEMORY_MAPPED_IO_PORT 4
+#define EFI_RESOURCE_MEMORY_RESERVED 5
+#define EFI_RESOURCE_IO_RESERVED 6
+#define EFI_RESOURCE_MAX_MEMORY_TYPE 7
+
+typedef UINT32 EFI_RESOURCE_ATTRIBUTE_TYPE;
+
+#define EFI_RESOURCE_ATTRIBUTE_PRESENT 0x00000001
+#define EFI_RESOURCE_ATTRIBUTE_INITIALIZED 0x00000002
+#define EFI_RESOURCE_ATTRIBUTE_TESTED 0x00000004
+#define EFI_RESOURCE_ATTRIBUTE_SINGLE_BIT_ECC 0x00000008
+#define EFI_RESOURCE_ATTRIBUTE_MULTIPLE_BIT_ECC 0x00000010
+#define EFI_RESOURCE_ATTRIBUTE_ECC_RESERVED_1 0x00000020
+#define EFI_RESOURCE_ATTRIBUTE_ECC_RESERVED_2 0x00000040
+#define EFI_RESOURCE_ATTRIBUTE_READ_PROTECTED 0x00000080
+#define EFI_RESOURCE_ATTRIBUTE_WRITE_PROTECTED 0x00000100
+#define EFI_RESOURCE_ATTRIBUTE_EXECUTION_PROTECTED 0x00000200
+#define EFI_RESOURCE_ATTRIBUTE_UNCACHEABLE 0x00000400
+#define EFI_RESOURCE_ATTRIBUTE_WRITE_COMBINEABLE 0x00000800
+#define EFI_RESOURCE_ATTRIBUTE_WRITE_THROUGH_CACHEABLE 0x00001000
+#define EFI_RESOURCE_ATTRIBUTE_WRITE_BACK_CACHEABLE 0x00002000
+#define EFI_RESOURCE_ATTRIBUTE_16_BIT_IO 0x00004000
+#define EFI_RESOURCE_ATTRIBUTE_32_BIT_IO 0x00008000
+#define EFI_RESOURCE_ATTRIBUTE_64_BIT_IO 0x00010000
+#define EFI_RESOURCE_ATTRIBUTE_UNCACHED_EXPORTED 0x00020000
+
+typedef struct {
+ EFI_HOB_GENERIC_HEADER Header;
+ EFI_GUID Owner;
+ EFI_RESOURCE_TYPE ResourceType;
+ EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute;
+ EFI_PHYSICAL_ADDRESS PhysicalStart;
+ UINT64 ResourceLength;
+} EFI_HOB_RESOURCE_DESCRIPTOR;
+
+//
+// GUID Extension HOB
+// The HobLength is variable as it includes the GUID specific data.
+//
+#define EFI_HOB_TYPE_GUID_EXTENSION 0x0004
+
+typedef struct {
+ EFI_HOB_GENERIC_HEADER Header;
+ EFI_GUID Name;
+
+ //
+ // Guid specific data goes here
+ //
+} EFI_HOB_GUID_TYPE;
+
+//
+// Firmware Volume HOB
+//
+#define EFI_HOB_TYPE_FV 0x0005
+
+typedef struct {
+ EFI_HOB_GENERIC_HEADER Header;
+ EFI_PHYSICAL_ADDRESS BaseAddress;
+ UINT64 Length;
+} EFI_HOB_FIRMWARE_VOLUME;
+
+//
+// CPU HOB
+//
+#define EFI_HOB_TYPE_CPU 0x0006
+
+typedef struct {
+ EFI_HOB_GENERIC_HEADER Header;
+ UINT8 SizeOfMemorySpace;
+ UINT8 SizeOfIoSpace;
+ UINT8 Reserved[6];
+} EFI_HOB_CPU;
+
+//
+// PEI Core Memory Pool HOB
+// The HobLength is variable as the HOB contains pool allocations by
+// the PeiServices AllocatePool function
+//
+#define EFI_HOB_TYPE_PEI_MEMORY_POOL 0x0007
+
+typedef struct {
+ EFI_HOB_GENERIC_HEADER Header;
+} EFI_HOB_MEMORY_POOL;
+
+//
+// Capsule volume HOB -- identical to a firmware volume
+//
+#define EFI_HOB_TYPE_CV 0x0008
+
+typedef struct {
+ EFI_HOB_GENERIC_HEADER Header;
+ EFI_PHYSICAL_ADDRESS BaseAddress;
+ UINT64 Length;
+} EFI_HOB_CAPSULE_VOLUME;
+
+//;;## ...AMI_OVERRIDE... Support PI1.x
+#if (PI_SPECIFICATION_VERSION >= 0x00010000)
+
+#define EFI_HOB_TYPE_FV2 0x0009
+
+typedef struct {
+ EFI_HOB_GENERIC_HEADER Header;
+ EFI_PHYSICAL_ADDRESS BaseAddress;
+ UINT64 Length;
+ EFI_GUID FvName;
+ EFI_GUID FileName;
+} EFI_HOB_FIRMWARE_VOLUME2;
+
+#define EFI_HOB_TYPE_LOAD_PEIM 0x000A
+
+#endif
+
+#define EFI_HOB_TYPE_UNUSED 0xFFFE
+
+//
+// Union of all the possible HOB Types
+//
+typedef union {
+ EFI_HOB_GENERIC_HEADER *Header;
+ EFI_HOB_HANDOFF_INFO_TABLE *HandoffInformationTable;
+ EFI_HOB_MEMORY_ALLOCATION *MemoryAllocation;
+ EFI_HOB_MEMORY_ALLOCATION_BSP_STORE *MemoryAllocationBspStore;
+ EFI_HOB_MEMORY_ALLOCATION_STACK *MemoryAllocationStack;
+ EFI_HOB_MEMORY_ALLOCATION_MODULE *MemoryAllocationModule;
+ EFI_HOB_RESOURCE_DESCRIPTOR *ResourceDescriptor;
+ EFI_HOB_GUID_TYPE *Guid;
+ EFI_HOB_FIRMWARE_VOLUME *FirmwareVolume;
+//;;## ...AMI_OVERRIDE... Support PI1.x
+#if (PI_SPECIFICATION_VERSION >= 0x00010000)
+ EFI_HOB_FIRMWARE_VOLUME2 *FirmwareVolume2;
+#endif
+ EFI_HOB_CPU *Cpu;
+ EFI_HOB_MEMORY_POOL *Pool;
+ EFI_HOB_CAPSULE_VOLUME *CapsuleVolume;
+ UINT8 *Raw;
+} EFI_PEI_HOB_POINTERS;
+
+#define GET_HOB_TYPE(Hob) ((Hob).Header->HobType)
+#define GET_HOB_LENGTH(Hob) ((Hob).Header->HobLength)
+#define GET_NEXT_HOB(Hob) ((Hob).Raw + GET_HOB_LENGTH (Hob))
+#define END_OF_HOB_LIST(Hob) (GET_HOB_TYPE (Hob) == EFI_HOB_TYPE_END_OF_HOB_LIST)
+
+#endif
diff --git a/EDK/Foundation/Framework/Include/TianoSpecApi.h b/EDK/Foundation/Framework/Include/TianoSpecApi.h
new file mode 100644
index 0000000..2279eda
--- /dev/null
+++ b/EDK/Foundation/Framework/Include/TianoSpecApi.h
@@ -0,0 +1,590 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ TianoSpecApi.h
+
+Abstract:
+
+ Tiano intrinsic definitions in Tiano spec.
+
+
+--*/
+
+#ifndef _TIANO_SPEC_API_H_
+#define _TIANO_SPEC_API_H_
+
+
+#if ((TIANO_RELEASE_VERSION != 0) && (EFI_SPECIFICATION_VERSION < 0x00020000))
+//
+// Prior to UEFI 2.0 Tiano extended these enums. This was replaced by
+// CreateEventEx() Event Groups in UEFI 2.0
+//
+#define EFI_EVENT_NOTIFY_SIGNAL_ALL 0x00000400
+
+#define EFI_EVENT_SIGNAL_READY_TO_BOOT 0x00000203
+#define EFI_EVENT_SIGNAL_LEGACY_BOOT 0x00000204
+#endif
+
+typedef
+EFI_BOOTSERVICE
+EFI_STATUS
+(EFIAPI *EFI_ADD_MEMORY_SPACE) (
+ IN EFI_GCD_MEMORY_TYPE GcdMemoryType,
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length,
+ IN UINT64 Capabilities
+ )
+/*++
+
+Routine Description:
+
+ Adds reserved memory, system memory, or memory-mapped I/O resources to the
+global coherency domain of the processor.
+
+Arguments:
+
+ GcdMemoryType - Memory type of the memory space.
+
+ BaseAddress - Base address of the memory space.
+
+ Length - Length of the memory space.
+
+ Capabilities - alterable attributes of the memory space.
+
+Returns:
+
+ EFI_SUCCESS - Merged this memory space into GCD map.
+
+--*/
+;
+
+typedef
+EFI_BOOTSERVICE
+EFI_STATUS
+(EFIAPI *EFI_ALLOCATE_MEMORY_SPACE) (
+ IN EFI_GCD_ALLOCATE_TYPE GcdAllocateType,
+ IN EFI_GCD_MEMORY_TYPE GcdMemoryType,
+ IN UINTN Alignment,
+ IN UINT64 Length,
+ IN OUT EFI_PHYSICAL_ADDRESS * BaseAddress,
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_HANDLE DeviceHandle OPTIONAL
+ )
+/*++
+
+Routine Description:
+
+ Allocates nonexistent memory, reserved memory, system memory, or memorymapped
+I/O resources from the global coherency domain of the processor.
+
+Arguments:
+
+ GcdAllocateType - The type of allocate operation
+
+ GcdMemoryType - The desired memory type
+
+ Alignment - Align with 2^Alignment
+
+ Length - Length to allocate
+
+ BaseAddress - Base address to allocate
+
+ Imagehandle - The image handle consume the allocated space.
+
+ DeviceHandle - The device handle consume the allocated space.
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Invalid parameter.
+
+ EFI_NOT_FOUND - No descriptor contains the desired space.
+
+ EFI_SUCCESS - Memory space successfully allocated.
+
+--*/
+;
+
+typedef
+EFI_BOOTSERVICE
+EFI_STATUS
+(EFIAPI *EFI_FREE_MEMORY_SPACE) (
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length
+ )
+/*++
+
+Routine Description:Routine Description:
+
+ Frees nonexistent memory, reserved memory, system memory, or memory-mapped
+I/O resources from the global coherency domain of the processor.
+
+Arguments:
+
+ BaseAddress - Base address of the segment.
+
+ Length - Length of the segment.
+
+Returns:
+
+ EFI_SUCCESS - Space successfully freed.
+
+--*/
+;
+
+typedef
+EFI_BOOTSERVICE
+EFI_STATUS
+(EFIAPI *EFI_REMOVE_MEMORY_SPACE) (
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length
+ )
+/*++
+
+Routine Description:Routine Description:
+
+ Removes reserved memory, system memory, or memory-mapped I/O resources from
+the global coherency domain of the processor.
+
+Arguments:
+
+ BaseAddress - Base address of the memory space.
+
+ Length - Length of the memory space.
+
+Returns:
+
+ EFI_SUCCESS - Successfully remove a segment of memory space.
+
+--*/
+;
+
+typedef
+EFI_BOOTSERVICE
+EFI_STATUS
+(EFIAPI *EFI_GET_MEMORY_SPACE_DESCRIPTOR) (
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ OUT EFI_GCD_MEMORY_SPACE_DESCRIPTOR * Descriptor
+ )
+/*++
+
+Routine Description:
+
+ Retrieves the descriptor for a memory region containing a specified address.
+
+Arguments:
+
+ BaseAddress - Specified start address
+
+ Descriptor - Specified length
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Invalid parameter
+
+ EFI_SUCCESS - Successfully get memory space descriptor.
+
+--*/
+;
+
+typedef
+EFI_BOOTSERVICE
+EFI_STATUS
+(EFIAPI *EFI_SET_MEMORY_SPACE_ATTRIBUTES) (
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length,
+ IN UINT64 Attributes
+ )
+/*++
+
+Routine Description:
+
+ Modifies the attributes for a memory region in the global coherency domain of the
+processor.
+
+Arguments:
+
+ BaseAddress - Specified start address
+
+ Length - Specified length
+
+ Attributes - Specified attributes
+
+Returns:
+
+ EFI_SUCCESS - Successfully set attribute of a segment of memory space.
+
+--*/
+;
+
+typedef
+EFI_BOOTSERVICE
+EFI_STATUS
+(EFIAPI *EFI_GET_MEMORY_SPACE_MAP) (
+ OUT UINTN *NumberOfDescriptors,
+ OUT EFI_GCD_MEMORY_SPACE_DESCRIPTOR **MemorySpaceMap
+ )
+/*++
+
+Routine Description:
+
+ Returns a map of the memory resources in the global coherency domain of the
+processor.
+
+Arguments:
+
+ NumberOfDescriptors - Number of descriptors.
+
+ MemorySpaceMap - Descriptor array
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Invalid parameter
+
+ EFI_OUT_OF_RESOURCES - No enough buffer to allocate
+
+ EFI_SUCCESS - Successfully get memory space map.
+
+--*/
+;
+
+typedef
+EFI_BOOTSERVICE
+EFI_STATUS
+(EFIAPI *EFI_ADD_IO_SPACE) (
+ IN EFI_GCD_IO_TYPE GcdIoType,
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length
+ )
+/*++
+
+Routine Description:
+
+ Adds reserved I/O or I/O resources to the global coherency domain of the processor.
+
+Arguments:
+
+ GcdIoType - IO type of the segment.
+
+ BaseAddress - Base address of the segment.
+
+ Length - Length of the segment.
+
+Returns:
+
+ EFI_SUCCESS - Merged this segment into GCD map.
+
+--*/
+;
+
+typedef
+EFI_BOOTSERVICE
+EFI_STATUS
+(EFIAPI *EFI_ALLOCATE_IO_SPACE) (
+ IN EFI_GCD_ALLOCATE_TYPE GcdAllocateType,
+ IN EFI_GCD_IO_TYPE GcdIoType,
+ IN UINTN Alignment,
+ IN UINT64 Length,
+ IN OUT EFI_PHYSICAL_ADDRESS * BaseAddress,
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_HANDLE DeviceHandle OPTIONAL
+ )
+/*++
+
+Routine Description:
+
+ Allocates nonexistent I/O, reserved I/O, or I/O resources from the global coherency
+domain of the processor.
+
+Arguments:
+
+ GcdAllocateType - The type of allocate operation
+
+ GcdIoType - The desired IO type
+
+ Alignment - Align with 2^Alignment
+
+ Length - Length to allocate
+
+ BaseAddress - Base address to allocate
+
+ Imagehandle - The image handle consume the allocated space.
+
+ DeviceHandle - The device handle consume the allocated space.
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Invalid parameter.
+
+ EFI_NOT_FOUND - No descriptor contains the desired space.
+
+ EFI_SUCCESS - IO space successfully allocated.
+
+--*/
+;
+
+typedef
+EFI_BOOTSERVICE
+EFI_STATUS
+(EFIAPI *EFI_FREE_IO_SPACE) (
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length
+ )
+/*++
+
+Routine Description:Routine Description:
+
+ Frees nonexistent I/O, reserved I/O, or I/O resources from the global coherency
+domain of the processor.
+
+Arguments:
+
+ BaseAddress - Base address of the segment.
+
+ Length - Length of the segment.
+
+Returns:
+
+ EFI_SUCCESS - Space successfully freed.
+
+--*/
+;
+
+typedef
+EFI_BOOTSERVICE
+EFI_STATUS
+(EFIAPI *EFI_REMOVE_IO_SPACE) (
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length
+ )
+/*++
+
+Routine Description:Routine Description:
+
+ Removes reserved I/O or I/O resources from the global coherency domain of the
+processor.
+
+Arguments:
+
+ BaseAddress - Base address of the segment.
+
+ Length - Length of the segment.
+
+Returns:
+
+ EFI_SUCCESS - Successfully removed a segment of IO space.
+
+--*/
+;
+
+typedef
+EFI_BOOTSERVICE
+EFI_STATUS
+(EFIAPI *EFI_GET_IO_SPACE_DESCRIPTOR) (
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ OUT EFI_GCD_IO_SPACE_DESCRIPTOR * Descriptor
+ )
+/*++
+
+Routine Description:
+
+ Retrieves the descriptor for an I/O region containing a specified address.
+
+Arguments:
+
+ BaseAddress - Specified start address
+
+ Descriptor - Specified length
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Descriptor is NULL.
+
+ EFI_SUCCESS - Successfully get the IO space descriptor.
+
+--*/
+;
+
+typedef
+EFI_BOOTSERVICE
+EFI_STATUS
+(EFIAPI *EFI_GET_IO_SPACE_MAP) (
+ OUT UINTN *NumberOfDescriptors,
+ OUT EFI_GCD_IO_SPACE_DESCRIPTOR **IoSpaceMap
+ )
+/*++
+
+Routine Description:
+
+ Returns a map of the I/O resources in the global coherency domain of the processor.
+
+Arguments:
+
+ NumberOfDescriptors - Number of descriptors.
+
+ MemorySpaceMap - Descriptor array
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Invalid parameter
+
+ EFI_OUT_OF_RESOURCES - No enough buffer to allocate
+
+ EFI_SUCCESS - Successfully get IO space map.
+
+--*/
+;
+
+typedef
+EFI_BOOTSERVICE
+EFI_STATUS
+(EFIAPI *EFI_DISPATCH) (VOID)
+/*++
+
+Routine Description:
+
+ Loads and executed DXE drivers from firmware volumes.
+
+Arguments:
+
+ None
+
+Returns:
+
+ Status code
+
+--*/
+;
+
+typedef
+EFI_BOOTSERVICE
+EFI_STATUS
+(EFIAPI *EFI_SCHEDULE) (
+ IN EFI_HANDLE FirmwareVolumeHandle,
+ IN EFI_GUID * DriverName
+ )
+/*++
+
+Routine Description:
+
+ Clears the Schedule on Request (SOR) flag for a component that is stored in a firmware volume.
+
+Arguments:
+
+ FirmwareVolumeHandle - The handle of the firmware volume that contains the file specified by FileName.
+
+ DriverName - A pointer to the name of the file in a firmware volume.
+
+Returns:
+
+ Status code
+
+--*/
+;
+
+typedef
+EFI_BOOTSERVICE
+EFI_STATUS
+(EFIAPI *EFI_TRUST) (
+ IN EFI_HANDLE FirmwareVolumeHandle,
+ IN EFI_GUID * DriverName
+ )
+/*++
+
+Routine Description:
+
+ Promotes a file stored in a firmware volume from the untrusted to the trusted state.
+
+Arguments:
+
+ FirmwareVolumeHandle - The handle of the firmware volume that contains the file specified by FileName.
+
+ DriverName - A pointer to the name of the file in a firmware volume.
+
+Returns:
+
+ Status code
+
+--*/
+;
+
+typedef
+EFI_BOOTSERVICE
+EFI_STATUS
+(EFIAPI *EFI_PROCESS_FIRMWARE_VOLUME) (
+ IN VOID *FvHeader,
+ IN UINTN Size,
+ OUT EFI_HANDLE * FirmwareVolumeHandle
+ )
+/*++
+
+Routine Description:
+
+ Creates a firmware volume handle for a firmware volume that is present in system memory.
+
+Arguments:
+
+ FirmwareVolumeHeader - A pointer to the header of the firmware volume.
+ Size - The size, in bytes, of the firmware volume.
+ FirmwareVolumeHandle - On output, a pointer to the created handle.
+
+Returns:
+
+ Status code
+
+--*/
+;
+
+//
+// DXE Services Table
+//
+#define EFI_DXE_SERVICES_SIGNATURE 0x565245535f455844
+//;;## ...AMI_OVERRIDE... Support PI1.x
+#if (PI_SPECIFICATION_VERSION < 0x00010000)
+#define EFI_DXE_SERVICES_REVISION ((0 << 16) | (90))
+#else
+#define EFI_DXE_SERVICES_REVISION ((1 << 16) | (00))
+#endif
+
+typedef struct {
+ EFI_TABLE_HEADER Hdr;
+
+ //
+ // Global Coherency Domain Services
+ //
+ EFI_ADD_MEMORY_SPACE AddMemorySpace;
+ EFI_ALLOCATE_MEMORY_SPACE AllocateMemorySpace;
+ EFI_FREE_MEMORY_SPACE FreeMemorySpace;
+ EFI_REMOVE_MEMORY_SPACE RemoveMemorySpace;
+ EFI_GET_MEMORY_SPACE_DESCRIPTOR GetMemorySpaceDescriptor;
+ EFI_SET_MEMORY_SPACE_ATTRIBUTES SetMemorySpaceAttributes;
+ EFI_GET_MEMORY_SPACE_MAP GetMemorySpaceMap;
+ EFI_ADD_IO_SPACE AddIoSpace;
+ EFI_ALLOCATE_IO_SPACE AllocateIoSpace;
+ EFI_FREE_IO_SPACE FreeIoSpace;
+ EFI_REMOVE_IO_SPACE RemoveIoSpace;
+ EFI_GET_IO_SPACE_DESCRIPTOR GetIoSpaceDescriptor;
+ EFI_GET_IO_SPACE_MAP GetIoSpaceMap;
+
+ //
+ // Dispatcher Services
+ //
+ EFI_DISPATCH Dispatch;
+ EFI_SCHEDULE Schedule;
+ EFI_TRUST Trust;
+ //
+ // Service to process a single firmware volume found in a capsule
+ //
+ EFI_PROCESS_FIRMWARE_VOLUME ProcessFirmwareVolume;
+} EFI_DXE_SERVICES;
+
+#endif
diff --git a/EDK/Foundation/Framework/Include/TianoSpecDevicePath.h b/EDK/Foundation/Framework/Include/TianoSpecDevicePath.h
new file mode 100644
index 0000000..efe7eaf
--- /dev/null
+++ b/EDK/Foundation/Framework/Include/TianoSpecDevicePath.h
@@ -0,0 +1,32 @@
+/*++
+
+Copyright (c) 2004 - 2008, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ TianoSpecDevicePath.h
+
+Abstract:
+
+ Tiano Device Path definitions in Tiano Spec.
+
+--*/
+
+#ifndef _TIANO_SPEC_DEVICE_PATH_H
+#define _TIANO_SPEC_DEVICE_PATH_H
+
+#include "EfiDevicePath.h"
+
+//
+// MEDIA_FW_VOL_FILEPATH_DEVICE_PATH and MEDIA_FW_VOL_DEVICE_PATH are defined in
+// EfiDevicePath.h
+//
+
+#endif
diff --git a/EDK/Foundation/Framework/Include/TianoSpecError.h b/EDK/Foundation/Framework/Include/TianoSpecError.h
new file mode 100644
index 0000000..815cdf4
--- /dev/null
+++ b/EDK/Foundation/Framework/Include/TianoSpecError.h
@@ -0,0 +1,41 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ TianoSpecError.h
+
+Abstract:
+
+ Tiano error codes defined in Tiano spec.
+
+--*/
+
+#ifndef _TIANO_SPEC_ERROR_H_
+#define _TIANO_SPEC_ERROR_H_
+
+#include "EfiBind.h"
+#define TIANO_ERROR(a) (MAX_2_BITS | (a))
+
+//
+// Tiano added a couple of return types. These are owned by UEFI specification
+// and Tiano can not use them. Thus for UEFI 2.0/R8.6 support we moved the values
+// to a UEFI OEM extension range to conform to UEFI specification.
+//
+#if (EFI_SPECIFICATION_VERSION < 0x00020000)
+ #define EFI_NOT_AVAILABLE_YET EFIERR (28)
+ #define EFI_UNLOAD_IMAGE EFIERR (29)
+#else
+ #define EFI_NOT_AVAILABLE_YET TIANO_ERROR (0)
+ #define EFI_UNLOAD_IMAGE TIANO_ERROR (1)
+#endif
+
+#endif
diff --git a/EDK/Foundation/Framework/Include/TianoSpecTypes.h b/EDK/Foundation/Framework/Include/TianoSpecTypes.h
new file mode 100644
index 0000000..e7ff834
--- /dev/null
+++ b/EDK/Foundation/Framework/Include/TianoSpecTypes.h
@@ -0,0 +1,75 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ TianoSpecTypes.h
+
+Abstract:
+
+ Tiano types defined in Tiano spec.
+
+--*/
+
+#ifndef _TIANO_SPEC_TYPES_H_
+#define _TIANO_SPEC_TYPES_H_
+
+//
+// Modifier for EFI DXE Services
+//
+#define EFI_DXESERVICE
+
+//
+// Global Coherencey Domain types
+//
+typedef enum {
+ EfiGcdMemoryTypeNonExistent,
+ EfiGcdMemoryTypeReserved,
+ EfiGcdMemoryTypeSystemMemory,
+ EfiGcdMemoryTypeMemoryMappedIo,
+ EfiGcdMemoryTypeMaximum
+} EFI_GCD_MEMORY_TYPE;
+
+typedef enum {
+ EfiGcdIoTypeNonExistent,
+ EfiGcdIoTypeReserved,
+ EfiGcdIoTypeIo,
+ EfiGcdIoTypeMaximum
+} EFI_GCD_IO_TYPE;
+
+typedef enum {
+ EfiGcdAllocateAnySearchBottomUp,
+ EfiGcdAllocateMaxAddressSearchBottomUp,
+ EfiGcdAllocateAddress,
+ EfiGcdAllocateAnySearchTopDown,
+ EfiGcdAllocateMaxAddressSearchTopDown,
+ EfiGcdMaxAllocateType
+} EFI_GCD_ALLOCATE_TYPE;
+
+typedef struct {
+ EFI_PHYSICAL_ADDRESS BaseAddress;
+ UINT64 Length;
+ UINT64 Capabilities;
+ UINT64 Attributes;
+ EFI_GCD_MEMORY_TYPE GcdMemoryType;
+ EFI_HANDLE ImageHandle;
+ EFI_HANDLE DeviceHandle;
+} EFI_GCD_MEMORY_SPACE_DESCRIPTOR;
+
+typedef struct {
+ EFI_PHYSICAL_ADDRESS BaseAddress;
+ UINT64 Length;
+ EFI_GCD_IO_TYPE GcdIoType;
+ EFI_HANDLE ImageHandle;
+ EFI_HANDLE DeviceHandle;
+} EFI_GCD_IO_SPACE_DESCRIPTOR;
+
+#endif
diff --git a/EDK/Foundation/Framework/Ppi/BlockIo/BlockIo.c b/EDK/Foundation/Framework/Ppi/BlockIo/BlockIo.c
new file mode 100644
index 0000000..b8b0953
--- /dev/null
+++ b/EDK/Foundation/Framework/Ppi/BlockIo/BlockIo.c
@@ -0,0 +1,29 @@
+/*++
+
+Copyright (c) 1999 - 2002, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ BlockIo.c
+
+Abstract:
+
+ BlockIo PPI GUID as defined in EFI 2.0
+
+--*/
+
+#include "Tiano.h"
+#include "Pei.h"
+#include EFI_PPI_DEFINITION (BlockIo)
+
+EFI_GUID gPeiBlockIoPpiGuid = PEI_BLOCK_IO_PPI_GUID;
+
+EFI_GUID_STRING(&gPeiBlockIoPpiGuid, "BlockIo", "PEI Block I/O PPI");
diff --git a/EDK/Foundation/Framework/Ppi/BlockIo/BlockIo.h b/EDK/Foundation/Framework/Ppi/BlockIo/BlockIo.h
new file mode 100644
index 0000000..c518b37
--- /dev/null
+++ b/EDK/Foundation/Framework/Ppi/BlockIo/BlockIo.h
@@ -0,0 +1,88 @@
+/*++
+
+Copyright (c) 1999 - 2002, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ BlockIo.h
+
+Abstract:
+
+ BlockIo PPI as defined in EFI 2.0
+
+ Used to access block-oriented storage devices
+
+--*/
+
+#ifndef _PEI_BLOCK_IO_H_
+#define _PEI_BLOCK_IO_H_
+
+#define PEI_BLOCK_IO_PPI_GUID \
+ { \
+ 0x695d8aa1, 0x42ee, 0x4c46, 0x80, 0x5c, 0x6e, 0xa6, 0xbc, 0xe7, 0x99, 0xe3 \
+ }
+
+EFI_FORWARD_DECLARATION (PEI_RECOVERY_BLOCK_IO_INTERFACE);
+
+typedef UINT64 PEI_LBA;
+
+typedef enum {
+ LegacyFloppy = 0,
+ IdeCDROM = 1,
+ IdeLS120 = 2,
+ UsbMassStorage= 3,
+ MaxDeviceType
+} PEI_BLOCK_DEVICE_TYPE;
+
+typedef struct {
+ PEI_BLOCK_DEVICE_TYPE DeviceType;
+ BOOLEAN MediaPresent;
+ UINTN LastBlock;
+ UINTN BlockSize;
+} PEI_BLOCK_IO_MEDIA;
+
+typedef
+EFI_STATUS
+(EFIAPI *PEI_GET_NUMBER_BLOCK_DEVICES) (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_RECOVERY_BLOCK_IO_INTERFACE * This,
+ OUT UINTN *NumberBlockDevices
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *PEI_GET_DEVICE_MEDIA_INFORMATION) (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_RECOVERY_BLOCK_IO_INTERFACE * This,
+ IN UINTN DeviceIndex,
+ OUT PEI_BLOCK_IO_MEDIA * MediaInfo
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *PEI_READ_BLOCKS) (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_RECOVERY_BLOCK_IO_INTERFACE * This,
+ IN UINTN DeviceIndex,
+ IN PEI_LBA StartLBA,
+ IN UINTN BufferSize,
+ OUT VOID *Buffer
+ );
+
+typedef struct _PEI_RECOVERY_BLOCK_IO_INTERFACE {
+ PEI_GET_NUMBER_BLOCK_DEVICES GetNumberOfBlockDevices;
+ PEI_GET_DEVICE_MEDIA_INFORMATION GetBlockDeviceMediaInfo;
+ PEI_READ_BLOCKS ReadBlocks;
+} PEI_RECOVERY_BLOCK_IO_INTERFACE;
+
+extern EFI_GUID gPeiBlockIoPpiGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Ppi/BootInRecoveryMode/BootInRecoveryMode.c b/EDK/Foundation/Framework/Ppi/BootInRecoveryMode/BootInRecoveryMode.c
new file mode 100644
index 0000000..e5840a8
--- /dev/null
+++ b/EDK/Foundation/Framework/Ppi/BootInRecoveryMode/BootInRecoveryMode.c
@@ -0,0 +1,29 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ BootInRecoveryMode.c
+
+Abstract:
+
+ Boot Mode PPI GUID as defined in PEI EAS
+
+--*/
+
+#include "Tiano.h"
+#include "PeiBind.h"
+#include "PeiApi.h"
+#include EFI_PPI_DEFINITION (BootInRecoveryMode)
+
+EFI_GUID gPeiBootInRecoveryModePpiGuid = PEI_BOOT_IN_RECOVERY_MODE_PEIM_PPI;
+
+EFI_GUID_STRING(&gPeiMasterBootModePpiGuid, "BootMode", "Master Boot Mode PPI");
diff --git a/EDK/Foundation/Framework/Ppi/BootInRecoveryMode/BootInRecoveryMode.h b/EDK/Foundation/Framework/Ppi/BootInRecoveryMode/BootInRecoveryMode.h
new file mode 100644
index 0000000..15ca5ca
--- /dev/null
+++ b/EDK/Foundation/Framework/Ppi/BootInRecoveryMode/BootInRecoveryMode.h
@@ -0,0 +1,34 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ BootInRecoveryMode.h
+
+Abstract:
+
+ Boot Mode PPI as defined in Tiano
+
+--*/
+
+#ifndef _PEI_BOOT_IN_RECOVERY_MODE_PPI_H
+#define _PEI_BOOT_IN_RECOVERY_MODE_PPI_H
+
+#define PEI_BOOT_IN_RECOVERY_MODE_PEIM_PPI \
+ { \
+ 0x17ee496a, 0xd8e4, 0x4b9a, 0x94, 0xd1, 0xce, 0x82, 0x72, 0x30, 0x8, 0x50 \
+ }
+
+EFI_FORWARD_DECLARATION (PEI_BOOT_IN_RECOVERY_MODE_PPI);
+
+extern EFI_GUID gPeiBootInRecoveryModePpiGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Ppi/BootMode/BootMode.c b/EDK/Foundation/Framework/Ppi/BootMode/BootMode.c
new file mode 100644
index 0000000..f88b757
--- /dev/null
+++ b/EDK/Foundation/Framework/Ppi/BootMode/BootMode.c
@@ -0,0 +1,29 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ BootMode.c
+
+Abstract:
+
+ Boot Mode PPI GUID as defined in PEI EAS
+
+--*/
+
+#include "Tiano.h"
+#include "PeiBind.h"
+#include "PeiApi.h"
+#include EFI_PPI_DEFINITION (BootMode)
+
+EFI_GUID gPeiMasterBootModePpiGuid = PEI_MASTER_BOOT_MODE_PEIM_PPI;
+
+EFI_GUID_STRING(&gPeiMasterBootModePpiGuid, "BootMode", "Master Boot Mode PPI");
diff --git a/EDK/Foundation/Framework/Ppi/BootMode/BootMode.h b/EDK/Foundation/Framework/Ppi/BootMode/BootMode.h
new file mode 100644
index 0000000..552ed23
--- /dev/null
+++ b/EDK/Foundation/Framework/Ppi/BootMode/BootMode.h
@@ -0,0 +1,34 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ BootMode.h
+
+Abstract:
+
+ Boot Mode PPI as defined in Tiano
+
+--*/
+
+#ifndef _PEI_MASTER_BOOT_MODE_PPI_H
+#define _PEI_MASTER_BOOT_MODE_PPI_H
+
+#define PEI_MASTER_BOOT_MODE_PEIM_PPI \
+ { \
+ 0x7408d748, 0xfc8c, 0x4ee6, 0x92, 0x88, 0xc4, 0xbe, 0xc0, 0x92, 0xa4, 0x10 \
+ }
+
+EFI_FORWARD_DECLARATION (PEI_MASTER_BOOT_MODE_PPI);
+
+extern EFI_GUID gPeiMasterBootModePpiGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Ppi/BootScriptExecuter/BootScriptExecuter.c b/EDK/Foundation/Framework/Ppi/BootScriptExecuter/BootScriptExecuter.c
new file mode 100644
index 0000000..bcb7d48
--- /dev/null
+++ b/EDK/Foundation/Framework/Ppi/BootScriptExecuter/BootScriptExecuter.c
@@ -0,0 +1,29 @@
+/*++
+
+Copyright (c) 2001 - 2002, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ BootScriptExecuter.c
+
+Abstract:
+
+ Boot Script Executer PPI GUID as defined in EFI 2.0
+
+--*/
+
+#include "Tiano.h"
+#include "PeiBind.h"
+#include "PeiApi.h"
+#include EFI_PPI_DEFINITION (BootScriptExecuter)
+
+EFI_GUID gPeiBootScriptExecuterPpiGuid = PEI_BOOT_SCRIPT_EXECUTER_PPI_GUID;
+
+EFI_GUID_STRING(&gPeiBootScriptExecuterPpiGuid, "BootScriptExecuter", "Boot Script Executer PPI");
diff --git a/EDK/Foundation/Framework/Ppi/BootScriptExecuter/BootScriptExecuter.h b/EDK/Foundation/Framework/Ppi/BootScriptExecuter/BootScriptExecuter.h
new file mode 100644
index 0000000..72540f0
--- /dev/null
+++ b/EDK/Foundation/Framework/Ppi/BootScriptExecuter/BootScriptExecuter.h
@@ -0,0 +1,50 @@
+/*++
+
+Copyright (c) 2001 - 2002, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ BootScriptExecuter.h
+
+Abstract:
+
+ Boot Script Executer PPI as defined in EFI 2.0
+
+--*/
+
+#ifndef _PEI_BOOT_SCRIPT_EXECUTER_PPI_H
+#define _PEI_BOOT_SCRIPT_EXECUTER_PPI_H
+
+#define PEI_BOOT_SCRIPT_EXECUTER_PPI_GUID \
+ { \
+ 0xabd42895, 0x78cf, 0x4872, 0x84, 0x44, 0x1b, 0x5c, 0x18, 0x0b, 0xfb, 0xff \
+ }
+
+EFI_FORWARD_DECLARATION (PEI_BOOT_SCRIPT_EXECUTER_PPI);
+
+#define PEI_BOOT_SCRIPT_EXECUTER_PPI_REVISION 0x00000001
+
+typedef
+EFI_STATUS
+(EFIAPI *PEI_BOOT_SCRIPT_EXECUTE) (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_BOOT_SCRIPT_EXECUTER_PPI * This,
+ IN EFI_PHYSICAL_ADDRESS Address,
+ IN EFI_GUID * FvFile OPTIONAL
+ );
+
+typedef struct _PEI_BOOT_SCRIPT_EXECUTER_PPI {
+ UINT64 Revision;
+ PEI_BOOT_SCRIPT_EXECUTE Execute;
+} PEI_BOOT_SCRIPT_EXECUTER_PPI;
+
+extern EFI_GUID gPeiBootScriptExecuterPpiGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Ppi/CpuIo/CpuIo.c b/EDK/Foundation/Framework/Ppi/CpuIo/CpuIo.c
new file mode 100644
index 0000000..10daaf3
--- /dev/null
+++ b/EDK/Foundation/Framework/Ppi/CpuIo/CpuIo.c
@@ -0,0 +1,29 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ CpuIO.c
+
+Abstract:
+
+ CPU IO PPI GUID as defined in Tiano
+
+
+--*/
+
+#include "Tiano.h"
+#include "Pei.h"
+#include EFI_PPI_DEFINITION (CpuIo)
+
+EFI_GUID gPeiCpuIoPpiInServiceTableGuid = PEI_CPU_IO_PPI_GUID;
+
+EFI_GUID_STRING(&gPeiCpuIoPpiInServiceTableGuid, "CPU IO", "CPU IO PPI");
diff --git a/EDK/Foundation/Framework/Ppi/CpuIo/CpuIo.h b/EDK/Foundation/Framework/Ppi/CpuIo/CpuIo.h
new file mode 100644
index 0000000..b99fca9
--- /dev/null
+++ b/EDK/Foundation/Framework/Ppi/CpuIo/CpuIo.h
@@ -0,0 +1,250 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ CpuIo.h
+
+Abstract:
+
+ CPU IO PPI defined in Tiano
+ CPU IO PPI abstracts CPU IO access
+
+
+--*/
+
+#ifndef _PEI_CPUIO_PPI_H_
+#define _PEI_CPUIO_PPI_H_
+
+#define PEI_CPU_IO_PPI_GUID \
+ { \
+ 0xe6af1f7b, 0xfc3f, 0x46da, 0xa8, 0x28, 0xa3, 0xb4, 0x57, 0xa4, 0x42, 0x82 \
+ }
+
+EFI_FORWARD_DECLARATION (PEI_CPU_IO_PPI);
+
+//
+// *******************************************************
+// PEI_CPU_IO_PPI_WIDTH
+// *******************************************************
+//
+typedef enum {
+ PeiCpuIoWidthUint8,
+ PeiCpuIoWidthUint16,
+ PeiCpuIoWidthUint32,
+ PeiCpuIoWidthUint64,
+ PeiCpuIoWidthFifoUint8,
+ PeiCpuIoWidthFifoUint16,
+ PeiCpuIoWidthFifoUint32,
+ PeiCpuIoWidthFifoUint64,
+ PeiCpuIoWidthFillUint8,
+ PeiCpuIoWidthFillUint16,
+ PeiCpuIoWidthFillUint32,
+ PeiCpuIoWidthFillUint64,
+ PeiCpuIoWidthMaximum
+} PEI_CPU_IO_PPI_WIDTH;
+
+//
+// *******************************************************
+// PEI_CPU_IO_PPI_IO_MEM
+// *******************************************************
+//
+typedef
+EFI_STATUS
+(EFIAPI *PEI_CPU_IO_PPI_IO_MEM) (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_CPU_IO_PPI * This,
+ IN PEI_CPU_IO_PPI_WIDTH Width,
+ IN UINT64 Address,
+ IN UINTN Count,
+ IN OUT VOID *Buffer
+ );
+
+//
+// *******************************************************
+// PEI_CPU_IO_PPI_ACCESS
+// *******************************************************
+//
+typedef struct {
+ PEI_CPU_IO_PPI_IO_MEM Read;
+ PEI_CPU_IO_PPI_IO_MEM Write;
+} PEI_CPU_IO_PPI_ACCESS;
+
+//
+// *******************************************************
+// Base IO Class Functions
+// *******************************************************
+//
+typedef
+UINT8
+(EFIAPI *PEI_CPU_IO_PPI_IO_READ8) (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_CPU_IO_PPI * This,
+ IN UINT64 Address
+ );
+
+typedef
+UINT16
+(EFIAPI *PEI_CPU_IO_PPI_IO_READ16) (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_CPU_IO_PPI * This,
+ IN UINT64 Address
+ );
+
+typedef
+UINT32
+(EFIAPI *PEI_CPU_IO_PPI_IO_READ32) (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_CPU_IO_PPI * This,
+ IN UINT64 Address
+ );
+
+typedef
+UINT64
+(EFIAPI *PEI_CPU_IO_PPI_IO_READ64) (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_CPU_IO_PPI * This,
+ IN UINT64 Address
+ );
+
+typedef
+VOID
+(EFIAPI *PEI_CPU_IO_PPI_IO_WRITE8) (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_CPU_IO_PPI * This,
+ IN UINT64 Address,
+ IN UINT8 Data
+ );
+
+typedef
+VOID
+(EFIAPI *PEI_CPU_IO_PPI_IO_WRITE16) (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_CPU_IO_PPI * This,
+ IN UINT64 Address,
+ IN UINT16 Data
+ );
+
+typedef
+VOID
+(EFIAPI *PEI_CPU_IO_PPI_IO_WRITE32) (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_CPU_IO_PPI * This,
+ IN UINT64 Address,
+ IN UINT32 Data
+ );
+
+typedef
+VOID
+(EFIAPI *PEI_CPU_IO_PPI_IO_WRITE64) (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_CPU_IO_PPI * This,
+ IN UINT64 Address,
+ IN UINT64 Data
+ );
+
+typedef
+UINT8
+(EFIAPI *PEI_CPU_IO_PPI_MEM_READ8) (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_CPU_IO_PPI * This,
+ IN UINT64 Address
+ );
+
+typedef
+UINT16
+(EFIAPI *PEI_CPU_IO_PPI_MEM_READ16) (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_CPU_IO_PPI * This,
+ IN UINT64 Address
+ );
+
+typedef
+UINT32
+(EFIAPI *PEI_CPU_IO_PPI_MEM_READ32) (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_CPU_IO_PPI * This,
+ IN UINT64 Address
+ );
+
+typedef
+UINT64
+(EFIAPI *PEI_CPU_IO_PPI_MEM_READ64) (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_CPU_IO_PPI * This,
+ IN UINT64 Address
+ );
+
+typedef
+VOID
+(EFIAPI *PEI_CPU_IO_PPI_MEM_WRITE8) (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_CPU_IO_PPI * This,
+ IN UINT64 Address,
+ IN UINT8 Data
+ );
+
+typedef
+VOID
+(EFIAPI *PEI_CPU_IO_PPI_MEM_WRITE16) (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_CPU_IO_PPI * This,
+ IN UINT64 Address,
+ IN UINT16 Data
+ );
+
+typedef
+VOID
+(EFIAPI *PEI_CPU_IO_PPI_MEM_WRITE32) (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_CPU_IO_PPI * This,
+ IN UINT64 Address,
+ IN UINT32 Data
+ );
+
+typedef
+VOID
+(EFIAPI *PEI_CPU_IO_PPI_MEM_WRITE64) (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_CPU_IO_PPI * This,
+ IN UINT64 Address,
+ IN UINT64 Data
+ );
+
+//
+// *******************************************************
+// PEI_CPU_IO_PPI
+// *******************************************************
+//
+typedef struct _PEI_CPU_IO_PPI {
+ PEI_CPU_IO_PPI_ACCESS Mem;
+ PEI_CPU_IO_PPI_ACCESS Io;
+ PEI_CPU_IO_PPI_IO_READ8 IoRead8;
+ PEI_CPU_IO_PPI_IO_READ16 IoRead16;
+ PEI_CPU_IO_PPI_IO_READ32 IoRead32;
+ PEI_CPU_IO_PPI_IO_READ64 IoRead64;
+ PEI_CPU_IO_PPI_IO_WRITE8 IoWrite8;
+ PEI_CPU_IO_PPI_IO_WRITE16 IoWrite16;
+ PEI_CPU_IO_PPI_IO_WRITE32 IoWrite32;
+ PEI_CPU_IO_PPI_IO_WRITE64 IoWrite64;
+ PEI_CPU_IO_PPI_MEM_READ8 MemRead8;
+ PEI_CPU_IO_PPI_MEM_READ16 MemRead16;
+ PEI_CPU_IO_PPI_MEM_READ32 MemRead32;
+ PEI_CPU_IO_PPI_MEM_READ64 MemRead64;
+ PEI_CPU_IO_PPI_MEM_WRITE8 MemWrite8;
+ PEI_CPU_IO_PPI_MEM_WRITE16 MemWrite16;
+ PEI_CPU_IO_PPI_MEM_WRITE32 MemWrite32;
+ PEI_CPU_IO_PPI_MEM_WRITE64 MemWrite64;
+} PEI_CPU_IO_PPI;
+
+extern EFI_GUID gPeiCpuIoPpiInServiceTableGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Ppi/Decompress/Decompress.c b/EDK/Foundation/Framework/Ppi/Decompress/Decompress.c
new file mode 100644
index 0000000..4b95013
--- /dev/null
+++ b/EDK/Foundation/Framework/Ppi/Decompress/Decompress.c
@@ -0,0 +1,28 @@
+/*++
+
+Copyright (c) 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Decompress.c
+
+Abstract:
+
+ PI 1.0 spec definition.
+
+--*/
+
+#include "Tiano.h"
+#include "Pei.h"
+#include EFI_PPI_DEFINITION (Decompress)
+
+
+EFI_GUID gEfiPeiDecompressPpiGuid = EFI_PEI_DECOMPRESS_PPI_GUID;
+EFI_GUID_STRING(&gEfiPeiDecompressPpiGuid, "PeiDecompress", "PeiDecompress PPI");
diff --git a/EDK/Foundation/Framework/Ppi/Decompress/Decompress.h b/EDK/Foundation/Framework/Ppi/Decompress/Decompress.h
new file mode 100644
index 0000000..7007576
--- /dev/null
+++ b/EDK/Foundation/Framework/Ppi/Decompress/Decompress.h
@@ -0,0 +1,49 @@
+/*++
+
+Copyright (c) 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Decompress.h
+
+Abstract:
+
+ PI 1.0 spec definition.
+
+--*/
+
+#ifndef __DECOMPRESS_PPI_H__
+#define __DECOMPRESS_PPI_H__
+
+
+#define EFI_PEI_DECOMPRESS_PPI_GUID \
+ { 0x1a36e4e7, 0xfab6, 0x476a, 0x8e, 0x75, 0x69, 0x5a, 0x5, 0x76, 0xfd, 0xd7}
+
+EFI_FORWARD_DECLARATION (EFI_PEI_DECOMPRESS_PPI);
+
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_DECOMPRESS_DECOMPRESS)(
+ IN CONST EFI_PEI_DECOMPRESS_PPI *This,
+ IN CONST EFI_COMPRESSION_SECTION *InputSection,
+ OUT VOID **OutputBuffer,
+ OUT UINTN *OutputSize
+ );
+
+typedef struct _EFI_PEI_DECOMPRESS_PPI {
+ EFI_PEI_DECOMPRESS_DECOMPRESS Decompress;
+} EFI_PEI_DECOMPRESS_PPI;
+
+
+
+extern EFI_GUID gEfiPeiDecompressPpiGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Ppi/DeviceRecoveryModule/DeviceRecoveryModule.c b/EDK/Foundation/Framework/Ppi/DeviceRecoveryModule/DeviceRecoveryModule.c
new file mode 100644
index 0000000..909b8d7
--- /dev/null
+++ b/EDK/Foundation/Framework/Ppi/DeviceRecoveryModule/DeviceRecoveryModule.c
@@ -0,0 +1,30 @@
+/*++
+
+Copyright (c) 1999 - 2002, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ DeviceRecoveryModule.c
+
+Abstract:
+
+ Device Recovery Module PPI GUID as defined in PEI EAS
+
+--*/
+
+#include "Tiano.h"
+#include "PeiBind.h"
+#include "PeiApi.h"
+#include EFI_PPI_DEFINITION (DeviceRecoveryModule)
+
+EFI_GUID gPeiDeviceRecoveryModulePpiGuid = PEI_DEVICE_RECOVERY_MODULE_INTERFACE_PPI;
+
+EFI_GUID_STRING(&gPeiDeviceRecoveryModulePpiGuid, "DeviceRecoveryModule", "Device Recovery Module PPI");
diff --git a/EDK/Foundation/Framework/Ppi/DeviceRecoveryModule/DeviceRecoveryModule.h b/EDK/Foundation/Framework/Ppi/DeviceRecoveryModule/DeviceRecoveryModule.h
new file mode 100644
index 0000000..40d0602
--- /dev/null
+++ b/EDK/Foundation/Framework/Ppi/DeviceRecoveryModule/DeviceRecoveryModule.h
@@ -0,0 +1,68 @@
+/*++
+
+Copyright (c) 1999 - 2002, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ DeviceRecoveryModule.h
+
+Abstract:
+
+ Device Recovery Module PPI as defined in EFI 2.0
+
+--*/
+
+#ifndef _PEI_DEVICE_RECOVERY_MODULE_PPI_H
+#define _PEI_DEVICE_RECOVERY_MODULE_PPI_H
+
+#define PEI_DEVICE_RECOVERY_MODULE_INTERFACE_PPI \
+ { \
+ 0x0DE2CE25, 0x446A, 0x45a7, 0xBF, 0xC9, 0x37, 0xDA, 0x26, 0x34, 0x4B, 0x37 \
+ }
+
+EFI_FORWARD_DECLARATION (PEI_DEVICE_RECOVERY_MODULE_INTERFACE);
+
+typedef
+EFI_STATUS
+(EFIAPI *PEI_DEVICE_GET_NUMBER_RECOVERY_CAPSULE) (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_DEVICE_RECOVERY_MODULE_INTERFACE * This,
+ OUT UINTN *NumberRecoveryCapsules
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *PEI_DEVICE_GET_RECOVERY_CAPSULE_INFO) (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_DEVICE_RECOVERY_MODULE_INTERFACE * This,
+ IN UINTN CapsuleInstance,
+ OUT UINTN *Size,
+ OUT EFI_GUID * CapsuleType
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *PEI_DEVICE_LOAD_RECOVERY_CAPSULE) (
+ IN OUT EFI_PEI_SERVICES **PeiServices,
+ IN PEI_DEVICE_RECOVERY_MODULE_INTERFACE * This,
+ IN UINTN CapsuleInstance,
+ OUT VOID *Buffer
+ );
+
+typedef struct _PEI_DEVICE_RECOVERY_MODULE_INTERFACE {
+ PEI_DEVICE_GET_NUMBER_RECOVERY_CAPSULE GetNumberRecoveryCapsules;
+ PEI_DEVICE_GET_RECOVERY_CAPSULE_INFO GetRecoveryCapsuleInfo;
+ PEI_DEVICE_LOAD_RECOVERY_CAPSULE LoadRecoveryCapsule;
+} PEI_DEVICE_RECOVERY_MODULE_INTERFACE;
+
+extern EFI_GUID gPeiDeviceRecoveryModulePpiGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Ppi/DxeIpl/DxeIpl.c b/EDK/Foundation/Framework/Ppi/DxeIpl/DxeIpl.c
new file mode 100644
index 0000000..4884011
--- /dev/null
+++ b/EDK/Foundation/Framework/Ppi/DxeIpl/DxeIpl.c
@@ -0,0 +1,29 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ DxeIpl.c
+
+Abstract:
+
+ DXE Initial Program Load PPI GUID as defined in Tiano
+
+--*/
+
+#include "Tiano.h"
+#include "PeiBind.h"
+#include "PeiApi.h"
+#include EFI_PPI_DEFINITION (DxeIpl)
+
+EFI_GUID gEfiDxeIplPpiGuid = EFI_DXE_IPL_PPI_GUID;
+
+EFI_GUID_STRING(&gEfiDxeIplPpiGuid, "DxeIpl", "DXE IPL PPI");
diff --git a/EDK/Foundation/Framework/Ppi/DxeIpl/DxeIpl.h b/EDK/Foundation/Framework/Ppi/DxeIpl/DxeIpl.h
new file mode 100644
index 0000000..688ec8a
--- /dev/null
+++ b/EDK/Foundation/Framework/Ppi/DxeIpl/DxeIpl.h
@@ -0,0 +1,51 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ DxeIpl.h
+
+Abstract:
+
+ DXE Initial Program Load PPI as defined in Tiano
+
+ When the PEI core is done it calls the DXE IPL via this PPI.
+
+--*/
+
+#ifndef _DXE_IPL_H_
+#define _DXE_IPL_H_
+
+#include "Tiano.h"
+#include "PeiHob.h"
+
+#define EFI_DXE_IPL_PPI_GUID \
+ { \
+ 0xae8ce5d, 0xe448, 0x4437, 0xa8, 0xd7, 0xeb, 0xf5, 0xf1, 0x94, 0xf7, 0x31 \
+ }
+
+EFI_FORWARD_DECLARATION (EFI_DXE_IPL_PPI);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_DXE_IPL_ENTRY) (
+ IN EFI_DXE_IPL_PPI * This,
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PEI_HOB_POINTERS HobList
+ );
+
+typedef struct _EFI_DXE_IPL_PPI {
+ EFI_DXE_IPL_ENTRY Entry;
+} EFI_DXE_IPL_PPI;
+
+extern EFI_GUID gEfiDxeIplPpiGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Ppi/EcpPciCfg/EcpPciCfg.c b/EDK/Foundation/Framework/Ppi/EcpPciCfg/EcpPciCfg.c
new file mode 100644
index 0000000..6a2194e
--- /dev/null
+++ b/EDK/Foundation/Framework/Ppi/EcpPciCfg/EcpPciCfg.c
@@ -0,0 +1,28 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EcpPciCfg.c
+
+Abstract:
+
+ This PPI which is same with PciCfg PPI. But Modify API is removed.
+
+--*/
+
+#include "Tiano.h"
+#include "Pei.h"
+#include EFI_PPI_DEFINITION (EcpPciCfg)
+
+EFI_GUID gEcpPeiPciCfgPpiGuid = ECP_PEI_PCI_CFG_PPI_GUID;
+
+EFI_GUID_STRING(&gEcpPeiPciCfgPpiGuid, "Ecp PciCfg", "Ecp PciCfg PPI");
diff --git a/EDK/Foundation/Framework/Ppi/EcpPciCfg/EcpPciCfg.h b/EDK/Foundation/Framework/Ppi/EcpPciCfg/EcpPciCfg.h
new file mode 100644
index 0000000..eddd9bb
--- /dev/null
+++ b/EDK/Foundation/Framework/Ppi/EcpPciCfg/EcpPciCfg.h
@@ -0,0 +1,50 @@
+/*++
+
+Copyright (c) 2008, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PciCfg.h
+
+Abstract:
+
+ This PPI which is same with PciCfg PPI. But Modify API is removed.
+
+--*/
+
+#ifndef _ECP_PEI_PCI_CFG_H_
+#define _ECP_PEI_PCI_CFG_H_
+#include EFI_PPI_DEFINITION (PciCfg)
+
+#define ECP_PEI_PCI_CFG_PPI_GUID \
+ {0xb0ee53d4, 0xa049, 0x4a79, { 0xb2, 0xff, 0x19, 0xd9, 0xfa, 0xef, 0xaa, 0x94 }}
+
+EFI_FORWARD_DECLARATION (ECP_PEI_PCI_CFG_PPI);
+
+
+typedef
+EFI_STATUS
+(EFIAPI *ECP_PEI_PCI_CFG_PPI_IO) (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN ECP_PEI_PCI_CFG_PPI *This,
+ IN PEI_PCI_CFG_PPI_WIDTH Width,
+ IN UINT64 Address,
+ IN OUT VOID *Buffer
+ );
+
+struct _ECP_PEI_PCI_CFG_PPI {
+ ECP_PEI_PCI_CFG_PPI_IO Read;
+ ECP_PEI_PCI_CFG_PPI_IO Write;
+};
+
+extern EFI_GUID gEcpPeiPciCfgPpiGuid;
+
+#endif
+
diff --git a/EDK/Foundation/Framework/Ppi/EdkFrameworkPpiLib.cif b/EDK/Foundation/Framework/Ppi/EdkFrameworkPpiLib.cif
new file mode 100644
index 0000000..fecf03f
--- /dev/null
+++ b/EDK/Foundation/Framework/Ppi/EdkFrameworkPpiLib.cif
@@ -0,0 +1,74 @@
+<component>
+ name = "EdkFrameworkPpiLib"
+ category = ModulePart
+ LocalRoot = "Edk\Foundation\Framework\Ppi\"
+ RefName = "EdkFrameworkPpiLib"
+[files]
+"EdkFrameworkPpiLib.sdl"
+"EdkFrameworkPpiLib.mak"
+"BlockIo\BlockIo.h"
+"BlockIo\BlockIo.c"
+"BootInRecoveryMode\BootInRecoveryMode.h"
+"BootInRecoveryMode\BootInRecoveryMode.c"
+"BootMode\BootMode.h"
+"BootMode\BootMode.c"
+"BootScriptExecuter\BootScriptExecuter.h"
+"BootScriptExecuter\BootScriptExecuter.c"
+"CpuIo\CpuIo.h"
+"CpuIo\CpuIo.c"
+"DeviceRecoveryModule\DeviceRecoveryModule.h"
+"DeviceRecoveryModule\DeviceRecoveryModule.c"
+"DxeIpl\DxeIpl.h"
+"DxeIpl\DxeIpl.c"
+"EndOfPeiSignal\EndOfPeiSignal.h"
+"EndOfPeiSignal\EndOfPeiSignal.c"
+"FindFv\FindFv.h"
+"FindFv\FindFv.c"
+"LoadFile\LoadFile.h"
+"LoadFile\LoadFile.c"
+"MemoryDiscovered\MemoryDiscovered.h"
+"MemoryDiscovered\MemoryDiscovered.c"
+"PciCfg\PciCfg.h"
+"PciCfg\PciCfg.c"
+"PciCfg2\PciCfg2.h"
+"PciCfg2\PciCfg2.c"
+"RecoveryModule\RecoveryModule.h"
+"RecoveryModule\RecoveryModule.c"
+"Reset\Reset.h"
+"Reset\Reset.c"
+"S3Resume\S3Resume.h"
+"S3Resume\S3Resume.c"
+"SecPlatformInformation\SecPlatformInformation.h"
+"SecPlatformInformation\SecPlatformInformation.c"
+"SectionExtraction\SectionExtraction.h"
+"SectionExtraction\SectionExtraction.c"
+"Security\Security.h"
+"Security\Security.c"
+"Smbus\Smbus.h"
+"Smbus\Smbus.c"
+"Smbus2\Smbus2.h"
+"Smbus2\Smbus2.c"
+"Stall\Stall.h"
+"Stall\Stall.c"
+"StatusCode\StatusCode.h"
+"StatusCode\StatusCode.c"
+"Variable\Variable.h"
+"Variable\Variable.c"
+"Variable2\Variable2.h"
+"Variable2\Variable2.c"
+"Decompress\Decompress.h"
+"Decompress\Decompress.c"
+"FirmwareVolumeInfo\FirmwareVolumeInfo.h"
+"FirmwareVolumeInfo\FirmwareVolumeInfo.c"
+"LoadFile2\LoadFile2.h"
+"LoadFile2\LoadFile2.c"
+"Security2\Security2.h"
+"Security2\Security2.c"
+"FirmwareVolume\FirmwareVolume.h"
+"FirmwareVolume\FirmwareVolume.c"
+"GuidedSectionExtraction\GuidedSectionExtraction.h"
+"GuidedSectionExtraction\GuidedSectionExtraction.c"
+"EdkFrameworkPpiLib.inf"
+"EcpPciCfg\EcpPciCfg.c"
+"EcpPciCfg\EcpPciCfg.h"
+<endComponent>
diff --git a/EDK/Foundation/Framework/Ppi/EdkFrameworkPpiLib.inf b/EDK/Foundation/Framework/Ppi/EdkFrameworkPpiLib.inf
new file mode 100644
index 0000000..95e2542
--- /dev/null
+++ b/EDK/Foundation/Framework/Ppi/EdkFrameworkPpiLib.inf
@@ -0,0 +1,91 @@
+#/*++
+#
+# Copyright (c) 2004, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# EdkFrameworkPpiLib.inf
+#
+# Abstract:
+#
+# Component description file.
+#
+#--*/
+
+[defines]
+BASE_NAME= EdkFrameworkPpiLib
+COMPONENT_TYPE= LIBRARY
+
+[includes.common]
+ $(EDK_SOURCE)\Foundation\Framework
+ $(EDK_SOURCE)\Foundation\Efi
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)\Foundation\Include\Pei
+ $(EDK_SOURCE)\Foundation\Library\Pei\Include
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+
+[nmake.common]
+C_STD_INCLUDE=
+
+[sources.common]
+ BlockIo\BlockIo.h
+ BlockIo\BlockIo.c
+ BootInRecoveryMode\BootInRecoveryMode.h
+ BootInRecoveryMode\BootInRecoveryMode.c
+ BootMode\BootMode.h
+ BootMode\BootMode.c
+ BootScriptExecuter\BootScriptExecuter.h
+ BootScriptExecuter\BootScriptExecuter.c
+ CpuIo\CpuIo.h
+ CpuIo\CpuIo.c
+ DeviceRecoveryModule\DeviceRecoveryModule.h
+ DeviceRecoveryModule\DeviceRecoveryModule.c
+ DxeIpl\DxeIpl.h
+ DxeIpl\DxeIpl.c
+ EndOfPeiSignal\EndOfPeiSignal.h
+ EndOfPeiSignal\EndOfPeiSignal.c
+ FindFv\FindFv.h
+ FindFv\FindFv.c
+ LoadFile\LoadFile.h
+ LoadFile\LoadFile.c
+ MemoryDiscovered\MemoryDiscovered.h
+ MemoryDiscovered\MemoryDiscovered.c
+ PciCfg\PciCfg.h
+ PciCfg\PciCfg.c
+ PciCfg2\PciCfg2.h
+ PciCfg2\PciCfg2.c
+ RecoveryModule\RecoveryModule.h
+ RecoveryModule\RecoveryModule.c
+ Reset\Reset.h
+ Reset\Reset.c
+ S3Resume\S3Resume.h
+ S3Resume\S3Resume.c
+ SecPlatformInformation\SecPlatformInformation.h
+ SecPlatformInformation\SecPlatformInformation.c
+ SectionExtraction\SectionExtraction.h
+ SectionExtraction\SectionExtraction.c
+ Security\Security.h
+ Security\Security.c
+ Smbus\Smbus.h
+ Smbus\Smbus.c
+ Stall\Stall.h
+ Stall\Stall.c
+ StatusCode\StatusCode.h
+ StatusCode\StatusCode.c
+ Variable\Variable.h
+ Variable\Variable.c
+ FirmwareVolumeInfo\FirmwareVolumeInfo.h
+ FirmwareVolumeInfo\FirmwareVolumeInfo.c
+ EcpPciCfg\EcpPciCfg.h
+ EcpPciCfg\EcpPciCfg.c
diff --git a/EDK/Foundation/Framework/Ppi/EdkFrameworkPpiLib.mak b/EDK/Foundation/Framework/Ppi/EdkFrameworkPpiLib.mak
new file mode 100644
index 0000000..1aec2e0
--- /dev/null
+++ b/EDK/Foundation/Framework/Ppi/EdkFrameworkPpiLib.mak
@@ -0,0 +1,70 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkFrameworkPpiLib/EdkFrameworkPpiLib.mak 2 3/27/12 4:26a Jeffch $
+#
+# $Revision: 2 $
+#
+# $Date: 3/27/12 4:26a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkFrameworkPpiLib/EdkFrameworkPpiLib.mak $
+#
+# 2 3/27/12 4:26a Jeffch
+#
+# 1 1/20/12 4:03a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 9/27/11 6:26a Wesleychen
+# Intel EDK initially releases.
+#
+# 2 9/02/09 3:19a Iminglin
+# EIP24919
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: EdkFrameworkPpiLib.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+
+$(EDKFRAMEWORKPPILIB) : EdkFrameworkPpiLib
+
+EdkFrameworkPpiLib : $(BUILD_DIR)\EdkFrameworkPpiLib.mak EdkFrameworkPpiLibBin
+
+$(BUILD_DIR)\EdkFrameworkPpiLib.mak : $(EdkFrameworkPpiLib_DIR)\$(@B).cif $(EdkFrameworkPpiLib_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(EdkFrameworkPpiLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+EdkFrameworkPpiLibBin : $(EDKPPILIB)
+ $(MAKE) /$(MAKEFLAGS) $(EDK_DEFAULTS)\
+ /f $(BUILD_DIR)\EdkFrameworkPpiLib.mak all\
+ TYPE=PEI_LIBRARY \
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#********************************************************************** \ No newline at end of file
diff --git a/EDK/Foundation/Framework/Ppi/EdkFrameworkPpiLib.sdl b/EDK/Foundation/Framework/Ppi/EdkFrameworkPpiLib.sdl
new file mode 100644
index 0000000..5485bc0
--- /dev/null
+++ b/EDK/Foundation/Framework/Ppi/EdkFrameworkPpiLib.sdl
@@ -0,0 +1,26 @@
+TOKEN
+ Name = "EdkFrameworkPpiLib_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable EdkFrameworkPpiLib support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "EDKFRAMEWORKPPILIB"
+ Value = "$(BUILD_DIR)\EdkFrameworkPpiLib.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "EdkFrameworkPpiLib_DIR"
+End
+
+MODULE
+ Help = "Includes EdkFrameworkPpiLib.mak to Project"
+ File = "EdkFrameworkPpiLib.mak"
+End
+
diff --git a/EDK/Foundation/Framework/Ppi/EndOfPeiSignal/EndOfPeiSignal.c b/EDK/Foundation/Framework/Ppi/EndOfPeiSignal/EndOfPeiSignal.c
new file mode 100644
index 0000000..eb43147
--- /dev/null
+++ b/EDK/Foundation/Framework/Ppi/EndOfPeiSignal/EndOfPeiSignal.c
@@ -0,0 +1,29 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EndOfPeiSignal.c
+
+Abstract:
+
+ This is installed prior to DXE taking over the memory map
+
+--*/
+
+#include "Tiano.h"
+#include "PeiBind.h"
+#include "PeiApi.h"
+#include EFI_PPI_DEFINITION (EndOfPeiSignal)
+
+EFI_GUID gEndOfPeiSignalPpiGuid = PEI_END_OF_PEI_PHASE_PPI_GUID;
+
+EFI_GUID_STRING(&gEndOfPeiSignalPpiGuid, "EndOfPeiSignal", "End of PEI Phase Signalled PPI");
diff --git a/EDK/Foundation/Framework/Ppi/EndOfPeiSignal/EndOfPeiSignal.h b/EDK/Foundation/Framework/Ppi/EndOfPeiSignal/EndOfPeiSignal.h
new file mode 100644
index 0000000..155ed82
--- /dev/null
+++ b/EDK/Foundation/Framework/Ppi/EndOfPeiSignal/EndOfPeiSignal.h
@@ -0,0 +1,35 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EndOfPeiSignal.h
+
+Abstract:
+
+ PPI to be used to signal when the PEI ownership of the memory map
+ officially ends and DXE will take over
+
+--*/
+
+#ifndef _PEI_END_OF_PEI_SIGNAL_PPI_H
+#define _PEI_END_OF_PEI_SIGNAL_PPI_H
+
+#define PEI_END_OF_PEI_PHASE_PPI_GUID \
+ { \
+ 0x605EA650, 0xC65C, 0x42e1, 0xBA, 0x80, 0x91, 0xA5, 0x2A, 0xB6, 0x18, 0xC6 \
+ }
+
+EFI_FORWARD_DECLARATION (PEI_END_OF_PEI_SIGNAL_PPI);
+
+extern EFI_GUID gEndOfPeiSignalPpiGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Ppi/FindFv/FindFv.c b/EDK/Foundation/Framework/Ppi/FindFv/FindFv.c
new file mode 100644
index 0000000..91b06fd
--- /dev/null
+++ b/EDK/Foundation/Framework/Ppi/FindFv/FindFv.c
@@ -0,0 +1,29 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ FindFv.c
+
+Abstract:
+
+ FindFv PPI GUID as defined in Tiano
+
+--*/
+
+#include "Tiano.h"
+#include "PeiBind.h"
+#include "PeiApi.h"
+#include EFI_PPI_DEFINITION (FindFv)
+
+EFI_GUID gEfiFindFvPpiGuid = EFI_FIND_FV_PPI_GUID;
+
+EFI_GUID_STRING(&gEfiFindFvPpiGuid, "FindFv", "FindFv PPI");
diff --git a/EDK/Foundation/Framework/Ppi/FindFv/FindFv.h b/EDK/Foundation/Framework/Ppi/FindFv/FindFv.h
new file mode 100644
index 0000000..da87115
--- /dev/null
+++ b/EDK/Foundation/Framework/Ppi/FindFv/FindFv.h
@@ -0,0 +1,51 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ FindFv.h
+
+Abstract:
+
+ FindFv PPI as defined in Tiano
+
+ Used to locate FVs that contain PEIMs in PEI
+
+--*/
+
+#ifndef _FIND_FV_H_
+#define _FIND_FV_H_
+
+#include "EfiFirmwareVolumeHeader.h"
+
+#define EFI_FIND_FV_PPI_GUID \
+ { \
+ 0x36164812, 0xa023, 0x44e5, 0xbd, 0x85, 0x5, 0xbf, 0x3c, 0x77, 0x0, 0xaa \
+ }
+
+EFI_FORWARD_DECLARATION (EFI_FIND_FV_PPI);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_FIND_FV_FINDFV) (
+ IN EFI_FIND_FV_PPI * This,
+ IN EFI_PEI_SERVICES **PeiServices,
+ UINT8 *FvNumber,
+ EFI_FIRMWARE_VOLUME_HEADER **FVAddress
+ );
+
+typedef struct _EFI_FIND_FV_PPI {
+ EFI_FIND_FV_FINDFV FindFv;
+} EFI_FIND_FV_PPI;
+
+extern EFI_GUID gEfiFindFvPpiGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Ppi/FirmwareVolume/FirmwareVolume.c b/EDK/Foundation/Framework/Ppi/FirmwareVolume/FirmwareVolume.c
new file mode 100644
index 0000000..5afe01f
--- /dev/null
+++ b/EDK/Foundation/Framework/Ppi/FirmwareVolume/FirmwareVolume.c
@@ -0,0 +1,30 @@
+/*++
+
+Copyright (c) 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ FirmwareVolume.c
+
+Abstract:
+
+ PI 1.0 spec definition.
+
+--*/
+
+
+#include "Tiano.h"
+#include "Pei.h"
+#include EFI_PPI_DEFINITION (FirmwareVolume)
+
+//
+// There is no PPI Guid definition here, since the guid of
+// this ppi is the same as the firmware volume format Guid.
+// \ No newline at end of file
diff --git a/EDK/Foundation/Framework/Ppi/FirmwareVolume/FirmwareVolume.h b/EDK/Foundation/Framework/Ppi/FirmwareVolume/FirmwareVolume.h
new file mode 100644
index 0000000..0c8b508
--- /dev/null
+++ b/EDK/Foundation/Framework/Ppi/FirmwareVolume/FirmwareVolume.h
@@ -0,0 +1,112 @@
+/*++
+
+Copyright (c) 2007 - 2009, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ FirmwareVolume.h
+
+Abstract:
+
+ PI 1.0 spec definition.
+
+--*/
+
+#ifndef __FIRMWARE_VOLUME_H__
+#define __FIRMWARE_VOLUME_H__
+
+EFI_FORWARD_DECLARATION (EFI_PEI_FIRMWARE_VOLUME_PPI);
+
+typedef UINT32 EFI_FV_FILE_ATTRIBUTES;
+typedef VOID * EFI_PEI_FILE_HANDLE;
+typedef VOID * EFI_PEI_FV_HANDLE;
+
+
+typedef struct {
+ EFI_GUID FileName;
+ EFI_FV_FILETYPE FileType;
+ EFI_FV_FILE_ATTRIBUTES FileAttributes;
+ VOID *Buffer;
+ UINT32 BufferSize;
+} EFI_FV_FILE_INFO;
+
+typedef struct {
+ EFI_FVB_ATTRIBUTES FvAttributes;
+ EFI_GUID FvFormat;
+ EFI_GUID FvName;
+ VOID *FvStart;
+ UINT64 FvSize;
+} EFI_FV_INFO;
+
+
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_FV_PROCESS_FV) (
+ IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI *This,
+ IN VOID *Buffer,
+ IN UINTN BufferSize,
+ OUT EFI_PEI_FV_HANDLE *FvHandle
+ );
+
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_FV_FIND_FILE_TYPE) (
+ IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI *This,
+ IN EFI_FV_FILETYPE SearchType,
+ IN EFI_PEI_FV_HANDLE FvHandle,
+ IN OUT EFI_PEI_FILE_HANDLE *FileHandle
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_FV_FIND_FILE_NAME) (
+ IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI *This,
+ IN CONST EFI_GUID *FileName,
+ IN OUT EFI_PEI_FV_HANDLE *FvHandle,
+ OUT EFI_PEI_FILE_HANDLE *FileHandle
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_FV_GET_FILE_INFO) (
+ IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI *This,
+ IN EFI_PEI_FILE_HANDLE FileHandle,
+ OUT EFI_FV_FILE_INFO *FileInfo
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_FV_GET_INFO)(
+ IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI *This,
+ IN EFI_PEI_FV_HANDLE FvHandle,
+ OUT EFI_FV_INFO *VolumeInfo
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_FV_FIND_SECTION) (
+ IN CONST EFI_PEI_FIRMWARE_VOLUME_PPI *This,
+ IN EFI_SECTION_TYPE SearchType,
+ IN EFI_PEI_FILE_HANDLE FileHandle,
+ OUT VOID **SectionData
+ );
+
+typedef struct _EFI_PEI_FIRMWARE_VOLUME_PPI {
+ EFI_PEI_FV_PROCESS_FV ProcessVolume;
+ EFI_PEI_FV_FIND_FILE_TYPE FindFileByType;
+ EFI_PEI_FV_FIND_FILE_NAME FindFileByName;
+ EFI_PEI_FV_GET_FILE_INFO GetFileInfo;
+ EFI_PEI_FV_GET_INFO GetVolumeInfo;
+ EFI_PEI_FV_FIND_SECTION FindSectionByType;
+} EFI_PEI_FIRMWARE_VOLUME_PPI;
+
+#endif
diff --git a/EDK/Foundation/Framework/Ppi/FirmwareVolumeInfo/FirmwareVolumeInfo.c b/EDK/Foundation/Framework/Ppi/FirmwareVolumeInfo/FirmwareVolumeInfo.c
new file mode 100644
index 0000000..ed00f62
--- /dev/null
+++ b/EDK/Foundation/Framework/Ppi/FirmwareVolumeInfo/FirmwareVolumeInfo.c
@@ -0,0 +1,28 @@
+/*++
+
+Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ FirmwareVolumeInfo.c
+
+Abstract:
+
+ PI 1.0 spec definition.
+
+--*/
+
+
+#include "Tiano.h"
+#include "Pei.h"
+#include EFI_PPI_DEFINITION (FirmwareVolumeInfo)
+
+EFI_GUID gEfiFirmwareVolumeInfoPpiGuid = EFI_PEI_FIRMWARE_VOLUME_INFO_PPI_GUID;
+EFI_GUID_STRING(&gEfiFirmwareVolumeInfoPpiGuid, "FirmwareVolumeInfo", "FirmwareVolumeInfo PPI");
diff --git a/EDK/Foundation/Framework/Ppi/FirmwareVolumeInfo/FirmwareVolumeInfo.h b/EDK/Foundation/Framework/Ppi/FirmwareVolumeInfo/FirmwareVolumeInfo.h
new file mode 100644
index 0000000..f1a49ee
--- /dev/null
+++ b/EDK/Foundation/Framework/Ppi/FirmwareVolumeInfo/FirmwareVolumeInfo.h
@@ -0,0 +1,46 @@
+/*++
+
+Copyright (c) 2007, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ FirmwareVolumeInfo.h
+
+Abstract:
+
+ PI 1.0 spec definition.
+
+--*/
+
+#ifndef __FIRMWARE_VOLUME_INFO_PPI__
+#define __FIRMWARE_VOLUME_INFO_PPI__
+
+EFI_FORWARD_DECLARATION (EFI_PEI_FIRMWARE_VOLUME_INFO_PPI);
+
+
+//
+// The PPI GUID must match the EFI_GUID FvFormat value
+//
+#define EFI_PEI_FIRMWARE_VOLUME_INFO_PPI_GUID \
+ { 0x49edb1c1, 0xbf21, 0x4761, { 0xbb, 0x12, 0xeb, 0x0, 0x31, 0xaa, 0xbb, 0x39 } }
+
+
+struct _EFI_PEI_FIRMWARE_VOLUME_INFO_PPI {
+ EFI_GUID FvFormat;
+ VOID *FvInfo;
+ UINT32 FvInfoSize;
+ EFI_GUID *ParentFvName;
+ EFI_GUID *ParentFileName;
+};
+
+
+extern EFI_GUID gEfiFirmwareVolumeInfoPpiGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Ppi/GuidedSectionExtraction/GuidedSectionExtraction.c b/EDK/Foundation/Framework/Ppi/GuidedSectionExtraction/GuidedSectionExtraction.c
new file mode 100644
index 0000000..a7460ac
--- /dev/null
+++ b/EDK/Foundation/Framework/Ppi/GuidedSectionExtraction/GuidedSectionExtraction.c
@@ -0,0 +1,29 @@
+/*++
+
+Copyright (c) 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ GuidedSectionExtraction.c
+
+Abstract:
+
+ PI 1.0 spec definition.
+
+--*/
+
+#include "Tiano.h"
+#include "Pei.h"
+#include EFI_PPI_DEFINITION (GuidedSectionExtraction)
+
+//
+// There is no PPI Guid definition here since this PPI is for
+// extract EFI_SECTION_GUID_DEFINED type section.
+// \ No newline at end of file
diff --git a/EDK/Foundation/Framework/Ppi/GuidedSectionExtraction/GuidedSectionExtraction.h b/EDK/Foundation/Framework/Ppi/GuidedSectionExtraction/GuidedSectionExtraction.h
new file mode 100644
index 0000000..b53ffa6
--- /dev/null
+++ b/EDK/Foundation/Framework/Ppi/GuidedSectionExtraction/GuidedSectionExtraction.h
@@ -0,0 +1,42 @@
+/*++
+
+Copyright (c) 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ GuidedSectionExtraction.h
+
+Abstract:
+
+ PI 1.0 spec definition.
+
+--*/
+
+
+#ifndef __GUIDED_SECTION_EXTRACTION_PPI_H__
+#define __GUIDED_SECTION_EXTRACTION_PPI_H__
+
+EFI_FORWARD_DECLARATION (EFI_PEI_GUIDED_SECTION_EXTRACTION_PPI);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_EXTRACT_GUIDED_SECTION)(
+ IN CONST EFI_PEI_GUIDED_SECTION_EXTRACTION_PPI *This,
+ IN CONST VOID *InputSection,
+ OUT VOID **OutputBuffer,
+ OUT UINTN *OutputSize,
+ OUT UINT32 *AuthenticationStatus
+ );
+
+typedef struct _EFI_PEI_GUIDED_SECTION_EXTRACTION_PPI {
+ EFI_PEI_EXTRACT_GUIDED_SECTION ExtractSection;
+} EFI_PEI_GUIDED_SECTION_EXTRACTION_PPI;
+
+#endif
diff --git a/EDK/Foundation/Framework/Ppi/LoadFile/LoadFile.c b/EDK/Foundation/Framework/Ppi/LoadFile/LoadFile.c
new file mode 100644
index 0000000..e8a4065
--- /dev/null
+++ b/EDK/Foundation/Framework/Ppi/LoadFile/LoadFile.c
@@ -0,0 +1,29 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ LoadFile.c
+
+Abstract:
+
+ Load File PPI GUID.
+
+--*/
+
+#include "Tiano.h"
+#include "PeiBind.h"
+#include "PeiApi.h"
+#include EFI_PPI_DEFINITION (LoadFile)
+
+EFI_GUID gPeiFvFileLoaderPpiGuid = EFI_PEI_FV_FILE_LOADER_GUID;
+
+EFI_GUID_STRING(&gPeiFvFileLoaderPpiGuid, "FvFileLoader", "Fv File Loader Support PPI");
diff --git a/EDK/Foundation/Framework/Ppi/LoadFile/LoadFile.h b/EDK/Foundation/Framework/Ppi/LoadFile/LoadFile.h
new file mode 100644
index 0000000..6cd4b1d
--- /dev/null
+++ b/EDK/Foundation/Framework/Ppi/LoadFile/LoadFile.h
@@ -0,0 +1,48 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ LoadFile.h
+
+Abstract:
+
+ Load image file from fv to memory.
+
+--*/
+
+#ifndef _PEI_FV_FILE_LOADER_PPI_H
+#define _PEI_FV_FILE_LOADER_PPI_H
+
+#define EFI_PEI_FV_FILE_LOADER_GUID \
+ { \
+ 0x7e1f0d85, 0x4ff, 0x4bb2, 0x86, 0x6a, 0x31, 0xa2, 0x99, 0x6a, 0x48, 0xa8 \
+ }
+
+EFI_FORWARD_DECLARATION (EFI_PEI_FV_FILE_LOADER_PPI);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_FV_LOAD_FILE) (
+ IN EFI_PEI_FV_FILE_LOADER_PPI * This,
+ IN EFI_FFS_FILE_HEADER * FfsHeader,
+ OUT EFI_PHYSICAL_ADDRESS * ImageAddress,
+ OUT UINT64 *ImageSize,
+ OUT EFI_PHYSICAL_ADDRESS * EntryPoint
+ );
+
+typedef struct _EFI_PEI_FV_FILE_LOADER_PPI {
+ EFI_PEI_FV_LOAD_FILE FvLoadFile;
+} EFI_PEI_FV_FILE_LOADER_PPI;
+
+extern EFI_GUID gPeiFvFileLoaderPpiGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Ppi/LoadFile2/LoadFile2.c b/EDK/Foundation/Framework/Ppi/LoadFile2/LoadFile2.c
new file mode 100644
index 0000000..9e63e7b
--- /dev/null
+++ b/EDK/Foundation/Framework/Ppi/LoadFile2/LoadFile2.c
@@ -0,0 +1,29 @@
+/*++
+
+Copyright (c) 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ LoadFile2.c
+
+Abstract:
+
+ PI 1.0 spec definition.
+
+--*/
+
+
+#include "Tiano.h"
+#include "Pei.h"
+#include EFI_PPI_DEFINITION (LoadFile2)
+
+
+EFI_GUID gEfiLoadFile2PpiGuid = EFI_PEI_LOAD_FILE_GUID;
+EFI_GUID_STRING(&gEfiLoadFile2PpiGuid, "PeiLoadFile2", "PeiLoadFile2 PPI");
diff --git a/EDK/Foundation/Framework/Ppi/LoadFile2/LoadFile2.h b/EDK/Foundation/Framework/Ppi/LoadFile2/LoadFile2.h
new file mode 100644
index 0000000..4646b1c
--- /dev/null
+++ b/EDK/Foundation/Framework/Ppi/LoadFile2/LoadFile2.h
@@ -0,0 +1,49 @@
+/*++
+
+Copyright (c) 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ LoadFile2.h
+
+Abstract:
+
+ PI 1.0 spec definition.
+
+--*/
+
+#ifndef __LOAD_FILE_PPI_H__
+#define __LOAD_FILE_PPI_H__
+
+EFI_FORWARD_DECLARATION (EFI_PEI_LOAD_FILE_PPI);
+
+#define EFI_PEI_LOAD_FILE_GUID \
+ { 0xb9e0abfe, 0x5979, 0x4914, 0x97, 0x7f, 0x6d, 0xee, 0x78, 0xc2, 0x78, 0xa6}
+
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_LOAD_FILE) (
+ IN CONST EFI_PEI_LOAD_FILE_PPI *This,
+ IN EFI_PEI_FILE_HANDLE FileHandle,
+ OUT EFI_PHYSICAL_ADDRESS *ImageAddress,
+ OUT UINT64 *ImageSize,
+ OUT EFI_PHYSICAL_ADDRESS *EntryPoint,
+ OUT UINT32 *AuthenticationState
+ );
+
+
+typedef struct _EFI_PEI_LOAD_FILE_PPI {
+ EFI_PEI_LOAD_FILE LoadFile;
+} EFI_PEI_LOAD_FILE_PPI;
+
+
+extern EFI_GUID gEfiLoadFile2PpiGuid;
+#endif
diff --git a/EDK/Foundation/Framework/Ppi/MemoryDiscovered/MemoryDiscovered.c b/EDK/Foundation/Framework/Ppi/MemoryDiscovered/MemoryDiscovered.c
new file mode 100644
index 0000000..8a4779f
--- /dev/null
+++ b/EDK/Foundation/Framework/Ppi/MemoryDiscovered/MemoryDiscovered.c
@@ -0,0 +1,29 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ MemoryDiscovered.c
+
+Abstract:
+
+ Memory Discovered PPI GUID as defined in PEI EAS
+
+--*/
+
+#include "Tiano.h"
+#include "PeiBind.h"
+#include "PeiApi.h"
+#include EFI_PPI_DEFINITION (MemoryDiscovered)
+
+EFI_GUID gPeiMemoryDiscoveredPpiGuid = PEI_PERMANENT_MEMORY_INSTALLED_PPI_GUID;
+
+EFI_GUID_STRING(&gPeiMemoryDiscoveredPpiGuid, "MemoryDiscovered", "Memory Discovered PPI");
diff --git a/EDK/Foundation/Framework/Ppi/MemoryDiscovered/MemoryDiscovered.h b/EDK/Foundation/Framework/Ppi/MemoryDiscovered/MemoryDiscovered.h
new file mode 100644
index 0000000..7cde19a
--- /dev/null
+++ b/EDK/Foundation/Framework/Ppi/MemoryDiscovered/MemoryDiscovered.h
@@ -0,0 +1,34 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ MemoryDiscovered.h
+
+Abstract:
+
+ Memory Discovered PPI as defined in Tiano
+
+--*/
+
+#ifndef _PEI_MEMORY_DISCOVERED_PPI_H
+#define _PEI_MEMORY_DISCOVERED_PPI_H
+
+#define PEI_PERMANENT_MEMORY_INSTALLED_PPI_GUID \
+ { \
+ 0xf894643d, 0xc449, 0x42d1, 0x8e, 0xa8, 0x85, 0xbd, 0xd8, 0xc6, 0x5b, 0xde \
+ }
+
+EFI_FORWARD_DECLARATION (PEI_PERMANENT_MEMORY_INSTALLED_PPI);
+
+extern EFI_GUID gPeiMemoryDiscoveredPpiGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Ppi/PciCfg/PciCfg.c b/EDK/Foundation/Framework/Ppi/PciCfg/PciCfg.c
new file mode 100644
index 0000000..5bc6f68
--- /dev/null
+++ b/EDK/Foundation/Framework/Ppi/PciCfg/PciCfg.c
@@ -0,0 +1,28 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PciCfg.c
+
+Abstract:
+
+ PciCfg PPI GUID as defined in PEI CIS specification.
+
+--*/
+
+#include "Tiano.h"
+#include "Pei.h"
+#include EFI_PPI_DEFINITION (PciCfg)
+
+EFI_GUID gPeiPciCfgPpiInServiceTableGuid = PEI_PCI_CFG_PPI_GUID;
+
+EFI_GUID_STRING(&gPeiPciCfgPpiInServiceTableGuid, "PciCfg", "PciCfg PPI");
diff --git a/EDK/Foundation/Framework/Ppi/PciCfg/PciCfg.h b/EDK/Foundation/Framework/Ppi/PciCfg/PciCfg.h
new file mode 100644
index 0000000..d116b50
--- /dev/null
+++ b/EDK/Foundation/Framework/Ppi/PciCfg/PciCfg.h
@@ -0,0 +1,65 @@
+/*++
+
+Copyright (c) 2004 - 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PciCfg.h
+
+Abstract:
+
+ PciCfg PPI as defined in PEI CIS specification
+
+ Used to access PCI configuration space in PEI
+
+--*/
+
+#ifndef _PEI_PCI_CFG_H_
+#define _PEI_PCI_CFG_H_
+#include "EfiPciCfg.h"
+
+#define PEI_PCI_CFG_PPI_GUID \
+ { \
+ 0xe1f2eba0, 0xf7b9, 0x4a26, 0x86, 0x20, 0x13, 0x12, 0x21, 0x64, 0x2a, 0x90 \
+ }
+
+EFI_FORWARD_DECLARATION (PEI_PCI_CFG_PPI);
+
+
+typedef
+EFI_STATUS
+(EFIAPI *PEI_PCI_CFG_PPI_IO) (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_PCI_CFG_PPI * This,
+ IN PEI_PCI_CFG_PPI_WIDTH Width,
+ IN UINT64 Address,
+ IN OUT VOID *Buffer
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *PEI_PCI_CFG_PPI_RW) (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_PCI_CFG_PPI * This,
+ IN PEI_PCI_CFG_PPI_WIDTH Width,
+ IN UINT64 Address,
+ IN UINTN SetBits,
+ IN UINTN ClearBits
+ );
+
+typedef struct _PEI_PCI_CFG_PPI {
+ PEI_PCI_CFG_PPI_IO Read;
+ PEI_PCI_CFG_PPI_IO Write;
+ PEI_PCI_CFG_PPI_RW Modify;
+} PEI_PCI_CFG_PPI;
+
+extern EFI_GUID gPeiPciCfgPpiInServiceTableGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Ppi/PciCfg2/PciCfg2.c b/EDK/Foundation/Framework/Ppi/PciCfg2/PciCfg2.c
new file mode 100644
index 0000000..e733d74
--- /dev/null
+++ b/EDK/Foundation/Framework/Ppi/PciCfg2/PciCfg2.c
@@ -0,0 +1,28 @@
+/*++
+
+Copyright (c) 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PciCfg2.c
+
+Abstract:
+
+ PciCfg2 PPI GUID as defined in PI1.0 specification.
+
+--*/
+
+#include "Tiano.h"
+#include "Pei.h"
+#include EFI_PPI_DEFINITION (PciCfg2)
+
+EFI_GUID gPeiPciCfg2PpiGuid = EFI_PEI_PCI_CFG2_PPI_GUID;
+
+EFI_GUID_STRING(&gPeiPciCfg2PpiGuid, "PciCfg2", "PciCfg2 PPI");
diff --git a/EDK/Foundation/Framework/Ppi/PciCfg2/PciCfg2.h b/EDK/Foundation/Framework/Ppi/PciCfg2/PciCfg2.h
new file mode 100644
index 0000000..285f97c
--- /dev/null
+++ b/EDK/Foundation/Framework/Ppi/PciCfg2/PciCfg2.h
@@ -0,0 +1,67 @@
+/*++
+
+Copyright (c) 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PciCfg2.h
+
+Abstract:
+
+ PciCfg2 PPI as defined in PI1.0 specification
+
+ Used to access PCI configuration space in PEI
+
+--*/
+
+#ifndef _PEI_PCI_CFG2_H_
+#define _PEI_PCI_CFG2_H_
+#include "EfiPciCfg.h"
+
+//;;## ...AMI_OVERRIDE... Fixed Build error issue.
+#define EFI_PEI_PCI_CFG2_PPI_GUID \
+ { \
+ 0x57a449a, 0x1fdc, 0x4c06, 0xbf, 0xc9, 0xf5, 0x3f, 0x6a, 0x99, 0xbb, 0x92 \
+ }
+
+EFI_FORWARD_DECLARATION (EFI_PEI_PCI_CFG2_PPI);
+
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_PCI_CFG_PPI_IO) (
+ IN CONST EFI_PEI_SERVICES **PeiServices,
+ IN CONST EFI_PEI_PCI_CFG2_PPI *This,
+ IN EFI_PEI_PCI_CFG_PPI_WIDTH Width,
+ IN UINT64 Address,
+ IN OUT VOID *Buffer
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_PCI_CFG_PPI_RW) (
+ IN CONST EFI_PEI_SERVICES **PeiServices,
+ IN CONST EFI_PEI_PCI_CFG2_PPI *This,
+ IN EFI_PEI_PCI_CFG_PPI_WIDTH Width,
+ IN UINT64 Address,
+ IN VOID *SetBits,
+ IN VOID *ClearBits
+ );
+
+struct _EFI_PEI_PCI_CFG2_PPI {
+ EFI_PEI_PCI_CFG_PPI_IO Read;
+ EFI_PEI_PCI_CFG_PPI_IO Write;
+ EFI_PEI_PCI_CFG_PPI_RW Modify;
+ UINT16 Segment;
+};
+
+extern EFI_GUID gPeiPciCfg2PpiGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Ppi/RecoveryModule/RecoveryModule.c b/EDK/Foundation/Framework/Ppi/RecoveryModule/RecoveryModule.c
new file mode 100644
index 0000000..ad53fe3
--- /dev/null
+++ b/EDK/Foundation/Framework/Ppi/RecoveryModule/RecoveryModule.c
@@ -0,0 +1,29 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ RecoveryModule.c
+
+Abstract:
+
+ Recovery Module PPI GUID as defined in PEI EAS
+
+--*/
+
+#include "Tiano.h"
+#include "PeiBind.h"
+#include "PeiApi.h"
+#include EFI_PPI_DEFINITION (RecoveryModule)
+
+EFI_GUID gPeiRecoveryModulePpiGuid = PEI_RECOVERY_MODULE_INTERFACE_PPI;
+
+EFI_GUID_STRING(&gPeiRecoveryModulePpiGuid, "RecoveryModule", "Recovery Module PPI");
diff --git a/EDK/Foundation/Framework/Ppi/RecoveryModule/RecoveryModule.h b/EDK/Foundation/Framework/Ppi/RecoveryModule/RecoveryModule.h
new file mode 100644
index 0000000..c36e914
--- /dev/null
+++ b/EDK/Foundation/Framework/Ppi/RecoveryModule/RecoveryModule.h
@@ -0,0 +1,45 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ RecoveryModule.h
+
+Abstract:
+
+ Recovery Module PPI as defined in Tiano
+
+--*/
+
+#ifndef _PEI_RECOVERY_MODULE_PPI_H
+#define _PEI_RECOVERY_MODULE_PPI_H
+
+#define PEI_RECOVERY_MODULE_INTERFACE_PPI \
+ { \
+ 0xFB6D9542, 0x612D, 0x4f45, 0x87, 0x2F, 0x5C, 0xFF, 0x52, 0xE9, 0x3D, 0xCF \
+ }
+
+EFI_FORWARD_DECLARATION (PEI_RECOVERY_MODULE_INTERFACE);
+
+typedef
+EFI_STATUS
+(EFIAPI *PEI_LOAD_RECOVERY_CAPSULE) (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_RECOVERY_MODULE_INTERFACE * This
+ );
+
+typedef struct _PEI_RECOVERY_MODULE_INTERFACE {
+ PEI_LOAD_RECOVERY_CAPSULE LoadRecoveryCapsule;
+} PEI_RECOVERY_MODULE_INTERFACE;
+
+extern EFI_GUID gPeiRecoveryModulePpiGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Ppi/Reset/Reset.c b/EDK/Foundation/Framework/Ppi/Reset/Reset.c
new file mode 100644
index 0000000..6f680b2
--- /dev/null
+++ b/EDK/Foundation/Framework/Ppi/Reset/Reset.c
@@ -0,0 +1,28 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Reset.c
+
+Abstract:
+
+ Reset Service PPI GUID as defined in Tiano
+
+--*/
+
+#include "Tiano.h"
+#include "Pei.h"
+#include EFI_PPI_DEFINITION (Reset)
+
+EFI_GUID gPeiResetPpiGuid = PEI_RESET_PPI_GUID;
+
+EFI_GUID_STRING(&gPeiResetPpiGuid, "Reset", "Reset PPI");
diff --git a/EDK/Foundation/Framework/Ppi/Reset/Reset.h b/EDK/Foundation/Framework/Ppi/Reset/Reset.h
new file mode 100644
index 0000000..8239b42
--- /dev/null
+++ b/EDK/Foundation/Framework/Ppi/Reset/Reset.h
@@ -0,0 +1,54 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Reset.h
+
+Abstract:
+
+ Reset PPI as defined in Tiano
+
+ Used to reset the platform from PEI
+
+--*/
+
+#ifndef _PEI_RESET_H_
+#define _PEI_RESET_H_
+
+#define PEI_RESET_PPI_GUID \
+ { \
+ 0xef398d58, 0x9dfd, 0x4103, 0xbf, 0x94, 0x78, 0xc6, 0xf4, 0xfe, 0x71, 0x2f \
+ }
+
+//
+// *******************************************************
+// PEI_RESET_TYPE
+// *******************************************************
+//
+typedef enum {
+ PeiResetCold,
+ PeiResetWarm,
+} PEI_RESET_TYPE;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_RESET_SYSTEM) (
+ IN EFI_PEI_SERVICES **PeiServices
+ );
+
+typedef struct {
+ EFI_PEI_RESET_SYSTEM ResetSystem;
+} PEI_RESET_PPI;
+
+extern EFI_GUID gPeiResetPpiGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Ppi/S3Resume/S3Resume.c b/EDK/Foundation/Framework/Ppi/S3Resume/S3Resume.c
new file mode 100644
index 0000000..12b8e56
--- /dev/null
+++ b/EDK/Foundation/Framework/Ppi/S3Resume/S3Resume.c
@@ -0,0 +1,29 @@
+/*++
+
+ Copyright (c) 2004, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ S3Resume.c
+
+Abstract:
+
+ Boot Script Executer PPI GUID as defined in Tiano
+
+--*/
+
+#include "Tiano.h"
+#include "PeiBind.h"
+#include "PeiApi.h"
+#include EFI_PPI_DEFINITION (S3Resume)
+
+EFI_GUID gPeiS3ResumePpiGuid = PEI_S3_RESUME_PPI_GUID;
+
+EFI_GUID_STRING(&gPeiS3ResumePpiGuid, "S3Resume", "S3 Resume PPI");
diff --git a/EDK/Foundation/Framework/Ppi/S3Resume/S3Resume.h b/EDK/Foundation/Framework/Ppi/S3Resume/S3Resume.h
new file mode 100644
index 0000000..43a2afb
--- /dev/null
+++ b/EDK/Foundation/Framework/Ppi/S3Resume/S3Resume.h
@@ -0,0 +1,44 @@
+/*++
+
+ Copyright (c) 2004, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ S3Resume.h
+
+Abstract:
+
+ S3 Resume PPI
+
+--*/
+
+#ifndef _PEI_S3_RESUME_PPI_H
+#define _PEI_S3_RESUME_PPI_H
+
+#define PEI_S3_RESUME_PPI_GUID \
+ { \
+ 0x4426CCB2, 0xE684, 0x4a8a, 0xAE, 0x40, 0x20, 0xD4, 0xB0, 0x25, 0xB7, 0x10 \
+ }
+
+EFI_FORWARD_DECLARATION (PEI_S3_RESUME_PPI);
+
+typedef
+EFI_STATUS
+(EFIAPI *PEI_S3_RESUME_PPI_RESTORE_CONFIG) (
+ IN EFI_PEI_SERVICES **PeiServices
+ );
+
+typedef struct _PEI_S3_RESUME_PPI {
+ PEI_S3_RESUME_PPI_RESTORE_CONFIG S3RestoreConfig;
+} PEI_S3_RESUME_PPI;
+
+extern EFI_GUID gPeiS3ResumePpiGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Ppi/SecPlatformInformation/SecPlatformInformation.c b/EDK/Foundation/Framework/Ppi/SecPlatformInformation/SecPlatformInformation.c
new file mode 100644
index 0000000..ecc0c34
--- /dev/null
+++ b/EDK/Foundation/Framework/Ppi/SecPlatformInformation/SecPlatformInformation.c
@@ -0,0 +1,29 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ SecPlatformInformation.c
+
+Abstract:
+
+ Sec Platform Information as defined in PEI EAS
+
+--*/
+
+#include "Tiano.h"
+#include "PeiBind.h"
+#include "PeiApi.h"
+#include EFI_PPI_DEFINITION (SecPlatformInformation)
+
+EFI_GUID gEfiSecPlatformInformationPpiGuid = EFI_SEC_PLATFORM_INFORMATION_GUID;
+
+EFI_GUID_STRING(&gEfiSecPlatformInformationPpiGuid, "SecPlatformInformation", "Sec Platform Information");
diff --git a/EDK/Foundation/Framework/Ppi/SecPlatformInformation/SecPlatformInformation.h b/EDK/Foundation/Framework/Ppi/SecPlatformInformation/SecPlatformInformation.h
new file mode 100644
index 0000000..f9ea0e6
--- /dev/null
+++ b/EDK/Foundation/Framework/Ppi/SecPlatformInformation/SecPlatformInformation.h
@@ -0,0 +1,57 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ SecPlatformInformation.h
+
+Abstract:
+
+ Sec Platform Information PPI as defined in Tiano
+
+--*/
+
+#ifndef _PEI_SEC_PLATFORM_INFORMATION_PPI_H
+#define _PEI_SEC_PLATFORM_INFORMATION_PPI_H
+
+#define EFI_SEC_PLATFORM_INFORMATION_GUID \
+ { \
+ 0x6f8c2b35, 0xfef4, 0x448d, 0x82, 0x56, 0xe1, 0x1b, 0x19, 0xd6, 0x10, 0x77 \
+ }
+
+EFI_FORWARD_DECLARATION (EFI_SEC_PLATFORM_INFORMATION_PPI);
+
+extern EFI_GUID gEfiSecPlatformInformationPpiGuid;
+
+typedef struct {
+ UINTN HealthFlags;
+} SEC_PLATFORM_INFORMATION_RECORD;
+
+typedef struct {
+ UINTN BootPhase; // entry r20 value
+ UINTN UniqueId; // PAL arbitration ID
+ UINTN HealthStat; // Health Status
+ UINTN PALRetAddress; // return address to PAL
+} IPF_HANDOFF_STATUS;
+
+typedef
+EFI_STATUS
+(EFIAPI *SEC_PLATFORM_INFORMATION) (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN OUT UINT64 *StructureSize,
+ IN OUT SEC_PLATFORM_INFORMATION_RECORD * PlatformInformationRecord
+ );
+
+typedef struct _EFI_SEC_PLATFORM_INFORMATION_PPI {
+ SEC_PLATFORM_INFORMATION PlatformInformation;
+} EFI_SEC_PLATFORM_INFORMATION_PPI;
+
+#endif
diff --git a/EDK/Foundation/Framework/Ppi/SectionExtraction/SectionExtraction.c b/EDK/Foundation/Framework/Ppi/SectionExtraction/SectionExtraction.c
new file mode 100644
index 0000000..7f3d962
--- /dev/null
+++ b/EDK/Foundation/Framework/Ppi/SectionExtraction/SectionExtraction.c
@@ -0,0 +1,28 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ SectionExtraction.c
+
+Abstract:
+
+ Section Extraction Protocol PPI GUID as defined in Tiano
+
+--*/
+
+#include "Tiano.h"
+#include "Pei.h"
+#include EFI_PPI_DEFINITION (SectionExtraction)
+
+EFI_GUID gPeiSectionExtractionPpiGuid = EFI_PEI_SECTION_EXTRACTION_PPI_GUID;
+
+EFI_GUID_STRING(&gPeiSectionExtractionPpiGuid, "Section Extraction PPI", "Section Extraction PPI");
diff --git a/EDK/Foundation/Framework/Ppi/SectionExtraction/SectionExtraction.h b/EDK/Foundation/Framework/Ppi/SectionExtraction/SectionExtraction.h
new file mode 100644
index 0000000..1e1a501
--- /dev/null
+++ b/EDK/Foundation/Framework/Ppi/SectionExtraction/SectionExtraction.h
@@ -0,0 +1,59 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ SectionExtraction.h
+
+Abstract:
+
+ Section Extraction PPI as defined in Tiano
+
+--*/
+
+#ifndef _SECTION_EXTRACTION_PPI_H_
+#define _SECTION_EXTRACTION_PPI_H_
+
+#define EFI_PEI_SECTION_EXTRACTION_PPI_GUID \
+ { \
+ 0x4F89E208, 0xE144, 0x4804, 0x9E, 0xC8, 0x0F, 0x89, 0x4F, 0x7E, 0x36, 0xD7 \
+ }
+
+EFI_FORWARD_DECLARATION (EFI_PEI_SECTION_EXTRACTION_PPI);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_GET_SECTION) (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PEI_SECTION_EXTRACTION_PPI * This,
+ IN EFI_SECTION_TYPE * SectionType,
+ IN EFI_GUID * SectionDefinitionGuid, OPTIONAL
+ IN UINTN SectionInstance,
+ IN VOID **Buffer,
+ IN OUT UINT32 *BufferSize,
+ OUT UINT32 *AuthenticationStatus
+ );
+
+//
+// Bit values for AuthenticationStatus
+//
+#define EFI_PEI_AUTH_STATUS_PLATFORM_OVERRIDE 0x01
+#define EFI_PEI_AUTH_STATUS_IMAGE_SIGNED 0x02
+#define EFI_PEI_AUTH_STATUS_NOT_TESTED 0x04
+#define EFI_PEI_AUTH_STATUS_TEST_FAILED 0x08
+
+typedef struct _EFI_PEI_SECTION_EXTRACTION_PPI {
+ EFI_PEI_GET_SECTION PeiGetSection;
+} EFI_PEI_SECTION_EXTRACTION_PPI;
+
+extern EFI_GUID gPeiSectionExtractionPpiGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Ppi/Security/Security.c b/EDK/Foundation/Framework/Ppi/Security/Security.c
new file mode 100644
index 0000000..9d18044
--- /dev/null
+++ b/EDK/Foundation/Framework/Ppi/Security/Security.c
@@ -0,0 +1,28 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Security.c
+
+Abstract:
+
+ Security Architectural Protocol PPI GUID as defined in Tiano
+
+--*/
+
+#include "Tiano.h"
+#include "Pei.h"
+#include EFI_PPI_DEFINITION (Security)
+
+EFI_GUID gPeiSecurityPpiGuid = PEI_SECURITY_PPI_GUID;
+
+EFI_GUID_STRING(&gPeiSecurityPpiGuid, "Security PPI", "Security Arch PPI");
diff --git a/EDK/Foundation/Framework/Ppi/Security/Security.h b/EDK/Foundation/Framework/Ppi/Security/Security.h
new file mode 100644
index 0000000..ec72ffa
--- /dev/null
+++ b/EDK/Foundation/Framework/Ppi/Security/Security.h
@@ -0,0 +1,48 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Security.h
+
+Abstract:
+
+ Security Architectural PPI as defined in Tiano
+
+--*/
+
+#ifndef _SECURITY_PPI_H_
+#define _SECURITY_PPI_H_
+
+#define PEI_SECURITY_PPI_GUID \
+ { \
+ 0x1388066e, 0x3a57, 0x4efa, 0x98, 0xf3, 0xc1, 0x2f, 0x3a, 0x95, 0x8a, 0x29 \
+ }
+
+EFI_FORWARD_DECLARATION (PEI_SECURITY_PPI);
+
+typedef
+EFI_STATUS
+(EFIAPI *PEI_SECURITY_AUTHENTICATION_STATE) (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_SECURITY_PPI * This,
+ IN UINT32 AuthenticationStatus,
+ IN EFI_FFS_FILE_HEADER * FfsFileHeader,
+ IN OUT BOOLEAN *StartCrisisRecovery
+ );
+
+typedef struct _PEI_SECURITY_PPI {
+ PEI_SECURITY_AUTHENTICATION_STATE AuthenticationState;
+} PEI_SECURITY_PPI;
+
+extern EFI_GUID gPeiSecurityPpiGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Ppi/Security2/Security2.c b/EDK/Foundation/Framework/Ppi/Security2/Security2.c
new file mode 100644
index 0000000..b2ada7f
--- /dev/null
+++ b/EDK/Foundation/Framework/Ppi/Security2/Security2.c
@@ -0,0 +1,28 @@
+/*++
+
+Copyright (c) 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Security2.c
+
+Abstract:
+
+ PI 1.0 spec definition.
+
+--*/
+
+#include "Tiano.h"
+#include "Pei.h"
+#include EFI_PPI_DEFINITION (Security2)
+
+EFI_GUID gEfiPeiSecurity2PpiGuid = EFI_PEI_SECURITY2_PPI_GUID;
+
+EFI_GUID_STRING(&gEfiPeiSecurity2PpiGuid, "Security2 PPI", "Security2 Arch PPI");
diff --git a/EDK/Foundation/Framework/Ppi/Security2/Security2.h b/EDK/Foundation/Framework/Ppi/Security2/Security2.h
new file mode 100644
index 0000000..55d2031
--- /dev/null
+++ b/EDK/Foundation/Framework/Ppi/Security2/Security2.h
@@ -0,0 +1,50 @@
+/*++
+
+Copyright (c) 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Security2.h
+
+Abstract:
+
+ PI 1.0 spec definition.
+
+--*/
+
+
+#ifndef __SECURITY2_PPI_H__
+#define __SECURITY2_PPI_H__
+
+#define EFI_PEI_SECURITY2_PPI_GUID \
+ { 0xdcd0be23, 0x9586, 0x40f4, 0xb6, 0x43, 0x6, 0x52, 0x2c, 0xed, 0x4e, 0xde}
+
+
+EFI_FORWARD_DECLARATION (EFI_PEI_SECURITY2_PPI);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_SECURITY_AUTHENTICATION_STATE) (
+ IN CONST EFI_PEI_SERVICES **PeiServices,
+ IN CONST EFI_PEI_SECURITY2_PPI *This,
+ IN UINT32 AuthenticationStatus,
+ IN EFI_PEI_FV_HANDLE FvHandle,
+ IN EFI_PEI_FILE_HANDLE FileHandle,
+ IN OUT BOOLEAN *DeferExection
+ );
+
+typedef struct _EFI_PEI_SECURITY2_PPI {
+ EFI_PEI_SECURITY_AUTHENTICATION_STATE AuthenticationState;
+} EFI_PEI_SECURITY2_PPI;
+
+
+extern EFI_GUID gEfiPeiSecurity2PpiGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Ppi/Smbus/Smbus.c b/EDK/Foundation/Framework/Ppi/Smbus/Smbus.c
new file mode 100644
index 0000000..ad2340c
--- /dev/null
+++ b/EDK/Foundation/Framework/Ppi/Smbus/Smbus.c
@@ -0,0 +1,29 @@
+/*++
+
+Copyright (c) 1999 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ Smbus.c
+
+Abstract:
+
+ Smbus PPI GUID as defined in EFI 2.0
+
+--*/
+
+#include "Tiano.h"
+#include "Pei.h"
+#include EFI_PPI_DEFINITION (Smbus)
+
+EFI_GUID gPeiSmbusPpiGuid = PEI_SMBUS_PPI_GUID;
+
+EFI_GUID_STRING(&gPeiSmbusPpiGuid, "Smbus", "Smbus PPI");
diff --git a/EDK/Foundation/Framework/Ppi/Smbus/Smbus.h b/EDK/Foundation/Framework/Ppi/Smbus/Smbus.h
new file mode 100644
index 0000000..c4c6fbe
--- /dev/null
+++ b/EDK/Foundation/Framework/Ppi/Smbus/Smbus.h
@@ -0,0 +1,115 @@
+/*++
+
+Copyright (c) 1999 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ Smbus.h
+
+Abstract:
+
+ Smbus PPI as defined in EFI 2.0
+
+--*/
+
+#ifndef _PEI_SMBUS_PPI_H
+#define _PEI_SMBUS_PPI_H
+
+#include "EfiSmbus.h"
+
+#define PEI_SMBUS_PPI_GUID \
+ { \
+ 0xabd42895, 0x78cf, 0x4872, 0x84, 0x44, 0x1b, 0x5c, 0x18, 0xb, 0xfb, 0xda \
+ }
+
+EFI_FORWARD_DECLARATION (PEI_SMBUS_PPI);
+
+typedef
+EFI_STATUS
+(EFIAPI *PEI_SMBUS_PPI_EXECUTE_OPERATION) (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_SMBUS_PPI * This,
+ IN EFI_SMBUS_DEVICE_ADDRESS SlaveAddress,
+ IN EFI_SMBUS_DEVICE_COMMAND Command,
+ IN EFI_SMBUS_OPERATION Operation,
+ IN BOOLEAN PecCheck,
+ IN OUT UINTN *Length,
+ IN OUT VOID *Buffer
+ );
+
+//;;## ...AMI_OVERRIDE... Support PI1.x typedef struct {
+//;;## ...AMI_OVERRIDE... Support PI1.x UINT32 VendorSpecificId;
+//;;## ...AMI_OVERRIDE... Support PI1.x UINT16 SubsystemDeviceId;
+//;;## ...AMI_OVERRIDE... Support PI1.x UINT16 SubsystemVendorId;
+//;;## ...AMI_OVERRIDE... Support PI1.x UINT16 Interface;
+//;;## ...AMI_OVERRIDE... Support PI1.x UINT16 DeviceId;
+//;;## ...AMI_OVERRIDE... Support PI1.x UINT16 VendorId;
+//;;## ...AMI_OVERRIDE... Support PI1.x UINT8 VendorRevision;
+//;;## ...AMI_OVERRIDE... Support PI1.x UINT8 DeviceCapabilities;
+//;;## ...AMI_OVERRIDE... Support PI1.x } EFI_SMBUS_UDID;
+
+typedef
+EFI_STATUS
+(EFIAPI *PEI_SMBUS_NOTIFY_FUNCTION) (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_SMBUS_PPI * SmbusPpi,
+ IN EFI_SMBUS_DEVICE_ADDRESS SlaveAddress,
+ IN UINTN Data
+ );
+
+//
+// If ArpAll is TRUE, SmbusUdid/SlaveAddress is Optional.
+// If FALSE, ArpDevice will enum SmbusUdid and the address will be at SlaveAddress
+//
+typedef
+EFI_STATUS
+(EFIAPI *PEI_SMBUS_PPI_ARP_DEVICE) (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_SMBUS_PPI * This,
+ IN BOOLEAN ArpAll,
+ IN EFI_SMBUS_UDID * SmbusUdid, OPTIONAL
+ IN OUT EFI_SMBUS_DEVICE_ADDRESS * SlaveAddress OPTIONAL
+ );
+
+//;;## ...AMI_OVERRIDE... Support PI1.x typedef struct {
+//;;## ...AMI_OVERRIDE... Support PI1.x EFI_SMBUS_DEVICE_ADDRESS SmbusDeviceAddress;
+//;;## ...AMI_OVERRIDE... Support PI1.x EFI_SMBUS_UDID SmbusDeviceUdid;
+//;;## ...AMI_OVERRIDE... Support PI1.x } EFI_SMBUS_DEVICE_MAP;
+
+typedef
+EFI_STATUS
+(EFIAPI *PEI_SMBUS_PPI_GET_ARP_MAP) (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_SMBUS_PPI * This,
+ IN OUT UINTN *Length,
+ IN OUT EFI_SMBUS_DEVICE_MAP **SmbusDeviceMap
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *PEI_SMBUS_PPI_NOTIFY) (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_SMBUS_PPI * This,
+ IN EFI_SMBUS_DEVICE_ADDRESS SlaveAddress,
+ IN UINTN Data,
+ IN PEI_SMBUS_NOTIFY_FUNCTION NotifyFunction
+ );
+
+typedef struct _PEI_SMBUS_PPI {
+ PEI_SMBUS_PPI_EXECUTE_OPERATION Execute;
+ PEI_SMBUS_PPI_ARP_DEVICE ArpDevice;
+ PEI_SMBUS_PPI_GET_ARP_MAP GetArpMap;
+ PEI_SMBUS_PPI_NOTIFY Notify;
+} PEI_SMBUS_PPI;
+
+extern EFI_GUID gPeiSmbusPpiGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Ppi/Smbus2/Smbus2.c b/EDK/Foundation/Framework/Ppi/Smbus2/Smbus2.c
new file mode 100644
index 0000000..bbd372a
--- /dev/null
+++ b/EDK/Foundation/Framework/Ppi/Smbus2/Smbus2.c
@@ -0,0 +1,29 @@
+/*++
+
+Copyright (c) 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ Smbus2.c
+
+Abstract:
+
+ Smbus2 PPI GUID as defined in PI1.0
+
+--*/
+
+#include "Tiano.h"
+#include "Pei.h"
+#include EFI_PPI_DEFINITION (Smbus2)
+
+EFI_GUID gPeiSmbus2PpiGuid = PEI_SMBUS2_PPI_GUID;
+
+EFI_GUID_STRING(&gPeiSmbus2PpiGuid, "Smbus2", "Smbus2 PPI");
diff --git a/EDK/Foundation/Framework/Ppi/Smbus2/Smbus2.h b/EDK/Foundation/Framework/Ppi/Smbus2/Smbus2.h
new file mode 100644
index 0000000..23bfa93
--- /dev/null
+++ b/EDK/Foundation/Framework/Ppi/Smbus2/Smbus2.h
@@ -0,0 +1,96 @@
+/*++
+
+Copyright (c) 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ Smbus2.h
+
+Abstract:
+
+ Smbus2 PPI as defined in PI 1.0
+
+--*/
+
+#ifndef _PEI_SMBUS2_PPI_H
+#define _PEI_SMBUS2_PPI_H
+
+#include "EfiSmbus.h"
+
+#define PEI_SMBUS2_PPI_GUID \
+ { \
+ 0x9ca93627, 0xb65b, 0x4324, 0xa2, 0x2, 0xc0, 0xb4, 0x61, 0x76, 0x45, 0x43 \
+ }
+
+EFI_FORWARD_DECLARATION (EFI_PEI_SMBUS2_PPI);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_SMBUS2_PPI_EXECUTE_OPERATION) (
+ IN CONST EFI_PEI_SMBUS2_PPI * This,
+ IN EFI_SMBUS_DEVICE_ADDRESS SlaveAddress,
+ IN EFI_SMBUS_DEVICE_COMMAND Command,
+ IN EFI_SMBUS_OPERATION Operation,
+ IN BOOLEAN PecCheck,
+ IN OUT UINTN *Length,
+ IN OUT VOID *Buffer
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_SMBUS_NOTIFY2_FUNCTION) (
+ IN CONST EFI_PEI_SMBUS2_PPI * SmbusPpi,
+ IN EFI_SMBUS_DEVICE_ADDRESS SlaveAddress,
+ IN UINTN Data
+ );
+
+//
+// If ArpAll is TRUE, SmbusUdid/SlaveAddress is Optional.
+// If FALSE, ArpDevice will enum SmbusUdid and the address will be at SlaveAddress
+//
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_SMBUS2_PPI_ARP_DEVICE) (
+ IN CONST EFI_PEI_SMBUS2_PPI * This,
+ IN BOOLEAN ArpAll,
+ IN EFI_SMBUS_UDID * SmbusUdid, OPTIONAL
+ IN OUT EFI_SMBUS_DEVICE_ADDRESS * SlaveAddress OPTIONAL
+ );
+
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_SMBUS2_PPI_GET_ARP_MAP) (
+ IN CONST EFI_PEI_SMBUS2_PPI * This,
+ IN OUT UINTN *Length,
+ IN OUT EFI_SMBUS_DEVICE_MAP **SmbusDeviceMap
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_SMBUS2_PPI_NOTIFY) (
+ IN CONST EFI_PEI_SMBUS2_PPI * This,
+ IN EFI_SMBUS_DEVICE_ADDRESS SlaveAddress,
+ IN UINTN Data,
+ IN EFI_PEI_SMBUS_NOTIFY2_FUNCTION NotifyFunction
+ );
+
+typedef struct _EFI_PEI_SMBUS2_PPI {
+ EFI_PEI_SMBUS2_PPI_EXECUTE_OPERATION Execute;
+ EFI_PEI_SMBUS2_PPI_ARP_DEVICE ArpDevice;
+ EFI_PEI_SMBUS2_PPI_GET_ARP_MAP GetArpMap;
+ EFI_PEI_SMBUS2_PPI_NOTIFY Notify;
+ EFI_GUID Identifier;
+} EFI_PEI_SMBUS2_PPI;
+
+extern EFI_GUID gPeiSmbus2PpiGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Ppi/Stall/Stall.c b/EDK/Foundation/Framework/Ppi/Stall/Stall.c
new file mode 100644
index 0000000..8d00347
--- /dev/null
+++ b/EDK/Foundation/Framework/Ppi/Stall/Stall.c
@@ -0,0 +1,28 @@
+/*++
+
+ Copyright (c) 1999 - 2002, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Stall.c
+
+Abstract:
+
+ Stall PPI
+
+--*/
+
+#include "Tiano.h"
+#include "Pei.h"
+#include EFI_PPI_DEFINITION (Stall)
+
+EFI_GUID gPeiStallPpiGuid = PEI_STALL_PPI_GUID;
+
+EFI_GUID_STRING(&gPeiStallPpiGuid, "Stall", "Stall PPI");
diff --git a/EDK/Foundation/Framework/Ppi/Stall/Stall.h b/EDK/Foundation/Framework/Ppi/Stall/Stall.h
new file mode 100644
index 0000000..c878a63
--- /dev/null
+++ b/EDK/Foundation/Framework/Ppi/Stall/Stall.h
@@ -0,0 +1,47 @@
+/*++
+
+ Copyright (c) 1999 - 2002, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Stall.h
+
+Abstract:
+
+ Stall PPI
+
+--*/
+
+#ifndef _PEI_STALL_PPI_H_
+#define _PEI_STALL_PPI_H_
+
+#define PEI_STALL_PPI_GUID \
+ { \
+ 0x1f4c6f90, 0xb06b, 0x48d8, 0xa2, 0x01, 0xba, 0xe5, 0xf1, 0xcd, 0x7d, 0x56 \
+ }
+
+EFI_FORWARD_DECLARATION (PEI_STALL_PPI);
+
+typedef
+EFI_STATUS
+(EFIAPI *PEI_STALL) (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_STALL_PPI * This,
+ IN UINTN Microseconds
+ );
+
+typedef struct _PEI_STALL_PPI {
+ UINTN Resolution;
+ PEI_STALL Stall;
+} PEI_STALL_PPI;
+
+extern EFI_GUID gPeiStallPpiGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Ppi/StatusCode/StatusCode.c b/EDK/Foundation/Framework/Ppi/StatusCode/StatusCode.c
new file mode 100644
index 0000000..6fc697c
--- /dev/null
+++ b/EDK/Foundation/Framework/Ppi/StatusCode/StatusCode.c
@@ -0,0 +1,29 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ StatusCode.c
+
+Abstract:
+
+ Status Code PPI GUID as defined in PEI EAS
+
+--*/
+
+#include "Tiano.h"
+#include "PeiBind.h"
+#include "PeiApi.h"
+#include EFI_PPI_DEFINITION (StatusCode)
+
+EFI_GUID gPeiStatusCodePpiGuid = PEI_STATUS_CODE_PPI_GUID;
+
+EFI_GUID_STRING(&gPeiProgressCodePpiGuid, "StatusCode", "Status Code PPI");
diff --git a/EDK/Foundation/Framework/Ppi/StatusCode/StatusCode.h b/EDK/Foundation/Framework/Ppi/StatusCode/StatusCode.h
new file mode 100644
index 0000000..a19800b
--- /dev/null
+++ b/EDK/Foundation/Framework/Ppi/StatusCode/StatusCode.h
@@ -0,0 +1,49 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ StatusCode.h
+
+Abstract:
+
+ Status Code PPI as defined in Tiano
+
+--*/
+
+#ifndef _PEI_STATUS_CODE_PPI_H
+#define _PEI_STATUS_CODE_PPI_H
+
+#define PEI_STATUS_CODE_PPI_GUID \
+ { \
+ 0x229832d3, 0x7a30, 0x4b36, 0xb8, 0x27, 0xf4, 0xc, 0xb7, 0xd4, 0x54, 0x36 \
+ }
+
+EFI_FORWARD_DECLARATION (PEI_STATUS_CODE_PPI);
+
+typedef
+EFI_STATUS
+(EFIAPI *PEI_REPORT_STATUS_CODE) (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_STATUS_CODE_TYPE CodeType,
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN UINT32 Instance,
+ IN EFI_GUID * CallerId,
+ IN EFI_STATUS_CODE_DATA * Data OPTIONAL
+ );
+
+typedef struct _PEI_STATUS_CODE_PPI {
+ PEI_REPORT_STATUS_CODE ReportStatusCode;
+} PEI_STATUS_CODE_PPI;
+
+extern EFI_GUID gPeiStatusCodePpiGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Ppi/Variable/Variable.c b/EDK/Foundation/Framework/Ppi/Variable/Variable.c
new file mode 100644
index 0000000..77d8359
--- /dev/null
+++ b/EDK/Foundation/Framework/Ppi/Variable/Variable.c
@@ -0,0 +1,29 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Variable.c
+
+Abstract:
+
+ Boot Mode PPI GUID as defined in PEI EAS
+
+--*/
+
+#include "Tiano.h"
+#include "PeiBind.h"
+#include "PeiApi.h"
+#include EFI_PPI_DEFINITION (Variable)
+
+EFI_GUID gPeiReadOnlyVariablePpiGuid = PEI_READ_ONLY_VARIABLE_ACCESS_PPI_GUID;
+
+EFI_GUID_STRING(&gPeiReadOnlyVariablePpiGuid, "Variable", "Read Only Variable PPI");
diff --git a/EDK/Foundation/Framework/Ppi/Variable/Variable.h b/EDK/Foundation/Framework/Ppi/Variable/Variable.h
new file mode 100644
index 0000000..90965cb
--- /dev/null
+++ b/EDK/Foundation/Framework/Ppi/Variable/Variable.h
@@ -0,0 +1,69 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Variable.h
+
+Abstract:
+
+ Read-only Variable Service PPI as defined in Tiano
+
+--*/
+
+#ifndef _PEI_READ_ONLY_VARIABLE_PPI_H
+#define _PEI_READ_ONLY_VARIABLE_PPI_H
+
+#include "EfiVariable.h" //;;## ...AMI_OVERRIDE... Support PI1.x
+
+#define PEI_READ_ONLY_VARIABLE_ACCESS_PPI_GUID \
+ { \
+ 0x3cdc90c6, 0x13fb, 0x4a75, 0x9e, 0x79, 0x59, 0xe9, 0xdd, 0x78, 0xb9, 0xfa \
+ }
+
+//
+// Variable attributes
+//
+//;;## ...AMI_OVERRIDE... Support PI1.x #define EFI_VARIABLE_NON_VOLATILE 0x00000001
+//;;## ...AMI_OVERRIDE... Support PI1.x #define EFI_VARIABLE_BOOTSERVICE_ACCESS 0x00000002
+//;;## ...AMI_OVERRIDE... Support PI1.x #define EFI_VARIABLE_RUNTIME_ACCESS 0x00000004
+//;;## ...AMI_OVERRIDE... Support PI1.x #define EFI_VARIABLE_READ_ONLY 0x00000008
+
+typedef
+EFI_STATUS
+(EFIAPI *PEI_GET_VARIABLE) (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN CHAR16 *VariableName,
+ IN EFI_GUID * VendorGuid,
+ OUT UINT32 *Attributes OPTIONAL,
+ IN OUT UINTN *DataSize,
+ OUT VOID *Data
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *PEI_GET_NEXT_VARIABLE_NAME) (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN OUT UINTN *VariableNameSize,
+ IN OUT CHAR16 *VariableName,
+ IN OUT EFI_GUID * VendorGuid
+ );
+
+typedef struct PEI_READ_ONLY_VARIABLE_PPI {
+ PEI_GET_VARIABLE PeiGetVariable;
+ PEI_GET_NEXT_VARIABLE_NAME PeiGetNextVariableName;
+} PEI_READ_ONLY_VARIABLE_PPI;
+
+EFI_FORWARD_DECLARATION (PEI_MASTER_BOOT_MODE_PPI);
+
+extern EFI_GUID gPeiReadOnlyVariablePpiGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Ppi/Variable2/Variable2.c b/EDK/Foundation/Framework/Ppi/Variable2/Variable2.c
new file mode 100644
index 0000000..3f4d57a
--- /dev/null
+++ b/EDK/Foundation/Framework/Ppi/Variable2/Variable2.c
@@ -0,0 +1,29 @@
+/*++
+
+Copyright (c) 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Variable2.c
+
+Abstract:
+
+ Read-only Variable2 Service PPI as defined in PI1.0
+
+--*/
+
+#include "Tiano.h"
+#include "PeiBind.h"
+#include "PeiApi.h"
+#include EFI_PPI_DEFINITION (Variable2)
+
+EFI_GUID gPeiReadOnlyVariable2PpiGuid = EFI_PEI_READ_ONLY_VARIABLE2_PPI_GUID;
+
+EFI_GUID_STRING(&gPeiReadOnlyVariable2PpiGuid, "Variable2", "Read Only Variable2 PPI");
diff --git a/EDK/Foundation/Framework/Ppi/Variable2/Variable2.h b/EDK/Foundation/Framework/Ppi/Variable2/Variable2.h
new file mode 100644
index 0000000..31020ed
--- /dev/null
+++ b/EDK/Foundation/Framework/Ppi/Variable2/Variable2.h
@@ -0,0 +1,61 @@
+/*++
+
+Copyright (c) 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Variable2.h
+
+Abstract:
+
+ Read-only Variable2 Service PPI as defined in PI1.0
+
+--*/
+
+#ifndef _PEI_READ_ONLY_VARIABLE2_PPI_H
+#define _PEI_READ_ONLY_VARIABLE2_PPI_H
+
+#include "EfiVariable.h"
+
+#define EFI_PEI_READ_ONLY_VARIABLE2_PPI_GUID \
+ { \
+ 0x2ab86ef5, 0xecb5, 0x4134, 0xb5, 0x56, 0x38, 0x54, 0xca, 0x1f, 0xe1, 0xb4 \
+ }
+
+EFI_FORWARD_DECLARATION (EFI_PEI_READ_ONLY_VARIABLE2_PPI);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_GET_VARIABLE2) (
+ IN CONST EFI_PEI_READ_ONLY_VARIABLE2_PPI *This,
+ IN CONST CHAR16 *VariableName,
+ IN CONST EFI_GUID *VariableGuid,
+ OUT UINT32 *Attributes,
+ IN OUT UINTN *DataSize,
+ OUT VOID *Data
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_GET_NEXT_VARIABLE_NAME2) (
+ IN CONST EFI_PEI_READ_ONLY_VARIABLE2_PPI *This,
+ IN OUT UINTN *VariableNameSize,
+ IN OUT CHAR16 *VariableName,
+ IN OUT EFI_GUID *VariableGuid
+ );
+
+typedef struct _EFI_PEI_READ_ONLY_VARIABLE2_PPI {
+ EFI_PEI_GET_VARIABLE2 GetVariable;
+ EFI_PEI_GET_NEXT_VARIABLE_NAME2 GetNextVariableName;
+} EFI_PEI_READ_ONLY_VARIABLE2_PPI;
+
+extern EFI_GUID gPeiReadOnlyVariable2PpiGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Protocol/AcpiS3Save/AcpiS3Save.c b/EDK/Foundation/Framework/Protocol/AcpiS3Save/AcpiS3Save.c
new file mode 100644
index 0000000..cca3c2f
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/AcpiS3Save/AcpiS3Save.c
@@ -0,0 +1,28 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ AcpiS3Save.c
+
+Abstract:
+
+ Tiano Tiano S3 Save Protocol
+
+--*/
+
+#include "Tiano.h"
+
+#include EFI_PROTOCOL_DEFINITION (AcpiS3Save)
+
+EFI_GUID gEfiAcpiS3SaveGuid = EFI_ACPI_S3_SAVE_GUID;
+
+EFI_GUID_STRING(&gEfiAcpiS3SaveGuid, "EFI Acpi S3 Save Protocol", "Tiano Acpi S3 Save Protocol");
diff --git a/EDK/Foundation/Framework/Protocol/AcpiS3Save/AcpiS3Save.h b/EDK/Foundation/Framework/Protocol/AcpiS3Save/AcpiS3Save.h
new file mode 100644
index 0000000..bdd61b4
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/AcpiS3Save/AcpiS3Save.h
@@ -0,0 +1,68 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ AcpiS3Save.h
+
+Abstract:
+
+
+--*/
+
+#ifndef _ACPI_S3_SAVE_PROTOCOL_H
+#define _ACPI_S3_SAVE_PROTOCOL_H
+
+//
+// Includes
+//
+#include "Tiano.h"
+
+//
+// Forward reference for pure ANSI compatability
+//
+EFI_FORWARD_DECLARATION (EFI_ACPI_S3_SAVE_PROTOCOL);
+
+//
+// S3 Save Protocol GUID
+//
+#define EFI_ACPI_S3_SAVE_GUID \
+ { \
+ 0x125f2de1, 0xfb85, 0x440c, 0xa5, 0x4c, 0x4d, 0x99, 0x35, 0x8a, 0x8d, 0x38 \
+ }
+
+//
+// Protocol Data Structures
+//
+typedef
+EFI_STATUS
+EFI_BOOTSERVICE
+(EFIAPI *EFI_ACPI_S3_SAVE) (
+ IN EFI_ACPI_S3_SAVE_PROTOCOL * This,
+ IN VOID * LegacyMemoryAddress
+ );
+
+typedef
+EFI_STATUS
+EFI_BOOTSERVICE
+(EFIAPI *EFI_ACPI_GET_LEGACY_MEMORY_SIZE) (
+ IN EFI_ACPI_S3_SAVE_PROTOCOL * This,
+ OUT UINTN * Size
+);
+
+typedef struct _EFI_ACPI_S3_SAVE_PROTOCOL {
+ EFI_ACPI_GET_LEGACY_MEMORY_SIZE GetLegacyMemorySize;
+ EFI_ACPI_S3_SAVE S3Save;
+} EFI_ACPI_S3_SAVE_PROTOCOL;
+
+extern EFI_GUID gEfiAcpiS3SaveGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Protocol/AcpiSupport/AcpiSupport.c b/EDK/Foundation/Framework/Protocol/AcpiSupport/AcpiSupport.c
new file mode 100644
index 0000000..7723b32
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/AcpiSupport/AcpiSupport.c
@@ -0,0 +1,29 @@
+/*++
+
+Copyright (c) 1999 - 2005, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ AcpiSupport.c
+
+Abstract:
+
+ Tiano EFI 2.0 ACPI Support Protocol
+
+--*/
+
+#include "Tiano.h"
+
+#include EFI_PROTOCOL_DEFINITION (AcpiSupport)
+
+EFI_GUID gEfiAcpiSupportGuid = EFI_ACPI_SUPPORT_GUID;
+
+EFI_GUID_STRING(&gEfiAcpiSupportGuid, "ACPI Support Protocol", "EFI 2.0 ACPI Support Protocol");
diff --git a/EDK/Foundation/Framework/Protocol/AcpiSupport/AcpiSupport.h b/EDK/Foundation/Framework/Protocol/AcpiSupport/AcpiSupport.h
new file mode 100644
index 0000000..10205fa
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/AcpiSupport/AcpiSupport.h
@@ -0,0 +1,128 @@
+/*++
+
+Copyright (c) 1999 - 2005, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ AcpiSupport.h
+
+Abstract:
+
+ Definition of the ACPI Support protocol. This is defined in the
+ Tiano ACPI External Product Specification, revision 0.5.1.
+
+--*/
+
+#ifndef _ACPI_SUPPORT_PROTOCOL_H_
+#define _ACPI_SUPPORT_PROTOCOL_H_
+
+//
+// Includes
+//
+#include "Tiano.h"
+
+//
+// Forward reference for pure ANSI compatability
+//
+EFI_FORWARD_DECLARATION (EFI_ACPI_SUPPORT_PROTOCOL);
+
+//
+// ACPI Support Protocol GUID
+//
+#define EFI_ACPI_SUPPORT_GUID \
+ { \
+ 0xdbff9d55, 0x89b7, 0x46da, 0xbd, 0xdf, 0x67, 0x7d, 0x3d, 0xc0, 0x24, 0x1d \
+ }
+
+//
+// Extern the GUID for protocol users.
+//
+extern EFI_GUID gEfiAcpiSupportGuid;
+
+//
+// Protocol Data Definitions
+//
+//
+// ACPI Version bitmap definition:
+//
+// EFI_ACPI_TABLE_VERSION_1_0B - ACPI Version 1.0b
+// EFI_ACPI_TABLE_VERSION_2_0 - ACPI Version 2.0
+// EFI_ACPI_TABLE_VERSION_3_0 - ACPI Version 3.0
+// EFI_ACPI_TABLE_VERSION_NONE - No ACPI Versions. This might be used
+// to create memory-based operation regions or other information
+// that is not part of the ACPI "tree" but must still be found
+// in ACPI memory space and/or managed by the core ACPI driver.
+//
+// Note that EFI provides discrete GUIDs for each version of ACPI
+// that is supported. It is expected that each EFI GUIDed
+// version of ACPI will also have a corresponding bitmap
+// definition. This allows maintenance of separate ACPI trees
+// for each distinctly different version of ACPI.
+//
+#define EFI_ACPI_TABLE_VERSION UINT32
+
+#define EFI_ACPI_TABLE_VERSION_NONE (1 << 0)
+#define EFI_ACPI_TABLE_VERSION_1_0B (1 << 1)
+#define EFI_ACPI_TABLE_VERSION_2_0 (1 << 2)
+#define EFI_ACPI_TABLE_VERSION_3_0 (1 << 3)
+
+//
+// Protocol Member Functions
+//
+//
+// Retrieve a copy of an ACPI table and the handle of the table.
+//
+typedef
+EFI_STATUS
+EFI_BOOTSERVICE
+(EFIAPI *EFI_ACPI_GET_ACPI_TABLE) (
+ IN EFI_ACPI_SUPPORT_PROTOCOL * This,
+ IN INTN Index,
+ OUT VOID **Table,
+ OUT EFI_ACPI_TABLE_VERSION * Version,
+ OUT UINTN *Handle
+ );
+
+//
+// Add, update, or remove a table.
+//
+typedef
+EFI_STATUS
+EFI_BOOTSERVICE
+(EFIAPI *EFI_ACPI_SET_ACPI_TABLE) (
+ IN EFI_ACPI_SUPPORT_PROTOCOL * This,
+ IN VOID *Table OPTIONAL,
+ IN BOOLEAN Checksum,
+ IN EFI_ACPI_TABLE_VERSION Version,
+ IN OUT UINTN *Handle
+ );
+
+//
+// Publish tables to the outside world
+//
+typedef
+EFI_STATUS
+EFI_BOOTSERVICE
+(EFIAPI *EFI_ACPI_PUBLISH_TABLES) (
+ IN EFI_ACPI_SUPPORT_PROTOCOL * This,
+ IN EFI_ACPI_TABLE_VERSION Version
+ );
+
+//
+// ACPI Support Protocol
+//
+typedef struct _EFI_ACPI_SUPPORT_PROTOCOL {
+ EFI_ACPI_GET_ACPI_TABLE GetAcpiTable;
+ EFI_ACPI_SET_ACPI_TABLE SetAcpiTable;
+ EFI_ACPI_PUBLISH_TABLES PublishTables;
+} EFI_ACPI_SUPPORT_PROTOCOL;
+
+#endif
diff --git a/EDK/Foundation/Framework/Protocol/BootScriptSave/BootScriptSave.c b/EDK/Foundation/Framework/Protocol/BootScriptSave/BootScriptSave.c
new file mode 100644
index 0000000..d196780
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/BootScriptSave/BootScriptSave.c
@@ -0,0 +1,28 @@
+/*++
+
+Copyright (c) 1999 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ BootScriptSave.c
+
+Abstract:
+
+ S3 Save Protocol
+
+--*/
+
+#include "Tiano.h"
+
+#include EFI_PROTOCOL_DEFINITION (BootScriptSave)
+
+EFI_GUID gEfiBootScriptSaveGuid = EFI_BOOT_SCRIPT_SAVE_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiBootScriptSaveGuid, "EFI Boot Script Save Protocol", "EFI Boot Script Save Protocol");
diff --git a/EDK/Foundation/Framework/Protocol/BootScriptSave/BootScriptSave.h b/EDK/Foundation/Framework/Protocol/BootScriptSave/BootScriptSave.h
new file mode 100644
index 0000000..ff103e8
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/BootScriptSave/BootScriptSave.h
@@ -0,0 +1,75 @@
+/*++
+
+Copyright (c) 1999 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ BootScriptSave.h
+
+Abstract:
+
+ S3 Save Protocol
+
+--*/
+
+#ifndef _BOOT_SCRIPT_SAVE_PROTOCOL_H
+#define _BOOT_SCRIPT_SAVE_PROTOCOL_H
+
+//
+// Includes
+//
+#include "Tiano.h"
+
+//
+// Forward reference for pure ANSI compatability
+//
+EFI_FORWARD_DECLARATION (EFI_BOOT_SCRIPT_SAVE_PROTOCOL);
+
+//
+// S3 Save Protocol GUID
+//
+#define EFI_BOOT_SCRIPT_SAVE_PROTOCOL_GUID \
+ { \
+ 0x470e1529, 0xb79e, 0x4e32, 0xa0, 0xfe, 0x6a, 0x15, 0x6d, 0x29, 0xf9, 0xb2 \
+ }
+
+//
+// Protocol Data Structures
+//
+typedef
+EFI_STATUS
+EFI_BOOTSERVICE
+(EFIAPI *EFI_BOOT_SCRIPT_WRITE) (
+ IN EFI_BOOT_SCRIPT_SAVE_PROTOCOL * This,
+ IN UINT16 TableName,
+ IN UINT16 OpCode,
+ ...
+ );
+
+typedef
+EFI_STATUS
+EFI_BOOTSERVICE
+(EFIAPI *EFI_BOOT_SCRIPT_CLOSE_TABLE) (
+ IN EFI_BOOT_SCRIPT_SAVE_PROTOCOL * This,
+ IN UINT16 TableName,
+ OUT EFI_PHYSICAL_ADDRESS * Address
+ );
+
+//
+// S3 Save Protocol data structure
+//
+typedef struct _EFI_BOOT_SCRIPT_SAVE_PROTOCOL {
+ EFI_BOOT_SCRIPT_WRITE Write;
+ EFI_BOOT_SCRIPT_CLOSE_TABLE CloseTable;
+} EFI_BOOT_SCRIPT_SAVE_PROTOCOL;
+
+extern EFI_GUID gEfiBootScriptSaveGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Protocol/CpuIo/CpuIo.c b/EDK/Foundation/Framework/Protocol/CpuIo/CpuIo.c
new file mode 100644
index 0000000..f3044b3
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/CpuIo/CpuIo.c
@@ -0,0 +1,28 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ CpuIO.c
+
+Abstract:
+
+ CPU IO Protocol GUID as defined in Tiano
+
+
+--*/
+
+#include "Tiano.h"
+#include EFI_PROTOCOL_DEFINITION (CpuIo)
+
+EFI_GUID gEfiCpuIoProtocolGuid = EFI_CPU_IO_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiCpuIoProtocolGuid, "CPU IO", "CPU IO Protocol");
diff --git a/EDK/Foundation/Framework/Protocol/CpuIo/CpuIo.h b/EDK/Foundation/Framework/Protocol/CpuIo/CpuIo.h
new file mode 100644
index 0000000..1e8fb70
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/CpuIo/CpuIo.h
@@ -0,0 +1,93 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ CpuIO.h
+
+Abstract:
+
+ CPU IO Protocol as defined in Tiano
+
+ This code abstracts the CPU IO Protocol
+
+--*/
+
+#ifndef _CPUIO_H_
+#define _CPUIO_H_
+
+#define EFI_CPU_IO_PROTOCOL_GUID \
+ { \
+ 0xB0732526, 0x38C8, 0x4b40, 0x88, 0x77, 0x61, 0xC7, 0xB0, 0x6A, 0xAC, 0x45 \
+ }
+
+EFI_FORWARD_DECLARATION (EFI_CPU_IO_PROTOCOL);
+
+//
+// *******************************************************
+// EFI_CPU_IO_PROTOCOL_WIDTH
+// *******************************************************
+//
+typedef enum {
+ EfiCpuIoWidthUint8,
+ EfiCpuIoWidthUint16,
+ EfiCpuIoWidthUint32,
+ EfiCpuIoWidthUint64,
+ EfiCpuIoWidthFifoUint8,
+ EfiCpuIoWidthFifoUint16,
+ EfiCpuIoWidthFifoUint32,
+ EfiCpuIoWidthFifoUint64,
+ EfiCpuIoWidthFillUint8,
+ EfiCpuIoWidthFillUint16,
+ EfiCpuIoWidthFillUint32,
+ EfiCpuIoWidthFillUint64,
+ EfiCpuIoWidthMaximum
+} EFI_CPU_IO_PROTOCOL_WIDTH;
+
+//
+// *******************************************************
+// EFI_CPU_IO_PROTOCOL_IO_MEM
+// *******************************************************
+//
+typedef
+EFI_STATUS
+EFI_RUNTIMESERVICE
+(EFIAPI *EFI_CPU_IO_PROTOCOL_IO_MEM) (
+ IN EFI_CPU_IO_PROTOCOL * This,
+ IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
+ IN UINT64 Address,
+ IN UINTN Count,
+ IN OUT VOID *Buffer
+ );
+
+//
+// *******************************************************
+// EFI_CPU_IO_PROTOCOL_ACCESS
+// *******************************************************
+//
+typedef struct {
+ EFI_CPU_IO_PROTOCOL_IO_MEM Read;
+ EFI_CPU_IO_PROTOCOL_IO_MEM Write;
+} EFI_CPU_IO_PROTOCOL_ACCESS;
+
+//
+// *******************************************************
+// EFI_CPU_IO_PROTOCOL
+// *******************************************************
+//
+typedef struct _EFI_CPU_IO_PROTOCOL {
+ EFI_CPU_IO_PROTOCOL_ACCESS Mem;
+ EFI_CPU_IO_PROTOCOL_ACCESS Io;
+} EFI_CPU_IO_PROTOCOL;
+
+extern EFI_GUID gEfiCpuIoProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Protocol/DataHub/DataHub.c b/EDK/Foundation/Framework/Protocol/DataHub/DataHub.c
new file mode 100644
index 0000000..7cc5e29
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/DataHub/DataHub.c
@@ -0,0 +1,32 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ DataHub.c
+
+Abstract:
+
+ The logging hub protocol is used both by agents wishing to log
+ errors and those wishing to be made aware of all information that
+ has been logged.
+
+ For more information please look at Intel Platform Innovation
+ Framework for EFI Data Hub Specification.
+
+--*/
+
+#include "Tiano.h"
+#include EFI_PROTOCOL_DEFINITION (DataHub)
+
+EFI_GUID gEfiDataHubProtocolGuid = EFI_DATA_HUB_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiDataHubProtocolGuid, "DataHub Protocol", "EFI Data Hub Protocol");
diff --git a/EDK/Foundation/Framework/Protocol/DataHub/DataHub.h b/EDK/Foundation/Framework/Protocol/DataHub/DataHub.h
new file mode 100644
index 0000000..5245eca
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/DataHub/DataHub.h
@@ -0,0 +1,125 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ DataHub.h
+
+Abstract:
+
+ The data hub protocol is used both by agents wishing to log
+ data and those wishing to be made aware of all information that
+ has been logged.
+
+ For more information please look at Intel Platform Innovation
+ Framework for EFI Data Hub Specification.
+
+--*/
+
+#ifndef __DATA_HUB_H__
+#define __DATA_HUB_H__
+
+#define EFI_DATA_HUB_PROTOCOL_GUID \
+ { \
+ 0xae80d021, 0x618e, 0x11d4, 0xbc, 0xd7, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 \
+ }
+
+//
+// EFI generic Data Hub Header
+//
+// A Data Record is an EFI_DATA_RECORD_HEADER followed by RecordSize bytes of
+// data. The format of the data is defined by the DataRecordGuid.
+//
+// If EFI_DATA_RECORD_HEADER is extended in the future the Version number must
+// change and the HeaderSize will change if the definition of
+// EFI_DATA_RECORD_HEADER is extended.
+//
+// The logger is responcible for initializing:
+// Version, HeaderSize, RecordSize, DataRecordGuid, DataRecordClass
+//
+// The Data Hub driver is responcible for initializing:
+// LogTime and LogMonotonicCount.
+//
+#define EFI_DATA_RECORD_HEADER_VERSION 0x0100
+typedef struct {
+ UINT16 Version;
+ UINT16 HeaderSize;
+ UINT32 RecordSize;
+ EFI_GUID DataRecordGuid;
+ EFI_GUID ProducerName;
+ UINT64 DataRecordClass;
+ EFI_TIME LogTime;
+ UINT64 LogMonotonicCount;
+} EFI_DATA_RECORD_HEADER;
+
+//
+// Definition of DataRecordClass. These are used to filter out class types
+// at a very high level. The DataRecordGuid still defines the format of
+// the data. See DateHub.doc for rules on what can and can not be a
+// new DataRecordClass
+//
+#define EFI_DATA_RECORD_CLASS_DEBUG 0x0000000000000001
+#define EFI_DATA_RECORD_CLASS_ERROR 0x0000000000000002
+#define EFI_DATA_RECORD_CLASS_DATA 0x0000000000000004
+#define EFI_DATA_RECORD_CLASS_PROGRESS_CODE 0x0000000000000008
+
+//
+// Forward reference for pure ANSI compatability
+//
+EFI_FORWARD_DECLARATION (EFI_DATA_HUB_PROTOCOL);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_DATA_HUB_LOG_DATA) (
+ IN EFI_DATA_HUB_PROTOCOL * This,
+ IN EFI_GUID * DataRecordGuid,
+ IN EFI_GUID * ProducerName,
+ IN UINT64 DataRecordClass,
+ IN VOID *RawData,
+ IN UINT32 RawDataSize
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_DATA_HUB_GET_NEXT_RECORD) (
+ IN EFI_DATA_HUB_PROTOCOL * This,
+ IN OUT UINT64 *MonotonicCount,
+ IN EFI_EVENT * FilterDriver OPTIONAL,
+ OUT EFI_DATA_RECORD_HEADER **Record
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_DATA_HUB_REGISTER_FILTER_DRIVER) (
+ IN EFI_DATA_HUB_PROTOCOL * This,
+ IN EFI_EVENT FilterEvent,
+ IN EFI_TPL FilterTpl,
+ IN UINT64 FilterClass,
+ IN EFI_GUID * FilterDataRecordGuid OPTIONAL
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_DATA_HUB_UNREGISTER_FILTER_DRIVER) (
+ IN EFI_DATA_HUB_PROTOCOL * This,
+ IN EFI_EVENT FilterEvent
+ );
+
+typedef struct _EFI_DATA_HUB_PROTOCOL {
+ EFI_DATA_HUB_LOG_DATA LogData;
+ EFI_DATA_HUB_GET_NEXT_RECORD GetNextRecord;
+ EFI_DATA_HUB_REGISTER_FILTER_DRIVER RegisterFilterDriver;
+ EFI_DATA_HUB_UNREGISTER_FILTER_DRIVER UnregisterFilterDriver;
+} EFI_DATA_HUB_PROTOCOL;
+
+extern EFI_GUID gEfiDataHubProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Protocol/EdkFrameworkProtocolLib.cif b/EDK/Foundation/Framework/Protocol/EdkFrameworkProtocolLib.cif
new file mode 100644
index 0000000..25fe8c8
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/EdkFrameworkProtocolLib.cif
@@ -0,0 +1,87 @@
+<component>
+ name = "EdkFrameworkProtocolLib"
+ category = ModulePart
+ LocalRoot = "Edk\Foundation\Framework\Protocol\"
+ RefName = "EdkFrameworkProtocolLib"
+[files]
+"EdkFrameworkProtocolLib.sdl"
+"EdkFrameworkProtocolLib.mak"
+"AcpiS3Save\AcpiS3Save.h"
+"AcpiS3Save\AcpiS3Save.c"
+"AcpiSupport\AcpiSupport.h"
+"AcpiSupport\AcpiSupport.c"
+"BootScriptSave\BootScriptSave.h"
+"BootScriptSave\BootScriptSave.c"
+"CpuIo\CpuIo.h"
+"CpuIo\CpuIo.c"
+"DataHub\DataHub.h"
+"DataHub\DataHub.c"
+"ExitPmAuth\ExitPmAuth.h"
+"ExitPmAuth\ExitPmAuth.c"
+"FirmwareVolume\FirmwareVolume.h"
+"FirmwareVolume\FirmwareVolume.c"
+"FirmwareVolume2\FirmwareVolume2.h"
+"FirmwareVolume2\FirmwareVolume2.c"
+"FirmwareVolumeBlock\FirmwareVolumeBlock.h"
+"FirmwareVolumeBlock\FirmwareVolumeBlock.c"
+"FormBrowser\FormBrowser.h"
+"FormBrowser\FormBrowser.c"
+"FormCallback\FormCallback.h"
+"FormCallback\FormCallback.c"
+"Hii\Hii.h"
+"Hii\Hii.c"
+"IdeControllerInit\IdeControllerInit.h"
+"IdeControllerInit\IdeControllerInit.c"
+"IncompatiblePciDeviceSupport\IncompatiblePciDeviceSupport.h"
+"IncompatiblePciDeviceSupport\IncompatiblePciDeviceSupport.c"
+"Legacy8259\Legacy8259.h"
+"Legacy8259\Legacy8259.c"
+"LegacyBios\LegacyBios.h"
+"LegacyBios\LegacyBios.c"
+"LegacyBiosPlatform\LegacyBiosPlatform.h"
+"LegacyBiosPlatform\LegacyBiosPlatform.c"
+"LegacyInterrupt\LegacyInterrupt.h"
+"LegacyInterrupt\LegacyInterrupt.c"
+"LegacyRegion\LegacyRegion.h"
+"LegacyRegion\LegacyRegion.c"
+"PciHostBridgeResourceAllocation\PciHostBridgeResourceAllocation.h"
+"PciHostBridgeResourceAllocation\PciHostBridgeResourceAllocation.c"
+"PciHotPlugInit\PciHotPlugInit.h"
+"PciHotPlugInit\PciHotPlugInit.c"
+"PciPlatform\PciPlatform.h"
+"PciPlatform\PciPlatform.c"
+"SectionExtraction\SectionExtraction.h"
+"SectionExtraction\SectionExtraction.c"
+"SecurityPolicy\SecurityPolicy.h"
+"SecurityPolicy\SecurityPolicy.c"
+"Smbus\Smbus.h"
+"Smbus\Smbus.c"
+"SmmAccess\SmmAccess.h"
+"SmmAccess\SmmAccess.c"
+"SmmBase\SmmBase.h"
+"SmmBase\SmmBase.c"
+"SmmControl\SmmControl.h"
+"SmmControl\SmmControl.c"
+"SmmCpuState\CpuSaveState.h"
+"SmmCpuState\SmmCpuState.h"
+"SmmCpuState\SmmCpuState.c"
+"SmmGpiDispatch\SmmGpiDispatch.h"
+"SmmGpiDispatch\SmmGpiDispatch.c"
+"SmmIchnDispatch\SmmIchnDispatch.h"
+"SmmIchnDispatch\SmmIchnDispatch.c"
+"SmmPeriodicTimerDispatch\SmmPeriodicTimerDispatch.h"
+"SmmPeriodicTimerDispatch\SmmPeriodicTimerDispatch.c"
+"SmmPowerButtonDispatch\SmmPowerButtonDispatch.h"
+"SmmPowerButtonDispatch\SmmPowerButtonDispatch.c"
+"SmmStandbyButtonDispatch\SmmStandbyButtonDispatch.h"
+"SmmStandbyButtonDispatch\SmmStandbyButtonDispatch.c"
+"SmmStatusCode\SmmStatusCode.h"
+"SmmStatusCode\SmmStatusCode.c"
+"SmmSwDispatch\SmmSwDispatch.h"
+"SmmSwDispatch\SmmSwDispatch.c"
+"SmmSxDispatch\SmmSxDispatch.h"
+"SmmSxDispatch\SmmSxDispatch.c"
+"SmmUsbDispatch\SmmUsbDispatch.h"
+"SmmUsbDispatch\SmmUsbDispatch.c"
+"EdkFrameworkProtocolLib.inf"
+<endComponent>
diff --git a/EDK/Foundation/Framework/Protocol/EdkFrameworkProtocolLib.inf b/EDK/Foundation/Framework/Protocol/EdkFrameworkProtocolLib.inf
new file mode 100644
index 0000000..2e1b3e6
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/EdkFrameworkProtocolLib.inf
@@ -0,0 +1,117 @@
+#/*++
+#
+# Copyright (c) 2004, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# EdkFrameworkProtocolLib.inf
+#
+# Abstract:
+#
+# Component description file.
+#
+#--*/
+
+[defines]
+BASE_NAME= EdkFrameworkProtocolLib
+COMPONENT_TYPE= LIBRARY
+
+[includes.common]
+ $(EDK_SOURCE)\Foundation\Framework
+ $(EDK_SOURCE)\Foundation\Efi
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)\Foundation\Include\Pei
+ $(EDK_SOURCE)\Foundation\Library\Pei\Include
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+
+[nmake.common]
+C_STD_INCLUDE=
+
+[sources.common]
+ AcpiS3Save\AcpiS3Save.h
+ AcpiS3Save\AcpiS3Save.c
+ AcpiSupport\AcpiSupport.h
+ AcpiSupport\AcpiSupport.c
+ BootScriptSave\BootScriptSave.h
+ BootScriptSave\BootScriptSave.c
+ CpuIo\CpuIo.h
+ CpuIo\CpuIo.c
+ DataHub\DataHub.h
+ DataHub\DataHub.c
+ ExitPmAuth\ExitPmAuth.h
+ ExitPmAuth\ExitPmAuth.c
+ FirmwareVolume\FirmwareVolume.h
+ FirmwareVolume\FirmwareVolume.c
+ FirmwareVolumeBlock\FirmwareVolumeBlock.h
+ FirmwareVolumeBlock\FirmwareVolumeBlock.c
+ FormBrowser\FormBrowser.h
+ FormBrowser\FormBrowser.c
+ FormCallback\FormCallback.h
+ FormCallback\FormCallback.c
+ Hii\Hii.h
+ Hii\Hii.c
+ IdeControllerInit\IdeControllerInit.h
+ IdeControllerInit\IdeControllerInit.c
+ IncompatiblePciDeviceSupport\IncompatiblePciDeviceSupport.h
+ IncompatiblePciDeviceSupport\IncompatiblePciDeviceSupport.c
+ Legacy8259\Legacy8259.h
+ Legacy8259\Legacy8259.c
+ LegacyBios\LegacyBios.h
+ LegacyBios\LegacyBios.c
+ LegacyBiosPlatform\LegacyBiosPlatform.h
+ LegacyBiosPlatform\LegacyBiosPlatform.c
+ LegacyInterrupt\LegacyInterrupt.h
+ LegacyInterrupt\LegacyInterrupt.c
+ LegacyRegion\LegacyRegion.h
+ LegacyRegion\LegacyRegion.c
+ PciHostBridgeResourceAllocation\PciHostBridgeResourceAllocation.h
+ PciHostBridgeResourceAllocation\PciHostBridgeResourceAllocation.c
+ PciHotPlugInit\PciHotPlugInit.h
+ PciHotPlugInit\PciHotPlugInit.c
+ PciPlatform\PciPlatform.h
+ PciPlatform\PciPlatform.c
+ SectionExtraction\SectionExtraction.h
+ SectionExtraction\SectionExtraction.c
+ SecurityPolicy\SecurityPolicy.h
+ SecurityPolicy\SecurityPolicy.c
+ Smbus\Smbus.h
+ Smbus\Smbus.c
+
+[sources.ia32,sources.x64]
+ SmmAccess\SmmAccess.h
+ SmmAccess\SmmAccess.c
+ SmmBase\SmmBase.h
+ SmmBase\SmmBase.c
+ SmmControl\SmmControl.h
+ SmmControl\SmmControl.c
+ SmmCpuState\SmmCpuState.h
+ SmmCpuState\SmmCpuState.c
+ SmmGpiDispatch\SmmGpiDispatch.h
+ SmmGpiDispatch\SmmGpiDispatch.c
+ SmmIchnDispatch\SmmIchnDispatch.h
+ SmmIchnDispatch\SmmIchnDispatch.c
+ SmmPeriodicTimerDispatch\SmmPeriodicTimerDispatch.h
+ SmmPeriodicTimerDispatch\SmmPeriodicTimerDispatch.c
+ SmmPowerButtonDispatch\SmmPowerButtonDispatch.h
+ SmmPowerButtonDispatch\SmmPowerButtonDispatch.c
+ SmmStandbyButtonDispatch\SmmStandbyButtonDispatch.h
+ SmmStandbyButtonDispatch\SmmStandbyButtonDispatch.c
+ SmmStatusCode\SmmStatusCode.h
+ SmmStatusCode\SmmStatusCode.c
+ SmmSwDispatch\SmmSwDispatch.h
+ SmmSwDispatch\SmmSwDispatch.c
+ SmmSxDispatch\SmmSxDispatch.h
+ SmmSxDispatch\SmmSxDispatch.c
+ SmmUsbDispatch\SmmUsbDispatch.h
+ SmmUsbDispatch\SmmUsbDispatch.c \ No newline at end of file
diff --git a/EDK/Foundation/Framework/Protocol/EdkFrameworkProtocolLib.mak b/EDK/Foundation/Framework/Protocol/EdkFrameworkProtocolLib.mak
new file mode 100644
index 0000000..4545cd9
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/EdkFrameworkProtocolLib.mak
@@ -0,0 +1,68 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkFrameworkProtocolLib/EdkFrameworkProtocolLib.mak 1 1/20/12 4:03a Jeffch $
+#
+# $Revision: 1 $
+#
+# $Date: 1/20/12 4:03a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkFrameworkProtocolLib/EdkFrameworkProtocolLib.mak $
+#
+# 1 1/20/12 4:03a Jeffch
+#
+# 1 9/27/11 6:27a Wesleychen
+# Intel EDK initially releases.
+#
+# 2 9/02/09 3:20a Iminglin
+# EIP24919
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: EdkFrameworkProtocolLib.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+$(EDKFRAMEWORKPROTOCOLLIB) : EdkFrameworkProtocolLib
+
+$(BUILD_DIR)\EdkFrameworkProtocolLib.lib : EdkFrameworkProtocolLib
+
+EdkFrameworkProtocolLib : $(BUILD_DIR)\EdkFrameworkProtocolLib.mak EdkFrameworkProtocolLibBin
+
+$(BUILD_DIR)\EdkFrameworkProtocolLib.mak : $(EdkFrameworkProtocolLib_DIR)\$(@B).cif $(EdkFrameworkProtocolLib_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(EdkFrameworkProtocolLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+EdkFrameworkProtocolLibBin :
+ $(MAKE) /$(MAKEFLAGS) $(EDK_DEFAULTS)\
+ /f $(BUILD_DIR)\EdkFrameworkProtocolLib.mak all\
+ TYPE=LIBRARY \
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#********************************************************************** \ No newline at end of file
diff --git a/EDK/Foundation/Framework/Protocol/EdkFrameworkProtocolLib.sdl b/EDK/Foundation/Framework/Protocol/EdkFrameworkProtocolLib.sdl
new file mode 100644
index 0000000..5471689
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/EdkFrameworkProtocolLib.sdl
@@ -0,0 +1,26 @@
+TOKEN
+ Name = "EdkFrameworkProtocolLib_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable EdkFrameworkProtocolLib support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "EDKFRAMEWORKPROTOCOLLIB"
+ Value = "$(BUILD_DIR)\EdkFrameworkProtocolLib.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "EdkFrameworkProtocolLib_DIR"
+End
+
+MODULE
+ Help = "Includes EdkFrameworkProtocolLib.mak to Project"
+ File = "EdkFrameworkProtocolLib.mak"
+End
+
diff --git a/EDK/Foundation/Framework/Protocol/ExitPmAuth/ExitPmAuth.c b/EDK/Foundation/Framework/Protocol/ExitPmAuth/ExitPmAuth.c
new file mode 100644
index 0000000..9e1624a
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/ExitPmAuth/ExitPmAuth.c
@@ -0,0 +1,35 @@
+/*++
+ This file contains 'Framework Code' and is licensed as such
+ under the terms of your license agreement with Intel or your
+ vendor. This file may not be modified, except as allowed by
+ additional terms of your license agreement.
+--*/
+/*++
+
+Copyright (c) 2009 Intel Corporation. All rights reserved
+This software and associated documentation (if any) is furnished
+under a license and may only be used or copied in accordance
+with the terms of the license. Except as permitted by such
+license, no part of this software or documentation may be
+reproduced, stored in a retrieval system, or transmitted in any
+form or by any means without the express written consent of
+Intel Corporation.
+
+
+Module Name:
+
+ ExitPmAuth.c
+
+Abstract:
+
+
+
+--*/
+
+#include "Tiano.h"
+#include EFI_PROTOCOL_DEFINITION (ExitPmAuth)
+
+EFI_GUID gExitPmAuthProtocolGuid = EXIT_PM_AUTH_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gExitPmAuthProtocolGuid, "Exit PM Auth Protocol", "Exit PM Auth Protocol");
+
diff --git a/EDK/Foundation/Framework/Protocol/ExitPmAuth/ExitPmAuth.h b/EDK/Foundation/Framework/Protocol/ExitPmAuth/ExitPmAuth.h
new file mode 100644
index 0000000..d27689b
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/ExitPmAuth/ExitPmAuth.h
@@ -0,0 +1,40 @@
+//
+// This file contains 'Framework Code' and is licensed as such
+// under the terms of your license agreement with Intel or your
+// vendor. This file may not be modified, except as allowed by
+// additional terms of your license agreement.
+//
+/*++
+
+Copyright (c) 2009 Intel Corporation. All rights reserved
+This software and associated documentation (if any) is furnished
+under a license and may only be used or copied in accordance
+with the terms of the license. Except as permitted by such
+license, no part of this software or documentation may be
+reproduced, stored in a retrieval system, or transmitted in any
+form or by any means without the express written consent of
+Intel Corporation.
+
+
+Module Name:
+
+ ExitPmAuth.h
+
+Abstract:
+
+
+--*/
+
+#ifndef _EXIT_PM_AUTH_PROTOCOL_H_
+#define _EXIT_PM_AUTH_PROTOCOL_H_
+
+#include "Tiano.h"
+
+#define EXIT_PM_AUTH_PROTOCOL_GUID \
+ { \
+ 0xd088a413, 0xa70, 0x4217, 0xba, 0x55, 0x9a, 0x3c, 0xb6, 0x5c, 0x41, 0xb3 \
+ }
+
+extern EFI_GUID gExitPmAuthProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Protocol/FirmwareVolume/FirmwareVolume.c b/EDK/Foundation/Framework/Protocol/FirmwareVolume/FirmwareVolume.c
new file mode 100644
index 0000000..c64d73a
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/FirmwareVolume/FirmwareVolume.c
@@ -0,0 +1,31 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ FirmwareVolume.c
+
+Abstract:
+
+ Firmware Volume protocol as defined in the Tiano Firmware Volume
+ specification.
+
+ File level access layered on top of Firmware File System protocol. This
+ protocol exists to provide a hook for a filter driver for a firmware volume.
+
+--*/
+
+#include "Tiano.h"
+#include EFI_PROTOCOL_DEFINITION (FirmwareVolume)
+
+EFI_GUID gEfiFirmwareVolumeProtocolGuid = EFI_FIRMWARE_VOLUME_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiFirmwareVolumeProtocolGuid, "FirmwareVolume Protocol", "Firmware Volume protocol");
diff --git a/EDK/Foundation/Framework/Protocol/FirmwareVolume/FirmwareVolume.h b/EDK/Foundation/Framework/Protocol/FirmwareVolume/FirmwareVolume.h
new file mode 100644
index 0000000..fadc1b8
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/FirmwareVolume/FirmwareVolume.h
@@ -0,0 +1,334 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ FirmwareVolume.h
+
+Abstract:
+
+ Firmware Volume protocol as defined in the Tiano Firmware Volume
+ specification.
+
+--*/
+
+#ifndef _FW_VOL_H_
+#define _FW_VOL_H_
+
+//
+// Statements that include other files
+//
+#include "EfiFirmwareVolumeHeader.h"
+#include "EfiFirmwareFileSystem.h"
+#include "EfiFirmwareVolume.h" //;;## ...AMI_OVERRIDE... Support PI1.x
+//
+// Firmware Volume Protocol GUID definition
+//
+#define EFI_FIRMWARE_VOLUME_PROTOCOL_GUID \
+ { \
+ 0x389F751F, 0x1838, 0x4388, 0x83, 0x90, 0xCD, 0x81, 0x54, 0xBD, 0x27, 0xF8 \
+ }
+
+//;;## ...AMI_OVERRIDE... Support PI1.x #define FV_DEVICE_SIGNATURE EFI_SIGNATURE_32 ('_', 'F', 'V', '_')
+
+EFI_FORWARD_DECLARATION (EFI_FIRMWARE_VOLUME_PROTOCOL);
+
+//
+// EFI_FV_ATTRIBUTES bit definitions
+//
+//;;## ...AMI_OVERRIDE... Support PI1.x typedef UINT64 EFI_FV_ATTRIBUTES;
+
+//
+// ************************************************************
+// EFI_FV_ATTRIBUTES bit definitions
+// ************************************************************
+//
+#define EFI_FV_READ_DISABLE_CAP 0x0000000000000001
+#define EFI_FV_READ_ENABLE_CAP 0x0000000000000002
+#define EFI_FV_READ_STATUS 0x0000000000000004
+
+#define EFI_FV_WRITE_DISABLE_CAP 0x0000000000000008
+#define EFI_FV_WRITE_ENABLE_CAP 0x0000000000000010
+#define EFI_FV_WRITE_STATUS 0x0000000000000020
+
+#define EFI_FV_LOCK_CAP 0x0000000000000040
+#define EFI_FV_LOCK_STATUS 0x0000000000000080
+#define EFI_FV_WRITE_POLICY_RELIABLE 0x0000000000000100
+
+#define EFI_FV_ALIGNMENT_CAP 0x0000000000008000
+#define EFI_FV_ALIGNMENT_2 0x0000000000010000
+#define EFI_FV_ALIGNMENT_4 0x0000000000020000
+#define EFI_FV_ALIGNMENT_8 0x0000000000040000
+#define EFI_FV_ALIGNMENT_16 0x0000000000080000
+#define EFI_FV_ALIGNMENT_32 0x0000000000100000
+#define EFI_FV_ALIGNMENT_64 0x0000000000200000
+#define EFI_FV_ALIGNMENT_128 0x0000000000400000
+#define EFI_FV_ALIGNMENT_256 0x0000000000800000
+#define EFI_FV_ALIGNMENT_512 0x0000000001000000
+#define EFI_FV_ALIGNMENT_1K 0x0000000002000000
+#define EFI_FV_ALIGNMENT_2K 0x0000000004000000
+#define EFI_FV_ALIGNMENT_4K 0x0000000008000000
+#define EFI_FV_ALIGNMENT_8K 0x0000000010000000
+#define EFI_FV_ALIGNMENT_16K 0x0000000020000000
+#define EFI_FV_ALIGNMENT_32K 0x0000000040000000
+#define EFI_FV_ALIGNMENT_64K 0x0000000080000000
+
+//
+// Protocol API definitions
+//
+//
+// Forward declaration of protocol data structure
+//
+typedef struct _EFI_FIRMWARE_VOLUME_PROTOCOL EFI_FIRMWARE_VOLUME_PROTOCOL;
+
+typedef
+EFI_STATUS
+//;;## ...AMI_OVERRIDE... Support PI1.x (EFIAPI *EFI_FV_GET_ATTRIBUTES) (
+(EFIAPI *FV_GET_ATTRIBUTES) (
+ IN EFI_FIRMWARE_VOLUME_PROTOCOL * This,
+ OUT EFI_FV_ATTRIBUTES * Attributes
+ );
+
+/*++
+
+Routine Description:
+ Retrieves attributes, insures positive polarity of attribute bits, returns
+ resulting attributes in output parameter
+
+Arguments:
+ This - Calling context
+ Attributes - output buffer which contains attributes
+
+Returns:
+ EFI_INVALID_PARAMETER
+ EFI_SUCCESS
+
+--*/
+typedef
+EFI_STATUS
+//;;## ...AMI_OVERRIDE... Support PI1.x (EFIAPI *EFI_FV_SET_ATTRIBUTES) (
+(EFIAPI *FV_SET_ATTRIBUTES) (
+ IN EFI_FIRMWARE_VOLUME_PROTOCOL * This,
+ IN OUT EFI_FV_ATTRIBUTES * Attributes
+ );
+
+/*++
+
+Routine Description:
+ Sets volume attributes
+
+Arguments:
+ This Calling context
+ Attributes Buffer which contains attributes
+
+Returns:
+ EFI_INVALID_PARAMETER
+ EFI_DEVICE_ERROR
+ EFI_SUCCESS
+
+--*/
+//;;## ...AMI_OVERRIDE... Support PI1.x typedef UINT32 EFI_FV_FILE_ATTRIBUTES;
+
+//;;## ...AMI_OVERRIDE... Support PI1.x #define EFI_FV_FILE_ATTRIB_ALIGNMENT 0x0000001F
+
+typedef
+EFI_STATUS
+//;;## ...AMI_OVERRIDE... Support PI1.x (EFIAPI *EFI_FV_READ_FILE) (
+(EFIAPI *FV_READ_FILE) (
+ IN EFI_FIRMWARE_VOLUME_PROTOCOL * This,
+ IN EFI_GUID * NameGuid,
+ IN OUT VOID **Buffer,
+ IN OUT UINTN *BufferSize,
+ OUT EFI_FV_FILETYPE * FoundType,
+ OUT EFI_FV_FILE_ATTRIBUTES * FileAttributes,
+ OUT UINT32 *AuthenticationStatus
+ );
+
+/*++
+
+Routine Description:
+ Read the requested file (NameGuid) and returns data in Buffer.
+
+Arguments:
+ This - Calling context
+ NameGuid - Filename identifying which file to read
+ Buffer - Pointer to pointer to buffer in which contents of file are returned.
+
+ If Buffer is NULL, only type, attributes, and size are returned as
+ there is no output buffer.
+
+ If Buffer != NULL and *Buffer == NULL, the output buffer is allocated
+ from BS pool by ReadFile
+
+ If Buffer != NULL and *Buffer != NULL, the output buffer has been
+ allocated by the caller and is being passed in.
+
+ BufferSize - Indicates the buffer size passed in, and on output the size
+ required to complete the read
+ FoundType - Indicates the type of the file who's data is returned
+ FileAttributes - Indicates the attributes of the file who's data is resturned
+ AuthenticationStatus - Indicates the authentication status of the data
+
+Returns:
+ EFI_SUCCESS
+ EFI_WARN_BUFFER_TOO_SMALL
+ EFI_NOT_FOUND
+ EFI_DEVICE_ERROR
+ EFI_ACCESS_DENIED
+
+--*/
+typedef
+EFI_STATUS
+//;;## ...AMI_OVERRIDE... Support PI1.x (EFIAPI *EFI_FV_READ_SECTION) (
+(EFIAPI *FV_READ_SECTION) (
+ IN EFI_FIRMWARE_VOLUME_PROTOCOL * This,
+ IN EFI_GUID * NameGuid,
+ IN EFI_SECTION_TYPE SectionType,
+ IN UINTN SectionInstance,
+ IN OUT VOID **Buffer,
+ IN OUT UINTN *BufferSize,
+ OUT UINT32 *AuthenticationStatus
+ );
+
+/*++
+
+Routine Description:
+ Read the requested section from the specified file and returns data in Buffer.
+
+Arguments:
+ This - Calling context
+ NameGuid - Filename identifying the file from which to read
+ SectionType - Indicates what section type to retrieve
+ SectionInstance - Indicates which instance of SectionType to retrieve
+ Buffer - Pointer to pointer to buffer in which contents of file are returned.
+
+ If Buffer is NULL, only type, attributes, and size are returned as
+ there is no output buffer.
+
+ If Buffer != NULL and *Buffer == NULL, the output buffer is allocated
+ from BS pool by ReadFile
+
+ If Buffer != NULL and *Buffer != NULL, the output buffer has been
+ allocated by the caller and is being passed in.
+
+ BufferSize - Indicates the buffer size passed in, and on output the size
+ required to complete the read
+ AuthenticationStatus - Indicates the authentication status of the data
+
+Returns:
+ EFI_SUCCESS
+ EFI_WARN_BUFFER_TOO_SMALL
+ EFI_OUT_OF_RESOURCES
+ EFI_NOT_FOUND
+ EFI_DEVICE_ERROR
+ EFI_ACCESS_DENIED
+
+--*/
+//;;## ...AMI_OVERRIDE... Support PI1.x typedef UINT32 EFI_FV_WRITE_POLICY;
+
+//;;## ...AMI_OVERRIDE... Support PI1.x #define EFI_FV_UNRELIABLE_WRITE 0x00000000
+//;;## ...AMI_OVERRIDE... Support PI1.x #define EFI_FV_RELIABLE_WRITE 0x00000001
+
+//;;## ...AMI_OVERRIDE... Support PI1.x typedef struct {
+//;;## ...AMI_OVERRIDE... Support PI1.x EFI_GUID *NameGuid;
+//;;## ...AMI_OVERRIDE... Support PI1.x EFI_FV_FILETYPE Type;
+//;;## ...AMI_OVERRIDE... Support PI1.x EFI_FV_FILE_ATTRIBUTES FileAttributes;
+//;;## ...AMI_OVERRIDE... Support PI1.x VOID *Buffer;
+//;;## ...AMI_OVERRIDE... Support PI1.x UINT32 BufferSize;
+//;;## ...AMI_OVERRIDE... Support PI1.x } EFI_FV_WRITE_FILE_DATA;
+
+typedef
+EFI_STATUS
+//;;## ...AMI_OVERRIDE... Support PI1.x (EFIAPI *EFI_FV_WRITE_FILE) (
+(EFIAPI *FV_WRITE_FILE) (
+ IN EFI_FIRMWARE_VOLUME_PROTOCOL * This,
+ IN UINT32 NumberOfFiles,
+ IN EFI_FV_WRITE_POLICY WritePolicy,
+ IN EFI_FV_WRITE_FILE_DATA * FileData
+ );
+
+/*++
+
+Routine Description:
+ Write the supplied file (NameGuid) to the FV.
+
+Arguments:
+ This - Calling context
+ NumberOfFiles - Indicates the number of file records pointed to by FileData
+ WritePolicy - Indicates the level of reliability of the write with respect to
+ things like power failure events.
+ FileData - A pointer to an array of EFI_FV_WRITE_FILE_DATA structures. Each
+ element in the array indicates a file to write, and there are
+ NumberOfFiles elements in the input array.
+
+Returns:
+ EFI_SUCCESS
+ EFI_OUT_OF_RESOURCES
+ EFI_DEVICE_ERROR
+ EFI_WRITE_PROTECTED
+ EFI_NOT_FOUND
+ EFI_INVALID_PARAMETER
+
+--*/
+typedef
+EFI_STATUS
+//;;## ...AMI_OVERRIDE... Support PI1.x (EFIAPI *EFI_FV_GET_NEXT_FILE) (
+(EFIAPI *FV_GET_NEXT_FILE) (
+ IN EFI_FIRMWARE_VOLUME_PROTOCOL * This,
+ IN OUT VOID *Key,
+ IN OUT EFI_FV_FILETYPE * FileType,
+ OUT EFI_GUID * NameGuid,
+ OUT EFI_FV_FILE_ATTRIBUTES * Attributes,
+ OUT UINTN *Size
+ );
+
+/*++
+
+Routine Description:
+ Given the input key, search for the next matching file in the volume.
+
+Arguments:
+ This - Calling context
+ Key - Pointer to a caller allocated buffer that contains an implementation
+ specific key that is used to track where to begin searching on
+ successive calls.
+ FileType - Indicates the file type to filter for
+ NameGuid - Guid filename of the file found
+ Attributes - Attributes of the file found
+ Size - Size in bytes of the file found
+
+Returns:
+ EFI_SUCCESS
+ EFI_NOT_FOUND
+ EFI_DEVICE_ERROR
+ EFI_ACCESS_DENIED
+
+--*/
+typedef struct _EFI_FIRMWARE_VOLUME_PROTOCOL {
+//;;## ...AMI_OVERRIDE... Support PI1.x EFI_FV_GET_ATTRIBUTES GetVolumeAttributes;
+//;;## ...AMI_OVERRIDE... Support PI1.x EFI_FV_SET_ATTRIBUTES SetVolumeAttributes;
+//;;## ...AMI_OVERRIDE... Support PI1.x EFI_FV_READ_FILE ReadFile;
+//;;## ...AMI_OVERRIDE... Support PI1.x EFI_FV_READ_SECTION ReadSection;
+//;;## ...AMI_OVERRIDE... Support PI1.x EFI_FV_WRITE_FILE WriteFile;
+//;;## ...AMI_OVERRIDE... Support PI1.x EFI_FV_GET_NEXT_FILE GetNextFile;
+ FV_GET_ATTRIBUTES GetVolumeAttributes;
+ FV_SET_ATTRIBUTES SetVolumeAttributes;
+ FV_READ_FILE ReadFile;
+ FV_READ_SECTION ReadSection;
+ FV_WRITE_FILE WriteFile;
+ FV_GET_NEXT_FILE GetNextFile;
+ UINT32 KeySize;
+ EFI_HANDLE ParentHandle;
+} EFI_FIRMWARE_VOLUME_PROTOCOL;
+
+extern EFI_GUID gEfiFirmwareVolumeProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Protocol/FirmwareVolume2/FirmwareVolume2.c b/EDK/Foundation/Framework/Protocol/FirmwareVolume2/FirmwareVolume2.c
new file mode 100644
index 0000000..9e284b2
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/FirmwareVolume2/FirmwareVolume2.c
@@ -0,0 +1,30 @@
+/*++
+
+Copyright (c) 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ FirmwareVolume2.c
+
+Abstract:
+
+ PI 1.0 spec definition.
+
+--*/
+
+
+#include "Tiano.h"
+
+#include EFI_PROTOCOL_DEFINITION (FirmwareVolume2)
+
+ //;;## ...AMI_ADD FILE... Support PI1.x
+EFI_GUID gEfiFirmwareVolume2ProtocolGuid = EFI_FIRMWARE_VOLUME2_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiFirmwareVolume2ProtocolGuid, "FirmwareVolume2Protocol", "Efi FirmwareVolume2Protocol"); \ No newline at end of file
diff --git a/EDK/Foundation/Framework/Protocol/FirmwareVolume2/FirmwareVolume2.h b/EDK/Foundation/Framework/Protocol/FirmwareVolume2/FirmwareVolume2.h
new file mode 100644
index 0000000..766cc94
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/FirmwareVolume2/FirmwareVolume2.h
@@ -0,0 +1,195 @@
+/*++
+
+Copyright (c) 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ FirmwareVolume2.h
+
+Abstract:
+
+ PI 1.0 spec definition.
+
+--*/
+
+#ifndef __FIRMWARE_VOLUME2_H__
+#define __FIRMWARE_VOLUME2_H__
+#include "EfiImageFormat.h"
+#include "EfiFirmwareVolume.h"
+ //;;## ...AMI_ADD FILE... Support PI1.x
+//
+// Firmware Volume Protocol GUID definition
+//
+#define EFI_FIRMWARE_VOLUME2_PROTOCOL_GUID \
+ { 0x220e73b6, 0x6bdb, 0x4413, 0x84, 0x5, 0xb9, 0x74, 0xb1, 0x8, 0x61, 0x9a }
+
+
+EFI_FORWARD_DECLARATION (EFI_FIRMWARE_VOLUME2_PROTOCOL);
+
+
+//
+// ************************************************************
+// EFI_FV2_ATTRIBUTES bit definitions
+// ************************************************************
+//
+#define EFI_FV2_READ_DISABLE_CAP 0x0000000000000001
+#define EFI_FV2_READ_ENABLE_CAP 0x0000000000000002
+#define EFI_FV2_READ_STATUS 0x0000000000000004
+
+#define EFI_FV2_WRITE_DISABLE_CAP 0x0000000000000008
+#define EFI_FV2_WRITE_ENABLE_CAP 0x0000000000000010
+#define EFI_FV2_WRITE_STATUS 0x0000000000000020
+
+#define EFI_FV2_LOCK_CAP 0x0000000000000040
+#define EFI_FV2_LOCK_STATUS 0x0000000000000080
+#define EFI_FV2_WRITE_POLICY_RELIABLE 0x0000000000000100
+
+#define EFI_FV2_READ_LOCK_CAP 0x0000000000001000
+#define EFI_FV2_READ_LOCK_STATUS 0x0000000000002000
+#define EFI_FV2_WRITE_LOCK_CAP 0x0000000000004000
+#define EFI_FV2_WRITE_LOCK_STATUS 0x0000000000008000
+#define EFI_FV2_ALIGNMENT 0x00000000001F0000
+
+
+#define EFI_FV2_ALIGNMENT_1 0x0000000000000000
+#define EFI_FV2_ALIGNMENT_2 0x0000000000010000
+#define EFI_FV2_ALIGNMENT_4 0x0000000000020000
+#define EFI_FV2_ALIGNMENT_8 0x0000000000030000
+#define EFI_FV2_ALIGNMENT_16 0x0000000000040000
+#define EFI_FV2_ALIGNMENT_32 0x0000000000050000
+#define EFI_FV2_ALIGNMENT_64 0x0000000000060000
+#define EFI_FV2_ALIGNMENT_128 0x0000000000070000
+#define EFI_FV2_ALIGNMENT_256 0x0000000000080000
+#define EFI_FV2_ALIGNMENT_512 0x0000000000090000
+#define EFI_FV2_ALIGNMENT_1K 0x00000000000A0000
+#define EFI_FV2_ALIGNMENT_2K 0x00000000000B0000
+#define EFI_FV2_ALIGNMENT_4K 0x00000000000C0000
+#define EFI_FV2_ALIGNMENT_8K 0x00000000000D0000
+#define EFI_FV2_ALIGNMENT_16K 0x00000000000E0000
+#define EFI_FV2_ALIGNMENT_32K 0x00000000000F0000
+#define EFI_FV2_ALIGNMENT_64K 0x0000000000100000
+#define EFI_FV2_ALIGNMENT_128K 0x0000000000110000
+#define EFI_FV2_ALIGNMENT_256K 0x0000000000120000
+#define EFI_FV2_ALIGNMENT_512K 0x0000000000130000
+#define EFI_FV2_ALIGNMENT_1M 0x0000000000140000
+#define EFI_FV2_ALIGNMENT_2M 0x0000000000150000
+#define EFI_FV2_ALIGNMENT_4M 0x0000000000160000
+#define EFI_FV2_ALIGNMENT_8M 0x0000000000170000
+#define EFI_FV2_ALIGNMENT_16M 0x0000000000180000
+#define EFI_FV2_ALIGNMENT_32M 0x0000000000190000
+#define EFI_FV2_ALIGNMENT_64M 0x00000000001A0000
+#define EFI_FV2_ALIGNMENT_128M 0x00000000001B0000
+#define EFI_FV2_ALIGNMENT_256M 0x00000000001C0000
+#define EFI_FV2_ALIGNMENT_512M 0x00000000001D0000
+#define EFI_FV2_ALIGNMENT_1G 0x00000000001E0000
+#define EFI_FV2_ALIGNMENT_2G 0x00000000001F0000
+
+#define EFI_FV_FILE_ATTRIB_FIXED 0x00000100
+#define EFI_FV_FILE_ATTRIB_MEMORY_MAPPED 0x00000200
+
+
+//
+// Protocol API definitions
+//
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_FV_GET_ATTRIBUTES) (
+ IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,
+ OUT EFI_FV_ATTRIBUTES *Attributes
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_FV_SET_ATTRIBUTES) (
+ IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,
+ IN OUT EFI_FV_ATTRIBUTES *Attributes
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_FV_READ_FILE) (
+ IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,
+ IN CONST EFI_GUID *NameGuid,
+ IN OUT VOID **Buffer,
+ IN OUT UINTN *BufferSize,
+ OUT EFI_FV_FILETYPE *FoundType,
+ OUT EFI_FV_FILE_ATTRIBUTES *FileAttributes,
+ OUT UINT32 *AuthenticationStatus
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_FV_READ_SECTION) (
+ IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,
+ IN CONST EFI_GUID *NameGuid,
+ IN EFI_SECTION_TYPE SectionType,
+ IN UINTN SectionInstance,
+ IN OUT VOID **Buffer,
+ IN OUT UINTN *BufferSize,
+ OUT UINT32 *AuthenticationStatus
+ );
+
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_FV_WRITE_FILE) (
+ IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,
+ IN UINT32 NumberOfFiles,
+ IN EFI_FV_WRITE_POLICY WritePolicy,
+ IN EFI_FV_WRITE_FILE_DATA *FileData
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_FV_GET_NEXT_FILE) (
+ IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,
+ IN OUT VOID *Key,
+ IN OUT EFI_FV_FILETYPE *FileType,
+ OUT EFI_GUID *NameGuid,
+ OUT EFI_FV_FILE_ATTRIBUTES *Attributes,
+ OUT UINTN *Size
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_FV_GET_INFO) (
+ IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,
+ IN CONST EFI_GUID *InformationType,
+ IN OUT UINTN *BufferSize,
+ OUT VOID *Buffer
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_FV_SET_INFO) (
+ IN CONST EFI_FIRMWARE_VOLUME2_PROTOCOL *This,
+ IN CONST EFI_GUID *InformationType,
+ IN UINTN BufferSize,
+ IN CONST VOID *Buffer
+ );
+
+
+typedef struct _EFI_FIRMWARE_VOLUME2_PROTOCOL {
+ EFI_FV_GET_ATTRIBUTES GetVolumeAttributes;
+ EFI_FV_SET_ATTRIBUTES SetVolumeAttributes;
+ EFI_FV_READ_FILE ReadFile;
+ EFI_FV_READ_SECTION ReadSection;
+ EFI_FV_WRITE_FILE WriteFile;
+ EFI_FV_GET_NEXT_FILE GetNextFile;
+ UINT32 KeySize;
+ EFI_HANDLE ParentHandle;
+ EFI_FV_GET_INFO GetInfo;
+ EFI_FV_SET_INFO SetInfo;
+} EFI_FIRMWARE_VOLUME2_PROTOCOL;
+
+extern EFI_GUID gEfiFirmwareVolume2ProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Protocol/FirmwareVolumeBlock/FirmwareVolumeBlock.c b/EDK/Foundation/Framework/Protocol/FirmwareVolumeBlock/FirmwareVolumeBlock.c
new file mode 100644
index 0000000..17c37df
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/FirmwareVolumeBlock/FirmwareVolumeBlock.c
@@ -0,0 +1,35 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ FirmwareVolumeBlock.c
+
+Abstract:
+
+ Firmware Volume Block protocol as defined in the Tiano Firmware Volume
+ specification.
+
+ Low level firmware device access routines to abstract firmware device
+ hardware.
+
+--*/
+
+#include "Tiano.h"
+#include EFI_PROTOCOL_DEFINITION (FirmwareVolumeBlock)
+
+EFI_GUID gFramerworkEfiFirmwareVolumeBlockProtocolGuid = FRAMEWORK_EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL_GUID; //;;## ...AMI_OVERRIDE... Support PI1.x
+EFI_GUID gEfiFirmwareVolumeBlockProtocolGuid = EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL_GUID;
+EFI_GUID gEfiFirmwareVolumeBlock2ProtocolGuid = EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL_GUID; //;;## ...AMI_OVERRIDE... Support PI1.x
+
+EFI_GUID_STRING(&gFramerworkEfiFirmwareVolumeBlockProtocolGuid, "FirmwareVolumeBlock Protocol", "Framework Firmware Volume Block protocol"); //;;## ...AMI_OVERRIDE... Support PI1.x
+EFI_GUID_STRING(&gEfiFirmwareVolumeBlock2ProtocolGuid, "FirmwareVolumeBlock2 Protocol", "Firmware Volume Block2 protocol"); //;;## ...AMI_OVERRIDE... Support PI1.x
+
diff --git a/EDK/Foundation/Framework/Protocol/FirmwareVolumeBlock/FirmwareVolumeBlock.h b/EDK/Foundation/Framework/Protocol/FirmwareVolumeBlock/FirmwareVolumeBlock.h
new file mode 100644
index 0000000..12599f6
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/FirmwareVolumeBlock/FirmwareVolumeBlock.h
@@ -0,0 +1,270 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ FirmwareVolumeBlock.h
+
+Abstract:
+
+ Firmware Volume Block protocol as defined in the Tiano Firmware Volume
+ specification.
+
+ Low level firmware device access routines to abstract firmware device
+ hardware.
+
+--*/
+
+#ifndef _FW_VOL_BLOCK_H_
+#define _FW_VOL_BLOCK_H_
+
+#include "EfiFirmwareVolumeHeader.h"
+//;;## ...AMI_OVERRIDE... Support PI1.x start
+#define FRAMEWORK_EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL_GUID \
+ { \
+ 0xDE28BC59, 0x6228, 0x41BD, 0xBD, 0xF6, 0xA3, 0xB9, 0xAD, 0xB5, 0x8D, 0xA1 \
+ }
+
+#define EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL_GUID \
+ { \
+ 0x8f644fa9, 0xe850, 0x4db1, 0x9c, 0xe2, 0xb, 0x44, 0x69, 0x8e, 0x8d, 0xa4 \
+ }
+
+#if (PI_SPECIFICATION_VERSION < 0x00010000)
+#define EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL_GUID FRAMEWORK_EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL_GUID
+#else
+//
+// EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL is defined in PI 1.0 spec and its GUID value
+// is later updated to be the same as that of EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL
+// defined in PI 1.2 spec.
+//
+#define EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL_GUID EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL_GUID
+#endif
+
+EFI_FORWARD_DECLARATION (EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL);
+typedef EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL EFI_FIRMWARE_VOLUME_BLOCK2_PROTOCOL;
+//;;## ...AMI_OVERRIDE... Support PI1.x end
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_FVB_GET_ATTRIBUTES) (
+ IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL * This,
+ OUT EFI_FVB_ATTRIBUTES * Attributes
+ )
+/*++
+
+Routine Description:
+ Retrieves Volume attributes. No polarity translations are done.
+
+Arguments:
+ This - Calling context
+ Attributes - output buffer which contains attributes
+
+Returns:
+ EFI_INVALID_PARAMETER
+ EFI_SUCCESS
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_FVB_SET_ATTRIBUTES) (
+ IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL * This,
+ IN OUT EFI_FVB_ATTRIBUTES * Attributes
+ )
+/*++
+
+Routine Description:
+ Sets Volume attributes. No polarity translations are done.
+
+Arguments:
+ This - Calling context
+ Attributes - On input: contains new attributes
+ On output: contains current attributes of FV
+
+Returns:
+ EFI_INVALID_PARAMETER
+ EFI_SUCCESS
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_FVB_GET_PHYSICAL_ADDRESS) (
+ IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL * This,
+ OUT EFI_PHYSICAL_ADDRESS * Address
+ )
+/*++
+
+Routine Description:
+ Retrieves the physical address of a memory mapped FV.
+
+Arguments:
+ This - Calling context
+ Attributes - Address is a pointer to a caller allocated EFI_PHYSICAL_ADDRESS
+ that on successful return from GetPhysicalAddress() contains the
+ base address of the firmware volume.
+
+Returns:
+ EFI_UNSUPPORTED
+ EFI_SUCCESS
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_FVB_GET_BLOCK_SIZE) (
+ IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL * This,
+ IN EFI_LBA Lba,
+ OUT UINTN *BlockSize,
+ OUT UINTN *NumberOfBlocks
+ )
+/*++
+
+Routine Description:
+ Retrieves the size in bytes of a specific block within an FV.
+
+Arguments:
+ This - Calling context.
+ Lba - Indicates which block to return the size for.
+ BlockSize - BlockSize is a pointer to a caller allocated
+ UINTN in which the size of the block is returned.
+ NumberOfBlocks - NumberOfBlocks is a pointer to a caller allocated
+ UINTN in which the number of consecutive blocks
+ starting with Lba is returned. All blocks in this
+ range have a size of BlockSize.
+
+Returns:
+ EFI_INVALID_PARAMETER
+ EFI_SUCCESS
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_FVB_READ) (
+ IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL * This,
+ IN EFI_LBA Lba,
+ IN UINTN Offset,
+ IN OUT UINTN *NumBytes,
+ OUT UINT8 *Buffer
+ )
+/*++
+
+Routine Description:
+ Reads data beginning at Lba:Offset from FV and places the data in Buffer.
+ The read terminates either when *NumBytes of data have been read, or when
+ a block boundary is reached. *NumBytes is updated to reflect the actual
+ number of bytes read.
+
+Arguments:
+ This - Calling context
+ Lba - Block in which to begin read
+ Offset - Offset in the block at which to begin read
+ NumBytes - At input, indicates the requested read size. At output, indicates
+ the actual number of bytes read.
+ Buffer - Data buffer in which to place data read.
+
+Returns:
+ EFI_INVALID_PARAMETER
+ EFI_NOT_FOUND
+ EFI_DEVICE_ERROR
+ EFI_SUCCESS
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_FVB_WRITE) (
+ IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL * This,
+ IN EFI_LBA Lba,
+ IN UINTN Offset,
+ IN OUT UINTN *NumBytes,
+ IN UINT8 *Buffer
+ )
+/*++
+
+Routine Description:
+
+ Writes data beginning at Lba:Offset from FV. The write terminates either
+ when *NumBytes of data have been written, or when a block boundary is
+ reached. *NumBytes is updated to reflect the actual number of bytes
+ written.
+
+Arguments:
+ This - Calling context
+ Lba - Block in which to begin write
+ Offset - Offset in the block at which to begin write
+ NumBytes - At input, indicates the requested write size. At output, indicates
+ the actual number of bytes written.
+ Buffer - Buffer containing source data for the write.
+
+Returns:
+ EFI_INVALID_PARAMETER
+ EFI_NOT_FOUND
+ EFI_DEVICE_ERROR
+ EFI_SUCCESS
+
+--*/
+;
+
+#define EFI_LBA_LIST_TERMINATOR 0xFFFFFFFFFFFFFFFF
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_FVB_ERASE_BLOCKS) (
+ IN EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL * This,
+ ...
+ )
+/*++
+
+Routine Description:
+ The EraseBlock() function erases one or more blocks as denoted by the
+variable argument list. The entire parameter list of blocks must be verified
+prior to erasing any blocks. If a block is requested that does not exist
+within the associated firmware volume (it has a larger index than the last
+block of the firmware volume), the EraseBlock() function must return
+EFI_INVALID_PARAMETER without modifying the contents of the firmware volume.
+
+Arguments:
+ This - Calling context
+ ... - Starting LBA followed by Number of Lba to erase. a -1 to terminate
+ the list.
+
+Returns:
+ EFI_INVALID_PARAMETER
+ EFI_DEVICE_ERROR
+ EFI_SUCCESS
+ EFI_ACCESS_DENIED
+
+--*/
+;
+
+typedef struct _EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL {
+ EFI_FVB_GET_ATTRIBUTES GetVolumeAttributes;
+ EFI_FVB_SET_ATTRIBUTES SetVolumeAttributes;
+ EFI_FVB_GET_PHYSICAL_ADDRESS GetPhysicalAddress;
+ EFI_FVB_GET_BLOCK_SIZE GetBlockSize;
+ EFI_FVB_READ Read;
+ EFI_FVB_WRITE Write;
+ EFI_FVB_ERASE_BLOCKS EraseBlocks;
+ EFI_HANDLE ParentHandle;
+} EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL;
+
+extern EFI_GUID gEfiFirmwareVolumeBlockProtocolGuid;
+extern EFI_GUID gEfiFirmwareVolumeBlock2ProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Protocol/FormBrowser/FormBrowser.c b/EDK/Foundation/Framework/Protocol/FormBrowser/FormBrowser.c
new file mode 100644
index 0000000..f8c5843
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/FormBrowser/FormBrowser.c
@@ -0,0 +1,31 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ FormBrowser.c
+
+Abstract:
+
+ The EFI_FORM_BROWSER_PROTOCOL is the interface to the EFI
+ Configuration Driver. This will allow the caller to direct the
+ configuration driver to use either the HII database or use the passed
+ in packet of data. This will also allow the caller to post messages
+ into the configuration drivers internal mailbox.
+
+--*/
+
+#include "Tiano.h"
+#include EFI_PROTOCOL_DEFINITION (FormBrowser)
+
+EFI_GUID gEfiFormBrowserProtocolGuid = EFI_FORM_BROWSER_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiFormBrowserProtocolGuid, "Form Browser Protocol", "Form Browser 1.0 protocol");
diff --git a/EDK/Foundation/Framework/Protocol/FormBrowser/FormBrowser.h b/EDK/Foundation/Framework/Protocol/FormBrowser/FormBrowser.h
new file mode 100644
index 0000000..5f1e3ba
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/FormBrowser/FormBrowser.h
@@ -0,0 +1,97 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ FormBrowser.h
+
+Abstract:
+
+ The EFI_FORM_BROWSER_PROTOCOL is the interface to the EFI
+ Configuration Driver. This will allow the caller to direct the
+ configuration driver to use either the HII database or use the passed
+ in packet of data. This will also allow the caller to post messages
+ into the configuration drivers internal mailbox.
+
+--*/
+
+#ifndef _FORM_BROWSER_H_
+#define _FORM_BROWSER_H_
+
+#include EFI_PROTOCOL_DEFINITION (Hii)
+
+#define EFI_FORM_BROWSER_PROTOCOL_GUID \
+ { \
+ 0xe5a1333e, 0xe1b4, 0x4d55, 0xce, 0xeb, 0x35, 0xc3, 0xef, 0x13, 0x34, 0x43 \
+ }
+
+//
+// Forward reference for pure ANSI compatability
+//
+EFI_FORWARD_DECLARATION (EFI_FORM_BROWSER_PROTOCOL);
+
+typedef struct _EFI_FORM_BROWSER_PROTOCOL EFI_FORM_BROWSER_PROTOCOL;
+
+typedef struct {
+ UINT32 Length;
+ UINT16 Type;
+ UINT8 Data[1];
+} EFI_HII_PACKET;
+
+typedef struct {
+ EFI_HII_IFR_PACK *IfrData;
+ EFI_HII_STRING_PACK *StringData;
+} EFI_IFR_PACKET;
+
+typedef struct {
+ UINTN LeftColumn;
+ UINTN RightColumn;
+ UINTN TopRow;
+ UINTN BottomRow;
+} SCREEN_DESCRIPTOR;
+
+//
+// The following types are currently defined:
+//
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SEND_FORM) (
+ IN EFI_FORM_BROWSER_PROTOCOL * This,
+ IN BOOLEAN UseDatabase,
+ IN EFI_HII_HANDLE * Handle,
+ IN UINTN HandleCount,
+ IN EFI_IFR_PACKET * Packet,
+ IN EFI_HANDLE CallbackHandle,
+ IN UINT8 *NvMapOverride,
+ IN SCREEN_DESCRIPTOR * ScreenDimensions,
+ OUT BOOLEAN *ResetRequired OPTIONAL
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_CREATE_POP_UP) (
+ IN UINTN NumberOfLines,
+ IN BOOLEAN HotKey,
+ IN UINTN MaximumStringSize,
+ OUT CHAR16 *StringBuffer,
+ OUT EFI_INPUT_KEY * KeyValue,
+ IN CHAR16 *String,
+ ...
+ );
+
+typedef struct _EFI_FORM_BROWSER_PROTOCOL {
+ EFI_SEND_FORM SendForm;
+ EFI_CREATE_POP_UP CreatePopUp;
+} EFI_FORM_BROWSER_PROTOCOL;
+
+extern EFI_GUID gEfiFormBrowserProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Protocol/FormCallback/FormCallback.c b/EDK/Foundation/Framework/Protocol/FormCallback/FormCallback.c
new file mode 100644
index 0000000..3563117
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/FormCallback/FormCallback.c
@@ -0,0 +1,31 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ FormCallback.c
+
+Abstract:
+
+ The EFI_FORM_CALLBACK_PROTOCOL is the defined interface for access to custom
+ NV storage devices as well as communication of user selections in a more
+ interactive environment. This protocol should be published by hardware
+ specific drivers which want to export access to custom hardware storage or
+ publish IFR which has a requirement to call back the original driver.
+
+--*/
+
+#include "Tiano.h"
+#include EFI_PROTOCOL_DEFINITION (FormCallback)
+
+EFI_GUID gEfiFormCallbackProtocolGuid = EFI_FORM_CALLBACK_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiFormCallbackProtocolGuid, "Form Callback Protocol", "Form Callback 1.0 protocol");
diff --git a/EDK/Foundation/Framework/Protocol/FormCallback/FormCallback.h b/EDK/Foundation/Framework/Protocol/FormCallback/FormCallback.h
new file mode 100644
index 0000000..7595981
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/FormCallback/FormCallback.h
@@ -0,0 +1,120 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ FormCallback.h
+
+Abstract:
+
+ The EFI_FORM_CALLBACK_PROTOCOL is the defined interface for access to custom
+ NV storage devices as well as communication of user selections in a more
+ interactive environment. This protocol should be published by hardware
+ specific drivers which want to export access to custom hardware storage or
+ publish IFR which has a requirement to call back the original driver.
+
+--*/
+
+#ifndef _FORM_CALLBACK_H_
+#define _FORM_CALLBACK_H_
+
+#include EFI_PROTOCOL_DEFINITION (FormBrowser)
+
+#define EFI_FORM_CALLBACK_PROTOCOL_GUID \
+ { \
+ 0xf3e4543d, 0xcf35, 0x6cef, 0x35, 0xc4, 0x4f, 0xe6, 0x34, 0x4d, 0xfc, 0x54 \
+ }
+
+//
+// Forward reference for pure ANSI compatability
+//
+EFI_FORWARD_DECLARATION (EFI_FORM_CALLBACK_PROTOCOL);
+
+typedef struct _EFI_FORM_CALLBACK_PROTOCOL EFI_FORM_CALLBACK_PROTOCOL;
+
+#define RESET_REQUIRED 1 // Flags setting to signify that the callback operation resulted in an eventual
+// reset to be done upon exit of the browser
+//
+#define EXIT_REQUIRED 2 // Flags setting to signify that after the processing of the callback results - exit the browser
+#define SAVE_REQUIRED 4 // Flags setting to signify that after the processing of the callback results - save the NV data
+#define NV_CHANGED 8 // Flags setting to signify that after the processing of the callback results - turn the NV flag on
+#define NV_NOT_CHANGED 16 // Flags setting to signify that after the processing of the callback results - turn the NV flag off
+#pragma pack(1)
+typedef struct {
+ UINT8 OpCode; // Likely a string, numeric, or one-of
+ UINT8 Length; // Length of the EFI_IFR_DATA_ENTRY packet
+ UINT16 Flags; // Flags settings to determine what behavior is desired from the browser after the callback
+ VOID *Data; // The data in the form based on the op-code type - this is not a pointer to the data, the data follows immediately
+ // If the OpCode is a OneOf or Numeric type - Data is a UINT16 value
+ // If the OpCode is a String type - Data is a CHAR16[x] type
+ // If the OpCode is a Checkbox type - Data is a UINT8 value
+ // If the OpCode is a NV Access type - Data is a EFI_IFR_NV_DATA structure
+ //
+} EFI_IFR_DATA_ENTRY;
+
+typedef struct {
+ VOID *NvRamMap; // If the flag of the op-code specified retrieval of a copy of the NVRAM map,
+ // this is a pointer to a buffer copy
+ //
+ UINT32 EntryCount; // How many EFI_IFR_DATA_ENTRY entries
+ EFI_IFR_DATA_ENTRY Data[1]; // The in-line Data entries.
+} EFI_IFR_DATA_ARRAY;
+
+typedef union {
+ EFI_IFR_DATA_ARRAY DataArray; // Primarily used by those who call back to their drivers and use HII as a repository
+ EFI_IFR_PACKET DataPacket; // Primarily used by those which do not use HII as a repository
+ CHAR16 String[1]; // If returning an error - fill the string with null-terminated contents
+} EFI_HII_CALLBACK_PACKET;
+#pragma pack()
+//
+// The following types are currently defined:
+//
+typedef
+EFI_STATUS
+(EFIAPI *EFI_NV_READ) (
+ IN EFI_FORM_CALLBACK_PROTOCOL * This,
+ IN CHAR16 *VariableName,
+ IN EFI_GUID * VendorGuid,
+ OUT UINT32 *Attributes OPTIONAL,
+ IN OUT UINTN *DataSize,
+ OUT VOID *Buffer
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_NV_WRITE) (
+ IN EFI_FORM_CALLBACK_PROTOCOL * This,
+ IN CHAR16 *VariableName,
+ IN EFI_GUID * VendorGuid,
+ IN UINT32 Attributes,
+ IN UINTN DataSize,
+ IN VOID *Buffer,
+ OUT BOOLEAN *ResetRequired
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_FORM_CALLBACK) (
+ IN EFI_FORM_CALLBACK_PROTOCOL * This,
+ IN UINT16 KeyValue,
+ IN EFI_IFR_DATA_ARRAY * Data,
+ OUT EFI_HII_CALLBACK_PACKET **Packet
+ );
+
+typedef struct _EFI_FORM_CALLBACK_PROTOCOL {
+ EFI_NV_READ NvRead;
+ EFI_NV_WRITE NvWrite;
+ EFI_FORM_CALLBACK Callback;
+} EFI_FORM_CALLBACK_PROTOCOL;
+
+extern EFI_GUID gEfiFormCallbackProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Protocol/Hii/Hii.c b/EDK/Foundation/Framework/Protocol/Hii/Hii.c
new file mode 100644
index 0000000..917d89b
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/Hii/Hii.c
@@ -0,0 +1,30 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Hii.c
+
+Abstract:
+
+ This file defines the Human Interface Infrastructure protocol which will
+ be used by resources which want to publish IFR/Font/String data and have it
+ collected by the Configuration engine.
+
+
+--*/
+
+#include "Tiano.h"
+#include EFI_PROTOCOL_DEFINITION (Hii)
+
+EFI_GUID gEfiHiiProtocolGuid = EFI_HII_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiHiiProtocolGuid, "Human Interface Infrastructure Protocol", "HII 1.0 protocol");
diff --git a/EDK/Foundation/Framework/Protocol/Hii/Hii.h b/EDK/Foundation/Framework/Protocol/Hii/Hii.h
new file mode 100644
index 0000000..ee1341b
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/Hii/Hii.h
@@ -0,0 +1,618 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Hii.h
+
+Abstract:
+
+ This file defines the Human Interface Infrastructure protocol which will
+ be used by resources which want to publish IFR/Font/String data and have it
+ collected by the Configuration engine.
+
+--*/
+
+#ifndef _HII_H_
+#define _HII_H_
+
+#include "EfiInternalFormRepresentation.h"
+#include EFI_PROTOCOL_DEFINITION (UgaDraw)
+#include EFI_PROTOCOL_DEFINITION (GraphicsOutput)
+
+//*** AMI PORTING BEGIN ***//
+//#define EFI_HII_PROTOCOL_GUID \
+// { \
+// 0xd7ad636e, 0xb997, 0x459b, 0xbf, 0x3f, 0x88, 0x46, 0x89, 0x79, 0x80, 0xe1 \
+// }
+
+#define EFI_HII_NEW_PROTOCOL_GUID \
+ { 0xea816d2c, 0xcee5, 0x4f02, 0x99, 0xb5, 0xd3, 0x90, 0x5c, 0xbb, 0xd0, 0x77 }
+#define EFI_HII_PROTOCOL_GUID EFI_HII_NEW_PROTOCOL_GUID
+//*** AMI PORTING END *****//
+//
+// Forward reference for pure ANSI compatability
+//
+EFI_FORWARD_DECLARATION (EFI_HII_PROTOCOL);
+
+typedef struct _EFI_HII_PROTOCOL EFI_HII_PROTOCOL;
+
+//
+// Global definition
+//
+#define NARROW_CHAR 0xFFF0
+#define WIDE_CHAR 0xFFF1
+#define NON_BREAKING_CHAR 0xFFF2
+#define GLYPH_WIDTH 8
+#define GLYPH_HEIGHT 19
+
+#define EFI_HII_FONT 1
+#define EFI_HII_STRING 2
+#define EFI_HII_IFR 3
+#define EFI_HII_KEYBOARD 4
+#define EFI_HII_HANDLES 5
+#define EFI_HII_VARIABLE 6
+#define EFI_HII_DEVICE_PATH 7
+
+#define HANG(foo) { \
+ volatile INT32 __iii; \
+ __iii = foo; \
+ while (__iii) \
+ ; \
+ }
+//
+// #define HANG(foo)
+//
+// References to string tokens must use this macro to enable scanning for
+// token usages.
+//
+#define STRING_TOKEN(t) t
+
+//
+// The following types are currently defined:
+//
+typedef UINT16 EFI_FORM_ID;
+typedef UINT16 EFI_FORM_LABEL;
+typedef UINT16 EFI_HII_HANDLE;
+
+#pragma pack(1)
+
+typedef struct {
+ UINT32 Length;
+ UINT16 Type;
+} EFI_HII_PACK_HEADER;
+
+//
+// A form list consists of a large variety of structure
+// possibilities so to represent the binary blob of data
+// associated with a package of forms, we will assume a
+// pointer to a self-describing data buffer.
+//
+typedef struct {
+ EFI_HII_PACK_HEADER Header;
+} EFI_HII_IFR_PACK;
+
+typedef struct {
+ EFI_HII_PACK_HEADER Header; // Must be filled in
+ EFI_HANDLE ImageHandle; // Must be filled in
+ EFI_HANDLE DeviceHandle; // Optional
+ EFI_HANDLE ControllerHandle; // Optional
+ EFI_HANDLE CallbackHandle; // Optional
+ EFI_HANDLE COBExportHandle; // Optional
+} EFI_HII_HANDLE_PACK;
+
+//
+// ********************************************************
+// EFI_VARIABLE_CONTENTS
+// ********************************************************
+//
+typedef struct {
+ EFI_HII_PACK_HEADER Header;
+ EFI_GUID VariableGuid;
+ UINT32 VariableNameLength;
+ UINT16 VariableId;
+ //
+ // CHAR16 VariableName[]; //Null-terminated
+ //
+} EFI_HII_VARIABLE_PACK;
+
+//
+// ********************************************************
+// EFI_DEVICE_PATH_PACK
+// ********************************************************
+//
+typedef struct {
+ EFI_HII_PACK_HEADER Header;
+ //
+ // EFI_DEVICE_PATH DevicePath[];
+ //
+} EFI_HII_DEVICE_PATH_PACK;
+
+//
+// ********************************************************
+// EFI_HII_DATA_TABLE
+// ********************************************************
+//
+typedef struct {
+ EFI_HII_HANDLE HiiHandle;
+ EFI_GUID PackageGuid;
+ UINT32 DataTableSize;
+ UINT32 IfrDataOffset;
+ UINT32 StringDataOffset;
+ UINT32 VariableDataOffset;
+ UINT32 DevicePathOffset;
+ UINT32 NumberOfVariableData;
+ UINT32 NumberOfLanguages;
+ //
+ // EFI_HII_DEVICE_PATH_PACK DevicePath[];
+ // EFI_HII_VARIABLE_PACK VariableData[];
+ // EFI_HII_IFR_PACK IfrData;
+ // EFI_HII_STRING_PACK StringData[];
+ //
+} EFI_HII_DATA_TABLE;
+
+//
+// ********************************************************
+// EFI_HII_EXPORT_TABLE
+// ********************************************************
+//
+typedef struct {
+ UINT16 NumberOfHiiDataTables;
+ EFI_GUID Revision;
+ //
+ // EFI_HII_DATA_TABLE HiiDataTable[];
+ //
+} EFI_HII_EXPORT_TABLE;
+
+typedef struct {
+ BOOLEAN FormSetUpdate; // If TRUE, next variable is significant
+ EFI_PHYSICAL_ADDRESS FormCallbackHandle; // If not 0, will update Formset with this info
+ BOOLEAN FormUpdate; // If TRUE, next variable is significant
+ STRING_REF FormTitle; // If not 0, will update Form with this info
+ UINT16 DataCount; // The number of Data entries in this structure
+ UINT8 *Data; // An array of 1+ op-codes, specified by DataCount
+} EFI_HII_UPDATE_DATA;
+
+//
+// String attributes
+//
+#define LANG_RIGHT_TO_LEFT 0x00000001
+
+//
+// A string package is used to localize strings to a particular
+// language. The package is associated with a particular driver
+// or set of drivers. Tools are used to associate tokens with
+// string references in forms and in programs. These tokens are
+// language agnostic. When paired with a language pack (directly
+// or indirectly), the string token resolves into an actual
+// UNICODE string. The NumStringPointers determines how many
+// StringPointers (offset values) there are as well as the total
+// number of Strings that are defined.
+//
+typedef struct {
+ EFI_HII_PACK_HEADER Header;
+ RELOFST LanguageNameString;
+ RELOFST PrintableLanguageName;
+ UINT32 NumStringPointers;
+ UINT32 Attributes;
+ //
+ // RELOFST StringPointers[];
+ // EFI_STRING Strings[];
+ //
+} EFI_HII_STRING_PACK;
+
+//
+// We use this one to get the real size of the header
+//
+typedef struct {
+ EFI_HII_PACK_HEADER Header;
+ RELOFST LanguageNameString;
+ RELOFST PrintableLanguageName;
+ UINT32 NumStringPointers;
+ UINT32 Attributes;
+} EFI_HII_STRING_PACK_HEADER;
+
+//
+// Glyph Attributes
+//
+#define GLYPH_NON_SPACING 1
+#define GLYPH_NON_BREAKING 2
+
+typedef struct {
+ CHAR16 UnicodeWeight;
+ UINT8 Attributes;
+ UINT8 GlyphCol1[GLYPH_HEIGHT];
+} EFI_NARROW_GLYPH;
+
+typedef struct {
+ CHAR16 UnicodeWeight;
+ UINT8 Attributes;
+ UINT8 GlyphCol1[GLYPH_HEIGHT];
+ UINT8 GlyphCol2[GLYPH_HEIGHT];
+ UINT8 Pad[3];
+} EFI_WIDE_GLYPH;
+
+//
+// A font list consists of a font header followed by a series
+// of glyph structures. Note that fonts are not language specific.
+//
+typedef struct {
+ EFI_HII_PACK_HEADER Header;
+ UINT16 NumberOfNarrowGlyphs;
+ UINT16 NumberOfWideGlyphs;
+} EFI_HII_FONT_PACK;
+
+//
+// The IfrData in the EFI_HII_IFR_PACK structure definition
+// is variable length, and not really part of the header. To
+// simplify from code the size of the header, define an
+// identical structure that does not include the IfrData field.
+// Then use sizeof() this new structure to determine the
+// actual size of the header.
+//
+typedef struct {
+ EFI_HII_PACK_HEADER Header;
+} EFI_HII_IFR_PACK_HEADER;
+
+//
+// pedef EFI_HII_PACK_HEADER EFI_HII_IFR_PACK_HEADER;
+//
+typedef enum {
+ EfiKeyLCtrl,
+ EfiKeyA0,
+ EfiKeyLAlt,
+ EfiKeySpaceBar,
+ EfiKeyA2,
+ EfiKeyA3,
+ EfiKeyA4,
+ EfiKeyRCtrl,
+ EfiKeyLeftArrow,
+ EfiKeyDownArrow,
+ EfiKeyRightArrow,
+ EfiKeyZero,
+ EfiKeyPeriod,
+ EfiKeyEnter,
+ EfiKeyLShift,
+ EfiKeyB0,
+ EfiKeyB1,
+ EfiKeyB2,
+ EfiKeyB3,
+ EfiKeyB4,
+ EfiKeyB5,
+ EfiKeyB6,
+ EfiKeyB7,
+ EfiKeyB8,
+ EfiKeyB9,
+ EfiKeyB10,
+ EfiKeyRshift,
+ EfiKeyUpArrow,
+ EfiKeyOne,
+ EfiKeyTwo,
+ EfiKeyThree,
+ EfiKeyCapsLock,
+ EfiKeyC1,
+ EfiKeyC2,
+ EfiKeyC3,
+ EfiKeyC4,
+ EfiKeyC5,
+ EfiKeyC6,
+ EfiKeyC7,
+ EfiKeyC8,
+ EfiKeyC9,
+ EfiKeyC10,
+ EfiKeyC11,
+ EfiKeyC12,
+ EfiKeyFour,
+ EfiKeyFive,
+ EfiKeySix,
+ EfiKeyPlus,
+ EfiKeyTab,
+ EfiKeyD1,
+ EfiKeyD2,
+ EfiKeyD3,
+ EfiKeyD4,
+ EfiKeyD5,
+ EfiKeyD6,
+ EfiKeyD7,
+ EfiKeyD8,
+ EfiKeyD9,
+ EfiKeyD10,
+ EfiKeyD11,
+ EfiKeyD12,
+ EfiKeyD13,
+ EfiKeyDel,
+ EfiKeyEnd,
+ EfiKeyPgDn,
+ EfiKeySeven,
+ EfiKeyEight,
+ EfiKeyNine,
+ EfiKeyE0,
+ EfiKeyE1,
+ EfiKeyE2,
+ EfiKeyE3,
+ EfiKeyE4,
+ EfiKeyE5,
+ EfiKeyE6,
+ EfiKeyE7,
+ EfiKeyE8,
+ EfiKeyE9,
+ EfiKeyE10,
+ EfiKeyE11,
+ EfiKeyE12,
+ EfiKeyBackSpace,
+ EfiKeyIns,
+ EfiKeyHome,
+ EfiKeyPgUp,
+ EfiKeyNLck,
+ EfiKeySlash,
+ EfiKeyAsterisk,
+ EfiKeyMinus,
+ EfiKeyEsc,
+ EfiKeyF1,
+ EfiKeyF2,
+ EfiKeyF3,
+ EfiKeyF4,
+ EfiKeyF5,
+ EfiKeyF6,
+ EfiKeyF7,
+ EfiKeyF8,
+ EfiKeyF9,
+ EfiKeyF10,
+ EfiKeyF11,
+ EfiKeyF12,
+ EfiKeyPrint,
+ EfiKeySLck,
+ EfiKeyPause
+} EFI_KEY;
+
+typedef struct {
+ EFI_KEY Key;
+ CHAR16 Unicode;
+ CHAR16 ShiftedUnicode;
+ CHAR16 AltGrUnicode;
+ CHAR16 ShiftedAltGrUnicode;
+ UINT16 Modifier;
+} EFI_KEY_DESCRIPTOR;
+
+//
+// This structure allows a sparse set of keys to be redefined
+// or a complete redefinition of the keyboard layout. Most
+// keyboards have a lot of commonality in their layouts, therefore
+// only defining those keys that need to change from the default
+// minimizes the passed in information.
+//
+// Additionally, when an update occurs, the active keyboard layout
+// will be switched to the newly updated keyboard layout. This
+// allows for situations that when a keyboard layout driver is
+// loaded as part of system initialization, the system will default
+// the keyboard behavior to the new layout.
+//
+// Each call to update the keyboard mapping should contain the
+// complete set of key descriptors to be updated, since every
+// call to the HII which contains an EFI_HII_KEYBOARD_PACK will
+// wipe the previous set of overrides. A call to
+//
+typedef struct {
+ EFI_HII_PACK_HEADER Header;
+ EFI_KEY_DESCRIPTOR *Descriptor;
+ UINT8 DescriptorCount;
+} EFI_HII_KEYBOARD_PACK;
+
+//
+// The EFI_HII_PACKAGES can contain different types of packages just
+// after the structure as inline data.
+//
+typedef struct {
+ UINTN NumberOfPackages;
+ EFI_GUID *GuidId;
+ //
+ // EFI_HII_HANDLE_PACK *HandlePack; // Only one pack.
+ // EFI_HII_IFR_PACK *IfrPack; // Only one pack.
+ // EFI_HII_FONT_PACK *FontPack[]; // Multiple packs ok
+ // EFI_HII_STRING_PACK *StringPack[]; // Multiple packs ok
+ // EFI_HII_KEYBOARD_PACK *KeyboardPack[]; // Multiple packs ok
+ //
+} EFI_HII_PACKAGES;
+
+typedef struct _EFI_HII_VARIABLE_PACK_LIST {
+ struct _EFI_HII_VARIABLE_PACK_LIST *NextVariablePack;
+ EFI_HII_VARIABLE_PACK *VariablePack;
+} EFI_HII_VARIABLE_PACK_LIST;
+
+#pragma pack()
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_HII_NEW_PACK) (
+ IN EFI_HII_PROTOCOL * This,
+ IN EFI_HII_PACKAGES * Packages,
+ OUT EFI_HII_HANDLE * Handle
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_HII_REMOVE_PACK) (
+ IN EFI_HII_PROTOCOL *This,
+ IN EFI_HII_HANDLE Handle
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_HII_FIND_HANDLES) (
+ IN EFI_HII_PROTOCOL *This,
+ IN OUT UINT16 *HandleBufferLength,
+ OUT EFI_HII_HANDLE *Handle
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_HII_EXPORT) (
+ IN EFI_HII_PROTOCOL *This,
+ IN EFI_HII_HANDLE Handle,
+ IN OUT UINTN *BufferSize,
+ OUT VOID *Buffer
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_HII_RESET_STRINGS) (
+ IN EFI_HII_PROTOCOL *This,
+ IN EFI_HII_HANDLE Handle
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_HII_TEST_STRING) (
+ IN EFI_HII_PROTOCOL *This,
+ IN CHAR16 *StringToTest,
+ IN OUT UINT32 *FirstMissing,
+ OUT UINT32 *GlyphBufferSize
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_HII_GET_GLYPH) (
+ IN EFI_HII_PROTOCOL *This,
+ IN CHAR16 *Source,
+ IN OUT UINT16 *Index,
+ OUT UINT8 **GlyphBuffer,
+ OUT UINT16 *BitWidth,
+ IN OUT UINT32 *InternalStatus
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_HII_GLYPH_TO_BLT) (
+ IN EFI_HII_PROTOCOL *This,
+ IN UINT8 *GlyphBuffer,
+ IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL Foreground,
+ IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL Background,
+ IN UINTN Count,
+ IN UINTN Width,
+ IN UINTN Height,
+ IN OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_HII_NEW_STRING) (
+ IN EFI_HII_PROTOCOL *This,
+ IN CHAR16 *Language,
+ IN EFI_HII_HANDLE Handle,
+ IN OUT STRING_REF *Reference,
+ IN CHAR16 *NewString
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_HII_GET_PRI_LANGUAGES) (
+ IN EFI_HII_PROTOCOL *This,
+ IN EFI_HII_HANDLE Handle,
+ OUT EFI_STRING *LanguageString
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_HII_GET_SEC_LANGUAGES) (
+ IN EFI_HII_PROTOCOL *This,
+ IN EFI_HII_HANDLE Handle,
+ IN CHAR16 *PrimaryLanguage,
+ OUT EFI_STRING *LanguageString
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_HII_GET_STRING) (
+ IN EFI_HII_PROTOCOL *This,
+ IN EFI_HII_HANDLE Handle,
+ IN STRING_REF Token,
+ IN BOOLEAN Raw,
+ IN CHAR16 *LanguageString,
+ IN OUT UINTN *BufferLength,
+ OUT EFI_STRING StringBuffer
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_HII_GET_LINE) (
+ IN EFI_HII_PROTOCOL *This,
+ IN EFI_HII_HANDLE Handle,
+ IN STRING_REF Token,
+ IN OUT UINT16 *Index,
+ IN UINT16 LineWidth,
+ IN CHAR16 *LanguageString,
+ IN OUT UINT16 *BufferLength,
+ OUT EFI_STRING StringBuffer
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_HII_GET_FORMS) (
+ IN EFI_HII_PROTOCOL *This,
+ IN EFI_HII_HANDLE Handle,
+ IN EFI_FORM_ID FormId,
+ IN OUT UINTN *BufferLength,
+ OUT UINT8 *Buffer
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_HII_GET_DEFAULT_IMAGE) (
+ IN EFI_HII_PROTOCOL *This,
+ IN EFI_HII_HANDLE Handle,
+ IN UINTN DefaultMask,
+ OUT EFI_HII_VARIABLE_PACK_LIST **VariablePackList
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_HII_UPDATE_FORM) (
+ IN EFI_HII_PROTOCOL *This,
+ IN EFI_HII_HANDLE Handle,
+ IN EFI_FORM_LABEL Label,
+ IN BOOLEAN AddData,
+ IN EFI_HII_UPDATE_DATA *Data
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_HII_GET_KEYBOARD_LAYOUT) (
+ IN EFI_HII_PROTOCOL * This,
+ OUT UINT16 *DescriptorCount,
+ OUT EFI_KEY_DESCRIPTOR * Descriptor
+ );
+
+typedef struct _EFI_HII_PROTOCOL {
+ EFI_HII_NEW_PACK NewPack;
+ EFI_HII_REMOVE_PACK RemovePack;
+ EFI_HII_FIND_HANDLES FindHandles;
+ EFI_HII_EXPORT ExportDatabase;
+
+ EFI_HII_TEST_STRING TestString;
+ EFI_HII_GET_GLYPH GetGlyph;
+ EFI_HII_GLYPH_TO_BLT GlyphToBlt;
+
+ EFI_HII_NEW_STRING NewString;
+ EFI_HII_GET_PRI_LANGUAGES GetPrimaryLanguages;
+ EFI_HII_GET_SEC_LANGUAGES GetSecondaryLanguages;
+ EFI_HII_GET_STRING GetString;
+ EFI_HII_RESET_STRINGS ResetStrings;
+ EFI_HII_GET_LINE GetLine;
+ EFI_HII_GET_FORMS GetForms;
+ EFI_HII_GET_DEFAULT_IMAGE GetDefaultImage;
+ EFI_HII_UPDATE_FORM UpdateForm;
+
+ EFI_HII_GET_KEYBOARD_LAYOUT GetKeyboardLayout;
+} EFI_HII_PROTOCOL;
+
+extern EFI_GUID gEfiHiiProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Protocol/IdeControllerInit/IdeControllerInit.c b/EDK/Foundation/Framework/Protocol/IdeControllerInit/IdeControllerInit.c
new file mode 100644
index 0000000..5ae8b2b
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/IdeControllerInit/IdeControllerInit.c
@@ -0,0 +1,30 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ IdeControllerInit.c
+
+Abstract:
+
+ EFI IDE Controller Init Protocol
+
+Revision History
+
+--*/
+
+#include "Tiano.h"
+
+#include EFI_PROTOCOL_DEFINITION (IdeControllerInit)
+
+EFI_GUID gEfiIdeControllerInitProtocolGuid = EFI_IDE_CONTROLLER_INIT_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiIdeControllerInitProtocolGuid, "IDE Controller Init Protocol", "Platform IDE Init Protocol");
diff --git a/EDK/Foundation/Framework/Protocol/IdeControllerInit/IdeControllerInit.h b/EDK/Foundation/Framework/Protocol/IdeControllerInit/IdeControllerInit.h
new file mode 100644
index 0000000..09cbc96
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/IdeControllerInit/IdeControllerInit.h
@@ -0,0 +1,348 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ IdeControllerInit.h
+
+Abstract:
+
+ EFI Platform IDE Init Protocol
+
+Revision History
+
+ 0.01 - Draft, 5-01-2002
+ Add Atapi6 Identify structure definition, 8-14-2002
+
+--*/
+
+#ifndef _EFI_IDE_CONTROLLER_INIT_PROTOCOL_H
+#define _EFI_IDE_CONTROLLER_INIT_PROTOCOL_H
+
+//
+// Global ID for the EFI Platform IDE Protocol GUID
+//
+#define EFI_IDE_CONTROLLER_INIT_PROTOCOL_GUID \
+ { 0xa1e37052, 0x80d9, 0x4e65, 0xa3, 0x17, 0x3e, 0x9a, 0x55, 0xc4, 0x3e, 0xc9 }
+
+////////////////////////////////////////////////////////////////////////////////////////
+// Forward reference, ANSI compatability
+//
+EFI_FORWARD_DECLARATION (EFI_IDE_CONTROLLER_INIT_PROTOCOL);
+
+//
+//////////////////////////////////////////////////////////////////////////////////////////
+// EFI_IDE_BUS_ENUMERATION_PHASE
+// EFI_IDE_CONTROLLER_ENUM_PHASE
+//
+typedef enum{
+ EfiIdeBeforeChannelEnumeration,
+ EfiIdeAfterChannelEnumeration,
+ EfiIdeBeforeChannelReset,
+ EfiIdeAfterChannelReset,
+ EfiIdeBusBeforeDevicePresenceDetection,
+ EfiIdeBusAfterDevicePresenceDetection,
+ EfiIdeResetMode,
+ EfiIdeBusPhaseMaximum
+} EFI_IDE_CONTROLLER_ENUM_PHASE;
+
+//
+//******************************************************
+// EFI_ATA_EXT_TRANSFER_PROTOCOL
+//******************************************************
+//
+// This extended mode describes the SATA physical protocol.
+// SATA physical layers can operate at different speeds.
+// These speeds are defined below. Various PATA protocols
+// and associated modes are not applicable to SATA devices.
+//
+
+typedef enum {
+ EfiAtaSataTransferProtocol
+} EFI_ATA_EXT_TRANSFER_PROTOCOL;
+
+#define EFI_SATA_AUTO_SPEED 0
+#define EFI_SATA_GEN1_SPEED 1
+#define EFI_SATA_GEN2_SPEED 2
+
+//
+//*******************************************************
+// EFI_IDE_CABLE_TYPE
+//*******************************************************
+//
+typedef enum {
+ EfiIdeCableTypeUnknown,
+ EfiIdeCableType40pin,
+ EfiIdeCableType80Pin,
+ EfiIdeCableTypeSerial,
+ EfiIdeCableTypeMaximum
+} EFI_IDE_CABLE_TYPE;
+
+//
+//******************************************************
+// EFI_ATA_MODE
+//******************************************************
+//
+typedef struct {
+ BOOLEAN Valid;
+ UINT32 Mode;
+} EFI_ATA_MODE;
+
+//
+//******************************************************
+// EFI_ATA_EXTENDED_MODE
+//******************************************************
+//
+typedef struct {
+ EFI_ATA_EXT_TRANSFER_PROTOCOL TransferProtocol;
+ UINT32 Mode;
+} EFI_ATA_EXTENDED_MODE;
+
+//
+//******************************************************
+// EFI_ATA_COLLECTIVE_MODE
+//******************************************************
+//
+typedef struct {
+ EFI_ATA_MODE PioMode;
+ EFI_ATA_MODE SingleWordDmaMode;
+ EFI_ATA_MODE MultiWordDmaMode;
+ EFI_ATA_MODE UdmaMode;
+ UINT32 ExtModeCount;
+ EFI_ATA_EXTENDED_MODE ExtMode[1];
+} EFI_ATA_COLLECTIVE_MODE;
+
+//
+//*******************************************************
+// EFI_ATA_IDENTIFY_DATA
+//*******************************************************
+//
+
+#pragma pack(1)
+
+typedef struct {
+ UINT16 config; // General Configuration
+ UINT16 cylinders; // Number of Cylinders
+ UINT16 reserved_2;
+ UINT16 heads; //Number of logical heads
+ UINT16 vendor_data1;
+ UINT16 vendor_data2;
+ UINT16 sectors_per_track;
+ UINT16 vendor_specific_7_9[3];
+ CHAR8 SerialNo[20]; // ASCII
+ UINT16 vendor_specific_20_21[2];
+ UINT16 ecc_bytes_available;
+ CHAR8 FirmwareVer[8]; // ASCII
+ CHAR8 ModelName[40]; // ASCII
+ UINT16 multi_sector_cmd_max_sct_cnt;
+ UINT16 reserved_48;
+ UINT16 capabilities;
+ UINT16 reserved_50;
+ UINT16 pio_cycle_timing;
+ UINT16 reserved_52;
+ UINT16 field_validity;
+ UINT16 current_cylinders;
+ UINT16 current_heads;
+ UINT16 current_sectors;
+ UINT16 CurrentCapacityLsb;
+ UINT16 CurrentCapacityMsb;
+ UINT16 reserved_59;
+ UINT16 user_addressable_sectors_lo;
+ UINT16 user_addressable_sectors_hi;
+ UINT16 reserved_62;
+ UINT16 multi_word_dma_mode;
+ UINT16 advanced_pio_modes;
+ UINT16 min_multi_word_dma_cycle_time;
+ UINT16 rec_multi_word_dma_cycle_time;
+ UINT16 min_pio_cycle_time_without_flow_control;
+ UINT16 min_pio_cycle_time_with_flow_control;
+ UINT16 reserved_69_79[11];
+ UINT16 major_version_no;
+ UINT16 minor_version_no;
+ UINT16 command_set_supported_82; // word 82
+ UINT16 command_set_supported_83; // word 83
+ UINT16 command_set_feature_extn; // word 84
+ UINT16 command_set_feature_enb_85; // word 85
+ UINT16 command_set_feature_enb_86; // word 86
+ UINT16 command_set_feature_default; // word 87
+ UINT16 ultra_dma_mode; // word 88
+ UINT16 reserved_89_127[39];
+ UINT16 security_status;
+ UINT16 vendor_data_129_159[31];
+ UINT16 reserved_160_255[96];
+} EFI_ATA_IDENTIFY_DATA;
+
+#pragma pack()
+//
+//*******************************************************
+// EFI_ATAPI_IDENTIFY_DATA
+//*******************************************************
+//
+#pragma pack(1)
+typedef struct {
+ UINT16 config; // General Configuration
+ UINT16 obsolete_1;
+ UINT16 specific_config;
+ UINT16 obsolete_3;
+ UINT16 retired_4_5[2];
+ UINT16 obsolete_6;
+ UINT16 cfa_reserved_7_8[2];
+ UINT16 retired_9;
+ CHAR8 SerialNo[20]; // ASCII
+ UINT16 retired_20_21[2];
+ UINT16 obsolete_22;
+ CHAR8 FirmwareVer[8]; // ASCII
+ CHAR8 ModelName[40]; // ASCII
+ UINT16 multi_sector_cmd_max_sct_cnt;
+ UINT16 reserved_48;
+ UINT16 capabilities_49;
+ UINT16 capabilities_50;
+ UINT16 obsolete_51_52[2];
+ UINT16 field_validity;
+ UINT16 obsolete_54_58[5];
+ UINT16 mutil_sector_setting;
+ UINT16 user_addressable_sectors_lo;
+ UINT16 user_addressable_sectors_hi;
+ UINT16 obsolete_62;
+ UINT16 multi_word_dma_mode;
+ UINT16 advanced_pio_modes;
+ UINT16 min_multi_word_dma_cycle_time;
+ UINT16 rec_multi_word_dma_cycle_time;
+ UINT16 min_pio_cycle_time_without_flow_control;
+ UINT16 min_pio_cycle_time_with_flow_control;
+ UINT16 reserved_69_74[6];
+ UINT16 queue_depth;
+ UINT16 reserved_76_79[4];
+ UINT16 major_version_no;
+ UINT16 minor_version_no;
+ UINT16 cmd_set_support_82;
+ UINT16 cmd_set_support_83;
+ UINT16 cmd_feature_support;
+ UINT16 cmd_feature_enable_85;
+ UINT16 cmd_feature_enable_86;
+ UINT16 cmd_feature_default;
+ UINT16 ultra_dma_select;
+ UINT16 time_required_for_sec_erase;
+ UINT16 time_required_for_enhanced_sec_erase;
+ UINT16 current_advanced_power_mgmt_value;
+ UINT16 master_pwd_revison_code;
+ UINT16 hardware_reset_result;
+ UINT16 current_auto_acoustic_mgmt_value;
+ UINT16 reserved_95_99[5];
+ UINT16 max_user_lba_for_48bit_addr[4];
+ UINT16 reserved_104_126[23];
+ UINT16 removable_media_status_notification_support;
+ UINT16 security_status;
+ UINT16 vendor_data_129_159[31];
+ UINT16 cfa_power_mode;
+ UINT16 cfa_reserved_161_175[15];
+ UINT16 current_media_serial_no[30];
+ UINT16 reserved_206_254[49];
+ UINT16 integrity_word;
+} EFI_ATAPI_IDENTIFY_DATA;
+
+#pragma pack()
+//
+//*******************************************************
+// EFI_IDENTIFY_DATA
+//*******************************************************
+//
+typedef union {
+ EFI_ATA_IDENTIFY_DATA AtaData;
+ EFI_ATAPI_IDENTIFY_DATA AtapiData;
+} EFI_IDENTIFY_DATA;
+
+#define EFI_ATAPI_DEVICE_IDENTIFY_DATA 0x8000
+
+//
+/////////////////////////////////////////////////////////////////////////////////////////
+// Function prototype declaration, for ANSI compatability
+//
+typedef
+EFI_STATUS
+(EFIAPI *EFI_IDE_CONTROLLER_GET_CHANNEL_INFO) (
+ IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,
+ IN UINT8 Channel,
+ OUT BOOLEAN *Enabled,
+ OUT UINT8 *MaxDevices
+
+);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_IDE_CONTROLLER_NOTIFY_PHASE) (
+ IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,
+ IN EFI_IDE_CONTROLLER_ENUM_PHASE Phase,
+ IN UINT8 Channel
+);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_IDE_CONTROLLER_SUBMIT_DATA) (
+ IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,
+ IN UINT8 Channel,
+ IN UINT8 Device,
+ IN EFI_IDENTIFY_DATA *IdentifyData
+);
+
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_IDE_CONTROLLER_DISQUALIFY_MODE) (
+ IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,
+ IN UINT8 Channel,
+ IN UINT8 Device,
+ IN EFI_ATA_COLLECTIVE_MODE *BadModes
+);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_IDE_CONTROLLER_CALCULATE_MODE) (
+ IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,
+ IN UINT8 Channel,
+ IN UINT8 Device,
+ OUT EFI_ATA_COLLECTIVE_MODE **SupportedModes
+);
+
+//
+// ?? What happen to EFI_IDE_CONTROLLER_SET_TIMING ???
+//
+typedef
+EFI_STATUS
+(EFIAPI *EFI_IDE_CONTROLLER_SET_TIMING) (
+ IN EFI_IDE_CONTROLLER_INIT_PROTOCOL *This,
+ IN UINT8 Channel,
+ IN UINT8 Device,
+ IN EFI_ATA_COLLECTIVE_MODE *Modes
+);
+
+//
+////////////////////////////////////////////////////////////////////////////////////////////////////
+// Interface structure
+// EFI_IDE_CONTROLLER_INIT_PROTOCOL protocol provides the chipset specific information to the IDE bus driver.
+// An IDE Bus driver wants to manage an IDE bus and possible IDE devices will have to retrieve the
+// EFI_IDE_CONTROLLER_INIT_PROTOCOL instances.
+//
+typedef struct _EFI_IDE_CONTROLLER_INIT_PROTOCOL {
+ EFI_IDE_CONTROLLER_GET_CHANNEL_INFO GetChannelInfo;
+ EFI_IDE_CONTROLLER_NOTIFY_PHASE NotifyPhase;
+ EFI_IDE_CONTROLLER_SUBMIT_DATA SubmitData;
+ EFI_IDE_CONTROLLER_DISQUALIFY_MODE DisqualifyMode;
+ EFI_IDE_CONTROLLER_CALCULATE_MODE CalculateMode;
+ EFI_IDE_CONTROLLER_SET_TIMING SetTiming;
+ BOOLEAN EnumAll;
+ UINT8 ChannelCount;
+} EFI_IDE_CONTROLLER_INIT_PROTOCOL;
+
+
+extern EFI_GUID gEfiIdeControllerInitProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Protocol/IncompatiblePciDeviceSupport/IncompatiblePciDeviceSupport.c b/EDK/Foundation/Framework/Protocol/IncompatiblePciDeviceSupport/IncompatiblePciDeviceSupport.c
new file mode 100644
index 0000000..020331b
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/IncompatiblePciDeviceSupport/IncompatiblePciDeviceSupport.c
@@ -0,0 +1,34 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ IncompatiblePciDeviceSupport.c
+
+Abstract:
+
+ EFI Incompatible PCI Device Support Protocol
+
+Revision History
+
+--*/
+
+#include "Tiano.h"
+
+#include EFI_PROTOCOL_DEFINITION (IncompatiblePciDeviceSupport)
+
+EFI_GUID gEfiIncompatiblePciDeviceSupportProtocolGuid = EFI_INCOMPATIBLE_PCI_DEVICE_SUPPORT_PROTOCOL_GUID;
+
+EFI_GUID_STRING
+ (
+ &gEfiIncompatiblePciDeviceSupportProtocolGuid, "Incompatible PCI Device Support Protocol",
+ "Tiano Incompatible PCI Device Support Protocol"
+ );
diff --git a/EDK/Foundation/Framework/Protocol/IncompatiblePciDeviceSupport/IncompatiblePciDeviceSupport.h b/EDK/Foundation/Framework/Protocol/IncompatiblePciDeviceSupport/IncompatiblePciDeviceSupport.h
new file mode 100644
index 0000000..c8b946d
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/IncompatiblePciDeviceSupport/IncompatiblePciDeviceSupport.h
@@ -0,0 +1,55 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ IncompatiblePciDeviceSupport.h
+
+Abstract:
+
+ EFI Incompatible PCI Device Support Protocol
+
+Revision History
+
+--*/
+
+#ifndef _INCOMPATIBLE_PCI_DEVICE_SUPPORT_H_
+#define _INCOMPATIBLE_PCI_DEVICE_SUPPORT_H_
+
+#define EFI_INCOMPATIBLE_PCI_DEVICE_SUPPORT_PROTOCOL_GUID \
+ {0xeb23f55a, 0x7863, 0x4ac2, 0x8d, 0x3d, 0x95, 0x65, 0x35, 0xde, 0x03, 0x75}
+
+EFI_FORWARD_DECLARATION (EFI_INCOMPATIBLE_PCI_DEVICE_SUPPORT);
+
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_INCOMPATIBLE_PCI_DEVICE_SUPPORT_CHECK_DEVICE) (
+ IN EFI_INCOMPATIBLE_PCI_DEVICE_SUPPORT *This,
+ IN UINTN VendorId,
+ IN UINTN DeviceId,
+ IN UINTN Revision,
+ IN UINTN SubVendorId,OPTIONAL
+ IN UINTN SubDeviceId,OPTIONAL
+ OUT VOID *Configuration
+);
+
+
+//
+// Interface structure for the Incompatible PCI Device Support Protocol
+//
+typedef struct _EFI_INCOMPATIBLE_PCI_DEVICE_SUPPORT {
+ EFI_INCOMPATIBLE_PCI_DEVICE_SUPPORT_CHECK_DEVICE CheckDevice;
+} EFI_INCOMPATIBLE_PCI_DEVICE_SUPPORT_PROTOCOL;
+
+extern EFI_GUID gEfiIncompatiblePciDeviceSupportProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Protocol/Legacy8259/Legacy8259.c b/EDK/Foundation/Framework/Protocol/Legacy8259/Legacy8259.c
new file mode 100644
index 0000000..f52c030
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/Legacy8259/Legacy8259.c
@@ -0,0 +1,31 @@
+/*++
+
+Copyright (c) 1999 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ Legacy8259.c
+
+Abstract:
+
+ EFI Legacy Region Protocol
+
+Revision History
+
+--*/
+
+#include "Tiano.h"
+
+#include EFI_PROTOCOL_DEFINITION (Legacy8259)
+
+EFI_GUID gEfiLegacy8259ProtocolGuid = EFI_LEGACY_8259_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiLegacy8259ProtocolGuid, "Legacy 8259 Protocol", "Legacy 8259 Protocol");
diff --git a/EDK/Foundation/Framework/Protocol/Legacy8259/Legacy8259.h b/EDK/Foundation/Framework/Protocol/Legacy8259/Legacy8259.h
new file mode 100644
index 0000000..2819a5e
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/Legacy8259/Legacy8259.h
@@ -0,0 +1,317 @@
+/*++
+
+Copyright (c) 1999 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ Legacy8259.h
+
+Abstract:
+
+ This protocol abstracts the 8259 interrupt controller. This includes
+ PCI IRQ routing need to program the PCI Interrupt Line register.
+
+Revision History
+
+ The EFI Legacy 8259 Protocol is compliant with CSM spec 0.96.
+
+--*/
+
+#ifndef _EFI_LEGACY_8259_H
+#define _EFI_LEGACY_8259_H
+
+#define EFI_LEGACY_8259_PROTOCOL_GUID \
+ { \
+ 0x38321dba, 0x4fe0, 0x4e17, 0x8a, 0xec, 0x41, 0x30, 0x55, 0xea, 0xed, 0xc1 \
+ }
+
+EFI_FORWARD_DECLARATION (EFI_LEGACY_8259_PROTOCOL);
+
+typedef enum {
+ Efi8259Irq0,
+ Efi8259Irq1,
+ Efi8259Irq2,
+ Efi8259Irq3,
+ Efi8259Irq4,
+ Efi8259Irq5,
+ Efi8259Irq6,
+ Efi8259Irq7,
+ Efi8259Irq8,
+ Efi8259Irq9,
+ Efi8259Irq10,
+ Efi8259Irq11,
+ Efi8259Irq12,
+ Efi8259Irq13,
+ Efi8259Irq14,
+ Efi8259Irq15,
+ Efi8259IrqMax
+} EFI_8259_IRQ;
+
+typedef enum {
+ Efi8259LegacyMode,
+ Efi8259ProtectedMode,
+ Efi8259MaxMode
+} EFI_8259_MODE;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_LEGACY_8259_SET_VECTOR_BASE) (
+ IN EFI_LEGACY_8259_PROTOCOL * This,
+ IN UINT8 MasterBase,
+ IN UINT8 SlaveBase
+ )
+/*++
+
+ Routine Description:
+ Get the 8259 interrupt masks for Irq0 - Irq15. A different mask exists for
+ the legacy mode mask and the protected mode mask. The base address for the 8259
+ is different for legacy and protected mode, so two masks are required.
+
+ Arguments:
+ This - Protocol instance pointer.
+ MasterBase - The base vector for the Master PIC in the 8259 controller
+ Slavebase - The base vector for the Master PIC in the 8259 controller
+
+ Returns:
+ EFI_SUCCESS - The new bases were programmed
+ EFI_DEVICE_ERROR - A device erro occured programming the vector bases
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_LEGACY_8259_GET_MASK) (
+ IN EFI_LEGACY_8259_PROTOCOL * This,
+ OUT UINT16 *LegacyMask, OPTIONAL
+ OUT UINT16 *LegacyEdgeLevel, OPTIONAL
+ OUT UINT16 *ProtectedMask, OPTIONAL
+ OUT UINT16 *ProtectedEdgeLevel OPTIONAL
+ )
+/*++
+
+ Routine Description:
+ Get the 8259 interrupt masks for Irq0 - Irq15. A different mask exists for
+ the legacy mode mask and the protected mode mask. The base address for the 8259
+ is different for legacy and protected mode, so two masks are required.
+
+ Arguments:
+ This - Protocol instance pointer.
+ LegacyMask - Bit 0 is Irq0 - Bit 15 is Irq15
+ LegacyEdgeLevel - Bit 0 is Irq0 - Bit 15 is Irq15
+ ProtectedMask - Bit 0 is Irq0 - Bit 15 is Irq15
+ ProtectedEdgeLevel - Bit 0 is Irq0 - Bit 15 is Irq15
+
+ Returns:
+ EFI_SUCCESS - 8259 status returned
+ EFI_DEVICE_ERROR - Error reading 8259
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_LEGACY_8259_SET_MASK) (
+ IN EFI_LEGACY_8259_PROTOCOL * This,
+ IN UINT16 *LegacyMask, OPTIONAL
+ IN UINT16 *LegacyEdgeLevel, OPTIONAL
+ IN UINT16 *ProtectedMask, OPTIONAL
+ IN UINT16 *ProtectedEdgeLevel OPTIONAL
+ )
+/*++
+
+ Routine Description:
+ Set the 8259 interrupt masks for Irq0 - Irq15. A different mask exists for
+ the legacy mode mask and the protected mode mask. The base address for the 8259
+ is different for legacy and protected mode, so two masks are required.
+ Also set the edge/level masks.
+
+ Arguments:
+ This - Protocol instance pointer.
+ LegacyMask - Bit 0 is Irq0 - Bit 15 is Irq15
+ LegacyEdgeLevel - Bit 0 is Irq0 - Bit 15 is Irq15
+ ProtectedMask - Bit 0 is Irq0 - Bit 15 is Irq15
+ ProtectedEdgeLevel - Bit 0 is Irq0 - Bit 15 is Irq15
+
+ Returns:
+ EFI_SUCCESS - 8259 status returned
+ EFI_DEVICE_ERROR - Error reading 8259
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_LEGACY_8259_SET_MODE) (
+ IN EFI_LEGACY_8259_PROTOCOL * This,
+ IN EFI_8259_MODE Mode,
+ IN UINT16 *Mask, OPTIONAL
+ IN UINT16 *EdgeLevel OPTIONAL
+ )
+/*++
+
+ Routine Description:
+ Set the 8259 mode of operation. The base address for the 8259 is different for
+ legacy and protected mode. The legacy mode requires the master 8259 to have a
+ master base of 0x08 and the slave base of 0x70. The protected mode base locations
+ are not defined. Interrupts must be masked by the caller before this function
+ is called. The interrupt mask from the current mode is saved. The interrupt
+ mask for the new mode is Mask, or if Mask does not exist the previously saved
+ mask is used.
+
+
+ Arguments:
+ This - Protocol instance pointer.
+ Mode - Mode of operation. i.e. real mode or protected mode
+ Mask - Optional interupt mask for the new mode.
+ EdgeLevel - Optional trigger mask for the new mode.
+
+ Returns:
+ EFI_SUCCESS - 8259 programmed
+ EFI_DEVICE_ERROR - Error writting to 8259
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_LEGACY_8259_GET_VECTOR) (
+ IN EFI_LEGACY_8259_PROTOCOL * This,
+ IN EFI_8259_IRQ Irq,
+ OUT UINT8 *Vector
+ )
+/*++
+
+ Routine Description:
+ Convert from IRQ to processor interrupt vector number.
+
+ Arguments:
+ This - Protocol instance pointer.
+ Irq - 8259 IRQ0 - IRQ15
+ Vector - Processor vector number that matches Irq
+
+ Returns:
+ EFI_SUCCESS - The Vector matching Irq is returned
+ EFI_INVALID_PARAMETER - Irq not valid
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_LEGACY_8259_ENABLE_IRQ) (
+ IN EFI_LEGACY_8259_PROTOCOL * This,
+ IN EFI_8259_IRQ Irq,
+ IN BOOLEAN LevelTriggered
+ )
+/*++
+
+ Routine Description:
+ Enable Irq by unmasking interrupt in 8259
+
+ Arguments:
+ This - Protocol instance pointer.
+ Irq - 8259 IRQ0 - IRQ15
+ LevelTriggered - TRUE if level triggered. FALSE if edge triggered.
+
+ Returns:
+ EFI_SUCCESS - Irq enabled on 8259
+ EFI_INVALID_PARAMETER - Irq not valid
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_LEGACY_8259_DISABLE_IRQ) (
+ IN EFI_LEGACY_8259_PROTOCOL * This,
+ IN EFI_8259_IRQ Irq
+ )
+/*++
+
+ Routine Description:
+ Disable Irq by masking interrupt in 8259
+
+ Arguments:
+ This - Protocol instance pointer.
+ Irq - 8259 IRQ0 - IRQ15
+
+ Returns:
+ EFI_SUCCESS - Irq disabled on 8259
+ EFI_INVALID_PARAMETER - Irq not valid
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_LEGACY_8259_GET_INTERRUPT_LINE) (
+ IN EFI_LEGACY_8259_PROTOCOL * This,
+ IN EFI_HANDLE PciHandle,
+ OUT UINT8 *Vector
+ )
+/*++
+
+ Routine Description:
+ PciHandle represents a PCI config space of a PCI function. Vector
+ represents Interrupt Pin (from PCI config space) and it is the data
+ that is programmed into the Interrupt Line (from the PCI config space)
+ register.
+
+ Arguments:
+ This - Protocol instance pointer.
+ PciHandle - PCI function to return vector for
+ Vector - Vector for fucntion that matches
+
+ Returns:
+ EFI_SUCCESS - A valid Vector is returned
+ EFI_INVALID_PARAMETER - PciHandle not valid
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_LEGACY_8259_END_OF_INTERRUPT) (
+ IN EFI_LEGACY_8259_PROTOCOL * This,
+ IN EFI_8259_IRQ Irq
+ )
+/*++
+
+ Routine Description:
+ Send an EOI to 8259
+
+ Arguments:
+ This - Protocol instance pointer.
+ Irq - 8259 IRQ0 - IRQ15
+
+ Returns:
+ EFI_SUCCESS - EOI successfully sent to 8259
+ EFI_INVALID_PARAMETER - Irq not valid
+
+--*/
+;
+
+typedef struct _EFI_LEGACY_8259_PROTOCOL {
+ EFI_LEGACY_8259_SET_VECTOR_BASE SetVectorBase;
+ EFI_LEGACY_8259_GET_MASK GetMask;
+ EFI_LEGACY_8259_SET_MASK SetMask;
+ EFI_LEGACY_8259_SET_MODE SetMode;
+ EFI_LEGACY_8259_GET_VECTOR GetVector;
+ EFI_LEGACY_8259_ENABLE_IRQ EnableIrq;
+ EFI_LEGACY_8259_DISABLE_IRQ DisableIrq;
+ EFI_LEGACY_8259_GET_INTERRUPT_LINE GetInterruptLine;
+ EFI_LEGACY_8259_END_OF_INTERRUPT EndOfInterrupt;
+} EFI_LEGACY_8259_PROTOCOL;
+
+extern EFI_GUID gEfiLegacy8259ProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Protocol/LegacyBios/LegacyBios.c b/EDK/Foundation/Framework/Protocol/LegacyBios/LegacyBios.c
new file mode 100644
index 0000000..bfeaf00
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/LegacyBios/LegacyBios.c
@@ -0,0 +1,30 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ LegacyBios.c
+
+Abstract:
+
+ EFI Legacy BIOS Protocol
+
+Revision History
+
+--*/
+
+#include "Tiano.h"
+
+#include EFI_PROTOCOL_DEFINITION (LegacyBios)
+
+EFI_GUID gEfiLegacyBiosProtocolGuid = EFI_LEGACY_BIOS_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiLegacyBiosProtocolGuid, "Legacy BIOS Protocol", "Legacy BIOS Protocol");
diff --git a/EDK/Foundation/Framework/Protocol/LegacyBios/LegacyBios.h b/EDK/Foundation/Framework/Protocol/LegacyBios/LegacyBios.h
new file mode 100644
index 0000000..d145be8
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/LegacyBios/LegacyBios.h
@@ -0,0 +1,714 @@
+/*++
+
+Copyright (c) 2004 - 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ LegacyBios.h
+
+Abstract:
+
+ The EFI Legacy BIOS Protocol is used to abstract legacy Option ROM usage
+ under EFI and Legacy OS boot.
+
+ Note: The names for EFI_IA32_REGISTER_SET elements were picked to follow
+ well known naming conventions.
+
+ Thunk - A thunk is a transition from one processor mode to another. A Thunk
+ is a transition from native EFI mode to 16-bit mode. A reverse thunk
+ would be a transition from 16-bit mode to native EFI mode.
+
+
+ Note: Note: Note: Note: Note: Note: Note:
+
+ You most likely should not use this protocol! Find the EFI way to solve the
+ problem to make your code portable
+
+ Note: Note: Note: Note: Note: Note: Note:
+
+Revision History
+
+ The EFI Legacy BIOS Protocol is compliant with CSM spec 0.96.
+
+--*/
+
+#ifndef _EFI_LEGACY_BIOS_H
+#define _EFI_LEGACY_BIOS_H
+
+#define EFI_LEGACY_BIOS_PROTOCOL_GUID \
+ { \
+ 0xdb9a1e3d, 0x45cb, 0x4abb, 0x85, 0x3b, 0xe5, 0x38, 0x7f, 0xdb, 0x2e, 0x2d \
+ }
+
+EFI_FORWARD_DECLARATION (EFI_LEGACY_BIOS_PROTOCOL);
+
+//
+// Convert from 32-bit address (_Adr) to Segment:Offset 16-bit form
+//
+#define EFI_SEGMENT(_Adr) (UINT16) ((UINT16) (((UINTN) (_Adr)) >> 4) & 0xf000)
+#define EFI_OFFSET(_Adr) (UINT16) (((UINT16) ((UINTN) (_Adr))) & 0xffff)
+#define BYTE_GRANULARITY 0x01
+#define WORD_GRANULARITY 0x02
+#define DWORD_GRANULARITY 0x04
+#define QWORD_GRANULARITY 0x08
+#define PARAGRAPH_GRANULARITY 0x10
+
+#define CARRY_FLAG 0x01
+
+typedef struct {
+ UINT32 CF:1;
+ UINT32 Reserved1:1;
+ UINT32 PF:1;
+ UINT32 Reserved2:1;
+ UINT32 AF:1;
+ UINT32 Reserved3:1;
+ UINT32 ZF:1;
+ UINT32 SF:1;
+ UINT32 TF:1;
+ UINT32 IF:1;
+ UINT32 DF:1;
+ UINT32 OF:1;
+ UINT32 IOPL:2;
+ UINT32 NT:1;
+ UINT32 Reserved4:2;
+ UINT32 VM:1;
+ UINT32 Reserved5:14;
+} EFI_EFLAGS_REG;
+
+typedef struct {
+ UINT16 CF : 1;
+ UINT16 Reserved1 : 1;
+ UINT16 PF : 1;
+ UINT16 Reserved2 : 1;
+ UINT16 AF : 1;
+ UINT16 Reserved3 : 1;
+ UINT16 ZF : 1;
+ UINT16 SF : 1;
+ UINT16 TF : 1;
+ UINT16 IF : 1;
+ UINT16 DF : 1;
+ UINT16 OF : 1;
+ UINT16 IOPL : 2;
+ UINT16 NT : 1;
+ UINT16 Reserved4 : 1;
+} EFI_FLAGS_REG;
+
+typedef struct {
+ UINT32 EAX;
+ UINT32 EBX;
+ UINT32 ECX;
+ UINT32 EDX;
+ UINT32 ESI;
+ UINT32 EDI;
+ EFI_EFLAGS_REG EFlags;
+ UINT16 ES;
+ UINT16 CS;
+ UINT16 SS;
+ UINT16 DS;
+ UINT16 FS;
+ UINT16 GS;
+ UINT32 EBP;
+ UINT32 ESP;
+} EFI_DWORD_REGS;
+
+typedef struct {
+ UINT16 AX;
+ UINT16 ReservedAX;
+ UINT16 BX;
+ UINT16 ReservedBX;
+ UINT16 CX;
+ UINT16 ReservedCX;
+ UINT16 DX;
+ UINT16 ReservedDX;
+ UINT16 SI;
+ UINT16 ReservedSI;
+ UINT16 DI;
+ UINT16 ReservedDI;
+ EFI_FLAGS_REG Flags;
+ UINT16 ReservedFlags;
+ UINT16 ES;
+ UINT16 CS;
+ UINT16 SS;
+ UINT16 DS;
+ UINT16 FS;
+ UINT16 GS;
+ UINT16 BP;
+ UINT16 ReservedBP;
+ UINT16 SP;
+ UINT16 ReservedSP;
+} EFI_WORD_REGS;
+
+typedef struct {
+ UINT8 AL;
+ UINT8 AH;
+ UINT16 ReservedAX;
+ UINT8 BL;
+ UINT8 BH;
+ UINT16 ReservedBX;
+ UINT8 CL;
+ UINT8 CH;
+ UINT16 ReservedCX;
+ UINT8 DL;
+ UINT8 DH;
+ UINT16 ReservedDX;
+} EFI_BYTE_REGS;
+
+typedef union {
+ EFI_DWORD_REGS E;
+ EFI_WORD_REGS X;
+ EFI_BYTE_REGS H;
+} EFI_IA32_REGISTER_SET;
+
+#pragma pack(1)
+//
+// $EFI table created by Legacy16 code and consumed by EFI Legacy driver
+//
+typedef struct {
+ UINT32 Signature; // "$EFI"
+ UINT8 TableChecksum;
+ UINT8 TableLength;
+ UINT8 EfiMajorRevision;
+ UINT8 EfiMinorRevision;
+ UINT8 TableMajorRevision;
+ UINT8 TableMinorRevision;
+ UINT16 Reserved;
+ UINT16 Compatibility16CallSegment;
+ UINT16 Compatibility16CallOffset;
+
+ UINT16 PnPInstallationCheckSegment;
+ UINT16 PnPInstallationCheckOffset;
+
+ UINT32 EfiSystemTable; // IPF - CSM Integration
+ UINT32 OemIdStringPointer;
+ UINT32 AcpiRsdPtrPointer;
+ UINT16 OemRevision;
+ UINT32 E820Pointer;
+ UINT32 E820Length;
+ UINT32 IrqRoutingTablePointer;
+ UINT32 IrqRoutingTableLength;
+ UINT32 MpTablePtr;
+ UINT32 MpTableLength;
+ UINT16 OemIntSegment;
+ UINT16 OemIntOffset;
+ UINT16 Oem32Segment;
+ UINT16 Oem32Offset;
+ UINT16 Oem16Segment;
+ UINT16 Oem16Offset;
+ UINT16 TpmSegment;
+ UINT16 TpmOffset;
+ UINT32 IbvPointer;
+ UINT32 PciExpressBase;
+ UINT8 LastPciBus;
+
+} EFI_COMPATIBILITY16_TABLE;
+
+typedef enum {
+ Compatibility16InitializeYourself = 0x0000,
+ Compatibility16UpdateBbs = 0x0001,
+ Compatibility16PrepareToBoot = 0x0002,
+ Compatibility16Boot = 0x0003,
+ Compatibility16RetrieveLastBootDevice = 0x0004,
+ Compatibility16DispatchOprom = 0x0005,
+ Compatibility16GetTableAddress = 0x0006,
+ Compatibility16SetKeyboardLeds = 0x0007,
+ Compatibility16InstallPciHandler = 0x0008,
+} EFI_COMPATIBILITY_FUNCTIONS;
+
+//
+// define maximum number of HDD system supports
+//
+#define MAX_HDD_ENTRIES 0x30
+
+typedef struct {
+ UINT16 Raw[256];
+} ATAPI_IDENTIFY;
+
+//
+// HDD_INFO status
+//
+#define HDD_PRIMARY 0x01
+#define HDD_SECONDARY 0x02
+#define HDD_MASTER_ATAPI_CDROM 0x04
+#define HDD_SLAVE_ATAPI_CDROM 0x08
+#define HDD_MASTER_IDE 0x20
+#define HDD_SLAVE_IDE 0x40
+#define HDD_MASTER_ATAPI_ZIPDISK 0x10
+#define HDD_SLAVE_ATAPI_ZIPDISK 0x80
+
+typedef struct {
+ UINT16 Status;
+ UINT32 Bus;
+ UINT32 Device;
+ UINT32 Function;
+ UINT16 CommandBaseAddress;
+ UINT16 ControlBaseAddress;
+ UINT16 BusMasterAddress;
+ UINT8 HddIrq;
+ ATAPI_IDENTIFY IdentifyDrive[2];
+} HDD_INFO;
+
+//
+// Parties data structures
+//
+typedef struct {
+ UINT8 DirectoryServiceValidity : 1;
+ UINT8 RabcaUsedFlag : 1;
+ UINT8 ExecuteHddDiagnosticsFlag : 1;
+ UINT8 Reserved : 5;
+} UDC_ATTRIBUTES;
+
+typedef struct {
+ UDC_ATTRIBUTES Attributes;
+ UINT8 DeviceNumber;
+ UINT8 BbsTableEntryNumberForParentDevice;
+ UINT8 BbsTableEntryNumberForBoot;
+ UINT8 BbsTableEntryNumberForHddDiag;
+ UINT8 BeerData[128];
+ UINT8 ServiceAreaData[64];
+} UD_TABLE;
+
+//
+// define BBS Device Types
+//
+#define BBS_FLOPPY 0x01
+#define BBS_HARDDISK 0x02
+#define BBS_CDROM 0x03
+#define BBS_PCMCIA 0x04
+#define BBS_USB 0x05
+#define BBS_EMBED_NETWORK 0x06
+#define BBS_BEV_DEVICE 0x80
+#define BBS_UNKNOWN 0xff
+
+typedef struct {
+ UINT16 OldPosition : 4;
+ UINT16 Reserved1 : 4;
+ UINT16 Enabled : 1;
+ UINT16 Failed : 1;
+ UINT16 MediaPresent : 2;
+ UINT16 Reserved2 : 4;
+} BBS_STATUS_FLAGS;
+
+#define MAX_BBS_ENTRIES 0x100
+//
+// BBS_IGNORE_ENTRY is placed in the BootPriority field if the entry is to
+// be skipped.
+// BBS_UNPRIORITIZED_ENTRY is placed in the BootPriority field before
+// priority has been assigned but indicates valid entry.
+// BBS_LOWEST_PRIORITY is normally used for removable media with no media
+// inserted. This allows the 16-bit CSM to allocate a drive letter to
+// the device.
+// BBS_DO_NOT_BOOT_FROM is used for devices that the 16-bit CSM is to assign
+// a drive letter to but never boot from.
+//
+// AdditionalIrq??Handler usage is IBV specific. The fields have been added
+// for:
+// 1. Saving non-BBS card info about IRQs taken by card.
+// 2. For BBS compliant cards that hook IRQs in order to have their SETUP
+// executed.
+//
+#define BBS_DO_NOT_BOOT_FROM 0xFFFC
+#define BBS_LOWEST_PRIORITY 0xFFFD
+#define BBS_UNPRIORITIZED_ENTRY 0xFFFE
+#define BBS_IGNORE_ENTRY 0xFFFF
+
+typedef struct {
+ UINT16 BootPriority;
+ UINT32 Bus;
+ UINT32 Device;
+ UINT32 Function;
+ UINT8 Class;
+ UINT8 SubClass;
+ UINT16 MfgStringOffset;
+ UINT16 MfgStringSegment;
+ UINT16 DeviceType;
+ BBS_STATUS_FLAGS StatusFlags;
+ UINT16 BootHandlerOffset;
+ UINT16 BootHandlerSegment;
+ UINT16 DescStringOffset;
+ UINT16 DescStringSegment;
+ UINT32 InitPerReserved;
+ UINT32 AdditionalIrq13Handler;
+ UINT32 AdditionalIrq18Handler;
+ UINT32 AdditionalIrq19Handler;
+ UINT32 AdditionalIrq40Handler;
+ UINT8 AssignedDriveNumber;
+ UINT32 AdditionalIrq41Handler;
+ UINT32 AdditionalIrq46Handler;
+ UINT32 IBV1;
+ UINT32 IBV2;
+} BBS_TABLE;
+
+#pragma pack()
+
+typedef
+BOOLEAN
+(EFIAPI *EFI_LEGACY_BIOS_INT86) (
+ IN EFI_LEGACY_BIOS_PROTOCOL * This,
+ IN UINT8 BiosInt,
+ IN OUT EFI_IA32_REGISTER_SET * Regs
+ )
+/*++
+
+ Routine Description:
+ Thunk to 16-bit real mode and execute a software interrupt with a vector
+ of BiosInt. Regs will contain the 16-bit register context on entry and
+ exit.
+
+ Arguments:
+ This - Protocol instance pointer.
+ BiosInt - Processor interrupt vector to invoke
+ Reg - Register contexted passed into (and returned) from thunk to
+ 16-bit mode
+
+ Returns:
+ FALSE - Thunk completed, and there were no BIOS errors in the target code.
+ See Regs for status.
+ TRUE - There was a BIOS erro in the target code.
+
+--*/
+;
+
+typedef
+BOOLEAN
+(EFIAPI *EFI_LEGACY_BIOS_FARCALL86) (
+ IN EFI_LEGACY_BIOS_PROTOCOL * This,
+ IN UINT16 Segment,
+ IN UINT16 Offset,
+ IN EFI_IA32_REGISTER_SET * Regs,
+ IN VOID *Stack,
+ IN UINTN StackSize
+ )
+/*++
+
+ Routine Description:
+ Thunk to 16-bit real mode and call Segment:Offset. Regs will contain the
+ 16-bit register context on entry and exit. Arguments can be passed on
+ the Stack argument
+
+ Arguments:
+ This - Protocol instance pointer.
+ Segment - Segemnt of 16-bit mode call
+ Offset - Offset of 16-bit mdoe call
+ Reg - Register contexted passed into (and returned) from thunk to
+ 16-bit mode
+ Stack - Caller allocated stack used to pass arguments
+ StackSize - Size of Stack in bytes
+
+ Returns:
+ FALSE - Thunk completed, and there were no BIOS errors in the target code.
+ See Regs for status.
+ TRUE - There was a BIOS erro in the target code.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_LEGACY_BIOS_CHECK_ROM) (
+ IN EFI_LEGACY_BIOS_PROTOCOL * This,
+ IN EFI_HANDLE PciHandle,
+ OUT VOID **RomImage, OPTIONAL
+ OUT UINTN *RomSize, OPTIONAL
+ OUT UINTN *Flags
+
+ )
+/*++
+
+ Routine Description:
+ Test to see if a legacy PCI ROM exists for this device. Optionally return
+ the Legacy ROM instance for this PCI device.
+
+ Arguments:
+ This - Protocol instance pointer.
+ PciHandle - The PCI PC-AT OPROM from this devices ROM BAR will be loaded
+ RomImage - Return the legacy PCI ROM for this device
+ RomSize - Size of ROM Image
+ Flags - Indicates if ROM found and if PC-AT.
+
+ Returns:
+ EFI_SUCCESS - Legacy Option ROM availible for this device
+ EFI_UNSUPPORTED - Legacy Option ROM not supported.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_LEGACY_BIOS_INSTALL_ROM) (
+ IN EFI_LEGACY_BIOS_PROTOCOL * This,
+ IN EFI_HANDLE PciHandle,
+ IN VOID **RomImage,
+ OUT UINTN *Flags,
+ OUT UINT8 *DiskStart, OPTIONAL
+ OUT UINT8 *DiskEnd, OPTIONAL
+ OUT VOID **RomShadowAddress, OPTIONAL
+ OUT UINT32 *ShadowedRomSize OPTIONAL
+ )
+/*++
+
+ Routine Description:
+ Load a legacy PC-AT OPROM on the PciHandle device. Return information
+ about how many disks were added by the OPROM and the shadow address and
+ size. DiskStart & DiskEnd are INT 13h drive letters. Thus 0x80 is C:
+
+ Arguments:
+ This - Protocol instance pointer.
+ PciHandle - The PCI PC-AT OPROM from this devices ROM BAR will be loaded.
+ This value is NULL if RomImage is non-NULL. This is the normal
+ case.
+ RomImage - A PCI PC-AT ROM image. This argument is non-NULL if there is
+ no hardware associated with the ROM and thus no PciHandle,
+ otherwise is must be NULL.
+ Example is PXE base code.
+ Flags - Return Status if ROM was found and if was Legacy OPROM.
+ DiskStart - Disk number of first device hooked by the ROM. If DiskStart
+ is the same as DiskEnd no disked were hooked.
+ DiskEnd - Disk number of the last device hooked by the ROM.
+ RomShadowAddress - Shadow address of PC-AT ROM
+ RomShadowSize - Size of RomShadowAddress in bytes
+
+ Returns:
+ EFI_SUCCESS - Thunk completed, see Regs for status.
+ EFI_INVALID_PARAMETER - PciHandle not found
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_LEGACY_BIOS_BOOT) (
+ IN EFI_LEGACY_BIOS_PROTOCOL * This,
+ IN BBS_BBS_DEVICE_PATH * BootOption,
+ IN UINT32 LoadOptionsSize,
+ IN VOID *LoadOptions
+ )
+/*++
+
+ Routine Description:
+ Attempt to legacy boot the BootOption. If the EFI contexted has been
+ compromised this function will not return.
+
+ Arguments:
+ This - Protocol instance pointer.
+ BootOption - EFI Device Path from BootXXXX variable.
+ LoadOptionSize - Size of LoadOption in size.
+ LoadOption - LoadOption from BootXXXX variable
+
+ Returns:
+ EFI_SUCCESS - Removable media not present
+
+--*/
+;
+typedef
+EFI_STATUS
+(EFIAPI *EFI_LEGACY_BIOS_UPDATE_KEYBOARD_LED_STATUS) (
+ IN EFI_LEGACY_BIOS_PROTOCOL * This,
+ IN UINT8 Leds
+ )
+/*++
+
+ Routine Description:
+ Update BDA with current Scroll, Num & Cap lock LEDS
+
+ Arguments:
+ This - Protocol instance pointer.
+ Leds - Status of current Scroll, Num & Cap lock LEDS
+ Bit 0 is Scroll Lock 0 = Not locked
+ Bit 1 is Num Lock
+ Bit 2 is Caps Lock
+
+ Returns:
+ EFI_SUCCESS - Removable media not present
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_LEGACY_BIOS_GET_BBS_INFO) (
+ IN EFI_LEGACY_BIOS_PROTOCOL * This,
+ OUT UINT16 *HddCount,
+ OUT HDD_INFO **HddInfo,
+ OUT UINT16 *BbsCount,
+ IN OUT BBS_TABLE **BbsTable
+ )
+/*++
+
+ Routine Description:
+ Retrieve legacy BBS info and assign boot priority.
+
+ Arguments:
+ This - Protocol instance pointer.
+ HddCount - Number of HDD_INFO structures
+ HddInfo - Onboard IDE controller information
+ BbsCount - Number of BBS_TABLE structures
+ BbsTable - List BBS entries
+
+ Returns:
+ EFI_SUCCESS - Tables returned
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_LEGACY_BIOS_PREPARE_TO_BOOT_EFI) (
+ IN EFI_LEGACY_BIOS_PROTOCOL * This,
+ OUT UINT16 *BbsCount,
+ OUT BBS_TABLE **BbsTable
+ )
+/*++
+
+ Routine Description:
+ Assign drive number to legacy HDD drives prior to booting an EFI
+ aware OS so the OS can access drives without an EFI driver.
+
+ Arguments:
+ This - Protocol instance pointer.
+ BbsCount - Number of BBS_TABLE structures
+ BbsTable - List BBS entries
+
+ Returns:
+ EFI_SUCCESS - Drive numbers assigned
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_LEGACY_BIOS_BOOT_UNCONVENTIONAL_DEVICE) (
+ IN EFI_LEGACY_BIOS_PROTOCOL * This,
+ IN UDC_ATTRIBUTES Attributes,
+ IN UINTN BbsEntry,
+ IN VOID *BeerData,
+ IN VOID *ServiceAreaData
+ )
+/*++
+
+ Routine Description:
+ To boot from an unconventional device like parties and/or execute
+ HDD diagnostics.
+
+ Arguments:
+ This - Protocol instance pointer.
+ Attributes - How to interpret the other input parameters
+ BbsEntry - The 0-based index into the BbsTable for the parent
+ device.
+ BeerData - Pointer to the 128 bytes of ram BEER data.
+ ServiceAreaData - Pointer to the 64 bytes of raw Service Area data. The
+ caller must provide a pointer to the specific Service
+ Area and not the start all Service Areas.
+ Returns:
+ EFI_INVALID_PARAMETER if error. Does NOT return if no error.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_LEGACY_BIOS_SHADOW_ALL_LEGACY_OPROMS) (
+ IN EFI_LEGACY_BIOS_PROTOCOL * This
+ )
+/*++
+
+ Routine Description:
+ Shadow all legacy16 OPROMs that haven't been shadowed.
+ Warning: Use this with caution. This routine disconnects all EFI
+ drivers. If used externally then caller must re-connect EFI
+ drivers.
+ Arguments:
+
+ Returns:
+ EFI_SUCCESS - OPROMs shadowed
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_LEGACY_BIOS_GET_LEGACY_REGION) (
+ IN EFI_LEGACY_BIOS_PROTOCOL * This,
+ IN UINTN LegacyMemorySize,
+ IN UINTN Region,
+ IN UINTN Alignment,
+ OUT VOID **LegacyMemoryAddress
+ )
+/*++
+
+Routine Description:
+ Get a region from the LegacyBios for S3 usage.
+
+Arguments:
+ This - Protocol instance pointer.
+ LegacyMemorySize - Size of required region
+ Region - Region to use.
+ 00 = Either 0xE0000 or 0xF0000 block
+ Bit0 = 1 0xF0000 block
+ Bit1 = 1 0xE0000 block
+ Alignment - Address alignment. Bit mapped. First non-zero
+ bit from right is alignment.
+ LegacyMemoryAddress - Region Assigned
+
+Returns:
+
+ EFI_SUCCESS - Region assigned
+
+ Other - Region not assigned
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_LEGACY_BIOS_COPY_LEGACY_REGION) (
+ IN EFI_LEGACY_BIOS_PROTOCOL * This,
+ IN UINTN LegacyMemorySize,
+ IN VOID *LegacyMemoryAddress,
+ IN VOID *LegacyMemorySourceAddress
+ )
+/*++
+
+Routine Description:
+ Get a region from the LegacyBios for Tiano usage. Can only be invoked once.
+
+Arguments:
+ This - Protocol instance pointer.
+ LegacyMemorySize - Size of data to copy
+ LegacyMemoryAddress - Legacy Region destination address
+ Note: must be in region assigned by
+ LegacyBiosGetLegacyRegion
+ LegacyMemorySourceAddress - Source of data
+
+Returns:
+
+ EFI_SUCCESS - Region assigned
+ EFI_ACCESS_DENIED - Destination outside assigned region
+
+--*/
+;
+
+typedef struct _EFI_LEGACY_BIOS_PROTOCOL {
+ EFI_LEGACY_BIOS_INT86 Int86;
+ EFI_LEGACY_BIOS_FARCALL86 FarCall86;
+ EFI_LEGACY_BIOS_CHECK_ROM CheckPciRom;
+ EFI_LEGACY_BIOS_INSTALL_ROM InstallPciRom;
+ EFI_LEGACY_BIOS_BOOT LegacyBoot;
+ EFI_LEGACY_BIOS_UPDATE_KEYBOARD_LED_STATUS UpdateKeyboardLedStatus;
+ EFI_LEGACY_BIOS_GET_BBS_INFO GetBbsInfo;
+ EFI_LEGACY_BIOS_SHADOW_ALL_LEGACY_OPROMS ShadowAllLegacyOproms;
+ EFI_LEGACY_BIOS_PREPARE_TO_BOOT_EFI PrepareToBootEfi;
+ EFI_LEGACY_BIOS_GET_LEGACY_REGION GetLegacyRegion;
+ EFI_LEGACY_BIOS_COPY_LEGACY_REGION CopyLegacyRegion;
+ EFI_LEGACY_BIOS_BOOT_UNCONVENTIONAL_DEVICE BootUnconventionalDevice;
+} EFI_LEGACY_BIOS_PROTOCOL;
+
+extern EFI_GUID gEfiLegacyBiosProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Protocol/LegacyBiosPlatform/LegacyBiosPlatform.c b/EDK/Foundation/Framework/Protocol/LegacyBiosPlatform/LegacyBiosPlatform.c
new file mode 100644
index 0000000..4581935
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/LegacyBiosPlatform/LegacyBiosPlatform.c
@@ -0,0 +1,31 @@
+/*++
+
+Copyright (c) 1999 - 2002, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ LegacyBiosPlatform.c
+
+Abstract:
+
+ EFI Legacy BIOS Platform Protocol
+
+Revision History
+
+--*/
+
+#include "Tiano.h"
+
+#include EFI_PROTOCOL_DEFINITION (LegacyBiosPlatform)
+
+EFI_GUID gEfiLegacyBiosPlatformProtocolGuid = EFI_LEGACY_BIOS_PLATFORM_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiLegacyBiosPlatformProtocolGuid, "Legacy BIOS Platform Protocol", "Legacy BIOS Platform Protocol");
diff --git a/EDK/Foundation/Framework/Protocol/LegacyBiosPlatform/LegacyBiosPlatform.h b/EDK/Foundation/Framework/Protocol/LegacyBiosPlatform/LegacyBiosPlatform.h
new file mode 100644
index 0000000..d727fe5
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/LegacyBiosPlatform/LegacyBiosPlatform.h
@@ -0,0 +1,349 @@
+/*++
+
+Copyright (c) 1999 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ LegacyBiosPlatform.h
+
+Abstract:
+
+ The EFI Legacy BIOS Patform Protocol is used to mate a Legacy16
+ implementation with this EFI code. The EFI driver that produces
+ the Legacy BIOS protocol is generic and consumes this protocol.
+ A driver that matches the Legacy16 produces this protocol
+
+Revision History
+
+ The EFI Legacy BIOS Platform Protocol is compliant with CSM spec 0.96.
+
+--*/
+
+#ifndef _EFI_LEGACY_BIOS_PLATFORM_H
+#define _EFI_LEGACY_BIOS_PLATFORM_H
+
+#define EFI_LEGACY_BIOS_PLATFORM_PROTOCOL_GUID \
+ { \
+ 0x783658a3, 0x4172, 0x4421, 0xa2, 0x99, 0xe0, 0x9, 0x7, 0x9c, 0xc, 0xb4 \
+ }
+
+EFI_FORWARD_DECLARATION (EFI_LEGACY_BIOS_PLATFORM_PROTOCOL);
+
+#include "Tiano.h"
+#include EFI_PROTOCOL_DEFINITION (LegacyBios)
+
+#pragma pack(1)
+//
+// Define structures for GetOemIntData
+// Note:
+// OemIntDataElenent is an array of structures from 0 to Count-1.
+// RawData is an array of bytes from 0 to RamDataLength-1.
+//
+typedef struct {
+ UINT16 Int;
+ UINT16 Ax;
+ UINT32 RawDataLength;
+ UINT8 RawData[1];
+} EFI_OEM_INT_DATA_ELEMENT;
+
+typedef struct {
+ UINT16 Count;
+ EFI_OEM_INT_DATA_ELEMENT OemIntDataElement[1];
+} EFI_OEM_INT_DATA;
+#pragma pack()
+
+typedef enum {
+ EfiGetPlatformBinaryMpTable = 0,
+ EfiGetPlatformBinaryOemIntData = 1,
+ EfiGetPlatformBinaryOem16Data = 2,
+ EfiGetPlatformBinaryOem32Data = 3,
+ EfiGetPlatformBinaryTpmBinary = 4,
+ EfiGetPlatformBinarySystemRom = 5,
+ EfiGetPlatformPciExpressBase = 6,
+ EfiGetPlatformPmmSize = 7,
+ EfiGetPlatformEndOfOpromShadowAddr = 8
+} EFI_GET_PLATFORM_INFO_MODE;
+
+typedef enum {
+ EfiGetPlatformVgaHandle = 0,
+ EfiGetPlatformIdeHandle = 1,
+ EfiGetPlatformIsaBusHandle = 2,
+ EfiGetPlatformUsbHandle = 3
+} EFI_GET_PLATFORM_HANDLE_MODE;
+
+typedef enum {
+ EfiPlatformHookPrepareToScanRom = 0,
+ EfiPlatformHookShadowServiceRoms= 1,
+ EfiPlatformHookAfterRomInit = 2
+} EFI_GET_PLATFORM_HOOK_MODE;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_LEGACY_BIOS_PLATFORM_GET_PLATFORM_INFO) (
+ IN EFI_LEGACY_BIOS_PLATFORM_PROTOCOL * This,
+ IN EFI_GET_PLATFORM_INFO_MODE Mode,
+ OUT VOID **Table,
+ OUT UINTN *TableSize,
+ OUT UINTN *Location,
+ OUT UINTN *Alignment,
+ IN UINT16 LegacySegment,
+ IN UINT16 LegacyOffset
+ )
+/*++
+
+ Routine Description:
+ Return a System ROM image for the platform
+
+ Arguments:
+ This - Protocol instance pointer.
+ Mode - Specifies what data to return
+ Table - Pointer to MP table.
+ TableSize - Size in bytes of table.
+ Location - Legacy region requested
+ 0x00 = Any location
+ Bit 0 = 0xF0000 region
+ Bit 1 = 0xE0000 region
+ Multiple bits can be set
+ Alignment - Address alignment for allocation.
+ Bit mapped. First non-zero bit from right
+ is alignment.
+
+ LegacySegment - Segment in LegacyBios where Table is stored
+ LegacyOffset - Offset in LegacyBios where Table is stored
+
+ Returns:
+ EFI_SUCCESS - Data was returned successfully.
+ EFI_UNSUPPORTED - Mode is not supported on the platform.
+ EFI_NOT_FOUND - Binary image or table not found.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_LEGACY_BIOS_PLATFORM_GET_PLATFORM_HANDLE) (
+ IN EFI_LEGACY_BIOS_PLATFORM_PROTOCOL * This,
+ IN EFI_GET_PLATFORM_HANDLE_MODE Mode,
+ IN UINT16 Type,
+ OUT EFI_HANDLE **HandleBuffer,
+ OUT UINTN *HandleCount,
+ IN VOID **AdditionalData OPTIONAL
+ )
+/*++
+
+ Routine Description:
+ Return the Legacy16 policy for which device should be the VGA controller
+ used during a Legacy16 boot.
+
+ Arguments:
+ This - Protocol instance pointer.
+ Mode - Specifies what handle to return.
+ Type - Type from Device Path for Handle to represent.
+ HandleBuffer - Handles of the device/controller in priority order
+ with HandleBuffer[0] highest priority.
+ HandleCount - Number of handles in the buffer.
+ AdditionalData - Mode specific.
+
+
+ Returns:
+ EFI_SUCCESS - Handle is valid
+ EFI_UNSUPPORTED - Mode is not supported on the platform.
+ EFI_NOT_FOUND - Handle is not known
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_LEGACY_BIOS_PLATFORM_SMM_INIT) (
+ IN EFI_LEGACY_BIOS_PLATFORM_PROTOCOL * This,
+ IN VOID *EfiToLegacy16BootTable
+ );
+
+/*++
+
+ Routine Description:
+ Load and initialize the Legacy BIOS SMM handler.
+
+ Arguments:
+ This - Protocol instance pointer.
+ EfiToLegacy16BootTable - Pointer to Legacy16 boot table.
+ Returns:
+ EFI_SUCCESS - SMM code loaded.
+ EFI_DEVICE_ERROR - SMM code failed to load
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_LEGACY_BIOS_PLATFORM_HOOKS) (
+ IN EFI_LEGACY_BIOS_PLATFORM_PROTOCOL * This,
+ IN EFI_GET_PLATFORM_HOOK_MODE Mode,
+ IN UINT16 Type,
+ IN EFI_HANDLE DeviceHandle,
+ IN OUT UINTN *ShadowAddress,
+ IN EFI_COMPATIBILITY16_TABLE * Compatibility16Table,
+ IN VOID **AdditionalData OPTIONAL
+ )
+/*++
+
+ Routine Description:
+ Prepare to scan a ROM.
+
+ Arguments:
+ This - Protocol instance pointer.
+ Handle - Device handle
+ ShadowAddress - Address that ROM is shadowed at prior to
+ initialization or first free ROM address,
+ depending upon mode.
+ Compatibility16Table - Pointer to Compatibility16Table.
+ AdditionalData - Mode specific.
+
+
+ Returns:
+ EFI_SUCCESS - RomImage is valid
+ EFI_UNSUPPORTED - Mode is not supported on the platform or platform
+ policy is to not install this OPROM.
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_LEGACY_BIOS_PLATFORM_GET_ROUTING_TABLE) (
+ IN EFI_LEGACY_BIOS_PLATFORM_PROTOCOL * This,
+ OUT VOID **RoutingTable,
+ OUT UINTN *RoutingTableEntries,
+ OUT VOID **LocalPirqTable, OPTIONAL
+ OUT UINTN *PirqTableSize, OPTIONAL
+ OUT VOID **LocalIrqPriorityTable, OPTIONAL
+ OUT UINTN *IrqPriorityTableEntries OPTIONAL
+ )
+/*++
+
+ Routine Description:
+ 1. List of IRQ routing entries and number of entries.
+ 2. Pointer to Entire $PIR table and length.
+ 3. List of IRQs to assign to PCI in priority.
+
+ Arguments:
+ This - Protocol instance pointer.
+ RoutingTable - Pointer to PCI IRQ Routing table.
+ RoutingTableEntries - Number of entries in table.
+ LocalPirqTable - $PIR table
+ PirqTableSize - $PIR table size
+ LocalIrqPriorityTable - List of interrupts in priority order to assign
+ IrqPriorityTableEntries- Number of entries in priority table
+
+ Returns:
+ EFI_SUCCESS - Table pointer returned
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_LEGACY_BIOS_PLATFORM_TRANSLATE_PIRQ) (
+ IN EFI_LEGACY_BIOS_PLATFORM_PROTOCOL * This,
+ IN UINTN PciBus,
+ IN UINTN PciDevice,
+ IN UINTN PciFunction,
+ IN OUT UINT8 *Pirq,
+ OUT UINT8 *PciIrq
+ )
+/*++
+
+ Routine Description:
+ Translate the PIRQ reported by the PCI device into the true PIRQ
+ from the internal IRQ routing information and IRQ assigned or to be
+ assigned to device.
+
+ Arguments:
+ This - Protocol instance pointer.
+ Base as defined below is the bus,device, function in
+ IRQ routing table.
+ PciBus - Base Bus for this device.
+ PciDevice - Base Device for this device.
+ PciFunction - Base Function for this device.
+ Pirq - Input is PIRQ reported by device, output is true PIRQ.
+ PciIrq - The IRQ already assigned to the PIRQ or the IRQ to be
+ assigned to the PIRQ.
+
+ Returns:
+ EFI_SUCCESS - Irq translated
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_LEGACY_BIOS_PLATFORM_PREPARE_TO_BOOT) (
+ IN EFI_LEGACY_BIOS_PLATFORM_PROTOCOL * This,
+ IN BBS_BBS_DEVICE_PATH * BbsDevicePath,
+ IN VOID *BbsTable,
+ IN UINT32 LoadOptionsSize,
+ IN VOID *LoadOptions,
+ IN VOID *EfiToLegacy16BootTable
+ )
+/*++
+
+ Routine Description:
+ Attempt to legacy boot the BootOption. If the EFI contexted has been
+ compromised this function will not return.
+
+ Arguments:
+ This - Protocol instance pointer.
+ BbsDevicePath - EFI Device Path from BootXXXX variable.
+ BbsTable - Internal BBS table.
+ LoadOptionSize - Size of LoadOption in size.
+ LoadOption - LoadOption from BootXXXX variable
+ EfiToLegacy16BootTable - Pointer to BootTable structure
+
+ Returns:
+ EFI_SUCCESS - Removable media not present
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_LEGACY_BIOS_PLATFORM_PERFORM_PLATFORM_TPM_TASKS) (
+ IN EFI_LEGACY_BIOS_PLATFORM_PROTOCOL * This
+ )
+/*++
+
+ Routine Description:
+ Perform platform-related TPM tasks.
+
+ Arguments:
+ This - Protocol instance pointer.
+
+ Returns:
+ EFI_SUCCESS - Successfully performed the TPM tasks or TCG service not found.
+ Others - Failed to perform the TPM tasks.
+
+--*/
+;
+
+typedef struct _EFI_LEGACY_BIOS_PLATFORM_PROTOCOL {
+ EFI_LEGACY_BIOS_PLATFORM_GET_PLATFORM_INFO GetPlatformInfo;
+ EFI_LEGACY_BIOS_PLATFORM_GET_PLATFORM_HANDLE GetPlatformHandle;
+ EFI_LEGACY_BIOS_PLATFORM_SMM_INIT SmmInit;
+ EFI_LEGACY_BIOS_PLATFORM_HOOKS PlatformHooks;
+ EFI_LEGACY_BIOS_PLATFORM_GET_ROUTING_TABLE GetRoutingTable;
+ EFI_LEGACY_BIOS_PLATFORM_TRANSLATE_PIRQ TranslatePirq;
+ EFI_LEGACY_BIOS_PLATFORM_PREPARE_TO_BOOT PrepareToBoot;
+ EFI_LEGACY_BIOS_PLATFORM_PERFORM_PLATFORM_TPM_TASKS PerformPlatformTpmTasks;
+} EFI_LEGACY_BIOS_PLATFORM_PROTOCOL;
+
+extern EFI_GUID gEfiLegacyBiosPlatformProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Protocol/LegacyInterrupt/LegacyInterrupt.c b/EDK/Foundation/Framework/Protocol/LegacyInterrupt/LegacyInterrupt.c
new file mode 100644
index 0000000..605d71e
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/LegacyInterrupt/LegacyInterrupt.c
@@ -0,0 +1,31 @@
+/*++
+
+Copyright (c) 1999 - 2002, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ LegacyInterrupt.c
+
+Abstract:
+
+ EFI Legacy InterruptProtocol
+
+Revision History
+
+--*/
+
+#include "Tiano.h"
+
+#include EFI_PROTOCOL_DEFINITION (LegacyInterrupt)
+
+EFI_GUID gEfiLegacyInterruptProtocolGuid = EFI_LEGACY_INTERRUPT_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiLegacyInterruptProtocolGuid, "Legacy Interrupt Protocol", "Legacy Interrupt Protocol");
diff --git a/EDK/Foundation/Framework/Protocol/LegacyInterrupt/LegacyInterrupt.h b/EDK/Foundation/Framework/Protocol/LegacyInterrupt/LegacyInterrupt.h
new file mode 100644
index 0000000..5c2783d
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/LegacyInterrupt/LegacyInterrupt.h
@@ -0,0 +1,136 @@
+/*++
+
+Copyright (c) 1999 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ LegacyInterrupt.h
+
+Abstract:
+
+ This protocol manages the PIRQ for PCI devices
+
+Revision History
+
+ The EFI Legacy Interrupt Protocol is compliant with CSM spec 0.96.
+
+--*/
+
+#ifndef _EFI_LEGACY_INTERRUPT_H_
+#define _EFI_LEGACY_INTERRUPT_H_
+
+#define EFI_LEGACY_INTERRUPT_PROTOCOL_GUID \
+ { \
+ 0x31ce593d, 0x108a, 0x485d, 0xad, 0xb2, 0x78, 0xf2, 0x1f, 0x29, 0x66, 0xbe \
+ }
+
+EFI_FORWARD_DECLARATION (EFI_LEGACY_INTERRUPT_PROTOCOL);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_LEGACY_INTERRUPT_GET_NUMBER_PIRQS) (
+ IN EFI_LEGACY_INTERRUPT_PROTOCOL * This,
+ OUT UINT8 *NumberPirqs
+ );
+
+/*++
+
+ Routine Description:
+ Return the number of PIRQs this hardware supports.
+
+ Arguments:
+ This - Protocol instance pointer.
+ NumberPirsq - Number of PIRQs.
+
+ Returns:
+ EFI_SUCCESS - Number of PIRQs returned.
+
+--*/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_LEGACY_INTERRUPT_GET_LOCATION) (
+ IN EFI_LEGACY_INTERRUPT_PROTOCOL * This,
+ OUT UINT8 *Bus,
+ OUT UINT8 *Device,
+ OUT UINT8 *Function
+ );
+
+/*++
+
+ Routine Description:
+ Return PCI location of this device. $PIR table requires this info.
+
+ Arguments:
+ This - Protocol instance pointer.
+ Bus - PCI Bus
+ Device - PCI Device
+ Function - PCI Function
+
+ Returns:
+ EFI_SUCCESS - Bus/Device/Function returned
+
+--*/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_LEGACY_INTERRUPT_READ_PIRQ) (
+ IN EFI_LEGACY_INTERRUPT_PROTOCOL * This,
+ IN UINT8 PirqNumber,
+ OUT UINT8 *PirqData
+ );
+
+/*++
+
+ Routine Description:
+ Read the PIRQ register and return the data
+
+ Arguments:
+ This - Protocol instance pointer.
+ PirqNumber - PIRQ register to read
+ PirqData - Data read
+
+ Returns:
+ EFI_SUCCESS - Data was read
+ EFI_INVALID_PARAMETER - Invalid PIRQ number
+
+--*/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_LEGACY_INTERRUPT_WRITE_PIRQ) (
+ IN EFI_LEGACY_INTERRUPT_PROTOCOL * This,
+ IN UINT8 PirqNumber,
+ IN UINT8 PirqData
+ );
+
+/*++
+
+ Routine Description:
+ Write the specified PIRQ register with the given data.
+
+ Arguments:
+ This - Protocol instance pointer.
+ PirqNumber - PIRQ register to read.
+ PirqData - Data written.
+
+ Returns:
+ EFI_SUCCESS - Table pointer returned
+ EFI_INVALID_PARAMETER - Invalid PIRQ number
+
+--*/
+typedef struct _EFI_LEGACY_INTERRUPT_PROTOCOL {
+ EFI_LEGACY_INTERRUPT_GET_NUMBER_PIRQS GetNumberPirqs;
+ EFI_LEGACY_INTERRUPT_GET_LOCATION GetLocation;
+ EFI_LEGACY_INTERRUPT_READ_PIRQ ReadPirq;
+ EFI_LEGACY_INTERRUPT_WRITE_PIRQ WritePirq;
+} EFI_LEGACY_INTERRUPT_PROTOCOL;
+
+extern EFI_GUID gEfiLegacyInterruptProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Protocol/LegacyRegion/LegacyRegion.c b/EDK/Foundation/Framework/Protocol/LegacyRegion/LegacyRegion.c
new file mode 100644
index 0000000..e465c27
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/LegacyRegion/LegacyRegion.c
@@ -0,0 +1,31 @@
+/*++
+
+Copyright (c) 1999 - 2002, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ LegacyRegion.c
+
+Abstract:
+
+ EFI Legacy Region Protocol
+
+Revision History
+
+--*/
+
+#include "Tiano.h"
+
+#include EFI_PROTOCOL_DEFINITION (LegacyRegion)
+
+EFI_GUID gEfiLegacyRegionProtocolGuid = EFI_LEGACY_REGION_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiLegacyRegionProtocolGuid, "Legacy Region Protocol", "Legacy Region Protocol");
diff --git a/EDK/Foundation/Framework/Protocol/LegacyRegion/LegacyRegion.h b/EDK/Foundation/Framework/Protocol/LegacyRegion/LegacyRegion.h
new file mode 100644
index 0000000..c0bf631
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/LegacyRegion/LegacyRegion.h
@@ -0,0 +1,82 @@
+/*++
+
+Copyright (c) 1999 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ LegacyRegion.h
+
+Abstract:
+
+ This protocol manages the legacy memory regions between 0xc0000 - 0xfffff
+
+Revision History
+
+ The EFI Legacy Region Protocol is compliant with CSM spec 0.96.
+
+--*/
+
+#ifndef _EFI_LEGACY_REGION_H_
+#define _EFI_LEGACY_REGION_H_
+
+#define EFI_LEGACY_REGION_PROTOCOL_GUID \
+ { \
+ 0xfc9013a, 0x568, 0x4ba9, 0x9b, 0x7e, 0xc9, 0xc3, 0x90, 0xa6, 0x60, 0x9b \
+ }
+
+EFI_FORWARD_DECLARATION (EFI_LEGACY_REGION_PROTOCOL);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_LEGACY_REGION_DECODE) (
+ IN EFI_LEGACY_REGION_PROTOCOL * This,
+ IN UINT32 Start,
+ IN UINT32 Length,
+ IN BOOLEAN *On
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_LEGACY_REGION_LOCK) (
+ IN EFI_LEGACY_REGION_PROTOCOL * This,
+ IN UINT32 Start,
+ IN UINT32 Length,
+ OUT UINT32 *Granularity OPTIONAL
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_LEGACY_REGION_BOOT_LOCK) (
+ IN EFI_LEGACY_REGION_PROTOCOL * This,
+ IN UINT32 Start,
+ IN UINT32 Length,
+ OUT UINT32 *Granularity OPTIONAL
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_LEGACY_REGION_UNLOCK) (
+ IN EFI_LEGACY_REGION_PROTOCOL * This,
+ IN UINT32 Start,
+ IN UINT32 Length,
+ OUT UINT32 *Granularity OPTIONAL
+ );
+
+typedef struct _EFI_LEGACY_REGION_PROTOCOL {
+ EFI_LEGACY_REGION_DECODE Decode;
+ EFI_LEGACY_REGION_LOCK Lock;
+ EFI_LEGACY_REGION_BOOT_LOCK BootLock;
+ EFI_LEGACY_REGION_UNLOCK UnLock;
+} EFI_LEGACY_REGION_PROTOCOL;
+
+extern EFI_GUID gEfiLegacyRegionProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Protocol/PciHostBridgeResourceAllocation/PciHostBridgeResourceAllocation.c b/EDK/Foundation/Framework/Protocol/PciHostBridgeResourceAllocation/PciHostBridgeResourceAllocation.c
new file mode 100644
index 0000000..5fcfb9f
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/PciHostBridgeResourceAllocation/PciHostBridgeResourceAllocation.c
@@ -0,0 +1,31 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PciHostBridgeResourceAllocation.c
+
+Abstract:
+
+
+--*/
+
+#include "Tiano.h"
+
+#include EFI_PROTOCOL_DEFINITION (PciHostBridgeResourceAllocation)
+
+EFI_GUID gEfiPciHostBridgeResourceAllocationProtocolGuid = EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL_GUID;
+
+EFI_GUID_STRING
+ (
+ &gEfiPciHostBridgeResourceAllocationProtocolGuid, "PciHostBridgeRresourceAllocation Protocol",
+ "Pci Host Bridge Resource Allocation Protocol"
+ );
diff --git a/EDK/Foundation/Framework/Protocol/PciHostBridgeResourceAllocation/PciHostBridgeResourceAllocation.h b/EDK/Foundation/Framework/Protocol/PciHostBridgeResourceAllocation/PciHostBridgeResourceAllocation.h
new file mode 100644
index 0000000..fa13082
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/PciHostBridgeResourceAllocation/PciHostBridgeResourceAllocation.h
@@ -0,0 +1,364 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PciHostBridgeResourceAllocation.h
+
+Abstract:
+
+
+--*/
+
+#ifndef _PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_H_
+#define _PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_H_
+
+#include "Tiano.h"
+#include EFI_PROTOCOL_DEFINITION(PciRootBridgeIo)
+
+
+#define EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL_GUID \
+ { 0xCF8034BE,0x6768,0x4d8b,0xB7,0x39,0x7C,0xCE,0x68,0x3A,0x9F,0xBE }
+
+
+EFI_FORWARD_DECLARATION (EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL);
+
+
+//
+// EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ATTRIBUTES
+//
+
+// If this bit is set, then the PCI Root Bridge does not
+// support separate windows for Non-prefetchable and Prefetchable
+// memory. A PCI bus driver needs to include requests for Prefetchable
+// memory in the Non-prefetchable memory pool.
+//
+#define EFI_PCI_HOST_BRIDGE_COMBINE_MEM_PMEM 1
+
+//
+// If this bit is set, then the PCI Root Bridge supports
+// 64 bit memory windows. If this bit is not set,
+// the PCI bus driver needs to include requests for 64 bit
+// memory address in the corresponding 32 bit memory pool.
+//
+#define EFI_PCI_HOST_BRIDGE_MEM64_DECODE 2
+
+
+//
+// EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PHASE
+//
+typedef enum {
+ EfiPciHostBridgeBeginEnumeration,
+ EfiPciHostBridgeBeginBusAllocation,
+ EfiPciHostBridgeEndBusAllocation,
+ EfiPciHostBridgeBeginResourceAllocation,
+ EfiPciHostBridgeAllocateResources,
+ EfiPciHostBridgeSetResources,
+ EfiPciHostBridgeFreeResources,
+ EfiPciHostBridgeEndResourceAllocation
+} EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PHASE;
+
+//
+// EfiPciHostBridgeBeginEnumeration
+// Reset the host bridge PCI apertures and internal data structures.
+// PCI enumerator should issue this notification before starting fresh
+// enumeration process. Enumeration cannot be restarted after sending
+// any other notification such as EfiPciHostBridgeBeginBusAllocation.
+//
+// EfiPciHostBridgeBeginBusAllocation
+// The bus allocation phase is about to begin. No specific action
+// is required here. This notification can be used to perform any
+// chipset specific programming.
+//
+// EfiPciHostBridgeEndBusAllocation
+// The bus allocation and bus programming phase is complete. No specific
+// action is required here. This notification can be used to perform any
+// chipset specific programming.
+//
+// EfiPciHostBridgeBeginResourceAllocation
+// The resource allocation phase is about to begin.No specific action is
+// required here. This notification can be used to perform any chipset specific programming.
+//
+// EfiPciHostBridgeAllocateResources
+// Allocate resources per previously submitted requests for all the PCI Root
+// Bridges. These resource settings are returned on the next call to
+// GetProposedResources().
+//
+// EfiPciHostBridgeSetResources
+// Program the Host Bridge hardware to decode previously allocated resources
+// (proposed resources) for all the PCI Root Bridges.
+//
+// EfiPciHostBridgeFreeResources
+// De-allocate previously allocated resources previously for all the PCI
+// Root Bridges and reset the I/O and memory apertures to initial state.
+//
+// EfiPciHostBridgeEndResourceAllocation
+// The resource allocation phase is completed. No specific action is required
+// here. This notification can be used to perform any chipset specific programming.
+
+
+
+//
+// EFI_PCI_CONTROLLER_RESOURCE_ALLOCATION_PHASE
+//
+typedef enum {
+ EfiPciBeforeChildBusEnumeration,
+ EfiPciBeforeResourceCollection
+} EFI_PCI_CONTROLLER_RESOURCE_ALLOCATION_PHASE;
+
+//
+// EfiPciBeforeChildBusEnumeration
+// This notification is only applicable to PCI-PCI bridges and
+// indicates that the PCI enumerator is about to begin enumerating
+// the bus behind the PCI-PCI Bridge. This notification is sent after
+// the primary bus number, the secondary bus number and the subordinate
+// bus number registers in the PCI-PCI Bridge are programmed to valid
+// (not necessary final) values
+//
+// EfiPciBeforeResourceCollection
+// This notification is sent before the PCI enumerator probes BAR registers
+// for every valid PCI function.
+//
+
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL_NOTIFY_PHASE) (
+ IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,
+ IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PHASE Phase
+ );
+/*++
+
+Routine Description:
+ Enter a certain phase of the PCI enumeration process
+
+Arguments:
+ This -- The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL instance
+ Phase -- The phase during enumeration
+
+Returns:
+ EFI_SUCCESS - Success
+ EFI_OUT_OF_RESOURCES - If SubmitResources ( ) could not allocate resources
+ EFI_NOT_READY - This phase cannot be entered at this time
+ EFI_DEVICE_ERROR - SetResources failed due to HW error.
+
+--*/
+
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL_GET_NEXT_ROOT_BRIDGE) (
+ IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,
+ IN OUT EFI_HANDLE *RootBridgeHandle
+ );
+/*++
+
+Routine Description:
+ Return the device handle of the next PCI root bridge that is associated with
+ this Host Bridge
+
+Arguments:
+ This -- The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance
+ RootBridgeHandle -- Returns the device handle of the next PCI Root Bridge.
+ On input, it holds the RootBridgeHandle returned by the most
+ recent call to GetNextRootBridge().The handle for the first
+ PCI Root Bridge is returned if RootBridgeHandle is NULL on input
+
+Returns:
+ EFI_SUCCESS - Success
+ EFI_INVALID_PARAMETER - RootBridgeHandle is invalid
+
+--*/
+
+
+typedef
+EFI_STATUS
+(EFIAPI * EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL_GET_ATTRIBUTES) (
+ IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,
+ IN EFI_HANDLE RootBridgeHandle,
+ OUT UINT64 *Attributes
+ );
+/*++
+
+Routine Description:
+ Returns the attributes of a PCI Root Bridge.
+
+Arguments:
+ This -- The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance
+ RootBridgeHandle -- The device handle of the PCI Root Bridge
+ that the caller is interested in
+ Attribute -- The pointer to attributes of the PCI Root Bridge
+
+Returns:
+ EFI_SUCCESS - Success
+ EFI_INVALID_PARAMETER - RootBridgeHandle is invalid
+ EFI_INVALID_PARAMETER - Attributes is NULL
+
+--*/
+
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL_START_BUS_ENUMERATION) (
+ IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,
+ IN EFI_HANDLE RootBridgeHandle,
+ OUT VOID **Configuration
+ );
+/*++
+
+Routine Description:
+ This is the request from the PCI enumerator to set up
+ the specified PCI Root Bridge for bus enumeration process.
+
+Arguments:
+ This -- The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance
+ RootBridgeHandle -- The PCI Root Bridge to be set up
+ Configuration -- Pointer to the pointer to the PCI bus resource descriptor
+
+Returns:
+ EFI_SUCCESS - Success
+ EFI_INVALID_PARAMETER - RootBridgeHandle is invalid
+ EFI_DEVICE_ERROR - Request failed due to hardware error
+ EFI_OUT_OF_RESOURCES - Request failed due to lack of resources
+--*/
+
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL_SET_BUS_NUMBERS) (
+ IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,
+ IN EFI_HANDLE RootBridgeHandle,
+ IN VOID *Configuration
+ );
+/*++
+
+Routine Description:
+ This function programs the PCI Root Bridge hardware so that
+ it decodes the specified PCI bus range
+
+Arguments:
+ This -- The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance
+ RootBridgeHandle -- The PCI Root Bridge whose bus range is to be programmed
+ Configuration -- The pointer to the PCI bus resource descriptor
+
+Returns:
+ EFI_SUCCESS - Success
+ EFI_INVALID_PARAMETER - RootBridgeHandle is invalid
+ EFI_INVALID_PARAMETER - Configuration is NULL
+ EFI_INVALID_PARAMETER - Configuration does not point to a valid ACPI resource descriptor
+ EFI_INVALID_PARAMETER - Configuration contains one or more memory or IO ACPI resource descriptor
+ EFI_INVALID_PARAMETER - Address Range Minimum or Address Range Length fields in Configuration
+ are invalid for this Root Bridge.
+ EFI_INVALID_PARAMETER - Configuration contains one or more invalid ACPI resource descriptor
+ EFI_DEVICE_ERROR - Request failed due to hardware error
+ EFI_OUT_OF_RESOURCES - Request failed due to lack of resources
+
+--*/
+
+
+typedef
+EFI_STATUS
+(EFIAPI * EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL_SUBMIT_RESOURCES) (
+ IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,
+ IN EFI_HANDLE RootBridgeHandle,
+ IN VOID *Configuration
+ );
+/*++
+
+Routine Description:
+ Submits the I/O and memory resource requirements for the specified PCI Root Bridge
+
+Arguments:
+ This -- The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance
+ RootBridgeHandle -- The PCI Root Bridge whose I/O and memory resource requirements
+ are being submitted
+ Configuration -- The pointer to the PCI I/O and PCI memory resource descriptor
+Returns:
+ EFI_SUCCESS - Success
+ EFI_INVALID_PARAMETER - RootBridgeHandle is invalid
+ EFI_INVALID_PARAMETER - Configuration is NULL
+ EFI_INVALID_PARAMETER - Configuration does not point to a valid ACPI resource descriptor
+ EFI_INVALID_PARAMETER - Configuration includes a resource descriptor of unsupported type
+
+--*/
+
+
+typedef
+EFI_STATUS
+(EFIAPI * EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL_GET_PROPOSED_RESOURCES) (
+ IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,
+ IN EFI_HANDLE RootBridgeHandle,
+ OUT VOID **Configuration
+ );
+/*++
+
+Routine Description:
+ This function returns the proposed resource settings for the specified
+ PCI Root Bridge
+
+Arguments:
+ This -- The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance
+ RootBridgeHandle -- The PCI Root Bridge handle
+ Configuration -- The pointer to the pointer to the PCI I/O
+ and memory resource descriptor
+
+Returns:
+ EFI_SUCCESS - Success
+ EFI_INVALID_PARAMETER - RootBridgeHandle is invalid
+ EFI_DEVICE_ERROR - Request failed due to hardware error
+ EFI_OUT_OF_RESOURCES - Request failed due to lack of resources
+
+--*/
+
+
+
+typedef
+EFI_STATUS
+(EFIAPI * EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL_PREPROCESS_CONTROLLER) (
+ IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL *This,
+ IN EFI_HANDLE RootBridgeHandle,
+ IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_PCI_ADDRESS PciAddress,
+ IN EFI_PCI_CONTROLLER_RESOURCE_ALLOCATION_PHASE Phase
+ );
+/*++
+
+Routine Description:
+ This function is called for all the PCI controllers that the PCI
+ bus driver finds. Can be used to Preprogram the controller.
+
+Arguments:
+ This -- The EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_ PROTOCOL instance
+ RootBridgeHandle -- The PCI Root Bridge handle
+ PciBusAddress -- Address of the controller on the PCI bus
+ Phase -- The Phase during resource allocation
+
+Returns:
+ EFI_SUCCESS - Success
+ EFI_INVALID_PARAMETER - RootBridgeHandle is invalid
+ EFI_DEVICE_ERROR - Device pre-initialization failed due to hardware error.
+--*/
+
+
+
+typedef struct _EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL {
+ EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL_NOTIFY_PHASE NotifyPhase;
+ EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL_GET_NEXT_ROOT_BRIDGE GetNextRootBridge;
+ EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL_GET_ATTRIBUTES GetAllocAttributes;
+ EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL_START_BUS_ENUMERATION StartBusEnumeration;
+ EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL_SET_BUS_NUMBERS SetBusNumbers;
+ EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL_SUBMIT_RESOURCES SubmitResources;
+ EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL_GET_PROPOSED_RESOURCES GetProposedResources;
+ EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL_PREPROCESS_CONTROLLER PreprocessController;
+} EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PROTOCOL;
+
+extern EFI_GUID gEfiPciHostBridgeResourceAllocationProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Protocol/PciHotPlugInit/PciHotPlugInit.c b/EDK/Foundation/Framework/Protocol/PciHotPlugInit/PciHotPlugInit.c
new file mode 100644
index 0000000..6f30668
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/PciHotPlugInit/PciHotPlugInit.c
@@ -0,0 +1,30 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PciHotPlugInit.c
+
+Abstract:
+
+ EFI PCI Hot Plug Init Protocol
+
+Revision History
+
+--*/
+
+#include "Tiano.h"
+
+#include EFI_PROTOCOL_DEFINITION (PciHotPlugInit)
+
+EFI_GUID gEfiPciHotPlugInitProtocolGuid = EFI_PCI_HOT_PLUG_INIT_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiPciHotPlugInitProtocolGuid, "PCI Hot Plug Init Protocol", "PCI Hot Plug Init Protocol");
diff --git a/EDK/Foundation/Framework/Protocol/PciHotPlugInit/PciHotPlugInit.h b/EDK/Foundation/Framework/Protocol/PciHotPlugInit/PciHotPlugInit.h
new file mode 100644
index 0000000..732b658
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/PciHotPlugInit/PciHotPlugInit.h
@@ -0,0 +1,97 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PciHotPlugInit.h
+
+Abstract:
+
+ EFI PCI Hot Plug Init Protocol
+
+Revision History
+
+--*/
+
+#ifndef _EFI_PCI_HOT_PLUG_INIT_H
+#define _EFI_PCI_HOT_PLUG_INIT_H
+
+//
+// Global ID for the PCI Hot Plug Protocol
+//
+#define EFI_PCI_HOT_PLUG_INIT_PROTOCOL_GUID \
+ { 0xaa0e8bc1, 0xdabc, 0x46b0, 0xa8, 0x44, 0x37, 0xb8, 0x16, 0x9b, 0x2b, 0xea }
+
+
+EFI_FORWARD_DECLARATION (EFI_PCI_HOT_PLUG_INIT_PROTOCOL);
+
+#define EFI_HPC_STATE_INITIALIZED 0x01
+#define EFI_HPC_STATE_ENABLED 0x02
+
+typedef UINT16 EFI_HPC_STATE;
+
+
+typedef struct{
+ EFI_DEVICE_PATH_PROTOCOL *HpcDevicePath;
+ EFI_DEVICE_PATH_PROTOCOL *HpbDevicePath;
+} EFI_HPC_LOCATION;
+
+
+typedef enum{
+ EfiPaddingPciBus,
+ EfiPaddingPciRootBridge
+} EFI_HPC_PADDING_ATTRIBUTES;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_GET_ROOT_HPC_LIST) (
+ IN EFI_PCI_HOT_PLUG_INIT_PROTOCOL *This,
+ OUT UINTN *HpcCount,
+ OUT EFI_HPC_LOCATION **HpcList
+);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_INITIALIZE_ROOT_HPC) (
+ IN EFI_PCI_HOT_PLUG_INIT_PROTOCOL *This,
+ IN EFI_DEVICE_PATH_PROTOCOL *HpcDevicePath,
+ IN UINT64 HpcPciAddress,
+ IN EFI_EVENT Event, OPTIONAL
+ OUT EFI_HPC_STATE *HpcState
+);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_GET_PCI_HOT_PLUG_PADDING) (
+ IN EFI_PCI_HOT_PLUG_INIT_PROTOCOL *This,
+ IN EFI_DEVICE_PATH_PROTOCOL *HpcDevicePath,
+ IN UINT64 HpcPciAddress,
+ OUT EFI_HPC_STATE *HpcState,
+ OUT VOID **Padding,
+ OUT EFI_HPC_PADDING_ATTRIBUTES *Attributes
+);
+
+
+//
+// Prototypes for the PCI Hot Plug Init Protocol
+//
+
+
+typedef struct _EFI_PCI_HOT_PLUG_INIT_PROTOCOL {
+ EFI_GET_ROOT_HPC_LIST GetRootHpcList;
+ EFI_INITIALIZE_ROOT_HPC InitializeRootHpc;
+ EFI_GET_PCI_HOT_PLUG_PADDING GetResourcePadding;
+} EFI_PCI_HOT_PLUG_INIT_PROTOCOL;
+
+
+extern EFI_GUID gEfiPciHotPlugInitProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Protocol/PciPlatform/PciPlatform.c b/EDK/Foundation/Framework/Protocol/PciPlatform/PciPlatform.c
new file mode 100644
index 0000000..d1d417d
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/PciPlatform/PciPlatform.c
@@ -0,0 +1,26 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+ PciPlatform.c
+
+Abstract:
+ This file defines global GUID variables for PlatformOpRom protocols.
+
+--*/
+
+#include "Tiano.h"
+#include EFI_PROTOCOL_PRODUCER (PciPlatform)
+
+
+EFI_GUID gEfiPciPlatformProtocolGuid = EFI_PCI_PLATFORM_PROTOCOL_GUID;
+
+EFI_GUID_STRING (&gEfiPciPlatformProtocolGuid, "Pci Platform Protocol", "Pci Platform Protocol");
diff --git a/EDK/Foundation/Framework/Protocol/PciPlatform/PciPlatform.h b/EDK/Foundation/Framework/Protocol/PciPlatform/PciPlatform.h
new file mode 100644
index 0000000..8beebfd
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/PciPlatform/PciPlatform.h
@@ -0,0 +1,211 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+ PciPlatform.h
+
+Abstract:
+ This file declares PlatfromOpRom protocols.
+
+--*/
+
+#ifndef _PCI_PLATFORM_H_
+#define _PCI_PLATFORM_H_
+
+
+#include "Tiano.h"
+#include "TianoTypes.h"
+
+#include EFI_PROTOCOL_DEFINITION (PciHostBridgeResourceAllocation)
+#include EFI_PROTOCOL_DEFINITION (PciRootBridgeIo)
+
+//
+// Protocol for GUID.
+//
+
+#define EFI_PCI_PLATFORM_PROTOCOL_GUID \
+{ 0x7d75280, 0x27d4, 0x4d69, 0x90, 0xd0, 0x56, 0x43, 0xe2, 0x38, 0xb3, 0x41}
+
+
+EFI_FORWARD_DECLARATION (EFI_PCI_PLATFORM_PROTOCOL);
+
+typedef UINT32 EFI_PCI_PLATFORM_POLICY;
+
+
+#define EFI_RESERVE_NONE_IO_ALIAS 0x0000
+#define EFI_RESERVE_ISA_IO_ALIAS 0x0001
+#define EFI_RESERVE_ISA_IO_NO_ALIAS 0x0002
+#define EFI_RESERVE_VGA_IO_ALIAS 0x0004
+#define EFI_RESERVE_VGA_IO_NO_ALIAS 0x0008
+
+
+typedef enum {
+ ChipsetEntry,
+ ChipsetExit,
+ MaximumChipsetPhase
+} EFI_PCI_CHIPSET_EXECUTION_PHASE;
+
+
+typedef
+EFI_STATUS
+(EFIAPI * EFI_PCI_PLATFORM_PHASE_NOTIFY) (
+ IN EFI_PCI_PLATFORM_PROTOCOL *This,
+ IN EFI_HANDLE HostBridge,
+ IN EFI_PCI_HOST_BRIDGE_RESOURCE_ALLOCATION_PHASE Phase,
+ IN EFI_PCI_CHIPSET_EXECUTION_PHASE ChipsetPhase
+)
+/*++
+
+ Routine Description:
+ The PlatformNotify() function can be used to notify the platform driver so that
+ it can perform platform-specific actions. No specific actions are required.
+ Eight notification points are defined at this time. More synchronization points
+ may be added as required in the future. The PCI bus driver calls the platform driver
+ twice for every Phase-once before the PCI Host Bridge Resource Allocation Protocol
+ driver is notified, and once after the PCI Host Bridge Resource Allocation Protocol
+ driver has been notified.
+ This member function may not perform any error checking on the input parameters. It
+ also does not return any error codes. If this member function detects any error condition,
+ it needs to handle those errors on its own because there is no way to surface any
+ errors to the caller.
+
+ Arguments:
+ This - Pointer to the EFI_PCI_PLATFORM_PROTOCOL instance.
+ HostBridge - The handle of the host bridge controller.
+ Phase - The phase of the PCI bus enumeration.
+ ChipsetPhase - Defines the execution phase of the PCI chipset driver.
+
+ Returns:
+ EFI_SUCCESS - The function completed successfully.
+
+--*/
+;
+
+
+typedef
+EFI_STATUS
+(EFIAPI * EFI_PCI_PLATFORM_PREPROCESS_CONTROLLER) (
+ IN EFI_PCI_PLATFORM_PROTOCOL *This,
+ IN EFI_HANDLE HostBridge,
+ IN EFI_HANDLE RootBridge,
+ IN EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_PCI_ADDRESS PciAddress,
+ IN EFI_PCI_CONTROLLER_RESOURCE_ALLOCATION_PHASE Phase,
+ IN EFI_PCI_CHIPSET_EXECUTION_PHASE ChipsetPhase
+)
+/*++
+
+ Routine Description:
+ The PlatformPrepController() function can be used to notify the platform driver so that
+ it can perform platform-specific actions. No specific actions are required.
+ Several notification points are defined at this time. More synchronization points may be
+ added as required in the future. The PCI bus driver calls the platform driver twice for
+ every PCI controller-once before the PCI Host Bridge Resource Allocation Protocol driver
+ is notified, and once after the PCI Host Bridge Resource Allocation Protocol driver has
+ been notified.
+ This member function may not perform any error checking on the input parameters. It also
+ does not return any error codes. If this member function detects any error condition, it
+ needs to handle those errors on its own because there is no way to surface any errors to
+ the caller.
+
+ Arguments:
+ This - Pointer to the EFI_PCI_PLATFORM_PROTOCOL instance.
+ HostBridge - The associated PCI host bridge handle.
+ RootBridge - The associated PCI root bridge handle.
+ PciAddress - The address of the PCI device on the PCI bus.
+ Phase - The phase of the PCI controller enumeration.
+ ChipsetPhase - Defines the execution phase of the PCI chipset driver.
+
+ Returns:
+ EFI_SUCCESS - The function completed successfully.
+
+--*/
+;
+
+
+typedef
+EFI_STATUS
+(EFIAPI * EFI_PCI_PLATFORM_GET_PLATFORM_POLICY) (
+ IN EFI_PCI_PLATFORM_PROTOCOL *This,
+ OUT EFI_PCI_PLATFORM_POLICY *PciPolicy
+)
+/*++
+
+ Routine Description:
+ The GetPlatformPolicy() function retrieves the platform policy regarding PCI
+ enumeration. The PCI bus driver and the PCI Host Bridge Resource Allocation Protocol
+ driver can call this member function to retrieve the policy.
+
+ Arguments:
+ This - Pointer to the EFI_PCI_PLATFORM_PROTOCOL instance.
+ PciPolicy - The platform policy with respect to VGA and ISA aliasing.
+
+ Returns:
+ EFI_SUCCESS - The function completed successfully.
+ EFI_INVALID_PARAMETER - PciPolicy is NULL.
+
+--*/
+;
+
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PCI_PLATFORM_GET_PCI_ROM) (
+ IN EFI_PCI_PLATFORM_PROTOCOL *This,
+ IN EFI_HANDLE PciHandle,
+ OUT VOID **RomImage,
+ OUT UINTN *RomSize
+)
+/*++
+
+ Routine Description:
+ The GetPciRom() function gets the PCI device's option ROM from a platform-specific location.
+ The option ROM will be loaded into memory. This member function is used to return an image
+ that is packaged as a PCI 2.2 option ROM. The image may contain both legacy and EFI option
+ ROMs. See the EFI 1.10 Specification for details. This member function can be used to return
+ option ROM images for embedded controllers. Option ROMs for embedded controllers are typically
+ stored in platform-specific storage, and this member function can retrieve it from that storage
+ and return it to the PCI bus driver. The PCI bus driver will call this member function before
+ scanning the ROM that is attached to any controller, which allows a platform to specify a ROM
+ image that is different from the ROM image on a PCI card.
+
+ Arguments:
+ This - Pointer to the EFI_PCI_PLATFORM_PROTOCOL instance.
+ PciHandle - The handle of the PCI device.
+ RomImage - If the call succeeds, the pointer to the pointer to the option ROM image.
+ Otherwise, this field is undefined. The memory for RomImage is allocated
+ by EFI_PCI_PLATFORM_PROTOCOL.GetPciRom() using the EFI Boot Service AllocatePool().
+ It is the caller's responsibility to free the memory using the EFI Boot Service
+ FreePool(), when the caller is done with the option ROM.
+ RomSize - If the call succeeds, a pointer to the size of the option ROM size. Otherwise,
+ this field is undefined.
+
+ Returns:
+ EFI_SUCCESS - The option ROM was available for this device and loaded into memory.
+ EFI_NOT_FOUND - No option ROM was available for this device.
+ EFI_OUT_OF_RESOURCES - No memory was available to load the option ROM.
+ EFI_DEVICE_ERROR - An error occurred in getting the option ROM.
+
+--*/
+;
+
+
+typedef struct _EFI_PCI_PLATFORM_PROTOCOL {
+ EFI_PCI_PLATFORM_PHASE_NOTIFY PhaseNotify;
+ EFI_PCI_PLATFORM_PREPROCESS_CONTROLLER PlatformPrepController;
+ EFI_PCI_PLATFORM_GET_PLATFORM_POLICY GetPlatformPolicy;
+ EFI_PCI_PLATFORM_GET_PCI_ROM GetPciRom;
+} EFI_PCI_PLATFORM_PROTOCOL;
+
+extern EFI_GUID gEfiPciPlatformProtocolGuid;
+
+
+
+#endif
diff --git a/EDK/Foundation/Framework/Protocol/SectionExtraction/SectionExtraction.c b/EDK/Foundation/Framework/Protocol/SectionExtraction/SectionExtraction.c
new file mode 100644
index 0000000..aaad016
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/SectionExtraction/SectionExtraction.c
@@ -0,0 +1,28 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ SectionExtraction.c
+
+Abstract:
+
+ Section Extraction protocol as defined in the Tiano File Image Format
+ specification.
+
+--*/
+
+#include "Tiano.h"
+#include EFI_PROTOCOL_DEFINITION (SectionExtraction)
+
+EFI_GUID gEfiSectionExtractionProtocolGuid = EFI_SECTION_EXTRACTION_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiSectionExtractionProtocolGuid, "Section Extraction Protocol", "Tiano Section Extraction Protocol");
diff --git a/EDK/Foundation/Framework/Protocol/SectionExtraction/SectionExtraction.h b/EDK/Foundation/Framework/Protocol/SectionExtraction/SectionExtraction.h
new file mode 100644
index 0000000..9d46b86
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/SectionExtraction/SectionExtraction.h
@@ -0,0 +1,83 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ SectionExtraction.h
+
+Abstract:
+
+ Section extraction protocol as defined in the Tiano File Image Format specification.
+
+ This interface provides a means of decoding a set of sections into a linked list of
+ leaf sections. This provides for an extensible and flexible file format.
+
+--*/
+
+#ifndef _SECTION_EXTRACTION_PROTOCOL_H
+#define _SECTION_EXTRACTION_PROTOCOL_H
+
+#include "EfiFirmwareFileSystem.h"
+
+//
+// Protocol GUID definition
+//
+#define EFI_SECTION_EXTRACTION_PROTOCOL_GUID \
+ { \
+ 0x448F5DA4, 0x6DD7, 0x4FE1, 0x93, 0x07, 0x69, 0x22, 0x41, 0x92, 0x21, 0x5D \
+ }
+
+EFI_FORWARD_DECLARATION (EFI_SECTION_EXTRACTION_PROTOCOL);
+
+//
+// Protocol member functions
+//
+typedef
+EFI_STATUS
+(EFIAPI *EFI_OPEN_SECTION_STREAM) (
+ IN EFI_SECTION_EXTRACTION_PROTOCOL * This,
+ IN UINTN SectionStreamLength,
+ IN VOID *SectionStream,
+ OUT UINTN *SectionStreamHandle
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_GET_SECTION) (
+ IN EFI_SECTION_EXTRACTION_PROTOCOL * This,
+ IN UINTN SectionStreamHandle,
+ IN EFI_SECTION_TYPE * SectionType,
+ IN EFI_GUID * SectionDefinitionGuid,
+ IN UINTN SectionInstance,
+ IN VOID **Buffer,
+ IN OUT UINTN *BufferSize,
+ OUT UINT32 *AuthenticationStatus
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_CLOSE_SECTION_STREAM) (
+ IN EFI_SECTION_EXTRACTION_PROTOCOL * This,
+ IN UINTN SectionStreamHandle
+ );
+
+//
+// Protocol definition
+//
+typedef struct _EFI_SECTION_EXTRACTION_PROTOCOL {
+ EFI_OPEN_SECTION_STREAM OpenSectionStream;
+ EFI_GET_SECTION GetSection;
+ EFI_CLOSE_SECTION_STREAM CloseSectionStream;
+} EFI_SECTION_EXTRACTION_PROTOCOL;
+
+extern EFI_GUID gEfiSectionExtractionProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Protocol/SecurityPolicy/SecurityPolicy.c b/EDK/Foundation/Framework/Protocol/SecurityPolicy/SecurityPolicy.c
new file mode 100644
index 0000000..e2c38af
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/SecurityPolicy/SecurityPolicy.c
@@ -0,0 +1,28 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ SecurityPolicy.c
+
+Abstract:
+
+ Security Policy protocol as defined in the DXE CIS
+
+--*/
+
+#include "Tiano.h"
+#include EFI_PROTOCOL_DEFINITION (SecurityPolicy)
+
+EFI_GUID gEfiSecurityPolicyProtocolGuid = EFI_SECURITY_POLICY_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiSecurityPolicyProtocolGuid, "Security Policy protocol", "Security Policy protocol");
+
diff --git a/EDK/Foundation/Framework/Protocol/SecurityPolicy/SecurityPolicy.h b/EDK/Foundation/Framework/Protocol/SecurityPolicy/SecurityPolicy.h
new file mode 100644
index 0000000..56feac9
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/SecurityPolicy/SecurityPolicy.h
@@ -0,0 +1,33 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ SecurityPolicy.h
+
+Abstract:
+
+ Security Policy protocol as defined in the DXE CIS
+
+--*/
+
+#ifndef _SECURITY_POLICY_H_
+#define _SECURITY_POLICY_H_
+
+//
+// Security policy protocol GUID definition
+//
+#define EFI_SECURITY_POLICY_PROTOCOL_GUID \
+ {0x78E4D245, 0xCD4D, 0x4a05, 0xA2, 0xBA, 0x47, 0x43, 0xE8, 0x6C, 0xFC, 0xAB}
+
+extern EFI_GUID gEfiSecurityPolicyProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Protocol/Smbus/Smbus.c b/EDK/Foundation/Framework/Protocol/Smbus/Smbus.c
new file mode 100644
index 0000000..ecdbe14
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/Smbus/Smbus.c
@@ -0,0 +1,31 @@
+/*++
+
+Copyright (c) 1999 - 2002, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ SmBus.c
+
+Abstract:
+
+ EFI SMBUS Protocol
+
+Revision History
+
+--*/
+
+#include "Tiano.h"
+
+#include EFI_PROTOCOL_DEFINITION (Smbus)
+
+EFI_GUID gEfiSmbusProtocolGuid = EFI_SMBUS_HC_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiSmbusProtocolGuid, "SMBUS Protocol", "EFI 2.0 SMBUS Protocol");
diff --git a/EDK/Foundation/Framework/Protocol/Smbus/Smbus.h b/EDK/Foundation/Framework/Protocol/Smbus/Smbus.h
new file mode 100644
index 0000000..067823f
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/Smbus/Smbus.h
@@ -0,0 +1,108 @@
+/*++
+
+Copyright (c) 1999 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ Smbus.h
+
+Abstract:
+
+ EFI SMBUS Protocol
+
+--*/
+
+#ifndef _EFI_SMBUS_H
+#define _EFI_SMBUS_H
+
+#include "EfiSmbus.h"
+
+#define EFI_SMBUS_HC_PROTOCOL_GUID \
+ { \
+ 0xe49d33ed, 0x513d, 0x4634, 0xb6, 0x98, 0x6f, 0x55, 0xaa, 0x75, 0x1c, 0x1b \
+ }
+
+EFI_FORWARD_DECLARATION (EFI_SMBUS_HC_PROTOCOL);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SMBUS_HC_EXECUTE_OPERATION) (
+ IN EFI_SMBUS_HC_PROTOCOL * This,
+ IN EFI_SMBUS_DEVICE_ADDRESS SlaveAddress,
+ IN EFI_SMBUS_DEVICE_COMMAND Command,
+ IN EFI_SMBUS_OPERATION Operation,
+ IN BOOLEAN PecCheck,
+ IN OUT UINTN *Length,
+ IN OUT VOID *Buffer
+ );
+
+//;;## ...AMI_OVERRIDE... Support PI1.x typedef struct {
+//;;## ...AMI_OVERRIDE... Support PI1.x UINT32 VendorSpecificId;
+//;;## ...AMI_OVERRIDE... Support PI1.x UINT16 SubsystemDeviceId;
+//;;## ...AMI_OVERRIDE... Support PI1.x UINT16 SubsystemVendorId;
+//;;## ...AMI_OVERRIDE... Support PI1.x UINT16 Interface;
+//;;## ...AMI_OVERRIDE... Support PI1.x UINT16 DeviceId;
+//;;## ...AMI_OVERRIDE... Support PI1.x UINT16 VendorId;
+//;;## ...AMI_OVERRIDE... Support PI1.x UINT8 VendorRevision;
+//;;## ...AMI_OVERRIDE... Support PI1.x UINT8 DeviceCapabilities;
+//;;## ...AMI_OVERRIDE... Support PI1.x } EFI_SMBUS_UDID;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SMBUS_NOTIFY_FUNCTION) (
+ IN EFI_SMBUS_DEVICE_ADDRESS SlaveAddress,
+ IN UINTN Data
+ );
+
+//
+// If ArpAll is TRUE, SmbusUdid/SlaveAddress is Optional.
+// If FALSE, ArpDevice will enum SmbusUdid and the address will be at SlaveAddress
+//
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SMBUS_HC_PROTOCOL_ARP_DEVICE) (
+ IN EFI_SMBUS_HC_PROTOCOL * This,
+ IN BOOLEAN ArpAll,
+ IN EFI_SMBUS_UDID * SmbusUdid, OPTIONAL
+ IN OUT EFI_SMBUS_DEVICE_ADDRESS * SlaveAddress OPTIONAL
+ );
+
+//;;## ...AMI_OVERRIDE... Support PI1.x typedef struct {
+//;;## ...AMI_OVERRIDE... Support PI1.x EFI_SMBUS_DEVICE_ADDRESS SmbusDeviceAddress;
+//;;## ...AMI_OVERRIDE... Support PI1.x EFI_SMBUS_UDID SmbusDeviceUdid;
+//;;## ...AMI_OVERRIDE... Support PI1.x } EFI_SMBUS_DEVICE_MAP;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SMBUS_HC_PROTOCOL_GET_ARP_MAP) (
+ IN EFI_SMBUS_HC_PROTOCOL * This,
+ IN OUT UINTN *Length,
+ IN OUT EFI_SMBUS_DEVICE_MAP **SmbusDeviceMap
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SMBUS_HC_PROTOCOL_NOTIFY) (
+ IN EFI_SMBUS_HC_PROTOCOL * This,
+ IN EFI_SMBUS_DEVICE_ADDRESS SlaveAddress,
+ IN UINTN Data,
+ IN EFI_SMBUS_NOTIFY_FUNCTION NotifyFunction
+ );
+
+typedef struct _EFI_SMBUS_HC_PROTOCOL {
+ EFI_SMBUS_HC_EXECUTE_OPERATION Execute;
+ EFI_SMBUS_HC_PROTOCOL_ARP_DEVICE ArpDevice;
+ EFI_SMBUS_HC_PROTOCOL_GET_ARP_MAP GetArpMap;
+ EFI_SMBUS_HC_PROTOCOL_NOTIFY Notify;
+} EFI_SMBUS_HC_PROTOCOL;
+
+extern EFI_GUID gEfiSmbusProtocolGuid;
+#endif
diff --git a/EDK/Foundation/Framework/Protocol/SmmAccess/SmmAccess.c b/EDK/Foundation/Framework/Protocol/SmmAccess/SmmAccess.c
new file mode 100644
index 0000000..6a84d40
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/SmmAccess/SmmAccess.c
@@ -0,0 +1,30 @@
+/*++
+
+Copyright (c) 1999 - 2002, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ SmmAccess.c
+
+Abstract:
+
+ This file defines SMM SMRAM abstraction protocol defined by the
+ SMM Component Interface Specification
+
+
+--*/
+
+#include "Tiano.h"
+#include EFI_PROTOCOL_DEFINITION (SmmAccess)
+
+EFI_GUID gEfiSmmAccessProtocolGuid = EFI_SMM_ACCESS_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiSmmAccessProtocolGuid, "SMM Access Protocol", "SMM Access protocol");
diff --git a/EDK/Foundation/Framework/Protocol/SmmAccess/SmmAccess.h b/EDK/Foundation/Framework/Protocol/SmmAccess/SmmAccess.h
new file mode 100644
index 0000000..9dddaca
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/SmmAccess/SmmAccess.h
@@ -0,0 +1,92 @@
+/*++
+
+Copyright (c) 1999 - 2002, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ SmmAccess.h
+
+Abstract:
+
+ This file defines SMM SMRAM Access abstraction protocol defined
+ by the SMM CIS.
+
+--*/
+
+#ifndef _SMM_ACCESS_H_
+#define _SMM_ACCESS_H_
+
+#include EFI_GUID_DEFINITION (SmramMemoryReserve)
+
+EFI_FORWARD_DECLARATION (EFI_SMM_ACCESS_PROTOCOL);
+
+#define EFI_SMM_ACCESS_PROTOCOL_GUID \
+ { \
+ 0x3792095a, 0xe309, 0x4c1e, 0xaa, 0x01, 0x85, 0xf5, 0x65, 0x5a, 0x17, 0xf1 \
+ }
+
+//
+// SMM Access specification constant and types
+//
+// *******************************************************
+// EFI_SMRAM_STATE
+// *******************************************************
+//
+#define EFI_SMRAM_OPEN 0x00000001
+#define EFI_SMRAM_CLOSED 0x00000002
+#define EFI_SMRAM_LOCKED 0x00000004
+#define EFI_CACHEABLE 0x00000008
+#define EFI_ALLOCATED 0x00000010
+
+//
+// SMM Access specification Data Structures
+//
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SMM_OPEN) (
+ IN EFI_SMM_ACCESS_PROTOCOL * This,
+ UINTN DescriptorIndex
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SMM_CLOSE) (
+ IN EFI_SMM_ACCESS_PROTOCOL * This,
+ UINTN DescriptorIndex
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SMM_LOCK) (
+ IN EFI_SMM_ACCESS_PROTOCOL * This,
+ UINTN DescriptorIndex
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SMM_CAPABILITIES) (
+ IN EFI_SMM_ACCESS_PROTOCOL * This,
+ IN OUT UINTN *SmramMapSize,
+ IN OUT EFI_SMRAM_DESCRIPTOR * SmramMap
+ );
+
+typedef struct _EFI_SMM_ACCESS_PROTOCOL {
+ EFI_SMM_OPEN Open;
+ EFI_SMM_CLOSE Close;
+ EFI_SMM_LOCK Lock;
+ EFI_SMM_CAPABILITIES GetCapabilities;
+ BOOLEAN LockState;
+ BOOLEAN OpenState;
+} EFI_SMM_ACCESS_PROTOCOL;
+
+extern EFI_GUID gEfiSmmAccessProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Protocol/SmmBase/SmmBase.c b/EDK/Foundation/Framework/Protocol/SmmBase/SmmBase.c
new file mode 100644
index 0000000..0a3fd01
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/SmmBase/SmmBase.c
@@ -0,0 +1,38 @@
+/*++
+
+Copyright (c) 1999 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ SmmBase.c
+
+Abstract:
+
+ This file defines SMM Base abstraction protocol defined by the
+ SMM Component Interface Specification
+
+
+--*/
+
+#include "Tiano.h"
+#include EFI_PROTOCOL_DEFINITION (SmmBase)
+
+EFI_GUID gEfiSmmBaseProtocolGuid = EFI_SMM_BASE_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiSmmBaseProtocolGuid, "SMM Base Protocol", "SMM Base protocol");
+
+EFI_GUID gEfiSmmCpuIoGuid = EFI_SMM_CPU_IO_GUID;
+
+EFI_GUID_STRING(&gEfiSmmCpuIoGuid, "SMM CPU IO", "SMM CPU IO");
+
+EFI_GUID gEfiSmmCommunicateHeaderGuid = SMM_COMMUNICATE_HEADER_GUID;
+
+EFI_GUID_STRING(&gEfiSmmCommunicateHeaderGuid, "SMM Communicate Header Guid", "SMM Communicate Header Guid");
diff --git a/EDK/Foundation/Framework/Protocol/SmmBase/SmmBase.h b/EDK/Foundation/Framework/Protocol/SmmBase/SmmBase.h
new file mode 100644
index 0000000..19193be
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/SmmBase/SmmBase.h
@@ -0,0 +1,797 @@
+/*++
+
+Copyright (c) 1999 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ SmmBase.h
+
+Abstract:
+
+ This file defines SMM Base abstraction protocol defined by the SMM Architecture
+ Specification. This is the base level of compatiblity for SMM drivers.
+
+--*/
+
+#ifndef _SMM_BASE_H_
+#define _SMM_BASE_H_
+
+#include EFI_PROTOCOL_DEFINITION (DevicePath)
+
+#define EFI_SMM_BASE_PROTOCOL_GUID \
+ { \
+ 0x1390954D, 0xda95, 0x4227, 0x93, 0x28, 0x72, 0x82, 0xc2, 0x17, 0xda, 0xa8 \
+ }
+
+#define EFI_SMM_CPU_IO_GUID \
+ { \
+ 0x5f439a0b, 0x45d8, 0x4682, 0xa4, 0xf4, 0xf0, 0x57, 0x6b, 0x51, 0x34, 0x41 \
+ }
+
+#define SMM_COMMUNICATE_HEADER_GUID \
+ { \
+ 0xF328E36C, 0x23B6, 0x4a95, 0x85, 0x4B, 0x32, 0xE1, 0x95, 0x34, 0xCD, 0x75 \
+ }
+
+//
+// SMM Base specification constant and types
+//
+#define SMM_SMST_SIGNATURE EFI_SIGNATURE_32 ('S', 'M', 'S', 'T')
+#define EFI_SMM_SYSTEM_TABLE_REVISION (0 << 16) | (0x09)
+
+EFI_FORWARD_DECLARATION (EFI_SMM_BASE_PROTOCOL);
+EFI_FORWARD_DECLARATION (EFI_SMM_CPU_IO_INTERFACE);
+EFI_FORWARD_DECLARATION (EFI_SMM_CPU_SAVE_STATE);
+EFI_FORWARD_DECLARATION (EFI_SMM_OPTIONAL_FP_SAVE_STATE);
+EFI_FORWARD_DECLARATION (EFI_SMM_SYSTEM_TABLE);
+
+//
+// *******************************************************
+// EFI_SMM_IO_WIDTH
+// *******************************************************
+//
+typedef enum {
+ SMM_IO_UINT8 = 0,
+ SMM_IO_UINT16 = 1,
+ SMM_IO_UINT32 = 2,
+ SMM_IO_UINT64 = 3
+} EFI_SMM_IO_WIDTH;
+
+//
+// *******************************************************
+// EFI_SMM_IO_ACCESS
+// *******************************************************
+//
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SMM_CPU_IO) (
+ IN EFI_SMM_CPU_IO_INTERFACE * This,
+ IN EFI_SMM_IO_WIDTH Width,
+ IN UINT64 Address,
+ IN UINTN Count,
+ IN OUT VOID *Buffer
+ );
+
+typedef struct {
+ EFI_SMM_CPU_IO Read;
+ EFI_SMM_CPU_IO Write;
+} EFI_SMM_IO_ACCESS;
+
+typedef struct _EFI_SMM_CPU_IO_INTERFACE {
+ EFI_SMM_IO_ACCESS Mem;
+ EFI_SMM_IO_ACCESS Io;
+} EFI_SMM_CPU_IO_INTERFACE;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SMMCORE_ALLOCATE_POOL) (
+ IN EFI_MEMORY_TYPE PoolType,
+ IN UINTN Size,
+ OUT VOID **Buffer
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SMMCORE_FREE_POOL) (
+ IN VOID *Buffer
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SMMCORE_ALLOCATE_PAGES) (
+ IN EFI_ALLOCATE_TYPE Type,
+ IN EFI_MEMORY_TYPE MemoryType,
+ IN UINTN NumberOfPages,
+ OUT EFI_PHYSICAL_ADDRESS * Memory
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SMMCORE_FREE_PAGES) (
+ IN EFI_PHYSICAL_ADDRESS Memory,
+ IN UINTN NumberOfPages
+ );
+
+typedef
+VOID
+(EFIAPI *EFI_AP_PROCEDURE) (
+ IN VOID *Buffer
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SMM_STARTUP_THIS_AP) (
+ IN EFI_AP_PROCEDURE Procedure,
+ IN UINTN CpuNumber,
+ IN OUT VOID *ProcArguments OPTIONAL
+ );
+
+typedef struct _EFI_SMM_CPU_SAVE_STATE {
+ UINT8 Reserved1[248];
+ UINT32 SMBASE;
+ UINT32 SMMRevId;
+ UINT16 IORestart;
+ UINT16 AutoHALTRestart;
+ UINT8 Reserved2[164];
+ UINT32 ES;
+ UINT32 CS;
+ UINT32 SS;
+ UINT32 DS;
+ UINT32 FS;
+ UINT32 GS;
+ UINT32 LDTBase;
+ UINT32 TR;
+ UINT32 DR7;
+ UINT32 DR6;
+ UINT32 EAX;
+ UINT32 ECX;
+ UINT32 EDX;
+ UINT32 EBX;
+ UINT32 ESP;
+ UINT32 EBP;
+ UINT32 ESI;
+ UINT32 EDI;
+ UINT32 EIP;
+ UINT32 EFLAGS;
+ UINT32 CR3;
+ UINT32 CR0;
+} EFI_SMM_CPU_SAVE_STATE;
+
+typedef struct {
+ UINT8 Reserved19[760]; // FC00
+ UINT32 SMBASE; // FEF8
+ UINT32 REVID; // FEFC
+ UINT16 HALT_RESTART; // FF00
+ UINT16 IO_RESTART; // FF02
+ UINT32 Reserved17[22]; // FF58, 54, 50, 4c, 48, 44, 40, 3c, 38, 34, 30, 2c, 28, 24, 20, 1c, 18, 14, 10, 0c, 08, 04
+ UINT32 EAX; // FF5C
+ UINT32 Reserved16; // FF60
+ UINT32 ECX; // FF64
+ UINT32 Reserved15; // FF68
+ UINT32 EDX; // FF6C
+ UINT32 Reserved14; // FF70
+ UINT32 EBX; // FF74
+ UINT32 Reserved13; // FF78
+ UINT32 ESP; // FF7C
+ UINT32 Reserved12; // FF80
+ UINT32 EBP; // FF84
+ UINT32 Reserved11; // FF88
+ UINT32 ESI; // FF8C
+ UINT32 Reserved9; // FF90
+ UINT32 EDI; // FF94
+ UINT32 Reserved8; // FF98
+ UINT32 IO_MEM_ADDR; // FF9C
+ UINT32 Reserved7; // FFA0
+ UINT32 IO_MISC; // FFA4
+ UINT32 ES_SEL; // FFA8
+ UINT32 CS_SEL; // FFAC
+ UINT32 SS_SEL; // FFB0
+ UINT32 DS_SEL; // FFB4
+ UINT32 FS_SEL; // FFB8
+ UINT32 GS_SEL; // FFBC
+ UINT32 LDTR_SEL; // FFC0
+ UINT32 TR_SEL; // FFC4
+ UINT32 DR7; // FFC8
+ UINT32 Reserved6; // FFCC
+ UINT32 DR6; // FFD0
+ UINT32 Reserved5; // FFD4
+ UINT32 EIP; // FFD8
+ UINT32 Reserved4; // FFDC
+ UINT32 EFER; // FFE0
+ UINT32 Reserved3; // FFE4
+ UINT32 EFLAGS; // FFE8
+ UINT32 Reserved2; // FFEC
+ UINT32 CR3; // FFF0
+ UINT32 Reserved1; // FFF4
+ UINT32 CR0; // FFF8
+ UINT32 Reserved0; // FFFC
+} EFI_SMM_CPU_CT_SAVE_STATE;
+
+typedef struct {
+ UINT8 Reserved26[464]; // FC00 - FDCF
+ UINT32 GdtrUpperBase; // FDD0
+ UINT32 LdtrUpperBase; // FDD4
+ UINT32 IdtrUpperBase; // FDD8
+ UINT32 Reserved25; // FDDC - FDDF
+ UINT64 IoRdi; // FDE0
+ UINT64 IoRip; // FDE8
+ UINT64 IoRcx; // FDF0
+ UINT64 IoRsi; // FDF8
+ UINT8 Reserved24[64]; // FE00 - FE3F
+ UINT64 Cr4; // FE40
+ UINT8 Reserved23[68]; // FE48 - FE8B
+ UINT32 GdtrBase; // FE8C
+ UINT32 Reserved22; // FE90
+ UINT32 IdtrBase; // FE94
+ UINT32 Reserved21; // FE98
+ UINT32 LdtrBase; // FE9C
+ UINT32 Reserved20; // FEA0
+ UINT8 Reserved19[84]; // FEA4 - FEF7
+ UINT32 Smbase; // FEF8
+ UINT32 RevId; // FEFC
+ UINT16 IoRestart; // FF00
+ UINT16 HaltRestart; // FF02
+ UINT8 Reserved18[24]; // FF04 - FF1B
+ UINT32 R15; // FF1C
+ UINT32 Reserved17; // FE20
+ UINT32 R14; // FF24
+ UINT32 Reserved16; // FE28
+ UINT32 R13; // FF2C
+ UINT32 Reserved15; // FE30
+ UINT32 R12; // FF34
+ UINT32 Reserved14; // FE38
+ UINT32 R11; // FF3C
+ UINT32 Reserved13; // FE40
+ UINT32 R10; // FF44
+ UINT32 Reserved12; // FE48
+ UINT32 R9; // FF4C
+ UINT32 Reserved11; // FE50
+ UINT32 R8; // FF54
+ UINT32 Reserved10; // FE58
+ UINT32 Rax; // FF5C
+ UINT32 Reserved9; // FE60
+ UINT32 Rcx; // FF64
+ UINT32 Reserved8; // FE68
+ UINT32 Rdx; // FF6C
+ UINT32 Reserved7; // FE70
+ UINT32 Rbx; // FF74
+ UINT32 Reserved6; // FE78
+ UINT32 Rsp; // FF7C
+ UINT32 Reserved5; // FE80
+ UINT32 Rbp; // FF84
+ UINT32 Reserved4; // FE88
+ UINT32 Rsi; // FF8C
+ UINT32 Reserved3; // FE90
+ UINT32 Rdi; // FF94
+ UINT32 Reserved2; // FE98
+ UINT32 IoMemAddr; // FF9C
+ UINT32 Reserved1; // FEA0
+ UINT32 IoMiscInfo; // FFA4
+ UINT32 EsSel; // FFA8
+ UINT32 CsSel; // FFAC
+ UINT32 SsSel; // FFB0
+ UINT32 DsSel; // FFB4
+ UINT32 FsSel; // FFB8
+ UINT32 GsSel; // FFBC
+ UINT32 LdtrSel; // FFC0
+ UINT32 TrSel; // FFC4
+ UINT64 Dr7; // FFC8
+ UINT64 Dr6; // FFD0
+ UINT32 Rip; // FFD8
+ UINT32 Reserved0; // FFDC
+ UINT64 Efr; // FFE0
+ UINT64 RFlags; // FFE8
+ UINT64 Cr3; // FFF0
+ UINT64 Cr0; // FFF8
+} EFI_SMM_CPU_MEROM_SAVE_STATE;
+
+
+typedef struct {
+ UINT8 Reserved14[0x228]; // FC00-FE28
+ UINT32 IO_EIP; // FE28
+ UINT8 Reserved13[0x14]; // FE2C-FE40
+ UINT32 CR4; // FE40
+ UINT8 Reserved12[0x48]; // FE44-FE8C
+ UINT32 GDT_BASE; // FE8C
+ UINT8 Reserved11[0xC]; // FE90-FE9C
+ UINT32 LDT_BASE; // FE9C
+ UINT8 Reserved10[0x58]; // FEA0-FEF8
+ UINT32 SMBASE;
+ UINT32 REVID;
+ UINT16 IO_RESTART;
+ UINT16 HALT_RESTART;
+ UINT8 Reserved9[0xA4];
+
+ UINT16 ES;
+ UINT16 Reserved8;
+ UINT16 CS;
+ UINT16 Reserved7;
+ UINT16 SS;
+ UINT16 Reserved6;
+ UINT16 DS;
+ UINT16 Reserved5;
+ UINT16 FS;
+ UINT16 Reserved4;
+ UINT16 GS;
+ UINT16 Reserved3;
+ UINT32 Reserved2;
+ UINT16 TR;
+ UINT16 Reserved1;
+ UINT32 DR7;
+ UINT32 DR6;
+ UINT32 EAX;
+ UINT32 ECX;
+ UINT32 EDX;
+ UINT32 EBX;
+ UINT32 ESP;
+ UINT32 EBP;
+ UINT32 ESI;
+ UINT32 EDI;
+ UINT32 EIP;
+ UINT32 EFLAGS;
+ UINT32 CR3;
+ UINT32 CR0;
+} EFI_SMM_CPU_CT_NOT_ENABLED_SAVE_STATE;
+
+typedef struct _EFI_SMM_OPTIONAL_FP_SAVE_STATE {
+ UINT16 Fcw;
+ UINT16 Fsw;
+ UINT16 Ftw;
+ UINT16 Opcode;
+ UINT32 Eip;
+ UINT16 Cs;
+ UINT16 Rsvd1;
+ UINT32 DataOffset;
+ UINT16 Ds;
+ UINT8 Rsvd2[10];
+ UINT8 St0Mm0[10], Rsvd3[6];
+ UINT8 St0Mm1[10], Rsvd4[6];
+ UINT8 St0Mm2[10], Rsvd5[6];
+ UINT8 St0Mm3[10], Rsvd6[6];
+ UINT8 St0Mm4[10], Rsvd7[6];
+ UINT8 St0Mm5[10], Rsvd8[6];
+ UINT8 St0Mm6[10], Rsvd9[6];
+ UINT8 St0Mm7[10], Rsvd10[6];
+ UINT8 Rsvd11[22 * 16];
+} EFI_SMM_OPTIONAL_FP_SAVE_STATE;
+
+typedef struct _EFI_SMM_OPTIONAL_FP_SAVE_STATE32 {
+ UINT16 Fcw;
+ UINT16 Fsw;
+ UINT16 Ftw;
+ UINT16 Opcode;
+ UINT32 Eip;
+ UINT16 Cs;
+ UINT16 Rsvd1;
+ UINT32 DataOffset;
+ UINT16 Ds;
+ UINT8 Reserved2[10];
+ UINT8 St0Mm0[10], Rsvd3[6];
+ UINT8 St1Mm1[10], Rsvd4[6];
+ UINT8 St2Mm2[10], Rsvd5[6];
+ UINT8 St3Mm3[10], Rsvd6[6];
+ UINT8 St4Mm4[10], Rsvd7[6];
+ UINT8 St5Mm5[10], Rsvd8[6];
+ UINT8 St6Mm6[10], Rsvd9[6];
+ UINT8 St7Mm7[10], Rsvd10[6];
+ UINT8 Xmm0[16];
+ UINT8 Xmm1[16];
+ UINT8 Xmm2[16];
+ UINT8 Xmm3[16];
+ UINT8 Xmm4[16];
+ UINT8 Xmm5[16];
+ UINT8 Xmm6[16];
+ UINT8 Xmm7[16];
+ UINT8 Rsvd11[14 * 16];
+} EFI_SMM_OPTIONAL_FP_SAVE_STATE32;
+
+typedef struct _EFI_SMM_OPTIONAL_FP_SAVE_STATE64 {
+ UINT16 Fcw;
+ UINT16 Fsw;
+ UINT16 Ftw;
+ UINT16 Opcode;
+ UINT64 Rip;
+ UINT64 DataOffset;
+ UINT8 Rsvd1[8];
+ UINT8 St0Mm0[10], Rsvd2[6];
+ UINT8 St1Mm1[10], Rsvd3[6];
+ UINT8 St2Mm2[10], Rsvd4[6];
+ UINT8 St3Mm3[10], Rsvd5[6];
+ UINT8 St4Mm4[10], Rsvd6[6];
+ UINT8 St5Mm5[10], Rsvd7[6];
+ UINT8 St6Mm6[10], Rsvd8[6];
+ UINT8 St7Mm7[10], Rsvd9[6];
+ UINT8 Xmm0[16];
+ UINT8 Xmm1[16];
+ UINT8 Xmm2[16];
+ UINT8 Xmm3[16];
+ UINT8 Xmm4[16];
+ UINT8 Xmm5[16];
+ UINT8 Xmm6[16];
+ UINT8 Xmm7[16];
+ UINT8 Xmm8[16];
+ UINT8 Xmm9[16];
+ UINT8 Xmm10[16];
+ UINT8 Xmm11[16];
+ UINT8 Xmm12[16];
+ UINT8 Xmm13[16];
+ UINT8 Xmm14[16];
+ UINT8 Xmm15[16];
+ UINT8 Rsvd10[6 * 16];
+} EFI_SMM_OPTIONAL_FP_SAVE_STATE64;
+
+struct _EFI_SMM_SYSTEM_TABLE;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SMM_INSTALL_CONFIGURATION_TABLE) (
+ IN EFI_SMM_SYSTEM_TABLE * SystemTable,
+ IN EFI_GUID * Guid,
+ IN VOID *Table,
+ IN UINTN TableSize
+ )
+/*++
+
+ Routine Description:
+ The SmmInstallConfigurationTable() function is used to maintain the list
+ of configuration tables that are stored in the System Management System
+ Table. The list is stored as an array of (GUID, Pointer) pairs. The list
+ must be allocated from pool memory with PoolType set to EfiRuntimeServicesData.
+
+ Arguments:
+ SystemTable - A pointer to the SMM System Table.
+ Guid - A pointer to the GUID for the entry to add, update, or remove.
+ Table - A pointer to the buffer of the table to add.
+ TableSize - The size of the table to install.
+
+ Returns:
+ EFI_SUCCESS - The (Guid, Table) pair was added, updated, or removed.
+ EFI_INVALID_PARAMETER - Guid is not valid.
+ EFI_NOT_FOUND - An attempt was made to delete a non-existent entry.
+ EFI_OUT_OF_RESOURCES - There is not enough memory available to complete the operation.
+
+--*/
+;
+
+//
+// System Management System Table (SMST)
+//
+typedef struct _EFI_SMM_SYSTEM_TABLE {
+ EFI_TABLE_HEADER Hdr;
+
+ CHAR16 *SmmFirmwareVendor;
+ UINT32 SmmFirmwareRevision;
+
+ EFI_SMM_INSTALL_CONFIGURATION_TABLE SmmInstallConfigurationTable;
+
+ //
+ // I/O Services
+ //
+ EFI_GUID EfiSmmCpuIoGuid;
+ EFI_SMM_CPU_IO_INTERFACE SmmIo;
+
+ //
+ // Runtime memory service
+ //
+ EFI_SMMCORE_ALLOCATE_POOL SmmAllocatePool;
+ EFI_SMMCORE_FREE_POOL SmmFreePool;
+ EFI_SMMCORE_ALLOCATE_PAGES SmmAllocatePages;
+ EFI_SMMCORE_FREE_PAGES SmmFreePages;
+
+ //
+ // MP service
+ //
+ EFI_SMM_STARTUP_THIS_AP SmmStartupThisAp;
+
+ //
+ // CPU information records
+ //
+ UINTN CurrentlyExecutingCpu;
+ UINTN NumberOfCpus;
+ EFI_SMM_CPU_SAVE_STATE *CpuSaveState;
+ EFI_SMM_OPTIONAL_FP_SAVE_STATE *CpuOptionalFloatingPointState;
+
+ //
+ // Extensibility table
+ //
+ UINTN NumberOfTableEntries;
+ EFI_CONFIGURATION_TABLE *SmmConfigurationTable;
+
+} EFI_SMM_SYSTEM_TABLE;
+
+//
+// SMM Handler Definition
+//
+#define EFI_HANDLER_SUCCESS 0x0000
+#define EFI_HANDLER_CRITICAL_EXIT 0x0001
+#define EFI_HANDLER_SOURCE_QUIESCED 0x0002
+#define EFI_HANDLER_SOURCE_PENDING 0x0003
+
+//
+// Structure of Communicate Buffer
+//
+typedef struct {
+ EFI_GUID HeaderGuid;
+ UINTN MessageLength;
+ UINT8 Data[1];
+} EFI_SMM_COMMUNICATE_HEADER;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SMM_HANDLER_ENTRY_POINT) (
+ IN EFI_HANDLE SmmImageHandle,
+ IN OUT VOID *CommunicationBuffer OPTIONAL,
+ IN OUT UINTN *SourceSize OPTIONAL
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SMM_CALLBACK_ENTRY_POINT) (
+ IN EFI_HANDLE SmmImageHandle,
+ IN OUT VOID *CommunicationBuffer OPTIONAL,
+ IN OUT UINTN *SourceSize OPTIONAL
+ );
+
+typedef struct {
+ EFI_HANDLE SmmHandler;
+ EFI_DEVICE_PATH_PROTOCOL *HandlerDevicePath;
+} EFI_HANDLER_DESCRIPTOR;
+
+//
+// SMM Base Protocol Definition
+//
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SMM_REGISTER_HANDLER) (
+ IN EFI_SMM_BASE_PROTOCOL * This,
+ IN EFI_DEVICE_PATH_PROTOCOL * FilePath,
+ IN VOID *SourceBuffer OPTIONAL,
+ IN UINTN SourceSize,
+ OUT EFI_HANDLE * ImageHandle,
+ IN BOOLEAN LegacyIA32Binary OPTIONAL
+ )
+/*++
+
+ Routine Description:
+ Register a given driver into SMRAM. This is the equivalent of performing
+ the LoadImage/StartImage into System Management Mode.
+
+ Arguments:
+ This - Protocol instance pointer.
+ SourceBuffer - Optional source buffer in case of the image file
+ being in memory.
+ SourceSize - Size of the source image file, if in memory.
+ ImageHandle - Pointer to the handle that reflects the driver
+ loaded into SMM.
+ LegacyIA32Binary - The binary image to load is legacy 16 bit code.
+
+ Returns:
+ EFI_SUCCESS - The operation was successful.
+ EFI_OUT_OF_RESOURCES - There were no additional SMRAM resources to load the handler
+ EFI_UNSUPPORTED - This platform does not support 16-bit handlers.
+ EFI_UNSUPPORTED - In runtime.
+ EFI_INVALID_PARAMETER - The handlers was not the correct image type
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SMM_UNREGISTER_HANDLER) (
+ IN EFI_SMM_BASE_PROTOCOL * This,
+ IN EFI_HANDLE ImageHandle
+ )
+/*++
+
+ Routine Description:
+ Remove a given driver SMRAM. This is the equivalent of performing
+ the UnloadImage System Management Mode.
+
+ Arguments:
+ This - Protocol instance pointer.
+ ImageHandle - Pointer to the handle that reflects the driver
+ loaded into SMM.
+
+ Returns:
+ EFI_SUCCESS - The operation was successful
+ EFI_INVALID_PARAMETER - The handler did not exist
+ EFI_UNSUPPORTED - In runtime.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SMM_COMMUNICATE) (
+ IN EFI_SMM_BASE_PROTOCOL * This,
+ IN EFI_HANDLE ImageHandle,
+ IN OUT VOID *CommunicationBuffer,
+ IN OUT UINTN *SourceSize
+ )
+/*++
+
+ Routine Description:
+ The SMM Inter-module Communicate Service Communicate() function
+ provides a services to send/received messages from a registered
+ EFI service. The BASE protocol driver is responsible for doing
+ any of the copies such that the data lives in boot-service accessible RAM.
+
+ Arguments:
+ This - Protocol instance pointer.
+ ImageHandle - Pointer to the handle that reflects the driver
+ loaded into SMM.
+ CommunicationBuffer - Pointer to the buffer to convey into SMRAM.
+ SourceSize - Size of the contents of buffer..
+
+ Returns:
+ EFI_SUCCESS - The message was successfully posted
+ EFI_INVALID_PARAMETER - The buffer was NULL
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SMM_CALLBACK_SERVICE) (
+ IN EFI_SMM_BASE_PROTOCOL * This,
+ IN EFI_HANDLE SmmImageHandle,
+ IN EFI_SMM_CALLBACK_ENTRY_POINT CallbackAddress,
+ IN BOOLEAN MakeLast OPTIONAL,
+ IN BOOLEAN FloatingPointSave OPTIONAL
+ )
+/*++
+
+ Routine Description:
+ Register a callback to execute within SMM.
+ This allows receipt of messages created with the Boot Service COMMUNICATE.
+
+ Arguments:
+ This - Protocol instance pointer.
+ CallbackAddress - Address of the callback service
+ MakeFirst - If present, will stipulate that the handler is posted
+ to be the first module executed in the dispatch table.
+ MakeLast - If present, will stipulate that the handler is posted
+ to be last executed in the dispatch table.
+ FloatingPointSave - This is an optional parameter which informs the
+ EFI_SMM_ACCESS_PROTOCOL Driver core if it needs to save
+ the floating point register state. If any of the handlers
+ require this, then the state will be saved for all of the handlers.
+
+ Returns:
+ EFI_SUCCESS - The operation was successful
+ EFI_OUT_OF_RESOURCES - Not enough space in the dispatch queue
+ EFI_UNSUPPORTED - In runtime.
+ EFI_UNSUPPORTED - Not in SMM.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SMM_ALLOCATE_POOL) (
+ IN EFI_SMM_BASE_PROTOCOL * This,
+ IN EFI_MEMORY_TYPE PoolType,
+ IN UINTN Size,
+ OUT VOID **Buffer
+ )
+/*++
+
+ Routine Description:
+ The SmmAllocatePool() function allocates a memory region of Size bytes from memory of
+ type PoolType and returns the address of the allocated memory in the location referenced
+ by Buffer. This function allocates pages from EFI SMRAM Memory as needed to grow the
+ requested pool type. All allocations are eight-byte aligned.
+
+ Arguments:
+ This - Protocol instance pointer.
+ PoolType - The type of pool to allocate.
+ The only supported type is EfiRuntimeServicesData;
+ the interface will internally map this runtime request to SMRAM.
+ Size - The number of bytes to allocate from the pool.
+ Buffer - A pointer to a pointer to the allocated buffer if the call
+ succeeds; undefined otherwise.
+
+ Returns:
+ EFI_SUCCESS - The requested number of bytes was allocated.
+ EFI_OUT_OF_RESOURCES - The pool requested could not be allocated.
+ EFI_INVALID_PARAMETER - PoolType was invalid.
+ EFI_UNSUPPORTED - In runtime.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SMM_FREE_POOL) (
+ IN EFI_SMM_BASE_PROTOCOL * This,
+ IN VOID *Buffer
+ )
+/*++
+
+ Routine Description:
+ The SmmFreePool() function returns the memory specified by Buffer to the system.
+ On return, the memory's type is EFI SMRAM Memory. The Buffer that is freed must
+ have been allocated by SmmAllocatePool().
+
+ Arguments:
+ This - Protocol instance pointer.
+ Buffer - Pointer to the buffer allocation.
+
+ Returns:
+ EFI_SUCCESS - The memory was returned to the system.
+ EFI_INVALID_PARAMETER - Buffer was invalid.
+ EFI_UNSUPPORTED - In runtime.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SMM_INSIDE_OUT) (
+ IN EFI_SMM_BASE_PROTOCOL * This,
+ OUT BOOLEAN *InSmm
+ )
+/*++
+
+ Routine Description:
+ This routine tells caller if execution context is SMM or not.
+
+ Arguments:
+ This - Protocol instance pointer.
+
+ Returns:
+ EFI_SUCCESS - The operation was successful
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SMM_GET_SMST_LOCATION) (
+ IN EFI_SMM_BASE_PROTOCOL * This,
+ IN OUT EFI_SMM_SYSTEM_TABLE **Smst
+ )
+/*++
+
+ Routine Description:
+ The GetSmstLocation() function returns the locatin of the System Management
+ Service Table. The use of the API is such that a driver can discover the
+ location of the SMST in its entry point and then cache it in some driver
+ global variable so that the SMST can be invoked in subsequent callbacks.
+
+ Arguments:
+ This - Protocol instance pointer.
+ Smst - Pointer to the SMST.
+
+ Returns:
+ EFI_SUCCESS - The operation was successful
+ EFI_INVALID_PARAMETER - Smst was invalid.
+ EFI_UNSUPPORTED - Not in SMM.
+
+--*/
+;
+
+typedef struct _EFI_SMM_BASE_PROTOCOL {
+ EFI_SMM_REGISTER_HANDLER Register;
+ EFI_SMM_UNREGISTER_HANDLER UnRegister;
+ EFI_SMM_COMMUNICATE Communicate;
+ EFI_SMM_CALLBACK_SERVICE RegisterCallback;
+ EFI_SMM_INSIDE_OUT InSmm;
+ EFI_SMM_ALLOCATE_POOL SmmAllocatePool;
+ EFI_SMM_FREE_POOL SmmFreePool;
+ EFI_SMM_GET_SMST_LOCATION GetSmstLocation;
+} EFI_SMM_BASE_PROTOCOL;
+
+extern EFI_GUID gEfiSmmBaseProtocolGuid;
+extern EFI_GUID gEfiSmmCpuIoGuid;
+extern EFI_GUID gEfiSmmCommunicateHeaderGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Protocol/SmmControl/SmmControl.c b/EDK/Foundation/Framework/Protocol/SmmControl/SmmControl.c
new file mode 100644
index 0000000..78e1f61
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/SmmControl/SmmControl.c
@@ -0,0 +1,30 @@
+/*++
+
+Copyright (c) 1999 - 2002, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ SmmControl.c
+
+Abstract:
+
+ This file defines SMM Control abstraction protocol defined by the
+ SMM Component Interface Specification
+
+
+--*/
+
+#include "Tiano.h"
+#include EFI_PROTOCOL_DEFINITION (SmmControl)
+
+EFI_GUID gEfiSmmControlProtocolGuid = EFI_SMM_CONTROL_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiSmmControlProtocolGuid, "SMM Control Protocol", "SMM Control protocol");
diff --git a/EDK/Foundation/Framework/Protocol/SmmControl/SmmControl.h b/EDK/Foundation/Framework/Protocol/SmmControl/SmmControl.h
new file mode 100644
index 0000000..ae7d691
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/SmmControl/SmmControl.h
@@ -0,0 +1,79 @@
+/*++
+
+Copyright (c) 1999 - 2002, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ SmmControl.h
+
+Abstract:
+
+ This file defines SMM Control abstraction protocol defined
+ by the SMM CIS.
+
+--*/
+
+#ifndef _SMM_CONTROL_H_
+#define _SMM_CONTROL_H_
+
+EFI_FORWARD_DECLARATION (EFI_SMM_CONTROL_PROTOCOL);
+
+#define EFI_SMM_CONTROL_PROTOCOL_GUID \
+ { \
+ 0x8d12e231, 0xc667, 0x4fd1, 0x98, 0xf2, 0x24, 0x49, 0xa7, 0xe7, 0xb2, 0xe5 \
+ }
+
+//
+// SMM Control specification constant and types
+//
+// typedef EFI_SMM_PERIOD UINTN
+//
+// SMM Access specification Data Structures
+//
+typedef struct {
+ UINT8 SmiTriggerRegister;
+ UINT8 SmiDataRegister;
+} EFI_SMM_CONTROL_REGISTER;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SMM_ACTIVATE) (
+ IN EFI_SMM_CONTROL_PROTOCOL * This,
+ IN OUT INT8 *ArgumentBuffer OPTIONAL,
+ IN OUT UINTN *ArgumentBufferSize OPTIONAL,
+ IN BOOLEAN Periodic OPTIONAL,
+ IN UINTN ActivationInterval OPTIONAL
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SMM_DEACTIVATE) (
+ IN EFI_SMM_CONTROL_PROTOCOL * This,
+ IN BOOLEAN Periodic OPTIONAL
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SMM_GET_REGISTER_INFO) (
+ IN EFI_SMM_CONTROL_PROTOCOL * This,
+ IN OUT EFI_SMM_CONTROL_REGISTER * SmiRegister
+ );
+
+typedef struct _EFI_SMM_CONTROL_PROTOCOL {
+ EFI_SMM_ACTIVATE Trigger;
+ EFI_SMM_DEACTIVATE Clear;
+ EFI_SMM_GET_REGISTER_INFO GetRegisterInfo;
+ UINTN MinimumTriggerPeriod;
+} EFI_SMM_CONTROL_PROTOCOL;
+
+extern EFI_GUID gEfiSmmControlProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Protocol/SmmCpuState/CpuSaveState.h b/EDK/Foundation/Framework/Protocol/SmmCpuState/CpuSaveState.h
new file mode 100644
index 0000000..1b5c774
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/SmmCpuState/CpuSaveState.h
@@ -0,0 +1,150 @@
+/*++
+
+Copyright (c) 2005, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ CpuSaveState.h
+
+Abstract:
+
+ Define data structures used by EFI_SMM_CPU_SAVE_STATE protocol.
+
+Revision History
+
+++*/
+
+#ifndef _CPUSAVESTATE_H_
+#define _CPUSAVESTATE_H_
+
+typedef unsigned char ASM_UINT8;
+typedef ASM_UINT8 ASM_BOOL;
+typedef unsigned short ASM_UINT16;
+typedef unsigned long ASM_UINT32;
+
+#ifdef _H2INC
+typedef double ASM_UINT64;
+#else
+typedef unsigned __int64 ASM_UINT64;
+#endif
+
+#pragma pack (push)
+#pragma pack (1)
+
+typedef struct _EFI_SMM_CPU_STATE32 {
+ ASM_UINT8 Reserved1[0xf8]; // fe00h
+ ASM_UINT32 SMBASE; // fef8h
+ ASM_UINT32 SMMRevId; // fefch
+ ASM_UINT16 IORestart; // ff00h
+ ASM_UINT16 AutoHALTRestart; // ff02h
+ ASM_UINT32 IEDBASE; // ff04h
+ ASM_UINT8 Reserved2[0x98]; // ff08h
+ ASM_UINT32 IOMemAddr; // ffa0h
+ ASM_UINT32 IOMisc; // ffa4h
+ ASM_UINT32 _ES;
+ ASM_UINT32 _CS;
+ ASM_UINT32 _SS;
+ ASM_UINT32 _DS;
+ ASM_UINT32 _FS;
+ ASM_UINT32 _GS;
+ ASM_UINT32 _LDTBase;
+ ASM_UINT32 _TR;
+ ASM_UINT32 _DR7;
+ ASM_UINT32 _DR6;
+ ASM_UINT32 _EAX;
+ ASM_UINT32 _ECX;
+ ASM_UINT32 _EDX;
+ ASM_UINT32 _EBX;
+ ASM_UINT32 _ESP;
+ ASM_UINT32 _EBP;
+ ASM_UINT32 _ESI;
+ ASM_UINT32 _EDI;
+ ASM_UINT32 _EIP;
+ ASM_UINT32 _EFLAGS;
+ ASM_UINT32 _CR3;
+ ASM_UINT32 _CR0;
+} EFI_SMM_CPU_STATE32;
+
+typedef struct _EFI_SMM_CPU_STATE64 {
+ ASM_UINT8 Reserved1[0x1d0]; // fc00h
+ ASM_UINT32 GdtBaseHiDword; // fdd0h
+ ASM_UINT32 LdtBaseHiDword; // fdd4h
+ ASM_UINT32 IdtBaseHiDword; // fdd8h
+ ASM_UINT8 Reserved2[0xc]; // fddch
+ ASM_UINT64 IO_EIP; // fde8h
+ ASM_UINT8 Reserved3[0x50]; // fdf0h
+ ASM_UINT32 _CR4; // fe40h
+ ASM_UINT8 Reserved4[0x48]; // fe44h
+ ASM_UINT32 GdtBaseLoDword; // fe8ch
+ ASM_UINT32 GdtLimit; // fe90h
+ ASM_UINT32 IdtBaseLoDword; // fe94h
+ ASM_UINT32 IdtLimit; // fe98h
+ ASM_UINT32 LdtBaseLoDword; // fe9ch
+ ASM_UINT32 LdtLimit; // fea0h
+ ASM_UINT32 LdtInfo; // fea4h
+ ASM_UINT8 Reserved5[0x50]; // fea8h
+ ASM_UINT32 SMBASE; // fef8h
+ ASM_UINT32 SMMRevId; // fefch
+ ASM_UINT16 IORestart; // ff00h
+ ASM_UINT16 AutoHALTRestart; // ff02h
+ ASM_UINT32 IEDBASE; // ff04h
+ ASM_UINT8 Reserved6[0x14]; // ff08h
+ ASM_UINT64 _R15; // ff1ch
+ ASM_UINT64 _R14;
+ ASM_UINT64 _R13;
+ ASM_UINT64 _R12;
+ ASM_UINT64 _R11;
+ ASM_UINT64 _R10;
+ ASM_UINT64 _R9;
+ ASM_UINT64 _R8;
+ ASM_UINT64 _RAX; // ff5ch
+ ASM_UINT64 _RCX;
+ ASM_UINT64 _RDX;
+ ASM_UINT64 _RBX;
+ ASM_UINT64 _RSP;
+ ASM_UINT64 _RBP;
+ ASM_UINT64 _RSI;
+ ASM_UINT64 _RDI;
+ ASM_UINT64 IOMemAddr; // ff9ch
+ ASM_UINT32 IOMisc; // ffa4h
+ ASM_UINT32 _ES; // ffa8h
+ ASM_UINT32 _CS;
+ ASM_UINT32 _SS;
+ ASM_UINT32 _DS;
+ ASM_UINT32 _FS;
+ ASM_UINT32 _GS;
+ ASM_UINT32 _LDTR; // ffc0h
+ ASM_UINT32 _TR;
+ ASM_UINT64 _DR7; // ffc8h
+ ASM_UINT64 _DR6;
+ ASM_UINT64 _RIP; // ffd8h
+ ASM_UINT64 IA32_EFER; // ffe0h
+ ASM_UINT64 _RFLAGS; // ffe8h
+ ASM_UINT64 _CR3; // fff0h
+ ASM_UINT64 _CR0; // fff8h
+} EFI_SMM_CPU_STATE64;
+
+#pragma warning (push)
+#pragma warning (disable: 4201)
+typedef union _EFI_SMM_CPU_STATE {
+ struct {
+ ASM_UINT8 Reserved[0x200];
+ EFI_SMM_CPU_STATE32 x86;
+ };
+ EFI_SMM_CPU_STATE64 x64;
+} EFI_SMM_CPU_STATE;
+#pragma warning (pop)
+
+#pragma pack (pop)
+
+#define EFI_SMM_MIN_REV_ID_x64 0x30006
+
+#endif
diff --git a/EDK/Foundation/Framework/Protocol/SmmCpuState/SmmCpuState.c b/EDK/Foundation/Framework/Protocol/SmmCpuState/SmmCpuState.c
new file mode 100644
index 0000000..6057a43
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/SmmCpuState/SmmCpuState.c
@@ -0,0 +1,30 @@
+/*++
+
+Copyright (c) 2005, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ SmmCpuState.c
+
+Abstract:
+
+ Protocol definition for EFI_SMM_CPU_SAVE_STATE protocol
+
+Revision History
+
+--*/
+
+#include "Tiano.h"
+#include EFI_PROTOCOL_DEFINITION (SmmCpuState)
+
+EFI_GUID gEfiSmmCpuSaveStateProtocolGuid = EFI_SMM_CPU_SAVE_STATE_PROTOCOL_GUID;
+
+EFI_GUID_STRING (&gEfiSmmCpuSaveStateProtocolGuid, "SMM CPU Save State Protocol", "SMM CPU Save State Protocol");
diff --git a/EDK/Foundation/Framework/Protocol/SmmCpuState/SmmCpuState.h b/EDK/Foundation/Framework/Protocol/SmmCpuState/SmmCpuState.h
new file mode 100644
index 0000000..a5f0324
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/SmmCpuState/SmmCpuState.h
@@ -0,0 +1,43 @@
+/*++
+
+Copyright (c) 2005, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ SmmCpuState.h
+
+Abstract:
+
+ Protocol definition for EFI_SMM_CPU_SAVE_STATE protocol
+
+Revision History
+
+--*/
+
+#ifndef _SMMSAVESTATE_H_
+#define _SMMSAVESTATE_H_
+
+#include "CpuSaveState.h"
+
+//
+// Global ID for the Sx SMI Protocol
+//
+// {21F302AD-6E94-471b-84BC-B14800403A1D}
+#define EFI_SMM_CPU_SAVE_STATE_PROTOCOL_GUID \
+ { 0x21f302ad, 0x6e94, 0x471b, 0x84, 0xbc, 0xb1, 0x48, 0x0, 0x40, 0x3a, 0x1d }
+
+typedef struct _EFI_SMM_CPU_SAVE_STATE_PROTOCOL {
+ EFI_SMM_CPU_STATE **CpuSaveState;
+} EFI_SMM_CPU_SAVE_STATE_PROTOCOL;
+
+extern EFI_GUID gEfiSmmCpuSaveStateProtocolGuid;
+
+#endif // _SMMSAVESTATE_H_ \ No newline at end of file
diff --git a/EDK/Foundation/Framework/Protocol/SmmGpiDispatch/SmmGpiDispatch.c b/EDK/Foundation/Framework/Protocol/SmmGpiDispatch/SmmGpiDispatch.c
new file mode 100644
index 0000000..03700e4
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/SmmGpiDispatch/SmmGpiDispatch.c
@@ -0,0 +1,31 @@
+/*++
+
+Copyright (c) 1999 - 2002, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ SmmGpiDispatch.c
+
+Abstract:
+
+ EFI Smm Gpi Smi Child Protocol
+
+Revision History
+
+--*/
+
+#include "Tiano.h"
+#include EFI_PROTOCOL_DEFINITION (SmmGpiDispatch)
+
+EFI_GUID gEfiSmmGpiDispatchProtocolGuid = EFI_SMM_GPI_DISPATCH_PROTOCOL_GUID;
+
+EFI_GUID_STRING
+ (&gEfiSmmGpiDispatchProtocolGuid, "SMM GPI SMI Dispatch Protocol", "EFI 2.0 SMM GPI SMI Dispatch Protocol");
diff --git a/EDK/Foundation/Framework/Protocol/SmmGpiDispatch/SmmGpiDispatch.h b/EDK/Foundation/Framework/Protocol/SmmGpiDispatch/SmmGpiDispatch.h
new file mode 100644
index 0000000..3eba7b2
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/SmmGpiDispatch/SmmGpiDispatch.h
@@ -0,0 +1,152 @@
+/*++
+
+Copyright (c) 1999 - 2002, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ SmmGpiDispatch.h
+
+Abstract:
+
+ EFI Smm Gpi Smi Child Protocol
+
+Revision History
+
+--*/
+
+#ifndef _EFI_SMM_GPI_DISPATCH_H_
+#define _EFI_SMM_GPI_DISPATCH_H_
+
+//
+// Global ID for the GPI SMI Protocol
+//
+#define EFI_SMM_GPI_DISPATCH_PROTOCOL_GUID \
+ { \
+ 0xe0744b81, 0x9513, 0x49cd, 0x8c, 0xea, 0xe9, 0x24, 0x5e, 0x70, 0x39, 0xda \
+ }
+
+EFI_FORWARD_DECLARATION (EFI_SMM_GPI_DISPATCH_PROTOCOL);
+
+//
+// Related Definitions
+//
+//
+// GpiMask is a bit mask of 32 possible general purpose inputs that can generate a
+// a SMI. Bit 0 corresponds to logical GPI[0], 1 corresponds to logical GPI[1], etc.
+//
+// The logical GPI index to physical pin on device is described by the GPI device name
+// found on the same handle as the GpiSmi child dispatch protocol. The GPI device name
+// is defined as protocol with a GUID name and NULL protocol pointer.
+//
+typedef struct {
+ UINTN GpiNum;
+} EFI_SMM_GPI_DISPATCH_CONTEXT;
+
+//
+// Member functions
+//
+typedef
+VOID
+(EFIAPI *EFI_SMM_GPI_DISPATCH) (
+ IN EFI_HANDLE DispatchHandle,
+ IN EFI_SMM_GPI_DISPATCH_CONTEXT * DispatchContext
+ );
+
+/*++
+
+ Routine Description:
+ Dispatch function for a GPI SMI handler.
+
+ Arguments:
+ DispatchHandle - Handle of this dispatch function.
+ DispatchContext - Pointer to the dispatch function's context.
+ The DispatchContext fields are filled in
+ by the dispatching driver prior to
+ invoking this dispatch function.
+
+ Returns:
+ Nothing
+
+--*/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SMM_GPI_REGISTER) (
+ IN EFI_SMM_GPI_DISPATCH_PROTOCOL * This,
+ IN EFI_SMM_GPI_DISPATCH DispatchFunction,
+ IN EFI_SMM_GPI_DISPATCH_CONTEXT * DispatchContext,
+ OUT EFI_HANDLE * DispatchHandle
+ );
+
+/*++
+
+ Routine Description:
+ Register a child SMI source dispatch function with a parent SMM driver
+
+ Arguments:
+ This - Protocol instance pointer.
+ DispatchFunction - Pointer to dispatch function to be invoked for
+ this SMI source
+ DispatchContext - Pointer to the dispatch function's context.
+ The caller fills this context in before calling
+ the register function to indicate to the register
+ function the GPI(s) for which the dispatch function
+ should be invoked.
+ DispatchHandle - Handle of dispatch function, for when interfacing
+ with the parent Sx state SMM driver.
+
+ Returns:
+ EFI_SUCCESS - The dispatch function has been successfully
+ registered and the SMI source has been enabled.
+ EFI_DEVICE_ERROR - The driver was unable to enable the SMI source.
+ EFI_OUT_OF_RESOURCES - Not enough memory (system or SMM) to manage this
+ child.
+ EFI_INVALID_PARAMETER - DispatchContext is invalid. The GPI input value
+ is not within valid range.
+
+--*/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SMM_GPI_UNREGISTER) (
+ IN EFI_SMM_GPI_DISPATCH_PROTOCOL * This,
+ IN EFI_HANDLE DispatchHandle
+ );
+
+/*++
+
+ Routine Description:
+ Unregister a child SMI source dispatch function with a parent SMM driver
+
+ Arguments:
+ This - Protocol instance pointer.
+ DispatchHandle - Handle of dispatch function to deregister.
+
+ Returns:
+ EFI_SUCCESS - The dispatch function has been successfully
+ unregistered and the SMI source has been disabled
+ if there are no other registered child dispatch
+ functions for this SMI source.
+ EFI_INVALID_PARAMETER - Handle is invalid.
+ other - TBD
+
+--*/
+
+//
+// Interface structure for the SMM GPI SMI Dispatch Protocol
+//
+typedef struct _EFI_SMM_GPI_DISPATCH_PROTOCOL {
+ EFI_SMM_GPI_REGISTER Register;
+ EFI_SMM_GPI_UNREGISTER UnRegister;
+ UINTN NumSupportedGpis;
+} EFI_SMM_GPI_DISPATCH_PROTOCOL;
+
+extern EFI_GUID gEfiSmmGpiDispatchProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Protocol/SmmIchnDispatch/SmmIchnDispatch.c b/EDK/Foundation/Framework/Protocol/SmmIchnDispatch/SmmIchnDispatch.c
new file mode 100644
index 0000000..0b2120c
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/SmmIchnDispatch/SmmIchnDispatch.c
@@ -0,0 +1,31 @@
+/*++
+
+Copyright (c) 1999 - 2002, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ SmmIchnDispatch.c
+
+Abstract:
+
+ EFI Smm ICH N Smi Child Protocol
+
+Revision History
+
+--*/
+
+#include "Tiano.h"
+#include EFI_PROTOCOL_DEFINITION (SmmIchnDispatch)
+
+EFI_GUID gEfiSmmIchnDispatchProtocolGuid = EFI_SMM_ICHN_DISPATCH_PROTOCOL_GUID;
+
+EFI_GUID_STRING
+ (&gEfiSmmIchnDispatchProtocolGuid, "SMM ICHn SMI Dispatch Protocol", "EFI 2.0 SMM ICHn SMI Dispatch Protocol");
diff --git a/EDK/Foundation/Framework/Protocol/SmmIchnDispatch/SmmIchnDispatch.h b/EDK/Foundation/Framework/Protocol/SmmIchnDispatch/SmmIchnDispatch.h
new file mode 100644
index 0000000..b02a00b
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/SmmIchnDispatch/SmmIchnDispatch.h
@@ -0,0 +1,199 @@
+/*++
+
+Copyright (c) 1999 - 2002, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ SmmIchnDispatch.h
+
+Abstract:
+
+ EFI Smm ICH [N] Specific Smi Child Protocol
+
+Revision History
+
+--*/
+
+#ifndef _EFI_SMM_ICHN_DISPATCH_H_
+#define _EFI_SMM_ICHN_DISPATCH_H_
+
+//
+// Global ID for the ICH SMI Protocol
+//
+#define EFI_SMM_ICHN_DISPATCH_PROTOCOL_GUID \
+ { \
+ 0xc50b323e, 0x9075, 0x4f2a, 0xac, 0x8e, 0xd2, 0x59, 0x6a, 0x10, 0x85, 0xcc \
+ }
+
+EFI_FORWARD_DECLARATION (EFI_SMM_ICHN_DISPATCH_PROTOCOL);
+
+//
+// Related Definitions
+//
+//
+// ICHN Specific SMIs. These are miscellaneous SMI sources that are supported by the
+// ICHN specific SMI implementation. These may change over time. TrapNumber is only
+// valid if the Type is Trap.
+//
+typedef enum {
+ //
+ // NOTE: NEVER delete items from this list/enumeration! Doing so will prevent other versions
+ // of the code from compiling. If the ICH version your driver is written for doesn't support
+ // some of these SMIs, then simply return EFI_UNSUPPORTED when a child/client tries to register
+ // for them.
+ //
+ IchnMch,
+ IchnPme,
+ IchnRtcAlarm,
+ IchnRingIndicate,
+ IchnAc97Wake,
+ IchnSerialIrq,
+ IchnY2KRollover,
+ IchnTcoTimeout,
+ IchnOsTco,
+ IchnNmi,
+ IchnIntruderDetect,
+ IchnBiosWp,
+ IchnMcSmi,
+ IchnPmeB0,
+ IchnThrmSts,
+ IchnSmBus,
+ IchnIntelUsb2,
+ IchnMonSmi7,
+ IchnMonSmi6,
+ IchnMonSmi5,
+ IchnMonSmi4,
+ IchnDevTrap13,
+ IchnDevTrap12,
+ IchnDevTrap11,
+ IchnDevTrap10,
+ IchnDevTrap9,
+ IchnDevTrap8,
+ IchnDevTrap7,
+ IchnDevTrap6,
+ IchnDevTrap5,
+ IchnDevTrap3,
+ IchnDevTrap2,
+ IchnDevTrap1,
+ IchnDevTrap0,
+ IchnIoTrap3,
+ IchnIoTrap2,
+ IchnIoTrap1,
+ IchnIoTrap0,
+ //
+ // INSERT NEW ITEMS JUST BEFORE THIS LINE
+ //
+ NUM_ICHN_TYPES // the number of items in this enumeration
+} EFI_SMM_ICHN_SMI_TYPE;
+
+typedef struct {
+ EFI_SMM_ICHN_SMI_TYPE Type;
+} EFI_SMM_ICHN_DISPATCH_CONTEXT;
+
+//
+// Member functions
+//
+typedef
+VOID
+(EFIAPI *EFI_SMM_ICHN_DISPATCH) (
+ IN EFI_HANDLE DispatchHandle,
+ IN EFI_SMM_ICHN_DISPATCH_CONTEXT * DispatchContext
+ );
+
+/*++
+
+ Routine Description:
+ Dispatch function for a ICH n specific SMI handler.
+
+ Arguments:
+ DispatchHandle - Handle of this dispatch function.
+ DispatchContext - Pointer to the dispatch function's context.
+ The DispatchContext fields are filled in
+ by the dispatching driver prior to
+ invoking this dispatch function.
+
+ Returns:
+ Nothing
+
+--*/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SMM_ICHN_REGISTER) (
+ IN EFI_SMM_ICHN_DISPATCH_PROTOCOL * This,
+ IN EFI_SMM_ICHN_DISPATCH DispatchFunction,
+ IN EFI_SMM_ICHN_DISPATCH_CONTEXT * DispatchContext,
+ OUT EFI_HANDLE * DispatchHandle
+ );
+
+/*++
+
+ Routine Description:
+ Register a child SMI source dispatch function with a parent SMM driver
+
+ Arguments:
+ This - Protocol instance pointer.
+ DispatchFunction - Pointer to dispatch function to be invoked for
+ this SMI source
+ DispatchContext - Pointer to the dispatch function's context.
+ The caller fills this context in before calling
+ the register function to indicate to the register
+ function the ICHN SMI source for which the dispatch
+ function should be invoked.
+ DispatchHandle - Handle of dispatch function, for when interfacing
+ with the parent Sx state SMM driver.
+
+ Returns:
+ EFI_SUCCESS - The dispatch function has been successfully
+ registered and the SMI source has been enabled.
+ EFI_DEVICE_ERROR - The driver was unable to enable the SMI source.
+ EFI_OUT_OF_RESOURCES - Not enough memory (system or SMM) to manage this
+ child.
+ EFI_INVALID_PARAMETER - DispatchContext is invalid. The ICHN input value
+ is not within valid range.
+
+--*/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SMM_ICHN_UNREGISTER) (
+ IN EFI_SMM_ICHN_DISPATCH_PROTOCOL * This,
+ IN EFI_HANDLE DispatchHandle
+ );
+
+/*++
+
+ Routine Description:
+ Unregister a child SMI source dispatch function with a parent SMM driver
+
+ Arguments:
+ This - Protocol instance pointer.
+ DispatchHandle - Handle of dispatch function to deregister.
+
+ Returns:
+ EFI_SUCCESS - The dispatch function has been successfully
+ unregistered and the SMI source has been disabled
+ if there are no other registered child dispatch
+ functions for this SMI source.
+ EFI_INVALID_PARAMETER - Handle is invalid.
+ other - TBD
+
+--*/
+
+//
+// Interface structure for the SMM Ich n specific SMI Dispatch Protocol
+//
+typedef struct _EFI_SMM_ICHN_DISPATCH_PROTOCOL {
+ EFI_SMM_ICHN_REGISTER Register;
+ EFI_SMM_ICHN_UNREGISTER UnRegister;
+} EFI_SMM_ICHN_DISPATCH_PROTOCOL;
+
+extern EFI_GUID gEfiSmmIchnDispatchProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Protocol/SmmPeriodicTimerDispatch/SmmPeriodicTimerDispatch.c b/EDK/Foundation/Framework/Protocol/SmmPeriodicTimerDispatch/SmmPeriodicTimerDispatch.c
new file mode 100644
index 0000000..17afa7e
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/SmmPeriodicTimerDispatch/SmmPeriodicTimerDispatch.c
@@ -0,0 +1,34 @@
+/*++
+
+Copyright (c) 1999 - 2002, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ SmmPeriodicTimerDispatch.c
+
+Abstract:
+
+ EFI Smm Periodic Timer Smi Child Protocol
+
+Revision History
+
+--*/
+
+#include "Tiano.h"
+#include EFI_PROTOCOL_DEFINITION (SmmPeriodicTimerDispatch)
+
+EFI_GUID gEfiSmmPeriodicTimerDispatchProtocolGuid = EFI_SMM_PERIODIC_TIMER_DISPATCH_PROTOCOL_GUID;
+
+EFI_GUID_STRING
+ (
+ &gEfiSmmPeriodicTimerDispatchProtocolGuid, "SMM Periodic Timer SMI Dispatch Protocol",
+ "EFI 2.0 SMM Periodic Timer SMI Dispatch Protocol"
+ );
diff --git a/EDK/Foundation/Framework/Protocol/SmmPeriodicTimerDispatch/SmmPeriodicTimerDispatch.h b/EDK/Foundation/Framework/Protocol/SmmPeriodicTimerDispatch/SmmPeriodicTimerDispatch.h
new file mode 100644
index 0000000..e7a12a2
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/SmmPeriodicTimerDispatch/SmmPeriodicTimerDispatch.h
@@ -0,0 +1,224 @@
+/*++
+
+Copyright (c) 1999 - 2002, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ SmmPeriodicTimerDispatch.h
+
+Abstract:
+
+ EFI Smm Periodic Timer Smi Child Protocol
+
+Revision History
+
+--*/
+
+#ifndef _EFI_SMM_PERIODIC_TIMER_DISPATCH_H_
+#define _EFI_SMM_PERIODIC_TIMER_DISPATCH_H_
+
+//
+// Global ID for the Periodic Timer SMI Protocol
+//
+#define EFI_SMM_PERIODIC_TIMER_DISPATCH_PROTOCOL_GUID \
+ { \
+ 0x9cca03fc, 0x4c9e, 0x4a19, 0x9b, 0x6, 0xed, 0x7b, 0x47, 0x9b, 0xde, 0x55 \
+ }
+
+EFI_FORWARD_DECLARATION (EFI_SMM_PERIODIC_TIMER_DISPATCH_PROTOCOL);
+
+//
+// Related Definitions
+//
+//
+// Period is the minimum period of time in 100 nanosecond units that child gets called.
+// The child will be called back after a time greater than the time Period.
+//
+// SmiTickInterval is the period of time interval between SMIs. Children of this interface
+// should use this field when registering for periodic timer intervals when a finer
+// granularity periodic SMI is desired. Valid values for this field are those returned
+// by GetNextInterval. A value of 0 indicates the parent is allowed to use any SMI
+// interval period to satisfy the requested period.
+// Example: A chipset supports periodic SMIs on every 64ms or 2 seconds.
+// A child wishes schedule a period SMI to fire on a period of 3 seconds, there
+// are several ways to approach the problem:
+// 1. The child may accept a 4 second periodic rate, in which case it registers with
+// Period = 40000
+// SmiTickInterval = 20000
+// The resulting SMI will occur every 2 seconds with the child called back on
+// every 2nd SMI.
+// NOTE: the same result would occur if the child set SmiTickInterval = 0.
+// 2. The child may choose the finer granularity SMI (64ms):
+// Period = 30000
+// SmiTickInterval = 640
+// The resulting SMI will occur every 64ms with the child called back on
+// every 47th SMI.
+// NOTE: the child driver should be aware that this will result in more
+// SMIs occuring during system runtime which can negatively impact system
+// performance.
+//
+// ElapsedTime is the actual time in 100 nanosecond units elapsed since last called, a
+// value of 0 indicates an unknown amount of time.
+//
+typedef struct {
+ UINT64 Period;
+ UINT64 SmiTickInterval;
+ UINT64 ElapsedTime;
+//*** AMI PORTING BEGIN ***//
+ BOOLEAN TimerEnabled;
+//*** AMI PORTING END ***//
+} EFI_SMM_PERIODIC_TIMER_DISPATCH_CONTEXT;
+
+//
+// Member functions
+//
+typedef
+VOID
+(EFIAPI *EFI_SMM_PERIODIC_TIMER_DISPATCH) (
+ IN EFI_HANDLE DispatchHandle,
+ IN EFI_SMM_PERIODIC_TIMER_DISPATCH_CONTEXT * DispatchContext
+ );
+
+/*++
+
+ Routine Description:
+ Dispatch function for a Periodic Timer SMI handler.
+
+ Arguments:
+ DispatchHandle - Handle of this dispatch function.
+ DispatchContext - Pointer to the dispatch function's context.
+ The DispatchContext fields are filled in
+ by the dispatching driver prior to
+ invoking this dispatch function.
+
+ Returns:
+ Nothing
+
+--*/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SMM_PERIODIC_TIMER_INTERVAL) (
+ IN EFI_SMM_PERIODIC_TIMER_DISPATCH_PROTOCOL * This,
+ IN OUT UINT64 **SmiTickInterval
+ );
+
+/*++
+
+ Routine Description:
+ Returns the next SMI tick period supported by the chipset. The order
+ returned is from longest to shortest interval period.
+
+ Arguments:
+ This - Protocol instance pointer.
+ SmiTickInterval - Pointer to pointer of next shorter SMI interval
+ period supported by the child. This parameter
+ works as a get-first, get-next field. The first
+ time this function is called, *SmiTickInterval
+ should be set to NULL to get the longest SMI
+ interval. The returned *SmiTickInterval should
+ be passed in on subsequent calls to get
+ the next shorter interval period until
+ *SmiTickInterval = NULL.
+
+ Returns:
+ EFI_SUCCESS
+
+--*/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SMM_PERIODIC_TIMER_REGISTER) (
+ IN EFI_SMM_PERIODIC_TIMER_DISPATCH_PROTOCOL * This,
+ IN EFI_SMM_PERIODIC_TIMER_DISPATCH DispatchFunction,
+ IN EFI_SMM_PERIODIC_TIMER_DISPATCH_CONTEXT * DispatchContext,
+ OUT EFI_HANDLE * DispatchHandle
+ );
+
+/*++
+
+ Routine Description:
+ Register a child SMI source dispatch function with a parent SMM driver
+
+ Arguments:
+ This - Protocol instance pointer.
+ DispatchFunction - Pointer to dispatch function to be invoked for
+ this SMI source
+ DispatchContext - Pointer to the dispatch function's context.
+ The caller fills this context in before calling
+ the register function to indicate to the register
+ function the period at which the dispatch function
+ should be invoked.
+ DispatchHandle - Handle of dispatch function, for when interfacing
+ with the parent Sx state SMM driver.
+
+ Returns:
+ EFI_SUCCESS - The dispatch function has been successfully
+ registered and the SMI source has been enabled.
+ EFI_DEVICE_ERROR - The driver was unable to enable the SMI source.
+ EFI_OUT_OF_RESOURCES - Not enough memory (system or SMM) to manage this
+ child.
+ EFI_INVALID_PARAMETER - DispatchContext is invalid. The period input value
+ is not within valid range.
+
+--*/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SMM_PERIODIC_TIMER_UNREGISTER) (
+ IN EFI_SMM_PERIODIC_TIMER_DISPATCH_PROTOCOL * This,
+ IN EFI_HANDLE DispatchHandle
+ );
+
+/*++
+
+ Routine Description:
+ Unregister a child SMI source dispatch function with a parent SMM driver
+
+ Arguments:
+ This - Protocol instance pointer.
+ DispatchHandle - Handle of dispatch function to deregister.
+
+ Returns:
+ EFI_SUCCESS - The dispatch function has been successfully
+ unregistered and the SMI source has been disabled
+ if there are no other registered child dispatch
+ functions for this SMI source.
+ EFI_INVALID_PARAMETER - Handle is invalid.
+ other - TBD
+
+--*/
+
+//*** AMI PORTING BEGIN ***//
+typedef EFI_STATUS (EFIAPI *EFI_SMM_PERIODIC_ENABLE) (
+ IN EFI_SMM_PERIODIC_TIMER_DISPATCH_PROTOCOL *This,
+ IN EFI_HANDLE DispatchHandle
+);
+
+typedef EFI_STATUS (EFIAPI *EFI_SMM_PERIODIC_DISABLE) (
+ IN EFI_SMM_PERIODIC_TIMER_DISPATCH_PROTOCOL *This,
+ IN EFI_HANDLE DispatchHandle
+);
+//*** AMI PORTING END ***//
+
+//
+// Interface structure for the SMM Periodic Timer Dispatch Protocol
+//
+typedef struct _EFI_SMM_PERIODIC_TIMER_DISPATCH_PROTOCOL {
+ EFI_SMM_PERIODIC_TIMER_REGISTER Register;
+ EFI_SMM_PERIODIC_TIMER_UNREGISTER UnRegister;
+ EFI_SMM_PERIODIC_TIMER_INTERVAL GetNextShorterInterval;
+//*** AMI PORTING BEGIN ***//
+ EFI_SMM_PERIODIC_ENABLE SmmPeriodicSmiEnable;
+ EFI_SMM_PERIODIC_DISABLE SmmPeriodicSmiDisable;
+//*** AMI PORTING END ***//
+} EFI_SMM_PERIODIC_TIMER_DISPATCH_PROTOCOL;
+
+extern EFI_GUID gEfiSmmPeriodicTimerDispatchProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Protocol/SmmPowerButtonDispatch/SmmPowerButtonDispatch.c b/EDK/Foundation/Framework/Protocol/SmmPowerButtonDispatch/SmmPowerButtonDispatch.c
new file mode 100644
index 0000000..13000e7
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/SmmPowerButtonDispatch/SmmPowerButtonDispatch.c
@@ -0,0 +1,34 @@
+/*++
+
+Copyright (c) 1999 - 2002, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ SmmPowerButtonDispatch.c
+
+Abstract:
+
+ EFI Smm Power Button Smi Child Protocol
+
+Revision History
+
+--*/
+
+#include "Tiano.h"
+#include EFI_PROTOCOL_DEFINITION (SmmPowerButtonDispatch)
+
+EFI_GUID gEfiSmmPowerButtonDispatchProtocolGuid = EFI_SMM_POWER_BUTTON_DISPATCH_PROTOCOL_GUID;
+
+EFI_GUID_STRING
+ (
+ &gEfiSmmPowerButtonDispatchProtocolGuid, "SMM Power Button SMI Dispatch Protocol",
+ "EFI 2.0 SMM Power Button SMI Dispatch Protocol"
+ );
diff --git a/EDK/Foundation/Framework/Protocol/SmmPowerButtonDispatch/SmmPowerButtonDispatch.h b/EDK/Foundation/Framework/Protocol/SmmPowerButtonDispatch/SmmPowerButtonDispatch.h
new file mode 100644
index 0000000..b4e3673
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/SmmPowerButtonDispatch/SmmPowerButtonDispatch.h
@@ -0,0 +1,153 @@
+/*++
+
+Copyright (c) 1999 - 2002, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ SmmPowerButtonDispatch.h
+
+Abstract:
+
+ EFI Smm Power Button Smi Child Protocol
+
+Revision History
+
+--*/
+
+#ifndef _EFI_SMM_POWER_BUTTON_DISPATCH_H_
+#define _EFI_SMM_POWER_BUTTON_DISPATCH_H_
+
+//
+// Global ID for the Power Button SMI Protocol
+//
+#define EFI_SMM_POWER_BUTTON_DISPATCH_PROTOCOL_GUID \
+ { \
+ 0xb709efa0, 0x47a6, 0x4b41, 0xb9, 0x31, 0x12, 0xec, 0xe7, 0xa8, 0xee, 0x56 \
+ }
+
+EFI_FORWARD_DECLARATION (EFI_SMM_POWER_BUTTON_DISPATCH_PROTOCOL);
+
+//
+// Related Definitions
+//
+//
+// Power Button. Example, Use for changing LEDs before ACPI OS is on.
+// - DXE/BDS Phase
+// - OS Install Phase
+//
+typedef enum {
+ PowerButtonEntry,
+ PowerButtonExit
+} EFI_POWER_BUTTON_PHASE;
+
+typedef struct {
+ EFI_POWER_BUTTON_PHASE Phase;
+} EFI_SMM_POWER_BUTTON_DISPATCH_CONTEXT;
+
+//
+// Member functions
+//
+typedef
+VOID
+(EFIAPI *EFI_SMM_POWER_BUTTON_DISPATCH) (
+ IN EFI_HANDLE DispatchHandle,
+ IN EFI_SMM_POWER_BUTTON_DISPATCH_CONTEXT * DispatchContext
+ );
+
+/*++
+
+ Routine Description:
+ Dispatch function for a Power Button SMI handler.
+
+ Arguments:
+ DispatchHandle - Handle of this dispatch function.
+ DispatchContext - Pointer to the dispatch function's context.
+ The DispatchContext fields are filled in
+ by the dispatching driver prior to
+ invoking this dispatch function.
+
+ Returns:
+ Nothing
+
+--*/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SMM_POWER_BUTTON_REGISTER) (
+ IN EFI_SMM_POWER_BUTTON_DISPATCH_PROTOCOL * This,
+ IN EFI_SMM_POWER_BUTTON_DISPATCH DispatchFunction,
+ IN EFI_SMM_POWER_BUTTON_DISPATCH_CONTEXT * DispatchContext,
+ OUT EFI_HANDLE * DispatchHandle
+ );
+
+/*++
+
+ Routine Description:
+ Register a child SMI source dispatch function with a parent SMM driver
+
+ Arguments:
+ This - Protocol instance pointer.
+ DispatchFunction - Pointer to dispatch function to be invoked for
+ this SMI source
+ DispatchContext - Pointer to the dispatch function's context.
+ The caller fills this context in before calling
+ the register function to indicate to the register
+ function the Power Button SMI phase for which the dispatch
+ function should be invoked.
+ DispatchHandle - Handle of dispatch function, for when interfacing
+ with the parent Sx state SMM driver.
+
+ Returns:
+ EFI_SUCCESS - The dispatch function has been successfully
+ registered and the SMI source has been enabled.
+ EFI_DEVICE_ERROR - The driver was unable to enable the SMI source.
+ EFI_OUT_OF_RESOURCES - Not enough memory (system or SMM) to manage this
+ child.
+ EFI_INVALID_PARAMETER - DispatchContext is invalid. The Power Button SMI
+ phase is not within valid range.
+
+--*/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SMM_POWER_BUTTON_UNREGISTER) (
+ IN EFI_SMM_POWER_BUTTON_DISPATCH_PROTOCOL * This,
+ IN EFI_HANDLE DispatchHandle
+ );
+
+/*++
+
+ Routine Description:
+ Unregister a child SMI source dispatch function with a parent SMM driver
+
+ Arguments:
+ This - Protocol instance pointer.
+ DispatchHandle - Handle of dispatch function to deregister.
+
+ Returns:
+ EFI_SUCCESS - The dispatch function has been successfully
+ unregistered and the SMI source has been disabled
+ if there are no other registered child dispatch
+ functions for this SMI source.
+ EFI_INVALID_PARAMETER - Handle is invalid.
+ other - TBD
+
+--*/
+
+//
+// Interface structure for the SMM Power Button SMI Dispatch Protocol
+//
+typedef struct _EFI_SMM_POWER_BUTTON_DISPATCH_PROTOCOL {
+ EFI_SMM_POWER_BUTTON_REGISTER Register;
+ EFI_SMM_POWER_BUTTON_UNREGISTER UnRegister;
+} EFI_SMM_POWER_BUTTON_DISPATCH_PROTOCOL;
+
+extern EFI_GUID gEfiSmmPowerButtonDispatchProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Protocol/SmmStandbyButtonDispatch/SmmStandbyButtonDispatch.c b/EDK/Foundation/Framework/Protocol/SmmStandbyButtonDispatch/SmmStandbyButtonDispatch.c
new file mode 100644
index 0000000..d362f8e
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/SmmStandbyButtonDispatch/SmmStandbyButtonDispatch.c
@@ -0,0 +1,34 @@
+/*++
+
+Copyright (c) 1999 - 2002, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ SmmStandbyButtonDispatch.c
+
+Abstract:
+
+ EFI Smm Standby Button Smi Child Protocol
+
+Revision History
+
+--*/
+
+#include "Tiano.h"
+#include EFI_PROTOCOL_DEFINITION (SmmStandbyButtonDispatch)
+
+EFI_GUID gEfiSmmStandbyButtonDispatchProtocolGuid = EFI_SMM_STANDBY_BUTTON_DISPATCH_PROTOCOL_GUID;
+
+EFI_GUID_STRING
+ (
+ &gEfiSmmStandbyButtonDispatchProtocolGuid, "SMM Standby Button SMI Dispatch Protocol",
+ "EFI 2.0 SMM Standby Button SMI Dispatch Protocol"
+ );
diff --git a/EDK/Foundation/Framework/Protocol/SmmStandbyButtonDispatch/SmmStandbyButtonDispatch.h b/EDK/Foundation/Framework/Protocol/SmmStandbyButtonDispatch/SmmStandbyButtonDispatch.h
new file mode 100644
index 0000000..4ec47c0
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/SmmStandbyButtonDispatch/SmmStandbyButtonDispatch.h
@@ -0,0 +1,153 @@
+/*++
+
+Copyright (c) 1999 - 2002, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ SmmStandbyButtonDispatch.h
+
+Abstract:
+
+ EFI Smm Standby Button Smi Child Protocol
+
+Revision History
+
+--*/
+
+#ifndef _EFI_SMM_STANDBY_BUTTON_DISPATCH_H_
+#define _EFI_SMM_STANDBY_BUTTON_DISPATCH_H_
+
+//
+// Global ID for the Standby Button SMI Protocol
+//
+#define EFI_SMM_STANDBY_BUTTON_DISPATCH_PROTOCOL_GUID \
+ { \
+ 0x78965b98, 0xb0bf, 0x449e, 0x8b, 0x22, 0xd2, 0x91, 0x4e, 0x49, 0x8a, 0x98 \
+ }
+
+EFI_FORWARD_DECLARATION (EFI_SMM_STANDBY_BUTTON_DISPATCH_PROTOCOL);
+
+//
+// Related Definitions
+//
+//
+// Standby Button. Example, Use for changing LEDs before ACPI OS is on.
+// - DXE/BDS Phase
+// - OS Install Phase
+//
+typedef enum {
+ Entry,
+ Exit
+} EFI_STANDBY_BUTTON_PHASE;
+
+typedef struct {
+ EFI_STANDBY_BUTTON_PHASE Phase;
+} EFI_SMM_STANDBY_BUTTON_DISPATCH_CONTEXT;
+
+//
+// Member functions
+//
+typedef
+VOID
+(EFIAPI *EFI_SMM_STANDBY_BUTTON_DISPATCH) (
+ IN EFI_HANDLE DispatchHandle,
+ IN EFI_SMM_STANDBY_BUTTON_DISPATCH_CONTEXT * DispatchContext
+ );
+
+/*++
+
+ Routine Description:
+ Dispatch function for a Standby Button SMI handler.
+
+ Arguments:
+ DispatchHandle - Handle of this dispatch function.
+ DispatchContext - Pointer to the dispatch function's context.
+ The DispatchContext fields are filled in
+ by the dispatching driver prior to
+ invoking this dispatch function.
+
+ Returns:
+ Nothing
+
+--*/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SMM_STANDBY_BUTTON_REGISTER) (
+ IN EFI_SMM_STANDBY_BUTTON_DISPATCH_PROTOCOL * This,
+ IN EFI_SMM_STANDBY_BUTTON_DISPATCH DispatchFunction,
+ IN EFI_SMM_STANDBY_BUTTON_DISPATCH_CONTEXT * DispatchContext,
+ OUT EFI_HANDLE * DispatchHandle
+ );
+
+/*++
+
+ Routine Description:
+ Register a child SMI source dispatch function with a parent SMM driver
+
+ Arguments:
+ This - Protocol instance pointer.
+ DispatchFunction - Pointer to dispatch function to be invoked for
+ this SMI source
+ DispatchContext - Pointer to the dispatch function's context.
+ The caller fills this context in before calling
+ the register function to indicate to the register
+ function the Standby Button SMI phase for which the dispatch
+ function should be invoked.
+ DispatchHandle - Handle of dispatch function, for when interfacing
+ with the parent Sx state SMM driver.
+
+ Returns:
+ EFI_SUCCESS - The dispatch function has been successfully
+ registered and the SMI source has been enabled.
+ EFI_DEVICE_ERROR - The driver was unable to enable the SMI source.
+ EFI_OUT_OF_RESOURCES - Not enough memory (system or SMM) to manage this
+ child.
+ EFI_INVALID_PARAMETER - DispatchContext is invalid. The Standby Button SMI
+ phase is not within valid range.
+
+--*/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SMM_STANDBY_BUTTON_UNREGISTER) (
+ IN EFI_SMM_STANDBY_BUTTON_DISPATCH_PROTOCOL * This,
+ IN EFI_HANDLE DispatchHandle
+ );
+
+/*++
+
+ Routine Description:
+ Unregister a child SMI source dispatch function with a parent SMM driver
+
+ Arguments:
+ This - Protocol instance pointer.
+ DispatchHandle - Handle of dispatch function to deregister.
+
+ Returns:
+ EFI_SUCCESS - The dispatch function has been successfully
+ unregistered and the SMI source has been disabled
+ if there are no other registered child dispatch
+ functions for this SMI source.
+ EFI_INVALID_PARAMETER - Handle is invalid.
+ other - TBD
+
+--*/
+
+//
+// Interface structure for the SMM Standby Button SMI Dispatch Protocol
+//
+typedef struct _EFI_SMM_STANDBY_BUTTON_DISPATCH_PROTOCOL {
+ EFI_SMM_STANDBY_BUTTON_REGISTER Register;
+ EFI_SMM_STANDBY_BUTTON_UNREGISTER UnRegister;
+} EFI_SMM_STANDBY_BUTTON_DISPATCH_PROTOCOL;
+
+extern EFI_GUID gEfiSmmStandbyButtonDispatchProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Protocol/SmmStatusCode/SmmStatusCode.c b/EDK/Foundation/Framework/Protocol/SmmStatusCode/SmmStatusCode.c
new file mode 100644
index 0000000..2592da7
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/SmmStatusCode/SmmStatusCode.c
@@ -0,0 +1,30 @@
+/*++
+
+Copyright (c) 1999 - 2002, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ SmmStatusCode.c
+
+Abstract:
+
+ SMM Status code Protocol as defined in EFI 2.0 (for Status Code Architectural Protocol)
+
+ This code abstracts Status Code reporting.
+
+--*/
+
+#include "Tiano.h"
+#include EFI_PROTOCOL_DEFINITION (SmmStatusCode)
+
+EFI_GUID gEfiSmmStatusCodeProtocolGuid = EFI_SMM_STATUS_CODE_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiSmmStatusCodeProtocolGuid, "SMM Status Code", "SMM Status Code Protocol");
diff --git a/EDK/Foundation/Framework/Protocol/SmmStatusCode/SmmStatusCode.h b/EDK/Foundation/Framework/Protocol/SmmStatusCode/SmmStatusCode.h
new file mode 100644
index 0000000..db1c23f
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/SmmStatusCode/SmmStatusCode.h
@@ -0,0 +1,58 @@
+/*++
+
+Copyright (c) 1999 - 2002, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ SmmStatusCode.h
+
+Abstract:
+
+ SMM Status code Protocol as defined in the DXE CIS (Status Code Architectural Protocol)
+
+ This code abstracts SMM Status Code reporting.
+
+--*/
+
+#ifndef _PROTOCOL_SMM_STATUS_CODE_H__
+#define _PROTOCOL_SMM_STATUS_CODE_H__
+
+//
+// Global ID for the Smm Status Code Protocol
+//
+#define EFI_SMM_STATUS_CODE_PROTOCOL_GUID \
+ { \
+ 0x6afd2b77, 0x98c1, 0x4acd, 0xa6, 0xf9, 0x8a, 0x94, 0x39, 0xde, 0xf, 0xb1 \
+ }
+
+extern EFI_GUID gEfiSmmStatusCodeProtocolGuid;
+
+//
+// Forward reference for pure ANSI compatability
+//
+EFI_FORWARD_DECLARATION (EFI_SMM_STATUS_CODE_PROTOCOL);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SMM_REPORT_STATUS_CODE) (
+ IN EFI_SMM_STATUS_CODE_PROTOCOL * This,
+ IN EFI_STATUS_CODE_TYPE CodeType,
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN UINT32 Instance,
+ IN EFI_GUID * CallerId,
+ IN EFI_STATUS_CODE_DATA * Data OPTIONAL
+ );
+
+typedef struct _EFI_SMM_STATUS_CODE_PROTOCOL {
+ EFI_SMM_REPORT_STATUS_CODE ReportStatusCode;
+} EFI_SMM_STATUS_CODE_PROTOCOL;
+
+#endif
diff --git a/EDK/Foundation/Framework/Protocol/SmmSwDispatch/SmmSwDispatch.c b/EDK/Foundation/Framework/Protocol/SmmSwDispatch/SmmSwDispatch.c
new file mode 100644
index 0000000..bee21fa
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/SmmSwDispatch/SmmSwDispatch.c
@@ -0,0 +1,30 @@
+/*++
+
+Copyright (c) 1999 - 2002, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ SmmSwDispatch.c
+
+Abstract:
+
+ EFI Smm Software Smi Child Protocol
+
+Revision History
+
+--*/
+
+#include "Tiano.h"
+#include EFI_PROTOCOL_DEFINITION (SmmSwDispatch)
+
+EFI_GUID gEfiSmmSwDispatchProtocolGuid = EFI_SMM_SW_DISPATCH_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiSmmSwDispatchProtocolGuid, "SMM Sw SMI Dispatch Protocol", "EFI 2.0 SMM Sw SMI Dispatch Protocol");
diff --git a/EDK/Foundation/Framework/Protocol/SmmSwDispatch/SmmSwDispatch.h b/EDK/Foundation/Framework/Protocol/SmmSwDispatch/SmmSwDispatch.h
new file mode 100644
index 0000000..63b6c68
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/SmmSwDispatch/SmmSwDispatch.h
@@ -0,0 +1,151 @@
+/*++
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ SmmSwDispatch.h
+
+Abstract:
+
+ EFI Smm Software Smi Child Protocol
+
+Revision History
+
+--*/
+
+#ifndef _EFI_SMM_SW_DISPATCH_H_
+#define _EFI_SMM_SW_DISPATCH_H_
+
+//
+// Global ID for the SW SMI Protocol
+//
+#define EFI_SMM_SW_DISPATCH_PROTOCOL_GUID \
+ { \
+ 0xe541b773, 0xdd11, 0x420c, 0xb0, 0x26, 0xdf, 0x99, 0x36, 0x53, 0xf8, 0xbf \
+ }
+
+EFI_FORWARD_DECLARATION (EFI_SMM_SW_DISPATCH_PROTOCOL);
+
+//
+// Related Definitions
+//
+//
+// A particular chipset may not support all possible software SMI input values.
+// For example, the ICH supports only values 00h to 0FFh. The parent only allows a single
+// child registration for each SwSmiInputValue.
+//
+typedef struct {
+ UINTN SwSmiInputValue;
+} EFI_SMM_SW_DISPATCH_CONTEXT;
+
+//
+// Member functions
+//
+typedef
+VOID
+(EFIAPI *EFI_SMM_SW_DISPATCH) (
+ IN EFI_HANDLE DispatchHandle,
+ IN EFI_SMM_SW_DISPATCH_CONTEXT * DispatchContext
+ );
+
+/*++
+
+ Routine Description:
+ Dispatch function for a Software SMI handler.
+
+ Arguments:
+ DispatchHandle - Handle of this dispatch function.
+ DispatchContext - Pointer to the dispatch function's context.
+ The SwSmiInputValue field is filled in
+ by the software dispatch driver prior to
+ invoking this dispatch function.
+ The dispatch function will only be called
+ for input values for which it is registered.
+
+ Returns:
+ Nothing
+
+--*/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SMM_SW_REGISTER) (
+ IN EFI_SMM_SW_DISPATCH_PROTOCOL * This,
+ IN EFI_SMM_SW_DISPATCH DispatchFunction,
+ IN EFI_SMM_SW_DISPATCH_CONTEXT * DispatchContext,
+ OUT EFI_HANDLE * DispatchHandle
+ );
+
+/*++
+
+ Routine Description:
+ Register a child SMI source dispatch function with a parent SMM driver
+
+ Arguments:
+ This - Protocol instance pointer.
+ DispatchFunction - Pointer to dispatch function to be invoked for
+ this SMI source
+ DispatchContext - Pointer to the dispatch function's context.
+ The caller fills this context in before calling
+ the register function to indicate to the register
+ function which Software SMI input value the
+ dispatch function should be invoked for.
+ DispatchHandle - Handle of dispatch function, for when interfacing
+ with the parent Sx state SMM driver.
+
+ Returns:
+ EFI_SUCCESS - The dispatch function has been successfully
+ registered and the SMI source has been enabled.
+ EFI_DEVICE_ERROR - The SW driver was unable to enable the SMI source.
+ EFI_OUT_OF_RESOURCES - Not enough memory (system or SMM) to manage this
+ child.
+ EFI_INVALID_PARAMETER - DispatchContext is invalid. The SW SMI input value
+ is not within valid range.
+
+--*/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SMM_SW_UNREGISTER) (
+ IN EFI_SMM_SW_DISPATCH_PROTOCOL * This,
+ IN EFI_HANDLE DispatchHandle
+ );
+
+/*++
+
+ Routine Description:
+ Unregister a child SMI source dispatch function with a parent SMM driver
+
+ Arguments:
+ This - Protocol instance pointer.
+ DispatchHandle - Handle of dispatch function to deregister.
+
+ Returns:
+ EFI_SUCCESS - The dispatch function has been successfully
+ unregistered and the SMI source has been disabled
+ if there are no other registered child dispatch
+ functions for this SMI source.
+ EFI_INVALID_PARAMETER - Handle is invalid.
+ other - TBD
+
+--*/
+
+//
+// Interface structure for the SMM Software SMI Dispatch Protocol
+//
+typedef struct _EFI_SMM_SW_DISPATCH_PROTOCOL {
+ EFI_SMM_SW_REGISTER Register;
+ EFI_SMM_SW_UNREGISTER UnRegister;
+ UINTN MaximumSwiValue;
+} EFI_SMM_SW_DISPATCH_PROTOCOL;
+
+extern EFI_GUID gEfiSmmSwDispatchProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Protocol/SmmSxDispatch/SmmSxDispatch.c b/EDK/Foundation/Framework/Protocol/SmmSxDispatch/SmmSxDispatch.c
new file mode 100644
index 0000000..cc27979
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/SmmSxDispatch/SmmSxDispatch.c
@@ -0,0 +1,30 @@
+/*++
+
+Copyright (c) 1999 - 2002, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ SmmSxDispatch.c
+
+Abstract:
+
+ EFI Smm Sx Smi Child Protocol
+
+Revision History
+
+--*/
+
+#include "Tiano.h"
+#include EFI_PROTOCOL_DEFINITION (SmmSxDispatch)
+
+EFI_GUID gEfiSmmSxDispatchProtocolGuid = EFI_SMM_SX_DISPATCH_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiSmmSxDispatchProtocolGuid, "SMM Sx Dispatch Protocol", "EFI 2.0 SMM Sx Dispatch Protocol");
diff --git a/EDK/Foundation/Framework/Protocol/SmmSxDispatch/SmmSxDispatch.h b/EDK/Foundation/Framework/Protocol/SmmSxDispatch/SmmSxDispatch.h
new file mode 100644
index 0000000..7e0b196
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/SmmSxDispatch/SmmSxDispatch.h
@@ -0,0 +1,170 @@
+/*++
+
+Copyright (c) 1999 - 2002, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ SmmSxDispatch.h
+
+Abstract:
+
+ EFI Smm Sx Smi Child Protocol
+
+Revision History
+
+--*/
+
+#ifndef _EFI_SMM_SX_DISPATCH_H_
+#define _EFI_SMM_SX_DISPATCH_H_
+
+//
+// Global ID for the Sx SMI Protocol
+//
+#define EFI_SMM_SX_DISPATCH_PROTOCOL_GUID \
+ { \
+ 0x14fc52be, 0x1dc, 0x426c, 0x91, 0xae, 0xa2, 0x3c, 0x3e, 0x22, 0xa, 0xe8 \
+ }
+
+EFI_FORWARD_DECLARATION (EFI_SMM_SX_DISPATCH_PROTOCOL);
+
+//
+// Related Definitions
+//
+typedef enum {
+ SxS0,
+ SxS1,
+ SxS2,
+ SxS3,
+ SxS4,
+ SxS5,
+ EfiMaximumSleepType
+} EFI_SLEEP_TYPE;
+
+typedef enum {
+ SxEntry,
+ SxExit,
+ EfiMaximumPhase
+} EFI_SLEEP_PHASE;
+
+typedef struct {
+ EFI_SLEEP_TYPE Type;
+ EFI_SLEEP_PHASE Phase;
+} EFI_SMM_SX_DISPATCH_CONTEXT;
+
+//
+// Member functions
+//
+typedef
+VOID
+(EFIAPI *EFI_SMM_SX_DISPATCH) (
+ IN EFI_HANDLE DispatchHandle,
+ IN EFI_SMM_SX_DISPATCH_CONTEXT * DispatchContext
+ );
+
+/*++
+
+ Routine Description:
+ Dispatch function for a Sx state SMI handler.
+
+ Arguments:
+ DispatchHandle - Handle of this dispatch function.
+ DispatchContext - Pointer to the dispatch function's context.
+ The Type and Phase fields are filled in
+ by the Sx dispatch driver prior to invoking
+ this dispatch function.
+ For this intertace, the Sx driver will call the
+ dispatch function for all Sx type and phases,
+ so the Sx state handler(s) must check the Type
+ and Phase field of the Dispatch context and act
+ accordingly.
+
+ Returns:
+ Nothing
+
+--*/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SMM_SX_REGISTER) (
+ IN EFI_SMM_SX_DISPATCH_PROTOCOL * This,
+ IN EFI_SMM_SX_DISPATCH DispatchFunction,
+ IN EFI_SMM_SX_DISPATCH_CONTEXT * DispatchContext,
+ OUT EFI_HANDLE * DispatchHandle
+ );
+
+/*++
+
+ Routine Description:
+ Register a child SMI source dispatch function with a parent SMM driver
+
+ Arguments:
+ This - Protocol instance pointer.
+ DispatchFunction - Pointer to dispatch function to be invoked for
+ this SMI source
+ DispatchContext - Pointer to the dispatch function's context.
+ The caller fills this context in before calling
+ the register function to indicate to the register
+ function which Sx state type and phase the caller
+ wishes to be called back on. For this intertace,
+ the Sx driver will call the registered handlers for
+ all Sx type and phases, so the Sx state handler(s)
+ must check the Type and Phase field of the Dispatch
+ context and act accordingly.
+ DispatchHandle - Handle of dispatch function, for when interfacing
+ with the parent Sx state SMM driver.
+
+ Returns:
+ EFI_SUCCESS - The dispatch function has been successfully
+ registered and the SMI source has been enabled.
+ EFI_UNSUPPORTED - The Sx driver or hardware does not support that
+ Sx Type/Phase.
+ EFI_DEVICE_ERROR - The Sx driver was unable to enable the SMI source.
+ EFI_OUT_OF_RESOURCES - Not enough memory (system or SMM) to manage this
+ child.
+ EFI_INVALID_PARAMETER - DispatchContext is invalid. Type & Phase are not
+ within valid range.
+
+--*/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SMM_SX_UNREGISTER) (
+ IN EFI_SMM_SX_DISPATCH_PROTOCOL * This,
+ IN EFI_HANDLE DispatchHandle
+ );
+
+/*++
+
+ Routine Description:
+ Unregister a child SMI source dispatch function with a parent SMM driver
+
+ Arguments:
+ This - Protocol instance pointer.
+ DispatchHandle - Handle of dispatch function to deregister.
+
+ Returns:
+ EFI_SUCCESS - The dispatch function has been successfully unregistered and the
+ SMI source has been disabled if there are no other registered child
+ dispatch functions for this SMI source.
+ EFI_INVALID_PARAMETER - Handle is invalid.
+ other - TBD
+
+--*/
+
+//
+// Interface structure for the SMM Child Dispatch Protocol
+//
+typedef struct _EFI_SMM_SX_DISPATCH_PROTOCOL {
+ EFI_SMM_SX_REGISTER Register;
+ EFI_SMM_SX_UNREGISTER UnRegister;
+} EFI_SMM_SX_DISPATCH_PROTOCOL;
+
+extern EFI_GUID gEfiSmmSxDispatchProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Framework/Protocol/SmmUsbDispatch/SmmUsbDispatch.c b/EDK/Foundation/Framework/Protocol/SmmUsbDispatch/SmmUsbDispatch.c
new file mode 100644
index 0000000..6668c7d
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/SmmUsbDispatch/SmmUsbDispatch.c
@@ -0,0 +1,31 @@
+/*++
+
+Copyright (c) 1999 - 2002, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ SmmUsbDispatch.c
+
+Abstract:
+
+ EFI Smm USB Smi Child Protocol
+
+Revision History
+
+--*/
+
+#include "Tiano.h"
+#include EFI_PROTOCOL_DEFINITION (SmmUsbDispatch)
+
+EFI_GUID gEfiSmmUsbDispatchProtocolGuid = EFI_SMM_USB_DISPATCH_PROTOCOL_GUID;
+
+EFI_GUID_STRING
+ (&gEfiSmmUsbDispatchProtocolGuid, "SMM USB SMI Dispatch Protocol", "EFI 2.0 SMM USB SMI Dispatch Protocol");
diff --git a/EDK/Foundation/Framework/Protocol/SmmUsbDispatch/SmmUsbDispatch.h b/EDK/Foundation/Framework/Protocol/SmmUsbDispatch/SmmUsbDispatch.h
new file mode 100644
index 0000000..b2d89e1
--- /dev/null
+++ b/EDK/Foundation/Framework/Protocol/SmmUsbDispatch/SmmUsbDispatch.h
@@ -0,0 +1,149 @@
+/*++
+
+Copyright (c) 1999 - 2002, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ SmmUsbDispatch.h
+
+Abstract:
+
+ EFI Smm USB Smi Child Protocol
+
+Revision History
+
+--*/
+
+#ifndef _EFI_SMM_USB_DISPATCH_H_
+#define _EFI_SMM_USB_DISPATCH_H_
+
+//
+// Global ID for the USB Protocol
+//
+#define EFI_SMM_USB_DISPATCH_PROTOCOL_GUID \
+ { \
+ 0xa05b6ffd, 0x87af, 0x4e42, 0x95, 0xc9, 0x62, 0x28, 0xb6, 0x3c, 0xf3, 0xf3 \
+ }
+
+EFI_FORWARD_DECLARATION (EFI_SMM_USB_DISPATCH_PROTOCOL);
+
+//
+// Related Definitions
+//
+typedef enum {
+ UsbLegacy,
+ UsbWake
+} EFI_USB_SMI_TYPE;
+
+typedef struct {
+ EFI_USB_SMI_TYPE Type;
+ EFI_DEVICE_PATH_PROTOCOL *Device;
+} EFI_SMM_USB_DISPATCH_CONTEXT;
+
+//
+// Member functions
+//
+typedef
+VOID
+(EFIAPI *EFI_SMM_USB_DISPATCH) (
+ IN EFI_HANDLE DispatchHandle,
+ IN EFI_SMM_USB_DISPATCH_CONTEXT * DispatchContext
+ );
+
+/*++
+
+ Routine Description:
+ Dispatch function for a USB SMI handler.
+
+ Arguments:
+ DispatchHandle - Handle of this dispatch function.
+ DispatchContext - Pointer to the dispatch function's context.
+ The DispatchContext fields are filled in
+ by the dispatching driver prior to
+ invoking this dispatch function.
+
+ Returns:
+ Nothing
+
+--*/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SMM_USB_REGISTER) (
+ IN EFI_SMM_USB_DISPATCH_PROTOCOL * This,
+ IN EFI_SMM_USB_DISPATCH DispatchFunction,
+ IN EFI_SMM_USB_DISPATCH_CONTEXT * DispatchContext,
+ OUT EFI_HANDLE * DispatchHandle
+ );
+
+/*++
+
+ Routine Description:
+ Register a child SMI source dispatch function with a parent SMM driver
+
+ Arguments:
+ This - Protocol instance pointer.
+ DispatchFunction - Pointer to dispatch function to be invoked for
+ this SMI source
+ DispatchContext - Pointer to the dispatch function's context.
+ The caller fills this context in before calling
+ the register function to indicate to the register
+ function the USB SMI types for which the dispatch
+ function should be invoked.
+ DispatchHandle - Handle of dispatch function, for when interfacing
+ with the parent Sx state SMM driver.
+
+ Returns:
+ EFI_SUCCESS - The dispatch function has been successfully
+ registered and the SMI source has been enabled.
+ EFI_DEVICE_ERROR - The driver was unable to enable the SMI source.
+ EFI_OUT_OF_RESOURCES - Not enough memory (system or SMM) to manage this
+ child.
+ EFI_INVALID_PARAMETER - DispatchContext is invalid. The USB SMI type
+ is not within valid range.
+
+--*/
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SMM_USB_UNREGISTER) (
+ IN EFI_SMM_USB_DISPATCH_PROTOCOL * This,
+ IN EFI_HANDLE DispatchHandle
+ );
+
+/*++
+
+ Routine Description:
+ Unregister a child SMI source dispatch function with a parent SMM driver
+
+ Arguments:
+ This - Protocol instance pointer.
+ DispatchHandle - Handle of dispatch function to deregister.
+
+ Returns:
+ EFI_SUCCESS - The dispatch function has been successfully
+ unregistered and the SMI source has been disabled
+ if there are no other registered child dispatch
+ functions for this SMI source.
+ EFI_INVALID_PARAMETER - Handle is invalid.
+ other - TBD
+
+--*/
+
+//
+// Interface structure for the SMM USB SMI Dispatch Protocol
+//
+typedef struct _EFI_SMM_USB_DISPATCH_PROTOCOL {
+ EFI_SMM_USB_REGISTER Register;
+ EFI_SMM_USB_UNREGISTER UnRegister;
+} EFI_SMM_USB_DISPATCH_PROTOCOL;
+
+extern EFI_GUID gEfiSmmUsbDispatchProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Guid/AlternateFvBlock/AlternateFvBlock.c b/EDK/Foundation/Guid/AlternateFvBlock/AlternateFvBlock.c
new file mode 100644
index 0000000..1be59cc
--- /dev/null
+++ b/EDK/Foundation/Guid/AlternateFvBlock/AlternateFvBlock.c
@@ -0,0 +1,28 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ AlternateFvBlock.c
+
+Abstract:
+
+ Tiano Guid used to define the Alternate Firmware Volume Block Guid.
+
+--*/
+
+#include "Tiano.h"
+#include EFI_GUID_DEFINITION (AlternateFvBlock)
+
+EFI_GUID gEfiAlternateFvBlockGuid = EFI_ALTERNATE_FV_BLOCK_GUID;
+
+EFI_GUID_STRING
+ (&gEfiAlternateFvBlockGuid, "Alternate Firmware Volume Block GUID", "Alternate Firmware Volume Block GUID");
diff --git a/EDK/Foundation/Guid/AlternateFvBlock/AlternateFvBlock.h b/EDK/Foundation/Guid/AlternateFvBlock/AlternateFvBlock.h
new file mode 100644
index 0000000..20f3977
--- /dev/null
+++ b/EDK/Foundation/Guid/AlternateFvBlock/AlternateFvBlock.h
@@ -0,0 +1,32 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ AlternateFvBlock.h
+
+Abstract:
+
+ Tiano Guid used to define the Alternate Firmware Volume Block Guid.
+
+--*/
+
+#ifndef _ALT_FVB_GUID_H
+#define _ALT_FVB_GUID_H
+
+#define EFI_ALTERNATE_FV_BLOCK_GUID \
+ { \
+ 0xf496922d, 0x172f, 0x4bbc, 0xa1, 0xeb, 0xe, 0xeb, 0x94, 0x9c, 0x34, 0x86 \
+ }
+
+extern EFI_GUID gEfiAlternateFvBlockGuid;
+
+#endif
diff --git a/EDK/Foundation/Guid/Bmp/Bmp.c b/EDK/Foundation/Guid/Bmp/Bmp.c
new file mode 100644
index 0000000..0a17246
--- /dev/null
+++ b/EDK/Foundation/Guid/Bmp/Bmp.c
@@ -0,0 +1,29 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Bmp.c
+ .c
+
+Abstract:
+
+ GUID used as a filename for the BMP logo
+
+--*/
+
+#include "Tiano.h"
+#include EFI_GUID_DEFINITION (Bmp)
+
+EFI_GUID gEfiDefaultBmpLogoGuid = EFI_DEFAULT_BMP_LOGO_GUID;
+
+EFI_GUID_STRING (&gEfiDefaultBmpLogoGuid, "Guid for BMP logo", "Guid for BMP logo");
+
diff --git a/EDK/Foundation/Guid/Bmp/Bmp.h b/EDK/Foundation/Guid/Bmp/Bmp.h
new file mode 100644
index 0000000..17f8b62
--- /dev/null
+++ b/EDK/Foundation/Guid/Bmp/Bmp.h
@@ -0,0 +1,62 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Bmp.h
+
+Abstract:
+
+--*/
+
+#ifndef _BMP_GUID_H_
+#define _BMP_GUID_H_
+
+
+//
+// Definitions for BMP files
+//
+#pragma pack(1)
+
+typedef struct {
+ UINT8 Blue;
+ UINT8 Green;
+ UINT8 Red;
+ UINT8 Reserved;
+} BMP_COLOR_MAP;
+
+typedef struct {
+ CHAR8 CharB;
+ CHAR8 CharM;
+ UINT32 Size;
+ UINT16 Reserved[2];
+ UINT32 ImageOffset;
+ UINT32 HeaderSize;
+ UINT32 PixelWidth;
+ UINT32 PixelHeight;
+ UINT16 Planes; // Must be 1
+ UINT16 BitPerPixel; // 1, 4, 8, or 24
+ UINT32 CompressionType;
+ UINT32 ImageSize; // Compressed image size in bytes
+ UINT32 XPixelsPerMeter;
+ UINT32 YPixelsPerMeter;
+ UINT32 NumberOfColors;
+ UINT32 ImportantColors;
+} BMP_IMAGE_HEADER;
+
+#pragma pack()
+
+#define EFI_DEFAULT_BMP_LOGO_GUID \
+ {0x7BB28B99,0x61BB,0x11d5,0x9A,0x5D,0x00,0x90,0x27,0x3F,0xC1,0x4D}
+
+extern EFI_GUID gEfiDefaultBmpLogoGuid;
+
+#endif
diff --git a/EDK/Foundation/Guid/BootState/BootState.c b/EDK/Foundation/Guid/BootState/BootState.c
new file mode 100644
index 0000000..b12ed44
--- /dev/null
+++ b/EDK/Foundation/Guid/BootState/BootState.c
@@ -0,0 +1,30 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ BootState.c
+
+Abstract:
+
+ GUID for use conveying the boot-state to PEI
+
+--*/
+
+#include "Tiano.h"
+#include EFI_GUID_DEFINITION (BootState)
+
+EFI_GUID gEfiBootStateGuid = EFI_BOOT_STATE_VARIABLE_GUID;
+
+//
+// GUID for frequency selection HOB
+//
+EFI_GUID_STRING(&gEfiBootStateGuid, "Boot State", "Boot State");
diff --git a/EDK/Foundation/Guid/BootState/BootState.h b/EDK/Foundation/Guid/BootState/BootState.h
new file mode 100644
index 0000000..42eed61
--- /dev/null
+++ b/EDK/Foundation/Guid/BootState/BootState.h
@@ -0,0 +1,38 @@
+/*++
+
+Copyright (c) 2004 - 2005, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ BootState.h
+
+Abstract:
+
+ Constants and declarations that are common accross PEI and DXE.
+--*/
+
+#ifndef _BOOT_STATE_H_
+#define _BOOT_STATE_H_
+
+#include "Tiano.h"
+
+//
+// BOOT STATE
+//
+
+typedef UINT32 EFI_BOOT_STATE;
+
+#define BOOT_STATE_VARIABLE_NAME L"BootState"
+
+#define EFI_BOOT_STATE_VARIABLE_GUID \
+ {0x60b5e939, 0xfcf, 0x4227, 0xba, 0x83, 0x6b, 0xbe, 0xd4, 0x5b, 0xc0, 0xe3}
+
+extern EFI_GUID gEfiBootStateGuid;
+#endif
diff --git a/EDK/Foundation/Guid/Capsule/Capsule.c b/EDK/Foundation/Guid/Capsule/Capsule.c
new file mode 100644
index 0000000..71bdbac
--- /dev/null
+++ b/EDK/Foundation/Guid/Capsule/Capsule.c
@@ -0,0 +1,29 @@
+/*++
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Capsule.c
+
+Abstract:
+
+ EFI Capsule update Guid data declarations.
+
+--*/
+
+#include "Tiano.h"
+
+#include EFI_GUID_DEFINITION(Capsule)
+
+EFI_GUID gEfiCapsuleVendorGuid = EFI_CAPSULE_VENDOR_GUID;
+
+EFI_GUID_STRING(&gEfiCapsuleVendorGuid, "EFI", "Efi Capsule GUID")
+
diff --git a/EDK/Foundation/Guid/Capsule/Capsule.h b/EDK/Foundation/Guid/Capsule/Capsule.h
new file mode 100644
index 0000000..6688874
--- /dev/null
+++ b/EDK/Foundation/Guid/Capsule/Capsule.h
@@ -0,0 +1,40 @@
+/*++
+
+Copyright (c) 2006 - 2011, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Capsule.h
+
+Abstract:
+
+ Capsule update Guid definitions
+
+--*/
+
+#ifndef _EFI_CAPSULE_VENDOR_GUID_H_
+#define _EFI_CAPSULE_VENDOR_GUID_H_
+
+//
+// Note -- This guid is used as a vendor GUID (depending on implementation)
+// for the capsule variable if the capsule pointer is passes through reset
+// via a variable.
+//
+#define EFI_CAPSULE_VENDOR_GUID \
+ { 0x711C703F, 0xC285, 0x4B10, 0xA3, 0xB0, 0x36, 0xEC, 0xBD, 0x3C, 0x8B, 0xE2 }
+
+//
+// Name of capsule variable.
+//
+#define EFI_CAPSULE_VARIABLE_NAME L"CapsuleUpdateData"
+
+extern EFI_GUID gEfiCapsuleVendorGuid;
+
+#endif // #ifndef _EFI_CAPSULE_VENDOR_GUID_H_
diff --git a/EDK/Foundation/Guid/CompatibleMemoryTested/CompatibleMemoryTested.c b/EDK/Foundation/Guid/CompatibleMemoryTested/CompatibleMemoryTested.c
new file mode 100644
index 0000000..c4a43bb
--- /dev/null
+++ b/EDK/Foundation/Guid/CompatibleMemoryTested/CompatibleMemoryTested.c
@@ -0,0 +1,28 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ CompatibleMemoryTested.c
+
+Abstract:
+
+ Tiano Guid used for all Compatible Memory Range Tested GUID.
+
+--*/
+
+#include "Tiano.h"
+#include EFI_GUID_DEFINITION (CompatibleMemoryTested)
+
+EFI_GUID gEfiCompatibleMemoryTestedGuid = EFI_COMPATIBLE_MEMORY_TESTED_PROTOCOL_GUID;
+
+EFI_GUID_STRING
+ (&gEfiCompatibleMemoryTestedGuid, "CompatibleMemoryTested Protocol", "Tiano Generic Memory Test Protocol");
diff --git a/EDK/Foundation/Guid/CompatibleMemoryTested/CompatibleMemoryTested.h b/EDK/Foundation/Guid/CompatibleMemoryTested/CompatibleMemoryTested.h
new file mode 100644
index 0000000..5eef353
--- /dev/null
+++ b/EDK/Foundation/Guid/CompatibleMemoryTested/CompatibleMemoryTested.h
@@ -0,0 +1,32 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ CompatibleMemoryTested.h
+
+Abstract:
+
+ Tiano Guid used for all Compatible Memory Range Tested GUID.
+
+--*/
+
+#ifndef _COMPATIBLE_MEMORY_TESTED_GUID_H_
+#define _COMPATIBLE_MEMORY_TESTED_GUID_H_
+
+#define EFI_COMPATIBLE_MEMORY_TESTED_PROTOCOL_GUID \
+ { \
+ 0x64c475ef, 0x344b, 0x492c, 0x93, 0xad, 0xab, 0x9e, 0xb4, 0x39, 0x50, 0x4 \
+ }
+
+extern EFI_GUID gEfiCompatibleMemoryTestedGuid;
+
+#endif
diff --git a/EDK/Foundation/Guid/ConsoleInDevice/ConsoleInDevice.c b/EDK/Foundation/Guid/ConsoleInDevice/ConsoleInDevice.c
new file mode 100644
index 0000000..6c40491
--- /dev/null
+++ b/EDK/Foundation/Guid/ConsoleInDevice/ConsoleInDevice.c
@@ -0,0 +1,27 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ ConsoleInDevice.c
+
+Abstract:
+
+
+--*/
+
+#include "Tiano.h"
+#include EFI_GUID_DEFINITION(ConsoleInDevice)
+
+
+EFI_GUID gEfiConsoleInDeviceGuid = EFI_CONSOLE_IN_DEVICE_GUID;
+
+EFI_GUID_STRING(&gEfiConsoleInDeviceGuid, "Console In Device Guid", "EFI Conosle In Device Guid");
diff --git a/EDK/Foundation/Guid/ConsoleInDevice/ConsoleInDevice.h b/EDK/Foundation/Guid/ConsoleInDevice/ConsoleInDevice.h
new file mode 100644
index 0000000..893a0b2
--- /dev/null
+++ b/EDK/Foundation/Guid/ConsoleInDevice/ConsoleInDevice.h
@@ -0,0 +1,29 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ ConsoleInDevice.h
+
+Abstract:
+
+
+--*/
+
+#ifndef _CONSOLE_IN_DEVICE_H_
+#define _CONSOLE_IN_DEVICE_H_
+
+#define EFI_CONSOLE_IN_DEVICE_GUID \
+ { 0xd3b36f2b, 0xd551, 0x11d4, 0x9a, 0x46, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d }
+
+extern EFI_GUID gEfiConsoleInDeviceGuid;
+
+#endif
diff --git a/EDK/Foundation/Guid/ConsoleOutDevice/ConsoleOutDevice.c b/EDK/Foundation/Guid/ConsoleOutDevice/ConsoleOutDevice.c
new file mode 100644
index 0000000..0cee45a
--- /dev/null
+++ b/EDK/Foundation/Guid/ConsoleOutDevice/ConsoleOutDevice.c
@@ -0,0 +1,27 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ ConsoleOutDevice.c
+
+Abstract:
+
+
+--*/
+
+#include "Tiano.h"
+#include EFI_GUID_DEFINITION(ConsoleOutDevice)
+
+
+EFI_GUID gEfiConsoleOutDeviceGuid = EFI_CONSOLE_OUT_DEVICE_GUID;
+
+EFI_GUID_STRING(&gEfiConsoleOutDeviceGuid, "Console Out Device Guid", "EFI Console Out Device Guid");
diff --git a/EDK/Foundation/Guid/ConsoleOutDevice/ConsoleOutDevice.h b/EDK/Foundation/Guid/ConsoleOutDevice/ConsoleOutDevice.h
new file mode 100644
index 0000000..1bf910f
--- /dev/null
+++ b/EDK/Foundation/Guid/ConsoleOutDevice/ConsoleOutDevice.h
@@ -0,0 +1,29 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ ConsoleOutDevice.h
+
+Abstract:
+
+
+--*/
+
+#ifndef _CONSOLE_OUT_DEVICE_H_
+#define _CONSOLE_OUT_DEVICE_H_
+
+#define EFI_CONSOLE_OUT_DEVICE_GUID \
+ { 0xd3b36f2c, 0xd551, 0x11d4, 0x9a, 0x46, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d }
+
+extern EFI_GUID gEfiConsoleOutDeviceGuid;
+
+#endif
diff --git a/EDK/Foundation/Guid/EdkGuidLib.cif b/EDK/Foundation/Guid/EdkGuidLib.cif
new file mode 100644
index 0000000..37e5d87
--- /dev/null
+++ b/EDK/Foundation/Guid/EdkGuidLib.cif
@@ -0,0 +1,68 @@
+<component>
+ name = "EdkGuidLib"
+ category = ModulePart
+ LocalRoot = "Edk\Foundation\Guid\"
+ RefName = "EdkGuidLib"
+[files]
+"EdkGuidLib.sdl"
+"EdkGuidLib.mak"
+"AlternateFvBlock\AlternateFvBlock.h"
+"AlternateFvBlock\AlternateFvBlock.c"
+"Bmp\Bmp.h"
+"Bmp\Bmp.c"
+"BootState\BootState.h"
+"BootState\BootState.c"
+"Capsule\Capsule.h"
+"Capsule\Capsule.c"
+"CompatibleMemoryTested\CompatibleMemoryTested.h"
+"CompatibleMemoryTested\CompatibleMemoryTested.c"
+"ConsoleInDevice\ConsoleInDevice.h"
+"ConsoleInDevice\ConsoleInDevice.c"
+"ConsoleOutDevice\ConsoleOutDevice.h"
+"ConsoleOutDevice\ConsoleOutDevice.c"
+"EfiShell\EfiShell.h"
+"EfiShell\EfiShell.c"
+"FlashMapHob\FlashMapHob.h"
+"FlashMapHob\FlashMapHob.c"
+"HotPlugDevice\HotPlugDevice.h"
+"HotPlugDevice\HotPlugDevice.c"
+"IoBaseHob\IoBaseHob.h"
+"IoBaseHob\IoBaseHob.c"
+"MemoryTypeInformation\MemoryTypeInformation.h"
+"MemoryTypeInformation\MemoryTypeInformation.c"
+"PciHotPlugDevice\PciHotplugDevice.h"
+"PciHotPlugDevice\PciHotplugDevice.c"
+"PciOptionRomTable\PciOptionRomTable.h"
+"PciOptionRomTable\PciOptionRomTable.c"
+"PciExpressBaseAddress\PciExpressBaseAddress.h"
+"PciExpressBaseAddress\PciExpressBaseAddress.c"
+"PeiFlushInstructionCache\PeiFlushInstructionCache.h"
+"PeiFlushInstructionCache\PeiFlushInstructionCache.c"
+"PeiPeCoffLoader\PeiPeCoffLoader.h"
+"PeiPeCoffLoader\PeiPeCoffLoader.c"
+"PeiPerformanceHob\PeiPerformanceHob.h"
+"PeiPerformanceHob\PeiPerformanceHob.c"
+"PeiTransferControl\PeiTransferControl.h"
+"PeiTransferControl\PeiTransferControl.c"
+"PrimaryConsoleInDevice\PrimaryConsoleInDevice.h"
+"PrimaryConsoleInDevice\PrimaryConsoleInDevice.c"
+"PrimaryConsoleOutDevice\PrimaryConsoleOutDevice.h"
+"PrimaryConsoleOutDevice\PrimaryConsoleOutDevice.c"
+"PrimaryStandardErrorDevice\PrimaryStandardErrorDevice.h"
+"PrimaryStandardErrorDevice\PrimaryStandardErrorDevice.c"
+"StandardErrorDevice\StandardErrorDevice.h"
+"StandardErrorDevice\StandardErrorDevice.c"
+"StatusCode\StatusCode.h"
+"StatusCode\StatusCode.c"
+"StatusCodeCallerId\StatusCodeCallerId.h"
+"StatusCodeCallerId\StatusCodeCallerId.c"
+"SystemNvDataGuid\SystemNvDataGuid.h"
+"SystemNvDataGuid\SystemNvDataGuid.c"
+"EventLegacyBios\EventLegacyBios.h"
+"EventLegacyBios\EventLegacyBios.c"
+"GenericVariable\GenericVariable.h"
+"GenericVariable\GenericVariable.c"
+"EdkGuidLib.inf"
+"FastBootExceptionInfo\FastBootExceptionInfo.c"
+"FastBootExceptionInfo\FastBootExceptionInfo.h"
+<endComponent>
diff --git a/EDK/Foundation/Guid/EdkGuidLib.inf b/EDK/Foundation/Guid/EdkGuidLib.inf
new file mode 100644
index 0000000..fc47f75
--- /dev/null
+++ b/EDK/Foundation/Guid/EdkGuidLib.inf
@@ -0,0 +1,98 @@
+#/*++
+#
+# Copyright (c) 2004 - 2006, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# EdkGuidLib.inf
+#
+# Abstract:
+#
+# Component description file for the Edk Guid library.
+#
+#--*/
+[defines]
+BASE_NAME= EdkGuidLib
+COMPONENT_TYPE= LIBRARY
+
+[includes.common]
+ $(EDK_SOURCE)\Foundation
+ $(EDK_SOURCE)\Foundation\Framework
+ $(EDK_SOURCE)\Foundation\Efi
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+ $(EDK_SOURCE)\Foundation\Include\Pei
+ $(EDK_SOURCE)\Foundation\Library\Pei\Include
+
+[nmake.common]
+C_STD_INCLUDE=
+[sources.common]
+ AlternateFvBlock\AlternateFvBlock.h
+ AlternateFvBlock\AlternateFvBlock.c
+ Bmp\Bmp.h
+ Bmp\Bmp.c
+ BootState\BootState.h
+ BootState\BootState.c
+ Capsule\Capsule.h
+ Capsule\Capsule.c
+ CompatibleMemoryTested\CompatibleMemoryTested.h
+ CompatibleMemoryTested\CompatibleMemoryTested.c
+ ConsoleInDevice\ConsoleInDevice.h
+ ConsoleInDevice\ConsoleInDevice.c
+ ConsoleOutDevice\ConsoleOutDevice.h
+ ConsoleOutDevice\ConsoleOutDevice.c
+ EfiShell\EfiShell.h
+ EfiShell\EfiShell.c
+ FlashMapHob\FlashMapHob.h
+ FlashMapHob\FlashMapHob.c
+ HotPlugDevice\HotPlugDevice.h
+ HotPlugDevice\HotPlugDevice.c
+ IoBaseHob\IoBaseHob.h
+ IoBaseHob\IoBaseHob.c
+ MemoryTypeInformation\MemoryTypeInformation.h
+ MemoryTypeInformation\MemoryTypeInformation.c
+ PciHotPlugDevice\PciHotPlugDevice.h
+ PciHotPlugDevice\PciHotPlugDevice.c
+ PciOptionRomTable\PciOptionRomTable.h
+ PciOptionRomTable\PciOptionRomTable.c
+ PciExpressBaseAddress\PciExpressBaseAddress.h
+ PciExpressBaseAddress\PciExpressBaseAddress.c
+ PeiFlushInstructionCache\PeiFlushInstructionCache.h
+ PeiFlushInstructionCache\PeiFlushInstructionCache.c
+ PeiPeCoffLoader\PeiPeCoffLoader.h
+ PeiPeCoffLoader\PeiPeCoffLoader.c
+ PeiPerformanceHob\PeiPerformanceHob.h
+ PeiPerformanceHob\PeiPerformanceHob.c
+ PeiTransferControl\PeiTransferControl.h
+ PeiTransferControl\PeiTransferControl.c
+ PrimaryConsoleInDevice\PrimaryConsoleInDevice.h
+ PrimaryConsoleInDevice\PrimaryConsoleInDevice.c
+ PrimaryConsoleOutDevice\PrimaryConsoleOutDevice.h
+ PrimaryConsoleOutDevice\PrimaryConsoleOutDevice.c
+ PrimaryStandardErrorDevice\PrimaryStandardErrorDevice.h
+ PrimaryStandardErrorDevice\PrimaryStandardErrorDevice.c
+ StandardErrorDevice\StandardErrorDevice.h
+ StandardErrorDevice\StandardErrorDevice.c
+ StatusCode\StatusCode.h
+ StatusCode\StatusCode.c
+ StatusCodeCallerId\StatusCodeCallerId.h
+ StatusCodeCallerId\StatusCodeCallerId.c
+ SystemNvDataGuid\SystemNvDataGuid.h
+ SystemNvDataGuid\SystemNvDataGuid.c
+ EventLegacyBios\EventLegacyBios.h
+ EventLegacyBios\EventLegacyBios.c
+ GenericVariable\GenericVariable.h
+ GenericVariable\GenericVariable.c
+ FastBootExceptionInfo\FastBootExceptionInfo.h
+ FastBootExceptionInfo\FastBootExceptionInfo.c
diff --git a/EDK/Foundation/Guid/EdkGuidLib.mak b/EDK/Foundation/Guid/EdkGuidLib.mak
new file mode 100644
index 0000000..74a330c
--- /dev/null
+++ b/EDK/Foundation/Guid/EdkGuidLib.mak
@@ -0,0 +1,73 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkGuidLib/EdkGuidLib.mak 1 1/20/12 4:04a Jeffch $
+#
+# $Revision: 1 $
+#
+# $Date: 1/20/12 4:04a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkGuidLib/EdkGuidLib.mak $
+#
+# 1 1/20/12 4:04a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 9/27/11 6:28a Wesleychen
+# Intel EDK initially releases.
+#
+# 2 9/02/09 3:22a Iminglin
+# EIP24919
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: EdkGuidLib.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+
+$(EDKGUIDLIB) : EdkGuidLib
+
+EdkGuidLib : $(BUILD_DIR)\EdkGuidLib.mak EdkGuidLibBin
+
+$(BUILD_DIR)\EdkGuidLib.mak : $(EdkGuidLib_DIR)\$(@B).cif $(EdkGuidLib_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(EdkGuidLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+EdkGuidLibBin :
+ $(MAKE) /$(MAKEFLAGS) $(EDK_DEFAULTS)\
+ /f $(BUILD_DIR)\EdkGuidLib.mak all\
+ TYPE=LIBRARY
+!IF "$(x64_BUILD)"=="1"
+ $(MAKE) /$(MAKEFLAGS) $(EDK_DEFAULTS) BUILD_DIR=$(BUILD_DIR)\IA32\
+ /f $(BUILD_DIR)\EdkGuidLib.mak all\
+ TYPE=PEI_LIBRARY
+!ENDIF
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#********************************************************************** \ No newline at end of file
diff --git a/EDK/Foundation/Guid/EdkGuidLib.sdl b/EDK/Foundation/Guid/EdkGuidLib.sdl
new file mode 100644
index 0000000..e5dddb6
--- /dev/null
+++ b/EDK/Foundation/Guid/EdkGuidLib.sdl
@@ -0,0 +1,26 @@
+TOKEN
+ Name = "EdkGuidLib_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable EdkGuidLib support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "EDKGUIDLIB"
+ Value = "$$(LIB_BUILD_DIR)\EdkGuidLib.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "EdkGuidLib_DIR"
+End
+
+MODULE
+ Help = "Includes EdkGuidLib.mak to Project"
+ File = "EdkGuidLib.mak"
+End
+
diff --git a/EDK/Foundation/Guid/EfiShell/EfiShell.c b/EDK/Foundation/Guid/EfiShell/EfiShell.c
new file mode 100644
index 0000000..29d46bc
--- /dev/null
+++ b/EDK/Foundation/Guid/EfiShell/EfiShell.c
@@ -0,0 +1,31 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiShell.c
+
+Abstract:
+
+ FFS Filename for EFI Shell
+
+--*/
+
+#include "Tiano.h"
+
+#include EFI_GUID_DEFINITION (EfiShell)
+
+EFI_GUID gEfiShellFileGuid = EFI_SHELL_FILE_GUID;
+EFI_GUID gEfiMiniShellFileGuid = EFI_MINI_SHELL_FILE_GUID;
+
+EFI_GUID_STRING (&gEfiShellFileGuid, "EfiShell", "Efi Shell FFS file name GUID")
+EFI_GUID_STRING (&gEfiMiniShellFileGuid, "EfiMiniShell", "Efi Mini-Shell FFS file name GUID")
+
diff --git a/EDK/Foundation/Guid/EfiShell/EfiShell.h b/EDK/Foundation/Guid/EfiShell/EfiShell.h
new file mode 100644
index 0000000..3e7030b
--- /dev/null
+++ b/EDK/Foundation/Guid/EfiShell/EfiShell.h
@@ -0,0 +1,34 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiShell.h
+
+Abstract:
+
+ FFS Filename for EFI Shell
+
+--*/
+
+#ifndef _EFI_SHELL_H_
+#define _EFI_SHELL_H_
+
+#define EFI_SHELL_FILE_GUID \
+ { 0xc57ad6b7, 0x0515, 0x40a8, 0x9d, 0x21, 0x55, 0x16, 0x52, 0x85, 0x4e, 0x37 }
+
+#define EFI_MINI_SHELL_FILE_GUID \
+ { 0x86ad232b, 0xd33a, 0x465c, 0xbf, 0x5f, 0x41, 0x37, 0xb, 0xa9, 0x2f, 0xe2 }
+
+extern EFI_GUID gEfiShellFileGuid;
+extern EFI_GUID gEfiMiniShellFileGuid;
+
+#endif
diff --git a/EDK/Foundation/Guid/EventLegacyBios/EventLegacyBios.c b/EDK/Foundation/Guid/EventLegacyBios/EventLegacyBios.c
new file mode 100644
index 0000000..b1e754d
--- /dev/null
+++ b/EDK/Foundation/Guid/EventLegacyBios/EventLegacyBios.c
@@ -0,0 +1,23 @@
+/*++
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiLegacyBios.c
+
+--*/
+#include "Tiano.h"
+
+#include EFI_GUID_DEFINITION (EventLegacyBios)
+
+EFI_GUID gEfiEventLegacyBootGuid = EFI_EVENT_LEGACY_BOOT_GUID;
+
+EFI_GUID_STRING (&gEfiEventLegacyBootGuid, "EventLegacyBoot", "Event Legacy Boot GUID")
diff --git a/EDK/Foundation/Guid/EventLegacyBios/EventLegacyBios.h b/EDK/Foundation/Guid/EventLegacyBios/EventLegacyBios.h
new file mode 100644
index 0000000..13737df
--- /dev/null
+++ b/EDK/Foundation/Guid/EventLegacyBios/EventLegacyBios.h
@@ -0,0 +1,28 @@
+/** @file
+ GUID is the name of events used with CreateEventEx in order to be notified when the EFI boot manager is about to boot a legacy boot option. Events of this type are notificated just before Int19h is invoked.
+
+ Copyright (c) 2006, Intel Corporation
+ All rights reserved. This program and the accompanying materials
+ are licensed and made available under the terms and conditions of the BSD License
+ which accompanies this distribution. The full text of the license may be found at
+ http://opensource.org/licenses/bsd-license.php
+
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+ Module Name: EventLegacyBios.h
+
+ @par Revision Reference:
+ GUIDs defined in DXE CIS 0.91b.
+
+**/
+
+#ifndef __EVENT_LEGACY_BIOS_GUID_H__
+#define __EVENT_LEGACY_BIOS_GUID_H__
+
+#define EFI_EVENT_LEGACY_BOOT_GUID \
+ { 0x2a571201, 0x4966, 0x47f6, 0x8b, 0x86, 0xf3, 0x1e, 0x41, 0xf3, 0x2f, 0x10 }
+
+extern EFI_GUID gEfiEventLegacyBootGuid;
+
+#endif
diff --git a/EDK/Foundation/Guid/FastBootExceptionInfo/FastBootExceptionInfo.c b/EDK/Foundation/Guid/FastBootExceptionInfo/FastBootExceptionInfo.c
new file mode 100644
index 0000000..44347a6
--- /dev/null
+++ b/EDK/Foundation/Guid/FastBootExceptionInfo/FastBootExceptionInfo.c
@@ -0,0 +1,27 @@
+/*++
+
+Copyright (c) 1999 - 2011 Intel Corporation. All rights reserved
+This software and associated documentation (if any) is furnished
+under a license and may only be used or copied in accordance
+with the terms of the license. Except as permitted by such
+license, no part of this software or documentation may be
+reproduced, stored in a retrieval system, or transmitted in any
+form or by any means without the express written consent of
+Intel Corporation.
+
+Module Name:
+
+ FastBootExceptionInfo.c
+
+Abstract:
+
+
+--*/
+
+#include "Tiano.h"
+
+#include EFI_GUID_DEFINITION (FastBootExceptionInfo)
+
+EFI_GUID gFastBootExceptionInfoHobGuid = FAST_BOOT_EXCEPTION_INFO_HOB_GUID;
+
+EFI_GUID_STRING(&gFastBootExceptionInfoHobGuid, "FastBootExceptionInfoHob", "Fast Boot Exception Info HOB");
diff --git a/EDK/Foundation/Guid/FastBootExceptionInfo/FastBootExceptionInfo.h b/EDK/Foundation/Guid/FastBootExceptionInfo/FastBootExceptionInfo.h
new file mode 100644
index 0000000..4d11816
--- /dev/null
+++ b/EDK/Foundation/Guid/FastBootExceptionInfo/FastBootExceptionInfo.h
@@ -0,0 +1,44 @@
+/*++
+
+Copyright (c) 1999 - 2011 Intel Corporation. All rights reserved
+This software and associated documentation (if any) is furnished
+under a license and may only be used or copied in accordance
+with the terms of the license. Except as permitted by such
+license, no part of this software or documentation may be
+reproduced, stored in a retrieval system, or transmitted in any
+form or by any means without the express written consent of
+Intel Corporation.
+
+Module Name:
+
+ FastBootExceptionInfo.h
+
+Abstract:
+
+ This file defines the HOB data structure recording an Fast Boot exception
+ occurrence in PEI phase, which will be used/referenced by some DXE phase drivers.
+
+--*/
+
+#ifndef _FAST_BOOT_EXCEPTION_INFO_HOB_GUID_H_
+#define _FAST_BOOT_EXCEPTION_INFO_HOB_GUID_H_
+
+#include <PeiHob.h>
+#include <FastBootDataDef.h>
+
+#define FAST_BOOT_EXCEPTION_INFO_HOB_GUID \
+ { 0x4ed88276, 0xd4df, 0x4d03, 0x86, 0x61, 0x29, 0x58, 0x1, 0xb2, 0xda, 0x58 }
+
+EFI_FORWARD_DECLARATION (FAST_BOOT_EXCEPTION_INFO_HOB);
+
+typedef struct _FAST_BOOT_EXCEPTION_INFO_HOB {
+ EFI_HOB_GUID_TYPE Header;
+ EFI_GUID GuidName;
+ FAST_BOOT_EXCEPTION_TYPE FbExceptionType;
+ FAST_BOOT_EXCEPTION_CATEGORY FbExceptionCategory;
+};
+
+extern EFI_GUID gFastBootExceptionInfoHobGuid;
+
+#endif
+
diff --git a/EDK/Foundation/Guid/FlashMapHob/FlashMapHob.c b/EDK/Foundation/Guid/FlashMapHob/FlashMapHob.c
new file mode 100644
index 0000000..7e093e8
--- /dev/null
+++ b/EDK/Foundation/Guid/FlashMapHob/FlashMapHob.c
@@ -0,0 +1,29 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ FlashMapHob.c
+
+Abstract:
+
+ GUIDs used for Flash Map HOB entries in the in the HOB list.
+
+--*/
+
+#include "Tiano.h"
+#include EFI_GUID_DEFINITION (FlashMapHob)
+
+
+EFI_GUID gEfiFlashMapHobGuid = EFI_FLASH_MAP_HOB_GUID;
+
+EFI_GUID_STRING (&gEfiFlashMapHobGuid, "Flash Map HOB", "Flash Map HOB GUID for HOB list");
+
diff --git a/EDK/Foundation/Guid/FlashMapHob/FlashMapHob.h b/EDK/Foundation/Guid/FlashMapHob/FlashMapHob.h
new file mode 100644
index 0000000..247441b
--- /dev/null
+++ b/EDK/Foundation/Guid/FlashMapHob/FlashMapHob.h
@@ -0,0 +1,33 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ FlashMapHob.h
+
+Abstract:
+
+ GUID used for Flash Map HOB entries in the HOB list.
+
+--*/
+
+#ifndef _FLASH_MAP_HOB_GUID_H_
+#define _FLASH_MAP_HOB_GUID_H_
+
+//
+// Definitions for Flash Map
+//
+#define EFI_FLASH_MAP_HOB_GUID \
+ { 0xb091e7d2, 0x5a0, 0x4198, 0x94, 0xf0, 0x74, 0xb7, 0xb8, 0xc5, 0x54, 0x59 }
+
+extern EFI_GUID gEfiFlashMapHobGuid;
+
+#endif // _FLASH_MAP_HOB_GUID_H_
diff --git a/EDK/Foundation/Guid/GenericVariable/GenericVariable.c b/EDK/Foundation/Guid/GenericVariable/GenericVariable.c
new file mode 100644
index 0000000..9079610
--- /dev/null
+++ b/EDK/Foundation/Guid/GenericVariable/GenericVariable.c
@@ -0,0 +1,27 @@
+/*++
+
+Copyright (c) 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ GenericVariable.c
+
+Abstract:
+
+ The variable space Guid to pair with a Unicode string name to tag an EFI variable
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_GUID_DEFINITION (GenericVariable)
+
+EFI_GUID gEfiGenericVariableGuid = EFI_GENERIC_VARIABLE_GUID;
+
+EFI_GUID_STRING(&gEfiGenericVariableGuid, "GenericVariable", "Generic Variable GUID");
diff --git a/EDK/Foundation/Guid/GenericVariable/GenericVariable.h b/EDK/Foundation/Guid/GenericVariable/GenericVariable.h
new file mode 100644
index 0000000..416a1a5
--- /dev/null
+++ b/EDK/Foundation/Guid/GenericVariable/GenericVariable.h
@@ -0,0 +1,32 @@
+/*++
+
+Copyright (c) 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ GenericVariable.h
+
+Abstract:
+
+ The variable space Guid to pair with a Unicode string name to tag an EFI variable
+
+--*/
+
+#ifndef _GENERIC_VARIABLE_H_
+#define _GENERIC_VARIABLE_H_
+
+#define EFI_GENERIC_VARIABLE_GUID \
+ { \
+ 0x59d1c24f, 0x50f1, 0x401a, 0xb1, 0x01, 0xf3, 0x3e, 0x0d, 0xae, 0xd4, 0x43 \
+ }
+
+extern EFI_GUID gEfiGenericVariableGuid;
+
+#endif
diff --git a/EDK/Foundation/Guid/HotPlugDevice/HotPlugDevice.c b/EDK/Foundation/Guid/HotPlugDevice/HotPlugDevice.c
new file mode 100644
index 0000000..e0df677
--- /dev/null
+++ b/EDK/Foundation/Guid/HotPlugDevice/HotPlugDevice.c
@@ -0,0 +1,27 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ HotPlugDevice.c
+
+Abstract:
+
+
+--*/
+
+#include "Tiano.h"
+#include EFI_GUID_DEFINITION(HotPlugDevice)
+
+
+EFI_GUID gEfiHotPlugDeviceGuid = HOT_PLUG_DEVICE_GUID;
+
+EFI_GUID_STRING(&gEfiHotPlugDeviceGuid, "Hot Plug Device Guid", "Hot Plug Device Guid");
diff --git a/EDK/Foundation/Guid/HotPlugDevice/HotPlugDevice.h b/EDK/Foundation/Guid/HotPlugDevice/HotPlugDevice.h
new file mode 100644
index 0000000..01e9ce3
--- /dev/null
+++ b/EDK/Foundation/Guid/HotPlugDevice/HotPlugDevice.h
@@ -0,0 +1,28 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ HotPlugDevice.h
+
+Abstract:
+
+
+--*/
+
+#ifndef _HOT_PLUG_DEVICE_H_
+#define _HOT_PLUG_DEVICE_H_
+
+#define HOT_PLUG_DEVICE_GUID \
+ { 0x220ac432, 0x1d43, 0x49e5, 0xa7, 0x4f, 0x4c, 0x9d, 0xa6, 0x7a, 0xd2, 0x3b }
+
+extern EFI_GUID gEfiHotPlugDeviceGuid;
+#endif
diff --git a/EDK/Foundation/Guid/IoBaseHob/IoBaseHob.c b/EDK/Foundation/Guid/IoBaseHob/IoBaseHob.c
new file mode 100644
index 0000000..d34e843
--- /dev/null
+++ b/EDK/Foundation/Guid/IoBaseHob/IoBaseHob.c
@@ -0,0 +1,29 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ IoBaseHob.c
+
+Abstract:
+
+ GUIDs used for IoBase HOB entries in the in the HOB list.
+
+--*/
+
+#include "Tiano.h"
+#include EFI_GUID_DEFINITION(IoBaseHob)
+
+
+EFI_GUID gEfiIoBaseHobGuid = EFI_IOBASE_HOB_GUID;
+
+EFI_GUID_STRING(&gEfiIoBaseHobGuid, "IOBASE HOB", "IOBASE HOB GUID for HOB list.");
+
diff --git a/EDK/Foundation/Guid/IoBaseHob/IoBaseHob.h b/EDK/Foundation/Guid/IoBaseHob/IoBaseHob.h
new file mode 100644
index 0000000..81ef1dc
--- /dev/null
+++ b/EDK/Foundation/Guid/IoBaseHob/IoBaseHob.h
@@ -0,0 +1,30 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ IoBaseHob.h
+
+Abstract:
+
+ GUID used for IoBase HOB entries in the HOB list.
+
+--*/
+
+#ifndef _IOBASE_GUID_H_
+#define _IOBASE_GUID_H_
+
+#define EFI_IOBASE_HOB_GUID \
+{ 0xd4a28a3e, 0xdcf2, 0x43cf, 0xa2, 0xb7, 0xf3, 0x57, 0x2a, 0x7c, 0xab, 0x9 }
+
+extern EFI_GUID gEfiIoBaseHobGuid;
+
+#endif
diff --git a/EDK/Foundation/Guid/MemoryTypeInformation/MemoryTypeInformation.c b/EDK/Foundation/Guid/MemoryTypeInformation/MemoryTypeInformation.c
new file mode 100644
index 0000000..c1a5cb1
--- /dev/null
+++ b/EDK/Foundation/Guid/MemoryTypeInformation/MemoryTypeInformation.c
@@ -0,0 +1,29 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ MemoryTypeInformation.c
+
+Abstract:
+
+ GUID used for Memory Type Information entries in the HOB list.
+
+--*/
+
+#include "Tiano.h"
+#include EFI_GUID_DEFINITION(MemoryTypeInformation)
+
+EFI_GUID gEfiMemoryTypeInformationGuid = EFI_MEMORY_TYPE_INFORMATION_GUID;
+
+EFI_GUID_STRING(&gEfiMemoryTypeInformationGuid, "Memory Type Information",
+ "Memory Type Information HOB GUID for HOB list.");
+
diff --git a/EDK/Foundation/Guid/MemoryTypeInformation/MemoryTypeInformation.h b/EDK/Foundation/Guid/MemoryTypeInformation/MemoryTypeInformation.h
new file mode 100644
index 0000000..79f02b0
--- /dev/null
+++ b/EDK/Foundation/Guid/MemoryTypeInformation/MemoryTypeInformation.h
@@ -0,0 +1,37 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ MemoryTypeInformation.h
+
+Abstract:
+
+ GUID used for Memory Type Information entries in the HOB list.
+
+--*/
+
+#ifndef _MEMORY_TYPE_INFORMATION_GUID_H_
+#define _MEMORY_TYPE_INFORMATION_GUID_H_
+
+#define EFI_MEMORY_TYPE_INFORMATION_GUID \
+ { 0x4c19049f,0x4137,0x4dd3,0x9c,0x10,0x8b,0x97,0xa8,0x3f,0xfd,0xfa }
+
+#define EFI_MEMORY_TYPE_INFORMATION_VARIABLE_NAME L"MemoryTypeInformation"
+
+extern EFI_GUID gEfiMemoryTypeInformationGuid;
+
+typedef struct {
+ UINT32 Type;
+ UINT32 NumberOfPages;
+} EFI_MEMORY_TYPE_INFORMATION;
+
+#endif
diff --git a/EDK/Foundation/Guid/PciExpressBaseAddress/PciExpressBaseAddress.c b/EDK/Foundation/Guid/PciExpressBaseAddress/PciExpressBaseAddress.c
new file mode 100644
index 0000000..4e0a95b
--- /dev/null
+++ b/EDK/Foundation/Guid/PciExpressBaseAddress/PciExpressBaseAddress.c
@@ -0,0 +1,28 @@
+/*++
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PciExpressBaseAddress.c
+
+Abstract:
+
+
+ GUIDs used for PciExpress Base Address
+
+--*/
+
+#include "Tiano.h"
+#include EFI_GUID_DEFINITION (PciExpressBaseAddress)
+
+EFI_GUID gEfiPciExpressBaseAddressGuid = EFI_PCI_EXPRESS_BASE_ADDRESS_GUID;
+
+EFI_GUID_STRING(&gEfiPciExpressBaseAddressGuid, "PCI Express Base Address", "PCI Express Base Address GUID");
diff --git a/EDK/Foundation/Guid/PciExpressBaseAddress/PciExpressBaseAddress.h b/EDK/Foundation/Guid/PciExpressBaseAddress/PciExpressBaseAddress.h
new file mode 100644
index 0000000..ca0b4b6
--- /dev/null
+++ b/EDK/Foundation/Guid/PciExpressBaseAddress/PciExpressBaseAddress.h
@@ -0,0 +1,46 @@
+/*++
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PciExpressBaseAddress.h
+
+Abstract:
+
+
+ GUIDs used for PciExpress Base Address
+
+--*/
+
+#ifndef _EFI_PCI_EXPRESS_BASE_ADDRESS_H_
+#define _EFI_PCI_EXPRESS_BASE_ADDRESS_H_
+
+#define EFI_PCI_EXPRESS_BASE_ADDRESS_GUID \
+ { \
+ 0x3677d529, 0x326f, 0x4603, 0xa9, 0x26, 0xea, 0xac, 0xe0, 0x1d, 0xcb, 0xb0 \
+ }
+
+//
+// Following structure defines PCI Express Base Address information.
+// This information is platform specific, and built into hob in PEI phase.
+// It can be consumed by PEI PCI driver and DXE PCI driver.
+//
+#pragma pack(1)
+typedef struct _EFI_PCI_EXPRESS_BASE_ADDRESS_INFORMATION {
+ UINT32 HostBridgeNumber;
+ UINT32 RootBridgeNumber;
+ UINT64 PciExpressBaseAddress;
+} EFI_PCI_EXPRESS_BASE_ADDRESS_INFORMATION;
+#pragma pack()
+
+extern EFI_GUID gEfiPciExpressBaseAddressGuid;
+
+#endif
diff --git a/EDK/Foundation/Guid/PciHotPlugDevice/PciHotplugDevice.c b/EDK/Foundation/Guid/PciHotPlugDevice/PciHotplugDevice.c
new file mode 100644
index 0000000..6af4025
--- /dev/null
+++ b/EDK/Foundation/Guid/PciHotPlugDevice/PciHotplugDevice.c
@@ -0,0 +1,29 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PciHotplugDevice.c
+
+Abstract:
+
+
+ GUIDs used to indicate the device is Pccard hotplug device
+
+--*/
+
+#include "Tiano.h"
+#include EFI_GUID_DEFINITION(PciHotplugDevice)
+
+
+EFI_GUID gEfiPciHotplugDeviceGuid = EFI_PCI_HOTPLUG_DEVICE_GUID;
+
+EFI_GUID_STRING(&gEfiPciHotplugDeviceGuid, "PCI Hotplug Device", "PCI Hotplug Device GUID in EFI System Table");
diff --git a/EDK/Foundation/Guid/PciHotPlugDevice/PciHotplugDevice.h b/EDK/Foundation/Guid/PciHotPlugDevice/PciHotplugDevice.h
new file mode 100644
index 0000000..f036696
--- /dev/null
+++ b/EDK/Foundation/Guid/PciHotPlugDevice/PciHotplugDevice.h
@@ -0,0 +1,30 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PciHotplugDevice.h
+
+Abstract:
+
+ GUIDs used to indicate the device is Pccard hotplug device
+
+--*/
+
+#ifndef _PCI_HOTPLUG_DEVICE_GUID_H_
+#define _PCI_HOTPLUG_DEVICE_GUID_H_
+
+#define EFI_PCI_HOTPLUG_DEVICE_GUID \
+ { 0x0b280816, 0x52e7, 0x4e51, 0xaa, 0x57, 0x11, 0xbd, 0x41, 0xcb, 0xef, 0xc3 }
+
+extern EFI_GUID gEfiPciHotplugDeviceGuid;
+
+#endif
diff --git a/EDK/Foundation/Guid/PciOptionRomTable/PciOptionRomTable.c b/EDK/Foundation/Guid/PciOptionRomTable/PciOptionRomTable.c
new file mode 100644
index 0000000..72f7063
--- /dev/null
+++ b/EDK/Foundation/Guid/PciOptionRomTable/PciOptionRomTable.c
@@ -0,0 +1,27 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PciOptionRomTable.c
+
+Abstract:
+
+ GUID and data structure used to describe the list of PCI Option ROMs present in a system.
+
+--*/
+
+#include "Tiano.h"
+#include EFI_GUID_DEFINITION(PciOptionRomTable)
+
+EFI_GUID gEfiPciOptionRomTableGuid = EFI_PCI_OPTION_ROM_TABLE_GUID;
+
+EFI_GUID_STRING(&gEfiPciOptionRomTableGuid, "PCI Option ROM Table", "PCI Option ROM Table GUID in EFI System Table");
diff --git a/EDK/Foundation/Guid/PciOptionRomTable/PciOptionRomTable.h b/EDK/Foundation/Guid/PciOptionRomTable/PciOptionRomTable.h
new file mode 100644
index 0000000..81f1816
--- /dev/null
+++ b/EDK/Foundation/Guid/PciOptionRomTable/PciOptionRomTable.h
@@ -0,0 +1,48 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PciOptionRomTable.h
+
+Abstract:
+
+ GUID and data structure used to describe the list of PCI Option ROMs present in a system.
+
+--*/
+
+#ifndef _PCI_OPTION_ROM_TABLE_GUID_H_
+#define _PCI_OPTION_ROM_TABLE_GUID_H_ //;;## ...AMI_OVERRIDE... fixed Build error.
+
+
+#define EFI_PCI_OPTION_ROM_TABLE_GUID \
+ { 0x7462660f, 0x1cbd, 0x48da, 0xad, 0x11, 0x91, 0x71, 0x79, 0x13, 0x83, 0x1c }
+
+extern EFI_GUID gEfiPciOptionRomTableGuid;
+
+typedef struct {
+ EFI_PHYSICAL_ADDRESS RomAddress;
+ EFI_MEMORY_TYPE MemoryType;
+ UINT32 RomLength;
+ UINT32 Seg;
+ UINT8 Bus;
+ UINT8 Dev;
+ UINT8 Func;
+ BOOLEAN ExecutedLegacyBiosImage;
+ BOOLEAN DontLoadEfiRom;
+} EFI_PCI_OPTION_ROM_DESCRIPTOR;
+
+typedef struct {
+ UINT64 PciOptionRomCount;
+ EFI_PCI_OPTION_ROM_DESCRIPTOR *PciOptionRomDescriptors;
+} EFI_PCI_OPTION_ROM_TABLE;
+
+#endif
diff --git a/EDK/Foundation/Guid/PeiFlushInstructionCache/PeiFlushInstructionCache.c b/EDK/Foundation/Guid/PeiFlushInstructionCache/PeiFlushInstructionCache.c
new file mode 100644
index 0000000..da9dd92
--- /dev/null
+++ b/EDK/Foundation/Guid/PeiFlushInstructionCache/PeiFlushInstructionCache.c
@@ -0,0 +1,29 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PeiFlushInstructionCache.c
+
+Abstract:
+
+ GUID for the Instruction Cache Flushing APIs shared between PEI and DXE
+
+--*/
+
+#include "Tiano.h"
+#include EFI_GUID_DEFINITION(PeiFlushInstructionCache)
+
+EFI_GUID gEfiPeiFlushInstructionCacheGuid = EFI_PEI_FLUSH_INSTRUCTION_CACHE_GUID;
+
+EFI_GUID_STRING(&gEfiPeiFlushInstructionCacheGuid, "PEI Flush Instruction Cache",
+ "Flush Instruction Cache APIs from PEI");
+
diff --git a/EDK/Foundation/Guid/PeiFlushInstructionCache/PeiFlushInstructionCache.h b/EDK/Foundation/Guid/PeiFlushInstructionCache/PeiFlushInstructionCache.h
new file mode 100644
index 0000000..a9d1308
--- /dev/null
+++ b/EDK/Foundation/Guid/PeiFlushInstructionCache/PeiFlushInstructionCache.h
@@ -0,0 +1,44 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PeiFlushInstructionCache.h
+
+Abstract:
+
+ GUID for the Instruction Cache Flushing APIs shared between PEI and DXE
+
+--*/
+
+#ifndef _PEI_FLUSH_INSTRUCTION_CACHE_GUID_H_
+#define _PEI_FLUSH_INSTRUCTION_CACHE_GUID_H_
+
+#define EFI_PEI_FLUSH_INSTRUCTION_CACHE_GUID \
+ { 0xd8117cfc, 0x94a6, 0x11d4, 0x9a, 0x3a, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d }
+
+EFI_FORWARD_DECLARATION (EFI_PEI_FLUSH_INSTRUCTION_CACHE_PROTOCOL);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_FLUSH_INSTRUCTION_CACHE_FLUSH) (
+ IN EFI_PEI_FLUSH_INSTRUCTION_CACHE_PROTOCOL *This,
+ IN EFI_PHYSICAL_ADDRESS Start,
+ IN UINT64 Length
+ );
+
+typedef struct _EFI_PEI_FLUSH_INSTRUCTION_CACHE_PROTOCOL {
+ EFI_PEI_FLUSH_INSTRUCTION_CACHE_FLUSH Flush;
+} EFI_PEI_FLUSH_INSTRUCTION_CACHE_PROTOCOL;
+
+extern EFI_GUID gEfiPeiFlushInstructionCacheGuid;
+
+#endif
diff --git a/EDK/Foundation/Guid/PeiPeCoffLoader/PeiPeCoffLoader.c b/EDK/Foundation/Guid/PeiPeCoffLoader/PeiPeCoffLoader.c
new file mode 100644
index 0000000..3777dbf
--- /dev/null
+++ b/EDK/Foundation/Guid/PeiPeCoffLoader/PeiPeCoffLoader.c
@@ -0,0 +1,28 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PeiPeCoffLoader.c
+
+Abstract:
+
+ GUID for the PE/COFF Loader APIs shared between PEI and DXE
+
+--*/
+
+#include "Tiano.h"
+#include EFI_GUID_DEFINITION(PeiPeCoffLoader)
+
+EFI_GUID gEfiPeiPeCoffLoaderGuid = EFI_PEI_PE_COFF_LOADER_GUID;
+
+EFI_GUID_STRING(&gEfiPeiPeCoffLoaderGuid, "PE/COFF Loader", "PE/COFF Loader APIs from PEI");
+
diff --git a/EDK/Foundation/Guid/PeiPeCoffLoader/PeiPeCoffLoader.h b/EDK/Foundation/Guid/PeiPeCoffLoader/PeiPeCoffLoader.h
new file mode 100644
index 0000000..7c2010f
--- /dev/null
+++ b/EDK/Foundation/Guid/PeiPeCoffLoader/PeiPeCoffLoader.h
@@ -0,0 +1,119 @@
+/*++
+
+Copyright (c) 2005 - 2008, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PeiPeCoffLoader.h
+
+Abstract:
+
+ GUID for the PE/COFF Loader APIs shared between PEI and DXE
+
+--*/
+
+#ifndef _PEI_PE_COFF_LOADER_H_
+#define _PEI_PE_COFF_LOADER_H_
+
+#include "EfiImage.h"
+
+#define EFI_PEI_PE_COFF_LOADER_GUID \
+ { 0xd8117cff, 0x94a6, 0x11d4, 0x9a, 0x3a, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d }
+
+EFI_FORWARD_DECLARATION (EFI_PEI_PE_COFF_LOADER_PROTOCOL);
+
+#define EFI_IMAGE_ERROR_SUCCESS 0
+#define EFI_IMAGE_ERROR_IMAGE_READ 1
+#define EFI_IMAGE_ERROR_INVALID_PE_HEADER_SIGNATURE 2
+#define EFI_IMAGE_ERROR_INVALID_MACHINE_TYPE 3
+#define EFI_IMAGE_ERROR_INVALID_SUBSYSTEM 4
+#define EFI_IMAGE_ERROR_INVALID_IMAGE_ADDRESS 5
+#define EFI_IMAGE_ERROR_INVALID_IMAGE_SIZE 6
+#define EFI_IMAGE_ERROR_INVALID_SECTION_ALIGNMENT 7
+#define EFI_IMAGE_ERROR_SECTION_NOT_LOADED 8
+#define EFI_IMAGE_ERROR_FAILED_RELOCATION 9
+#define EFI_IMAGE_ERROR_FAILED_ICACHE_FLUSH 10
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_PE_COFF_LOADER_READ_FILE) (
+ IN VOID *FileHandle,
+ IN UINTN FileOffset,
+ IN OUT UINTN *ReadSize,
+ OUT VOID *Buffer
+ );
+
+typedef struct {
+ EFI_PHYSICAL_ADDRESS ImageAddress;
+ UINT64 ImageSize;
+ EFI_PHYSICAL_ADDRESS DestinationAddress;
+ EFI_PHYSICAL_ADDRESS EntryPoint;
+ EFI_PEI_PE_COFF_LOADER_READ_FILE ImageRead;
+ VOID *Handle;
+ VOID *FixupData;
+ UINT32 SectionAlignment;
+ UINT32 PeCoffHeaderOffset;
+ UINT32 DebugDirectoryEntryRva;
+ VOID *CodeView;
+ CHAR8 *PdbPointer;
+ UINTN SizeOfHeaders;
+ UINT32 ImageCodeMemoryType;
+ UINT32 ImageDataMemoryType;
+ UINT32 ImageError;
+ UINTN FixupDataSize;
+ UINT16 Machine;
+ UINT16 ImageType;
+ BOOLEAN RelocationsStripped;
+ BOOLEAN IsTeImage;
+#ifdef EFI_NT_EMULATOR
+ VOID **ModHandle;
+#endif
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
+ EFI_PHYSICAL_ADDRESS HiiResourceData;
+#endif
+} EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_PE_COFF_LOADER_GET_IMAGE_INFO) (
+ IN EFI_PEI_PE_COFF_LOADER_PROTOCOL *This,
+ IN OUT EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_PE_COFF_LOADER_LOAD_IMAGE) (
+ IN EFI_PEI_PE_COFF_LOADER_PROTOCOL *This,
+ IN OUT EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_PE_COFF_LOADER_RELOCATE_IMAGE) (
+ IN EFI_PEI_PE_COFF_LOADER_PROTOCOL *This,
+ IN OUT EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_PE_COFF_LOADER_UNLOAD_IMAGE) (
+ IN EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
+ );
+
+typedef struct _EFI_PEI_PE_COFF_LOADER_PROTOCOL {
+ EFI_PEI_PE_COFF_LOADER_GET_IMAGE_INFO GetImageInfo;
+ EFI_PEI_PE_COFF_LOADER_LOAD_IMAGE LoadImage;
+ EFI_PEI_PE_COFF_LOADER_RELOCATE_IMAGE RelocateImage;
+ EFI_PEI_PE_COFF_LOADER_UNLOAD_IMAGE UnloadImage;
+} EFI_PEI_PE_COFF_LOADER_PROTOCOL;
+
+extern EFI_GUID gEfiPeiPeCoffLoaderGuid;
+
+#endif
diff --git a/EDK/Foundation/Guid/PeiPerformanceHob/PeiPerformanceHob.c b/EDK/Foundation/Guid/PeiPerformanceHob/PeiPerformanceHob.c
new file mode 100644
index 0000000..9a0d18c
--- /dev/null
+++ b/EDK/Foundation/Guid/PeiPerformanceHob/PeiPerformanceHob.c
@@ -0,0 +1,28 @@
+/*++
+
+Copyright (c) 2004 - 2011, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PeiPerformanceHob.c
+
+Abstract:
+
+ The GUID of the GUIDed HOB that represents the Pei Firmware Performance Hob.
+
+--*/
+
+#include "Tiano.h"
+#include EFI_GUID_DEFINITION (PeiPerformanceHob)
+
+EFI_GUID gPeiFirmwarePerformanceGuid = PEI_FIRMWARE_PERFORMANCE_GUID;
+
+EFI_GUID_STRING (&gPeiFirmwarePerformanceGuid, "PEI Firmware Performance HOB",
+ "Guid for PEI Firmware Performance HOB");
diff --git a/EDK/Foundation/Guid/PeiPerformanceHob/PeiPerformanceHob.h b/EDK/Foundation/Guid/PeiPerformanceHob/PeiPerformanceHob.h
new file mode 100644
index 0000000..f98f35e
--- /dev/null
+++ b/EDK/Foundation/Guid/PeiPerformanceHob/PeiPerformanceHob.h
@@ -0,0 +1,55 @@
+/*++
+
+Copyright (c) 2004 - 2012, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PeiPerformanceHob.h
+
+Abstract:
+ The PEI Firmware performance HOB definition.
+
+--*/
+
+#ifndef _PEI_PERFORMANCE_HOB_GUID_H_
+#define _PEI_PERFORMANCE_HOB_GUID_H_
+
+#define PEI_FIRMWARE_PERFORMANCE_GUID \
+ { \
+ 0x55765e8f, 0x21a, 0x41f9, 0x93, 0x2d, 0x4c, 0x49, 0xc5, 0xb7, 0xef, 0x5d \
+ }
+
+#pragma pack(push, 1)
+typedef struct _PEI_GUID_EVENT_REC {
+ UINT16 ProgressID;
+ EFI_GUID Guid;
+ UINT32 ApicID;
+ UINT64 Timestamp;
+} PEI_GUID_EVENT_REC;
+#pragma pack(pop)
+
+typedef struct {
+ UINT32 NumberOfEntries;
+ UINT32 Reserved;
+ PEI_GUID_EVENT_REC GuidEventRecord[1];
+} PEI_FIRMWARE_PERFORMANCE_HOB;
+
+#define PEIM_START_ID 0x1
+#define PEIM_END_ID 0x2
+#define PREMEM_START_ID 0x20
+#define PREMEM_END_ID 0x21
+#define DISMEM_START_ID 0x30
+#define DISMEM_END_ID 0x31
+#define POSTMEM_START_ID 0x40
+#define POSTMEM_END_ID 0x41
+
+extern EFI_GUID gPeiFirmwarePerformanceGuid;
+
+#endif \ No newline at end of file
diff --git a/EDK/Foundation/Guid/PeiTransferControl/PeiTransferControl.c b/EDK/Foundation/Guid/PeiTransferControl/PeiTransferControl.c
new file mode 100644
index 0000000..06662bf
--- /dev/null
+++ b/EDK/Foundation/Guid/PeiTransferControl/PeiTransferControl.c
@@ -0,0 +1,28 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PeiTransferControl.c
+
+Abstract:
+
+ GUID for the SetJump()/LongJump() APIs shared between PEI and DXE
+
+--*/
+
+#include "Tiano.h"
+#include EFI_GUID_DEFINITION(PeiTransferControl)
+
+EFI_GUID gEfiPeiTransferControlGuid = EFI_PEI_TRANSFER_CONTROL_GUID;
+
+EFI_GUID_STRING(&gEfiPeiTransferControlGuid, "Transfer Control", "Transfer Control APIs from PEI");
+
diff --git a/EDK/Foundation/Guid/PeiTransferControl/PeiTransferControl.h b/EDK/Foundation/Guid/PeiTransferControl/PeiTransferControl.h
new file mode 100644
index 0000000..fbf5c35
--- /dev/null
+++ b/EDK/Foundation/Guid/PeiTransferControl/PeiTransferControl.h
@@ -0,0 +1,53 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PeiTransferControl.h
+
+Abstract:
+
+ GUID for the SetJump()/LongJump() APIs shared between PEI and DXE
+
+--*/
+
+#ifndef _PEI_TRANSFER_CONTROL_H_
+#define _PEI_TRANSFER_CONTROL_H_
+
+#define EFI_PEI_TRANSFER_CONTROL_GUID \
+ { 0xd8117d02, 0x94a6, 0x11d4, 0x9a, 0x3a, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d }
+
+
+EFI_FORWARD_DECLARATION (EFI_PEI_TRANSFER_CONTROL_PROTOCOL);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_TRANSFER_CONTROL_SET_JUMP) (
+ IN EFI_PEI_TRANSFER_CONTROL_PROTOCOL *This,
+ OUT VOID *Context
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PEI_TRANSFER_CONTROL_LONG_JUMP) (
+ IN EFI_PEI_TRANSFER_CONTROL_PROTOCOL *This,
+ IN VOID *Context
+ );
+
+typedef struct _EFI_PEI_TRANSFER_CONTROL_PROTOCOL {
+ EFI_PEI_TRANSFER_CONTROL_LONG_JUMP SetJump;
+ EFI_PEI_TRANSFER_CONTROL_LONG_JUMP LongJump;
+ UINT32 JumpContextSize;
+} EFI_PEI_TRANSFER_CONTROL_PROTOCOL;
+
+extern EFI_GUID gEfiPeiTransferControlGuid;
+
+#endif
diff --git a/EDK/Foundation/Guid/PrimaryConsoleInDevice/PrimaryConsoleInDevice.c b/EDK/Foundation/Guid/PrimaryConsoleInDevice/PrimaryConsoleInDevice.c
new file mode 100644
index 0000000..a85cf80
--- /dev/null
+++ b/EDK/Foundation/Guid/PrimaryConsoleInDevice/PrimaryConsoleInDevice.c
@@ -0,0 +1,28 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PrimaryConsoleInDevice.c
+
+Abstract:
+
+
+--*/
+
+#include "Tiano.h"
+#include EFI_GUID_DEFINITION(PrimaryConsoleInDevice)
+
+
+EFI_GUID gEfiPrimaryConsoleInDeviceGuid = EFI_PRIMARY_CONSOLE_IN_DEVICE_GUID;
+
+EFI_GUID_STRING(&gEfiPrimaryConsoleInDeviceGuid, "Primary Console In Device Guid",
+ "EFI Primary Conosle In Device Guid");
diff --git a/EDK/Foundation/Guid/PrimaryConsoleInDevice/PrimaryConsoleInDevice.h b/EDK/Foundation/Guid/PrimaryConsoleInDevice/PrimaryConsoleInDevice.h
new file mode 100644
index 0000000..1793080
--- /dev/null
+++ b/EDK/Foundation/Guid/PrimaryConsoleInDevice/PrimaryConsoleInDevice.h
@@ -0,0 +1,29 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PrimaryConsoleInDevice.h
+
+Abstract:
+
+
+--*/
+
+#ifndef _PRIMARY_CONSOLE_IN_DEVICE_H_
+#define _PRIMARY_CONSOLE_IN_DEVICE_H_
+
+#define EFI_PRIMARY_CONSOLE_IN_DEVICE_GUID \
+ { 0xe451dcbe, 0x96a1, 0x4729, 0xa5, 0xcf, 0x6b, 0x9c, 0x2c, 0xff, 0x47, 0xfd }
+
+extern EFI_GUID gEfiPrimaryConsoleInDeviceGuid;
+
+#endif
diff --git a/EDK/Foundation/Guid/PrimaryConsoleOutDevice/PrimaryConsoleOutDevice.c b/EDK/Foundation/Guid/PrimaryConsoleOutDevice/PrimaryConsoleOutDevice.c
new file mode 100644
index 0000000..15dc463
--- /dev/null
+++ b/EDK/Foundation/Guid/PrimaryConsoleOutDevice/PrimaryConsoleOutDevice.c
@@ -0,0 +1,26 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PrimaryConsoleOutDevice.c
+
+Abstract:
+
+--*/
+
+#include "Tiano.h"
+#include EFI_GUID_DEFINITION(PrimaryConsoleOutDevice)
+
+EFI_GUID gEfiPrimaryConsoleOutDeviceGuid = EFI_PRIMARY_CONSOLE_OUT_DEVICE_GUID;
+
+EFI_GUID_STRING(&gEfiPrimaryConsoleOutDeviceGuid, "Primary Console Out Device Guid",
+ "EFI Primary Console Out Device Guid");
diff --git a/EDK/Foundation/Guid/PrimaryConsoleOutDevice/PrimaryConsoleOutDevice.h b/EDK/Foundation/Guid/PrimaryConsoleOutDevice/PrimaryConsoleOutDevice.h
new file mode 100644
index 0000000..df776d9
--- /dev/null
+++ b/EDK/Foundation/Guid/PrimaryConsoleOutDevice/PrimaryConsoleOutDevice.h
@@ -0,0 +1,28 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PrimaryConsoleOutDevice.h
+
+Abstract:
+
+--*/
+
+#ifndef _PRIMARY_CONSOLE_OUT_DEVICE_H_
+#define _PRIMARY_CONSOLE_OUT_DEVICE_H_
+
+#define EFI_PRIMARY_CONSOLE_OUT_DEVICE_GUID \
+ { 0x62bdf38a, 0xe3d5, 0x492c, 0x95, 0xc, 0x23, 0xa7, 0xf6, 0x6e, 0x67, 0x2e }
+
+extern EFI_GUID gEfiPrimaryConsoleOutDeviceGuid;
+
+#endif
diff --git a/EDK/Foundation/Guid/PrimaryStandardErrorDevice/PrimaryStandardErrorDevice.c b/EDK/Foundation/Guid/PrimaryStandardErrorDevice/PrimaryStandardErrorDevice.c
new file mode 100644
index 0000000..f84e528
--- /dev/null
+++ b/EDK/Foundation/Guid/PrimaryStandardErrorDevice/PrimaryStandardErrorDevice.c
@@ -0,0 +1,26 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PrimaryStandardErrorDevice.c
+
+Abstract:
+
+--*/
+
+#include "Tiano.h"
+#include EFI_GUID_DEFINITION(PrimaryStandardErrorDevice)
+
+EFI_GUID gEfiPrimaryStandardErrorDeviceGuid = EFI_PRIMARY_STANDARD_ERROR_DEVICE_GUID;
+
+EFI_GUID_STRING(&gEfiPrimaryStandardErrorDeviceGuid, "Primary Standard Error Device Guid",
+ "EFI Primary Standard Error Device Guid");
diff --git a/EDK/Foundation/Guid/PrimaryStandardErrorDevice/PrimaryStandardErrorDevice.h b/EDK/Foundation/Guid/PrimaryStandardErrorDevice/PrimaryStandardErrorDevice.h
new file mode 100644
index 0000000..1984c36
--- /dev/null
+++ b/EDK/Foundation/Guid/PrimaryStandardErrorDevice/PrimaryStandardErrorDevice.h
@@ -0,0 +1,28 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PrimaryStandardErrorDevice.h
+
+Abstract:
+
+--*/
+
+#ifndef _PRIMARY_STANDARD_ERROR_DEVICE_H_
+#define _PRIMARY_STANDARD_ERROR_DEVICE_H_
+
+#define EFI_PRIMARY_STANDARD_ERROR_DEVICE_GUID \
+ { 0x5a68191b, 0x9b97, 0x4752, 0x99, 0x46, 0xe3, 0x6a, 0x5d, 0xa9, 0x42, 0xb1 }
+
+extern EFI_GUID gEfiPrimaryStandardErrorDeviceGuid;
+
+#endif
diff --git a/EDK/Foundation/Guid/StandardErrorDevice/StandardErrorDevice.c b/EDK/Foundation/Guid/StandardErrorDevice/StandardErrorDevice.c
new file mode 100644
index 0000000..f10828d
--- /dev/null
+++ b/EDK/Foundation/Guid/StandardErrorDevice/StandardErrorDevice.c
@@ -0,0 +1,27 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ StandardErrorDevice.c
+
+Abstract:
+
+
+--*/
+
+#include "Tiano.h"
+#include EFI_GUID_DEFINITION(StandardErrorDevice)
+
+
+EFI_GUID gEfiStandardErrorDeviceGuid = EFI_STANDARD_ERROR_DEVICE_GUID;
+
+EFI_GUID_STRING(&gEfiStandardErrorDeviceGuid, "Standard Error Device Guid", "EFI Standard Error Device Guid");
diff --git a/EDK/Foundation/Guid/StandardErrorDevice/StandardErrorDevice.h b/EDK/Foundation/Guid/StandardErrorDevice/StandardErrorDevice.h
new file mode 100644
index 0000000..35f3278
--- /dev/null
+++ b/EDK/Foundation/Guid/StandardErrorDevice/StandardErrorDevice.h
@@ -0,0 +1,29 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ StandardErrorDevice.h
+
+Abstract:
+
+
+--*/
+
+#ifndef _STANDARD_ERROR_DEVICE_H_
+#define _STANDARD_ERROR_DEVICE_H_
+
+#define EFI_STANDARD_ERROR_DEVICE_GUID \
+ { 0xd3b36f2d, 0xd551, 0x11d4, 0x9a, 0x46, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d }
+
+extern EFI_GUID gEfiStandardErrorDeviceGuid;
+
+#endif
diff --git a/EDK/Foundation/Guid/StatusCode/StatusCode.c b/EDK/Foundation/Guid/StatusCode/StatusCode.c
new file mode 100644
index 0000000..bc2f48c
--- /dev/null
+++ b/EDK/Foundation/Guid/StatusCode/StatusCode.c
@@ -0,0 +1,28 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ StatusCode.c
+
+Abstract:
+
+ GUIDs used to identify Data Hub records that originate from the Tiano
+ ReportStatusCode API.
+
+--*/
+
+#include "Tiano.h"
+#include EFI_GUID_DEFINITION (StatusCode)
+
+EFI_GUID gEfiStatusCodeGuid = EFI_STATUS_CODE_GUID;
+
+EFI_GUID_STRING(&gEfiStatusCodeGuid, "Status Code", "Data Hub record for Tiano ReportStatusCode API");
diff --git a/EDK/Foundation/Guid/StatusCode/StatusCode.h b/EDK/Foundation/Guid/StatusCode/StatusCode.h
new file mode 100644
index 0000000..e3da307
--- /dev/null
+++ b/EDK/Foundation/Guid/StatusCode/StatusCode.h
@@ -0,0 +1,33 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ StatusCode.h
+
+Abstract:
+
+ GUID used to identify Data Hub records that originate from the Tiano
+ ReportStatusCode API.
+
+--*/
+
+#ifndef _STATUS_CODE_H__
+#define _STATUS_CODE_H__
+
+#define EFI_STATUS_CODE_GUID \
+ { \
+ 0xd083e94c, 0x6560, 0x42e4, 0xb6, 0xd4, 0x2d, 0xf7, 0x5a, 0xdf, 0x6a, 0x2a \
+ }
+
+extern EFI_GUID gEfiStatusCodeGuid;
+
+#endif
diff --git a/EDK/Foundation/Guid/StatusCodeCallerId/StatusCodeCallerId.c b/EDK/Foundation/Guid/StatusCodeCallerId/StatusCodeCallerId.c
new file mode 100644
index 0000000..ae03aac
--- /dev/null
+++ b/EDK/Foundation/Guid/StatusCodeCallerId/StatusCodeCallerId.c
@@ -0,0 +1,27 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ StatusCodeCallerId.c
+
+Abstract:
+
+ GUID used to identify id for the caller who is initiating the Status Code.
+
+--*/
+
+#include "Tiano.h"
+#include EFI_GUID_DEFINITION (StatusCodeCallerId)
+
+EFI_GUID gEfiCallerIdGuid = EFI_STANDARD_CALLER_ID_GUID;
+
+EFI_GUID_STRING(&gEfiCallerIdGuid, "Status Code Caller Id", "Caller Id for Tiano ReportStatusCode API");
diff --git a/EDK/Foundation/Guid/StatusCodeCallerId/StatusCodeCallerId.h b/EDK/Foundation/Guid/StatusCodeCallerId/StatusCodeCallerId.h
new file mode 100644
index 0000000..2af50b4
--- /dev/null
+++ b/EDK/Foundation/Guid/StatusCodeCallerId/StatusCodeCallerId.h
@@ -0,0 +1,37 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ StatusCodeCallerId.h
+
+Abstract:
+
+ GUID used to identify id for the caller who is initiating the Status Code.
+
+--*/
+
+#ifndef _STATUS_CODE_CALLER_ID_H__
+#define _STATUS_CODE_CALLER_ID_H__
+
+#include "EfiStatusCode.h"
+
+#ifndef EFI_STANDARD_CALLER_ID_GUID
+
+#define EFI_STANDARD_CALLER_ID_GUID \
+ {0xC9DCF469, 0xA7C4, 0x11D5, 0x87, 0xDA, 0x00, 0x06, 0x29, 0x45, 0xC3, 0xB9}
+
+#endif
+
+extern EFI_GUID gEfiCallerIdGuid;
+
+
+#endif
diff --git a/EDK/Foundation/Guid/SystemNvDataGuid/SystemNvDataGuid.c b/EDK/Foundation/Guid/SystemNvDataGuid/SystemNvDataGuid.c
new file mode 100644
index 0000000..43140a6
--- /dev/null
+++ b/EDK/Foundation/Guid/SystemNvDataGuid/SystemNvDataGuid.c
@@ -0,0 +1,32 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ SystemNvDataGuid.c
+
+Abstract:
+
+ GUIDs used for System Non Volatile HOB entries in the in the HOB list and FV Guids carrying
+ the System specific information.
+
+--*/
+
+#include "Tiano.h"
+#include EFI_GUID_DEFINITION(SystemNvDataGuid)
+
+
+EFI_GUID gEfiSystemNvDataHobGuid = EFI_SYSTEM_NV_DATA_HOB_GUID;
+EFI_GUID gEfiSystemNvDataFvGuid = EFI_SYSTEM_NV_DATA_FV_GUID;
+
+EFI_GUID_STRING(&gEfiSystemNvDataHobGuid, "SYSTEM NV DATA HOB", "SYSTEM NV DATA HOB GUID for HOB list.");
+EFI_GUID_STRING(&gEfiSystemNvDataFvGuid, "SYSTEM NV DATA FV", "SYSTEM NV DATA FV GUID");
+
diff --git a/EDK/Foundation/Guid/SystemNvDataGuid/SystemNvDataGuid.h b/EDK/Foundation/Guid/SystemNvDataGuid/SystemNvDataGuid.h
new file mode 100644
index 0000000..f7550bb
--- /dev/null
+++ b/EDK/Foundation/Guid/SystemNvDataGuid/SystemNvDataGuid.h
@@ -0,0 +1,45 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ SystemNvDataGuid.h
+
+Abstract:
+
+ GUIDs used for System Non Volatile HOB entries in the in the HOB list and FV Guids carrying
+ the System specific information.
+
+--*/
+
+#ifndef _SYSTEM_NV_DATA_GUID_H_
+#define _SYSTEM_NV_DATA_GUID_H_
+
+#define EFI_SYSTEM_NV_DATA_FV_GUID \
+ {0xfff12b8d, 0x7696, 0x4c8b, 0xa9, 0x85, 0x27, 0x47, 0x7, 0x5b, 0x4f, 0x50}
+
+#define EFI_SYSTEM_NV_DATA_HOB_GUID \
+ {0xd6e5092d, 0xc7b2, 0x4872, 0xaf, 0x66, 0xfd, 0xc0, 0xe6, 0xf9, 0x5e, 0x78}
+
+typedef struct {
+ EFI_GUID SystemNvDataHobGuid;
+ EFI_GUID SystemNvDataFvGuid;
+ EFI_LBA StartLba;
+ UINTN StartLbaOffset;
+ EFI_LBA EndLba;
+ UINTN EndLbaOffset;
+ UINT32 DataTypeSignature;
+} NV_SYSTEM_DATA_GUID_TYPE;
+
+extern EFI_GUID gEfiSystemNvDataHobGuid;
+extern EFI_GUID gEfiSystemNvDataFvGuid;
+
+#endif
diff --git a/EDK/Foundation/Include/Ebc/EfiBind.h b/EDK/Foundation/Include/Ebc/EfiBind.h
new file mode 100644
index 0000000..68ec8ae
--- /dev/null
+++ b/EDK/Foundation/Include/Ebc/EfiBind.h
@@ -0,0 +1,129 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiBind.h
+
+Abstract:
+
+ Processor or compiler specific defines and types for EBC.
+
+--*/
+
+#ifndef _EFI_BIND_H_
+#define _EFI_BIND_H_
+
+#define EFI_DRIVER_ENTRY_POINT(InitFunction)
+#define EFI_APPLICATION_ENTRY_POINT EFI_DRIVER_ENTRY_POINT
+
+//
+// Disable warning that make it impossible to compile at /W3
+// This only works for Intel EBC Compiler tools
+//
+
+//
+// Disabling argument of type "TYPE **" is incompatible with parameter of type "void **"
+//
+#pragma warning ( disable : 167 )
+
+//
+// Disabling pointless comparison of unsigned integer with zero
+//
+#pragma warning ( disable : 186 )
+
+//
+// Disabling enumerated type mixed with another type
+//
+#pragma warning ( disable : 188 )
+
+//
+// Native integer types
+//
+typedef char int8_t;
+typedef unsigned char uint8_t;
+
+typedef short int16_t;
+typedef unsigned short uint16_t;
+
+typedef int int32_t;
+typedef unsigned int uint32_t;
+
+typedef __int64 int64_t;
+typedef unsigned __int64 uint64_t;
+
+//
+// "long" type scales to the processor native size with EBC compiler
+//
+typedef long intn_t;
+typedef unsigned long uintn_t;
+
+//
+// Scalable macro to set the most significant bit in a natural number
+//
+#define EFI_MAX_BIT ((UINTN)0x01 << ((sizeof (char *) * 8) - 1))
+#define MAX_2_BITS (EFI_MAX_BIT | (EFI_MAX_BIT >> 1))
+
+//
+// Maximum legal EBC address
+//
+#define EFI_MAX_ADDRESS (UINTN)~0
+
+//
+// Bad pointer value to use in check builds.
+// if you see this value you are using uninitialized or free'ed data
+//
+#define EFI_BAD_POINTER (UINTN)0xAFAFAFAFAFAFAFAF
+#define EFI_BAD_POINTER_AS_BYTE (UINTN)0xAF
+
+//
+// _break() is an EBC compiler intrinsic function
+//
+extern
+uint64_t
+_break (
+ unsigned char BreakCode
+ );
+
+//
+// Macro to inject a break point in the code to assist debugging.
+//
+#define EFI_BREAKPOINT() _break ( 3 )
+#define EFI_DEADLOOP() while (TRUE)
+
+//
+// Memory Fence forces serialization, and is needed to support out of order
+// memory transactions. The Memory Fence is mainly used to make sure IO
+// transactions complete in a deterministic sequence, and to syncronize locks
+// an other MP code. Currently no memory fencing is required.
+//
+#define MEMORY_FENCE()
+
+//
+// Some compilers don't support the forward reference construct:
+// typedef struct XXXXX. The forward reference is required for
+// ANSI compatibility.
+//
+// The following macro provide a workaround for such cases.
+//
+
+
+#ifdef EFI_NO_INTERFACE_DECL
+ #define EFI_FORWARD_DECLARATION(x)
+#else
+ #define EFI_FORWARD_DECLARATION(x) typedef struct _##x x
+#endif
+
+
+#define _EFIAPI
+
+#endif // ifndef _EFI_BIND_H_
+
diff --git a/EDK/Foundation/Include/Ebc/EfiPeOptionalHeader.h b/EDK/Foundation/Include/Ebc/EfiPeOptionalHeader.h
new file mode 100644
index 0000000..c6efb1a
--- /dev/null
+++ b/EDK/Foundation/Include/Ebc/EfiPeOptionalHeader.h
@@ -0,0 +1,46 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiPeOptionalHeader.h
+
+Abstract:
+ Defines the optional header in the PE image per the PE specification. This
+ file must be included only from within EfiImage.h since
+ EFI_IMAGE_DATA_DIRECTORY and EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES are defined
+ there.
+
+--*/
+
+#ifndef _EFI_PE_OPTIONAL_HEADER_H_
+#define _EFI_PE_OPTIONAL_HEADER_H_
+
+//
+// This is just to make sure you can cross compile with the EBC compiiler.
+// It does not make sense to have a PE loader coded in EBC. You need to
+// understand the basic
+//
+#define EFI_IMAGE_MACHINE_TYPE (EFI_IMAGE_MACHINE_EBC)
+
+#define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) ((Machine) == EFI_IMAGE_MACHINE_EBC)
+
+#define EFI_IMAGE_MACHINE_CROSS_TYPE_SUPPORTED(Machine) (FALSE)
+
+//
+// BUGBUG: Is this the correct magic for EBC?
+//
+#define EFI_IMAGE_NT_OPTIONAL_HDR_MAGIC EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC
+
+typedef EFI_IMAGE_OPTIONAL_HEADER32 EFI_IMAGE_OPTIONAL_HEADER;
+typedef EFI_IMAGE_NT_HEADERS32 EFI_IMAGE_NT_HEADERS;
+
+#endif
diff --git a/EDK/Foundation/Include/Ebc/TianoBind.h b/EDK/Foundation/Include/Ebc/TianoBind.h
new file mode 100644
index 0000000..139257a
--- /dev/null
+++ b/EDK/Foundation/Include/Ebc/TianoBind.h
@@ -0,0 +1,30 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ TianoBind.h
+
+Abstract:
+
+ Tiano's Processor or Compiler specific defines and types for EBC
+ besides EfiBind.h.
+
+--*/
+
+#ifndef _TIANO_BIND_H_
+#define _TIANO_BIND_H_
+
+#include "EfiBind.h"
+
+#define EFI_DXE_ENTRY_POINT(InitFunction)
+
+#endif
diff --git a/EDK/Foundation/Include/EfiCommon.h b/EDK/Foundation/Include/EfiCommon.h
new file mode 100644
index 0000000..c8c66fe
--- /dev/null
+++ b/EDK/Foundation/Include/EfiCommon.h
@@ -0,0 +1,53 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiCommon.h
+
+Abstract:
+
+--*/
+
+#ifndef _EFI_COMMON_H_
+#define _EFI_COMMON_H_
+
+#include "EfiBind.h"
+#include "EfiTypes.h"
+#include "EfiStdArg.h"
+#include "EfiError.h"
+
+//
+// Define macros for including Protocols and Guids.
+//
+#define EFI_STRINGIZE(a) #a
+#define EFI_PROTOCOL_DEFINITION(a) EFI_STRINGIZE (Protocol/a/a.h)
+#define EFI_GUID_DEFINITION(a) EFI_STRINGIZE (Guid/a/a.h)
+
+//
+// These should be used to include protocols. If they are followed,
+// intelligent build tools can be created to check dependencies at build
+// time.
+//
+#define EFI_PROTOCOL_PRODUCER(a) EFI_PROTOCOL_DEFINITION (a)
+#define EFI_PROTOCOL_CONSUMER(a) EFI_PROTOCOL_DEFINITION (a)
+#define EFI_PROTOCOL_DEPENDENCY(a) EFI_PROTOCOL_DEFINITION (a)
+
+//
+// Mechanism to associate a short and long ascii string with a GUID.
+// For normal builds the strings are not included. A build utility
+// can be constructed to extract the strings and build a table. It may
+// be possible to add a build opption to automatically generate a GUID
+// string table for a GUID to string utility build.
+//
+#define EFI_GUID_STRING(guidpointer, shortstring, longstring)
+
+#endif
diff --git a/EDK/Foundation/Include/EfiCompNameSupport.h b/EDK/Foundation/Include/EfiCompNameSupport.h
new file mode 100644
index 0000000..fd8373f
--- /dev/null
+++ b/EDK/Foundation/Include/EfiCompNameSupport.h
@@ -0,0 +1,120 @@
+/*++
+
+Copyright (c) 2004 - 2008, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiCompNameSupport.h
+
+Abstract:
+
+ Private data structures for the Console Splitter driver
+
+--*/
+
+#ifndef EFI_COMPONENT_NAME_SUPPORT_H
+#define EFI_COMPONENT_NAME_SUPPORT_H
+
+#include "Tiano.h"
+
+#ifndef EFI_SIZE_REDUCTION_APPLIED
+
+#define INSTALL_ALL_DRIVER_PROTOCOLS(ImageHandle, \
+ SystemTable, \
+ DriverBinding, \
+ DriverBindingHandle, \
+ ComponentName, \
+ DriverConfiguration, \
+ DriverDiagnostics) \
+ EfiLibInstallAllDriverProtocols ((ImageHandle), \
+ (SystemTable), \
+ (DriverBinding), \
+ (DriverBindingHandle), \
+ (ComponentName), \
+ (DriverConfiguration), \
+ (DriverDiagnostics))
+
+#define INSTALL_ALL_DRIVER_PROTOCOLS2(ImageHandle, \
+ SystemTable, \
+ DriverBinding, \
+ DriverBindingHandle, \
+ ComponentName, \
+ DriverConfiguration, \
+ DriverDiagnostics) \
+ EfiLibInstallAllDriverProtocols2((ImageHandle), \
+ (SystemTable), \
+ (DriverBinding), \
+ (DriverBindingHandle), \
+ (ComponentName), \
+ (DriverConfiguration), \
+ (DriverDiagnostics))
+#else
+
+#define INSTALL_ALL_DRIVER_PROTOCOLS(ImageHandle, \
+ SystemTable, \
+ DriverBinding, \
+ DriverBindingHandle, \
+ ComponentName, \
+ DriverConfiguration, \
+ DriverDiagnostics) \
+ EfiLibInstallDriverBinding ((ImageHandle), \
+ (SystemTable), \
+ (DriverBinding), \
+ (DriverBindingHandle))
+
+#define INSTALL_ALL_DRIVER_PROTOCOLS2(ImageHandle, \
+ SystemTable, \
+ DriverBinding, \
+ DriverBindingHandle, \
+ ComponentName, \
+ DriverConfiguration, \
+ DriverDiagnostics) \
+ EfiLibInstallDriverBinding ((ImageHandle), \
+ (SystemTable), \
+ (DriverBinding), \
+ (DriverBindingHandle))
+#endif
+
+#if (EFI_SPECIFICATION_VERSION < 0x00020000)
+
+#define INSTALL_ALL_DRIVER_PROTOCOLS_OR_PROTOCOLS2(ImageHandle, \
+ SystemTable, \
+ DriverBinding, \
+ DriverBindingHandle, \
+ ComponentName, \
+ DriverConfiguration, \
+ DriverDiagnostics) \
+ INSTALL_ALL_DRIVER_PROTOCOLS ((ImageHandle), \
+ (SystemTable), \
+ (DriverBinding), \
+ (DriverBindingHandle), \
+ (ComponentName), \
+ (DriverConfiguration), \
+ (DriverDiagnostics))
+
+#else
+
+#define INSTALL_ALL_DRIVER_PROTOCOLS_OR_PROTOCOLS2(ImageHandle, \
+ SystemTable, \
+ DriverBinding, \
+ DriverBindingHandle, \
+ ComponentName, \
+ DriverConfiguration, \
+ DriverDiagnostics) \
+ INSTALL_ALL_DRIVER_PROTOCOLS2 ((ImageHandle), \
+ (SystemTable), \
+ (DriverBinding), \
+ (DriverBindingHandle), \
+ (ComponentName), \
+ (DriverConfiguration), \
+ (DriverDiagnostics))
+
+#endif
+#endif
diff --git a/EDK/Foundation/Include/EfiDebug.h b/EDK/Foundation/Include/EfiDebug.h
new file mode 100644
index 0000000..1bf342a
--- /dev/null
+++ b/EDK/Foundation/Include/EfiDebug.h
@@ -0,0 +1,170 @@
+/*++
+
+Copyright (c) 2004 - 2011, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiDebug.h
+
+Abstract:
+
+ EFI Debug macros. The work needs tobe done in library. The Debug
+ macros them selves are standard for all files, including the core.
+
+ There needs to be code linked in that produces the following macros:
+
+ EfiDebugAssert(file, linenumber, assertion string) - worker function for
+ ASSERT. filename and line number of where this ASSERT() is located
+ is passed in along with the stringized version of the assertion.
+
+ EfiDebugPrint - Worker function for debug print
+
+ _DEBUG_SET_MEM(address, length, value) - Set memory at address to value
+ for legnth bytes. This macro is used to initialzed uninitialized memory
+ or memory that is free'ed, so it will not be used by mistake.
+
+--*/
+
+#ifndef _EFI_DEBUG_H_
+#define _EFI_DEBUG_H_
+
+#ifdef EFI_DEBUG
+
+ VOID
+ EfiDebugAssert (
+ IN CHAR8 *FileName,
+ IN INTN LineNumber,
+ IN CHAR8 *Description
+ );
+
+ VOID
+ EfiDebugPrint (
+ IN UINTN ErrorLevel,
+ IN CHAR8 *Format,
+ ...
+ );
+
+ VOID
+ EfiDebugVPrint (
+ IN UINTN ErrorLevel,
+ IN CHAR8 *Format,
+ IN VA_LIST Marker
+ );
+
+ //
+ // Define macros for the above functions so we can make them go away
+ // in non-debug builds.
+ //
+ #define EFI_DEBUG_VPRINT(ErrorLevel, Format, Marker) \
+ EfiDebugVPrint(ErrorLevel, Format, Marker)
+
+ #define EFI_DEBUG_ASSERT(FileName, LineNumber, Description) \
+ EfiDebugAssert (FileName, LineNumber, Description)
+
+ #define _DEBUG_ASSERT(assertion) \
+ EfiDebugAssert (__FILE__, __LINE__, #assertion)
+
+ #define _DEBUG(arg) DebugPrint arg
+
+ //
+ // Define ASSERT() macro, if assertion is FALSE trigger the ASSERT
+ //
+ #define ASSERT(assertion) if(!(assertion)) \
+ _DEBUG_ASSERT(assertion)
+
+ #define ASSERT_LOCKED(l) if(!(l)->Lock) _DEBUG_ASSERT(l not locked)
+
+ //
+ // DEBUG((DebugLevel, "format string", ...)) - if DebugLevel is active do
+ // the a debug print.
+ //
+ #define DEBUG(arg) EfiDebugPrint arg
+
+ #define DEBUG_CODE(code) code
+
+ #define CR(record, TYPE, field, signature) \
+ _CR(record, TYPE, field)->Signature != signature ? \
+ (TYPE *) (_DEBUG_ASSERT("CR has Bad Signature"), record) : \
+ _CR(record, TYPE, field)
+
+ #define _DEBUG_SET_MEM(address, length, data) EfiCommonLibSetMem(address, length, data)
+
+ //
+ // Generate an ASSERT if the protocol specified by GUID is already installed on Handle.
+ // If Handle is NULL, then an ASSERT is generated if the protocol specified by GUID
+ // is present anywhere in the handle database
+ //
+ #define ASSERT_PROTOCOL_ALREADY_INSTALLED(Handle, Guid) \
+ DEBUG_CODE ( { \
+ VOID *Instance; \
+ if (Handle == NULL) { \
+ ASSERT(EFI_ERROR(gBS->LocateProtocol (Guid, NULL, &Instance))); \
+ } else { \
+ ASSERT(EFI_ERROR(gBS->HandleProtocol (Handle, Guid, &Instance))); \
+ } } )
+
+#else
+ #define ASSERT(a)
+ #define ASSERT_LOCKED(l)
+ #define DEBUG(arg)
+ #define DEBUG_CODE(code)
+ #define CR(Record, TYPE, Field, Signature) \
+ _CR(Record, TYPE, Field)
+ #define _DEBUG_SET_MEM(address, length, data)
+ #define EFI_DEBUG_VPRINT(ErrorLevel, Format, Marker)
+ #define EFI_DEBUG_ASSERT(FileName, LineNumber, Description)
+ #define ASSERT_PROTOCOL_ALREADY_INSTALLED(Handle, Guid)
+#endif
+
+//
+// Generate an ASSERT if Status is an error code
+//
+//#define ASSERT_EFI_ERROR(status) ASSERT(!EFI_ERROR(status))
+#define ASSERT_EFI_ERROR(status) if (EFI_ERROR(status)) \
+ DEBUG_CODE ( { \
+ DEBUG ((EFI_D_ERROR, "\nASSERT_EFI_ERROR, Status = %r (0x%08X)\n", status, status)); \
+ ASSERT (!EFI_ERROR (status)); \
+ } )
+
+#ifdef EFI_DEBUG_CLEAR_MEMORY
+ #define DEBUG_SET_MEMORY(address,length) \
+ _DEBUG_SET_MEM(address, length, EFI_BAD_POINTER_AS_BYTE)
+#else
+ #define DEBUG_SET_MEMORY(address,length)
+#endif
+
+#define EFI_D_INIT 0x00000001 // Initialization style messages
+#define EFI_D_WARN 0x00000002 // Warnings
+#define EFI_D_LOAD 0x00000004 // Load events
+#define EFI_D_FS 0x00000008 // EFI File system
+#define EFI_D_POOL 0x00000010 // Alloc & Free's
+#define EFI_D_PAGE 0x00000020 // Alloc & Free's
+#define EFI_D_INFO 0x00000040 // Informational debug messages
+#define EFI_D_VARIABLE 0x00000100 // Variable
+#define EFI_D_BM 0x00000400 // Boot Manager (BDS)
+#define EFI_D_BLKIO 0x00001000 // BlkIo Driver
+#define EFI_D_NET 0x00004000 // SNI Driver
+#define EFI_D_UNDI 0x00010000 // UNDI Driver
+#define EFI_D_LOADFILE 0x00020000 // UNDI Driver
+#define EFI_D_EVENT 0x00080000 // Event messages
+#define EFI_D_VERBOSE 0x00400000 // Detailed debug messages that may significantly impact boot performance
+#define EFI_D_ERROR 0x80000000 // Error
+
+#define EFI_D_GENERIC (EFI_D_ERROR | EFI_D_INIT | EFI_D_WARN | EFI_D_INFO | \
+ EFI_D_VERBOSE| EFI_D_BLKIO | EFI_D_NET | EFI_D_UNDI )
+
+#define EFI_D_INTRINSIC ( EFI_D_EVENT | EFI_D_POOL | EFI_D_PAGE | \
+ EFI_D_BM | EFI_D_LOAD | EFI_D_VARIABLE )
+
+#define EFI_D_RESERVED (EFI_D_GENERIC | EFI_D_INTRINSIC)
+
+#define EFI_DBUG_MASK (EFI_D_ERROR)
+
+#endif
diff --git a/EDK/Foundation/Include/EfiDepex.h b/EDK/Foundation/Include/EfiDepex.h
new file mode 100644
index 0000000..5c08d7b
--- /dev/null
+++ b/EDK/Foundation/Include/EfiDepex.h
@@ -0,0 +1,54 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+ EfiDepex.h
+
+Abstract:
+ This include file is only used in *.DXS files. Do not use this
+ include file in normal DXE code.
+
+ Depex - Dependency Expresion
+
+ The BNF grammar is thus:
+ <depex> ::= before GUID
+ | after GUID
+ | SOR <bool>
+ | <bool>
+ <bool> ::= <bool> and <term>
+ | <bool> or <term>
+ | <term>
+ <term> ::= not <factor>
+ | <factor>
+ <factor> ::= <bool>
+ | <boolval>
+ | <depinst>
+ | <termval>
+ <boolval> ::= true
+ | false
+ <depinst> ::= push GUID
+ <termval> ::= end
+
+--*/
+
+#ifndef _EFI_DEPEX_H_
+#define _EFI_DEPEX_H_
+
+#include "Tiano.h"
+
+//
+// The Depex grammer needs the string "TRUE" and "FALSE" we must
+// undo any pre-processor redefinitions
+//
+#undef TRUE
+#undef FALSE
+
+#endif
diff --git a/EDK/Foundation/Include/EfiFlashMap.h b/EDK/Foundation/Include/EfiFlashMap.h
new file mode 100644
index 0000000..a660afc
--- /dev/null
+++ b/EDK/Foundation/Include/EfiFlashMap.h
@@ -0,0 +1,111 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiFlashMap.h
+
+Abstract:
+
+ Defines for the EFI Flash Map functionality
+
+--*/
+
+#ifndef _EFI_FLASHMAP_H_
+#define _EFI_FLASHMAP_H_
+
+#include "PeiHob.h"
+
+//
+// Definition for flash map GUIDed HOBs
+//
+typedef UINT32 EFI_FLASH_AREA_ATTRIBUTES;
+
+#define EFI_FLASH_AREA_FV 0x0001
+#define EFI_FLASH_AREA_SUBFV 0x0002
+#define EFI_FLASH_AREA_MEMMAPPED_FV 0x0004
+#define EFI_FLASH_AREA_REQUIRED 0x0008
+#define EFI_FLASH_AREA_CORRUPT 0x0010
+
+typedef UINT8 EFI_FLASH_AREA_TYPE;
+
+#define EFI_FLASH_AREA_RECOVERY_BIOS 0x0 // Recovery code
+#define EFI_FLASH_AREA_MAIN_BIOS 0x1 // Regular BIOS code
+#define EFI_FLASH_AREA_PAL_B 0x2 // PAL-B
+#define EFI_FLASH_AREA_RESERVED_03 0x3 // Reserved for backwards compatibility
+#define EFI_FLASH_AREA_RESERVED_04 0x4 // Reserved for backwards compatibility
+#define EFI_FLASH_AREA_DMI_FRU 0x5 // DMI FRU information
+#define EFI_FLASH_AREA_OEM_BINARY 0x6 // OEM Binary Code/data
+#define EFI_FLASH_AREA_RESERVED_07 0x7 // Reserved for backwards compatibility
+#define EFI_FLASH_AREA_RESERVED_08 0x8 // Reserved for backwards compatibility
+#define EFI_FLASH_AREA_RESERVED_09 0x9 // Reserved for backwards compatibility
+#define EFI_FLASH_AREA_RESERVED_0A 0x0a // Reserved for backwards compatibility
+#define EFI_FLASH_AREA_EFI_VARIABLES 0x0b // EFI variables
+#define EFI_FLASH_AREA_MCA_LOG 0x0c // MCA error log
+#define EFI_FLASH_AREA_SMBIOS_LOG 0x0d // SMBIOS error log
+#define EFI_FLASH_AREA_FTW_BACKUP 0x0e // A backup block during FTW operations
+#define EFI_FLASH_AREA_FTW_STATE 0x0f // State information during FTW operations
+#define EFI_FLASH_AREA_UNUSED 0x0fd // Not used
+#define EFI_FLASH_AREA_GUID_DEFINED 0x0fe // Usage defined by a GUID
+#pragma pack(1)
+//
+// An individual sub-area Entry.
+// A single flash area may consist of more than one sub-area.
+//
+typedef struct {
+ EFI_FLASH_AREA_ATTRIBUTES Attributes;
+ UINT32 Reserved;
+ EFI_PHYSICAL_ADDRESS Base;
+ EFI_PHYSICAL_ADDRESS Length;
+ EFI_GUID FileSystem;
+} EFI_FLASH_SUBAREA_ENTRY;
+
+typedef struct {
+ UINT8 Reserved[3];
+ EFI_FLASH_AREA_TYPE AreaType;
+ EFI_GUID AreaTypeGuid;
+ UINT32 NumEntries;
+ EFI_FLASH_SUBAREA_ENTRY Entries[1];
+} EFI_FLASH_MAP_ENTRY_DATA;
+
+typedef struct {
+ EFI_HOB_GENERIC_HEADER Header;
+ EFI_GUID Name;
+ UINT8 Reserved[3];
+ EFI_FLASH_AREA_TYPE AreaType;
+ EFI_GUID AreaTypeGuid;
+ UINT32 NumEntries;
+ EFI_FLASH_SUBAREA_ENTRY Entries[1];
+} EFI_HOB_FLASH_MAP_ENTRY_TYPE;
+
+//
+// Internal definitions
+//
+typedef struct {
+ UINT8 Reserved[3];
+ EFI_FLASH_AREA_TYPE AreaType;
+ EFI_GUID AreaTypeGuid;
+ UINT32 NumberOfEntries;
+ EFI_FLASH_SUBAREA_ENTRY SubAreaData;
+} EFI_FLASH_AREA_HOB_DATA;
+
+typedef struct {
+ UINTN Base;
+ UINTN Length;
+ EFI_FLASH_AREA_ATTRIBUTES Attributes;
+ EFI_FLASH_AREA_TYPE AreaType;
+ UINT8 Reserved[3];
+ EFI_GUID AreaTypeGuid;
+} EFI_FLASH_AREA_DATA;
+
+#pragma pack()
+
+#endif // #ifndef _EFI_FLASHMAP_H_
diff --git a/EDK/Foundation/Include/EfiPci.h b/EDK/Foundation/Include/EfiPci.h
new file mode 100644
index 0000000..3328048
--- /dev/null
+++ b/EDK/Foundation/Include/EfiPci.h
@@ -0,0 +1,64 @@
+/*++
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiPci.h
+
+Abstract:
+ Support for EFI PCI specification.
+
+Revision History
+
+--*/
+
+#ifndef _EFI_PCI_H_
+#define _EFI_PCI_H_
+
+//#include "pci22.h"
+//#include "pci23.h"
+//#include "pci30.h"
+
+#pragma pack(push, 1)
+
+typedef struct {
+ UINT8 Register;
+ UINT8 Function;
+ UINT8 Device;
+ UINT8 Bus;
+ UINT8 Reserved[4];
+} DEFIO_PCI_ADDR;
+
+#define EFI_ROOT_BRIDGE_LIST 'eprb'
+#define EFI_PCI_EXPANSION_ROM_HEADER_EFISIGNATURE 0x0EF1
+
+typedef struct {
+ UINT16 Signature; // 0xaa55
+ UINT16 InitializationSize;
+ UINT32 EfiSignature; // 0x0EF1
+ UINT16 EfiSubsystem;
+ UINT16 EfiMachineType;
+ UINT16 CompressionType;
+ UINT8 Reserved[8];
+ UINT16 EfiImageHeaderOffset;
+ UINT16 PcirOffset;
+} EFI_PCI_EXPANSION_ROM_HEADER;
+
+typedef union {
+ UINT8 *Raw;
+ PCI_EXPANSION_ROM_HEADER *Generic;
+ EFI_PCI_EXPANSION_ROM_HEADER *Efi;
+ EFI_LEGACY_EXPANSION_ROM_HEADER *PcAt;
+} EFI_PCI_ROM_HEADER;
+
+#pragma pack(pop)
+
+#endif
diff --git a/EDK/Foundation/Include/EfiPerf.h b/EDK/Foundation/Include/EfiPerf.h
new file mode 100644
index 0000000..309bf25
--- /dev/null
+++ b/EDK/Foundation/Include/EfiPerf.h
@@ -0,0 +1,211 @@
+/*++
+
+Copyright (c) 2004 - 2011, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiPerf.h
+
+Abstract:
+ EfiPerf.h provides performance primitive for the DXE and Shell phase
+
+
+--*/
+
+#ifndef _EFI_PERF_H_
+#define _EFI_PERF_H_
+
+#include EFI_PROTOCOL_DEFINITION (FirmwarePerformance)
+
+EFI_STATUS
+InitializePerformanceInfrastructure (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable,
+ IN UINT64 Ticker
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ ImageHandle - TODO: add argument description
+ SystemTable - TODO: add argument description
+ Ticker - TODO: add argument description
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+
+EFI_STATUS
+EndMeasure (
+ IN EFI_HANDLE Handle,
+ IN UINT16 *Token,
+ IN UINT16 *Host,
+ IN UINT64 Ticker
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ Handle - TODO: add argument description
+ Token - TODO: add argument description
+ Host - TODO: add argument description
+ Ticker - TODO: add argument description
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+
+EFI_STATUS
+StartMeasure (
+ IN EFI_HANDLE Handle,
+ IN UINT16 *Token,
+ IN UINT16 *Host,
+ IN UINT64 Ticker
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ Handle - TODO: add argument description
+ Token - TODO: add argument description
+ Host - TODO: add argument description
+ Ticker - TODO: add argument description
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+
+EFI_STATUS
+StartMeasureEx (
+ IN EFI_HANDLE Handle,
+ IN UINT16 *Token,
+ IN UINT16 *Host,
+ IN UINT64 Ticker,
+ IN UINT16 Identifier
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ Handle - TODO: add argument description
+ Token - TODO: add argument description
+ Host - TODO: add argument description
+ Ticker - TODO: add argument description
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+
+EFI_STATUS
+EndMeasureEx (
+ IN EFI_HANDLE Handle,
+ IN UINT16 *Token,
+ IN UINT16 *Host,
+ IN UINT64 Ticker,
+ IN UINT16 Identifier
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ Handle - TODO: add argument description
+ Token - TODO: add argument description
+ Host - TODO: add argument description
+ Ticker - TODO: add argument description
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+
+EFI_STATUS
+UpdateMeasure (
+ IN EFI_HANDLE Handle,
+ IN UINT16 *Token,
+ IN UINT16 *Host,
+ IN EFI_HANDLE HandleNew,
+ IN UINT16 *TokenNew,
+ IN UINT16 *HostNew
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ Handle - TODO: add argument description
+ Token - TODO: add argument description
+ Host - TODO: add argument description
+ HandleNew - TODO: add argument description
+ TokenNew - TODO: add argument description
+ HostNew - TODO: add argument description
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+
+#ifdef FIRMWARE_PERFORMANCE
+#define PERF_ENABLE(handle, table, ticker) InitializePerformanceInfrastructure (handle, table, ticker)
+#define PERF_START(handle, token, host, ticker) StartMeasure (handle, token, host, ticker)
+#define PERF_END(handle, token, host, ticker) EndMeasure (handle, token, host, ticker)
+#define PERF_START_EX(handle, token, host, ticker, identifier) StartMeasureEx (handle, token, host, ticker, identifier)
+#define PERF_END_EX(handle, token, host, ticker, identifier) EndMeasureEx (handle, token, host, ticker, identifier)
+#define PERF_UPDATE(handle, token, host, handlenew, tokennew, hostnew)
+#define PERF_CODE(code) code
+#else
+#define PERF_ENABLE(handle, table, ticker)
+#define PERF_START(handle, token, host, ticker)
+#define PERF_END(handle, token, host, ticker)
+#define PERF_START_EX(handle, token, host, ticker, identifier)
+#define PERF_END_EX(handle, token, host, ticker, identifier)
+#define PERF_UPDATE(handle, token, host, handlenew, tokennew, hostnew)
+#define PERF_CODE(code)
+#endif
+
+#endif
diff --git a/EDK/Foundation/Include/EfiPxe.h b/EDK/Foundation/Include/EfiPxe.h
new file mode 100644
index 0000000..5b27145
--- /dev/null
+++ b/EDK/Foundation/Include/EfiPxe.h
@@ -0,0 +1,1816 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module name:
+
+ EfiPxe.h
+
+32/64-bit PXE specification:
+
+ alpha-4, 99-Dec-17
+
+Abstract:
+
+ This header file contains all of the PXE type definitions,
+ structure prototypes, global variables and constants that
+ are needed for porting PXE to EFI.
+--*/
+
+#ifndef _EFIPXE_H
+#define _EFIPXE_H
+
+#pragma pack(1)
+
+#define PXE_INTEL_ORDER 1 // Intel order
+// #define PXE_NETWORK_ORDER 1 // network order
+//
+#define PXE_UINT64_SUPPORT 1 // UINT64 supported
+// #define PXE_NO_UINT64_SUPPORT 1 // UINT64 not supported
+//
+#define PXE_BUSTYPE(a, b, c, d) \
+ ( \
+ (((UINT32) (d) & 0xFF) << 24) | (((UINT32) (c) & 0xFF) << 16) | (((UINT32) (b) & 0xFF) << 8) | \
+ ((UINT32) (a) & 0xFF) \
+ )
+
+//
+// UNDI ROM ID and devive ID signature
+//
+#define PXE_BUSTYPE_PXE PXE_BUSTYPE ('!', 'P', 'X', 'E')
+
+//
+// BUS ROM ID signatures
+//
+#define PXE_BUSTYPE_PCI PXE_BUSTYPE ('P', 'C', 'I', 'R')
+#define PXE_BUSTYPE_PC_CARD PXE_BUSTYPE ('P', 'C', 'C', 'R')
+#define PXE_BUSTYPE_USB PXE_BUSTYPE ('U', 'S', 'B', 'R')
+#define PXE_BUSTYPE_1394 PXE_BUSTYPE ('1', '3', '9', '4')
+
+#define PXE_SWAP_UINT16(n) ((((UINT16) (n) & 0x00FF) << 8) | (((UINT16) (n) & 0xFF00) >> 8))
+
+#define PXE_SWAP_UINT32(n) \
+((((UINT32)(n) & 0x000000FF) << 24) | \
+(((UINT32)(n) & 0x0000FF00) << 8) | \
+(((UINT32)(n) & 0x00FF0000) >> 8) | \
+(((UINT32)(n) & 0xFF000000) >> 24))
+
+#if PXE_UINT64_SUPPORT != 0
+#define PXE_SWAP_UINT64(n) \
+((((UINT64)(n) & 0x00000000000000FF) << 56) | \
+(((UINT64)(n) & 0x000000000000FF00) << 40) | \
+(((UINT64)(n) & 0x0000000000FF0000) << 24) | \
+(((UINT64)(n) & 0x00000000FF000000) << 8) | \
+(((UINT64)(n) & 0x000000FF00000000) >> 8) | \
+(((UINT64)(n) & 0x0000FF0000000000) >> 24) | \
+(((UINT64)(n) & 0x00FF000000000000) >> 40) | \
+(((UINT64)(n) & 0xFF00000000000000) >> 56))
+#endif // PXE_UINT64_SUPPORT
+#if PXE_NO_UINT64_SUPPORT != 0
+#define PXE_SWAP_UINT64(n) { \
+ UINT32 tmp; \
+ tmp = (PXE_UINT64) (n)[1]; \
+ (UINT64) (n)[1] = PXE_SWAP_UINT32 ((UINT64) (n)[0]); \
+ (UINT64) (n)[0] = tmp; \
+ }
+#endif // PXE_NO_UINT64_SUPPORT
+#define PXE_CPBSIZE_NOT_USED 0 // zero
+#define PXE_DBSIZE_NOT_USED 0 // zero
+#define PXE_CPBADDR_NOT_USED (PXE_UINT64) 0 // zero
+#define PXE_DBADDR_NOT_USED (PXE_UINT64) 0 // zero
+#define PXE_CONST const
+
+#define PXE_VOLATILE volatile
+
+#if PXE_UINT64_SUPPORT != 0
+//
+// typedef unsigned long PXE_UINT64;
+//
+typedef UINT64 PXE_UINT64;
+#endif // PXE_UINT64_SUPPORT
+#if PXE_NO_UINT64_SUPPORT != 0
+typedef PXE_UINT32 PXE_UINT64[2];
+#endif // PXE_NO_UINT64_SUPPORT
+#define PXE_FALSE 0 // zero
+#define PXE_TRUE (!PXE_FALSE)
+
+typedef UINT16 PXE_OPCODE;
+
+//
+// Return UNDI operational state.
+//
+#define PXE_OPCODE_GET_STATE 0x0000
+
+//
+// Change UNDI operational state from Stopped to Started.
+//
+#define PXE_OPCODE_START 0x0001
+
+//
+// Change UNDI operational state from Started to Stopped.
+//
+#define PXE_OPCODE_STOP 0x0002
+
+//
+// Get UNDI initialization information.
+//
+#define PXE_OPCODE_GET_INIT_INFO 0x0003
+
+//
+// Get NIC configuration information.
+//
+#define PXE_OPCODE_GET_CONFIG_INFO 0x0004
+
+//
+// Changed UNDI operational state from Started to Initialized.
+//
+#define PXE_OPCODE_INITIALIZE 0x0005
+
+//
+// Re-initialize the NIC H/W.
+//
+#define PXE_OPCODE_RESET 0x0006
+
+//
+// Change the UNDI operational state from Initialized to Started.
+//
+#define PXE_OPCODE_SHUTDOWN 0x0007
+
+//
+// Read & change state of external interrupt enables.
+//
+#define PXE_OPCODE_INTERRUPT_ENABLES 0x0008
+
+//
+// Read & change state of packet receive filters.
+//
+#define PXE_OPCODE_RECEIVE_FILTERS 0x0009
+
+//
+// Read & change station MAC address.
+//
+#define PXE_OPCODE_STATION_ADDRESS 0x000A
+
+//
+// Read traffic statistics.
+//
+#define PXE_OPCODE_STATISTICS 0x000B
+
+//
+// Convert multicast IP address to multicast MAC address.
+//
+#define PXE_OPCODE_MCAST_IP_TO_MAC 0x000C
+
+//
+// Read or change non-volatile storage on the NIC.
+//
+#define PXE_OPCODE_NVDATA 0x000D
+
+//
+// Get & clear interrupt status.
+//
+#define PXE_OPCODE_GET_STATUS 0x000E
+
+//
+// Fill media header in packet for transmit.
+//
+#define PXE_OPCODE_FILL_HEADER 0x000F
+
+//
+// Transmit packet(s).
+//
+#define PXE_OPCODE_TRANSMIT 0x0010
+
+//
+// Receive packet.
+//
+#define PXE_OPCODE_RECEIVE 0x0011
+
+//
+// last valid opcode:
+//
+#define PXE_OPCODE_VALID_MAX 0x0011
+
+//
+// Last valid PXE UNDI OpCode number.
+//
+#define PXE_OPCODE_LAST_VALID 0x0011
+
+typedef UINT16 PXE_OPFLAGS;
+
+#define PXE_OPFLAGS_NOT_USED 0x0000
+
+//
+// //////////////////////////////////////
+// UNDI Get State
+//
+// No OpFlags
+
+////////////////////////////////////////
+// UNDI Start
+//
+// No OpFlags
+
+////////////////////////////////////////
+// UNDI Stop
+//
+// No OpFlags
+
+////////////////////////////////////////
+// UNDI Get Init Info
+//
+// No Opflags
+
+////////////////////////////////////////
+// UNDI Get Config Info
+//
+// No Opflags
+
+////////////////////////////////////////
+// UNDI Initialize
+//
+#define PXE_OPFLAGS_INITIALIZE_CABLE_DETECT_MASK 0x0001
+#define PXE_OPFLAGS_INITIALIZE_DETECT_CABLE 0x0000
+#define PXE_OPFLAGS_INITIALIZE_DO_NOT_DETECT_CABLE 0x0001
+
+//
+// //////////////////////////////////////
+// UNDI Reset
+//
+#define PXE_OPFLAGS_RESET_DISABLE_INTERRUPTS 0x0001
+#define PXE_OPFLAGS_RESET_DISABLE_FILTERS 0x0002
+
+//
+// //////////////////////////////////////
+// UNDI Shutdown
+//
+// No OpFlags
+
+////////////////////////////////////////
+// UNDI Interrupt Enables
+//
+//
+// Select whether to enable or disable external interrupt signals.
+// Setting both enable and disable will return PXE_STATCODE_INVALID_OPFLAGS.
+//
+#define PXE_OPFLAGS_INTERRUPT_OPMASK 0xC000
+#define PXE_OPFLAGS_INTERRUPT_ENABLE 0x8000
+#define PXE_OPFLAGS_INTERRUPT_DISABLE 0x4000
+#define PXE_OPFLAGS_INTERRUPT_READ 0x0000
+
+//
+// Enable receive interrupts. An external interrupt will be generated
+// after a complete non-error packet has been received.
+//
+#define PXE_OPFLAGS_INTERRUPT_RECEIVE 0x0001
+
+//
+// Enable transmit interrupts. An external interrupt will be generated
+// after a complete non-error packet has been transmitted.
+//
+#define PXE_OPFLAGS_INTERRUPT_TRANSMIT 0x0002
+
+//
+// Enable command interrupts. An external interrupt will be generated
+// when command execution stops.
+//
+#define PXE_OPFLAGS_INTERRUPT_COMMAND 0x0004
+
+//
+// Generate software interrupt. Setting this bit generates an external
+// interrupt, if it is supported by the hardware.
+//
+#define PXE_OPFLAGS_INTERRUPT_SOFTWARE 0x0008
+
+//
+// //////////////////////////////////////
+// UNDI Receive Filters
+//
+//
+// Select whether to enable or disable receive filters.
+// Setting both enable and disable will return PXE_STATCODE_INVALID_OPCODE.
+//
+#define PXE_OPFLAGS_RECEIVE_FILTER_OPMASK 0xC000
+#define PXE_OPFLAGS_RECEIVE_FILTER_ENABLE 0x8000
+#define PXE_OPFLAGS_RECEIVE_FILTER_DISABLE 0x4000
+#define PXE_OPFLAGS_RECEIVE_FILTER_READ 0x0000
+
+//
+// To reset the contents of the multicast MAC address filter list,
+// set this OpFlag:
+//
+#define PXE_OPFLAGS_RECEIVE_FILTER_RESET_MCAST_LIST 0x2000
+
+//
+// Enable unicast packet receiving. Packets sent to the current station
+// MAC address will be received.
+//
+#define PXE_OPFLAGS_RECEIVE_FILTER_UNICAST 0x0001
+
+//
+// Enable broadcast packet receiving. Packets sent to the broadcast
+// MAC address will be received.
+//
+#define PXE_OPFLAGS_RECEIVE_FILTER_BROADCAST 0x0002
+
+//
+// Enable filtered multicast packet receiving. Packets sent to any
+// of the multicast MAC addresses in the multicast MAC address filter
+// list will be received. If the filter list is empty, no multicast
+//
+#define PXE_OPFLAGS_RECEIVE_FILTER_FILTERED_MULTICAST 0x0004
+
+//
+// Enable promiscuous packet receiving. All packets will be received.
+//
+#define PXE_OPFLAGS_RECEIVE_FILTER_PROMISCUOUS 0x0008
+
+//
+// Enable promiscuous multicast packet receiving. All multicast
+// packets will be received.
+//
+#define PXE_OPFLAGS_RECEIVE_FILTER_ALL_MULTICAST 0x0010
+
+//
+// //////////////////////////////////////
+// UNDI Station Address
+//
+#define PXE_OPFLAGS_STATION_ADDRESS_READ 0x0000
+#define PXE_OPFLAGS_STATION_ADDRESS_WRITE 0x0000
+#define PXE_OPFLAGS_STATION_ADDRESS_RESET 0x0001
+
+//
+// //////////////////////////////////////
+// UNDI Statistics
+//
+#define PXE_OPFLAGS_STATISTICS_READ 0x0000
+#define PXE_OPFLAGS_STATISTICS_RESET 0x0001
+
+//
+// //////////////////////////////////////
+// UNDI MCast IP to MAC
+//
+//
+// Identify the type of IP address in the CPB.
+//
+#define PXE_OPFLAGS_MCAST_IP_TO_MAC_OPMASK 0x0003
+#define PXE_OPFLAGS_MCAST_IPV4_TO_MAC 0x0000
+#define PXE_OPFLAGS_MCAST_IPV6_TO_MAC 0x0001
+
+//
+// //////////////////////////////////////
+// UNDI NvData
+//
+//
+// Select the type of non-volatile data operation.
+//
+#define PXE_OPFLAGS_NVDATA_OPMASK 0x0001
+#define PXE_OPFLAGS_NVDATA_READ 0x0000
+#define PXE_OPFLAGS_NVDATA_WRITE 0x0001
+
+//
+// //////////////////////////////////////
+// UNDI Get Status
+//
+//
+// Return current interrupt status. This will also clear any interrupts
+// that are currently set. This can be used in a polling routine. The
+// interrupt flags are still set and cleared even when the interrupts
+// are disabled.
+//
+#define PXE_OPFLAGS_GET_INTERRUPT_STATUS 0x0001
+
+//
+// Return list of transmitted buffers for recycling. Transmit buffers
+// must not be changed or unallocated until they have recycled. After
+// issuing a transmit command, wait for a transmit complete interrupt.
+// When a transmit complete interrupt is received, read the transmitted
+// buffers. Do not plan on getting one buffer per interrupt. Some
+// NICs and UNDIs may transmit multiple buffers per interrupt.
+//
+#define PXE_OPFLAGS_GET_TRANSMITTED_BUFFERS 0x0002
+
+//
+// //////////////////////////////////////
+// UNDI Fill Header
+//
+#define PXE_OPFLAGS_FILL_HEADER_OPMASK 0x0001
+#define PXE_OPFLAGS_FILL_HEADER_FRAGMENTED 0x0001
+#define PXE_OPFLAGS_FILL_HEADER_WHOLE 0x0000
+
+//
+// //////////////////////////////////////
+// UNDI Transmit
+//
+//
+// S/W UNDI only. Return after the packet has been transmitted. A
+// transmit complete interrupt will still be generated and the transmit
+// buffer will have to be recycled.
+//
+#define PXE_OPFLAGS_SWUNDI_TRANSMIT_OPMASK 0x0001
+#define PXE_OPFLAGS_TRANSMIT_BLOCK 0x0001
+#define PXE_OPFLAGS_TRANSMIT_DONT_BLOCK 0x0000
+
+//
+//
+//
+#define PXE_OPFLAGS_TRANSMIT_OPMASK 0x0002
+#define PXE_OPFLAGS_TRANSMIT_FRAGMENTED 0x0002
+#define PXE_OPFLAGS_TRANSMIT_WHOLE 0x0000
+
+//
+// //////////////////////////////////////
+// UNDI Receive
+//
+// No OpFlags
+//
+typedef UINT16 PXE_STATFLAGS;
+
+#define PXE_STATFLAGS_INITIALIZE 0x0000
+
+//
+// //////////////////////////////////////
+// Common StatFlags that can be returned by all commands.
+//
+//
+// The COMMAND_COMPLETE and COMMAND_FAILED status flags must be
+// implemented by all UNDIs. COMMAND_QUEUED is only needed by UNDIs
+// that support command queuing.
+//
+#define PXE_STATFLAGS_STATUS_MASK 0xC000
+#define PXE_STATFLAGS_COMMAND_COMPLETE 0xC000
+#define PXE_STATFLAGS_COMMAND_FAILED 0x8000
+#define PXE_STATFLAGS_COMMAND_QUEUED 0x4000
+//
+// #define PXE_STATFLAGS_INITIALIZE 0x0000
+//
+#define PXE_STATFLAGS_DB_WRITE_TRUNCATED 0x2000
+
+//
+// //////////////////////////////////////
+// UNDI Get State
+//
+#define PXE_STATFLAGS_GET_STATE_MASK 0x0003
+#define PXE_STATFLAGS_GET_STATE_INITIALIZED 0x0002
+#define PXE_STATFLAGS_GET_STATE_STARTED 0x0001
+#define PXE_STATFLAGS_GET_STATE_STOPPED 0x0000
+
+//
+// //////////////////////////////////////
+// UNDI Start
+//
+// No additional StatFlags
+
+////////////////////////////////////////
+// UNDI Get Init Info
+//
+#define PXE_STATFLAGS_CABLE_DETECT_MASK 0x0001
+#define PXE_STATFLAGS_CABLE_DETECT_NOT_SUPPORTED 0x0000
+#define PXE_STATFLAGS_CABLE_DETECT_SUPPORTED 0x0001
+
+//
+// //////////////////////////////////////
+// UNDI Initialize
+//
+#define PXE_STATFLAGS_INITIALIZED_NO_MEDIA 0x0001
+
+//
+// //////////////////////////////////////
+// UNDI Reset
+//
+#define PXE_STATFLAGS_RESET_NO_MEDIA 0x0001
+
+//
+// //////////////////////////////////////
+// UNDI Shutdown
+//
+// No additional StatFlags
+
+////////////////////////////////////////
+// UNDI Interrupt Enables
+//
+//
+// If set, receive interrupts are enabled.
+//
+#define PXE_STATFLAGS_INTERRUPT_RECEIVE 0x0001
+
+//
+// If set, transmit interrupts are enabled.
+//
+#define PXE_STATFLAGS_INTERRUPT_TRANSMIT 0x0002
+
+//
+// If set, command interrupts are enabled.
+//
+#define PXE_STATFLAGS_INTERRUPT_COMMAND 0x0004
+
+//
+// //////////////////////////////////////
+// UNDI Receive Filters
+//
+//
+// If set, unicast packets will be received.
+//
+#define PXE_STATFLAGS_RECEIVE_FILTER_UNICAST 0x0001
+
+//
+// If set, broadcast packets will be received.
+//
+#define PXE_STATFLAGS_RECEIVE_FILTER_BROADCAST 0x0002
+
+//
+// If set, multicast packets that match up with the multicast address
+// filter list will be received.
+//
+#define PXE_STATFLAGS_RECEIVE_FILTER_FILTERED_MULTICAST 0x0004
+
+//
+// If set, all packets will be received.
+//
+#define PXE_STATFLAGS_RECEIVE_FILTER_PROMISCUOUS 0x0008
+
+//
+// If set, all multicast packets will be received.
+//
+#define PXE_STATFLAGS_RECEIVE_FILTER_ALL_MULTICAST 0x0010
+
+//
+// //////////////////////////////////////
+// UNDI Station Address
+//
+// No additional StatFlags
+
+////////////////////////////////////////
+// UNDI Statistics
+//
+// No additional StatFlags
+
+////////////////////////////////////////
+// UNDI MCast IP to MAC
+//
+// No additional StatFlags
+
+////////////////////////////////////////
+// UNDI NvData
+//
+// No additional StatFlags
+
+
+////////////////////////////////////////
+// UNDI Get Status
+//
+//
+// Use to determine if an interrupt has occurred.
+//
+#define PXE_STATFLAGS_GET_STATUS_INTERRUPT_MASK 0x000F
+#define PXE_STATFLAGS_GET_STATUS_NO_INTERRUPTS 0x0000
+
+//
+// If set, at least one receive interrupt occurred.
+//
+#define PXE_STATFLAGS_GET_STATUS_RECEIVE 0x0001
+
+//
+// If set, at least one transmit interrupt occurred.
+//
+#define PXE_STATFLAGS_GET_STATUS_TRANSMIT 0x0002
+
+//
+// If set, at least one command interrupt occurred.
+//
+#define PXE_STATFLAGS_GET_STATUS_COMMAND 0x0004
+
+//
+// If set, at least one software interrupt occurred.
+//
+#define PXE_STATFLAGS_GET_STATUS_SOFTWARE 0x0008
+
+//
+// This flag is set if the transmitted buffer queue is empty. This flag
+// will be set if all transmitted buffer addresses get written into the DB.
+//
+#define PXE_STATFLAGS_GET_STATUS_TXBUF_QUEUE_EMPTY 0x0010
+
+//
+// This flag is set if no transmitted buffer addresses were written
+// into the DB. (This could be because DBsize was too small.)
+//
+#define PXE_STATFLAGS_GET_STATUS_NO_TXBUFS_WRITTEN 0x0020
+
+//
+// //////////////////////////////////////
+// UNDI Fill Header
+//
+// No additional StatFlags
+
+////////////////////////////////////////
+// UNDI Transmit
+//
+// No additional StatFlags.
+
+////////////////////////////////////////
+// UNDI Receive
+//
+// No additional StatFlags.
+//
+typedef UINT16 PXE_STATCODE;
+
+#define PXE_STATCODE_INITIALIZE 0x0000
+
+//
+// //////////////////////////////////////
+// Common StatCodes returned by all UNDI commands, UNDI protocol functions
+// and BC protocol functions.
+//
+#define PXE_STATCODE_SUCCESS 0x0000
+
+#define PXE_STATCODE_INVALID_CDB 0x0001
+#define PXE_STATCODE_INVALID_CPB 0x0002
+#define PXE_STATCODE_BUSY 0x0003
+#define PXE_STATCODE_QUEUE_FULL 0x0004
+#define PXE_STATCODE_ALREADY_STARTED 0x0005
+#define PXE_STATCODE_NOT_STARTED 0x0006
+#define PXE_STATCODE_NOT_SHUTDOWN 0x0007
+#define PXE_STATCODE_ALREADY_INITIALIZED 0x0008
+#define PXE_STATCODE_NOT_INITIALIZED 0x0009
+#define PXE_STATCODE_DEVICE_FAILURE 0x000A
+#define PXE_STATCODE_NVDATA_FAILURE 0x000B
+#define PXE_STATCODE_UNSUPPORTED 0x000C
+#define PXE_STATCODE_BUFFER_FULL 0x000D
+#define PXE_STATCODE_INVALID_PARAMETER 0x000E
+#define PXE_STATCODE_INVALID_UNDI 0x000F
+#define PXE_STATCODE_IPV4_NOT_SUPPORTED 0x0010
+#define PXE_STATCODE_IPV6_NOT_SUPPORTED 0x0011
+#define PXE_STATCODE_NOT_ENOUGH_MEMORY 0x0012
+#define PXE_STATCODE_NO_DATA 0x0013
+
+typedef UINT16 PXE_IFNUM;
+
+//
+// This interface number must be passed to the S/W UNDI Start command.
+//
+#define PXE_IFNUM_START 0x0000
+
+//
+// This interface number is returned by the S/W UNDI Get State and
+// Start commands if information in the CDB, CPB or DB is invalid.
+//
+#define PXE_IFNUM_INVALID 0x0000
+
+typedef UINT16 PXE_CONTROL;
+
+//
+// Setting this flag directs the UNDI to queue this command for later
+// execution if the UNDI is busy and it supports command queuing.
+// If queuing is not supported, a PXE_STATCODE_INVALID_CONTROL error
+// is returned. If the queue is full, a PXE_STATCODE_CDB_QUEUE_FULL
+// error is returned.
+//
+#define PXE_CONTROL_QUEUE_IF_BUSY 0x0002
+
+//
+// These two bit values are used to determine if there are more UNDI
+// CDB structures following this one. If the link bit is set, there
+// must be a CDB structure following this one. Execution will start
+// on the next CDB structure as soon as this one completes successfully.
+// If an error is generated by this command, execution will stop.
+//
+#define PXE_CONTROL_LINK 0x0001
+#define PXE_CONTROL_LAST_CDB_IN_LIST 0x0000
+
+typedef UINT8 PXE_FRAME_TYPE;
+
+#define PXE_FRAME_TYPE_NONE 0x00
+#define PXE_FRAME_TYPE_UNICAST 0x01
+#define PXE_FRAME_TYPE_BROADCAST 0x02
+#define PXE_FRAME_TYPE_MULTICAST 0x03
+#define PXE_FRAME_TYPE_PROMISCUOUS 0x04
+
+typedef UINT32 PXE_IPV4;
+
+typedef UINT32 PXE_IPV6[4];
+#define PXE_MAC_LENGTH 32
+
+typedef UINT8 PXE_MAC_ADDR[PXE_MAC_LENGTH];
+
+typedef UINT8 PXE_IFTYPE;
+typedef UINT16 PXE_MEDIA_PROTOCOL;
+
+//
+// This information is from the ARP section of RFC 1700.
+//
+// 1 Ethernet (10Mb) [JBP]
+// 2 Experimental Ethernet (3Mb) [JBP]
+// 3 Amateur Radio AX.25 [PXK]
+// 4 Proteon ProNET Token Ring [JBP]
+// 5 Chaos [GXP]
+// 6 IEEE 802 Networks [JBP]
+// 7 ARCNET [JBP]
+// 8 Hyperchannel [JBP]
+// 9 Lanstar [TU]
+// 10 Autonet Short Address [MXB1]
+// 11 LocalTalk [JKR1]
+// 12 LocalNet (IBM* PCNet or SYTEK* LocalNET) [JXM]
+// 13 Ultra link [RXD2]
+// 14 SMDS [GXC1]
+// 15 Frame Relay [AGM]
+// 16 Asynchronous Transmission Mode (ATM) [JXB2]
+// 17 HDLC [JBP]
+// 18 Fibre Channel [Yakov Rekhter]
+// 19 Asynchronous Transmission Mode (ATM) [Mark Laubach]
+// 20 Serial Line [JBP]
+// 21 Asynchronous Transmission Mode (ATM) [MXB1]
+//
+// * Other names and brands may be claimed as the property of others.
+//
+#define PXE_IFTYPE_ETHERNET 0x01
+#define PXE_IFTYPE_TOKENRING 0x04
+#define PXE_IFTYPE_FIBRE_CHANNEL 0x12
+
+typedef struct s_pxe_hw_undi {
+ UINT32 Signature; // PXE_ROMID_SIGNATURE
+ UINT8 Len; // sizeof(PXE_HW_UNDI)
+ UINT8 Fudge; // makes 8-bit cksum equal zero
+ UINT8 Rev; // PXE_ROMID_REV
+ UINT8 IFcnt; // physical connector count
+ UINT8 MajorVer; // PXE_ROMID_MAJORVER
+ UINT8 MinorVer; // PXE_ROMID_MINORVER
+ UINT16 reserved; // zero, not used
+ UINT32 Implementation; // implementation flags
+ // reserved // vendor use
+ // UINT32 Status; // status port
+ // UINT32 Command; // command port
+ // UINT64 CDBaddr; // CDB address port
+ //
+} PXE_HW_UNDI;
+
+//
+// Status port bit definitions
+//
+//
+// UNDI operation state
+//
+#define PXE_HWSTAT_STATE_MASK 0xC0000000
+#define PXE_HWSTAT_BUSY 0xC0000000
+#define PXE_HWSTAT_INITIALIZED 0x80000000
+#define PXE_HWSTAT_STARTED 0x40000000
+#define PXE_HWSTAT_STOPPED 0x00000000
+
+//
+// If set, last command failed
+//
+#define PXE_HWSTAT_COMMAND_FAILED 0x20000000
+
+//
+// If set, identifies enabled receive filters
+//
+#define PXE_HWSTAT_PROMISCUOUS_MULTICAST_RX_ENABLED 0x00001000
+#define PXE_HWSTAT_PROMISCUOUS_RX_ENABLED 0x00000800
+#define PXE_HWSTAT_BROADCAST_RX_ENABLED 0x00000400
+#define PXE_HWSTAT_MULTICAST_RX_ENABLED 0x00000200
+#define PXE_HWSTAT_UNICAST_RX_ENABLED 0x00000100
+
+//
+// If set, identifies enabled external interrupts
+//
+#define PXE_HWSTAT_SOFTWARE_INT_ENABLED 0x00000080
+#define PXE_HWSTAT_TX_COMPLETE_INT_ENABLED 0x00000040
+#define PXE_HWSTAT_PACKET_RX_INT_ENABLED 0x00000020
+#define PXE_HWSTAT_CMD_COMPLETE_INT_ENABLED 0x00000010
+
+//
+// If set, identifies pending interrupts
+//
+#define PXE_HWSTAT_SOFTWARE_INT_PENDING 0x00000008
+#define PXE_HWSTAT_TX_COMPLETE_INT_PENDING 0x00000004
+#define PXE_HWSTAT_PACKET_RX_INT_PENDING 0x00000002
+#define PXE_HWSTAT_CMD_COMPLETE_INT_PENDING 0x00000001
+
+//
+// Command port definitions
+//
+//
+// If set, CDB identified in CDBaddr port is given to UNDI.
+// If not set, other bits in this word will be processed.
+//
+#define PXE_HWCMD_ISSUE_COMMAND 0x80000000
+#define PXE_HWCMD_INTS_AND_FILTS 0x00000000
+
+//
+// Use these to enable/disable receive filters.
+//
+#define PXE_HWCMD_PROMISCUOUS_MULTICAST_RX_ENABLE 0x00001000
+#define PXE_HWCMD_PROMISCUOUS_RX_ENABLE 0x00000800
+#define PXE_HWCMD_BROADCAST_RX_ENABLE 0x00000400
+#define PXE_HWCMD_MULTICAST_RX_ENABLE 0x00000200
+#define PXE_HWCMD_UNICAST_RX_ENABLE 0x00000100
+
+//
+// Use these to enable/disable external interrupts
+//
+#define PXE_HWCMD_SOFTWARE_INT_ENABLE 0x00000080
+#define PXE_HWCMD_TX_COMPLETE_INT_ENABLE 0x00000040
+#define PXE_HWCMD_PACKET_RX_INT_ENABLE 0x00000020
+#define PXE_HWCMD_CMD_COMPLETE_INT_ENABLE 0x00000010
+
+//
+// Use these to clear pending external interrupts
+//
+#define PXE_HWCMD_CLEAR_SOFTWARE_INT 0x00000008
+#define PXE_HWCMD_CLEAR_TX_COMPLETE_INT 0x00000004
+#define PXE_HWCMD_CLEAR_PACKET_RX_INT 0x00000002
+#define PXE_HWCMD_CLEAR_CMD_COMPLETE_INT 0x00000001
+
+typedef struct s_pxe_sw_undi {
+ UINT32 Signature; // PXE_ROMID_SIGNATURE
+ UINT8 Len; // sizeof(PXE_SW_UNDI)
+ UINT8 Fudge; // makes 8-bit cksum zero
+ UINT8 Rev; // PXE_ROMID_REV
+ UINT8 IFcnt; // physical connector count
+ UINT8 MajorVer; // PXE_ROMID_MAJORVER
+ UINT8 MinorVer; // PXE_ROMID_MINORVER
+ UINT16 reserved1; // zero, not used
+ UINT32 Implementation; // Implementation flags
+ UINT64 EntryPoint; // API entry point
+ UINT8 reserved2[3]; // zero, not used
+ UINT8 BusCnt; // number of bustypes supported
+ UINT32 BusType[1]; // list of supported bustypes
+} PXE_SW_UNDI;
+
+typedef union u_pxe_undi {
+ PXE_HW_UNDI hw;
+ PXE_SW_UNDI sw;
+} PXE_UNDI;
+
+//
+// Signature of !PXE structure
+//
+#define PXE_ROMID_SIGNATURE PXE_BUSTYPE ('!', 'P', 'X', 'E')
+
+//
+// !PXE structure format revision
+//
+#define PXE_ROMID_REV 0x02
+
+//
+// UNDI command interface revision. These are the values that get sent
+// in option 94 (Client Network Interface Identifier) in the DHCP Discover
+// and PXE Boot Server Request packets.
+//
+#define PXE_ROMID_MAJORVER 0x03
+#define PXE_ROMID_MINORVER 0x00
+#define PXE_ROMID_MINORVER_31 0x10
+
+//
+// Implementation flags
+//
+#define PXE_ROMID_IMP_HW_UNDI 0x80000000
+#define PXE_ROMID_IMP_SW_VIRT_ADDR 0x40000000
+#define PXE_ROMID_IMP_64BIT_DEVICE 0x00010000
+#define PXE_ROMID_IMP_FRAG_SUPPORTED 0x00008000
+#define PXE_ROMID_IMP_CMD_LINK_SUPPORTED 0x00004000
+#define PXE_ROMID_IMP_CMD_QUEUE_SUPPORTED 0x00002000
+#define PXE_ROMID_IMP_MULTI_FRAME_SUPPORTED 0x00001000
+#define PXE_ROMID_IMP_NVDATA_SUPPORT_MASK 0x00000C00
+#define PXE_ROMID_IMP_NVDATA_BULK_WRITABLE 0x00000C00
+#define PXE_ROMID_IMP_NVDATA_SPARSE_WRITABLE 0x00000800
+#define PXE_ROMID_IMP_NVDATA_READ_ONLY 0x00000400
+#define PXE_ROMID_IMP_NVDATA_NOT_AVAILABLE 0x00000000
+#define PXE_ROMID_IMP_STATISTICS_SUPPORTED 0x00000200
+#define PXE_ROMID_IMP_STATION_ADDR_SETTABLE 0x00000100
+#define PXE_ROMID_IMP_PROMISCUOUS_MULTICAST_RX_SUPPORTED 0x00000080
+#define PXE_ROMID_IMP_PROMISCUOUS_RX_SUPPORTED 0x00000040
+#define PXE_ROMID_IMP_BROADCAST_RX_SUPPORTED 0x00000020
+#define PXE_ROMID_IMP_FILTERED_MULTICAST_RX_SUPPORTED 0x00000010
+#define PXE_ROMID_IMP_SOFTWARE_INT_SUPPORTED 0x00000008
+#define PXE_ROMID_IMP_TX_COMPLETE_INT_SUPPORTED 0x00000004
+#define PXE_ROMID_IMP_PACKET_RX_INT_SUPPORTED 0x00000002
+#define PXE_ROMID_IMP_CMD_COMPLETE_INT_SUPPORTED 0x00000001
+
+typedef struct s_pxe_cdb {
+ PXE_OPCODE OpCode;
+ PXE_OPFLAGS OpFlags;
+ UINT16 CPBsize;
+ UINT16 DBsize;
+ UINT64 CPBaddr;
+ UINT64 DBaddr;
+ PXE_STATCODE StatCode;
+ PXE_STATFLAGS StatFlags;
+ UINT16 IFnum;
+ PXE_CONTROL Control;
+} PXE_CDB;
+
+typedef union u_pxe_ip_addr {
+ PXE_IPV6 IPv6;
+ PXE_IPV4 IPv4;
+} PXE_IP_ADDR;
+
+typedef union pxe_device {
+ //
+ // PCI and PC Card NICs are both identified using bus, device
+ // and function numbers. For PC Card, this may require PC
+ // Card services to be loaded in the BIOS or preboot
+ // environment.
+ //
+ struct {
+ //
+ // See S/W UNDI ROMID structure definition for PCI and
+ // PCC BusType definitions.
+ //
+ UINT32 BusType;
+
+ //
+ // Bus, device & function numbers that locate this device.
+ //
+ UINT16 Bus;
+ UINT8 Device;
+ UINT8 Function;
+ }
+ PCI, PCC;
+
+ //
+ // %%TBD - More information is needed about enumerating
+ // USB and 1394 devices.
+ //
+ struct {
+ UINT32 BusType;
+ UINT32 tdb;
+ }
+ USB, _1394;
+} PXE_DEVICE;
+
+//
+// cpb and db definitions
+//
+#define MAX_PCI_CONFIG_LEN 64 // # of dwords
+#define MAX_EEPROM_LEN 128 // #of dwords
+#define MAX_XMIT_BUFFERS 32 // recycling Q length for xmit_done
+#define MAX_MCAST_ADDRESS_CNT 8
+
+typedef struct s_pxe_cpb_start {
+ //
+ // PXE_VOID Delay(UINTN microseconds);
+ //
+ // UNDI will never request a delay smaller than 10 microseconds
+ // and will always request delays in increments of 10 microseconds.
+ // The Delay() CallBack routine must delay between n and n + 10
+ // microseconds before returning control to the UNDI.
+ //
+ // This field cannot be set to zero.
+ //
+ UINT64 Delay;
+
+ //
+ // PXE_VOID Block(UINT32 enable);
+ //
+ // UNDI may need to block multi-threaded/multi-processor access to
+ // critical code sections when programming or accessing the network
+ // device. To this end, a blocking service is needed by the UNDI.
+ // When UNDI needs a block, it will call Block() passing a non-zero
+ // value. When UNDI no longer needs a block, it will call Block()
+ // with a zero value. When called, if the Block() is already enabled,
+ // do not return control to the UNDI until the previous Block() is
+ // disabled.
+ //
+ // This field cannot be set to zero.
+ //
+ UINT64 Block;
+
+ //
+ // PXE_VOID Virt2Phys(UINT64 virtual, UINT64 physical_ptr);
+ //
+ // UNDI will pass the virtual address of a buffer and the virtual
+ // address of a 64-bit physical buffer. Convert the virtual address
+ // to a physical address and write the result to the physical address
+ // buffer. If virtual and physical addresses are the same, just
+ // copy the virtual address to the physical address buffer.
+ //
+ // This field can be set to zero if virtual and physical addresses
+ // are equal.
+ //
+ UINT64 Virt2Phys;
+ //
+ // PXE_VOID Mem_IO(UINT8 read_write, UINT8 len, UINT64 port,
+ // UINT64 buf_addr);
+ //
+ // UNDI will read or write the device io space using this call back
+ // function. It passes the number of bytes as the len parameter and it
+ // will be either 1,2,4 or 8.
+ //
+ // This field can not be set to zero.
+ //
+ UINT64 Mem_IO;
+} PXE_CPB_START;
+
+typedef struct s_pxe_cpb_start_31 {
+ //
+ // PXE_VOID Delay(UINT64 UnqId, UINTN microseconds);
+ //
+ // UNDI will never request a delay smaller than 10 microseconds
+ // and will always request delays in increments of 10 microseconds.
+ // The Delay() CallBack routine must delay between n and n + 10
+ // microseconds before returning control to the UNDI.
+ //
+ // This field cannot be set to zero.
+ //
+ UINT64 Delay;
+
+ //
+ // PXE_VOID Block(UINT64 unq_id, UINT32 enable);
+ //
+ // UNDI may need to block multi-threaded/multi-processor access to
+ // critical code sections when programming or accessing the network
+ // device. To this end, a blocking service is needed by the UNDI.
+ // When UNDI needs a block, it will call Block() passing a non-zero
+ // value. When UNDI no longer needs a block, it will call Block()
+ // with a zero value. When called, if the Block() is already enabled,
+ // do not return control to the UNDI until the previous Block() is
+ // disabled.
+ //
+ // This field cannot be set to zero.
+ //
+ UINT64 Block;
+
+ //
+ // PXE_VOID Virt2Phys(UINT64 UnqId, UINT64 virtual, UINT64 physical_ptr);
+ //
+ // UNDI will pass the virtual address of a buffer and the virtual
+ // address of a 64-bit physical buffer. Convert the virtual address
+ // to a physical address and write the result to the physical address
+ // buffer. If virtual and physical addresses are the same, just
+ // copy the virtual address to the physical address buffer.
+ //
+ // This field can be set to zero if virtual and physical addresses
+ // are equal.
+ //
+ UINT64 Virt2Phys;
+ //
+ // PXE_VOID Mem_IO(UINT64 UnqId, UINT8 read_write, UINT8 len, UINT64 port,
+ // UINT64 buf_addr);
+ //
+ // UNDI will read or write the device io space using this call back
+ // function. It passes the number of bytes as the len parameter and it
+ // will be either 1,2,4 or 8.
+ //
+ // This field can not be set to zero.
+ //
+ UINT64 Mem_IO;
+ //
+ // PXE_VOID Map_Mem(UINT64 unq_id, UINT64 virtual_addr, UINT32 size,
+ // UINT32 Direction, UINT64 mapped_addr);
+ //
+ // UNDI will pass the virtual address of a buffer, direction of the data
+ // flow from/to the mapped buffer (the constants are defined below)
+ // and a place holder (pointer) for the mapped address.
+ // This call will Map the given address to a physical DMA address and write
+ // the result to the mapped_addr pointer. If there is no need to
+ // map the given address to a lower address (i.e. the given address is
+ // associated with a physical address that is already compatible to be
+ // used with the DMA, it converts the given virtual address to it's
+ // physical address and write that in the mapped address pointer.
+ //
+ // This field can be set to zero if there is no mapping service available
+ //
+ UINT64 Map_Mem;
+
+ //
+ // PXE_VOID UnMap_Mem(UINT64 unq_id, UINT64 virtual_addr, UINT32 size,
+ // UINT32 Direction, UINT64 mapped_addr);
+ //
+ // UNDI will pass the virtual and mapped addresses of a buffer
+ // This call will un map the given address
+ //
+ // This field can be set to zero if there is no unmapping service available
+ //
+ UINT64 UnMap_Mem;
+
+ //
+ // PXE_VOID Sync_Mem(UINT64 unq_id, UINT64 virtual,
+ // UINT32 size, UINT32 Direction, UINT64 mapped_addr);
+ //
+ // UNDI will pass the virtual and mapped addresses of a buffer
+ // This call will synchronize the contents of both the virtual and mapped
+ // buffers for the given Direction.
+ //
+ // This field can be set to zero if there is no service available
+ //
+ UINT64 Sync_Mem;
+
+ //
+ // protocol driver can provide anything for this Unique_ID, UNDI remembers
+ // that as just a 64bit value assocaited to the interface specified by
+ // the ifnum and gives it back as a parameter to all the call-back routines
+ // when calling for that interface!
+ //
+ UINT64 Unique_ID;
+ //
+} PXE_CPB_START_31;
+
+#define TO_AND_FROM_DEVICE 0
+#define FROM_DEVICE 1
+#define TO_DEVICE 2
+
+#define PXE_DELAY_MILLISECOND 1000
+#define PXE_DELAY_SECOND 1000000
+#define PXE_IO_READ 0
+#define PXE_IO_WRITE 1
+#define PXE_MEM_READ 2
+#define PXE_MEM_WRITE 4
+
+typedef struct s_pxe_db_get_init_info {
+ //
+ // Minimum length of locked memory buffer that must be given to
+ // the Initialize command. Giving UNDI more memory will generally
+ // give better performance.
+ //
+ // If MemoryRequired is zero, the UNDI does not need and will not
+ // use system memory to receive and transmit packets.
+ //
+ UINT32 MemoryRequired;
+
+ //
+ // Maximum frame data length for Tx/Rx excluding the media header.
+ //
+ UINT32 FrameDataLen;
+
+ //
+ // Supported link speeds are in units of mega bits. Common ethernet
+ // values are 10, 100 and 1000. Unused LinkSpeeds[] entries are zero
+ // filled.
+ //
+ UINT32 LinkSpeeds[4];
+
+ //
+ // Number of non-volatile storage items.
+ //
+ UINT32 NvCount;
+
+ //
+ // Width of non-volatile storage item in bytes. 0, 1, 2 or 4
+ //
+ UINT16 NvWidth;
+
+ //
+ // Media header length. This is the typical media header length for
+ // this UNDI. This information is needed when allocating receive
+ // and transmit buffers.
+ //
+ UINT16 MediaHeaderLen;
+
+ //
+ // Number of bytes in the NIC hardware (MAC) address.
+ //
+ UINT16 HWaddrLen;
+
+ //
+ // Maximum number of multicast MAC addresses in the multicast
+ // MAC address filter list.
+ //
+ UINT16 MCastFilterCnt;
+
+ //
+ // Default number and size of transmit and receive buffers that will
+ // be allocated by the UNDI. If MemoryRequired is non-zero, this
+ // allocation will come out of the memory buffer given to the Initialize
+ // command. If MemoryRequired is zero, this allocation will come out of
+ // memory on the NIC.
+ //
+ UINT16 TxBufCnt;
+ UINT16 TxBufSize;
+ UINT16 RxBufCnt;
+ UINT16 RxBufSize;
+
+ //
+ // Hardware interface types defined in the Assigned Numbers RFC
+ // and used in DHCP and ARP packets.
+ // See the PXE_IFTYPE typedef and PXE_IFTYPE_xxx macros.
+ //
+ UINT8 IFtype;
+
+ //
+ // Supported duplex. See PXE_DUPLEX_xxxxx #defines below.
+ //
+ UINT8 Duplex;
+
+ //
+ // Supported loopback options. See PXE_LOOPBACK_xxxxx #defines below.
+ //
+ UINT8 LoopBack;
+} PXE_DB_GET_INIT_INFO;
+
+#define PXE_MAX_TXRX_UNIT_ETHER 1500
+
+#define PXE_HWADDR_LEN_ETHER 0x0006
+#define PXE_MAC_HEADER_LEN_ETHER 0x000E
+
+#define PXE_DUPLEX_ENABLE_FULL_SUPPORTED 1
+#define PXE_DUPLEX_FORCE_FULL_SUPPORTED 2
+
+#define PXE_LOOPBACK_INTERNAL_SUPPORTED 1
+#define PXE_LOOPBACK_EXTERNAL_SUPPORTED 2
+
+typedef struct s_pxe_pci_config_info {
+ //
+ // This is the flag field for the PXE_DB_GET_CONFIG_INFO union.
+ // For PCI bus devices, this field is set to PXE_BUSTYPE_PCI.
+ //
+ UINT32 BusType;
+
+ //
+ // This identifies the PCI network device that this UNDI interface
+ // is bound to.
+ //
+ UINT16 Bus;
+ UINT8 Device;
+ UINT8 Function;
+
+ //
+ // This is a copy of the PCI configuration space for this
+ // network device.
+ //
+ union {
+ UINT8 Byte[256];
+ UINT16 Word[128];
+ UINT32 Dword[64];
+ } Config;
+} PXE_PCI_CONFIG_INFO;
+
+typedef struct s_pxe_pcc_config_info {
+ //
+ // This is the flag field for the PXE_DB_GET_CONFIG_INFO union.
+ // For PCC bus devices, this field is set to PXE_BUSTYPE_PCC.
+ //
+ UINT32 BusType;
+
+ //
+ // This identifies the PCC network device that this UNDI interface
+ // is bound to.
+ //
+ UINT16 Bus;
+ UINT8 Device;
+ UINT8 Function;
+
+ //
+ // This is a copy of the PCC configuration space for this
+ // network device.
+ //
+ union {
+ UINT8 Byte[256];
+ UINT16 Word[128];
+ UINT32 Dword[64];
+ } Config;
+} PXE_PCC_CONFIG_INFO;
+
+typedef struct s_pxe_usb_config_info {
+ UINT32 BusType;
+ //
+ // %%TBD What should we return here...
+ //
+} PXE_USB_CONFIG_INFO;
+
+typedef struct s_pxe_1394_config_info {
+ UINT32 BusType;
+ //
+ // %%TBD What should we return here...
+ //
+} PXE_1394_CONFIG_INFO;
+
+typedef union u_pxe_db_get_config_info {
+ PXE_PCI_CONFIG_INFO pci;
+ PXE_PCC_CONFIG_INFO pcc;
+ PXE_USB_CONFIG_INFO usb;
+ PXE_1394_CONFIG_INFO _1394;
+} PXE_DB_GET_CONFIG_INFO;
+
+typedef struct s_pxe_cpb_initialize {
+ //
+ // Address of first (lowest) byte of the memory buffer. This buffer must
+ // be in contiguous physical memory and cannot be swapped out. The UNDI
+ // will be using this for transmit and receive buffering.
+ //
+ UINT64 MemoryAddr;
+
+ //
+ // MemoryLength must be greater than or equal to MemoryRequired
+ // returned by the Get Init Info command.
+ //
+ UINT32 MemoryLength;
+
+ //
+ // Desired link speed in Mbit/sec. Common ethernet values are 10, 100
+ // and 1000. Setting a value of zero will auto-detect and/or use the
+ // default link speed (operation depends on UNDI/NIC functionality).
+ //
+ UINT32 LinkSpeed;
+
+ //
+ // Suggested number and size of receive and transmit buffers to
+ // allocate. If MemoryAddr and MemoryLength are non-zero, this
+ // allocation comes out of the supplied memory buffer. If MemoryAddr
+ // and MemoryLength are zero, this allocation comes out of memory
+ // on the NIC.
+ //
+ // If these fields are set to zero, the UNDI will allocate buffer
+ // counts and sizes as it sees fit.
+ //
+ UINT16 TxBufCnt;
+ UINT16 TxBufSize;
+ UINT16 RxBufCnt;
+ UINT16 RxBufSize;
+
+ //
+ // The following configuration parameters are optional and must be zero
+ // to use the default values.
+ //
+ UINT8 Duplex;
+
+ UINT8 LoopBack;
+} PXE_CPB_INITIALIZE;
+
+#define PXE_DUPLEX_DEFAULT 0x00
+#define PXE_FORCE_FULL_DUPLEX 0x01
+#define PXE_ENABLE_FULL_DUPLEX 0x02
+#define PXE_FORCE_HALF_DUPLEX 0x04
+#define PXE_DISABLE_FULL_DUPLEX 0x08
+
+#define LOOPBACK_NORMAL 0
+#define LOOPBACK_INTERNAL 1
+#define LOOPBACK_EXTERNAL 2
+
+typedef struct s_pxe_db_initialize {
+ //
+ // Actual amount of memory used from the supplied memory buffer. This
+ // may be less that the amount of memory suppllied and may be zero if
+ // the UNDI and network device do not use external memory buffers.
+ //
+ // Memory used by the UNDI and network device is allocated from the
+ // lowest memory buffer address.
+ //
+ UINT32 MemoryUsed;
+
+ //
+ // Actual number and size of receive and transmit buffers that were
+ // allocated.
+ //
+ UINT16 TxBufCnt;
+ UINT16 TxBufSize;
+ UINT16 RxBufCnt;
+ UINT16 RxBufSize;
+} PXE_DB_INITIALIZE;
+
+typedef struct s_pxe_cpb_receive_filters {
+ //
+ // List of multicast MAC addresses. This list, if present, will
+ // replace the existing multicast MAC address filter list.
+ //
+ PXE_MAC_ADDR MCastList[MAX_MCAST_ADDRESS_CNT];
+} PXE_CPB_RECEIVE_FILTERS;
+
+typedef struct s_pxe_db_receive_filters {
+ //
+ // Filtered multicast MAC address list.
+ //
+ PXE_MAC_ADDR MCastList[MAX_MCAST_ADDRESS_CNT];
+} PXE_DB_RECEIVE_FILTERS;
+
+typedef struct s_pxe_cpb_station_address {
+ //
+ // If supplied and supported, the current station MAC address
+ // will be changed.
+ //
+ PXE_MAC_ADDR StationAddr;
+} PXE_CPB_STATION_ADDRESS;
+
+typedef struct s_pxe_dpb_station_address {
+ //
+ // Current station MAC address.
+ //
+ PXE_MAC_ADDR StationAddr;
+
+ //
+ // Station broadcast MAC address.
+ //
+ PXE_MAC_ADDR BroadcastAddr;
+
+ //
+ // Permanent station MAC address.
+ //
+ PXE_MAC_ADDR PermanentAddr;
+} PXE_DB_STATION_ADDRESS;
+
+typedef struct s_pxe_db_statistics {
+ //
+ // Bit field identifying what statistic data is collected by the
+ // UNDI/NIC.
+ // If bit 0x00 is set, Data[0x00] is collected.
+ // If bit 0x01 is set, Data[0x01] is collected.
+ // If bit 0x20 is set, Data[0x20] is collected.
+ // If bit 0x21 is set, Data[0x21] is collected.
+ // Etc.
+ //
+ UINT64 Supported;
+
+ //
+ // Statistic data.
+ //
+ UINT64 Data[64];
+} PXE_DB_STATISTICS;
+
+//
+// Total number of frames received. Includes frames with errors and
+// dropped frames.
+//
+#define PXE_STATISTICS_RX_TOTAL_FRAMES 0x00
+
+//
+// Number of valid frames received and copied into receive buffers.
+//
+#define PXE_STATISTICS_RX_GOOD_FRAMES 0x01
+
+//
+// Number of frames below the minimum length for the media.
+// This would be <64 for ethernet.
+//
+#define PXE_STATISTICS_RX_UNDERSIZE_FRAMES 0x02
+
+//
+// Number of frames longer than the maxminum length for the
+// media. This would be >1500 for ethernet.
+//
+#define PXE_STATISTICS_RX_OVERSIZE_FRAMES 0x03
+
+//
+// Valid frames that were dropped because receive buffers were full.
+//
+#define PXE_STATISTICS_RX_DROPPED_FRAMES 0x04
+
+//
+// Number of valid unicast frames received and not dropped.
+//
+#define PXE_STATISTICS_RX_UNICAST_FRAMES 0x05
+
+//
+// Number of valid broadcast frames received and not dropped.
+//
+#define PXE_STATISTICS_RX_BROADCAST_FRAMES 0x06
+
+//
+// Number of valid mutlicast frames received and not dropped.
+//
+#define PXE_STATISTICS_RX_MULTICAST_FRAMES 0x07
+
+//
+// Number of frames w/ CRC or alignment errors.
+//
+#define PXE_STATISTICS_RX_CRC_ERROR_FRAMES 0x08
+
+//
+// Total number of bytes received. Includes frames with errors
+// and dropped frames.
+//
+#define PXE_STATISTICS_RX_TOTAL_BYTES 0x09
+
+//
+// Transmit statistics.
+//
+#define PXE_STATISTICS_TX_TOTAL_FRAMES 0x0A
+#define PXE_STATISTICS_TX_GOOD_FRAMES 0x0B
+#define PXE_STATISTICS_TX_UNDERSIZE_FRAMES 0x0C
+#define PXE_STATISTICS_TX_OVERSIZE_FRAMES 0x0D
+#define PXE_STATISTICS_TX_DROPPED_FRAMES 0x0E
+#define PXE_STATISTICS_TX_UNICAST_FRAMES 0x0F
+#define PXE_STATISTICS_TX_BROADCAST_FRAMES 0x10
+#define PXE_STATISTICS_TX_MULTICAST_FRAMES 0x11
+#define PXE_STATISTICS_TX_CRC_ERROR_FRAMES 0x12
+#define PXE_STATISTICS_TX_TOTAL_BYTES 0x13
+
+//
+// Number of collisions detection on this subnet.
+//
+#define PXE_STATISTICS_COLLISIONS 0x14
+
+//
+// Number of frames destined for unsupported protocol.
+//
+#define PXE_STATISTICS_UNSUPPORTED_PROTOCOL 0x15
+
+typedef struct s_pxe_cpb_mcast_ip_to_mac {
+ //
+ // Multicast IP address to be converted to multicast MAC address.
+ //
+ PXE_IP_ADDR IP;
+} PXE_CPB_MCAST_IP_TO_MAC;
+
+typedef struct s_pxe_db_mcast_ip_to_mac {
+ //
+ // Multicast MAC address.
+ //
+ PXE_MAC_ADDR MAC;
+} PXE_DB_MCAST_IP_TO_MAC;
+
+typedef struct s_pxe_cpb_nvdata_sparse {
+ //
+ // NvData item list. Only items in this list will be updated.
+ //
+ struct {
+ //
+ // Non-volatile storage address to be changed.
+ //
+ UINT32 Addr;
+
+ //
+ // Data item to write into above storage address.
+ //
+ union {
+ UINT8 Byte;
+ UINT16 Word;
+ UINT32 Dword;
+ } Data;
+ } Item[MAX_EEPROM_LEN];
+}
+PXE_CPB_NVDATA_SPARSE;
+
+//
+// When using bulk update, the size of the CPB structure must be
+// the same size as the non-volatile NIC storage.
+//
+typedef union u_pxe_cpb_nvdata_bulk {
+ //
+ // Array of byte-wide data items.
+ //
+ UINT8 Byte[MAX_EEPROM_LEN << 2];
+
+ //
+ // Array of word-wide data items.
+ //
+ UINT16 Word[MAX_EEPROM_LEN << 1];
+
+ //
+ // Array of dword-wide data items.
+ //
+ UINT32 Dword[MAX_EEPROM_LEN];
+} PXE_CPB_NVDATA_BULK;
+
+typedef struct s_pxe_db_nvdata {
+ //
+ // Arrays of data items from non-volatile storage.
+ //
+ union {
+ //
+ // Array of byte-wide data items.
+ //
+ UINT8 Byte[MAX_EEPROM_LEN << 2];
+
+ //
+ // Array of word-wide data items.
+ //
+ UINT16 Word[MAX_EEPROM_LEN << 1];
+
+ //
+ // Array of dword-wide data items.
+ //
+ UINT32 Dword[MAX_EEPROM_LEN];
+ } Data;
+} PXE_DB_NVDATA;
+
+typedef struct s_pxe_db_get_status {
+ //
+ // Length of next receive frame (header + data). If this is zero,
+ // there is no next receive frame available.
+ //
+ UINT32 RxFrameLen;
+
+ //
+ // Reserved, set to zero.
+ //
+ UINT32 reserved;
+
+ //
+ // Addresses of transmitted buffers that need to be recycled.
+ //
+ UINT64 TxBuffer[MAX_XMIT_BUFFERS];
+} PXE_DB_GET_STATUS;
+
+typedef struct s_pxe_cpb_fill_header {
+ //
+ // Source and destination MAC addresses. These will be copied into
+ // the media header without doing byte swapping.
+ //
+ PXE_MAC_ADDR SrcAddr;
+ PXE_MAC_ADDR DestAddr;
+
+ //
+ // Address of first byte of media header. The first byte of packet data
+ // follows the last byte of the media header.
+ //
+ UINT64 MediaHeader;
+
+ //
+ // Length of packet data in bytes (not including the media header).
+ //
+ UINT32 PacketLen;
+
+ //
+ // Protocol type. This will be copied into the media header without
+ // doing byte swapping. Protocol type numbers can be obtained from
+ // the Assigned Numbers RFC 1700.
+ //
+ UINT16 Protocol;
+
+ //
+ // Length of the media header in bytes.
+ //
+ UINT16 MediaHeaderLen;
+} PXE_CPB_FILL_HEADER;
+
+#define PXE_PROTOCOL_ETHERNET_IP 0x0800
+#define PXE_PROTOCOL_ETHERNET_ARP 0x0806
+#define MAX_XMIT_FRAGMENTS 16
+
+typedef struct s_pxe_cpb_fill_header_fragmented {
+ //
+ // Source and destination MAC addresses. These will be copied into
+ // the media header without doing byte swapping.
+ //
+ PXE_MAC_ADDR SrcAddr;
+ PXE_MAC_ADDR DestAddr;
+
+ //
+ // Length of packet data in bytes (not including the media header).
+ //
+ UINT32 PacketLen;
+
+ //
+ // Protocol type. This will be copied into the media header without
+ // doing byte swapping. Protocol type numbers can be obtained from
+ // the Assigned Numbers RFC 1700.
+ //
+ PXE_MEDIA_PROTOCOL Protocol;
+
+ //
+ // Length of the media header in bytes.
+ //
+ UINT16 MediaHeaderLen;
+
+ //
+ // Number of packet fragment descriptors.
+ //
+ UINT16 FragCnt;
+
+ //
+ // Reserved, must be set to zero.
+ //
+ UINT16 reserved;
+
+ //
+ // Array of packet fragment descriptors. The first byte of the media
+ // header is the first byte of the first fragment.
+ //
+ struct {
+ //
+ // Address of this packet fragment.
+ //
+ UINT64 FragAddr;
+
+ //
+ // Length of this packet fragment.
+ //
+ UINT32 FragLen;
+
+ //
+ // Reserved, must be set to zero.
+ //
+ UINT32 reserved;
+ } FragDesc[MAX_XMIT_FRAGMENTS];
+}
+PXE_CPB_FILL_HEADER_FRAGMENTED;
+
+typedef struct s_pxe_cpb_transmit {
+ //
+ // Address of first byte of frame buffer. This is also the first byte
+ // of the media header.
+ //
+ UINT64 FrameAddr;
+
+ //
+ // Length of the data portion of the frame buffer in bytes. Do not
+ // include the length of the media header.
+ //
+ UINT32 DataLen;
+
+ //
+ // Length of the media header in bytes.
+ //
+ UINT16 MediaheaderLen;
+
+ //
+ // Reserved, must be zero.
+ //
+ UINT16 reserved;
+} PXE_CPB_TRANSMIT;
+
+typedef struct s_pxe_cpb_transmit_fragments {
+ //
+ // Length of packet data in bytes (not including the media header).
+ //
+ UINT32 FrameLen;
+
+ //
+ // Length of the media header in bytes.
+ //
+ UINT16 MediaheaderLen;
+
+ //
+ // Number of packet fragment descriptors.
+ //
+ UINT16 FragCnt;
+
+ //
+ // Array of frame fragment descriptors. The first byte of the first
+ // fragment is also the first byte of the media header.
+ //
+ struct {
+ //
+ // Address of this frame fragment.
+ //
+ UINT64 FragAddr;
+
+ //
+ // Length of this frame fragment.
+ //
+ UINT32 FragLen;
+
+ //
+ // Reserved, must be set to zero.
+ //
+ UINT32 reserved;
+ } FragDesc[MAX_XMIT_FRAGMENTS];
+}
+PXE_CPB_TRANSMIT_FRAGMENTS;
+
+typedef struct s_pxe_cpb_receive {
+ //
+ // Address of first byte of receive buffer. This is also the first byte
+ // of the frame header.
+ //
+ UINT64 BufferAddr;
+
+ //
+ // Length of receive buffer. This must be large enough to hold the
+ // received frame (media header + data). If the length of smaller than
+ // the received frame, data will be lost.
+ //
+ UINT32 BufferLen;
+
+ //
+ // Reserved, must be set to zero.
+ //
+ UINT32 reserved;
+} PXE_CPB_RECEIVE;
+
+typedef struct s_pxe_db_receive {
+ //
+ // Source and destination MAC addresses from media header.
+ //
+ PXE_MAC_ADDR SrcAddr;
+ PXE_MAC_ADDR DestAddr;
+
+ //
+ // Length of received frame. May be larger than receive buffer size.
+ // The receive buffer will not be overwritten. This is how to tell
+ // if data was lost because the receive buffer was too small.
+ //
+ UINT32 FrameLen;
+
+ //
+ // Protocol type from media header.
+ //
+ PXE_MEDIA_PROTOCOL Protocol;
+
+ //
+ // Length of media header in received frame.
+ //
+ UINT16 MediaHeaderLen;
+
+ //
+ // Type of receive frame.
+ //
+ PXE_FRAME_TYPE Type;
+
+ //
+ // Reserved, must be zero.
+ //
+ UINT8 reserved[7];
+
+} PXE_DB_RECEIVE;
+
+#pragma pack()
+
+#endif
diff --git a/EDK/Foundation/Include/EfiSpec.h b/EDK/Foundation/Include/EfiSpec.h
new file mode 100644
index 0000000..173c9c4
--- /dev/null
+++ b/EDK/Foundation/Include/EfiSpec.h
@@ -0,0 +1,51 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiSpec.h
+
+Abstract:
+
+ EFI master include file.
+
+ This is the main include file for EFI components. There should be
+ no defines or macros added to this file, other than the EFI version
+ information already in this file.
+
+ Don't add include files to the list for convenience, only add things
+ that are architectural. Don't add Protocols or GUID include files here
+
+--*/
+
+#ifndef _EFI_SPEC_H_
+#define _EFI_SPEC_H_
+
+#include "EfiCommon.h"
+#include "EfiApi.h"
+#include "EfiDevicePath.h"
+
+//
+// Check to make sure EFI_SPECIFICATION_VERSION and TIANO_RELEASE_VERSION are defined.
+//
+#if !defined(EFI_SPECIFICATION_VERSION)
+ #error EFI_SPECIFICATION_VERSION not defined
+#elif !defined(TIANO_RELEASE_VERSION)
+ #error TIANO_RELEASE_VERSION not defined
+#elif (TIANO_RELEASE_VERSION == 0)
+//
+// UEFI mode with no Tiano extensions is legal
+//
+#elif ((TIANO_RELEASE_VERSION < 0x00080005) && (EFI_SPECIFICATION_VERSION >= 0x00020000))
+ #error Illegal combination of EFI_SPECIFICATION_VERSION and TIANO_RELEASE_VERSION versions
+#endif
+
+#endif
diff --git a/EDK/Foundation/Include/EfiStdArg.h b/EDK/Foundation/Include/EfiStdArg.h
new file mode 100644
index 0000000..ced59c3
--- /dev/null
+++ b/EDK/Foundation/Include/EfiStdArg.h
@@ -0,0 +1,75 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiStdArg.h
+
+Abstract:
+
+ Support for variable length argument lists using the ANSI standard.
+
+ Since we are using the ANSI standard we used the standard nameing and
+ did not folow the coding convention
+
+ VA_LIST - typedef for argument list.
+ VA_START (VA_LIST Marker, argument before the ...) - Init Marker for use.
+ VA_END (VA_LIST Marker) - Clear Marker
+ VA_ARG (VA_LIST Marker, var arg size) - Use Marker to get an argumnet from
+ the ... list. You must know the size and pass it in this macro.
+
+ example:
+
+ UINTN
+ ExampleVarArg (
+ IN UINTN NumberOfArgs,
+ ...
+ )
+ {
+ VA_LIST Marker;
+ UINTN Index;
+ UINTN Result;
+
+ //
+ // Initialize the Marker
+ //
+ VA_START (Marker, NumberOfArgs);
+ for (Index = 0, Result = 0; Index < NumberOfArgs; Index++) {
+ //
+ // The ... list is a series of UINTN values, so average them up.
+ //
+ Result += VA_ARG (Marker, UINTN);
+ }
+
+ VA_END (Marker);
+ return Result
+ }
+
+--*/
+
+#ifndef _EFISTDARG_H_
+#define _EFISTDARG_H_
+
+#define _EFI_INT_SIZE_OF(n) ((sizeof (n) + sizeof (UINTN) - 1) &~(sizeof (UINTN) - 1))
+
+//
+// Also support coding convention rules for var arg macros
+//
+#ifndef VA_START
+
+typedef CHAR8 *VA_LIST;
+#define VA_START(ap, v) (ap = (VA_LIST) & (v) + _EFI_INT_SIZE_OF (v))
+#define VA_ARG(ap, t) (*(t *) ((ap += _EFI_INT_SIZE_OF (t)) - _EFI_INT_SIZE_OF (t)))
+#define VA_END(ap) (ap = (VA_LIST) 0)
+
+#endif
+
+#endif
diff --git a/EDK/Foundation/Include/EfiTpm.h b/EDK/Foundation/Include/EfiTpm.h
new file mode 100644
index 0000000..acebf5f
--- /dev/null
+++ b/EDK/Foundation/Include/EfiTpm.h
@@ -0,0 +1,144 @@
+/*++
+
+Copyright (c) 2006 - 2009, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiTpm.h
+
+Abstract:
+
+ EFI definition according to TCG_EFI_Platform_1_20_Final
+
+ See http://trustedcomputinggroup.org for latest specification updates
+
+--*/
+
+#ifndef _EFI_TPM_H_
+#define _EFI_TPM_H_
+
+#include "Tiano.h"
+
+//
+// The start of TPM return codes
+//
+#define TPM_BASE (EFI_MAX_BIT + (EFI_MAX_BIT >> 1))
+#include "Tpm12.h"
+
+//
+// Standard event types
+//
+#define EV_POST_CODE ((TCG_EVENTTYPE) 0x00000001)
+#define EV_SEPARATOR ((TCG_EVENTTYPE) 0x00000004)
+#define EV_S_CRTM_CONTENTS ((TCG_EVENTTYPE) 0x00000007)
+#define EV_S_CRTM_VERSION ((TCG_EVENTTYPE) 0x00000008)
+
+//
+// EFI specific event types
+//
+#define EV_EFI_EVENT_BASE ((TCG_EVENTTYPE) 0x80000000)
+#define EV_EFI_VARIABLE_DRIVER_CONFIG (EV_EFI_EVENT_BASE + 1)
+#define EV_EFI_VARIABLE_BOOT (EV_EFI_EVENT_BASE + 2)
+#define EV_EFI_BOOT_SERVICES_APPLICATION (EV_EFI_EVENT_BASE + 3)
+#define EV_EFI_BOOT_SERVICES_DRIVER (EV_EFI_EVENT_BASE + 4)
+#define EV_EFI_RUNTIME_SERVICES_DRIVER (EV_EFI_EVENT_BASE + 5)
+#define EV_EFI_GPT_EVENT (EV_EFI_EVENT_BASE + 6)
+#define EV_EFI_ACTION (EV_EFI_EVENT_BASE + 7)
+#define EV_EFI_PLATFORM_FIRMWARE_BLOB (EV_EFI_EVENT_BASE + 8)
+#define EV_EFI_HANDOFF_TABLES (EV_EFI_EVENT_BASE + 9)
+
+//
+// Set structure alignment to 1-byte
+//
+#pragma pack (push, 1)
+
+typedef UINT32 TCG_EVENTTYPE;
+
+#define TCG_DIGEST TPM_DIGEST
+#define TCG_PCRINDEX TPM_PCRINDEX
+
+//
+// TCG_PCR_EVENT
+//
+typedef struct _TCG_PCR_EVENT {
+ TCG_PCRINDEX PCRIndex; // PCRIndex event extended to
+ TCG_EVENTTYPE EventType; // TCG EFI event type
+ TCG_DIGEST Digest; // Value extended into PCRIndex
+ UINT32 EventSize; // Size of the event data
+ UINT8 Event[1]; // The event data
+} TCG_PCR_EVENT;
+
+//
+// TCG_PCR_EVENT_HDR
+//
+typedef struct _TCG_PCR_EVENT_HDR {
+ TCG_PCRINDEX PCRIndex;
+ TCG_EVENTTYPE EventType;
+ TCG_DIGEST Digest;
+ UINT32 EventSize;
+} TCG_PCR_EVENT_HDR;
+
+//
+// EFI_PLATFORM_FIRMWARE_BLOB
+//
+// BlobLength should be of type UINTN but we use UINT64 here
+// because PEI is 32-bit while DXE is 64-bit on x64 platforms
+//
+typedef struct _EFI_PLATFORM_FIRMWARE_BLOB {
+ EFI_PHYSICAL_ADDRESS BlobBase;
+ UINT64 BlobLength;
+} EFI_PLATFORM_FIRMWARE_BLOB;
+
+//
+// EFI_IMAGE_LOAD_EVENT
+//
+// This structure is used in EV_EFI_BOOT_SERVICES_APPLICATION,
+// EV_EFI_BOOT_SERVICES_DRIVER and EV_EFI_RUNTIME_SERVICES_DRIVER
+//
+typedef struct _EFI_IMAGE_LOAD_EVENT {
+ EFI_PHYSICAL_ADDRESS ImageLocationInMemory;
+ UINTN ImageLengthInMemory;
+ UINTN ImageLinkTimeAddress;
+ UINTN LengthOfDevicePath;
+ EFI_DEVICE_PATH_PROTOCOL DevicePath[1];
+} EFI_IMAGE_LOAD_EVENT;
+
+//
+// EFI_HANDOFF_TABLE_POINTERS
+//
+// This structure is used in EV_EFI_HANDOFF_TABLES event to facilitate
+// the measurement of given configuration tables.
+//
+typedef struct _EFI_HANDOFF_TABLE_POINTERS {
+ UINTN NumberOfTables;
+ EFI_CONFIGURATION_TABLE TableEntry[1];
+} EFI_HANDOFF_TABLE_POINTERS;
+
+//
+// EFI_VARIABLE_DATA
+//
+// This structure serves as the header for measuring variables. The name of the
+// variable (in Unicode format) should immediately follow, then the variable
+// data.
+//
+typedef struct _EFI_VARIABLE_DATA {
+ EFI_GUID VariableName;
+ UINTN UnicodeNameLength;
+ UINTN VariableDataLength;
+ CHAR16 UnicodeName[1];
+ INT8 VariableData[1]; // Driver or platform-specific data
+} EFI_VARIABLE_DATA;
+
+//
+// Restore original structure alignment
+//
+#pragma pack (pop)
+
+#endif // _EFI_TPM_H_
diff --git a/EDK/Foundation/Include/EfiVariable.h b/EDK/Foundation/Include/EfiVariable.h
new file mode 100644
index 0000000..72d3690
--- /dev/null
+++ b/EDK/Foundation/Include/EfiVariable.h
@@ -0,0 +1,78 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiVariable.h
+
+Abstract:
+
+ Header file for EFI Variable Services
+
+--*/
+
+#ifndef _EFI_VARIABLE_H_
+#define _EFI_VARIABLE_H_
+
+#define VARIABLE_STORE_SIGNATURE EFI_SIGNATURE_32 ('$', 'V', 'S', 'S')
+
+#define MAX_VARIABLE_SIZE 1024
+
+#define VARIABLE_DATA 0x55AA
+
+//
+// Variable Store Header flags
+//
+#define VARIABLE_STORE_FORMATTED 0x5a
+#define VARIABLE_STORE_HEALTHY 0xfe
+
+//
+// Variable Store Status
+//
+typedef enum {
+ EfiRaw,
+ EfiValid,
+ EfiInvalid,
+ EfiUnknown
+} VARIABLE_STORE_STATUS;
+
+//
+// Variable State flags
+//
+#define VAR_IN_DELETED_TRANSITION 0xfe // Variable is in obsolete transistion
+#define VAR_DELETED 0xfd // Variable is obsolete
+#define VAR_ADDED 0x7f // Variable has been completely added
+#define IS_VARIABLE_STATE(_c, _Mask) (BOOLEAN) (((~_c) & (~_Mask)) != 0)
+
+#pragma pack(1)
+
+typedef struct {
+ UINT32 Signature;
+ UINT32 Size;
+ UINT8 Format;
+ UINT8 State;
+ UINT16 Reserved;
+ UINT32 Reserved1;
+} VARIABLE_STORE_HEADER;
+
+typedef struct {
+ UINT16 StartId;
+ UINT8 State;
+ UINT8 Reserved;
+ UINT32 Attributes;
+ UINT32 NameSize;
+ UINT32 DataSize;
+ EFI_GUID VendorGuid;
+} VARIABLE_HEADER;
+
+#pragma pack()
+
+#endif // _EFI_VARIABLE_H_
diff --git a/EDK/Foundation/Include/EfiWorkingBlockHeader.h b/EDK/Foundation/Include/EfiWorkingBlockHeader.h
new file mode 100644
index 0000000..073252d
--- /dev/null
+++ b/EDK/Foundation/Include/EfiWorkingBlockHeader.h
@@ -0,0 +1,47 @@
+/*++
+
+Copyright (c) 2004 - 2005, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiWorkingBlockHeader.h
+
+Abstract:
+
+ Defines data structure that is the headers found at the runtime
+ updatable firmware volumes, such as the FileSystemGuid of the
+ working block, the header structure of the variable block, FTW
+ working block, or event log block.
+
+--*/
+
+#ifndef _EFI_WORKING_BLOCK_HEADER_H_
+#define _EFI_WORKING_BLOCK_HEADER_H_
+
+//
+// EFI Fault tolerant working block header
+// The header is immediately followed by the write queue.
+//
+typedef struct {
+ EFI_GUID Signature;
+ UINT32 Crc;
+ UINT8 WorkingBlockValid : 1;
+ UINT8 WorkingBlockInvalid : 1;
+#define WORKING_BLOCK_VALID 0x1
+#define WORKING_BLOCK_INVALID 0x2
+ UINT8 Reserved : 6;
+ UINT8 Reserved3[3];
+ UINTN WriteQueueSize;
+ //
+ // UINT8 WriteQueue[WriteQueueSize];
+ //
+} EFI_FAULT_TOLERANT_WORKING_BLOCK_HEADER;
+
+#endif
diff --git a/EDK/Foundation/Include/FastBootDataDef.h b/EDK/Foundation/Include/FastBootDataDef.h
new file mode 100644
index 0000000..d5bb7b1
--- /dev/null
+++ b/EDK/Foundation/Include/FastBootDataDef.h
@@ -0,0 +1,56 @@
+/*++
+
+Copyright (c) 1999 - 2011 Intel Corporation. All rights reserved
+This software and associated documentation (if any) is furnished
+under a license and may only be used or copied in accordance
+with the terms of the license. Except as permitted by such
+license, no part of this software or documentation may be
+reproduced, stored in a retrieval system, or transmitted in any
+form or by any means without the express written consent of
+Intel Corporation.
+
+Module Name:
+
+Module Name:
+
+ FastBootDataDef.h
+
+Abstract:
+
+ This file defines Fast Boot exception types and categories defined by
+ the Intel Fast Boot Specification.
+
+--*/
+
+#ifndef _FAST_BOOT_DATA_DEF_H_
+#define _FAST_BOOT_DATA_DEF_H_
+
+typedef enum {
+ NoException = 0,
+ ExceptionType1,
+ ExceptionType2,
+ ExceptionType3A,
+ ExceptionType3B,
+ ExceptionTypeMax
+} FAST_BOOT_EXCEPTION_TYPE;
+
+typedef enum {
+ NoExceptionCategory = 0,
+ FastBootDisabled,
+ FastBootOverridden,
+ FastBootBreakByUser,
+ FirstBoot,
+ BootFailure,
+ HardwareChanged,
+ SetupConfigurationChanged,
+ ConsoleDeviceChanged,
+ BootDeviceChanged,
+ ContentLost,
+ PowerFailure,
+ HardwareError,
+ SpecialBoot,
+ AnyOfOtherCategories,
+ ExceptionCategoryMax
+} FAST_BOOT_EXCEPTION_CATEGORY;
+
+#endif
diff --git a/EDK/Foundation/Include/Ia32/EfiBind.h b/EDK/Foundation/Include/Ia32/EfiBind.h
new file mode 100644
index 0000000..e27dc1a
--- /dev/null
+++ b/EDK/Foundation/Include/Ia32/EfiBind.h
@@ -0,0 +1,266 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiBind.h
+
+Abstract:
+
+ Processor or Compiler specific defines and types for IA-32.
+ We are using the ANSI C 2000 _t type definitions for basic types.
+ This it technically a violation of the coding standard, but they
+ are used to make EfiTypes.h portable. Code other than EfiTypes.h
+ should never use any ANSI C 2000 _t integer types.
+
+--*/
+
+#ifndef _EFI_BIND_H_
+#define _EFI_BIND_H_
+
+#ifdef EFI_DEBUG
+
+#ifdef EFI_NT_EMULATOR
+
+#define EFI_DRIVER_ENTRY_POINT(InitFunction) \
+ EFI_STATUS \
+ EFIAPI \
+ InitFunction ( \
+ EFI_HANDLE ImageHandle, \
+ EFI_SYSTEM_TABLE *SystemTable \
+ ); \
+ \
+ UINTN \
+ __stdcall \
+ _DllMainCRTStartup ( \
+ UINTN Inst, \
+ UINTN reason_for_call, \
+ VOID *rserved \
+ ) \
+ { \
+ return 1; \
+ } \
+ \
+ EFI_STATUS \
+ __declspec( dllexport ) \
+ __cdecl \
+ InitializeDriver ( \
+ VOID *ImageHandle, \
+ VOID *SystemTable \
+ ) \
+ { \
+ return InitFunction(ImageHandle, SystemTable); \
+ }
+
+#define EFI_APPLICATION_ENTRY_POINT EFI_DRIVER_ENTRY_POINT
+
+#else
+
+#define EFI_DRIVER_ENTRY_POINT(InitFunction)
+#define EFI_APPLICATION_ENTRY_POINT EFI_DRIVER_ENTRY_POINT
+
+#endif
+
+#else
+
+#define EFI_DRIVER_ENTRY_POINT(InitFunction)
+#define EFI_APPLICATION_ENTRY_POINT EFI_DRIVER_ENTRY_POINT
+
+#endif
+
+
+
+
+
+//
+// Make sure we are useing the correct packing rules per EFI specification
+//
+#pragma pack()
+
+#if _MSC_EXTENSIONS
+
+//
+// Disable warning that make it impossible to compile at /W4
+// This only works for Microsoft* tools
+//
+
+//
+// Disabling bitfield type checking warnings.
+//
+#pragma warning ( disable : 4214 )
+
+//
+// Disabling the unreferenced formal parameter warnings.
+//
+#pragma warning ( disable : 4100 )
+
+//
+// Disable slightly different base types warning as CHAR8 * can not be set
+// to a constant string.
+//
+#pragma warning ( disable : 4057 )
+
+//
+// ASSERT(FALSE) or while (TRUE) are legal constructes so supress this warning
+//
+#pragma warning ( disable : 4127 )
+
+//
+// Int64ShllMod32 unreferenced inline function
+//
+#pragma warning ( disable : 4514 )
+
+//
+// Unreferenced formal parameter - We are object oriented, so we pass This even
+// if we don't need them.
+//
+#pragma warning ( disable : 4100 )
+
+
+//#pragma warning ( disable : 4133 )
+
+#endif
+
+
+#if (__STDC_VERSION__ < 199901L)
+ //
+ // No ANSI C 2000 stdint.h integer width declarations, so define equivalents
+ //
+
+ #if _MSC_EXTENSIONS
+
+ //
+ // use Microsoft* C complier dependent interger width types
+ //
+ typedef unsigned __int64 uint64_t;
+ typedef __int64 int64_t;
+ typedef unsigned __int32 uint32_t;
+ typedef __int32 int32_t;
+ typedef unsigned short uint16_t;
+ typedef short int16_t;
+ typedef unsigned char uint8_t;
+ typedef char int8_t;
+ #else
+
+ //
+ // Assume standard IA-32 alignment.
+ // BugBug: Need to check portability of long long
+ //
+ typedef unsigned long long uint64_t;
+ typedef long long int64_t;
+ typedef unsigned int uint32_t;
+ typedef int int32_t;
+ typedef unsigned short uint16_t;
+ typedef short int16_t;
+ typedef unsigned char uint8_t;
+ typedef char int8_t;
+ #endif
+#else
+ //
+ // Use ANSI C 2000 stdint.h integer width declarations
+ //
+ #include "stdint.h"
+#endif
+
+//
+// Native integer size in stdint.h
+//
+typedef uint32_t uintn_t;
+typedef int32_t intn_t;
+
+//
+// Processor specific defines
+//
+#define EFI_MAX_BIT 0x80000000
+#define MAX_2_BITS 0xC0000000
+
+//
+// Maximum legal IA-32 address
+//
+#define EFI_MAX_ADDRESS 0xFFFFFFFF
+
+//
+// Bad pointer value to use in check builds.
+// if you see this value you are using uninitialized or free'ed data
+//
+#define EFI_BAD_POINTER 0xAFAFAFAF
+#define EFI_BAD_POINTER_AS_BYTE 0xAF
+
+//
+// Inject a break point in the code to assist debugging for NT Emulation Environment
+// For real hardware, just put in a halt loop. Don't do a while(1) because the
+// compiler will optimize away the rest of the function following, so that you run out in
+// the weeds if you skip over it with a debugger.
+//
+#define EFI_BREAKPOINT() __asm { int 3 }
+#define EFI_DEADLOOP() { volatile UINTN __iii; __iii = 1; while (__iii); }
+
+//
+// Memory Fence forces serialization, and is needed to support out of order
+// memory transactions. The Memory Fence is mainly used to make sure IO
+// transactions complete in a deterministic sequence, and to syncronize locks
+// an other MP code. Currently no memory fencing is required.
+//
+#define MEMORY_FENCE()
+
+//
+// Some compilers don't support the forward reference construct:
+// typedef struct XXXXX. The forward reference is required for
+// ANSI compatibility.
+//
+// The following macro provide a workaround for such cases.
+//
+
+
+#ifdef EFI_NO_INTERFACE_DECL
+ #define EFI_FORWARD_DECLARATION(x)
+#else
+ #define EFI_FORWARD_DECLARATION(x) typedef struct _##x x
+#endif
+
+
+//
+// Some C compilers optimize the calling conventions to increase performance.
+// _EFIAPI is used to make all public APIs follow the standard C calling
+// convention.
+//
+#if _MSC_EXTENSIONS
+ //
+ // Microsoft* compiler requires _EFIAPI useage, __cdecl is Microsoft* specific C.
+ //
+
+ #define _EFIAPI __cdecl
+#else
+ #define _EFIAPI
+#endif
+
+
+#ifdef _EFI_WINNT
+
+ #define EFI_SUPPRESS_BENIGN_REDEFINITION_OF_TYPE_WARNING() \
+ warning ( disable : 4142 )
+
+ #define EFI_DEFAULT_BENIGN_REDEFINITION_OF_TYPE_WARNING() \
+ warning ( default : 4142 )
+#else
+
+ #define EFI_SUPPRESS_BENIGN_REDEFINITION_OF_TYPE_WARNING() \
+ warning ( disable : 4068 )
+
+ #define EFI_DEFAULT_BENIGN_REDEFINITION_OF_TYPE_WARNING() \
+ warning ( default : 4068 )
+
+#endif
+
+
+
+#endif
+
diff --git a/EDK/Foundation/Include/Ia32/EfiPeOptionalHeader.h b/EDK/Foundation/Include/Ia32/EfiPeOptionalHeader.h
new file mode 100644
index 0000000..30ee831
--- /dev/null
+++ b/EDK/Foundation/Include/Ia32/EfiPeOptionalHeader.h
@@ -0,0 +1,38 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiPeOptionalHeader.h
+
+Abstract:
+ Defines the optional header in the PE image per the PE specification. This
+ file must be included only from within EfiImage.h since
+ EFI_IMAGE_DATA_DIRECTORY and EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES are defined
+ there.
+
+--*/
+
+#ifndef _EFI_PE_OPTIONAL_HEADER_H_
+#define _EFI_PE_OPTIONAL_HEADER_H_
+
+#define EFI_IMAGE_MACHINE_TYPE (EFI_IMAGE_MACHINE_IA32)
+
+#define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) \
+ (((Machine) == EFI_IMAGE_MACHINE_IA32) || ((Machine) == EFI_IMAGE_MACHINE_EBC))
+
+#define EFI_IMAGE_MACHINE_CROSS_TYPE_SUPPORTED(Machine) ((Machine) == EFI_IMAGE_MACHINE_X64)
+
+#define EFI_IMAGE_NT_OPTIONAL_HDR_MAGIC EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC
+typedef EFI_IMAGE_OPTIONAL_HEADER32 EFI_IMAGE_OPTIONAL_HEADER;
+typedef EFI_IMAGE_NT_HEADERS32 EFI_IMAGE_NT_HEADERS;
+
+#endif
diff --git a/EDK/Foundation/Include/Ia32/TianoBind.h b/EDK/Foundation/Include/Ia32/TianoBind.h
new file mode 100644
index 0000000..ffb7a4a
--- /dev/null
+++ b/EDK/Foundation/Include/Ia32/TianoBind.h
@@ -0,0 +1,102 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ TianoBind.h
+
+Abstract:
+
+ Tiano's Processor or Compiler specific defines and types for IA-32
+ besides EfiBind.h.
+
+--*/
+
+#ifndef _TIANO_BIND_H_
+#define _TIANO_BIND_H_
+
+#include "EfiBind.h"
+
+#ifdef EFI_DEBUG
+
+#ifdef EFI_NT_EMULATOR
+
+#define EFI_DXE_ENTRY_POINT(InitFunction) \
+ VOID \
+ EFIAPI \
+ InitFunction ( \
+ IN VOID *HobStart \
+ ); \
+ \
+ UINTN \
+ __stdcall \
+ _DllMainCRTStartup ( \
+ UINTN Inst, \
+ UINTN reason_for_call, \
+ VOID *rserved \
+ ) \
+ { \
+ return 1; \
+ } \
+ \
+ VOID \
+ __declspec( dllexport ) \
+ __cdecl \
+ InitializeDriver ( \
+ VOID *Hob \
+ ) \
+ { \
+ InitFunction(Hob); \
+ }
+
+
+
+
+#define EFI_SMI_HANDLER_ENTRY_POINT(InitFunction) \
+ UINTN \
+ __stdcall \
+ _DllMainCRTStartup ( \
+ UINTN Inst, \
+ UINTN reason_for_call, \
+ VOID *rserved \
+ ) \
+ { \
+ return 1; \
+ } \
+ \
+ EFI_STATUS \
+ __declspec( dllexport ) \
+ __cdecl \
+ InitializeDriver ( \
+ VOID *ImageHandle, \
+ VOID *Smst, \
+ VOID *CommunicationBuffer, \
+ UINTN *SourceSize \
+ ) \
+ { \
+ return InitFunction(ImageHandle, Smst, CommunicationBuffer, SourceSize); \
+ }
+
+#else
+
+#define EFI_DXE_ENTRY_POINT(InitFunction)
+#define EFI_SMI_HANDLER_ENTRY_POINT(InitFunction)
+
+#endif
+
+#else
+
+#define EFI_DXE_ENTRY_POINT(InitFunction)
+#define EFI_SMI_HANDLER_ENTRY_POINT(InitFunction)
+
+#endif
+
+#endif
diff --git a/EDK/Foundation/Include/IndustryStandard/Acpi.h b/EDK/Foundation/Include/IndustryStandard/Acpi.h
new file mode 100644
index 0000000..ad48ae1
--- /dev/null
+++ b/EDK/Foundation/Include/IndustryStandard/Acpi.h
@@ -0,0 +1,31 @@
+/*++
+
+Copyright (c) 2004 - 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Acpi.h
+
+Abstract:
+
+ This file contains some basic ACPI definitions that are consumed by drivers
+ that do not care about ACPI versions.
+
+--*/
+
+#ifndef _ACPI_H_
+#define _ACPI_H_
+
+#include "AcpiCommon.h"
+#include "Acpi1_0.h"
+#include "Acpi2_0.h"
+#include "Acpi3_0.h"
+
+#endif
diff --git a/EDK/Foundation/Include/IndustryStandard/Acpi1_0.h b/EDK/Foundation/Include/IndustryStandard/Acpi1_0.h
new file mode 100644
index 0000000..b051222
--- /dev/null
+++ b/EDK/Foundation/Include/IndustryStandard/Acpi1_0.h
@@ -0,0 +1,299 @@
+/*++
+
+Copyright (c) 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Acpi1_0.h
+
+Abstract:
+
+ ACPI 1.0b definitions from the ACPI Specification, revision 1.0b
+
+--*/
+
+#ifndef _ACPI_1_0_H_
+#define _ACPI_1_0_H_
+
+//
+// Statements that include other files
+//
+#include "AcpiCommon.h"
+
+//
+// Ensure proper structure formats
+//
+#pragma pack(1)
+//
+// ACPI 1.0b table structures
+//
+//
+// Root System Description Pointer Structure
+//
+typedef struct {
+ UINT64 Signature;
+ UINT8 Checksum;
+ UINT8 OemId[6];
+ UINT8 Reserved;
+ UINT32 RsdtAddress;
+} EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_POINTER;
+
+//
+// Root System Description Table
+// No definition needed as it is a common description table header followed by a
+// variable number of UINT32 table pointers.
+//
+//
+// RSDT Revision (as defined in ACPI 1.0b spec.)
+//
+#define EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_TABLE_REVISION 0x01
+
+//
+// Fixed ACPI Description Table Structure (FADT)
+//
+typedef struct {
+ EFI_ACPI_DESCRIPTION_HEADER Header;
+ UINT32 FirmwareCtrl;
+ UINT32 Dsdt;
+ UINT8 IntModel;
+ UINT8 Reserved1;
+ UINT16 SciInt;
+ UINT32 SmiCmd;
+ UINT8 AcpiEnable;
+ UINT8 AcpiDisable;
+ UINT8 S4BiosReq;
+ UINT8 Reserved2;
+ UINT32 Pm1aEvtBlk;
+ UINT32 Pm1bEvtBlk;
+ UINT32 Pm1aCntBlk;
+ UINT32 Pm1bCntBlk;
+ UINT32 Pm2CntBlk;
+ UINT32 PmTmrBlk;
+ UINT32 Gpe0Blk;
+ UINT32 Gpe1Blk;
+ UINT8 Pm1EvtLen;
+ UINT8 Pm1CntLen;
+ UINT8 Pm2CntLen;
+ UINT8 PmTmLen;
+ UINT8 Gpe0BlkLen;
+ UINT8 Gpe1BlkLen;
+ UINT8 Gpe1Base;
+ UINT8 Reserved3;
+ UINT16 PLvl2Lat;
+ UINT16 PLvl3Lat;
+ UINT16 FlushSize;
+ UINT16 FlushStride;
+ UINT8 DutyOffset;
+ UINT8 DutyWidth;
+ UINT8 DayAlrm;
+ UINT8 MonAlrm;
+ UINT8 Century;
+ UINT8 Reserved4;
+ UINT8 Reserved5;
+ UINT8 Reserved6;
+ UINT32 Flags;
+} EFI_ACPI_1_0_FIXED_ACPI_DESCRIPTION_TABLE;
+
+//
+// FADT Version (as defined in ACPI 1.0b spec.)
+//
+#define EFI_ACPI_1_0_FIXED_ACPI_DESCRIPTION_TABLE_REVISION 0x01
+
+//
+// Fixed ACPI Description Table Fixed Feature Flags
+// All other bits are reserved and must be set to 0.
+//
+#define EFI_ACPI_1_0_WBINVD (1 << 0)
+#define EFI_ACPI_1_0_WBINVD_FLUSH (1 << 1)
+#define EFI_ACPI_1_0_PROC_C1 (1 << 2)
+#define EFI_ACPI_1_0_P_LVL2_UP (1 << 3)
+#define EFI_ACPI_1_0_PWR_BUTTON (1 << 4)
+#define EFI_ACPI_1_0_SLP_BUTTON (1 << 5)
+#define EFI_ACPI_1_0_FIX_RTC (1 << 6)
+#define EFI_ACPI_1_0_RTC_S4 (1 << 7)
+#define EFI_ACPI_1_0_TMR_VAL_EXT (1 << 8)
+#define EFI_ACPI_1_0_DCK_CAP (1 << 9)
+
+//
+// Firmware ACPI Control Structure
+//
+typedef struct {
+ UINT32 Signature;
+ UINT32 Length;
+ UINT32 HardwareSignature;
+ UINT32 FirmwareWakingVector;
+ UINT32 GlobalLock;
+ UINT32 Flags;
+ UINT8 Reserved[40];
+} EFI_ACPI_1_0_FIRMWARE_ACPI_CONTROL_STRUCTURE;
+
+//
+// Firmware Control Structure Feature Flags
+// All other bits are reserved and must be set to 0.
+//
+#define EFI_ACPI_1_0_S4BIOS_F (1 << 0)
+
+//
+// Multiple APIC Description Table header definition. The rest of the table
+// must be defined in a platform specific manner.
+//
+typedef struct {
+ EFI_ACPI_DESCRIPTION_HEADER Header;
+ UINT32 LocalApicAddress;
+ UINT32 Flags;
+} EFI_ACPI_1_0_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER;
+
+//
+// MADT Revision (as defined in ACPI 1.0b spec.)
+//
+#define EFI_ACPI_1_0_MULTIPLE_APIC_DESCRIPTION_TABLE_REVISION 0x01
+
+//
+// Multiple APIC Flags
+// All other bits are reserved and must be set to 0.
+//
+#define EFI_ACPI_1_0_PCAT_COMPAT (1 << 0)
+
+//
+// Multiple APIC Description Table APIC structure types
+// All other values between 0x09 an 0xFF are reserved and
+// will be ignored by OSPM.
+//
+#define EFI_ACPI_1_0_PROCESSOR_LOCAL_APIC 0x00
+#define EFI_ACPI_1_0_IO_APIC 0x01
+#define EFI_ACPI_1_0_INTERRUPT_SOURCE_OVERRIDE 0x02
+#define EFI_ACPI_1_0_NON_MASKABLE_INTERRUPT_SOURCE 0x03
+#define EFI_ACPI_1_0_LOCAL_APIC_NMI 0x04
+
+//
+// APIC Structure Definitions
+//
+//
+// Processor Local APIC Structure Definition
+//
+typedef struct {
+ UINT8 Type;
+ UINT8 Length;
+ UINT8 AcpiProcessorId;
+ UINT8 ApicId;
+ UINT32 Flags;
+} EFI_ACPI_1_0_PROCESSOR_LOCAL_APIC_STRUCTURE;
+
+//
+// Local APIC Flags. All other bits are reserved and must be 0.
+//
+#define EFI_ACPI_1_0_LOCAL_APIC_ENABLED (1 << 0)
+
+//
+// IO APIC Structure
+//
+typedef struct {
+ UINT8 Type;
+ UINT8 Length;
+ UINT8 IoApicId;
+ UINT8 Reserved;
+ UINT32 IoApicAddress;
+ UINT32 SystemVectorBase;
+} EFI_ACPI_1_0_IO_APIC_STRUCTURE;
+
+//
+// Interrupt Source Override Structure
+//
+typedef struct {
+ UINT8 Type;
+ UINT8 Length;
+ UINT8 Bus;
+ UINT8 Source;
+ UINT32 GlobalSystemInterruptVector;
+ UINT16 Flags;
+} EFI_ACPI_1_0_INTERRUPT_SOURCE_OVERRIDE_STRUCTURE;
+
+//
+// Non-Maskable Interrupt Source Structure
+//
+typedef struct {
+ UINT8 Type;
+ UINT8 Length;
+ UINT16 Flags;
+ UINT32 GlobalSystemInterruptVector;
+} EFI_ACPI_1_0_NON_MASKABLE_INTERRUPT_SOURCE_STRUCTURE;
+
+//
+// Local APIC NMI Structure
+//
+typedef struct {
+ UINT8 Type;
+ UINT8 Length;
+ UINT8 AcpiProcessorId;
+ UINT16 Flags;
+ UINT8 LocalApicInti;
+} EFI_ACPI_1_0_LOCAL_APIC_NMI_STRUCTURE;
+
+//
+// Smart Battery Description Table (SBST)
+//
+typedef struct {
+ EFI_ACPI_DESCRIPTION_HEADER Header;
+ UINT32 WarningEnergyLevel;
+ UINT32 LowEnergyLevel;
+ UINT32 CriticalEnergyLevel;
+} EFI_ACPI_1_0_SMART_BATTERY_DESCRIPTION_TABLE;
+
+//
+// Known table signatures
+//
+//
+// "RSD PTR " Root System Description Pointer
+//
+#define EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_POINTER_SIGNATURE 0x2052545020445352
+
+//
+// "APIC" Multiple APIC Description Table
+//
+#define EFI_ACPI_1_0_APIC_SIGNATURE 0x43495041
+
+//
+// "DSDT" Differentiated System Description Table
+//
+#define EFI_ACPI_1_0_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE 0x54445344
+
+//
+// "FACS" Firmware ACPI Control Structure
+//
+#define EFI_ACPI_1_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_SIGNATURE 0x53434146
+
+//
+// "FACP" Fixed ACPI Description Table
+//
+#define EFI_ACPI_1_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE 0x50434146
+
+//
+// "PSDT" Persistent System Description Table
+//
+#define EFI_ACPI_1_0_PERSISTENT_SYSTEM_DESCRIPTION_TABLE_SIGNATURE 0x54445350
+
+//
+// "RSDT" Root System Description Table
+//
+#define EFI_ACPI_1_0_ROOT_SYSTEM_DESCRIPTION_TABLE_SIGNATURE 0x54445352
+
+//
+// "SBST" Smart Battery Specification Table
+//
+#define EFI_ACPI_1_0_SMART_BATTERY_SPECIFICATION_TABLE_SIGNATURE 0x54534253
+
+//
+// "SSDT" Secondary System Description Table
+//
+#define EFI_ACPI_1_0_SECONDARY_SYSTEM_DESCRIPTION_TABLE_SIGNATURE 0x54445353
+
+#pragma pack()
+
+#endif
diff --git a/EDK/Foundation/Include/IndustryStandard/Acpi2_0.h b/EDK/Foundation/Include/IndustryStandard/Acpi2_0.h
new file mode 100644
index 0000000..9597461
--- /dev/null
+++ b/EDK/Foundation/Include/IndustryStandard/Acpi2_0.h
@@ -0,0 +1,513 @@
+/*++
+
+Copyright (c) 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Acpi2_0.h
+
+Abstract:
+
+ ACPI 2.0 definitions from the ACPI Specification, revision 2.0
+
+--*/
+
+#ifndef _ACPI_2_0_H_
+#define _ACPI_2_0_H_
+
+//
+// Statements that include other files
+//
+#include "AcpiCommon.h"
+
+//
+// Ensure proper structure formats
+//
+#pragma pack(1)
+//
+// ACPI Specification Revision
+//
+#define EFI_ACPI_2_0_REVISION 0x02
+
+//
+// ACPI 2.0 Generic Address Space definition
+//
+typedef struct {
+ UINT8 AddressSpaceId;
+ UINT8 RegisterBitWidth;
+ UINT8 RegisterBitOffset;
+ UINT8 Reserved;
+ UINT64 Address;
+} EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE;
+
+//
+// Generic Address Space Address IDs
+//
+#define EFI_ACPI_2_0_SYSTEM_MEMORY 0
+#define EFI_ACPI_2_0_SYSTEM_IO 1
+#define EFI_ACPI_2_0_PCI_CONFIGURATION_SPACE 2
+#define EFI_ACPI_2_0_EMBEDDED_CONTROLLER 3
+#define EFI_ACPI_2_0_SMBUS 4
+#define EFI_ACPI_2_0_FUNCTIONAL_FIXED_HARDWARE 0x7F
+
+//
+// ACPI 2.0 table structures
+//
+//
+// Root System Description Pointer Structure
+//
+typedef struct {
+ UINT64 Signature;
+ UINT8 Checksum;
+ UINT8 OemId[6];
+ UINT8 Revision;
+ UINT32 RsdtAddress;
+ UINT32 Length;
+ UINT64 XsdtAddress;
+ UINT8 ExtendedChecksum;
+ UINT8 Reserved[3];
+} EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER;
+
+//
+// RSD_PTR Revision (as defined in ACPI 2.0 spec.)
+//
+#define EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER_REVISION 0x02
+
+//
+// Common table header, this prefaces all ACPI tables, including FACS, but
+// excluding the RSD PTR structure
+//
+typedef struct {
+ UINT32 Signature;
+ UINT32 Length;
+} EFI_ACPI_2_0_COMMON_HEADER;
+
+//
+// Root System Description Table
+// No definition needed as it is a common description table header followed by a
+// variable number of UINT32 table pointers.
+//
+//
+// RSDT Revision (as defined in ACPI 2.0 spec.)
+//
+#define EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_TABLE_REVISION 0x01
+
+//
+// Extended System Description Table
+// No definition needed as it is a common description table header followed by a
+// variable number of UINT64 table pointers.
+//
+//
+// XSDT Revision (as defined in ACPI 2.0 spec.)
+//
+#define EFI_ACPI_2_0_EXTENDED_SYSTEM_DESCRIPTION_TABLE_REVISION 0x01
+
+//
+// Fixed ACPI Description Table Structure (FADT)
+//
+typedef struct {
+ EFI_ACPI_DESCRIPTION_HEADER Header;
+ UINT32 FirmwareCtrl;
+ UINT32 Dsdt;
+ UINT8 Reserved0;
+ UINT8 PreferredPmProfile;
+ UINT16 SciInt;
+ UINT32 SmiCmd;
+ UINT8 AcpiEnable;
+ UINT8 AcpiDisable;
+ UINT8 S4BiosReq;
+ UINT8 PstateCnt;
+ UINT32 Pm1aEvtBlk;
+ UINT32 Pm1bEvtBlk;
+ UINT32 Pm1aCntBlk;
+ UINT32 Pm1bCntBlk;
+ UINT32 Pm2CntBlk;
+ UINT32 PmTmrBlk;
+ UINT32 Gpe0Blk;
+ UINT32 Gpe1Blk;
+ UINT8 Pm1EvtLen;
+ UINT8 Pm1CntLen;
+ UINT8 Pm2CntLen;
+ UINT8 PmTmrLen;
+ UINT8 Gpe0BlkLen;
+ UINT8 Gpe1BlkLen;
+ UINT8 Gpe1Base;
+ UINT8 CstCnt;
+ UINT16 PLvl2Lat;
+ UINT16 PLvl3Lat;
+ UINT16 FlushSize;
+ UINT16 FlushStride;
+ UINT8 DutyOffset;
+ UINT8 DutyWidth;
+ UINT8 DayAlrm;
+ UINT8 MonAlrm;
+ UINT8 Century;
+ UINT16 IaPcBootArch;
+ UINT8 Reserved1;
+ UINT32 Flags;
+ EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE ResetReg;
+ UINT8 ResetValue;
+ UINT8 Reserved2[3];
+ UINT64 XFirmwareCtrl;
+ UINT64 XDsdt;
+ EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE XPm1aEvtBlk;
+ EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE XPm1bEvtBlk;
+ EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE XPm1aCntBlk;
+ EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE XPm1bCntBlk;
+ EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE XPm2CntBlk;
+ EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE XPmTmrBlk;
+ EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE XGpe0Blk;
+ EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE XGpe1Blk;
+} EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE;
+
+//
+// FADT Version (as defined in ACPI 2.0 spec.)
+//
+#define EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE_REVISION 0x03
+
+//
+// Fixed ACPI Description Table Boot Architecture Flags
+// All other bits are reserved and must be set to 0.
+//
+#define EFI_ACPI_2_0_LEGACY_DEVICES (1 << 0)
+#define EFI_ACPI_2_0_8042 (1 << 1)
+
+//
+// Fixed ACPI Description Table Fixed Feature Flags
+// All other bits are reserved and must be set to 0.
+//
+#define EFI_ACPI_2_0_WBINVD (1 << 0)
+#define EFI_ACPI_2_0_WBINVD_FLUSH (1 << 1)
+#define EFI_ACPI_2_0_PROC_C1 (1 << 2)
+#define EFI_ACPI_2_0_P_LVL2_UP (1 << 3)
+#define EFI_ACPI_2_0_PWR_BUTTON (1 << 4)
+#define EFI_ACPI_2_0_SLP_BUTTON (1 << 5)
+#define EFI_ACPI_2_0_FIX_RTC (1 << 6)
+#define EFI_ACPI_2_0_RTC_S4 (1 << 7)
+#define EFI_ACPI_2_0_TMR_VAL_EXT (1 << 8)
+#define EFI_ACPI_2_0_DCK_CAP (1 << 9)
+#define EFI_ACPI_2_0_RESET_REG_SUP (1 << 10)
+#define EFI_ACPI_2_0_SEALED_CASE (1 << 11)
+#define EFI_ACPI_2_0_HEADLESS (1 << 12)
+#define EFI_ACPI_2_0_CPU_SW_SLP (1 << 13)
+
+//
+// Firmware ACPI Control Structure
+//
+typedef struct {
+ UINT32 Signature;
+ UINT32 Length;
+ UINT32 HardwareSignature;
+ UINT32 FirmwareWakingVector;
+ UINT32 GlobalLock;
+ UINT32 Flags;
+ UINT64 XFirmwareWakingVector;
+ UINT8 Version;
+ UINT8 Reserved[31];
+} EFI_ACPI_2_0_FIRMWARE_ACPI_CONTROL_STRUCTURE;
+
+//
+// FACS Version (as defined in ACPI 2.0 spec.)
+//
+#define EFI_ACPI_2_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_VERSION 0x01
+
+//
+// Firmware Control Structure Feature Flags
+// All other bits are reserved and must be set to 0.
+//
+#define EFI_ACPI_2_0_S4BIOS_F (1 << 0)
+
+//
+// Multiple APIC Description Table header definition. The rest of the table
+// must be defined in a platform specific manner.
+//
+typedef struct {
+ EFI_ACPI_DESCRIPTION_HEADER Header;
+ UINT32 LocalApicAddress;
+ UINT32 Flags;
+} EFI_ACPI_2_0_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER;
+
+//
+// MADT Revision (as defined in ACPI 2.0 spec.)
+//
+#define EFI_ACPI_2_0_MULTIPLE_APIC_DESCRIPTION_TABLE_REVISION 0x01
+
+//
+// Multiple APIC Flags
+// All other bits are reserved and must be set to 0.
+//
+#define EFI_ACPI_2_0_PCAT_COMPAT (1 << 0)
+
+//
+// Multiple APIC Description Table APIC structure types
+// All other values between 0x09 an 0xFF are reserved and
+// will be ignored by OSPM.
+//
+#define EFI_ACPI_2_0_PROCESSOR_LOCAL_APIC 0x00
+#define EFI_ACPI_2_0_IO_APIC 0x01
+#define EFI_ACPI_2_0_INTERRUPT_SOURCE_OVERRIDE 0x02
+#define EFI_ACPI_2_0_NON_MASKABLE_INTERRUPT_SOURCE 0x03
+#define EFI_ACPI_2_0_LOCAL_APIC_NMI 0x04
+#define EFI_ACPI_2_0_LOCAL_APIC_ADDRESS_OVERRIDE 0x05
+#define EFI_ACPI_2_0_IO_SAPIC 0x06
+#define EFI_ACPI_2_0_PROCESSOR_LOCAL_SAPIC 0x07
+#define EFI_ACPI_2_0_PLATFORM_INTERRUPT_SOURCES 0x08
+
+//
+// APIC Structure Definitions
+//
+//
+// Processor Local APIC Structure Definition
+//
+typedef struct {
+ UINT8 Type;
+ UINT8 Length;
+ UINT8 AcpiProcessorId;
+ UINT8 ApicId;
+ UINT32 Flags;
+} EFI_ACPI_2_0_PROCESSOR_LOCAL_APIC_STRUCTURE;
+
+//
+// Local APIC Flags. All other bits are reserved and must be 0.
+//
+#define EFI_ACPI_2_0_LOCAL_APIC_ENABLED (1 << 0)
+
+//
+// IO APIC Structure
+//
+typedef struct {
+ UINT8 Type;
+ UINT8 Length;
+ UINT8 IoApicId;
+ UINT8 Reserved;
+ UINT32 IoApicAddress;
+ UINT32 GlobalSystemInterruptBase;
+} EFI_ACPI_2_0_IO_APIC_STRUCTURE;
+
+//
+// Interrupt Source Override Structure
+//
+typedef struct {
+ UINT8 Type;
+ UINT8 Length;
+ UINT8 Bus;
+ UINT8 Source;
+ UINT32 GlobalSystemInterrupt;
+ UINT16 Flags;
+} EFI_ACPI_2_0_INTERRUPT_SOURCE_OVERRIDE_STRUCTURE;
+
+//
+// Non-Maskable Interrupt Source Structure
+//
+typedef struct {
+ UINT8 Type;
+ UINT8 Length;
+ UINT16 Flags;
+ UINT32 GlobalSystemInterrupt;
+} EFI_ACPI_2_0_NON_MASKABLE_INTERRUPT_SOURCE_STRUCTURE;
+
+//
+// Local APIC NMI Structure
+//
+typedef struct {
+ UINT8 Type;
+ UINT8 Length;
+ UINT8 AcpiProcessorId;
+ UINT16 Flags;
+ UINT8 LocalApicLint;
+} EFI_ACPI_2_0_LOCAL_APIC_NMI_STRUCTURE;
+
+//
+// Local APIC Address Override Structure
+//
+typedef struct {
+ UINT8 Type;
+ UINT8 Length;
+ UINT16 Reserved;
+ UINT64 LocalApicAddress;
+} EFI_ACPI_2_0_LOCAL_APIC_ADDRESS_OVERRIDE_STRUCTURE;
+
+//
+// IO SAPIC Structure
+//
+typedef struct {
+ UINT8 Type;
+ UINT8 Length;
+ UINT8 IoApicId;
+ UINT8 Reserved;
+ UINT32 GlobalSystemInterruptBase;
+ UINT64 IoSapicAddress;
+} EFI_ACPI_2_0_IO_SAPIC_STRUCTURE;
+
+//
+// Local SAPIC Structure
+//
+typedef struct {
+ UINT8 Type;
+ UINT8 Length;
+ UINT8 AcpiProcessorId;
+ UINT8 LocalSapicId;
+ UINT8 LocalSapicEid;
+ UINT8 Reserved[3];
+ UINT32 Flags;
+} EFI_ACPI_2_0_PROCESSOR_LOCAL_SAPIC_STRUCTURE;
+
+//
+// Platform Interrupt Sources Structure
+//
+typedef struct {
+ UINT8 Type;
+ UINT8 Length;
+ UINT16 Flags;
+ UINT8 InterruptType;
+ UINT8 ProcessorId;
+ UINT8 ProcessorEid;
+ UINT8 IoSapicVector;
+ UINT32 GlobalSystemInterrupt;
+ UINT32 Reserved;
+} EFI_ACPI_2_0_PLATFORM_INTERRUPT_SOURCES_STRUCTURE;
+
+//
+// Smart Battery Description Table (SBST)
+//
+typedef struct {
+ EFI_ACPI_DESCRIPTION_HEADER Header;
+ UINT32 WarningEnergyLevel;
+ UINT32 LowEnergyLevel;
+ UINT32 CriticalEnergyLevel;
+} EFI_ACPI_2_0_SMART_BATTERY_DESCRIPTION_TABLE;
+
+//
+// SBST Version (as defined in ACPI 2.0 spec.)
+//
+#define EFI_ACPI_2_0_SMART_BATTERY_DESCRIPTION_TABLE_REVISION 0x01
+
+//
+// Embedded Controller Boot Resources Table (ECDT)
+// The table is followed by a null terminated ASCII string that contains
+// a fully qualified reference to the name space object.
+//
+typedef struct {
+ EFI_ACPI_DESCRIPTION_HEADER Header;
+ EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE EcControl;
+ EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE EcData;
+ UINT32 Uid;
+ UINT8 GpeBit;
+} EFI_ACPI_2_0_EMBEDDED_CONTROLLER_BOOT_RESOURCES_TABLE;
+
+//
+// ECDT Version (as defined in ACPI 2.0 spec.)
+//
+#define EFI_ACPI_2_0_EMBEDDED_CONTROLLER_BOOT_RESOURCES_TABLE_REVISION 0x01
+
+//
+// Known table signatures
+//
+//
+// "RSD PTR " Root System Description Pointer
+//
+#define EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_POINTER_SIGNATURE 0x2052545020445352
+
+//
+// "SPIC" Multiple SAPIC Description Table
+//
+// BUGBUG: Don't know where this came from except SR870BN4 uses it.
+// #define EFI_ACPI_2_0_MULTIPLE_SAPIC_DESCRIPTION_TABLE_SIGNATURE 0x43495053
+//
+#define EFI_ACPI_2_0_MULTIPLE_SAPIC_DESCRIPTION_TABLE_SIGNATURE 0x43495041
+
+//
+// "BOOT" MS Simple Boot Spec
+//
+#define EFI_ACPI_2_0_SIMPLE_BOOT_FLAG_TABLE_SIGNATURE 0x544F4F42
+
+//
+// "DBGP" MS Bebug Port Spec
+//
+#define EFI_ACPI_2_0_DEBUG_PORT_TABLE_SIGNATURE 0x50474244
+
+//
+// "DSDT" Differentiated System Description Table
+//
+#define EFI_ACPI_2_0_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE 0x54445344
+
+//
+// "ECDT" Embedded Controller Boot Resources Table
+//
+#define EFI_ACPI_2_0_EMBEDDED_CONTROLLER_BOOT_RESOURCES_TABLE_SIGNATURE 0x54444345
+
+//
+// "ETDT" Event Timer Description Table
+//
+#define EFI_ACPI_2_0_EVENT_TIMER_DESCRIPTION_TABLE_SIGNATURE 0x54445445
+
+//
+// "FACS" Firmware ACPI Control Structure
+//
+#define EFI_ACPI_2_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_SIGNATURE 0x53434146
+
+//
+// "FACP" Fixed ACPI Description Table
+//
+#define EFI_ACPI_2_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE 0x50434146
+
+//
+// "APIC" Multiple APIC Description Table
+//
+#define EFI_ACPI_2_0_MULTIPLE_APIC_DESCRIPTION_TABLE_SIGNATURE 0x43495041
+
+//
+// "PSDT" Persistent System Description Table
+//
+#define EFI_ACPI_2_0_PERSISTENT_SYSTEM_DESCRIPTION_TABLE_SIGNATURE 0x54445350
+
+//
+// "RSDT" Root System Description Table
+//
+#define EFI_ACPI_2_0_ROOT_SYSTEM_DESCRIPTION_TABLE_SIGNATURE 0x54445352
+
+//
+// "SBST" Smart Battery Specification Table
+//
+#define EFI_ACPI_2_0_SMART_BATTERY_SPECIFICATION_TABLE_SIGNATURE 0x54534253
+
+//
+// "SLIT" System Locality Information Table
+//
+#define EFI_ACPI_2_0_SYSTEM_LOCALITY_INFORMATION_TABLE_SIGNATURE 0x54494C53
+
+//
+// "SPCR" Serial Port Concole Redirection Table
+//
+#define EFI_ACPI_2_0_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_SIGNATURE 0x52435053
+
+//
+// "SRAT" Static Resource Affinity Table
+//
+#define EFI_ACPI_2_0_STATIC_RESOURCE_AFFINITY_TABLE_SIGNATURE 0x54415253
+
+//
+// "SSDT" Secondary System Description Table
+//
+#define EFI_ACPI_2_0_SECONDARY_SYSTEM_DESCRIPTION_TABLE_SIGNATURE 0x54445353
+
+//
+// "SPMI" Server Platform Management Interface Table
+//
+#define EFI_ACPI_2_0_SERVER_PLATFORM_MANAGEMENT_INTERFACE_SIGNATURE 0x494D5053
+
+//
+// "XSDT" Extended System Description Table
+//
+#define EFI_ACPI_2_0_EXTENDED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE 0x54445358
+
+#pragma pack()
+
+#endif
diff --git a/EDK/Foundation/Include/IndustryStandard/Acpi3_0.h b/EDK/Foundation/Include/IndustryStandard/Acpi3_0.h
new file mode 100644
index 0000000..954ab00
--- /dev/null
+++ b/EDK/Foundation/Include/IndustryStandard/Acpi3_0.h
@@ -0,0 +1,691 @@
+/*++
+
+Copyright (c) 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Acpi3_0.h
+
+Abstract:
+
+ ACPI 3.0 definitions from the ACPI Specification Revision 3.0
+
+--*/
+
+#ifndef _ACPI_3_0_H_
+#define _ACPI_3_0_H_
+
+//
+// Statements that include other files
+//
+#include "AcpiCommon.h"
+
+//
+// Ensure proper structure formats
+//
+#pragma pack(1)
+//
+// ACPI Specification Revision
+//
+#define EFI_ACPI_3_0_REVISION 0x03
+
+//
+// ACPI 3.0 Generic Address Space definition
+//
+typedef struct {
+ UINT8 AddressSpaceId;
+ UINT8 RegisterBitWidth;
+ UINT8 RegisterBitOffset;
+ UINT8 AccessSize;
+ UINT64 Address;
+} EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE;
+
+//
+// Generic Address Space Address IDs
+//
+#define EFI_ACPI_3_0_SYSTEM_MEMORY 0
+#define EFI_ACPI_3_0_SYSTEM_IO 1
+#define EFI_ACPI_3_0_PCI_CONFIGURATION_SPACE 2
+#define EFI_ACPI_3_0_EMBEDDED_CONTROLLER 3
+#define EFI_ACPI_3_0_SMBUS 4
+#define EFI_ACPI_3_0_FUNCTIONAL_FIXED_HARDWARE 0x7F
+
+//
+// Generic Address Space Access Sizes
+//
+#define EFI_ACPI_3_0_UNDEFINED 0
+#define EFI_ACPI_3_0_BYTE 1
+#define EFI_ACPI_3_0_WORD 2
+#define EFI_ACPI_3_0_DWORD 3
+#define EFI_ACPI_3_0_QWORD 4
+
+//
+// ACPI 3.0 table structures
+//
+//
+// Root System Description Pointer Structure
+//
+typedef struct {
+ UINT64 Signature;
+ UINT8 Checksum;
+ UINT8 OemId[6];
+ UINT8 Revision;
+ UINT32 RsdtAddress;
+ UINT32 Length;
+ UINT64 XsdtAddress;
+ UINT8 ExtendedChecksum;
+ UINT8 Reserved[3];
+} EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER;
+
+//
+// RSD_PTR Revision (as defined in ACPI 3.0 spec.)
+//
+#define EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER_REVISION 0x02 // ACPISpec30 (Revision 3.0) says current value is 2
+//
+// Common table header, this prefaces all ACPI tables, including FACS, but
+// excluding the RSD PTR structure
+//
+typedef struct {
+ UINT32 Signature;
+ UINT32 Length;
+} EFI_ACPI_3_0_COMMON_HEADER;
+
+//
+// Root System Description Table
+// No definition needed as it is a common description table header followed by a
+// variable number of UINT32 table pointers.
+//
+//
+// RSDT Revision (as defined in ACPI 3.0 spec.)
+//
+#define EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_TABLE_REVISION 0x01
+
+//
+// Extended System Description Table
+// No definition needed as it is a common description table header followed by a
+// variable number of UINT64 table pointers.
+//
+//
+// XSDT Revision (as defined in ACPI 3.0 spec.)
+//
+#define EFI_ACPI_3_0_EXTENDED_SYSTEM_DESCRIPTION_TABLE_REVISION 0x01
+
+//
+// Fixed ACPI Description Table Structure (FADT)
+//
+typedef struct {
+ EFI_ACPI_DESCRIPTION_HEADER Header;
+ UINT32 FirmwareCtrl;
+ UINT32 Dsdt;
+ UINT8 Reserved0;
+ UINT8 PreferredPmProfile;
+ UINT16 SciInt;
+ UINT32 SmiCmd;
+ UINT8 AcpiEnable;
+ UINT8 AcpiDisable;
+ UINT8 S4BiosReq;
+ UINT8 PstateCnt;
+ UINT32 Pm1aEvtBlk;
+ UINT32 Pm1bEvtBlk;
+ UINT32 Pm1aCntBlk;
+ UINT32 Pm1bCntBlk;
+ UINT32 Pm2CntBlk;
+ UINT32 PmTmrBlk;
+ UINT32 Gpe0Blk;
+ UINT32 Gpe1Blk;
+ UINT8 Pm1EvtLen;
+ UINT8 Pm1CntLen;
+ UINT8 Pm2CntLen;
+ UINT8 PmTmrLen;
+ UINT8 Gpe0BlkLen;
+ UINT8 Gpe1BlkLen;
+ UINT8 Gpe1Base;
+ UINT8 CstCnt;
+ UINT16 PLvl2Lat;
+ UINT16 PLvl3Lat;
+ UINT16 FlushSize;
+ UINT16 FlushStride;
+ UINT8 DutyOffset;
+ UINT8 DutyWidth;
+ UINT8 DayAlrm;
+ UINT8 MonAlrm;
+ UINT8 Century;
+ UINT16 IaPcBootArch;
+ UINT8 Reserved1;
+ UINT32 Flags;
+ EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE ResetReg;
+ UINT8 ResetValue;
+ UINT8 Reserved2[3];
+ UINT64 XFirmwareCtrl;
+ UINT64 XDsdt;
+ EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE XPm1aEvtBlk;
+ EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE XPm1bEvtBlk;
+ EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE XPm1aCntBlk;
+ EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE XPm1bCntBlk;
+ EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE XPm2CntBlk;
+ EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE XPmTmrBlk;
+ EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE XGpe0Blk;
+ EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE XGpe1Blk;
+} EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE;
+
+//
+// FADT Version (as defined in ACPI 3.0 spec.)
+//
+#define EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE_REVISION 0x04
+
+//
+// Fixed ACPI Description Table Preferred Power Management Profile
+//
+#define EFI_ACPI_3_0_PM_PROFILE_UNSPECIFIED 0
+#define EFI_ACPI_3_0_PM_PROFILE_DESKTOP 1
+#define EFI_ACPI_3_0_PM_PROFILE_MOBILE 2
+#define EFI_ACPI_3_0_PM_PROFILE_WORKSTATION 3
+#define EFI_ACPI_3_0_PM_PROFILE_ENTERPRISE_SERVER 4
+#define EFI_ACPI_3_0_PM_PROFILE_SOHO_SERVER 5
+#define EFI_ACPI_3_0_PM_PROFILE_APPLIANCE_PC 6
+#define EFI_ACPI_3_0_PM_PROFILE_PERFORMANCE_SERVER 7
+
+//
+// Fixed ACPI Description Table Boot Architecture Flags
+// All other bits are reserved and must be set to 0.
+//
+#define EFI_ACPI_3_0_LEGACY_DEVICES (1 << 0)
+#define EFI_ACPI_3_0_8042 (1 << 1)
+#define EFI_ACPI_3_0_VGA_NOT_PRESENT (1 << 2)
+#define EFI_ACPI_3_0_MSI_NOT_SUPPORTED (1 << 3)
+#define EFI_ACPI_3_0_PCIE_ASPM_CONTROLS (1 << 4)
+//
+// Fixed ACPI Description Table Fixed Feature Flags
+// All other bits are reserved and must be set to 0.
+//
+#define EFI_ACPI_3_0_WBINVD (1 << 0)
+#define EFI_ACPI_3_0_WBINVD_FLUSH (1 << 1)
+#define EFI_ACPI_3_0_PROC_C1 (1 << 2)
+#define EFI_ACPI_3_0_P_LVL2_UP (1 << 3)
+#define EFI_ACPI_3_0_PWR_BUTTON (1 << 4)
+#define EFI_ACPI_3_0_SLP_BUTTON (1 << 5)
+#define EFI_ACPI_3_0_FIX_RTC (1 << 6)
+#define EFI_ACPI_3_0_RTC_S4 (1 << 7)
+#define EFI_ACPI_3_0_TMR_VAL_EXT (1 << 8)
+#define EFI_ACPI_3_0_DCK_CAP (1 << 9)
+#define EFI_ACPI_3_0_RESET_REG_SUP (1 << 10)
+#define EFI_ACPI_3_0_SEALED_CASE (1 << 11)
+#define EFI_ACPI_3_0_HEADLESS (1 << 12)
+#define EFI_ACPI_3_0_CPU_SW_SLP (1 << 13)
+#define EFI_ACPI_3_0_PCI_EXP_WAK (1 << 14)
+#define EFI_ACPI_3_0_USE_PLATFORM_CLOCK (1 << 15)
+#define EFI_ACPI_3_0_S4_RTC_STS_VALID (1 << 16)
+#define EFI_ACPI_3_0_REMOTE_POWER_ON_CAPABLE (1 << 17)
+#define EFI_ACPI_3_0_FORCE_APIC_CLUSTER_MODEL (1 << 18)
+#define EFI_ACPI_3_0_FORCE_APIC_PHYSICAL_DESTINATION_MODE (1 << 19)
+
+//
+// Firmware ACPI Control Structure
+//
+typedef struct {
+ UINT32 Signature;
+ UINT32 Length;
+ UINT32 HardwareSignature;
+ UINT32 FirmwareWakingVector;
+ UINT32 GlobalLock;
+ UINT32 Flags;
+ UINT64 XFirmwareWakingVector;
+ UINT8 Version;
+ UINT8 Reserved[31];
+} EFI_ACPI_3_0_FIRMWARE_ACPI_CONTROL_STRUCTURE;
+
+//
+// FACS Version (as defined in ACPI 3.0 spec.)
+//
+#define EFI_ACPI_3_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_VERSION 0x01
+
+//
+// Firmware Control Structure Feature Flags
+// All other bits are reserved and must be set to 0.
+//
+#define EFI_ACPI_3_0_S4BIOS_F (1 << 0)
+
+//
+// Differentiated System Description Table,
+// Secondary System Description Table
+// and Persistent System Description Table,
+// no definition needed as they are common description table header followed by a
+// definition block.
+//
+#define EFI_ACPI_3_0_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_REVISION 0x02
+#define EFI_ACPI_3_0_SECONDARY_SYSTEM_DESCRIPTION_TABLE_REVISION 0x02
+
+//
+// Multiple APIC Description Table header definition. The rest of the table
+// must be defined in a platform specific manner.
+//
+typedef struct {
+ EFI_ACPI_DESCRIPTION_HEADER Header;
+ UINT32 LocalApicAddress;
+ UINT32 Flags;
+} EFI_ACPI_3_0_MULTIPLE_APIC_DESCRIPTION_TABLE_HEADER;
+
+//
+// MADT Revision (as defined in ACPI 3.0 spec.)
+//
+#define EFI_ACPI_3_0_MULTIPLE_APIC_DESCRIPTION_TABLE_REVISION 0x02
+
+//
+// Multiple APIC Flags
+// All other bits are reserved and must be set to 0.
+//
+#define EFI_ACPI_3_0_PCAT_COMPAT (1 << 0)
+
+//
+// Multiple APIC Description Table APIC structure types
+// All other values between 0x09 an 0xFF are reserved and
+// will be ignored by OSPM.
+//
+#define EFI_ACPI_3_0_PROCESSOR_LOCAL_APIC 0x00
+#define EFI_ACPI_3_0_IO_APIC 0x01
+#define EFI_ACPI_3_0_INTERRUPT_SOURCE_OVERRIDE 0x02
+#define EFI_ACPI_3_0_NON_MASKABLE_INTERRUPT_SOURCE 0x03
+#define EFI_ACPI_3_0_LOCAL_APIC_NMI 0x04
+#define EFI_ACPI_3_0_LOCAL_APIC_ADDRESS_OVERRIDE 0x05
+#define EFI_ACPI_3_0_IO_SAPIC 0x06
+#define EFI_ACPI_3_0_LOCAL_SAPIC 0x07
+#define EFI_ACPI_3_0_PLATFORM_INTERRUPT_SOURCES 0x08
+
+//
+// APIC Structure Definitions
+//
+//
+// Processor Local APIC Structure Definition
+//
+typedef struct {
+ UINT8 Type;
+ UINT8 Length;
+ UINT8 AcpiProcessorId;
+ UINT8 ApicId;
+ UINT32 Flags;
+} EFI_ACPI_3_0_PROCESSOR_LOCAL_APIC_STRUCTURE;
+
+//
+// Local APIC Flags. All other bits are reserved and must be 0.
+//
+#define EFI_ACPI_3_0_LOCAL_APIC_ENABLED (1 << 0)
+
+//
+// IO APIC Structure
+//
+typedef struct {
+ UINT8 Type;
+ UINT8 Length;
+ UINT8 IoApicId;
+ UINT8 Reserved;
+ UINT32 IoApicAddress;
+ UINT32 GlobalSystemInterruptBase;
+} EFI_ACPI_3_0_IO_APIC_STRUCTURE;
+
+//
+// Interrupt Source Override Structure
+//
+typedef struct {
+ UINT8 Type;
+ UINT8 Length;
+ UINT8 Bus;
+ UINT8 Source;
+ UINT32 GlobalSystemInterrupt;
+ UINT16 Flags;
+} EFI_ACPI_3_0_INTERRUPT_SOURCE_OVERRIDE_STRUCTURE;
+
+//
+// Platform Interrupt Sources Structure Definition
+//
+typedef struct {
+ UINT8 Type;
+ UINT8 Length;
+ UINT16 Flags;
+ UINT8 InterruptType;
+ UINT8 ProcessorId;
+ UINT8 ProcessorEid;
+ UINT8 IoSapicVector;
+ UINT32 GlobalSystemInterrupt;
+ UINT32 PlatformInterruptSourceFlags;
+ UINT8 CpeiProcessorOverride;
+ UINT8 Reserved[31];
+} EFI_ACPI_3_0_PLATFORM_INTERRUPT_APIC_STRUCTURE;
+
+//
+// MPS INTI flags.
+// All other bits are reserved and must be set to 0.
+//
+#define EFI_ACPI_3_0_POLARITY (3 << 0)
+#define EFI_ACPI_3_0_TRIGGER_MODE (3 << 2)
+
+//
+// Non-Maskable Interrupt Source Structure
+//
+typedef struct {
+ UINT8 Type;
+ UINT8 Length;
+ UINT16 Flags;
+ UINT32 GlobalSystemInterrupt;
+} EFI_ACPI_3_0_NON_MASKABLE_INTERRUPT_SOURCE_STRUCTURE;
+
+//
+// Local APIC NMI Structure
+//
+typedef struct {
+ UINT8 Type;
+ UINT8 Length;
+ UINT8 AcpiProcessorId;
+ UINT16 Flags;
+ UINT8 LocalApicLint;
+} EFI_ACPI_3_0_LOCAL_APIC_NMI_STRUCTURE;
+
+//
+// Local APIC Address Override Structure
+//
+typedef struct {
+ UINT8 Type;
+ UINT8 Length;
+ UINT16 Reserved;
+ UINT64 LocalApicAddress;
+} EFI_ACPI_3_0_LOCAL_APIC_ADDRESS_OVERRIDE_STRUCTURE;
+
+//
+// IO SAPIC Structure
+//
+typedef struct {
+ UINT8 Type;
+ UINT8 Length;
+ UINT8 IoApicId;
+ UINT8 Reserved;
+ UINT32 GlobalSystemInterruptBase;
+ UINT64 IoSapicAddress;
+} EFI_ACPI_3_0_IO_SAPIC_STRUCTURE;
+
+//
+// Local SAPIC Structure
+// This struct followed by a null-terminated ASCII string - ACPI Processor UID String
+//
+typedef struct {
+ UINT8 Type;
+ UINT8 Length;
+ UINT8 AcpiProcessorId;
+ UINT8 LocalSapicId;
+ UINT8 LocalSapicEid;
+ UINT8 Reserved[3];
+ UINT32 Flags;
+ UINT32 ACPIProcessorUIDValue;
+} EFI_ACPI_3_0_PROCESSOR_LOCAL_SAPIC_STRUCTURE;
+
+//
+// Platform Interrupt Sources Structure
+//
+typedef struct {
+ UINT8 Type;
+ UINT8 Length;
+ UINT16 Flags;
+ UINT8 InterruptType;
+ UINT8 ProcessorId;
+ UINT8 ProcessorEid;
+ UINT8 IoSapicVector;
+ UINT32 GlobalSystemInterrupt;
+ UINT32 PlatformInterruptSourceFlags;
+} EFI_ACPI_3_0_PLATFORM_INTERRUPT_SOURCES_STRUCTURE;
+
+//
+// Platform Interrupt Source Flags.
+// All other bits are reserved and must be set to 0.
+//
+#define EFI_ACPI_3_0_CPEI_PROCESSOR_OVERRIDE (1 << 0)
+
+//
+// Smart Battery Description Table (SBST)
+//
+typedef struct {
+ EFI_ACPI_DESCRIPTION_HEADER Header;
+ UINT32 WarningEnergyLevel;
+ UINT32 LowEnergyLevel;
+ UINT32 CriticalEnergyLevel;
+} EFI_ACPI_3_0_SMART_BATTERY_DESCRIPTION_TABLE;
+
+//
+// SBST Version (as defined in ACPI 3.0 spec.)
+//
+#define EFI_ACPI_3_0_SMART_BATTERY_DESCRIPTION_TABLE_REVISION 0x01
+
+//
+// Embedded Controller Boot Resources Table (ECDT)
+// The table is followed by a null terminated ASCII string that contains
+// a fully qualified reference to the name space object.
+//
+typedef struct {
+ EFI_ACPI_DESCRIPTION_HEADER Header;
+ EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE EcControl;
+ EFI_ACPI_3_0_GENERIC_ADDRESS_STRUCTURE EcData;
+ UINT32 Uid;
+ UINT8 GpeBit;
+} EFI_ACPI_3_0_EMBEDDED_CONTROLLER_BOOT_RESOURCES_TABLE;
+
+//
+// ECDT Version (as defined in ACPI 3.0 spec.)
+//
+#define EFI_ACPI_3_0_EMBEDDED_CONTROLLER_BOOT_RESOURCES_TABLE_REVISION 0x01
+
+//
+// System Resource Affinity Table (SRAT. The rest of the table
+// must be defined in a platform specific manner.
+//
+typedef struct {
+ EFI_ACPI_DESCRIPTION_HEADER Header;
+ UINT32 Reserved1; // Must be set to 1
+ UINT64 Reserved2;
+} EFI_ACPI_3_0_SYSTEM_RESOURCE_AFFINITY_TABLE_HEADER;
+
+//
+// SRAT Version (as defined in ACPI 3.0 spec.)
+//
+#define EFI_ACPI_3_0_SYSTEM_RESOURCE_AFFINITY_TABLE_REVISION 0x02
+
+//
+// SRAT structure types.
+// All other values between 0x02 an 0xFF are reserved and
+// will be ignored by OSPM.
+//
+#define EFI_ACPI_3_0_PROCESSOR_LOCAL_APIC_SAPIC_AFFINITY 0x00
+#define EFI_ACPI_3_0_MEMORY_AFFINITY 0x01
+
+//
+// Processor Local APIC/SAPIC Affinity Structure Definition
+//
+typedef struct {
+ UINT8 Type;
+ UINT8 Length;
+ UINT8 ProximityDomain7To0;
+ UINT8 ApicId;
+ UINT32 Flags;
+ UINT8 LocalSapicEid;
+ UINT8 ProximityDomain31To8[3];
+ UINT8 Reserved[4];
+} EFI_ACPI_3_0_PROCESSOR_LOCAL_APIC_SAPIC_AFFINITY_STRUCTURE;
+
+//
+// Local APIC/SAPIC Flags. All other bits are reserved and must be 0.
+//
+#define EFI_ACPI_3_0_PROCESSOR_LOCAL_APIC_SAPIC_ENABLED (1 << 0)
+
+//
+// Memory Affinity Structure Definition
+//
+typedef struct {
+ UINT8 Type;
+ UINT8 Length;
+ UINT32 ProximityDomain;
+ UINT16 Reserved1;
+ UINT32 AddressBaseLow;
+ UINT32 AddressBaseHigh;
+ UINT32 LengthLow;
+ UINT32 LengthHigh;
+ UINT32 Reserved2;
+ UINT32 Flags;
+ UINT64 Reserved3;
+} EFI_ACPI_3_0_MEMORY_AFFINITY_STRUCTURE;
+
+//
+// Memory Flags. All other bits are reserved and must be 0.
+//
+#define EFI_ACPI_3_0_MEMORY_ENABLED (1 << 0)
+#define EFI_ACPI_3_0_MEMORY_HOT_PLUGGABLE (1 << 1)
+#define EFI_ACPI_3_0_MEMORY_NONVOLATILE (1 << 2)
+
+//
+// System Locality Distance Information Table (SLIT).
+// The rest of the table is a matrix.
+//
+typedef struct {
+ EFI_ACPI_DESCRIPTION_HEADER Header;
+ UINT64 NumberOfSystemLocalities;
+} EFI_ACPI_3_0_SYSTEM_LOCALITY_DISTANCE_INFORMATION_TABLE_HEADER;
+
+//
+// SLIT Version (as defined in ACPI 3.0 spec.)
+//
+#define EFI_ACPI_3_0_SYSTEM_LOCALITY_DISTANCE_INFORMATION_TABLE_REVISION 0x01
+
+//
+// Known table signatures
+//
+//
+// "RSD PTR " Root System Description Pointer
+//
+#define EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_POINTER_SIGNATURE 0x2052545020445352
+
+//
+// "APIC" Multiple APIC Description Table
+//
+#define EFI_ACPI_3_0_MULTIPLE_APIC_DESCRIPTION_TABLE_SIGNATURE 0x43495041
+
+//
+// "DSDT" Differentiated System Description Table
+//
+#define EFI_ACPI_3_0_DIFFERENTIATED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE 0x54445344
+
+//
+// "ECDT" Embedded Controller Boot Resources Table
+//
+#define EFI_ACPI_3_0_EMBEDDED_CONTROLLER_BOOT_RESOURCES_TABLE_SIGNATURE 0x54444345
+
+//
+// "FACP" Fixed ACPI Description Table
+//
+#define EFI_ACPI_3_0_FIXED_ACPI_DESCRIPTION_TABLE_SIGNATURE 0x50434146
+
+//
+// "FACS" Firmware ACPI Control Structure
+//
+#define EFI_ACPI_3_0_FIRMWARE_ACPI_CONTROL_STRUCTURE_SIGNATURE 0x53434146
+
+//
+// "PSDT" Persistent System Description Table
+//
+#define EFI_ACPI_3_0_PERSISTENT_SYSTEM_DESCRIPTION_TABLE_SIGNATURE 0x54445350
+
+//
+// "RSDT" Root System Description Table
+//
+#define EFI_ACPI_3_0_ROOT_SYSTEM_DESCRIPTION_TABLE_SIGNATURE 0x54445352
+
+//
+// "SBST" Smart Battery Specification Table
+//
+#define EFI_ACPI_3_0_SMART_BATTERY_SPECIFICATION_TABLE_SIGNATURE 0x54534253
+
+//
+// "SLIT" System Locality Information Table
+//
+#define EFI_ACPI_3_0_SYSTEM_LOCALITY_INFORMATION_TABLE_SIGNATURE 0x54494C53
+
+//
+// "SRAT" System Resource Affinity Table
+//
+#define EFI_ACPI_3_0_SYSTEM_RESOURCE_AFFINITY_TABLE_SIGNATURE 0x54415253
+
+//
+// "SSDT" Secondary System Description Table
+//
+#define EFI_ACPI_3_0_SECONDARY_SYSTEM_DESCRIPTION_TABLE_SIGNATURE 0x54445353
+
+//
+// "XSDT" Extended System Description Table
+//
+#define EFI_ACPI_3_0_EXTENDED_SYSTEM_DESCRIPTION_TABLE_SIGNATURE 0x54445358
+
+//
+// "BOOT" MS Simple Boot Spec
+//
+#define EFI_ACPI_3_0_SIMPLE_BOOT_FLAG_TABLE_SIGNATURE 0x544F4F42
+
+//
+// "CPEP" Corrected Platform Error Polling Table
+// See
+//
+#define EFI_ACPI_3_0_CORRECTED_PLATFORM_ERROR_POLLING_TABLE_SIGNATURE 0x50455043
+
+//
+// "DBGP" MS Debug Port Spec
+//
+#define EFI_ACPI_3_0_DEBUG_PORT_TABLE_SIGNATURE 0x50474244
+
+//
+// "ETDT" Event Timer Description Table
+//
+#define EFI_ACPI_3_0_EVENT_TIMER_DESCRIPTION_TABLE_SIGNATURE 0x54445445
+
+//
+// "HPET" IA-PC High Precision Event Timer Table
+//
+#define EFI_ACPI_3_0_HIGH_PRECISION_EVENT_TIMER_TABLE_SIGNATURE 0x54455048
+
+//
+// "MCFG" PCI Express Memory Mapped Configuration Space Base Address Description Table
+//
+#define EFI_ACPI_3_0_PCI_EXPRESS_MEMORY_MAPPED_CONFIGURATION_SPACE_BASE_ADDRESS_DESCRIPTION_TABLE_SIGNATURE 0x4746434D
+
+//
+// "SPCR" Serial Port Concole Redirection Table
+//
+#define EFI_ACPI_3_0_SERIAL_PORT_CONSOLE_REDIRECTION_TABLE_SIGNATURE 0x52435053
+
+//
+// "SPMI" Server Platform Management Interface Table
+//
+#define EFI_ACPI_3_0_SERVER_PLATFORM_MANAGEMENT_INTERFACE_TABLE_SIGNATURE 0x494D5053
+
+//
+// "TCPA" Trusted Computing Platform Alliance Capabilities Table
+//
+#define EFI_ACPI_3_0_TRUSTED_COMPUTING_PLATFORM_ALLIANCE_CAPABILITIES_TABLE_SIGNATURE 0x41504354
+
+//
+// "WDRT" Watchdog Resource Table
+//
+#define EFI_ACPI_3_0_WATCHDOG_RESOURCE_TABLE_SIGNATURE 0x54524457
+
+//
+// "WDAT" Watchdog Action Table
+//
+#define EFI_ACPI_3_0_WATCHDOG_ACTION_TABLE_SIGNATURE 0x54414457
+
+//
+// "iBFT" iSCSI Boot Firmware Table
+//
+#define EFI_ACPI_3_0_ISCSI_BOOT_FIRMWARE_TABLE_SIGNATURE 0x54464269
+
+#pragma pack()
+
+#endif
diff --git a/EDK/Foundation/Include/IndustryStandard/AcpiCommon.h b/EDK/Foundation/Include/IndustryStandard/AcpiCommon.h
new file mode 100644
index 0000000..eeee24e
--- /dev/null
+++ b/EDK/Foundation/Include/IndustryStandard/AcpiCommon.h
@@ -0,0 +1,98 @@
+/*++
+
+Copyright (c) 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ AcpiCommon.h
+
+Abstract:
+
+ This file contains some basic ACPI definitions that are consumed by drivers
+ that do not care about ACPI versions.
+
+--*/
+
+#ifndef _ACPI_COMMON_H_
+#define _ACPI_COMMON_H_
+
+#include "Tiano.h"
+
+//
+// Common table header, this prefaces all ACPI tables, including FACS, but
+// excluding the RSD PTR structure
+//
+typedef struct {
+ UINT32 Signature;
+ UINT32 Length;
+} EFI_ACPI_COMMON_HEADER;
+
+//
+// Common ACPI description table header. This structure prefaces most ACPI tables.
+//
+#pragma pack(1)
+
+typedef struct {
+ UINT32 Signature;
+ UINT32 Length;
+ UINT8 Revision;
+ UINT8 Checksum;
+ UINT8 OemId[6];
+ UINT64 OemTableId;
+ UINT32 OemRevision;
+ UINT32 CreatorId;
+ UINT32 CreatorRevision;
+} EFI_ACPI_DESCRIPTION_HEADER;
+
+#pragma pack()
+//
+// Define for Pci Host Bridge Resource Allocation
+//
+#define ACPI_ADDRESS_SPACE_DESCRIPTOR 0x8A
+#define ACPI_END_TAG_DESCRIPTOR 0x79
+
+#define ACPI_ADDRESS_SPACE_TYPE_MEM 0x00
+#define ACPI_ADDRESS_SPACE_TYPE_IO 0x01
+#define ACPI_ADDRESS_SPACE_TYPE_BUS 0x02
+
+//
+// Make sure structures match spec
+//
+#pragma pack(1)
+
+typedef struct {
+ UINT8 Desc;
+ UINT16 Len;
+ UINT8 ResType;
+ UINT8 GenFlag;
+ UINT8 SpecificFlag;
+ UINT64 AddrSpaceGranularity;
+ UINT64 AddrRangeMin;
+ UINT64 AddrRangeMax;
+ UINT64 AddrTranslationOffset;
+ UINT64 AddrLen;
+} EFI_ACPI_ADDRESS_SPACE_DESCRIPTOR;
+
+typedef struct {
+ UINT8 Desc;
+ UINT8 Checksum;
+} EFI_ACPI_END_TAG_DESCRIPTOR;
+
+//
+// General use definitions
+//
+#define EFI_ACPI_RESERVED_BYTE 0x00
+#define EFI_ACPI_RESERVED_WORD 0x0000
+#define EFI_ACPI_RESERVED_DWORD 0x00000000
+#define EFI_ACPI_RESERVED_QWORD 0x0000000000000000
+
+#pragma pack()
+
+#endif
diff --git a/EDK/Foundation/Include/IndustryStandard/AlertStandardFormatTable.h b/EDK/Foundation/Include/IndustryStandard/AlertStandardFormatTable.h
new file mode 100644
index 0000000..14fe2c4
--- /dev/null
+++ b/EDK/Foundation/Include/IndustryStandard/AlertStandardFormatTable.h
@@ -0,0 +1,123 @@
+/*++
+
+Copyright (c) 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ AlertStandardFormatTable.h
+
+Abstract:
+
+ ACPI Alert Standard Format Description Table ASF! as described
+ in the ASF2.0 Specification
+
+--*/
+
+#ifndef _ALERT_STANDARD_FORMAT_TABLE_H
+#define _ALERT_STANDARD_FORMAT_TABLE_H
+
+#include "Acpi2_0.h"
+
+//
+// Ensure proper structure formats
+//
+#pragma pack (1)
+
+//
+// Information Record header that appears at the beginning of each record
+//
+typedef struct {
+ UINT8 Type;
+ UINT8 Reserved;
+ UINT16 RecordLength;
+} EFI_ACPI_ASF_RECORD_HEADER;
+
+//
+// This structure contains information that identifies the system type
+// and configuration
+//
+typedef struct {
+ EFI_ACPI_ASF_RECORD_HEADER RecordHeader;
+ UINT8 MinWatchDogResetValue;
+ UINT8 MinPollingInterval;
+ UINT16 SystemID;
+ UINT32 IANAManufactureID;
+ UINT8 FeatureFlags;
+ UINT8 Reserved[3];
+} EFI_ACPI_ASF_INFO;
+
+//
+// Alert sensors definition
+//
+#define ASF_ALRT_SENSOR_ARRAY_LENGTH 36
+
+typedef struct {
+ EFI_ACPI_ASF_RECORD_HEADER RecordHeader;
+ UINT8 AssertionEventBitMask;
+ UINT8 DeassertionEventBitMask;
+ UINT8 NumberOfAlerts;
+ UINT8 ArrayElementLength;
+ UINT8 DeviceArray[ASF_ALRT_SENSOR_ARRAY_LENGTH];
+} EFI_ACPI_ASF_ALRT;
+
+//
+// Alert Remote Control System Actions
+//
+#define ASF_RCTL_DEVICES_ARRAY_LENGTH 16
+typedef struct {
+ EFI_ACPI_ASF_RECORD_HEADER RecordHeader;
+ UINT8 NumberOfControls;
+ UINT8 ArrayElementLength;
+ UINT16 RctlReserved;
+ UINT8 ControlArray[ASF_RCTL_DEVICES_ARRAY_LENGTH];
+} EFI_ACPI_ASF_RCTL;
+
+//
+// Remote Control Capabilities
+//
+typedef struct {
+ EFI_ACPI_ASF_RECORD_HEADER RecordHeader;
+ UINT8 RemoteControlCapabilities[7];
+ UINT8 RMCPCompletionCode;
+ UINT32 RMCPIANA;
+ UINT8 RMCPSpecialCommand;
+ UINT8 RMCPSpecialCommandParameter[2];
+ UINT8 RMCPBootOptions[2];
+ UINT8 RMCPOEMParameters[2];
+} EFI_ACPI_ASF_RMCP;
+
+//
+// SMBus Devices with fixed addresses
+//
+#define ASF_ADDR_DEVICE_ARRAY_LENGTH 16
+typedef struct {
+ EFI_ACPI_ASF_RECORD_HEADER RecordHeader;
+ UINT8 SEEPROMAddress;
+ UINT8 NumberOfDevices;
+ UINT8 FixedSmbusAddresses[ASF_ADDR_DEVICE_ARRAY_LENGTH];
+} EFI_ACPI_ASF_ADDR;
+
+typedef struct {
+ EFI_ACPI_DESCRIPTION_HEADER Header;
+ EFI_ACPI_ASF_INFO AsfInfo;
+ EFI_ACPI_ASF_ALRT AsfAlert;
+ EFI_ACPI_ASF_RCTL AsfRctl;
+ EFI_ACPI_ASF_RMCP AsfRmcp;
+ EFI_ACPI_ASF_ADDR AsfAddr;
+} EFI_ACPI_1_0_ASF_DESCRIPTION_TABLE;
+
+//
+// "ASF!" ASF Description Table Signature
+//
+#define EFI_ACPI_1_0_ASF_DESCRIPTION_TABLE_SIGNATURE 0x21465341
+
+#pragma pack ()
+
+#endif // _ALERT_STANDARD_FORMAT_TABLE_H
diff --git a/EDK/Foundation/Include/IndustryStandard/DMARemappingReportingTable.h b/EDK/Foundation/Include/IndustryStandard/DMARemappingReportingTable.h
new file mode 100644
index 0000000..bdc3903
--- /dev/null
+++ b/EDK/Foundation/Include/IndustryStandard/DMARemappingReportingTable.h
@@ -0,0 +1,203 @@
+/*++
+
+Copyright (c) 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ DMARemappingReportingTable.h
+
+Abstract:
+
+ The definition for ACPI DMA-Remapping Reporting (DMAR) Table.
+ It is defined in "Intel VT for Direct IO Architecture Specification".
+
+--*/
+
+#ifndef _EFI_DMA_REMAPPING_REPORTING_TABLE_H_
+#define _EFI_DMA_REMAPPING_REPORTING_TABLE_H_
+
+#include "AcpiCommon.h"
+
+//
+// "DMAR" DMAR Description Table Signature
+//
+#define EFI_ACPI_DMAR_DESCRIPTION_TABLE_SIGNATURE 0x52414d44
+
+//
+// DMAR Revision
+//
+#define EFI_ACPI_DMAR_DESCRIPTION_TABLE_REVISION 0x01
+
+//
+// Ensure proper structure formats
+//
+#pragma pack (1)
+
+//
+// Definition for DMA Remapping Structure Types
+//
+#define EFI_ACPI_DMA_REMAPPING_STRUCTURE_TYPE_DRHD 0
+#define EFI_ACPI_DMA_REMAPPING_STRUCTURE_TYPE_RMRR 1
+#define EFI_ACPI_DMA_REMAPPING_STRUCTURE_TYPE_ATSR 2
+
+//
+// Definition for DMA Remapping Structure Header
+//
+typedef struct {
+ UINT16 Type;
+ UINT16 Length;
+} EFI_ACPI_DMAR_STRUCTURE_HEADER;
+
+//
+// Definition for DMA-Remapping PCI Path
+//
+typedef struct {
+ UINT8 Device;
+ UINT8 Function;
+} EFI_ACPI_DMAR_PCI_PATH;
+
+//
+// Definition for DMA-Remapping Device Scope Entry Structure
+//
+#define EFI_ACPI_DEVICE_SCOPE_ENTRY_TYPE_ENDPOINT 0x01
+#define EFI_ACPI_DEVICE_SCOPE_ENTRY_TYPE_BRIDGE 0x02
+#define EFI_ACPI_DEVICE_SCOPE_ENTRY_TYPE_IOAPIC 0x03
+#define EFI_ACPI_DEVICE_SCOPE_ENTRY_TYPE_MSI_CAPABLE_HPET 0x04
+typedef struct {
+ UINT8 DeviceScopeEntryType;
+ UINT8 Length;
+ UINT16 Reserved_2;
+ UINT8 EnumerationID;
+ UINT8 StartingBusNumber;
+} EFI_ACPI_DMAR_DEVICE_SCOPE_ENTRY_STRUCTURE;
+
+//
+// Definition for DMA-Remapping Hardware Definition (DRHD) Structure
+//
+#define EFI_ACPI_DMAR_DRHD_FLAGS_INCLUDE_ALL_SET 0x1
+#define EFI_ACPI_DMAR_DRHD_FLAGS_INCLUDE_ALL_CLEAR 0x0
+typedef struct {
+ UINT16 Type;
+ UINT16 Length;
+ UINT8 Flags;
+ UINT8 Reserved_5;
+ UINT16 SegmentNumber;
+ UINT64 RegisterBaseAddress;
+} EFI_ACPI_DMAR_HARDWARE_UNIT_DEFINITION_STRUCTURE;
+
+//
+// Definition for Reserved Memory Region Reporting (RMRR) Structure
+//
+typedef struct {
+ UINT16 Type;
+ UINT16 Length;
+ UINT8 Reserved_4[2];
+ UINT16 SegmentNumber;
+ UINT64 ReservedMemoryRegionBaseAddress;
+ UINT64 ReservedMemoryRegionLimitAddress;
+} EFI_ACPI_DMAR_RESERVED_MEMORY_REGION_REPORTING_STRUCTURE;
+
+//
+// Definition for Root Port ATS Capability Reporting (ATSR) Structure
+//
+#define EFI_ACPI_DMAR_ATSR_FLAGS_ALL_PORTS_SET 0x1
+#define EFI_ACPI_DMAR_ATSR_FLAGS_ALL_PORTS_CLEAR 0x0
+typedef struct {
+ UINT16 Type;
+ UINT16 Length;
+ UINT8 Flags;
+ UINT8 Reserved_5;
+ UINT16 SegmentNumber;
+} EFI_ACPI_DMAR_ROOT_PORT_ATS_CAPABILITY_REPORTING_STRUCTURE;
+
+//
+// Definition for DMA Remapping Structure
+//
+typedef union {
+ EFI_ACPI_DMAR_STRUCTURE_HEADER DMARStructureHeader;
+ EFI_ACPI_DMAR_HARDWARE_UNIT_DEFINITION_STRUCTURE DMARHardwareUnitDefinition;
+ EFI_ACPI_DMAR_RESERVED_MEMORY_REGION_REPORTING_STRUCTURE DMARReservedMemoryRegionReporting;
+ EFI_ACPI_DMAR_ROOT_PORT_ATS_CAPABILITY_REPORTING_STRUCTURE DMARRootPortATSCapabilityReporting;
+} EFI_ACPI_DMA_REMAPPING_STRUCTURE;
+
+//
+// Definition for DMA-Remapping Reporting ACPI Table
+//
+#define EFI_ACPI_DMAR_TABLE_FLAGS_INTR_REMAP_SET 0x01
+#define EFI_ACPI_DMAR_TABLE_FLAGS_INTR_REMAP_CLEAR 0x00
+typedef struct {
+ EFI_ACPI_DESCRIPTION_HEADER Header;
+ UINT8 HostAddressWidth;
+ UINT8 Flags;
+ UINT8 Reserved_38[10];
+} EFI_ACPI_DMAR_DESCRIPTION_TABLE;
+
+//
+// The Platform specific definition can be as follows:
+// NOTE: we use /**/ as comment for user convenience to copy it.
+//
+
+/*
+
+//
+// Dmar.h
+//
+
+#define EFI_ACPI_MAX_NUM_PCI_PATH_ENTRIES 0x01 // user need to update
+typedef struct {
+ EFI_ACPI_DMAR_DEVICE_SCOPE_ENTRY_STRUCTURE Header;
+ EFI_ACPI_DMAR_PCI_PATH PciPath[EFI_ACPI_MAX_NUM_PCI_PATH_ENTRIES];
+} EFI_ACPI_3_0_DMAR_DEVICE_SCOPE_ENTRY_STRUCTURE;
+
+#define EFI_ACPI_MAX_NUM_OF_DEVICE_SCOPE_PER_DHRD_ENTRY 0x01 // user need to update
+typedef struct {
+ EFI_ACPI_DMAR_HARDWARE_UNIT_DEFINITION_STRUCTURE Header;
+ EFI_ACPI_3_0_DMAR_DEVICE_SCOPE_ENTRY_STRUCTURE DeviceScopeEntry[EFI_ACPI_MAX_NUM_OF_DEVICE_SCOPE_PER_DHRD_ENTRY];
+} EFI_ACPI_3_0_DMAR_HARDWARE_UNIT_DEFINITION_STRUCTURE;
+
+#define EFI_ACPI_MAX_NUM_OF_DEVICE_SCOPE_PER_RMRR_ENTRY 0x01 // user need to update
+typedef struct {
+ EFI_ACPI_DMAR_RESERVED_MEMORY_REGION_REPORTING_STRUCTURE Header;
+ EFI_ACPI_3_0_DMAR_DEVICE_SCOPE_ENTRY_STRUCTURE DeviceScopeEntry[EFI_ACPI_MAX_NUM_OF_DEVICE_SCOPE_PER_RMRR_ENTRY];
+} EFI_ACPI_3_0_DMAR_RESERVED_MEMORY_REGION_REPORTING_STRUCTURE;
+
+#define EFI_ACPI_MAX_NUM_OF_DEVICE_SCOPE_PER_ATSR_ENTRY 0x01 // user need to update
+typedef struct {
+ EFI_ACPI_DMAR_ROOT_PORT_ATS_CAPABILITY_REPORTING_STRUCTURE Header;
+ EFI_ACPI_3_0_DMAR_DEVICE_SCOPE_ENTRY_STRUCTURE DeviceScopeEntry[EFI_ACPI_MAX_NUM_OF_DEVICE_SCOPE_PER_ATSR_ENTRY];
+} EFI_ACPI_3_0_DMAR_ROOT_PORT_ATS_CAPABILITY_REPORTING_STRUCTURE;
+
+#define EFI_ACPI_DMAR_DHRD_ENTRY_COUNT 0x1 // user need to update
+#define EFI_ACPI_DMAR_RMRR_ENTRY_COUNT 0x1 // user need to update
+#define EFI_ACPI_DMAR_ATSR_ENTRY_COUNT 0x1 // user need to update
+
+typedef struct {
+ EFI_ACPI_DMAR_DESCRIPTION_TABLE Header;
+
+#if EFI_ACPI_3_0_DMAR_DHRD_ENTRY_COUNT > 0
+ EFI_ACPI_3_0_DMAR_HARDWARE_UNIT_DEFINITION_STRUCTURE Dhrd[EFI_ACPI_DMAR_DHRD_ENTRY_COUNT];
+#endif
+
+#if EFI_ACPI_3_0_DMAR_RMRR_ENTRY_COUNT > 0
+ EFI_ACPI_3_0_DMAR_RESERVED_MEMORY_REGION_REPORTING_STRUCTURE Rmrr[EFI_ACPI_DMAR_RMRR_ENTRY_COUNT];
+#endif
+
+#if EFI_ACPI_3_0_DMAR_ATSR_ENTRY_COUNT > 0
+ EFI_ACPI_3_0_DMAR_ROOT_PORT_ATS_CAPABILITY_REPORTING_STRUCTURE Atsr[EFI_ACPI_DMAR_ATSR_ENTRY_COUNT];
+#endif
+
+} EFI_ACPI_3_0_DMA_REMAPPING_REPORTING_TABLE;
+
+*/
+
+#pragma pack()
+
+#endif
+
diff --git a/EDK/Foundation/Include/IndustryStandard/HighPrecisionEventTimerTable.h b/EDK/Foundation/Include/IndustryStandard/HighPrecisionEventTimerTable.h
new file mode 100644
index 0000000..8c138c5
--- /dev/null
+++ b/EDK/Foundation/Include/IndustryStandard/HighPrecisionEventTimerTable.h
@@ -0,0 +1,62 @@
+/*++
+
+Copyright (c) 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ HighPrecisionEventTimerTable.h
+
+Abstract:
+
+ ACPI high precision event timer table definition, defined at
+ Intel IA-PC HPET (High Precision Event Timers) Specification.
+
+--*/
+
+#ifndef _HIGH_PRECISION_EVENT_TIMER_TABLE_H_
+#define _HIGH_PRECISION_EVENT_TIMER_TABLE_H_
+
+//
+// Include files
+//
+#include "Acpi2_0.h"
+
+//
+// Ensure proper structure formats
+//
+#pragma pack(1)
+//
+// High Precision Event Timer Table header definition.
+//
+typedef struct {
+ EFI_ACPI_DESCRIPTION_HEADER Header;
+ UINT32 EventTimerBlockId;
+ EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE BaseAddressLower32Bit;
+ UINT8 HpetNumber;
+ UINT16 MainCounterMinimumClockTickInPeriodicMode;
+ UINT8 PageProtectionAndOemAttribute;
+} EFI_ACPI_HIGH_PRECISION_EVENT_TIMER_TABLE_HEADER;
+
+//
+// HPET Revision (defined in spec)
+//
+#define EFI_ACPI_HIGH_PRECISION_EVENT_TIMER_TABLE_REVISION 0x01
+
+//
+// Page protection setting
+// Values 3 through 15 are reserved for use by the specification
+//
+#define EFI_ACPI_NO_PAGE_PROTECTION 0
+#define EFI_ACPI_4KB_PAGE_PROTECTION 1
+#define EFI_ACPI_64KB_PAGE_PROTECTION 2
+
+#pragma pack()
+
+#endif
diff --git a/EDK/Foundation/Include/IndustryStandard/IScsiBootFirmwareTable.h b/EDK/Foundation/Include/IndustryStandard/IScsiBootFirmwareTable.h
new file mode 100644
index 0000000..66ba200
--- /dev/null
+++ b/EDK/Foundation/Include/IndustryStandard/IScsiBootFirmwareTable.h
@@ -0,0 +1,146 @@
+/*++
+
+Copyright (c) 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ IScsiBootFirmwareTable.h
+
+Abstract:
+
+ The definition for iSCSI Boot Firmware Table, it's defined in
+ Microsoft iBFT document.
+
+--*/
+
+#ifndef _ISCSI_BOOT_FIRMWARE_TABLE_H_
+#define _ISCSI_BOOT_FIRMWARE_TABLE_H_
+
+#include "Tiano.h"
+#include "Acpi3_0.h"
+
+#define EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_REVISION 0x01
+#define EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_STRUCTURE_ALIGNMENT 8
+
+enum {
+ EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_RESERVED_STRUCTURE_ID = 0,
+ EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_CONTROL_STRUCTURE_ID,
+ EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_INITIATOR_STRUCTURE_ID,
+ EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE_ID,
+ EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE_ID,
+ EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_EXTERNSIONS_STRUCTURE_ID,
+};
+
+enum {
+ IpPrefixOriginOther = 0,
+ IpPrefixOriginManual,
+ IpPrefixOriginWellKnown,
+ IpPrefixOriginDhcp,
+ IpPrefixOriginRouterAdvertisement,
+ IpPrefixOriginUnchanged = 16
+};
+
+#pragma pack(1)
+
+typedef struct {
+ UINT32 Signature;
+ UINT32 Length;
+ UINT8 Revision;
+ UINT8 Checksum;
+ UINT8 OemId[6];
+ UINT64 OemTableId;
+ UINT8 Reserved[24];
+} EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_HEADER;
+
+typedef struct {
+ UINT8 StructureId;
+ UINT8 Version;
+ UINT16 Length;
+ UINT8 Index;
+ UINT8 Flags;
+} EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_STRUCTURE_HEADER;
+
+#define EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_CONTROL_STRUCTURE_VERSION 0x1
+#define EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_CONTROL_STRUCTURE_FLAG_BOOT_FAILOVER 0x1
+
+typedef struct {
+ EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_STRUCTURE_HEADER Header;
+ UINT16 Extensions;
+ UINT16 InitiatorOffset;
+ UINT16 NIC0Offset;
+ UINT16 Target0Offset;
+ UINT16 NIC1Offset;
+ UINT16 Target1Offset;
+} EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_CONTROL_STRUCTURE;
+
+#define EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_INITIATOR_STRUCTURE_VERSION 0x1
+#define EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_INITIATOR_STRUCTURE_FLAG_BLOCK_VALID 0x1
+#define EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_INITIATOR_STRUCTURE_FLAG_BOOT_SELECTED 0x2
+
+typedef struct {
+ EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_STRUCTURE_HEADER Header;
+ EFI_IPv6_ADDRESS ISnsServer;
+ EFI_IPv6_ADDRESS SlpServer;
+ EFI_IPv6_ADDRESS PrimaryRadiusServer;
+ EFI_IPv6_ADDRESS SecondaryRadiusServer;
+ UINT16 IScsiNameLength;
+ UINT16 IScsiNameOffset;
+} EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_INITIATOR_STRUCTURE;
+
+#define EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE_VERSION 0x1
+#define EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE_FLAG_BLOCK_VALID 0x1
+#define EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE_FLAG_BOOT_SELECTED 0x2
+#define EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE_FLAG_GLOBAL 0x4
+
+typedef struct {
+ EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_STRUCTURE_HEADER Header;
+ EFI_IPv6_ADDRESS Ip;
+ UINT8 SubnetMaskPrefixLength;
+ UINT8 Origin;
+ EFI_IPv6_ADDRESS Gateway;
+ EFI_IPv6_ADDRESS PrimaryDns;
+ EFI_IPv6_ADDRESS SecondaryDns;
+ EFI_IPv6_ADDRESS DhcpServer;
+ UINT16 VLanTag;
+ UINT8 Mac[6];
+ UINT16 PciLocation;
+ UINT16 HostNameLength;
+ UINT16 HostNameOffset;
+} EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_NIC_STRUCTURE;
+
+#define EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE_VERSION 0x1
+#define EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE_FLAG_BLOCK_VALID 0x1
+#define EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE_FLAG_BOOT_SELECTED 0x2
+#define EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE_FLAG_RADIUS_CHAP 0x4
+#define EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE_FLAG_RADIUS_RCHAP 0x8
+
+typedef struct {
+ EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_STRUCTURE_HEADER Header;
+ EFI_IPv6_ADDRESS Ip;
+ UINT16 Port;
+ UINT8 BootLun[8];
+ UINT8 CHAPType;
+ UINT8 NicIndex;
+ UINT16 IScsiNameLength;
+ UINT16 IScsiNameOffset;
+ UINT16 CHAPNameLength;
+ UINT16 CHAPNameOffset;
+ UINT16 CHAPSecretLength;
+ UINT16 CHAPSecretOffset;
+ UINT16 ReverseCHAPNameLength;
+ UINT16 ReverseCHAPNameOffset;
+ UINT16 ReverseCHAPSecretLength;
+ UINT16 ReverseCHAPSecretOffset;
+} EFI_ACPI_ISCSI_BOOT_FIRMWARE_TABLE_TARGET_STRUCTURE;
+
+#pragma pack()
+
+#endif
+
diff --git a/EDK/Foundation/Include/IndustryStandard/LegacyBiosMpTable.h b/EDK/Foundation/Include/IndustryStandard/LegacyBiosMpTable.h
new file mode 100644
index 0000000..48dca83
--- /dev/null
+++ b/EDK/Foundation/Include/IndustryStandard/LegacyBiosMpTable.h
@@ -0,0 +1,283 @@
+/*++
+
+Copyright (c) 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ LegacyBiosMpTable.h
+
+Abstract:
+ Defives data structures per Multi Processor Specification Ver 1.4.
+
+--*/
+
+#ifndef LEGACY_BIOS_MPTABLE_H_
+#define LEGACY_BIOS_MPTABLE_H_
+
+#include "Tiano.h"
+
+#define EFI_LEGACY_MP_TABLE_REV_1_4 0x04
+
+//
+// Define MP table structures. All are packed.
+//
+#pragma pack(push, 1)
+
+#define EFI_LEGACY_MP_TABLE_FLOATING_POINTER_SIGNATURE EFI_SIGNATURE_32 ('_', 'M', 'P', '_')
+typedef struct {
+ UINT32 Signature;
+ UINT32 PhysicalAddress;
+ UINT8 Length;
+ UINT8 SpecRev;
+ UINT8 Checksum;
+ UINT8 FeatureByte1;
+ struct {
+ UINT32 Reserved1 : 6;
+ UINT32 MutipleClk : 1;
+ UINT32 Imcr : 1;
+ UINT32 Reserved2 : 24;
+ } FeatureByte2_5;
+} EFI_LEGACY_MP_TABLE_FLOATING_POINTER;
+
+#define EFI_LEGACY_MP_TABLE_HEADER_SIGNATURE EFI_SIGNATURE_32 ('P', 'C', 'M', 'P')
+typedef struct {
+ UINT32 Signature;
+ UINT16 BaseTableLength;
+ UINT8 SpecRev;
+ UINT8 Checksum;
+ CHAR8 OemId[8];
+ CHAR8 OemProductId[12];
+ UINT32 OemTablePointer;
+ UINT16 OemTableSize;
+ UINT16 EntryCount;
+ UINT32 LocalApicAddress;
+ UINT16 ExtendedTableLength;
+ UINT8 ExtendedChecksum;
+ UINT8 Reserved;
+} EFI_LEGACY_MP_TABLE_HEADER;
+
+typedef struct {
+ UINT8 EntryType;
+} EFI_LEGACY_MP_TABLE_ENTRY_TYPE;
+
+//
+// Entry Type 0: Processor.
+//
+#define EFI_LEGACY_MP_TABLE_ENTRY_TYPE_PROCESSOR 0x00
+typedef struct {
+ UINT8 EntryType;
+ UINT8 Id;
+ UINT8 Ver;
+ struct {
+ UINT8 Enabled : 1;
+ UINT8 Bsp : 1;
+ UINT8 Reserved : 6;
+ } Flags;
+ struct {
+ UINT32 Stepping : 4;
+ UINT32 Model : 4;
+ UINT32 Family : 4;
+ UINT32 Reserved : 20;
+ } Signature;
+ struct {
+ UINT32 Fpu : 1;
+ UINT32 Reserved1 : 6;
+ UINT32 Mce : 1;
+ UINT32 Cx8 : 1;
+ UINT32 Apic : 1;
+ UINT32 Reserved2 : 22;
+ } Features;
+ UINT32 Reserved1;
+ UINT32 Reserved2;
+} EFI_LEGACY_MP_TABLE_ENTRY_PROCESSOR;
+
+//
+// Entry Type 1: Bus.
+//
+#define EFI_LEGACY_MP_TABLE_ENTRY_TYPE_BUS 0x01
+typedef struct {
+ UINT8 EntryType;
+ UINT8 Id;
+ CHAR8 TypeString[6];
+} EFI_LEGACY_MP_TABLE_ENTRY_BUS;
+
+#define EFI_LEGACY_MP_TABLE_ENTRY_BUS_STRING_CBUS "CBUS " // Corollary CBus
+#define EFI_LEGACY_MP_TABLE_ENTRY_BUS_STRING_CBUSII "CBUSII" // Corollary CBUS II
+#define EFI_LEGACY_MP_TABLE_ENTRY_BUS_STRING_EISA "EISA " // Extended ISA
+#define EFI_LEGACY_MP_TABLE_ENTRY_BUS_STRING_FUTURE "FUTURE" // IEEE FutureBus
+#define EFI_LEGACY_MP_TABLE_ENTRY_BUS_STRING_INTERN "INTERN" // Internal bus
+#define EFI_LEGACY_MP_TABLE_ENTRY_BUS_STRING_ISA "ISA " // Industry Standard Architecture
+#define EFI_LEGACY_MP_TABLE_ENTRY_BUS_STRING_MBI "MBI " // Multibus I
+#define EFI_LEGACY_MP_TABLE_ENTRY_BUS_STRING_MBII "MBII " // Multibus II
+#define EFI_LEGACY_MP_TABLE_ENTRY_BUS_STRING_MCA "MCA " // Micro Channel Architecture
+#define EFI_LEGACY_MP_TABLE_ENTRY_BUS_STRING_MPI "MPI " // MPI
+#define EFI_LEGACY_MP_TABLE_ENTRY_BUS_STRING_MPSA "MPSA " // MPSA
+#define EFI_LEGACY_MP_TABLE_ENTRY_BUS_STRING_NUBUS "NUBUS " // Apple Macintosh NuBus
+#define EFI_LEGACY_MP_TABLE_ENTRY_BUS_STRING_PCI "PCI " // Peripheral Component Interconnect
+#define EFI_LEGACY_MP_TABLE_ENTRY_BUS_STRING_PCMCIA "PCMCIA" // PC Memory Card International Assoc.
+#define EFI_LEGACY_MP_TABLE_ENTRY_BUS_STRING_TC "TC " // DEC TurboChannel
+#define EFI_LEGACY_MP_TABLE_ENTRY_BUS_STRING_VL "VL " // VESA Local Bus
+#define EFI_LEGACY_MP_TABLE_ENTRY_BUS_STRING_VME "VME " // VMEbus
+#define EFI_LEGACY_MP_TABLE_ENTRY_BUS_STRING_XPRESS "XPRESS" // Express System Bus
+//
+// Entry Type 2: I/O APIC.
+//
+#define EFI_LEGACY_MP_TABLE_ENTRY_TYPE_IOAPIC 0x02
+typedef struct {
+ UINT8 EntryType;
+ UINT8 Id;
+ UINT8 Ver;
+ struct {
+ UINT8 Enabled : 1;
+ UINT8 Reserved : 7;
+ } Flags;
+ UINT32 Address;
+} EFI_LEGACY_MP_TABLE_ENTRY_IOAPIC;
+
+//
+// Entry Type 3: I/O Interrupt Assignment.
+//
+#define EFI_LEGACY_MP_TABLE_ENTRY_TYPE_IO_INT 0x03
+typedef struct {
+ UINT8 EntryType;
+ UINT8 IntType;
+ struct {
+ UINT16 Polarity : 2;
+ UINT16 Trigger : 2;
+ UINT16 Reserved : 12;
+ } Flags;
+ UINT8 SourceBusId;
+ union {
+ struct {
+ UINT8 IntNo : 2;
+ UINT8 Dev : 5;
+ UINT8 Reserved : 1;
+ } fields;
+ UINT8 byte;
+ } SourceBusIrq;
+ UINT8 DestApicId;
+ UINT8 DestApicIntIn;
+} EFI_LEGACY_MP_TABLE_ENTRY_IO_INT;
+
+typedef enum {
+ EfiLegacyMpTableEntryIoIntTypeInt = 0,
+ EfiLegacyMpTableEntryIoIntTypeNmi = 1,
+ EfiLegacyMpTableEntryIoIntTypeSmi = 2,
+ EfiLegacyMpTableEntryIoIntTypeExtInt= 3,
+} EFI_LEGACY_MP_TABLE_ENTRY_IO_INT_TYPE;
+
+typedef enum {
+ EfiLegacyMpTableEntryIoIntFlagsPolaritySpec = 0x0,
+ EfiLegacyMpTableEntryIoIntFlagsPolarityActiveHigh = 0x1,
+ EfiLegacyMpTableEntryIoIntFlagsPolarityReserved = 0x2,
+ EfiLegacyMpTableEntryIoIntFlagsPolarityActiveLow = 0x3,
+} EFI_LEGACY_MP_TABLE_ENTRY_IO_INT_FLAGS_POLARITY;
+
+typedef enum {
+ EfiLegacyMpTableEntryIoIntFlagsTriggerSpec = 0x0,
+ EfiLegacyMpTableEntryIoIntFlagsTriggerEdge = 0x1,
+ EfiLegacyMpTableEntryIoIntFlagsTriggerReserved = 0x2,
+ EfiLegacyMpTableEntryIoIntFlagsTriggerLevel = 0x3,
+} EFI_LEGACY_MP_TABLE_ENTRY_IO_INT_FLAGS_TRIGGER;
+
+//
+// Entry Type 4: Local Interrupt Assignment.
+//
+#define EFI_LEGACY_MP_TABLE_ENTRY_TYPE_LOCAL_INT 0x04
+typedef struct {
+ UINT8 EntryType;
+ UINT8 IntType;
+ struct {
+ UINT16 Polarity : 2;
+ UINT16 Trigger : 2;
+ UINT16 Reserved : 12;
+ } Flags;
+ UINT8 SourceBusId;
+ UINT8 SourceBusIrq;
+ UINT8 DestApicId;
+ UINT8 DestApicIntIn;
+} EFI_LEGACY_MP_TABLE_ENTRY_LOCAL_INT;
+
+typedef enum {
+ EfiLegacyMpTableEntryLocalIntTypeInt = 0,
+ EfiLegacyMpTableEntryLocalIntTypeNmi = 1,
+ EfiLegacyMpTableEntryLocalIntTypeSmi = 2,
+ EfiLegacyMpTableEntryLocalIntTypeExtInt = 3,
+} EFI_LEGACY_MP_TABLE_ENTRY_LOCAL_INT_TYPE;
+
+typedef enum {
+ EfiLegacyMpTableEntryLocalIntFlagsPolaritySpec = 0x0,
+ EfiLegacyMpTableEntryLocalIntFlagsPolarityActiveHigh= 0x1,
+ EfiLegacyMpTableEntryLocalIntFlagsPolarityReserved = 0x2,
+ EfiLegacyMpTableEntryLocalIntFlagsPolarityActiveLow = 0x3,
+} EFI_LEGACY_MP_TABLE_ENTRY_LOCAL_INT_FLAGS_POLARITY;
+
+typedef enum {
+ EfiLegacyMpTableEntryLocalIntFlagsTriggerSpec = 0x0,
+ EfiLegacyMpTableEntryLocalIntFlagsTriggerEdge = 0x1,
+ EfiLegacyMpTableEntryLocalIntFlagsTriggerReserved = 0x2,
+ EfiLegacyMpTableEntryLocalIntFlagsTriggerLevel = 0x3,
+} EFI_LEGACY_MP_TABLE_ENTRY_LOCAL_INT_FLAGS_TRIGGER;
+
+//
+// Entry Type 128: System Address Space Mapping.
+//
+#define EFI_LEGACY_MP_TABLE_ENTRY_EXT_TYPE_SYS_ADDR_SPACE_MAPPING 0x80
+typedef struct {
+ UINT8 EntryType;
+ UINT8 Length;
+ UINT8 BusId;
+ UINT8 AddressType;
+ UINT64 AddressBase;
+ UINT64 AddressLength;
+} EFI_LEGACY_MP_TABLE_ENTRY_EXT_SYS_ADDR_SPACE_MAPPING;
+
+typedef enum {
+ EfiLegacyMpTableEntryExtSysAddrSpaceMappingIo = 0,
+ EfiLegacyMpTableEntryExtSysAddrSpaceMappingMemory = 1,
+ EfiLegacyMpTableEntryExtSysAddrSpaceMappingPrefetch = 2,
+} EFI_LEGACY_MP_TABLE_ENTRY_EXT_SYS_ADDR_SPACE_MAPPING_TYPE;
+
+//
+// Entry Type 129: Bus Hierarchy.
+//
+#define EFI_LEGACY_MP_TABLE_ENTRY_EXT_TYPE_BUS_HIERARCHY 0x81
+typedef struct {
+ UINT8 EntryType;
+ UINT8 Length;
+ UINT8 BusId;
+ struct {
+ UINT8 SubtractiveDecode : 1;
+ UINT8 Reserved : 7;
+ } BusInfo;
+ UINT8 ParentBus;
+ UINT8 Reserved1;
+ UINT8 Reserved2;
+ UINT8 Reserved3;
+} EFI_LEGACY_MP_TABLE_ENTRY_EXT_BUS_HIERARCHY;
+
+//
+// Entry Type 130: Compatibility Bus Address Space Modifier.
+//
+#define EFI_LEGACY_MP_TABLE_ENTRY_EXT_TYPE_COMPAT_BUS_ADDR_SPACE_MODIFIER 0x82
+typedef struct {
+ UINT8 EntryType;
+ UINT8 Length;
+ UINT8 BusId;
+ struct {
+ UINT8 RangeMode : 1;
+ UINT8 Reserved : 7;
+ } AddrMode;
+ UINT32 PredefinedRangeList;
+} EFI_LEGACY_MP_TABLE_ENTRY_EXT_COMPAT_BUS_ADDR_SPACE_MODIFIER;
+
+#pragma pack(pop)
+
+#endif
diff --git a/EDK/Foundation/Include/IndustryStandard/MemoryMappedConfigurationSpaceAccessTable.h b/EDK/Foundation/Include/IndustryStandard/MemoryMappedConfigurationSpaceAccessTable.h
new file mode 100644
index 0000000..a933a80
--- /dev/null
+++ b/EDK/Foundation/Include/IndustryStandard/MemoryMappedConfigurationSpaceAccessTable.h
@@ -0,0 +1,56 @@
+/*++
+
+Copyright (c) 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ MemoryMappedConfigurationSpaceAccessTable.h
+
+Abstract:
+
+ ACPI memory mapped configuration space access table definition, defined at
+ in the PCI Firmware Specification, version 3.0.
+ Specification is available at http://www.pcisig.com.
+
+--*/
+
+#ifndef _MEMORY_MAPPED_CONFIGURATION_SPACE_ACCESS_TABLE_H_
+#define _MEMORY_MAPPED_CONFIGURATION_SPACE_ACCESS_TABLE_H_
+
+//
+// Include files
+//
+#include "AcpiCommon.h"
+
+//
+// Ensure proper structure formats
+//
+#pragma pack(1)
+//
+// Memory Mapped Configuration Space Access Table (MCFG)
+// This table is a basic description table header followed by
+// a number of base address allocation structures.
+//
+typedef struct {
+ UINT64 BaseAddress;
+ UINT16 PciSegmentGroupNumber;
+ UINT8 StartBusNumber;
+ UINT8 EndBusNumber;
+ UINT32 Reserved;
+} EFI_ACPI_MEMORY_MAPPED_ENHANCED_CONFIGURATION_SPACE_BASE_ADDRESS_ALLOCATION_STRUCTURE;
+
+//
+// MCFG Revision (defined in spec)
+//
+#define EFI_ACPI_MEMORY_MAPPED_CONFIGURATION_SPACE_ACCESS_TABLE_REVISION 0x01
+
+#pragma pack()
+
+#endif
diff --git a/EDK/Foundation/Include/IndustryStandard/SdramSpd.h b/EDK/Foundation/Include/IndustryStandard/SdramSpd.h
new file mode 100644
index 0000000..c570615
--- /dev/null
+++ b/EDK/Foundation/Include/IndustryStandard/SdramSpd.h
@@ -0,0 +1,73 @@
+/*++
+
+Copyright (c) 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ SdramSpd.h
+
+Abstract:
+
+ This file contains definitions for the SPD fields on an SDRAM.
+
+--*/
+
+#ifndef _SDRAM_SPD_H
+#define _SDRAM_SPD_H
+
+//
+// SDRAM SPD field definitions
+//
+#define SPD_MEMORY_TYPE 2
+#define SPD_SDRAM_ROW_ADDR 3
+#define SPD_SDRAM_COL_ADDR 4
+#define SPD_SDRAM_MODULE_ROWS 5
+#define SPD_SDRAM_MODULE_DATA_WIDTH_LSB 6
+#define SPD_SDRAM_MODULE_DATA_WIDTH_MSB 7
+#define SPD_SDRAM_ECC_SUPPORT 11
+#define SPD_SDRAM_REFRESH 12
+#define SPD_SDRAM_WIDTH 13
+#define SPD_SDRAM_ERROR_WIDTH 14
+#define SPD_SDRAM_BURST_LENGTH 16
+#define SPD_SDRAM_NO_OF_BANKS 17
+#define SPD_SDRAM_CAS_LATENCY 18
+#define SPD_SDRAM_MODULE_ATTR 21
+
+#define SPD_SDRAM_TCLK1_PULSE 9 // cycle time for highest cas latency
+#define SPD_SDRAM_TAC1_PULSE 10 // access time for highest cas latency
+#define SPD_SDRAM_TCLK2_PULSE 23 // cycle time for 2nd highest cas latency
+#define SPD_SDRAM_TAC2_PULSE 24 // access time for 2nd highest cas latency
+#define SPD_SDRAM_TCLK3_PULSE 25 // cycle time for 3rd highest cas latency
+#define SPD_SDRAM_TAC3_PULSE 26 // access time for 3rd highest cas latency
+#define SPD_SDRAM_MIN_PRECHARGE 27
+#define SPD_SDRAM_ACTIVE_MIN 28
+#define SPD_SDRAM_RAS_CAS 29
+#define SPD_SDRAM_RAS_PULSE 30
+#define SPD_SDRAM_DENSITY 31
+
+//
+// Memory Type Definitions
+//
+#define SPD_VAL_SDR_TYPE 4 // SDR SDRAM memory
+#define SPD_VAL_DDR_TYPE 7 // DDR SDRAM memory
+#define SPD_VAL_DDR2_TYPE 8 // DDR2 SDRAM memory
+//
+// ECC Type Definitions
+//
+#define SPD_ECC_TYPE_NONE 0x00 // No error checking
+#define SPD_ECC_TYPE_PARITY 0x01 // No error checking
+#define SPD_ECC_TYPE_ECC 0x02 // Error checking only
+//
+// Module Attributes (Bit positions)
+//
+#define SPD_BUFFERED 0x01
+#define SPD_REGISTERED 0x02
+
+#endif
diff --git a/EDK/Foundation/Include/IndustryStandard/ServerProcessorManagementInterfaceTable.h b/EDK/Foundation/Include/IndustryStandard/ServerProcessorManagementInterfaceTable.h
new file mode 100644
index 0000000..4bd3b98
--- /dev/null
+++ b/EDK/Foundation/Include/IndustryStandard/ServerProcessorManagementInterfaceTable.h
@@ -0,0 +1,80 @@
+/*++
+
+Copyright (c) 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ ServerProcessorManagementInterfaceTable.h
+
+Abstract:
+
+ ACPI Server Processor Management Interface Table SPMI as described
+ in the IPMI2.0 Specification Revistion 1.5
+
+--*/
+
+#ifndef _SERVER_PROCESSOR_MANAGEMENT_INTERFACE_TABLE_H_
+#define _SERVER_PROCESSOR_MANAGEMENT_INTERFACE_TABLE_H_
+
+#include "Acpi2_0.h"
+
+//
+// Ensure proper structure formats
+//
+#pragma pack (1)
+
+//
+// Server Processor Management Interface Table definition.
+//
+typedef struct {
+ EFI_ACPI_DESCRIPTION_HEADER Header;
+ UINT8 Reserved_36;
+ UINT8 InterfaceType;
+ UINT16 SpecificationRevision;
+ UINT8 InterruptType;
+ UINT8 GPE;
+ UINT8 Reserved_42;
+ UINT8 PCIDeviceFlag;
+ UINT32 GlobalSystemInterrupt;
+ EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE BaseAddress;
+ UINT8 PCISegmentGroup_UID1;
+ UINT8 PCIBusNumber_UID2;
+ UINT8 PCIDeviceNumber_UID3;
+ UINT8 PCIFunctionNumber_UID4;
+} EFI_ACPI_SERVER_PROCESSOR_MANAGEMENT_INTERFACE_DESCRIPTION_TABLE;
+
+#pragma pack ()
+
+//
+// SPMI Revision
+//
+#define EFI_ACPI_SERVER_PROCESSOR_MANAGEMENT_INTERFACE_TABLE_REVISION 0x05
+
+//
+// Interface Type
+//
+#define EFI_ACPI_SPMI_INTERFACE_TYPE_RESERVED 0
+#define EFI_ACPI_SPMI_INTERFACE_TYPE_KCS 1
+#define EFI_ACPI_SPMI_INTERFACE_TYPE_SMIC 2
+#define EFI_ACPI_SPMI_INTERFACE_TYPE_BT 3
+#define EFI_ACPI_SPMI_INTERFACE_TYPE_SSIF 4
+
+//
+// SPMI Specfication Revision
+//
+#define EFI_ACPI_SPMI_SPECIFICATION_REVISION 0x0150
+
+//
+// SPMI Interrupt Type
+//
+#define EFI_ACPI_SPMI_INTERRUPT_TYPE_SCI 0x1
+#define EFI_ACPI_SPMI_INTERRUPT_TYPE_IOAPIC 0x2
+
+#endif
diff --git a/EDK/Foundation/Include/IndustryStandard/Smbios.h b/EDK/Foundation/Include/IndustryStandard/Smbios.h
new file mode 100644
index 0000000..554cc99
--- /dev/null
+++ b/EDK/Foundation/Include/IndustryStandard/Smbios.h
@@ -0,0 +1,691 @@
+/*++
+
+Copyright (c) 2007 - 2011, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Smbios.h
+
+Abstract:
+
+--*/
+
+#ifndef _SMBIOS_TABLE_H_
+#define _SMBIOS_TABLE_H_
+
+#include "Tiano.h"
+
+//
+// Reference SMBIOS 2.6, chapter 3.1.2.
+// For v2.1 and later, handle values in the range 0FF00h to 0FFFFh are reserved for
+// use by this specification.
+//
+#define SMBIOS_HANDLE_RESERVED_BEGIN 0xFF00
+
+//
+// Reference SMBIOS 2.7, chapter 6.1.2.
+// The UEFI Platform Initialization Specification reserves handle number FFFEh for its
+// EFI_SMBIOS_PROTOCOL.Add() function to mean "assign an unused handle number automatically."
+// This number is not used for any other purpose by the SMBIOS specification.
+//
+#define SMBIOS_HANDLE_PI_RESERVED 0xFFFE
+
+//
+// Reference SMBIOS 2.6, chapter 3.1.3
+// Each text string is limited to 64 significant characters due to system MIF limitations
+// Reference SMBIOS 2.7, chapter 6.1.3.
+// It will have no limit on the length of each individual text string.
+//
+#define SMBIOS_STRING_MAX_LENGTH 64
+
+//
+// Inactive type is added from SMBIOS 2.2. Reference SMBIOS 2.6, chapter 3.3.43.
+// Upper-level software that interprets the SMBIOS structure-table should bypass an
+// Inactive structure just like a structure type that the software does not recognize.
+//
+#define SMBIOS_TYPE_INACTIVE 0x007E
+
+//
+// End-of-table type is added from SMBIOS 2.2. Reference SMBIOS 2.6, chapter 3.3.44.
+// The end-of-table indicator is used in the last physical structure in a table
+//
+#define SMBIOS_TYPE_END_OF_TABLE 0x007F
+
+#pragma pack(1)
+
+typedef UINT8 SMBIOS_TABLE_STRING;
+
+typedef struct {
+ UINT8 AnchorString[4];
+ UINT8 EntryPointStructureChecksum;
+ UINT8 EntryPointLength;
+ UINT8 MajorVersion;
+ UINT8 MinorVersion;
+ UINT16 MaxStructureSize;
+ UINT8 EntryPointRevision;
+ UINT8 FormattedArea[5];
+ UINT8 IntermediateAnchorString[5];
+ UINT8 IntermediateChecksum;
+ UINT16 TableLength;
+ UINT32 TableAddress;
+ UINT16 NumberOfSmbiosStructures;
+ UINT8 SmbiosBcdRevision;
+} SMBIOS_TABLE_STRUCTURE;
+
+typedef struct {
+ UINT8 Type;
+ UINT8 Length;
+ UINT16 Handle;
+} SMBIOS_TABLE_HEADER;
+
+typedef struct {
+ SMBIOS_TABLE_HEADER Hdr;
+ SMBIOS_TABLE_STRING Vendor;
+ SMBIOS_TABLE_STRING BiosVersion;
+ UINT16 BiosSegment;
+ SMBIOS_TABLE_STRING BiosReleaseDate;
+ UINT8 BiosSize;
+ UINT64 BiosCharacteristics;
+ UINT8 BIOSCharacteristicsExtensionBytes[2];
+ UINT8 SystemBiosMajorRelease;
+ UINT8 SystemBiosMinorRelease;
+ UINT8 EmbeddedControllerFirmwareMajorRelease;
+ UINT8 EmbeddedControllerFirmwareMinorRelease;
+} SMBIOS_TABLE_TYPE0;
+
+typedef struct {
+ SMBIOS_TABLE_HEADER Hdr;
+ SMBIOS_TABLE_STRING Manufacturer;
+ SMBIOS_TABLE_STRING ProductName;
+ SMBIOS_TABLE_STRING Version;
+ SMBIOS_TABLE_STRING SerialNumber;
+ EFI_GUID Uuid;
+ UINT8 WakeUpType;
+ SMBIOS_TABLE_STRING SKUNumber;
+ SMBIOS_TABLE_STRING Family;
+} SMBIOS_TABLE_TYPE1;
+
+typedef struct {
+ SMBIOS_TABLE_HEADER Hdr;
+ SMBIOS_TABLE_STRING Manufacturer;
+ SMBIOS_TABLE_STRING ProductName;
+ SMBIOS_TABLE_STRING Version;
+ SMBIOS_TABLE_STRING SerialNumber;
+ SMBIOS_TABLE_STRING AssetTag;
+ UINT8 FeatureFlag;
+ SMBIOS_TABLE_STRING LocationInChassis;
+ UINT16 ChassisHandle;
+ UINT8 BoardType;
+ UINT8 NumberOfContainedObjectHandles;
+ UINT16 ContainedObjectHandles[1];
+} SMBIOS_TABLE_TYPE2;
+
+typedef struct {
+ UINT8 ContainedElementType;
+ UINT8 ContainedElementMinimum;
+ UINT8 ContainedElementMaximum;
+} CONTAINED_ELEMENT;
+
+typedef struct {
+ SMBIOS_TABLE_HEADER Hdr;
+ SMBIOS_TABLE_STRING Manufacturer;
+ UINT8 Type;
+ SMBIOS_TABLE_STRING Version;
+ SMBIOS_TABLE_STRING SerialNumber;
+ SMBIOS_TABLE_STRING AssetTag;
+ UINT8 BootupState;
+ UINT8 PowerSupplyState;
+ UINT8 ThermalState;
+ UINT8 SecurityStatus;
+ UINT8 OemDefined[4];
+ UINT8 Height;
+ UINT8 NumberofPowerCords;
+ UINT8 ContainedElementCount;
+ UINT8 ContainedElementRecordLength;
+ CONTAINED_ELEMENT ContainedElements[1];
+} SMBIOS_TABLE_TYPE3;
+
+typedef struct {
+ SMBIOS_TABLE_HEADER Hdr;
+ UINT8 Socket;
+ UINT8 ProcessorType;
+ UINT8 ProcessorFamily;
+ SMBIOS_TABLE_STRING ProcessorManufacture;
+ UINT8 ProcessorId[8];
+ SMBIOS_TABLE_STRING ProcessorVersion;
+ UINT8 Voltage;
+ UINT16 ExternalClock;
+ UINT16 MaxSpeed;
+ UINT16 CurrentSpeed;
+ UINT8 Status;
+ UINT8 ProcessorUpgrade;
+ UINT16 L1CacheHandle;
+ UINT16 L2CacheHandle;
+ UINT16 L3CacheHandle;
+ SMBIOS_TABLE_STRING SerialNumber;
+ SMBIOS_TABLE_STRING AssetTag;
+ SMBIOS_TABLE_STRING PartNumber;
+ //
+ // Add for smbios 2.5
+ //
+ UINT8 CoreCount;
+ UINT8 EnabledCoreCount;
+ UINT8 ThreadCount;
+ UINT16 ProcessorCharacteristics;
+ //
+ // Add for smbios 2.6
+ //
+ UINT16 ProcessorFamily2;
+} SMBIOS_TABLE_TYPE4;
+
+typedef struct {
+ SMBIOS_TABLE_HEADER Hdr;
+ UINT8 ErrDetectMethod;
+ UINT8 ErrCorrectCapability;
+ UINT8 SupportInterleave;
+ UINT8 CurrentInterleave;
+ UINT8 MaxMemoryModuleSize;
+ UINT16 SupportSpeed;
+ UINT16 SupportMemoryType;
+ UINT8 MemoryModuleVoltage;
+ UINT8 AssociatedMemorySlotNum;
+ UINT16 MemoryModuleConfigHandles[1];
+// UINT8 EnableErrCorrectCapabilities;
+} SMBIOS_TABLE_TYPE5;
+
+typedef struct {
+ SMBIOS_TABLE_HEADER Hdr;
+ SMBIOS_TABLE_STRING SocketDesignation;
+ UINT8 BankConnections;
+ UINT8 CurrentSpeed;
+ UINT16 CurrentMemoryType;
+ UINT8 InstalledSize;
+ UINT8 EnabledSize;
+ UINT8 ErrorStatus;
+} SMBIOS_TABLE_TYPE6;
+
+typedef struct {
+ SMBIOS_TABLE_HEADER Hdr;
+ SMBIOS_TABLE_STRING SocketDesignation;
+ UINT16 CacheConfiguration;
+ UINT16 MaximumCacheSize;
+ UINT16 InstalledSize;
+ UINT16 SupportedSRAMType;
+ UINT16 CurrentSRAMType;
+ UINT8 CacheSpeed;
+ UINT8 ErrorCorrectionType;
+ UINT8 SystemCacheType;
+ UINT8 Associativity;
+} SMBIOS_TABLE_TYPE7;
+
+typedef struct {
+ SMBIOS_TABLE_HEADER Hdr;
+ SMBIOS_TABLE_STRING InternalReferenceDesignator;
+ UINT8 InternalConnectorType;
+ SMBIOS_TABLE_STRING ExternalReferenceDesignator;
+ UINT8 ExternalConnectorType;
+ UINT8 PortType;
+} SMBIOS_TABLE_TYPE8;
+
+typedef struct {
+ SMBIOS_TABLE_HEADER Hdr;
+ SMBIOS_TABLE_STRING SlotDesignation;
+ UINT8 SlotType;
+ UINT8 SlotDataBusWidth;
+ UINT8 CurrentUsage;
+ UINT8 SlotLength;
+ UINT16 SlotID;
+ UINT8 SlotCharacteristics1;
+ UINT8 SlotCharacteristics2;
+ //
+ // Add for smbios 2.6
+ //
+ UINT16 SegmentGroupNum;
+ UINT8 BusNum;
+ UINT8 DevFuncNum;
+} SMBIOS_TABLE_TYPE9;
+
+typedef struct {
+ UINT8 DeviceType;
+ SMBIOS_TABLE_STRING DescriptionString;
+} DEVICE_STRUCT;
+
+typedef struct {
+ SMBIOS_TABLE_HEADER Hdr;
+ DEVICE_STRUCT Device[1];
+} SMBIOS_TABLE_TYPE10;
+
+typedef struct {
+ SMBIOS_TABLE_HEADER Hdr;
+ UINT8 StringCount;
+} SMBIOS_TABLE_TYPE11;
+
+typedef struct {
+ SMBIOS_TABLE_HEADER Hdr;
+ UINT8 StringCount;
+} SMBIOS_TABLE_TYPE12;
+
+typedef struct {
+ SMBIOS_TABLE_HEADER Hdr;
+ UINT8 InstallableLanguages;
+ UINT8 Flags;
+ UINT8 reserved[15];
+ SMBIOS_TABLE_STRING CurrentLanguages;
+} SMBIOS_TABLE_TYPE13;
+
+typedef struct {
+ UINT8 ItemType;
+ UINT16 ItemHandle;
+} GROUP_STRUCT;
+
+typedef struct {
+ SMBIOS_TABLE_HEADER Hdr;
+ SMBIOS_TABLE_STRING GroupName;
+ GROUP_STRUCT Group[1];
+} SMBIOS_TABLE_TYPE14;
+
+typedef struct {
+ UINT8 LogType;
+ UINT8 DataFormatType;
+} EVENT_LOG_TYPE;
+
+typedef struct {
+ SMBIOS_TABLE_HEADER Hdr;
+ UINT16 LogAreaLength;
+ UINT16 LogHeaderStartOffset;
+ UINT16 LogDataStartOffset;
+ UINT8 AccessMethod;
+ UINT8 LogStatus;
+ UINT32 LogChangeToken;
+ UINT32 AccessMethodAddress;
+ UINT8 LogHeaderFormat;
+ UINT8 NumberOfSupportedLogTypeDescriptors;
+ UINT8 LengthOfLogTypeDescriptor;
+ EVENT_LOG_TYPE EventLogTypeDescriptors[1];
+} SMBIOS_TABLE_TYPE15;
+
+typedef struct {
+ SMBIOS_TABLE_HEADER Hdr;
+ UINT8 Location;
+ UINT8 Use;
+ UINT8 MemoryErrorCorrection;
+ UINT32 MaximumCapacity;
+ UINT16 MemoryErrorInformationHandle;
+ UINT16 NumberOfMemoryDevices;
+ //
+ // Add for smbios 2.7
+ //
+ UINT64 ExtendedMaximumCapacity;
+} SMBIOS_TABLE_TYPE16;
+
+typedef struct {
+ SMBIOS_TABLE_HEADER Hdr;
+ UINT16 MemoryArrayHandle;
+ UINT16 MemoryErrorInformationHandle;
+ UINT16 TotalWidth;
+ UINT16 DataWidth;
+ UINT16 Size;
+ UINT8 FormFactor;
+ UINT8 DeviceSet;
+ SMBIOS_TABLE_STRING DeviceLocator;
+ SMBIOS_TABLE_STRING BankLocator;
+ UINT8 MemoryType;
+ UINT16 TypeDetail;
+ UINT16 Speed;
+ SMBIOS_TABLE_STRING Manufacturer;
+ SMBIOS_TABLE_STRING SerialNumber;
+ SMBIOS_TABLE_STRING AssetTag;
+ SMBIOS_TABLE_STRING PartNumber;
+ //
+ // Add for smbios 2.6
+ //
+ UINT8 Attributes;
+ //
+ // Add for smbios 2.7
+ //
+ UINT32 ExtendedSize;
+ UINT16 ConfiguredMemoryClockSpeed;
+} SMBIOS_TABLE_TYPE17;
+
+typedef struct {
+ SMBIOS_TABLE_HEADER Hdr;
+ UINT8 ErrorType;
+ UINT8 ErrorGranularity;
+ UINT8 ErrorOperation;
+ UINT32 VendorSyndrome;
+ UINT32 MemoryArrayErrorAddress;
+ UINT32 DeviceErrorAddress;
+ UINT32 ErrorResolution;
+} SMBIOS_TABLE_TYPE18;
+
+typedef struct {
+ SMBIOS_TABLE_HEADER Hdr;
+ UINT32 StartingAddress;
+ UINT32 EndingAddress;
+ UINT16 MemoryArrayHandle;
+ UINT8 PartitionWidth;
+ //
+ // Add for smbios 2.7
+ //
+ UINT64 ExtendedStartingAddress;
+ UINT64 ExtendedEndingAddress;
+} SMBIOS_TABLE_TYPE19;
+
+typedef struct {
+ SMBIOS_TABLE_HEADER Hdr;
+ UINT32 StartingAddress;
+ UINT32 EndingAddress;
+ UINT16 MemoryDeviceHandle;
+ UINT16 MemoryArrayMappedAddressHandle;
+ UINT8 PartitionRowPosition;
+ UINT8 InterleavePosition;
+ UINT8 InterleavedDataDepth;
+ //
+ // Add for smbios 2.7
+ //
+ UINT64 ExtendedStartingAddress;
+ UINT64 ExtendedEndingAddress;
+} SMBIOS_TABLE_TYPE20;
+
+typedef struct {
+ SMBIOS_TABLE_HEADER Hdr;
+ UINT8 Type;
+ UINT8 Interface;
+ UINT8 NumberOfButtons;
+} SMBIOS_TABLE_TYPE21;
+
+typedef struct {
+ SMBIOS_TABLE_HEADER Hdr;
+ SMBIOS_TABLE_STRING Location;
+ SMBIOS_TABLE_STRING Manufacturer;
+ SMBIOS_TABLE_STRING ManufactureDate;
+ SMBIOS_TABLE_STRING SerialNumber;
+ SMBIOS_TABLE_STRING DeviceName;
+ UINT8 DeviceChemistry;
+ UINT16 DeviceCapacity;
+ UINT16 DesignVoltage;
+ SMBIOS_TABLE_STRING SBDSVersionNumber;
+ UINT8 MaximumErrorInBatteryData;
+ UINT16 SBDSSerialNumber;
+ UINT16 SBDSManufactureDate;
+ SMBIOS_TABLE_STRING SBDSDeviceChemistry;
+ UINT8 DesignCapacityMultiplier;
+ UINT32 OEMSpecific;
+} SMBIOS_TABLE_TYPE22;
+
+typedef struct {
+ SMBIOS_TABLE_HEADER Hdr;
+ UINT8 Capabilities;
+ UINT16 ResetCount;
+ UINT16 ResetLimit;
+ UINT16 TimerInterval;
+ UINT16 Timeout;
+} SMBIOS_TABLE_TYPE23;
+
+typedef struct {
+ SMBIOS_TABLE_HEADER Hdr;
+ UINT8 HardwareSecuritySettings;
+} SMBIOS_TABLE_TYPE24;
+
+typedef struct {
+ SMBIOS_TABLE_HEADER Hdr;
+ UINT8 NextScheduledPowerOnMonth;
+ UINT8 NextScheduledPowerOnDayOfMonth;
+ UINT8 NextScheduledPowerOnHour;
+ UINT8 NextScheduledPowerOnMinute;
+ UINT8 NextScheduledPowerOnSecond;
+} SMBIOS_TABLE_TYPE25;
+
+typedef struct {
+ SMBIOS_TABLE_HEADER Hdr;
+ SMBIOS_TABLE_STRING Description;
+ UINT8 LocationAndStatus;
+ UINT16 MaximumValue;
+ UINT16 MinimumValue;
+ UINT16 Resolution;
+ UINT16 Tolerance;
+ UINT16 Accuracy;
+ UINT32 OEMDefined;
+ UINT16 NominalValue;
+} SMBIOS_TABLE_TYPE26;
+
+typedef struct {
+ SMBIOS_TABLE_HEADER Hdr;
+ UINT16 TemperatureProbeHandle;
+ UINT8 DeviceTypeAndStatus;
+ UINT8 CoolingUnitGroup;
+ UINT32 OEMDefined;
+ UINT16 NominalSpeed;
+ //
+ // Add for smbios 2.7
+ //
+ SMBIOS_TABLE_STRING Description;
+} SMBIOS_TABLE_TYPE27;
+
+typedef struct {
+ SMBIOS_TABLE_HEADER Hdr;
+ SMBIOS_TABLE_STRING Description;
+ UINT8 LocationAndStatus;
+ UINT16 MaximumValue;
+ UINT16 MinimumValue;
+ UINT16 Resolution;
+ UINT16 Tolerance;
+ UINT16 Accuracy;
+ UINT32 OEMDefined;
+ UINT16 NominalValue;
+} SMBIOS_TABLE_TYPE28;
+
+typedef struct {
+ SMBIOS_TABLE_HEADER Hdr;
+ SMBIOS_TABLE_STRING Description;
+ UINT8 LocationAndStatus;
+ UINT16 MaximumValue;
+ UINT16 MinimumValue;
+ UINT16 Resolution;
+ UINT16 Tolerance;
+ UINT16 Accuracy;
+ UINT32 OEMDefined;
+ UINT16 NominalValue;
+} SMBIOS_TABLE_TYPE29;
+
+typedef struct {
+ SMBIOS_TABLE_HEADER Hdr;
+ SMBIOS_TABLE_STRING ManufacturerName;
+ UINT8 Connections;
+} SMBIOS_TABLE_TYPE30;
+
+typedef struct {
+ SMBIOS_TABLE_HEADER Hdr;
+ UINT8 Checksum;
+ UINT8 Reserved1;
+ UINT16 Reserved2;
+ UINT32 BisEntry16;
+ UINT32 BisEntry32;
+ UINT64 Reserved3;
+ UINT32 Reserved4;
+} SMBIOS_TABLE_TYPE31;
+
+typedef struct {
+ SMBIOS_TABLE_HEADER Hdr;
+ UINT8 Reserved[6];
+ UINT8 BootStatus[1];
+} SMBIOS_TABLE_TYPE32;
+
+typedef struct {
+ SMBIOS_TABLE_HEADER Hdr;
+ UINT8 ErrorType;
+ UINT8 ErrorGranularity;
+ UINT8 ErrorOperation;
+ UINT32 VendorSyndrome;
+ UINT64 MemoryArrayErrorAddress;
+ UINT64 DeviceErrorAddress;
+ UINT32 ErrorResolution;
+} SMBIOS_TABLE_TYPE33;
+
+typedef struct {
+ SMBIOS_TABLE_HEADER Hdr;
+ SMBIOS_TABLE_STRING Description;
+ UINT8 Type;
+ UINT32 Address;
+ UINT8 AddressType;
+} SMBIOS_TABLE_TYPE34;
+
+typedef struct {
+ SMBIOS_TABLE_HEADER Hdr;
+ SMBIOS_TABLE_STRING Description;
+ UINT16 ManagementDeviceHandle;
+ UINT16 ComponentHandle;
+ UINT16 ThresholdHandle;
+} SMBIOS_TABLE_TYPE35;
+
+typedef struct {
+ SMBIOS_TABLE_HEADER Hdr;
+ UINT16 LowerThresholdNonCritical;
+ UINT16 UpperThresholdNonCritical;
+ UINT16 LowerThresholdCritical;
+ UINT16 UpperThresholdCritical;
+ UINT16 LowerThresholdNonRecoverable;
+ UINT16 UpperThresholdNonRecoverable;
+} SMBIOS_TABLE_TYPE36;
+
+typedef struct {
+ UINT8 DeviceLoad;
+ UINT16 DeviceHandle;
+} MEMORY_DEVICE;
+
+typedef struct {
+ SMBIOS_TABLE_HEADER Hdr;
+ UINT8 ChannelType;
+ UINT8 MaximumChannelLoad;
+ UINT8 MemoryDeviceCount;
+ MEMORY_DEVICE MemoryDevice[1];
+} SMBIOS_TABLE_TYPE37;
+
+typedef struct {
+ SMBIOS_TABLE_HEADER Hdr;
+ UINT8 InterfaceType;
+ UINT8 IPMISpecificationRevision;
+ UINT8 I2CSlaveAddress;
+ UINT8 NVStorageDeviceAddress;
+ UINT64 BaseAddress;
+ UINT8 BaseAddressModifier_InterruptInfo;
+ UINT8 InterruptNumber;
+} SMBIOS_TABLE_TYPE38;
+
+typedef struct {
+ SMBIOS_TABLE_HEADER Hdr;
+ UINT8 PowerUnitGroup;
+ SMBIOS_TABLE_STRING Location;
+ SMBIOS_TABLE_STRING DeviceName;
+ SMBIOS_TABLE_STRING Manufacturer;
+ SMBIOS_TABLE_STRING SerialNumber;
+ SMBIOS_TABLE_STRING AssetTagNumber;
+ SMBIOS_TABLE_STRING ModelPartNumber;
+ SMBIOS_TABLE_STRING RevisionLevel;
+ UINT16 MaxPowerCapacity;
+ UINT16 PowerSupplyCharacteristics;
+ UINT16 InputVoltageProbeHandle;
+ UINT16 CoolingDeviceHandle;
+ UINT16 InputCurrentProbeHandle;
+} SMBIOS_TABLE_TYPE39;
+
+//
+// Add type 40 and type 41 for smbios 2.6
+//
+typedef struct {
+ UINT8 EntryLength;
+ UINT16 ReferencedHandle;
+ UINT8 ReferencedOffset;
+ SMBIOS_TABLE_STRING EntryString;
+ UINT8 Value[1];
+}ADDITIONAL_INFORMATION_ENTRY;
+
+typedef struct {
+ SMBIOS_TABLE_HEADER Hdr;
+ UINT8 NumberOfAdditionalInformationEntries;
+ ADDITIONAL_INFORMATION_ENTRY AdditionalInfoEntries[1];
+} SMBIOS_TABLE_TYPE40;
+
+typedef struct {
+ SMBIOS_TABLE_HEADER Hdr;
+ SMBIOS_TABLE_STRING ReferenceDesignation;
+ UINT8 DeviceType;
+ UINT8 DeviceTypeInstance;
+ UINT16 SegmentGroupNum;
+ UINT8 BusNum;
+ UINT8 DevFuncNum;
+} SMBIOS_TABLE_TYPE41;
+
+typedef struct {
+ SMBIOS_TABLE_HEADER Hdr;
+ UINT8 InterfaceType;
+ UINT8 MCHostInterfaceData[1]; // This field has a minimum of four bytes
+} SMBIOS_TABLE_TYPE42;
+
+typedef struct {
+ SMBIOS_TABLE_HEADER Hdr;
+} SMBIOS_TABLE_TYPE126;
+
+typedef struct {
+ SMBIOS_TABLE_HEADER Hdr;
+} SMBIOS_TABLE_TYPE127;
+
+typedef union {
+ SMBIOS_TABLE_HEADER *Hdr;
+ SMBIOS_TABLE_TYPE0 *Type0;
+ SMBIOS_TABLE_TYPE1 *Type1;
+ SMBIOS_TABLE_TYPE2 *Type2;
+ SMBIOS_TABLE_TYPE3 *Type3;
+ SMBIOS_TABLE_TYPE4 *Type4;
+ SMBIOS_TABLE_TYPE5 *Type5;
+ SMBIOS_TABLE_TYPE6 *Type6;
+ SMBIOS_TABLE_TYPE7 *Type7;
+ SMBIOS_TABLE_TYPE8 *Type8;
+ SMBIOS_TABLE_TYPE9 *Type9;
+ SMBIOS_TABLE_TYPE10 *Type10;
+ SMBIOS_TABLE_TYPE11 *Type11;
+ SMBIOS_TABLE_TYPE12 *Type12;
+ SMBIOS_TABLE_TYPE13 *Type13;
+ SMBIOS_TABLE_TYPE14 *Type14;
+ SMBIOS_TABLE_TYPE15 *Type15;
+ SMBIOS_TABLE_TYPE16 *Type16;
+ SMBIOS_TABLE_TYPE17 *Type17;
+ SMBIOS_TABLE_TYPE18 *Type18;
+ SMBIOS_TABLE_TYPE19 *Type19;
+ SMBIOS_TABLE_TYPE20 *Type20;
+ SMBIOS_TABLE_TYPE21 *Type21;
+ SMBIOS_TABLE_TYPE22 *Type22;
+ SMBIOS_TABLE_TYPE23 *Type23;
+ SMBIOS_TABLE_TYPE24 *Type24;
+ SMBIOS_TABLE_TYPE25 *Type25;
+ SMBIOS_TABLE_TYPE26 *Type26;
+ SMBIOS_TABLE_TYPE27 *Type27;
+ SMBIOS_TABLE_TYPE28 *Type28;
+ SMBIOS_TABLE_TYPE29 *Type29;
+ SMBIOS_TABLE_TYPE30 *Type30;
+ SMBIOS_TABLE_TYPE31 *Type31;
+ SMBIOS_TABLE_TYPE32 *Type32;
+ SMBIOS_TABLE_TYPE33 *Type33;
+ SMBIOS_TABLE_TYPE34 *Type34;
+ SMBIOS_TABLE_TYPE35 *Type35;
+ SMBIOS_TABLE_TYPE36 *Type36;
+ SMBIOS_TABLE_TYPE37 *Type37;
+ SMBIOS_TABLE_TYPE38 *Type38;
+ SMBIOS_TABLE_TYPE39 *Type39;
+ SMBIOS_TABLE_TYPE40 *Type40;
+ SMBIOS_TABLE_TYPE41 *Type41;
+ SMBIOS_TABLE_TYPE126 *Type126;
+ SMBIOS_TABLE_TYPE127 *Type127;
+ UINT8 *Raw;
+} SMBIOS_STRUCTURE_POINTER;
+
+#pragma pack()
+
+#endif
diff --git a/EDK/Foundation/Include/IndustryStandard/Tpm12.h b/EDK/Foundation/Include/IndustryStandard/Tpm12.h
new file mode 100644
index 0000000..e0905b0
--- /dev/null
+++ b/EDK/Foundation/Include/IndustryStandard/Tpm12.h
@@ -0,0 +1,1964 @@
+/*++
+
+Copyright (c) 2005 - 2008, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Tpm12.h
+
+Abstract:
+
+ TPM Specification data structures (TCG TPM Specification Version 1.2 Revision 103)
+
+ See http://trustedcomputinggroup.org for latest specification updates
+
+--*/
+
+#ifndef _TPM12_H_
+#define _TPM12_H_
+
+//
+// Structures are all packed on 1-byte alignment
+//
+
+#pragma pack (push)
+#pragma pack (1)
+
+//
+// Part 2, section 2.2: Basic types & Helper redefinitions
+//
+typedef UINT8 TPM_AUTH_DATA_USAGE;
+typedef UINT8 TPM_PAYLOAD_TYPE;
+typedef UINT8 TPM_VERSION_BYTE;
+typedef UINT8 TPM_DA_STATE;
+typedef UINT16 TPM_TAG;
+typedef UINT16 TPM_PROTOCOL_ID;
+typedef UINT16 TPM_STARTUP_TYPE;
+typedef UINT16 TPM_ENC_SCHEME;
+typedef UINT16 TPM_SIG_SCHEME;
+typedef UINT16 TPM_MIGRATE_SCHEME;
+typedef UINT16 TPM_PHYSICAL_PRESENCE;
+typedef UINT16 TPM_ENTITY_TYPE;
+typedef UINT16 TPM_KEY_USAGE;
+typedef UINT16 TPM_EK_TYPE;
+typedef UINT16 TPM_STRUCTURE_TAG;
+typedef UINT16 TPM_PLATFORM_SPECIFIC;
+typedef UINT32 TPM_COMMAND_CODE;
+typedef UINT32 TPM_CAPABILITY_AREA;
+typedef UINT32 TPM_KEY_FLAGS;
+typedef UINT32 TPM_ALGORITHM_ID;
+typedef UINT32 TPM_MODIFIER_INDICATOR;
+typedef UINT32 TPM_ACTUAL_COUNT;
+typedef UINT32 TPM_TRANSPORT_ATTRIBUTES;
+typedef UINT32 TPM_AUTHHANDLE;
+typedef UINT32 TPM_DIRINDEX;
+typedef UINT32 TPM_KEY_HANDLE;
+typedef UINT32 TPM_PCRINDEX;
+typedef UINT32 TPM_RESULT;
+typedef UINT32 TPM_RESOURCE_TYPE;
+typedef UINT32 TPM_KEY_CONTROL;
+typedef UINT32 TPM_NV_INDEX;
+typedef UINT32 TPM_FAMILY_ID;
+typedef UINT32 TPM_FAMILY_VERIFICATION;
+typedef UINT32 TPM_STARTUP_EFFECTS;
+typedef UINT32 TPM_SYM_MODE;
+typedef UINT32 TPM_FAMILY_FLAGS;
+typedef UINT32 TPM_DELEGATE_INDEX;
+typedef UINT32 TPM_CMK_DELEGATE;
+typedef UINT32 TPM_COUNT_ID;
+typedef UINT32 TPM_REDIT_COMMAND;
+typedef UINT32 TPM_TRANSHANDLE;
+typedef UINT32 TPM_HANDLE;
+typedef UINT32 TPM_FAMILY_OPERATION;
+
+//
+// Part 2, section 2.2.4: Vendor specific
+// The following defines allow for the quick specification of a
+// vendor specific item.
+//
+#define TPM_Vendor_Specific32 ((UINT32) 0x00000400)
+#define TPM_Vendor_Specific8 ((UINT8) 0x80)
+
+//
+// Part 2, section 3.1: Structure TAGs
+//
+#define TPM_TAG_CONTEXTBLOB ((TPM_STRUCTURE_TAG) 0x0001)
+#define TPM_TAG_CONTEXT_SENSITIVE ((TPM_STRUCTURE_TAG) 0x0002)
+#define TPM_TAG_CONTEXTPOINTER ((TPM_STRUCTURE_TAG) 0x0003)
+#define TPM_TAG_CONTEXTLIST ((TPM_STRUCTURE_TAG) 0x0004)
+#define TPM_TAG_SIGNINFO ((TPM_STRUCTURE_TAG) 0x0005)
+#define TPM_TAG_PCR_INFO_LONG ((TPM_STRUCTURE_TAG) 0x0006)
+#define TPM_TAG_PERSISTENT_FLAGS ((TPM_STRUCTURE_TAG) 0x0007)
+#define TPM_TAG_VOLATILE_FLAGS ((TPM_STRUCTURE_TAG) 0x0008)
+#define TPM_TAG_PERSISTENT_DATA ((TPM_STRUCTURE_TAG) 0x0009)
+#define TPM_TAG_VOLATILE_DATA ((TPM_STRUCTURE_TAG) 0x000A)
+#define TPM_TAG_SV_DATA ((TPM_STRUCTURE_TAG) 0x000B)
+#define TPM_TAG_EK_BLOB ((TPM_STRUCTURE_TAG) 0x000C)
+#define TPM_TAG_EK_BLOB_AUTH ((TPM_STRUCTURE_TAG) 0x000D)
+#define TPM_TAG_COUNTER_VALUE ((TPM_STRUCTURE_TAG) 0x000E)
+#define TPM_TAG_TRANSPORT_INTERNAL ((TPM_STRUCTURE_TAG) 0x000F)
+#define TPM_TAG_TRANSPORT_LOG_IN ((TPM_STRUCTURE_TAG) 0x0010)
+#define TPM_TAG_TRANSPORT_LOG_OUT ((TPM_STRUCTURE_TAG) 0x0011)
+#define TPM_TAG_AUDIT_EVENT_IN ((TPM_STRUCTURE_TAG) 0x0012)
+#define TPM_TAG_AUDIT_EVENT_OUT ((TPM_STRUCTURE_TAG) 0x0013)
+#define TPM_TAG_CURRENT_TICKS ((TPM_STRUCTURE_TAG) 0x0014)
+#define TPM_TAG_KEY ((TPM_STRUCTURE_TAG) 0x0015)
+#define TPM_TAG_STORED_DATA12 ((TPM_STRUCTURE_TAG) 0x0016)
+#define TPM_TAG_NV_ATTRIBUTES ((TPM_STRUCTURE_TAG) 0x0017)
+#define TPM_TAG_NV_DATA_PUBLIC ((TPM_STRUCTURE_TAG) 0x0018)
+#define TPM_TAG_NV_DATA_SENSITIVE ((TPM_STRUCTURE_TAG) 0x0019)
+#define TPM_TAG_DELEGATIONS ((TPM_STRUCTURE_TAG) 0x001A)
+#define TPM_TAG_DELEGATE_PUBLIC ((TPM_STRUCTURE_TAG) 0x001B)
+#define TPM_TAG_DELEGATE_TABLE_ROW ((TPM_STRUCTURE_TAG) 0x001C)
+#define TPM_TAG_TRANSPORT_AUTH ((TPM_STRUCTURE_TAG) 0x001D)
+#define TPM_TAG_TRANSPORT_PUBLIC ((TPM_STRUCTURE_TAG) 0x001E)
+#define TPM_TAG_PERMANENT_FLAGS ((TPM_STRUCTURE_TAG) 0x001F)
+#define TPM_TAG_STCLEAR_FLAGS ((TPM_STRUCTURE_TAG) 0x0020)
+#define TPM_TAG_STANY_FLAGS ((TPM_STRUCTURE_TAG) 0x0021)
+#define TPM_TAG_PERMANENT_DATA ((TPM_STRUCTURE_TAG) 0x0022)
+#define TPM_TAG_STCLEAR_DATA ((TPM_STRUCTURE_TAG) 0x0023)
+#define TPM_TAG_STANY_DATA ((TPM_STRUCTURE_TAG) 0x0024)
+#define TPM_TAG_FAMILY_TABLE_ENTRY ((TPM_STRUCTURE_TAG) 0x0025)
+#define TPM_TAG_DELEGATE_SENSITIVE ((TPM_STRUCTURE_TAG) 0x0026)
+#define TPM_TAG_DELG_KEY_BLOB ((TPM_STRUCTURE_TAG) 0x0027)
+#define TPM_TAG_KEY12 ((TPM_STRUCTURE_TAG) 0x0028)
+#define TPM_TAG_CERTIFY_INFO2 ((TPM_STRUCTURE_TAG) 0x0029)
+#define TPM_TAG_DELEGATE_OWNER_BLOB ((TPM_STRUCTURE_TAG) 0x002A)
+#define TPM_TAG_EK_BLOB_ACTIVATE ((TPM_STRUCTURE_TAG) 0x002B)
+#define TPM_TAG_DAA_BLOB ((TPM_STRUCTURE_TAG) 0x002C)
+#define TPM_TAG_DAA_CONTEXT ((TPM_STRUCTURE_TAG) 0x002D)
+#define TPM_TAG_DAA_ENFORCE ((TPM_STRUCTURE_TAG) 0x002E)
+#define TPM_TAG_DAA_ISSUER ((TPM_STRUCTURE_TAG) 0x002F)
+#define TPM_TAG_CAP_VERSION_INFO ((TPM_STRUCTURE_TAG) 0x0030)
+#define TPM_TAG_DAA_SENSITIVE ((TPM_STRUCTURE_TAG) 0x0031)
+#define TPM_TAG_DAA_TPM ((TPM_STRUCTURE_TAG) 0x0032)
+#define TPM_TAG_CMK_MIGAUTH ((TPM_STRUCTURE_TAG) 0x0033)
+#define TPM_TAG_CMK_SIGTICKET ((TPM_STRUCTURE_TAG) 0x0034)
+#define TPM_TAG_CMK_MA_APPROVAL ((TPM_STRUCTURE_TAG) 0x0035)
+#define TPM_TAG_QUOTE_INFO2 ((TPM_STRUCTURE_TAG) 0x0036)
+#define TPM_TAG_DA_INFO ((TPM_STRUCTURE_TAG) 0x0037)
+#define TPM_TAG_DA_LIMITED ((TPM_STRUCTURE_TAG) 0x0038)
+#define TPM_TAG_DA_ACTION_TYPE ((TPM_STRUCTURE_TAG) 0x0039)
+
+//
+// Part 2, section 4: TPM Types
+//
+
+//
+// Part 2, section 4.1: TPM_RESOURCE_TYPE
+//
+#define TPM_RT_KEY ((TPM_RESOURCE_TYPE) 0x00000001) // The handle is a key handle and is the result of a LoadKey type operation
+#define TPM_RT_AUTH ((TPM_RESOURCE_TYPE) 0x00000002) // The handle is an authorization handle. Auth handles come from TPM_OIAP, TPM_OSAP and TPM_DSAP
+#define TPM_RT_HASH ((TPM_RESOURCE_TYPE) 0x00000003) // Reserved for hashes
+#define TPM_RT_TRANS ((TPM_RESOURCE_TYPE) 0x00000004) // The handle is for a transport session. Transport handles come from TPM_EstablishTransport
+#define TPM_RT_CONTEXT ((TPM_RESOURCE_TYPE) 0x00000005) // Resource wrapped and held outside the TPM using the context save/restore commands
+#define TPM_RT_COUNTER ((TPM_RESOURCE_TYPE) 0x00000006) // Reserved for counters
+#define TPM_RT_DELEGATE ((TPM_RESOURCE_TYPE) 0x00000007) // The handle is for a delegate row. These are the internal rows held in NV storage by the TPM
+#define TPM_RT_DAA_TPM ((TPM_RESOURCE_TYPE) 0x00000008) // The value is a DAA TPM specific blob
+#define TPM_RT_DAA_V0 ((TPM_RESOURCE_TYPE) 0x00000009) // The value is a DAA V0 parameter
+#define TPM_RT_DAA_V1 ((TPM_RESOURCE_TYPE) 0x0000000A) // The value is a DAA V1 parameter
+
+//
+// Part 2, section 4.2: TPM_PAYLOAD_TYPE
+//
+#define TPM_PT_ASYM ((TPM_PAYLOAD_TYPE) 0x01) // The entity is an asymmetric key
+#define TPM_PT_BIND ((TPM_PAYLOAD_TYPE) 0x02) // The entity is bound data
+#define TPM_PT_MIGRATE ((TPM_PAYLOAD_TYPE) 0x03) // The entity is a migration blob
+#define TPM_PT_MAINT ((TPM_PAYLOAD_TYPE) 0x04) // The entity is a maintenance blob
+#define TPM_PT_SEAL ((TPM_PAYLOAD_TYPE) 0x05) // The entity is sealed data
+#define TPM_PT_MIGRATE_RESTRICTED ((TPM_PAYLOAD_TYPE) 0x06) // The entity is a restricted-migration asymmetric key
+#define TPM_PT_MIGRATE_EXTERNAL ((TPM_PAYLOAD_TYPE) 0x07) // The entity is a external migratable key
+#define TPM_PT_CMK_MIGRATE ((TPM_PAYLOAD_TYPE) 0x08) // The entity is a CMK migratable blob
+#define TPM_PT_VENDOR_SPECIFIC ((TPM_PAYLOAD_TYPE) 0x80) // 0x80 - 0xFF Vendor specific payloads
+
+//
+// Part 2, section 4.3: TPM_ENTIRY_TYPE
+//
+#define TPM_ET_KEYHANDLE ((UINT16) 0x0001) // The entity is a keyHandle or key
+#define TPM_ET_OWNER ((UINT16) 0x0002) // The entity is the TPM Owner
+#define TPM_ET_DATA ((UINT16) 0x0003) // The entity is some data
+#define TPM_ET_SRK ((UINT16) 0x0004) // The entity is the SRK
+#define TPM_ET_KEY ((UINT16) 0x0005) // The entity is a key or keyHandle
+#define TPM_ET_REVOKE ((UINT16) 0x0006) // The entity is the RevokeTrust value
+#define TPM_ET_DEL_OWNER_BLOB ((UINT16) 0x0007) // The entity is a delegate owner blob
+#define TPM_ET_DEL_ROW ((UINT16) 0x0008) // The entity is a delegate row
+#define TPM_ET_DEL_KEY_BLOB ((UINT16) 0x0009) // The entity is a delegate key blob
+#define TPM_ET_COUNTER ((UINT16) 0x000A) // The entity is a counter
+#define TPM_ET_NV ((UINT16) 0x000B) // The entity is a NV index
+#define TPM_ET_OPERATOR ((UINT16) 0x000C) // The entity is the operator
+#define TPM_ET_RESERVED_HANDLE ((UINT16) 0x0040) // Reserved. This value avoids collisions with the handle MSB setting.
+//
+// TPM_ENTITY_TYPE MSB Values: The MSB is used to indicate the ADIP encryption sheme when applicable
+//
+#define TPM_ET_XOR ((UINT16) 0x0000) // ADIP encryption scheme: XOR
+#define TPM_ET_AES128 ((UINT16) 0x0006) // ADIP encryption scheme: AES 128 bits
+
+//
+// Part 2, section 4.4.1: Reserved Key Handles
+//
+#define TPM_KH_SRK ((TPM_KEY_HANDLE) 0x40000000) // The handle points to the SRK
+#define TPM_KH_OWNER ((TPM_KEY_HANDLE) 0x40000001) // The handle points to the TPM Owner
+#define TPM_KH_REVOKE ((TPM_KEY_HANDLE) 0x40000002) // The handle points to the RevokeTrust value
+#define TPM_KH_TRANSPORT ((TPM_KEY_HANDLE) 0x40000003) // The handle points to the EstablishTransport static authorization
+#define TPM_KH_OPERATOR ((TPM_KEY_HANDLE) 0x40000004) // The handle points to the Operator auth
+#define TPM_KH_ADMIN ((TPM_KEY_HANDLE) 0x40000005) // The handle points to the delegation administration auth
+#define TPM_KH_EK ((TPM_KEY_HANDLE) 0x40000006) // The handle points to the PUBEK, only usable with TPM_OwnerReadInternalPub
+
+//
+// Part 2, section 4.5: TPM_STARTUP_TYPE
+//
+#define TPM_ST_CLEAR ((TPM_STARTUP_TYPE) 0x0001) // The TPM is starting up from a clean state
+#define TPM_ST_STATE ((TPM_STARTUP_TYPE) 0x0002) // The TPM is starting up from a saved state
+#define TPM_ST_DEACTIVATED ((TPM_STARTUP_TYPE) 0x0003) // The TPM is to startup and set the deactivated flag to TRUE
+
+//
+// Part 2, section 4.6: TPM_STATUP_EFFECTS
+// The table makeup is still an open issue.
+//
+
+//
+// Part 2, section 4.7: TPM_PROTOCOL_ID
+//
+#define TPM_PID_OIAP ((TPM_PROTOCOL_ID) 0x0001) // The OIAP protocol.
+#define TPM_PID_OSAP ((TPM_PROTOCOL_ID) 0x0002) // The OSAP protocol.
+#define TPM_PID_ADIP ((TPM_PROTOCOL_ID) 0x0003) // The ADIP protocol.
+#define TPM_PID_ADCP ((TPM_PROTOCOL_ID) 0x0004) // The ADCP protocol.
+#define TPM_PID_OWNER ((TPM_PROTOCOL_ID) 0x0005) // The protocol for taking ownership of a TPM.
+#define TPM_PID_DSAP ((TPM_PROTOCOL_ID) 0x0006) // The DSAP protocol
+#define TPM_PID_TRANSPORT ((TPM_PROTOCOL_ID) 0x0007) // The transport protocol
+
+//
+// Part 2, section 4.8: TPM_ALGORITHM_ID
+// The TPM MUST support the algorithms TPM_ALG_RSA, TPM_ALG_SHA, TPM_ALG_HMAC,
+// TPM_ALG_MGF1
+//
+#define TPM_ALG_RSA ((TPM_ALGORITHM_ID) 0x00000001) // The RSA algorithm.
+#define TPM_ALG_DES ((TPM_ALGORITHM_ID) 0x00000002) // The DES algorithm
+#define TPM_ALG_3DES ((TPM_ALGORITHM_ID) 0x00000003) // The 3DES algorithm in EDE mode
+#define TPM_ALG_SHA ((TPM_ALGORITHM_ID) 0x00000004) // The SHA1 algorithm
+#define TPM_ALG_HMAC ((TPM_ALGORITHM_ID) 0x00000005) // The RFC 2104 HMAC algorithm
+#define TPM_ALG_AES128 ((TPM_ALGORITHM_ID) 0x00000006) // The AES algorithm, key size 128
+#define TPM_ALG_MGF1 ((TPM_ALGORITHM_ID) 0x00000007) // The XOR algorithm using MGF1 to create a string the size of the encrypted block
+#define TPM_ALG_AES192 ((TPM_ALGORITHM_ID) 0x00000008) // AES, key size 192
+#define TPM_ALG_AES256 ((TPM_ALGORITHM_ID) 0x00000009) // AES, key size 256
+#define TPM_ALG_XOR ((TPM_ALGORITHM_ID) 0x0000000A) // XOR using the rolling nonces
+
+//
+// Part 2, section 4.9: TPM_PHYSICAL_PRESENCE
+//
+#define TPM_PHYSICAL_PRESENCE_HW_DISABLE ((TPM_PHYSICAL_PRESENCE) 0x0200) // Sets the physicalPresenceHWEnable to FALSE
+#define TPM_PHYSICAL_PRESENCE_CMD_DISABLE ((TPM_PHYSICAL_PRESENCE) 0x0100) // Sets the physicalPresenceCMDEnable to FALSE
+#define TPM_PHYSICAL_PRESENCE_LIFETIME_LOCK ((TPM_PHYSICAL_PRESENCE) 0x0080) // Sets the physicalPresenceLifetimeLock to TRUE
+#define TPM_PHYSICAL_PRESENCE_HW_ENABLE ((TPM_PHYSICAL_PRESENCE) 0x0040) // Sets the physicalPresenceHWEnable to TRUE
+#define TPM_PHYSICAL_PRESENCE_CMD_ENABLE ((TPM_PHYSICAL_PRESENCE) 0x0020) // Sets the physicalPresenceCMDEnable to TRUE
+#define TPM_PHYSICAL_PRESENCE_NOTPRESENT ((TPM_PHYSICAL_PRESENCE) 0x0010) // Sets PhysicalPresence = FALSE
+#define TPM_PHYSICAL_PRESENCE_PRESENT ((TPM_PHYSICAL_PRESENCE) 0x0008) // Sets PhysicalPresence = TRUE
+#define TPM_PHYSICAL_PRESENCE_LOCK ((TPM_PHYSICAL_PRESENCE) 0x0004) // Sets PhysicalPresenceLock = TRUE
+
+//
+// Part 2, section 4.10: TPM_MIGRATE_SCHEME
+//
+#define TPM_MS_MIGRATE ((TPM_MIGRATE_SCHEME) 0x0001) // A public key that can be used with all TPM migration commands other than 'ReWrap' mode.
+#define TPM_MS_REWRAP ((TPM_MIGRATE_SCHEME) 0x0002) // A public key that can be used for the ReWrap mode of TPM_CreateMigrationBlob.
+#define TPM_MS_MAINT ((TPM_MIGRATE_SCHEME) 0x0003) // A public key that can be used for the Maintenance commands
+#define TPM_MS_RESTRICT_MIGRATE ((TPM_MIGRATE_SCHEME) 0x0004) // The key is to be migrated to a Migration Authority.
+#define TPM_MS_RESTRICT_APPROVE_DOUBLE ((TPM_MIGRATE_SCHEME) 0x0005) // The key is to be migrated to an entity approved by a Migration Authority using double wrapping
+
+//
+// Part 2, section 4.11: TPM_EK_TYPE
+//
+#define TPM_EK_TYPE_ACTIVATE ((TPM_EK_TYPE) 0x0001) // The blob MUST be TPM_EK_BLOB_ACTIVATE
+#define TPM_EK_TYPE_AUTH ((TPM_EK_TYPE) 0x0002) // The blob MUST be TPM_EK_BLOB_AUTH
+
+//
+// Part 2, section 4.12: TPM_PLATFORM_SPECIFIC
+//
+#define TPM_PS_PC_11 ((TPM_PLATFORM_SPECIFIC) 0x0001) // PC Specific version 1.1
+#define TPM_PS_PC_12 ((TPM_PLATFORM_SPECIFIC) 0x0002) // PC Specific version 1.2
+#define TPM_PS_PDA_12 ((TPM_PLATFORM_SPECIFIC) 0x0003) // PDA Specific version 1.2
+#define TPM_PS_Server_12 ((TPM_PLATFORM_SPECIFIC) 0x0004) // Server Specific version 1.2
+#define TPM_PS_Mobile_12 ((TPM_PLATFORM_SPECIFIC) 0x0005) // Mobil Specific version 1.2
+
+//
+// Part 2, section 5: Basic Structures
+//
+
+//
+// Part 2, section 5.1: TPM_STRUCT_VER
+//
+typedef struct _TPM_STRUCT_VER {
+ UINT8 major;
+ UINT8 minor;
+ UINT8 revMajor;
+ UINT8 revMinor;
+} TPM_STRUCT_VER;
+
+//
+// Part 2, section 5.3: TPM_VERSION
+//
+typedef struct _TPM_VERSION {
+ TPM_VERSION_BYTE major;
+ TPM_VERSION_BYTE minor;
+ UINT8 revMajor;
+ UINT8 revMinor;
+} TPM_VERSION;
+
+//
+// Part 2, section 5.4: TPM_DIGEST
+//
+#define TPM_SHA1_160_HASH_LEN 0x14
+#define TPM_SHA1BASED_NONCE_LEN TPM_SHA1_160_HASH_LEN
+
+typedef struct _TPM_DIGEST{
+ UINT8 digest[TPM_SHA1_160_HASH_LEN];
+} TPM_DIGEST;
+
+typedef TPM_DIGEST TPM_CHOSENID_HASH; // This SHALL be the digest of the chosen identityLabel and privacyCA for a new TPM identity.
+typedef TPM_DIGEST TPM_COMPOSITE_HASH; // This SHALL be the hash of a list of PCR indexes and PCR values that a key or data is bound to.
+typedef TPM_DIGEST TPM_DIRVALUE; // This SHALL be the value of a DIR register
+typedef TPM_DIGEST TPM_HMAC;
+typedef TPM_DIGEST TPM_PCRVALUE; // The value inside of the PCR
+typedef TPM_DIGEST TPM_AUDITDIGEST; // This SHALL be the value of the current internal audit state
+
+//
+// Part 2, section 5.5: TPM_NONCE
+//
+typedef struct _TPM_NONCE{
+ UINT8 nonce[20];
+} TPM_NONCE;
+
+typedef TPM_NONCE TPM_DAA_TPM_SEED; // This SHALL be a random value generated by a TPM immediately after the EK is installed in that TPM, whenever an EK is installed in that TPM
+typedef TPM_NONCE TPM_DAA_CONTEXT_SEED; // This SHALL be a random value
+
+//
+// Part 2, section 5.6: TPM_AUTHDATA
+//
+typedef UINT8 TPM_AUTHDATA[20];
+typedef TPM_AUTHDATA TPM_SECRET;
+typedef TPM_AUTHDATA TPM_ENCAUTH;
+
+//
+// Part 2, section 5.7: TPM_KEY_HANDLE_LIST
+// Size of handle is loaded * sizeof(TPM_KEY_HANDLE)
+//
+typedef struct _TPM_KEY_HANDLE_LIST {
+ UINT16 loaded;
+ TPM_KEY_HANDLE handle[1];
+} TPM_KEY_HANDLE_LIST;
+
+//
+// Part 2, section 5.8: TPM_KEY_USAGE values
+//
+
+#define TPM_KEY_SIGNING ((UINT16) 0x0010)
+// TPM_KEY_SIGNING SHALL indicate a signing key. The [private] key SHALL be
+// used for signing operations, only. This means that it MUST be a leaf of the
+// Protected Storage key hierarchy.
+
+#define TPM_KEY_STORAGE ((UINT16) 0x0011)
+// TPM_KEY_STORAGE SHALL indicate a storage key. The key SHALL be used to wrap
+// and unwrap other keys in the Protected Storage hierarchy
+
+#define TPM_KEY_IDENTITY ((UINT16) 0x0012)
+// TPM_KEY_IDENTITY SHALL indicate an identity key. The key SHALL be used for
+// operations that require a TPM identity, only.
+
+#define TPM_KEY_AUTHCHANGE ((UINT16) 0x0013)
+// TPM_KEY_AUTHCHANGE SHALL indicate an ephemeral key that is in use during
+// the ChangeAuthAsym process, only.
+
+#define TPM_KEY_BIND ((UINT16) 0x0014)
+// TPM_KEY_BIND SHALL indicate a key that can be used for TPM_Bind and
+// TPM_Unbind operations only.
+
+#define TPM_KEY_LEGACY ((UINT16) 0x0015)
+// TPM_KEY_LEGACY SHALL indicate a key that can perform signing and binding
+// operations. The key MAY be used for both signing and binding operations.
+// The TPM_KEY_LEGACY key type is to allow for use by applications where both
+// signing and encryption operations occur with the same key. The use of this
+// key type is not recommended TPM_KEY_MIGRATE 0x0016 This SHALL indicate a
+// key in use for TPM_MigrateKey
+
+#define TPM_KEY_MIGRATE ((UINT16) 0x0016)
+// TPM_KEY_MIGRAGE SHALL indicate a key in use for TPM_MigrateKey
+
+//
+// Part 2, section 5.8.1: Encryption/Signature schemes
+//
+
+#define TPM_ES_NONE ((TPM_ENC_SCHEME) 0x0001)
+#define TPM_ES_RSAESPKCSv15 ((TPM_ENC_SCHEME) 0x0002)
+#define TPM_ES_RSAESOAEP_SHA1_MGF1 ((TPM_ENC_SCHEME) 0x0003)
+#define TPM_ES_SYM_CNT ((TPM_ENC_SCHEME) 0x0004) // rev94 defined
+#define TPM_ES_SYM_CTR ((TPM_ENC_SCHEME) 0x0004)
+#define TPM_ES_SYM_OFB ((TPM_ENC_SCHEME) 0x0005)
+
+#define TPM_SS_NONE ((TPM_SIG_SCHEME) 0x0001)
+#define TPM_SS_RSASSAPKCS1v15_SHA1 ((TPM_SIG_SCHEME) 0x0002)
+#define TPM_SS_RSASSAPKCS1v15_DER ((TPM_SIG_SCHEME) 0x0003)
+#define TPM_SS_RSASSAPKCS1v15_INFO ((TPM_SIG_SCHEME) 0x0004)
+
+//
+// Part 2, section 5.9: TPM_AUTH_DATA_USAGE values
+//
+#define TPM_AUTH_NEVER ((TPM_AUTH_DATA_USAGE) 0x00)
+#define TPM_AUTH_ALWAYS ((TPM_AUTH_DATA_USAGE) 0x01)
+#define TPM_AUTH_PRIV_USE_ONLY ((TPM_AUTH_DATA_USAGE) 0x03)
+
+//
+// Part 2, section 5.10: TPM_KEY_FLAGS
+//
+enum _TPM_KEY_FLAGS {
+ redirection = 0x00000001,
+ migratable = 0x00000002,
+ isVolatile = 0x00000004,
+ pcrIgnoredOnRead = 0x00000008,
+ migrateAuthority = 0x00000010
+};
+
+//
+// Part 2, section 5.11: TPM_CHANGEAUTH_VALIDATE
+//
+typedef struct _TPM_CHANGEAUTH_VALIDATE {
+ TPM_SECRET newAuthSecret;
+ TPM_NONCE n1;
+} TPM_CHANGEAUTH_VALIDATE;
+
+//
+// Part 2, section 5.12: TPM_MIGRATIONKEYAUTH
+// decalared after section 10 to catch declaration of TPM_PUBKEY
+//
+// Part 2 section 10.1: TPM_KEY_PARMS
+// [size_is(parmSize)] BYTE* parms;
+//
+typedef struct _TPM_KEY_PARMS {
+ TPM_ALGORITHM_ID algorithmID;
+ TPM_ENC_SCHEME encScheme;
+ TPM_SIG_SCHEME sigScheme;
+ UINT32 parmSize;
+ UINT8 *parms;
+} TPM_KEY_PARMS;
+
+//
+// Part 2, section 10.4: TPM_STORE_PUBKEY
+//
+typedef struct _TPM_STORE_PUBKEY {
+ UINT32 keyLength;
+ UINT8 key[1];
+} TPM_STORE_PUBKEY;
+
+//
+// Part 2, section 10.5: TPM_PUBKEY
+//
+typedef struct _TPM_PUBKEY{
+ TPM_KEY_PARMS algorithmParms;
+ TPM_STORE_PUBKEY pubKey;
+} TPM_PUBKEY;
+
+//
+// Part 2, section 5.12: TPM_MIGRATIONKEYAUTH
+//
+typedef struct _TPM_MIGRATIONKEYAUTH{
+ TPM_PUBKEY migrationKey;
+ TPM_MIGRATE_SCHEME migrationScheme;
+ TPM_DIGEST digest;
+} TPM_MIGRATIONKEYAUTH;
+
+//
+// Part 2, section 5.13: TPM_COUNTER_VALUE
+//
+typedef struct _TPM_COUNTER_VALUE{
+ TPM_STRUCTURE_TAG tag;
+ UINT8 label[4];
+ TPM_ACTUAL_COUNT counter;
+} TPM_COUNTER_VALUE;
+
+//
+// Part 2, section 5.14: TPM_SIGN_INFO
+// Size of data indicated by dataLen
+//
+typedef struct _TPM_SIGN_INFO {
+ TPM_STRUCTURE_TAG tag;
+ UINT8 fixed[4];
+ TPM_NONCE replay;
+ UINT32 dataLen;
+ UINT8 *data;
+} TPM_SIGN_INFO;
+
+//
+// Part 2, section 5.15: TPM_MSA_COMPOSITE
+// Number of migAuthDigest indicated by MSAlist
+//
+typedef struct _TPM_MSA_COMPOSITE {
+ UINT32 MSAlist;
+ TPM_DIGEST migAuthDigest[1];
+} TPM_MSA_COMPOSITE;
+
+//
+// Part 2, section 5.16: TPM_CMK_AUTH
+//
+typedef struct _TPM_CMK_AUTH{
+ TPM_DIGEST migrationAuthorityDigest;
+ TPM_DIGEST destinationKeyDigest;
+ TPM_DIGEST sourceKeyDigest;
+} TPM_CMK_AUTH;
+
+//
+// Part 2, section 5.17: TPM_CMK_DELEGATE
+//
+#define TPM_CMK_DELEGATE_SIGNING (((TPM_CMK_DELEGATE)1) << 31)
+#define TPM_CMK_DELEGATE_STORAGE (((TPM_CMK_DELEGATE)1) << 30)
+#define TPM_CMK_DELEGATE_BIND (((TPM_CMK_DELEGATE)1) << 29)
+#define TPM_CMK_DELEGATE_LEGACY (((TPM_CMK_DELEGATE)1) << 28)
+#define TPM_CMK_DELEGATE_MIGRATE (((TPM_CMK_DELEGATE)1) << 27)
+
+//
+// Part 2, section 5.18: TPM_SELECT_SIZE
+//
+typedef struct _TPM_SELECT_SIZE {
+ UINT8 major;
+ UINT8 minor;
+ UINT16 reqSize;
+} TPM_SELECT_SIZE;
+
+//
+// Part 2, section 5,19: TPM_CMK_MIGAUTH
+//
+typedef struct _TPM_CMK_MIGAUTH{
+ TPM_STRUCTURE_TAG tag;
+ TPM_DIGEST msaDigest;
+ TPM_DIGEST pubKeyDigest;
+} TPM_CMK_MIGAUTH;
+
+//
+// Part 2, section 5.20: TPM_CMK_SIGTICKET
+//
+typedef struct _TPM_CMK_SIGTICKET{
+ TPM_STRUCTURE_TAG tag;
+ TPM_DIGEST verKeyDigest;
+ TPM_DIGEST signedData;
+} TPM_CMK_SIGTICKET;
+
+//
+// Part 2, section 5.21: TPM_CMK_MA_APPROVAL
+//
+typedef struct _TPM_CMK_MA_APPROVAL{
+ TPM_STRUCTURE_TAG tag;
+ TPM_DIGEST migrationAuthorityDigest;
+} TPM_CMK_MA_APPROVAL;
+
+//
+// Part 2, section 6: Command Tags
+//
+#define TPM_TAG_RQU_COMMAND ((TPM_STRUCTURE_TAG) 0x00C1)
+#define TPM_TAG_RQU_AUTH1_COMMAND ((TPM_STRUCTURE_TAG) 0x00C2)
+#define TPM_TAG_RQU_AUTH2_COMMAND ((TPM_STRUCTURE_TAG) 0x00C3)
+#define TPM_TAG_RSP_COMMAND ((TPM_STRUCTURE_TAG) 0x00C4)
+#define TPM_TAG_RSP_AUTH1_COMMAND ((TPM_STRUCTURE_TAG) 0x00C5)
+#define TPM_TAG_RSP_AUTH2_COMMAND ((TPM_STRUCTURE_TAG) 0x00C6)
+
+//
+// Part 2, section 7.1: TPM_PERMANENT_FLAGS
+//
+typedef struct _TPM_PERMANENT_FLAGS{
+ TPM_STRUCTURE_TAG tag;
+ BOOLEAN disable;
+ BOOLEAN ownership;
+ BOOLEAN deactivated;
+ BOOLEAN readPubek;
+ BOOLEAN disableOwnerClear;
+ BOOLEAN allowMaintenance;
+ BOOLEAN physicalPresenceLifetimeLock;
+ BOOLEAN physicalPresenceHWEnable;
+ BOOLEAN physicalPresenceCMDEnable;
+ BOOLEAN CEKPUsed;
+ BOOLEAN TPMpost;
+ BOOLEAN TPMpostLock;
+ BOOLEAN FIPS;
+ BOOLEAN operator;
+ BOOLEAN enableRevokeEK;
+ BOOLEAN nvLocked;
+ BOOLEAN readSRKPub;
+ BOOLEAN tpmEstablished;
+ BOOLEAN maintenanceDone;
+ BOOLEAN disableFullDALogicInfo;
+} TPM_PERMANENT_FLAGS;
+
+//
+// Part 2, section 7.1.1: PERMANENT_FLAGS Subcap for SetCapability
+//
+#define TPM_PF_DISABLE ((TPM_CAPABILITY_AREA) 1)
+#define TPM_PF_OWNERSHIP ((TPM_CAPABILITY_AREA) 2)
+#define TPM_PF_DEACTIVATED ((TPM_CAPABILITY_AREA) 3)
+#define TPM_PF_READPUBEK ((TPM_CAPABILITY_AREA) 4)
+#define TPM_PF_DISABLEOWNERCLEAR ((TPM_CAPABILITY_AREA) 5)
+#define TPM_PF_ALLOWMAINTENANCE ((TPM_CAPABILITY_AREA) 6)
+#define TPM_PF_PHYSICALPRESENCELIFETIMELOCK ((TPM_CAPABILITY_AREA) 7)
+#define TPM_PF_PHYSICALPRESENCEHWENABLE ((TPM_CAPABILITY_AREA) 8)
+#define TPM_PF_PHYSICALPRESENCECMDENABLE ((TPM_CAPABILITY_AREA) 9)
+#define TPM_PF_CEKPUSED ((TPM_CAPABILITY_AREA) 10)
+#define TPM_PF_TPMPOST ((TPM_CAPABILITY_AREA) 11)
+#define TPM_PF_TPMPOSTLOCK ((TPM_CAPABILITY_AREA) 12)
+#define TPM_PF_FIPS ((TPM_CAPABILITY_AREA) 13)
+#define TPM_PF_OPERATOR ((TPM_CAPABILITY_AREA) 14)
+#define TPM_PF_ENABLEREVOKEEK ((TPM_CAPABILITY_AREA) 15)
+#define TPM_PF_NV_LOCKED ((TPM_CAPABILITY_AREA) 16)
+#define TPM_PF_READSRKPUB ((TPM_CAPABILITY_AREA) 17)
+#define TPM_PF_TPMESTABLISHED ((TPM_CAPABILITY_AREA) 18)
+#define TPM_PF_MAINTENANCEDONE ((TPM_CAPABILITY_AREA) 19)
+#define TPM_PF_DISABLEFULLDALOGICINFO ((TPM_CAPABILITY_AREA) 20)
+
+//
+// Part 2, section 7.2: TPM_STCLEAR_FLAGS
+//
+typedef struct _TPM_STCLEAR_FLAGS{
+ TPM_STRUCTURE_TAG tag;
+ BOOLEAN deactivated;
+ BOOLEAN disableForceClear;
+ BOOLEAN physicalPresence;
+ BOOLEAN physicalPresenceLock;
+ BOOLEAN bGlobalLock;
+} TPM_STCLEAR_FLAGS;
+
+//
+// Part 2, section 7.2.1: STCLEAR_FLAGS Subcap for SetCapability
+//
+#define TPM_SF_DEACTIVATED ((TPM_CAPABILITY_AREA) 1)
+#define TPM_SF_DISABLEFORCECLEAR ((TPM_CAPABILITY_AREA) 2)
+#define TPM_SF_PHYSICALPRESENCE ((TPM_CAPABILITY_AREA) 3)
+#define TPM_SF_PHYSICALPRESENCELOCK ((TPM_CAPABILITY_AREA) 4)
+#define TPM_SF_BGLOBALLOCK ((TPM_CAPABILITY_AREA) 5)
+
+//
+// Part 2, section 7.3: TPM_STANY_FLAGS
+//
+typedef struct _TPM_STANY_FLAGS{
+ TPM_STRUCTURE_TAG tag;
+ BOOLEAN postInitialise;
+ TPM_MODIFIER_INDICATOR localityModifier;
+ BOOLEAN transportExclusive;
+ BOOLEAN TOSPresent;
+} TPM_STANY_FLAGS;
+
+//
+// Part 2, section 7.3.1: STANY_FLAGS Subcap for SetCapability
+//
+#define TPM_AF_POSTINITIALISE ((TPM_CAPABILITY_AREA) 1)
+#define TPM_AF_LOCALITYMODIFIER ((TPM_CAPABILITY_AREA) 2)
+#define TPM_AF_TRANSPORTEXCLUSIVE ((TPM_CAPABILITY_AREA) 3)
+#define TPM_AF_TOSPRESENT ((TPM_CAPABILITY_AREA) 4)
+
+//
+// All those structures (section 7.4, 7.5, 7.6) are not normative and
+// thus no definitions here
+//
+// Part 2, section 7.4: TPM_PERMANENT_DATA
+//
+#define TPM_MIN_COUNTERS 4 // the minimum number of counters is 4
+#define TPM_DELEGATE_KEY TPM_KEY
+#define TPM_NUM_PCR 16
+#define TPM_MAX_NV_WRITE_NOOWNER 64
+
+//typedef struct _TPM_PERMANENT_DATA
+//{
+// TPM_STRUCTURE_TAG tag;
+// UINT8 revMajor;
+// UINT8 revMinor;
+// TPM_NONCE tpmProof;
+// TPM_NONCE ekReset;
+// TPM_SECRET ownerAuth;
+// TPM_SECRET operatorAuth;
+// TPM_DIRVALUE authDIR[1];
+// TPM_PUBKEY manuMaintPub;
+// TPM_KEY endorsementKey;
+// TPM_KEY srk;
+// TPM_KEY contextKey;
+// TPM_KEY delegateKey;
+// TPM_COUNTER_VALUE auditMonotonicCounter;
+// TPM_COUNTER_VALUE monitonicCounter[TPM_MIN_COUNTERS];
+// TPM_PCR_ATTRIBUTES pcrAttrib[TPM_NUM_PCR];
+// UINT8 ordinalAuditStatus[];
+// UINT8 *rngState;
+// TPM_FAMILY_TABLE familyTable;
+// TPM_DELEGATE_TABLE delegateTable;
+// UINT32 maxNVBufSize;
+// UINT32 lastFamilyID;
+// UINT32 noOwnerNVWrite;
+// TPM_CMK_DELEGATE restrictDelegate;
+// TPM_DAA_TPM_SEED tpmDAASeed;
+// TPM_NONCE daaProff;
+// TPM_KEY daaBlobKey;
+//} TPM_PERMANENT_DATA;
+
+//
+// Part 2, section 7.4.1: PERMANENT_DATA Subcap for SetCapability
+//
+#define TPM_PD_REVMAJOR ((TPM_CAPABILITY_AREA) 1)
+#define TPM_PD_REVMINOR ((TPM_CAPABILITY_AREA) 2)
+#define TPM_PD_TPMPROOF ((TPM_CAPABILITY_AREA) 3)
+#define TPM_PD_OWNERAUTH ((TPM_CAPABILITY_AREA) 4)
+#define TPM_PD_OPERATORAUTH ((TPM_CAPABILITY_AREA) 5)
+#define TPM_PD_MANUMAINTPUB ((TPM_CAPABILITY_AREA) 6)
+#define TPM_PD_ENDORSEMENTKEY ((TPM_CAPABILITY_AREA) 7)
+#define TPM_PD_SRK ((TPM_CAPABILITY_AREA) 8)
+#define TPM_PD_DELEGATEKEY ((TPM_CAPABILITY_AREA) 9)
+#define TPM_PD_CONTEXTKEY ((TPM_CAPABILITY_AREA) 10)
+#define TPM_PD_AUDITMONOTONICCOUNTER ((TPM_CAPABILITY_AREA) 11)
+#define TPM_PD_MONOTONICCOUNTER ((TPM_CAPABILITY_AREA) 12)
+#define TPM_PD_PCRATTRIB ((TPM_CAPABILITY_AREA) 13)
+#define TPM_PD_ORDINALAUDITSTATUS ((TPM_CAPABILITY_AREA) 14)
+#define TPM_PD_AUTHDIR ((TPM_CAPABILITY_AREA) 15)
+#define TPM_PD_RNGSTATE ((TPM_CAPABILITY_AREA) 16)
+#define TPM_PD_FAMILYTABLE ((TPM_CAPABILITY_AREA) 17)
+#define TPM_DELEGATETABLE ((TPM_CAPABILITY_AREA) 18)
+#define TPM_PD_EKRESET ((TPM_CAPABILITY_AREA) 19)
+#define TPM_PD_MAXNVBUFSIZE ((TPM_CAPABILITY_AREA) 20)
+#define TPM_PD_LASTFAMILYID ((TPM_CAPABILITY_AREA) 21)
+#define TPM_PD_NOOWNERNVWRITE ((TPM_CAPABILITY_AREA) 22)
+#define TPM_PD_RESTRICTDELEGATE ((TPM_CAPABILITY_AREA) 23)
+#define TPM_PD_TPMDAASEED ((TPM_CAPABILITY_AREA) 24)
+#define TPM_PD_DAAPROOF ((TPM_CAPABILITY_AREA) 25)
+
+//
+// Part 2, section 7.5: TPM_STCLEAR_DATA
+// available inside TPM only
+//
+ typedef struct _TPM_STCLEAR_DATA{
+ TPM_STRUCTURE_TAG tag;
+ TPM_NONCE contextNonceKey;
+ TPM_COUNT_ID countID;
+ UINT32 ownerReference;
+ BOOLEAN disableResetLock;
+ TPM_PCRVALUE PCR[TPM_NUM_PCR];
+ UINT32 deferredPhysicalPresence;
+ }TPM_STCLEAR_DATA;
+
+//
+// Part 2, section 7.5.1: STCLEAR_DATA Subcap for SetCapability
+//
+#define TPM_SD_CONTEXTNONCEKEY ((TPM_CAPABILITY_AREA)0x00000001)
+#define TPM_SD_COUNTID ((TPM_CAPABILITY_AREA)0x00000002)
+#define TPM_SD_OWNERREFERENCE ((TPM_CAPABILITY_AREA)0x00000003)
+#define TPM_SD_DISABLERESETLOCK ((TPM_CAPABILITY_AREA)0x00000004)
+#define TPM_SD_PCR ((TPM_CAPABILITY_AREA)0x00000005)
+#define TPM_SD_DEFERREDPHYSICALPRESENCE ((TPM_CAPABILITY_AREA)0x00000006)
+
+//
+// Part 2, section 7.6: TPM_STANY_DATA
+// available inside TPM only
+//
+//typedef struct _TPM_STANY_DATA
+//{
+// TPM_STRUCTURE_TAG tag;
+// TPM_NONCE contextNonceSession;
+// TPM_DIGEST auditDigest;
+// TPM_CURRENT_TICKS currentTicks;
+// UINT32 contextCount;
+// UINT32 contextList[TPM_MIN_SESSION_LIST];
+// TPM_SESSION_DATA sessions[TPM_MIN_SESSIONS];
+//} TPM_STANY_DATA;
+
+//
+// Part 2, section 7.6.1: STANY_DATA Subcap for SetCapability
+//
+#define TPM_AD_CONTEXTNONCESESSION ((TPM_CAPABILITY_AREA) 1)
+#define TPM_AD_AUDITDIGEST ((TPM_CAPABILITY_AREA) 2)
+#define TPM_AD_CURRENTTICKS ((TPM_CAPABILITY_AREA) 3)
+#define TPM_AD_CONTEXTCOUNT ((TPM_CAPABILITY_AREA) 4)
+#define TPM_AD_CONTEXTLIST ((TPM_CAPABILITY_AREA) 5)
+#define TPM_AD_SESSIONS ((TPM_CAPABILITY_AREA) 6)
+
+//
+// Part 2, section 8: PCR Structures
+//
+
+//
+// Part 2, section 8.1: TPM_PCR_SELECTION
+// Size of pcrSelect[] indicated by sizeOfSelect
+//
+typedef struct _TPM_PCR_SELECTION {
+ UINT16 sizeOfSelect;
+ UINT8 pcrSelect[1];
+} TPM_PCR_SELECTION;
+
+//
+// Part 2, section 8.2: TPM_PCR_COMPOSITE
+// Size of pcrValue[] indicated by valueSize
+//
+typedef struct _TPM_PCR_COMPOSITE {
+ TPM_PCR_SELECTION select;
+ UINT32 valueSize;
+ TPM_PCRVALUE pcrValue[1];
+} TPM_PCR_COMPOSITE;
+
+//
+// Part 2, section 8.3: TPM_PCR_INFO
+//
+typedef struct _TPM_PCR_INFO {
+ TPM_PCR_SELECTION pcrSelection;
+ TPM_COMPOSITE_HASH digestAtRelease;
+ TPM_COMPOSITE_HASH digestAtCreation;
+} TPM_PCR_INFO;
+
+//
+// Part 2, section 8.6: TPM_LOCALITY_SELECTION
+//
+typedef UINT8 TPM_LOCALITY_SELECTION;
+
+#define TPM_LOC_FOUR ((UINT8) 0x10)
+#define TPM_LOC_THREE ((UINT8) 0x08)
+#define TPM_LOC_TWO ((UINT8) 0x04)
+#define TPM_LOC_ONE ((UINT8) 0x02)
+#define TPM_LOC_ZERO ((UINT8) 0x01)
+
+//
+// Part 2, section 8.4: TPM_PCR_INFO_LONG
+//
+typedef struct _TPM_PCR_INFO_LONG {
+ TPM_STRUCTURE_TAG tag;
+ TPM_LOCALITY_SELECTION localityAtCreation;
+ TPM_LOCALITY_SELECTION localityAtRelease;
+ TPM_PCR_SELECTION creationPCRSelection;
+ TPM_PCR_SELECTION releasePCRSelection;
+ TPM_COMPOSITE_HASH digestAtCreation;
+ TPM_COMPOSITE_HASH digestAtRelease;
+} TPM_PCR_INFO_LONG;
+
+//
+// Part 2, section 8.5: TPM_PCR_INFO_SHORT
+//
+typedef struct _TPM_PCR_INFO_SHORT{
+ TPM_PCR_SELECTION pcrSelection;
+ TPM_LOCALITY_SELECTION localityAtRelease;
+ TPM_COMPOSITE_HASH digestAtRelease;
+} TPM_PCR_INFO_SHORT;
+
+//
+// Part 2, section 8.8: TPM_PCR_ATTRIBUTES
+//
+typedef struct _TPM_PCR_ATTRIBUTES{
+ BOOLEAN pcrReset;
+ TPM_LOCALITY_SELECTION pcrExtendLocal;
+ TPM_LOCALITY_SELECTION pcrResetLocal;
+} TPM_PCR_ATTRIBUTES;
+
+//
+// Part 2, section 9: Storage Structures
+//
+
+//
+// Part 2, section 9.1: TPM_STORED_DATA
+// [size_is(sealInfoSize)] BYTE* sealInfo;
+// [size_is(encDataSize)] BYTE* encData;
+//
+typedef struct _TPM_STORED_DATA {
+ TPM_STRUCT_VER ver;
+ UINT32 sealInfoSize;
+ UINT8 *sealInfo;
+ UINT32 encDataSize;
+ UINT8 *encData;
+} TPM_STORED_DATA;
+
+//
+// Part 2, section 9.2: TPM_STORED_DATA12
+// [size_is(sealInfoSize)] BYTE* sealInfo;
+// [size_is(encDataSize)] BYTE* encData;
+//
+typedef struct _TPM_STORED_DATA12 {
+ TPM_STRUCTURE_TAG tag;
+ TPM_ENTITY_TYPE et;
+ UINT32 sealInfoSize;
+ UINT8 *sealInfo;
+ UINT32 encDataSize;
+ UINT8 *encData;
+} TPM_STORED_DATA12;
+
+//
+// Part 2, section 9.3: TPM_SEALED_DATA
+// [size_is(dataSize)] BYTE* data;
+//
+typedef struct _TPM_SEALED_DATA {
+ TPM_PAYLOAD_TYPE payload;
+ TPM_SECRET authData;
+ TPM_NONCE tpmProof;
+ TPM_DIGEST storedDigest;
+ UINT32 dataSize;
+ UINT8 *data;
+} TPM_SEALED_DATA;
+
+//
+// Part 2, section 9.4: TPM_SYMMETRIC_KEY
+// [size_is(size)] BYTE* data;
+//
+typedef struct _TPM_SYMMETRIC_KEY {
+ TPM_ALGORITHM_ID algId;
+ TPM_ENC_SCHEME encScheme;
+ UINT16 dataSize;
+ UINT8 *data;
+} TPM_SYMMETRIC_KEY;
+
+//
+// Part 2, section 9.5: TPM_BOUND_DATA
+//
+typedef struct _TPM_BOUND_DATA {
+ TPM_STRUCT_VER ver;
+ TPM_PAYLOAD_TYPE payload;
+ UINT8 payloadData[1];
+} TPM_BOUND_DATA;
+
+//
+// Part 2 section 10: TPM_KEY complex
+//
+
+//
+// Part 2, section 10.2: TPM_KEY
+// [size_is(encDataSize)] BYTE* encData;
+//
+typedef struct _TPM_KEY{
+ TPM_STRUCT_VER ver;
+ TPM_KEY_USAGE keyUsage;
+ TPM_KEY_FLAGS keyFlags;
+ TPM_AUTH_DATA_USAGE authDataUsage;
+ TPM_KEY_PARMS algorithmParms;
+ UINT32 PCRInfoSize;
+ UINT8 *PCRInfo;
+ TPM_STORE_PUBKEY pubKey;
+ UINT32 encDataSize;
+ UINT8 *encData;
+} TPM_KEY;
+
+//
+// Part 2, section 10.3: TPM_KEY12
+// [size_is(encDataSize)] BYTE* encData;
+//
+typedef struct _TPM_KEY12{
+ TPM_STRUCTURE_TAG tag;
+ UINT16 fill;
+ TPM_KEY_USAGE keyUsage;
+ TPM_KEY_FLAGS keyFlags;
+ TPM_AUTH_DATA_USAGE authDataUsage;
+ TPM_KEY_PARMS algorithmParms;
+ UINT32 PCRInfoSize;
+ UINT8 *PCRInfo;
+ TPM_STORE_PUBKEY pubKey;
+ UINT32 encDataSize;
+ UINT8 *encData;
+} TPM_KEY12;
+
+//
+// Part 2, section 10.7: TPM_STORE_PRIVKEY
+// [size_is(keyLength)] BYTE* key;
+//
+typedef struct _TPM_STORE_PRIVKEY {
+ UINT32 keyLength;
+ UINT8 *key;
+} TPM_STORE_PRIVKEY;
+
+//
+// Part 2, section 10.6: TPM_STORE_ASYMKEY
+//
+typedef struct _TPM_STORE_ASYMKEY { // pos len total
+ TPM_PAYLOAD_TYPE payload; // 0 1 1
+ TPM_SECRET usageAuth; // 1 20 21
+ TPM_SECRET migrationAuth; // 21 20 41
+ TPM_DIGEST pubDataDigest; // 41 20 61
+ TPM_STORE_PRIVKEY privKey; // 61 132-151 193-214
+} TPM_STORE_ASYMKEY;
+
+//
+// Part 2, section 10.8: TPM_MIGRATE_ASYMKEY
+// [size_is(partPrivKeyLen)] BYTE* partPrivKey;
+//
+typedef struct _TPM_MIGRATE_ASYMKEY { // pos len total
+ TPM_PAYLOAD_TYPE payload; // 0 1 1
+ TPM_SECRET usageAuth; // 1 20 21
+ TPM_DIGEST pubDataDigest; // 21 20 41
+ UINT32 partPrivKeyLen; // 41 4 45
+ UINT8 *partPrivKey; // 45 112-127 157-172
+} TPM_MIGRATE_ASYMKEY;
+
+//
+// Part 2, section 10.9: TPM_KEY_CONTROL
+//
+#define TPM_KEY_CONTROL_OWNER_EVICT ((UINT32) 0x00000001)
+
+//
+// Part 2, section 11: Signed Structures
+//
+
+typedef struct _TPM_CERTIFY_INFO
+{
+ TPM_STRUCT_VER version;
+ TPM_KEY_USAGE keyUsage;
+ TPM_KEY_FLAGS keyFlags;
+ TPM_AUTH_DATA_USAGE authDataUsage;
+ TPM_KEY_PARMS algorithmParms;
+ TPM_DIGEST pubkeyDigest;
+ TPM_NONCE data;
+ BOOLEAN parentPCRStatus;
+ UINT32 PCRInfoSize;
+ UINT8 *PCRInfo;
+} TPM_CERTIFY_INFO;
+
+typedef struct _TPM_CERTIFY_INFO2
+{
+ TPM_STRUCTURE_TAG tag;
+ UINT8 fill;
+ TPM_PAYLOAD_TYPE payloadType;
+ TPM_KEY_USAGE keyUsage;
+ TPM_KEY_FLAGS keyFlags;
+ TPM_AUTH_DATA_USAGE authDataUsage;
+ TPM_KEY_PARMS algorithmParms;
+ TPM_DIGEST pubkeyDigest;
+ TPM_NONCE data;
+ BOOLEAN parentPCRStatus;
+ UINT32 PCRInfoSize;
+ UINT8 *PCRInfo;
+ UINT32 migrationAuthoritySize;
+ UINT8 *migrationAuthority;
+} TPM_CERTIFY_INFO2;
+
+typedef struct _TPM_QUOTE_INFO
+{
+ TPM_STRUCT_VER version;
+ UINT8 fixed[4];
+ TPM_COMPOSITE_HASH digestValue;
+ TPM_NONCE externalData;
+} TPM_QUOTE_INFO;
+
+typedef struct _TPM_QUOTE_INFO2
+{
+ TPM_STRUCTURE_TAG tag;
+ UINT8 fixed[4];
+ TPM_NONCE externalData;
+ TPM_PCR_INFO_SHORT infoShort;
+} TPM_QUOTE_INFO2;
+
+//
+// Part 2, section 12: Identity Structures
+//
+
+typedef struct _TPM_EK_BLOB
+{
+ TPM_STRUCTURE_TAG tag;
+ TPM_EK_TYPE ekType;
+ UINT32 blobSize;
+ UINT8 *blob;
+} TPM_EK_BLOB;
+
+typedef struct _TPM_EK_BLOB_ACTIVATE
+{
+ TPM_STRUCTURE_TAG tag;
+ TPM_SYMMETRIC_KEY sessionKey;
+ TPM_DIGEST idDigest;
+ TPM_PCR_INFO_SHORT pcrInfo;
+} TPM_EK_BLOB_ACTIVATE;
+
+typedef struct _TPM_EK_BLOB_AUTH
+{
+ TPM_STRUCTURE_TAG tag;
+ TPM_SECRET authValue;
+} TPM_EK_BLOB_AUTH;
+
+
+// TPM_CHOSENID_HASH = SHA(identityLabel || privacyCA)
+typedef TPM_DIGEST TPM_CHOSENID_HASH;
+
+typedef struct _TPM_IDENTITY_CONTENTS
+{
+ TPM_STRUCT_VER ver;
+ UINT32 ordinal;
+ TPM_CHOSENID_HASH labelPrivCADigest;
+ TPM_PUBKEY identityPubKey;
+} TPM_IDENTITY_CONTENTS;
+
+typedef struct _TPM_IDENTITY_REQ
+{
+ UINT32 asymSize;
+ UINT32 symSize;
+ TPM_KEY_PARMS asymAlgorithm;
+ TPM_KEY_PARMS symAlgorithm;
+ UINT8 *asymBlob;
+ UINT8 *symBlob;
+} TPM_IDENTITY_REQ;
+
+typedef struct _TPM_IDENTITY_PROOF
+{
+ TPM_STRUCT_VER ver;
+ UINT32 labelSize;
+ UINT32 identityBindingSize;
+ UINT32 endorsementSize;
+ UINT32 platformSize;
+ UINT32 conformanceSize;
+ TPM_PUBKEY identityKey;
+ UINT8 *labelArea;
+ UINT8 *identityBinding;
+ UINT8 *endorsementCredential;
+ UINT8 *platformCredential;
+ UINT8 *conformanceCredential;
+} TPM_IDENTITY_PROOF;
+
+typedef struct _TPM_ASYM_CA_CONTENTS
+{
+ TPM_SYMMETRIC_KEY sessionKey;
+ TPM_DIGEST idDigest;
+} TPM_ASYM_CA_CONTENTS;
+
+typedef struct _TPM_SYM_CA_ATTESTATION
+{
+ UINT32 credSize;
+ TPM_KEY_PARMS algorithm;
+ UINT8 *credential;
+} TPM_SYM_CA_ATTESTATION;
+
+//
+// Part 2, section 15: TPM_CURRENT_TICKS
+// Placed here out of order because definitions are used in section 13.
+//
+typedef struct _TPM_CURRENT_TICKS {
+ TPM_STRUCTURE_TAG tag;
+ UINT64 currentTicks;
+ UINT16 tickRate;
+ TPM_NONCE tickNonce;
+} TPM_CURRENT_TICKS;
+
+//
+// Part 2, section 13: Transport structures
+//
+
+#define TPM_TRANSPORT_ENCRYPT ((UINT32)0x00000001)
+#define TPM_TRANSPORT_LOG ((UINT32)0x00000002)
+#define TPM_TRANSPORT_EXCLUSIVE ((UINT32)0x00000004)
+
+typedef struct _TPM_TRANSPORT_PUBLIC
+{
+ TPM_STRUCTURE_TAG tag;
+ TPM_TRANSPORT_ATTRIBUTES transAttributes;
+ TPM_ALGORITHM_ID algId;
+ TPM_ENC_SCHEME encScheme;
+} TPM_TRANSPORT_PUBLIC;
+
+typedef struct _TPM_TRANSPORT_INTERNAL
+{
+ TPM_STRUCTURE_TAG tag;
+ TPM_AUTHDATA authData;
+ TPM_TRANSPORT_PUBLIC transPublic;
+ TPM_TRANSHANDLE transHandle;
+ TPM_NONCE transNonceEven;
+ TPM_DIGEST transDigest;
+} TPM_TRANSPORT_INTERNAL;
+
+typedef struct _TPM_TRANSPORT_LOG_IN
+{
+ TPM_STRUCTURE_TAG tag;
+ TPM_DIGEST parameters;
+ TPM_DIGEST pubKeyHash;
+} TPM_TRANSPORT_LOG_IN;
+
+typedef struct _TPM_TRANSPORT_LOG_OUT
+{
+ TPM_STRUCTURE_TAG tag;
+ TPM_CURRENT_TICKS currentTicks;
+ TPM_DIGEST parameters;
+ TPM_MODIFIER_INDICATOR locality;
+} TPM_TRANSPORT_LOG_OUT;
+
+typedef struct _TPM_TRANSPORT_AUTH
+{
+ TPM_STRUCTURE_TAG tag;
+ TPM_AUTHDATA authData;
+} TPM_TRANSPORT_AUTH;
+
+//
+// Part 2, section 14: Audit Structures
+//
+
+typedef struct _TPM_AUDIT_EVENT_IN
+{
+ TPM_STRUCTURE_TAG tag;
+ TPM_DIGEST inputParms;
+ TPM_COUNTER_VALUE auditCount;
+} TPM_AUDIT_EVENT_IN;
+
+typedef struct _TPM_AUDIT_EVENT_OUT
+{
+ TPM_STRUCTURE_TAG tag;
+ TPM_COMMAND_CODE ordinal;
+ TPM_DIGEST outputParms;
+ TPM_COUNTER_VALUE auditCount;
+ TPM_RESULT returnCode;
+} TPM_AUDIT_EVENT_OUT;
+
+//
+// Part 2, section 16: Return Codes
+//
+#ifndef TPM_BASE
+#error "TPM Error Codes require definition of TPM_BASE"
+#endif
+
+#define TPM_VENDOR_ERROR TPM_Vendor_Specific32
+#define TPM_NON_FATAL 0x00000800
+
+#define TPM_SUCCESS ((TPM_RESULT) TPM_BASE)
+#define TPM_AUTHFAIL ((TPM_RESULT) (TPM_BASE + 1))
+#define TPM_BADINDEX ((TPM_RESULT) (TPM_BASE + 2))
+#define TPM_BAD_PARAMETER ((TPM_RESULT) (TPM_BASE + 3))
+#define TPM_AUDITFAILURE ((TPM_RESULT) (TPM_BASE + 4))
+#define TPM_CLEAR_DISABLED ((TPM_RESULT) (TPM_BASE + 5))
+#define TPM_DEACTIVATED ((TPM_RESULT) (TPM_BASE + 6))
+#define TPM_DISABLED ((TPM_RESULT) (TPM_BASE + 7))
+#define TPM_DISABLED_CMD ((TPM_RESULT) (TPM_BASE + 8))
+#define TPM_FAIL ((TPM_RESULT) (TPM_BASE + 9))
+#define TPM_BAD_ORDINAL ((TPM_RESULT) (TPM_BASE + 10))
+#define TPM_INSTALL_DISABLED ((TPM_RESULT) (TPM_BASE + 11))
+#define TPM_INVALID_KEYHANDLE ((TPM_RESULT) (TPM_BASE + 12))
+#define TPM_KEYNOTFOUND ((TPM_RESULT) (TPM_BASE + 13))
+#define TPM_INAPPROPRIATE_ENC ((TPM_RESULT) (TPM_BASE + 14))
+#define TPM_MIGRATEFAIL ((TPM_RESULT) (TPM_BASE + 15))
+#define TPM_INVALID_PCR_INFO ((TPM_RESULT) (TPM_BASE + 16))
+#define TPM_NOSPACE ((TPM_RESULT) (TPM_BASE + 17))
+#define TPM_NOSRK ((TPM_RESULT) (TPM_BASE + 18))
+#define TPM_NOTSEALED_BLOB ((TPM_RESULT) (TPM_BASE + 19))
+#define TPM_OWNER_SET ((TPM_RESULT) (TPM_BASE + 20))
+#define TPM_RESOURCES ((TPM_RESULT) (TPM_BASE + 21))
+#define TPM_SHORTRANDOM ((TPM_RESULT) (TPM_BASE + 22))
+#define TPM_SIZE ((TPM_RESULT) (TPM_BASE + 23))
+#define TPM_WRONGPCRVAL ((TPM_RESULT) (TPM_BASE + 24))
+#define TPM_BAD_PARAM_SIZE ((TPM_RESULT) (TPM_BASE + 25))
+#define TPM_SHA_THREAD ((TPM_RESULT) (TPM_BASE + 26))
+#define TPM_SHA_ERROR ((TPM_RESULT) (TPM_BASE + 27))
+#define TPM_FAILEDSELFTEST ((TPM_RESULT) (TPM_BASE + 28))
+#define TPM_AUTH2FAIL ((TPM_RESULT) (TPM_BASE + 29))
+#define TPM_BADTAG ((TPM_RESULT) (TPM_BASE + 30))
+#define TPM_IOERROR ((TPM_RESULT) (TPM_BASE + 31))
+#define TPM_ENCRYPT_ERROR ((TPM_RESULT) (TPM_BASE + 32))
+#define TPM_DECRYPT_ERROR ((TPM_RESULT) (TPM_BASE + 33))
+#define TPM_INVALID_AUTHHANDLE ((TPM_RESULT) (TPM_BASE + 34))
+#define TPM_NO_ENDORSEMENT ((TPM_RESULT) (TPM_BASE + 35))
+#define TPM_INVALID_KEYUSAGE ((TPM_RESULT) (TPM_BASE + 36))
+#define TPM_WRONG_ENTITYTYPE ((TPM_RESULT) (TPM_BASE + 37))
+#define TPM_INVALID_POSTINIT ((TPM_RESULT) (TPM_BASE + 38))
+#define TPM_INAPPROPRIATE_SIG ((TPM_RESULT) (TPM_BASE + 39))
+#define TPM_BAD_KEY_PROPERTY ((TPM_RESULT) (TPM_BASE + 40))
+#define TPM_BAD_MIGRATION ((TPM_RESULT) (TPM_BASE + 41))
+#define TPM_BAD_SCHEME ((TPM_RESULT) (TPM_BASE + 42))
+#define TPM_BAD_DATASIZE ((TPM_RESULT) (TPM_BASE + 43))
+#define TPM_BAD_MODE ((TPM_RESULT) (TPM_BASE + 44))
+#define TPM_BAD_PRESENCE ((TPM_RESULT) (TPM_BASE + 45))
+#define TPM_BAD_VERSION ((TPM_RESULT) (TPM_BASE + 46))
+#define TPM_NO_WRAP_TRANSPORT ((TPM_RESULT) (TPM_BASE + 47))
+#define TPM_AUDITFAIL_UNSUCCESSFUL ((TPM_RESULT) (TPM_BASE + 48))
+#define TPM_AUDITFAIL_SUCCESSFUL ((TPM_RESULT) (TPM_BASE + 49))
+#define TPM_NOTRESETABLE ((TPM_RESULT) (TPM_BASE + 50))
+#define TPM_NOTLOCAL ((TPM_RESULT) (TPM_BASE + 51))
+#define TPM_BAD_TYPE ((TPM_RESULT) (TPM_BASE + 52))
+#define TPM_INVALID_RESOURCE ((TPM_RESULT) (TPM_BASE + 53))
+#define TPM_NOTFIPS ((TPM_RESULT) (TPM_BASE + 54))
+#define TPM_INVALID_FAMILY ((TPM_RESULT) (TPM_BASE + 55))
+#define TPM_NO_NV_PERMISSION ((TPM_RESULT) (TPM_BASE + 56))
+#define TPM_REQUIRES_SIGN ((TPM_RESULT) (TPM_BASE + 57))
+#define TPM_KEY_NOTSUPPORTED ((TPM_RESULT) (TPM_BASE + 58))
+#define TPM_AUTH_CONFLICT ((TPM_RESULT) (TPM_BASE + 59))
+#define TPM_AREA_LOCKED ((TPM_RESULT) (TPM_BASE + 60))
+#define TPM_BAD_LOCALITY ((TPM_RESULT) (TPM_BASE + 61))
+#define TPM_READ_ONLY ((TPM_RESULT) (TPM_BASE + 62))
+#define TPM_PER_NOWRITE ((TPM_RESULT) (TPM_BASE + 63))
+#define TPM_FAMILYCOUNT ((TPM_RESULT) (TPM_BASE + 64))
+#define TPM_WRITE_LOCKED ((TPM_RESULT) (TPM_BASE + 65))
+#define TPM_BAD_ATTRIBUTES ((TPM_RESULT) (TPM_BASE + 66))
+#define TPM_INVALID_STRUCTURE ((TPM_RESULT) (TPM_BASE + 67))
+#define TPM_KEY_OWNER_CONTROL ((TPM_RESULT) (TPM_BASE + 68))
+#define TPM_BAD_COUNTER ((TPM_RESULT) (TPM_BASE + 69))
+#define TPM_NOT_FULLWRITE ((TPM_RESULT) (TPM_BASE + 70))
+#define TPM_CONTEXT_GAP ((TPM_RESULT) (TPM_BASE + 71))
+#define TPM_MAXNVWRITES ((TPM_RESULT) (TPM_BASE + 72))
+#define TPM_NOOPERATOR ((TPM_RESULT) (TPM_BASE + 73))
+#define TPM_RESOURCEMISSING ((TPM_RESULT) (TPM_BASE + 74))
+#define TPM_DELEGATE_LOCK ((TPM_RESULT) (TPM_BASE + 75))
+#define TPM_DELEGATE_FAMILY ((TPM_RESULT) (TPM_BASE + 76))
+#define TPM_DELEGATE_ADMIN ((TPM_RESULT) (TPM_BASE + 77))
+#define TPM_TRANSPORT_NOTEXCLUSIVE ((TPM_RESULT) (TPM_BASE + 78))
+#define TPM_OWNER_CONTROL ((TPM_RESULT) (TPM_BASE + 79))
+#define TPM_DAA_RESOURCES ((TPM_RESULT) (TPM_BASE + 80))
+#define TPM_DAA_INPUT_DATA0 ((TPM_RESULT) (TPM_BASE + 81))
+#define TPM_DAA_INPUT_DATA1 ((TPM_RESULT) (TPM_BASE + 82))
+#define TPM_DAA_ISSUER_SETTINGS ((TPM_RESULT) (TPM_BASE + 83))
+#define TPM_DAA_TPM_SETTINGS ((TPM_RESULT) (TPM_BASE + 84))
+#define TPM_DAA_STAGE ((TPM_RESULT) (TPM_BASE + 85))
+#define TPM_DAA_ISSUER_VALIDITY ((TPM_RESULT) (TPM_BASE + 86))
+#define TPM_DAA_WRONG_W ((TPM_RESULT) (TPM_BASE + 87))
+#define TPM_BAD_HANDLE ((TPM_RESULT) (TPM_BASE + 88))
+#define TPM_BAD_DELEGATE ((TPM_RESULT) (TPM_BASE + 89))
+#define TPM_BADCONTEXT ((TPM_RESULT) (TPM_BASE + 90))
+#define TPM_TOOMANYCONTEXTS ((TPM_RESULT) (TPM_BASE + 91))
+#define TPM_MA_TICKET_SIGNATURE ((TPM_RESULT) (TPM_BASE + 92))
+#define TPM_MA_DESTINATION ((TPM_RESULT) (TPM_BASE + 93))
+#define TPM_MA_SOURCE ((TPM_RESULT) (TPM_BASE + 94))
+#define TPM_MA_AUTHORITY ((TPM_RESULT) (TPM_BASE + 95))
+#define TPM_PERMANENTEK ((TPM_RESULT) (TPM_BASE + 97))
+#define TPM_BAD_SIGNATURE ((TPM_RESULT) (TPM_BASE + 98))
+#define TPM_NOCONTEXTSPACE ((TPM_RESULT) (TPM_BASE + 99))
+
+#define TPM_RETRY ((TPM_RESULT) (TPM_BASE + TPM_NON_FATAL))
+#define TPM_NEEDS_SELFTEST ((TPM_RESULT) (TPM_BASE + TPM_NON_FATAL + 1))
+#define TPM_DOING_SELFTEST ((TPM_RESULT) (TPM_BASE + TPM_NON_FATAL + 2))
+#define TPM_DEFEND_LOCK_RUNNING ((TPM_RESULT) (TPM_BASE + TPM_NON_FATAL + 3))
+
+//
+// Part 2, section 17: Ordinals
+//
+// Ordinals are 32 bit values. The upper byte contains values that serve as
+// flag indicators, the next byte contains values indicating what committee
+// designated the ordinal, and the final two bytes contain the Command
+// Ordinal Index.
+// 3 2 1
+// 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0 9 8 7 6 5 4 3 2 1 0
+// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+// |P|C|V| Reserved| Purview | Command Ordinal Index |
+// +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+//
+// Where:
+//
+// * P is Protected/Unprotected command. When 0 the command is a Protected
+// command, when 1 the command is an Unprotected command.
+//
+// * C is Non-Connection/Connection related command. When 0 this command
+// passes through to either the protected (TPM) or unprotected (TSS)
+// components.
+//
+// * V is TPM/Vendor command. When 0 the command is TPM defined, when 1 the
+// command is vendor defined.
+//
+// * All reserved area bits are set to 0.
+//
+
+#define TPM_ORD_ActivateIdentity ((TPM_COMMAND_CODE) 0x0000007A)
+#define TPM_ORD_AuthorizeMigrationKey ((TPM_COMMAND_CODE) 0x0000002B)
+#define TPM_ORD_CertifyKey ((TPM_COMMAND_CODE) 0x00000032)
+#define TPM_ORD_CertifyKey2 ((TPM_COMMAND_CODE) 0x00000033)
+#define TPM_ORD_CertifySelfTest ((TPM_COMMAND_CODE) 0x00000052)
+#define TPM_ORD_ChangeAuth ((TPM_COMMAND_CODE) 0x0000000C)
+#define TPM_ORD_ChangeAuthAsymFinish ((TPM_COMMAND_CODE) 0x0000000F)
+#define TPM_ORD_ChangeAuthAsymStart ((TPM_COMMAND_CODE) 0x0000000E)
+#define TPM_ORD_ChangeAuthOwner ((TPM_COMMAND_CODE) 0x00000010)
+#define TPM_ORD_CMK_ApproveMA ((TPM_COMMAND_CODE) 0x0000001D)
+#define TPM_ORD_CMK_ConvertMigration ((TPM_COMMAND_CODE) 0x00000024)
+#define TPM_ORD_CMK_CreateBlob ((TPM_COMMAND_CODE) 0x0000001B)
+#define TPM_ORD_CMK_CreateKey ((TPM_COMMAND_CODE) 0x00000013)
+#define TPM_ORD_CMK_CreateTicket ((TPM_COMMAND_CODE) 0x00000012)
+#define TPM_ORD_CMK_SetRestrictions ((TPM_COMMAND_CODE) 0x0000001C)
+#define TPM_ORD_ContinueSelfTest ((TPM_COMMAND_CODE) 0x00000053)
+#define TPM_ORD_ConvertMigrationBlob ((TPM_COMMAND_CODE) 0x0000002A)
+#define TPM_ORD_CreateCounter ((TPM_COMMAND_CODE) 0x000000DC)
+#define TPM_ORD_CreateEndorsementKeyPair ((TPM_COMMAND_CODE) 0x00000078)
+#define TPM_ORD_CreateMaintenanceArchive ((TPM_COMMAND_CODE) 0x0000002C)
+#define TPM_ORD_CreateMigrationBlob ((TPM_COMMAND_CODE) 0x00000028)
+#define TPM_ORD_CreateRevocableEK ((TPM_COMMAND_CODE) 0x0000007F)
+#define TPM_ORD_CreateWrapKey ((TPM_COMMAND_CODE) 0x0000001F)
+#define TPM_ORD_DAA_JOIN ((TPM_COMMAND_CODE) 0x00000029)
+#define TPM_ORD_DAA_SIGN ((TPM_COMMAND_CODE) 0x00000031)
+#define TPM_ORD_Delegate_CreateKeyDelegation ((TPM_COMMAND_CODE) 0x000000D4)
+#define TPM_ORD_Delegate_CreateOwnerDelegation ((TPM_COMMAND_CODE) 0x000000D5)
+#define TPM_ORD_Delegate_LoadOwnerDelegation ((TPM_COMMAND_CODE) 0x000000D8)
+#define TPM_ORD_Delegate_Manage ((TPM_COMMAND_CODE) 0x000000D2)
+#define TPM_ORD_Delegate_ReadTable ((TPM_COMMAND_CODE) 0x000000DB)
+#define TPM_ORD_Delegate_UpdateVerification ((TPM_COMMAND_CODE) 0x000000D1)
+#define TPM_ORD_Delegate_VerifyDelegation ((TPM_COMMAND_CODE) 0x000000D6)
+#define TPM_ORD_DirRead ((TPM_COMMAND_CODE) 0x0000001A)
+#define TPM_ORD_DirWriteAuth ((TPM_COMMAND_CODE) 0x00000019)
+#define TPM_ORD_DisableForceClear ((TPM_COMMAND_CODE) 0x0000005E)
+#define TPM_ORD_DisableOwnerClear ((TPM_COMMAND_CODE) 0x0000005C)
+#define TPM_ORD_DisablePubekRead ((TPM_COMMAND_CODE) 0x0000007E)
+#define TPM_ORD_DSAP ((TPM_COMMAND_CODE) 0x00000011)
+#define TPM_ORD_EstablishTransport ((TPM_COMMAND_CODE) 0x000000E6)
+#define TPM_ORD_EvictKey ((TPM_COMMAND_CODE) 0x00000022)
+#define TPM_ORD_ExecuteTransport ((TPM_COMMAND_CODE) 0x000000E7)
+#define TPM_ORD_Extend ((TPM_COMMAND_CODE) 0x00000014)
+#define TPM_ORD_FieldUpgrade ((TPM_COMMAND_CODE) 0x000000AA)
+#define TPM_ORD_FlushSpecific ((TPM_COMMAND_CODE) 0x000000BA)
+#define TPM_ORD_ForceClear ((TPM_COMMAND_CODE) 0x0000005D)
+#define TPM_ORD_GetAuditDigest ((TPM_COMMAND_CODE) 0x00000085)
+#define TPM_ORD_GetAuditDigestSigned ((TPM_COMMAND_CODE) 0x00000086)
+#define TPM_ORD_GetAuditEvent ((TPM_COMMAND_CODE) 0x00000082)
+#define TPM_ORD_GetAuditEventSigned ((TPM_COMMAND_CODE) 0x00000083)
+#define TPM_ORD_GetCapability ((TPM_COMMAND_CODE) 0x00000065)
+#define TPM_ORD_GetCapabilityOwner ((TPM_COMMAND_CODE) 0x00000066)
+#define TPM_ORD_GetCapabilitySigned ((TPM_COMMAND_CODE) 0x00000064)
+#define TPM_ORD_GetOrdinalAuditStatus ((TPM_COMMAND_CODE) 0x0000008C)
+#define TPM_ORD_GetPubKey ((TPM_COMMAND_CODE) 0x00000021)
+#define TPM_ORD_GetRandom ((TPM_COMMAND_CODE) 0x00000046)
+#define TPM_ORD_GetTestResult ((TPM_COMMAND_CODE) 0x00000054)
+#define TPM_ORD_GetTicks ((TPM_COMMAND_CODE) 0x000000F1)
+#define TPM_ORD_IncrementCounter ((TPM_COMMAND_CODE) 0x000000DD)
+#define TPM_ORD_Init ((TPM_COMMAND_CODE) 0x00000097)
+#define TPM_ORD_KeyControlOwner ((TPM_COMMAND_CODE) 0x00000023)
+#define TPM_ORD_KillMaintenanceFeature ((TPM_COMMAND_CODE) 0x0000002E)
+#define TPM_ORD_LoadAuthContext ((TPM_COMMAND_CODE) 0x000000B7)
+#define TPM_ORD_LoadContext ((TPM_COMMAND_CODE) 0x000000B9)
+#define TPM_ORD_LoadKey ((TPM_COMMAND_CODE) 0x00000020)
+#define TPM_ORD_LoadKey2 ((TPM_COMMAND_CODE) 0x00000041)
+#define TPM_ORD_LoadKeyContext ((TPM_COMMAND_CODE) 0x000000B5)
+#define TPM_ORD_LoadMaintenanceArchive ((TPM_COMMAND_CODE) 0x0000002D)
+#define TPM_ORD_LoadManuMaintPub ((TPM_COMMAND_CODE) 0x0000002F)
+#define TPM_ORD_MakeIdentity ((TPM_COMMAND_CODE) 0x00000079)
+#define TPM_ORD_MigrateKey ((TPM_COMMAND_CODE) 0x00000025)
+#define TPM_ORD_NV_DefineSpace ((TPM_COMMAND_CODE) 0x000000CC)
+#define TPM_ORD_NV_ReadValue ((TPM_COMMAND_CODE) 0x000000CF)
+#define TPM_ORD_NV_ReadValueAuth ((TPM_COMMAND_CODE) 0x000000D0)
+#define TPM_ORD_NV_WriteValue ((TPM_COMMAND_CODE) 0x000000CD)
+#define TPM_ORD_NV_WriteValueAuth ((TPM_COMMAND_CODE) 0x000000CE)
+#define TPM_ORD_OIAP ((TPM_COMMAND_CODE) 0x0000000A)
+#define TPM_ORD_OSAP ((TPM_COMMAND_CODE) 0x0000000B)
+#define TPM_ORD_OwnerClear ((TPM_COMMAND_CODE) 0x0000005B)
+#define TPM_ORD_OwnerReadInternalPub ((TPM_COMMAND_CODE) 0x00000081)
+#define TPM_ORD_OwnerReadPubek ((TPM_COMMAND_CODE) 0x0000007D)
+#define TPM_ORD_OwnerSetDisable ((TPM_COMMAND_CODE) 0x0000006E)
+#define TPM_ORD_PCR_Reset ((TPM_COMMAND_CODE) 0x000000C8)
+#define TPM_ORD_PcrRead ((TPM_COMMAND_CODE) 0x00000015)
+#define TPM_ORD_PhysicalDisable ((TPM_COMMAND_CODE) 0x00000070)
+#define TPM_ORD_PhysicalEnable ((TPM_COMMAND_CODE) 0x0000006F)
+#define TPM_ORD_PhysicalSetDeactivated ((TPM_COMMAND_CODE) 0x00000072)
+#define TPM_ORD_Quote ((TPM_COMMAND_CODE) 0x00000016)
+#define TPM_ORD_Quote2 ((TPM_COMMAND_CODE) 0x0000003E)
+#define TPM_ORD_ReadCounter ((TPM_COMMAND_CODE) 0x000000DE)
+#define TPM_ORD_ReadManuMaintPub ((TPM_COMMAND_CODE) 0x00000030)
+#define TPM_ORD_ReadPubek ((TPM_COMMAND_CODE) 0x0000007C)
+#define TPM_ORD_ReleaseCounter ((TPM_COMMAND_CODE) 0x000000DF)
+#define TPM_ORD_ReleaseCounterOwner ((TPM_COMMAND_CODE) 0x000000E0)
+#define TPM_ORD_ReleaseTransportSigned ((TPM_COMMAND_CODE) 0x000000E8)
+#define TPM_ORD_Reset ((TPM_COMMAND_CODE) 0x0000005A)
+#define TPM_ORD_ResetLockValue ((TPM_COMMAND_CODE) 0x00000040)
+#define TPM_ORD_RevokeTrust ((TPM_COMMAND_CODE) 0x00000080)
+#define TPM_ORD_SaveAuthContext ((TPM_COMMAND_CODE) 0x000000B6)
+#define TPM_ORD_SaveContext ((TPM_COMMAND_CODE) 0x000000B8)
+#define TPM_ORD_SaveKeyContext ((TPM_COMMAND_CODE) 0x000000B4)
+#define TPM_ORD_SaveState ((TPM_COMMAND_CODE) 0x00000098)
+#define TPM_ORD_Seal ((TPM_COMMAND_CODE) 0x00000017)
+#define TPM_ORD_Sealx ((TPM_COMMAND_CODE) 0x0000003D)
+#define TPM_ORD_SelfTestFull ((TPM_COMMAND_CODE) 0x00000050)
+#define TPM_ORD_SetCapability ((TPM_COMMAND_CODE) 0x0000003F)
+#define TPM_ORD_SetOperatorAuth ((TPM_COMMAND_CODE) 0x00000074)
+#define TPM_ORD_SetOrdinalAuditStatus ((TPM_COMMAND_CODE) 0x0000008D)
+#define TPM_ORD_SetOwnerInstall ((TPM_COMMAND_CODE) 0x00000071)
+#define TPM_ORD_SetOwnerPointer ((TPM_COMMAND_CODE) 0x00000075)
+#define TPM_ORD_SetRedirection ((TPM_COMMAND_CODE) 0x0000009A)
+#define TPM_ORD_SetTempDeactivated ((TPM_COMMAND_CODE) 0x00000073)
+#define TPM_ORD_SHA1Complete ((TPM_COMMAND_CODE) 0x000000A2)
+#define TPM_ORD_SHA1CompleteExtend ((TPM_COMMAND_CODE) 0x000000A3)
+#define TPM_ORD_SHA1Start ((TPM_COMMAND_CODE) 0x000000A0)
+#define TPM_ORD_SHA1Update ((TPM_COMMAND_CODE) 0x000000A1)
+#define TPM_ORD_Sign ((TPM_COMMAND_CODE) 0x0000003C)
+#define TPM_ORD_Startup ((TPM_COMMAND_CODE) 0x00000099)
+#define TPM_ORD_StirRandom ((TPM_COMMAND_CODE) 0x00000047)
+#define TPM_ORD_TakeOwnership ((TPM_COMMAND_CODE) 0x0000000D)
+#define TPM_ORD_Terminate_Handle ((TPM_COMMAND_CODE) 0x00000096)
+#define TPM_ORD_TickStampBlob ((TPM_COMMAND_CODE) 0x000000F2)
+#define TPM_ORD_UnBind ((TPM_COMMAND_CODE) 0x0000001E)
+#define TPM_ORD_Unseal ((TPM_COMMAND_CODE) 0x00000018)
+#define TSC_ORD_PhysicalPresence ((TPM_COMMAND_CODE) 0x4000000A)
+#define TSC_ORD_ResetEstablishmentBit ((TPM_COMMAND_CODE) 0x4000000B)
+
+//
+// Part 2, section 18: Context structures
+//
+
+typedef struct _TPM_CONTEXT_BLOB
+{
+ TPM_STRUCTURE_TAG tag;
+ TPM_RESOURCE_TYPE resourceType;
+ TPM_HANDLE handle;
+ UINT8 label[16];
+ UINT32 contextCount;
+ TPM_DIGEST integrityDigest;
+ UINT32 additionalSize;
+ UINT8 *additionalData;
+ UINT32 sensitiveSize;
+ UINT8 *sensitiveData;
+} TPM_CONTEXT_BLOB;
+
+typedef struct _TPM_CONTEXT_SENSITIVE
+{
+ TPM_STRUCTURE_TAG tag;
+ TPM_NONCE contextNonce;
+ UINT32 internalSize;
+ UINT8 *internalData;
+} TPM_CONTEXT_SENSITIVE;
+
+//
+// Part 2, section 19: NV Structures
+//
+
+#define TPM_NV_INDEX_LOCK ((UINT32)0xffffffff)
+#define TPM_NV_INDEX0 ((UINT32)0x00000000)
+#define TPM_NV_INDEX_DIR ((UINT32)0x10000001)
+#define TPM_NV_INDEX_EKCert ((UINT32)0x0000f000)
+#define TPM_NV_INDEX_TPM_CC ((UINT32)0x0000f001)
+#define TPM_NV_INDEX_PlatformCert ((UINT32)0x0000f002)
+#define TPM_NV_INDEX_Platform_CC ((UINT32)0x0000f003)
+// The following define ranges of reserved indices.
+#define TPM_NV_INDEX_TSS_BASE ((UINT32)0x00011100)
+#define TPM_NV_INDEX_PC_BASE ((UINT32)0x00011200)
+#define TPM_NV_INDEX_SERVER_BASE ((UINT32)0x00011300)
+#define TPM_NV_INDEX_MOBILE_BASE ((UINT32)0x00011400)
+#define TPM_NV_INDEX_PERIPHERAL_BASE ((UINT32)0x00011500)
+#define TPM_NV_INDEX_GROUP_RESV_BASE ((UINT32)0x00010000)
+
+typedef UINT32 TPM_NV_PER_ATTRIBUTES;
+// The typedefs TPM_NV_PER_ATTRIBUTES (not present in TPM 1.2 Spec. have been added
+// and structure fields that were to hold the following values
+#define TPM_NV_PER_READ_STCLEAR (((UINT32)1)<<31)
+#define TPM_NV_PER_AUTHREAD (((UINT32)1)<<18)
+#define TPM_NV_PER_OWNERREAD (((UINT32)1)<<17)
+#define TPM_NV_PER_PPREAD (((UINT32)1)<<16)
+#define TPM_NV_PER_GLOBALLOCK (((UINT32)1)<<15)
+#define TPM_NV_PER_WRITE_STCLEAR (((UINT32)1)<<14)
+#define TPM_NV_PER_WRITEDEFINE (((UINT32)1)<<13)
+#define TPM_NV_PER_WRITEALL (((UINT32)1)<<12)
+#define TPM_NV_PER_AUTHWRITE (((UINT32)1)<<2)
+#define TPM_NV_PER_OWNERWRITE (((UINT32)1)<<1)
+#define TPM_NV_PER_PPWRITE (((UINT32)1)<<0)
+
+typedef struct _TPM_NV_ATTRIBUTES
+{
+ TPM_STRUCTURE_TAG tag;
+ TPM_NV_PER_ATTRIBUTES attributes;
+} TPM_NV_ATTRIBUTES;
+
+
+typedef struct _TPM_NV_DATA_PUBLIC
+{
+ TPM_STRUCTURE_TAG tag;
+ TPM_NV_INDEX nvIndex;
+ TPM_PCR_INFO_SHORT pcrInfoRead;
+ TPM_PCR_INFO_SHORT pcrInfoWrite;
+ TPM_NV_ATTRIBUTES permission;
+ BOOLEAN bReadSTClear;
+ BOOLEAN bWriteSTClear;
+ BOOLEAN bWriteDefine;
+ UINT32 dataSize;
+} TPM_NV_DATA_PUBLIC;
+
+
+
+// Internal to TPM:
+//typedef struct _TPM_NV_DATA_SENSITIVE
+//{
+// TPM_STRUCTURE_TAG tag;
+// TPM_NV_DATA_PUBLIC pubInfo;
+// TPM_AUTHDATA authValue;
+// UINT8 *data;
+//} TPM_NV_DATA_SENSITIVE;
+
+
+//
+// Part 2, section 20: Delegation
+//
+
+//
+// Part 2, section 20.2.1: Owner Permissions Settings for per1 bits
+//
+#define TPM_DELEGATE_SetOrdinalAuditStatus (((UINT32)1)<<30)
+#define TPM_DELEGATE_DirWriteAuth (((UINT32)1)<<29)
+#define TPM_DELEGATE_CMK_ApproveMA (((UINT32)1)<<28)
+#define TPM_DELEGATE_NV_WriteValue (((UINT32)1)<<27)
+#define TPM_DELEGATE_CMK_CreateTicket (((UINT32)1)<<26)
+#define TPM_DELEGATE_NV_ReadValue (((UINT32)1)<<25)
+#define TPM_DELEGATE_Delegate_LoadOwnerDelegation (((UINT32)1)<<24)
+#define TPM_DELEGATE_DAA_Join (((UINT32)1)<<23)
+#define TPM_DELEGATE_AuthorizeMigrationKey (((UINT32)1)<<22)
+#define TPM_DELEGATE_CreateMaintenanceArchive (((UINT32)1)<<21)
+#define TPM_DELEGATE_LoadMaintenanceArchive (((UINT32)1)<<20)
+#define TPM_DELEGATE_KillMaintenanceFeature (((UINT32)1)<<19)
+#define TPM_DELEGATE_OwnerReadInteralPub (((UINT32)1)<<18)
+#define TPM_DELEGATE_ResetLockValue (((UINT32)1)<<17)
+#define TPM_DELEGATE_OwnerClear (((UINT32)1)<<16)
+#define TPM_DELEGATE_DisableOwnerClear (((UINT32)1)<<15)
+#define TPM_DELEGATE_NV_DefineSpace (((UINT32)1)<<14)
+#define TPM_DELEGATE_OwnerSetDisable (((UINT32)1)<<13)
+#define TPM_DELEGATE_SetCapability (((UINT32)1)<<12)
+#define TPM_DELEGATE_MakeIdentity (((UINT32)1)<<11)
+#define TPM_DELEGATE_ActivateIdentity (((UINT32)1)<<10)
+#define TPM_DELEGATE_OwnerReadPubek (((UINT32)1)<<9)
+#define TPM_DELEGATE_DisablePubekRead (((UINT32)1)<<8)
+#define TPM_DELEGATE_SetRedirection (((UINT32)1)<<7)
+#define TPM_DELEGATE_FieldUpgrade (((UINT32)1)<<6)
+#define TPM_DELEGATE_Delegate_UpdateVerification (((UINT32)1)<<5)
+#define TPM_DELEGATE_CreateCounter (((UINT32)1)<<4)
+#define TPM_DELEGATE_ReleaseCounterOwner (((UINT32)1)<<3)
+#define TPM_DELEGATE_DelegateManage (((UINT32)1)<<2)
+#define TPM_DELEGATE_Delegate_CreateOwnerDelegation (((UINT32)1)<<1)
+#define TPM_DELEGATE_DAA_Sign (((UINT32)1)<<0)
+
+//
+// Part 2, section 20.2.3: Key Permissions Settings for per1 bits
+//
+#define TPM_KEY_DELEGATE_CMK_ConvertMigration (((UINT32)1)<<28)
+#define TPM_KEY_DELEGATE_TickStampBlob (((UINT32)1)<<27)
+#define TPM_KEY_DELEGATE_ChangeAuthAsymStart (((UINT32)1)<<26)
+#define TPM_KEY_DELEGATE_ChangeAuthAsymFinish (((UINT32)1)<<25)
+#define TPM_KEY_DELEGATE_CMK_CreateKey (((UINT32)1)<<24)
+#define TPM_KEY_DELEGATE_MigrateKey (((UINT32)1)<<23)
+#define TPM_KEY_DELEGATE_LoadKey2 (((UINT32)1)<<22)
+#define TPM_KEY_DELEGATE_EstablishTransport (((UINT32)1)<<21)
+#define TPM_KEY_DELEGATE_ReleaseTransportSigned (((UINT32)1)<<20)
+#define TPM_KEY_DELEGATE_Quote2 (((UINT32)1)<<19)
+#define TPM_KEY_DELEGATE_Sealx (((UINT32)1)<<18)
+#define TPM_KEY_DELEGATE_MakeIdentity (((UINT32)1)<<17)
+#define TPM_KEY_DELEGATE_ActivateIdentity (((UINT32)1)<<16)
+#define TPM_KEY_DELEGATE_GetAuditDigestSigned (((UINT32)1)<<15)
+#define TPM_KEY_DELEGATE_Sign (((UINT32)1)<<14)
+#define TPM_KEY_DELEGATE_CertifyKey2 (((UINT32)1)<<13)
+#define TPM_KEY_DELEGATE_CertifyKey (((UINT32)1)<<12)
+#define TPM_KEY_DELEGATE_CreateWrapKey (((UINT32)1)<<11)
+#define TPM_KEY_DELEGATE_CMK_CreateBlob (((UINT32)1)<<10)
+#define TPM_KEY_DELEGATE_CreateMigrationBlob (((UINT32)1)<<9)
+#define TPM_KEY_DELEGATE_ConvertMigrationBlob (((UINT32)1)<<8)
+#define TPM_KEY_DELEGATE_CreateKeyDelegation (((UINT32)1)<<7)
+#define TPM_KEY_DELEGATE_ChangeAuth (((UINT32)1)<<6)
+#define TPM_KEY_DELEGATE_GetPubKey (((UINT32)1)<<5)
+#define TPM_KEY_DELEGATE_UnBind (((UINT32)1)<<4)
+#define TPM_KEY_DELEGATE_Quote (((UINT32)1)<<3)
+#define TPM_KEY_DELEGATE_Unseal (((UINT32)1)<<2)
+#define TPM_KEY_DELEGATE_Seal (((UINT32)1)<<1)
+#define TPM_KEY_DELEGATE_LoadKey (((UINT32)1)<<0)
+
+#define TPM_FAMILY_CREATE ((UINT32)0x00000001)
+#define TPM_FAMILY_ENABLE ((UINT32)0x00000002)
+#define TPM_FAMILY_ADMIN ((UINT32)0x00000003)
+#define TPM_FAMILY_INVALIDATE ((UINT32)0x00000004)
+
+#define TPM_FAMFLAG_DELEGATE_ADMIN_LOCK (((UINT32)1)<<1)
+#define TPM_FAMFLAG_ENABLE (((UINT32)1)<<0)
+
+typedef struct _TPM_FAMILY_LABEL
+{
+ UINT8 label;
+} TPM_FAMILY_LABEL;
+
+typedef struct _TPM_FAMILY_TABLE_ENTRY
+{
+ TPM_STRUCTURE_TAG tag;
+ TPM_FAMILY_LABEL label;
+ TPM_FAMILY_ID familyID;
+ TPM_FAMILY_VERIFICATION verificationCount;
+ TPM_FAMILY_FLAGS flags;
+} TPM_FAMILY_TABLE_ENTRY;
+
+#define TPM_FAMILY_TABLE_ENTRY_MIN 8
+//typedef struct _TPM_FAMILY_TABLE
+//{
+// TPM_FAMILY_TABLE_ENTRY FamTableRow[TPM_NUM_FAMILY_TABLE_ENTRY_MIN];
+//} TPM_FAMILY_TABLE;
+
+
+typedef struct _TPM_DELEGATE_LABEL
+{
+ UINT8 label;
+} TPM_DELEGATE_LABEL;
+
+
+typedef UINT32 TPM_DELEGATE_TYPE;
+#define TPM_DEL_OWNER_BITS ((UINT32)0x00000001)
+#define TPM_DEL_KEY_BITS ((UINT32)0x00000002)
+
+typedef struct _TPM_DELEGATIONS
+{
+ TPM_STRUCTURE_TAG tag;
+ TPM_DELEGATE_TYPE delegateType;
+ UINT32 per1;
+ UINT32 per2;
+} TPM_DELEGATIONS;
+
+typedef struct _TPM_DELEGATE_PUBLIC
+{
+ TPM_STRUCTURE_TAG tag;
+ TPM_DELEGATE_LABEL label;
+ TPM_PCR_INFO_SHORT pcrInfo;
+ TPM_DELEGATIONS permissions;
+ TPM_FAMILY_ID familyID;
+ TPM_FAMILY_VERIFICATION verificationCount;
+} TPM_DELEGATE_PUBLIC;
+
+typedef struct _TPM_DELEGATE_TABLE_ROW
+{
+ TPM_STRUCTURE_TAG tag;
+ TPM_DELEGATE_PUBLIC pub;
+ TPM_SECRET authValue;
+} TPM_DELEGATE_TABLE_ROW;
+
+
+#define TPM_NUM_DELEGATE_TABLE_ENTRY_MIN 2
+//typedef struct _TPM_DELEGATE_TABLE
+//{
+// TPM_DELEGATE_TABLE_ROW delRow[TPM_NUM_DELEGATE_TABLE_ENTRY_MIN];
+//} TPM_DELEGATE_TABLE;
+
+typedef struct _TPM_DELEGATE_SENSITIVE
+{
+ TPM_STRUCTURE_TAG tag;
+ TPM_SECRET authValue;
+} TPM_DELEGATE_SENSITIVE;
+
+typedef struct _TPM_DELEGATE_OWNER_BLOB
+{
+ TPM_STRUCTURE_TAG tag;
+ TPM_DELEGATE_PUBLIC pub;
+ TPM_DIGEST integrityDigest;
+ UINT32 additionalSize;
+ UINT8 *additionalArea;
+ UINT32 sensitiveSize;
+ UINT8 *sensitiveArea;
+} TPM_DELEGATE_OWNER_BLOB;
+
+typedef struct _TPM_DELEGATE_KEY_BLOB
+{
+ TPM_STRUCTURE_TAG tag;
+ TPM_DELEGATE_PUBLIC pub;
+ TPM_DIGEST integrityDigest;
+ TPM_DIGEST pubKeyDigest;
+ UINT32 additionalSize;
+ UINT8 *additionalArea;
+ UINT32 sensitiveSize;
+ UINT8 *sensitiveArea;
+} TPM_DELEGATE_KEY_BLOB;
+
+//
+// Part 2, section 21.1: TPM_CAPABILITY_AREA for GetCapability
+//
+#define TPM_CAP_ORD ((TPM_CAPABILITY_AREA) 0x00000001)
+#define TPM_CAP_ALG ((TPM_CAPABILITY_AREA) 0x00000002)
+#define TPM_CAP_PID ((TPM_CAPABILITY_AREA) 0x00000003)
+#define TPM_CAP_FLAG ((TPM_CAPABILITY_AREA) 0x00000004)
+#define TPM_CAP_PROPERTY ((TPM_CAPABILITY_AREA) 0x00000005)
+#define TPM_CAP_VERSION ((TPM_CAPABILITY_AREA) 0x00000006)
+#define TPM_CAP_KEY_HANDLE ((TPM_CAPABILITY_AREA) 0x00000007)
+#define TPM_CAP_CHECK_LOADED ((TPM_CAPABILITY_AREA) 0x00000008)
+#define TPM_CAP_SYM_MODE ((TPM_CAPABILITY_AREA) 0x00000009)
+#define TPM_CAP_KEY_STATUS ((TPM_CAPABILITY_AREA) 0x0000000C)
+#define TPM_CAP_NV_LIST ((TPM_CAPABILITY_AREA) 0x0000000D)
+#define TPM_CAP_MFR ((TPM_CAPABILITY_AREA) 0x00000010)
+#define TPM_CAP_NV_INDEX ((TPM_CAPABILITY_AREA) 0x00000011)
+#define TPM_CAP_TRANS_ALG ((TPM_CAPABILITY_AREA) 0x00000012)
+#define TPM_CAP_HANDLE ((TPM_CAPABILITY_AREA) 0x00000014)
+#define TPM_CAP_TRANS_ES ((TPM_CAPABILITY_AREA) 0x00000015)
+#define TPM_CAP_AUTH_ENCRYPT ((TPM_CAPABILITY_AREA) 0x00000017)
+#define TPM_CAP_SELECT_SIZE ((TPM_CAPABILITY_AREA) 0x00000018)
+#define TPM_CAP_VERSION_VAL ((TPM_CAPABILITY_AREA) 0x0000001A)
+
+#define TPM_CAP_FLAG_PERMANENT ((TPM_CAPABILITY_AREA) 0x00000108)
+#define TPM_CAP_FLAG_VOLATILE ((TPM_CAPABILITY_AREA) 0x00000109)
+
+//
+// Part 2, section 21.2: CAP_PROPERTY Subcap values for GetCapability
+//
+#define TPM_CAP_PROP_PCR ((TPM_CAPABILITY_AREA) 0x00000101)
+#define TPM_CAP_PROP_DIR ((TPM_CAPABILITY_AREA) 0x00000102)
+#define TPM_CAP_PROP_MANUFACTURER ((TPM_CAPABILITY_AREA) 0x00000103)
+#define TPM_CAP_PROP_KEYS ((TPM_CAPABILITY_AREA) 0x00000104)
+#define TPM_CAP_PROP_MIN_COUNTER ((TPM_CAPABILITY_AREA) 0x00000107)
+#define TPM_CAP_PROP_AUTHSESS ((TPM_CAPABILITY_AREA) 0x0000010A)
+#define TPM_CAP_PROP_TRANSESS ((TPM_CAPABILITY_AREA) 0x0000010B)
+#define TPM_CAP_PROP_COUNTERS ((TPM_CAPABILITY_AREA) 0x0000010C)
+#define TPM_CAP_PROP_MAX_AUTHSESS ((TPM_CAPABILITY_AREA) 0x0000010D)
+#define TPM_CAP_PROP_MAX_TRANSESS ((TPM_CAPABILITY_AREA) 0x0000010E)
+#define TPM_CAP_PROP_MAX_COUNTERS ((TPM_CAPABILITY_AREA) 0x0000010F)
+#define TPM_CAP_PROP_MAX_KEYS ((TPM_CAPABILITY_AREA) 0x00000110)
+#define TPM_CAP_PROP_OWNER ((TPM_CAPABILITY_AREA) 0x00000111)
+#define TPM_CAP_PROP_CONTEXT ((TPM_CAPABILITY_AREA) 0x00000112)
+#define TPM_CAP_PROP_MAX_CONTEXT ((TPM_CAPABILITY_AREA) 0x00000113)
+#define TPM_CAP_PROP_FAMILYROWS ((TPM_CAPABILITY_AREA) 0x00000114)
+#define TPM_CAP_PROP_TIS_TIMEOUT ((TPM_CAPABILITY_AREA) 0x00000115)
+#define TPM_CAP_PROP_STARTUP_EFFECT ((TPM_CAPABILITY_AREA) 0x00000116)
+#define TPM_CAP_PROP_DELEGATE_ROW ((TPM_CAPABILITY_AREA) 0x00000117)
+#define TPM_CAP_PROP_DAA_MAX ((TPM_CAPABILITY_AREA) 0x00000119)
+#define CAP_PROP_SESSION_DAA ((TPM_CAPABILITY_AREA) 0x0000011A)
+#define TPM_CAP_PROP_CONTEXT_DIST ((TPM_CAPABILITY_AREA) 0x0000011B)
+#define TPM_CAP_PROP_DAA_INTERRUPT ((TPM_CAPABILITY_AREA) 0x0000011C)
+#define TPM_CAP_PROP_SESSIONS ((TPM_CAPABILITY_AREA) 0x0000011D)
+#define TPM_CAP_PROP_MAX_SESSIONS ((TPM_CAPABILITY_AREA) 0x0000011E)
+#define TPM_CAP_PROP_CMK_RESTRICTION ((TPM_CAPABILITY_AREA) 0x0000011F)
+#define TPM_CAP_PROP_DURATION ((TPM_CAPABILITY_AREA) 0x00000120)
+#define TPM_CAP_PROP_ACTIVE_COUNTER ((TPM_CAPABILITY_AREA) 0x00000122)
+#define TPM_CAP_PROP_MAX_NV_AVAILABLE ((TPM_CAPABILITY_AREA) 0x00000123)
+#define TPM_CAP_PROP_INPUT_BUFFER ((TPM_CAPABILITY_AREA) 0x00000124)
+
+//
+// Part 2, section 21.4: TPM_CAPABILITY_AREA for SetCapability
+//
+#define TPM_SET_PERM_FLAGS ((TPM_CAPABILITY_AREA) 0x00000001)
+#define TPM_SET_PERM_DATA ((TPM_CAPABILITY_AREA) 0x00000002)
+#define TPM_SET_STCLEAR_FLAGS ((TPM_CAPABILITY_AREA) 0x00000003)
+#define TPM_SET_STCLEAR_DATA ((TPM_CAPABILITY_AREA) 0x00000004)
+#define TPM_SET_STANY_FLAGS ((TPM_CAPABILITY_AREA) 0x00000005)
+#define TPM_SET_STANY_DATA ((TPM_CAPABILITY_AREA) 0x00000006)
+
+// Part 2, section 21.6: TPM_CAP_VERSION_INFO
+// [size_is(vendorSpecificSize)] BYTE* vendorSpecific;
+//
+typedef struct _TPM_CAP_VERSION_INFO {
+ TPM_STRUCTURE_TAG tag;
+ TPM_VERSION version;
+ UINT16 specLevel;
+ UINT8 errataRev;
+ UINT8 tpmVendorID[4];
+ UINT16 vendorSpecificSize;
+ UINT8 *vendorSpecific;
+} TPM_CAP_VERSION_INFO;
+
+//
+// Part 2, section 21.10: TPM_DA_ACTION_TYPE
+//
+typedef struct _TPM_DA_ACTION_TYPE {
+ TPM_STRUCTURE_TAG tag;
+ UINT32 actions;
+} TPM_DA_ACTION_TYPE;
+
+#define TPM_DA_ACTION_FAILURE_MODE (((UINT32)1)<<3)
+#define TPM_DA_ACTION_DEACTIVATE (((UINT32)1)<<2)
+#define TPM_DA_ACTION_DISABLE (((UINT32)1)<<1)
+#define TPM_DA_ACTION_TIMEOUT (((UINT32)1)<<0)
+
+//
+// Part 2, section 21.7: TPM_DA_INFO
+//
+typedef struct _TPM_DA_INFO {
+ TPM_STRUCTURE_TAG tag;
+ TPM_DA_STATE state;
+ UINT16 currentCount;
+ UINT16 thresholdCount;
+ TPM_DA_ACTION_TYPE actionAtThreshold;
+ UINT32 actionDependValue;
+ UINT32 vendorDataSize;
+ UINT8 *vendorData;
+} TPM_DA_INFO;
+
+//
+// Part 2, section 21.8: TPM_DA_INFO_LIMITED
+//
+typedef struct _TPM_DA_INFO_LIMITED {
+ TPM_STRUCTURE_TAG tag;
+ TPM_DA_STATE state;
+ TPM_DA_ACTION_TYPE actionAtThreshold;
+ UINT32 vendorDataSize;
+ UINT8 *vendorData;
+} TPM_DA_INFO_LIMITED;
+
+//
+// Part 2, section 21.9: CAP_PROPERTY Subcap values for GetCapability
+//
+#define TPM_DA_STATE_INACTIVE ((UINT8)0x00)
+#define TPM_DA_STATE_ACTIVE ((UINT8)0x01)
+
+//
+// Part 2, section 22: DAA Structures
+//
+
+#define TPM_DAA_SIZE_r0 (43)
+#define TPM_DAA_SIZE_r1 (43)
+#define TPM_DAA_SIZE_r2 (128)
+#define TPM_DAA_SIZE_r3 (168)
+#define TPM_DAA_SIZE_r4 (219)
+#define TPM_DAA_SIZE_NT (20)
+#define TPM_DAA_SIZE_v0 (128)
+#define TPM_DAA_SIZE_v1 (192)
+#define TPM_DAA_SIZE_NE (256)
+#define TPM_DAA_SIZE_w (256)
+#define TPM_DAA_SIZE_issuerModulus (256)
+#define TPM_DAA_power0 (104)
+#define TPM_DAA_power1 (1024)
+
+typedef struct _TPM_DAA_ISSUER
+{
+ TPM_STRUCTURE_TAG tag;
+ TPM_DIGEST DAA_digest_R0;
+ TPM_DIGEST DAA_digest_R1;
+ TPM_DIGEST DAA_digest_S0;
+ TPM_DIGEST DAA_digest_S1;
+ TPM_DIGEST DAA_digest_n;
+ TPM_DIGEST DAA_digest_gamma;
+ UINT8 DAA_generic_q[26];
+} TPM_DAA_ISSUER;
+
+
+typedef struct _TPM_DAA_TPM
+{
+ TPM_STRUCTURE_TAG tag;
+ TPM_DIGEST DAA_digestIssuer;
+ TPM_DIGEST DAA_digest_v0;
+ TPM_DIGEST DAA_digest_v1;
+ TPM_DIGEST DAA_rekey;
+ UINT32 DAA_count;
+} TPM_DAA_TPM;
+
+typedef struct _TPM_DAA_CONTEXT
+{
+ TPM_STRUCTURE_TAG tag;
+ TPM_DIGEST DAA_digestContext;
+ TPM_DIGEST DAA_digest;
+ TPM_DAA_CONTEXT_SEED DAA_contextSeed;
+ UINT8 DAA_scratch[256];
+ UINT8 DAA_stage;
+} TPM_DAA_CONTEXT;
+
+typedef struct _TPM_DAA_JOINDATA
+{
+ UINT8 DAA_join_u0[128];
+ UINT8 DAA_join_u1[138];
+ TPM_DIGEST DAA_digest_n0;
+} TPM_DAA_JOINDATA;
+
+typedef struct _TPM_DAA_BLOB
+{
+ TPM_STRUCTURE_TAG tag;
+ TPM_RESOURCE_TYPE resourceType;
+ UINT8 label[16];
+ TPM_DIGEST blobIntegrity;
+ UINT32 additionalSize;
+ UINT8 *additionalData;
+ UINT32 sensitiveSize;
+ UINT8 *sensitiveData;
+} TPM_DAA_BLOB;
+
+typedef struct _TPM_DAA_SENSITIVE
+{
+ TPM_STRUCTURE_TAG tag;
+ UINT32 internalSize;
+ UINT8 *internalData;
+} TPM_DAA_SENSITIVE;
+
+
+//
+// Part 2, section 23: Redirection
+//
+
+// This section of the TPM spec defines exactly one value but does not
+// give it a name. The definition of TPM_SetRedirection in Part3
+// refers to exactly one name but does not give its value. We join
+// them here.
+#define TPM_REDIR_GPIO (0x00000001)
+
+//
+// TPM Command & Response Headers
+//
+typedef struct _TPM_RQU_COMMAND_HDR {
+ TPM_STRUCTURE_TAG tag;
+ UINT32 paramSize;
+ TPM_COMMAND_CODE ordinal;
+} TPM_RQU_COMMAND_HDR;
+
+typedef struct _TPM_RSP_COMMAND_HDR {
+ TPM_STRUCTURE_TAG tag;
+ UINT32 paramSize;
+ TPM_RESULT returnCode;
+} TPM_RSP_COMMAND_HDR;
+
+#pragma pack (pop)
+
+#endif // _TPM12_H_
diff --git a/EDK/Foundation/Include/IndustryStandard/WatchdogDescriptionTable.h b/EDK/Foundation/Include/IndustryStandard/WatchdogDescriptionTable.h
new file mode 100644
index 0000000..6038ecb
--- /dev/null
+++ b/EDK/Foundation/Include/IndustryStandard/WatchdogDescriptionTable.h
@@ -0,0 +1,94 @@
+/*++
+
+Copyright (c) 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ WatchdogDescriptionTable.h
+
+Abstract:
+
+ ACPI Watchdog Description Table as defined in Intel
+ ICH Family Watchdog Timer (WDT) Application Note (AP-725)
+
+--*/
+
+#ifndef _WATCH_DOG_DESCRIPTION_TABLE_H_
+#define _WATCH_DOG_DESCRIPTION_TABLE_H_
+
+//
+// Include files
+//
+#include "Acpi2_0.h"
+
+//
+// Ensure proper structure formats
+//
+#pragma pack(1)
+//
+// WDDT structure
+//
+typedef struct {
+ EFI_ACPI_DESCRIPTION_HEADER Header;
+ UINT16 SpecVersion;
+ UINT16 TableVersion;
+ UINT16 Vid;
+ EFI_ACPI_2_0_GENERIC_ADDRESS_STRUCTURE BaseAddress;
+ UINT16 TimerMaxCount;
+ UINT16 TimerMinCount;
+ UINT16 TimerCountPeriod;
+ UINT16 Status;
+ UINT16 Capability;
+} EFI_ACPI_1_0_WATCH_DOG_DESCRIPTION_TABLE;
+
+//
+// "WDDT" Watchdog Description Table signatures
+//
+#define EFI_ACPI_1_0_WDDT_SIGNATURE 0x54444457
+
+#pragma pack()
+
+//
+// WDDT Revision
+//
+#define EFI_ACPI_WATCHDOG_DESCRIPTION_1_0_TABLE_REVISION 0x01
+
+//
+// WDDT Spec Version
+//
+#define EFI_ACPI_WDDT_SPEC_1_0_VERSION 0x01
+
+//
+// WDDT Description Table Version
+//
+#define EFI_ACPI_WDDT_TABLE_1_0_VERSION 0x01
+
+//
+// WDT Status
+//
+#define EFI_ACPI_WDDT_STATUS_AVAILABLE 0x0001
+#define EFI_ACPI_WDDT_STATUS_ACTIVE 0x0002
+#define EFI_ACPI_WDDT_STATUS_OWNED_BY_BIOS 0x0000
+#define EFI_ACPI_WDDT_STATUS_OWNED_BY_OS 0x0004
+#define EFI_ACPI_WDDT_STATUS_USER_RESET_EVENT 0x0800
+#define EFI_ACPI_WDDT_STATUS_WDT_EVENT 0x1000
+#define EFI_ACPI_WDDT_STATUS_POWER_FAIL_EVENT 0x2000
+#define EFI_ACPI_WDDT_STATUS_UNKNOWN_RESET_EVENT 0x4000
+
+//
+// WDT Capability
+//
+#define EFI_ACPI_WDDT_CAPABILITY_AUTO_RESET 0x0001
+#define EFI_ACPI_WDDT_CAPABILITY_ALERT_SUPPORT 0x0002
+#define EFI_ACPI_WDDT_CAPABILITY_PLATFORM_SHUTDOWN 0x0004
+#define EFI_ACPI_WDDT_CAPABILITY_IMMEDIATE_SHUTDOWN 0x0008
+#define EFI_ACPI_WDDT_CAPABILITY_BIOS_HANDOFF_SUPPORT 0x0010
+
+#endif
diff --git a/EDK/Foundation/Include/IndustryStandard/atapi.h b/EDK/Foundation/Include/IndustryStandard/atapi.h
new file mode 100644
index 0000000..11b8892
--- /dev/null
+++ b/EDK/Foundation/Include/IndustryStandard/atapi.h
@@ -0,0 +1,331 @@
+/*++
+
+Copyright (c) 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Atapi.h
+
+Abstract:
+
+
+Revision History
+--*/
+
+#ifndef _ATAPI_H
+#define _ATAPI_H
+
+#include "Tiano.h"
+
+#pragma pack(1)
+
+typedef struct {
+ UINT16 config; /* General Configuration */
+ UINT16 cylinders; /* Number of Cylinders */
+ UINT16 reserved_2;
+ UINT16 heads; /* Number of logical heads */
+ UINT16 vendor_data1;
+ UINT16 vendoe_data2;
+ UINT16 sectors_per_track;
+ UINT16 vendor_specific_7_9[3];
+ CHAR8 SerialNo[20]; /* ASCII */
+ UINT16 vendor_specific_20_21[2];
+ UINT16 ecc_bytes_available;
+ CHAR8 FirmwareVer[8]; /* ASCII */
+ CHAR8 ModelName[40]; /* ASCII */
+ UINT16 multi_sector_cmd_max_sct_cnt;
+ UINT16 reserved_48;
+ UINT16 capabilities;
+ UINT16 reserved_50;
+ UINT16 pio_cycle_timing;
+ UINT16 reserved_52;
+ UINT16 field_validity;
+ UINT16 current_cylinders;
+ UINT16 current_heads;
+ UINT16 current_sectors;
+ UINT16 CurrentCapacityLsb;
+ UINT16 CurrentCapacityMsb;
+ UINT16 reserved_59;
+ UINT16 user_addressable_sectors_lo;
+ UINT16 user_addressable_sectors_hi;
+ UINT16 reserved_62;
+ UINT16 multi_word_dma_mode;
+ UINT16 advanced_pio_modes;
+ UINT16 min_multi_word_dma_cycle_time;
+ UINT16 rec_multi_word_dma_cycle_time;
+ UINT16 min_pio_cycle_time_without_flow_control;
+ UINT16 min_pio_cycle_time_with_flow_control;
+ UINT16 reserved_69_79[11];
+ UINT16 major_version_no;
+ UINT16 minor_version_no;
+ UINT16 reserved_82_127[46];
+ UINT16 security_status;
+ UINT16 vendor_data_129_159[31];
+ UINT16 reserved_160_255[96];
+} IDENTIFY;
+
+typedef struct {
+ UINT8 peripheral_type;
+ UINT8 RMB;
+ UINT8 version;
+ UINT8 response_data_format;
+ UINT8 addnl_length;
+ UINT8 reserved_5;
+ UINT8 reserved_6;
+ UINT8 reserved_7;
+ UINT8 vendor_info[8];
+ UINT8 product_id[12];
+ UINT8 eeprom_product_code[4];
+ UINT8 firmware_rev_level[4];
+ UINT8 firmware_sub_rev_level[1];
+ UINT8 reserved_37;
+ UINT8 reserved_38;
+ UINT8 reserved_39;
+ UINT8 max_capacity_hi;
+ UINT8 max_capacity_mid;
+ UINT8 max_capacity_lo;
+ UINT8 reserved_43_95[95 - 43 + 1];
+ UINT8 vendor_id[20];
+ UINT8 eeprom_drive_sno[12];
+} INQUIRY_DATA;
+
+typedef struct {
+ UINT8 error_code : 7;
+ UINT8 valid : 1;
+ UINT8 reserved_1;
+ UINT8 sense_key : 4;
+ UINT8 reserved_21 : 1;
+ UINT8 ILI : 1;
+ UINT8 reserved_22 : 2;
+ UINT8 vendor_specific_3;
+ UINT8 vendor_specific_4;
+ UINT8 vendor_specific_5;
+ UINT8 vendor_specific_6;
+ UINT8 addnl_sense_length; // n - 7
+ UINT8 vendor_specific_8;
+ UINT8 vendor_specific_9;
+ UINT8 vendor_specific_10;
+ UINT8 vendor_specific_11;
+ UINT8 addnl_sense_code; // mandatory
+ UINT8 addnl_sense_code_qualifier; // mandatory
+ UINT8 field_replaceable_unit_code; // optional
+ UINT8 reserved_15;
+ UINT8 reserved_16;
+ UINT8 reserved_17;
+ //
+ // Followed by additional sense bytes : FIXME
+ //
+} REQUEST_SENSE_DATA;
+
+typedef struct {
+ UINT8 LastLba3;
+ UINT8 LastLba2;
+ UINT8 LastLba1;
+ UINT8 LastLba0;
+ UINT8 BlockSize3;
+ UINT8 BlockSize2;
+ UINT8 BlockSize1;
+ UINT8 BlockSize0;
+} READ_CAPACITY_DATA;
+
+typedef struct {
+ UINT8 reserved_0;
+ UINT8 reserved_1;
+ UINT8 reserved_2;
+ UINT8 Capacity_Length;
+ UINT8 LastLba3;
+ UINT8 LastLba2;
+ UINT8 LastLba1;
+ UINT8 LastLba0;
+ UINT8 DesCode : 2;
+ UINT8 reserved_9 : 6;
+ UINT8 BlockSize2;
+ UINT8 BlockSize1;
+ UINT8 BlockSize0;
+} READ_FORMAT_CAPACITY_DATA;
+
+#pragma pack()
+//
+// ATAPI Command
+//
+#define ATAPI_SOFT_RESET_CMD 0x08
+#define PACKET_CMD 0xA0
+#define ATAPI_IDENTIFY_DEVICE_CMD 0xA1
+#define ATAPI_SERVICE_CMD 0xA2
+
+//
+// ATAPI Packet Command
+//
+#pragma pack(1)
+
+typedef struct {
+ UINT8 opcode;
+ UINT8 reserved_1;
+ UINT8 reserved_2;
+ UINT8 reserved_3;
+ UINT8 reserved_4;
+ UINT8 reserved_5;
+ UINT8 reserved_6;
+ UINT8 reserved_7;
+ UINT8 reserved_8;
+ UINT8 reserved_9;
+ UINT8 reserved_10;
+ UINT8 reserved_11;
+} TEST_UNIT_READY_CMD;
+
+typedef struct {
+ UINT8 opcode;
+ UINT8 reserved_1 : 4;
+ UINT8 lun : 4;
+ UINT8 page_code;
+ UINT8 reserved_3;
+ UINT8 allocation_length;
+ UINT8 reserved_5;
+ UINT8 reserved_6;
+ UINT8 reserved_7;
+ UINT8 reserved_8;
+ UINT8 reserved_9;
+ UINT8 reserved_10;
+ UINT8 reserved_11;
+} INQUIRY_CMD;
+
+typedef struct {
+ UINT8 opcode;
+ UINT8 reserved_1 : 4;
+ UINT8 lun : 4;
+ UINT8 reserved_2;
+ UINT8 reserved_3;
+ UINT8 allocation_length;
+ UINT8 reserved_5;
+ UINT8 reserved_6;
+ UINT8 reserved_7;
+ UINT8 reserved_8;
+ UINT8 reserved_9;
+ UINT8 reserved_10;
+ UINT8 reserved_11;
+} REQUEST_SENSE_CMD;
+
+typedef struct {
+ UINT8 opcode;
+ UINT8 reserved_1 : 5;
+ UINT8 lun : 3;
+ UINT8 Lba0;
+ UINT8 Lba1;
+ UINT8 Lba2;
+ UINT8 Lba3;
+ UINT8 reserved_6;
+ UINT8 TranLen0;
+ UINT8 TranLen1;
+ UINT8 reserved_9;
+ UINT8 reserved_10;
+ UINT8 reserved_11;
+} READ10_CMD;
+
+typedef struct {
+ UINT8 opcode;
+ UINT8 reserved_1;
+ UINT8 reserved_2;
+ UINT8 reserved_3;
+ UINT8 reserved_4;
+ UINT8 reserved_5;
+ UINT8 reserved_6;
+ UINT8 allocation_length_hi;
+ UINT8 allocation_length_lo;
+ UINT8 reserved_9;
+ UINT8 reserved_10;
+ UINT8 reserved_11;
+} READ_FORMAT_CAP_CMD;
+
+typedef struct {
+ UINT8 peripheral_type;
+ UINT8 RMB;
+ UINT8 version;
+ UINT8 response_data_format;
+ UINT8 addnl_length;
+ UINT8 reserved_5;
+ UINT8 reserved_6;
+ UINT8 reserved_7;
+ UINT8 vendor_info[8];
+ UINT8 product_id[12];
+ UINT8 eeprom_product_code[4];
+ UINT8 firmware_rev_level[4];
+} USB_INQUIRY_DATA;
+
+typedef union {
+ UINT16 Data16[6];
+ TEST_UNIT_READY_CMD TestUnitReady;
+ READ10_CMD Read10;
+ REQUEST_SENSE_CMD RequestSence;
+ INQUIRY_CMD Inquiry;
+ READ_FORMAT_CAP_CMD ReadFormatCapacity;
+} ATAPI_PACKET_COMMAND;
+
+#pragma pack()
+//
+// Packet Command Code
+//
+#define TEST_UNIT_READY 0x00
+#define REQUEST_SENSE 0x03
+#define INQUIRY 0x12
+#define READ_FORMAT_CAPACITY 0x23
+#define READ_CAPACITY 0x25
+#define READ_10 0x28
+
+#define DEFAULT_CTL (0x0a) // default content of device control register, disable INT
+#define DEFAULT_CMD (0xa0)
+
+#define MAX_ATAPI_BYTE_COUNT (0xfffe)
+
+//
+// Sense Key
+//
+#define REQUEST_SENSE_ERROR (0x70)
+#define SK_NO_SENSE (0x0)
+#define SK_RECOVERY_ERROR (0x1)
+#define SK_NOT_READY (0x2)
+#define SK_MEDIUM_ERROR (0x3)
+#define SK_HARDWARE_ERROR (0x4)
+#define SK_ILLEGAL_REQUEST (0x5)
+#define SK_UNIT_ATTENTION (0x6)
+#define SK_DATA_PROTECT (0x7)
+#define SK_BLANK_CHECK (0x8)
+#define SK_VENDOR_SPECIFIC (0x9)
+#define SK_RESERVED_A (0xA)
+#define SK_ABORT (0xB)
+#define SK_RESERVED_C (0xC)
+#define SK_OVERFLOW (0xD)
+#define SK_MISCOMPARE (0xE)
+#define SK_RESERVED_F (0xF)
+
+//
+// Additional Sense Codes
+//
+#define ASC_NOT_READY (0x04)
+#define ASC_MEDIA_ERR1 (0x10)
+#define ASC_MEDIA_ERR2 (0x11)
+#define ASC_MEDIA_ERR3 (0x14)
+#define ASC_MEDIA_ERR4 (0x30)
+#define ASC_MEDIA_UPSIDE_DOWN (0x06)
+#define ASC_INVALID_CMD (0x20)
+#define ASC_LBA_OUT_OF_RANGE (0x21)
+#define ASC_INVALID_FIELD (0x24)
+#define ASC_WRITE_PROTECTED (0x27)
+#define ASC_MEDIA_CHANGE (0x28)
+#define ASC_RESET (0x29) /* Power On Reset or Bus Reset occurred */
+#define ASC_ILLEGAL_FIELD (0x26)
+#define ASC_NO_MEDIA (0x3A)
+#define ASC_ILLEGAL_MODE_FOR_THIS_TRACK (0x64)
+
+//
+// Additional Sense Code Qualifier
+//
+#define ASCQ_IN_PROGRESS (0x01)
+
+#endif
diff --git a/EDK/Foundation/Include/IndustryStandard/pci.h b/EDK/Foundation/Include/IndustryStandard/pci.h
new file mode 100644
index 0000000..960324d
--- /dev/null
+++ b/EDK/Foundation/Include/IndustryStandard/pci.h
@@ -0,0 +1,31 @@
+/*++
+
+Copyright (c) 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ pci.h
+
+Abstract:
+ Support for PCI standard.
+
+Revision History
+
+--*/
+
+#ifndef _PCI_H
+#define _PCI_H
+
+#include "pci22.h"
+#include "pci23.h"
+#include "pci30.h"
+#include "EfiPci.h"
+
+#endif
diff --git a/EDK/Foundation/Include/IndustryStandard/pci22.h b/EDK/Foundation/Include/IndustryStandard/pci22.h
new file mode 100644
index 0000000..6f4b514
--- /dev/null
+++ b/EDK/Foundation/Include/IndustryStandard/pci22.h
@@ -0,0 +1,555 @@
+/*++
+
+Copyright (c) 2004 - 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ pci22.h
+
+Abstract:
+ Support for PCI 2.2 standard.
+
+Revision History
+
+--*/
+
+#ifndef _PCI22_H
+#define _PCI22_H
+
+#define PCI_MAX_SEGMENT 0
+
+#define PCI_MAX_BUS 255
+
+#define PCI_MAX_DEVICE 31
+#define PCI_MAX_FUNC 7
+
+//
+// Command
+//
+#define PCI_VGA_PALETTE_SNOOP_DISABLED 0x20
+
+#pragma pack(push, 1)
+typedef struct {
+ UINT16 VendorId;
+ UINT16 DeviceId;
+ UINT16 Command;
+ UINT16 Status;
+ UINT8 RevisionID;
+ UINT8 ClassCode[3];
+ UINT8 CacheLineSize;
+ UINT8 LatencyTimer;
+ UINT8 HeaderType;
+ UINT8 BIST;
+} PCI_DEVICE_INDEPENDENT_REGION;
+
+typedef struct {
+ UINT32 Bar[6];
+ UINT32 CISPtr;
+ UINT16 SubsystemVendorID;
+ UINT16 SubsystemID;
+ UINT32 ExpansionRomBar;
+ UINT8 CapabilityPtr;
+ UINT8 Reserved1[3];
+ UINT32 Reserved2;
+ UINT8 InterruptLine;
+ UINT8 InterruptPin;
+ UINT8 MinGnt;
+ UINT8 MaxLat;
+} PCI_DEVICE_HEADER_TYPE_REGION;
+
+typedef struct {
+ PCI_DEVICE_INDEPENDENT_REGION Hdr;
+ PCI_DEVICE_HEADER_TYPE_REGION Device;
+} PCI_TYPE00;
+
+typedef struct {
+ UINT32 Bar[2];
+ UINT8 PrimaryBus;
+ UINT8 SecondaryBus;
+ UINT8 SubordinateBus;
+ UINT8 SecondaryLatencyTimer;
+ UINT8 IoBase;
+ UINT8 IoLimit;
+ UINT16 SecondaryStatus;
+ UINT16 MemoryBase;
+ UINT16 MemoryLimit;
+ UINT16 PrefetchableMemoryBase;
+ UINT16 PrefetchableMemoryLimit;
+ UINT32 PrefetchableBaseUpper32;
+ UINT32 PrefetchableLimitUpper32;
+ UINT16 IoBaseUpper16;
+ UINT16 IoLimitUpper16;
+ UINT8 CapabilityPtr;
+ UINT8 Reserved[3];
+ UINT32 ExpansionRomBAR;
+ UINT8 InterruptLine;
+ UINT8 InterruptPin;
+ UINT16 BridgeControl;
+} PCI_BRIDGE_CONTROL_REGISTER;
+
+typedef struct {
+ PCI_DEVICE_INDEPENDENT_REGION Hdr;
+ PCI_BRIDGE_CONTROL_REGISTER Bridge;
+} PCI_TYPE01;
+
+typedef union {
+ PCI_TYPE00 Device;
+ PCI_TYPE01 Bridge;
+} PCI_TYPE_GENERIC;
+
+typedef struct {
+ UINT32 CardBusSocketReg; // Cardus Socket/ExCA Base
+ // Address Register
+ //
+ UINT16 Reserved;
+ UINT16 SecondaryStatus; // Secondary Status
+ UINT8 PciBusNumber; // PCI Bus Number
+ UINT8 CardBusBusNumber; // CardBus Bus Number
+ UINT8 SubordinateBusNumber; // Subordinate Bus Number
+ UINT8 CardBusLatencyTimer; // CardBus Latency Timer
+ UINT32 MemoryBase0; // Memory Base Register 0
+ UINT32 MemoryLimit0; // Memory Limit Register 0
+ UINT32 MemoryBase1;
+ UINT32 MemoryLimit1;
+ UINT32 IoBase0;
+ UINT32 IoLimit0; // I/O Base Register 0
+ UINT32 IoBase1; // I/O Limit Register 0
+ UINT32 IoLimit1;
+ UINT8 InterruptLine; // Interrupt Line
+ UINT8 InterruptPin; // Interrupt Pin
+ UINT16 BridgeControl; // Bridge Control
+} PCI_CARDBUS_CONTROL_REGISTER;
+
+//
+// Definitions of PCI class bytes and manipulation macros.
+//
+#define PCI_CLASS_OLD 0x00
+#define PCI_CLASS_OLD_OTHER 0x00
+#define PCI_CLASS_OLD_VGA 0x01
+
+#define PCI_CLASS_MASS_STORAGE 0x01
+#define PCI_CLASS_MASS_STORAGE_SCSI 0x00
+#define PCI_CLASS_MASS_STORAGE_IDE 0x01 // obsolete
+#define PCI_CLASS_IDE 0x01
+#define PCI_CLASS_MASS_STORAGE_FLOPPY 0x02
+#define PCI_CLASS_MASS_STORAGE_IPI 0x03
+#define PCI_CLASS_MASS_STORAGE_RAID 0x04
+#define PCI_CLASS_MASS_STORAGE_OTHER 0x80
+
+#define PCI_CLASS_NETWORK 0x02
+#define PCI_CLASS_NETWORK_ETHERNET 0x00
+#define PCI_CLASS_ETHERNET 0x00 // obsolete
+#define PCI_CLASS_NETWORK_TOKENRING 0x01
+#define PCI_CLASS_NETWORK_FDDI 0x02
+#define PCI_CLASS_NETWORK_ATM 0x03
+#define PCI_CLASS_NETWORK_ISDN 0x04
+#define PCI_CLASS_NETWORK_OTHER 0x80
+
+#define PCI_CLASS_DISPLAY 0x03
+#define PCI_CLASS_DISPLAY_CTRL 0x03 // obsolete
+#define PCI_CLASS_DISPLAY_VGA 0x00
+#define PCI_CLASS_VGA 0x00 // obsolete
+#define PCI_CLASS_DISPLAY_XGA 0x01
+#define PCI_CLASS_DISPLAY_3D 0x02
+#define PCI_CLASS_DISPLAY_OTHER 0x80
+#define PCI_CLASS_DISPLAY_GFX 0x80
+#define PCI_CLASS_GFX 0x80 // obsolete
+
+#define PCI_CLASS_BRIDGE 0x06
+#define PCI_CLASS_BRIDGE_HOST 0x00
+#define PCI_CLASS_BRIDGE_ISA 0x01
+#define PCI_CLASS_ISA 0x01 // obsolete
+#define PCI_CLASS_BRIDGE_EISA 0x02
+#define PCI_CLASS_BRIDGE_MCA 0x03
+#define PCI_CLASS_BRIDGE_P2P 0x04
+#define PCI_CLASS_BRIDGE_PCMCIA 0x05
+#define PCI_CLASS_BRIDGE_NUBUS 0x06
+#define PCI_CLASS_BRIDGE_CARDBUS 0x07
+#define PCI_CLASS_BRIDGE_RACEWAY 0x08
+#define PCI_CLASS_BRIDGE_ISA_PDECODE 0x80
+#define PCI_CLASS_ISA_POSITIVE_DECODE 0x80 // obsolete
+
+#define PCI_CLASS_SCC 0x07 // Simple communications controllers
+#define PCI_SUBCLASS_SERIAL 0x00
+#define PCI_IF_GENERIC_XT 0x00
+#define PCI_IF_16450 0x01
+#define PCI_IF_16550 0x02
+#define PCI_IF_16650 0x03
+#define PCI_IF_16750 0x04
+#define PCI_IF_16850 0x05
+#define PCI_IF_16950 0x06
+#define PCI_SUBCLASS_PARALLEL 0x01
+#define PCI_IF_PARALLEL_PORT 0x00
+#define PCI_IF_BI_DIR_PARALLEL_PORT 0x01
+#define PCI_IF_ECP_PARALLEL_PORT 0x02
+#define PCI_IF_1284_CONTROLLER 0x03
+#define PCI_IF_1284_DEVICE 0xFE
+#define PCI_SUBCLASS_MULTIPORT_SERIAL 0x02
+#define PCI_SUBCLASS_MODEM 0x03
+#define PCI_IF_GENERIC_MODEM 0x00
+#define PCI_IF_16450_MODEM 0x01
+#define PCI_IF_16550_MODEM 0x02
+#define PCI_IF_16650_MODEM 0x03
+#define PCI_IF_16750_MODEM 0x04
+#define PCI_SUBCLASS_OTHER 0x80
+
+#define PCI_CLASS_SYSTEM_PERIPHERAL 0x08
+#define PCI_SUBCLASS_PIC 0x00
+#define PCI_IF_8259_PIC 0x00
+#define PCI_IF_ISA_PIC 0x01
+#define PCI_IF_EISA_PIC 0x02
+#define PCI_IF_APIC_CONTROLLER 0x10 // I/O APIC interrupt controller , 32 bye none-prefectable memory.
+#define PCI_IF_APIC_CONTROLLER2 0x20
+#define PCI_SUBCLASS_TIMER 0x02
+#define PCI_IF_8254_TIMER 0x00
+#define PCI_IF_ISA_TIMER 0x01
+#define PCI_EISA_TIMER 0x02
+#define PCI_SUBCLASS_RTC 0x03
+#define PCI_IF_GENERIC_RTC 0x00
+#define PCI_IF_ISA_RTC 0x00
+#define PCI_SUBCLASS_PNP_CONTROLLER 0x04 // HotPlug Controller
+
+#define PCI_CLASS_INPUT_DEVICE 0x09
+#define PCI_SUBCLASS_KEYBOARD 0x00
+#define PCI_SUBCLASS_PEN 0x01
+#define PCI_SUBCLASS_MOUSE_CONTROLLER 0x02
+#define PCI_SUBCLASS_SCAN_CONTROLLER 0x03
+#define PCI_SUBCLASS_GAMEPORT 0x04
+
+#define PCI_CLASS_DOCKING_STATION 0x0A
+
+#define PCI_CLASS_PROCESSOR 0x0B
+#define PCI_SUBCLASS_PROC_386 0x00
+#define PCI_SUBCLASS_PROC_486 0x01
+#define PCI_SUBCLASS_PROC_PENTIUM 0x02
+#define PCI_SUBCLASS_PROC_ALPHA 0x10
+#define PCI_SUBCLASS_PROC_POWERPC 0x20
+#define PCI_SUBCLASS_PROC_MIPS 0x30
+#define PCI_SUBCLASS_PROC_CO_PORC 0x40 // Co-Processor
+
+#define PCI_CLASS_SERIAL 0x0C
+#define PCI_CLASS_SERIAL_FIREWIRE 0x00
+#define PCI_CLASS_SERIAL_ACCESS_BUS 0x01
+#define PCI_CLASS_SERIAL_SSA 0x02
+#define PCI_CLASS_SERIAL_USB 0x03
+#define PCI_IF_EHCI 0x20
+#define PCI_CLASS_SERIAL_FIBRECHANNEL 0x04
+#define PCI_CLASS_SERIAL_SMB 0x05
+
+#define PCI_CLASS_WIRELESS 0x0D
+#define PCI_SUBCLASS_IRDA 0x00
+#define PCI_SUBCLASS_IR 0x01
+#define PCI_SUBCLASS_RF 0x02
+
+#define PCI_CLASS_INTELLIGENT_IO 0x0E
+
+#define PCI_CLASS_SATELLITE 0x0F
+#define PCI_SUBCLASS_TV 0x01
+#define PCI_SUBCLASS_AUDIO 0x02
+#define PCI_SUBCLASS_VOICE 0x03
+#define PCI_SUBCLASS_DATA 0x04
+
+#define PCI_SECURITY_CONTROLLER 0x10 // Encryption and decryption controller
+#define PCI_SUBCLASS_NET_COMPUT 0x00
+#define PCI_SUBCLASS_ENTERTAINMENT 0x10
+
+#define PCI_CLASS_DPIO 0x11
+
+#define IS_CLASS1(_p, c) ((_p)->Hdr.ClassCode[2] == (c))
+#define IS_CLASS2(_p, c, s) (IS_CLASS1 (_p, c) && ((_p)->Hdr.ClassCode[1] == (s)))
+#define IS_CLASS3(_p, c, s, p) (IS_CLASS2 (_p, c, s) && ((_p)->Hdr.ClassCode[0] == (p)))
+
+#define IS_PCI_DISPLAY(_p) IS_CLASS1 (_p, PCI_CLASS_DISPLAY)
+#define IS_PCI_VGA(_p) IS_CLASS3 (_p, PCI_CLASS_DISPLAY, PCI_CLASS_DISPLAY_VGA, 0)
+#define IS_PCI_8514(_p) IS_CLASS3 (_p, PCI_CLASS_DISPLAY, PCI_CLASS_DISPLAY_VGA, 1)
+#define IS_PCI_GFX(_p) IS_CLASS3 (_p, PCI_CLASS_DISPLAY, PCI_CLASS_DISPLAY_GFX, 0)
+#define IS_PCI_OLD(_p) IS_CLASS1 (_p, PCI_CLASS_OLD)
+#define IS_PCI_OLD_VGA(_p) IS_CLASS2 (_p, PCI_CLASS_OLD, PCI_CLASS_OLD_VGA)
+#define IS_PCI_IDE(_p) IS_CLASS2 (_p, PCI_CLASS_MASS_STORAGE, PCI_CLASS_MASS_STORAGE_IDE)
+#define IS_PCI_SCSI(_p) IS_CLASS3 (_p, PCI_CLASS_MASS_STORAGE, PCI_CLASS_MASS_STORAGE_SCSI, 0)
+#define IS_PCI_RAID(_p) IS_CLASS3 (_p, PCI_CLASS_MASS_STORAGE, PCI_CLASS_MASS_STORAGE_RAID, 0)
+#define IS_PCI_LPC(_p) IS_CLASS3 (_p, PCI_CLASS_BRIDGE, PCI_CLASS_BRIDGE_ISA, 0)
+#define IS_PCI_ISA_PDECODE(_p) IS_CLASS3 (_p, PCI_CLASS_BRIDGE, PCI_CLASS_BRIDGE_ISA_PDECODE, 0)
+#define IS_PCI_P2P(_p) IS_CLASS3 (_p, PCI_CLASS_BRIDGE, PCI_CLASS_BRIDGE_P2P, 0)
+#define IS_PCI_P2P_SUB(_p) IS_CLASS3 (_p, PCI_CLASS_BRIDGE, PCI_CLASS_BRIDGE_P2P, 1)
+#define IS_PCI_16550_SERIAL(_p) IS_CLASS3 (_p, PCI_CLASS_SCC, PCI_SUBCLASS_SERIAL, PCI_IF_16550)
+#define IS_PCI_USB(_p) IS_CLASS2 (_p, PCI_CLASS_SERIAL, PCI_CLASS_SERIAL_USB)
+
+#define HEADER_TYPE_DEVICE 0x00
+#define HEADER_TYPE_PCI_TO_PCI_BRIDGE 0x01
+#define HEADER_TYPE_CARDBUS_BRIDGE 0x02
+
+#define HEADER_TYPE_MULTI_FUNCTION 0x80
+#define HEADER_LAYOUT_CODE 0x7f
+
+#define IS_PCI_BRIDGE(_p) (((_p)->Hdr.HeaderType & HEADER_LAYOUT_CODE) == (HEADER_TYPE_PCI_TO_PCI_BRIDGE))
+#define IS_CARDBUS_BRIDGE(_p) (((_p)->Hdr.HeaderType & HEADER_LAYOUT_CODE) == (HEADER_TYPE_CARDBUS_BRIDGE))
+#define IS_PCI_MULTI_FUNC(_p) ((_p)->Hdr.HeaderType & HEADER_TYPE_MULTI_FUNCTION)
+
+#define PCI_DEVICE_ROMBAR 0x30
+#define PCI_BRIDGE_ROMBAR 0x38
+
+#define PCI_MAX_BAR 0x0006
+#define PCI_MAX_CONFIG_OFFSET 0x0100
+
+#define PCI_VENDOR_ID_OFFSET 0x00
+#define PCI_DEVICE_ID_OFFSET 0x02
+#define PCI_COMMAND_OFFSET 0x04
+#define PCI_PRIMARY_STATUS_OFFSET 0x06
+#define PCI_REVISION_ID_OFFSET 0x08
+#define PCI_CLASSCODE_OFFSET 0x09
+#define PCI_SUBCLASSCODE_OFFSET 0x0A
+#define PCI_CACHELINE_SIZE_OFFSET 0x0C
+#define PCI_LATENCY_TIMER_OFFSET 0x0D
+#define PCI_HEADER_TYPE_OFFSET 0x0E
+#define PCI_BIST_OFFSET 0x0F
+#define PCI_BASE_ADDRESSREG_OFFSET 0x10
+#define PCI_CARDBUS_CIS_OFFSET 0x28
+#define PCI_SVID_OFFSET 0x2C // SubSystem Vendor id
+#define PCI_SUBSYSTEM_VENDOR_ID_OFFSET 0x2C
+#define PCI_SID_OFFSET 0x2E // SubSystem ID
+#define PCI_SUBSYSTEM_ID_OFFSET 0x2E
+#define PCI_EXPANSION_ROM_BASE 0x30
+#define PCI_CAPBILITY_POINTER_OFFSET 0x34
+#define PCI_INT_LINE_OFFSET 0x3C // Interrupt Line Register
+#define PCI_INT_PIN_OFFSET 0x3D // Interrupt Pin Register
+#define PCI_MAXGNT_OFFSET 0x3E // Max Grant Register
+#define PCI_MAXLAT_OFFSET 0x3F // Max Latency Register
+
+#define PCI_BRIDGE_CONTROL_REGISTER_OFFSET 0x3E
+#define PCI_BRIDGE_STATUS_REGISTER_OFFSET 0x1E
+
+#define PCI_BRIDGE_PRIMARY_BUS_REGISTER_OFFSET 0x18
+#define PCI_BRIDGE_SECONDARY_BUS_REGISTER_OFFSET 0x19
+#define PCI_BRIDGE_SUBORDINATE_BUS_REGISTER_OFFSET 0x1a
+
+//
+// Interrupt Line "Unknown" or "No connection" value defined for x86 based system
+//
+#define PCI_INT_LINE_UNKNOWN 0xFF
+
+
+typedef struct {
+ UINT32 Reg : 8;
+ UINT32 Func : 3;
+ UINT32 Dev : 5;
+ UINT32 Bus : 8;
+ UINT32 Reserved : 7;
+ UINT32 Enable : 1;
+} PCI_CONFIG_ACCESS_CF8;
+
+#pragma pack()
+
+#define PCI_EXPANSION_ROM_HEADER_SIGNATURE 0xaa55
+#define PCI_DATA_STRUCTURE_SIGNATURE EFI_SIGNATURE_32 ('P', 'C', 'I', 'R')
+#define PCI_CODE_TYPE_PCAT_IMAGE 0x00
+#define PCI_CODE_TYPE_EFI_IMAGE 0x03
+#define EFI_PCI_EXPANSION_ROM_HEADER_COMPRESSED 0x0001
+
+#define EFI_PCI_COMMAND_IO_SPACE 0x0001
+#define EFI_PCI_COMMAND_MEMORY_SPACE 0x0002
+#define EFI_PCI_COMMAND_BUS_MASTER 0x0004
+#define EFI_PCI_COMMAND_SPECIAL_CYCLE 0x0008
+#define EFI_PCI_COMMAND_MEMORY_WRITE_AND_INVALIDATE 0x0010
+#define EFI_PCI_COMMAND_VGA_PALETTE_SNOOP 0x0020
+#define EFI_PCI_COMMAND_PARITY_ERROR_RESPOND 0x0040
+#define EFI_PCI_COMMAND_STEPPING_CONTROL 0x0080
+#define EFI_PCI_COMMAND_SERR 0x0100
+#define EFI_PCI_COMMAND_FAST_BACK_TO_BACK 0x0200
+
+#define EFI_PCI_BRIDGE_CONTROL_PARITY_ERROR_RESPONSE 0x0001
+#define EFI_PCI_BRIDGE_CONTROL_SERR 0x0002
+#define EFI_PCI_BRIDGE_CONTROL_ISA 0x0004
+#define EFI_PCI_BRIDGE_CONTROL_VGA 0x0008
+#define EFI_PCI_BRIDGE_CONTROL_VGA_16 0x0010
+#define EFI_PCI_BRIDGE_CONTROL_MASTER_ABORT 0x0020
+#define EFI_PCI_BRIDGE_CONTROL_RESET_SECONDARY_BUS 0x0040
+#define EFI_PCI_BRIDGE_CONTROL_FAST_BACK_TO_BACK 0x0080
+#define EFI_PCI_BRIDGE_CONTROL_PRIMARY_DISCARD_TIMER 0x0100
+#define EFI_PCI_BRIDGE_CONTROL_SECONDARY_DISCARD_TIMER 0x0200
+#define EFI_PCI_BRIDGE_CONTROL_TIMER_STATUS 0x0400
+#define EFI_PCI_BRIDGE_CONTROL_DISCARD_TIMER_SERR 0x0800
+
+//
+// Following are the PCI-CARDBUS bridge control bit
+//
+#define EFI_PCI_BRIDGE_CONTROL_IREQINT_ENABLE 0x0080
+#define EFI_PCI_BRIDGE_CONTROL_RANGE0_MEMORY_TYPE 0x0100
+#define EFI_PCI_BRIDGE_CONTROL_RANGE1_MEMORY_TYPE 0x0200
+#define EFI_PCI_BRIDGE_CONTROL_WRITE_POSTING_ENABLE 0x0400
+
+//
+// Following are the PCI status control bit
+//
+#define EFI_PCI_STATUS_CAPABILITY 0x0010
+#define EFI_PCI_STATUS_66MZ_CAPABLE 0x0020
+#define EFI_PCI_FAST_BACK_TO_BACK_CAPABLE 0x0080
+#define EFI_PCI_MASTER_DATA_PARITY_ERROR 0x0100
+
+#define EFI_PCI_CAPABILITY_PTR 0x34
+#define EFI_PCI_CARDBUS_BRIDGE_CAPABILITY_PTR 0x14
+
+#pragma pack(1)
+typedef struct {
+ UINT16 Signature; // 0xaa55
+ UINT8 Reserved[0x16];
+ UINT16 PcirOffset;
+} PCI_EXPANSION_ROM_HEADER;
+
+typedef struct {
+ UINT16 Signature; // 0xaa55
+ UINT8 Size512;
+ UINT8 InitEntryPoint[3];
+ UINT8 Reserved[0x12];
+ UINT16 PcirOffset;
+} EFI_LEGACY_EXPANSION_ROM_HEADER;
+
+typedef struct {
+ UINT32 Signature; // "PCIR"
+ UINT16 VendorId;
+ UINT16 DeviceId;
+ UINT16 Reserved0;
+ UINT16 Length;
+ UINT8 Revision;
+ UINT8 ClassCode[3];
+ UINT16 ImageLength;
+ UINT16 CodeRevision;
+ UINT8 CodeType;
+ UINT8 Indicator;
+ UINT16 Reserved1;
+} PCI_DATA_STRUCTURE;
+
+//
+// PCI Capability List IDs and records
+//
+#define EFI_PCI_CAPABILITY_ID_PMI 0x01
+#define EFI_PCI_CAPABILITY_ID_AGP 0x02
+#define EFI_PCI_CAPABILITY_ID_VPD 0x03
+#define EFI_PCI_CAPABILITY_ID_SLOTID 0x04
+#define EFI_PCI_CAPABILITY_ID_MSI 0x05
+#define EFI_PCI_CAPABILITY_ID_HOTPLUG 0x06
+#define EFI_PCI_CAPABILITY_ID_PCIX 0x07
+
+typedef struct {
+ UINT8 CapabilityID;
+ UINT8 NextItemPtr;
+} EFI_PCI_CAPABILITY_HDR;
+
+//
+// Capability EFI_PCI_CAPABILITY_ID_PMI
+//
+typedef struct {
+ EFI_PCI_CAPABILITY_HDR Hdr;
+ UINT16 PMC;
+ UINT16 PMCSR;
+ UINT8 BridgeExtention;
+ UINT8 Data;
+} EFI_PCI_CAPABILITY_PMI;
+
+//
+// Capability EFI_PCI_CAPABILITY_ID_AGP
+//
+typedef struct {
+ EFI_PCI_CAPABILITY_HDR Hdr;
+ UINT8 Rev;
+ UINT8 Reserved;
+ UINT32 Status;
+ UINT32 Command;
+} EFI_PCI_CAPABILITY_AGP;
+
+//
+// Capability EFI_PCI_CAPABILITY_ID_VPD
+//
+typedef struct {
+ EFI_PCI_CAPABILITY_HDR Hdr;
+ UINT16 AddrReg;
+ UINT32 DataReg;
+} EFI_PCI_CAPABILITY_VPD;
+
+//
+// Capability EFI_PCI_CAPABILITY_ID_SLOTID
+//
+typedef struct {
+ EFI_PCI_CAPABILITY_HDR Hdr;
+ UINT8 ExpnsSlotReg;
+ UINT8 ChassisNo;
+} EFI_PCI_CAPABILITY_SLOTID;
+
+//
+// Capability EFI_PCI_CAPABILITY_ID_MSI
+//
+typedef struct {
+ EFI_PCI_CAPABILITY_HDR Hdr;
+ UINT16 MsgCtrlReg;
+ UINT32 MsgAddrReg;
+ UINT16 MsgDataReg;
+} EFI_PCI_CAPABILITY_MSI32;
+
+typedef struct {
+ EFI_PCI_CAPABILITY_HDR Hdr;
+ UINT16 MsgCtrlReg;
+ UINT32 MsgAddrRegLsdw;
+ UINT32 MsgAddrRegMsdw;
+ UINT16 MsgDataReg;
+} EFI_PCI_CAPABILITY_MSI64;
+
+//
+// Capability EFI_PCI_CAPABILITY_ID_HOTPLUG
+//
+typedef struct {
+ EFI_PCI_CAPABILITY_HDR Hdr;
+ //
+ // not finished - fields need to go here
+ //
+} EFI_PCI_CAPABILITY_HOTPLUG;
+
+//
+// Capability EFI_PCI_CAPABILITY_ID_PCIX
+//
+typedef struct {
+ EFI_PCI_CAPABILITY_HDR Hdr;
+ UINT16 CommandReg;
+ UINT32 StatusReg;
+} EFI_PCI_CAPABILITY_PCIX;
+
+typedef struct {
+ EFI_PCI_CAPABILITY_HDR Hdr;
+ UINT16 SecStatusReg;
+ UINT32 StatusReg;
+ UINT32 SplitTransCtrlRegUp;
+ UINT32 SplitTransCtrlRegDn;
+} EFI_PCI_CAPABILITY_PCIX_BRDG;
+
+#define DEVICE_ID_NOCARE 0xFFFF
+
+#define PCI_ACPI_UNUSED 0
+#define PCI_BAR_NOCHANGE 0
+#define PCI_BAR_OLD_ALIGN 0xFFFFFFFFFFFFFFFF
+#define PCI_BAR_EVEN_ALIGN 0xFFFFFFFFFFFFFFFE
+#define PCI_BAR_SQUAD_ALIGN 0xFFFFFFFFFFFFFFFD
+#define PCI_BAR_DQUAD_ALIGN 0xFFFFFFFFFFFFFFFC
+
+#define PCI_BAR_IDX0 0x00
+#define PCI_BAR_IDX1 0x01
+#define PCI_BAR_IDX2 0x02
+#define PCI_BAR_IDX3 0x03
+#define PCI_BAR_IDX4 0x04
+#define PCI_BAR_IDX5 0x05
+#define PCI_BAR_ALL 0xFF
+
+#pragma pack(pop)
+
+//
+// NOTE: The following header files are included here for
+// compatibility consideration.
+//
+#include "EfiPci.h"
+
+#endif
diff --git a/EDK/Foundation/Include/IndustryStandard/pci23.h b/EDK/Foundation/Include/IndustryStandard/pci23.h
new file mode 100644
index 0000000..8a46cf7
--- /dev/null
+++ b/EDK/Foundation/Include/IndustryStandard/pci23.h
@@ -0,0 +1,41 @@
+/*++
+
+Copyright (c) 2006 - 2009, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ pci23.h
+
+Abstract:
+ Support for PCI 2.3 standard.
+
+Revision History
+
+--*/
+
+#ifndef _PCI23_H
+#define _PCI23_H
+
+#include "pci22.h"
+
+//
+// PCI_CLASS_MASS_STORAGE
+//
+#define PCI_CLASS_MASS_STORAGE_ATA 0x05
+
+//
+// PCI_CLASS_SERIAL
+//
+#define PCI_CLASS_SERIAL_IB 0x06
+
+#define PCI_EXP_MAX_CONFIG_OFFSET 0x1000
+#define EFI_PCI_CAPABILITY_ID_PCIEXP 0x10
+
+#endif
diff --git a/EDK/Foundation/Include/IndustryStandard/pci30.h b/EDK/Foundation/Include/IndustryStandard/pci30.h
new file mode 100644
index 0000000..30987a6
--- /dev/null
+++ b/EDK/Foundation/Include/IndustryStandard/pci30.h
@@ -0,0 +1,52 @@
+/*++
+
+Copyright (c) 2006 - 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ pci30.h
+
+Abstract:
+ Support for PCI 3.0 standard.
+
+Revision History
+
+--*/
+
+#ifndef _PCI30_H
+#define _PCI30_H
+
+#include "pci23.h"
+
+#define PCI_CLASS_MASS_STORAGE_SATADPA 0x06
+#define PCI_CLASS_MASS_STORAGE_AHCI PCI_CLASS_MASS_STORAGE_SATADPA
+
+#pragma pack(push, 1)
+
+typedef struct {
+ UINT32 Signature; // "PCIR"
+ UINT16 VendorId;
+ UINT16 DeviceId;
+ UINT16 DeviceListOffset;
+ UINT16 Length;
+ UINT8 Revision;
+ UINT8 ClassCode[3];
+ UINT16 ImageLength;
+ UINT16 CodeRevision;
+ UINT8 CodeType;
+ UINT8 Indicator;
+ UINT16 MaxRuntimeImageLength;
+ UINT16 ConfigUtilityCodeHeaderOffset;
+ UINT16 DMTFCLPEntryPointOffset;
+} PCI_3_0_DATA_STRUCTURE;
+
+#pragma pack(pop)
+
+#endif
diff --git a/EDK/Foundation/Include/IndustryStandard/scsi.h b/EDK/Foundation/Include/IndustryStandard/scsi.h
new file mode 100644
index 0000000..bc7b62d
--- /dev/null
+++ b/EDK/Foundation/Include/IndustryStandard/scsi.h
@@ -0,0 +1,314 @@
+/*++
+
+Copyright (c) 2004 - 2008, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ scsi.h
+
+Abstract:
+ support for SCSI standard
+
+Revision History
+--*/
+
+#ifndef _SCSI_H
+#define _SCSI_H
+
+//
+// SCSI command OP Code
+//
+//
+// Commands for all device types
+//
+#define EFI_SCSI_OP_CHANGE_DEFINITION 0x40
+#define EFI_SCSI_OP_COMPARE 0x39
+#define EFI_SCSI_OP_COPY 0x18
+#define EFI_SCSI_OP_COPY_VERIFY 0x3a
+#define EFI_SCSI_OP_INQUIRY 0x12
+#define EFI_SCSI_OP_LOG_SELECT 0x4c
+#define EFI_SCSI_OP_LOG_SENSE 0x4d
+#define EFI_SCSI_OP_MODE_SEL6 0x15
+#define EFI_SCSI_OP_MODE_SEL10 0x55
+#define EFI_SCSI_OP_MODE_SEN6 0x1a
+#define EFI_SCSI_OP_MODE_SEN10 0x5a
+#define EFI_SCSI_OP_READ_BUFFER 0x3c
+#define EFI_SCSI_OP_REQUEST_SENSE 0x03
+#define EFI_SCSI_OP_SEND_DIAG 0x1d
+#define EFI_SCSI_OP_TEST_UNIT_READY 0x00
+#define EFI_SCSI_OP_WRITE_BUFF 0x3b
+
+//
+// Commands unique to Direct Access Devices
+//
+#define EFI_SCSI_OP_COMPARE 0x39
+#define EFI_SCSI_OP_FORMAT 0x04
+#define EFI_SCSI_OP_LOCK_UN_CACHE 0x36
+#define EFI_SCSI_OP_PREFETCH 0x34
+#define EFI_SCSI_OP_MEDIA_REMOVAL 0x1e
+#define EFI_SCSI_OP_READ6 0x08
+#define EFI_SCSI_OP_READ10 0x28
+#define EFI_SCSI_OP_READ_CAPACITY 0x25
+#define EFI_SCSI_OP_READ_CAPACITY16 0x9e
+#define EFI_SCSI_OP_READ_DEFECT 0x37
+#define EFI_SCSI_OP_READ_LONG 0x3e
+#define EFI_SCSI_OP_REASSIGN_BLK 0x07
+#define EFI_SCSI_OP_RECEIVE_DIAG 0x1c
+#define EFI_SCSI_OP_RELEASE 0x17
+#define EFI_SCSI_OP_REZERO 0x01
+#define EFI_SCSI_OP_SEARCH_DATA_E 0x31
+#define EFI_SCSI_OP_SEARCH_DATA_H 0x30
+#define EFI_SCSI_OP_SEARCH_DATA_L 0x32
+#define EFI_SCSI_OP_SEEK6 0x0b
+#define EFI_SCSI_OP_SEEK10 0x2b
+#define EFI_SCSI_OP_SEND_DIAG 0x1d
+#define EFI_SCSI_OP_SET_LIMIT 0x33
+#define EFI_SCSI_OP_START_STOP_UNIT 0x1b
+#define EFI_SCSI_OP_SYNC_CACHE 0x35
+#define EFI_SCSI_OP_VERIFY 0x2f
+#define EFI_SCSI_OP_WRITE6 0x0a
+#define EFI_SCSI_OP_WRITE10 0x2a
+#define EFI_SCSI_OP_WRITE_VERIFY 0x2e
+#define EFI_SCSI_OP_WRITE_LONG 0x3f
+#define EFI_SCSI_OP_WRITE_SAME 0x41
+
+//
+// Commands unique to Sequential Access Devices
+//
+#define EFI_SCSI_OP_ERASE 0x19
+#define EFI_SCSI_OP_LOAD_UNLOAD 0x1b
+#define EFI_SCSI_OP_LOCATE 0x2b
+#define EFI_SCSI_OP_READ_BLOCK_LIMIT 0x05
+#define EFI_SCSI_OP_READ_POS 0x34
+#define EFI_SCSI_OP_READ_REVERSE 0x0f
+#define EFI_SCSI_OP_RECOVER_BUF_DATA 0x14
+#define EFI_SCSI_OP_RESERVE_UNIT 0x16
+#define EFI_SCSI_OP_REWIND 0x01
+#define EFI_SCSI_OP_SPACE 0x11
+#define EFI_SCSI_OP_VERIFY_TAPE 0x13
+#define EFI_SCSI_OP_WRITE_FILEMARK 0x10
+
+//
+// Commands unique to Printer Devices
+//
+#define EFI_SCSI_OP_PRINT 0x0a
+#define EFI_SCSI_OP_SLEW_PRINT 0x0b
+#define EFI_SCSI_OP_STOP_PRINT 0x1b
+#define EFI_SCSI_OP_SYNC_BUFF 0x10
+
+//
+// Commands unique to Processor Devices
+//
+#define EFI_SCSI_OP_RECEIVE 0x08
+#define EFI_SCSI_OP_SEND 0x0a
+
+//
+// Commands unique to Write-Once Devices
+//
+#define EFI_SCSI_OP_MEDIUM_SCAN 0x38
+#define EFI_SCSI_OP_SEARCH_DAT_E10 0x31
+#define EFI_SCSI_OP_SEARCH_DAT_E12 0xb1
+#define EFI_SCSI_OP_SEARCH_DAT_H10 0x30
+#define EFI_SCSI_OP_SEARCH_DAT_H12 0xb0
+#define EFI_SCSI_OP_SEARCH_DAT_L10 0x32
+#define EFI_SCSI_OP_SEARCH_DAT_L12 0xb2
+#define EFI_SCSI_OP_SET_LIMIT10 0x33
+#define EFI_SCSI_OP_SET_LIMIT12 0xb3
+#define EFI_SCSI_OP_VERIFY10 0x2f
+#define EFI_SCSI_OP_VERIFY12 0xaf
+#define EFI_SCSI_OP_WRITE12 0xaa
+#define EFI_SCSI_OP_WRITE_VERIFY10 0x2e
+#define EFI_SCSI_OP_WRITE_VERIFY12 0xae
+
+//
+// Commands unique to CD-ROM Devices
+//
+#define EFI_SCSI_OP_PLAY_AUD_10 0x45
+#define EFI_SCSI_OP_PLAY_AUD_12 0xa5
+#define EFI_SCSI_OP_PLAY_AUD_MSF 0x47
+#define EFI_SCSI_OP_PLAY_AUD_TKIN 0x48
+#define EFI_SCSI_OP_PLAY_TK_REL10 0x49
+#define EFI_SCSI_OP_PLAY_TK_REL12 0xa9
+#define EFI_SCSI_OP_READ_CD_CAPACITY 0x25
+#define EFI_SCSI_OP_READ_HEADER 0x44
+#define EFI_SCSI_OP_READ_SUB_CHANNEL 0x42
+#define EFI_SCSI_OP_READ_TOC 0x43
+
+//
+// Commands unique to Scanner Devices
+//
+#define EFI_SCSI_OP_GET_DATABUFF_STAT 0x34
+#define EFI_SCSI_OP_GET_WINDOW 0x25
+#define EFI_SCSI_OP_OBJECT_POS 0x31
+#define EFI_SCSI_OP_SCAN 0x1b
+#define EFI_SCSI_OP_SET_WINDOW 0x24
+
+//
+// Commands unique to Optical Memory Devices
+//
+#define EFI_SCSI_OP_UPDATE_BLOCK 0x3d
+
+//
+// Commands unique to Medium Changer Devices
+//
+#define EFI_SCSI_OP_EXCHANGE_MEDIUM 0xa6
+#define EFI_SCSI_OP_INIT_ELEMENT_STAT 0x07
+#define EFI_SCSI_OP_POS_TO_ELEMENT 0x2b
+#define EFI_SCSI_OP_REQUEST_VE_ADDR 0xb5
+#define EFI_SCSI_OP_SEND_VOL_TAG 0xb6
+
+//
+// Commands unique to Communition Devices
+//
+#define EFI_SCSI_OP_GET_MESSAGE6 0x08
+#define EFI_SCSI_OP_GET_MESSAGE10 0x28
+#define EFI_SCSI_OP_GET_MESSAGE12 0xa8
+#define EFI_SCSI_OP_SEND_MESSAGE6 0x0a
+#define EFI_SCSI_OP_SEND_MESSAGE10 0x2a
+#define EFI_SCSI_OP_SEND_MESSAGE12 0xaa
+
+//
+// SCSI Data Transfer Direction
+//
+#define EFI_SCSI_DATA_IN 0
+#define EFI_SCSI_DATA_OUT 1
+
+//
+// Peripheral Device Type Definitions
+//
+#define EFI_SCSI_TYPE_DISK 0x00 // Disk device
+#define EFI_SCSI_TYPE_TAPE 0x01 // Tape device
+#define EFI_SCSI_TYPE_PRINTER 0x02 // Printer
+#define EFI_SCSI_TYPE_PROCESSOR 0x03 // Processor
+#define EFI_SCSI_TYPE_WORM 0x04 // Write-once read-multiple
+#define EFI_SCSI_TYPE_CDROM 0x05 // CD-ROM device
+#define EFI_SCSI_TYPE_SCANNER 0x06 // Scanner device
+#define EFI_SCSI_TYPE_OPTICAL 0x07 // Optical memory device
+#define EFI_SCSI_TYPE_MEDIUMCHANGER 0x08 // Medium Changer device
+#define EFI_SCSI_TYPE_COMMUNICATION 0x09 // Communications device
+#define EFI_SCSI_TYPE_RESERVED_LOW 0x0A // Reserved (low)
+#define EFI_SCSI_TYPE_RESERVED_HIGH 0x1E // Reserved (high)
+#define EFI_SCSI_TYPE_UNKNOWN 0x1F // Unknown or no device type
+#pragma pack(1)
+//
+// Data structures for scsi command use
+//
+typedef struct {
+ UINT8 Peripheral_Type : 5;
+ UINT8 Peripheral_Qualifier : 3;
+ UINT8 DeviceType_Modifier : 7;
+ UINT8 RMB : 1;
+ UINT8 Version;
+ UINT8 Response_Data_Format;
+ UINT8 Addnl_Length;
+ UINT8 Reserved_5_95[95 - 5 + 1];
+} EFI_SCSI_INQUIRY_DATA;
+
+typedef struct {
+ UINT8 Error_Code : 7;
+ UINT8 Valid : 1;
+ UINT8 Segment_Number;
+ UINT8 Sense_Key : 4;
+ UINT8 Reserved_21 : 1;
+ UINT8 ILI : 1;
+ UINT8 Reserved_22 : 2;
+ UINT8 Information_3_6[4];
+ UINT8 Addnl_Sense_Length; // n - 7
+ UINT8 Vendor_Specific_8_11[4];
+ UINT8 Addnl_Sense_Code; // mandatory
+ UINT8 Addnl_Sense_Code_Qualifier; // mandatory
+ UINT8 Field_Replaceable_Unit_Code; // optional
+ UINT8 Reserved_15_17[3];
+} EFI_SCSI_SENSE_DATA;
+
+typedef struct {
+ UINT8 LastLba3;
+ UINT8 LastLba2;
+ UINT8 LastLba1;
+ UINT8 LastLba0;
+ UINT8 BlockSize3;
+ UINT8 BlockSize2;
+ UINT8 BlockSize1;
+ UINT8 BlockSize0;
+} EFI_SCSI_DISK_CAPACITY_DATA;
+
+typedef struct {
+ UINT8 LastLba7;
+ UINT8 LastLba6;
+ UINT8 LastLba5;
+ UINT8 LastLba4;
+ UINT8 LastLba3;
+ UINT8 LastLba2;
+ UINT8 LastLba1;
+ UINT8 LastLba0;
+ UINT8 BlockSize3;
+ UINT8 BlockSize2;
+ UINT8 BlockSize1;
+ UINT8 BlockSize0;
+ UINT8 Protection;
+ UINT8 LogicPerPhysical;
+ UINT8 LowestAlignLogic2;
+ UINT8 LowestAlignLogic1;
+ UINT8 Reserved[16];
+} EFI_SCSI_DISK_CAPACITY_DATA16;
+
+
+#pragma pack()
+//
+// Sense Key
+//
+#define EFI_SCSI_REQUEST_SENSE_ERROR (0x70)
+#define EFI_SCSI_SK_NO_SENSE (0x0)
+#define EFI_SCSI_SK_RECOVERY_ERROR (0x1)
+#define EFI_SCSI_SK_NOT_READY (0x2)
+#define EFI_SCSI_SK_MEDIUM_ERROR (0x3)
+#define EFI_SCSI_SK_HARDWARE_ERROR (0x4)
+#define EFI_SCSI_SK_ILLEGAL_REQUEST (0x5)
+#define EFI_SCSI_SK_UNIT_ATTENTION (0x6)
+#define EFI_SCSI_SK_DATA_PROTECT (0x7)
+#define EFI_SCSI_SK_BLANK_CHECK (0x8)
+#define EFI_SCSI_SK_VENDOR_SPECIFIC (0x9)
+#define EFI_SCSI_SK_RESERVED_A (0xA)
+#define EFI_SCSI_SK_ABORT (0xB)
+#define EFI_SCSI_SK_RESERVED_C (0xC)
+#define EFI_SCSI_SK_OVERFLOW (0xD)
+#define EFI_SCSI_SK_MISCOMPARE (0xE)
+#define EFI_SCSI_SK_RESERVED_F (0xF)
+
+//
+// Additional Sense Codes
+//
+#define EFI_SCSI_ASC_NOT_READY (0x04)
+#define EFI_SCSI_ASC_MEDIA_ERR1 (0x10)
+#define EFI_SCSI_ASC_MEDIA_ERR2 (0x11)
+#define EFI_SCSI_ASC_MEDIA_ERR3 (0x14)
+#define EFI_SCSI_ASC_MEDIA_ERR4 (0x30)
+#define EFI_SCSI_ASC_MEDIA_UPSIDE_DOWN (0x06)
+#define EFI_SCSI_ASC_INVALID_CMD (0x20)
+#define EFI_SCSI_ASC_LBA_OUT_OF_RANGE (0x21)
+#define EFI_SCSI_ASC_INVALID_FIELD (0x24)
+#define EFI_SCSI_ASC_WRITE_PROTECTED (0x27)
+#define EFI_SCSI_ASC_MEDIA_CHANGE (0x28)
+#define EFI_SCSI_ASC_RESET (0x29) /* Power On Reset or Bus Reset occurred */
+#define EFI_SCSI_ASC_ILLEGAL_FIELD (0x26)
+#define EFI_SCSI_ASC_NO_MEDIA (0x3A)
+#define EFI_SCSI_ASC_ILLEGAL_MODE_FOR_THIS_TRACK (0x64)
+
+//
+// Additional Sense Code Qualifier
+//
+#define EFI_SCSI_ASCQ_IN_PROGRESS (0x01)
+
+//
+// Max bytes needed to represent ID of a SCSI device
+//
+#define EFI_SCSI_TARGET_MAX_BYTES (0x10)
+
+#endif
diff --git a/EDK/Foundation/Include/IndustryStandard/usb.h b/EDK/Foundation/Include/IndustryStandard/usb.h
new file mode 100644
index 0000000..95fb0f7
--- /dev/null
+++ b/EDK/Foundation/Include/IndustryStandard/usb.h
@@ -0,0 +1,344 @@
+/*++
+
+Copyright (c) 2004 - 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ usb.h
+
+Abstract:
+ Support for USB standard.
+
+
+
+
+Revision History
+
+--*/
+
+#ifndef _USB_INDUSTRY_H_
+#define _USB_INDUSTRY_H_
+
+//
+// USB Transfer Results
+//
+#define EFI_USB_NOERROR 0x00
+#define EFI_USB_ERR_NOTEXECUTE 0x01
+#define EFI_USB_ERR_STALL 0x02
+#define EFI_USB_ERR_BUFFER 0x04
+#define EFI_USB_ERR_BABBLE 0x08
+#define EFI_USB_ERR_NAK 0x10
+#define EFI_USB_ERR_CRC 0x20
+#define EFI_USB_ERR_TIMEOUT 0x40
+#define EFI_USB_ERR_BITSTUFF 0x80
+#define EFI_USB_ERR_SYSTEM 0x100
+
+//
+// Constant value for Port Status & Port Change Status
+//
+#define USB_PORT_STAT_CONNECTION 0x0001
+#define USB_PORT_STAT_ENABLE 0x0002
+#define USB_PORT_STAT_SUSPEND 0x0004
+#define USB_PORT_STAT_OVERCURRENT 0x0008
+#define USB_PORT_STAT_RESET 0x0010
+#define USB_PORT_STAT_POWER 0x0100
+#define USB_PORT_STAT_LOW_SPEED 0x0200
+#define USB_PORT_STAT_HIGH_SPEED 0x0400
+#define USB_PORT_STAT_OWNER 0x0800
+
+#define USB_PORT_STAT_C_CONNECTION 0x0001
+#define USB_PORT_STAT_C_ENABLE 0x0002
+#define USB_PORT_STAT_C_SUSPEND 0x0004
+#define USB_PORT_STAT_C_OVERCURRENT 0x0008
+#define USB_PORT_STAT_C_RESET 0x0010
+
+//
+// Usb data transfer direction
+//
+typedef enum {
+ EfiUsbDataIn,
+ EfiUsbDataOut,
+ EfiUsbNoData
+} EFI_USB_DATA_DIRECTION;
+
+//
+// Usb data recipient type
+//
+typedef enum {
+ EfiUsbDevice,
+ EfiUsbInterface,
+ EfiUsbEndpoint
+} EFI_USB_RECIPIENT;
+
+//
+// Usb port features
+//
+typedef enum {
+ EfiUsbPortEnable = 1,
+ EfiUsbPortSuspend = 2,
+ EfiUsbPortReset = 4,
+ EfiUsbPortPower = 8,
+ EfiUsbPortOwner = 13,
+ EfiUsbPortConnectChange = 16,
+ EfiUsbPortEnableChange = 17,
+ EfiUsbPortSuspendChange = 18,
+ EfiUsbPortOverCurrentChange = 19,
+ EfiUsbPortResetChange = 20
+} EFI_USB_PORT_FEATURE;
+
+//
+// Following are definitions not specified by UEFI spec.
+// Add new definitions below this line
+//
+enum {
+ //
+ // USB request type
+ //
+ USB_REQ_TYPE_STANDARD = (0x00 << 5),
+ USB_REQ_TYPE_CLASS = (0x01 << 5),
+ USB_REQ_TYPE_VENDOR = (0x02 << 5),
+
+ //
+ // Standard control transfer request type, or the value
+ // to fill in EFI_USB_DEVICE_REQUEST.Request
+ //
+ USB_REQ_GET_STATUS = 0x00,
+ USB_REQ_CLEAR_FEATURE = 0x01,
+ USB_REQ_SET_FEATURE = 0x03,
+ USB_REQ_SET_ADDRESS = 0x05,
+ USB_REQ_GET_DESCRIPTOR = 0x06,
+ USB_REQ_SET_DESCRIPTOR = 0x07,
+ USB_REQ_GET_CONFIG = 0x08,
+ USB_REQ_SET_CONFIG = 0x09,
+ USB_REQ_GET_INTERFACE = 0x0A,
+ USB_REQ_SET_INTERFACE = 0x0B,
+ USB_REQ_SYNCH_FRAME = 0x0C,
+
+ //
+ // Usb control transfer target
+ //
+ USB_TARGET_DEVICE = 0,
+ USB_TARGET_INTERFACE = 0x01,
+ USB_TARGET_ENDPOINT = 0x02,
+ USB_TARGET_OTHER = 0x03,
+
+ //
+ // USB Descriptor types
+ //
+ USB_DESC_TYPE_DEVICE = 0x01,
+ USB_DESC_TYPE_CONFIG = 0x02,
+ USB_DESC_TYPE_STRING = 0x03,
+ USB_DESC_TYPE_INTERFACE = 0x04,
+ USB_DESC_TYPE_ENDPOINT = 0x05,
+ USB_DESC_TYPE_HID = 0x21,
+
+ //
+ // Features to be cleared by CLEAR_FEATURE requests
+ //
+ USB_FEATURE_ENDPOINT_HALT = 0,
+
+ //
+ // USB endpoint types: 00: control, 01: isochronous, 10: bulk, 11: interrupt
+ //
+ USB_ENDPOINT_CONTROL = 0x00,
+ USB_ENDPOINT_ISO = 0x01,
+ USB_ENDPOINT_BULK = 0x02,
+ USB_ENDPOINT_INTERRUPT = 0x03,
+
+ USB_ENDPOINT_TYPE_MASK = 0x03,
+ USB_ENDPOINT_DIR_IN = 0x80,
+
+ MAXBYTES = 8,
+
+ //
+ //Use 200 ms to increase the error handling response time
+ //
+ EFI_USB_INTERRUPT_DELAY = 2000000,
+};
+
+
+//
+// USB standard descriptors and reqeust
+//
+#pragma pack(1)
+
+typedef struct {
+ UINT8 RequestType;
+ UINT8 Request;
+ UINT16 Value;
+ UINT16 Index;
+ UINT16 Length;
+} EFI_USB_DEVICE_REQUEST;
+
+typedef struct {
+ UINT8 Length;
+ UINT8 DescriptorType;
+ UINT16 BcdUSB;
+ UINT8 DeviceClass;
+ UINT8 DeviceSubClass;
+ UINT8 DeviceProtocol;
+ UINT8 MaxPacketSize0;
+ UINT16 IdVendor;
+ UINT16 IdProduct;
+ UINT16 BcdDevice;
+ UINT8 StrManufacturer;
+ UINT8 StrProduct;
+ UINT8 StrSerialNumber;
+ UINT8 NumConfigurations;
+} EFI_USB_DEVICE_DESCRIPTOR;
+
+typedef struct {
+ UINT8 Length;
+ UINT8 DescriptorType;
+ UINT16 TotalLength;
+ UINT8 NumInterfaces;
+ UINT8 ConfigurationValue;
+ UINT8 Configuration;
+ UINT8 Attributes;
+ UINT8 MaxPower;
+} EFI_USB_CONFIG_DESCRIPTOR;
+
+typedef struct {
+ UINT8 Length;
+ UINT8 DescriptorType;
+ UINT8 InterfaceNumber;
+ UINT8 AlternateSetting;
+ UINT8 NumEndpoints;
+ UINT8 InterfaceClass;
+ UINT8 InterfaceSubClass;
+ UINT8 InterfaceProtocol;
+ UINT8 Interface;
+} EFI_USB_INTERFACE_DESCRIPTOR;
+
+typedef struct {
+ UINT8 Length;
+ UINT8 DescriptorType;
+ UINT8 EndpointAddress;
+ UINT8 Attributes;
+ UINT16 MaxPacketSize;
+ UINT8 Interval;
+} EFI_USB_ENDPOINT_DESCRIPTOR;
+
+typedef struct {
+ UINT8 Length;
+ UINT8 DescriptorType;
+ CHAR16 String[1];
+} EFI_USB_STRING_DESCRIPTOR;
+
+typedef struct {
+ UINT16 PortStatus;
+ UINT16 PortChangeStatus;
+} EFI_USB_PORT_STATUS;
+
+typedef struct {
+ UINT8 Length;
+ UINT8 DescriptorType;
+ UINT8 NbrPorts;
+ UINT8 HubCharacteristics[2];
+ UINT8 PwrOn2PwrGood;
+ UINT8 HubContrCurrent;
+ UINT8 Filler[MAXBYTES];
+} EFI_USB_HUB_DESCRIPTOR;
+
+#pragma pack()
+
+
+///////////////////////////////////////////////////////////////////////////
+/////////////////// Backward Compatibility ///////////////////
+///////////////////////////////////////////////////////////////////////////
+
+//
+// USB Descriptor types
+//
+#define USB_DT_DEVICE 0x01
+#define USB_DT_CONFIG 0x02
+#define USB_DT_STRING 0x03
+#define USB_DT_INTERFACE 0x04
+#define USB_DT_ENDPOINT 0x05
+#define USB_DT_HUB 0x29
+#define USB_DT_HID 0x21
+
+//
+// USB request type
+//
+#define USB_TYPE_STANDARD (0x00 << 5)
+#define USB_TYPE_CLASS (0x01 << 5)
+#define USB_TYPE_VENDOR (0x02 << 5)
+#define USB_TYPE_RESERVED (0x03 << 5)
+
+//
+// USB request targer device
+//
+#define USB_RECIP_DEVICE 0x00
+#define USB_RECIP_INTERFACE 0x01
+#define USB_RECIP_ENDPOINT 0x02
+#define USB_RECIP_OTHER 0x03
+
+//
+// Request target types.
+//
+#define USB_RT_DEVICE 0x00
+#define USB_RT_INTERFACE 0x01
+#define USB_RT_ENDPOINT 0x02
+#define USB_RT_HUB (USB_TYPE_CLASS | USB_RECIP_DEVICE)
+#define USB_RT_PORT (USB_TYPE_CLASS | USB_RECIP_OTHER)
+
+typedef enum {
+ EfiUsbEndpointHalt,
+ EfiUsbDeviceRemoteWakeup
+} EFI_USB_STANDARD_FEATURE_SELECTOR;
+
+//
+// Standard USB request
+//
+#define USB_DEV_GET_STATUS 0x00
+#define USB_DEV_CLEAR_FEATURE 0x01
+#define USB_DEV_SET_FEATURE 0x03
+#define USB_DEV_SET_ADDRESS 0x05
+#define USB_DEV_SET_ADDRESS_REQ_TYPE 0x00
+#define USB_DEV_GET_DESCRIPTOR 0x06
+#define USB_DEV_GET_DESCRIPTOR_REQ_TYPE 0x80
+#define USB_DEV_SET_DESCRIPTOR 0x07
+#define USB_DEV_SET_DESCRIPTOR_REQ_TYPE 0x00
+#define USB_DEV_GET_CONFIGURATION 0x08
+#define USB_DEV_GET_CONFIGURATION_REQ_TYPE 0x80
+#define USB_DEV_SET_CONFIGURATION 0x09
+#define USB_DEV_SET_CONFIGURATION_REQ_TYPE 0x00
+#define USB_DEV_GET_INTERFACE 0x0A
+#define USB_DEV_GET_INTERFACE_REQ_TYPE 0x81
+#define USB_DEV_SET_INTERFACE 0x0B
+#define USB_DEV_SET_INTERFACE_REQ_TYPE 0x01
+#define USB_DEV_SYNCH_FRAME 0x0C
+#define USB_DEV_SYNCH_FRAME_REQ_TYPE 0x82
+
+#pragma pack(1)
+//
+// Supported String Languages
+//
+typedef struct {
+ UINT8 Length;
+ UINT8 DescriptorType;
+ UINT16 SupportedLanID[1];
+} EFI_USB_SUPPORTED_LANGUAGES;
+
+//
+// USB alternate setting
+//
+typedef struct {
+ EFI_USB_INTERFACE_DESCRIPTOR *Interface;
+} USB_ALT_SETTING;
+
+#pragma pack()
+
+///////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////
+///////////////////////////////////////////////////////////////////////////
+
+#endif
diff --git a/EDK/Foundation/Include/Ipf/EfiBind.h b/EDK/Foundation/Include/Ipf/EfiBind.h
new file mode 100644
index 0000000..9a6a009
--- /dev/null
+++ b/EDK/Foundation/Include/Ipf/EfiBind.h
@@ -0,0 +1,239 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiBind.h
+
+Abstract:
+
+ Processor or Compiler specific defines and types for Intel Itanium(TM).
+ We are using the ANSI C 2000 _t type definitions for basic types.
+ This it technically a violation of the coding standard, but they
+ are used to make EfiTypes.h portable. Code other than EfiTypes.h
+ should never use any ANSI C 2000 _t integer types.
+
+--*/
+
+#ifndef _EFI_BIND_H_
+#define _EFI_BIND_H_
+
+
+#define EFI_DRIVER_ENTRY_POINT(InitFunction)
+
+#define EFI_APPLICATION_ENTRY_POINT EFI_DRIVER_ENTRY_POINT
+
+
+
+
+//
+// Make sure we are useing the correct packing rules per EFI specification
+//
+#pragma pack()
+
+
+#if _MSC_EXTENSIONS
+
+//
+// Disable warning that make it impossible to compile at /W4
+// This only works for Microsoft tools. Copied from the
+// IA-32 version of efibind.h
+//
+
+//
+// Disabling bitfield type checking warnings.
+//
+#pragma warning ( disable : 4214 )
+
+
+// Disabling the unreferenced formal parameter warnings.
+//
+#pragma warning ( disable : 4100 )
+
+//
+// Disable slightly different base types warning as CHAR8 * can not be set
+// to a constant string.
+//
+#pragma warning ( disable : 4057 )
+
+//
+// ASSERT(FALSE) or while (TRUE) are legal constructes so supress this warning
+//
+#pragma warning ( disable : 4127 )
+
+//
+// Can not cast a function pointer to a data pointer. We need to do this on
+// IPF to get access to the PLABEL.
+//
+#pragma warning ( disable : 4514 )
+
+//
+// Int64ShllMod32 unreferenced inline function
+//
+#pragma warning ( disable : 4054 )
+
+//
+// Unreferenced formal parameter - We are object oriented, so we pass This even
+// if we don't need them.
+//
+#pragma warning ( disable : 4100 )
+
+
+
+#endif
+
+
+#if (__STDC_VERSION__ < 199901L)
+ //
+ // No ANSI C 2000 stdint.h integer width declarations, so define equivalents
+ //
+
+ #if _MSC_EXTENSIONS
+
+
+ //
+ // use Microsoft C complier dependent interger width types
+ //
+ typedef unsigned __int64 uint64_t;
+ typedef __int64 int64_t;
+ typedef unsigned __int32 uint32_t;
+ typedef __int32 int32_t;
+ typedef unsigned short uint16_t;
+ typedef short int16_t;
+ typedef unsigned char uint8_t;
+ typedef char int8_t;
+ #else
+ #ifdef _EFI_P64
+ //
+ // P64 - is Intel Itanium(TM) speak for pointers being 64-bit and longs and ints
+ // are 32-bits
+ //
+ typedef unsigned long long uint64_t;
+ typedef long long int64_t;
+ typedef unsigned int uint32_t;
+ typedef int int32_t;
+ typedef unsigned short uint16_t;
+ typedef short int16_t;
+ typedef unsigned char uint8_t;
+ typedef char int8_t;
+ #else
+ //
+ // Assume LP64 - longs and pointers are 64-bit. Ints are 32-bit.
+ //
+ typedef unsigned long uint64_t;
+ typedef long int64_t;
+ typedef unsigned int uint32_t;
+ typedef int int32_t;
+ typedef unsigned short uint16_t;
+ typedef short int16_t;
+ typedef unsigned char uint8_t;
+ typedef char int8_t;
+ #endif
+ #endif
+#else
+ //
+ // Use ANSI C 2000 stdint.h integer width declarations
+ //
+ #include "stdint.h"
+#endif
+
+//
+// Native integer size in stdint.h
+//
+typedef uint64_t uintn_t;
+typedef int64_t intn_t;
+
+//
+// Processor specific defines
+//
+#define EFI_MAX_BIT 0x8000000000000000
+#define MAX_2_BITS 0xC000000000000000
+
+//
+// Maximum legal Itanium-based address
+//
+#define EFI_MAX_ADDRESS 0xFFFFFFFFFFFFFFFF
+
+//
+// Bad pointer value to use in check builds.
+// if you see this value you are using uninitialized or free'ed data
+//
+#define EFI_BAD_POINTER 0xAFAFAFAFAFAFAFAF
+#define EFI_BAD_POINTER_AS_BYTE 0xAF
+
+//
+// Inject a break point in the code to assist debugging.
+//
+#pragma intrinsic (__break)
+#define EFI_BREAKPOINT() __break(0)
+#define EFI_DEADLOOP() while(TRUE)
+
+//
+// Memory Fence forces serialization, and is needed to support out of order
+// memory transactions. The Memory Fence is mainly used to make sure IO
+// transactions complete in a deterministic sequence, and to syncronize locks
+// an other MP code. Intel Itanium(TM) processors require explicit memory fence instructions
+// after every IO. Need to find a way of doing that in the function _mf.
+//
+void __mfa (void);
+#pragma intrinsic (__mfa)
+#define MEMORY_FENCE() __mfa()
+
+
+//
+// Some compilers don't support the forward reference construct:
+// typedef struct XXXXX. The forward reference is required for
+// ANSI compatibility.
+//
+// The following macro provide a workaround for such cases.
+//
+
+
+#ifdef EFI_NO_INTERFACE_DECL
+ #define EFI_FORWARD_DECLARATION(x)
+#else
+ #define EFI_FORWARD_DECLARATION(x) typedef struct _##x x
+#endif
+
+//
+// Some C compilers optimize the calling conventions to increase performance.
+// _EFIAPI is used to make all public APIs follow the standard C calling
+// convention.
+//
+
+#if _MSC_EXTENSIONS
+ #define _EFIAPI __cdecl
+#else
+ #define _EFIAPI
+#endif
+
+
+#ifdef _EFI_WINNT
+
+ #define EFI_SUPPRESS_BENIGN_REDEFINITION_OF_TYPE_WARNING() \
+ warning ( disable : 4142 )
+
+ #define EFI_DEFAULT_BENIGN_REDEFINITION_OF_TYPE_WARNING() \
+ warning ( default : 4142 )
+#else
+
+ #define EFI_SUPPRESS_BENIGN_REDEFINITION_OF_TYPE_WARNING() \
+ warning ( disable : 4068 )
+
+ #define EFI_DEFAULT_BENIGN_REDEFINITION_OF_TYPE_WARNING() \
+ warning ( default : 4068 )
+
+
+#endif
+
+
+#endif
+
diff --git a/EDK/Foundation/Include/Ipf/EfiPeOptionalHeader.h b/EDK/Foundation/Include/Ipf/EfiPeOptionalHeader.h
new file mode 100644
index 0000000..ae68945
--- /dev/null
+++ b/EDK/Foundation/Include/Ipf/EfiPeOptionalHeader.h
@@ -0,0 +1,37 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiPeOptionalHeader.h
+
+Abstract:
+ Defines the optional header in the PE image per the PE specification. This
+ file must be included only from within EfiImage.h since
+ EFI_IMAGE_DATA_DIRECTORY and EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES are defined
+ there.
+
+--*/
+
+#ifndef _EFI_PE_OPTIONAL_HEADER_H_
+#define _EFI_PE_OPTIONAL_HEADER_H_
+
+#define EFI_IMAGE_MACHINE_TYPE (EFI_IMAGE_MACHINE_IA64)
+
+#define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) \
+ (((Machine) == EFI_IMAGE_MACHINE_IA64) || ((Machine) == EFI_IMAGE_MACHINE_EBC))
+
+#define EFI_IMAGE_MACHINE_CROSS_TYPE_SUPPORTED(Machine) (FALSE)
+
+#define EFI_IMAGE_NT_OPTIONAL_HDR_MAGIC EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC
+typedef EFI_IMAGE_OPTIONAL_HEADER64 EFI_IMAGE_OPTIONAL_HEADER;
+typedef EFI_IMAGE_NT_HEADERS64 EFI_IMAGE_NT_HEADERS;
+#endif
diff --git a/EDK/Foundation/Include/Ipf/IpfDefines.h b/EDK/Foundation/Include/Ipf/IpfDefines.h
new file mode 100644
index 0000000..96e9e68
--- /dev/null
+++ b/EDK/Foundation/Include/Ipf/IpfDefines.h
@@ -0,0 +1,556 @@
+// ++
+
+// TODO: fix comment to start with /*++
+//
+// Copyright (c) 2004, Intel Corporation
+// All rights reserved. This program and the accompanying materials
+// are licensed and made available under the terms and conditions of the BSD License
+// which accompanies this distribution. The full text of the license may be found at
+// http://opensource.org/licenses/bsd-license.php
+//
+// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+//
+// Module Name:
+//
+// IpfDefines.h
+//
+// Abstract:
+//
+// IPF Processor Defines.
+// NOTE: This file is included by assembly files as well.
+//
+// --
+//
+#ifndef _IPFDEFINES_H
+#define _IPFDEFINES_H
+
+//
+// IPI DElivery Methods
+//
+#define IPI_INT_DELIVERY 0x0
+#define IPI_PMI_DELIVERY 0x2
+#define IPI_NMI_DELIVERY 0x4
+#define IPI_INIT_DELIVERY 0x5
+#define IPI_ExtINT_DELIVERY 0x7
+
+//
+// Define Itanium-based system registers.
+//
+// Define Itanium-based system register bit field offsets.
+//
+// Processor Status Register (PSR) Bit positions
+//
+// User / System mask
+//
+#define PSR_RV0 0
+#define PSR_BE 1
+#define PSR_UP 2
+#define PSR_AC 3
+#define PSR_MFL 4
+#define PSR_MFH 5
+
+//
+// PSR bits 6-12 reserved (must be zero)
+//
+#define PSR_MBZ0 6
+#define PSR_MBZ0_V 0x1ffUL L
+
+//
+// System only mask
+//
+#define PSR_IC 13
+#define PSR_IC_MASK (1 << 13)
+#define PSR_I 14
+#define PSR_PK 15
+#define PSR_MBZ1 16
+#define PSR_MBZ1_V 0x1UL L
+#define PSR_DT 17
+#define PSR_DFL 18
+#define PSR_DFH 19
+#define PSR_SP 20
+#define PSR_PP 21
+#define PSR_DI 22
+#define PSR_SI 23
+#define PSR_DB 24
+#define PSR_LP 25
+#define PSR_TB 26
+#define PSR_RT 27
+
+//
+// PSR bits 28-31 reserved (must be zero)
+//
+#define PSR_MBZ2 28
+#define PSR_MBZ2_V 0xfUL L
+
+//
+// Neither mask
+//
+#define PSR_CPL 32
+#define PSR_CPL_LEN 2
+#define PSR_IS 34
+#define PSR_MC 35
+#define PSR_IT 36
+#define PSR_IT_MASK 0x1000000000
+#define PSR_ID 37
+#define PSR_DA 38
+#define PSR_DD 39
+#define PSR_SS 40
+#define PSR_RI 41
+#define PSR_RI_LEN 2
+#define PSR_ED 43
+#define PSR_BN 44
+
+//
+// PSR bits 45-63 reserved (must be zero)
+//
+#define PSR_MBZ3 45
+#define PSR_MBZ3_V 0xfffffUL L
+
+//
+// Floating Point Status Register (FPSR) Bit positions
+//
+//
+// Traps
+//
+#define FPSR_VD 0
+#define FPSR_DD 1
+#define FPSR_ZD 2
+#define FPSR_OD 3
+#define FPSR_UD 4
+#define FPSR_ID 5
+
+//
+// Status Field 0 - Controls
+//
+#define FPSR0_FTZ0 6
+#define FPSR0_WRE0 7
+#define FPSR0_PC0 8
+#define FPSR0_RC0 10
+#define FPSR0_TD0 12
+
+//
+// Status Field 0 - Flags
+//
+#define FPSR0_V0 13
+#define FPSR0_D0 14
+#define FPSR0_Z0 15
+#define FPSR0_O0 16
+#define FPSR0_U0 17
+#define FPSR0_I0 18
+
+//
+// Status Field 1 - Controls
+//
+#define FPSR1_FTZ0 19
+#define FPSR1_WRE0 20
+#define FPSR1_PC0 21
+#define FPSR1_RC0 23
+#define FPSR1_TD0 25
+
+//
+// Status Field 1 - Flags
+//
+#define FPSR1_V0 26
+#define FPSR1_D0 27
+#define FPSR1_Z0 28
+#define FPSR1_O0 29
+#define FPSR1_U0 30
+#define FPSR1_I0 31
+
+//
+// Status Field 2 - Controls
+//
+#define FPSR2_FTZ0 32
+#define FPSR2_WRE0 33
+#define FPSR2_PC0 34
+#define FPSR2_RC0 36
+#define FPSR2_TD0 38
+
+//
+// Status Field 2 - Flags
+//
+#define FPSR2_V0 39
+#define FPSR2_D0 40
+#define FPSR2_Z0 41
+#define FPSR2_O0 42
+#define FPSR2_U0 43
+#define FPSR2_I0 44
+
+//
+// Status Field 3 - Controls
+//
+#define FPSR3_FTZ0 45
+#define FPSR3_WRE0 46
+#define FPSR3_PC0 47
+#define FPSR3_RC0 49
+#define FPSR3_TD0 51
+
+//
+// Status Field 0 - Flags
+//
+#define FPSR3_V0 52
+#define FPSR3_D0 53
+#define FPSR3_Z0 54
+#define FPSR3_O0 55
+#define FPSR3_U0 56
+#define FPSR3_I0 57
+
+//
+// FPSR bits 58-63 Reserved -- Must be zero
+//
+#define FPSR_MBZ0 58
+#define FPSR_MBZ0_V 0x3fUL L
+
+//
+// For setting up FPSR on kernel entry
+// All traps are disabled.
+//
+#define FPSR_FOR_KERNEL 0x3f
+
+#define FP_REG_SIZE 16 // 16 byte spill size
+#define HIGHFP_REGS_LENGTH (96 * 16)
+
+//
+// Define hardware Task Priority Register (TPR)
+//
+//
+// TPR bit positions
+//
+#define TPR_MIC 4 // Bits 0 - 3 ignored
+#define TPR_MIC_LEN 4
+#define TPR_MMI 16 // Mask Maskable Interrupt
+//
+// Define hardware Interrupt Status Register (ISR)
+//
+//
+// ISR bit positions
+//
+#define ISR_CODE 0
+#define ISR_CODE_LEN 16
+#define ISR_CODE_MASK 0xFFFF
+#define ISR_IA_VECTOR 16
+#define ISR_IA_VECTOR_LEN 8
+#define ISR_MBZ0 24
+#define ISR_MBZ0_V 0xff
+#define ISR_X 32
+#define ISR_W 33
+#define ISR_R 34
+#define ISR_NA 35
+#define ISR_SP 36
+#define ISR_RS 37
+#define ISR_IR 38
+#define ISR_NI 39
+#define ISR_MBZ1 40
+#define ISR_EI 41
+#define ISR_ED 43
+#define ISR_MBZ2 44
+#define ISR_MBZ2_V 0xfffff
+
+//
+// ISR codes
+//
+// For General exceptions: ISR{3:0}
+//
+#define ISR_ILLEGAL_OP 0 // Illegal operation fault
+#define ISR_PRIV_OP 1 // Privileged operation fault
+#define ISR_PRIV_REG 2 // Privileged register fauls
+#define ISR_RESVD_REG 3 // Reserved register/field flt
+#define ISR_ILLEGAL_ISA 4 // Disabled instruction set transition fault
+//
+// Define hardware Default Control Register (DCR)
+//
+//
+// DCR bit positions
+//
+#define DCR_PP 0
+#define DCR_BE 1
+#define DCR_LC 2
+#define DCR_MBZ0 4
+#define DCR_MBZ0_V 0xf
+#define DCR_DM 8
+#define DCR_DP 9
+#define DCR_DK 10
+#define DCR_DX 11
+#define DCR_DR 12
+#define DCR_DA 13
+#define DCR_DD 14
+#define DCR_DEFER_ALL 0x7f00
+#define DCR_MBZ1 2
+#define DCR_MBZ1_V 0xffffffffffffUL L
+
+//
+// Define hardware RSE Configuration Register
+//
+// RS Configuration (RSC) bit field positions
+//
+#define RSC_MODE 0
+#define RSC_PL 2
+#define RSC_BE 4
+#define RSC_MBZ0 5
+#define RSC_MBZ0_V 0x3ff
+#define RSC_LOADRS 16
+#define RSC_LOADRS_LEN 14
+#define RSC_MBZ1 30
+#define RSC_MBZ1_V 0x3ffffffffUL L
+
+//
+// RSC modes
+//
+#define RSC_MODE_LY (0x0) // Lazy
+#define RSC_MODE_SI (0x1) // Store intensive
+#define RSC_MODE_LI (0x2) // Load intensive
+#define RSC_MODE_EA (0x3) // Eager
+//
+// RSC Endian bit values
+//
+#define RSC_BE_LITTLE 0
+#define RSC_BE_BIG 1
+
+//
+// Define Interruption Function State (IFS) Register
+//
+// IFS bit field positions
+//
+#define IFS_IFM 0
+#define IFS_IFM_LEN 38
+#define IFS_MBZ0 38
+#define IFS_MBZ0_V 0x1ffffff
+#define IFS_V 63
+#define IFS_V_LEN 1
+
+//
+// IFS is valid when IFS_V = IFS_VALID
+//
+#define IFS_VALID 1
+
+//
+// Define Page Table Address (PTA)
+//
+#define PTA_VE 0
+#define PTA_VF 8
+#define PTA_SIZE 2
+#define PTA_SIZE_LEN 6
+#define PTA_BASE 15
+
+//
+// Define Region Register (RR)
+//
+//
+// RR bit field positions
+//
+#define RR_VE 0
+#define RR_MBZ0 1
+#define RR_PS 2
+#define RR_PS_LEN 6
+#define RR_RID 8
+#define RR_RID_LEN 24
+#define RR_MBZ1 32
+
+//
+// SAL uses region register 0 and RID of 1000
+//
+#define SAL_RID 0x1000
+#define SAL_RR_REG 0x0
+#define SAL_TR 0x0
+
+//
+// Total number of region registers
+//
+#define RR_SIZE 8
+
+//
+// Define Protection Key Register (PKR)
+//
+// PKR bit field positions
+//
+#define PKR_V 0
+#define PKR_WD 1
+#define PKR_RD 2
+#define PKR_XD 3
+#define PKR_MBZ0 4
+#define PKR_KEY 8
+#define PKR_KEY_LEN 24
+#define PKR_MBZ1 32
+
+#define PKR_VALID (1 << PKR_V)
+
+//
+// Number of protection key registers
+//
+#define PKRNUM 8
+
+//
+// Define Interruption TLB Insertion register (ITIR)
+//
+//
+// Define Translation Insertion Format (TR)
+//
+// PTE0 bit field positions
+//
+#define PTE0_P 0
+#define PTE0_MBZ0 1
+#define PTE0_MA 2
+#define PTE0_A 5
+#define PTE0_D 6
+#define PTE0_PL 7
+#define PTE0_AR 9
+#define PTE0_PPN 12
+#define PTE0_MBZ1 48
+#define PTE0_ED 52
+#define PTE0_IGN0 53
+
+//
+// ITIR bit field positions
+//
+#define ITIR_MBZ0 0
+#define ITIR_PS 2
+#define ITIR_PS_LEN 6
+#define ITIR_KEY 8
+#define ITIR_KEY_LEN 24
+#define ITIR_MBZ1 32
+#define ITIR_MBZ1_LEN 16
+#define ITIR_PPN 48
+#define ITIR_PPN_LEN 15
+#define ITIR_MBZ2 63
+
+#define ATTR_IPAGE 0x661 // Access Rights = RWX (bits 11-9=011), PL 0(8-7=0)
+#define ATTR_DEF_BITS 0x661 // Access Rights = RWX (bits 11-9=010), PL 0(8-7=0)
+// Dirty (bit 6=1), Accessed (bit 5=1),
+// MA WB (bits 4-2=000), Present (bit 0=1)
+//
+// Memory access rights
+//
+#define AR_UR_KR 0x0 // user/kernel read
+#define AR_URX_KRX 0x1 // user/kernel read and execute
+#define AR_URW_KRW 0x2 // user/kernel read & write
+#define AR_URWX_KRWX 0x3 // user/kernel read,write&execute
+#define AR_UR_KRW 0x4 // user read/kernel read,write
+#define AR_URX_KRWX 0x5 // user read/execute, kernel all
+#define AR_URWX_KRW 0x6 // user all, kernel read & write
+#define AR_UX_KRX 0x7 // user execute only, kernel read and execute
+//
+// Memory attribute values
+//
+//
+// The next 4 are all cached, non-sequential & speculative, coherent
+//
+#define MA_WBU 0x0 // Write back, unordered
+//
+// The next 3 are all non-cached, sequential & non-speculative
+//
+#define MA_UC 0x4 // Non-coalescing, sequential & non-speculative
+#define MA_UCE 0x5 // Non-coalescing, sequential, non-speculative
+// & fetchadd exported
+//
+#define MA_WC 0x6 // Non-cached, Coalescing, non-seq., spec.
+#define MA_NAT 0xf // NaT page
+//
+// Definition of the offset of TRAP/INTERRUPT/FAULT handlers from the
+// base of IVA (Interruption Vector Address)
+//
+#define IVT_SIZE 0x8000
+#define EXTRA_ALIGNMENT 0x1000
+
+#define OFF_VHPTFLT 0x0000 // VHPT Translation fault
+#define OFF_ITLBFLT 0x0400 // Instruction TLB fault
+#define OFF_DTLBFLT 0x0800 // Data TLB fault
+#define OFF_ALTITLBFLT 0x0C00 // Alternate ITLB fault
+#define OFF_ALTDTLBFLT 0x1000 // Alternate DTLB fault
+#define OFF_NESTEDTLBFLT 0x1400 // Nested TLB fault
+#define OFF_IKEYMISSFLT 0x1800 // Inst Key Miss fault
+#define OFF_DKEYMISSFLT 0x1C00 // Data Key Miss fault
+#define OFF_DIRTYBITFLT 0x2000 // Dirty-Bit fault
+#define OFF_IACCESSBITFLT 0x2400 // Inst Access-Bit fault
+#define OFF_DACCESSBITFLT 0x2800 // Data Access-Bit fault
+#define OFF_BREAKFLT 0x2C00 // Break Inst fault
+#define OFF_EXTINT 0x3000 // External Interrupt
+//
+// Offset 0x3400 to 0x0x4C00 are reserved
+//
+#define OFF_PAGENOTPFLT 0x5000 // Page Not Present fault
+#define OFF_KEYPERMFLT 0x5100 // Key Permission fault
+#define OFF_IACCESSRTFLT 0x5200 // Inst Access-Rights flt
+#define OFF_DACCESSRTFLT 0x5300 // Data Access-Rights fault
+#define OFF_GPFLT 0x5400 // General Exception fault
+#define OFF_FPDISFLT 0x5500 // Disable-FP fault
+#define OFF_NATFLT 0x5600 // NAT Consumption fault
+#define OFF_SPECLNFLT 0x5700 // Speculation fault
+#define OFF_DBGFLT 0x5900 // Debug fault
+#define OFF_ALIGNFLT 0x5A00 // Unaligned Reference fault
+#define OFF_LOCKDREFFLT 0x5B00 // Locked Data Reference fault
+#define OFF_FPFLT 0x5C00 // Floating Point fault
+#define OFF_FPTRAP 0x5D00 // Floating Point Trap
+#define OFF_LOPRIVTRAP 0x5E00 // Lower-Privilege Transfer Trap
+#define OFF_TAKENBRTRAP 0x5F00 // Taken Branch Trap
+#define OFF_SSTEPTRAP 0x6000 // Single Step Trap
+//
+// Offset 0x6100 to 0x6800 are reserved
+//
+#define OFF_IA32EXCEPTN 0x6900 // iA32 Exception
+#define OFF_IA32INTERCEPT 0x6A00 // iA32 Intercept
+#define OFF_IA32INT 0x6B00 // iA32 Interrupt
+#define NUMBER_OF_VECTORS 0x100
+//
+// Privilege levels
+//
+#define PL_KERNEL 0
+#define PL_USER 3
+
+//
+// Instruction set (IS) bits
+//
+#define IS_IA64 0
+#define IS_IA 1
+
+//
+// RSC while in kernel: enabled, little endian, PL = 0, eager mode
+//
+#define RSC_KERNEL ((RSC_MODE_EA << RSC_MODE) | (RSC_BE_LITTLE << RSC_BE))
+
+//
+// Lazy RSC in kernel: enabled, little endian, pl = 0, lazy mode
+//
+#define RSC_KERNEL_LAZ ((RSC_MODE_LY << RSC_MODE) | (RSC_BE_LITTLE << RSC_BE))
+
+//
+// RSE disabled: disabled, PL = 0, little endian, eager mode
+//
+#define RSC_KERNEL_DISABLED ((RSC_MODE_LY << RSC_MODE) | (RSC_BE_LITTLE << RSC_BE))
+
+#define NAT_BITS_PER_RNAT_REG 63
+
+//
+// Macros for generating PTE0 and PTE1 value
+//
+#define PTE0(ed, ppn12_47, ar, pl, d, a, ma, p) \
+ ( ( ed << PTE0_ED ) | \
+ ( ppn12_47 << PTE0_PPN ) | \
+ ( ar << PTE0_AR ) | \
+ ( pl << PTE0_PL ) | \
+ ( d << PTE0_D ) | \
+ ( a << PTE0_A ) | \
+ ( ma << PTE0_MA ) | \
+ ( p << PTE0_P ) \
+ )
+
+#define ITIR(ppn48_63, key, ps) \
+ ( ( ps << ITIR_PS ) | \
+ ( key << ITIR_KEY ) | \
+ ( ppn48_63 << ITIR_PPN ) \
+ )
+
+//
+// Macro to generate mask value from bit position. The result is a
+// 64-bit.
+//
+#define BITMASK(bp, value) (value << bp)
+
+#define BUNDLE_SIZE 16
+#define SPURIOUS_INT 0xF
+
+#define FAST_DISABLE_INTERRUPTS rsm BITMASK (PSR_I, 1);;
+
+#define FAST_ENABLE_INTERRUPTS ssm BITMASK (PSR_I, 1);;
+
+#endif
diff --git a/EDK/Foundation/Include/Ipf/IpfMacro.i b/EDK/Foundation/Include/Ipf/IpfMacro.i
new file mode 100644
index 0000000..a9be754
--- /dev/null
+++ b/EDK/Foundation/Include/Ipf/IpfMacro.i
@@ -0,0 +1,66 @@
+//++
+// Copyright (c) 2004, Intel Corporation
+// All rights reserved. This program and the accompanying materials
+// are licensed and made available under the terms and conditions of the BSD License
+// which accompanies this distribution. The full text of the license may be found at
+// http://opensource.org/licenses/bsd-license.php
+//
+// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+//
+// Module Name:
+//
+// IpfMacro.i
+//
+// Abstract:
+//
+// Contains the macros needed for calling procedures in Itanium-based assembly code.
+//
+//
+// Revision History:
+//
+//--
+
+#ifndef _IA64PROC_I
+#define _IA64PROC_I
+
+
+#define PROCEDURE_ENTRY(name) .##text; \
+ .##type name, @function; \
+ .##proc name; \
+name::
+
+#define PROCEDURE_EXIT(name) .##endp name
+
+// Note: use of NESTED_SETUP requires number of locals (l) >= 3
+
+#define NESTED_SETUP(i,l,o,r) \
+ alloc loc1=ar##.##pfs,i,l,o,r ;\
+ mov loc0=b0
+
+#define NESTED_RETURN \
+ mov b0=loc0 ;\
+ mov ar##.##pfs=loc1 ;;\
+ br##.##ret##.##dpnt b0;;
+
+
+#define INTERRUPT_HANDLER_BEGIN(name) \
+PROCEDURE_ENTRY(name##HandlerBegin) \
+;; \
+PROCEDURE_EXIT(name##HandlerBegin)
+
+#define INTERRUPT_HANDLER_END(name) \
+PROCEDURE_ENTRY(name##HandlerEnd) \
+;; \
+PROCEDURE_EXIT(name##HandlerEnd)
+
+
+#define INTERRUPT_HANDLER_BLOCK_BEGIN \
+INTERRUPT_HANDLER_BEGIN(First)
+
+#define INTERRUPT_HANDLER_BLOCK_END \
+INTERRUPT_HANDLER_END(Last)
+
+
+
+#endif // _IA64PROC_I
diff --git a/EDK/Foundation/Include/Ipf/PalApi.h b/EDK/Foundation/Include/Ipf/PalApi.h
new file mode 100644
index 0000000..d2c976a
--- /dev/null
+++ b/EDK/Foundation/Include/Ipf/PalApi.h
@@ -0,0 +1,133 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PalApi.h
+
+Abstract:
+
+ Main PAL API's defined in PAL specification.
+
+
+Revision History:
+
+--*/
+
+#ifndef _PALPROC_H
+#define _PALPROC_H
+
+#include "Tiano.h"
+
+#define PAL_CACHE_FLUSH 0x0001
+#define PAL_CACHE_INFO 0x0002
+#define PAL_CACHE_INIT 0x0003
+#define PAL_CACHE_SUMMARY 0x0004
+#define PAL_MEM_ATTRIB 0x0005
+#define PAL_PTCE_INFO 0x0006
+#define PAL_VM_INFO 0x0007
+#define PAL_VM_SUMMARY 0x0008
+#define PAL_BUS_GET_FEATURES 0x0009
+#define PAL_BUS_SET_FEATURES 0x000a
+#define PAL_DEBUG_INFO 0x000b
+#define PAL_FIXED_ADDR 0x000c
+#define PAL_FREQ_BASE 0x000d
+#define PAL_FREQ_RATIOS 0x000e
+#define PAL_PERF_MON_INFO 0x000f
+#define PAL_PLATFORM_ADDR 0x0010
+#define PAL_PROC_GET_FEATURES 0x0011
+#define PAL_PROC_SET_FEATURES 0x0012
+#define PAL_RSE_INFO 0x0013
+#define PAL_VERSION 0x0014
+
+#define PAL_MC_CLEAR_LOG 0x0015
+#define PAL_MC_DRAIN 0x0016
+#define PAL_MC_EXPECTED 0x0017
+#define PAL_MC_DYNAMIC_STATE 0x0018
+#define PAL_MC_ERROR_INFO 0x0019
+#define PAL_MC_RESUME 0x001a
+#define PAL_MC_REGISTER_MEM 0x001b
+#define PAL_HALT 0x001c
+#define PAL_HALT_LIGHT 0x001d
+#define PAL_COPY_INFO 0x001e
+#define PAL_SHUTDOWN 0x002c
+#define PAL_AUTH 0x0209
+#define PAL_SINGL_DISPERSAL 0x0226 // dec. 550
+#define PAL_HALT_INFO 0x0101
+#define PAL_CACHE_LINE_INIT 0x001f
+#define PAL_PMI_ENTRYPOINT 0x0020
+#define PAL_ENTER_IA_32_ENV 0x0021
+#define PAL_VM_PAGE_SIZE 0x0022
+#define PAL_MEM_FOR_TEST 0x0025
+#define PAL_CACHE_PROT_INFO 0x0026
+
+#define PAL_COPY_PAL 0x0100
+#define PAL_CACHE_READ 0x0103
+#define PAL_CACHE_WRITE 0x0104
+#define PAL_TEST_PROC 0x0102
+
+#define PAL_DEBUG_FEATURE 0x0063 // vp1
+typedef UINT64 EFI_PAL_STATUS;
+
+//
+// Return values from PAL
+//
+typedef struct {
+ EFI_PAL_STATUS Status; // register r8
+ UINT64 r9;
+ UINT64 r10;
+ UINT64 r11;
+} PAL_RETURN_REGS;
+
+//
+// PAL equates for other parameters.
+//
+#define PAL_SUCCESS 0x0
+#define PAL_CALL_ERROR 0xfffffffffffffffd
+#define PAL_CALL_UNIMPLEMENTED 0xffffffffffffffff
+#define PAL_CACHE_TYPE_I 0x1
+#define PAL_CACHE_TYPE_D 0x2
+#define PAL_CACHE_TYPE_I_AND_D 0x3
+#define PAL_CACHE_NO_INT 0x0
+#define PAL_CACHE_INT 0x2
+//
+// #define PAL_CACHE_PLAT_ACK 0x4
+//
+#define PAL_CACHE_NO_PLAT_ACK 0x0
+#define PAL_CACHE_INVALIDATE 0x1
+#define PAL_CACHE_NO_INVALIDATE 0x0
+#define PAL_CACHE_ALL_LEVELS - 0x1
+
+#define PAL_FEATURE_ENABLE 0x1
+#define PAL_ENABLE_BERR_BIT 63
+#define PAL_ENABLE_MCA_BINIT_BIT 61
+#define PAL_ENABLE_CMCI_MCA_BIT 60
+#define PAL_CACHE_DISABLE_BIT 59
+#define PAL_DISABLE_COHERENCY_BIT 58
+
+#define PAL_DIS_BUS_DATA_ERR_CHECK_BIT 63
+#define PAL_DIS_BUS_ADDR_ERR_CHECK_BIT 61
+#define PAL_DIS_BUS_INIT_EVENT_SIGNAL_BIT 60
+#define PAL_DIS_BUS_REQ_ERR_SIGNAL_BIT 58
+#define PAL_DIS_BUS_REQ_INT_ERR_SIGNAL_BIT 57
+#define PAL_DIS_BUS_REQ_ERR_CHECK_BIT 56
+#define PAL_DIS_BUS_RESP_ERR_CHECK_BIT 55
+
+#define PAL_COPY_BSP_TOKEN 0x0
+#define PAL_COPY_AP_TOKEN 0x1
+
+#define PAL_CODE_TOKEN 0x0
+#define PAL_IA32EMU_CODE_TOKEN 0x1
+
+#define PAL_INTERRUPT_BLOCK_TOKEN 0x0
+#define PAL_IO_BLOCK_TOKEN 0x1
+
+#endif
diff --git a/EDK/Foundation/Include/Ipf/SalApi.h b/EDK/Foundation/Include/Ipf/SalApi.h
new file mode 100644
index 0000000..89cbb72
--- /dev/null
+++ b/EDK/Foundation/Include/Ipf/SalApi.h
@@ -0,0 +1,724 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ SalApi.h
+
+Abstract:
+
+ Main SAL API's defined in SAL 3.0 specification.
+
+
+Revision History:
+
+--*/
+
+#ifndef _SAL_API_H_
+#define _SAL_API_H_
+
+typedef UINTN EFI_SAL_STATUS;
+
+//
+// EFI_SAL_STATUS defines
+//
+#define EFI_SAL_SUCCESS ((EFI_SAL_STATUS) 0)
+#define EFI_SAL_MORE_RECORDS ((EFI_SAL_STATUS) 3)
+#define EFI_SAL_NOT_IMPLEMENTED ((EFI_SAL_STATUS) - 1)
+#define EFI_SAL_INVALID_ARGUMENT ((EFI_SAL_STATUS) - 2)
+#define EFI_SAL_ERROR ((EFI_SAL_STATUS) - 3)
+#define EFI_SAL_VIRTUAL_ADDRESS_ERROR ((EFI_SAL_STATUS) - 4)
+#define EFI_SAL_NO_INFORMATION ((EFI_SAL_STATUS) - 5)
+#define EFI_SAL_NOT_ENOUGH_SCRATCH ((EFI_SAL_STATUS) - 9)
+
+//
+// Delivery Mode of IPF CPU.
+//
+typedef enum {
+ INT,
+ MPreserved1,
+ PMI,
+ MPreserved2,
+ NMI,
+ INIT,
+ MPreserved3,
+ ExtINT
+} EFI_DELIVERY_MODE;
+
+//
+// Return values from SAL
+//
+typedef struct {
+ EFI_SAL_STATUS Status; // register r8
+ UINTN r9;
+ UINTN r10;
+ UINTN r11;
+} SAL_RETURN_REGS;
+
+typedef SAL_RETURN_REGS (EFIAPI *SAL_PROC)
+ (
+ IN UINT64 FunctionId,
+ IN UINT64 Arg2,
+ IN UINT64 Arg3,
+ IN UINT64 Arg4,
+ IN UINT64 Arg5,
+ IN UINT64 Arg6,
+ IN UINT64 Arg7,
+ IN UINT64 Arg8
+ );
+
+//
+// SAL Procedure FunctionId definition
+//
+#define EFI_SAL_SET_VECTORS 0x01000000
+#define EFI_SAL_GET_STATE_INFO 0x01000001
+#define EFI_SAL_GET_STATE_INFO_SIZE 0x01000002
+#define EFI_SAL_CLEAR_STATE_INFO 0x01000003
+#define EFI_SAL_MC_RENDEZ 0x01000004
+#define EFI_SAL_MC_SET_PARAMS 0x01000005
+#define EFI_SAL_REGISTER_PHYSICAL_ADDR 0x01000006
+#define EFI_SAL_CACHE_FLUSH 0x01000008
+#define EFI_SAL_CACHE_INIT 0x01000009
+#define EFI_SAL_PCI_CONFIG_READ 0x01000010
+#define EFI_SAL_PCI_CONFIG_WRITE 0x01000011
+#define EFI_SAL_FREQ_BASE 0x01000012
+#define EFI_SAL_UPDATE_PAL 0x01000020
+
+#define EFI_SAL_FUNCTION_ID_MASK 0x0000ffff
+#define EFI_SAL_MAX_SAL_FUNCTION_ID 0x00000021
+
+//
+// SAL Procedure parameter definitions
+// Not much point in using typedefs or enums because all params
+// are UINT64 and the entry point is common
+//
+// EFI_SAL_SET_VECTORS
+//
+#define EFI_SAL_SET_MCA_VECTOR 0x0
+#define EFI_SAL_SET_INIT_VECTOR 0x1
+#define EFI_SAL_SET_BOOT_RENDEZ_VECTOR 0x2
+
+typedef struct {
+ UINT64 Length : 32;
+ UINT64 ChecksumValid : 1;
+ UINT64 Reserved1 : 7;
+ UINT64 ByteChecksum : 8;
+ UINT64 Reserved2 : 16;
+} SAL_SET_VECTORS_CS_N;
+
+//
+// EFI_SAL_GET_STATE_INFO, EFI_SAL_GET_STATE_INFO_SIZE,
+// EFI_SAL_CLEAR_STATE_INFO
+//
+#define EFI_SAL_MCA_STATE_INFO 0x0
+#define EFI_SAL_INIT_STATE_INFO 0x1
+#define EFI_SAL_CMC_STATE_INFO 0x2
+#define EFI_SAL_CP_STATE_INFO 0x3
+
+//
+// EFI_SAL_MC_SET_PARAMS
+//
+#define EFI_SAL_MC_SET_RENDEZ_PARAM 0x1
+#define EFI_SAL_MC_SET_WAKEUP_PARAM 0x2
+#define EFI_SAL_MC_SET_CPE_PARAM 0x3
+
+#define EFI_SAL_MC_SET_INTR_PARAM 0x1
+#define EFI_SAL_MC_SET_MEM_PARAM 0x2
+
+//
+// EFI_SAL_REGISTER_PAL_PHYSICAL_ADDR
+//
+#define EFI_SAL_REGISTER_PAL_ADDR 0x0
+
+//
+// EFI_SAL_CACHE_FLUSH
+//
+#define EFI_SAL_FLUSH_I_CACHE 0x01
+#define EFI_SAL_FLUSH_D_CACHE 0x02
+#define EFI_SAL_FLUSH_BOTH_CACHE 0x03
+#define EFI_SAL_FLUSH_MAKE_COHERENT 0x04
+
+//
+// EFI_SAL_PCI_CONFIG_READ, EFI_SAL_PCI_CONFIG_WRITE
+//
+#define EFI_SAL_PCI_CONFIG_ONE_BYTE 0x1
+#define EFI_SAL_PCI_CONFIG_TWO_BYTES 0x2
+#define EFI_SAL_PCI_CONFIG_FOUR_BYTES 0x4
+
+typedef struct {
+ UINT64 Register : 8;
+ UINT64 Function : 3;
+ UINT64 Device : 5;
+ UINT64 Bus : 8;
+ UINT64 Segment : 8;
+ UINT64 Reserved : 32;
+} SAL_PCI_ADDRESS;
+
+//
+// EFI_SAL_FREQ_BASE
+//
+#define EFI_SAL_CPU_INPUT_FREQ_BASE 0x0
+#define EFI_SAL_PLATFORM_IT_FREQ_BASE 0x1
+#define EFI_SAL_PLATFORM_RTC_FREQ_BASE 0x2
+
+//
+// EFI_SAL_UPDATE_PAL
+//
+#define EFI_SAL_UPDATE_BAD_PAL_VERSION ((UINT64) -1)
+#define EFI_SAL_UPDATE_PAL_AUTH_FAIL ((UINT64) -2)
+#define EFI_SAL_UPDATE_PAL_BAD_TYPE ((UINT64) -3)
+#define EFI_SAL_UPDATE_PAL_READONLY ((UINT64) -4)
+#define EFI_SAL_UPDATE_PAL_WRITE_FAIL ((UINT64) -10)
+#define EFI_SAL_UPDATE_PAL_ERASE_FAIL ((UINT64) -11)
+#define EFI_SAL_UPDATE_PAL_READ_FAIL ((UINT64) -12)
+#define EFI_SAL_UPDATE_PAL_CANT_FIT ((UINT64) -13)
+
+typedef struct {
+ UINT32 Size;
+ UINT32 MmddyyyyDate;
+ UINT16 Version;
+ UINT8 Type;
+ UINT8 Reserved[5];
+ UINT64 FwVendorId;
+} SAL_UPDATE_PAL_DATA_BLOCK;
+
+typedef struct _SAL_UPDATE_PAL_INFO_BLOCK {
+ struct _SAL_UPDATE_PAL_INFO_BLOCK *Next;
+ struct SAL_UPDATE_PAL_DATA_BLOCK *DataBlock;
+ UINT8 StoreChecksum;
+ UINT8 Reserved[15];
+} SAL_UPDATE_PAL_INFO_BLOCK;
+
+//
+// SAL System Table Definitions
+//
+#pragma pack(1)
+typedef struct {
+ UINT32 Signature;
+ UINT32 Length;
+ UINT16 SalRevision;
+ UINT16 EntryCount;
+ UINT8 CheckSum;
+ UINT8 Reserved[7];
+ UINT16 SalAVersion;
+ UINT16 SalBVersion;
+ UINT8 OemId[32];
+ UINT8 ProductId[32];
+ UINT8 Reserved2[8];
+} SAL_SYSTEM_TABLE_HEADER;
+#pragma pack()
+
+#define EFI_SAL_ST_HEADER_SIGNATURE "SST_"
+#define EFI_SAL_REVISION 0x0300
+//
+// SAL System Types
+//
+#define EFI_SAL_ST_ENTRY_POINT 0
+#define EFI_SAL_ST_MEMORY_DESCRIPTOR 1
+#define EFI_SAL_ST_PLATFORM_FEATURES 2
+#define EFI_SAL_ST_TR_USAGE 3
+#define EFI_SAL_ST_PTC 4
+#define EFI_SAL_ST_AP_WAKEUP 5
+
+#pragma pack(1)
+typedef struct {
+ UINT8 Type; // Type == 0
+ UINT8 Reserved[7];
+ UINT64 PalProcEntry;
+ UINT64 SalProcEntry;
+ UINT64 SalGlobalDataPointer;
+ UINT64 Reserved2[2];
+} SAL_ST_ENTRY_POINT_DESCRIPTOR;
+
+//
+// Not needed for Itanium-based OS boot
+//
+typedef struct {
+ UINT8 Type; // Type == 1
+ UINT8 NeedVirtualRegistration;
+ UINT8 MemoryAttributes;
+ UINT8 PageAccessRights;
+ UINT8 SupportedAttributes;
+ UINT8 Reserved;
+ UINT8 MemoryType;
+ UINT8 MemoryUsage;
+ UINT64 PhysicalMemoryAddress;
+ UINT32 Length;
+ UINT32 Reserved1;
+ UINT64 OemReserved;
+} SAL_ST_MEMORY_DESCRIPTOR_ENTRY;
+
+#pragma pack()
+//
+// Memory Attributes
+//
+#define SAL_MDT_ATTRIB_WB 0x00
+//
+// #define SAL_MDT_ATTRIB_UC 0x02
+//
+#define SAL_MDT_ATTRIB_UC 0x04
+#define SAL_MDT_ATTRIB_UCE 0x05
+#define SAL_MDT_ATTRIB_WC 0x06
+
+//
+// Supported memory Attributes
+//
+#define SAL_MDT_SUPPORT_WB 0x1
+#define SAL_MDT_SUPPORT_UC 0x2
+#define SAL_MDT_SUPPORT_UCE 0x4
+#define SAL_MDT_SUPPORT_WC 0x8
+
+//
+// Virtual address registration
+//
+#define SAL_MDT_NO_VA 0x00
+#define SAL_MDT_NEED_VA 0x01
+//
+// MemoryType info
+//
+#define SAL_REGULAR_MEMORY 0x0000
+#define SAL_MMIO_MAPPING 0x0001
+#define SAL_SAPIC_IPI_BLOCK 0x0002
+#define SAL_IO_PORT_MAPPING 0x0003
+#define SAL_FIRMWARE_MEMORY 0x0004
+#define SAL_BLACK_HOLE 0x000A
+//
+// Memory Usage info
+//
+#define SAL_MDT_USAGE_UNSPECIFIED 0x00
+#define SAL_PAL_CODE 0x01
+#define SAL_BOOTSERVICE_CODE 0x02
+#define SAL_BOOTSERVICE_DATA 0x03
+#define SAL_RUNTIMESERVICE_CODE 0x04
+#define SAL_RUNTIMESERVICE_DATA 0x05
+#define SAL_IA32_OPTIONROM 0x06
+#define SAL_IA32_SYSTEMROM 0x07
+#define SAL_PMI_CODE 0x0a
+#define SAL_PMI_DATA 0x0b
+
+#pragma pack(1)
+typedef struct {
+ UINT8 Type; // Type == 2
+ UINT8 PlatformFeatures;
+ UINT8 Reserved[14];
+} SAL_ST_PLATFORM_FEATURES;
+#pragma pack()
+
+#define SAL_PLAT_FEAT_BUS_LOCK 0x01
+#define SAL_PLAT_FEAT_PLAT_IPI_HINT 0x02
+#define SAL_PLAT_FEAT_PROC_IPI_HINT 0x04
+
+#pragma pack(1)
+typedef struct {
+ UINT8 Type; // Type == 3
+ UINT8 TRType;
+ UINT8 TRNumber;
+ UINT8 Reserved[5];
+ UINT64 VirtualAddress;
+ UINT64 EncodedPageSize;
+ UINT64 Reserved1;
+} SAL_ST_TR_DECRIPTOR;
+#pragma pack()
+
+#define EFI_SAL_ST_TR_USAGE_INSTRUCTION 00
+#define EFI_SAL_ST_TR_USAGE_DATA 01
+
+#pragma pack(1)
+typedef struct {
+ UINT64 NumberOfProcessors;
+ UINT64 LocalIDRegister;
+} SAL_COHERENCE_DOMAIN_INFO;
+#pragma pack()
+
+#pragma pack(1)
+typedef struct {
+ UINT8 Type; // Type == 4
+ UINT8 Reserved[3];
+ UINT32 NumberOfDomains;
+ SAL_COHERENCE_DOMAIN_INFO *DomainInformation;
+} SAL_ST_CACHE_COHERENCE_DECRIPTOR;
+#pragma pack()
+
+#pragma pack(1)
+typedef struct {
+ UINT8 Type; // Type == 5
+ UINT8 WakeUpType;
+ UINT8 Reserved[6];
+ UINT64 ExternalInterruptVector;
+} SAL_ST_AP_WAKEUP_DECRIPTOR;
+#pragma pack()
+//
+// FIT Entry
+//
+#define EFI_SAL_FIT_ENTRY_PTR (0x100000000 - 32) // 4GB - 24
+#define EFI_SAL_FIT_PALA_ENTRY (0x100000000 - 48) // 4GB - 32
+#define EFI_SAL_FIT_PALB_TYPE 01
+
+typedef struct {
+ UINT64 Address;
+ UINT8 Size[3];
+ UINT8 Reserved;
+ UINT16 Revision;
+ UINT8 Type : 7;
+ UINT8 CheckSumValid : 1;
+ UINT8 CheckSum;
+} EFI_SAL_FIT_ENTRY;
+
+//
+// SAL Common Record Header
+//
+typedef struct {
+ UINT16 Length;
+ UINT8 Data[1024];
+} SAL_OEM_DATA;
+
+typedef struct {
+ UINT8 Seconds;
+ UINT8 Minutes;
+ UINT8 Hours;
+ UINT8 Reserved;
+ UINT8 Day;
+ UINT8 Month;
+ UINT8 Year;
+ UINT8 Century;
+} SAL_TIME_STAMP;
+
+typedef struct {
+ UINT64 RecordId;
+ UINT16 Revision;
+ UINT8 ErrorSeverity;
+ UINT8 ValidationBits;
+ UINT32 RecordLength;
+ SAL_TIME_STAMP TimeStamp;
+ UINT8 OemPlatformId[16];
+} SAL_RECORD_HEADER;
+
+typedef struct {
+ EFI_GUID Guid;
+ UINT16 Revision;
+ UINT8 ErrorRecoveryInfo;
+ UINT8 Reserved;
+ UINT32 SectionLength;
+} SAL_SEC_HEADER;
+
+//
+// SAL Processor Record
+//
+#define SAL_PROCESSOR_ERROR_RECORD_INFO \
+ { \
+ 0xe429faf1, 0x3cb7, 0x11d4, 0xbc, 0xa7, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 \
+ }
+
+#define CHECK_INFO_VALID_BIT_MASK 0x1
+#define REQUESTOR_ID_VALID_BIT_MASK 0x2
+#define RESPONDER_ID_VALID_BIT_MASK 0x4
+#define TARGER_ID_VALID_BIT_MASK 0x8
+#define PRECISE_IP_VALID_BIT_MASK 0x10
+
+typedef struct {
+ UINT64 InfoValid : 1;
+ UINT64 ReqValid : 1;
+ UINT64 RespValid : 1;
+ UINT64 TargetValid : 1;
+ UINT64 IpValid : 1;
+ UINT64 Reserved : 59;
+ UINT64 Info;
+ UINT64 Req;
+ UINT64 Resp;
+ UINT64 Target;
+ UINT64 Ip;
+} MOD_ERROR_INFO;
+
+typedef struct {
+ UINT8 CpuidInfo[40];
+ UINT8 Reserved;
+} CPUID_INFO;
+
+typedef struct {
+ UINT64 FrLow;
+ UINT64 FrHigh;
+} FR_STRUCT;
+
+#define MIN_STATE_VALID_BIT_MASK 0x1
+#define BR_VALID_BIT_MASK 0x2
+#define CR_VALID_BIT_MASK 0x4
+#define AR_VALID_BIT_MASK 0x8
+#define RR_VALID_BIT_MASK 0x10
+#define FR_VALID_BIT_MASK 0x20
+
+typedef struct {
+ UINT64 ValidFieldBits;
+ UINT8 MinStateInfo[1024];
+ UINT64 Br[8];
+ UINT64 Cr[128];
+ UINT64 Ar[128];
+ UINT64 Rr[8];
+ FR_STRUCT Fr[128];
+} PSI_STATIC_STRUCT;
+
+#define PROC_ERROR_MAP_VALID_BIT_MASK 0x1
+#define PROC_STATE_PARAMETER_VALID_BIT_MASK 0x2
+#define PROC_CR_LID_VALID_BIT_MASK 0x4
+#define PROC_STATIC_STRUCT_VALID_BIT_MASK 0x8
+#define CPU_INFO_VALID_BIT_MASK 0x1000000
+
+typedef struct {
+ SAL_SEC_HEADER SectionHeader;
+ UINT64 ValidationBits;
+ UINT64 ProcErrorMap;
+ UINT64 ProcStateParameter;
+ UINT64 ProcCrLid;
+ MOD_ERROR_INFO CacheError[15];
+ MOD_ERROR_INFO TlbError[15];
+ MOD_ERROR_INFO BusError[15];
+ MOD_ERROR_INFO RegFileCheck[15];
+ MOD_ERROR_INFO MsCheck[15];
+ CPUID_INFO CpuInfo;
+ PSI_STATIC_STRUCT PsiValidData;
+} SAL_PROCESSOR_ERROR_RECORD;
+
+//
+// Sal Platform memory Error Record
+//
+#define SAL_MEMORY_ERROR_RECORD_INFO \
+ { \
+ 0xe429faf2, 0x3cb7, 0x11d4, 0xbc, 0xa7, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 \
+ }
+
+#define MEMORY_ERROR_STATUS_VALID_BIT_MASK 0x1
+#define MEMORY_PHYSICAL_ADDRESS_VALID_BIT_MASK 0x2
+#define MEMORY_ADDR_BIT_MASK 0x4
+#define MEMORY_NODE_VALID_BIT_MASK 0x8
+#define MEMORY_CARD_VALID_BIT_MASK 0x10
+#define MEMORY_MODULE_VALID_BIT_MASK 0x20
+#define MEMORY_BANK_VALID_BIT_MASK 0x40
+#define MEMORY_DEVICE_VALID_BIT_MASK 0x80
+#define MEMORY_ROW_VALID_BIT_MASK 0x100
+#define MEMORY_COLUMN_VALID_BIT_MASK 0x200
+#define MEMORY_BIT_POSITION_VALID_BIT_MASK 0x400
+#define MEMORY_PLATFORM_REQUESTOR_ID_VALID_BIT_MASK 0x800
+#define MEMORY_PLATFORM_RESPONDER_ID_VALID_BIT_MASK 0x1000
+#define MEMORY_PLATFORM_TARGET_VALID_BIT_MASK 0x2000
+#define MEMORY_PLATFORM_BUS_SPECIFIC_DATA_VALID_BIT_MASK 0x4000
+#define MEMORY_PLATFORM_OEM_ID_VALID_BIT_MASK 0x8000
+#define MEMORY_PLATFORM_OEM_DATA_STRUCT_VALID_BIT_MASK 0x10000
+
+typedef struct {
+ SAL_SEC_HEADER SectionHeader;
+ UINT64 ValidationBits;
+ UINT64 MemErrorStatus;
+ UINT64 MemPhysicalAddress;
+ UINT64 MemPhysicalAddressMask;
+ UINT16 MemNode;
+ UINT16 MemCard;
+ UINT16 MemModule;
+ UINT16 MemBank;
+ UINT16 MemDevice;
+ UINT16 MemRow;
+ UINT16 MemColumn;
+ UINT16 MemBitPosition;
+ UINT64 ModRequestorId;
+ UINT64 ModResponderId;
+ UINT64 ModTargetId;
+ UINT64 BusSpecificData;
+ UINT8 MemPlatformOemId[16];
+} SAL_MEMORY_ERROR_RECORD;
+
+//
+// PCI BUS Errors
+//
+#define SAL_PCI_BUS_ERROR_RECORD_INFO \
+ { \
+ 0xe429faf4, 0x3cb7, 0x11d4, 0xbc, 0xa7, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 \
+ }
+
+#define PCI_BUS_ERROR_STATUS_VALID_BIT_MASK 0x1
+#define PCI_BUS_ERROR_TYPE_VALID_BIT_MASK 0x2
+#define PCI_BUS_ID_VALID_BIT_MASK 0x4
+#define PCI_BUS_ADDRESS_VALID_BIT_MASK 0x8
+#define PCI_BUS_DATA_VALID_BIT_MASK 0x10
+#define PCI_BUS_CMD_VALID_BIT_MASK 0x20
+#define PCI_BUS_REQUESTOR_ID_VALID_BIT_MASK 0x40
+#define PCI_BUS_RESPONDER_ID_VALID_BIT_MASK 0x80
+#define PCI_BUS_TARGET_VALID_BIT_MASK 0x100
+#define PCI_BUS_OEM_ID_VALID_BIT_MASK 0x200
+#define PCI_BUS_OEM_DATA_STRUCT_VALID_BIT_MASK 0x400
+
+typedef enum {
+ Unknown,
+ DataParityError,
+ SystemError,
+ MasterAbort,
+ BusTimeout,
+ MasterDataParityError,
+ AddressParityError,
+ CommandParityError
+} PCI_BUS_ERROR_TYPE;
+
+typedef struct {
+ UINT8 BusNumber;
+ UINT8 SegmentNumber;
+} PCI_BUS_ID;
+
+typedef struct {
+ SAL_SEC_HEADER SectionHeader;
+ UINT64 ValidationBits;
+ UINT64 PciBusErrorStatus;
+ UINT16 PciBusErrorType;
+ PCI_BUS_ID PciBusId;
+ UINT32 Reserved;
+ UINT64 PciBusAddress;
+ UINT64 PciBusData;
+ UINT64 PciBusCommand;
+ UINT64 PciBusRequestorId;
+ UINT64 PciBusResponderId;
+ UINT64 PciBusTargetId;
+ UINT8 PciBusOemId[16];
+} SAL_PCI_BUS_ERROR_RECORD;
+
+//
+// PCI Component Errors
+//
+#define SAL_PCI_COMP_ERROR_RECORD_INFO \
+ { \
+ 0xe429faf6, 0x3cb7, 0x11d4, 0xbc, 0xa7, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 \
+ }
+
+#define PCI_COMP_ERROR_STATUS_VALID_BIT_MASK 0x1
+#define PCI_COMP_INFO_VALID_BIT_MASK 0x2
+#define PCI_COMP_MEM_NUM_VALID_BIT_MASK 0x4
+#define PCI_COMP_IO_NUM_VALID_BIT_MASK 0x8
+#define PCI_COMP_REG_DATA_PAIR_VALID_BIT_MASK 0x10
+#define PCI_COMP_OEM_DATA_STRUCT_VALID_BIT_MASK 0x20
+
+typedef struct {
+ UINT16 VendorId;
+ UINT16 DeviceId;
+ UINT8 ClassCode[3];
+ UINT8 FunctionNumber;
+ UINT8 DeviceNumber;
+ UINT8 BusNumber;
+ UINT8 SegmentNumber;
+ UINT8 Reserved[5];
+} PCI_COMP_INFO;
+
+typedef struct {
+ SAL_SEC_HEADER SectionHeader;
+ UINT64 ValidationBits;
+ UINT64 PciComponentErrorStatus;
+ PCI_COMP_INFO PciComponentInfo;
+ UINT32 PciComponentMemNum;
+ UINT32 PciComponentIoNum;
+ UINT8 PciBusOemId[16];
+} SAL_PCI_COMPONENT_ERROR_RECORD;
+
+//
+// Sal Device Errors Info.
+//
+#define SAL_DEVICE_ERROR_RECORD_INFO \
+ { \
+ 0xe429faf3, 0x3cb7, 0x11d4, 0xbc, 0xa7, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 \
+ }
+
+#define SEL_RECORD_ID_VALID_BIT_MASK 0x1;
+#define SEL_RECORD_TYPE_VALID_BIT_MASK 0x2;
+#define SEL_GENERATOR_ID_VALID_BIT_MASK 0x4;
+#define SEL_EVM_REV_VALID_BIT_MASK 0x8;
+#define SEL_SENSOR_TYPE_VALID_BIT_MASK 0x10;
+#define SEL_SENSOR_NUM_VALID_BIT_MASK 0x20;
+#define SEL_EVENT_DIR_TYPE_VALID_BIT_MASK 0x40;
+#define SEL_EVENT_DATA1_VALID_BIT_MASK 0x80;
+#define SEL_EVENT_DATA2_VALID_BIT_MASK 0x100;
+#define SEL_EVENT_DATA3_VALID_BIT_MASK 0x200;
+
+typedef struct {
+ SAL_SEC_HEADER SectionHeader;
+ UINT64 ValidationBits;
+ UINT16 SelRecordId;
+ UINT8 SelRecordType;
+ UINT32 TimeStamp;
+ UINT16 GeneratorId;
+ UINT8 EvmRevision;
+ UINT8 SensorType;
+ UINT8 SensorNum;
+ UINT8 EventDirType;
+ UINT8 Data1;
+ UINT8 Data2;
+ UINT8 Data3;
+} SAL_DEVICE_ERROR_RECORD;
+
+//
+// Sal SMBIOS Device Errors Info.
+//
+#define SAL_SMBIOS_ERROR_RECORD_INFO \
+ { \
+ 0xe429faf5, 0x3cb7, 0x11d4, 0xbc, 0xa7, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 \
+ }
+
+#define SMBIOS_EVENT_TYPE_VALID_BIT_MASK 0x1
+#define SMBIOS_LENGTH_VALID_BIT_MASK 0x2
+#define SMBIOS_TIME_STAMP_VALID_BIT_MASK 0x4
+#define SMBIOS_DATA_VALID_BIT_MASK 0x8
+
+typedef struct {
+ SAL_SEC_HEADER SectionHeader;
+ UINT64 ValidationBits;
+ UINT8 SmbiosEventType;
+ UINT8 SmbiosLength;
+ UINT8 SmbiosBcdTimeStamp[6];
+} SAL_SMBIOS_DEVICE_ERROR_RECORD;
+
+//
+// Sal Platform Specific Errors Info.
+//
+#define SAL_PLATFORM_ERROR_RECORD_INFO \
+ { \
+ 0xe429faf7, 0x3cb7, 0x11d4, 0xbc, 0xa7, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 \
+ }
+
+#define PLATFORM_ERROR_STATUS_VALID_BIT_MASK 0x1
+#define PLATFORM_REQUESTOR_ID_VALID_BIT_MASK 0x2
+#define PLATFORM_RESPONDER_ID_VALID_BIT_MASK 0x4
+#define PLATFORM_TARGET_VALID_BIT_MASK 0x8
+#define PLATFORM_SPECIFIC_DATA_VALID_BIT_MASK 0x10
+#define PLATFORM_OEM_ID_VALID_BIT_MASK 0x20
+#define PLATFORM_OEM_DATA_STRUCT_VALID_BIT_MASK 0x40
+#define PLATFORM_OEM_DEVICE_PATH_VALID_BIT_MASK 0x80
+
+typedef struct {
+ SAL_SEC_HEADER SectionHeader;
+ UINT64 ValidationBits;
+ UINT64 PlatformErrorStatus;
+ UINT64 PlatformRequestorId;
+ UINT64 PlatformResponderId;
+ UINT64 PlatformTargetId;
+ UINT64 PlatformBusSpecificData;
+ UINT8 OemComponentId[16];
+} SAL_PLATFORM_SPECIFIC_ERROR_RECORD;
+
+//
+// Union of all the possible Sal Record Types
+//
+typedef union {
+ SAL_RECORD_HEADER *RecordHeader;
+ SAL_PROCESSOR_ERROR_RECORD *SalProcessorRecord;
+ SAL_PCI_BUS_ERROR_RECORD *SalPciBusRecord;
+ SAL_PCI_COMPONENT_ERROR_RECORD *SalPciComponentRecord;
+ SAL_DEVICE_ERROR_RECORD *ImpiRecord;
+ SAL_SMBIOS_DEVICE_ERROR_RECORD *SmbiosRecord;
+ SAL_PLATFORM_SPECIFIC_ERROR_RECORD *PlatformRecord;
+ SAL_MEMORY_ERROR_RECORD *MemoryRecord;
+ UINT8 *Raw;
+} SAL_ERROR_RECORDS_POINTERS;
+
+#pragma pack()
+
+#endif
diff --git a/EDK/Foundation/Include/Ipf/TianoBind.h b/EDK/Foundation/Include/Ipf/TianoBind.h
new file mode 100644
index 0000000..c673ce4
--- /dev/null
+++ b/EDK/Foundation/Include/Ipf/TianoBind.h
@@ -0,0 +1,30 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ TianoBind.h
+
+Abstract:
+
+ Tiano's Processor or Compiler specific defines and types for Intel?Itanium(TM)
+ besides EfiBind.h.
+
+--*/
+
+#ifndef _TIANO_BIND_H_
+#define _TIANO_BIND_H_
+
+#include "EfiBind.h"
+
+#define EFI_DXE_ENTRY_POINT(InitFunction)
+
+#endif
diff --git a/EDK/Foundation/Include/Pei/Pei.h b/EDK/Foundation/Include/Pei/Pei.h
new file mode 100644
index 0000000..f40668d
--- /dev/null
+++ b/EDK/Foundation/Include/Pei/Pei.h
@@ -0,0 +1,58 @@
+/*++
+
+Copyright (c) 2004 - 2005, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Pei.h
+
+Abstract:
+
+ Framework PEI master include file.
+
+ This is the main include file for Framework PEI components. There should be
+ no defines or macros added to this file, other than the EFI version
+ information already in this file.
+
+ Don't add include files to the list for convenience, only add things
+ that are architectural. Don't add Protocols or GUID include files here
+
+--*/
+
+#ifndef _PEI_H_
+#define _PEI_H_
+
+//
+// PEI Specification Revision information
+//
+#include "TianoCommon.h"
+
+#include "PeiBind.h"
+#include "PeiApi.h"
+#include "EfiDebug.h"
+#include "PeiDebug.h"
+
+//
+// Enable code sharing with DXE by removing ASSERT and DEBUG
+//
+// #define ASSERT(a)
+// #define DEBUG (a)
+//
+
+#ifdef EFI_PEI_REPORT_STATUS_CODE_ON
+#define PEI_REPORT_STATUS_CODE_CODE(Code) Code
+#define PEI_REPORT_STATUS_CODE(PeiServices, CodeType, Value, Instance, CallerId, Data) \
+ (*PeiServices)->PeiReportStatusCode (PeiServices, CodeType, Value, Instance, CallerId, Data)
+#else
+#define PEI_REPORT_STATUS_CODE_CODE(Code)
+#define PEI_REPORT_STATUS_CODE(PeiServices, CodeType, Value, Instance, CallerId, Data)
+#endif
+
+#endif
diff --git a/EDK/Foundation/Include/Pei/PeiBind.h b/EDK/Foundation/Include/Pei/PeiBind.h
new file mode 100644
index 0000000..5452865
--- /dev/null
+++ b/EDK/Foundation/Include/Pei/PeiBind.h
@@ -0,0 +1,162 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PeiBind.h
+
+Abstract:
+
+ Tiano PEI core and PEIM binding macros
+
+--*/
+
+#ifndef _PEI_BIND_H_
+#define _PEI_BIND_H_
+
+#ifdef EFI_DEBUG
+
+#ifdef EFI_NT_EMULATOR
+
+//;;## ...AMI_OVERRIDE... Support PI1.x
+#if (PI_SPECIFICATION_VERSION < 0x00010000)
+
+#define EFI_PEI_CORE_ENTRY_POINT(InitFunction) \
+ UINTN \
+ __stdcall \
+ _DllMainCRTStartup ( \
+ UINTN Inst, \
+ UINTN reason_for_call, \
+ VOID *rserved \
+ ) \
+ { \
+ return 1; \
+ } \
+ \
+ EFI_STATUS \
+ __declspec( dllexport ) \
+ __cdecl \
+ InitializeDriver ( \
+ IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartup \
+ ) \
+ { \
+ return InitFunction(PeiStartup); \
+ }
+
+#else
+#define EFI_PEI_CORE_ENTRY_POINT(InitFunction) \
+ UINTN \
+ __stdcall \
+ _DllMainCRTStartup ( \
+ UINTN Inst, \
+ UINTN reason_for_call, \
+ VOID *rserved \
+ ) \
+ { \
+ return 1; \
+ } \
+ \
+ EFI_STATUS \
+ __declspec( dllexport ) \
+ __cdecl \
+ InitializeDriver ( \
+ IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData, \
+ IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList \
+ ) \
+ { \
+ return InitFunction(SecCoreData, PpiList); \
+ }
+
+#endif
+
+#define EFI_PEIM_ENTRY_POINT(InitFunction) \
+ UINTN \
+ __stdcall \
+ _DllMainCRTStartup ( \
+ UINTN Inst, \
+ UINTN reason_for_call, \
+ VOID *rserved \
+ ) \
+ { \
+ return 1; \
+ } \
+ \
+ EFI_STATUS \
+ __declspec( dllexport ) \
+ __cdecl \
+ InitializeDriver ( \
+ IN EFI_FFS_FILE_HEADER *FfsHeader, \
+ IN EFI_PEI_SERVICES **PeiServices \
+ ) \
+ { \
+ return InitFunction(FfsHeader, PeiServices); \
+ }
+
+#else
+
+#define EFI_PEI_CORE_ENTRY_POINT(InitFunction)
+#define EFI_PEIM_ENTRY_POINT(InitFunction)
+
+#endif
+
+#else
+
+#ifdef EFI_NT_EMULATOR
+
+//;;## ...AMI_OVERRIDE... Support PI1.x
+#if (PI_SPECIFICATION_VERSION < 0x00010000)
+
+#define EFI_PEI_CORE_ENTRY_POINT(InitFunction) \
+ EFI_STATUS \
+ __declspec( dllexport ) \
+ __cdecl \
+ InitializeDriver ( \
+ IN EFI_PEI_STARTUP_DESCRIPTOR *PeiStartup \
+ ) \
+ { \
+ return InitFunction(PeiStartup); \
+ }
+
+#else
+#define EFI_PEI_CORE_ENTRY_POINT(InitFunction) \
+ EFI_STATUS \
+ __declspec( dllexport ) \
+ __cdecl \
+ InitializeDriver ( \
+ IN CONST EFI_SEC_PEI_HAND_OFF *SecCoreData, \
+ IN CONST EFI_PEI_PPI_DESCRIPTOR *PpiList \
+ ) \
+ { \
+ return InitFunction(SecCoreData, PpiList); \
+ }
+
+#endif
+
+
+#define EFI_PEIM_ENTRY_POINT(InitFunction) \
+ EFI_STATUS \
+ __declspec( dllexport ) \
+ __cdecl \
+ InitializeDriver ( \
+ IN EFI_FFS_FILE_HEADER *FfsHeader, \
+ IN EFI_PEI_SERVICES **PeiServices \
+ ) \
+ { \
+ return InitFunction(FfsHeader, PeiServices); \
+ }
+#else
+
+#define EFI_PEI_CORE_ENTRY_POINT(InitFunction)
+#define EFI_PEIM_ENTRY_POINT(InitFunction)
+
+#endif
+#endif
+#endif
diff --git a/EDK/Foundation/Include/Pei/PeiDebug.h b/EDK/Foundation/Include/Pei/PeiDebug.h
new file mode 100644
index 0000000..dad6a6c
--- /dev/null
+++ b/EDK/Foundation/Include/Pei/PeiDebug.h
@@ -0,0 +1,111 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PeiDebug.h
+
+Abstract:
+
+ PEI Debug macros. The work needs to be done in library. The Debug
+ macros them selves are standard for all files, including the core.
+
+ There needs to be code linked in that produces the following macros:
+
+ PeiDebugAssert(file, linenumber, assertion string) - worker function for
+ ASSERT. filename and line number of where this ASSERT() is located
+ is passed in along with the stringized version of the assertion.
+
+ PeiDebugPrint - Worker function for debug print
+
+ _DEBUG_SET_MEM(address, length, value) - Set memory at address to value
+ for legnth bytes. This macro is used to initialzed uninitialized memory
+ or memory that is free'ed, so it will not be used by mistake.
+
+--*/
+
+#ifndef _PEIDEBUG_H_
+#define _PEIDEBUG_H_
+
+#ifdef EFI_DEBUG
+
+ VOID
+ PeiDebugAssert (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN CHAR8 *FileName,
+ IN INTN LineNumber,
+ IN CHAR8 *Description
+ );
+
+ VOID
+ PeiDebugPrint (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN UINTN ErrorLevel,
+ IN CHAR8 *Format,
+ ...
+ );
+
+ #define _PEI_DEBUG_ASSERT(PeiST, assertion) \
+ PeiDebugAssert (PeiST, __FILE__, __LINE__, #assertion)
+
+ #define _PEI_DEBUG(PeiST, arg) PeiDebugPrint (PeiST, arg)
+
+ //
+ // Define ASSERT() macro, if assertion is FALSE trigger the ASSERT
+ //
+ #define PEI_ASSERT(PeiST, assertion) if(!(assertion)) \
+ _PEI_DEBUG_ASSERT(PeiST, assertion)
+
+ #define PEI_ASSERT_LOCKED(PeiST, l) if(!(l)->Lock) _PEI_DEBUG_ASSERT(PeiST, l not locked)
+
+ //
+ // DEBUG((DebugLevel, "format string", ...)) - if DebugLevel is active do
+ // the a debug print.
+ //
+
+ #define PEI_DEBUG(arg) PeiDebugPrint arg
+
+ #define PEI_DEBUG_CODE(code) code
+
+ #define PEI_CR(Record, TYPE, Field, Signature) \
+ _CR(Record, TYPE, Field)
+
+
+ #define _PEI_DEBUG_SET_MEM(address, length, data) SetMem(address, length, data)
+
+#else
+ #define PEI_ASSERT(PeiST, a)
+ #define PEI_ASSERT_LOCKED(PeiST, l)
+ #define PEI_DEBUG(arg)
+ #define PEI_DEBUG_CODE(code)
+ #define PEI_CR(Record, TYPE, Field, Signature) \
+ _CR(Record, TYPE, Field)
+ #define _PEI_DEBUG_SET_MEM(address, length, data)
+#endif
+
+#define ASSERT_PEI_ERROR(PeiServices, Status) \
+ PEI_DEBUG_CODE ( \
+ if (EFI_ERROR (Status)) { \
+ PEI_DEBUG ((PeiServices, EFI_D_ERROR, "\nASSERT_PEI_ERROR, Status = %r (0x%08X)\n", \
+ Status, Status)); \
+ PEI_ASSERT (PeiServices, !EFI_ERROR (Status)); \
+ } \
+ )
+
+#ifdef EFI_DEBUG_CLEAR_MEMORY
+ #define PEI_DEBUG_SET_MEMORY(address,length) \
+ _PEI_DEBUG_SET_MEM(address, length, EFI_BAD_POINTER_AS_BYTE)
+#else
+ #define PEI_DEBUG_SET_MEMORY(address,length)
+#endif
+
+
+#endif
diff --git a/EDK/Foundation/Include/Tiano.h b/EDK/Foundation/Include/Tiano.h
new file mode 100644
index 0000000..89fdcfd
--- /dev/null
+++ b/EDK/Foundation/Include/Tiano.h
@@ -0,0 +1,56 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Tiano.h
+
+Abstract:
+
+ Tiano master include file.
+
+ This is the main include file for Tiano components.
+
+ Don't add include files to the list for convenience, only add things
+ that are architectural. Don't add Protocols or GUID include files here
+
+--*/
+
+#ifndef _TIANO_H_
+#define _TIANO_H_
+
+//
+// Check to make sure EFI_SPECIFICATION_VERSION and TIANO_RELEASE_VERSION are defined.
+//
+#if !defined(EFI_SPECIFICATION_VERSION)
+ #error EFI_SPECIFICATION_VERSION not defined
+#elif !defined(TIANO_RELEASE_VERSION)
+ #error TIANO_RELEASE_VERSION not defined
+#elif (TIANO_RELEASE_VERSION == 0)
+ #error TIANO_RELEASE_VERSION can not be zero
+#elif (EFI_SPECIFICATION_VERSION <= 0x00020000)
+ #define TIANO_EXTENSION_FLAG
+#endif
+
+#include "TianoCommon.h"
+#include "TianoApi.h"
+#include "EfiDebug.h"
+#include "TianoDevicePath.h"
+#include "EfiSpec.h"
+
+//
+// EFI Revision information
+//
+#define EFI_FIRMWARE_MAJOR_REVISION 0x1000
+#define EFI_FIRMWARE_MINOR_REVISION 1
+#define EFI_FIRMWARE_REVISION ((EFI_FIRMWARE_MAJOR_REVISION << 16) | (EFI_FIRMWARE_MINOR_REVISION))
+
+#endif
diff --git a/EDK/Foundation/Include/TianoApi.h b/EDK/Foundation/Include/TianoApi.h
new file mode 100644
index 0000000..2fa8bb4
--- /dev/null
+++ b/EDK/Foundation/Include/TianoApi.h
@@ -0,0 +1,46 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ TianoApi.h
+
+Abstract:
+
+ Tiano intrinsic definitions.
+
+
+--*/
+
+#ifndef _TIANO_API_H_
+#define _TIANO_API_H_
+
+#include "EfiApi.h"
+#include "TianoSpecApi.h"
+
+//
+// Pointer to internal runtime function
+//
+#define EFI_INTERNAL_FUNCTION 0x00000002
+
+//
+// Pointer to internal runtime pointer
+//
+#define EFI_INTERNAL_POINTER 0x00000004
+
+//
+// Pointer to internal runtime pointer
+//
+#define EFI_IPF_GP_POINTER 0x00000008
+
+#define EFI_TPL_DRIVER 6
+
+#endif
diff --git a/EDK/Foundation/Include/TianoCommon.h b/EDK/Foundation/Include/TianoCommon.h
new file mode 100644
index 0000000..b588ee3
--- /dev/null
+++ b/EDK/Foundation/Include/TianoCommon.h
@@ -0,0 +1,51 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ TianoCommon.h
+
+Abstract:
+
+ Tiano specific common definitions besides EfiCommon.h
+
+--*/
+
+#ifndef _TIANO_COMMON_H_
+#define _TIANO_COMMON_H_
+
+#include "TianoBind.h"
+#include "TianoTypes.h"
+#include "EfiStdArg.h"
+#include "TianoError.h"
+#include "EfiStatusCode.h"
+#include "EfiCommon.h"
+
+//
+// Define macros for including Architectural Protocols and PPIs
+//
+#define EFI_ARCH_PROTOCOL_DEFINITION(a) EFI_STRINGIZE (ArchProtocol/a/a.h)
+#define EFI_PPI_DEFINITION(a) EFI_STRINGIZE (Ppi/a/a.h)
+
+//
+// These should be used to include protocols. If they are followed,
+// intelligent build tools can be created to check dependencies at build
+// time.
+//
+#define EFI_ARCH_PROTOCOL_PRODUCER(a) EFI_ARCH_PROTOCOL_DEFINITION (a)
+#define EFI_ARCH_PROTOCOL_CONSUMER(a) EFI_ARCH_PROTOCOL_DEFINITION (a)
+#define EFI_ARCH_PROTOCOL_DEPENDENCY(a) EFI_ARCH_PROTOCOL_DEFINITION (a)
+
+#define EFI_PPI_PRODUCER(a) EFI_PPI_DEFINITION (a)
+#define EFI_PPI_CONSUMER(a) EFI_PPI_DEFINITION (a)
+#define EFI_PPI_DEPENDENCY(a) EFI_PPI_DEFINITION (a)
+
+#endif
diff --git a/EDK/Foundation/Include/TianoDevicePath.h b/EDK/Foundation/Include/TianoDevicePath.h
new file mode 100644
index 0000000..6679ed7
--- /dev/null
+++ b/EDK/Foundation/Include/TianoDevicePath.h
@@ -0,0 +1,130 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ TianoDevicePath.h
+
+Abstract:
+
+ Tiano Device Path definitions
+
+--*/
+
+#ifndef _TIANO_DEVICE_PATH_H
+#define _TIANO_DEVICE_PATH_H
+
+#include "EfiDevicePath.h"
+#include "TianoSpecDevicePath.h"
+
+#pragma pack(1)
+
+typedef struct _USB_PORT_DEVICE_PATH {
+ ACPI_HID_DEVICE_PATH PciRootBridgeDevicePath;
+ PCI_DEVICE_PATH PciBusDevicePath;
+ EFI_DEVICE_PATH_PROTOCOL EndDevicePath;
+} USB_PORT_DEVICE_PATH;
+
+//
+// IDE
+//
+typedef struct _IDE_DEVICE_PATH {
+ ACPI_HID_DEVICE_PATH PciRootBridgeDevicePath;
+ PCI_DEVICE_PATH PciBusDevicePath;
+ EFI_DEVICE_PATH_PROTOCOL EndDevicePath;
+} IDE_DEVICE_PATH;
+
+//
+// RMC Connector
+//
+typedef struct _RMC_CONN_DEVICE_PATH {
+ ACPI_HID_DEVICE_PATH PciRootBridgeDevicePath;
+ PCI_DEVICE_PATH PciBridgeDevicePath;
+ PCI_DEVICE_PATH PciBusDevicePath;
+ EFI_DEVICE_PATH_PROTOCOL EndDevicePath;
+} RMC_CONN_DEVICE_PATH;
+
+//
+// RIDE
+//
+typedef struct _RIDE_DEVICE_PATH {
+ ACPI_HID_DEVICE_PATH PciRootBridgeDevicePath;
+ PCI_DEVICE_PATH PciBridgeDevicePath;
+ PCI_DEVICE_PATH PciBusDevicePath;
+ EFI_DEVICE_PATH_PROTOCOL EndDevicePath;
+} RIDE_DEVICE_PATH;
+
+//
+// Gigabit NIC
+//
+typedef struct _GB_NIC_DEVICE_PATH {
+ ACPI_HID_DEVICE_PATH PciRootBridgeDevicePath;
+ PCI_DEVICE_PATH PciBridgeDevicePath;
+ PCI_DEVICE_PATH PciXBridgeDevicePath;
+ PCI_DEVICE_PATH PciXBusDevicePath;
+ EFI_DEVICE_PATH_PROTOCOL EndDevicePath;
+} GB_NIC_DEVICE_PATH;
+
+//
+// P/S2 Connector
+//
+typedef struct _PS2_CONN_DEVICE_PATH {
+ ACPI_HID_DEVICE_PATH PciRootBridgeDevicePath;
+ PCI_DEVICE_PATH LpcBridgeDevicePath;
+ ACPI_HID_DEVICE_PATH LpcBusDevicePath;
+ EFI_DEVICE_PATH_PROTOCOL EndDevicePath;
+} PS2_CONN_DEVICE_PATH;
+
+//
+// Serial Port Connector
+//
+typedef struct _SERIAL_CONN_DEVICE_PATH {
+ ACPI_HID_DEVICE_PATH PciRootBridgeDevicePath;
+ PCI_DEVICE_PATH LpcBridgeDevicePath;
+ ACPI_HID_DEVICE_PATH LpcBusDevicePath;
+ EFI_DEVICE_PATH_PROTOCOL EndDevicePath;
+} SERIAL_CONN_DEVICE_PATH;
+
+//
+// Parallel Port Connector
+//
+typedef struct _PARALLEL_CONN_DEVICE_PATH {
+ ACPI_HID_DEVICE_PATH PciRootBridgeDevicePath;
+ PCI_DEVICE_PATH LpcBridgeDevicePath;
+ ACPI_HID_DEVICE_PATH LpcBusDevicePath;
+ EFI_DEVICE_PATH_PROTOCOL EndDevicePath;
+} PARALLEL_CONN_DEVICE_PATH;
+
+//
+// Floopy Connector
+//
+typedef struct _FLOOPY_CONN_DEVICE_PATH {
+ ACPI_HID_DEVICE_PATH PciRootBridgeDevicePath;
+ PCI_DEVICE_PATH LpcBridgeDevicePath;
+ ACPI_HID_DEVICE_PATH LpcBusDevicePath;
+ EFI_DEVICE_PATH_PROTOCOL EndDevicePath;
+} FLOOPY_CONN_DEVICE_PATH;
+
+typedef union _EFI_MISC_PORT_DEVICE_PATH {
+ USB_PORT_DEVICE_PATH UsbDevicePath;
+ IDE_DEVICE_PATH IdeDevicePath;
+ RMC_CONN_DEVICE_PATH RmcConnDevicePath;
+ RIDE_DEVICE_PATH RideDevicePath;
+ GB_NIC_DEVICE_PATH GbNicDevicePath;
+ PS2_CONN_DEVICE_PATH Ps2ConnDevicePath;
+ SERIAL_CONN_DEVICE_PATH SerialConnDevicePath;
+ PARALLEL_CONN_DEVICE_PATH ParallelConnDevicePath;
+ FLOOPY_CONN_DEVICE_PATH FloppyConnDevicePath;
+} EFI_MISC_PORT_DEVICE_PATH;
+
+#pragma pack()
+
+#endif
diff --git a/EDK/Foundation/Include/TianoError.h b/EDK/Foundation/Include/TianoError.h
new file mode 100644
index 0000000..ecb6539
--- /dev/null
+++ b/EDK/Foundation/Include/TianoError.h
@@ -0,0 +1,30 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ TianoError.h
+
+Abstract:
+
+ Tiano error levels and their associated defines
+
+--*/
+
+#ifndef _TIANO_ERROR_H_
+#define _TIANO_ERROR_H_
+
+#include "EfiError.h"
+#include "TianoSpecError.h"
+
+#define EFI_WARN_RETURN_FROM_LONG_JUMP EFIWARN (5)
+
+#endif
diff --git a/EDK/Foundation/Include/TianoHii.h b/EDK/Foundation/Include/TianoHii.h
new file mode 100644
index 0000000..e41451f
--- /dev/null
+++ b/EDK/Foundation/Include/TianoHii.h
@@ -0,0 +1,124 @@
+/*++
+
+Copyright (c) 2007 - 2008, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ TianoHii.h
+
+Abstract:
+
+ Tiano specific HII relative definition.
+
+Revision History
+
+--*/
+
+#ifndef _TIANO_HII_H_
+#define _TIANO_HII_H_
+
+#include "EfiHii.h"
+
+#define NARROW_CHAR 0xFFF0
+#define WIDE_CHAR 0xFFF1
+#define NON_BREAKING_CHAR 0xFFF2
+
+#define GLYPH_WIDTH EFI_GLYPH_WIDTH
+#define GLYPH_HEIGHT EFI_GLYPH_HEIGHT
+
+//
+// State defined for password statemachine
+//
+#define BROWSER_STATE_VALIDATE_PASSWORD 0
+#define BROWSER_STATE_SET_PASSWORD 1
+
+//
+// References to string tokens must use this macro to enable scanning for
+// token usages.
+//
+#define STRING_TOKEN(t) t
+
+//
+// GUIDed opcodes defined for Tiano
+//
+#define EFI_IFR_TIANO_GUID \
+ { 0xf0b1735, 0x87a0, 0x4193, 0xb2, 0x66, 0x53, 0x8c, 0x38, 0xaf, 0x48, 0xce }
+
+//
+// ClassGuid for Front Page
+//
+#define EFI_HII_FRONT_PAGE_CLASS_GUID \
+ { 0x94d411b7, 0x7669, 0x45c3, 0xba, 0x3b, 0xf3, 0xa5, 0x8a, 0x71, 0x56, 0x81 }
+
+#pragma pack(1)
+
+#define EFI_IFR_EXTEND_OP_LABEL 0x0
+#define EFI_IFR_EXTEND_OP_BANNER 0x1
+#define EFI_IFR_EXTEND_OP_TIMEOUT 0x2
+#define EFI_IFR_EXTEND_OP_CLASS 0x3
+#define EFI_IFR_EXTEND_OP_SUBCLASS 0x4
+
+typedef struct _EFI_IFR_GUID_LABEL {
+ EFI_IFR_OP_HEADER Header;
+ EFI_GUID Guid;
+ UINT8 ExtendOpCode;
+ UINT16 Number;
+} EFI_IFR_GUID_LABEL;
+
+#define EFI_IFR_BANNER_ALIGN_LEFT 0
+#define EFI_IFR_BANNER_ALIGN_CENTER 1
+#define EFI_IFR_BANNER_ALIGN_RIGHT 2
+
+typedef struct _EFI_IFR_GUID_BANNER {
+ EFI_IFR_OP_HEADER Header;
+ EFI_GUID Guid;
+ UINT8 ExtendOpCode; // Extended opcode is EFI_IFR_EXTEND_OP_BANNER
+ EFI_STRING_ID Title; // The string token for the banner title
+ UINT16 LineNumber; // 1-based line number
+ UINT8 Alignment; // left, center, or right-aligned
+} EFI_IFR_GUID_BANNER;
+
+typedef struct _EFI_IFR_GUID_TIMEOUT {
+ EFI_IFR_OP_HEADER Header;
+ EFI_GUID Guid;
+ UINT8 ExtendOpCode;
+ UINT16 TimeOut;
+} EFI_IFR_GUID_TIMEOUT;
+
+#define EFI_NON_DEVICE_CLASS 0x00
+#define EFI_DISK_DEVICE_CLASS 0x01
+#define EFI_VIDEO_DEVICE_CLASS 0x02
+#define EFI_NETWORK_DEVICE_CLASS 0x04
+#define EFI_INPUT_DEVICE_CLASS 0x08
+#define EFI_ON_BOARD_DEVICE_CLASS 0x10
+#define EFI_OTHER_DEVICE_CLASS 0x20
+
+typedef struct _EFI_IFR_GUID_CLASS {
+ EFI_IFR_OP_HEADER Header;
+ EFI_GUID Guid;
+ UINT8 ExtendOpCode;
+ UINT16 Class;
+} EFI_IFR_GUID_CLASS;
+
+#define EFI_SETUP_APPLICATION_SUBCLASS 0x00
+#define EFI_GENERAL_APPLICATION_SUBCLASS 0x01
+#define EFI_FRONT_PAGE_SUBCLASS 0x02
+#define EFI_SINGLE_USE_SUBCLASS 0x03
+
+typedef struct _EFI_IFR_GUID_SUBCLASS {
+ EFI_IFR_OP_HEADER Header;
+ EFI_GUID Guid;
+ UINT8 ExtendOpCode;
+ UINT16 SubClass;
+} EFI_IFR_GUID_SUBCLASS;
+
+#pragma pack()
+
+#endif
diff --git a/EDK/Foundation/Include/TianoTypes.h b/EDK/Foundation/Include/TianoTypes.h
new file mode 100644
index 0000000..5ec82bc
--- /dev/null
+++ b/EDK/Foundation/Include/TianoTypes.h
@@ -0,0 +1,48 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ TianoTypes.h
+
+Abstract:
+
+ Tiano specific part besides EfiTypes.h
+
+--*/
+
+#ifndef _TIANO_TYPES_H_
+#define _TIANO_TYPES_H_
+
+#include "EfiTypes.h"
+#include "TianoSpecTypes.h"
+
+//
+// attributes for reserved memory before it is promoted to system memory
+//
+#define EFI_MEMORY_PRESENT 0x0100000000000000
+#define EFI_MEMORY_INITIALIZED 0x0200000000000000
+#define EFI_MEMORY_TESTED 0x0400000000000000
+
+//
+// range for memory mapped port I/O on IPF
+//
+#define EFI_MEMORY_PORT_IO 0x4000000000000000
+
+//
+// A pointer to a function in IPF points to a plabel.
+//
+typedef struct {
+ UINT64 EntryPoint;
+ UINT64 GP;
+} EFI_PLABEL;
+
+#endif
diff --git a/EDK/Foundation/Include/x64/EfiBind.h b/EDK/Foundation/Include/x64/EfiBind.h
new file mode 100644
index 0000000..3f8f7b9
--- /dev/null
+++ b/EDK/Foundation/Include/x64/EfiBind.h
@@ -0,0 +1,225 @@
+/*++
+
+Copyright (c) 2005 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiBind.h
+
+Abstract:
+
+ Processor or Compiler specific defines and types for x64.
+ We are using the ANSI C 2000 _t type definitions for basic types.
+ This it technically a violation of the coding standard, but they
+ are used to make EfiTypes.h portable. Code other than EfiTypes.h
+ should never use any ANSI C 2000 _t integer types.
+
+--*/
+
+#ifndef _EFI_BIND_H_
+#define _EFI_BIND_H_
+
+
+#define EFI_DRIVER_ENTRY_POINT(InitFunction)
+#define EFI_APPLICATION_ENTRY_POINT EFI_DRIVER_ENTRY_POINT
+
+
+
+//
+// Make sure we are useing the correct packing rules per EFI specification
+//
+#pragma pack()
+
+#if _MSC_EXTENSIONS
+
+//
+// Disable warning that make it impossible to compile at /W4
+// This only works for Microsoft* tools
+//
+
+//
+// Disabling bitfield type checking warnings.
+//
+#pragma warning ( disable : 4214 )
+
+//
+// Disabling the unreferenced formal parameter warnings.
+//
+#pragma warning ( disable : 4100 )
+
+//
+// Disable slightly different base types warning as CHAR8 * can not be set
+// to a constant string.
+//
+#pragma warning ( disable : 4057 )
+
+//
+// ASSERT(FALSE) or while (TRUE) are legal constructes so supress this warning
+//
+#pragma warning ( disable : 4127 )
+
+//
+// Int64ShllMod32 unreferenced inline function
+//
+#pragma warning ( disable : 4514 )
+
+//
+// Unreferenced formal parameter - We are object oriented, so we pass This even
+// if we don't need them.
+//
+#pragma warning ( disable : 4100 )
+
+//
+// This warning is caused by empty (after preprocessing) souce file.
+//
+#pragma warning ( disable : 4206 )
+
+//
+// Warning: The result of the unary '&' operator may be unaligned. Ignore it.
+//
+#pragma warning ( disable : 4366 )
+
+#endif
+
+
+#if (__STDC_VERSION__ < 199901L)
+ //
+ // No ANSI C 2000 stdint.h integer width declarations, so define equivalents
+ //
+
+ #if _MSC_EXTENSIONS
+
+ //
+ // use Microsoft* C complier dependent interger width types
+ //
+ typedef unsigned __int64 uint64_t;
+ typedef __int64 int64_t;
+ typedef unsigned __int32 uint32_t;
+ typedef __int32 int32_t;
+ typedef unsigned short uint16_t;
+ typedef short int16_t;
+ typedef unsigned char uint8_t;
+ typedef char int8_t;
+ #else
+
+ //
+ // Assume standard IA-32 alignment.
+ // BugBug: Need to check portability of long long
+ //
+ typedef unsigned long long uint64_t;
+ typedef long long int64_t;
+ typedef unsigned int uint32_t;
+ typedef int int32_t;
+ typedef unsigned short uint16_t;
+ typedef short int16_t;
+ typedef unsigned char uint8_t;
+ typedef char int8_t;
+ #endif
+#else
+ //
+ // Use ANSI C 2000 stdint.h integer width declarations
+ //
+ #include "stdint.h"
+#endif
+
+//
+// Native integer size in stdint.h
+//
+typedef uint64_t uintn_t;
+typedef int64_t intn_t;
+
+//
+// Processor specific defines
+//
+#define EFI_MAX_BIT 0x8000000000000000
+#define MAX_2_BITS 0xC000000000000000
+
+//
+// Maximum legal IA-32 address
+//
+#define EFI_MAX_ADDRESS 0xFFFFFFFFFFFFFFFF
+
+//
+// Bad pointer value to use in check builds.
+// if you see this value you are using uninitialized or free'ed data
+//
+#define EFI_BAD_POINTER 0xAFAFAFAFAFAFAFAF
+#define EFI_BAD_POINTER_AS_BYTE 0xAF
+
+//
+// Inject a break point in the code to assist debugging for NT Emulation Environment
+// For real hardware, just put in a halt loop. Don't do a while(1) because the
+// compiler will optimize away the rest of the function following, so that you run out in
+// the weeds if you skip over it with a debugger.
+//
+#define EFI_DEADLOOP() { volatile int __iii; __iii = 1; while (__iii); }
+#define EFI_BREAKPOINT() EFI_DEADLOOP()
+
+//
+// Memory Fence forces serialization, and is needed to support out of order
+// memory transactions. The Memory Fence is mainly used to make sure IO
+// transactions complete in a deterministic sequence, and to syncronize locks
+// an other MP code. Currently no memory fencing is required.
+//
+#define MEMORY_FENCE()
+
+//
+// Some compilers don't support the forward reference construct:
+// typedef struct XXXXX. The forward reference is required for
+// ANSI compatibility.
+//
+// The following macro provide a workaround for such cases.
+//
+
+
+#ifdef EFI_NO_INTERFACE_DECL
+ #define EFI_FORWARD_DECLARATION(x)
+#else
+ #define EFI_FORWARD_DECLARATION(x) typedef struct _##x x
+#endif
+
+
+//
+// Some C compilers optimize the calling conventions to increase performance.
+// _EFIAPI is used to make all public APIs follow the standard C calling
+// convention.
+//
+#if _MSC_EXTENSIONS
+ //
+ // Microsoft* compiler requires _EFIAPI useage, __cdecl is Microsoft* specific C.
+ //
+
+ #define _EFIAPI __cdecl
+#else
+ #define _EFIAPI
+#endif
+
+
+#ifdef _EFI_WINNT
+
+ #define EFI_SUPPRESS_BENIGN_REDEFINITION_OF_TYPE_WARNING() \
+ warning ( disable : 4142 )
+
+ #define EFI_DEFAULT_BENIGN_REDEFINITION_OF_TYPE_WARNING() \
+ warning ( default : 4142 )
+#else
+
+ #define EFI_SUPPRESS_BENIGN_REDEFINITION_OF_TYPE_WARNING() \
+ warning ( disable : 4068 )
+
+ #define EFI_DEFAULT_BENIGN_REDEFINITION_OF_TYPE_WARNING() \
+ warning ( default : 4068 )
+
+#endif
+
+
+
+#endif
+
diff --git a/EDK/Foundation/Include/x64/EfiPeOptionalHeader.h b/EDK/Foundation/Include/x64/EfiPeOptionalHeader.h
new file mode 100644
index 0000000..f12a8b1
--- /dev/null
+++ b/EDK/Foundation/Include/x64/EfiPeOptionalHeader.h
@@ -0,0 +1,42 @@
+/*++
+
+Copyright (c) 2005 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiPeOptionalHeader.h
+
+Abstract:
+ Defines the optional header in the PE image per the PE specification. This
+ file must be included only from within EfiImage.h since
+ EFI_IMAGE_DATA_DIRECTORY and EFI_IMAGE_NUMBER_OF_DIRECTORY_ENTRIES are defined
+ there.
+
+--*/
+
+#ifndef _EFI_PE_OPTIONAL_HEADER_H_
+#define _EFI_PE_OPTIONAL_HEADER_H_
+
+#define EFI_IMAGE_MACHINE_TYPE (EFI_IMAGE_MACHINE_X64)
+
+#define EFI_IMAGE_MACHINE_TYPE_SUPPORTED(Machine) \
+ (((Machine) == EFI_IMAGE_MACHINE_X64) || ((Machine) == EFI_IMAGE_MACHINE_EBC))
+
+#define EFI_IMAGE_MACHINE_CROSS_TYPE_SUPPORTED(Machine) ((Machine) == EFI_IMAGE_MACHINE_IA32)
+
+//
+// Assume we can use IPF values
+//
+#define EFI_IMAGE_NT_OPTIONAL_HDR_MAGIC EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC
+typedef EFI_IMAGE_OPTIONAL_HEADER64 EFI_IMAGE_OPTIONAL_HEADER;
+typedef EFI_IMAGE_NT_HEADERS64 EFI_IMAGE_NT_HEADERS;
+
+#endif
+
diff --git a/EDK/Foundation/Include/x64/TianoBind.h b/EDK/Foundation/Include/x64/TianoBind.h
new file mode 100644
index 0000000..0dafc37
--- /dev/null
+++ b/EDK/Foundation/Include/x64/TianoBind.h
@@ -0,0 +1,30 @@
+/*++
+
+Copyright (c) 2005, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ TianoBind.h
+
+Abstract:
+
+ Tiano's Processor or Compiler specific defines and types for Intel?Itanium(TM)
+ besides EfiBind.h.
+
+--*/
+
+#ifndef _TIANO_BIND_H_
+#define _TIANO_BIND_H_
+
+#include "EfiBind.h"
+
+#define EFI_DXE_ENTRY_POINT(InitFunction)
+
+#endif
diff --git a/EDK/Foundation/Library/CompilerStub/CompilerStub.cif b/EDK/Foundation/Library/CompilerStub/CompilerStub.cif
new file mode 100644
index 0000000..bfd60e4
--- /dev/null
+++ b/EDK/Foundation/Library/CompilerStub/CompilerStub.cif
@@ -0,0 +1,12 @@
+<component>
+ name = "CompilerStub"
+ category = ModulePart
+ LocalRoot = "EDK\Foundation\Library\CompilerStub\"
+ RefName = "CompilerStub"
+[files]
+"CompilerStub.sdl"
+"CompilerStub.mak"
+"memcpy.c"
+"memset.c"
+"CompilerStubLib.inf"
+<endComponent>
diff --git a/EDK/Foundation/Library/CompilerStub/CompilerStub.mak b/EDK/Foundation/Library/CompilerStub/CompilerStub.mak
new file mode 100644
index 0000000..b738375
--- /dev/null
+++ b/EDK/Foundation/Library/CompilerStub/CompilerStub.mak
@@ -0,0 +1,79 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/CompilerStub/CompilerStub.mak 1 1/20/12 3:59a Jeffch $
+#
+# $Revision: 1 $
+#
+# $Date: 1/20/12 3:59a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/CompilerStub/CompilerStub.mak $
+#
+# 1 1/20/12 3:59a Jeffch
+#
+# 1 9/27/11 6:22a Wesleychen
+# Intel EDK initially releases.
+#
+# 3 11/06/09 4:27a Iminglin
+# Edk-Dev-Snapshot-20090928
+#
+# 2 9/02/09 3:24a Iminglin
+# EIP24919
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: CompilerStub.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+
+$(COMPILERSTUB) : CompilerStub
+
+CompilerStub : $(BUILD_DIR)\CompilerStub.mak CompilerStubBin
+
+$(BUILD_DIR)\CompilerStub.mak : $(CompilerStub_DIR)\$(@B).cif $(CompilerStub_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(CompilerStub_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+CompilerStubBin :
+!IF "$(PROCESSOR)"=="x64"
+ $(MAKE) /$(MAKEFLAGS) $(EDK_DEFAULTS)\
+ /f $(BUILD_DIR)\CompilerStub.mak all\
+ TYPE=LIBRARY
+ $(MAKE) /$(MAKEFLAGS) $(EDK_DEFAULTS) BUILD_DIR=$(BUILD_DIR)\IA32\
+ /f $(BUILD_DIR)\CompilerStub.mak all\
+ TYPE=PEI_LIBRARY
+!ELSE
+ $(MAKE) /$(MAKEFLAGS) $(EDK_DEFAULTS)\
+ /f $(BUILD_DIR)\CompilerStub.mak all\
+ TYPE=LIBRARY
+!ENDIF
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#********************************************************************** \ No newline at end of file
diff --git a/EDK/Foundation/Library/CompilerStub/CompilerStub.sdl b/EDK/Foundation/Library/CompilerStub/CompilerStub.sdl
new file mode 100644
index 0000000..5cf7e65
--- /dev/null
+++ b/EDK/Foundation/Library/CompilerStub/CompilerStub.sdl
@@ -0,0 +1,26 @@
+TOKEN
+ Name = "CompilerStub_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable CompilerStub support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "COMPILERSTUB"
+ Value = "$$(LIB_BUILD_DIR)\CompilerStub.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "CompilerStub_DIR"
+End
+
+MODULE
+ Help = "Includes CompilerStub.mak to Project"
+ File = "CompilerStub.mak"
+End
+
diff --git a/EDK/Foundation/Library/CompilerStub/CompilerStubLib.inf b/EDK/Foundation/Library/CompilerStub/CompilerStubLib.inf
new file mode 100644
index 0000000..e6e6531
--- /dev/null
+++ b/EDK/Foundation/Library/CompilerStub/CompilerStubLib.inf
@@ -0,0 +1,54 @@
+#/*++
+#
+# Copyright (c) 2006, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# CompilerStubLib.inf
+#
+# Abstract:
+#
+# Component description file for the CompilerStub.
+#
+#--*/
+
+[defines]
+BASE_NAME = CompilerStub
+COMPONENT_TYPE = LIBRARY
+
+[sources.common]
+ memcpy.c
+ memset.c
+
+[includes.common]
+ $(EDK_SOURCE)\Foundation
+ $(EDK_SOURCE)\Foundation\Framework
+ $(EDK_SOURCE)\Foundation\Efi
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+ $(EDK_SOURCE)\Foundation\Include\Pei
+ $(EDK_SOURCE)\Foundation\Library\Pei\Include
+ $(EDK_SOURCE)\Foundation\Core\Pei\Include
+ $(EDK_SOURCE)\Foundation\Framework\Ppi\CpuIo
+ $(EDK_SOURCE)\Foundation\Framework
+
+[libraries.common]
+
+[nmake.common]
+ C_FLAGS = $(C_FLAGS) /Oi- /GL-
+ C_STD_INCLUDE=
+
+[nmake.ia32,nmake.x64]
+ C_STD_INCLUDE= $(C_STD_INCLUDE) /GL-
diff --git a/EDK/Foundation/Library/CompilerStub/memcpy.c b/EDK/Foundation/Library/CompilerStub/memcpy.c
new file mode 100644
index 0000000..91616c9
--- /dev/null
+++ b/EDK/Foundation/Library/CompilerStub/memcpy.c
@@ -0,0 +1,46 @@
+/*++
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+ memcpy.c
+
+Abstract:
+
+ The Microsoft compiler inlines memcpy and we can not stop it.
+ These routines allow the code to link!
+
+ There is no *.h definition of these modules as they are well known by the
+ compiler. See Microsoft documentation for more details!
+
+ volatile is used to prevent the compiler from trying to implement these
+ C functions as inline functions.
+
+--*/
+
+#include "Tiano.h"
+
+VOID *
+memcpy (
+ OUT VOID *Dest,
+ IN const VOID *Src,
+ IN UINTN Count
+ )
+{
+ volatile UINT8 *Ptr;
+ const UINT8 *Source;
+
+ for (Ptr = Dest, Source = Src; Count > 0; Count--, Source++, Ptr++) {
+ *Ptr = *Source;
+ }
+
+ return Dest;
+}
+
diff --git a/EDK/Foundation/Library/CompilerStub/memset.c b/EDK/Foundation/Library/CompilerStub/memset.c
new file mode 100644
index 0000000..0661335
--- /dev/null
+++ b/EDK/Foundation/Library/CompilerStub/memset.c
@@ -0,0 +1,45 @@
+/*++
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+ memset.c
+
+Abstract:
+
+ The Microsoft compiler inlines memset and we can not stop it.
+ These routines allow the code to link!
+
+ There is no *.h definition of these modules as they are well known by the
+ compiler. See Microsoft documentation for more details!
+
+ volatile is used to prevent the compiler from trying to implement these
+ C functions as inline functions.
+
+--*/
+
+#include "Tiano.h"
+
+VOID *
+memset (
+ OUT VOID *Dest,
+ IN UINTN Char,
+ IN UINTN Count
+ )
+{
+ volatile UINT8 *Ptr;
+
+ for (Ptr = Dest; Count > 0; Count--, Ptr++) {
+ *Ptr = (UINT8) Char;
+ }
+
+ return Dest;
+}
+
diff --git a/EDK/Foundation/Library/CustomizedDecompress/CustomizedDecompress.c b/EDK/Foundation/Library/CustomizedDecompress/CustomizedDecompress.c
new file mode 100644
index 0000000..8a86501
--- /dev/null
+++ b/EDK/Foundation/Library/CustomizedDecompress/CustomizedDecompress.c
@@ -0,0 +1,122 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ CustomizedDecompress.c
+
+Abstract:
+
+ Implementation file for Customized decompression routine
+
+--*/
+#include "TianoCommon.h"
+#include "CustomizedDecompress.h"
+
+EFI_CUSTOMIZED_DECOMPRESS_PROTOCOL mCustomizedDecompress = {
+ CustomizedGetInfo,
+ CustomizedDecompress
+};
+
+EFI_STATUS
+InstallCustomizedDecompress (
+ EFI_CUSTOMIZED_DECOMPRESS_PROTOCOL **This
+ )
+/*++
+
+Routine Description:
+
+ Install customeized decompress protocol.
+
+Arguments:
+
+ This - The protocol that needs to be installed.
+
+Returns:
+
+ EFI_SUCCESS - Always success
+
+--*/
+{
+ *This = &mCustomizedDecompress;
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+CustomizedGetInfo (
+ IN EFI_CUSTOMIZED_DECOMPRESS_PROTOCOL *This,
+ IN VOID *Source,
+ IN UINT32 SrcSize,
+ OUT UINT32 *DstSize,
+ OUT UINT32 *ScratchSize
+ )
+/*++
+
+Routine Description:
+
+ The implementation of Customized GetInfo().
+
+Arguments:
+ This - The EFI customized decompress protocol
+ Source - The source buffer containing the compressed data.
+ SrcSize - The size of source buffer
+ DstSize - The size of destination buffer.
+ ScratchSize - The size of scratch buffer.
+
+Returns:
+
+ EFI_SUCCESS - The size of destination buffer and the size of scratch buffer are successull retrieved.
+ EFI_INVALID_PARAMETER - The source data is corrupted
+ EFI_UNSUPPORTED - Not supported
+
+--*/
+{
+ return EFI_UNSUPPORTED;
+}
+
+EFI_STATUS
+EFIAPI
+CustomizedDecompress (
+ IN EFI_CUSTOMIZED_DECOMPRESS_PROTOCOL *This,
+ IN VOID *Source,
+ IN UINT32 SrcSize,
+ IN OUT VOID *Destination,
+ IN UINT32 DstSize,
+ IN OUT VOID *Scratch,
+ IN UINT32 ScratchSize
+ )
+/*++
+
+Routine Description:
+
+ The implementation of Customized Decompress().
+
+Arguments:
+
+ This - The protocol instance pointer
+ Source - The source buffer containing the compressed data.
+ SrcSize - The size of source buffer
+ Destination - The destination buffer to store the decompressed data
+ DstSize - The size of destination buffer.
+ Scratch - The buffer used internally by the decompress routine. This buffer is needed to store intermediate data.
+ ScratchSize - The size of scratch buffer.
+
+Returns:
+
+ EFI_SUCCESS - Decompression is successfull
+ EFI_INVALID_PARAMETER - The source data is corrupted
+ EFI_UNSUPPORTED - Not supported
+
+--*/
+{
+ return EFI_UNSUPPORTED;
+}
diff --git a/EDK/Foundation/Library/CustomizedDecompress/CustomizedDecompress.cif b/EDK/Foundation/Library/CustomizedDecompress/CustomizedDecompress.cif
new file mode 100644
index 0000000..3e5da36
--- /dev/null
+++ b/EDK/Foundation/Library/CustomizedDecompress/CustomizedDecompress.cif
@@ -0,0 +1,12 @@
+<component>
+ name = "CustomizedDecompress"
+ category = ModulePart
+ LocalRoot = "EDK\Foundation\Library\CustomizedDecompress\"
+ RefName = "CustomizedDecompress"
+[files]
+"CustomizedDecompress.c"
+"CustomizedDecompress.h"
+"CustomizedDecompress.sdl"
+"CustomizedDecompress.mak"
+"CustomizedDecompress.inf"
+<endComponent>
diff --git a/EDK/Foundation/Library/CustomizedDecompress/CustomizedDecompress.h b/EDK/Foundation/Library/CustomizedDecompress/CustomizedDecompress.h
new file mode 100644
index 0000000..9cd75f3
--- /dev/null
+++ b/EDK/Foundation/Library/CustomizedDecompress/CustomizedDecompress.h
@@ -0,0 +1,113 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ CustomizedDecompress.h
+
+Abstract:
+
+ Header file for Customized decompression routine
+
+--*/
+#ifndef _CUSTOMIZED_DECOMPRESS_LIB_H_
+#define _CUSTOMIZED_DECOMPRESS_LIB_H_
+
+#include EFI_PROTOCOL_DEFINITION (CustomizedDecompress)
+
+EFI_STATUS
+EFIAPI
+CustomizedGetInfo (
+ IN EFI_CUSTOMIZED_DECOMPRESS_PROTOCOL *This,
+ IN VOID *Source,
+ IN UINT32 SrcSize,
+ OUT UINT32 *DstSize,
+ OUT UINT32 *ScratchSize
+ )
+/*++
+
+Routine Description:
+
+ The implementation of Customized GetInfo().
+
+Arguments:
+ This - The EFI customized decompress protocol
+ Source - The source buffer containing the compressed data.
+ SrcSize - The size of source buffer
+ DstSize - The size of destination buffer.
+ ScratchSize - The size of scratch buffer.
+
+Returns:
+
+ EFI_SUCCESS - The size of destination buffer and the size of scratch buffer are successull retrieved.
+ EFI_INVALID_PARAMETER - The source data is corrupted
+ EFI_UNSUPPORTED - Not supported
+
+--*/
+;
+
+EFI_STATUS
+EFIAPI
+CustomizedDecompress (
+ IN EFI_CUSTOMIZED_DECOMPRESS_PROTOCOL *This,
+ IN VOID *Source,
+ IN UINT32 SrcSize,
+ IN OUT VOID *Destination,
+ IN UINT32 DstSize,
+ IN OUT VOID *Scratch,
+ IN UINT32 ScratchSize
+ )
+/*++
+
+Routine Description:
+
+ The implementation of Customized Decompress().
+
+Arguments:
+
+ This - The protocol instance pointer
+ Source - The source buffer containing the compressed data.
+ SrcSize - The size of source buffer
+ Destination - The destination buffer to store the decompressed data
+ DstSize - The size of destination buffer.
+ Scratch - The buffer used internally by the decompress routine. This buffer is needed to store intermediate data.
+ ScratchSize - The size of scratch buffer.
+
+Returns:
+
+ EFI_SUCCESS - Decompression is successfull
+ EFI_INVALID_PARAMETER - The source data is corrupted
+ EFI_UNSUPPORTED - Not supported
+
+--*/
+;
+
+EFI_STATUS
+InstallCustomizedDecompress (
+ EFI_CUSTOMIZED_DECOMPRESS_PROTOCOL **This
+ )
+/*++
+
+Routine Description:
+
+ Install customeized decompress protocol.
+
+Arguments:
+
+ This - The protocol that needs to be installed.
+
+Returns:
+
+ EFI_SUCCESS - Always success
+
+--*/
+;
+#endif
diff --git a/EDK/Foundation/Library/CustomizedDecompress/CustomizedDecompress.inf b/EDK/Foundation/Library/CustomizedDecompress/CustomizedDecompress.inf
new file mode 100644
index 0000000..3d96790
--- /dev/null
+++ b/EDK/Foundation/Library/CustomizedDecompress/CustomizedDecompress.inf
@@ -0,0 +1,39 @@
+#/*++
+#
+# Copyright (c) 2004, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# CustomizedDecompress.inf
+#
+# Abstract:
+#
+# Component description file for the Customized Decompress library.
+#
+#--*/
+
+[defines]
+BASE_NAME = CustomizedDecompress
+COMPONENT_TYPE = LIBRARY
+
+[sources.common]
+ CustomizedDecompress.c
+ CustomizedDecompress.h
+
+[includes.common]
+ .
+ $(EDK_SOURCE)\Foundation
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework
+ $(EDK_SOURCE)\Foundation\Framework\Include
+[nmake.common]
+ C_STD_INCLUDE= \ No newline at end of file
diff --git a/EDK/Foundation/Library/CustomizedDecompress/CustomizedDecompress.mak b/EDK/Foundation/Library/CustomizedDecompress/CustomizedDecompress.mak
new file mode 100644
index 0000000..b52e4cd
--- /dev/null
+++ b/EDK/Foundation/Library/CustomizedDecompress/CustomizedDecompress.mak
@@ -0,0 +1,69 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/CustomizedDecompress/CustomizedDecompress.mak 1 1/20/12 3:59a Jeffch $
+#
+# $Revision: 1 $
+#
+# $Date: 1/20/12 3:59a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/CustomizedDecompress/CustomizedDecompress.mak $
+#
+# 1 1/20/12 3:59a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 9/27/11 6:22a Wesleychen
+# Intel EDK initially releases.
+#
+# 2 9/02/09 3:26a Iminglin
+# EIP24919
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: CustomizedDecompress.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+$(CUSTOMIZEDDECOMPRESS) : CustomizedDecompress
+
+$(BUILD_DIR)\CustomizedDecompress.lib : CustomizedDecompress
+
+CustomizedDecompress : $(BUILD_DIR)\CustomizedDecompress.mak CustomizedDecompressBin
+
+$(BUILD_DIR)\CustomizedDecompress.mak : $(CustomizedDecompress_DIR)\$(@B).cif $(CustomizedDecompress_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(CustomizedDecompress_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+CustomizedDecompressBin :
+ $(MAKE) /$(MAKEFLAGS) $(EDK_DEFAULTS)\
+ /f $(BUILD_DIR)\CustomizedDecompress.mak all\
+ TYPE=LIBRARY \
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#********************************************************************** \ No newline at end of file
diff --git a/EDK/Foundation/Library/CustomizedDecompress/CustomizedDecompress.sdl b/EDK/Foundation/Library/CustomizedDecompress/CustomizedDecompress.sdl
new file mode 100644
index 0000000..0c76540
--- /dev/null
+++ b/EDK/Foundation/Library/CustomizedDecompress/CustomizedDecompress.sdl
@@ -0,0 +1,25 @@
+TOKEN
+ Name = "CustomizedDecompress_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable CustomizedDecompress support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "CUSTOMIZEDDECOMPRESS"
+ Value = "$(BUILD_DIR)\CustomizedDecompress.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "CustomizedDecompress_DIR"
+End
+
+MODULE
+ Help = "Includes CustomizedDecompress.mak to Project"
+ File = "CustomizedDecompress.mak"
+End
diff --git a/EDK/Foundation/Library/Dxe/EfiDriverLib/Debug.c b/EDK/Foundation/Library/Dxe/EfiDriverLib/Debug.c
new file mode 100644
index 0000000..446d229
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/EfiDriverLib/Debug.c
@@ -0,0 +1,173 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Debug.c
+
+Abstract:
+
+ Support for Debug primatives.
+
+--*/
+
+#include "Tiano.h"
+#include "EfiDriverLib.h"
+#include "EfiPrintLib.h"
+#include "EfiStatusCode.h"
+#include EFI_GUID_DEFINITION (StatusCodeCallerId)
+#include EFI_GUID_DEFINITION (StatusCodeDataTypeId)
+#include EFI_PROTOCOL_DEFINITION (DEBUGMASK)
+
+//
+// You would think you should divid by sizeof (UINT64), but EBC does not like
+// that!
+//
+#define EFI_STATUS_CODE_DATA_MAX_SIZE64 (EFI_STATUS_CODE_DATA_MAX_SIZE / 8)
+
+VOID
+EfiDebugAssert (
+ IN CHAR8 *FileName,
+ IN INTN LineNumber,
+ IN CHAR8 *Description
+ )
+/*++
+
+Routine Description:
+
+ Worker function for ASSERT(). If Error Logging hub is loaded log ASSERT
+ information. If Error Logging hub is not loaded BREAKPOINT().
+
+ We use UINT64 buffers due to IPF alignment concerns.
+
+Arguments:
+
+ FileName - File name of failing routine.
+
+ LineNumber - Line number of failing ASSERT().
+
+ Description - Descritption, usally the assertion,
+
+Returns:
+
+ None
+
+--*/
+{
+ UINT64 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE];
+
+ EfiDebugAssertWorker (FileName, LineNumber, Description, sizeof (Buffer), Buffer);
+
+ EfiLibReportStatusCode (
+ (EFI_ERROR_CODE | EFI_ERROR_UNRECOVERED),
+ (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_EC_ILLEGAL_SOFTWARE_STATE),
+ 0,
+ &gEfiCallerIdGuid,
+ (EFI_STATUS_CODE_DATA *) Buffer
+ );
+
+ //
+ // Put break point in module that contained the error.
+ //
+ EFI_BREAKPOINT ();
+}
+
+VOID
+EfiDebugVPrint (
+ IN UINTN ErrorLevel,
+ IN CHAR8 *Format,
+ IN VA_LIST Marker
+ )
+/*++
+
+Routine Description:
+
+ Worker function for DEBUG(). If Error Logging hub is loaded log ASSERT
+ information. If Error Logging hub is not loaded do nothing.
+
+ We use UINT64 buffers due to IPF alignment concerns.
+
+Arguments:
+
+ ErrorLevel - If error level is set do the debug print.
+
+ Format - String to use for the print, followed by Print arguments.
+
+ Marker - VarArgs
+
+Returns:
+
+ None
+
+--*/
+{
+ UINT64 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE];
+ UINTN ImageDebugMask;
+
+ //
+ // Check driver debug mask value and global mask
+ //
+ if (gDebugMaskInterface != NULL) {
+ gDebugMaskInterface->GetDebugMask (gDebugMaskInterface, &ImageDebugMask);
+ if (!(ErrorLevel & ImageDebugMask)) {
+ return ;
+ }
+ } else if (!(gErrorLevel & ErrorLevel)) {
+ return ;
+ }
+
+ EfiDebugVPrintWorker (ErrorLevel, Format, Marker, sizeof (Buffer), Buffer);
+
+ ASSERT (NULL != gRT);
+ EfiLibReportStatusCode (
+ EFI_DEBUG_CODE,
+ (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_DC_UNSPECIFIED),
+ 0,
+ &gEfiCallerIdGuid,
+ (EFI_STATUS_CODE_DATA *) Buffer
+ );
+
+ return ;
+}
+
+VOID
+EfiDebugPrint (
+ IN UINTN ErrorLevel,
+ IN CHAR8 *Format,
+ ...
+ )
+/*++
+
+Routine Description:
+
+ Wrapper for EfiDebugVPrint ()
+
+Arguments:
+
+ ErrorLevel - If error level is set do the debug print.
+
+ Format - String to use for the print, followed by Print arguments.
+
+ ... - Print arguments.
+
+
+Returns:
+
+ None
+
+--*/
+{
+ VA_LIST Marker;
+
+ VA_START (Marker, Format);
+ EfiDebugVPrint (ErrorLevel, Format, Marker);
+ VA_END (Marker);
+}
diff --git a/EDK/Foundation/Library/Dxe/EfiDriverLib/DevicePath.c b/EDK/Foundation/Library/Dxe/EfiDriverLib/DevicePath.c
new file mode 100644
index 0000000..8eb411f
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/EfiDriverLib/DevicePath.c
@@ -0,0 +1,551 @@
+/*++
+
+Copyright (c) 2004 - 2008, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ DevicePath.c
+
+Abstract:
+
+ Device Path services. The thing to remember is device paths are built out of
+ nodes. The device path is terminated by an end node that is length
+ sizeof(EFI_DEVICE_PATH_PROTOCOL). That would be why there is sizeof(EFI_DEVICE_PATH_PROTOCOL)
+ all over this file.
+
+ The only place where multi-instance device paths are supported is in
+ environment varibles. Multi-instance device paths should never be placed
+ on a Handle.
+
+--*/
+
+#include "Tiano.h"
+#include "EfiDriverLib.h"
+#include EFI_PROTOCOL_DEFINITION (DevicePath)
+
+EFI_DEVICE_PATH_PROTOCOL *
+EfiDevicePathInstance (
+ IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath,
+ OUT UINTN *Size
+ )
+/*++
+
+Routine Description:
+ Function retrieves the next device path instance from a device path data structure.
+
+Arguments:
+ DevicePath - A pointer to a device path data structure.
+
+ Size - A pointer to the size of a device path instance in bytes.
+
+Returns:
+
+ This function returns a pointer to the current device path instance.
+ In addition, it returns the size in bytes of the current device path instance in Size,
+ and a pointer to the next device path instance in DevicePath.
+ If there are no more device path instances in DevicePath, then DevicePath will be set to NULL.
+
+--*/
+{
+ EFI_DEVICE_PATH_PROTOCOL *DevPath;
+ EFI_DEVICE_PATH_PROTOCOL *ReturnValue;
+ UINT8 Temp;
+
+ if (*DevicePath == NULL) {
+ if (Size != NULL) {
+ *Size = 0;
+ }
+
+ return NULL;
+ }
+
+ //
+ // Find the end of the device path instance
+ //
+ DevPath = *DevicePath;
+ while (!IsDevicePathEndType (DevPath)) {
+ DevPath = NextDevicePathNode (DevPath);
+ }
+
+ //
+ // Compute the size of the device path instance
+ //
+ if (Size != NULL) {
+ *Size = ((UINTN) DevPath - (UINTN) (*DevicePath)) + sizeof (EFI_DEVICE_PATH_PROTOCOL);
+ }
+
+ //
+ // Make a copy and return the device path instance
+ //
+ Temp = DevPath->SubType;
+ DevPath->SubType = END_ENTIRE_DEVICE_PATH_SUBTYPE;
+ ReturnValue = EfiDuplicateDevicePath (*DevicePath);
+ DevPath->SubType = Temp;
+
+ //
+ // If DevPath is the end of an entire device path, then another instance
+ // does not follow, so *DevicePath is set to NULL.
+ //
+ if (DevicePathSubType (DevPath) == END_ENTIRE_DEVICE_PATH_SUBTYPE) {
+ *DevicePath = NULL;
+ } else {
+ *DevicePath = NextDevicePathNode (DevPath);
+ }
+
+ return ReturnValue;
+}
+
+BOOLEAN
+EfiIsDevicePathMultiInstance (
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ )
+/*++
+
+Routine Description:
+ Return TRUE is this is a multi instance device path.
+
+Arguments:
+ DevicePath - A pointer to a device path data structure.
+
+
+Returns:
+ TRUE - If DevicePath is multi instance. FALSE - If DevicePath is not multi
+ instance.
+
+--*/
+{
+ EFI_DEVICE_PATH_PROTOCOL *Node;
+
+ if (DevicePath == NULL) {
+ return FALSE;
+ }
+
+ Node = DevicePath;
+ while (!EfiIsDevicePathEnd (Node)) {
+ if (EfiIsDevicePathEndInstance (Node)) {
+ return TRUE;
+ }
+
+ Node = EfiNextDevicePathNode (Node);
+ }
+
+ return FALSE;
+}
+
+UINTN
+EfiDevicePathSize (
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ )
+/*++
+
+Routine Description:
+
+ Calculate the space size of a device path.
+
+Arguments:
+
+ DevicePath - A specified device path
+
+Returns:
+
+ The size.
+
+--*/
+{
+ EFI_DEVICE_PATH_PROTOCOL *Start;
+
+ if (DevicePath == NULL) {
+ return 0;
+ }
+
+ //
+ // Search for the end of the device path structure
+ //
+ Start = DevicePath;
+ while (!EfiIsDevicePathEnd (DevicePath)) {
+ DevicePath = EfiNextDevicePathNode (DevicePath);
+ }
+
+ //
+ // Compute the size and add back in the size of the end device path structure
+ //
+ return ((UINTN) DevicePath - (UINTN) Start) + sizeof (EFI_DEVICE_PATH_PROTOCOL);
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+EfiDevicePathFromHandle (
+ IN EFI_HANDLE Handle
+ )
+/*++
+
+Routine Description:
+
+ Get the device path protocol interface installed on a specified handle.
+
+Arguments:
+
+ Handle - a specified handle
+
+Returns:
+
+ The device path protocol interface installed on that handle.
+
+--*/
+{
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+
+ DevicePath = NULL;
+ gBS->HandleProtocol (
+ Handle,
+ &gEfiDevicePathProtocolGuid,
+ (VOID *) &DevicePath
+ );
+ return DevicePath;
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+EfiDuplicateDevicePath (
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ )
+/*++
+
+Routine Description:
+
+ Duplicate a device path structure.
+
+Arguments:
+
+ DevicePath - The device path to duplicated.
+
+Returns:
+
+ The duplicated device path.
+
+--*/
+{
+ EFI_DEVICE_PATH_PROTOCOL *NewDevicePath;
+ UINTN Size;
+
+ if (DevicePath == NULL) {
+ return NULL;
+ }
+
+ //
+ // Compute the size
+ //
+ Size = EfiDevicePathSize (DevicePath);
+ if (Size == 0) {
+ return NULL;
+ }
+
+ //
+ // Allocate space for duplicate device path
+ //
+ NewDevicePath = EfiLibAllocateCopyPool (Size, DevicePath);
+
+ return NewDevicePath;
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+EfiAppendDevicePath (
+ IN EFI_DEVICE_PATH_PROTOCOL *Src1,
+ IN EFI_DEVICE_PATH_PROTOCOL *Src2
+ )
+/*++
+
+Routine Description:
+ Function is used to append a Src1 and Src2 together.
+
+Arguments:
+ Src1 - A pointer to a device path data structure.
+
+ Src2 - A pointer to a device path data structure.
+
+Returns:
+
+ A pointer to the new device path is returned.
+ NULL is returned if space for the new device path could not be allocated from pool.
+ It is up to the caller to free the memory used by Src1 and Src2 if they are no longer needed.
+
+--*/
+{
+ UINTN Size;
+ UINTN Size1;
+ UINTN Size2;
+ EFI_DEVICE_PATH_PROTOCOL *NewDevicePath;
+ EFI_DEVICE_PATH_PROTOCOL *SecondDevicePath;
+
+ //
+ // If there's only 1 path, just duplicate it
+ //
+ if (!Src1) {
+ ASSERT (!IsDevicePathUnpacked (Src2));
+ return EfiDuplicateDevicePath (Src2);
+ }
+
+ if (!Src2) {
+ ASSERT (!IsDevicePathUnpacked (Src1));
+ return EfiDuplicateDevicePath (Src1);
+ }
+
+ //
+ // Allocate space for the combined device path. It only has one end node of
+ // length EFI_DEVICE_PATH_PROTOCOL
+ //
+ Size1 = EfiDevicePathSize (Src1);
+ Size2 = EfiDevicePathSize (Src2);
+ Size = Size1 + Size2 - sizeof (EFI_DEVICE_PATH_PROTOCOL);
+
+ NewDevicePath = EfiLibAllocateCopyPool (Size, Src1);
+
+ if (NewDevicePath != NULL) {
+
+ //
+ // Over write Src1 EndNode and do the copy
+ //
+ SecondDevicePath = (EFI_DEVICE_PATH_PROTOCOL *) ((CHAR8 *) NewDevicePath + (Size1 - sizeof (EFI_DEVICE_PATH_PROTOCOL)));
+ EfiCopyMem (SecondDevicePath, Src2, Size2);
+ }
+
+ return NewDevicePath;
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+EfiAppendDevicePathNode (
+ IN EFI_DEVICE_PATH_PROTOCOL *Src1,
+ IN EFI_DEVICE_PATH_PROTOCOL *Node
+ )
+/*++
+
+Routine Description:
+ Function is used to append a device path node to the end of another device path.
+
+Arguments:
+ Src1 - A pointer to a device path data structure.
+
+ Node - A pointer to a device path data structure.
+
+Returns:
+ This function returns a pointer to the new device path.
+ If there is not enough temporary pool memory available to complete this function,
+ then NULL is returned.
+
+
+--*/
+{
+ EFI_DEVICE_PATH_PROTOCOL *Temp;
+ EFI_DEVICE_PATH_PROTOCOL *NextNode;
+ EFI_DEVICE_PATH_PROTOCOL *NewDevicePath;
+ UINTN NodeLength;
+
+ //
+ // Build a Node that has a terminator on it
+ //
+ NodeLength = DevicePathNodeLength (Node);
+
+ Temp = EfiLibAllocateCopyPool (NodeLength + sizeof (EFI_DEVICE_PATH_PROTOCOL), Node);
+ if (Temp == NULL) {
+ return NULL;
+ }
+
+ //
+ // Add and end device path node to convert Node to device path
+ //
+ NextNode = NextDevicePathNode (Temp);
+ SetDevicePathEndNode (NextNode);
+
+ //
+ // Append device paths
+ //
+ NewDevicePath = EfiAppendDevicePath (Src1, Temp);
+ gBS->FreePool (Temp);
+ return NewDevicePath;
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+EfiFileDevicePath (
+ IN EFI_HANDLE Device OPTIONAL,
+ IN CHAR16 *FileName
+ )
+/*++
+
+Routine Description:
+
+ This function allocates a device path for a file and appends it to an existiong
+ device path.
+
+Arguments:
+ Device - A pointer to a device handle.
+
+ FileName - A pointer to a Null-terminated Unicodestring.
+
+Returns:
+ A device path contain the file name.
+
+--*/
+{
+ UINTN Size;
+ FILEPATH_DEVICE_PATH *FilePath;
+ EFI_DEVICE_PATH_PROTOCOL *Eop;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+
+ for (Size = 0; FileName[Size] != 0; Size++)
+ ;
+ Size = (Size + 1) * 2;
+
+ FilePath = EfiLibAllocateZeroPool (Size + SIZE_OF_FILEPATH_DEVICE_PATH + sizeof (EFI_DEVICE_PATH_PROTOCOL));
+
+ DevicePath = NULL;
+
+ if (FilePath != NULL) {
+
+ //
+ // Build a file path
+ //
+ FilePath->Header.Type = MEDIA_DEVICE_PATH;
+ FilePath->Header.SubType = MEDIA_FILEPATH_DP;
+ SetDevicePathNodeLength (&FilePath->Header, Size + SIZE_OF_FILEPATH_DEVICE_PATH);
+ EfiCopyMem (FilePath->PathName, FileName, Size);
+ Eop = NextDevicePathNode (&FilePath->Header);
+ SetDevicePathEndNode (Eop);
+
+ //
+ // Append file path to device's device path
+ //
+
+ DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) FilePath;
+ if (Device != NULL) {
+ DevicePath = EfiAppendDevicePath (
+ EfiDevicePathFromHandle (Device),
+ DevicePath
+ );
+
+ gBS->FreePool (FilePath);
+ }
+ }
+
+ return DevicePath;
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+EfiAppendDevicePathInstance (
+ IN EFI_DEVICE_PATH_PROTOCOL *Src,
+ IN EFI_DEVICE_PATH_PROTOCOL *Instance
+ )
+/*++
+
+Routine Description:
+
+ Append a device path instance to another.
+
+Arguments:
+
+ Src - The device path instance to be appended with.
+ Instance - The device path instance appending the other.
+
+Returns:
+
+ The contaction of these two.
+
+--*/
+{
+ UINT8 *Ptr;
+ EFI_DEVICE_PATH_PROTOCOL *DevPath;
+ UINTN SrcSize;
+ UINTN InstanceSize;
+
+ if (Src == NULL) {
+ return EfiDuplicateDevicePath (Instance);
+ }
+
+ SrcSize = EfiDevicePathSize (Src);
+ InstanceSize = EfiDevicePathSize (Instance);
+
+ Ptr = EfiLibAllocateCopyPool (SrcSize + InstanceSize, Src);
+ if (Ptr != NULL) {
+
+ DevPath = (EFI_DEVICE_PATH_PROTOCOL *) Ptr;
+
+ while (!IsDevicePathEnd (DevPath)) {
+ DevPath = NextDevicePathNode (DevPath);
+ }
+ //
+ // Convert the End to an End Instance, since we are
+ // appending another instacne after this one its a good
+ // idea.
+ //
+ DevPath->SubType = END_INSTANCE_DEVICE_PATH_SUBTYPE;
+
+ DevPath = NextDevicePathNode (DevPath);
+ EfiCopyMem (DevPath, Instance, InstanceSize);
+ }
+
+ return (EFI_DEVICE_PATH_PROTOCOL *) Ptr;
+}
+
+VOID
+EFIAPI
+EfiInitializeFwVolDevicepathNode (
+ IN MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode,
+ IN EFI_GUID *NameGuid
+ )
+/*++
+
+Routine Description:
+
+ Initialize a Firmware Volume (FV) Media Device Path node.
+
+Arguments:
+
+ FvDevicePathNode - Pointer to a FV device path node to initialize
+ NameGuid - FV file name to use in FvDevicePathNode
+
+Returns:
+
+ None
+
+--*/
+{
+ FvDevicePathNode->Header.Type = MEDIA_DEVICE_PATH;
+ FvDevicePathNode->Header.SubType = MEDIA_FV_FILEPATH_DP;
+ SetDevicePathNodeLength (&FvDevicePathNode->Header, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH));
+
+ EfiCopyMem (&FvDevicePathNode->NameGuid, NameGuid, sizeof(EFI_GUID));
+}
+
+EFI_GUID *
+EFIAPI
+EfiGetNameGuidFromFwVolDevicePathNode (
+ IN MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode
+ )
+/*++
+
+Routine Description:
+
+ Check to see if the Firmware Volume (FV) Media Device Path is valid.
+
+Arguments:
+
+ FvDevicePathNode - Pointer to FV device path to check
+
+Returns:
+
+ NULL - FvDevicePathNode is not valid.
+ Other - FvDevicePathNode is valid and pointer to NameGuid was returned.
+
+--*/
+{
+ if (DevicePathType (&FvDevicePathNode->Header) == MEDIA_DEVICE_PATH &&
+ DevicePathSubType (&FvDevicePathNode->Header) == MEDIA_FV_FILEPATH_DP) {
+ return &FvDevicePathNode->NameGuid;
+ }
+
+ return NULL;
+}
diff --git a/EDK/Foundation/Library/Dxe/EfiDriverLib/DxeDriverLib.c b/EDK/Foundation/Library/Dxe/EfiDriverLib/DxeDriverLib.c
new file mode 100644
index 0000000..0d5b36e
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/EfiDriverLib/DxeDriverLib.c
@@ -0,0 +1,56 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ DxeDriverLib.c
+
+Abstract:
+
+ Light weight lib to support EFI drivers.
+
+--*/
+
+#include "Tiano.h"
+#include "EfiDriverLib.h"
+
+EFI_STATUS
+DxeInitializeDriverLib (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+/*++
+
+Routine Description:
+
+ Intialize Driver Lib if it has not yet been initialized.
+
+Arguments:
+
+ ImageHandle - Standard EFI Image entry parameter
+
+ SystemTable - Standard EFI Image entry parameter
+
+Returns:
+
+ EFI_STATUS always returns EFI_SUCCESS
+
+--*/
+{
+ EFI_STATUS Status;
+
+ Status = EfiInitializeDriverLib (ImageHandle, SystemTable);
+ if (!EFI_ERROR (Status)) {
+ Status = EfiLibGetSystemConfigurationTable (&gEfiDxeServicesTableGuid, (VOID **) &gDS);
+ }
+
+ return Status;
+}
diff --git a/EDK/Foundation/Library/Dxe/EfiDriverLib/Ebc/PerformancePrimitives.c b/EDK/Foundation/Library/Dxe/EfiDriverLib/Ebc/PerformancePrimitives.c
new file mode 100644
index 0000000..7e77a2e
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/EfiDriverLib/Ebc/PerformancePrimitives.c
@@ -0,0 +1,52 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PerformancePrimitives.c
+
+Abstract:
+
+ Support for Performance library
+
+--*/
+
+#include "Tiano.h" // for ASSERT macro
+#include "TianoCommon.h"
+
+EFI_STATUS
+GetTimerValue (
+ OUT UINT64 *TimerValue
+ )
+/*++
+
+Routine Description:
+
+ Set TimerValue to 0, which is not expected to be run.
+
+Arguments:
+
+ TimerValue - Timer value for output
+
+Returns:
+
+ EFI_SUCCESS - Should not be reached.
+
+--*/
+{
+ //
+ // Should not be used for EBC, so assert.
+ //
+ *TimerValue = 0;
+ ASSERT (FALSE);
+
+ return EFI_SUCCESS;
+}
diff --git a/EDK/Foundation/Library/Dxe/EfiDriverLib/EfiDriverLib.c b/EDK/Foundation/Library/Dxe/EfiDriverLib/EfiDriverLib.c
new file mode 100644
index 0000000..674bf4c
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/EfiDriverLib/EfiDriverLib.c
@@ -0,0 +1,506 @@
+/*++
+
+Copyright (c) 2004 - 2008, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiDriverLib.c
+
+Abstract:
+
+ Light weight lib to support EFI drivers.
+
+--*/
+
+#include "Tiano.h"
+#include "EfiDriverLib.h"
+
+//
+// Global Interface for Debug Mask Protocol
+//
+EFI_DEBUG_MASK_PROTOCOL *gDebugMaskInterface = NULL;
+
+EFI_STATUS
+EfiInitializeDriverLib (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+/*++
+
+Routine Description:
+
+ Intialize Driver Lib if it has not yet been initialized.
+
+Arguments:
+
+ ImageHandle - Standard EFI Image entry parameter
+
+ SystemTable - Standard EFI Image entry parameter
+
+Returns:
+
+ EFI_STATUS always returns EFI_SUCCESS
+
+--*/
+{
+ gST = SystemTable;
+
+ ASSERT (gST != NULL);
+
+ gBS = gST->BootServices;
+ gRT = gST->RuntimeServices;
+
+ ASSERT (gBS != NULL);
+ ASSERT (gRT != NULL);
+
+ //
+ // Get driver debug mask protocol interface
+ //
+#ifdef EFI_DEBUG
+ gBS->HandleProtocol (
+ ImageHandle,
+ &gEfiDebugMaskProtocolGuid,
+ (VOID *) &gDebugMaskInterface
+ );
+#endif
+ //
+ // Should be at EFI_D_INFO, but lets us know things are running
+ //
+ DEBUG ((EFI_D_INFO, "EfiInitializeDriverLib: Started\n"));
+
+ return EFI_SUCCESS;
+}
+
+STATIC
+BOOLEAN
+IsIso639LanguageCode (
+ IN CHAR8 *Languages
+ )
+/*++
+
+Routine Description:
+
+ Tests whether a language code has format of ISO639-2.
+
+Arguments:
+
+ Languages - The language code to be tested.
+
+Returns:
+
+ TRUE - Language code format is ISO 639-2.
+ FALSE - Language code format is not ISO 639-2.
+
+--*/
+{
+ UINTN Index;
+
+ //
+ // Find out format of Languages
+ //
+ for (Index = 0; Languages[Index] != 0 && Languages[Index] != ';' && Languages[Index] != '-'; Index++);
+ if (Languages[Index] != 0) {
+ //
+ // RFC4646 language code
+ //
+ return FALSE;
+ }
+
+ //
+ // No ';' and '-', it's either ISO639-2 code (list) or single RFC4646 code
+ //
+ if (Index == 2) {
+ //
+ // Single RFC4646 language code without country code, e.g. "en"
+ //
+ return FALSE;
+ }
+
+ //
+ // Languages in format of ISO639-2
+ //
+ return TRUE;
+}
+
+BOOLEAN
+EfiLibCompareLanguage (
+ IN CHAR8 *Language1,
+ IN CHAR8 *Language2
+ )
+/*++
+
+Routine Description:
+
+ Compare the first language instance of two language codes, either could be a
+ single language code or a language code list. This function assume Language1
+ and Language2 has the same language code format, i.e. either ISO639-2 or RFC4646.
+
+Arguments:
+
+ Language1 - The first language code to be tested.
+ Language2 - The second language code to be tested.
+
+Returns:
+
+ TRUE - Language code match.
+ FALSE - Language code mismatch.
+
+--*/
+{
+ UINTN Index;
+
+ //
+ // Compare first two bytes of language tag
+ //
+ if ((Language1[0] != Language2[0]) || (Language1[1] != Language2[1])) {
+ return FALSE;
+ }
+
+ if (IsIso639LanguageCode (Language1)) {
+ //
+ // ISO639-2 language code, compare the third byte of language tag
+ //
+ return (Language1[2] == Language2[2]) ? TRUE : FALSE;
+ }
+
+ //
+ // RFC4646 language code
+ //
+ for (Index = 0; Language1[Index] != 0 && Language1[Index] != ';'; Index++);
+ if ((EfiAsciiStrnCmp (Language1, Language2, Index) == 0) && (Language2[Index] == 0 || Language2[Index] == ';')) {
+ return TRUE;
+}
+
+ return FALSE;
+}
+
+STATIC
+CHAR8 *
+NextSupportedLanguage (
+ IN CHAR8 *Languages
+ )
+/*++
+
+Routine Description:
+
+ Step to next language code of a language code list.
+
+Arguments:
+
+ Languages - The language code list to traverse.
+
+Returns:
+
+ Pointer to next language code or NULL terminator if it's the last one.
+
+--*/
+{
+ UINTN Index;
+
+ if (IsIso639LanguageCode (Languages)) {
+ //
+ // ISO639-2 language code
+ //
+ return (Languages + 3);
+ }
+
+ //
+ // Search in RFC4646 language code list
+ //
+ for (Index = 0; Languages[Index] != 0 && Languages[Index] != ';'; Index++);
+ if (Languages[Index] == ';') {
+ Index++;
+ }
+ return (Languages + Index);
+}
+
+EFI_STATUS
+EfiLibLookupUnicodeString (
+ IN CHAR8 *Language,
+ IN CHAR8 *SupportedLanguages,
+ IN EFI_UNICODE_STRING_TABLE *UnicodeStringTable,
+ OUT CHAR16 **UnicodeString
+ )
+/*++
+
+Routine Description:
+
+ Translate a unicode string to a specified language if supported.
+
+Arguments:
+
+ Language - The name of language to translate to
+ SupportedLanguages - Supported languages set
+ UnicodeStringTable - Pointer of one item in translation dictionary
+ UnicodeString - The translated string
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Invalid parameter
+ EFI_UNSUPPORTED - System not supported this language or this string translation
+ EFI_SUCCESS - String successfully translated
+
+--*/
+{
+ //
+ // Make sure the parameters are valid
+ //
+ if (Language == NULL || UnicodeString == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // If there are no supported languages, or the Unicode String Table is empty, then the
+ // Unicode String specified by Language is not supported by this Unicode String Table
+ //
+ if (SupportedLanguages == NULL || UnicodeStringTable == NULL) {
+ return EFI_UNSUPPORTED;
+ }
+
+ //
+ // Make sure Language is in the set of Supported Languages
+ //
+ while (*SupportedLanguages != 0) {
+ if (EfiLibCompareLanguage (Language, SupportedLanguages)) {
+
+ //
+ // Search the Unicode String Table for the matching Language specifier
+ //
+ while (UnicodeStringTable->Language != NULL) {
+ if (EfiLibCompareLanguage (Language, UnicodeStringTable->Language)) {
+
+ //
+ // A matching string was found, so return it
+ //
+ *UnicodeString = UnicodeStringTable->UnicodeString;
+ return EFI_SUCCESS;
+ }
+
+ UnicodeStringTable++;
+ }
+
+ return EFI_UNSUPPORTED;
+ }
+
+ SupportedLanguages = NextSupportedLanguage (SupportedLanguages);
+ }
+
+ return EFI_UNSUPPORTED;
+}
+
+EFI_STATUS
+EfiLibAddUnicodeString (
+ IN CHAR8 *Language,
+ IN CHAR8 *SupportedLanguages,
+ IN OUT EFI_UNICODE_STRING_TABLE **UnicodeStringTable,
+ IN CHAR16 *UnicodeString
+ )
+/*++
+
+Routine Description:
+
+ Add an translation to the dictionary if this language if supported.
+
+Arguments:
+
+ Language - The name of language to translate to
+ SupportedLanguages - Supported languages set
+ UnicodeStringTable - Translation dictionary
+ UnicodeString - The corresponding string for the language to be translated to
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Invalid parameter
+ EFI_UNSUPPORTED - System not supported this language
+ EFI_ALREADY_STARTED - Already has a translation item of this language
+ EFI_OUT_OF_RESOURCES - No enough buffer to be allocated
+ EFI_SUCCESS - String successfully translated
+
+--*/
+{
+ UINTN NumberOfEntries;
+ EFI_UNICODE_STRING_TABLE *OldUnicodeStringTable;
+ EFI_UNICODE_STRING_TABLE *NewUnicodeStringTable;
+ UINTN UnicodeStringLength;
+
+ //
+ // Make sure the parameter are valid
+ //
+ if (Language == NULL || UnicodeString == NULL || UnicodeStringTable == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // If there are no supported languages, then a Unicode String can not be added
+ //
+ if (SupportedLanguages == NULL) {
+ return EFI_UNSUPPORTED;
+ }
+
+ //
+ // If the Unicode String is empty, then a Unicode String can not be added
+ //
+ if (UnicodeString[0] == 0) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // Make sure Language is a member of SupportedLanguages
+ //
+ while (*SupportedLanguages != 0) {
+ if (EfiLibCompareLanguage (Language, SupportedLanguages)) {
+
+ //
+ // Determine the size of the Unicode String Table by looking for a NULL Language entry
+ //
+ NumberOfEntries = 0;
+ if (*UnicodeStringTable != NULL) {
+ OldUnicodeStringTable = *UnicodeStringTable;
+ while (OldUnicodeStringTable->Language != NULL) {
+ if (EfiLibCompareLanguage (Language, OldUnicodeStringTable->Language)) {
+ return EFI_ALREADY_STARTED;
+ }
+
+ OldUnicodeStringTable++;
+ NumberOfEntries++;
+ }
+ }
+
+ //
+ // Allocate space for a new Unicode String Table. It must hold the current number of
+ // entries, plus 1 entry for the new Unicode String, plus 1 entry for the end of table
+ // marker
+ //
+ NewUnicodeStringTable = EfiLibAllocatePool ((NumberOfEntries + 2) * sizeof (EFI_UNICODE_STRING_TABLE));
+ if (NewUnicodeStringTable == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ //
+ // If the current Unicode String Table contains any entries, then copy them to the
+ // newly allocated Unicode String Table.
+ //
+ if (*UnicodeStringTable != NULL) {
+ EfiCopyMem (
+ NewUnicodeStringTable,
+ *UnicodeStringTable,
+ NumberOfEntries * sizeof (EFI_UNICODE_STRING_TABLE)
+ );
+ }
+
+ //
+ // Allocate space for a copy of the Language specifier
+ //
+ NewUnicodeStringTable[NumberOfEntries].Language = EfiLibAllocateCopyPool (EfiAsciiStrSize (Language), Language);
+ if (NewUnicodeStringTable[NumberOfEntries].Language == NULL) {
+ gBS->FreePool (NewUnicodeStringTable);
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ //
+ // Compute the length of the Unicode String
+ //
+ for (UnicodeStringLength = 0; UnicodeString[UnicodeStringLength] != 0; UnicodeStringLength++)
+ ;
+
+ //
+ // Allocate space for a copy of the Unicode String
+ //
+ NewUnicodeStringTable[NumberOfEntries].UnicodeString = EfiLibAllocateCopyPool (
+ (UnicodeStringLength + 1) * sizeof (CHAR16),
+ UnicodeString
+ );
+ if (NewUnicodeStringTable[NumberOfEntries].UnicodeString == NULL) {
+ gBS->FreePool (NewUnicodeStringTable[NumberOfEntries].Language);
+ gBS->FreePool (NewUnicodeStringTable);
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ //
+ // Mark the end of the Unicode String Table
+ //
+ NewUnicodeStringTable[NumberOfEntries + 1].Language = NULL;
+ NewUnicodeStringTable[NumberOfEntries + 1].UnicodeString = NULL;
+
+ //
+ // Free the old Unicode String Table
+ //
+ if (*UnicodeStringTable != NULL) {
+ gBS->FreePool (*UnicodeStringTable);
+ }
+
+ //
+ // Point UnicodeStringTable at the newly allocated Unicode String Table
+ //
+ *UnicodeStringTable = NewUnicodeStringTable;
+
+ return EFI_SUCCESS;
+ }
+
+ SupportedLanguages = NextSupportedLanguage (SupportedLanguages);
+ }
+
+ return EFI_UNSUPPORTED;
+}
+
+EFI_STATUS
+EfiLibFreeUnicodeStringTable (
+ IN OUT EFI_UNICODE_STRING_TABLE *UnicodeStringTable
+ )
+/*++
+
+Routine Description:
+
+ Free a string table.
+
+Arguments:
+
+ UnicodeStringTable - The string table to be freed.
+
+Returns:
+
+ EFI_SUCCESS - The table successfully freed.
+
+--*/
+{
+ UINTN Index;
+
+ //
+ // If the Unicode String Table is NULL, then it is already freed
+ //
+ if (UnicodeStringTable == NULL) {
+ return EFI_SUCCESS;
+ }
+
+ //
+ // Loop through the Unicode String Table until we reach the end of table marker
+ //
+ for (Index = 0; UnicodeStringTable[Index].Language != NULL; Index++) {
+
+ //
+ // Free the Language string from the Unicode String Table
+ //
+ gBS->FreePool (UnicodeStringTable[Index].Language);
+
+ //
+ // Free the Unicode String from the Unicode String Table
+ //
+ if (UnicodeStringTable[Index].UnicodeString != NULL) {
+ gBS->FreePool (UnicodeStringTable[Index].UnicodeString);
+ }
+ }
+
+ //
+ // Free the Unicode String Table itself
+ //
+ gBS->FreePool (UnicodeStringTable);
+
+ return EFI_SUCCESS;
+}
diff --git a/EDK/Foundation/Library/Dxe/EfiDriverLib/EfiDriverLib.cif b/EDK/Foundation/Library/Dxe/EfiDriverLib/EfiDriverLib.cif
new file mode 100644
index 0000000..701a0b9
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/EfiDriverLib/EfiDriverLib.cif
@@ -0,0 +1,32 @@
+<component>
+ name = "EfiDriverLib"
+ category = ModulePart
+ LocalRoot = "EDK\Foundation\Library\Dxe\EfiDriverLib\"
+ RefName = "EfiDriverLib"
+[files]
+"EfiDriverLib.sdl"
+"EfiDriverLib.mak"
+"Debug.c"
+"DevicePath.c"
+"EfiDriverLib.c"
+"DxeDriverLib.c"
+"EfiGetConfigTable.c"
+"EfiDriverModelLib.c"
+"Event.c"
+"Handle.c"
+"LibGlobalSt.c"
+"LibGlobalDs.c"
+"LibGlobalErrorLevel.c"
+"Lock.c"
+"EfiLibAllocate.c"
+"Perf.c"
+"ReportStatusCode.c"
+"GetImage.c"
+"..\hob\hob.c"
+"IA32\PerformancePrimitives.c"
+"x64\PerformancePrimitives.c"
+"Ipf\PerformancePrimitives.s"
+"Ebc\PerformancePrimitives.c"
+"EfiDriverLib.inf"
+"HobLib.inf"
+<endComponent>
diff --git a/EDK/Foundation/Library/Dxe/EfiDriverLib/EfiDriverLib.inf b/EDK/Foundation/Library/Dxe/EfiDriverLib/EfiDriverLib.inf
new file mode 100644
index 0000000..83226e9
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/EfiDriverLib/EfiDriverLib.inf
@@ -0,0 +1,90 @@
+#/*++
+#
+# Copyright (c) 2004 - 2012, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# EfiDriverLib.inf
+#
+# Abstract:
+#
+# Component description file for the EFI driver library.
+#
+#--*/
+
+[defines]
+BASE_NAME = EfiDriverLib
+COMPONENT_TYPE = LIBRARY
+
+[sources.common]
+ Debug.c
+ DevicePath.c
+ EfiDriverLib.c
+ DxeDriverLib.c
+ EfiGetConfigTable.c
+ EfiDriverModelLib.c
+ Event.c
+ Handle.c
+ LibGlobalSt.c
+ LibGlobalDs.c
+ LibGlobalErrorLevel.c
+ Lock.c
+ EfiLibAllocate.c
+ Perf.c
+ ReportStatusCode.c
+ GetImage.c
+
+ ..\hob\hob.c
+
+[sources.ia32]
+ ia32\PerformancePrimitives.c
+
+[sources.x64]
+ x64\PerformancePrimitives.c
+
+[sources.ipf]
+ ipf\PerformancePrimitives.s
+
+[sources.ebc]
+ Ebc\PerformancePrimitives.c
+
+[includes.common]
+ $(EDK_SOURCE)\Foundation
+ $(EDK_SOURCE)\Foundation\Framework
+ $(EDK_SOURCE)\Foundation\Efi
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+ $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include
+
+[libraries.common]
+ EdkGuidLib
+ EdkProtocolLib
+ EdkFrameworkProtocolLib
+ EfiGuidLib
+ EfiProtocolLib
+ ArchProtocolLib
+ EfiCommonLib
+ PrintLib
+
+[libraries.ia32]
+ CpuIA32Lib
+
+[libraries.x64]
+ CpuIA32Lib
+
+[libraries.ipf]
+ CpuIA64Lib
+
+[nmake.common]
+ C_STD_INCLUDE=
diff --git a/EDK/Foundation/Library/Dxe/EfiDriverLib/EfiDriverLib.mak b/EDK/Foundation/Library/Dxe/EfiDriverLib/EfiDriverLib.mak
new file mode 100644
index 0000000..ac43c21
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/EfiDriverLib/EfiDriverLib.mak
@@ -0,0 +1,75 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EfiDriverLib/EfiDriverLib.mak 1 1/20/12 4:06a Jeffch $
+#
+# $Revision: 1 $
+#
+# $Date: 1/20/12 4:06a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EfiDriverLib/EfiDriverLib.mak $
+#
+# 1 1/20/12 4:06a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 9/27/11 6:30a Wesleychen
+# Intel EDK initially releases.
+#
+# 2 9/02/09 3:44a Iminglin
+# EIP24919
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: EfiDriverLib.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+$(EFIDRIVERLIB) : EfiDriverLib
+
+$(BUILD_DIR)\EfiDriverLib.lib : EfiDriverLib
+
+EfiDriverLib : $(BUILD_DIR)\EfiDriverLib.mak EfiDriverLibBin
+
+$(BUILD_DIR)\EfiDriverLib.mak : $(EfiDriverLib_DIR)\$(@B).cif $(EfiDriverLib_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(EfiDriverLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+!IF "$(PROCESSOR)"!="IPF"
+EfiDriverLibBin : $(CPUIA32LIB)
+!ELSE
+EfiDriverLibBin : $(CPUIA64LIB)
+!ENDIF
+
+EfiDriverLibBin : $(EDKGUIDLIB) $(EDKPROTOCOLLIB) $(EDKFRAMEWORKPROTOCOLLIB) $(EFIGUIDLIB) $(EFIPROTOCOLLIB) $(ARCHPROTOCOLLIB) $(EFICOMMONLIB)
+ $(MAKE) /$(MAKEFLAGS) $(EDK_DEFAULTS)\
+ /f $(BUILD_DIR)\EfiDriverLib.mak all\
+ TYPE=LIBRARY
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#********************************************************************** \ No newline at end of file
diff --git a/EDK/Foundation/Library/Dxe/EfiDriverLib/EfiDriverLib.sdl b/EDK/Foundation/Library/Dxe/EfiDriverLib/EfiDriverLib.sdl
new file mode 100644
index 0000000..9c3fc8d
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/EfiDriverLib/EfiDriverLib.sdl
@@ -0,0 +1,26 @@
+TOKEN
+ Name = "EfiDriverLib_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable EfiDriverLib support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "EFIDRIVERLIB"
+ Value = "$(BUILD_DIR)\EfiDriverLib.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "EfiDriverLib_DIR"
+End
+
+MODULE
+ Help = "Includes EfiDriverLib.mak to Project"
+ File = "EfiDriverLib.mak"
+End
+
diff --git a/EDK/Foundation/Library/Dxe/EfiDriverLib/EfiDriverModelLib.c b/EDK/Foundation/Library/Dxe/EfiDriverLib/EfiDriverModelLib.c
new file mode 100644
index 0000000..eb3d7ae
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/EfiDriverLib/EfiDriverModelLib.c
@@ -0,0 +1,444 @@
+/*++
+
+Copyright (c) 2004 - 2008, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiDriverModelLib.c
+
+Abstract:
+
+ Light weight lib to support EFI drivers.
+
+--*/
+
+#include "Tiano.h"
+#include "EfiDriverLib.h"
+
+EFI_STATUS
+EfiLibInstallDriverBinding (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable,
+ IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding,
+ IN EFI_HANDLE DriverBindingHandle
+ )
+/*++
+
+Routine Description:
+
+ Intialize a driver by installing the Driver Binding Protocol onto the
+ driver's DriverBindingHandle. This is typically the same as the driver's
+ ImageHandle, but it can be different if the driver produces multiple
+ DriverBinding Protocols. This function also initializes the EFI Driver
+ Library that initializes the global variables gST, gBS, gRT.
+
+Arguments:
+
+ ImageHandle - The image handle of the driver
+
+ SystemTable - The EFI System Table that was passed to the driver's entry point
+
+ DriverBinding - A Driver Binding Protocol instance that this driver is producing
+
+ DriverBindingHandle - The handle that DriverBinding is to be installe onto. If this
+ parameter is NULL, then a new handle is created.
+
+Returns:
+
+ EFI_SUCCESS is DriverBinding is installed onto DriverBindingHandle
+
+ Otherwise, then return status from gBS->InstallProtocolInterface()
+
+--*/
+{
+ EfiInitializeDriverLib (ImageHandle, SystemTable);
+
+ DriverBinding->ImageHandle = ImageHandle;
+
+ DriverBinding->DriverBindingHandle = DriverBindingHandle;
+
+ return gBS->InstallProtocolInterface (
+ &DriverBinding->DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid,
+ EFI_NATIVE_INTERFACE,
+ DriverBinding
+ );
+}
+
+EFI_STATUS
+InstallAllDriverProtocolsWorker (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE * SystemTable,
+ IN EFI_DRIVER_BINDING_PROTOCOL * DriverBinding,
+ IN EFI_HANDLE DriverBindingHandle,
+ IN EFI_COMPONENT_NAME_PROTOCOL * ComponentName, OPTIONAL
+ IN EFI_COMPONENT_NAME2_PROTOCOL * ComponentName2, OPTIONAL
+ IN EFI_DRIVER_CONFIGURATION_PROTOCOL * DriverConfiguration, OPTIONAL
+ IN EFI_DRIVER_CONFIGURATION2_PROTOCOL * DriverConfiguration2, OPTIONAL
+ IN EFI_DRIVER_DIAGNOSTICS_PROTOCOL * DriverDiagnostics, OPTIONAL
+ IN EFI_DRIVER_DIAGNOSTICS2_PROTOCOL * DriverDiagnostics2 OPTIONAL
+ )
+/*++
+
+Routine Description:
+
+ Intialize a driver by installing the Driver Binding Protocol onto the
+ driver's DriverBindingHandle. This is typically the same as the driver's
+ ImageHandle, but it can be different if the driver produces multiple
+ DriverBinding Protocols. This function also initializes the EFI Driver
+ Library that initializes the global variables gST, gBS, gRT.
+
+Arguments:
+
+ ImageHandle - The image handle of the driver
+
+ SystemTable - The EFI System Table that was passed to the driver's entry point
+
+ DriverBinding - A Driver Binding Protocol instance that this driver is producing
+
+ DriverBindingHandle - The handle that DriverBinding is to be installe onto. If this
+ parameter is NULL, then a new handle is created.
+
+ ComponentName - A Component Name Protocol instance that this driver is producing
+
+ ComponentName2 - A Component Name2 Protocol instance that this driver is producing
+
+ DriverConfiguration - A Driver Configuration Protocol instance that this driver is producing
+
+ DriverConfiguration2- A Driver Configuration2 Protocol instance that this driver is producing
+
+ DriverDiagnostics - A Driver Diagnostics Protocol instance that this driver is producing
+
+ DriverDiagnostics2 - A Driver Diagnostics2 Protocol instance that this driver is producing
+
+Returns:
+
+ EFI_SUCCESS if all the protocols were installed onto DriverBindingHandle
+
+ Otherwise, then return status from gBS->InstallProtocolInterface()
+
+--*/
+{
+ EFI_STATUS Status;
+
+ Status = EfiLibInstallDriverBinding (ImageHandle, SystemTable, DriverBinding, DriverBindingHandle);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ if (ComponentName != NULL) {
+ Status = gBS->InstallProtocolInterface (
+ &DriverBinding->DriverBindingHandle,
+ &gEfiComponentNameProtocolGuid,
+ EFI_NATIVE_INTERFACE,
+ ComponentName
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ }
+
+ if (ComponentName2 != NULL) {
+ Status = gBS->InstallProtocolInterface (
+ &DriverBinding->DriverBindingHandle,
+ &gEfiComponentName2ProtocolGuid,
+ EFI_NATIVE_INTERFACE,
+ ComponentName2
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ }
+
+ if (DriverConfiguration != NULL) {
+ Status = gBS->InstallProtocolInterface (
+ &DriverBinding->DriverBindingHandle,
+ &gEfiDriverConfigurationProtocolGuid,
+ EFI_NATIVE_INTERFACE,
+ DriverConfiguration
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ }
+
+ if (DriverConfiguration2 != NULL) {
+ Status = gBS->InstallProtocolInterface (
+ &DriverBinding->DriverBindingHandle,
+ &gEfiDriverConfiguration2ProtocolGuid,
+ EFI_NATIVE_INTERFACE,
+ DriverConfiguration2
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ }
+
+ if (DriverDiagnostics != NULL) {
+ Status = gBS->InstallProtocolInterface (
+ &DriverBinding->DriverBindingHandle,
+ &gEfiDriverDiagnosticsProtocolGuid,
+ EFI_NATIVE_INTERFACE,
+ DriverDiagnostics
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ }
+
+ if (DriverDiagnostics2 != NULL) {
+ Status = gBS->InstallProtocolInterface (
+ &DriverBinding->DriverBindingHandle,
+ &gEfiDriverDiagnostics2ProtocolGuid,
+ EFI_NATIVE_INTERFACE,
+ DriverDiagnostics2
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ }
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EfiLibInstallAllDriverProtocols (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE * SystemTable,
+ IN EFI_DRIVER_BINDING_PROTOCOL * DriverBinding,
+ IN EFI_HANDLE DriverBindingHandle,
+ IN EFI_COMPONENT_NAME_PROTOCOL * ComponentName, OPTIONAL
+ IN EFI_DRIVER_CONFIGURATION_PROTOCOL * DriverConfiguration, OPTIONAL
+ IN EFI_DRIVER_DIAGNOSTICS_PROTOCOL * DriverDiagnostics OPTIONAL
+ )
+/*++
+
+Routine Description:
+
+ Intialize a driver by installing the Driver Binding Protocol onto the
+ driver's DriverBindingHandle. This is typically the same as the driver's
+ ImageHandle, but it can be different if the driver produces multiple
+ DriverBinding Protocols. This function also initializes the EFI Driver
+ Library that initializes the global variables gST, gBS, gRT.
+
+Arguments:
+
+ ImageHandle - The image handle of the driver
+
+ SystemTable - The EFI System Table that was passed to the driver's entry point
+
+ DriverBinding - A Driver Binding Protocol instance that this driver is producing
+
+ DriverBindingHandle - The handle that DriverBinding is to be installe onto. If this
+ parameter is NULL, then a new handle is created.
+
+ ComponentName - A Component Name Protocol instance that this driver is producing
+
+ DriverConfiguration - A Driver Configuration Protocol instance that this driver is producing
+
+ DriverDiagnostics - A Driver Diagnostics Protocol instance that this driver is producing
+
+Returns:
+
+ EFI_SUCCESS if all the protocols were installed onto DriverBindingHandle
+
+ Otherwise, then return status from gBS->InstallProtocolInterface()
+
+--*/
+{
+ return InstallAllDriverProtocolsWorker (
+ ImageHandle,
+ SystemTable,
+ DriverBinding,
+ DriverBindingHandle,
+ ComponentName,
+ NULL,
+ DriverConfiguration,
+ NULL,
+ DriverDiagnostics,
+ NULL
+ );
+}
+
+EFI_STATUS
+EfiLibInstallAllDriverProtocols2 (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE * SystemTable,
+ IN EFI_DRIVER_BINDING_PROTOCOL * DriverBinding,
+ IN EFI_HANDLE DriverBindingHandle,
+ IN EFI_COMPONENT_NAME2_PROTOCOL * ComponentName2, OPTIONAL
+ IN EFI_DRIVER_CONFIGURATION2_PROTOCOL * DriverConfiguration2, OPTIONAL
+ IN EFI_DRIVER_DIAGNOSTICS2_PROTOCOL * DriverDiagnostics2 OPTIONAL
+ )
+/*++
+
+Routine Description:
+
+ Intialize a driver by installing the Driver Binding Protocol onto the
+ driver's DriverBindingHandle. This is typically the same as the driver's
+ ImageHandle, but it can be different if the driver produces multiple
+ DriverBinding Protocols. This function also initializes the EFI Driver
+ Library that initializes the global variables gST, gBS, gRT.
+
+Arguments:
+
+ ImageHandle - The image handle of the driver
+
+ SystemTable - The EFI System Table that was passed to the driver's entry point
+
+ DriverBinding - A Driver Binding Protocol instance that this driver is producing
+
+ DriverBindingHandle - The handle that DriverBinding is to be installe onto. If this
+ parameter is NULL, then a new handle is created.
+
+ ComponentName2 - A Component Name2 Protocol instance that this driver is producing
+
+ DriverConfiguration2- A Driver Configuration2 Protocol instance that this driver is producing
+
+ DriverDiagnostics2 - A Driver Diagnostics2 Protocol instance that this driver is producing
+
+Returns:
+
+ EFI_SUCCESS if all the protocols were installed onto DriverBindingHandle
+
+ Otherwise, then return status from gBS->InstallProtocolInterface()
+
+--*/
+{
+ return InstallAllDriverProtocolsWorker (
+ ImageHandle,
+ SystemTable,
+ DriverBinding,
+ DriverBindingHandle,
+ NULL,
+ ComponentName2,
+ NULL,
+ DriverConfiguration2,
+ NULL,
+ DriverDiagnostics2
+ );
+}
+
+EFI_STATUS
+EfiLibTestManagedDevice (
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE DriverBindingHandle,
+ IN EFI_GUID *ManagedProtocolGuid
+ )
+/*++
+
+Routine Description:
+
+ Test to see if the controller is managed by a specific driver.
+
+Arguments:
+
+ ControllerHandle - Handle for controller to test
+
+ DriverBindingHandle - Driver binding handle for controller
+
+ ManagedProtocolGuid - The protocol guid the driver opens on controller
+
+Returns:
+
+ EFI_SUCCESS - The controller is managed by the driver
+
+ EFI_UNSUPPORTED - The controller is not managed by the driver
+
+--*/
+{
+ EFI_STATUS Status;
+ VOID *ManagedInterface;
+
+ Status = gBS->OpenProtocol (
+ ControllerHandle,
+ ManagedProtocolGuid,
+ &ManagedInterface,
+ DriverBindingHandle,
+ ControllerHandle,
+ EFI_OPEN_PROTOCOL_BY_DRIVER
+ );
+ if (!EFI_ERROR (Status)) {
+ gBS->CloseProtocol (
+ ControllerHandle,
+ ManagedProtocolGuid,
+ DriverBindingHandle,
+ ControllerHandle
+ );
+ return EFI_UNSUPPORTED;
+ }
+
+ if (Status != EFI_ALREADY_STARTED) {
+ return EFI_UNSUPPORTED;
+ }
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EfiLibTestChildHandle (
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle,
+ IN EFI_GUID *ConsumedGuid
+ )
+/*++
+
+Routine Description:
+
+ Test to see if the child handle is the child of the controller
+
+Arguments:
+
+ ControllerHandle - Handle for controller (parent)
+
+ ChildHandle - Child handle to test
+
+ ConsumsedGuid - Protocol guid consumed by child from controller
+
+Returns:
+
+ EFI_SUCCESS - The child handle is the child of the controller
+
+ EFI_UNSUPPORTED - The child handle is not the child of the controller
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenInfoBuffer;
+ UINTN EntryCount;
+ UINTN Index;
+
+ //
+ // Retrieve the list of agents that are consuming one of the protocols
+ // on ControllerHandle that the children consume
+ //
+ Status = gBS->OpenProtocolInformation (
+ ControllerHandle,
+ ConsumedGuid,
+ &OpenInfoBuffer,
+ &EntryCount
+ );
+ if (EFI_ERROR (Status)) {
+ return EFI_UNSUPPORTED;
+ }
+
+ //
+ // See if one of the agents is ChildHandle
+ //
+ Status = EFI_UNSUPPORTED;
+ for (Index = 0; Index < EntryCount; Index++) {
+ if (OpenInfoBuffer[Index].ControllerHandle == ChildHandle &&
+ OpenInfoBuffer[Index].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) {
+ Status = EFI_SUCCESS;
+ }
+ }
+ gBS->FreePool (OpenInfoBuffer);
+ return Status;
+}
diff --git a/EDK/Foundation/Library/Dxe/EfiDriverLib/EfiGetConfigTable.c b/EDK/Foundation/Library/Dxe/EfiDriverLib/EfiGetConfigTable.c
new file mode 100644
index 0000000..619f1b2
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/EfiDriverLib/EfiGetConfigTable.c
@@ -0,0 +1,61 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiGetConfigTable.c
+
+Abstract:
+
+ Light weight lib to support EFI drivers.
+
+--*/
+
+#include "Tiano.h"
+#include "EfiDriverLib.h"
+
+EFI_STATUS
+EfiLibGetSystemConfigurationTable (
+ IN EFI_GUID *TableGuid,
+ IN OUT VOID **Table
+ )
+/*++
+
+Routine Description:
+
+ Get table from configuration table by name
+
+Arguments:
+
+ TableGuid - Table name to search
+
+ Table - Pointer to the table caller wants
+
+Returns:
+
+ EFI_NOT_FOUND - Not found the table
+
+ EFI_SUCCESS - Found the table
+
+--*/
+{
+ UINTN Index;
+
+ *Table = NULL;
+ for (Index = 0; Index < gST->NumberOfTableEntries; Index++) {
+ if (EfiCompareGuid (TableGuid, &(gST->ConfigurationTable[Index].VendorGuid))) {
+ *Table = gST->ConfigurationTable[Index].VendorTable;
+ return EFI_SUCCESS;
+ }
+ }
+
+ return EFI_NOT_FOUND;
+}
diff --git a/EDK/Foundation/Library/Dxe/EfiDriverLib/EfiLibAllocate.c b/EDK/Foundation/Library/Dxe/EfiDriverLib/EfiLibAllocate.c
new file mode 100644
index 0000000..373d2df
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/EfiDriverLib/EfiLibAllocate.c
@@ -0,0 +1,233 @@
+/*++
+
+Copyright (c) 2004 - 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiLibAllocate.c
+
+Abstract:
+
+ Support routines for memory allocation routines for use with drivers.
+
+--*/
+
+#include "Tiano.h"
+#include "EfiDriverLib.h"
+
+VOID *
+EfiLibAllocatePool (
+ IN UINTN AllocationSize
+ )
+/*++
+
+Routine Description:
+
+ Allocate BootServicesData pool.
+
+Arguments:
+
+ AllocationSize - The size to allocate
+
+Returns:
+
+ Pointer of the buffer allocated.
+
+--*/
+{
+ VOID *Memory;
+
+ Memory = NULL;
+ gBS->AllocatePool (EfiBootServicesData, AllocationSize, &Memory);
+ return Memory;
+}
+
+VOID *
+EfiLibAllocateRuntimePool (
+ IN UINTN AllocationSize
+ )
+/*++
+
+Routine Description:
+
+ Allocate RuntimeServicesData pool.
+
+Arguments:
+
+ AllocationSize - The size to allocate
+
+Returns:
+
+ Pointer of the buffer allocated.
+
+--*/
+{
+ VOID *Memory;
+
+ Memory = NULL;
+ gBS->AllocatePool (EfiRuntimeServicesData, AllocationSize, &Memory);
+ return Memory;
+}
+
+VOID *
+EfiLibAllocateZeroPool (
+ IN UINTN AllocationSize
+ )
+/*++
+
+Routine Description:
+
+ Allocate BootServicesData pool and zero it.
+
+Arguments:
+
+ AllocationSize - The size to allocate
+
+Returns:
+
+ Pointer of the buffer allocated.
+
+--*/
+{
+ VOID *Memory;
+
+ Memory = EfiLibAllocatePool (AllocationSize);
+ if (Memory != NULL) {
+ gBS->SetMem (Memory, AllocationSize, 0);
+ }
+
+ return Memory;
+}
+
+VOID *
+EfiLibAllocateRuntimeZeroPool (
+ IN UINTN AllocationSize
+ )
+/*++
+
+Routine Description:
+
+ Allocate RuntimeServicesData pool and zero it.
+
+Arguments:
+
+ AllocationSize - The size to allocate
+
+Returns:
+
+ Pointer of the buffer allocated.
+
+--*/
+{
+ VOID *Memory;
+
+ Memory = EfiLibAllocateRuntimePool (AllocationSize);
+ if (Memory != NULL) {
+ gBS->SetMem (Memory, AllocationSize, 0);
+ }
+
+ return Memory;
+}
+
+VOID *
+EfiLibAllocateCopyPool (
+ IN UINTN AllocationSize,
+ IN VOID *Buffer
+ )
+/*++
+
+Routine Description:
+
+ Allocate BootServicesData pool and use a buffer provided by
+ caller to fill it.
+
+Arguments:
+
+ AllocationSize - The size to allocate
+
+ Buffer - Buffer that will be filled into the buffer allocated
+
+Returns:
+
+ Pointer of the buffer allocated.
+
+--*/
+{
+ VOID *Memory;
+
+ Memory = NULL;
+ gBS->AllocatePool (EfiBootServicesData, AllocationSize, &Memory);
+ if (Memory != NULL) {
+ gBS->CopyMem (Memory, Buffer, AllocationSize);
+ }
+
+ return Memory;
+}
+
+VOID *
+EfiLibAllocateRuntimeCopyPool (
+ IN UINTN AllocationSize,
+ IN VOID *Buffer
+ )
+/*++
+
+Routine Description:
+
+ Allocate RuntimeServicesData pool and use a buffer provided by
+ caller to fill it.
+
+Arguments:
+
+ AllocationSize - The size to allocate
+
+ Buffer - Buffer that will be filled into the buffer allocated
+
+Returns:
+
+ Pointer of the buffer allocated.
+
+--*/
+{
+ VOID *Memory;
+
+ Memory = NULL;
+ gBS->AllocatePool (EfiRuntimeServicesData, AllocationSize, &Memory);
+ if (Memory != NULL) {
+ gBS->CopyMem (Memory, Buffer, AllocationSize);
+ }
+
+ return Memory;
+}
+
+
+VOID
+EfiLibSafeFreePool (
+ IN VOID *Buffer
+ )
+/*++
+
+Routine Description:
+
+ Free pool safely (without setting back Buffer to NULL).
+
+Arguments:
+
+ Buffer - The allocated pool entry to free
+
+Returns:
+
+ Pointer of the buffer allocated.
+
+--*/
+{
+ if (Buffer != NULL) {
+ gBS->FreePool (Buffer);
+ }
+} \ No newline at end of file
diff --git a/EDK/Foundation/Library/Dxe/EfiDriverLib/Event.c b/EDK/Foundation/Library/Dxe/EfiDriverLib/Event.c
new file mode 100644
index 0000000..c341d82
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/EfiDriverLib/Event.c
@@ -0,0 +1,371 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Event.c
+
+Abstract:
+
+ Support for Event lib fucntions.
+
+--*/
+
+#include "Tiano.h"
+#include "EfiDriverLib.h"
+
+EFI_EVENT
+EfiLibCreateProtocolNotifyEvent (
+ IN EFI_GUID *ProtocolGuid,
+ IN EFI_TPL NotifyTpl,
+ IN EFI_EVENT_NOTIFY NotifyFunction,
+ IN VOID *NotifyContext,
+ OUT VOID **Registration
+ )
+/*++
+
+Routine Description:
+
+ Create a protocol notification event and return it.
+
+Arguments:
+
+ ProtocolGuid - Protocol to register notification event on.
+
+ NotifyTpl - Maximum TPL to single the NotifyFunction.
+
+ NotifyFunction - EFI notification routine.
+
+ NotifyContext - Context passed into Event when it is created.
+
+ Registration - Registration key returned from RegisterProtocolNotify().
+
+Returns:
+
+ The EFI_EVENT that has been registered to be signaled when a ProtocolGuid
+ is added to the system.
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_EVENT Event;
+
+ //
+ // Create the event
+ //
+
+ Status = gBS->CreateEvent (
+ EFI_EVENT_NOTIFY_SIGNAL,
+ NotifyTpl,
+ NotifyFunction,
+ NotifyContext,
+ &Event
+ );
+ ASSERT (!EFI_ERROR (Status));
+
+ //
+ // Register for protocol notifactions on this event
+ //
+
+ Status = gBS->RegisterProtocolNotify (
+ ProtocolGuid,
+ Event,
+ Registration
+ );
+
+ ASSERT (!EFI_ERROR (Status));
+
+ //
+ // Kick the event so we will perform an initial pass of
+ // current installed drivers
+ //
+
+ gBS->SignalEvent (Event);
+ return Event;
+}
+
+EFI_STATUS
+EfiLibNamedEventListen (
+ IN EFI_GUID * Name,
+ IN EFI_TPL NotifyTpl,
+ IN EFI_EVENT_NOTIFY NotifyFunction,
+ IN VOID *NotifyContext
+ )
+/*++
+
+Routine Description:
+ Listenes to signals on the name.
+ EfiLibNamedEventSignal() signals the event.
+
+ NOTE: For now, the named listening/signalling is implemented
+ on a protocol interface being installed and uninstalled.
+ In the future, this maybe implemented based on a dedicated mechanism.
+
+Arguments:
+ Name - Name to register the listener on.
+ NotifyTpl - Maximum TPL to singnal the NotifyFunction.
+ NotifyFunction - The listener routine.
+ NotifyContext - Context passed into the listener routine.
+
+Returns:
+ EFI_SUCCESS if successful.
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_EVENT Event;
+ VOID *RegistrationLocal;
+
+ //
+ // Create event
+ //
+ Status = gBS->CreateEvent (
+ EFI_EVENT_NOTIFY_SIGNAL,
+ NotifyTpl,
+ NotifyFunction,
+ NotifyContext,
+ &Event
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ Status = gBS->RegisterProtocolNotify (
+ Name,
+ Event,
+ &RegistrationLocal
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EfiLibNamedEventSignal (
+ IN EFI_GUID *Name
+ )
+/*++
+
+Routine Description:
+ Signals a named event. All registered listeners will run.
+ The listeners should register using EfiLibNamedEventListen() function.
+
+ NOTE: For now, the named listening/signalling is implemented
+ on a protocol interface being installed and uninstalled.
+ In the future, this maybe implemented based on a dedicated mechanism.
+
+Arguments:
+ Name - Name to perform the signaling on. The name is a GUID.
+
+Returns:
+ EFI_SUCCESS if successfull.
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_HANDLE Handle;
+
+ Handle = NULL;
+ Status = gBS->InstallProtocolInterface (
+ &Handle,
+ Name,
+ EFI_NATIVE_INTERFACE,
+ NULL
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ Status = gBS->UninstallProtocolInterface (
+ Handle,
+ Name,
+ NULL
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ return EFI_SUCCESS;
+}
+
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+
+static
+VOID
+EFIAPI
+EventNotifySignalAllNullEvent (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+ //
+ // This null event is a size efficent way to enusre that
+ // EFI_EVENT_NOTIFY_SIGNAL_ALL is error checked correctly.
+ // EFI_EVENT_NOTIFY_SIGNAL_ALL is now mapped into
+ // CreateEventEx() and this function is used to make the
+ // old error checking in CreateEvent() for Tiano extensions
+ // function.
+ //
+ return;
+}
+
+#endif
+
+EFI_STATUS
+EFIAPI
+EfiCreateEventLegacyBoot (
+ IN EFI_TPL NotifyTpl,
+ IN EFI_EVENT_NOTIFY NotifyFunction,
+ IN VOID *NotifyContext,
+ OUT EFI_EVENT *LegacyBootEvent
+ )
+/*++
+
+Routine Description:
+ Create a Legacy Boot Event.
+ Tiano extended the CreateEvent Type enum to add a legacy boot event type.
+ This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was
+ added and now it's possible to not voilate the UEFI specification by
+ declaring a GUID for the legacy boot event class. This library supports
+ the R8.5/EFI 1.10 form and R8.6/UEFI 2.0 form and allows common code to
+ work both ways.
+
+Arguments:
+ LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex)
+
+Returns:
+ EFI_SUCCESS Event was created.
+ Other Event was not created.
+
+--*/
+{
+ EFI_STATUS Status;
+ UINT32 EventType;
+ EFI_EVENT_NOTIFY WorkerNotifyFunction;
+
+#if (EFI_SPECIFICATION_VERSION < 0x00020000)
+
+ if (NotifyFunction == NULL) {
+ EventType = EFI_EVENT_SIGNAL_LEGACY_BOOT | EFI_EVENT_NOTIFY_SIGNAL_ALL;
+ } else {
+ EventType = EFI_EVENT_SIGNAL_LEGACY_BOOT;
+ }
+ WorkerNotifyFunction = NotifyFunction;
+
+ //
+ // prior to UEFI 2.0 use Tiano extension to EFI
+ //
+ Status = gBS->CreateEvent (
+ EventType,
+ NotifyTpl,
+ WorkerNotifyFunction,
+ NotifyContext,
+ LegacyBootEvent
+ );
+#else
+
+ EventType = EFI_EVENT_NOTIFY_SIGNAL;
+ if (NotifyFunction == NULL) {
+ //
+ // CreatEventEx will check NotifyFunction is NULL or not
+ //
+ WorkerNotifyFunction = EventNotifySignalAllNullEvent;
+ } else {
+ WorkerNotifyFunction = NotifyFunction;
+ }
+
+ //
+ // For UEFI 2.0 and the future use an Event Group
+ //
+ Status = gBS->CreateEventEx (
+ EventType,
+ NotifyTpl,
+ WorkerNotifyFunction,
+ NotifyContext,
+ &gEfiEventLegacyBootGuid,
+ LegacyBootEvent
+ );
+#endif
+ return Status;
+}
+
+EFI_STATUS
+EFIAPI
+EfiCreateEventReadyToBoot (
+ IN EFI_TPL NotifyTpl,
+ IN EFI_EVENT_NOTIFY NotifyFunction,
+ IN VOID *NotifyContext,
+ OUT EFI_EVENT *ReadyToBootEvent
+ )
+/*++
+
+Routine Description:
+ Create a Read to Boot Event.
+
+ Tiano extended the CreateEvent Type enum to add a ready to boot event type.
+ This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was
+ added and now it's possible to not voilate the UEFI specification and use
+ the ready to boot event class defined in UEFI 2.0. This library supports
+ the R8.5/EFI 1.10 form and R8.6/UEFI 2.0 form and allows common code to
+ work both ways.
+
+Arguments:
+ @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex)
+
+Return:
+ EFI_SUCCESS - Event was created.
+ Other - Event was not created.
+
+--*/
+{
+ EFI_STATUS Status;
+ UINT32 EventType;
+ EFI_EVENT_NOTIFY WorkerNotifyFunction;
+
+#if (EFI_SPECIFICATION_VERSION < 0x00020000)
+
+ if (NotifyFunction == NULL) {
+ EventType = EFI_EVENT_SIGNAL_READY_TO_BOOT | EFI_EVENT_NOTIFY_SIGNAL_ALL;
+ } else {
+ EventType = EFI_EVENT_SIGNAL_READY_TO_BOOT;
+ }
+ WorkerNotifyFunction = NotifyFunction;
+
+ //
+ // prior to UEFI 2.0 use Tiano extension to EFI
+ //
+ Status = gBS->CreateEvent (
+ EventType,
+ NotifyTpl,
+ WorkerNotifyFunction,
+ NotifyContext,
+ ReadyToBootEvent
+ );
+#else
+
+ EventType = EFI_EVENT_NOTIFY_SIGNAL;
+ if (NotifyFunction == NULL) {
+ //
+ // CreatEventEx will check NotifyFunction is NULL or not
+ //
+ WorkerNotifyFunction = EventNotifySignalAllNullEvent;
+ } else {
+ WorkerNotifyFunction = NotifyFunction;
+ }
+
+ //
+ // For UEFI 2.0 and the future use an Event Group
+ //
+ Status = gBS->CreateEventEx (
+ EventType,
+ NotifyTpl,
+ WorkerNotifyFunction,
+ NotifyContext,
+ &gEfiEventReadyToBootGuid,
+ ReadyToBootEvent
+ );
+#endif
+ return Status;
+}
diff --git a/EDK/Foundation/Library/Dxe/EfiDriverLib/GetImage.c b/EDK/Foundation/Library/Dxe/EfiDriverLib/GetImage.c
new file mode 100644
index 0000000..20493b3
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/EfiDriverLib/GetImage.c
@@ -0,0 +1,220 @@
+/*++
+
+Copyright (c) 2006 - 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ GetImage.c
+
+Abstract:
+
+ Image data extraction support for common use.
+
+--*/
+
+#include "Tiano.h"
+#include "EfiDriverLib.h"
+#include "EfiImageFormat.h"
+
+#include EFI_PROTOCOL_CONSUMER (LoadedImage)
+
+EFI_STATUS
+GetImageFromFv (
+#if (PI_SPECIFICATION_VERSION < 0x00010000) //;;## ...AMI_OVERRIDE... Support PI1.x
+ IN EFI_FIRMWARE_VOLUME_PROTOCOL *Fv,
+#else
+ IN EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv,
+#endif
+ IN EFI_GUID *NameGuid,
+ IN EFI_SECTION_TYPE SectionType,
+ OUT VOID **Buffer,
+ OUT UINTN *Size
+ )
+{
+ EFI_STATUS Status;
+ EFI_FV_FILETYPE FileType;
+ EFI_FV_FILE_ATTRIBUTES Attributes;
+ UINT32 AuthenticationStatus;
+
+ //
+ // Read desired section content in NameGuid file
+ //
+ *Buffer = NULL;
+ *Size = 0;
+ Status = Fv->ReadSection (
+ Fv,
+ NameGuid,
+ SectionType,
+ 0,
+ Buffer,
+ Size,
+ &AuthenticationStatus
+ );
+
+ if (EFI_ERROR (Status) && (SectionType == EFI_SECTION_TE)) {
+ //
+ // Try reading PE32 section, since the TE section does not exist
+ //
+ *Buffer = NULL;
+ *Size = 0;
+ Status = Fv->ReadSection (
+ Fv,
+ NameGuid,
+ EFI_SECTION_PE32,
+ 0,
+ Buffer,
+ Size,
+ &AuthenticationStatus
+ );
+ }
+
+ if (EFI_ERROR (Status) &&
+ ((SectionType == EFI_SECTION_TE) || (SectionType == EFI_SECTION_PE32))) {
+ //
+ // Try reading raw file, since the desired section does not exist
+ //
+ *Buffer = NULL;
+ *Size = 0;
+ Status = Fv->ReadFile (
+ Fv,
+ NameGuid,
+ Buffer,
+ Size,
+ &FileType,
+ &Attributes,
+ &AuthenticationStatus
+ );
+ }
+
+ return Status;
+}
+
+EFI_STATUS
+GetImage (
+ IN EFI_GUID *NameGuid,
+ IN EFI_SECTION_TYPE SectionType,
+ OUT VOID **Buffer,
+ OUT UINTN *Size
+ )
+{
+ return GetImageEx (NULL, NameGuid, SectionType, Buffer, Size, FALSE);
+}
+
+EFI_STATUS
+GetImageEx (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_GUID *NameGuid,
+ IN EFI_SECTION_TYPE SectionType,
+ OUT VOID **Buffer,
+ OUT UINTN *Size,
+ BOOLEAN WithinImageFv
+ )
+{
+ EFI_STATUS Status;
+ EFI_HANDLE *HandleBuffer;
+ UINTN HandleCount;
+ UINTN Index;
+ EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
+#if (PI_SPECIFICATION_VERSION < 0x00010000) //;;## ...AMI_OVERRIDE... Support PI1.x
+ EFI_FIRMWARE_VOLUME_PROTOCOL *ImageFv;
+ EFI_FIRMWARE_VOLUME_PROTOCOL *Fv;
+#else
+ EFI_FIRMWARE_VOLUME2_PROTOCOL *ImageFv;
+ EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv;
+#endif
+
+ if (ImageHandle == NULL && WithinImageFv) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = EFI_NOT_FOUND;
+ ImageFv = NULL;
+ if (ImageHandle != NULL) {
+ Status = gBS->HandleProtocol (
+ ImageHandle,
+ &gEfiLoadedImageProtocolGuid,
+ (VOID **) &LoadedImage
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ Status = gBS->HandleProtocol (
+ LoadedImage->DeviceHandle,
+ #if (PI_SPECIFICATION_VERSION < 0x00010000)
+ &gEfiFirmwareVolumeProtocolGuid,
+ #else
+ &gEfiFirmwareVolume2ProtocolGuid,
+ #endif
+ (VOID **) &ImageFv
+ );
+ if (!EFI_ERROR (Status)) {
+ Status = GetImageFromFv (ImageFv, NameGuid, SectionType, Buffer, Size);
+ }
+ }
+
+ if (Status == EFI_SUCCESS || WithinImageFv) {
+ return Status;
+ }
+
+ Status = gBS->LocateHandleBuffer (
+ ByProtocol,
+ #if (PI_SPECIFICATION_VERSION < 0x00010000)
+ &gEfiFirmwareVolumeProtocolGuid,
+ #else
+ &gEfiFirmwareVolume2ProtocolGuid,
+ #endif
+ NULL,
+ &HandleCount,
+ &HandleBuffer
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ //
+ // Find desired image in all Fvs
+ //
+ for (Index = 0; Index < HandleCount; ++Index) {
+ Status = gBS->HandleProtocol (
+ HandleBuffer[Index],
+ #if (PI_SPECIFICATION_VERSION < 0x00010000)
+ &gEfiFirmwareVolumeProtocolGuid,
+ #else
+ &gEfiFirmwareVolume2ProtocolGuid,
+ #endif
+ (VOID**)&Fv
+ );
+
+ if (EFI_ERROR (Status)) {
+ gBS->FreePool(HandleBuffer);
+ return Status;
+ }
+
+ if (ImageFv != NULL && Fv == ImageFv) {
+ continue;
+ }
+
+ Status = GetImageFromFv (Fv, NameGuid, SectionType, Buffer, Size);
+
+ if (!EFI_ERROR (Status)) {
+ break;
+ }
+ }
+ gBS->FreePool(HandleBuffer);
+
+ //
+ // Not found image
+ //
+ if (Index == HandleCount) {
+ return EFI_NOT_FOUND;
+ }
+
+ return EFI_SUCCESS;
+}
diff --git a/EDK/Foundation/Library/Dxe/EfiDriverLib/Handle.c b/EDK/Foundation/Library/Dxe/EfiDriverLib/Handle.c
new file mode 100644
index 0000000..b440a10
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/EfiDriverLib/Handle.c
@@ -0,0 +1,176 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Handle.c
+
+Abstract:
+
+ Support for Handle lib fucntions.
+
+--*/
+
+#include "Tiano.h"
+#include "EfiDriverLib.h"
+
+EFI_STATUS
+EfiLibLocateHandleProtocolByProtocols (
+ IN OUT EFI_HANDLE * Handle, OPTIONAL
+ OUT VOID **Interface, OPTIONAL
+ ...
+ )
+/*++
+Routine Description:
+
+ Function locates Protocol and/or Handle on which all Protocols specified
+ as a variable list are installed.
+ It supports continued search. The caller must assure that no handles are added
+ or removed while performing continued search, by e.g., rising the TPL and not
+ calling any handle routines. Otherwise the behavior is undefined.
+
+Arguments:
+
+ Handle - The address of handle to receive the handle on which protocols
+ indicated by the variable list are installed.
+ If points to NULL, all handles are searched. If pointing to a
+ handle returned from previous call, searches starting from next handle.
+ If NULL, the parameter is ignored.
+
+ Interface - The address of a pointer to a protocol interface that will receive
+ the interface indicated by first variable argument.
+ If NULL, the parameter is ignored.
+
+ ... - A variable argument list containing protocol GUIDs. Must end with NULL.
+
+Returns:
+
+ EFI_SUCCESS - All the protocols where found on same handle.
+ EFI_NOT_FOUND - A Handle with all the protocols installed was not found.
+ Other values as may be returned from LocateHandleBuffer() or HandleProtocol().
+
+--*/
+{
+ VA_LIST args;
+ EFI_STATUS Status;
+ EFI_GUID *Protocol;
+ EFI_GUID *ProtocolFirst;
+ EFI_HANDLE *HandleBuffer;
+ UINTN NumberOfHandles;
+ UINTN Idx;
+ VOID *AnInterface;
+
+ AnInterface = NULL;
+ VA_START (args, Interface);
+ ProtocolFirst = VA_ARG (args, EFI_GUID *);
+
+ //
+ // Get list of all handles that support the first protocol.
+ //
+ Status = gBS->LocateHandleBuffer (
+ ByProtocol,
+ ProtocolFirst,
+ NULL,
+ &NumberOfHandles,
+ &HandleBuffer
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ //
+ // Check if this is a countinuation of handle searching.
+ //
+ Idx = 0;
+ if ((Handle != NULL) && (*Handle != NULL)) {
+ //
+ // Leave the Idx just beyond the matching handle.
+ //
+ for (; Idx < NumberOfHandles;) {
+ if (*Handle == HandleBuffer[Idx++]) {
+ break;
+ }
+ }
+ }
+
+ //
+ // Iterate handles testing for presence of remaining protocols.
+ //
+ for (; Idx < NumberOfHandles; Idx++) {
+
+ //
+ // Start with the second protocol, the first one is sure on this handle.
+ //
+ VA_START (args, Interface);
+ VA_ARG (args, EFI_GUID *);
+
+ //
+ // Iterate protocols from the variable list.
+ //
+ while (TRUE) {
+
+ Protocol = VA_ARG (args, EFI_GUID *);
+
+ if (Protocol == NULL) {
+
+ //
+ // If here, the list was iterated successfully
+ // finding each protocol on a single handle.
+ //
+
+ Status = EFI_SUCCESS;
+
+ //
+ // OPTIONAL parameter returning the Handle.
+ //
+ if (Handle != NULL) {
+ *Handle = HandleBuffer[Idx];
+ }
+
+ //
+ // OPTIONAL parameter returning the first rotocol's Interface.
+ //
+ if (Interface != NULL) {
+ Status = gBS->HandleProtocol (
+ HandleBuffer[Idx],
+ ProtocolFirst,
+ Interface
+ );
+ }
+
+ goto lbl_out;
+ }
+
+ Status = gBS->HandleProtocol (
+ HandleBuffer[Idx],
+ Protocol,
+ &AnInterface
+ );
+ if (EFI_ERROR (Status)) {
+
+ //
+ // This handle does not have the iterated protocol.
+ //
+ break;
+ }
+ }
+
+ }
+
+ //
+ // If here, no handle that bears all the protocols was found.
+ //
+ Status = EFI_NOT_FOUND;
+
+lbl_out:
+ gBS->FreePool (HandleBuffer);
+ return Status;
+}
diff --git a/EDK/Foundation/Library/Dxe/EfiDriverLib/HobLib.inf b/EDK/Foundation/Library/Dxe/EfiDriverLib/HobLib.inf
new file mode 100644
index 0000000..aecf5b7
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/EfiDriverLib/HobLib.inf
@@ -0,0 +1,47 @@
+#/*++
+#
+# Copyright (c) 2004, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# HobLib.inf
+#
+# Abstract:
+#
+# Component description file.
+#
+#--*/
+
+[defines]
+BASE_NAME = HobLib
+COMPONENT_TYPE = LIBRARY
+
+[sources.common]
+ Hob.c
+
+
+[includes.common]
+ $(EDK_SOURCE)\Foundation
+ $(EDK_SOURCE)\Foundation\Framework
+ $(EDK_SOURCE)\Foundation\Efi
+ .
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+
+[libraries.common]
+ EdkGuidLib
+ EdkFrameworkGuidLib
+
+[nmake.common]
+ C_STD_INCLUDE=
diff --git a/EDK/Foundation/Library/Dxe/EfiDriverLib/IA32/PerformancePrimitives.c b/EDK/Foundation/Library/Dxe/EfiDriverLib/IA32/PerformancePrimitives.c
new file mode 100644
index 0000000..d3a437c
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/EfiDriverLib/IA32/PerformancePrimitives.c
@@ -0,0 +1,47 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PerformancePrimitives.c
+
+Abstract:
+
+ Support for Performance library
+
+--*/
+
+#include "TianoCommon.h"
+#include "CpuIA32.h"
+
+EFI_STATUS
+GetTimerValue (
+ OUT UINT64 *TimerValue
+ )
+/*++
+
+Routine Description:
+
+ Set TimerValue with current tick.
+
+Arguments:
+
+ TimerValue - Timer value to be set
+
+Returns:
+
+ EFI_SUCCESS - TimerValue is set.
+
+--*/
+{
+ *TimerValue = EfiReadTsc ();
+ return EFI_SUCCESS;
+}
diff --git a/EDK/Foundation/Library/Dxe/EfiDriverLib/Ipf/PerformancePrimitives.s b/EDK/Foundation/Library/Dxe/EfiDriverLib/Ipf/PerformancePrimitives.s
new file mode 100644
index 0000000..5aeb886
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/EfiDriverLib/Ipf/PerformancePrimitives.s
@@ -0,0 +1,61 @@
+//++
+// Copyright (c) 2004, Intel Corporation
+// All rights reserved. This program and the accompanying materials
+// are licensed and made available under the terms and conditions of the BSD License
+// which accompanies this distribution. The full text of the license may be found at
+// http://opensource.org/licenses/bsd-license.php
+//
+// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+//
+// Module Name:
+//
+// PerformancePrimitives.s
+//
+// Abstract:
+//
+//
+// Revision History:
+//
+//--
+
+.file "PerformancePrimitives.s"
+
+#include "IpfMacro.i"
+
+//-----------------------------------------------------------------------------
+//++
+// GetTimerValue
+//
+// Implementation of CPU-based time service
+//
+// On Entry :
+// EFI_STATUS
+// GetTimerValue (
+// OUT UINT64 *TimerValue
+// )
+//
+// Return Value:
+// r8 = Status
+// r9 = 0
+// r10 = 0
+// r11 = 0
+//
+// As per static calling conventions.
+//
+//--
+//---------------------------------------------------------------------------
+PROCEDURE_ENTRY (GetTimerValue)
+
+ NESTED_SETUP (1,8,0,0)
+ mov r8 = ar.itc;;
+ st8 [r32]= r8
+ mov r8 = r0
+ mov r9 = r0
+ mov r10 = r0
+ mov r11 = r0
+ NESTED_RETURN
+
+PROCEDURE_EXIT (GetTimerValue)
+//---------------------------------------------------------------------------
+
diff --git a/EDK/Foundation/Library/Dxe/EfiDriverLib/LibGlobalDs.c b/EDK/Foundation/Library/Dxe/EfiDriverLib/LibGlobalDs.c
new file mode 100644
index 0000000..2edd766
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/EfiDriverLib/LibGlobalDs.c
@@ -0,0 +1,32 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ LibGlobalDs.c
+
+Abstract:
+
+ Globals used in EFI Driver Lib. They are initialized in EfiDriverLib.c.
+ Each seperatly linked module has it's own copy of these globals.
+
+ gBS - Boot Services table pointer
+ gRT - Runt Time services table pointer
+ gST - System Table pointer
+
+ gErrorLevel - Debug error level.
+
+--*/
+
+#include "Tiano.h"
+#include "EfiDriverLib.h"
+
+EFI_DXE_SERVICES *gDS = NULL;
diff --git a/EDK/Foundation/Library/Dxe/EfiDriverLib/LibGlobalErrorLevel.c b/EDK/Foundation/Library/Dxe/EfiDriverLib/LibGlobalErrorLevel.c
new file mode 100644
index 0000000..82bea32
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/EfiDriverLib/LibGlobalErrorLevel.c
@@ -0,0 +1,34 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ LibGlobalErrorLevel.c
+
+Abstract:
+
+ Globals used in EFI Driver Lib. They are initialized in EfiDriverLib.c.
+ Each seperatly linked module has it's own copy of these globals.
+
+ gBS - Boot Services table pointer
+ gRT - Runt Time services table pointer
+ gST - System Table pointer
+
+ gErrorLevel - Debug error level.
+
+--*/
+
+#include "Tiano.h"
+#include "EfiDriverLib.h"
+#include EFI_GUID_DEFINITION (StatusCodeCallerId)
+#include EFI_GUID_DEFINITION (StatusCodeDataTypeId)
+
+UINTN gErrorLevel = EFI_DBUG_MASK | EFI_D_LOAD | EFI_D_INFO; //;;## ...AMI_OVERRIDE... Aptio not support gEfiDebugMaskPpiGuid.
diff --git a/EDK/Foundation/Library/Dxe/EfiDriverLib/LibGlobalSt.c b/EDK/Foundation/Library/Dxe/EfiDriverLib/LibGlobalSt.c
new file mode 100644
index 0000000..cd866ba
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/EfiDriverLib/LibGlobalSt.c
@@ -0,0 +1,34 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ LibGlobalSt.c
+
+Abstract:
+
+ Globals used in EFI Driver Lib. They are initialized in EfiDriverLib.c.
+ Each seperatly linked module has it's own copy of these globals.
+
+ gBS - Boot Services table pointer
+ gRT - Runt Time services table pointer
+ gST - System Table pointer
+
+ gErrorLevel - Debug error level.
+
+--*/
+
+#include "Tiano.h"
+#include "EfiDriverLib.h"
+
+EFI_SYSTEM_TABLE *gST = NULL;
+EFI_BOOT_SERVICES *gBS = NULL;
+EFI_RUNTIME_SERVICES *gRT = NULL;
diff --git a/EDK/Foundation/Library/Dxe/EfiDriverLib/Lock.c b/EDK/Foundation/Library/Dxe/EfiDriverLib/Lock.c
new file mode 100644
index 0000000..f9d1006
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/EfiDriverLib/Lock.c
@@ -0,0 +1,159 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Lock.c
+
+Abstract:
+
+ Support for locking lib services.
+
+--*/
+
+#include "Tiano.h"
+#include "EfiDriverLib.h"
+
+VOID
+EfiInitializeLock (
+ IN OUT EFI_LOCK *Lock,
+ IN EFI_TPL Priority
+ )
+/*++
+
+Routine Description:
+
+ Initialize a basic mutual exclusion lock. Each lock
+ provides mutual exclusion access at it's task priority
+ level. Since there is no-premption (at any TPL) or
+ multiprocessor support, acquiring the lock only consists
+ of raising to the locks TPL.
+
+ Note on a check build ASSERT()s are used to ensure proper
+ lock usage.
+
+Arguments:
+
+ Lock - The EFI_LOCK structure to initialize
+
+ Priority - The task priority level of the lock
+
+
+Returns:
+
+ An initialized Efi Lock structure.
+
+--*/
+{
+ Lock->Tpl = Priority;
+ Lock->OwnerTpl = 0;
+ Lock->Lock = 0;
+}
+
+EFI_STATUS
+EfiAcquireLockOrFail (
+ IN EFI_LOCK *Lock
+ )
+/*++
+
+Routine Description:
+
+ Initialize a basic mutual exclusion lock. Each lock
+ provides mutual exclusion access at it's task priority
+ level. Since there is no-premption (at any TPL) or
+ multiprocessor support, acquiring the lock only consists
+ of raising to the locks TPL.
+
+Arguments:
+
+ Lock - The EFI_LOCK structure to initialize
+
+Returns:
+
+ EFI_SUCCESS - Lock Owned.
+ EFI_ACCESS_DENIED - Reentrant Lock Acquisition, Lock not Owned.
+
+--*/
+{
+ if (Lock->Lock != 0) {
+ //
+ // Lock is already owned, so bail out
+ //
+ return EFI_ACCESS_DENIED;
+ }
+
+ Lock->OwnerTpl = gBS->RaiseTPL (Lock->Tpl);
+
+ Lock->Lock += 1;
+ return EFI_SUCCESS;
+}
+
+VOID
+EfiAcquireLock (
+ IN EFI_LOCK *Lock
+ )
+/*++
+
+Routine Description:
+
+ Raising to the task priority level of the mutual exclusion
+ lock, and then acquires ownership of the lock.
+
+Arguments:
+
+ Lock - The lock to acquire
+
+Returns:
+
+ Lock owned
+
+--*/
+{
+ EFI_STATUS Status;
+
+ Status = EfiAcquireLockOrFail (Lock);
+
+ //
+ // Lock was already locked.
+ //
+ ASSERT_EFI_ERROR (Status);
+}
+
+VOID
+EfiReleaseLock (
+ IN EFI_LOCK *Lock
+ )
+/*++
+
+Routine Description:
+
+ Releases ownership of the mutual exclusion lock, and
+ restores the previous task priority level.
+
+Arguments:
+
+ Lock - The lock to release
+
+Returns:
+
+ Lock unowned
+
+--*/
+{
+ EFI_TPL Tpl;
+
+ Tpl = Lock->OwnerTpl;
+
+ ASSERT (Lock->Lock == 1);
+ Lock->Lock -= 1;
+
+ gBS->RestoreTPL (Tpl);
+}
diff --git a/EDK/Foundation/Library/Dxe/EfiDriverLib/Perf.c b/EDK/Foundation/Library/Dxe/EfiDriverLib/Perf.c
new file mode 100644
index 0000000..9bed854
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/EfiDriverLib/Perf.c
@@ -0,0 +1,946 @@
+/*++
+
+Copyright (c) 2004 - 2012, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Perf.c
+
+Abstract:
+
+ Support library for DXE Firmware Performance logging.
+
+--*/
+
+#include "Tiano.h"
+
+#include EFI_PROTOCOL_DEFINITION (FirmwarePerformance)
+#include EFI_GUID_DEFINITION (PeiPerformanceHob)
+#include EFI_PROTOCOL_DEFINITION (LoadedImage)
+#include EFI_PROTOCOL_DEFINITION (DriverBinding)
+#include EFI_GUID_DEFINITION (Hob)
+
+#include "EfiDriverLib.h"
+#include "EfiHobLib.h"
+#include "EfiImage.h"
+#include "EfiCommonLib.h"
+#include "CpuIA32.h"
+
+EFI_GUID gNullGuid = EFI_NULL_GUID;
+FIRMWARE_PERFORMANCE_PROTOCOL *FirmwarePerformance;
+
+static UINT32 *mPerformancePointer;
+static UINT32 mPerformanceLength;
+UINT16 BdsAttemptNumber = 0;
+
+#define LOCAL_APIC_BASE 0xfee00000
+#define APIC_ID_REGISTER 0x20
+#define MSR_EXT_XAPIC_LOGICAL_APIC_ID 0x802
+#define MSR_XAPIC_BASE 0x1B
+#define MSR_XAPIC_BASE_MASK 0x0c00
+#define MAX_NON_TURBO_RATIO_OFFSET 8
+#define MAX_NON_TURBO_RATIO_MASK 0xff
+#define PLATFORM_INFO_MSR 0xce
+
+EFI_STATUS
+GetTimerValue (
+ OUT UINT64 *TimerValue
+ );
+
+EFI_STATUS
+GetPeiFirmwarePerformanceHob (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ );
+
+UINT64 GetTimeInNanoSec (
+ UINT64 Ticker
+ )
+/*++
+
+Routine Description:
+
+ Internal routine to convert TSC value into nano second value
+
+Arguments:
+
+ Ticker - OPTIONAL. TSC value supplied by caller function
+
+Returns:
+
+ UINT64 - returns calculated timer value
+
+--*/
+{
+ UINT64 Tick, pi;
+ UINT8 Ratio;
+
+ if(Ticker != 0){
+ Tick = Ticker;
+ } else {
+ GetTimerValue (&Tick);
+ }
+
+ pi = EfiReadMsr(PLATFORM_INFO_MSR);
+ Ratio = (UINT8)( ((UINT32)(UINTN)RShiftU64(pi, MAX_NON_TURBO_RATIO_OFFSET)) & MAX_NON_TURBO_RATIO_MASK);
+
+ return (UINT64)DivU64x32((UINT64)MultU64x32(Tick, 10), (UINTN)(Ratio), NULL);
+}
+
+UINT32 GetApicId (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Internal routine to retrieve current APIC Id
+
+Arguments:
+
+ None
+
+Returns:
+
+ UINT32 - returns Apic Id value
+
+--*/
+{
+ BOOLEAN x2ApicEnabled;
+ UINT32 ApicId;
+
+ x2ApicEnabled = (BOOLEAN)(((EfiReadMsr (MSR_XAPIC_BASE)) & (MSR_XAPIC_BASE_MASK)) == MSR_XAPIC_BASE_MASK);
+ if (x2ApicEnabled) {
+ ApicId = (UINT32) EfiReadMsr (MSR_EXT_XAPIC_LOGICAL_APIC_ID);
+ } else {
+ ApicId = (UINT8) (*(volatile UINT32 *) (UINTN) (LOCAL_APIC_BASE + APIC_ID_REGISTER) >> 24);
+ }
+
+ return ApicId;
+}
+
+STATIC
+VOID
+GetShortPdbFileName (
+ CHAR8 *PdbFileName,
+ CHAR8 *GaugeString
+ )
+/*++
+
+Routine Description:
+
+ Shotens PDB path name
+
+Arguments:
+
+ PdbFileName - PdbFileName
+
+Returns:
+ GaugeString - GaugeString
+
+--*/
+{
+ UINTN Index;
+ UINTN Index1;
+ UINTN StartIndex;
+ UINTN EndIndex;
+
+ if (PdbFileName == NULL) {
+ EfiAsciiStrCpy (GaugeString, " ");
+ } else {
+ StartIndex = 0;
+ for (EndIndex = 0; PdbFileName[EndIndex] != 0; EndIndex++)
+ ;
+
+ for (Index = 0; PdbFileName[Index] != 0; Index++) {
+ if (PdbFileName[Index] == '\\') {
+ StartIndex = Index + 1;
+ }
+
+ if (PdbFileName[Index] == '.') {
+ EndIndex = Index;
+ }
+ }
+
+ Index1 = 0;
+ for (Index = StartIndex; Index < EndIndex; Index++) {
+ GaugeString[Index1] = PdbFileName[Index];
+ Index1++;
+ if (Index1 == STRING_EVENT_RECORD_NAME_LENGTH - 1) {
+ break;
+ }
+ }
+
+ GaugeString[Index1] = 0;
+ }
+
+ return ;
+}
+
+STATIC
+CHAR8 *
+GetPdbPath (
+ VOID *ImageBase
+ )
+/*++
+
+Routine Description:
+
+ Locate PDB path name in PE image
+
+Arguments:
+
+ ImageBase - base of PE to search
+
+Returns:
+
+ Pointer into image at offset of PDB file name if PDB file name is found,
+ Otherwise a pointer to an empty string.
+
+--*/
+{
+ CHAR8 *PdbPath;
+ UINT32 DirCount;
+ EFI_IMAGE_DOS_HEADER *DosHdr;
+ EFI_IMAGE_NT_HEADERS *NtHdr;
+ UINT16 Magic;
+ EFI_IMAGE_OPTIONAL_HEADER32 *OptionalHdr32;
+ EFI_IMAGE_OPTIONAL_HEADER64 *OptionalHdr64;
+ EFI_IMAGE_DATA_DIRECTORY *DirectoryEntry;
+ EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *DebugEntry;
+ VOID *CodeViewEntryPointer;
+
+ CodeViewEntryPointer = NULL;
+ PdbPath = NULL;
+ DosHdr = ImageBase;
+ if (DosHdr && DosHdr->e_magic == EFI_IMAGE_DOS_SIGNATURE) {
+ NtHdr = (EFI_IMAGE_NT_HEADERS *) ((UINT8 *) DosHdr + DosHdr->e_lfanew);
+ //
+ // NOTE: We use Machine to identify PE32/PE32+, instead of Magic.
+ // It is for backward-compatibility consideration, because
+ // some system will generate PE32+ image with PE32 Magic.
+ //
+ if (NtHdr->FileHeader.Machine == EFI_IMAGE_MACHINE_IA32) {
+ Magic = EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC;
+ } else if (NtHdr->FileHeader.Machine == EFI_IMAGE_MACHINE_IA64) {
+ Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC;
+ } else if (NtHdr->FileHeader.Machine == EFI_IMAGE_MACHINE_X64) {
+ Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC;
+ } else {
+ Magic = NtHdr->OptionalHeader.Magic;
+ }
+ if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
+ OptionalHdr32 = (VOID *) &NtHdr->OptionalHeader;
+ DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *) &(OptionalHdr32->DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]);
+ } else {
+ OptionalHdr64 = (VOID *) &NtHdr->OptionalHeader;
+ DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *) &(OptionalHdr64->DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]);
+ }
+
+ if (DirectoryEntry->VirtualAddress != 0) {
+ for (DirCount = 0;
+ (DirCount < DirectoryEntry->Size / sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY)) && CodeViewEntryPointer == NULL;
+ DirCount++
+ ) {
+ DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *) (DirectoryEntry->VirtualAddress + (UINTN) ImageBase + DirCount * sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY));
+ if (DebugEntry->Type == EFI_IMAGE_DEBUG_TYPE_CODEVIEW) {
+ CodeViewEntryPointer = (VOID *) ((UINTN) DebugEntry->RVA + (UINTN) ImageBase);
+ switch (*(UINT32 *) CodeViewEntryPointer) {
+ case CODEVIEW_SIGNATURE_NB10:
+ PdbPath = (CHAR8 *) CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY);
+ break;
+
+ case CODEVIEW_SIGNATURE_RSDS:
+ PdbPath = (CHAR8 *) CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY);
+ break;
+
+ default:
+ break;
+ }
+ }
+ }
+ }
+ }
+
+ return PdbPath;
+}
+
+STATIC
+VOID
+GetNameFromHandle (
+ IN EFI_HANDLE Handle,
+ OUT CHAR8 *GaugeString
+ )
+/*++
+
+Routine Description:
+
+ retrieves PDB path name from Handle
+
+Arguments:
+
+ Handle - Handle of image
+
+Returns:
+
+ Pointer to PDB Filename
+--*/
+{
+ EFI_STATUS Status;
+ EFI_LOADED_IMAGE_PROTOCOL *Image;
+ CHAR8 *PdbFileName;
+ EFI_DRIVER_BINDING_PROTOCOL *DriverBinding;
+
+ EfiAsciiStrCpy (GaugeString, " ");
+
+ //
+ // Get handle name from image protocol
+ //
+ Status = gBS->HandleProtocol (
+ Handle,
+ &gEfiLoadedImageProtocolGuid,
+ (VOID**)&Image
+ );
+
+ if (EFI_ERROR (Status)) {
+ Status = gBS->OpenProtocol (
+ Handle,
+ &gEfiDriverBindingProtocolGuid,
+ (VOID **) &DriverBinding,
+ NULL,
+ NULL,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
+ if (EFI_ERROR (Status)) {
+ return ;
+ }
+ //
+ // Get handle name from image protocol
+ //
+ Status = gBS->HandleProtocol (
+ DriverBinding->ImageHandle,
+ &gEfiLoadedImageProtocolGuid,
+ (VOID**)&Image
+ );
+ }
+
+ PdbFileName = GetPdbPath (Image->ImageBase);
+
+ if (PdbFileName != NULL) {
+ GetShortPdbFileName (PdbFileName, GaugeString);
+ }
+
+ return ;
+}
+
+EFI_GUID *
+GetGuidFromHandle (
+ EFI_HANDLE Handle
+ )
+/*++
+
+Routine Description:
+
+ retrieves GUID name from Handle
+
+Arguments:
+
+ Handle - Handle of image
+
+Returns:
+
+ Pointer to GUID name
+--*/
+{
+ EFI_STATUS Status;
+ EFI_LOADED_IMAGE_PROTOCOL *pImage;
+ MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFilePath;
+
+ if (Handle!=NULL){
+ Status = gBS->HandleProtocol(Handle,
+ &gEfiLoadedImageProtocolGuid,
+ &pImage
+ );
+ if (!EFI_ERROR(Status)){
+ if (pImage->FilePath->Type==MEDIA_DEVICE_PATH && pImage->FilePath->SubType==MEDIA_FV_FILEPATH_DP) {
+ //
+ // Determine GUID associated with module logging performance
+ //
+ FvFilePath = (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH*)pImage->FilePath;
+
+ return &FvFilePath->NameGuid;
+ }
+ }
+ }
+
+ return NULL;
+}
+
+EFI_STATUS
+LocatePerformanceProtocol(
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ locates Performance protocol interface
+
+Arguments:
+
+ None
+
+Returns:
+ EFI_STATUS
+
+--*/
+{
+ EFI_STATUS Status;
+
+ FirmwarePerformance = NULL;
+ Status = gBS->LocateProtocol (&gFirmwarePerformanceProtocolGuid, NULL, (VOID **) &FirmwarePerformance);
+
+ return Status;
+}
+
+EFI_STATUS
+EFIAPI
+InsertMeasurement (
+ IN FIRMWARE_PERFORMANCE_PROTOCOL *This,
+ IN EFI_HANDLE Handle,
+ IN UINT16 RecordType,
+ IN UINT64 Ticker,
+ IN UINT16 Identifier OPTIONAL
+ )
+/*++
+
+Routine Description:
+
+ Logs performance data according to Record Type into pre-allocated buffer
+
+Arguments:
+
+ This - Calling context
+ Handle - Handle of gauge data
+ RecordType - Type of FPDT record
+ Ticker - Set event's Tick. If 0, Tick is current timer.
+ Identifier - Identifier of event records and other types of records
+
+Returns:
+
+ EFI_SUCCESS - Successfully create and initialized a guage data node.
+ EFI_OUT_OF_RESOURCES - No enough resource to create a guage data node.
+
+--*/
+{
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ HARDWARE_BOOT_REC *HardwareBootRec;
+ STRING_EVENT_REC *StringEvent;
+ GUID_EVENT_REC *GuidEvent;
+ BDS_ATTEMPT_REC *BdsAttemptRec;
+ EFI_GUID *GuidName;
+
+ UINT8 PdbFileName[STRING_EVENT_RECORD_NAME_LENGTH] = {0};
+ UINT8 NullFileName[STRING_EVENT_RECORD_NAME_LENGTH] = {0};
+ DevicePath = NULL;
+
+ //
+ // buffer overflow check
+ //
+ if (mPerformanceLength + sizeof(STRING_EVENT_REC) > FIRMWARE_MAX_BUFFER) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ switch (RecordType) {
+ case HARDWARE_BOOT_TYPE:
+ //
+ // Hardware Boot Record Table
+ //
+ HardwareBootRec = (HARDWARE_BOOT_REC*) ((UINT8*)mPerformancePointer + mPerformanceLength);
+
+ HardwareBootRec->RecType = RecordType;
+ HardwareBootRec->RecLength = sizeof(HARDWARE_BOOT_REC);
+ HardwareBootRec->Revision = RECORD_REVISION_1;
+ HardwareBootRec->HardwareBoot = GetTimeInNanoSec(Ticker);
+
+ mPerformanceLength += sizeof(HARDWARE_BOOT_REC);
+ break;
+
+ case GUID_EVENT_REC_TYPE:
+ case STRING_EVENT_REC_TYPE:
+ //
+ // Determine Pdb FileName associated with module logging performance
+ //
+ if (Handle != NULL){
+ GetNameFromHandle (Handle, PdbFileName);
+ }
+
+ GuidName = GetGuidFromHandle(Handle);
+ if (EfiCompareMem (PdbFileName,NullFileName, STRING_EVENT_RECORD_NAME_LENGTH)){
+ //
+ // String Event Record
+ //
+ StringEvent = (STRING_EVENT_REC*) ((UINT8*)mPerformancePointer + mPerformanceLength);
+ StringEvent->RecType = STRING_EVENT_REC_TYPE;
+ StringEvent->RecLength = sizeof(STRING_EVENT_REC);
+ StringEvent->Revision = RECORD_REVISION_1;
+ StringEvent->ProgressID = Identifier;
+ StringEvent->ApicID = GetApicId();
+ StringEvent->Timestamp = GetTimeInNanoSec(Ticker);
+ if (GuidName != NULL) {
+ gBS->CopyMem(&(StringEvent->Guid),GuidName,sizeof(EFI_GUID));
+ }
+
+ (gBS->CopyMem) (StringEvent->NameString, PdbFileName, STRING_EVENT_RECORD_NAME_LENGTH);
+
+ mPerformanceLength += sizeof(STRING_EVENT_REC);
+
+ } else {
+ //
+ // GUID Event Record
+ //
+ GuidEvent = (GUID_EVENT_REC*) ((UINT8*)mPerformancePointer + mPerformanceLength);
+ GuidEvent->RecType = GUID_EVENT_REC_TYPE;
+ GuidEvent->RecLength = sizeof(GUID_EVENT_REC);
+ GuidEvent->Revision = RECORD_REVISION_1;
+ GuidEvent->ProgressID = Identifier;
+ GuidEvent->ApicID = GetApicId();
+ GuidEvent->Timestamp = GetTimeInNanoSec(Ticker);
+ if (GuidName != NULL) {
+ gBS->CopyMem(&(GuidEvent->Guid),GuidName,sizeof(EFI_GUID));
+ }
+
+ mPerformanceLength += sizeof(GUID_EVENT_REC);
+ }
+ break;
+
+ case BDS_ATTEMPT_EVENT_REC_TYPE:
+ //
+ // BDS Boot Attempt Record
+ //
+ DevicePath = EfiDevicePathFromHandle (Handle);
+
+ BdsAttemptRec = (BDS_ATTEMPT_REC*) ((UINT8*)mPerformancePointer + mPerformanceLength);
+ BdsAttemptRec->RecType = BDS_ATTEMPT_EVENT_REC_TYPE;
+ BdsAttemptRec->RecLength = sizeof(BDS_ATTEMPT_REC);
+ BdsAttemptRec->Revision = RECORD_REVISION_1;
+ BdsAttemptRec->ApicID = GetApicId();
+ BdsAttemptRec->BdsAttemptNo = BdsAttemptNumber + 1;
+ BdsAttemptRec->Timestamp = GetTimeInNanoSec(Ticker);
+ ASPrint ((CHAR8*)(&BdsAttemptRec->UEFIBootVar), sizeof(BdsAttemptRec->UEFIBootVar)+1, "BOOT%04x", Identifier);
+ BdsAttemptRec->DevicePathString = '0';
+ mPerformanceLength += sizeof(BDS_ATTEMPT_REC);
+ break;
+
+ default:
+ //
+ // Record is undefined, return EFI_ABORTED
+ //
+ return EFI_ABORTED;
+ break;
+ }
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+GetPerfBufferAddr (
+ IN FIRMWARE_PERFORMANCE_PROTOCOL *This,
+ OUT UINT32 *PerformanceBuffer
+ )
+{
+ EFI_STATUS Status;
+
+ *PerformanceBuffer = 0;
+
+ Status = LocatePerformanceProtocol();
+ if(EFI_ERROR(Status)) {
+ return EFI_NOT_FOUND;
+ }
+
+ if (mPerformancePointer == NULL) {
+ return EFI_NOT_FOUND;
+ }
+
+ *PerformanceBuffer = (UINT32)((UINTN)mPerformancePointer);
+
+ return Status;
+}
+
+
+UINT32
+GetPerfBufferLength (
+ IN FIRMWARE_PERFORMANCE_PROTOCOL *This
+ )
+{
+ EFI_STATUS Status;
+
+ Status = LocatePerformanceProtocol();
+ if(EFI_ERROR(Status)) {
+ return 0;
+ }
+
+ return mPerformanceLength;
+}
+
+FIRMWARE_PERFORMANCE_PROTOCOL FirmwarePerformanceProtocol = {
+ InsertMeasurement,
+ GetPerfBufferAddr,
+ GetPerfBufferLength
+};
+
+//
+// Driver entry point
+//
+EFI_STATUS
+InitializePerformanceInfrastructure (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable,
+ IN UINT64 Ticker
+ )
+/*++
+
+Routine Description:
+
+ Install gFirmwarePerformanceProtocolGuid protocol and transfer PEI performance to gauge data nodes.
+
+Arguments:
+
+ ImageHandle - Standard driver entry point parameter
+ SystemTable - Standard driver entry point parameter
+ Ticker - End tick for PEI performance
+
+Returns:
+
+ EFI_OUT_OF_RESOURCES - No enough buffer to allocate
+ EFI_SUCCESS - Protocol installed.
+
+--*/
+{
+ EFI_STATUS Status;
+
+ Status = EFI_SUCCESS;
+ //
+ //A buffer of MAX size
+ //
+ mPerformancePointer = EfiLibAllocateZeroPool (FIRMWARE_MAX_BUFFER);
+ if (mPerformancePointer == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ mPerformanceLength = 0;
+ //
+ // Install the protocol interfaces
+ //
+ Status = gBS->InstallProtocolInterface (
+ &ImageHandle,
+ &gFirmwarePerformanceProtocolGuid,
+ EFI_NATIVE_INTERFACE,
+ &FirmwarePerformanceProtocol
+ );
+ if (!EFI_ERROR (Status)) {
+ //
+ // Get PEI performance hob and convert into FPDT structure
+ //
+ GetPeiFirmwarePerformanceHob (ImageHandle, SystemTable);
+ }
+
+ return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+StartMeasure (
+ EFI_HANDLE Handle,
+ IN UINT16 *Token,
+ IN UINT16 *Host,
+ IN UINT64 Ticker
+ )
+/*++
+
+Routine Description:
+
+ Start measurement according to token field and insert into pre-allocated buffer
+
+Arguments:
+
+ Handle - Handle to measure
+ Token - Token to measure
+ Host - Host to measure
+ Ticker - Ticker as start tick
+
+Returns:
+
+ Status code.
+
+--*/
+{
+ EFI_STATUS Status;
+ UINT16 RecordType;
+ UINT16 Identifier;
+
+ Status = LocatePerformanceProtocol();
+ if(EFI_ERROR(Status)) {
+ return Status;
+ }
+
+ if (!EfiStrCmp (Token, START_IMAGE_TOK)) {
+ RecordType = STRING_EVENT_REC_TYPE;
+ Identifier = MODULE_START_ID;
+ } else if (!EfiStrCmp (Token, LOAD_IMAGE_TOK)) {
+ RecordType = STRING_EVENT_REC_TYPE;
+ Identifier = MODULE_LOADIMAGE_START_ID;
+ } else if (!EfiStrCmp (Token, DRIVERBINDING_START_TOK)) {
+ RecordType = STRING_EVENT_REC_TYPE;
+ Identifier = MODULE_DRIVERBINDING_START_ID;
+ } else if (!EfiStrCmp (Token, DXE_TOK)) {
+ RecordType = STRING_EVENT_REC_TYPE;
+ Identifier = DXE_START_ID;
+ } else if (!EfiStrCmp (Token, DXE_CORE_DISP_INIT_TOK)) {
+ RecordType = STRING_EVENT_REC_TYPE;
+ Identifier = DXE_CORE_DISP_START_ID;
+ } else if (!EfiStrCmp (Token, COREDISPATCHER_TOK)) {
+ RecordType = STRING_EVENT_REC_TYPE;
+ Identifier = COREDISPATCHER_START_ID;
+ } else {
+ RecordType = PERFORMANCE_RECORD_TYPE_MAX;
+ Identifier = 0;
+ }
+
+ Status = FirmwarePerformance->InsertMeasurement (FirmwarePerformance, Handle, RecordType, Ticker, Identifier);
+
+ return Status;
+}
+
+EFI_STATUS
+EndMeasure (
+ EFI_HANDLE Handle,
+ IN UINT16 *Token,
+ IN UINT16 *Host,
+ IN UINT64 Ticker
+ )
+/*++
+
+Routine Description:
+
+ End measurement according to token field and insert into pre-allocated buffer
+
+Arguments:
+
+ Handle - Handle to stop
+ Token - Token to stop
+ Host - Host to stop
+ Ticker - Ticker as end tick
+
+Returns:
+
+ Status code.
+
+--*/
+{
+ EFI_STATUS Status;
+ UINT16 RecordType;
+ UINT16 Identifier;
+
+ Status = LocatePerformanceProtocol();
+ if(EFI_ERROR(Status)) {
+ return Status;
+ }
+
+ if (!EfiStrCmp (Token, START_IMAGE_TOK)) {
+ RecordType = STRING_EVENT_REC_TYPE;
+ Identifier = MODULE_END_ID;
+ } else if (!EfiStrCmp (Token, LOAD_IMAGE_TOK)) {
+ RecordType = STRING_EVENT_REC_TYPE;
+ Identifier = MODULE_LOADIMAGE_END_ID;
+ } else if (!EfiStrCmp (Token, DRIVERBINDING_START_TOK)) {
+ RecordType = STRING_EVENT_REC_TYPE;
+ Identifier = MODULE_DRIVERBINDING_END_ID;
+ } else if (!EfiStrCmp (Token, DXE_TOK)) {
+ RecordType = STRING_EVENT_REC_TYPE;
+ Identifier = DXE_END_ID;
+ } else if (!EfiStrCmp (Token, DXE_CORE_DISP_INIT_TOK)) {
+ RecordType = STRING_EVENT_REC_TYPE;
+ Identifier = DXE_CORE_DISP_END_ID;
+ } else if (!EfiStrCmp (Token, COREDISPATCHER_TOK)) {
+ RecordType = STRING_EVENT_REC_TYPE;
+ Identifier = COREDISPATCHER_END_ID;
+ } else {
+ RecordType = PERFORMANCE_RECORD_TYPE_MAX;
+ Identifier = 0;
+ }
+
+ Status = FirmwarePerformance->InsertMeasurement (FirmwarePerformance, Handle, RecordType, Ticker, Identifier);
+
+ return Status;
+}
+
+EFI_STATUS
+StartMeasureEx (
+ IN EFI_HANDLE Handle,
+ IN UINT16 *Token,
+ IN UINT16 *Host,
+ IN UINT64 Ticker,
+ IN UINT16 Identifier
+ )
+/*++
+
+Routine Description:
+
+ Start extended measurement according to token field and insert into pre-allocated buffer
+
+Arguments:
+
+ Handle - Handle to stop
+ Token - Token to stop
+ Host - Host to stop
+ Ticker - Ticker as end tick
+ Identifier - Identifier for a given record
+Returns:
+
+ Status code.
+
+--*/
+{
+ EFI_STATUS Status;
+ UINT16 RecordType;
+
+ Status = LocatePerformanceProtocol();
+ if(EFI_ERROR(Status)) {
+ return Status;
+ }
+
+ if (!EfiStrCmp (Token, EVENT_REC_TOK)) {
+ RecordType = STRING_EVENT_REC_TYPE;
+ } else if (!EfiStrCmp (Token, BDS_ATTEMPT_TOK)) {
+ RecordType = BDS_ATTEMPT_EVENT_REC_TYPE;
+ } else if (!EfiStrCmp (Token, HARDWARE_BOOT_TOK)) {
+ RecordType = HARDWARE_BOOT_TYPE;
+ } else {
+ RecordType = PERFORMANCE_RECORD_TYPE_MAX;
+ }
+ Status = FirmwarePerformance->InsertMeasurement (FirmwarePerformance, Handle, RecordType, Ticker, Identifier);
+
+ return Status;
+}
+
+EFI_STATUS
+EndMeasureEx (
+ IN EFI_HANDLE Handle,
+ IN UINT16 *Token,
+ IN UINT16 *Host,
+ IN UINT64 Ticker,
+ IN UINT16 Identifier
+ )
+/*++
+
+Routine Description:
+
+ End extended measurement according to token field and insert into pre-allocated buffer
+
+Arguments:
+
+ Handle - Handle to stop
+ Token - Token to stop
+ Host - Host to stop
+ Ticker - Ticker as end tick
+ Identifier - Identifier for a given record
+Returns:
+
+ Status code.
+
+--*/
+{
+ EFI_STATUS Status;
+ UINT16 RecordType;
+
+ Status = LocatePerformanceProtocol();
+ if(EFI_ERROR(Status)) {
+ return Status;
+ }
+
+ if (!EfiStrCmp (Token, EVENT_REC_TOK)) {
+ RecordType = STRING_EVENT_REC_TYPE;
+ } else if (!EfiStrCmp (Token, BDS_ATTEMPT_TOK)) {
+ RecordType = BDS_ATTEMPT_EVENT_REC_TYPE;
+ } else if (!EfiStrCmp (Token, HARDWARE_BOOT_TOK)) {
+ RecordType = HARDWARE_BOOT_TYPE;
+ } else {
+ RecordType = PERFORMANCE_RECORD_TYPE_MAX;
+ }
+
+ Status = FirmwarePerformance->InsertMeasurement (FirmwarePerformance, Handle, RecordType, Ticker, Identifier);
+
+ return Status;
+}
+
+EFI_STATUS
+GetPeiFirmwarePerformanceHob (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+/*++
+
+Routine Description:
+
+ Transfer PEI performance data to pre-allocated memory into FPDT format.
+
+Arguments:
+
+ ImageHandle - Standard entry point parameter
+ SystemTable - Standard entry point parameter
+
+Returns:
+
+ EFI_OUT_OF_RESOURCES - No enough resource to create data node.
+ EFI_SUCCESS - Transfer done successfully.
+
+--*/
+{
+ EFI_STATUS Status;
+ UINT32 Index;
+ VOID *HobList;
+ PEI_FIRMWARE_PERFORMANCE_HOB *PeiFirmwarePerformanceHob;
+ PEI_GUID_EVENT_REC *PeiGuidRec;
+ GUID_EVENT_REC *GuidEvent;
+
+ //
+ // Locate installed Performance HOB
+ //
+ PeiFirmwarePerformanceHob = NULL;
+
+ EfiLibGetSystemConfigurationTable (&gEfiHobListGuid, &HobList);
+
+ do {
+ Status = GetNextGuidHob (&HobList, &gPeiFirmwarePerformanceGuid, (VOID **) &PeiFirmwarePerformanceHob, NULL);
+ if (EFI_ERROR (Status) || (PeiFirmwarePerformanceHob == NULL)) {
+ break;
+ }
+
+ for (Index = 0; Index < PeiFirmwarePerformanceHob->NumberOfEntries; Index++) {
+ PeiGuidRec = &(PeiFirmwarePerformanceHob->GuidEventRecord[Index]);
+ //
+ // GUID Event Records from PEI phase
+ //
+ GuidEvent = (GUID_EVENT_REC*)((UINT8*)mPerformancePointer + mPerformanceLength);
+ GuidEvent->RecType = GUID_EVENT_REC_TYPE;
+ GuidEvent->RecLength = sizeof(GUID_EVENT_REC);
+ GuidEvent->Revision = RECORD_REVISION_1;
+ GuidEvent->ProgressID = PeiGuidRec->ProgressID;
+ GuidEvent->ApicID = PeiGuidRec->ApicID;
+ GuidEvent->Timestamp = PeiGuidRec->Timestamp;
+ GuidEvent->Guid = PeiGuidRec->Guid;
+
+ mPerformanceLength += sizeof(GUID_EVENT_REC);
+ }
+ } while (!EFI_ERROR (Status));
+
+ return Status;
+} \ No newline at end of file
diff --git a/EDK/Foundation/Library/Dxe/EfiDriverLib/ReportStatusCode.c b/EDK/Foundation/Library/Dxe/EfiDriverLib/ReportStatusCode.c
new file mode 100644
index 0000000..31da17b
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/EfiDriverLib/ReportStatusCode.c
@@ -0,0 +1,130 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ ReportStatusCode.c
+
+Abstract:
+
+--*/
+
+#include "Tiano.h"
+#include "EfiDriverLib.h"
+#include EFI_PROTOCOL_DEFINITION (DevicePath)
+#include EFI_GUID_DEFINITION (StatusCodeDataTypeId)
+#include EFI_ARCH_PROTOCOL_DEFINITION (StatusCode)
+
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+STATIC EFI_STATUS_CODE_PROTOCOL *gStatusCode = NULL;
+#endif
+
+EFI_STATUS
+EfiLibReportStatusCode (
+ IN EFI_STATUS_CODE_TYPE Type,
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN UINT32 Instance,
+ IN EFI_GUID *CallerId OPTIONAL,
+ IN EFI_STATUS_CODE_DATA *Data OPTIONAL
+ )
+/*++
+
+Routine Description:
+
+ Report device path through status code.
+
+Arguments:
+
+ Type - Code type
+ Value - Code value
+ Instance - Instance number
+ CallerId - Caller name
+ DevicePath - Device path that to be reported
+
+Returns:
+
+ Status code.
+
+ EFI_OUT_OF_RESOURCES - No enough buffer could be allocated
+
+--*/
+{
+ EFI_STATUS Status;
+
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+ if (gStatusCode == NULL) {
+ if (gBS == NULL) {
+ return EFI_UNSUPPORTED;
+ }
+ Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID **)&gStatusCode);
+ if (EFI_ERROR (Status) || gStatusCode == NULL) {
+ return EFI_UNSUPPORTED;
+ }
+ }
+ Status = gStatusCode->ReportStatusCode (Type, Value, Instance, CallerId, Data);
+ return Status;
+#else
+ Status = gRT->ReportStatusCode (Type, Value, Instance, CallerId, Data);
+ return Status;
+#endif
+}
+
+EFI_STATUS
+ReportStatusCodeWithDevicePath (
+ IN EFI_STATUS_CODE_TYPE Type,
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN UINT32 Instance,
+ IN EFI_GUID * CallerId OPTIONAL,
+ IN EFI_DEVICE_PATH_PROTOCOL * DevicePath
+ )
+/*++
+
+Routine Description:
+
+ Report device path through status code.
+
+Arguments:
+
+ Type - Code type
+ Value - Code value
+ Instance - Instance number
+ CallerId - Caller name
+ DevicePath - Device path that to be reported
+
+Returns:
+
+ Status code.
+
+ EFI_OUT_OF_RESOURCES - No enough buffer could be allocated
+
+--*/
+{
+ UINT16 Size;
+ UINT16 DevicePathSize;
+ EFI_STATUS_CODE_DATA *ExtendedData;
+ EFI_DEVICE_PATH_PROTOCOL *ExtendedDevicePath;
+ EFI_STATUS Status;
+
+ DevicePathSize = (UINT16) EfiDevicePathSize (DevicePath);
+ Size = DevicePathSize + sizeof (EFI_STATUS_CODE_DATA);
+ ExtendedData = (EFI_STATUS_CODE_DATA *) EfiLibAllocatePool (Size);
+ if (ExtendedData == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ ExtendedDevicePath = EfiConstructStatusCodeData (Size, &gEfiStatusCodeSpecificDataGuid, ExtendedData);
+ EfiCopyMem (ExtendedDevicePath, DevicePath, DevicePathSize);
+
+ Status = EfiLibReportStatusCode (Type, Value, Instance, CallerId, (EFI_STATUS_CODE_DATA *) ExtendedData);
+
+ gBS->FreePool (ExtendedData);
+ return Status;
+}
diff --git a/EDK/Foundation/Library/Dxe/EfiDriverLib/x64/PerformancePrimitives.c b/EDK/Foundation/Library/Dxe/EfiDriverLib/x64/PerformancePrimitives.c
new file mode 100644
index 0000000..b8b5f8b
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/EfiDriverLib/x64/PerformancePrimitives.c
@@ -0,0 +1,47 @@
+/*++
+
+Copyright (c) 2005, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PerformancePrimitives.c
+
+Abstract:
+
+ Support for Performance library
+
+--*/
+
+#include "TianoCommon.h"
+#include "CpuIA32.h"
+
+EFI_STATUS
+GetTimerValue (
+ OUT UINT64 *TimerValue
+ )
+/*++
+
+Routine Description:
+
+ Set TimerValue with current tick.
+
+Arguments:
+
+ TimerValue - Timer value to be set
+
+Returns:
+
+ EFI_SUCCESS - TimerValue is set.
+
+--*/
+{
+ *TimerValue = EfiReadTsc ();
+ return EFI_SUCCESS;
+}
diff --git a/EDK/Foundation/Library/Dxe/EfiIfrSupportLib/EfiIfrSupportLib.cif b/EDK/Foundation/Library/Dxe/EfiIfrSupportLib/EfiIfrSupportLib.cif
new file mode 100644
index 0000000..8c467c9
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/EfiIfrSupportLib/EfiIfrSupportLib.cif
@@ -0,0 +1,15 @@
+<component>
+ name = "EfiIfrSupportLib"
+ category = ModulePart
+ LocalRoot = "EDK\Foundation\Library\Dxe\EfiIfrSupportLib\"
+ RefName = "EfiIfrSupportLib"
+[files]
+"EfiIfrSupportLib.sdl"
+"EfiIfrSupportLib.mak"
+"IfrCommon.c"
+"IfrLibrary.h"
+"IfrOnTheFly.c"
+"IfrOpCodeCreation.c"
+"IfrVariable.c"
+"EfiIfrSupportLib.inf"
+<endComponent>
diff --git a/EDK/Foundation/Library/Dxe/EfiIfrSupportLib/EfiIfrSupportLib.inf b/EDK/Foundation/Library/Dxe/EfiIfrSupportLib/EfiIfrSupportLib.inf
new file mode 100644
index 0000000..387978b
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/EfiIfrSupportLib/EfiIfrSupportLib.inf
@@ -0,0 +1,52 @@
+#/*++
+#
+# Copyright (c) 2004, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# EfiIfrSupportLib.inf
+#
+# Abstract:
+#
+# Component description file.
+#
+#--*/
+
+[defines]
+BASE_NAME = EfiIfrSupportLib
+COMPONENT_TYPE = LIBRARY
+
+[sources.common]
+ IfrCommon.c
+ IfrOnTheFly.c
+ IfrOpCodeCreation.c
+ IfrLibrary.h
+ IfrVariable.c
+
+[includes.common]
+ $(EDK_SOURCE)\Foundation\Efi
+ $(EDK_SOURCE)\Foundation\Framework
+ $(EDK_SOURCE)\Foundation
+ .
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+ $(EDK_SOURCE)\Foundation\Library\Dxe\EfiDriverLib
+
+[libraries.common]
+ EfiGuidLib
+ EdkFrameworkProtocolLib
+
+
+[nmake.common]
+ C_STD_INCLUDE=
diff --git a/EDK/Foundation/Library/Dxe/EfiIfrSupportLib/EfiIfrSupportLib.mak b/EDK/Foundation/Library/Dxe/EfiIfrSupportLib/EfiIfrSupportLib.mak
new file mode 100644
index 0000000..2b36924
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/EfiIfrSupportLib/EfiIfrSupportLib.mak
@@ -0,0 +1,69 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EfiIfrSupportLib/EfiIfrSupportLib.mak 1 1/20/12 4:07a Jeffch $
+#
+# $Revision: 1 $
+#
+# $Date: 1/20/12 4:07a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EfiIfrSupportLib/EfiIfrSupportLib.mak $
+#
+# 1 1/20/12 4:07a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 9/27/11 6:30a Wesleychen
+# Intel EDK initially releases.
+#
+# 2 9/02/09 3:45a Iminglin
+# EIP24919
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: EfiIfrSupportLib.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+$(EFIIFRSUPPORTLIB) : EfiIfrSupportLib
+
+$(BUILD_DIR)\EfiIfrSupportLib.lib : EfiIfrSupportLib
+
+EfiIfrSupportLib : $(BUILD_DIR)\EfiIfrSupportLib.mak EfiIfrSupportLibBin
+
+$(BUILD_DIR)\EfiIfrSupportLib.mak : $(EfiIfrSupportLib_DIR)\$(@B).cif $(EfiIfrSupportLib_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(EfiIfrSupportLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+EfiIfrSupportLibBin : $(EFIGUIDLIB) $(EDKFRAMEWORKPROTOCOLLIB)
+ $(MAKE) /$(MAKEFLAGS) $(EDK_DEFAULTS)\
+ /f $(BUILD_DIR)\EfiIfrSupportLib.mak all\
+ TYPE=LIBRARY \
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#********************************************************************** \ No newline at end of file
diff --git a/EDK/Foundation/Library/Dxe/EfiIfrSupportLib/EfiIfrSupportLib.sdl b/EDK/Foundation/Library/Dxe/EfiIfrSupportLib/EfiIfrSupportLib.sdl
new file mode 100644
index 0000000..88c2b12
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/EfiIfrSupportLib/EfiIfrSupportLib.sdl
@@ -0,0 +1,26 @@
+TOKEN
+ Name = "EfiIfrSupportLib_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable EfiIfrSupportLib support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "EFIIFRSUPPORTLIB"
+ Value = "$(BUILD_DIR)\EfiIfrSupportLib.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "EfiIfrSupportLib_DIR"
+End
+
+MODULE
+ Help = "Includes EfiIfrSupportLib.mak to Project"
+ File = "EfiIfrSupportLib.mak"
+End
+
diff --git a/EDK/Foundation/Library/Dxe/EfiIfrSupportLib/IfrCommon.c b/EDK/Foundation/Library/Dxe/EfiIfrSupportLib/IfrCommon.c
new file mode 100644
index 0000000..13654b1
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/EfiIfrSupportLib/IfrCommon.c
@@ -0,0 +1,1031 @@
+/*++
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+ IfrCommon.c
+
+Abstract:
+
+ Common Library Routines to assist in IFR creation on-the-fly
+
+--*/
+
+#include "IfrLibrary.h"
+
+EFI_STATUS
+GetCurrentLanguage (
+ OUT CHAR16 *Lang
+ )
+/*++
+
+Routine Description:
+
+ Determine what is the current language setting
+
+Arguments:
+
+ Lang - Pointer of system language
+
+Returns:
+
+ Status code
+
+--*/
+{
+ EFI_STATUS Status;
+ UINTN Size;
+ UINTN Index;
+ CHAR8 Language[4];
+
+ //
+ // Getting the system language and placing it into our Global Data
+ //
+ Size = sizeof (Language);
+
+ Status = gRT->GetVariable (
+ L"Lang",
+ &gEfiGlobalVariableGuid,
+ NULL,
+ &Size,
+ Language
+ );
+
+ if (EFI_ERROR (Status)) {
+ EfiAsciiStrCpy (Language, "eng");
+ }
+
+ for (Index = 0; Index < 3; Index++) {
+ //
+ // Bitwise AND ascii value with 0xDF yields an uppercase value.
+ // Sign extend into a unicode value
+ //
+ Lang[Index] = (CHAR16) (Language[Index] & 0xDF);
+ }
+
+ //
+ // Null-terminate the value
+ //
+ Lang[3] = (CHAR16) 0;
+
+ return Status;
+}
+
+
+EFI_STATUS
+AddString (
+ IN VOID *StringBuffer,
+ IN CHAR16 *Language,
+ IN CHAR16 *String,
+ IN OUT STRING_REF *StringToken
+ )
+/*++
+
+Routine Description:
+
+ Add a string to the incoming buffer and return the token and offset data
+
+Arguments:
+
+ StringBuffer - The incoming buffer
+
+ Language - Currrent language
+
+ String - The string to be added
+
+ StringToken - The index where the string placed
+
+Returns:
+
+ EFI_OUT_OF_RESOURCES - No enough buffer to allocate
+
+ EFI_SUCCESS - String successfully added to the incoming buffer
+
+--*/
+{
+ EFI_HII_STRING_PACK *StringPack;
+ EFI_HII_STRING_PACK *StringPackBuffer;
+ VOID *NewBuffer;
+ RELOFST *PackSource;
+ RELOFST *PackDestination;
+ UINT8 *Source;
+ UINT8 *Destination;
+ UINTN Index;
+ BOOLEAN Finished;
+
+ StringPack = (EFI_HII_STRING_PACK *) StringBuffer;
+ Finished = FALSE;
+
+ //
+ // Pre-allocate a buffer sufficient for us to work on.
+ // We will use it as a destination scratch pad to build data on
+ // and when complete shift the data back to the original buffer
+ //
+ NewBuffer = EfiLibAllocateZeroPool (DEFAULT_STRING_BUFFER_SIZE);
+ if (NewBuffer == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ StringPackBuffer = (EFI_HII_STRING_PACK *) NewBuffer;
+
+ //
+ // StringPack is terminated with a length 0 entry
+ //
+ for (; StringPack->Header.Length != 0;) {
+ //
+ // If this stringpack's language is same as CurrentLanguage, use it
+ //
+ if (EfiCompareMem ((VOID *) ((CHAR8 *) (StringPack) + StringPack->LanguageNameString), Language, 3) == 0) {
+ //
+ // We have some data in this string pack, copy the string package up to the string data
+ //
+ EfiCopyMem (&StringPackBuffer->Header, &StringPack->Header, sizeof (StringPack));
+
+ //
+ // These are references in the structure to tokens, need to increase them by the space occupied by an additional StringPointer
+ //
+ StringPackBuffer->LanguageNameString = (UINT16) (StringPackBuffer->LanguageNameString + (UINT16) sizeof (RELOFST));
+ StringPackBuffer->PrintableLanguageName = (UINT16) (StringPackBuffer->PrintableLanguageName + (UINT16) sizeof (RELOFST));
+
+ PackSource = (RELOFST *) (StringPack + 1);
+ PackDestination = (RELOFST *) (StringPackBuffer + 1);
+ for (Index = 0; PackSource[Index] != 0x0000; Index++) {
+ //
+ // Copy the stringpointers from old to new buffer
+ // remember that we are adding a string, so the string offsets will all go up by sizeof (RELOFST)
+ //
+ PackDestination[Index] = (UINT16) (PackDestination[Index] + sizeof (RELOFST));
+ }
+
+ //
+ // Add a new stringpointer in the new buffer since we are adding a string. Null terminate it
+ //
+ PackDestination[Index] = (UINT16)(PackDestination[Index-1] +
+ EfiStrSize((CHAR16 *)((CHAR8 *)(StringPack) + PackSource[Index-1])));
+ PackDestination[Index + 1] = (UINT16) 0;
+
+ //
+ // Index is the token value for the new string
+ //
+ *StringToken = (UINT16) Index;
+
+ //
+ // Source now points to the beginning of the old buffer strings
+ // Destination now points to the beginning of the new buffer strings
+ //
+ Source = (UINT8 *) &PackSource[Index + 1];
+ Destination = (UINT8 *) &PackDestination[Index + 2];
+
+ //
+ // This should copy all the strings from the old buffer to the new buffer
+ //
+ for (; Index != 0; Index--) {
+ //
+ // Copy Source string to destination buffer
+ //
+ EfiStrCpy ((CHAR16 *) Destination, (CHAR16 *) Source);
+
+ //
+ // Adjust the source/destination to the next string location
+ //
+ Destination = Destination + EfiStrSize ((CHAR16 *) Source);
+ Source = Source + EfiStrSize ((CHAR16 *) Source);
+ }
+
+ //
+ // This copies the new string to the destination buffer
+ //
+ EfiStrCpy ((CHAR16 *) Destination, (CHAR16 *) String);
+
+ //
+ // Adjust the size of the changed string pack by adding the size of the new string
+ // along with the size of the additional offset entry for the new string
+ //
+ StringPackBuffer->Header.Length = (UINT32) ((UINTN) StringPackBuffer->Header.Length + EfiStrSize (String) + sizeof (RELOFST));
+
+ //
+ // Advance the buffers to point to the next spots.
+ //
+ StringPackBuffer = (EFI_HII_STRING_PACK *) ((CHAR8 *) (StringPackBuffer) + StringPackBuffer->Header.Length);
+ StringPack = (EFI_HII_STRING_PACK *) ((CHAR8 *) (StringPack) + StringPack->Header.Length);
+ Finished = TRUE;
+ continue;
+ }
+ //
+ // This isn't the language of the stringpack we were asked to add a string to
+ // so we need to copy it to the new buffer.
+ //
+ EfiCopyMem (&StringPackBuffer->Header, &StringPack->Header, StringPack->Header.Length);
+
+ //
+ // Advance the buffers to point to the next spots.
+ //
+ StringPackBuffer = (EFI_HII_STRING_PACK *) ((CHAR8 *) (StringPackBuffer) + StringPack->Header.Length);
+ StringPack = (EFI_HII_STRING_PACK *) ((CHAR8 *) (StringPack) + StringPack->Header.Length);
+ }
+
+ //
+ // If we didn't copy the new data to a stringpack yet
+ //
+ if (!Finished) {
+ PackDestination = (RELOFST *) (StringPackBuffer + 1);
+ //
+ // Pointing to a new string pack location
+ //
+ StringPackBuffer->Header.Length = (UINT32)
+ (
+ sizeof (EFI_HII_STRING_PACK) -
+ sizeof (EFI_STRING) +
+ sizeof (RELOFST) +
+ sizeof (RELOFST) +
+ EfiStrSize (Language) +
+ EfiStrSize (String)
+ );
+ StringPackBuffer->Header.Type = EFI_HII_STRING;
+ StringPackBuffer->LanguageNameString = (UINT16) ((UINTN) &PackDestination[3] - (UINTN) StringPackBuffer);
+ StringPackBuffer->PrintableLanguageName = (UINT16) ((UINTN) &PackDestination[3] - (UINTN) StringPackBuffer);
+ StringPackBuffer->Attributes = 0;
+ PackDestination[0] = (UINT16) ((UINTN) &PackDestination[3] - (UINTN) StringPackBuffer);
+ PackDestination[1] = (UINT16) (PackDestination[0] + EfiStrSize (Language));
+ PackDestination[2] = (UINT16) 0;
+
+ //
+ // The first string location will be set to destination. The minimum number of strings
+ // associated with a stringpack will always be token 0 stored as the languagename (e.g. ENG, SPA, etc)
+ // and token 1 as the new string being added and and null entry for the stringpointers
+ //
+ Destination = (CHAR8 *) &PackDestination[3];
+
+ //
+ // Copy the language name string to the new buffer
+ //
+ EfiStrCpy ((CHAR16 *) Destination, Language);
+
+ //
+ // Advance the destination to the new empty spot
+ //
+ Destination = Destination + EfiStrSize (Language);
+
+ //
+ // Copy the string to the new buffer
+ //
+ EfiStrCpy ((CHAR16 *) Destination, String);
+
+ //
+ // Since we are starting with a new string pack - we know the new string is token 1
+ //
+ *StringToken = (UINT16) 1;
+ }
+
+ //
+ // Zero out the original buffer and copy the updated data in the new buffer to the old buffer
+ //
+ EfiZeroMem (StringBuffer, DEFAULT_STRING_BUFFER_SIZE);
+ EfiCopyMem (StringBuffer, NewBuffer, DEFAULT_STRING_BUFFER_SIZE);
+
+ //
+ // Free the newly created buffer since we don't need it anymore
+ //
+ gBS->FreePool (NewBuffer);
+ return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+AddOpCode (
+ IN VOID *FormBuffer,
+ IN OUT VOID *OpCodeData
+ )
+/*++
+
+Routine Description:
+
+ Add op-code data to the FormBuffer
+
+Arguments:
+
+ FormBuffer - Form buffer to be inserted to
+
+ OpCodeData - Op-code data to be inserted
+
+Returns:
+
+ EFI_OUT_OF_RESOURCES - No enough buffer to allocate
+
+ EFI_SUCCESS - Op-code data successfully inserted
+
+--*/
+{
+ EFI_HII_PACK_HEADER *NewBuffer;
+ UINT8 *Source;
+ UINT8 *Destination;
+
+ //
+ // Pre-allocate a buffer sufficient for us to work on.
+ // We will use it as a destination scratch pad to build data on
+ // and when complete shift the data back to the original buffer
+ //
+ NewBuffer = EfiLibAllocateZeroPool (DEFAULT_FORM_BUFFER_SIZE);
+ if (NewBuffer == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ Source = (UINT8 *) FormBuffer;
+ Destination = (UINT8 *) NewBuffer;
+
+ //
+ // Copy the IFR Package header to the new buffer
+ //
+ EfiCopyMem (Destination, Source, sizeof (EFI_HII_PACK_HEADER));
+
+ //
+ // Advance Source and Destination to next op-code
+ //
+ Source = Source + sizeof (EFI_HII_PACK_HEADER);
+ Destination = Destination + sizeof (EFI_HII_PACK_HEADER);
+
+ //
+ // Copy data to the new buffer until we run into the end_form
+ //
+ for (; ((EFI_IFR_OP_HEADER *) Source)->OpCode != EFI_IFR_END_FORM_OP;) {
+ //
+ // If the this opcode is an end_form_set we better be creating and endform
+ // Nonetheless, we will add data before the end_form_set. This also provides
+ // for interesting behavior in the code we will run, but has no bad side-effects
+ // since we will possibly do a 0 byte copy in this particular end-case.
+ //
+ if (((EFI_IFR_OP_HEADER *) Source)->OpCode == EFI_IFR_END_FORM_SET_OP) {
+ break;
+ }
+
+ //
+ // Copy data to new buffer
+ //
+ EfiCopyMem (Destination, Source, ((EFI_IFR_OP_HEADER *) Source)->Length);
+
+ //
+ // Adjust Source/Destination to next op-code location
+ //
+ Destination = Destination + (UINTN) ((EFI_IFR_OP_HEADER *) Source)->Length;
+ Source = Source + (UINTN) ((EFI_IFR_OP_HEADER *) Source)->Length;
+ }
+
+ //
+ // Prior to the end_form is where we insert the new op-code data
+ //
+ EfiCopyMem (Destination, OpCodeData, ((EFI_IFR_OP_HEADER *) OpCodeData)->Length);
+ Destination = Destination + (UINTN) ((EFI_IFR_OP_HEADER *) OpCodeData)->Length;
+
+ NewBuffer->Length = (UINT32) (NewBuffer->Length + (UINT32) (((EFI_IFR_OP_HEADER *) OpCodeData)->Length));
+
+ //
+ // Copy end-form data to new buffer
+ //
+ EfiCopyMem (Destination, Source, ((EFI_IFR_OP_HEADER *) Source)->Length);
+
+ //
+ // Adjust Source/Destination to next op-code location
+ //
+ Destination = Destination + (UINTN) ((EFI_IFR_OP_HEADER *) Source)->Length;
+ Source = Source + (UINTN) ((EFI_IFR_OP_HEADER *) Source)->Length;
+
+ //
+ // Copy end-formset data to new buffer
+ //
+ EfiCopyMem (Destination, Source, ((EFI_IFR_OP_HEADER *) Source)->Length);
+
+ //
+ // Zero out the original buffer and copy the updated data in the new buffer to the old buffer
+ //
+ EfiZeroMem (FormBuffer, DEFAULT_FORM_BUFFER_SIZE);
+ EfiCopyMem (FormBuffer, NewBuffer, DEFAULT_FORM_BUFFER_SIZE);
+
+ //
+ // Free the newly created buffer since we don't need it anymore
+ //
+ gBS->FreePool (NewBuffer);
+ return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+GetHiiInterface (
+ OUT EFI_HII_PROTOCOL **Hii
+ )
+/*++
+
+Routine Description:
+
+ Get the HII protocol interface
+
+Arguments:
+
+ Hii - HII protocol interface
+
+Returns:
+
+ Status code
+
+--*/
+{
+ EFI_STATUS Status;
+
+ //
+ // There should only be one HII protocol
+ //
+ Status = gBS->LocateProtocol (
+ &gEfiHiiProtocolGuid,
+ NULL,
+ (VOID **) Hii
+ );
+
+ return Status;;
+}
+
+
+EFI_STATUS
+ExtractDataFromHiiHandle (
+ IN EFI_HII_HANDLE HiiHandle,
+ IN OUT UINT16 *ImageLength,
+ OUT UINT8 *DefaultImage,
+ OUT EFI_GUID *Guid
+ )
+/*++
+
+Routine Description:
+
+ Extract information pertaining to the HiiHandle
+
+Arguments:
+
+ HiiHandle - Hii handle
+
+ ImageLength - For input, length of DefaultImage;
+ For output, length of actually required
+
+ DefaultImage - Image buffer prepared by caller
+
+ Guid - Guid information about the form
+
+Returns:
+
+ EFI_OUT_OF_RESOURCES - No enough buffer to allocate
+
+ EFI_BUFFER_TOO_SMALL - DefualtImage has no enough ImageLength
+
+ EFI_SUCCESS - Successfully extract data from Hii database.
+
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_HII_PROTOCOL *Hii;
+ UINTN DataLength;
+ UINT8 *RawData;
+ UINT8 *OldData;
+ UINTN Index;
+ UINTN Temp;
+ UINTN SizeOfNvStore;
+ UINTN CachedStart;
+
+ DataLength = DEFAULT_FORM_BUFFER_SIZE;
+ SizeOfNvStore = 0;
+ CachedStart = 0;
+
+ Status = GetHiiInterface (&Hii);
+
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ //
+ // Allocate space for retrieval of IFR data
+ //
+ RawData = EfiLibAllocateZeroPool ((UINTN) DataLength);
+ if (RawData == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ //
+ // Get all the forms associated with this HiiHandle
+ //
+ Status = Hii->GetForms (Hii, HiiHandle, 0, &DataLength, RawData);
+
+ if (EFI_ERROR (Status)) {
+ gBS->FreePool (RawData);
+
+ //
+ // Allocate space for retrieval of IFR data
+ //
+ RawData = EfiLibAllocateZeroPool ((UINTN) DataLength);
+ if (RawData == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ //
+ // Get all the forms associated with this HiiHandle
+ //
+ Status = Hii->GetForms (Hii, HiiHandle, 0, &DataLength, RawData);
+ }
+
+ OldData = RawData;
+
+ //
+ // Point RawData to the beginning of the form data
+ //
+ RawData = (UINT8 *) ((UINTN) RawData + sizeof (EFI_HII_PACK_HEADER));
+
+ for (Index = 0; RawData[Index] != EFI_IFR_END_FORM_SET_OP;) {
+ switch (RawData[Index]) {
+ case EFI_IFR_FORM_SET_OP:
+ //
+ // Copy the GUID information from this handle
+ //
+ EfiCopyMem (Guid, &((EFI_IFR_FORM_SET *) &RawData[Index])->Guid, sizeof (EFI_GUID));
+ break;
+
+ case EFI_IFR_ONE_OF_OP:
+ case EFI_IFR_CHECKBOX_OP:
+ case EFI_IFR_NUMERIC_OP:
+ case EFI_IFR_DATE_OP:
+ case EFI_IFR_TIME_OP:
+ case EFI_IFR_PASSWORD_OP:
+ case EFI_IFR_STRING_OP:
+ //
+ // Remember, multiple op-codes may reference the same item, so let's keep a running
+ // marker of what the highest QuestionId that wasn't zero length. This will accurately
+ // maintain the Size of the NvStore
+ //
+ if (((EFI_IFR_ONE_OF *) &RawData[Index])->Width != 0) {
+ Temp = ((EFI_IFR_ONE_OF *) &RawData[Index])->QuestionId + ((EFI_IFR_ONE_OF *) &RawData[Index])->Width;
+ if (SizeOfNvStore < Temp) {
+ SizeOfNvStore = ((EFI_IFR_ONE_OF *) &RawData[Index])->QuestionId + ((EFI_IFR_ONE_OF *) &RawData[Index])->Width;
+ }
+ }
+ }
+
+ Index = RawData[Index + 1] + Index;
+ }
+
+ //
+ // Return an error if buffer is too small
+ //
+ if (SizeOfNvStore > *ImageLength) {
+ gBS->FreePool (OldData);
+ *ImageLength = (UINT16) SizeOfNvStore;
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ EfiZeroMem (DefaultImage, SizeOfNvStore);
+
+ //
+ // Copy the default image information to the user's buffer
+ //
+ for (Index = 0; RawData[Index] != EFI_IFR_END_FORM_SET_OP;) {
+ switch (RawData[Index]) {
+ case EFI_IFR_ONE_OF_OP:
+ CachedStart = ((EFI_IFR_ONE_OF *) &RawData[Index])->QuestionId;
+ break;
+
+ case EFI_IFR_ONE_OF_OPTION_OP:
+ if (((EFI_IFR_ONE_OF_OPTION *) &RawData[Index])->Flags & EFI_IFR_FLAG_DEFAULT) {
+ EfiCopyMem (&DefaultImage[CachedStart], &((EFI_IFR_ONE_OF_OPTION *) &RawData[Index])->Value, 2);
+ }
+ break;
+
+ case EFI_IFR_CHECKBOX_OP:
+ DefaultImage[((EFI_IFR_ONE_OF *) &RawData[Index])->QuestionId] = ((EFI_IFR_CHECK_BOX *) &RawData[Index])->Flags;
+ break;
+
+ case EFI_IFR_NUMERIC_OP:
+ EfiCopyMem (
+ &DefaultImage[((EFI_IFR_ONE_OF *) &RawData[Index])->QuestionId],
+ &((EFI_IFR_NUMERIC *) &RawData[Index])->Default,
+ 2
+ );
+ break;
+
+ }
+
+ Index = RawData[Index + 1] + Index;
+ }
+
+ *ImageLength = (UINT16) SizeOfNvStore;
+
+ //
+ // Free our temporary repository of form data
+ //
+ gBS->FreePool (OldData);
+
+ return EFI_SUCCESS;
+}
+
+
+EFI_HII_HANDLE
+FindHiiHandle (
+ IN OUT EFI_HII_PROTOCOL **HiiProtocol, OPTIONAL
+ IN EFI_GUID *Guid
+ )
+/*++
+
+Routine Description:
+ Finds HII handle for given pack GUID previously registered with the HII.
+
+Arguments:
+ HiiProtocol - pointer to pointer to HII protocol interface.
+ If NULL, the interface will be found but not returned.
+ If it points to NULL, the interface will be found and
+ written back to the pointer that is pointed to.
+ Guid - The GUID of the pack that registered with the HII.
+
+Returns:
+ Handle to the HII pack previously registered by the memory driver.
+
+--*/
+{
+ EFI_STATUS Status;
+
+ EFI_HII_HANDLE *HiiHandleBuffer;
+ EFI_HII_HANDLE HiiHandle;
+ UINT16 HiiHandleBufferLength;
+ UINT32 NumberOfHiiHandles;
+ EFI_GUID HiiGuid;
+ EFI_HII_PROTOCOL *HiiProt;
+ UINT32 Index;
+ UINT16 Length;
+
+ HiiHandle = 0;
+ if ((HiiProtocol != NULL) && (*HiiProtocol != NULL)) {
+ //
+ // The protocol has been passed in
+ //
+ HiiProt = *HiiProtocol;
+ } else {
+ gBS->LocateProtocol (
+ &gEfiHiiProtocolGuid,
+ NULL,
+ (VOID **) &HiiProt
+ );
+ if (HiiProt == NULL) {
+ return HiiHandle;
+ }
+
+ if (HiiProtocol != NULL) {
+ //
+ // Return back the HII protocol for the caller as promissed
+ //
+ *HiiProtocol = HiiProt;
+ }
+ }
+ //
+ // Allocate buffer
+ //
+ HiiHandleBufferLength = 10;
+ HiiHandleBuffer = EfiLibAllocatePool (HiiHandleBufferLength);
+ ASSERT (HiiHandleBuffer != NULL);
+
+ //
+ // Get the Handles of the packages that were registered with Hii
+ //
+ Status = HiiProt->FindHandles (
+ HiiProt,
+ &HiiHandleBufferLength,
+ HiiHandleBuffer
+ );
+
+ //
+ // Get a bigger bugffer if this one is to small, and try again
+ //
+ if (Status == EFI_BUFFER_TOO_SMALL) {
+
+ gBS->FreePool (HiiHandleBuffer);
+
+ HiiHandleBuffer = EfiLibAllocatePool (HiiHandleBufferLength);
+ ASSERT (HiiHandleBuffer != NULL);
+
+ Status = HiiProt->FindHandles (
+ HiiProt,
+ &HiiHandleBufferLength,
+ HiiHandleBuffer
+ );
+ }
+
+ if (EFI_ERROR (Status)) {
+ goto lbl_exit;
+ }
+
+ NumberOfHiiHandles = HiiHandleBufferLength / sizeof (EFI_HII_HANDLE);
+
+ //
+ // Iterate Hii handles and look for the one that matches our Guid
+ //
+ for (Index = 0; Index < NumberOfHiiHandles; Index++) {
+
+ Length = 0;
+ ExtractDataFromHiiHandle (HiiHandleBuffer[Index], &Length, NULL, &HiiGuid);
+
+ if (EfiCompareGuid (&HiiGuid, Guid)) {
+
+ HiiHandle = HiiHandleBuffer[Index];
+ break;
+ }
+ }
+
+lbl_exit:
+ gBS->FreePool (HiiHandleBuffer);
+ return HiiHandle;
+}
+
+
+EFI_STATUS
+ValidateDataFromHiiHandle (
+ IN EFI_HII_HANDLE HiiHandle,
+ OUT BOOLEAN *Results
+ )
+/*++
+
+Routine Description:
+
+ Validate that the data associated with the HiiHandle in NVRAM is within
+ the reasonable parameters for that FormSet. Values for strings and passwords
+ are not verified due to their not having the equivalent of valid range settings.
+
+Arguments:
+
+ HiiHandle - Handle of the HII database entry to query
+
+ Results - If return Status is EFI_SUCCESS, Results provides valid data
+ TRUE = NVRAM Data is within parameters
+ FALSE = NVRAM Data is NOT within parameters
+
+Returns:
+
+ EFI_OUT_OF_RESOURCES - No enough buffer to allocate
+
+ EFI_SUCCESS - Data successfully validated
+--*/
+{
+ EFI_STATUS Status;
+ EFI_HII_PROTOCOL *Hii;
+ EFI_GUID Guid;
+ UINT8 *RawData;
+ UINT8 *OldData;
+ UINTN RawDataLength;
+ UINT8 *VariableData;
+ UINTN Index;
+ UINTN Temp;
+ UINTN SizeOfNvStore;
+ UINTN CachedStart;
+ BOOLEAN GotMatch;
+
+ RawDataLength = DEFAULT_FORM_BUFFER_SIZE;
+ SizeOfNvStore = 0;
+ CachedStart = 0;
+ GotMatch = FALSE;
+ *Results = TRUE;
+
+ Status = GetHiiInterface (&Hii);
+
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ //
+ // Allocate space for retrieval of IFR data
+ //
+ RawData = EfiLibAllocateZeroPool (RawDataLength);
+ if (RawData == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ //
+ // Get all the forms associated with this HiiHandle
+ //
+ Status = Hii->GetForms (Hii, HiiHandle, 0, &RawDataLength, RawData);
+
+ if (EFI_ERROR (Status)) {
+ gBS->FreePool (RawData);
+
+ //
+ // Allocate space for retrieval of IFR data
+ //
+ RawData = EfiLibAllocateZeroPool (RawDataLength);
+ if (RawData == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ //
+ // Get all the forms associated with this HiiHandle
+ //
+ Status = Hii->GetForms (Hii, HiiHandle, 0, &RawDataLength, RawData);
+ }
+
+ OldData = RawData;
+
+ //
+ // Point RawData to the beginning of the form data
+ //
+ RawData = (UINT8 *) ((UINTN) RawData + sizeof (EFI_HII_PACK_HEADER));
+
+ for (Index = 0; RawData[Index] != EFI_IFR_END_FORM_SET_OP;) {
+ if (RawData[Index] == EFI_IFR_FORM_SET_OP) {
+ EfiCopyMem (&Guid, &((EFI_IFR_FORM_SET *) &RawData[Index])->Guid, sizeof (EFI_GUID));
+ break;
+ }
+
+ Index = RawData[Index + 1] + Index;
+ }
+
+ for (Index = 0; RawData[Index] != EFI_IFR_END_FORM_SET_OP;) {
+ switch (RawData[Index]) {
+ case EFI_IFR_FORM_SET_OP:
+ break;
+
+ case EFI_IFR_ONE_OF_OP:
+ case EFI_IFR_CHECKBOX_OP:
+ case EFI_IFR_NUMERIC_OP:
+ case EFI_IFR_DATE_OP:
+ case EFI_IFR_TIME_OP:
+ case EFI_IFR_PASSWORD_OP:
+ case EFI_IFR_STRING_OP:
+ //
+ // Remember, multiple op-codes may reference the same item, so let's keep a running
+ // marker of what the highest QuestionId that wasn't zero length. This will accurately
+ // maintain the Size of the NvStore
+ //
+ if (((EFI_IFR_ONE_OF *) &RawData[Index])->Width != 0) {
+ Temp = ((EFI_IFR_ONE_OF *) &RawData[Index])->QuestionId + ((EFI_IFR_ONE_OF *) &RawData[Index])->Width;
+ if (SizeOfNvStore < Temp) {
+ SizeOfNvStore = ((EFI_IFR_ONE_OF *) &RawData[Index])->QuestionId + ((EFI_IFR_ONE_OF *) &RawData[Index])->Width;
+ }
+ }
+ }
+
+ Index = RawData[Index + 1] + Index;
+ }
+
+ //
+ // Allocate memory for our File Form Tags
+ //
+ VariableData = EfiLibAllocateZeroPool (SizeOfNvStore);
+ if (VariableData == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ Status = gRT->GetVariable (
+ L"Setup",
+ &Guid,
+ NULL,
+ &SizeOfNvStore,
+ (VOID *) VariableData
+ );
+
+ if (EFI_ERROR (Status)) {
+
+ //
+ // If there is a variable that exists already and it is larger than what we calculated the
+ // storage needs to be, we must assume the variable size from GetVariable is correct and not
+ // allow the truncation of the variable. It is very possible that the user who created the IFR
+ // we are cracking is not referring to a variable that was in a previous map, however we cannot
+ // allow it's truncation.
+ //
+ if (Status == EFI_BUFFER_TOO_SMALL) {
+ //
+ // Free the buffer that was allocated that was too small
+ //
+ gBS->FreePool (VariableData);
+
+ VariableData = EfiLibAllocatePool (SizeOfNvStore);
+ if (VariableData == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ Status = gRT->GetVariable (
+ L"Setup",
+ &Guid,
+ NULL,
+ &SizeOfNvStore,
+ (VOID *) VariableData
+ );
+ }
+ }
+
+ //
+ // Walk through the form and see that the variable data it refers to is ok.
+ // This allows for the possibility of stale (obsoleted) data in the variable
+ // can be overlooked without causing an error
+ //
+ for (Index = 0; RawData[Index] != EFI_IFR_END_FORM_SET_OP;) {
+ switch (RawData[Index]) {
+ case EFI_IFR_ONE_OF_OP:
+ //
+ // A one_of has no data, its the option that does - cache the storage Id
+ //
+ CachedStart = ((EFI_IFR_ONE_OF *) &RawData[Index])->QuestionId;
+ break;
+
+ case EFI_IFR_ONE_OF_OPTION_OP:
+ //
+ // A one_of_option can be any value
+ //
+ if (VariableData[CachedStart] == ((EFI_IFR_ONE_OF_OPTION *) &RawData[Index])->Value) {
+ GotMatch = TRUE;
+ }
+ break;
+
+ case EFI_IFR_END_ONE_OF_OP:
+ //
+ // At this point lets make sure that the data value in the NVRAM matches one of the options
+ //
+ if (!GotMatch) {
+ *Results = FALSE;
+ return EFI_SUCCESS;
+ }
+ break;
+
+ case EFI_IFR_CHECKBOX_OP:
+ //
+ // A checkbox is a boolean, so 0 and 1 are valid
+ // Remember, QuestionId corresponds to the offset location of the data in the variable
+ //
+ if (VariableData[((EFI_IFR_CHECK_BOX *) &RawData[Index])->QuestionId] > 1) {
+ *Results = FALSE;
+ return EFI_SUCCESS;
+ }
+ break;
+
+ case EFI_IFR_NUMERIC_OP:
+ if ((VariableData[((EFI_IFR_NUMERIC *)&RawData[Index])->QuestionId] < ((EFI_IFR_NUMERIC *)&RawData[Index])->Minimum) ||
+ (VariableData[((EFI_IFR_NUMERIC *)&RawData[Index])->QuestionId] > ((EFI_IFR_NUMERIC *)&RawData[Index])->Maximum)) {
+ *Results = FALSE;
+ return EFI_SUCCESS;
+ }
+ break;
+
+ }
+
+ Index = RawData[Index + 1] + Index;
+ }
+
+ //
+ // Free our temporary repository of form data
+ //
+ gBS->FreePool (OldData);
+ gBS->FreePool (VariableData);
+
+ return EFI_SUCCESS;
+}
+
+EFI_HII_PACKAGES *
+PreparePackages (
+ IN UINTN NumberOfPackages,
+ IN EFI_GUID *GuidId,
+ ...
+ )
+/*++
+
+Routine Description:
+
+ Assemble EFI_HII_PACKAGES according to the passed in packages.
+
+Arguments:
+
+ NumberOfPackages - Number of packages.
+ GuidId - Package GUID.
+
+Returns:
+
+ Pointer of EFI_HII_PACKAGES.
+
+--*/
+{
+ VA_LIST args;
+ EFI_HII_PACKAGES *HiiPackages;
+ VOID **Package;
+ UINTN Index;
+
+ ASSERT (NumberOfPackages > 0);
+
+ HiiPackages = EfiLibAllocateZeroPool (sizeof (EFI_HII_PACKAGES) + NumberOfPackages * sizeof (VOID *));
+
+ HiiPackages->GuidId = GuidId;
+ HiiPackages->NumberOfPackages = NumberOfPackages;
+ Package = (VOID **) (((UINT8 *) HiiPackages) + sizeof (EFI_HII_PACKAGES));
+
+ VA_START (args, GuidId);
+
+ for (Index = 0; Index < NumberOfPackages; Index++) {
+ *Package = VA_ARG (args, VOID *);
+ Package++;
+ }
+
+ VA_END (args);
+
+ return HiiPackages;
+}
diff --git a/EDK/Foundation/Library/Dxe/EfiIfrSupportLib/IfrLibrary.h b/EDK/Foundation/Library/Dxe/EfiIfrSupportLib/IfrLibrary.h
new file mode 100644
index 0000000..ebf8a1c
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/EfiIfrSupportLib/IfrLibrary.h
@@ -0,0 +1,1299 @@
+/*++
+
+Copyright (c) 2004 - 2005, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ IfrLibrary.h
+
+Abstract:
+ The file contain all library function for Ifr Operations.
+
+--*/
+
+#ifndef _IFRLIBRARY_H
+#define _IFRLIBRARY_H
+
+#include "Tiano.h"
+#include "EfiDriverLib.h"
+
+#include EFI_PROTOCOL_DEFINITION (Hii)
+#include EFI_GUID_DEFINITION (GlobalVariable)
+
+#define DEFAULT_FORM_BUFFER_SIZE 0xFFFF
+#define DEFAULT_STRING_BUFFER_SIZE 0xFFFF
+
+#pragma pack(1)
+typedef struct {
+ CHAR16 *OptionString; // Passed in string to generate a token for in a truly dynamic form creation
+ STRING_REF StringToken; // This is used when creating a single op-code without generating a StringToken (have one already)
+ UINT16 Value;
+ UINT8 Flags;
+ UINT16 Key;
+} IFR_OPTION;
+#pragma pack()
+
+EFI_STATUS
+GetCurrentLanguage (
+ OUT CHAR16 *Lang
+ )
+/*++
+
+Routine Description:
+
+ Determine what is the current language setting
+
+Arguments:
+
+ Lang - Pointer of system language
+
+Returns:
+
+ Status code
+
+--*/
+;
+
+EFI_STATUS
+AddString (
+ IN VOID *StringBuffer,
+ IN CHAR16 *Language,
+ IN CHAR16 *String,
+ IN OUT STRING_REF *StringToken
+ )
+/*++
+
+Routine Description:
+
+ Add a string to the incoming buffer and return the token and offset data
+
+Arguments:
+
+ StringBuffer - The incoming buffer
+
+ Language - Currrent language
+
+ String - The string to be added
+
+ StringToken - The index where the string placed
+
+Returns:
+
+ EFI_OUT_OF_RESOURCES - No enough buffer to allocate
+
+ EFI_SUCCESS - String successfully added to the incoming buffer
+
+--*/
+;
+
+EFI_STATUS
+AddOpCode (
+ IN VOID *FormBuffer,
+ IN OUT VOID *OpCodeData
+ )
+/*++
+
+Routine Description:
+
+ Add op-code data to the FormBuffer
+
+Arguments:
+
+ FormBuffer - Form buffer to be inserted to
+
+ OpCodeData - Op-code data to be inserted
+
+Returns:
+
+ EFI_OUT_OF_RESOURCES - No enough buffer to allocate
+
+ EFI_SUCCESS - Op-code data successfully inserted
+
+--*/
+;
+
+EFI_STATUS
+CreateFormSet (
+ IN CHAR16 *FormSetTitle,
+ IN EFI_GUID *Guid,
+ IN UINT8 Class,
+ IN UINT8 SubClass,
+ IN OUT VOID **FormBuffer,
+ IN OUT VOID **StringBuffer
+ )
+/*++
+
+Routine Description:
+
+ Create a formset
+
+Arguments:
+
+ FormSetTitle - Title of formset
+
+ Guid - Guid of formset
+
+ Class - Class of formset
+
+ SubClass - Sub class of formset
+
+ FormBuffer - Pointer of the formset created
+
+ StringBuffer - Pointer of FormSetTitile string created
+
+Returns:
+
+ EFI_OUT_OF_RESOURCES - No enough buffer to allocate
+
+ EFI_SUCCESS - Formset successfully created
+
+--*/
+;
+
+EFI_STATUS
+CreateForm (
+ IN CHAR16 *FormTitle,
+ IN UINT16 FormId,
+ IN OUT VOID *FormBuffer,
+ IN OUT VOID *StringBuffer
+ )
+/*++
+
+Routine Description:
+
+ Create a form
+
+Arguments:
+
+ FormTitle - Title of the form
+
+ FormId - Id of the form
+
+ FormBuffer - Pointer of the form created
+
+ StringBuffer - Pointer of FormTitil string created
+
+Returns:
+
+ EFI_SUCCESS - Form successfully created
+
+--*/
+;
+
+EFI_STATUS
+CreateSubTitle (
+ IN CHAR16 *SubTitle,
+ IN OUT VOID *FormBuffer,
+ IN OUT VOID *StringBuffer
+ )
+/*++
+
+Routine Description:
+
+ Create a SubTitle
+
+Arguments:
+
+ SubTitle - Sub title to be created
+
+ FormBuffer - Where this subtitle to add to
+
+ StringBuffer - String buffer created for subtitle
+
+Returns:
+
+ EFI_SUCCESS - Subtitle successfully created
+
+--*/
+;
+
+EFI_STATUS
+CreateText (
+ IN CHAR16 *String,
+ IN CHAR16 *String2,
+ IN CHAR16 *String3,
+ IN UINT8 Flags,
+ IN UINT16 Key,
+ IN OUT VOID *FormBuffer,
+ IN OUT VOID *StringBuffer
+ )
+/*++
+
+Routine Description:
+
+ Create a line of text
+
+Arguments:
+
+ String - First string of the text
+
+ String2 - Second string of the text
+
+ String3 - Help string of the text
+
+ Flags - Flag of the text
+
+ Key - Key of the text
+
+ FormBuffer - The form where this text adds to
+
+ StringBuffer - String buffer created for String, String2 and String3
+
+Returns:
+
+ EFI_SUCCESS - Text successfully created
+
+--*/
+;
+
+EFI_STATUS
+CreateGoto (
+ IN UINT16 FormId,
+ IN CHAR16 *Prompt,
+ IN OUT VOID *FormBuffer,
+ IN OUT VOID *StringBuffer
+ )
+/*++
+
+Routine Description:
+
+ Create a hyperlink
+
+Arguments:
+
+ FormId - Form ID of the hyperlink
+
+ Prompt - Prompt of the hyperlink
+
+ FormBuffer - The form where this hyperlink adds to
+
+ StringBuffer - String buffer created for Prompt
+
+Returns:
+
+ EFI_SUCCESS - Hyperlink successfully created
+
+--*/
+;
+
+EFI_STATUS
+CreateOneOf (
+ IN UINT16 QuestionId,
+ IN UINT8 DataWidth,
+ IN CHAR16 *Prompt,
+ IN CHAR16 *Help,
+ IN IFR_OPTION *OptionsList,
+ IN UINTN OptionCount,
+ IN OUT VOID *FormBuffer,
+ IN OUT VOID *StringBuffer
+ )
+/*++
+
+Routine Description:
+
+ Create a one-of question with a set of options to choose from. The
+ OptionsList is a pointer to a null-terminated list of option descriptions.
+
+Arguments:
+
+ QuestionId - Question ID of the one-of box
+
+ DataWidth - DataWidth of the one-of box
+
+ Prompt - Prompt of the one-of box
+
+ Help - Help of the one-of box
+
+ OptionsList - Each string in it is an option of the one-of box
+
+ OptionCount - Option string count
+
+ FormBuffer - The form where this one-of box adds to
+
+ StringBuffer - String buffer created for Prompt, Help and Option strings
+
+Returns:
+
+ EFI_DEVICE_ERROR - DataWidth > 2
+
+ EFI_SUCCESS - One-Of box successfully created.
+
+--*/
+;
+
+EFI_STATUS
+CreateOrderedList (
+ IN UINT16 QuestionId,
+ IN UINT8 MaxEntries,
+ IN CHAR16 *Prompt,
+ IN CHAR16 *Help,
+ IN IFR_OPTION *OptionsList,
+ IN UINTN OptionCount,
+ IN OUT VOID *FormBuffer,
+ IN OUT VOID *StringBuffer
+ )
+/*++
+
+Routine Description:
+
+ Create a one-of question with a set of options to choose from. The
+ OptionsList is a pointer to a null-terminated list of option descriptions.
+
+Arguments:
+
+ QuestionId - Question ID of the ordered list
+
+ MaxEntries - MaxEntries of the ordered list
+
+ Prompt - Prompt of the ordered list
+
+ Help - Help of the ordered list
+
+ OptionsList - Each string in it is an option of the ordered list
+
+ OptionCount - Option string count
+
+ FormBuffer - The form where this ordered list adds to
+
+ StringBuffer - String buffer created for Prompt, Help and Option strings
+
+Returns:
+
+ EFI_SUCCESS - Ordered list successfully created.
+
+--*/
+;
+
+EFI_STATUS
+CreateCheckBox (
+ IN UINT16 QuestionId,
+ IN UINT8 DataWidth,
+ IN CHAR16 *Prompt,
+ IN CHAR16 *Help,
+ IN UINT8 Flags,
+ IN OUT VOID *FormBuffer,
+ IN OUT VOID *StringBuffer
+ )
+/*++
+
+Routine Description:
+
+ Create a checkbox
+
+Arguments:
+
+ QuestionId - Question ID of the check box
+
+ DataWidth - DataWidth of the check box
+
+ Prompt - Prompt of the check box
+
+ Help - Help of the check box
+
+ Flags - Flags of the check box
+
+ FormBuffer - The form where this check box adds to
+
+ StringBuffer - String buffer created for Prompt and Help.
+
+Returns:
+
+ EFI_DEVICE_ERROR - DataWidth > 1
+
+ EFI_SUCCESS - Check box successfully created
+
+--*/
+;
+
+EFI_STATUS
+CreateNumeric (
+ IN UINT16 QuestionId,
+ IN UINT8 DataWidth,
+ IN CHAR16 *Prompt,
+ IN CHAR16 *Help,
+ IN UINT16 Minimum,
+ IN UINT16 Maximum,
+ IN UINT16 Step,
+ IN UINT16 Default,
+ IN UINT8 Flags,
+ IN UINT16 Key,
+ IN OUT VOID *FormBuffer,
+ IN OUT VOID *StringBuffer
+ )
+/*++
+
+Routine Description:
+
+ Create a numeric
+
+Arguments:
+
+ QuestionId - Question ID of the numeric
+
+ DataWidth - DataWidth of the numeric
+
+ Prompt - Prompt of the numeric
+
+ Help - Help of the numeric
+
+ Minimum - Minumun boundary of the numeric
+
+ Maximum - Maximum boundary of the numeric
+
+ Step - Step of the numeric
+
+ Default - Default value
+
+ Flags - Flags of the numeric
+
+ Key - Key of the numeric
+
+ FormBuffer - The form where this numeric adds to
+
+ StringBuffer - String buffer created for Prompt and Help.
+
+Returns:
+
+ EFI_DEVICE_ERROR - DataWidth > 2
+
+ EFI_SUCCESS - Numeric is successfully created
+
+--*/
+;
+
+EFI_STATUS
+CreateString (
+ IN UINT16 QuestionId,
+ IN UINT8 DataWidth,
+ IN CHAR16 *Prompt,
+ IN CHAR16 *Help,
+ IN UINT8 MinSize,
+ IN UINT8 MaxSize,
+ IN UINT8 Flags,
+ IN UINT16 Key,
+ IN OUT VOID *FormBuffer,
+ IN OUT VOID *StringBuffer
+ )
+/*++
+
+Routine Description:
+
+ Create a string
+
+Arguments:
+
+ QuestionId - Question ID of the string
+
+ DataWidth - DataWidth of the string
+
+ Prompt - Prompt of the string
+
+ Help - Help of the string
+
+ MinSize - Min size boundary of the string
+
+ MaxSize - Max size boundary of the string
+
+ Flags - Flags of the string
+
+ Key - Key of the string
+
+ FormBuffer - The form where this string adds to
+
+ StringBuffer - String buffer created for Prompt and Help.
+
+Returns:
+
+ EFI_SUCCESS - String successfully created.
+
+--*/
+;
+
+EFI_STATUS
+ExtractDataFromHiiHandle (
+ IN EFI_HII_HANDLE HiiHandle,
+ IN OUT UINT16 *ImageLength,
+ OUT UINT8 *DefaultImage,
+ OUT EFI_GUID *Guid
+ )
+/*++
+
+Routine Description:
+
+ Extract information pertaining to the HiiHandle
+
+Arguments:
+
+ HiiHandle - Hii handle
+
+ ImageLength - For input, length of DefaultImage;
+ For output, length of actually required
+
+ DefaultImage - Image buffer prepared by caller
+
+ Guid - Guid information about the form
+
+Returns:
+
+ EFI_OUT_OF_RESOURCES - No enough buffer to allocate
+
+ EFI_BUFFER_TOO_SMALL - DefualtImage has no enough ImageLength
+
+ EFI_SUCCESS - Successfully extract data from Hii database.
+
+
+--*/
+;
+
+EFI_HII_HANDLE
+FindHiiHandle (
+ IN OUT EFI_HII_PROTOCOL **HiiProtocol, OPTIONAL
+ IN EFI_GUID *Guid
+ )
+/*++
+
+Routine Description:
+ Finds HII handle for given pack GUID previously registered with the HII.
+
+Arguments:
+ HiiProtocol - pointer to pointer to HII protocol interface.
+ If NULL, the interface will be found but not returned.
+ If it points to NULL, the interface will be found and
+ written back to the pointer that is pointed to.
+ Guid - The GUID of the pack that registered with the HII.
+
+Returns:
+ Handle to the HII pack previously registered by the memory driver.
+
+--*/
+;
+
+EFI_STATUS
+CreateSubTitleOpCode (
+ IN STRING_REF StringToken,
+ IN OUT VOID *FormBuffer
+ )
+/*++
+
+Routine Description:
+
+ Create a SubTitle opcode independent of string creation
+ This is used primarily by users who need to create just one particular valid op-code and the string
+ data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label
+ location to pre-defined forms in HII)
+
+Arguments:
+
+ StringToken - StringToken of the subtitle
+
+ FormBuffer - Output of subtitle as a form
+
+Returns:
+
+ EFI_SUCCESS - Subtitle created to be a form
+
+--*/
+;
+
+EFI_STATUS
+CreateTextOpCode (
+ IN STRING_REF StringToken,
+ IN STRING_REF StringTokenTwo,
+ IN STRING_REF StringTokenThree,
+ IN UINT8 Flags,
+ IN UINT16 Key,
+ IN OUT VOID *FormBuffer
+ )
+/*++
+
+Routine Description:
+
+ Create a Text opcode independent of string creation
+ This is used primarily by users who need to create just one particular valid op-code and the string
+ data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label
+ location to pre-defined forms in HII)
+
+Arguments:
+
+ StringToken - First string token of the text
+
+ StringTokenTwo - Second string token of the text
+
+ StringTokenThree - Help string token of the text
+
+ Flags - Flag of the text
+
+ Key - Key of the text
+
+ FormBuffer - Output of text as a form
+
+Returns:
+
+ EFI_SUCCESS - Text created to be a form
+
+--*/
+;
+
+EFI_STATUS
+CreateGotoOpCode (
+ IN UINT16 FormId,
+ IN STRING_REF StringToken,
+ IN STRING_REF StringTokenTwo,
+ IN UINT8 Flags,
+ IN UINT16 Key,
+ IN OUT VOID *FormBuffer
+ )
+/*++
+
+Routine Description:
+
+ Create a hyperlink opcode independent of string creation
+ This is used primarily by users who need to create just one particular valid op-code and the string
+ data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label
+ location to pre-defined forms in HII)
+
+Arguments:
+
+ FormId - Form ID of the hyperlink
+
+ StringToken - Prompt string token of the hyperlink
+
+ StringTokenTwo - Help string token of the hyperlink
+
+ Flags - Flags of the hyperlink
+
+ Key - Key of the hyperlink
+
+ FormBuffer - Output of hyperlink as a form
+
+Returns:
+
+ EFI_SUCCESS - Hyperlink created to be a form
+
+--*/
+;
+
+EFI_STATUS
+CreateOneOfOpCode (
+ IN UINT16 QuestionId,
+ IN UINT8 DataWidth,
+ IN STRING_REF PromptToken,
+ IN STRING_REF HelpToken,
+ IN IFR_OPTION *OptionsList,
+ IN UINTN OptionCount,
+ IN OUT VOID *FormBuffer
+ )
+/*++
+
+Routine Description:
+
+ Create a one-of opcode with a set of option op-codes to choose from independent of string creation.
+ This is used primarily by users who need to create just one particular valid op-code and the string
+ data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label
+ location to pre-defined forms in HII)
+
+ OptionsList is a pointer to a null-terminated list of option descriptions. Ensure that OptionsList[x].StringToken
+ has been filled in since this routine will not generate StringToken values.
+
+Arguments:
+
+ QuestionId - Question ID of the one-of box
+
+ DataWidth - DataWidth of the one-of box
+
+ PromptToken - Prompt string token of the one-of box
+
+ HelpToken - Help string token of the one-of box
+
+ OptionsList - Each string in it is an option of the one-of box
+
+ OptionCount - Option string count
+
+ FormBuffer - Output of One-Of box as a form
+
+Returns:
+
+ EFI_SUCCESS - One-Of box created to be a form
+
+ EFI_DEVICE_ERROR - DataWidth > 2
+
+--*/
+;
+
+EFI_STATUS
+CreateOrderedListOpCode (
+ IN UINT16 QuestionId,
+ IN UINT8 MaxEntries,
+ IN STRING_REF PromptToken,
+ IN STRING_REF HelpToken,
+ IN IFR_OPTION *OptionsList,
+ IN UINTN OptionCount,
+ IN OUT VOID *FormBuffer
+ )
+/*++
+
+Routine Description:
+
+ Create a ordered list opcode with a set of option op-codes to choose from independent of string creation.
+ This is used primarily by users who need to create just one particular valid op-code and the string
+ data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label
+ location to pre-defined forms in HII)
+
+ OptionsList is a pointer to a null-terminated list of option descriptions. Ensure that OptionsList[x].StringToken
+ has been filled in since this routine will not generate StringToken values.
+
+Arguments:
+
+ QuestionId - Question ID of the ordered list
+
+ MaxEntries - MaxEntries of the ordered list
+
+ PromptToken - Prompt string token of the ordered list
+
+ HelpToken - Help string token of the ordered list
+
+ OptionsList - Each string in it is an option of the ordered list
+
+ OptionCount - Option string count
+
+ FormBuffer - Output of ordered list as a form
+
+Returns:
+
+ EFI_SUCCESS - Ordered list created to be a form
+
+--*/
+;
+
+EFI_STATUS
+CreateCheckBoxOpCode (
+ IN UINT16 QuestionId,
+ IN UINT8 DataWidth,
+ IN STRING_REF PromptToken,
+ IN STRING_REF HelpToken,
+ IN UINT8 Flags,
+ IN UINT16 Key,
+ IN OUT VOID *FormBuffer
+ )
+/*++
+
+Routine Description:
+
+ Create a checkbox opcode independent of string creation
+ This is used primarily by users who need to create just one particular valid op-code and the string
+ data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label
+ location to pre-defined forms in HII)
+
+Arguments:
+
+ QuestionId - Question ID of the check box
+
+ DataWidth - DataWidth of the check box
+
+ PromptToken - Prompt string token of the check box
+
+ HelpToken - Help string token of the check box
+
+ Flags - Flags of the check box
+
+ Key - Key of the check box
+
+ FormBuffer - Output of the check box as a form
+
+Returns:
+
+ EFI_SUCCESS - Checkbox created to be a form
+
+ EFI_DEVICE_ERROR - DataWidth > 1
+
+--*/
+;
+
+EFI_STATUS
+CreateNumericOpCode (
+ IN UINT16 QuestionId,
+ IN UINT8 DataWidth,
+ IN STRING_REF PromptToken,
+ IN STRING_REF HelpToken,
+ IN UINT16 Minimum,
+ IN UINT16 Maximum,
+ IN UINT16 Step,
+ IN UINT16 Default,
+ IN UINT8 Flags,
+ IN UINT16 Key,
+ IN OUT VOID *FormBuffer
+ )
+/*++
+
+Routine Description:
+
+ Create a numeric opcode independent of string creation
+ This is used primarily by users who need to create just one particular valid op-code and the string
+ data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label
+ location to pre-defined forms in HII)
+
+Arguments:
+
+ QuestionId - Question ID of the numeric
+
+ DataWidth - DataWidth of the numeric
+
+ PromptToken - Prompt string token of the numeric
+
+ HelpToken - Help string token of the numeric
+
+ Minimum - Minumun boundary of the numeric
+
+ Maximum - Maximum boundary of the numeric
+
+ Step - Step of the numeric
+
+ Default - Default value of the numeric
+
+ Flags - Flags of the numeric
+
+ Key - Key of the numeric
+
+ FormBuffer - Output of the numeric as a form
+
+Returns:
+
+ EFI_SUCCESS - The numeric created to be a form.
+
+ EFI_DEVICE_ERROR - DataWidth > 2
+
+--*/
+;
+
+EFI_STATUS
+CreateStringOpCode (
+ IN UINT16 QuestionId,
+ IN UINT8 DataWidth,
+ IN STRING_REF PromptToken,
+ IN STRING_REF HelpToken,
+ IN UINT8 MinSize,
+ IN UINT8 MaxSize,
+ IN UINT8 Flags,
+ IN UINT16 Key,
+ IN OUT VOID *FormBuffer
+ )
+/*++
+
+Routine Description:
+
+ Create a numeric opcode independent of string creation
+ This is used primarily by users who need to create just one particular valid op-code and the string
+ data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label
+ location to pre-defined forms in HII)
+
+Arguments:
+
+ QuestionId - Question ID of the string
+
+ DataWidth - DataWidth of the string
+
+ PromptToken - Prompt token of the string
+
+ HelpToken - Help token of the string
+
+ MinSize - Min size boundary of the string
+
+ MaxSize - Max size boundary of the string
+
+ Flags - Flags of the string
+
+ Key - Key of the string
+
+ FormBuffer - Output of the string as a form
+
+Returns:
+
+ EFI_SUCCESS - String created to be a form.
+
+--*/
+;
+
+EFI_STATUS
+ValidateDataFromHiiHandle (
+ IN EFI_HII_HANDLE HiiHandle,
+ OUT BOOLEAN *Results
+ )
+/*++
+
+Routine Description:
+
+ Validate that the data associated with the HiiHandle in NVRAM is within
+ the reasonable parameters for that FormSet. Values for strings and passwords
+ are not verified due to their not having the equivalent of valid range settings.
+
+Arguments:
+
+ HiiHandle - Handle of the HII database entry to query
+
+ Results - If return Status is EFI_SUCCESS, Results provides valid data
+ TRUE = NVRAM Data is within parameters
+ FALSE = NVRAM Data is NOT within parameters
+
+Returns:
+
+ EFI_OUT_OF_RESOURCES - No enough buffer to allocate
+
+ EFI_SUCCESS - Data successfully validated
+--*/
+;
+
+EFI_STATUS
+CreateBannerOpCode (
+ IN UINT16 Title,
+ IN UINT16 LineNumber,
+ IN UINT8 Alignment,
+ IN OUT VOID *FormBuffer
+ )
+/*++
+
+Routine Description:
+
+ Create a banner opcode. This is primarily used by the FrontPage implementation from BDS.
+
+Arguments:
+
+ Title - Title of the banner
+
+ LineNumber - LineNumber of the banner
+
+ Alignment - Alignment of the banner
+
+ FormBuffer - Output of banner as a form
+
+Returns:
+
+ EFI_SUCCESS - Banner created to be a form.
+
+--*/
+;
+
+EFI_HII_PACKAGES *
+PreparePackages (
+ IN UINTN NumberOfPackages,
+ IN EFI_GUID *GuidId,
+ ...
+ )
+/*++
+
+Routine Description:
+
+ Assemble EFI_HII_PACKAGES according to the passed in packages.
+
+Arguments:
+
+ NumberOfPackages - Number of packages.
+ GuidId - Package GUID.
+
+Returns:
+
+ Pointer of EFI_HII_PACKAGES.
+
+--*/
+;
+
+VOID
+EfiLibHiiVariablePackGetMap (
+ IN EFI_HII_VARIABLE_PACK *Pack,
+ OUT CHAR16 **Name, OPTIONAL
+ OUT EFI_GUID **Guid, OPTIONAL
+ OUT UINT16 *Id, OPTIONAL
+ OUT VOID **Var, OPTIONAL
+ OUT UINTN *Size OPTIONAL
+ )
+/*++
+
+Routine Description:
+
+ Extracts a variable form a Pack.
+
+Arguments:
+
+ Pack - List of variables
+ Name - Name of the variable/map
+ Guid - GUID of the variable/map
+ Var - Pointer to the variable/map
+ Size - Size of the variable/map in bytes
+
+Returns:
+
+ VOID.
+
+--*/
+;
+
+UINTN
+EfiLibHiiVariablePackListGetMapCnt (
+ IN EFI_HII_VARIABLE_PACK_LIST *List
+ )
+/*++
+
+Routine Description:
+
+ Finds a count of the variables/maps in the List.
+
+Arguments:
+
+ List - List of variables
+
+Returns:
+
+ Number of Map in the variable pack list.
+
+--*/
+;
+
+typedef VOID (EFI_LIB_HII_VARIABLE_PACK_LIST_CALLBACK) (
+ IN CHAR16 *Name,
+ IN EFI_GUID *Guid,
+ IN UINT16 Id,
+ IN VOID *Var,
+ IN UINTN Size
+ )
+/*++
+
+Routine Description:
+
+ type definition for the callback to be
+ used with EfiLibHiiVariablePackListForEachVar().
+
+Arguments:
+
+ Id - Variable/Map ID
+ Name - Name of the variable/map
+ Guid - GUID of the variable/map
+ Var - Pointer to the variable/map
+ Size - Size of the variable/map in bytes
+
+Returns:
+
+ VOID
+
+--*/
+;
+
+VOID
+EfiLibHiiVariablePackListForEachVar (
+ IN EFI_HII_VARIABLE_PACK_LIST *List,
+ IN EFI_LIB_HII_VARIABLE_PACK_LIST_CALLBACK *Callback
+ )
+/*++
+
+Routine Description:
+
+ Will iterate all variable/maps as appearing
+ in List and for each, it will call the Callback.
+
+Arguments:
+
+ List - List of variables
+ Callback - Routine to be called for each iterated variable.
+
+Returns:
+
+ VOID
+
+--*/
+;
+
+EFI_STATUS
+EfiLibHiiVariablePackListGetMapByIdx (
+ IN UINTN Idx,
+ IN EFI_HII_VARIABLE_PACK_LIST *List,
+ OUT CHAR16 **Name, OPTIONAL
+ OUT EFI_GUID **Guid, OPTIONAL
+ OUT UINT16 *Id, OPTIONAL
+ OUT VOID **Var,
+ OUT UINTN *Size
+ )
+/*++
+
+Routine Description:
+
+ Finds a variable form List given
+ the order number as appears in the List.
+
+Arguments:
+
+ Idx - The index of the variable/map to retrieve
+ List - List of variables
+ Name - Name of the variable/map
+ Guid - GUID of the variable/map
+ Var - Pointer to the variable/map
+ Size - Size of the variable/map in bytes
+
+Returns:
+
+ EFI_SUCCESS - Variable is found, OUT parameters are valid
+ EFI_NOT_FOUND - Variable is not found, OUT parameters are not valid
+
+--*/
+;
+
+EFI_STATUS
+EfiLibHiiVariablePackListGetMapById (
+ IN UINT16 Id,
+ IN EFI_HII_VARIABLE_PACK_LIST *List,
+ OUT CHAR16 **Name, OPTIONAL
+ OUT EFI_GUID **Guid, OPTIONAL
+ OUT VOID **Var,
+ OUT UINTN *Size
+ )
+/*++
+
+Routine Description:
+
+ Finds a variable form List given the
+ order number as appears in the List.
+
+Arguments:
+
+ Id - The ID of the variable/map to retrieve
+ List - List of variables
+ Name - Name of the variable/map
+ Guid - GUID of the variable/map
+ Var - Pointer to the variable/map
+ Size - Size of the variable/map in bytes
+
+Returns:
+
+ EFI_SUCCESS - Variable is found, OUT parameters are valid
+ EFI_NOT_FOUND - Variable is not found, OUT parameters are not valid
+
+--*/
+;
+
+EFI_STATUS
+EfiLibHiiVariablePackListGetMap (
+ IN EFI_HII_VARIABLE_PACK_LIST *List,
+ IN CHAR16 *Name,
+ IN EFI_GUID *Guid,
+ OUT UINT16 *Id,
+ OUT VOID **Var,
+ OUT UINTN *Size
+ )
+/*++
+
+Routine Description:
+
+ Finds a variable form EFI_HII_VARIABLE_PACK_LIST given name and GUID.
+
+Arguments:
+
+ List - List of variables
+ Name - Name of the variable/map to be found
+ Guid - GUID of the variable/map to be found
+ Var - Pointer to the variable/map found
+ Size - Size of the variable/map in bytes found
+
+Returns:
+
+ EFI_SUCCESS - variable is found, OUT parameters are valid
+ EFI_NOT_FOUND - variable is not found, OUT parameters are not valid
+
+--*/
+;
+
+EFI_STATUS
+EfiLibHiiVariableRetrieveFromNv (
+ IN CHAR16 *Name,
+ IN EFI_GUID *Guid,
+ IN UINTN Size,
+ OUT VOID **Var
+ )
+/*++
+
+Routine Description:
+ Finds out if a variable of specific Name/Guid/Size exists in NV.
+ If it does, it will retrieve it into the Var.
+
+Arguments:
+ Name, Guid, Size - Parameters of the variable to retrieve. Must match exactly.
+ Var - Variable will be retrieved into buffer pointed by this pointer.
+ If pointing to NULL, the buffer will be allocated. Caller is responsible for releasing the buffer.
+Returns:
+ EFI_SUCCESS - The variable of exact Name/Guid/Size parameters was retrieved and written to Var.
+ EFI_NOT_FOUND - The variable of this Name/Guid was not found in the NV.
+ EFI_LOAD_ERROR - The variable in the NV was of different size, or NV API returned error.
+
+--*/
+;
+
+////
+//// Variable override support.
+////
+
+EFI_STATUS
+EfiLibHiiVariableOverrideIfSuffix (
+ IN CHAR16 *Suffix,
+ IN CHAR16 *Name,
+ IN EFI_GUID *Guid,
+ IN UINTN Size,
+ OUT VOID *Var
+ )
+/*++
+
+Routine Description:
+ Overrrides the variable with NV data if found.
+ But it only does it if the Name ends with specified Suffix.
+ For example, if Suffix="MyOverride" and the Name="XyzSetupMyOverride",
+ the Suffix matches the end of Name, so the variable will be loaded from NV
+ provided the variable exists and the GUID and Size matches.
+
+Arguments:
+ Suffix - Suffix the Name should end with.
+ Name, Guid, Size - Parameters of the variable to retrieve. Must match exactly.
+ Var - Variable will be retrieved into this buffer.
+ Caller is responsible for providing storage of exactly Size size in bytes.
+Returns:
+ EFI_SUCCESS - The variable was overriden with NV variable of same Name/Guid/Size.
+ EFI_INVALID_PARAMETER - The name of the variable does not end with <Suffix>.
+ EFI_NOT_FOUND - The variable of this Name/Guid was not found in the NV.
+ EFI_LOAD_ERROR - The variable in the NV was of different size, or NV API returned error.
+
+--*/
+;
+
+EFI_STATUS
+EfiLibHiiVariableOverrideBySuffix (
+ IN CHAR16 *Suffix,
+ IN CHAR16 *Name,
+ IN EFI_GUID *Guid,
+ IN UINTN Size,
+ OUT VOID *Var
+ )
+/*++
+
+Routine Description:
+ Overrrides the variable with NV data if found.
+ But it only does it if the NV contains the same variable with Name is appended with Suffix.
+ For example, if Suffix="MyOverride" and the Name="XyzSetup",
+ the Suffix will be appended to the end of Name, and the variable with Name="XyzSetupMyOverride"
+ will be loaded from NV provided the variable exists and the GUID and Size matches.
+
+Arguments:
+ Suffix - Suffix the variable will be appended with.
+ Name, Guid, Size - Parameters of the variable to retrieve. Must match exactly.
+ Var - Variable will be retrieved into this buffer.
+ Caller is responsible for providing storage of exactly Size size in bytes.
+
+Returns:
+ EFI_SUCCESS - The variable was overriden with NV variable of same Name/Guid/Size.
+ EFI_NOT_FOUND - The variable of this Name/Guid was not found in the NV.
+ EFI_LOAD_ERROR - The variable in the NV was of different size, or NV API returned error.
+
+--*/
+;
+
+#endif
diff --git a/EDK/Foundation/Library/Dxe/EfiIfrSupportLib/IfrOnTheFly.c b/EDK/Foundation/Library/Dxe/EfiIfrSupportLib/IfrOnTheFly.c
new file mode 100644
index 0000000..7daadd4
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/EfiIfrSupportLib/IfrOnTheFly.c
@@ -0,0 +1,974 @@
+/*++
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+ IfrOnTheFly.c
+
+Abstract:
+
+ Library Routines to create IFR on-the-fly
+
+Revision History:
+
+--*/
+
+#include "IfrLibrary.h"
+
+EFI_STATUS
+CreateFormSet (
+ IN CHAR16 *FormSetTitle,
+ IN EFI_GUID *Guid,
+ IN UINT8 Class,
+ IN UINT8 SubClass,
+ IN OUT VOID **FormBuffer,
+ IN OUT VOID **StringBuffer
+ )
+/*++
+
+Routine Description:
+
+ Create a formset
+
+Arguments:
+
+ FormSetTitle - Title of formset
+
+ Guid - Guid of formset
+
+ Class - Class of formset
+
+ SubClass - Sub class of formset
+
+ FormBuffer - Pointer of the formset created
+
+ StringBuffer - Pointer of FormSetTitile string created
+
+Returns:
+
+ EFI_OUT_OF_RESOURCES - No enough buffer to allocate
+
+ EFI_SUCCESS - Formset successfully created
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_HII_IFR_PACK IfrPack;
+ EFI_IFR_FORM_SET FormSet;
+ EFI_IFR_END_FORM_SET EndFormSet;
+ UINT8 *Destination;
+ CHAR16 CurrentLanguage[4];
+ STRING_REF StringToken;
+
+ //
+ // Pre-allocate a buffer sufficient for us to work from.
+ //
+ FormBuffer = EfiLibAllocateZeroPool (DEFAULT_FORM_BUFFER_SIZE);
+ if (FormBuffer == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ //
+ // Pre-allocate a buffer sufficient for us to work from.
+ //
+ StringBuffer = EfiLibAllocateZeroPool (DEFAULT_STRING_BUFFER_SIZE);
+ if (StringBuffer == NULL) {
+ gBS->FreePool (FormBuffer);
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ //
+ // Obtain current language value
+ //
+ GetCurrentLanguage (CurrentLanguage);
+
+ //
+ // Add the FormSetTitle to the string buffer and get the StringToken
+ //
+ Status = AddString (*StringBuffer, CurrentLanguage, FormSetTitle, &StringToken);
+
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ //
+ // Initialize the Ifr Package header data
+ //
+ IfrPack.Header.Length = sizeof (EFI_HII_PACK_HEADER) + sizeof (EFI_IFR_FORM_SET) + sizeof (EFI_IFR_END_FORM_SET);
+ IfrPack.Header.Type = EFI_HII_IFR;
+
+ //
+ // Initialize FormSet with the appropriate information
+ //
+ FormSet.Header.OpCode = EFI_IFR_FORM_SET_OP;
+ FormSet.Header.Length = sizeof (EFI_IFR_FORM_SET);
+ FormSet.FormSetTitle = StringToken;
+ FormSet.Class = Class;
+ FormSet.SubClass = SubClass;
+ EfiCopyMem (&FormSet.Guid, Guid, sizeof (EFI_GUID));
+
+ //
+ // Initialize the end formset data
+ //
+ EndFormSet.Header.Length = sizeof (EFI_IFR_END_FORM_SET);
+ EndFormSet.Header.OpCode = EFI_IFR_END_FORM_SET_OP;
+
+ Destination = (CHAR8 *) *FormBuffer;
+
+ //
+ // Copy the formset/endformset data to the form buffer
+ //
+ EfiCopyMem (Destination, &IfrPack, sizeof (EFI_HII_PACK_HEADER));
+
+ Destination = Destination + sizeof (EFI_HII_PACK_HEADER);
+
+ EfiCopyMem (Destination, &FormSet, sizeof (EFI_IFR_FORM_SET));
+
+ Destination = Destination + sizeof (EFI_IFR_FORM_SET);
+
+ EfiCopyMem (Destination, &EndFormSet, sizeof (EFI_IFR_END_FORM_SET));
+ return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+CreateForm (
+ IN CHAR16 *FormTitle,
+ IN UINT16 FormId,
+ IN OUT VOID *FormBuffer,
+ IN OUT VOID *StringBuffer
+ )
+/*++
+
+Routine Description:
+
+ Create a form
+
+Arguments:
+
+ FormTitle - Title of the form
+
+ FormId - Id of the form
+
+ FormBuffer - Pointer of the form created
+
+ StringBuffer - Pointer of FormTitil string created
+
+Returns:
+
+ EFI_SUCCESS - Form successfully created
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_IFR_FORM Form;
+ EFI_IFR_END_FORM EndForm;
+ CHAR16 CurrentLanguage[4];
+ STRING_REF StringToken;
+
+ //
+ // Obtain current language value
+ //
+ GetCurrentLanguage (CurrentLanguage);
+
+ Status = AddString (StringBuffer, CurrentLanguage, FormTitle, &StringToken);
+
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Form.Header.OpCode = EFI_IFR_FORM_OP;
+ Form.Header.Length = sizeof (EFI_IFR_FORM);
+ Form.FormId = FormId;
+ Form.FormTitle = StringToken;
+
+ Status = AddOpCode (FormBuffer, &Form);
+
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ EndForm.Header.OpCode = EFI_IFR_END_FORM_OP;
+ EndForm.Header.Length = sizeof (EFI_IFR_END_FORM);
+
+ Status = AddOpCode (FormBuffer, &EndForm);
+
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+CreateSubTitle (
+ IN CHAR16 *SubTitle,
+ IN OUT VOID *FormBuffer,
+ IN OUT VOID *StringBuffer
+ )
+/*++
+
+Routine Description:
+
+ Create a SubTitle
+
+Arguments:
+
+ SubTitle - Sub title to be created
+
+ FormBuffer - Where this subtitle to add to
+
+ StringBuffer - String buffer created for subtitle
+
+Returns:
+
+ EFI_SUCCESS - Subtitle successfully created
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_IFR_SUBTITLE Subtitle;
+ CHAR16 CurrentLanguage[4];
+ STRING_REF StringToken;
+
+ //
+ // Obtain current language value
+ //
+ GetCurrentLanguage (CurrentLanguage);
+
+ Status = AddString (StringBuffer, CurrentLanguage, SubTitle, &StringToken);
+
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Subtitle.Header.OpCode = EFI_IFR_SUBTITLE_OP;
+ Subtitle.Header.Length = sizeof (EFI_IFR_SUBTITLE);
+ Subtitle.SubTitle = StringToken;
+
+ Status = AddOpCode (FormBuffer, &Subtitle);
+
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+CreateText (
+ IN CHAR16 *String,
+ IN CHAR16 *String2,
+ IN CHAR16 *String3,
+ IN UINT8 Flags,
+ IN UINT16 Key,
+ IN OUT VOID *FormBuffer,
+ IN OUT VOID *StringBuffer
+ )
+/*++
+
+Routine Description:
+
+ Create a line of text
+
+Arguments:
+
+ String - First string of the text
+
+ String2 - Second string of the text
+
+ String3 - Help string of the text
+
+ Flags - Flag of the text
+
+ Key - Key of the text
+
+ FormBuffer - The form where this text adds to
+
+ StringBuffer - String buffer created for String, String2 and String3
+
+Returns:
+
+ EFI_SUCCESS - Text successfully created
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_IFR_TEXT Text;
+ CHAR16 CurrentLanguage[4];
+ STRING_REF StringToken;
+
+ //
+ // Obtain current language value
+ //
+ GetCurrentLanguage (CurrentLanguage);
+
+ //
+ // Add first string, get first string's token
+ //
+ Status = AddString (StringBuffer, CurrentLanguage, String, &StringToken);
+
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Text.Header.OpCode = EFI_IFR_TEXT_OP;
+ Text.Header.Length = sizeof (EFI_IFR_TEXT);
+ Text.Text = StringToken;
+
+ //
+ // Add second string, get first string's token
+ //
+ Status = AddString (StringBuffer, CurrentLanguage, String2, &StringToken);
+
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Text.TextTwo = StringToken;
+
+ Text.Flags = (UINT8) (Flags | EFI_IFR_FLAG_CREATED);
+ Text.Key = Key;
+
+ //
+ // Add second string, get first string's token
+ //
+ Status = AddString (StringBuffer, CurrentLanguage, String3, &StringToken);
+
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Text.Help = StringToken;
+
+ Status = AddOpCode (FormBuffer, &Text);
+
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+CreateGoto (
+ IN UINT16 FormId,
+ IN CHAR16 *Prompt,
+ IN OUT VOID *FormBuffer,
+ IN OUT VOID *StringBuffer
+ )
+/*++
+
+Routine Description:
+
+ Create a hyperlink
+
+Arguments:
+
+ FormId - Form ID of the hyperlink
+
+ Prompt - Prompt of the hyperlink
+
+ FormBuffer - The form where this hyperlink adds to
+
+ StringBuffer - String buffer created for Prompt
+
+Returns:
+
+ EFI_SUCCESS - Hyperlink successfully created
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_IFR_REF Hyperlink;
+ CHAR16 CurrentLanguage[4];
+ STRING_REF StringToken;
+
+ //
+ // Obtain current language value
+ //
+ GetCurrentLanguage (CurrentLanguage);
+
+ Status = AddString (StringBuffer, CurrentLanguage, Prompt, &StringToken);
+
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Hyperlink.Header.OpCode = EFI_IFR_REF_OP;
+ Hyperlink.Header.Length = sizeof (EFI_IFR_REF);
+ Hyperlink.FormId = FormId;
+ Hyperlink.Prompt = StringToken;
+
+ Status = AddOpCode (FormBuffer, &Hyperlink);
+
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+CreateOneOf (
+ IN UINT16 QuestionId,
+ IN UINT8 DataWidth,
+ IN CHAR16 *Prompt,
+ IN CHAR16 *Help,
+ IN IFR_OPTION *OptionsList,
+ IN UINTN OptionCount,
+ IN OUT VOID *FormBuffer,
+ IN OUT VOID *StringBuffer
+ )
+/*++
+
+Routine Description:
+
+ Create a one-of question with a set of options to choose from. The
+ OptionsList is a pointer to a null-terminated list of option descriptions.
+
+Arguments:
+
+ QuestionId - Question ID of the one-of box
+
+ DataWidth - DataWidth of the one-of box
+
+ Prompt - Prompt of the one-of box
+
+ Help - Help of the one-of box
+
+ OptionsList - Each string in it is an option of the one-of box
+
+ OptionCount - Option string count
+
+ FormBuffer - The form where this one-of box adds to
+
+ StringBuffer - String buffer created for Prompt, Help and Option strings
+
+Returns:
+
+ EFI_DEVICE_ERROR - DataWidth > 2
+
+ EFI_SUCCESS - One-Of box successfully created.
+
+--*/
+{
+ EFI_STATUS Status;
+ UINTN Index;
+ EFI_IFR_ONE_OF OneOf;
+ EFI_IFR_ONE_OF_OPTION OneOfOption;
+ EFI_IFR_END_ONE_OF EndOneOf;
+ CHAR16 CurrentLanguage[4];
+ STRING_REF StringToken;
+
+ //
+ // We do not create op-code storage widths for one-of in excess of 16 bits for now
+ //
+ if (DataWidth > 2) {
+ return EFI_DEVICE_ERROR;
+ }
+
+ //
+ // Obtain current language value
+ //
+ GetCurrentLanguage (CurrentLanguage);
+
+ //
+ // Add first string, get first string's token
+ //
+ Status = AddString (StringBuffer, CurrentLanguage, Prompt, &StringToken);
+
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ OneOf.Header.OpCode = EFI_IFR_ONE_OF_OP;
+ OneOf.Header.Length = sizeof (EFI_IFR_ONE_OF);
+ OneOf.QuestionId = QuestionId;
+ OneOf.Width = DataWidth;
+ OneOf.Prompt = StringToken;
+
+ //
+ // Add second string, get first string's token
+ //
+ Status = AddString (StringBuffer, CurrentLanguage, Help, &StringToken);
+
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ OneOf.Help = StringToken;
+
+ Status = AddOpCode (FormBuffer, &OneOf);
+
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ for (Index = 0; Index < OptionCount; Index++) {
+ OneOfOption.Header.OpCode = EFI_IFR_ONE_OF_OPTION_OP;
+ OneOfOption.Header.Length = sizeof (EFI_IFR_ONE_OF_OPTION);
+
+ //
+ // Add string and get token back
+ //
+ Status = AddString (StringBuffer, CurrentLanguage, OptionsList[Index].OptionString, &StringToken);
+
+ OneOfOption.Option = StringToken;
+ OneOfOption.Value = OptionsList[Index].Value;
+ OneOfOption.Flags = (UINT8) (OptionsList[Index].Flags | EFI_IFR_FLAG_CREATED);
+ OneOfOption.Key = OptionsList[Index].Key;
+
+ Status = AddOpCode (FormBuffer, &OneOfOption);
+
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ }
+
+ EndOneOf.Header.Length = sizeof (EFI_IFR_END_ONE_OF);
+ EndOneOf.Header.OpCode = EFI_IFR_END_ONE_OF_OP;
+
+ Status = AddOpCode (FormBuffer, &EndOneOf);
+
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+CreateOrderedList (
+ IN UINT16 QuestionId,
+ IN UINT8 MaxEntries,
+ IN CHAR16 *Prompt,
+ IN CHAR16 *Help,
+ IN IFR_OPTION *OptionsList,
+ IN UINTN OptionCount,
+ IN OUT VOID *FormBuffer,
+ IN OUT VOID *StringBuffer
+ )
+/*++
+
+Routine Description:
+
+ Create a one-of question with a set of options to choose from. The
+ OptionsList is a pointer to a null-terminated list of option descriptions.
+
+Arguments:
+
+ QuestionId - Question ID of the ordered list
+
+ MaxEntries - MaxEntries of the ordered list
+
+ Prompt - Prompt of the ordered list
+
+ Help - Help of the ordered list
+
+ OptionsList - Each string in it is an option of the ordered list
+
+ OptionCount - Option string count
+
+ FormBuffer - The form where this ordered list adds to
+
+ StringBuffer - String buffer created for Prompt, Help and Option strings
+
+Returns:
+
+ EFI_SUCCESS - Ordered list successfully created.
+
+--*/
+{
+ EFI_STATUS Status;
+ UINTN Index;
+ EFI_IFR_ORDERED_LIST OrderedList;
+ EFI_IFR_ONE_OF_OPTION OrderedListOption;
+ EFI_IFR_END_ONE_OF EndOrderedList;
+ CHAR16 CurrentLanguage[4];
+ STRING_REF StringToken;
+
+ //
+ // Obtain current language value
+ //
+ GetCurrentLanguage (CurrentLanguage);
+
+ //
+ // Add first string, get first string's token
+ //
+ Status = AddString (StringBuffer, CurrentLanguage, Prompt, &StringToken);
+
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ OrderedList.Header.OpCode = EFI_IFR_ORDERED_LIST_OP;
+ OrderedList.Header.Length = sizeof (EFI_IFR_ORDERED_LIST);
+ OrderedList.QuestionId = QuestionId;
+ OrderedList.MaxEntries = MaxEntries;
+ OrderedList.Prompt = StringToken;
+
+ //
+ // Add second string, get first string's token
+ //
+ Status = AddString (StringBuffer, CurrentLanguage, Help, &StringToken);
+
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ OrderedList.Help = StringToken;
+
+ Status = AddOpCode (FormBuffer, &OrderedList);
+
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ for (Index = 0; Index < OptionCount; Index++) {
+ OrderedListOption.Header.OpCode = EFI_IFR_ONE_OF_OPTION_OP;
+ OrderedListOption.Header.Length = sizeof (EFI_IFR_ONE_OF_OPTION);
+
+ //
+ // Add string and get token back
+ //
+ Status = AddString (StringBuffer, CurrentLanguage, OptionsList[Index].OptionString, &StringToken);
+
+ OrderedListOption.Option = StringToken;
+ OrderedListOption.Value = OptionsList[Index].Value;
+ OrderedListOption.Flags = (UINT8) (OptionsList[Index].Flags | EFI_IFR_FLAG_CREATED);
+ OrderedListOption.Key = OptionsList[Index].Key;
+
+ Status = AddOpCode (FormBuffer, &OrderedListOption);
+
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ }
+
+ EndOrderedList.Header.Length = sizeof (EFI_IFR_END_ONE_OF);
+ EndOrderedList.Header.OpCode = EFI_IFR_END_ONE_OF_OP;
+
+ Status = AddOpCode (FormBuffer, &EndOrderedList);
+
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+CreateCheckBox (
+ IN UINT16 QuestionId,
+ IN UINT8 DataWidth,
+ IN CHAR16 *Prompt,
+ IN CHAR16 *Help,
+ IN UINT8 Flags,
+ IN OUT VOID *FormBuffer,
+ IN OUT VOID *StringBuffer
+ )
+/*++
+
+Routine Description:
+
+ Create a checkbox
+
+Arguments:
+
+ QuestionId - Question ID of the check box
+
+ DataWidth - DataWidth of the check box
+
+ Prompt - Prompt of the check box
+
+ Help - Help of the check box
+
+ Flags - Flags of the check box
+
+ FormBuffer - The form where this check box adds to
+
+ StringBuffer - String buffer created for Prompt and Help.
+
+Returns:
+
+ EFI_DEVICE_ERROR - DataWidth > 1
+
+ EFI_SUCCESS - Check box successfully created
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_IFR_CHECK_BOX CheckBox;
+ CHAR16 CurrentLanguage[4];
+ STRING_REF StringToken;
+
+ //
+ // We do not create op-code storage widths for checkbox in excess of 8 bits for now
+ //
+ if (DataWidth > 1) {
+ return EFI_DEVICE_ERROR;
+ }
+
+ //
+ // Obtain current language value
+ //
+ GetCurrentLanguage (CurrentLanguage);
+
+ //
+ // Add first string, get first string's token
+ //
+ Status = AddString (StringBuffer, CurrentLanguage, Prompt, &StringToken);
+
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ CheckBox.Header.OpCode = EFI_IFR_CHECKBOX_OP;
+ CheckBox.Header.Length = sizeof (EFI_IFR_CHECK_BOX);
+ CheckBox.QuestionId = QuestionId;
+ CheckBox.Width = DataWidth;
+ CheckBox.Prompt = StringToken;
+
+ //
+ // Add second string, get first string's token
+ //
+ Status = AddString (StringBuffer, CurrentLanguage, Help, &StringToken);
+
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ CheckBox.Help = StringToken;
+ CheckBox.Flags = (UINT8) (Flags | EFI_IFR_FLAG_CREATED);
+
+ Status = AddOpCode (FormBuffer, &CheckBox);
+
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+CreateNumeric (
+ IN UINT16 QuestionId,
+ IN UINT8 DataWidth,
+ IN CHAR16 *Prompt,
+ IN CHAR16 *Help,
+ IN UINT16 Minimum,
+ IN UINT16 Maximum,
+ IN UINT16 Step,
+ IN UINT16 Default,
+ IN UINT8 Flags,
+ IN UINT16 Key,
+ IN OUT VOID *FormBuffer,
+ IN OUT VOID *StringBuffer
+ )
+/*++
+
+Routine Description:
+
+ Create a numeric
+
+Arguments:
+
+ QuestionId - Question ID of the numeric
+
+ DataWidth - DataWidth of the numeric
+
+ Prompt - Prompt of the numeric
+
+ Help - Help of the numeric
+
+ Minimum - Minumun boundary of the numeric
+
+ Maximum - Maximum boundary of the numeric
+
+ Step - Step of the numeric
+
+ Default - Default value
+
+ Flags - Flags of the numeric
+
+ Key - Key of the numeric
+
+ FormBuffer - The form where this numeric adds to
+
+ StringBuffer - String buffer created for Prompt and Help.
+
+Returns:
+
+ EFI_DEVICE_ERROR - DataWidth > 2
+
+ EFI_SUCCESS - Numeric is successfully created
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_IFR_NUMERIC Numeric;
+ CHAR16 CurrentLanguage[4];
+ STRING_REF StringToken;
+
+ //
+ // We do not create op-code storage widths for numerics in excess of 16 bits for now
+ //
+ if (DataWidth > 2) {
+ return EFI_DEVICE_ERROR;
+ }
+
+ //
+ // Obtain current language value
+ //
+ GetCurrentLanguage (CurrentLanguage);
+
+ //
+ // Add first string, get first string's token
+ //
+ Status = AddString (StringBuffer, CurrentLanguage, Prompt, &StringToken);
+
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Numeric.Header.OpCode = EFI_IFR_NUMERIC_OP;
+ Numeric.Header.Length = sizeof (EFI_IFR_NUMERIC);
+ Numeric.QuestionId = QuestionId;
+ Numeric.Width = DataWidth;
+ Numeric.Prompt = StringToken;
+
+ //
+ // Add second string, get first string's token
+ //
+ Status = AddString (StringBuffer, CurrentLanguage, Help, &StringToken);
+
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Numeric.Help = StringToken;
+ Numeric.Minimum = Minimum;
+ Numeric.Maximum = Maximum;
+ Numeric.Step = Step;
+ Numeric.Default = Default;
+ Numeric.Flags = (UINT8) (Flags | EFI_IFR_FLAG_CREATED);
+ Numeric.Key = Key;
+
+ Status = AddOpCode (FormBuffer, &Numeric);
+
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+CreateString (
+ IN UINT16 QuestionId,
+ IN UINT8 DataWidth,
+ IN CHAR16 *Prompt,
+ IN CHAR16 *Help,
+ IN UINT8 MinSize,
+ IN UINT8 MaxSize,
+ IN UINT8 Flags,
+ IN UINT16 Key,
+ IN OUT VOID *FormBuffer,
+ IN OUT VOID *StringBuffer
+ )
+/*++
+
+Routine Description:
+
+ Create a string
+
+Arguments:
+
+ QuestionId - Question ID of the string
+
+ DataWidth - DataWidth of the string
+
+ Prompt - Prompt of the string
+
+ Help - Help of the string
+
+ MinSize - Min size boundary of the string
+
+ MaxSize - Max size boundary of the string
+
+ Flags - Flags of the string
+
+ Key - Key of the string
+
+ FormBuffer - The form where this string adds to
+
+ StringBuffer - String buffer created for Prompt and Help.
+
+Returns:
+
+ EFI_SUCCESS - String successfully created.
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_IFR_STRING String;
+ CHAR16 CurrentLanguage[4];
+ STRING_REF StringToken;
+
+ //
+ // Obtain current language value
+ //
+ GetCurrentLanguage (CurrentLanguage);
+
+ //
+ // Add first string, get first string's token
+ //
+ Status = AddString (StringBuffer, CurrentLanguage, Prompt, &StringToken);
+
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ String.Header.OpCode = EFI_IFR_STRING_OP;
+ String.Header.Length = sizeof (EFI_IFR_STRING);
+ String.QuestionId = QuestionId;
+ String.Width = DataWidth;
+ String.Prompt = StringToken;
+
+ //
+ // Add second string, get first string's token
+ //
+ Status = AddString (StringBuffer, CurrentLanguage, Help, &StringToken);
+
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ String.Help = StringToken;
+ String.MinSize = MinSize;
+ String.MaxSize = MaxSize;
+ String.Flags = (UINT8) (Flags | EFI_IFR_FLAG_CREATED);
+ String.Key = Key;
+
+ Status = AddOpCode (FormBuffer, &String);
+
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ return EFI_SUCCESS;
+}
diff --git a/EDK/Foundation/Library/Dxe/EfiIfrSupportLib/IfrOpCodeCreation.c b/EDK/Foundation/Library/Dxe/EfiIfrSupportLib/IfrOpCodeCreation.c
new file mode 100644
index 0000000..6759655
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/EfiIfrSupportLib/IfrOpCodeCreation.c
@@ -0,0 +1,615 @@
+/*++
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+ IfrOpCodeCreation.c
+
+Abstract:
+
+ Library Routines to create IFR independent of string data - assume tokens already exist
+ Primarily to be used for exporting op-codes at a label in pre-defined forms.
+
+Revision History:
+
+--*/
+
+#include "IfrLibrary.h"
+
+EFI_STATUS
+CreateSubTitleOpCode (
+ IN STRING_REF StringToken,
+ IN OUT VOID *FormBuffer
+ )
+/*++
+
+Routine Description:
+
+ Create a SubTitle opcode independent of string creation
+ This is used primarily by users who need to create just one particular valid op-code and the string
+ data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label
+ location to pre-defined forms in HII)
+
+Arguments:
+
+ StringToken - StringToken of the subtitle
+
+ FormBuffer - Output of subtitle as a form
+
+Returns:
+
+ EFI_SUCCESS - Subtitle created to be a form
+
+--*/
+{
+ EFI_IFR_SUBTITLE Subtitle;
+
+ Subtitle.Header.OpCode = EFI_IFR_SUBTITLE_OP;
+ Subtitle.Header.Length = sizeof (EFI_IFR_SUBTITLE);
+ Subtitle.SubTitle = StringToken;
+
+ EfiCopyMem (FormBuffer, &Subtitle, sizeof (EFI_IFR_SUBTITLE));
+ return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+CreateTextOpCode (
+ IN STRING_REF StringToken,
+ IN STRING_REF StringTokenTwo,
+ IN STRING_REF StringTokenThree,
+ IN UINT8 Flags,
+ IN UINT16 Key,
+ IN OUT VOID *FormBuffer
+ )
+/*++
+
+Routine Description:
+
+ Create a Text opcode independent of string creation
+ This is used primarily by users who need to create just one particular valid op-code and the string
+ data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label
+ location to pre-defined forms in HII)
+
+Arguments:
+
+ StringToken - First string token of the text
+
+ StringTokenTwo - Second string token of the text
+
+ StringTokenThree - Help string token of the text
+
+ Flags - Flag of the text
+
+ Key - Key of the text
+
+ FormBuffer - Output of text as a form
+
+Returns:
+
+ EFI_SUCCESS - Text created to be a form
+
+--*/
+{
+ EFI_IFR_TEXT Text;
+
+ Text.Header.OpCode = EFI_IFR_TEXT_OP;
+ Text.Header.Length = sizeof (EFI_IFR_TEXT);
+ Text.Text = StringToken;
+
+ Text.TextTwo = StringTokenTwo;
+ Text.Help = StringTokenThree;
+ Text.Flags = Flags;
+ Text.Key = Key;
+
+ EfiCopyMem (FormBuffer, &Text, sizeof (EFI_IFR_TEXT));
+
+ return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+CreateGotoOpCode (
+ IN UINT16 FormId,
+ IN STRING_REF StringToken,
+ IN STRING_REF StringTokenTwo,
+ IN UINT8 Flags,
+ IN UINT16 Key,
+ IN OUT VOID *FormBuffer
+ )
+/*++
+
+Routine Description:
+
+ Create a hyperlink opcode independent of string creation
+ This is used primarily by users who need to create just one particular valid op-code and the string
+ data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label
+ location to pre-defined forms in HII)
+
+Arguments:
+
+ FormId - Form ID of the hyperlink
+
+ StringToken - Prompt string token of the hyperlink
+
+ StringTokenTwo - Help string token of the hyperlink
+
+ Flags - Flags of the hyperlink
+
+ Key - Key of the hyperlink
+
+ FormBuffer - Output of hyperlink as a form
+
+Returns:
+
+ EFI_SUCCESS - Hyperlink created to be a form
+
+--*/
+{
+ EFI_IFR_REF Hyperlink;
+
+ Hyperlink.Header.OpCode = EFI_IFR_REF_OP;
+ Hyperlink.Header.Length = sizeof (EFI_IFR_REF);
+ Hyperlink.FormId = FormId;
+ Hyperlink.Prompt = StringToken;
+ Hyperlink.Help = StringTokenTwo;
+ Hyperlink.Key = Key;
+ Hyperlink.Flags = Flags;
+
+ EfiCopyMem (FormBuffer, &Hyperlink, sizeof (EFI_IFR_REF));
+
+ return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+CreateOneOfOpCode (
+ IN UINT16 QuestionId,
+ IN UINT8 DataWidth,
+ IN STRING_REF PromptToken,
+ IN STRING_REF HelpToken,
+ IN IFR_OPTION *OptionsList,
+ IN UINTN OptionCount,
+ IN OUT VOID *FormBuffer
+ )
+/*++
+
+Routine Description:
+
+ Create a one-of opcode with a set of option op-codes to choose from independent of string creation.
+ This is used primarily by users who need to create just one particular valid op-code and the string
+ data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label
+ location to pre-defined forms in HII)
+
+ OptionsList is a pointer to a null-terminated list of option descriptions. Ensure that OptionsList[x].StringToken
+ has been filled in since this routine will not generate StringToken values.
+
+Arguments:
+
+ QuestionId - Question ID of the one-of box
+
+ DataWidth - DataWidth of the one-of box
+
+ PromptToken - Prompt string token of the one-of box
+
+ HelpToken - Help string token of the one-of box
+
+ OptionsList - Each string in it is an option of the one-of box
+
+ OptionCount - Option string count
+
+ FormBuffer - Output of One-Of box as a form
+
+Returns:
+
+ EFI_SUCCESS - One-Of box created to be a form
+
+ EFI_DEVICE_ERROR - DataWidth > 2
+
+--*/
+{
+ UINTN Index;
+ EFI_IFR_ONE_OF OneOf;
+ EFI_IFR_ONE_OF_OPTION OneOfOption;
+ EFI_IFR_END_ONE_OF EndOneOf;
+ UINT8 *LocalBuffer;
+
+ //
+ // We do not create op-code storage widths for one-of in excess of 16 bits for now
+ //
+ if (DataWidth > 2) {
+ return EFI_DEVICE_ERROR;
+ }
+
+ OneOf.Header.OpCode = EFI_IFR_ONE_OF_OP;
+ OneOf.Header.Length = sizeof (EFI_IFR_ONE_OF);
+ OneOf.QuestionId = QuestionId;
+ OneOf.Width = DataWidth;
+ OneOf.Prompt = PromptToken;
+
+ OneOf.Help = HelpToken;
+
+ LocalBuffer = (CHAR8 *) FormBuffer;
+
+ EfiCopyMem (LocalBuffer, &OneOf, sizeof (EFI_IFR_ONE_OF));
+
+ LocalBuffer = (CHAR8 *) (LocalBuffer + sizeof (EFI_IFR_ONE_OF));
+
+ for (Index = 0; Index < OptionCount; Index++) {
+ OneOfOption.Header.OpCode = EFI_IFR_ONE_OF_OPTION_OP;
+ OneOfOption.Header.Length = sizeof (EFI_IFR_ONE_OF_OPTION);
+
+ OneOfOption.Option = OptionsList[Index].StringToken;
+ OneOfOption.Value = OptionsList[Index].Value;
+ OneOfOption.Flags = OptionsList[Index].Flags;
+ OneOfOption.Key = OptionsList[Index].Key;
+
+ EfiCopyMem (LocalBuffer, &OneOfOption, sizeof (EFI_IFR_ONE_OF_OPTION));
+
+ LocalBuffer = (CHAR8 *) (LocalBuffer + sizeof (EFI_IFR_ONE_OF_OPTION));
+ }
+
+ EndOneOf.Header.Length = sizeof (EFI_IFR_END_ONE_OF);
+ EndOneOf.Header.OpCode = EFI_IFR_END_ONE_OF_OP;
+
+ EfiCopyMem (LocalBuffer, &EndOneOf, sizeof (EFI_IFR_END_ONE_OF));
+
+ LocalBuffer = (CHAR8 *) (LocalBuffer + sizeof (EFI_IFR_END_ONE_OF));
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+CreateOrderedListOpCode (
+ IN UINT16 QuestionId,
+ IN UINT8 MaxEntries,
+ IN STRING_REF PromptToken,
+ IN STRING_REF HelpToken,
+ IN IFR_OPTION *OptionsList,
+ IN UINTN OptionCount,
+ IN OUT VOID *FormBuffer
+ )
+/*++
+
+Routine Description:
+
+ Create a ordered list opcode with a set of option op-codes to choose from independent of string creation.
+ This is used primarily by users who need to create just one particular valid op-code and the string
+ data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label
+ location to pre-defined forms in HII)
+
+ OptionsList is a pointer to a null-terminated list of option descriptions. Ensure that OptionsList[x].StringToken
+ has been filled in since this routine will not generate StringToken values.
+
+Arguments:
+
+ QuestionId - Question ID of the ordered list
+
+ MaxEntries - MaxEntries of the ordered list
+
+ PromptToken - Prompt string token of the ordered list
+
+ HelpToken - Help string token of the ordered list
+
+ OptionsList - Each string in it is an option of the ordered list
+
+ OptionCount - Option string count
+
+ FormBuffer - Output of ordered list as a form
+
+Returns:
+
+ EFI_SUCCESS - Ordered list created to be a form
+
+--*/
+{
+ UINTN Index;
+ EFI_IFR_ORDERED_LIST OrderedList;
+ EFI_IFR_ONE_OF_OPTION OrderedListOption;
+ EFI_IFR_END_ONE_OF EndOrderedList;
+ UINT8 *LocalBuffer;
+
+ OrderedList.Header.OpCode = EFI_IFR_ORDERED_LIST_OP;
+ OrderedList.Header.Length = sizeof (EFI_IFR_ORDERED_LIST);
+ OrderedList.QuestionId = QuestionId;
+ OrderedList.MaxEntries = MaxEntries;
+ OrderedList.Prompt = PromptToken;
+
+ OrderedList.Help = HelpToken;
+
+ LocalBuffer = (CHAR8 *) FormBuffer;
+
+ EfiCopyMem (LocalBuffer, &OrderedList, sizeof (EFI_IFR_ORDERED_LIST));
+
+ LocalBuffer = (CHAR8 *) (LocalBuffer + sizeof (EFI_IFR_ORDERED_LIST));
+
+ for (Index = 0; Index < OptionCount; Index++) {
+ OrderedListOption.Header.OpCode = EFI_IFR_ONE_OF_OPTION_OP;
+ OrderedListOption.Header.Length = sizeof (EFI_IFR_ONE_OF_OPTION);
+
+ OrderedListOption.Option = OptionsList[Index].StringToken;
+ OrderedListOption.Value = OptionsList[Index].Value;
+ OrderedListOption.Flags = OptionsList[Index].Flags;
+ OrderedListOption.Key = OptionsList[Index].Key;
+
+ EfiCopyMem (LocalBuffer, &OrderedListOption, sizeof (EFI_IFR_ONE_OF_OPTION));
+
+ LocalBuffer = (CHAR8 *) (LocalBuffer + sizeof (EFI_IFR_ONE_OF_OPTION));
+ }
+
+ EndOrderedList.Header.Length = sizeof (EFI_IFR_END_ONE_OF);
+ EndOrderedList.Header.OpCode = EFI_IFR_END_ONE_OF_OP;
+
+ EfiCopyMem (LocalBuffer, &EndOrderedList, sizeof (EFI_IFR_END_ONE_OF));
+
+ LocalBuffer = (CHAR8 *) (LocalBuffer + sizeof (EFI_IFR_END_ONE_OF));
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+CreateCheckBoxOpCode (
+ IN UINT16 QuestionId,
+ IN UINT8 DataWidth,
+ IN STRING_REF PromptToken,
+ IN STRING_REF HelpToken,
+ IN UINT8 Flags,
+ IN UINT16 Key,
+ IN OUT VOID *FormBuffer
+ )
+/*++
+
+Routine Description:
+
+ Create a checkbox opcode independent of string creation
+ This is used primarily by users who need to create just one particular valid op-code and the string
+ data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label
+ location to pre-defined forms in HII)
+
+Arguments:
+
+ QuestionId - Question ID of the check box
+
+ DataWidth - DataWidth of the check box
+
+ PromptToken - Prompt string token of the check box
+
+ HelpToken - Help string token of the check box
+
+ Flags - Flags of the check box
+
+ Key - Key of the check box
+
+ FormBuffer - Output of the check box as a form
+
+Returns:
+
+ EFI_SUCCESS - Checkbox created to be a form
+
+ EFI_DEVICE_ERROR - DataWidth > 1
+
+--*/
+{
+ EFI_IFR_CHECK_BOX CheckBox;
+
+ //
+ // We do not create op-code storage widths for checkbox in excess of 8 bits for now
+ //
+ if (DataWidth > 1) {
+ return EFI_DEVICE_ERROR;
+ }
+
+ CheckBox.Header.OpCode = EFI_IFR_CHECKBOX_OP;
+ CheckBox.Header.Length = sizeof (EFI_IFR_CHECK_BOX);
+ CheckBox.QuestionId = QuestionId;
+ CheckBox.Width = DataWidth;
+ CheckBox.Prompt = PromptToken;
+
+ CheckBox.Help = HelpToken;
+ CheckBox.Flags = Flags;
+ CheckBox.Key = Key;
+
+ EfiCopyMem (FormBuffer, &CheckBox, sizeof (EFI_IFR_CHECK_BOX));
+
+ return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+CreateNumericOpCode (
+ IN UINT16 QuestionId,
+ IN UINT8 DataWidth,
+ IN STRING_REF PromptToken,
+ IN STRING_REF HelpToken,
+ IN UINT16 Minimum,
+ IN UINT16 Maximum,
+ IN UINT16 Step,
+ IN UINT16 Default,
+ IN UINT8 Flags,
+ IN UINT16 Key,
+ IN OUT VOID *FormBuffer
+ )
+/*++
+
+Routine Description:
+
+ Create a numeric opcode independent of string creation
+ This is used primarily by users who need to create just one particular valid op-code and the string
+ data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label
+ location to pre-defined forms in HII)
+
+Arguments:
+
+ QuestionId - Question ID of the numeric
+
+ DataWidth - DataWidth of the numeric
+
+ PromptToken - Prompt string token of the numeric
+
+ HelpToken - Help string token of the numeric
+
+ Minimum - Minumun boundary of the numeric
+
+ Maximum - Maximum boundary of the numeric
+
+ Step - Step of the numeric
+
+ Default - Default value of the numeric
+
+ Flags - Flags of the numeric
+
+ Key - Key of the numeric
+
+ FormBuffer - Output of the numeric as a form
+
+Returns:
+
+ EFI_SUCCESS - The numeric created to be a form.
+
+ EFI_DEVICE_ERROR - DataWidth > 2
+
+--*/
+{
+ EFI_IFR_NUMERIC Numeric;
+
+ //
+ // We do not create op-code storage widths for numerics in excess of 16 bits for now
+ //
+ if (DataWidth > 2) {
+ return EFI_DEVICE_ERROR;
+ }
+
+ Numeric.Header.OpCode = EFI_IFR_NUMERIC_OP;
+ Numeric.Header.Length = sizeof (EFI_IFR_NUMERIC);
+ Numeric.QuestionId = QuestionId;
+ Numeric.Width = DataWidth;
+ Numeric.Prompt = PromptToken;
+
+ Numeric.Help = HelpToken;
+ Numeric.Minimum = Minimum;
+ Numeric.Maximum = Maximum;
+ Numeric.Step = Step;
+ Numeric.Default = Default;
+ Numeric.Flags = Flags;
+ Numeric.Key = Key;
+
+ EfiCopyMem (FormBuffer, &Numeric, sizeof (EFI_IFR_NUMERIC));
+
+ return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+CreateStringOpCode (
+ IN UINT16 QuestionId,
+ IN UINT8 DataWidth,
+ IN STRING_REF PromptToken,
+ IN STRING_REF HelpToken,
+ IN UINT8 MinSize,
+ IN UINT8 MaxSize,
+ IN UINT8 Flags,
+ IN UINT16 Key,
+ IN OUT VOID *FormBuffer
+ )
+/*++
+
+Routine Description:
+
+ Create a numeric opcode independent of string creation
+ This is used primarily by users who need to create just one particular valid op-code and the string
+ data will be assumed to exist in the HiiDatabase already. (Useful when exporting op-codes at a label
+ location to pre-defined forms in HII)
+
+Arguments:
+
+ QuestionId - Question ID of the string
+
+ DataWidth - DataWidth of the string
+
+ PromptToken - Prompt token of the string
+
+ HelpToken - Help token of the string
+
+ MinSize - Min size boundary of the string
+
+ MaxSize - Max size boundary of the string
+
+ Flags - Flags of the string
+
+ Key - Key of the string
+
+ FormBuffer - Output of the string as a form
+
+Returns:
+
+ EFI_SUCCESS - String created to be a form.
+
+--*/
+{
+ EFI_IFR_STRING String;
+
+ String.Header.OpCode = EFI_IFR_STRING_OP;
+ String.Header.Length = sizeof (EFI_IFR_STRING);
+ String.QuestionId = QuestionId;
+ String.Width = DataWidth;
+ String.Prompt = PromptToken;
+
+ String.Help = HelpToken;
+ String.MinSize = MinSize;
+ String.MaxSize = MaxSize;
+ String.Flags = Flags;
+ String.Key = Key;
+
+ EfiCopyMem (FormBuffer, &String, sizeof (EFI_IFR_STRING));
+
+ return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+CreateBannerOpCode (
+ IN UINT16 Title,
+ IN UINT16 LineNumber,
+ IN UINT8 Alignment,
+ IN OUT VOID *FormBuffer
+ )
+/*++
+
+Routine Description:
+
+ Create a banner opcode. This is primarily used by the FrontPage implementation from BDS.
+
+Arguments:
+
+ Title - Title of the banner
+
+ LineNumber - LineNumber of the banner
+
+ Alignment - Alignment of the banner
+
+ FormBuffer - Output of banner as a form
+
+Returns:
+
+ EFI_SUCCESS - Banner created to be a form.
+
+--*/
+{
+ EFI_IFR_BANNER Banner;
+
+ Banner.Header.OpCode = EFI_IFR_BANNER_OP;
+ Banner.Header.Length = sizeof (EFI_IFR_BANNER);
+ EfiCopyMem (&Banner.Title, &Title, sizeof (UINT16));
+ EfiCopyMem (&Banner.LineNumber, &LineNumber, sizeof (UINT16));
+ Banner.Alignment = Alignment;
+
+ EfiCopyMem (FormBuffer, &Banner, sizeof (EFI_IFR_BANNER));
+
+ return EFI_SUCCESS;
+}
diff --git a/EDK/Foundation/Library/Dxe/EfiIfrSupportLib/IfrVariable.c b/EDK/Foundation/Library/Dxe/EfiIfrSupportLib/IfrVariable.c
new file mode 100644
index 0000000..57a9221
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/EfiIfrSupportLib/IfrVariable.c
@@ -0,0 +1,488 @@
+/*++
+
+Copyright (c) 2005, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+ IfrVariable.c
+
+Abstract:
+ Variable/Map manipulations routines
+
+--*/
+
+#include "IfrLibrary.h"
+
+VOID
+EfiLibHiiVariablePackGetMap (
+ IN EFI_HII_VARIABLE_PACK *Pack,
+ OUT CHAR16 **Name, OPTIONAL
+ OUT EFI_GUID **Guid, OPTIONAL
+ OUT UINT16 *Id, OPTIONAL
+ OUT VOID **Var, OPTIONAL
+ OUT UINTN *Size OPTIONAL
+ )
+/*++
+
+Routine Description:
+
+ Extracts a variable form a Pack.
+
+Arguments:
+
+ Pack - List of variables
+ Name - Name of the variable/map
+ Guid - GUID of the variable/map
+ Var - Pointer to the variable/map
+ Size - Size of the variable/map in bytes
+
+Returns:
+
+ VOID
+
+--*/
+{
+ if (NULL != Name) {
+ *Name = (VOID *) (Pack + 1);
+ }
+
+ if (NULL != Guid) {
+ *Guid = (EFI_GUID *)(UINTN)&Pack->VariableGuid;
+ }
+
+
+ if (NULL != Id) {
+ *Id = Pack->VariableId;
+ }
+
+ if (NULL != Var) {
+ *Var = (VOID *) ((CHAR8 *) (Pack + 1) + Pack->VariableNameLength);
+ }
+
+ if (NULL != Size) {
+ *Size = Pack->Header.Length - sizeof (*Pack) - Pack->VariableNameLength;
+ }
+}
+
+
+UINTN
+EfiLibHiiVariablePackListGetMapCnt (
+ IN EFI_HII_VARIABLE_PACK_LIST *List
+ )
+
+/*++
+
+Routine Description:
+
+ Finds a count of the variables/maps in the List.
+
+Arguments:
+
+ List - List of variables
+
+Returns:
+
+ UINTN - The number of map count.
+
+--*/
+
+{
+ UINTN Cnt = 0;
+ while (NULL != List) {
+ Cnt++;
+ List = List->NextVariablePack;
+ }
+ return Cnt;
+}
+
+
+VOID
+EfiLibHiiVariablePackListForEachVar (
+ IN EFI_HII_VARIABLE_PACK_LIST *List,
+ IN EFI_LIB_HII_VARIABLE_PACK_LIST_CALLBACK *Callback
+ )
+/*++
+
+Routine Description:
+
+ Will iterate all variable/maps as appearing
+ in List and for each, it will call the Callback.
+
+Arguments:
+
+ List - List of variables
+ Callback - Routine to be called for each iterated variable.
+
+Returns:
+
+ VOID
+
+--*/
+
+{
+ CHAR16 *MapName;
+ EFI_GUID *MapGuid;
+ UINT16 MapId;
+ VOID *Map;
+ UINTN MapSize;
+
+ while (NULL != List) {
+ EfiLibHiiVariablePackGetMap (List->VariablePack, &MapName, &MapGuid, &MapId, &Map, &MapSize);
+ //
+ // call the callback
+ //
+ Callback (MapName, MapGuid, MapId, Map, MapSize);
+ List = List->NextVariablePack;
+ }
+}
+
+
+EFI_STATUS
+EfiLibHiiVariablePackListGetMapByIdx (
+ IN UINTN Idx,
+ IN EFI_HII_VARIABLE_PACK_LIST *List,
+ OUT CHAR16 **Name, OPTIONAL
+ OUT EFI_GUID **Guid, OPTIONAL
+ OUT UINT16 *Id, OPTIONAL
+ OUT VOID **Var,
+ OUT UINTN *Size
+ )
+
+/*++
+
+Routine Description:
+
+ Finds a variable form List given
+ the order number as appears in the List.
+
+Arguments:
+
+ Idx - The index of the variable/map to retrieve
+ List - List of variables
+ Name - Name of the variable/map
+ Guid - GUID of the variable/map
+ Var - Pointer to the variable/map
+ Size - Size of the variable/map in bytes
+
+Returns:
+
+ EFI_SUCCESS - Variable is found, OUT parameters are valid
+ EFI_NOT_FOUND - Variable is not found, OUT parameters are not valid
+
+--*/
+{
+ CHAR16 *MapName;
+ EFI_GUID *MapGuid;
+ UINT16 MapId;
+ VOID *Map;
+ UINTN MapSize;
+
+ while (NULL != List) {
+ EfiLibHiiVariablePackGetMap (List->VariablePack, &MapName, &MapGuid, &MapId, &Map, &MapSize);
+ if (0 == Idx--) {
+ *Var = Map;
+ *Size = MapSize;
+
+ if (NULL != Name) {
+ *Name = MapName;
+ }
+
+ if (NULL != Guid) {
+ *Guid = MapGuid;
+ }
+
+ if (NULL != Id) {
+ *Id = MapId;
+ }
+
+ return EFI_SUCCESS; // Map found
+ }
+ List = List->NextVariablePack;
+ }
+ //
+ // If here, the map is not found
+ //
+ return EFI_NOT_FOUND;
+}
+
+
+EFI_STATUS
+EfiLibHiiVariablePackListGetMapById (
+ IN UINT16 Id,
+ IN EFI_HII_VARIABLE_PACK_LIST *List,
+ OUT CHAR16 **Name, OPTIONAL
+ OUT EFI_GUID **Guid, OPTIONAL
+ OUT VOID **Var,
+ OUT UINTN *Size
+ )
+
+/*++
+
+Routine Description:
+
+ Finds a variable form List given the
+ order number as appears in the List.
+
+Arguments:
+
+ Id - The ID of the variable/map to retrieve
+ List - List of variables
+ Name - Name of the variable/map
+ Guid - GUID of the variable/map
+ Var - Pointer to the variable/map
+ Size - Size of the variable/map in bytes
+
+Returns:
+
+ EFI_SUCCESS - Variable is found, OUT parameters are valid
+ EFI_NOT_FOUND - Variable is not found, OUT parameters are not valid
+
+--*/
+
+{
+ CHAR16 *MapName;
+ EFI_GUID *MapGuid;
+ UINT16 MapId;
+ VOID *Map;
+ UINTN MapSize;
+
+ while (NULL != List) {
+ EfiLibHiiVariablePackGetMap (List->VariablePack, &MapName, &MapGuid, &MapId, &Map, &MapSize);
+ if (MapId == Id) {
+ *Var = Map;
+ *Size = MapSize;
+ if (NULL != Name) {
+ *Name = MapName;
+ }
+ if (NULL != Guid) {
+ *Guid = MapGuid;
+ }
+ //
+ // Map found
+ //
+ return EFI_SUCCESS;
+ }
+ List = List->NextVariablePack;
+ }
+ //
+ // If here, the map is not found
+ //
+ return EFI_NOT_FOUND;
+}
+
+
+EFI_STATUS
+EfiLibHiiVariablePackListGetMap (
+ IN EFI_HII_VARIABLE_PACK_LIST *List,
+ IN CHAR16 *Name,
+ IN EFI_GUID *Guid,
+ OUT UINT16 *Id,
+ OUT VOID **Var,
+ OUT UINTN *Size
+ )
+
+/*++
+
+Routine Description:
+
+ Finds a variable form EFI_HII_VARIABLE_PACK_LIST given name and GUID.
+
+Arguments:
+
+ List - List of variables
+ Name - Name of the variable/map to be found
+ Guid - GUID of the variable/map to be found
+ Var - Pointer to the variable/map found
+ Size - Size of the variable/map in bytes found
+
+Returns:
+
+ EFI_SUCCESS - variable is found, OUT parameters are valid
+ EFI_NOT_FOUND - variable is not found, OUT parameters are not valid
+
+--*/
+
+{
+ VOID *Map;
+ UINTN MapSize;
+ UINT16 MapId;
+ CHAR16 *MapName;
+ EFI_GUID *MapGuid;
+
+ while (NULL != List) {
+ EfiLibHiiVariablePackGetMap (List->VariablePack, &MapName, &MapGuid, &MapId, &Map, &MapSize);
+ if ((0 == EfiStrCmp (Name, MapName)) && EfiCompareGuid (Guid, MapGuid)) {
+ *Id = MapId;
+ *Var = Map;
+ *Size = MapSize;
+ return EFI_SUCCESS;
+ }
+ List = List->NextVariablePack;
+ }
+ //
+ // If here, the map is not found
+ //
+ return EFI_NOT_FOUND;
+}
+
+EFI_STATUS
+EfiLibHiiVariableRetrieveFromNv (
+ IN CHAR16 *Name,
+ IN EFI_GUID *Guid,
+ IN UINTN Size,
+ OUT VOID **Var
+ )
+/*++
+
+Routine Description:
+ Finds out if a variable of specific Name/Guid/Size exists in NV.
+ If it does, it will retrieve it into the Var.
+
+Arguments:
+ Name, Guid, Size - Parameters of the variable to retrieve. Must match exactly.
+ Var - Variable will be retrieved into buffer pointed by this pointer.
+ If pointing to NULL, the buffer will be allocated. Caller is responsible for releasing the buffer.
+Returns:
+ EFI_SUCCESS - The variable of exact Name/Guid/Size parameters was retrieved and written to Var.
+ EFI_NOT_FOUND - The variable of this Name/Guid was not found in the NV.
+ EFI_LOAD_ERROR - The variable in the NV was of different size, or NV API returned error.
+
+--*/
+{
+ EFI_STATUS Status;
+ UINTN SizeNv;
+
+ //
+ // Test for existence of the variable.
+ //
+ SizeNv = 0;
+ Status = gRT->GetVariable (Name, Guid, NULL, &SizeNv, NULL);
+ if (EFI_BUFFER_TOO_SMALL != Status) {
+ ASSERT (EFI_SUCCESS != Status);
+ return EFI_NOT_FOUND;
+ }
+ if (SizeNv != Size) {
+ //
+ // The variable is considered corrupt, as it has different size from expected.
+ //
+ return EFI_LOAD_ERROR;
+ }
+
+ if (NULL == *Var) {
+ *Var = EfiLibAllocatePool (Size);
+ ASSERT (NULL != *Var);
+ }
+ SizeNv = Size;
+ //
+ // Final read into the Var
+ //
+ Status = gRT->GetVariable (Name, Guid, NULL, &SizeNv, *Var);
+ //
+ // No tolerance for random failures. Such behavior is undetermined and not validated.
+ //
+ ASSERT_EFI_ERROR (Status);
+ ASSERT (SizeNv == Size);
+ return EFI_SUCCESS;
+}
+
+
+
+EFI_STATUS
+EfiLibHiiVariableOverrideIfSuffix (
+ IN CHAR16 *Suffix,
+ IN CHAR16 *Name,
+ IN EFI_GUID *Guid,
+ IN UINTN Size,
+ OUT VOID *Var
+ )
+/*++
+
+Routine Description:
+ Overrrides the variable with NV data if found.
+ But it only does it if the Name ends with specified Suffix.
+ For example, if Suffix="MyOverride" and the Name="XyzSetupMyOverride",
+ the Suffix matches the end of Name, so the variable will be loaded from NV
+ provided the variable exists and the GUID and Size matches.
+
+Arguments:
+ Suffix - Suffix the Name should end with.
+ Name, Guid, Size - Parameters of the variable to retrieve. Must match exactly.
+ Var - Variable will be retrieved into this buffer.
+ Caller is responsible for providing storage of exactly Size size in bytes.
+Returns:
+ EFI_SUCCESS - The variable was overriden with NV variable of same Name/Guid/Size.
+ EFI_INVALID_PARAMETER - The name of the variable does not end with <Suffix>.
+ EFI_NOT_FOUND - The variable of this Name/Guid was not found in the NV.
+ EFI_LOAD_ERROR - The variable in the NV was of different size, or NV API returned error.
+
+--*/
+{
+ UINTN StrLen;
+ UINTN StrLenSuffix;
+
+ StrLen = EfiStrLen (Name);
+ StrLenSuffix = EfiStrLen (Suffix);
+ if ((StrLen <= StrLenSuffix) || (0 != EfiStrCmp (Suffix, &Name[StrLen - StrLenSuffix]))) {
+ //
+ // Not ending with <Suffix>.
+ //
+ return EFI_INVALID_PARAMETER;
+ }
+ return EfiLibHiiVariableRetrieveFromNv (Name, Guid, Size, &Var);
+}
+
+
+
+EFI_STATUS
+EfiLibHiiVariableOverrideBySuffix (
+ IN CHAR16 *Suffix,
+ IN CHAR16 *Name,
+ IN EFI_GUID *Guid,
+ IN UINTN Size,
+ OUT VOID *Var
+ )
+/*++
+
+Routine Description:
+ Overrrides the variable with NV data if found.
+ But it only does it if the NV contains the same variable with Name is appended with Suffix.
+ For example, if Suffix="MyOverride" and the Name="XyzSetup",
+ the Suffix will be appended to the end of Name, and the variable with Name="XyzSetupMyOverride"
+ will be loaded from NV provided the variable exists and the GUID and Size matches.
+
+Arguments:
+ Suffix - Suffix the variable will be appended with.
+ Name, Guid, Size - Parameters of the variable to retrieve. Must match exactly.
+ Var - Variable will be retrieved into this buffer.
+ Caller is responsible for providing storage of exactly Size size in bytes.
+
+Returns:
+ EFI_SUCCESS - The variable was overriden with NV variable of same Name/Guid/Size.
+ EFI_NOT_FOUND - The variable of this Name/Guid was not found in the NV.
+ EFI_LOAD_ERROR - The variable in the NV was of different size, or NV API returned error.
+
+--*/
+{
+ EFI_STATUS Status;
+ CHAR16 *NameSuffixed;
+
+ //
+ // enough to concatenate both strings.
+ //
+ NameSuffixed = EfiLibAllocateZeroPool ((EfiStrLen (Name) + EfiStrLen (Suffix) + 1) * sizeof (CHAR16));
+
+ EfiStrCpy (NameSuffixed, Name);
+ EfiStrCat (NameSuffixed, Suffix);
+
+ Status = EfiLibHiiVariableRetrieveFromNv (NameSuffixed, Guid, Size, &Var);
+ gBS->FreePool (NameSuffixed);
+
+ return Status;
+}
+
diff --git a/EDK/Foundation/Library/Dxe/EfiScriptLib/EfiScriptLib.c b/EDK/Foundation/Library/Dxe/EfiScriptLib/EfiScriptLib.c
new file mode 100644
index 0000000..a2f5e28
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/EfiScriptLib/EfiScriptLib.c
@@ -0,0 +1,712 @@
+/*++
+
+Copyright (c) 2006 - 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiScriptLib.c
+
+Abstract:
+
+ Support for EFI script.
+
+--*/
+
+#include "EfiScriptLib.h"
+
+EFI_BOOT_SCRIPT_SAVE_PROTOCOL *mBootScriptSave;
+
+STATIC
+UINTN
+EfiScriptLibAsciiStrLen (
+ IN CHAR8 *String
+ )
+/*++
+
+Routine Description:
+ Return the number of Ascii characters in String. This is not the same as
+ the length of the string in bytes.
+
+Arguments:
+ String - String to process
+
+Returns:
+ Number of Ascii characters in String
+
+--*/
+{
+ UINTN Length;
+
+ for (Length=0; *String; String++, Length++);
+ return Length;
+}
+
+STATIC
+UINTN
+EfiScriptLibStrLen (
+ IN CHAR16 *String
+ )
+/*++
+
+Routine Description:
+ Return the number of Unicode characters in String. This is not the same as
+ the length of the string in bytes.
+
+Arguments:
+ String - String to process
+
+Returns:
+ Number of Unicode characters in String
+
+--*/
+{
+ UINTN Length;
+
+ for (Length=0; *String; String++, Length++);
+ return Length;
+}
+
+EFI_STATUS
+EFIAPI
+BootScriptSaveInitialize (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+/*++
+
+Routine Description:
+
+ Intialize Boot Script Lib if it has not yet been initialized.
+
+Arguments:
+
+ (Standard EFI Image entry - EFI_IMAGE_ENTRY_POINT)
+
+Returns:
+
+ EFI_STATUS always returns EFI_SUCCESS
+
+--*/
+// GC_TODO: ImageHandle - add argument and description to function comment
+// GC_TODO: SystemTable - add argument and description to function comment
+{
+ EFI_STATUS Status;
+ EFI_BOOT_SERVICES *BS;
+
+ BS = SystemTable->BootServices;
+
+ Status = BS->LocateProtocol (&gEfiBootScriptSaveGuid, NULL, &mBootScriptSave);
+ if (EFI_ERROR (Status) && Status != EFI_ALREADY_STARTED) {
+ mBootScriptSave = NULL;
+ }
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+BootScriptSaveIoWrite (
+ IN UINT16 TableName,
+ IN EFI_BOOT_SCRIPT_WIDTH Width,
+ IN UINT64 Address,
+ IN UINTN Count,
+ IN VOID *Buffer
+ )
+/*++
+
+Routine Description:
+
+ Save I/O write to boot script
+
+Arguments:
+
+ TableName - Desired boot script table
+
+ (Standard EFI IO write script parameter)
+
+Returns:
+
+ EFI_NOT_FOUND - BootScriptSave Protocol not exist.
+
+ EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
+
+--*/
+// GC_TODO: Width - add argument and description to function comment
+// GC_TODO: Address - add argument and description to function comment
+// GC_TODO: Count - add argument and description to function comment
+// GC_TODO: Buffer - add argument and description to function comment
+{
+ if (mBootScriptSave == NULL) {
+ return EFI_NOT_FOUND;
+ }
+
+ mBootScriptSave->Write (
+ mBootScriptSave,
+ TableName,
+ EFI_BOOT_SCRIPT_IO_WRITE_OPCODE,
+ Width,
+ Address,
+ Count,
+ Buffer
+ );
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+BootScriptSaveIoReadWrite (
+ IN UINT16 TableName,
+ IN EFI_BOOT_SCRIPT_WIDTH Width,
+ IN UINT64 Address,
+ IN VOID *Data,
+ IN VOID *DataMask
+ )
+/*++
+
+Routine Description:
+
+ Save I/O write to boot script
+
+Arguments:
+
+ TableName - Desired boot script table
+
+ (Standard EFI IO read write script parameter)
+
+Returns:
+
+ EFI_NOT_FOUND - BootScriptSave Protocol not exist.
+
+ EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
+
+--*/
+// GC_TODO: Width - add argument and description to function comment
+// GC_TODO: Address - add argument and description to function comment
+// GC_TODO: Data - add argument and description to function comment
+// GC_TODO: DataMask - add argument and description to function comment
+{
+ if (mBootScriptSave == NULL) {
+ return EFI_NOT_FOUND;
+ }
+
+ mBootScriptSave->Write (
+ mBootScriptSave,
+ TableName,
+ EFI_BOOT_SCRIPT_IO_READ_WRITE_OPCODE,
+ Width,
+ Address,
+ Data,
+ DataMask
+ );
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+BootScriptSaveMemWrite (
+ IN UINT16 TableName,
+ IN EFI_BOOT_SCRIPT_WIDTH Width,
+ IN UINT64 Address,
+ IN UINTN Count,
+ IN VOID *Buffer
+ )
+/*++
+
+Routine Description:
+
+ Save I/O write to boot script
+
+Arguments:
+
+ TableName - Desired boot script table
+
+ (Standard EFI MEM write script parameter)
+
+Returns:
+
+ EFI_NOT_FOUND - BootScriptSave Protocol not exist.
+
+ EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
+
+--*/
+// GC_TODO: Width - add argument and description to function comment
+// GC_TODO: Address - add argument and description to function comment
+// GC_TODO: Count - add argument and description to function comment
+// GC_TODO: Buffer - add argument and description to function comment
+{
+ if (mBootScriptSave == NULL) {
+ return EFI_NOT_FOUND;
+ }
+
+ mBootScriptSave->Write (
+ mBootScriptSave,
+ TableName,
+ EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE,
+ Width,
+ Address,
+ Count,
+ Buffer
+ );
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+BootScriptSaveMemReadWrite (
+ IN UINT16 TableName,
+ IN EFI_BOOT_SCRIPT_WIDTH Width,
+ IN UINT64 Address,
+ IN VOID *Data,
+ IN VOID *DataMask
+ )
+/*++
+
+Routine Description:
+
+ Save I/O write to boot script
+
+Arguments:
+
+ TableName - Desired boot script table
+
+ (Standard EFI MEM read write script parameter)
+
+Returns:
+
+ EFI_NOT_FOUND - BootScriptSave Protocol not exist.
+
+ EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
+
+--*/
+// GC_TODO: Width - add argument and description to function comment
+// GC_TODO: Address - add argument and description to function comment
+// GC_TODO: Data - add argument and description to function comment
+// GC_TODO: DataMask - add argument and description to function comment
+{
+ if (mBootScriptSave == NULL) {
+ return EFI_NOT_FOUND;
+ }
+
+ mBootScriptSave->Write (
+ mBootScriptSave,
+ TableName,
+ EFI_BOOT_SCRIPT_MEM_READ_WRITE_OPCODE,
+ Width,
+ Address,
+ Data,
+ DataMask
+ );
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+BootScriptSavePciCfgWrite (
+ IN UINT16 TableName,
+ IN EFI_BOOT_SCRIPT_WIDTH Width,
+ IN UINT64 Address,
+ IN UINTN Count,
+ IN VOID *Buffer
+ )
+/*++
+
+Routine Description:
+
+ Save I/O write to boot script
+
+Arguments:
+
+ TableName - Desired boot script table
+
+ (Standard EFI PCI write script parameter)
+
+Returns:
+
+ EFI_NOT_FOUND - BootScriptSave Protocol not exist.
+
+ EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
+
+--*/
+// GC_TODO: Width - add argument and description to function comment
+// GC_TODO: Address - add argument and description to function comment
+// GC_TODO: Count - add argument and description to function comment
+// GC_TODO: Buffer - add argument and description to function comment
+{
+ if (mBootScriptSave == NULL) {
+ return EFI_NOT_FOUND;
+ }
+
+ mBootScriptSave->Write (
+ mBootScriptSave,
+ TableName,
+ EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE_OPCODE,
+ Width,
+ Address,
+ Count,
+ Buffer
+ );
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+BootScriptSavePciCfgReadWrite (
+ IN UINT16 TableName,
+ IN EFI_BOOT_SCRIPT_WIDTH Width,
+ IN UINT64 Address,
+ IN VOID *Data,
+ IN VOID *DataMask
+ )
+/*++
+
+Routine Description:
+
+ Save I/O write to boot script
+
+Arguments:
+
+ TableName - Desired boot script table
+
+ (Standard EFI PCI read write script parameter)
+
+Returns:
+
+ EFI_NOT_FOUND - BootScriptSave Protocol not exist.
+
+ EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
+
+--*/
+// GC_TODO: Width - add argument and description to function comment
+// GC_TODO: Address - add argument and description to function comment
+// GC_TODO: Data - add argument and description to function comment
+// GC_TODO: DataMask - add argument and description to function comment
+{
+ if (mBootScriptSave == NULL) {
+ return EFI_NOT_FOUND;
+ }
+
+ mBootScriptSave->Write (
+ mBootScriptSave,
+ TableName,
+ EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE_OPCODE,
+ Width,
+ Address,
+ Data,
+ DataMask
+ );
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+BootScriptSaveSmbusExecute (
+ IN UINT16 TableName,
+ IN EFI_SMBUS_DEVICE_ADDRESS SlaveAddress,
+ IN EFI_SMBUS_DEVICE_COMMAND Command,
+ IN EFI_SMBUS_OPERATION Operation,
+ IN BOOLEAN PecCheck,
+ IN UINTN *Length,
+ IN VOID *Buffer
+ )
+/*++
+
+Routine Description:
+
+ Save I/O write to boot script
+
+Arguments:
+
+ TableName - Desired boot script table
+
+ (Standard EFI Smbus execute script parameter)
+
+Returns:
+
+ EFI_NOT_FOUND - BootScriptSave Protocol not exist.
+
+ EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
+
+--*/
+// GC_TODO: SlaveAddress - add argument and description to function comment
+// GC_TODO: Command - add argument and description to function comment
+// GC_TODO: Operation - add argument and description to function comment
+// GC_TODO: PecCheck - add argument and description to function comment
+// GC_TODO: Length - add argument and description to function comment
+// GC_TODO: Buffer - add argument and description to function comment
+{
+ if (mBootScriptSave == NULL) {
+ return EFI_NOT_FOUND;
+ }
+
+ mBootScriptSave->Write (
+ mBootScriptSave,
+ TableName,
+ EFI_BOOT_SCRIPT_SMBUS_EXECUTE_OPCODE,
+ SlaveAddress,
+ Command,
+ Operation,
+ PecCheck,
+ Length,
+ Buffer
+ );
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+BootScriptSaveStall (
+ IN UINT16 TableName,
+ IN UINTN Duration
+ )
+/*++
+
+Routine Description:
+
+ Save I/O write to boot script
+
+Arguments:
+
+ TableName - Desired boot script table
+
+ (Standard EFI stall script parameter)
+
+Returns:
+
+ EFI_NOT_FOUND - BootScriptSave Protocol not exist.
+
+ EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
+
+--*/
+// GC_TODO: Duration - add argument and description to function comment
+{
+ if (mBootScriptSave == NULL) {
+ return EFI_NOT_FOUND;
+ }
+
+ mBootScriptSave->Write (
+ mBootScriptSave,
+ TableName,
+ EFI_BOOT_SCRIPT_STALL_OPCODE,
+ Duration
+ );
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+BootScriptSaveDispatch (
+ IN UINT16 TableName,
+ IN EFI_PHYSICAL_ADDRESS EntryPoint
+ )
+/*++
+
+Routine Description:
+
+ GC_TODO: Add function description
+
+Arguments:
+
+ TableName - GC_TODO: add argument description
+ EntryPoint - GC_TODO: add argument description
+
+Returns:
+
+ EFI_NOT_FOUND - GC_TODO: Add description for return value
+ EFI_SUCCESS - GC_TODO: Add description for return value
+
+--*/
+{
+ if (mBootScriptSave == NULL) {
+ return EFI_NOT_FOUND;
+ }
+
+ mBootScriptSave->Write (
+ mBootScriptSave,
+ TableName,
+ EFI_BOOT_SCRIPT_DISPATCH_OPCODE,
+ EntryPoint
+ );
+
+ return EFI_SUCCESS;
+
+}
+
+EFI_STATUS
+EFIAPI
+BootScriptMemPoll (
+ IN UINT16 TableName,
+ IN EFI_BOOT_SCRIPT_WIDTH Width,
+ IN UINT64 Address,
+ IN VOID *BitMask,
+ IN VOID *BitValue,
+ IN UINTN Duration,
+ IN UINTN LoopTimes
+ )
+/*++
+
+Routine Description:
+
+ Save I/O write to boot script
+
+Arguments:
+ TableName - Desired boot script table
+
+ Width - The width of the memory operations.
+
+ Address - The base address of the memory operations.
+
+ BitMask - A pointer to the bit mask to be AND-ed with the data read from the register.
+
+ BitValue - A pointer to the data value after to be Masked.
+
+ Duration - Duration in microseconds of the stall.
+
+ LoopTimes - The times of the register polling.
+
+Returns:
+
+ EFI_NOT_FOUND - BootScriptSave Protocol not exist.
+
+ EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
+
+--*/
+{
+ mBootScriptSave->Write (
+ mBootScriptSave,
+ TableName,
+ EFI_BOOT_SCRIPT_MEM_POLL_OPCODE,
+ Width,
+ Address,
+ BitMask,
+ BitValue,
+ Duration,
+ LoopTimes
+ );
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+BootScriptSaveInformation (
+ IN UINT16 TableName,
+ IN UINT32 Length,
+ IN EFI_PHYSICAL_ADDRESS Buffer
+ )
+/*++
+
+Routine Description:
+
+ Save a Information Opcode record in table specified with TableName
+
+Arguments:
+
+ TableName - Desired boot script table
+ Length - Length of information in bytes
+ Buffer - Content of information that will be saved in script table
+
+Returns:
+
+ EFI_NOT_FOUND - BootScriptSave Protocol not exist.
+
+ EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
+
+--*/
+{
+ if (mBootScriptSave == NULL) {
+ return EFI_NOT_FOUND;
+ }
+
+ mBootScriptSave->Write (
+ mBootScriptSave,
+ TableName,
+ EFI_BOOT_SCRIPT_INFORMATION_OPCODE,
+ Length,
+ Buffer
+ );
+
+ return EFI_SUCCESS;
+
+}
+
+EFI_STATUS
+EFIAPI
+BootScriptSaveInformationUnicodeString (
+ IN UINT16 TableName,
+ IN CHAR16 *String
+ )
+/*++
+
+Routine Description:
+
+ Save a Information Opcode record in table specified with TableName, the information
+ is a unicode string.
+
+Arguments:
+
+ TableName - Desired boot script table
+ String - The string that will be saved in script table
+
+Returns:
+
+ EFI_NOT_FOUND - BootScriptSave Protocol not exist.
+
+ EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
+
+--*/
+{
+ return BootScriptSaveInformation (
+ TableName,
+ (UINT32) EfiScriptLibStrLen (String) * 2 + 2,
+ (EFI_PHYSICAL_ADDRESS)String
+ );
+}
+
+EFI_STATUS
+EFIAPI
+BootScriptSaveInformationAsciiString (
+ IN UINT16 TableName,
+ IN CHAR8 *String
+ )
+/*++
+
+Routine Description:
+
+ Save a Information Opcode record in table specified with TableName, the information
+ is a ascii string.
+
+Arguments:
+
+ TableName - Desired boot script table
+ String - The string that will be saved in script table
+
+Returns:
+
+ EFI_NOT_FOUND - BootScriptSave Protocol not exist.
+
+ EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
+
+--*/
+{
+ return BootScriptSaveInformation (
+ TableName,
+ (UINT32) EfiScriptLibAsciiStrLen (String) + 1,
+ (EFI_PHYSICAL_ADDRESS)String
+ );
+}
+
diff --git a/EDK/Foundation/Library/Dxe/EfiScriptLib/EfiScriptLib.cif b/EDK/Foundation/Library/Dxe/EfiScriptLib/EfiScriptLib.cif
new file mode 100644
index 0000000..ed0c96a
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/EfiScriptLib/EfiScriptLib.cif
@@ -0,0 +1,11 @@
+<component>
+ name = "EfiScriptLib"
+ category = ModulePart
+ LocalRoot = "EDK\Foundation\Library\Dxe\EfiScriptLib\"
+ RefName = "EfiScriptLib"
+[files]
+"EfiScriptLib.sdl"
+"EfiScriptLib.mak"
+"EfiScriptLib.c"
+"EfiScriptLib.inf"
+<endComponent>
diff --git a/EDK/Foundation/Library/Dxe/EfiScriptLib/EfiScriptLib.inf b/EDK/Foundation/Library/Dxe/EfiScriptLib/EfiScriptLib.inf
new file mode 100644
index 0000000..fd33eae
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/EfiScriptLib/EfiScriptLib.inf
@@ -0,0 +1,45 @@
+#/*++
+#
+# Copyright (c) 2006, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# EfiScriptLib.inf
+#
+# Abstract:
+#
+# Component description file.
+#
+#--*/
+
+[defines]
+BASE_NAME = EfiScriptLib
+COMPONENT_TYPE = LIBRARY
+
+[sources.common]
+ EfiScriptLib.c
+
+
+[includes.common]
+ $(EDK_SOURCE)\Foundation\Framework
+ $(EDK_SOURCE)\Foundation\Efi
+ .
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+ $(EFI_SOURCE)
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+
+[libraries.common]
+ EdkFrameworkProtocolLib
+
+[nmake.common]
diff --git a/EDK/Foundation/Library/Dxe/EfiScriptLib/EfiScriptLib.mak b/EDK/Foundation/Library/Dxe/EfiScriptLib/EfiScriptLib.mak
new file mode 100644
index 0000000..0283c99
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/EfiScriptLib/EfiScriptLib.mak
@@ -0,0 +1,70 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EfiScriptLib/EfiScriptLib.mak 1 1/20/12 4:12a Jeffch $
+#
+# $Revision: 1 $
+#
+# $Date: 1/20/12 4:12a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EfiScriptLib/EfiScriptLib.mak $
+#
+# 1 1/20/12 4:12a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 9/27/11 6:35a Wesleychen
+# Intel EDK initially releases.
+#
+# 2 9/02/09 3:46a Iminglin
+# EIP24919
+#
+#**********************************************************************
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: EfiScriptLib.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+$(EFISCRIPTLIB) : EfiScriptLib
+
+$(BUILD_DIR)\EfiScriptLib.lib : EfiScriptLib
+
+EfiScriptLib : $(BUILD_DIR)\EfiScriptLib.mak EfiScriptLibBin
+
+$(BUILD_DIR)\EfiScriptLib.mak : $(EfiScriptLib_DIR)\$(@B).cif $(EfiScriptLib_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(EfiScriptLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+EfiScriptLibBin : $(EDKFRAMEWORKPROTOCOLLIB)
+ $(MAKE) /$(MAKEFLAGS) $(EDK_DEFAULTS)\
+ /f $(BUILD_DIR)\EfiScriptLib.mak all\
+ TYPE=LIBRARY \
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#********************************************************************** \ No newline at end of file
diff --git a/EDK/Foundation/Library/Dxe/EfiScriptLib/EfiScriptLib.sdl b/EDK/Foundation/Library/Dxe/EfiScriptLib/EfiScriptLib.sdl
new file mode 100644
index 0000000..232e858
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/EfiScriptLib/EfiScriptLib.sdl
@@ -0,0 +1,26 @@
+TOKEN
+ Name = "EfiScriptLib_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable EfiScriptLib support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "EFISCRIPTLIB"
+ Value = "$(BUILD_DIR)\EfiScriptLib.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "EfiScriptLib_DIR"
+End
+
+MODULE
+ Help = "Includes EfiScriptLib.mak to Project"
+ File = "EfiScriptLib.mak"
+End
+
diff --git a/EDK/Foundation/Library/Dxe/Graphics/Ascii/GraphicsAscii.cif b/EDK/Foundation/Library/Dxe/Graphics/Ascii/GraphicsAscii.cif
new file mode 100644
index 0000000..6555b3e
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/Graphics/Ascii/GraphicsAscii.cif
@@ -0,0 +1,9 @@
+<component>
+ name = "GraphicsAscii"
+ category = ModulePart
+ LocalRoot = "EDK\Foundation\Library\Dxe\Graphics\Ascii"
+ RefName = "GraphicsAscii"
+[files]
+"PrintWidth.h"
+"Sprint.c"
+<endComponent>
diff --git a/EDK/Foundation/Library/Dxe/Graphics/Ascii/PrintWidth.h b/EDK/Foundation/Library/Dxe/Graphics/Ascii/PrintWidth.h
new file mode 100644
index 0000000..07901dc
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/Graphics/Ascii/PrintWidth.h
@@ -0,0 +1,88 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PrintWidth.h
+
+Abstract:
+
+ Unicde option for generic width.
+ CHAR_W is Ascii
+ STRING_W is ""
+
+--*/
+
+#ifndef _PRINT_WIDTH_H_
+#define _PRINT_WIDTH_H_
+
+typedef CHAR8 CHAR_W;
+#define STRING_W(_s) _s
+
+#define ASPrint(Buffer, BufferSize, Format) SPrint (Buffer, BufferSize, Format)
+#define AvSPrint(Buffer, BufferSize, Format, Marker) VSPrint (Buffer, BufferSize, Format, Marker)
+
+UINTN
+UvSPrint (
+ OUT CHAR16 *StartOfBuffer,
+ IN UINTN StrLen,
+ IN CONST CHAR16 *Format,
+ IN VA_LIST Marker
+ )
+/*++
+
+Routine Description:
+
+ Internal implementation of USPrint.
+ Process format and place the results in Buffer for wide chars.
+
+Arguments:
+
+ StartOfBuffer - Wide char buffer to print the results of the parsing of Format into.
+ StrLen - Maximum number of characters to put into buffer.
+ Format - Format string
+ Marker - Vararg list consumed by processing Format.
+
+Returns:
+
+ Number of characters printed.
+
+--*/
+;
+
+UINTN
+USPrint (
+ OUT CHAR16 *Buffer,
+ IN UINTN BufferSize,
+ IN CONST CHAR16 *Format,
+ ...
+ )
+/*++
+
+Routine Description:
+
+ Process format and place the results in Buffer for wide chars.
+
+Arguments:
+
+ Buffer - Wide char buffer to print the results of the parsing of Format into.
+ BufferSize - Maximum number of characters to put into buffer.
+ Format - Format string
+ ... - Vararg list consumed by processing Format.
+
+Returns:
+
+ Number of characters printed.
+
+--*/
+;
+
+#endif
diff --git a/EDK/Foundation/Library/Dxe/Graphics/Ascii/Sprint.c b/EDK/Foundation/Library/Dxe/Graphics/Ascii/Sprint.c
new file mode 100644
index 0000000..bb4bb1e
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/Graphics/Ascii/Sprint.c
@@ -0,0 +1,144 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Sprint.c
+
+Abstract:
+
+ Basic Ascii AvSPrintf() function named VSPrint(). VSPrint() enables very
+ simple implemenation of SPrint() and Print() to support debug.
+
+ You can not Print more than EFI_DRIVER_LIB_MAX_PRINT_BUFFER characters at a
+ time. This makes the implementation very simple.
+
+ VSPrint, Print, SPrint format specification has the follwoing form
+
+ %[flags][width]type
+
+ flags:
+ '-' - Left justify
+ '+' - Prefix a sign
+ ' ' - Prefix a blank
+ ',' - Place commas in numberss
+ '0' - Prefix for width with zeros
+ 'l' - UINT64
+ 'L' - UINT64
+
+ width:
+ '*' - Get width from a UINTN argumnet from the argument list
+ Decimal number that represents width of print
+
+ type:
+ 'X' - argument is a UINTN hex number, prefix '0'
+ 'x' - argument is a hex number
+ 'd' - argument is a decimal number
+ 'a' - argument is an ascii string
+ 'S','s' - argument is an Unicode string
+ 'g' - argument is a pointer to an EFI_GUID
+ 't' - argument is a pointer to an EFI_TIME structure
+ 'c' - argument is an ascii character
+ 'r' - argument is EFI_STATUS
+ '%' - Print a %
+
+--*/
+
+#include "TianoCommon.h"
+#include "PrintWidth.h"
+#include "EfiPrintLib.h"
+#include "Print.h"
+
+
+UINTN
+USPrint (
+ OUT CHAR16 *Buffer,
+ IN UINTN BufferSize,
+ IN CONST CHAR16 *Format,
+ ...
+ )
+/*++
+
+Routine Description:
+
+ Process format and place the results in Buffer for wide chars.
+
+Arguments:
+
+ Buffer - Wide char buffer to print the results of the parsing of Format into.
+ BufferSize - Maximum number of characters to put into buffer.
+ Format - Format string
+ ... - Vararg list consumed by processing Format.
+
+Returns:
+
+ Number of characters printed.
+
+--*/
+{
+ UINTN Return;
+ VA_LIST Marker;
+
+ VA_START (Marker, Format);
+ Return = UnicodeVSPrint (Buffer, BufferSize, Format, Marker);
+ VA_END (Marker);
+
+ return Return;
+}
+
+
+UINTN
+UvSPrint (
+ OUT CHAR16 *Buffer,
+ IN UINTN BufferSize,
+ IN CONST CHAR16 *FormatString,
+ IN VA_LIST Marker
+ )
+/*++
+
+Routine Description:
+
+ Internal implementation of USPrint.
+ Process format and place the results in Buffer for wide chars.
+
+Arguments:
+
+ Buffer - Wide char buffer to print the results of the parsing of Format into.
+ BufferSize - Maximum number of characters to put into buffer.
+ FormatString - Format string
+ Marker - Vararg list consumed by processing Format.
+
+Returns:
+
+ Number of characters printed.
+
+--*/
+{
+ UINTN Index;
+ CHAR8 AsciiFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];
+ CHAR8 AsciiResult[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];
+
+ for (Index = 0; Index < EFI_DRIVER_LIB_MAX_PRINT_BUFFER && FormatString[Index] != '\0'; Index++) {
+ AsciiFormat[Index] = (CHAR8) FormatString[Index];
+ }
+
+ AsciiFormat[Index] = '\0';
+
+ Index = VSPrint (AsciiResult, EFI_DRIVER_LIB_MAX_PRINT_BUFFER, AsciiFormat, Marker);
+
+ for (Index = 0; (Index < (BufferSize - 1)) && AsciiResult[Index] != '\0'; Index++) {
+ Buffer[Index] = (CHAR16) AsciiResult[Index];
+ }
+
+ Buffer[Index] = '\0';
+
+ return Index++;
+}
diff --git a/EDK/Foundation/Library/Dxe/Graphics/Graphics.c b/EDK/Foundation/Library/Dxe/Graphics/Graphics.c
new file mode 100644
index 0000000..5801d33
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/Graphics/Graphics.c
@@ -0,0 +1,617 @@
+/*++
+
+Copyright (c) 2004 - 2011, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Graphics.c
+
+Abstract:
+
+ Support for Basic Graphics operations.
+
+ BugBug: Currently *.BMP files are supported. This will be replaced
+ when Tiano graphics format is supported.
+
+--*/
+
+#include "Tiano.h"
+#include "EfiDriverLib.h"
+#include "GraphicsLib.h"
+
+
+EFI_STATUS
+GetGraphicsBitMapFromFV (
+ IN EFI_GUID *FileNameGuid,
+ OUT VOID **Image,
+ OUT UINTN *ImageSize
+ )
+/*++
+
+Routine Description:
+
+ Return the graphics image file named FileNameGuid into Image and return it's
+ size in ImageSize. All Firmware Volumes (FV) in the system are searched for the
+ file name.
+
+Arguments:
+
+ FileNameGuid - File Name of graphics file in the FV(s).
+
+ Image - Pointer to pointer to return graphics image. If NULL, a
+ buffer will be allocated.
+
+ ImageSize - Size of the graphics Image in bytes. Zero if no image found.
+
+
+Returns:
+
+ EFI_SUCCESS - Image and ImageSize are valid.
+ EFI_BUFFER_TOO_SMALL - Image not big enough. ImageSize has required size
+ EFI_NOT_FOUND - FileNameGuid not found
+
+--*/
+{
+ EFI_STATUS Status;
+ UINTN FvProtocolCount;
+ EFI_HANDLE *FvHandles;
+#if (PI_SPECIFICATION_VERSION < 0x00010000) //;;## ...AMI_OVERRIDE... Support PI1.x
+ EFI_FIRMWARE_VOLUME_PROTOCOL *Fv;
+#else
+ EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv;
+#endif
+ UINTN Index;
+ UINT32 AuthenticationStatus;
+
+ Status = gBS->LocateHandleBuffer (
+ ByProtocol,
+ #if (PI_SPECIFICATION_VERSION < 0x00010000) //;;## ...AMI_OVERRIDE... Support PI1.x
+ &gEfiFirmwareVolumeProtocolGuid,
+ #else
+ &gEfiFirmwareVolume2ProtocolGuid,
+ #endif
+ NULL,
+ &FvProtocolCount,
+ &FvHandles
+ );
+ if (EFI_ERROR (Status)) {
+ return EFI_NOT_FOUND;
+ }
+
+ for (Index = 0; Index < FvProtocolCount; Index++) {
+ Status = gBS->HandleProtocol (
+ FvHandles[Index],
+ #if (PI_SPECIFICATION_VERSION < 0x00010000) //;;## ...AMI_OVERRIDE... Support PI1.x
+ &gEfiFirmwareVolumeProtocolGuid,
+ #else
+ &gEfiFirmwareVolume2ProtocolGuid,
+ #endif
+ (VOID **) &Fv
+ );
+
+ //
+ // Assuming Image and ImageSize are correct on input.
+ //
+ Status = Fv->ReadSection (
+ Fv,
+ &gEfiDefaultBmpLogoGuid,
+ EFI_SECTION_RAW,
+ 0,
+ Image,
+ ImageSize,
+ &AuthenticationStatus
+ );
+ if (!EFI_ERROR (Status)) {
+ gBS->FreePool (FvHandles);
+ return EFI_SUCCESS;
+ } else if (Status == EFI_BUFFER_TOO_SMALL) {
+ //
+ // ImageSize updated to needed size so return
+ //
+ gBS->FreePool (FvHandles);
+ return EFI_BUFFER_TOO_SMALL;
+ }
+ }
+
+ gBS->FreePool (FvHandles);
+ return EFI_NOT_FOUND;
+}
+
+
+EFI_STATUS
+ConvertBmpToGopBlt (
+ IN VOID *BmpImage,
+ IN UINTN BmpImageSize,
+ IN OUT VOID **GopBlt,
+ IN OUT UINTN *GopBltSize,
+ OUT UINTN *PixelHeight,
+ OUT UINTN *PixelWidth
+ )
+/*++
+
+Routine Description:
+
+ Convert a *.BMP graphics image to a GOP/UGA blt buffer. If a NULL Blt buffer
+ is passed in a GopBlt buffer will be allocated by this routine. If a GopBlt
+ buffer is passed in it will be used if it is big enough.
+
+Arguments:
+
+ BmpImage - Pointer to BMP file
+
+ BmpImageSize - Number of bytes in BmpImage
+
+ GopBlt - Buffer containing GOP version of BmpImage.
+
+ GopBltSize - Size of GopBlt in bytes.
+
+ PixelHeight - Height of GopBlt/BmpImage in pixels
+
+ PixelWidth - Width of GopBlt/BmpImage in pixels
+
+
+Returns:
+
+ EFI_SUCCESS - GopBlt and GopBltSize are returned.
+ EFI_UNSUPPORTED - BmpImage is not a valid *.BMP image
+ EFI_BUFFER_TOO_SMALL - The passed in GopBlt buffer is not big enough.
+ GopBltSize will contain the required size.
+ EFI_OUT_OF_RESOURCES - No enough buffer to allocate
+
+--*/
+{
+ UINT8 *Image;
+ UINT8 *ImageHeader;
+ BMP_IMAGE_HEADER *BmpHeader;
+ BMP_COLOR_MAP *BmpColorMap;
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer;
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Blt;
+ UINT64 BltBufferSize;
+ UINTN Index;
+ UINTN Height;
+ UINTN Width;
+ UINTN ImageIndex;
+ BOOLEAN IsAllocated;
+
+ BmpHeader = (BMP_IMAGE_HEADER *) BmpImage;
+ if (BmpHeader->CharB != 'B' || BmpHeader->CharM != 'M') {
+ return EFI_UNSUPPORTED;
+ }
+
+ if (BmpHeader->CompressionType != 0) {
+ return EFI_UNSUPPORTED;
+ }
+
+ //
+ // Calculate Color Map offset in the image.
+ //
+ Image = BmpImage;
+ BmpColorMap = (BMP_COLOR_MAP *) (Image + sizeof (BMP_IMAGE_HEADER));
+
+ //
+ // Calculate graphics image data address in the image
+ //
+ Image = ((UINT8 *) BmpImage) + BmpHeader->ImageOffset;
+ ImageHeader = Image;
+
+ BltBufferSize = MultU64x32 ((UINT64) BmpHeader->PixelWidth, BmpHeader->PixelHeight);
+ //
+ // Ensure the BltBufferSize * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) doesn't overflow
+ //
+ if (BltBufferSize > DivU64x32 ((UINTN) ~0, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), NULL)) {
+ return EFI_UNSUPPORTED;
+ }
+ BltBufferSize = MultU64x32 (BltBufferSize, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
+
+ IsAllocated = FALSE;
+ if (*GopBlt == NULL) {
+ *GopBltSize = (UINTN) BltBufferSize;
+ *GopBlt = EfiLibAllocatePool (*GopBltSize);
+ IsAllocated = TRUE;
+ if (*GopBlt == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ } else {
+ if (*GopBltSize < (UINTN) BltBufferSize) {
+ *GopBltSize = (UINTN) BltBufferSize;
+ return EFI_BUFFER_TOO_SMALL;
+ }
+ }
+
+ *PixelWidth = BmpHeader->PixelWidth;
+ *PixelHeight = BmpHeader->PixelHeight;
+
+ //
+ // Convert image from BMP to Blt buffer format
+ //
+ BltBuffer = *GopBlt;
+ for (Height = 0; Height < BmpHeader->PixelHeight; Height++) {
+ Blt = &BltBuffer[(BmpHeader->PixelHeight - Height - 1) * BmpHeader->PixelWidth];
+ for (Width = 0; Width < BmpHeader->PixelWidth; Width++, Image++, Blt++) {
+ switch (BmpHeader->BitPerPixel) {
+ case 1:
+ //
+ // Convert 1bit BMP to 24-bit color
+ //
+ for (Index = 0; Index < 8 && Width < BmpHeader->PixelWidth; Index++) {
+ Blt->Red = BmpColorMap[((*Image) >> (7 - Index)) & 0x1].Red;
+ Blt->Green = BmpColorMap[((*Image) >> (7 - Index)) & 0x1].Green;
+ Blt->Blue = BmpColorMap[((*Image) >> (7 - Index)) & 0x1].Blue;
+ Blt++;
+ Width++;
+ }
+
+ Blt --;
+ Width --;
+ break;
+
+ case 4:
+ //
+ // Convert BMP Palette to 24-bit color
+ //
+ Index = (*Image) >> 4;
+ Blt->Red = BmpColorMap[Index].Red;
+ Blt->Green = BmpColorMap[Index].Green;
+ Blt->Blue = BmpColorMap[Index].Blue;
+ if (Width < (BmpHeader->PixelWidth - 1)) {
+ Blt++;
+ Width++;
+ Index = (*Image) & 0x0f;
+ Blt->Red = BmpColorMap[Index].Red;
+ Blt->Green = BmpColorMap[Index].Green;
+ Blt->Blue = BmpColorMap[Index].Blue;
+ }
+ break;
+
+ case 8:
+ //
+ // Convert BMP Palette to 24-bit color
+ //
+ Blt->Red = BmpColorMap[*Image].Red;
+ Blt->Green = BmpColorMap[*Image].Green;
+ Blt->Blue = BmpColorMap[*Image].Blue;
+ break;
+
+ case 24:
+ Blt->Blue = *Image++;
+ Blt->Green = *Image++;
+ Blt->Red = *Image;
+ break;
+
+ default:
+ if (IsAllocated) {
+ gBS->FreePool (*GopBlt);
+ *GopBlt = NULL;
+ }
+ return EFI_UNSUPPORTED;
+ break;
+ };
+
+ }
+
+ ImageIndex = (UINTN) (Image - ImageHeader);
+ if ((ImageIndex % 4) != 0) {
+ //
+ // Bmp Image starts each row on a 32-bit boundary!
+ //
+ Image = Image + (4 - (ImageIndex % 4));
+ }
+ }
+
+ return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+LockKeyboards (
+ IN CHAR16 *Password
+ )
+/*++
+
+Routine Description:
+ Use Console Control Protocol to lock the Console In Spliter virtual handle.
+ This is the ConInHandle and ConIn handle in the EFI system table. All key
+ presses will be ignored until the Password is typed in. The only way to
+ disable the password is to type it in to a ConIn device.
+
+Arguments:
+ Password - Password used to lock ConIn device
+
+
+Returns:
+
+ EFI_SUCCESS - ConsoleControl has been flipped to graphics and logo
+ displayed.
+ EFI_UNSUPPORTED - Logo not found
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_CONSOLE_CONTROL_PROTOCOL *ConsoleControl;
+
+ Status = gBS->LocateProtocol (&gEfiConsoleControlProtocolGuid, NULL, (VOID**)&ConsoleControl);
+ if (EFI_ERROR (Status)) {
+ return EFI_UNSUPPORTED;
+ }
+
+ Status = ConsoleControl->LockStdIn (ConsoleControl, Password);
+ return Status;
+}
+
+
+EFI_STATUS
+EnableQuietBoot (
+ IN EFI_GUID *LogoFile
+ )
+/*++
+
+Routine Description:
+
+ Use Console Control to turn off GOP/UGA based Simple Text Out consoles from going
+ to the GOP/UGA device. Put up LogoFile on every GOP/UGA device that is a console
+
+Arguments:
+
+ LogoFile - File name of logo to display on the center of the screen.
+
+
+Returns:
+
+ EFI_SUCCESS - ConsoleControl has been flipped to graphics and logo
+ displayed.
+ EFI_UNSUPPORTED - Logo not found
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_CONSOLE_CONTROL_PROTOCOL *ConsoleControl;
+ EFI_OEM_BADGING_PROTOCOL *Badging;
+ UINT32 SizeOfX;
+ UINT32 SizeOfY;
+ INTN DestX;
+ INTN DestY;
+ UINT8 *ImageData;
+ UINTN ImageSize;
+ UINTN BltSize;
+ UINT32 Instance;
+ EFI_BADGING_FORMAT Format;
+ EFI_BADGING_DISPLAY_ATTRIBUTE Attribute;
+ UINTN CoordinateX;
+ UINTN CoordinateY;
+ UINTN Height;
+ UINTN Width;
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Blt;
+ EFI_UGA_DRAW_PROTOCOL *UgaDraw;
+ UINT32 ColorDepth;
+ UINT32 RefreshRate;
+ EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
+
+ Status = gBS->LocateProtocol (&gEfiConsoleControlProtocolGuid, NULL, (VOID**)&ConsoleControl);
+ if (EFI_ERROR (Status)) {
+ return EFI_UNSUPPORTED;
+ }
+
+ UgaDraw = NULL;
+ //
+ // Try to open GOP first
+ //
+ Status = gBS->HandleProtocol (gST->ConsoleOutHandle, &gEfiGraphicsOutputProtocolGuid, (VOID**)&GraphicsOutput);
+ if (EFI_ERROR (Status)) {
+ GraphicsOutput = NULL;
+ //
+ // Open GOP failed, try to open UGA
+ //
+ Status = gBS->HandleProtocol (gST->ConsoleOutHandle, &gEfiUgaDrawProtocolGuid, (VOID**)&UgaDraw);
+ if (EFI_ERROR (Status)) {
+ return EFI_UNSUPPORTED;
+ }
+ }
+
+ Badging = NULL;
+ Status = gBS->LocateProtocol (&gEfiOEMBadgingProtocolGuid, NULL, (VOID**)&Badging);
+
+ ConsoleControl->SetMode (ConsoleControl, EfiConsoleControlScreenGraphics);
+
+ if (GraphicsOutput != NULL) {
+ SizeOfX = GraphicsOutput->Mode->Info->HorizontalResolution;
+ SizeOfY = GraphicsOutput->Mode->Info->VerticalResolution;
+ } else {
+ if (UgaDraw) {
+ Status = UgaDraw->GetMode (UgaDraw, &SizeOfX, &SizeOfY, &ColorDepth, &RefreshRate);
+ if (EFI_ERROR (Status)) {
+ return EFI_UNSUPPORTED;
+ }
+ } else {
+ return EFI_UNSUPPORTED;
+ }
+ }
+
+ Instance = 0;
+ while (1) {
+ ImageData = NULL;
+ ImageSize = 0;
+
+ if (Badging != NULL) {
+ Status = Badging->GetImage (
+ Badging,
+ &Instance,
+ &Format,
+ &ImageData,
+ &ImageSize,
+ &Attribute,
+ &CoordinateX,
+ &CoordinateY
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ //
+ // Currently only support BMP format
+ //
+ if (Format != EfiBadgingFormatBMP) {
+ gBS->FreePool (ImageData);
+ continue;
+ }
+ } else {
+ Status = GetGraphicsBitMapFromFV (LogoFile, &ImageData, &ImageSize);
+ if (EFI_ERROR (Status)) {
+ return EFI_UNSUPPORTED;
+ }
+
+ CoordinateX = 0;
+ CoordinateY = 0;
+ Attribute = EfiBadgingDisplayAttributeCenter;
+ }
+
+ Blt = NULL;
+ Status = ConvertBmpToGopBlt (
+ ImageData,
+ ImageSize,
+ (VOID**)&Blt,
+ &BltSize,
+ &Height,
+ &Width
+ );
+ if (EFI_ERROR (Status)) {
+ gBS->FreePool (ImageData);
+ if (Badging == NULL) {
+ return Status;
+ } else {
+ continue;
+ }
+ }
+
+ switch (Attribute) {
+ case EfiBadgingDisplayAttributeLeftTop:
+ DestX = CoordinateX;
+ DestY = CoordinateY;
+ break;
+
+ case EfiBadgingDisplayAttributeCenterTop:
+ DestX = (SizeOfX - Width) / 2;
+ DestY = CoordinateY;
+ break;
+
+ case EfiBadgingDisplayAttributeRightTop:
+ DestX = (SizeOfX - Width - CoordinateX);
+ DestY = CoordinateY;;
+ break;
+
+ case EfiBadgingDisplayAttributeCenterRight:
+ DestX = (SizeOfX - Width - CoordinateX);
+ DestY = (SizeOfY - Height) / 2;
+ break;
+
+ case EfiBadgingDisplayAttributeRightBottom:
+ DestX = (SizeOfX - Width - CoordinateX);
+ DestY = (SizeOfY - Height - CoordinateY);
+ break;
+
+ case EfiBadgingDisplayAttributeCenterBottom:
+ DestX = (SizeOfX - Width) / 2;
+ DestY = (SizeOfY - Height - CoordinateY);
+ break;
+
+ case EfiBadgingDisplayAttributeLeftBottom:
+ DestX = CoordinateX;
+ DestY = (SizeOfY - Height - CoordinateY);
+ break;
+
+ case EfiBadgingDisplayAttributeCenterLeft:
+ DestX = CoordinateX;
+ DestY = (SizeOfY - Height) / 2;
+ break;
+
+ case EfiBadgingDisplayAttributeCenter:
+ DestX = (SizeOfX - Width) / 2;
+ DestY = (SizeOfY - Height) / 2;
+ break;
+
+ default:
+ DestX = CoordinateX;
+ DestY = CoordinateY;
+ break;
+ }
+
+ if ((DestX >= 0) && (DestY >= 0)) {
+ if (GraphicsOutput != NULL) {
+ Status = GraphicsOutput->Blt (
+ GraphicsOutput,
+ Blt,
+ EfiBltBufferToVideo,
+ 0,
+ 0,
+ (UINTN) DestX,
+ (UINTN) DestY,
+ Width,
+ Height,
+ Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)
+ );
+ } else {
+ Status = UgaDraw->Blt (
+ UgaDraw,
+ (EFI_UGA_PIXEL *) Blt,
+ EfiUgaBltBufferToVideo,
+ 0,
+ 0,
+ (UINTN) DestX,
+ (UINTN) DestY,
+ Width,
+ Height,
+ Width * sizeof (EFI_UGA_PIXEL)
+ );
+ }
+ }
+
+ gBS->FreePool (ImageData);
+ gBS->FreePool (Blt);
+
+ if (Badging == NULL) {
+ break;
+ }
+ }
+
+ return Status;
+}
+
+
+EFI_STATUS
+DisableQuietBoot (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Use Console Control to turn on GOP/UGA based Simple Text Out consoles. The GOP/UGA
+ Simple Text Out screens will now be synced up with all non GOP/UGA output devices
+
+Arguments:
+
+ NONE
+
+Returns:
+
+ EFI_SUCCESS - GOP/UGA devices are back in text mode and synced up.
+ EFI_UNSUPPORTED - Logo not found
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_CONSOLE_CONTROL_PROTOCOL *ConsoleControl;
+
+ Status = gBS->LocateProtocol (&gEfiConsoleControlProtocolGuid, NULL, (VOID**)&ConsoleControl);
+ if (EFI_ERROR (Status)) {
+ return EFI_UNSUPPORTED;
+ }
+
+ return ConsoleControl->SetMode (ConsoleControl, EfiConsoleControlScreenText);
+}
diff --git a/EDK/Foundation/Library/Dxe/Graphics/Graphics.inf b/EDK/Foundation/Library/Dxe/Graphics/Graphics.inf
new file mode 100644
index 0000000..a405356
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/Graphics/Graphics.inf
@@ -0,0 +1,51 @@
+#/*++
+#
+# Copyright (c) 2004, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# Graphics.inf
+#
+# Abstract:
+#
+# Component description file.
+#
+#--*/
+
+[defines]
+BASE_NAME = Graphics
+COMPONENT_TYPE = LIBRARY
+
+[sources.common]
+ Graphics.c
+ Print.c
+ Print.h
+ Unicode\PrintWidth.h
+ Unicode\Sprint.c
+
+
+[includes.common]
+ $(EDK_SOURCE)\Foundation\Framework
+ $(EDK_SOURCE)\Foundation
+ $(EDK_SOURCE)\Foundation\Efi
+ .
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Graphics\Unicode
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+
+[libraries.common]
+ EfiDriverLib
+
+[nmake.common]
+ C_STD_INCLUDE=
diff --git a/EDK/Foundation/Library/Dxe/Graphics/GraphicsLib.cif b/EDK/Foundation/Library/Dxe/Graphics/GraphicsLib.cif
new file mode 100644
index 0000000..cdb2c8c
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/Graphics/GraphicsLib.cif
@@ -0,0 +1,18 @@
+<component>
+ name = "GraphicsLib"
+ category = ModulePart
+ LocalRoot = "EDK\Foundation\Library\Dxe\Graphics\"
+ RefName = "GraphicsLib"
+[files]
+"GraphicsLib.sdl"
+"GraphicsLib.mak"
+"Graphics.c"
+"Print.c"
+"Print.h"
+"Graphics.inf"
+[parts]
+"GraphicsAscii"
+"GraphicsUnicode"
+"GraphicsAscii"
+"GraphicsUnicode"
+<endComponent>
diff --git a/EDK/Foundation/Library/Dxe/Graphics/GraphicsLib.mak b/EDK/Foundation/Library/Dxe/Graphics/GraphicsLib.mak
new file mode 100644
index 0000000..0980401
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/Graphics/GraphicsLib.mak
@@ -0,0 +1,70 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/GraphicsLib/GraphicsLib.mak 1 1/20/12 4:07a Jeffch $
+#
+# $Revision: 1 $
+#
+# $Date: 1/20/12 4:07a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/GraphicsLib/GraphicsLib.mak $
+#
+# 1 1/20/12 4:07a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 9/27/11 6:31a Wesleychen
+# Intel EDK initially releases.
+#
+# 2 9/02/09 3:49a Iminglin
+# EIP24919
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: GraphicsLib.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+$(GRAPHICSLIB) : GraphicsLib
+
+$(BUILD_DIR)\GraphicsLib.lib : GraphicsLib
+
+GraphicsLib : $(BUILD_DIR)\GraphicsLib.mak GraphicsLibBin
+
+$(BUILD_DIR)\GraphicsLib.mak : $(GraphicsLib_DIR)\$(@B).cif $(GraphicsLib_DIR)\$(@B).mak $(BUILD_RULES) $(GraphicsLib_DIR)\Unicode\GraphicsUnicode.cif
+ $(CIF2MAK) $(GraphicsLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS) $(GraphicsLib_DIR)\Unicode\GraphicsUnicode.cif
+
+GraphicsLibBin : $(EFIDRIVERLIB)
+ $(MAKE) /$(MAKEFLAGS) $(EDK_DEFAULTS)\
+ /f $(BUILD_DIR)\GraphicsLib.mak all\
+ "MY_INCLUDES=/I$(GraphicsLib_DIR) /I$(GraphicsLib_DIR)\Unicode"\
+ TYPE=LIBRARY \
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#********************************************************************** \ No newline at end of file
diff --git a/EDK/Foundation/Library/Dxe/Graphics/GraphicsLib.sdl b/EDK/Foundation/Library/Dxe/Graphics/GraphicsLib.sdl
new file mode 100644
index 0000000..45b0fcb
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/Graphics/GraphicsLib.sdl
@@ -0,0 +1,26 @@
+TOKEN
+ Name = "GraphicsLib_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable GraphicsLib support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "GRAPHICSLIB"
+ Value = "$(BUILD_DIR)\GraphicsLib.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "GraphicsLib_DIR"
+End
+
+MODULE
+ Help = "Includes GraphicsLib.mak to Project"
+ File = "GraphicsLib.mak"
+End
+
diff --git a/EDK/Foundation/Library/Dxe/Graphics/Print.c b/EDK/Foundation/Library/Dxe/Graphics/Print.c
new file mode 100644
index 0000000..5e22d54
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/Graphics/Print.c
@@ -0,0 +1,973 @@
+/*++
+
+Copyright (c) 2004 - 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Print.c
+
+Abstract:
+
+ Basic Ascii AvSPrintf() function named VSPrint(). VSPrint() enables very
+ simple implemenation of SPrint() and Print() to support debug.
+
+ You can not Print more than EFI_DRIVER_LIB_MAX_PRINT_BUFFER characters at a
+ time. This makes the implementation very simple.
+
+ VSPrint, Print, SPrint format specification has the follwoing form
+
+ %[flags][width]type
+
+ flags:
+ '-' - Left justify
+ '+' - Prefix a sign
+ ' ' - Prefix a blank
+ ',' - Place commas in numberss
+ '0' - Prefix for width with zeros
+ 'l' - UINT64
+ 'L' - UINT64
+
+ width:
+ '*' - Get width from a UINTN argumnet from the argument list
+ Decimal number that represents width of print
+
+ type:
+ 'X' - argument is a UINTN hex number, prefix '0'
+ 'x' - argument is a hex number
+ 'd' - argument is a decimal number
+ 'a' - argument is an ascii string
+ 'S','s' - argument is an Unicode string
+ 'g' - argument is a pointer to an EFI_GUID
+ 't' - argument is a pointer to an EFI_TIME structure
+ 'c' - argument is an ascii character
+ 'r' - argument is EFI_STATUS
+ '%' - Print a %
+
+--*/
+
+#include "Tiano.h"
+#include "EfiDriverLib.h"
+#include "TianoCommon.h"
+#include "EfiCommonLib.h"
+#include "PrintWidth.h"
+#include "EfiPrintLib.h"
+#include "Print.h"
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
+#include EFI_PROTOCOL_DEFINITION (HiiFont)
+#else
+#include EFI_PROTOCOL_DEFINITION (Hii)
+#endif
+
+STATIC
+CHAR_W *
+GetFlagsAndWidth (
+ IN CHAR_W *Format,
+ OUT UINTN *Flags,
+ OUT UINTN *Width,
+ IN OUT VA_LIST *Marker
+ );
+
+STATIC
+UINTN
+GuidToString (
+ IN EFI_GUID *Guid,
+ IN OUT CHAR_W *Buffer,
+ IN UINTN BufferSize
+ );
+
+STATIC
+UINTN
+TimeToString (
+ IN EFI_TIME *Time,
+ IN OUT CHAR_W *Buffer,
+ IN UINTN BufferSize
+ );
+
+STATIC
+UINTN
+EfiStatusToString (
+ IN EFI_STATUS Status,
+ OUT CHAR_W *Buffer,
+ IN UINTN BufferSize
+ );
+
+static EFI_GRAPHICS_OUTPUT_BLT_PIXEL mEfiColors[16] = {
+ 0x00, 0x00, 0x00, 0x00,
+ 0x98, 0x00, 0x00, 0x00,
+ 0x00, 0x98, 0x00, 0x00,
+ 0x98, 0x98, 0x00, 0x00,
+ 0x00, 0x00, 0x98, 0x00,
+ 0x98, 0x00, 0x98, 0x00,
+ 0x00, 0x98, 0x98, 0x00,
+ 0x98, 0x98, 0x98, 0x00,
+ 0x10, 0x10, 0x10, 0x00,
+ 0xff, 0x10, 0x10, 0x00,
+ 0x10, 0xff, 0x10, 0x00,
+ 0xff, 0xff, 0x10, 0x00,
+ 0x10, 0x10, 0xff, 0x00,
+ 0xf0, 0x10, 0xff, 0x00,
+ 0x10, 0xff, 0xff, 0x00,
+ 0xff, 0xff, 0xff, 0x00,
+};
+
+
+UINTN
+_IPrint (
+ IN EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput,
+ IN EFI_UGA_DRAW_PROTOCOL *UgaDraw,
+ IN EFI_SIMPLE_TEXT_OUT_PROTOCOL *Sto,
+ IN UINTN X,
+ IN UINTN Y,
+ IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Foreground,
+ IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Background,
+ IN CHAR16 *fmt,
+ IN VA_LIST args
+ )
+/*++
+
+Routine Description:
+
+ Display string worker for: Print, PrintAt, IPrint, IPrintAt
+
+Arguments:
+
+ GraphicsOutput - Graphics output protocol interface
+
+ UgaDraw - UGA draw protocol interface
+
+ Sto - Simple text out protocol interface
+
+ X - X coordinate to start printing
+
+ Y - Y coordinate to start printing
+
+ Foreground - Foreground color
+
+ Background - Background color
+
+ fmt - Format string
+
+ args - Print arguments
+
+Returns:
+
+ EFI_SUCCESS - success
+ EFI_OUT_OF_RESOURCES - out of resources
+
+--*/
+{
+ VOID *Buffer;
+ EFI_STATUS Status;
+ UINTN Index;
+ CHAR16 *UnicodeWeight;
+ UINT32 HorizontalResolution;
+ UINT32 VerticalResolution;
+ UINT32 ColorDepth;
+ UINT32 RefreshRate;
+ UINTN BufferLen;
+ UINTN LineBufferLen;
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
+ EFI_HII_FONT_PROTOCOL *HiiFont;
+ EFI_IMAGE_OUTPUT *Blt;
+ EFI_FONT_DISPLAY_INFO *FontInfo;
+#else
+ EFI_HII_PROTOCOL *Hii;
+ UINT16 GlyphWidth;
+ UINT32 GlyphStatus;
+ UINT16 StringIndex;
+ EFI_NARROW_GLYPH *Glyph;
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL *LineBuffer;
+#endif
+
+ //
+ // For now, allocate an arbitrarily long buffer
+ //
+ Buffer = EfiLibAllocateZeroPool (0x10000);
+ if (Buffer == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ if (GraphicsOutput != NULL) {
+ HorizontalResolution = GraphicsOutput->Mode->Info->HorizontalResolution;
+ VerticalResolution = GraphicsOutput->Mode->Info->VerticalResolution;
+ } else {
+ UgaDraw->GetMode (UgaDraw, &HorizontalResolution, &VerticalResolution, &ColorDepth, &RefreshRate);
+ }
+ ASSERT ((HorizontalResolution != 0) && (VerticalResolution !=0));
+
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
+ Blt = NULL;
+ FontInfo = NULL;
+ ASSERT (GraphicsOutput != NULL);
+ Status = gBS->LocateProtocol (&gEfiHiiFontProtocolGuid, NULL, (VOID **) &HiiFont);
+ if (EFI_ERROR (Status)) {
+ goto Error;
+ }
+#else
+ LineBuffer = NULL;
+ Status = gBS->LocateProtocol (&gEfiHiiProtocolGuid, NULL, (VOID**)&Hii);
+ if (EFI_ERROR (Status)) {
+ goto Error;
+ }
+ LineBufferLen = sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) * HorizontalResolution * GLYPH_HEIGHT;
+ LineBuffer = EfiLibAllocatePool (LineBufferLen);
+ if (LineBuffer == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Error;
+ }
+#endif
+
+ VSPrint (Buffer, 0x10000, fmt, args);
+
+ UnicodeWeight = (CHAR16 *) Buffer;
+
+ for (Index = 0; UnicodeWeight[Index] != 0; Index++) {
+ if (UnicodeWeight[Index] == CHAR_BACKSPACE ||
+ UnicodeWeight[Index] == CHAR_LINEFEED ||
+ UnicodeWeight[Index] == CHAR_CARRIAGE_RETURN) {
+ UnicodeWeight[Index] = 0;
+ }
+ }
+
+ BufferLen = EfiStrLen (Buffer);
+
+
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
+ LineBufferLen = sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) * HorizontalResolution * EFI_GLYPH_HEIGHT;
+ if (EFI_GLYPH_WIDTH * EFI_GLYPH_HEIGHT * sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL) * BufferLen > LineBufferLen) {
+ Status = EFI_INVALID_PARAMETER;
+ goto Error;
+ }
+
+ Blt = (EFI_IMAGE_OUTPUT *) EfiLibAllocateZeroPool (sizeof (EFI_IMAGE_OUTPUT));
+ if (Blt == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Error;
+ }
+
+ Blt->Width = (UINT16) (HorizontalResolution);
+ Blt->Height = (UINT16) (VerticalResolution);
+ Blt->Image.Screen = GraphicsOutput;
+
+ FontInfo = (EFI_FONT_DISPLAY_INFO *) EfiLibAllocateZeroPool (sizeof (EFI_FONT_DISPLAY_INFO));
+ if (FontInfo == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Error;
+ }
+ if (Foreground != NULL) {
+ EfiCopyMem (&FontInfo->ForegroundColor, Foreground, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
+ } else {
+ EfiCopyMem (
+ &FontInfo->ForegroundColor,
+ &mEfiColors[Sto->Mode->Attribute & 0x0f],
+ sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)
+ );
+ }
+ if (Background != NULL) {
+ EfiCopyMem (&FontInfo->BackgroundColor, Background, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
+ } else {
+ EfiCopyMem (
+ &FontInfo->BackgroundColor,
+ &mEfiColors[Sto->Mode->Attribute >> 4],
+ sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)
+ );
+ }
+
+ Status = HiiFont->StringToImage (
+ HiiFont,
+ EFI_HII_IGNORE_IF_NO_GLYPH | EFI_HII_DIRECT_TO_SCREEN,
+ Buffer,
+ FontInfo,
+ &Blt,
+ X,
+ Y,
+ NULL,
+ NULL,
+ NULL
+ );
+
+#else
+ GlyphStatus = 0;
+
+ if (GLYPH_WIDTH * GLYPH_HEIGHT * sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL) * BufferLen > LineBufferLen) {
+ Status = EFI_INVALID_PARAMETER;
+ goto Error;
+ }
+
+ for (Index = 0; Index < BufferLen; Index++) {
+ StringIndex = (UINT16) Index;
+ Status = Hii->GetGlyph (Hii, UnicodeWeight, &StringIndex, (UINT8 **) &Glyph, &GlyphWidth, &GlyphStatus);
+ if (EFI_ERROR (Status)) {
+ goto Error;
+ }
+
+ if (Foreground == NULL || Background == NULL) {
+ Status = Hii->GlyphToBlt (
+ Hii,
+ (UINT8 *) Glyph,
+ mEfiColors[Sto->Mode->Attribute & 0x0f],
+ mEfiColors[Sto->Mode->Attribute >> 4],
+ BufferLen,
+ GlyphWidth,
+ GLYPH_HEIGHT,
+ &LineBuffer[Index * GLYPH_WIDTH]
+ );
+ } else {
+ Status = Hii->GlyphToBlt (
+ Hii,
+ (UINT8 *) Glyph,
+ *Foreground,
+ *Background,
+ BufferLen,
+ GlyphWidth,
+ GLYPH_HEIGHT,
+ &LineBuffer[Index * GLYPH_WIDTH]
+ );
+ }
+ }
+
+ //
+ // Blt a character to the screen
+ //
+ if (GraphicsOutput != NULL) {
+ Status = GraphicsOutput->Blt (
+ GraphicsOutput,
+ LineBuffer,
+ EfiBltBufferToVideo,
+ 0,
+ 0,
+ X,
+ Y,
+ GLYPH_WIDTH * BufferLen,
+ GLYPH_HEIGHT,
+ GLYPH_WIDTH * BufferLen * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)
+ );
+ } else {
+ Status = UgaDraw->Blt (
+ UgaDraw,
+ (EFI_UGA_PIXEL *) LineBuffer,
+ EfiUgaBltBufferToVideo,
+ 0,
+ 0,
+ X,
+ Y,
+ GLYPH_WIDTH * BufferLen,
+ GLYPH_HEIGHT,
+ GLYPH_WIDTH * BufferLen * sizeof (EFI_UGA_PIXEL)
+ );
+ }
+
+#endif
+
+Error:
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
+ EfiLibSafeFreePool (Blt);
+ EfiLibSafeFreePool (FontInfo);
+#else
+ gBS->FreePool (LineBuffer);
+#endif
+ gBS->FreePool (Buffer);
+ return Status;
+}
+
+
+UINTN
+PrintXY (
+ IN UINTN X,
+ IN UINTN Y,
+ IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *ForeGround, OPTIONAL
+ IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BackGround, OPTIONAL
+ IN CHAR_W *Fmt,
+ ...
+ )
+/*++
+
+Routine Description:
+
+ Prints a formatted unicode string to the default console
+
+Arguments:
+
+ X - X coordinate to start printing
+
+ Y - Y coordinate to start printing
+
+ ForeGround - Foreground color
+
+ BackGround - Background color
+
+ Fmt - Format string
+
+ ... - Print arguments
+
+Returns:
+
+ Length of string printed to the console
+
+--*/
+{
+ EFI_HANDLE Handle;
+ EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
+ EFI_UGA_DRAW_PROTOCOL *UgaDraw;
+ EFI_SIMPLE_TEXT_OUT_PROTOCOL *Sto;
+ EFI_STATUS Status;
+ VA_LIST Args;
+
+ VA_START (Args, Fmt);
+
+ Handle = gST->ConsoleOutHandle;
+
+ Status = gBS->HandleProtocol (
+ Handle,
+ &gEfiGraphicsOutputProtocolGuid,
+ (VOID**)&GraphicsOutput
+ );
+
+ UgaDraw = NULL;
+ if (EFI_ERROR (Status)) {
+ GraphicsOutput = NULL;
+
+ Status = gBS->HandleProtocol (
+ Handle,
+ &gEfiUgaDrawProtocolGuid,
+ (VOID**)&UgaDraw
+ );
+
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ }
+
+ Status = gBS->HandleProtocol (
+ Handle,
+ &gEfiSimpleTextOutProtocolGuid,
+ (VOID**)&Sto
+ );
+
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ return _IPrint (GraphicsOutput, UgaDraw, Sto, X, Y, ForeGround, BackGround, Fmt, Args);
+}
+
+
+UINTN
+SPrint (
+ OUT CHAR_W *Buffer,
+ IN UINTN BufferSize,
+ IN CONST CHAR_W *Format,
+ ...
+ )
+/*++
+
+Routine Description:
+
+ SPrint function to process format and place the results in Buffer.
+
+Arguments:
+
+ Buffer - Wide char buffer to print the results of the parsing of Format into.
+
+ BufferSize - Maximum number of characters to put into buffer. Zero means no
+ limit.
+
+ Format - Format string see file header for more details.
+
+ ... - Vararg list consumed by processing Format.
+
+Returns:
+
+ Number of characters printed.
+
+--*/
+{
+ UINTN Return;
+ VA_LIST Marker;
+
+ VA_START (Marker, Format);
+ Return = VSPrint (Buffer, BufferSize, Format, Marker);
+ VA_END (Marker);
+
+ return Return;
+}
+
+UINTN
+EFIAPI
+VSPrint (
+ OUT CHAR_W *StartOfBuffer,
+ IN UINTN BufferSize,
+ IN CONST CHAR_W *FormatString,
+ IN VA_LIST Marker
+ )
+/*++
+
+Routine Description:
+
+ VSPrint function to process format and place the results in Buffer. Since a
+ VA_LIST is used this rountine allows the nesting of Vararg routines. Thus
+ this is the main print working routine
+
+Arguments:
+
+ StartOfBuffer - Unicode buffer to print the results of the parsing of Format into.
+
+ BufferSize - Maximum number of characters to put into buffer. Zero means
+ no limit.
+
+ FormatString - Unicode format string see file header for more details.
+
+ Marker - Vararg list consumed by processing Format.
+
+Returns:
+
+ Number of characters printed.
+
+--*/
+{
+ CHAR16 TempBuffer[CHARACTER_NUMBER_FOR_VALUE];
+ CHAR_W *Buffer;
+ CHAR8 *AsciiStr;
+ CHAR16 *UnicodeStr;
+ CHAR_W *Format;
+ UINTN Index;
+ UINTN Flags;
+ UINTN Width;
+ UINTN Count;
+ UINTN NumberOfCharacters;
+ UINTN BufferLeft;
+ UINT64 Value;
+ EFI_GUID *TmpGUID;
+
+ //
+ // Process the format string. Stop if Buffer is over run.
+ //
+
+ Buffer = StartOfBuffer;
+ Format = (CHAR_W *) FormatString;
+ NumberOfCharacters = BufferSize / sizeof (CHAR_W);
+ BufferLeft = BufferSize;
+ for (Index = 0; (*Format != '\0') && (Index < NumberOfCharacters - 1); Format++) {
+ if (*Format != '%') {
+ if ((*Format == '\n') && (Index < NumberOfCharacters - 2)) {
+ //
+ // If carage return add line feed
+ //
+ Buffer[Index++] = '\r';
+ BufferLeft -= sizeof (CHAR_W);
+ }
+
+ Buffer[Index++] = *Format;
+ BufferLeft -= sizeof (CHAR_W);
+ } else {
+
+ //
+ // Now it's time to parse what follows after %
+ //
+ Format = GetFlagsAndWidth (Format, &Flags, &Width, &Marker);
+ switch (*Format) {
+ case 'X':
+ Flags |= PREFIX_ZERO;
+ Width = sizeof (UINT64) * 2;
+
+ //
+ // break skiped on purpose
+ //
+ case 'x':
+ if ((Flags & LONG_TYPE) == LONG_TYPE) {
+ Value = VA_ARG (Marker, UINT64);
+ } else {
+ Value = VA_ARG (Marker, UINTN);
+ }
+
+ EfiValueToHexStr (TempBuffer, Value, Flags, Width);
+ UnicodeStr = TempBuffer;
+
+ for (; (*UnicodeStr != '\0') && (Index < NumberOfCharacters - 1); UnicodeStr++) {
+ Buffer[Index++] = *UnicodeStr;
+ }
+ break;
+
+ case 'd':
+ if ((Flags & LONG_TYPE) == LONG_TYPE) {
+ Value = VA_ARG (Marker, UINT64);
+ } else {
+ Value = (UINTN) VA_ARG (Marker, UINTN);
+ }
+
+ EfiValueToString (TempBuffer, Value, Flags, Width);
+ UnicodeStr = TempBuffer;
+
+ for (; (*UnicodeStr != '\0') && (Index < NumberOfCharacters - 1); UnicodeStr++) {
+ Buffer[Index++] = *UnicodeStr;
+ }
+ break;
+
+ case 's':
+ case 'S':
+ UnicodeStr = (CHAR16 *) VA_ARG (Marker, CHAR_W *);
+ if (UnicodeStr == NULL) {
+ UnicodeStr = L"<null string>";
+ }
+
+ for (Count = 0; (*UnicodeStr != '\0') && (Index < NumberOfCharacters - 1); UnicodeStr++, Count++) {
+ Buffer[Index++] = *UnicodeStr;
+ }
+ //
+ // Add padding if needed
+ //
+ for (; (Count < Width) && (Index < NumberOfCharacters - 1); Count++) {
+ Buffer[Index++] = ' ';
+ }
+
+ break;
+
+ case 'a':
+ AsciiStr = (CHAR8 *) VA_ARG (Marker, CHAR8 *);
+ if (AsciiStr == NULL) {
+ AsciiStr = "<null string>";
+ }
+
+ for (Count = 0; (*AsciiStr != '\0') && (Index < NumberOfCharacters - 1); AsciiStr++, Count++) {
+ Buffer[Index++] = (CHAR_W) * AsciiStr;
+ }
+ //
+ // Add padding if needed
+ //
+ for (; (Count < Width) && (Index < NumberOfCharacters - 1); Count++) {
+ Buffer[Index++] = ' ';
+ }
+ break;
+
+ case 'c':
+ Buffer[Index++] = (CHAR_W) VA_ARG (Marker, UINTN);
+ break;
+
+ case 'g':
+ TmpGUID = VA_ARG (Marker, EFI_GUID *);
+ if (TmpGUID != NULL) {
+ Index += GuidToString (
+ TmpGUID,
+ &Buffer[Index],
+ BufferLeft
+ );
+ }
+ break;
+
+ case 't':
+ Index += TimeToString (
+ VA_ARG (Marker, EFI_TIME *),
+ &Buffer[Index],
+ BufferLeft
+ );
+ break;
+
+ case 'r':
+ Index += EfiStatusToString (
+ VA_ARG (Marker, EFI_STATUS),
+ &Buffer[Index],
+ BufferLeft
+ );
+ break;
+
+ case '%':
+ Buffer[Index++] = *Format;
+ break;
+
+ default:
+ //
+ // if the type is unknown print it to the screen
+ //
+ Buffer[Index++] = *Format;
+ }
+
+ BufferLeft = BufferSize - Index * sizeof (CHAR_W);
+ }
+ }
+
+ Buffer[Index++] = '\0';
+
+ return &Buffer[Index] - StartOfBuffer;
+}
+
+STATIC
+CHAR_W *
+GetFlagsAndWidth (
+ IN CHAR_W *Format,
+ OUT UINTN *Flags,
+ OUT UINTN *Width,
+ IN OUT VA_LIST *Marker
+ )
+/*++
+
+Routine Description:
+
+ VSPrint worker function that parses flag and width information from the
+ Format string and returns the next index into the Format string that needs
+ to be parsed. See file headed for details of Flag and Width.
+
+Arguments:
+
+ Format - Current location in the VSPrint format string.
+
+ Flags - Returns flags
+
+ Width - Returns width of element
+
+ Marker - Vararg list that may be paritally consumed and returned.
+
+Returns:
+
+ Pointer indexed into the Format string for all the information parsed
+ by this routine.
+
+--*/
+{
+ UINTN Count;
+ BOOLEAN Done;
+
+ *Flags = 0;
+ *Width = 0;
+ for (Done = FALSE; !Done;) {
+ Format++;
+
+ switch (*Format) {
+
+ case '-':
+ *Flags |= LEFT_JUSTIFY;
+ break;
+
+ case '+':
+ *Flags |= PREFIX_SIGN;
+ break;
+
+ case ' ':
+ *Flags |= PREFIX_BLANK;
+ break;
+
+ case ',':
+ *Flags |= COMMA_TYPE;
+ break;
+
+ case 'L':
+ case 'l':
+ *Flags |= LONG_TYPE;
+ break;
+
+ case '*':
+ *Width = VA_ARG (*Marker, UINTN);
+ break;
+
+ case '0':
+ *Flags |= PREFIX_ZERO;
+
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ Count = 0;
+ do {
+ Count = (Count * 10) +*Format - '0';
+ Format++;
+ } while ((*Format >= '0') && (*Format <= '9'));
+ Format--;
+ *Width = Count;
+ break;
+
+ default:
+ Done = TRUE;
+ }
+ }
+
+ return Format;
+}
+
+STATIC
+UINTN
+GuidToString (
+ IN EFI_GUID *Guid,
+ IN CHAR_W *Buffer,
+ IN UINTN BufferSize
+ )
+/*++
+
+Routine Description:
+
+ VSPrint worker function that prints an EFI_GUID.
+
+Arguments:
+
+ Guid - Pointer to GUID to print.
+
+ Buffer - Buffe to print Guid into.
+
+ BufferSize - Size of Buffer.
+
+Returns:
+
+ Number of characters printed.
+
+--*/
+{
+ UINTN Size;
+
+ Size = SPrint (
+ Buffer,
+ BufferSize,
+ STRING_W ("%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x"),
+ (UINTN)Guid->Data1,
+ (UINTN)Guid->Data2,
+ (UINTN)Guid->Data3,
+ (UINTN)Guid->Data4[0],
+ (UINTN)Guid->Data4[1],
+ (UINTN)Guid->Data4[2],
+ (UINTN)Guid->Data4[3],
+ (UINTN)Guid->Data4[4],
+ (UINTN)Guid->Data4[5],
+ (UINTN)Guid->Data4[6],
+ (UINTN)Guid->Data4[7]
+ );
+
+ //
+ // SPrint will null terminate the string. The -1 skips the null
+ //
+ return Size - 1;
+}
+
+
+STATIC
+UINTN
+TimeToString (
+ IN EFI_TIME *Time,
+ OUT CHAR_W *Buffer,
+ IN UINTN BufferSize
+ )
+/*++
+
+Routine Description:
+
+ VSPrint worker function that prints EFI_TIME.
+
+Arguments:
+
+ Time - Pointer to EFI_TIME sturcture to print.
+
+ Buffer - Buffer to print Time into.
+
+ BufferSize - Size of Buffer.
+
+Returns:
+
+ Number of characters printed.
+
+--*/
+{
+ UINTN Size;
+
+ Size = SPrint (
+ Buffer,
+ BufferSize,
+ STRING_W ("%02d/%02d/%04d %02d:%02d"),
+ (UINTN)Time->Month,
+ (UINTN)Time->Day,
+ (UINTN)Time->Year,
+ (UINTN)Time->Hour,
+ (UINTN)Time->Minute
+ );
+
+ //
+ // SPrint will null terminate the string. The -1 skips the null
+ //
+ return Size - 1;
+}
+
+STATIC
+UINTN
+EfiStatusToString (
+ IN EFI_STATUS Status,
+ OUT CHAR_W *Buffer,
+ IN UINTN BufferSize
+ )
+/*++
+
+Routine Description:
+
+ VSPrint worker function that prints EFI_STATUS as a string. If string is
+ not known a hex value will be printed.
+
+Arguments:
+
+ Status - EFI_STATUS sturcture to print.
+
+ Buffer - Buffer to print EFI_STATUS message string into.
+
+ BufferSize - Size of Buffer.
+
+Returns:
+
+ Number of characters printed.
+
+--*/
+{
+ UINTN Size;
+ CHAR8 *Desc;
+
+ Desc = NULL;
+
+ //
+ // Can't use global Status String Array as UINTN is not constant for EBC
+ //
+ if (Status == EFI_SUCCESS) { Desc = "Success"; } else
+ if (Status == EFI_LOAD_ERROR) { Desc = "Load Error"; } else
+ if (Status == EFI_INVALID_PARAMETER) { Desc = "Invalid Parameter"; } else
+ if (Status == EFI_UNSUPPORTED) { Desc = "Unsupported"; } else
+ if (Status == EFI_BAD_BUFFER_SIZE) { Desc = "Bad Buffer Size"; } else
+ if (Status == EFI_BUFFER_TOO_SMALL) { Desc = "Buffer Too Small"; } else
+ if (Status == EFI_NOT_READY) { Desc = "Not Ready"; } else
+ if (Status == EFI_DEVICE_ERROR) { Desc = "Device Error"; } else
+ if (Status == EFI_WRITE_PROTECTED) { Desc = "Write Protected"; } else
+ if (Status == EFI_OUT_OF_RESOURCES) { Desc = "Out of Resources"; } else
+ if (Status == EFI_VOLUME_CORRUPTED) { Desc = "Volume Corrupt"; } else
+ if (Status == EFI_VOLUME_FULL) { Desc = "Volume Full"; } else
+ if (Status == EFI_NO_MEDIA) { Desc = "No Media"; } else
+ if (Status == EFI_MEDIA_CHANGED) { Desc = "Media changed"; } else
+ if (Status == EFI_NOT_FOUND) { Desc = "Not Found"; } else
+ if (Status == EFI_ACCESS_DENIED) { Desc = "Access Denied"; } else
+ if (Status == EFI_NO_RESPONSE) { Desc = "No Response"; } else
+ if (Status == EFI_NO_MAPPING) { Desc = "No mapping"; } else
+ if (Status == EFI_TIMEOUT) { Desc = "Time out"; } else
+ if (Status == EFI_NOT_STARTED) { Desc = "Not started"; } else
+ if (Status == EFI_ALREADY_STARTED) { Desc = "Already started"; } else
+ if (Status == EFI_ABORTED) { Desc = "Aborted"; } else
+ if (Status == EFI_ICMP_ERROR) { Desc = "ICMP Error"; } else
+ if (Status == EFI_TFTP_ERROR) { Desc = "TFTP Error"; } else
+ if (Status == EFI_PROTOCOL_ERROR) { Desc = "Protocol Error"; } else
+ if (Status == EFI_WARN_UNKNOWN_GLYPH) { Desc = "Warning Unknown Glyph"; } else
+ if (Status == EFI_WARN_DELETE_FAILURE) { Desc = "Warning Delete Failure"; } else
+ if (Status == EFI_WARN_WRITE_FAILURE) { Desc = "Warning Write Failure"; } else
+ if (Status == EFI_WARN_BUFFER_TOO_SMALL) { Desc = "Warning Buffer Too Small"; }
+
+ //
+ // If we found a match, copy the message to the user's buffer. Otherwise
+ // sprint the hex status code to their buffer.
+ //
+ if (Desc != NULL) {
+ Size = SPrint (Buffer, BufferSize, STRING_W ("%a"), Desc);
+ } else {
+ Size = SPrint (Buffer, BufferSize, STRING_W ("%X"), Status);
+ }
+
+ return Size - 1;
+}
diff --git a/EDK/Foundation/Library/Dxe/Graphics/Print.h b/EDK/Foundation/Library/Dxe/Graphics/Print.h
new file mode 100644
index 0000000..ad54aa8
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/Graphics/Print.h
@@ -0,0 +1,37 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Print.h
+
+Abstract:
+
+ Private data for Print.c
+
+--*/
+
+#ifndef _PRINT_H_
+#define _PRINT_H_
+
+#define LEFT_JUSTIFY 0x01
+#define PREFIX_SIGN 0x02
+#define PREFIX_BLANK 0x04
+#define COMMA_TYPE 0x08
+#define LONG_TYPE 0x10
+#define PREFIX_ZERO 0x20
+
+//
+// Largest number of characters that can be printed out.
+//
+#define EFI_DRIVER_LIB_MAX_PRINT_BUFFER (80 * 4)
+
+#endif
diff --git a/EDK/Foundation/Library/Dxe/Graphics/Unicode/GraphicsUnicode.cif b/EDK/Foundation/Library/Dxe/Graphics/Unicode/GraphicsUnicode.cif
new file mode 100644
index 0000000..928a0b9
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/Graphics/Unicode/GraphicsUnicode.cif
@@ -0,0 +1,9 @@
+<component>
+ name = "GraphicsUnicode"
+ category = ModulePart
+ LocalRoot = "EDK\Foundation\Library\Dxe\Graphics\Unicode"
+ RefName = "GraphicsUnicode"
+[files]
+"PrintWidth.h"
+"Sprint.c"
+<endComponent>
diff --git a/EDK/Foundation/Library/Dxe/Graphics/Unicode/PrintWidth.h b/EDK/Foundation/Library/Dxe/Graphics/Unicode/PrintWidth.h
new file mode 100644
index 0000000..9df3fc9
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/Graphics/Unicode/PrintWidth.h
@@ -0,0 +1,34 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PrintWidth.h
+
+Abstract:
+
+ Unicde option for generic width.
+ CHAR_W is Unicode
+ STRING_W is L""
+
+--*/
+
+#ifndef _PRINT_WIDTH_H_
+#define _PRINT_WIDTH_H_
+
+typedef CHAR16 CHAR_W;
+#define STRING_W(_s) L##_s
+
+#define USPrint(Buffer, BufferSize, Format) SPrint (Buffer, BufferSize, Format)
+#define UvSPrint(Buffer, BufferSize, Format, Marker) VSPrint (Buffer, BufferSize, Format, Marker)
+
+#include "EfiCommonLib.h"
+#endif
diff --git a/EDK/Foundation/Library/Dxe/Graphics/Unicode/Sprint.c b/EDK/Foundation/Library/Dxe/Graphics/Unicode/Sprint.c
new file mode 100644
index 0000000..3daf4d9
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/Graphics/Unicode/Sprint.c
@@ -0,0 +1,147 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Sprint.c
+
+Abstract:
+
+ Basic Ascii AvSPrintf() function named VSPrint(). VSPrint() enables very
+ simple implemenation of SPrint() and Print() to support debug.
+
+ You can not Print more than EFI_DRIVER_LIB_MAX_PRINT_BUFFER characters at a
+ time. This makes the implementation very simple.
+
+ VSPrint, Print, SPrint format specification has the follwoing form
+
+ %[flags][width]type
+
+ flags:
+ '-' - Left justify
+ '+' - Prefix a sign
+ ' ' - Prefix a blank
+ ',' - Place commas in numberss
+ '0' - Prefix for width with zeros
+ 'l' - UINT64
+ 'L' - UINT64
+
+ width:
+ '*' - Get width from a UINTN argumnet from the argument list
+ Decimal number that represents width of print
+
+ type:
+ 'X' - argument is a UINTN hex number, prefix '0'
+ 'x' - argument is a hex number
+ 'd' - argument is a decimal number
+ 'a' - argument is an ascii string
+ 'S','s' - argument is an Unicode string
+ 'g' - argument is a pointer to an EFI_GUID
+ 't' - argument is a pointer to an EFI_TIME structure
+ 'c' - argument is an ascii character
+ 'r' - argument is EFI_STATUS
+ '%' - Print a %
+
+--*/
+
+#include "TianoCommon.h"
+#include "PrintWidth.h"
+#include "EfiPrintLib.h"
+#include "Print.h"
+
+
+UINTN
+ASPrint (
+ OUT CHAR8 *Buffer,
+ IN UINTN BufferSize,
+ IN CONST CHAR8 *Format,
+ ...
+ )
+/*++
+
+Routine Description:
+
+ Process format and place the results in Buffer for narrow chars.
+
+Arguments:
+
+ Buffer - Narrow char buffer to print the results of the parsing of Format into.
+ BufferSize - Maximum number of characters to put into buffer.
+ Format - Format string
+ ... - Vararg list consumed by processing Format.
+
+Returns:
+
+ Number of characters printed.
+
+--*/
+{
+ UINTN Return;
+ VA_LIST Marker;
+
+ VA_START (Marker, Format);
+ Return = AvSPrint (Buffer, BufferSize, Format, Marker);
+ VA_END (Marker);
+
+ return Return;
+}
+
+
+UINTN
+AvSPrint (
+ OUT CHAR8 *Buffer,
+ IN UINTN BufferSize,
+ IN CONST CHAR8 *FormatString,
+ IN VA_LIST Marker
+ )
+/*++
+
+Routine Description:
+
+ Internal implementation of ASPrint.
+ Process format and place the results in Buffer for narrow chars.
+
+Arguments:
+
+ Buffer - Narrow char buffer to print the results of the parsing of Format into.
+ BufferSize - Maximum number of characters to put into buffer.
+ FormatString - Format string
+ Marker - Vararg list consumed by processing Format.
+
+Returns:
+
+ Number of characters printed.
+
+--*/
+{
+ UINTN Index;
+ //
+ // Increase array size of 'UnicodeFormat' and 'UnicodeResult' by 1, as there is a possibility of buffer overflow.
+ //
+ CHAR16 UnicodeFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER+1];
+ CHAR16 UnicodeResult[EFI_DRIVER_LIB_MAX_PRINT_BUFFER+1];
+
+ for (Index = 0; Index < EFI_DRIVER_LIB_MAX_PRINT_BUFFER && FormatString[Index] != '\0'; Index++) {
+ UnicodeFormat[Index] = (CHAR16) FormatString[Index];
+ }
+
+ UnicodeFormat[Index] = '\0';
+
+ Index = VSPrint (UnicodeResult, sizeof (UnicodeResult)/sizeof (CHAR16), UnicodeFormat, Marker);
+
+ for (Index = 0; (Index < (BufferSize - 1)) && UnicodeResult[Index] != '\0'; Index++) {
+ Buffer[Index] = (CHAR8) UnicodeResult[Index];
+ }
+
+ Buffer[Index] = '\0';
+
+ return Index++;
+}
diff --git a/EDK/Foundation/Library/Dxe/GraphicsLite/Ascii/GraphicsLiteAscii.cif b/EDK/Foundation/Library/Dxe/GraphicsLite/Ascii/GraphicsLiteAscii.cif
new file mode 100644
index 0000000..2cbfcb6
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/GraphicsLite/Ascii/GraphicsLiteAscii.cif
@@ -0,0 +1,9 @@
+<component>
+ name = "GraphicsLiteAscii"
+ category = ModulePart
+ LocalRoot = "EDK\Foundation\Library\Dxe\GraphicsLite\Ascii"
+ RefName = "GraphicsLiteAscii"
+[files]
+"PrintWidth.h"
+"Sprint.c"
+<endComponent>
diff --git a/EDK/Foundation/Library/Dxe/GraphicsLite/Ascii/PrintWidth.h b/EDK/Foundation/Library/Dxe/GraphicsLite/Ascii/PrintWidth.h
new file mode 100644
index 0000000..07901dc
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/GraphicsLite/Ascii/PrintWidth.h
@@ -0,0 +1,88 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PrintWidth.h
+
+Abstract:
+
+ Unicde option for generic width.
+ CHAR_W is Ascii
+ STRING_W is ""
+
+--*/
+
+#ifndef _PRINT_WIDTH_H_
+#define _PRINT_WIDTH_H_
+
+typedef CHAR8 CHAR_W;
+#define STRING_W(_s) _s
+
+#define ASPrint(Buffer, BufferSize, Format) SPrint (Buffer, BufferSize, Format)
+#define AvSPrint(Buffer, BufferSize, Format, Marker) VSPrint (Buffer, BufferSize, Format, Marker)
+
+UINTN
+UvSPrint (
+ OUT CHAR16 *StartOfBuffer,
+ IN UINTN StrLen,
+ IN CONST CHAR16 *Format,
+ IN VA_LIST Marker
+ )
+/*++
+
+Routine Description:
+
+ Internal implementation of USPrint.
+ Process format and place the results in Buffer for wide chars.
+
+Arguments:
+
+ StartOfBuffer - Wide char buffer to print the results of the parsing of Format into.
+ StrLen - Maximum number of characters to put into buffer.
+ Format - Format string
+ Marker - Vararg list consumed by processing Format.
+
+Returns:
+
+ Number of characters printed.
+
+--*/
+;
+
+UINTN
+USPrint (
+ OUT CHAR16 *Buffer,
+ IN UINTN BufferSize,
+ IN CONST CHAR16 *Format,
+ ...
+ )
+/*++
+
+Routine Description:
+
+ Process format and place the results in Buffer for wide chars.
+
+Arguments:
+
+ Buffer - Wide char buffer to print the results of the parsing of Format into.
+ BufferSize - Maximum number of characters to put into buffer.
+ Format - Format string
+ ... - Vararg list consumed by processing Format.
+
+Returns:
+
+ Number of characters printed.
+
+--*/
+;
+
+#endif
diff --git a/EDK/Foundation/Library/Dxe/GraphicsLite/Ascii/Sprint.c b/EDK/Foundation/Library/Dxe/GraphicsLite/Ascii/Sprint.c
new file mode 100644
index 0000000..bb4bb1e
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/GraphicsLite/Ascii/Sprint.c
@@ -0,0 +1,144 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Sprint.c
+
+Abstract:
+
+ Basic Ascii AvSPrintf() function named VSPrint(). VSPrint() enables very
+ simple implemenation of SPrint() and Print() to support debug.
+
+ You can not Print more than EFI_DRIVER_LIB_MAX_PRINT_BUFFER characters at a
+ time. This makes the implementation very simple.
+
+ VSPrint, Print, SPrint format specification has the follwoing form
+
+ %[flags][width]type
+
+ flags:
+ '-' - Left justify
+ '+' - Prefix a sign
+ ' ' - Prefix a blank
+ ',' - Place commas in numberss
+ '0' - Prefix for width with zeros
+ 'l' - UINT64
+ 'L' - UINT64
+
+ width:
+ '*' - Get width from a UINTN argumnet from the argument list
+ Decimal number that represents width of print
+
+ type:
+ 'X' - argument is a UINTN hex number, prefix '0'
+ 'x' - argument is a hex number
+ 'd' - argument is a decimal number
+ 'a' - argument is an ascii string
+ 'S','s' - argument is an Unicode string
+ 'g' - argument is a pointer to an EFI_GUID
+ 't' - argument is a pointer to an EFI_TIME structure
+ 'c' - argument is an ascii character
+ 'r' - argument is EFI_STATUS
+ '%' - Print a %
+
+--*/
+
+#include "TianoCommon.h"
+#include "PrintWidth.h"
+#include "EfiPrintLib.h"
+#include "Print.h"
+
+
+UINTN
+USPrint (
+ OUT CHAR16 *Buffer,
+ IN UINTN BufferSize,
+ IN CONST CHAR16 *Format,
+ ...
+ )
+/*++
+
+Routine Description:
+
+ Process format and place the results in Buffer for wide chars.
+
+Arguments:
+
+ Buffer - Wide char buffer to print the results of the parsing of Format into.
+ BufferSize - Maximum number of characters to put into buffer.
+ Format - Format string
+ ... - Vararg list consumed by processing Format.
+
+Returns:
+
+ Number of characters printed.
+
+--*/
+{
+ UINTN Return;
+ VA_LIST Marker;
+
+ VA_START (Marker, Format);
+ Return = UnicodeVSPrint (Buffer, BufferSize, Format, Marker);
+ VA_END (Marker);
+
+ return Return;
+}
+
+
+UINTN
+UvSPrint (
+ OUT CHAR16 *Buffer,
+ IN UINTN BufferSize,
+ IN CONST CHAR16 *FormatString,
+ IN VA_LIST Marker
+ )
+/*++
+
+Routine Description:
+
+ Internal implementation of USPrint.
+ Process format and place the results in Buffer for wide chars.
+
+Arguments:
+
+ Buffer - Wide char buffer to print the results of the parsing of Format into.
+ BufferSize - Maximum number of characters to put into buffer.
+ FormatString - Format string
+ Marker - Vararg list consumed by processing Format.
+
+Returns:
+
+ Number of characters printed.
+
+--*/
+{
+ UINTN Index;
+ CHAR8 AsciiFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];
+ CHAR8 AsciiResult[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];
+
+ for (Index = 0; Index < EFI_DRIVER_LIB_MAX_PRINT_BUFFER && FormatString[Index] != '\0'; Index++) {
+ AsciiFormat[Index] = (CHAR8) FormatString[Index];
+ }
+
+ AsciiFormat[Index] = '\0';
+
+ Index = VSPrint (AsciiResult, EFI_DRIVER_LIB_MAX_PRINT_BUFFER, AsciiFormat, Marker);
+
+ for (Index = 0; (Index < (BufferSize - 1)) && AsciiResult[Index] != '\0'; Index++) {
+ Buffer[Index] = (CHAR16) AsciiResult[Index];
+ }
+
+ Buffer[Index] = '\0';
+
+ return Index++;
+}
diff --git a/EDK/Foundation/Library/Dxe/GraphicsLite/Graphics.c b/EDK/Foundation/Library/Dxe/GraphicsLite/Graphics.c
new file mode 100644
index 0000000..b54e960
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/GraphicsLite/Graphics.c
@@ -0,0 +1,617 @@
+/*++
+
+Copyright (c) 2004 - 2011, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Graphics.c
+
+Abstract:
+
+ Support for Basic Graphics operations.
+
+ BugBug: Currently *.BMP files are supported. This will be replaced
+ when Tiano graphics format is supported.
+
+--*/
+
+#include "Tiano.h"
+#include "EfiDriverLib.h"
+#include "GraphicsLib.h"
+
+
+EFI_STATUS
+GetGraphicsBitMapFromFV (
+ IN EFI_GUID *FileNameGuid,
+ OUT VOID **Image,
+ OUT UINTN *ImageSize
+ )
+/*++
+
+Routine Description:
+
+ Return the graphics image file named FileNameGuid into Image and return it's
+ size in ImageSize. All Firmware Volumes (FV) in the system are searched for the
+ file name.
+
+Arguments:
+
+ FileNameGuid - File Name of graphics file in the FV(s).
+
+ Image - Pointer to pointer to return graphics image. If NULL, a
+ buffer will be allocated.
+
+ ImageSize - Size of the graphics Image in bytes. Zero if no image found.
+
+
+Returns:
+
+ EFI_SUCCESS - Image and ImageSize are valid.
+ EFI_BUFFER_TOO_SMALL - Image not big enough. ImageSize has required size
+ EFI_NOT_FOUND - FileNameGuid not found
+
+--*/
+{
+ EFI_STATUS Status;
+ UINTN FvProtocolCount;
+ EFI_HANDLE *FvHandles;
+#if (PI_SPECIFICATION_VERSION < 0x00010000) //;;## ...AMI_OVERRIDE... Support PI1.x
+ EFI_FIRMWARE_VOLUME_PROTOCOL *Fv;
+#else
+ EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv;
+#endif
+ UINTN Index;
+ UINT32 AuthenticationStatus;
+
+ Status = gBS->LocateHandleBuffer (
+ ByProtocol,
+ #if (PI_SPECIFICATION_VERSION < 0x00010000) //;;## ...AMI_OVERRIDE... Support PI1.x
+ &gEfiFirmwareVolumeProtocolGuid,
+ #else
+ &gEfiFirmwareVolume2ProtocolGuid,
+ #endif
+ NULL,
+ &FvProtocolCount,
+ &FvHandles
+ );
+ if (EFI_ERROR (Status)) {
+ return EFI_NOT_FOUND;
+ }
+
+ for (Index = 0; Index < FvProtocolCount; Index++) {
+ Status = gBS->HandleProtocol (
+ FvHandles[Index],
+ #if (PI_SPECIFICATION_VERSION < 0x00010000) //;;## ...AMI_OVERRIDE... Support PI1.x
+ &gEfiFirmwareVolumeProtocolGuid,
+ #else
+ &gEfiFirmwareVolume2ProtocolGuid,
+ #endif
+ (VOID **) &Fv
+ );
+
+ //
+ // Assuming Image and ImageSize are correct on input.
+ //
+ Status = Fv->ReadSection (
+ Fv,
+ &gEfiDefaultBmpLogoGuid,
+ EFI_SECTION_RAW,
+ 0,
+ Image,
+ ImageSize,
+ &AuthenticationStatus
+ );
+ if (!EFI_ERROR (Status)) {
+ gBS->FreePool (FvHandles);
+ return EFI_SUCCESS;
+ } else if (Status == EFI_BUFFER_TOO_SMALL) {
+ //
+ // ImageSize updated to needed size so return
+ //
+ gBS->FreePool (FvHandles);
+ return EFI_BUFFER_TOO_SMALL;
+ }
+ }
+
+ gBS->FreePool (FvHandles);
+ return EFI_NOT_FOUND;
+}
+
+
+EFI_STATUS
+ConvertBmpToGopBlt (
+ IN VOID *BmpImage,
+ IN UINTN BmpImageSize,
+ IN OUT VOID **GopBlt,
+ IN OUT UINTN *GopBltSize,
+ OUT UINTN *PixelHeight,
+ OUT UINTN *PixelWidth
+ )
+/*++
+
+Routine Description:
+
+ Convert a *.BMP graphics image to a GOP/UGA blt buffer. If a NULL Blt buffer
+ is passed in a GopBlt buffer will be allocated by this routine. If a GopBlt
+ buffer is passed in it will be used if it is big enough.
+
+Arguments:
+
+ BmpImage - Pointer to BMP file
+
+ BmpImageSize - Number of bytes in BmpImage
+
+ GopBlt - Buffer containing GOP version of BmpImage.
+
+ GopBltSize - Size of GopBlt in bytes.
+
+ PixelHeight - Height of GopBlt/BmpImage in pixels
+
+ PixelWidth - Width of GopBlt/BmpImage in pixels
+
+
+Returns:
+
+ EFI_SUCCESS - GopBlt and GopBltSize are returned.
+ EFI_UNSUPPORTED - BmpImage is not a valid *.BMP image
+ EFI_BUFFER_TOO_SMALL - The passed in GopBlt buffer is not big enough.
+ GopBltSize will contain the required size.
+ EFI_OUT_OF_RESOURCES - No enough buffer to allocate
+
+--*/
+{
+ UINT8 *Image;
+ UINT8 *ImageHeader;
+ BMP_IMAGE_HEADER *BmpHeader;
+ BMP_COLOR_MAP *BmpColorMap;
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer;
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Blt;
+ UINT64 BltBufferSize;
+ UINTN Index;
+ UINTN Height;
+ UINTN Width;
+ UINTN ImageIndex;
+ BOOLEAN IsAllocated;
+
+ BmpHeader = (BMP_IMAGE_HEADER *) BmpImage;
+ if (BmpHeader->CharB != 'B' || BmpHeader->CharM != 'M') {
+ return EFI_UNSUPPORTED;
+ }
+
+ if (BmpHeader->CompressionType != 0) {
+ return EFI_UNSUPPORTED;
+ }
+
+ //
+ // Calculate Color Map offset in the image.
+ //
+ Image = BmpImage;
+ BmpColorMap = (BMP_COLOR_MAP *) (Image + sizeof (BMP_IMAGE_HEADER));
+
+ //
+ // Calculate graphics image data address in the image
+ //
+ Image = ((UINT8 *) BmpImage) + BmpHeader->ImageOffset;
+ ImageHeader = Image;
+
+ BltBufferSize = MultU64x32 ((UINT64) BmpHeader->PixelWidth, BmpHeader->PixelHeight);
+ //
+ // Ensure the BltBufferSize * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) doesn't overflow
+ //
+ if (BltBufferSize > DivU64x32 ((UINTN) ~0, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL), NULL)) {
+ return EFI_UNSUPPORTED;
+ }
+ BltBufferSize = MultU64x32 (BltBufferSize, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
+
+ IsAllocated = FALSE;
+ if (*GopBlt == NULL) {
+ *GopBltSize = (UINTN) BltBufferSize;
+ *GopBlt = EfiLibAllocatePool (*GopBltSize);
+ IsAllocated = TRUE;
+ if (*GopBlt == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ } else {
+ if (*GopBltSize < (UINTN) BltBufferSize) {
+ *GopBltSize = (UINTN) BltBufferSize;
+ return EFI_BUFFER_TOO_SMALL;
+ }
+ }
+
+ *PixelWidth = BmpHeader->PixelWidth;
+ *PixelHeight = BmpHeader->PixelHeight;
+
+ //
+ // Convert image from BMP to Blt buffer format
+ //
+ BltBuffer = *GopBlt;
+ for (Height = 0; Height < BmpHeader->PixelHeight; Height++) {
+ Blt = &BltBuffer[(BmpHeader->PixelHeight - Height - 1) * BmpHeader->PixelWidth];
+ for (Width = 0; Width < BmpHeader->PixelWidth; Width++, Image++, Blt++) {
+ switch (BmpHeader->BitPerPixel) {
+ case 1:
+ //
+ // Convert 1bit BMP to 24-bit color
+ //
+ for (Index = 0; Index < 8 && Width < BmpHeader->PixelWidth; Index++) {
+ Blt->Red = BmpColorMap[((*Image) >> (7 - Index)) & 0x1].Red;
+ Blt->Green = BmpColorMap[((*Image) >> (7 - Index)) & 0x1].Green;
+ Blt->Blue = BmpColorMap[((*Image) >> (7 - Index)) & 0x1].Blue;
+ Blt++;
+ Width++;
+ }
+
+ Blt --;
+ Width --;
+ break;
+
+ case 4:
+ //
+ // Convert BMP Palette to 24-bit color
+ //
+ Index = (*Image) >> 4;
+ Blt->Red = BmpColorMap[Index].Red;
+ Blt->Green = BmpColorMap[Index].Green;
+ Blt->Blue = BmpColorMap[Index].Blue;
+ if (Width < (BmpHeader->PixelWidth - 1)) {
+ Blt++;
+ Width++;
+ Index = (*Image) & 0x0f;
+ Blt->Red = BmpColorMap[Index].Red;
+ Blt->Green = BmpColorMap[Index].Green;
+ Blt->Blue = BmpColorMap[Index].Blue;
+ }
+ break;
+
+ case 8:
+ //
+ // Convert BMP Palette to 24-bit color
+ //
+ Blt->Red = BmpColorMap[*Image].Red;
+ Blt->Green = BmpColorMap[*Image].Green;
+ Blt->Blue = BmpColorMap[*Image].Blue;
+ break;
+
+ case 24:
+ Blt->Blue = *Image++;
+ Blt->Green = *Image++;
+ Blt->Red = *Image;
+ break;
+
+ default:
+ if (IsAllocated) {
+ gBS->FreePool (*GopBlt);
+ *GopBlt = NULL;
+ }
+ return EFI_UNSUPPORTED;
+ break;
+ };
+
+ }
+
+ ImageIndex = (UINTN) (Image - ImageHeader);
+ if ((ImageIndex % 4) != 0) {
+ //
+ // Bmp Image starts each row on a 32-bit boundary!
+ //
+ Image = Image + (4 - (ImageIndex % 4));
+ }
+ }
+
+ return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+LockKeyboards (
+ IN CHAR16 *Password
+ )
+/*++
+
+Routine Description:
+ Use Console Control Protocol to lock the Console In Spliter virtual handle.
+ This is the ConInHandle and ConIn handle in the EFI system table. All key
+ presses will be ignored until the Password is typed in. The only way to
+ disable the password is to type it in to a ConIn device.
+
+Arguments:
+ Password - Password used to lock ConIn device
+
+
+Returns:
+
+ EFI_SUCCESS - ConsoleControl has been flipped to graphics and logo
+ displayed.
+ EFI_UNSUPPORTED - Logo not found
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_CONSOLE_CONTROL_PROTOCOL *ConsoleControl;
+
+ Status = gBS->LocateProtocol (&gEfiConsoleControlProtocolGuid, NULL, &ConsoleControl);
+ if (EFI_ERROR (Status)) {
+ return EFI_UNSUPPORTED;
+ }
+
+ Status = ConsoleControl->LockStdIn (ConsoleControl, Password);
+ return Status;
+}
+
+
+EFI_STATUS
+EnableQuietBoot (
+ IN EFI_GUID *LogoFile
+ )
+/*++
+
+Routine Description:
+
+ Use Console Control to turn off GOP/UGA based Simple Text Out consoles from going
+ to the GOP/UGA device. Put up LogoFile on every GOP/UGA device that is a console
+
+Arguments:
+
+ LogoFile - File name of logo to display on the center of the screen.
+
+
+Returns:
+
+ EFI_SUCCESS - ConsoleControl has been flipped to graphics and logo
+ displayed.
+ EFI_UNSUPPORTED - Logo not found
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_CONSOLE_CONTROL_PROTOCOL *ConsoleControl;
+ EFI_OEM_BADGING_PROTOCOL *Badging;
+ UINT32 SizeOfX;
+ UINT32 SizeOfY;
+ INTN DestX;
+ INTN DestY;
+ UINT8 *ImageData;
+ UINTN ImageSize;
+ UINTN BltSize;
+ UINT32 Instance;
+ EFI_BADGING_FORMAT Format;
+ EFI_BADGING_DISPLAY_ATTRIBUTE Attribute;
+ UINTN CoordinateX;
+ UINTN CoordinateY;
+ UINTN Height;
+ UINTN Width;
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Blt;
+ EFI_UGA_DRAW_PROTOCOL *UgaDraw;
+ UINT32 ColorDepth;
+ UINT32 RefreshRate;
+ EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
+
+ Status = gBS->LocateProtocol (&gEfiConsoleControlProtocolGuid, NULL, &ConsoleControl);
+ if (EFI_ERROR (Status)) {
+ return EFI_UNSUPPORTED;
+ }
+
+ UgaDraw = NULL;
+ //
+ // Try to open GOP first
+ //
+ Status = gBS->HandleProtocol (gST->ConsoleOutHandle, &gEfiGraphicsOutputProtocolGuid, &GraphicsOutput);
+ if (EFI_ERROR (Status)) {
+ GraphicsOutput = NULL;
+ //
+ // Open GOP failed, try to open UGA
+ //
+ Status = gBS->HandleProtocol (gST->ConsoleOutHandle, &gEfiUgaDrawProtocolGuid, &UgaDraw);
+ if (EFI_ERROR (Status)) {
+ return EFI_UNSUPPORTED;
+ }
+ }
+
+ Badging = NULL;
+ Status = gBS->LocateProtocol (&gEfiOEMBadgingProtocolGuid, NULL, &Badging);
+
+ ConsoleControl->SetMode (ConsoleControl, EfiConsoleControlScreenGraphics);
+
+ if (GraphicsOutput != NULL) {
+ SizeOfX = GraphicsOutput->Mode->Info->HorizontalResolution;
+ SizeOfY = GraphicsOutput->Mode->Info->VerticalResolution;
+ } else {
+ if (UgaDraw) {
+ Status = UgaDraw->GetMode (UgaDraw, &SizeOfX, &SizeOfY, &ColorDepth, &RefreshRate);
+ if (EFI_ERROR (Status)) {
+ return EFI_UNSUPPORTED;
+ }
+ } else {
+ return EFI_UNSUPPORTED;
+ }
+ }
+
+ Instance = 0;
+ while (1) {
+ ImageData = NULL;
+ ImageSize = 0;
+
+ if (Badging != NULL) {
+ Status = Badging->GetImage (
+ Badging,
+ &Instance,
+ &Format,
+ &ImageData,
+ &ImageSize,
+ &Attribute,
+ &CoordinateX,
+ &CoordinateY
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ //
+ // Currently only support BMP format
+ //
+ if (Format != EfiBadgingFormatBMP) {
+ gBS->FreePool (ImageData);
+ continue;
+ }
+ } else {
+ Status = GetGraphicsBitMapFromFV (LogoFile, &ImageData, &ImageSize);
+ if (EFI_ERROR (Status)) {
+ return EFI_UNSUPPORTED;
+ }
+
+ CoordinateX = 0;
+ CoordinateY = 0;
+ Attribute = EfiBadgingDisplayAttributeCenter;
+ }
+
+ Blt = NULL;
+ Status = ConvertBmpToGopBlt (
+ ImageData,
+ ImageSize,
+ &Blt,
+ &BltSize,
+ &Height,
+ &Width
+ );
+ if (EFI_ERROR (Status)) {
+ gBS->FreePool (ImageData);
+ if (Badging == NULL) {
+ return Status;
+ } else {
+ continue;
+ }
+ }
+
+ switch (Attribute) {
+ case EfiBadgingDisplayAttributeLeftTop:
+ DestX = CoordinateX;
+ DestY = CoordinateY;
+ break;
+
+ case EfiBadgingDisplayAttributeCenterTop:
+ DestX = (SizeOfX - Width) / 2;
+ DestY = CoordinateY;
+ break;
+
+ case EfiBadgingDisplayAttributeRightTop:
+ DestX = (SizeOfX - Width - CoordinateX);
+ DestY = CoordinateY;;
+ break;
+
+ case EfiBadgingDisplayAttributeCenterRight:
+ DestX = (SizeOfX - Width - CoordinateX);
+ DestY = (SizeOfY - Height) / 2;
+ break;
+
+ case EfiBadgingDisplayAttributeRightBottom:
+ DestX = (SizeOfX - Width - CoordinateX);
+ DestY = (SizeOfY - Height - CoordinateY);
+ break;
+
+ case EfiBadgingDisplayAttributeCenterBottom:
+ DestX = (SizeOfX - Width) / 2;
+ DestY = (SizeOfY - Height - CoordinateY);
+ break;
+
+ case EfiBadgingDisplayAttributeLeftBottom:
+ DestX = CoordinateX;
+ DestY = (SizeOfY - Height - CoordinateY);
+ break;
+
+ case EfiBadgingDisplayAttributeCenterLeft:
+ DestX = CoordinateX;
+ DestY = (SizeOfY - Height) / 2;
+ break;
+
+ case EfiBadgingDisplayAttributeCenter:
+ DestX = (SizeOfX - Width) / 2;
+ DestY = (SizeOfY - Height) / 2;
+ break;
+
+ default:
+ DestX = CoordinateX;
+ DestY = CoordinateY;
+ break;
+ }
+
+ if ((DestX >= 0) && (DestY >= 0)) {
+ if (GraphicsOutput != NULL) {
+ Status = GraphicsOutput->Blt (
+ GraphicsOutput,
+ Blt,
+ EfiBltBufferToVideo,
+ 0,
+ 0,
+ (UINTN) DestX,
+ (UINTN) DestY,
+ Width,
+ Height,
+ Width * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)
+ );
+ } else {
+ Status = UgaDraw->Blt (
+ UgaDraw,
+ (EFI_UGA_PIXEL *) Blt,
+ EfiUgaBltBufferToVideo,
+ 0,
+ 0,
+ (UINTN) DestX,
+ (UINTN) DestY,
+ Width,
+ Height,
+ Width * sizeof (EFI_UGA_PIXEL)
+ );
+ }
+ }
+
+ gBS->FreePool (ImageData);
+ gBS->FreePool (Blt);
+
+ if (Badging == NULL) {
+ break;
+ }
+ }
+
+ return Status;
+}
+
+
+EFI_STATUS
+DisableQuietBoot (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Use Console Control to turn on GOP/UGA based Simple Text Out consoles. The GOP/UGA
+ Simple Text Out screens will now be synced up with all non GOP/UGA output devices
+
+Arguments:
+
+ NONE
+
+Returns:
+
+ EFI_SUCCESS - GOP/UGA devices are back in text mode and synced up.
+ EFI_UNSUPPORTED - Logo not found
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_CONSOLE_CONTROL_PROTOCOL *ConsoleControl;
+
+ Status = gBS->LocateProtocol (&gEfiConsoleControlProtocolGuid, NULL, &ConsoleControl);
+ if (EFI_ERROR (Status)) {
+ return EFI_UNSUPPORTED;
+ }
+
+ return ConsoleControl->SetMode (ConsoleControl, EfiConsoleControlScreenText);
+}
diff --git a/EDK/Foundation/Library/Dxe/GraphicsLite/Graphics.inf b/EDK/Foundation/Library/Dxe/GraphicsLite/Graphics.inf
new file mode 100644
index 0000000..f5d655a
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/GraphicsLite/Graphics.inf
@@ -0,0 +1,51 @@
+#/*++
+#
+# Copyright (c) 2004, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# Graphics.inf
+#
+# Abstract:
+#
+# Component description file.
+#
+#--*/
+
+[defines]
+BASE_NAME = GraphicsLite
+COMPONENT_TYPE = LIBRARY
+
+[sources.common]
+ Graphics.c
+ Print.c
+ Print.h
+ Unicode\PrintWidth.h
+ Unicode\Sprint.c
+
+
+[includes.common]
+ $(EDK_SOURCE)\Foundation\Framework
+ $(EDK_SOURCE)\Foundation
+ $(EDK_SOURCE)\Foundation\Efi
+ .
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Graphics\Unicode
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+
+[libraries.common]
+ EfiDriverLib
+
+[nmake.common]
+ C_STD_INCLUDE=
diff --git a/EDK/Foundation/Library/Dxe/GraphicsLite/GraphicsLite.cif b/EDK/Foundation/Library/Dxe/GraphicsLite/GraphicsLite.cif
new file mode 100644
index 0000000..955af56
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/GraphicsLite/GraphicsLite.cif
@@ -0,0 +1,18 @@
+<component>
+ name = "GraphicsLite"
+ category = ModulePart
+ LocalRoot = "EDK\Foundation\Library\Dxe\GraphicsLite\"
+ RefName = "GraphicsLite"
+[files]
+"GraphicsLite.sdl"
+"GraphicsLite.mak"
+"Graphics.c"
+"Print.c"
+"Print.h"
+"Graphics.inf"
+[parts]
+"GraphicsLiteAscii"
+"GraphicsLiteUnicode"
+"GraphicsLiteAscii"
+"GraphicsLiteUnicode"
+<endComponent>
diff --git a/EDK/Foundation/Library/Dxe/GraphicsLite/GraphicsLite.mak b/EDK/Foundation/Library/Dxe/GraphicsLite/GraphicsLite.mak
new file mode 100644
index 0000000..2003588
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/GraphicsLite/GraphicsLite.mak
@@ -0,0 +1,70 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/GraphicsLite/GraphicsLite.mak 1 1/20/12 4:08a Jeffch $
+#
+# $Revision: 1 $
+#
+# $Date: 1/20/12 4:08a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/GraphicsLite/GraphicsLite.mak $
+#
+# 1 1/20/12 4:08a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 9/27/11 6:31a Wesleychen
+# Intel EDK initially releases.
+#
+# 2 9/02/09 3:51a Iminglin
+# EIP24919
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: GraphicsLite.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+$(GRAPHICSLITE) : GraphicsLite
+
+$(BUILD_DIR)\GraphicsLite.lib : GraphicsLite
+
+GraphicsLite : $(BUILD_DIR)\GraphicsLite.mak GraphicsLiteBin
+
+$(BUILD_DIR)\GraphicsLite.mak : $(GraphicsLite_DIR)\$(@B).cif $(GraphicsLite_DIR)\$(@B).mak $(BUILD_RULES) $(GraphicsLite_DIR)\Unicode\GraphicsLiteUnicode.cif
+ $(CIF2MAK) $(GraphicsLite_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS) $(GraphicsLite_DIR)\Unicode\GraphicsLiteUnicode.cif
+
+GraphicsLiteBin : $(EFIDRIVERLIB)
+ $(MAKE) /$(MAKEFLAGS) $(EDK_DEFAULTS)\
+ /f $(BUILD_DIR)\GraphicsLite.mak all\
+ "MY_INCLUDES=/I$(GraphicsLite_DIR) /I$(GraphicsLite_DIR)\Unicode"\
+ TYPE=LIBRARY \
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#********************************************************************** \ No newline at end of file
diff --git a/EDK/Foundation/Library/Dxe/GraphicsLite/GraphicsLite.sdl b/EDK/Foundation/Library/Dxe/GraphicsLite/GraphicsLite.sdl
new file mode 100644
index 0000000..437059b
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/GraphicsLite/GraphicsLite.sdl
@@ -0,0 +1,26 @@
+TOKEN
+ Name = "GraphicsLite_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable GraphicsLite support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "GRAPHICSLITE"
+ Value = "$(BUILD_DIR)\GraphicsLite.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "GraphicsLite_DIR"
+End
+
+MODULE
+ Help = "Includes GraphicsLite.mak to Project"
+ File = "GraphicsLite.mak"
+End
+
diff --git a/EDK/Foundation/Library/Dxe/GraphicsLite/Print.c b/EDK/Foundation/Library/Dxe/GraphicsLite/Print.c
new file mode 100644
index 0000000..7aaa269
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/GraphicsLite/Print.c
@@ -0,0 +1,519 @@
+/*++
+
+Copyright (c) 2004 - 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Print.c
+
+Abstract:
+
+ Basic Ascii AvSPrintf() function named VSPrint(). VSPrint() enables very
+ simple implemenation of SPrint() and Print() to support debug.
+
+ You can not Print more than EFI_DRIVER_LIB_MAX_PRINT_BUFFER characters at a
+ time. This makes the implementation very simple.
+
+ VSPrint, Print, SPrint format specification has the follwoing form
+
+ %[flags][width]type
+
+ flags:
+ '-' - Left justify
+ '+' - Prefix a sign
+ ' ' - Prefix a blank
+ ',' - Place commas in numberss
+ '0' - Prefix for width with zeros
+ 'l' - UINT64
+ 'L' - UINT64
+
+ width:
+ '*' - Get width from a UINTN argumnet from the argument list
+ Decimal number that represents width of print
+
+ type:
+ 'X' - argument is a UINTN hex number, prefix '0'
+ 'x' - argument is a hex number
+ 'd' - argument is a decimal number
+ 'a' - argument is an ascii string
+ 'S','s' - argument is an Unicode string
+ 'g' - argument is a pointer to an EFI_GUID
+ 't' - argument is a pointer to an EFI_TIME structure
+ 'c' - argument is an ascii character
+ 'r' - argument is EFI_STATUS
+ '%' - Print a %
+
+--*/
+
+#include "Tiano.h"
+#include "EfiDriverLib.h"
+#include "TianoCommon.h"
+#include "EfiCommonLib.h"
+#include "PrintWidth.h"
+#include "EfiPrintLib.h"
+#include "Print.h"
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
+#include EFI_PROTOCOL_DEFINITION (HiiFont)
+#else
+#include EFI_PROTOCOL_DEFINITION (Hii)
+#endif
+
+static EFI_GRAPHICS_OUTPUT_BLT_PIXEL mEfiColors[16] = {
+ 0x00, 0x00, 0x00, 0x00,
+ 0x98, 0x00, 0x00, 0x00,
+ 0x00, 0x98, 0x00, 0x00,
+ 0x98, 0x98, 0x00, 0x00,
+ 0x00, 0x00, 0x98, 0x00,
+ 0x98, 0x00, 0x98, 0x00,
+ 0x00, 0x98, 0x98, 0x00,
+ 0x98, 0x98, 0x98, 0x00,
+ 0x10, 0x10, 0x10, 0x00,
+ 0xff, 0x10, 0x10, 0x00,
+ 0x10, 0xff, 0x10, 0x00,
+ 0xff, 0xff, 0x10, 0x00,
+ 0x10, 0x10, 0xff, 0x00,
+ 0xf0, 0x10, 0xff, 0x00,
+ 0x10, 0xff, 0xff, 0x00,
+ 0xff, 0xff, 0xff, 0x00,
+};
+
+
+UINTN
+_IPrint (
+ IN EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput,
+ IN EFI_UGA_DRAW_PROTOCOL *UgaDraw,
+ IN EFI_SIMPLE_TEXT_OUT_PROTOCOL *Sto,
+ IN UINTN X,
+ IN UINTN Y,
+ IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Foreground,
+ IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Background,
+ IN CHAR16 *fmt,
+ IN VA_LIST args
+ )
+/*++
+
+Routine Description:
+
+ Display string worker for: Print, PrintAt, IPrint, IPrintAt
+
+Arguments:
+
+ GraphicsOutput - Graphics output protocol interface
+
+ UgaDraw - UGA draw protocol interface
+
+ Sto - Simple text out protocol interface
+
+ X - X coordinate to start printing
+
+ Y - Y coordinate to start printing
+
+ Foreground - Foreground color
+
+ Background - Background color
+
+ fmt - Format string
+
+ args - Print arguments
+
+Returns:
+
+ EFI_SUCCESS - success
+ EFI_OUT_OF_RESOURCES - out of resources
+
+--*/
+{
+ VOID *Buffer;
+ EFI_STATUS Status;
+ UINTN Index;
+ CHAR16 *UnicodeWeight;
+ UINT32 HorizontalResolution;
+ UINT32 VerticalResolution;
+ UINT32 ColorDepth;
+ UINT32 RefreshRate;
+ UINTN BufferLen;
+ UINTN LineBufferLen;
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
+ EFI_HII_FONT_PROTOCOL *HiiFont;
+ EFI_IMAGE_OUTPUT *Blt;
+ EFI_FONT_DISPLAY_INFO *FontInfo;
+#else
+ EFI_HII_PROTOCOL *Hii;
+ UINT16 GlyphWidth;
+ UINT32 GlyphStatus;
+ UINT16 StringIndex;
+ EFI_NARROW_GLYPH *Glyph;
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL *LineBuffer;
+#endif
+
+ //
+ // For now, allocate an arbitrarily long buffer
+ //
+ Buffer = EfiLibAllocateZeroPool (0x10000);
+ if (Buffer == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ if (GraphicsOutput != NULL) {
+ HorizontalResolution = GraphicsOutput->Mode->Info->HorizontalResolution;
+ VerticalResolution = GraphicsOutput->Mode->Info->VerticalResolution;
+ } else {
+ UgaDraw->GetMode (UgaDraw, &HorizontalResolution, &VerticalResolution, &ColorDepth, &RefreshRate);
+ }
+ ASSERT ((HorizontalResolution != 0) && (VerticalResolution !=0));
+
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
+ Blt = NULL;
+ FontInfo = NULL;
+ ASSERT (GraphicsOutput != NULL);
+ Status = gBS->LocateProtocol (&gEfiHiiFontProtocolGuid, NULL, (VOID **) &HiiFont);
+ if (EFI_ERROR (Status)) {
+ goto Error;
+ }
+#else
+ LineBuffer = NULL;
+ Status = gBS->LocateProtocol (&gEfiHiiProtocolGuid, NULL, (VOID**)&Hii);
+ if (EFI_ERROR (Status)) {
+ goto Error;
+ }
+ LineBufferLen = sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) * HorizontalResolution * GLYPH_HEIGHT;
+ LineBuffer = EfiLibAllocatePool (LineBufferLen);
+ if (LineBuffer == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Error;
+ }
+#endif
+
+ VSPrint (Buffer, 0x10000, fmt, args);
+
+ UnicodeWeight = (CHAR16 *) Buffer;
+
+ for (Index = 0; UnicodeWeight[Index] != 0; Index++) {
+ if (UnicodeWeight[Index] == CHAR_BACKSPACE ||
+ UnicodeWeight[Index] == CHAR_LINEFEED ||
+ UnicodeWeight[Index] == CHAR_CARRIAGE_RETURN) {
+ UnicodeWeight[Index] = 0;
+ }
+ }
+
+ BufferLen = EfiStrLen (Buffer);
+
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
+ LineBufferLen = sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL) * HorizontalResolution * EFI_GLYPH_HEIGHT;
+ if (EFI_GLYPH_WIDTH * EFI_GLYPH_HEIGHT * sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL) * BufferLen > LineBufferLen) {
+ Status = EFI_INVALID_PARAMETER;
+ goto Error;
+ }
+
+ Blt = (EFI_IMAGE_OUTPUT *) EfiLibAllocateZeroPool (sizeof (EFI_IMAGE_OUTPUT));
+ if (Blt == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Error;
+ }
+
+ Blt->Width = (UINT16) (HorizontalResolution);
+ Blt->Height = (UINT16) (VerticalResolution);
+ Blt->Image.Screen = GraphicsOutput;
+
+ FontInfo = (EFI_FONT_DISPLAY_INFO *) EfiLibAllocateZeroPool (sizeof (EFI_FONT_DISPLAY_INFO));
+ if (FontInfo == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Error;
+ }
+ if (Foreground != NULL) {
+ EfiCopyMem (&FontInfo->ForegroundColor, Foreground, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
+ } else {
+ EfiCopyMem (
+ &FontInfo->ForegroundColor,
+ &mEfiColors[Sto->Mode->Attribute & 0x0f],
+ sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)
+ );
+ }
+ if (Background != NULL) {
+ EfiCopyMem (&FontInfo->BackgroundColor, Background, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL));
+ } else {
+ EfiCopyMem (
+ &FontInfo->BackgroundColor,
+ &mEfiColors[Sto->Mode->Attribute >> 4],
+ sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)
+ );
+ }
+
+ Status = HiiFont->StringToImage (
+ HiiFont,
+ EFI_HII_IGNORE_IF_NO_GLYPH | EFI_HII_DIRECT_TO_SCREEN,
+ Buffer,
+ FontInfo,
+ &Blt,
+ X,
+ Y,
+ NULL,
+ NULL,
+ NULL
+ );
+
+#else
+ GlyphStatus = 0;
+
+ if (GLYPH_WIDTH * GLYPH_HEIGHT * sizeof(EFI_GRAPHICS_OUTPUT_BLT_PIXEL) * BufferLen > LineBufferLen) {
+ Status = EFI_INVALID_PARAMETER;
+ goto Error;
+ }
+
+ for (Index = 0; Index < BufferLen; Index++) {
+ StringIndex = (UINT16) Index;
+ Status = Hii->GetGlyph (Hii, UnicodeWeight, &StringIndex, (UINT8 **) &Glyph, &GlyphWidth, &GlyphStatus);
+ if (EFI_ERROR (Status)) {
+ goto Error;
+ }
+
+ if (Foreground == NULL || Background == NULL) {
+ Status = Hii->GlyphToBlt (
+ Hii,
+ (UINT8 *) Glyph,
+ mEfiColors[Sto->Mode->Attribute & 0x0f],
+ mEfiColors[Sto->Mode->Attribute >> 4],
+ BufferLen,
+ GlyphWidth,
+ GLYPH_HEIGHT,
+ &LineBuffer[Index * GLYPH_WIDTH]
+ );
+ } else {
+ Status = Hii->GlyphToBlt (
+ Hii,
+ (UINT8 *) Glyph,
+ *Foreground,
+ *Background,
+ BufferLen,
+ GlyphWidth,
+ GLYPH_HEIGHT,
+ &LineBuffer[Index * GLYPH_WIDTH]
+ );
+ }
+ }
+
+ //
+ // Blt a character to the screen
+ //
+ if (GraphicsOutput != NULL) {
+ Status = GraphicsOutput->Blt (
+ GraphicsOutput,
+ LineBuffer,
+ EfiBltBufferToVideo,
+ 0,
+ 0,
+ X,
+ Y,
+ GLYPH_WIDTH * BufferLen,
+ GLYPH_HEIGHT,
+ GLYPH_WIDTH * BufferLen * sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)
+ );
+ } else {
+ Status = UgaDraw->Blt (
+ UgaDraw,
+ (EFI_UGA_PIXEL *) LineBuffer,
+ EfiUgaBltBufferToVideo,
+ 0,
+ 0,
+ X,
+ Y,
+ GLYPH_WIDTH * BufferLen,
+ GLYPH_HEIGHT,
+ GLYPH_WIDTH * BufferLen * sizeof (EFI_UGA_PIXEL)
+ );
+ }
+
+#endif
+
+Error:
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
+ EfiLibSafeFreePool (Blt);
+ EfiLibSafeFreePool (FontInfo);
+#else
+ gBS->FreePool (LineBuffer);
+#endif
+ gBS->FreePool (Buffer);
+ return Status;
+}
+
+
+UINTN
+PrintXY (
+ IN UINTN X,
+ IN UINTN Y,
+ IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *ForeGround, OPTIONAL
+ IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BackGround, OPTIONAL
+ IN CHAR_W *Fmt,
+ ...
+ )
+/*++
+
+Routine Description:
+
+ Prints a formatted unicode string to the default console
+
+Arguments:
+
+ X - X coordinate to start printing
+
+ Y - Y coordinate to start printing
+
+ ForeGround - Foreground color
+
+ BackGround - Background color
+
+ Fmt - Format string
+
+ ... - Print arguments
+
+Returns:
+
+ Length of string printed to the console
+
+--*/
+{
+ EFI_HANDLE Handle;
+ EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;
+ EFI_UGA_DRAW_PROTOCOL *UgaDraw;
+ EFI_SIMPLE_TEXT_OUT_PROTOCOL *Sto;
+ EFI_STATUS Status;
+ VA_LIST Args;
+
+ VA_START (Args, Fmt);
+
+ Handle = gST->ConsoleOutHandle;
+
+ Status = gBS->HandleProtocol (
+ Handle,
+ &gEfiGraphicsOutputProtocolGuid,
+ &GraphicsOutput
+ );
+
+ UgaDraw = NULL;
+ if (EFI_ERROR (Status)) {
+ GraphicsOutput = NULL;
+
+ Status = gBS->HandleProtocol (
+ Handle,
+ &gEfiUgaDrawProtocolGuid,
+ &UgaDraw
+ );
+
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ }
+
+ Status = gBS->HandleProtocol (
+ Handle,
+ &gEfiSimpleTextOutProtocolGuid,
+ &Sto
+ );
+
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ return _IPrint (GraphicsOutput, UgaDraw, Sto, X, Y, ForeGround, BackGround, Fmt, Args);
+}
+
+
+UINTN
+SPrint (
+ OUT CHAR_W *Buffer,
+ IN UINTN BufferSize,
+ IN CONST CHAR_W *Format,
+ ...
+ )
+/*++
+
+Routine Description:
+
+ SPrint function to process format and place the results in Buffer.
+
+Arguments:
+
+ Buffer - Wide char buffer to print the results of the parsing of Format into.
+
+ BufferSize - Maximum number of characters to put into buffer. Zero means no
+ limit.
+
+ Format - Format string see file header for more details.
+
+ ... - Vararg list consumed by processing Format.
+
+Returns:
+
+ Number of characters printed.
+
+--*/
+{
+ UINTN Return;
+ VA_LIST Marker;
+
+ VA_START (Marker, Format);
+ Return = VSPrint (Buffer, BufferSize, Format, Marker);
+ VA_END (Marker);
+
+ return Return;
+}
+
+UINTN
+EFIAPI
+VSPrint (
+ OUT CHAR_W *StartOfBuffer,
+ IN UINTN BufferSize,
+ IN CONST CHAR_W *FormatString,
+ IN VA_LIST Marker
+ )
+/*++
+
+Routine Description:
+
+ VSPrint function to process format and place the results in Buffer. Since a
+ VA_LIST is used this rountine allows the nesting of Vararg routines. Thus
+ this is the main print working routine
+
+Arguments:
+
+ StartOfBuffer - Unicode buffer to print the results of the parsing of Format into.
+
+ BufferSize - Maximum number of characters to put into buffer. Zero means
+ no limit.
+
+ FormatString - Unicode format string see file header for more details.
+
+ Marker - Vararg list consumed by processing Format.
+
+Returns:
+
+ Number of characters printed.
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_PRINT_PROTOCOL *PrintProtocol;
+
+ Status = gBS->LocateProtocol (
+ &gEfiPrintProtocolGuid,
+ NULL,
+ &PrintProtocol
+ );
+ if (EFI_ERROR (Status)) {
+ return 0;
+ } else {
+ return PrintProtocol->VSPrint (
+ StartOfBuffer,
+ BufferSize,
+ FormatString,
+ Marker
+ );
+ }
+}
diff --git a/EDK/Foundation/Library/Dxe/GraphicsLite/Print.h b/EDK/Foundation/Library/Dxe/GraphicsLite/Print.h
new file mode 100644
index 0000000..ad54aa8
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/GraphicsLite/Print.h
@@ -0,0 +1,37 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Print.h
+
+Abstract:
+
+ Private data for Print.c
+
+--*/
+
+#ifndef _PRINT_H_
+#define _PRINT_H_
+
+#define LEFT_JUSTIFY 0x01
+#define PREFIX_SIGN 0x02
+#define PREFIX_BLANK 0x04
+#define COMMA_TYPE 0x08
+#define LONG_TYPE 0x10
+#define PREFIX_ZERO 0x20
+
+//
+// Largest number of characters that can be printed out.
+//
+#define EFI_DRIVER_LIB_MAX_PRINT_BUFFER (80 * 4)
+
+#endif
diff --git a/EDK/Foundation/Library/Dxe/GraphicsLite/Unicode/GraphicsLiteUnicode.cif b/EDK/Foundation/Library/Dxe/GraphicsLite/Unicode/GraphicsLiteUnicode.cif
new file mode 100644
index 0000000..773911c
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/GraphicsLite/Unicode/GraphicsLiteUnicode.cif
@@ -0,0 +1,9 @@
+<component>
+ name = "GraphicsLiteUnicode"
+ category = ModulePart
+ LocalRoot = "EDK\Foundation\Library\Dxe\GraphicsLite\Unicode"
+ RefName = "GraphicsLiteUnicode"
+[files]
+"PrintWidth.h"
+"Sprint.c"
+<endComponent>
diff --git a/EDK/Foundation/Library/Dxe/GraphicsLite/Unicode/PrintWidth.h b/EDK/Foundation/Library/Dxe/GraphicsLite/Unicode/PrintWidth.h
new file mode 100644
index 0000000..fef9ea9
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/GraphicsLite/Unicode/PrintWidth.h
@@ -0,0 +1,35 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PrintWidth.h
+
+Abstract:
+
+ Unicde option for generic width.
+ CHAR_W is Unicode
+ STRING_W is L""
+
+--*/
+
+#ifndef _PRINT_WIDTH_H_
+#define _PRINT_WIDTH_H_
+
+typedef CHAR16 CHAR_W;
+#define STRING_W(_s) L##_s
+
+#define USPrint(Buffer, BufferSize, Format) SPrint (Buffer, BufferSize, Format)
+#define UvSPrint(Buffer, BufferSize, Format, Marker) VSPrint (Buffer, BufferSize, Format, Marker)
+
+#include "EfiCommonLib.h"
+
+#endif
diff --git a/EDK/Foundation/Library/Dxe/GraphicsLite/Unicode/Sprint.c b/EDK/Foundation/Library/Dxe/GraphicsLite/Unicode/Sprint.c
new file mode 100644
index 0000000..e3b8738
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/GraphicsLite/Unicode/Sprint.c
@@ -0,0 +1,147 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Sprint.c
+
+Abstract:
+
+ Basic Ascii AvSPrintf() function named VSPrint(). VSPrint() enables very
+ simple implemenation of SPrint() and Print() to support debug.
+
+ You can not Print more than EFI_DRIVER_LIB_MAX_PRINT_BUFFER characters at a
+ time. This makes the implementation very simple.
+
+ VSPrint, Print, SPrint format specification has the follwoing form
+
+ %[flags][width]type
+
+ flags:
+ '-' - Left justify
+ '+' - Prefix a sign
+ ' ' - Prefix a blank
+ ',' - Place commas in numberss
+ '0' - Prefix for width with zeros
+ 'l' - UINT64
+ 'L' - UINT64
+
+ width:
+ '*' - Get width from a UINTN argumnet from the argument list
+ Decimal number that represents width of print
+
+ type:
+ 'X' - argument is a UINTN hex number, prefix '0'
+ 'x' - argument is a hex number
+ 'd' - argument is a decimal number
+ 'a' - argument is an ascii string
+ 'S','s' - argument is an Unicode string
+ 'g' - argument is a pointer to an EFI_GUID
+ 't' - argument is a pointer to an EFI_TIME structure
+ 'c' - argument is an ascii character
+ 'r' - argument is EFI_STATUS
+ '%' - Print a %
+
+--*/
+
+#include "TianoCommon.h"
+#include "PrintWidth.h"
+#include "EfiPrintLib.h"
+#include "Print.h"
+
+
+UINTN
+ASPrint (
+ OUT CHAR8 *Buffer,
+ IN UINTN BufferSize,
+ IN CONST CHAR8 *Format,
+ ...
+ )
+/*++
+
+Routine Description:
+
+ Process format and place the results in Buffer for narrow chars.
+
+Arguments:
+
+ Buffer - Narrow char buffer to print the results of the parsing of Format into.
+ BufferSize - Maximum number of characters to put into buffer.
+ Format - Format string
+ ... - Vararg list consumed by processing Format.
+
+Returns:
+
+ Number of characters printed.
+
+--*/
+{
+ UINTN Return;
+ VA_LIST Marker;
+
+ VA_START (Marker, Format);
+ Return = AvSPrint (Buffer, BufferSize, Format, Marker);
+ VA_END (Marker);
+
+ return Return;
+}
+
+
+UINTN
+AvSPrint (
+ OUT CHAR8 *Buffer,
+ IN UINTN BufferSize,
+ IN CONST CHAR8 *FormatString,
+ IN VA_LIST Marker
+ )
+/*++
+
+Routine Description:
+
+ Internal implementation of ASPrint.
+ Process format and place the results in Buffer for narrow chars.
+
+Arguments:
+
+ Buffer - Narrow char buffer to print the results of the parsing of Format into.
+ BufferSize - Maximum number of characters to put into buffer.
+ FormatString - Format string
+ Marker - Vararg list consumed by processing Format.
+
+Returns:
+
+ Number of characters printed.
+
+--*/
+{
+ UINTN Index;
+ //
+ // Increase array size of 'UnicodeFormat' and 'UnicodeResult' by 1 as there is a possibility of buffer overflow.
+ //
+ CHAR16 UnicodeFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER+1];
+ CHAR16 UnicodeResult[EFI_DRIVER_LIB_MAX_PRINT_BUFFER+1];
+
+ for (Index = 0; Index < EFI_DRIVER_LIB_MAX_PRINT_BUFFER && FormatString[Index] != '\0'; Index++) {
+ UnicodeFormat[Index] = (CHAR16) FormatString[Index];
+ }
+
+ UnicodeFormat[Index] = '\0';
+
+ Index = VSPrint (UnicodeResult, sizeof (UnicodeResult)/sizeof (CHAR16), UnicodeFormat, Marker);
+
+ for (Index = 0; (Index < (BufferSize - 1)) && UnicodeResult[Index] != '\0'; Index++) {
+ Buffer[Index] = (CHAR8) UnicodeResult[Index];
+ }
+
+ Buffer[Index] = '\0';
+
+ return Index++;
+}
diff --git a/EDK/Foundation/Library/Dxe/Include/Ebc/ProcDep.h b/EDK/Foundation/Library/Dxe/Include/Ebc/ProcDep.h
new file mode 100644
index 0000000..7fd542b
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/Include/Ebc/ProcDep.h
@@ -0,0 +1,26 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ ProcDep.h
+
+Abstract:
+
+ EBC- specific runtime lib. Only used to get a clean build of
+ EFI libraries.
+
+--*/
+
+#ifndef _PROC_DEP_H_
+#define _PROC_DEP_H_
+
+#endif
diff --git a/EDK/Foundation/Library/Dxe/Include/EfiCombinationLib.h b/EDK/Foundation/Library/Dxe/Include/EfiCombinationLib.h
new file mode 100644
index 0000000..f091fdc
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/Include/EfiCombinationLib.h
@@ -0,0 +1,294 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiCombinationLib.h
+
+Abstract:
+
+ Library functions that can be called in both PEI and DXE phase
+
+--*/
+
+#ifndef _EFI_COMBINATION_LIB_H_
+#define _EFI_COMBINATION_LIB_H_
+
+EFI_STATUS
+EfiInitializeCommonDriverLib (
+ IN EFI_HANDLE ImageHandle,
+ IN VOID *SystemTable
+ )
+/*++
+
+Routine Description:
+
+ Initialize lib function calling phase: PEI or DXE
+
+Arguments:
+
+ ImageHandle - The firmware allocated handle for the EFI image.
+
+ SystemTable - A pointer to the EFI System Table.
+
+Returns:
+
+ EFI_STATUS always returns EFI_SUCCESS
+
+--*/
+;
+
+EFI_STATUS
+EfiCommonIoRead (
+ IN UINT8 Width,
+ IN UINTN Address,
+ IN UINTN Count,
+ IN OUT VOID *Buffer
+ )
+/*++
+
+Routine Description:
+
+ Io read operation.
+
+Arguments:
+
+ Width - Width of read operation
+ Address - Start IO address to read
+ Count - Read count
+ Buffer - Buffer to store result
+
+Returns:
+
+ Status code
+
+--*/
+;
+
+EFI_STATUS
+EfiCommonIoWrite (
+ IN UINT8 Width,
+ IN UINTN Address,
+ IN UINTN Count,
+ IN OUT VOID *Buffer
+ )
+/*++
+
+Routine Description:
+
+ Io write operation.
+
+Arguments:
+
+ Width - Width of write operation
+ Address - Start IO address to write
+ Count - Write count
+ Buffer - Buffer to write to the address
+
+Returns:
+
+ Status code
+
+--*/
+;
+
+EFI_STATUS
+EfiCommonPciRead (
+ IN UINT8 Width,
+ IN UINT64 Address,
+ IN UINTN Count,
+ IN OUT VOID *Buffer
+ )
+/*++
+
+Routine Description:
+
+ Pci read operation
+
+Arguments:
+
+ Width - Width of PCI read
+ Address - PCI address to read
+ Count - Read count
+ Buffer - Output buffer for the read
+
+Returns:
+
+ Status code
+
+--*/
+;
+
+EFI_STATUS
+EfiCommonPciWrite (
+ IN UINT8 Width,
+ IN UINT64 Address,
+ IN UINTN Count,
+ IN OUT VOID *Buffer
+ )
+/*++
+
+Routine Description:
+
+ Pci write operation
+
+Arguments:
+
+ Width - Width of PCI write
+ Address - PCI address to write
+ Count - Write count
+ Buffer - Buffer to write to the address
+
+Returns:
+
+ Status code
+
+--*/
+;
+
+EFI_STATUS
+EfiCommonStall (
+ IN UINTN Microseconds
+ )
+/*++
+
+Routine Description:
+
+ Induces a fine-grained stall.
+
+Arguments:
+
+ Microseconds - The number of microseconds to stall execution.
+
+Returns:
+
+ Status code
+
+--*/
+;
+
+EFI_STATUS
+EfiCommonCopyMem (
+ IN VOID *Destination,
+ IN VOID *Source,
+ IN UINTN Length
+ )
+/*++
+
+Routine Description:
+
+ Copy Length bytes from Source to Destination.
+
+Arguments:
+
+ Destination - Target of copy
+
+ Source - Place to copy from
+
+ Length - Number of bytes to copy
+
+Returns:
+
+ Status code
+
+--*/
+;
+
+EFI_STATUS
+EfiCommonAllocatePages (
+ IN EFI_ALLOCATE_TYPE Type,
+ IN EFI_MEMORY_TYPE MemoryType,
+ IN UINTN Pages,
+ IN OUT EFI_PHYSICAL_ADDRESS *Memory
+ )
+/*++
+
+Routine Description:
+
+ Allocates memory pages from the system.
+
+Arguments:
+
+ Type - The type of allocation to perform.
+ MemoryType - The type of memory to allocate.
+ Pages - The number of contiguous pages to allocate.
+ Memory - Pointer to a physical address.
+
+Returns:
+
+ EFI_OUT_OF_RESOURCES - The pages could not be allocated.
+
+ EFI_INVALID_PARAMETER - Invalid parameter
+
+ EFI_NOT_FOUND - The requested pages could not be found.
+
+ EFI_SUCCESS - The requested pages were allocated.
+
+--*/
+;
+
+EFI_STATUS
+EfiCommonLocateInterface (
+ IN EFI_GUID *Guid,
+ OUT VOID **Interface
+ )
+/*++
+
+Routine Description:
+
+ Returns the first protocol instance that matches the given protocol.
+
+Arguments:
+
+ Guid - Provides the protocol to search for.
+ Interface - On return, a pointer to the first interface that matches Protocol
+
+Returns:
+
+ Status code
+
+--*/
+;
+
+EFI_STATUS
+EfiCommonReportStatusCode (
+ IN EFI_STATUS_CODE_TYPE CodeType,
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN UINT32 Instance,
+ IN EFI_GUID * CallerId,
+ IN EFI_STATUS_CODE_DATA * Data OPTIONAL
+ )
+/*++
+
+Routine Description:
+
+ Status Code reporter
+
+Arguments:
+
+ CodeType - Type of Status Code.
+
+ Value - Value to output for Status Code.
+
+ Instance - Instance Number of this status code.
+
+ CallerId - ID of the caller of this status code.
+
+ Data - Optional data associated with this status code.
+
+Returns:
+
+ Status code
+
+--*/
+;
+
+#endif
diff --git a/EDK/Foundation/Library/Dxe/Include/EfiCommonLib.h b/EDK/Foundation/Library/Dxe/Include/EfiCommonLib.h
new file mode 100644
index 0000000..d499d2b
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/Include/EfiCommonLib.h
@@ -0,0 +1,1359 @@
+/*++
+
+Copyright (c) 2004 - 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiCommonLib.h
+
+Abstract:
+
+ Light weight lib to support EFI drivers.
+
+--*/
+
+#ifndef _EFI_COMMON_LIB_H_
+#define _EFI_COMMON_LIB_H_
+
+EFI_STATUS
+EfiLibGetSystemConfigurationTable (
+ IN EFI_GUID *TableGuid,
+ IN OUT VOID **Table
+ )
+/*++
+
+Routine Description:
+
+ Return the EFI 1.0 System Tabl entry with TableGuid
+
+Arguments:
+
+ TableGuid - Name of entry to return in the system table
+ Table - Pointer in EFI system table associated with TableGuid
+
+Returns:
+
+ EFI_SUCCESS - Table returned;
+ EFI_NOT_FOUND - TableGuid not in EFI system table
+
+--*/
+;
+
+//
+// ASPrint and AvSPrint definitions you must include the specific library
+// to get the expected behavior from the two functions
+// PEI: PeiLib
+// Graphics: Dxe\Graphics\Unicode Dxe\Graphics\ASCII
+// ASCII: Dxe\Print\ASCII
+// Unicode: Dxe\Print\Unicode
+//
+UINTN
+ASPrint (
+ OUT CHAR8 *Buffer,
+ IN UINTN BufferSize,
+ IN CONST CHAR8 *Format,
+ ...
+ )
+/*++
+
+Routine Description:
+
+ Process format and place the results in Buffer for narrow chars.
+
+Arguments:
+
+ Buffer - Narrow char buffer to print the results of the parsing of Format into.
+ BufferSize - Maximum number of characters to put into buffer.
+ Format - Format string
+ ... - Vararg list consumed by processing Format.
+
+Returns:
+
+ Number of characters printed.
+
+--*/
+;
+
+UINTN
+AvSPrint (
+ OUT CHAR8 *StartOfBuffer,
+ IN UINTN StrSize,
+ IN CONST CHAR8 *Format,
+ IN VA_LIST Marker
+ )
+/*++
+
+Routine Description:
+
+ Internal implementation of ASPrint.
+ Process format and place the results in Buffer for narrow chars.
+
+Arguments:
+
+ StartOfBuffer - Narrow char buffer to print the results of the parsing of Format into.
+ StrSize - Maximum number of characters to put into buffer.
+ FormatString - Format string
+ Marker - Vararg list consumed by processing Format.
+
+Returns:
+
+ Number of characters printed.
+
+--*/
+;
+
+//
+// Lib functions which can be used in both PEI and DXE pahse
+//
+EFI_STATUS
+EfiInitializeCommonDriverLib (
+ IN EFI_HANDLE ImageHandle,
+ IN VOID *SystemTable
+ )
+/*++
+
+Routine Description:
+
+ Initialize lib function calling phase: PEI or DXE
+
+Arguments:
+
+ ImageHandle - The firmware allocated handle for the EFI image.
+
+ SystemTable - A pointer to the EFI System Table.
+
+Returns:
+
+ EFI_STATUS always returns EFI_SUCCESS
+
+--*/
+;
+
+EFI_STATUS
+EfiCommonIoRead (
+ IN UINT8 Width,
+ IN UINTN Address,
+ IN UINTN Count,
+ IN OUT VOID *Buffer
+ )
+/*++
+
+Routine Description:
+
+ Io read operation.
+
+Arguments:
+
+ Width - Width of read operation
+ Address - Start IO address to read
+ Count - Read count
+ Buffer - Buffer to store result
+
+Returns:
+
+ Status code
+
+--*/
+;
+
+EFI_STATUS
+EfiCommonIoWrite (
+ IN UINT8 Width,
+ IN UINTN Address,
+ IN UINTN Count,
+ IN OUT VOID *Buffer
+ )
+/*++
+
+Routine Description:
+
+ Io write operation.
+
+Arguments:
+
+ Width - Width of write operation
+ Address - Start IO address to write
+ Count - Write count
+ Buffer - Buffer to write to the address
+
+Returns:
+
+ Status code
+
+--*/
+;
+
+EFI_STATUS
+EfiCommonPciRead (
+ IN UINT8 Width,
+ IN UINT64 Address,
+ IN UINTN Count,
+ IN OUT VOID *Buffer
+ )
+/*++
+
+Routine Description:
+
+ Pci read operation
+
+Arguments:
+
+ Width - Width of PCI read
+ Address - PCI address to read
+ Count - Read count
+ Buffer - Output buffer for the read
+
+Returns:
+
+ Status code
+
+--*/
+;
+
+EFI_STATUS
+EfiCommonPciWrite (
+ IN UINT8 Width,
+ IN UINT64 Address,
+ IN UINTN Count,
+ IN OUT VOID *Buffer
+ )
+/*++
+
+Routine Description:
+
+ Pci write operation
+
+Arguments:
+
+ Width - Width of PCI write
+ Address - PCI address to write
+ Count - Write count
+ Buffer - Buffer to write to the address
+
+Returns:
+
+ Status code
+
+--*/
+;
+
+BOOLEAN
+EfiCompareGuid (
+ IN EFI_GUID *Guid1,
+ IN EFI_GUID *Guid2
+ )
+/*++
+
+Routine Description:
+
+ Compares two GUIDs
+
+Arguments:
+
+ Guid1 - guid to compare
+
+ Guid2 - guid to compare
+
+Returns:
+ TRUE if Guid1 == Guid2
+ FALSE if Guid1 != Guid2
+
+--*/
+;
+
+VOID
+EfiCommonLibSetMem (
+ IN VOID *Buffer,
+ IN UINTN Size,
+ IN UINT8 Value
+ )
+/*++
+
+Routine Description:
+
+ Set Buffer to Value for Size bytes.
+
+Arguments:
+
+ Buffer - Memory to set.
+
+ Size - Number of bytes to set
+
+ Value - Value of the set operation.
+
+Returns:
+
+ None
+
+--*/
+;
+
+VOID
+EfiCommonLibCopyMem (
+ IN VOID *Destination,
+ IN VOID *Source,
+ IN UINTN Length
+ )
+/*++
+
+Routine Description:
+
+ Copy Length bytes from Source to Destination.
+
+Arguments:
+
+ Destination - Target of copy
+
+ Source - Place to copy from
+
+ Length - Number of bytes to copy
+
+Returns:
+
+ None
+
+--*/
+;
+
+INTN
+EfiCompareMem (
+ IN VOID *MemOne,
+ IN VOID *MemTwo,
+ IN UINTN Len
+ )
+/*++
+
+Routine Description:
+
+ Compares two memory buffers of a given length.
+
+Arguments:
+
+ MemOne - First memory buffer
+
+ MemTwo - Second memory buffer
+
+ Len - Length of Mem1 and Mem2 memory regions to compare
+
+Returns:
+
+ = 0 if MemOne == MemTwo
+
+ > 0 if MemOne > MemTwo
+
+ < 0 if MemOne < MemTwo
+
+--*/
+;
+
+VOID
+EfiCommonLibZeroMem (
+ IN VOID *Buffer,
+ IN UINTN Size
+ )
+/*++
+
+Routine Description:
+
+ Set Buffer to 0 for Size bytes.
+
+Arguments:
+
+ Buffer - Memory to set.
+
+ Size - Number of bytes to set
+
+Returns:
+
+ None
+
+--*/
+;
+
+//
+// Min Max
+//
+#define EFI_MIN(a, b) (((a) < (b)) ? (a) : (b))
+#define EFI_MAX(a, b) (((a) > (b)) ? (a) : (b))
+
+//
+// Align a pointer. The pointer represented by ptr is aligned to the bound.
+// The resulting pointer is always equal or greater (by no more than bound-1)
+// than the ptr. I.e., if the ptr is already aligned, the result will be equal to ptr.
+// Valid values for bound are powers of two: 2, 4, 8, 16, 32 etc.
+// The returned pointer is VOID* this assignment-compatible with all pointer types.
+//
+#define EFI_ALIGN(ptr, bound) ((VOID *) (((UINTN) (ptr) + ((UINTN) (bound) - 1)) &~((UINTN) (bound) - 1)))
+
+//
+// Alignment tests.
+//
+#define EFI_UINTN_ALIGN_MASK (sizeof (UINTN) - 1)
+#define EFI_UINTN_ALIGNED(ptr) (((UINTN) (ptr)) & EFI_UINTN_ALIGN_MASK)
+
+//
+// Integer division with rounding to the nearest rather than truncating.
+// For example 8/3=2 but EFI_IDIV_ROUND(8,3)=3. 1/3=0 and EFI_IDIV_ROUND(1,3)=0.
+// A half is rounded up e.g., EFI_IDIV_ROUND(1,2)=1 but 1/2=0.
+//
+#define EFI_IDIV_ROUND(r, s) ((r) / (s) + (((2 * ((r) % (s))) < (s)) ? 0 : 1))
+
+//
+// ReportStatusCode.c init
+//
+VOID *
+EfiConstructStatusCodeData (
+ IN UINT16 DataSize,
+ IN EFI_GUID *TypeGuid,
+ IN OUT EFI_STATUS_CODE_DATA *Data
+ )
+/*++
+
+Routine Description:
+
+ Construct stanader header for optional data passed into ReportStatusCode
+
+Arguments:
+
+ DataSize - Size of optional data. Does not include EFI_STATUS_CODE_DATA header
+ TypeGuid - GUID to place in EFI_STATUS_CODE_DATA
+ Data - Buffer to use.
+
+Returns:
+
+ Return pointer to Data buffer pointing past the end of EFI_STATUS_CODE_DATA
+
+--*/
+;
+
+EFI_STATUS
+EfiDebugVPrintWorker (
+ IN UINTN ErrorLevel,
+ IN CHAR8 *Format,
+ IN VA_LIST Marker,
+ IN UINTN BufferSize,
+ IN OUT VOID *Buffer
+ )
+/*++
+
+Routine Description:
+
+ Worker function for DEBUG(). If Error Logging hub is loaded log ASSERT
+ information. If Error Logging hub is not loaded do nothing.
+
+ We use UINT64 buffers due to IPF alignment concerns.
+
+Arguments:
+
+ ErrorLevel - If error level is set do the debug print.
+
+ Format - String to use for the print, followed by Print arguments.
+
+ Marker - VarArgs
+
+ BufferSize - Size of Buffer.
+
+ Buffer - Caller allocated buffer, contains ReportStatusCode extended data
+
+Returns:
+
+ Status code
+
+--*/
+;
+
+EFI_STATUS
+EfiDebugAssertWorker (
+ IN CHAR8 *FileName,
+ IN INTN LineNumber,
+ IN CHAR8 *Description,
+ IN UINTN BufferSize,
+ IN OUT VOID *Buffer
+ )
+/*++
+
+Routine Description:
+
+ Worker function for ASSERT (). If Error Logging hub is loaded log ASSERT
+ information. If Error Logging hub is not loaded DEADLOOP ().
+
+ We use UINT64 buffers due to IPF alignment concerns.
+
+Arguments:
+
+ FileName - File name of failing routine.
+
+ LineNumber - Line number of failing ASSERT().
+
+ Description - Description, usually the assertion,
+
+ BufferSize - Size of Buffer.
+
+ Buffer - Caller allocated buffer, contains ReportStatusCode extendecd data
+
+Returns:
+
+ Status code
+
+--*/
+;
+
+BOOLEAN
+ReportStatusCodeExtractAssertInfo (
+ IN EFI_STATUS_CODE_TYPE CodeType,
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN EFI_STATUS_CODE_DATA *Data,
+ OUT CHAR8 **Filename,
+ OUT CHAR8 **Description,
+ OUT UINT32 *LineNumber
+ )
+/*++
+
+Routine Description:
+
+ Extract assert information from status code data.
+
+Arguments:
+
+ CodeType - Code type
+ Value - Code value
+ Data - Optional data associated with this status code.
+ Filename - Filename extracted from Data
+ Description - Description extracted from Data
+ LineNumber - Line number extracted from Data
+
+Returns:
+
+ TRUE - Successfully extracted
+
+ FALSE - Extraction failed
+
+--*/
+;
+
+BOOLEAN
+ReportStatusCodeExtractDebugInfo (
+ IN EFI_STATUS_CODE_DATA *Data,
+ OUT UINT32 *ErrorLevel,
+ OUT VA_LIST *Marker,
+ OUT CHAR8 **Format
+ )
+/*++
+
+Routine Description:
+
+ Extract debug information from status code data.
+
+Arguments:
+
+ Data - Optional data associated with status code.
+ ErrorLevel - Error level extracted from Data
+ Marker - VA_LIST extracted from Data
+ Format - Format string extracted from Data
+
+Returns:
+
+ TRUE - Successfully extracted
+
+ FALSE - Extraction failed
+
+--*/
+;
+
+BOOLEAN
+CodeTypeToPostCode (
+ IN EFI_STATUS_CODE_TYPE CodeType,
+ IN EFI_STATUS_CODE_VALUE Value,
+ OUT UINT8 *PostCode
+ )
+/*++
+
+Routine Description:
+
+ Convert code value to an 8 bit post code
+
+Arguments:
+
+ CodeType - Code type
+ Value - Code value
+ PostCode - Post code as output
+
+Returns:
+
+ TRUE - Successfully converted
+
+ FALSE - Convertion failed
+
+--*/
+;
+
+//
+// math.c
+//
+UINT64
+MultU64x32 (
+ IN UINT64 Multiplicand,
+ IN UINTN Multiplier
+ )
+/*++
+
+Routine Description:
+
+ This routine allows a 64 bit value to be multiplied with a 32 bit
+ value returns 64bit result.
+ No checking if the result is greater than 64bits
+
+Arguments:
+
+ Multiplicand - multiplicand
+ Multiplier - multiplier
+
+Returns:
+
+ Multiplicand * Multiplier
+
+--*/
+;
+
+UINT64
+DivU64x32 (
+ IN UINT64 Dividend,
+ IN UINTN Divisor,
+ OUT UINTN *Remainder OPTIONAL
+ )
+/*++
+
+Routine Description:
+
+ This routine allows a 64 bit value to be divided with a 32 bit value returns
+ 64bit result and the Remainder.
+
+Arguments:
+
+ Dividend - dividend
+ Divisor - divisor
+ Remainder - buffer for remainder
+
+Returns:
+
+ Dividend / Divisor
+ Remainder = Dividend mod Divisor
+
+--*/
+;
+
+UINT64
+RShiftU64 (
+ IN UINT64 Operand,
+ IN UINTN Count
+ )
+/*++
+
+Routine Description:
+
+ This routine allows a 64 bit value to be right shifted by 32 bits and returns the
+ shifted value.
+ Count is valid up 63. (Only Bits 0-5 is valid for Count)
+
+Arguments:
+
+ Operand - Value to be shifted
+ Count - Number of times to shift right.
+
+Returns:
+
+ Value shifted right identified by the Count.
+
+--*/
+;
+
+UINT64
+LShiftU64 (
+ IN UINT64 Operand,
+ IN UINTN Count
+ )
+/*++
+
+Routine Description:
+
+ This routine allows a 64 bit value to be left shifted by 32 bits and
+ returns the shifted value.
+ Count is valid up 63. (Only Bits 0-5 is valid for Count)
+
+Arguments:
+
+ Operand - Value to be shifted
+ Count - Number of times to shift left.
+
+Returns:
+
+ Value shifted left identified by the Count.
+
+--*/
+;
+
+UINT64
+Power10U64 (
+ IN UINT64 Operand,
+ IN UINTN Power
+ )
+/*++
+
+Routine Description:
+
+ Raise 10 to the power of Power, and multiply the result with Operand
+
+Arguments:
+
+ Operand - multiplicand
+ Power - power
+
+Returns:
+
+ Operand * 10 ^ Power
+
+--*/
+;
+
+UINT8
+Log2 (
+ IN UINT64 Operand
+ )
+/*++
+
+Routine Description:
+
+ Calculates and floors logarithms based on 2
+
+Arguments:
+
+ Operand - value to calculate logarithm
+
+Returns:
+
+ The largest integer that is less than or equal
+ to the logarithm of Operand based on 2
+
+--*/
+;
+
+UINT64
+GetPowerOfTwo (
+ IN UINT64 Input
+ )
+/*++
+
+Routine Description:
+
+ Calculates the largest integer that is both
+ a power of two and less than Input
+
+Arguments:
+
+ Input - value to calculate power of two
+
+Returns:
+
+ the largest integer that is both a power of
+ two and less than Input
+
+--*/
+;
+
+//
+// Unicode String primatives
+//
+VOID
+EfiStrCpy (
+ IN CHAR16 *Destination,
+ IN CHAR16 *Source
+ )
+/*++
+
+Routine Description:
+ Copy the Unicode string Source to Destination.
+
+Arguments:
+ Destination - Location to copy string
+ Source - String to copy
+
+Returns:
+ NONE
+
+--*/
+;
+
+VOID
+EfiStrnCpy (
+ OUT CHAR16 *Dst,
+ IN CHAR16 *Src,
+ IN UINTN Length
+ )
+/*++
+
+Routine Description:
+ Copy a string from source to destination
+
+Arguments:
+ Dst Destination string
+ Src Source string
+ Length Length of destination string
+
+Returns:
+
+--*/
+;
+
+UINTN
+EfiStrLen (
+ IN CHAR16 *String
+ )
+/*++
+
+Routine Description:
+ Return the number of Unicode characters in String. This is not the same as
+ the length of the string in bytes.
+
+Arguments:
+ String - String to process
+
+Returns:
+ Number of Unicode characters in String
+
+--*/
+;
+
+UINTN
+EfiStrSize (
+ IN CHAR16 *String
+ )
+/*++
+
+Routine Description:
+ Return the number bytes in the Unicode String. This is not the same as
+ the length of the string in characters. The string size includes the NULL
+
+Arguments:
+ String - String to process
+
+Returns:
+ Number of bytes in String
+
+--*/
+;
+
+INTN
+EfiStrCmp (
+ IN CHAR16 *String,
+ IN CHAR16 *String2
+ )
+/*++
+
+Routine Description:
+ Return the alphabetic relationship between two stirngs.
+
+Arguments:
+ String - Compare to String2
+
+ String2 - Compare to String
+
+Returns:
+ 0 - Identical
+
+ > 0 - String is alphabeticly greater than String2
+
+ < 0 - String is alphabeticly less than String2
+
+--*/
+;
+
+INTN
+EfiStrnCmp (
+ IN CHAR16 *String,
+ IN CHAR16 *String2,
+ IN UINTN Length
+ )
+/*++
+
+Routine Description:
+ This function compares the Unicode string String to the Unicode
+ string String2 for len characters. If the first len characters
+ of String is identical to the first len characters of String2,
+ then 0 is returned. If substring of String sorts lexicographically
+ after String2, the function returns a number greater than 0. If
+ substring of String sorts lexicographically before String2, the
+ function returns a number less than 0.
+
+Arguments:
+ String - Compare to String2
+ String2 - Compare to String
+ Length - Number of Unicode characters to compare
+
+Returns:
+ 0 - The substring of String and String2 is identical.
+ > 0 - The substring of String sorts lexicographically after String2
+ < 0 - The substring of String sorts lexicographically before String2
+
+--*/
+;
+
+VOID
+EfiStrCat (
+ IN CHAR16 *Destination,
+ IN CHAR16 *Source
+ )
+/*++
+
+Routine Description:
+ Concatinate Source on the end of Destination
+
+Arguments:
+ Destination - String to added to the end of.
+ Source - String to concatinate.
+
+Returns:
+ NONE
+
+--*/
+;
+
+VOID
+EfiStrnCat (
+ IN CHAR16 *Dest,
+ IN CHAR16 *Src,
+ IN UINTN Length
+ )
+/*++
+
+Routine Description:
+ Concatinate Source on the end of Destination
+
+Arguments:
+ Dst Destination string
+ Src Source string
+ Length Length of destination string
+
+Returns:
+
+--*/
+;
+
+UINTN
+EfiAsciiStrLen (
+ IN CHAR8 *String
+ )
+/*++
+
+Routine Description:
+ Return the number of Ascii characters in String. This is not the same as
+ the length of the string in bytes.
+
+Arguments:
+ String - String to process
+
+Returns:
+ Number of Unicode characters in String
+
+--*/
+;
+
+CHAR8 *
+EfiAsciiStrCpy (
+ IN CHAR8 *Destination,
+ IN CHAR8 *Source
+ )
+/*++
+
+Routine Description:
+ Copy the Ascii string Source to Destination.
+
+Arguments:
+ Destination - Location to copy string
+ Source - String to copy
+
+Returns:
+ Pointer just pass the end of Destination
+
+--*/
+;
+
+VOID
+EfiAsciiStrnCpy (
+ OUT CHAR8 *Dst,
+ IN CHAR8 *Src,
+ IN UINTN Length
+ )
+/*++
+
+Routine Description:
+ Copy the Ascii string from source to destination
+
+Arguments:
+ Dst Destination string
+ Src Source string
+ Length Length of destination string
+
+Returns:
+
+--*/
+;
+
+UINTN
+EfiAsciiStrSize (
+ IN CHAR8 *String
+ )
+/*++
+
+Routine Description:
+ Return the number bytes in the Ascii String. This is not the same as
+ the length of the string in characters. The string size includes the NULL
+
+Arguments:
+ String - String to process
+
+Returns:
+ Number of bytes in String
+
+--*/
+;
+
+
+INTN
+EfiAsciiStrCmp (
+ IN CHAR8 *String,
+ IN CHAR8 *String2
+ )
+/*++
+
+Routine Description:
+ Compare the Ascii string pointed by String to the string pointed by String2.
+
+Arguments:
+ String - String to process
+
+ String2 - The other string to process
+
+Returns:
+ Return a positive integer if String is lexicall greater than String2; Zero if
+ the two strings are identical; and a negative interger if String is lexically
+ less than String2.
+--*/
+;
+
+INTN
+EfiAsciiStrnCmp (
+ IN CHAR8 *String,
+ IN CHAR8 *String2,
+ IN UINTN Length
+ )
+/*++
+
+Routine Description:
+ This function compares the ASCII string String to the ASCII
+ string String2 for len characters. If the first len characters
+ of String is identical to the first len characters of String2,
+ then 0 is returned. If substring of String sorts lexicographically
+ after String2, the function returns a number greater than 0. If
+ substring of String sorts lexicographically before String2, the
+ function returns a number less than 0.
+
+Arguments:
+ String - Compare to String2
+ String2 - Compare to String
+ Length - Number of ASCII characters to compare
+
+Returns:
+ 0 - The substring of String and String2 is identical.
+ > 0 - The substring of String sorts lexicographically after String2
+ < 0 - The substring of String sorts lexicographically before String2
+
+--*/
+;
+
+VOID
+EfiAsciiStrCat (
+ IN CHAR8 *Destination,
+ IN CHAR8 *Source
+ )
+/*++
+
+Routine Description:
+ Concatinate Source on the end of Destination
+
+Arguments:
+ Destination - String to added to the end of.
+ Source - String to concatinate.
+
+Returns:
+ NONE
+
+--*/
+;
+
+VOID
+EfiAsciiStrnCat (
+ IN CHAR8 *Destination,
+ IN CHAR8 *Source,
+ IN UINTN Length
+ )
+/*++
+
+Routine Description:
+ Concatinate Source on the end of Destination
+
+Arguments:
+ Destination - String to added to the end of.
+ Source - String to concatinate.
+
+Returns:
+ NONE
+
+--*/
+;
+
+//
+// Print primitives
+//
+#define LEFT_JUSTIFY 0x01
+#define PREFIX_SIGN 0x02
+#define PREFIX_BLANK 0x04
+#define COMMA_TYPE 0x08
+#define LONG_TYPE 0x10
+#define PREFIX_ZERO 0x20
+
+//
+// Length of temp string buffer to store value string.
+//
+#define CHARACTER_NUMBER_FOR_VALUE 30
+
+UINTN
+EfiValueToHexStr (
+ IN OUT CHAR16 *Buffer,
+ IN UINT64 Value,
+ IN UINTN Flags,
+ IN UINTN Width
+ )
+/*++
+
+Routine Description:
+
+ VSPrint worker function that prints a Value as a hex number in Buffer
+
+Arguments:
+
+ Buffer - Location to place ascii hex string of Value.
+
+ Value - Hex value to convert to a string in Buffer.
+
+ Flags - Flags to use in printing Hex string, see file header for details.
+
+ Width - Width of hex value.
+
+Returns:
+
+ Number of characters printed.
+
+--*/
+;
+
+UINTN
+EfiValueToString (
+ IN OUT CHAR16 *Buffer,
+ IN INT64 Value,
+ IN UINTN Flags,
+ IN UINTN Width
+ )
+/*++
+
+Routine Description:
+
+ VSPrint worker function that prints a Value as a decimal number in Buffer
+
+Arguments:
+
+ Buffer - Location to place ascii decimal number string of Value.
+
+ Value - Decimal value to convert to a string in Buffer.
+
+ Flags - Flags to use in printing decimal string, see file header for details.
+
+ Width - Width of hex value.
+
+Returns:
+
+ Number of characters printed.
+
+--*/
+;
+
+BOOLEAN
+IsHexDigit (
+ OUT UINT8 *Digit,
+ IN CHAR16 Char
+ )
+/*++
+
+ Routine Description:
+ Determines if a Unicode character is a hexadecimal digit.
+ The test is case insensitive.
+
+ Arguments:
+ Digit - Pointer to byte that receives the value of the hex character.
+ Char - Unicode character to test.
+
+ Returns:
+ TRUE - If the character is a hexadecimal digit.
+ FALSE - Otherwise.
+
+--*/
+;
+
+CHAR16
+NibbleToHexChar (
+ UINT8 Nibble
+ )
+/*++
+
+ Routine Description:
+ Converts the low nibble of a byte to hex unicode character.
+
+ Arguments:
+ Nibble - lower nibble of a byte.
+
+ Returns:
+ Hex unicode character.
+
+--*/
+;
+
+EFI_STATUS
+HexStringToBuf (
+ IN OUT UINT8 *Buf,
+ IN OUT UINTN *Len,
+ IN CHAR16 *Str,
+ OUT UINTN *ConvertedStrLen OPTIONAL
+ )
+/*++
+
+ Routine Description:
+ Converts Unicode string to binary buffer.
+ The conversion may be partial.
+ The first character in the string that is not hex digit stops the conversion.
+ At a minimum, any blob of data could be represented as a hex string.
+
+ Arguments:
+ Buf - Pointer to buffer that receives the data.
+ Len - Length in bytes of the buffer to hold converted data.
+ If routine return with EFI_SUCCESS, containing length of converted data.
+ If routine return with EFI_BUFFER_TOO_SMALL, containg length of buffer desired.
+ Str - String to be converted from.
+ ConvertedStrLen - Length of the Hex String consumed.
+
+ Returns:
+ EFI_SUCCESS: Routine Success.
+ EFI_BUFFER_TOO_SMALL: The buffer is too small to hold converted data.
+ EFI_
+
+--*/
+;
+
+EFI_STATUS
+BufToHexString (
+ IN OUT CHAR16 *Str,
+ IN OUT UINTN *HexStringBufferLength,
+ IN UINT8 *Buf,
+ IN UINTN Len
+ )
+/*++
+
+ Routine Description:
+ Converts binary buffer to Unicode string.
+ At a minimum, any blob of data could be represented as a hex string.
+
+ Arguments:
+ Str - Pointer to the string.
+ HexStringBufferLength - Length in bytes of buffer to hold the hex string. Includes tailing '\0' character.
+ If routine return with EFI_SUCCESS, containing length of hex string buffer.
+ If routine return with EFI_BUFFER_TOO_SMALL, containg length of hex string buffer desired.
+ Buf - Buffer to be converted from.
+ Len - Length in bytes of the buffer to be converted.
+
+ Returns:
+ EFI_SUCCESS: Routine success.
+ EFI_BUFFER_TOO_SMALL: The hex string buffer is too small.
+
+--*/
+;
+
+VOID
+EfiStrTrim (
+ IN OUT CHAR16 *str,
+ IN CHAR16 CharC
+ )
+/*++
+
+Routine Description:
+
+ Removes (trims) specified leading and trailing characters from a string.
+
+Arguments:
+
+ str - Pointer to the null-terminated string to be trimmed. On return,
+ str will hold the trimmed string.
+ CharC - Character will be trimmed from str.
+
+Returns:
+
+ None
+
+--*/
+;
+CHAR16*
+EfiStrStr (
+ IN CHAR16 *String,
+ IN CHAR16 *StrCharSet
+ )
+/*++
+
+Routine Description:
+
+ Find a substring.
+
+Arguments:
+
+ String - Null-terminated string to search.
+ StrCharSet - Null-terminated string to search for.
+
+Returns:
+ The address of the first occurrence of the matching substring if successful, or NULL otherwise.
+--*/
+;
+
+CHAR8*
+EfiAsciiStrStr (
+ IN CHAR8 *String,
+ IN CHAR8 *StrCharSet
+ )
+/*++
+
+Routine Description:
+
+ Find a Ascii substring.
+
+Arguments:
+
+ String - Null-terminated Ascii string to search.
+ StrCharSet - Null-terminated Ascii string to search for.
+
+Returns:
+ The address of the first occurrence of the matching Ascii substring if successful, or NULL otherwise.
+--*/
+;
+#endif
diff --git a/EDK/Foundation/Library/Dxe/Include/EfiDriverLib.h b/EDK/Foundation/Library/Dxe/Include/EfiDriverLib.h
new file mode 100644
index 0000000..20ba3af
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/Include/EfiDriverLib.h
@@ -0,0 +1,1231 @@
+/*++
+
+Copyright (c) 2004 - 2008, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiDriverLib.h
+
+Abstract:
+
+ Light weight lib to support EFI drivers.
+
+--*/
+
+#ifndef _EFI_DRIVER_LIB_H_
+#define _EFI_DRIVER_LIB_H_
+
+#include "EfiStatusCode.h"
+#include "EfiCommonLib.h"
+#include "EfiPerf.h"
+#include "LinkedList.h"
+#include "GetImage.h"
+#include "EfiImageFormat.h"
+#include "EfiCompNameSupport.h"
+
+#include EFI_GUID_DEFINITION (DxeServices)
+#include EFI_GUID_DEFINITION (EventGroup)
+#include EFI_GUID_DEFINITION (EventLegacyBios)
+#include EFI_GUID_DEFINITION (FrameworkDevicePath)
+#include EFI_PROTOCOL_DEFINITION (FirmwareVolume)
+#include EFI_PROTOCOL_DEFINITION (FirmwareVolume2) //;;## ...AMI_OVERRIDE... Support PI1.x
+#include EFI_PROTOCOL_DEFINITION (DataHub)
+#include EFI_PROTOCOL_DEFINITION (DriverBinding)
+#include EFI_PROTOCOL_DEFINITION (ComponentName)
+#include EFI_PROTOCOL_DEFINITION (ComponentName2)
+#include EFI_PROTOCOL_DEFINITION (DriverConfiguration)
+#include EFI_PROTOCOL_DEFINITION (DriverConfiguration2)
+#include EFI_PROTOCOL_DEFINITION (DriverDiagnostics)
+#include EFI_PROTOCOL_DEFINITION (DriverDiagnostics2)
+
+#include EFI_PROTOCOL_DEFINITION (DebugMask)
+
+typedef struct {
+ CHAR8 *Language;
+ CHAR16 *UnicodeString;
+} EFI_UNICODE_STRING_TABLE;
+
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+#define LANGUAGE_CODE_ENGLISH "en-US"
+#else
+#define LANGUAGE_CODE_ENGLISH "eng"
+#endif
+
+//
+// Macros for EFI Driver Library Functions that are really EFI Boot Services
+//
+#define EfiCopyMem(_Destination, _Source, _Length) gBS->CopyMem ((_Destination), (_Source), (_Length))
+#define EfiSetMem(_Destination, _Length, _Value) gBS->SetMem ((_Destination), (_Length), (_Value))
+#define EfiZeroMem(_Destination, _Length) gBS->SetMem ((_Destination), (_Length), 0)
+
+//
+// Driver Lib Globals.
+//
+extern EFI_BOOT_SERVICES *gBS;
+extern EFI_DXE_SERVICES *gDS;
+extern EFI_RUNTIME_SERVICES *gRT;
+extern EFI_SYSTEM_TABLE *gST;
+extern UINTN gErrorLevel;
+extern EFI_GUID gEfiCallerIdGuid;
+extern EFI_DEBUG_MASK_PROTOCOL *gDebugMaskInterface;
+
+EFI_STATUS
+EfiInitializeDriverLib (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+/*++
+
+Routine Description:
+
+ Intialize Driver Lib if it has not yet been initialized.
+
+Arguments:
+
+ ImageHandle - The firmware allocated handle for the EFI image.
+
+ SystemTable - A pointer to the EFI System Table.
+
+
+Returns:
+
+ EFI_STATUS always returns EFI_SUCCESS
+
+--*/
+;
+
+EFI_STATUS
+DxeInitializeDriverLib (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+/*++
+
+Routine Description:
+
+ Intialize Driver Lib if it has not yet been initialized.
+
+Arguments:
+
+ ImageHandle - The firmware allocated handle for the EFI image.
+
+ SystemTable - A pointer to the EFI System Table.
+
+Returns:
+
+ EFI_STATUS always returns EFI_SUCCESS
+
+--*/
+;
+
+EFI_STATUS
+EfiLibInstallDriverBinding (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable,
+ IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding,
+ IN EFI_HANDLE DriverBindingHandle
+ )
+/*++
+
+Routine Description:
+
+ Intialize a driver by installing the Driver Binding Protocol onto the
+ driver's DriverBindingHandle. This is typically the same as the driver's
+ ImageHandle, but it can be different if the driver produces multiple
+ DriverBinding Protocols. This function also initializes the EFI Driver
+ Library that initializes the global variables gST, gBS, gRT.
+
+Arguments:
+
+ ImageHandle - The image handle of the driver
+
+ SystemTable - The EFI System Table that was passed to the driver's entry point
+
+ DriverBinding - A Driver Binding Protocol instance that this driver is producing
+
+ DriverBindingHandle - The handle that DriverBinding is to be installe onto. If this
+ parameter is NULL, then a new handle is created.
+
+Returns:
+
+ EFI_SUCCESS is DriverBinding is installed onto DriverBindingHandle
+
+ Otherwise, then return status from gBS->InstallProtocolInterface()
+
+--*/
+;
+
+EFI_STATUS
+EfiLibInstallAllDriverProtocols (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable,
+ IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding,
+ IN EFI_HANDLE DriverBindingHandle,
+ IN EFI_COMPONENT_NAME_PROTOCOL *ComponentName, OPTIONAL
+ IN EFI_DRIVER_CONFIGURATION_PROTOCOL *DriverConfiguration, OPTIONAL
+ IN EFI_DRIVER_DIAGNOSTICS_PROTOCOL *DriverDiagnostics OPTIONAL
+ )
+/*++
+
+Routine Description:
+
+ Intialize a driver by installing the Driver Binding Protocol onto the
+ driver's DriverBindingHandle. This is typically the same as the driver's
+ ImageHandle, but it can be different if the driver produces multiple
+ DriverBinding Protocols. This function also initializes the EFI Driver
+ Library that initializes the global variables gST, gBS, gRT.
+
+Arguments:
+
+ ImageHandle - The image handle of the driver
+
+ SystemTable - The EFI System Table that was passed to the driver's entry point
+
+ DriverBinding - A Driver Binding Protocol instance that this driver is producing
+
+ DriverBindingHandle - The handle that DriverBinding is to be installe onto. If this
+ parameter is NULL, then a new handle is created.
+
+ ComponentName - A Component Name Protocol instance that this driver is producing
+
+ DriverConfiguration - A Driver Configuration Protocol instance that this driver is producing
+
+ DriverDiagnostics - A Driver Diagnostics Protocol instance that this driver is producing
+
+Returns:
+
+ EFI_SUCCESS if all the protocols were installed onto DriverBindingHandle
+
+ Otherwise, then return status from gBS->InstallProtocolInterface()
+
+--*/
+;
+
+EFI_STATUS
+EfiLibInstallAllDriverProtocols2 (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable,
+ IN EFI_DRIVER_BINDING_PROTOCOL *DriverBinding,
+ IN EFI_HANDLE DriverBindingHandle,
+ IN EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2, OPTIONAL
+ IN EFI_DRIVER_CONFIGURATION2_PROTOCOL *DriverConfiguration2, OPTIONAL
+ IN EFI_DRIVER_DIAGNOSTICS2_PROTOCOL *DriverDiagnostics2 OPTIONAL
+ )
+/*++
+
+Routine Description:
+
+ Intialize a driver by installing the Driver Binding Protocol onto the
+ driver's DriverBindingHandle. This is typically the same as the driver's
+ ImageHandle, but it can be different if the driver produces multiple
+ DriverBinding Protocols. This function also initializes the EFI Driver
+ Library that initializes the global variables gST, gBS, gRT.
+
+Arguments:
+
+ ImageHandle - The image handle of the driver
+
+ SystemTable - The EFI System Table that was passed to the driver's entry point
+
+ DriverBinding - A Driver Binding Protocol instance that this driver is producing
+
+ DriverBindingHandle - The handle that DriverBinding is to be installe onto. If this
+ parameter is NULL, then a new handle is created.
+
+ ComponentName2 - A Component Name2 Protocol instance that this driver is producing
+
+ DriverConfiguration2- A Driver Configuration2 Protocol instance that this driver is producing
+
+ DriverDiagnostics2 - A Driver Diagnostics2 Protocol instance that this driver is producing
+
+Returns:
+
+ EFI_SUCCESS if all the protocols were installed onto DriverBindingHandle
+
+ Otherwise, then return status from gBS->InstallProtocolInterface()
+
+--*/
+;
+
+EFI_STATUS
+EfiLibGetSystemConfigurationTable (
+ IN EFI_GUID *TableGuid,
+ OUT VOID **Table
+ )
+/*++
+
+Routine Description:
+
+ Return the EFI 1.0 System Tabl entry with TableGuid
+
+Arguments:
+
+ TableGuid - Name of entry to return in the system table
+ Table - Pointer in EFI system table associated with TableGuid
+
+Returns:
+
+ EFI_SUCCESS - Table returned;
+ EFI_NOT_FOUND - TableGuid not in EFI system table
+
+--*/
+;
+
+BOOLEAN
+EfiLibCompareLanguage (
+ CHAR8 *Language1,
+ CHAR8 *Language2
+ )
+/*++
+
+Routine Description:
+
+ Compare two languages to say whether they are identical.
+
+Arguments:
+
+ Language1 - first language
+ Language2 - second language
+
+Returns:
+
+ TRUE - identical
+ FALSE - not identical
+
+--*/
+;
+
+//
+// DevicePath.c
+//
+BOOLEAN
+EfiIsDevicePathMultiInstance (
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ )
+/*++
+
+Routine Description:
+ Return TRUE is this is a multi instance device path.
+
+Arguments:
+ DevicePath - A pointer to a device path data structure.
+
+
+Returns:
+ TRUE - If DevicePath is multi instance.
+ FALSE - If DevicePath is not multi instance.
+
+--*/
+;
+
+EFI_DEVICE_PATH_PROTOCOL *
+EfiDevicePathInstance (
+ IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath,
+ OUT UINTN *Size
+ )
+/*++
+
+Routine Description:
+ Function retrieves the next device path instance from a device path data structure.
+
+Arguments:
+ DevicePath - A pointer to a device path data structure.
+
+ Size - A pointer to the size of a device path instance in bytes.
+
+Returns:
+
+ This function returns a pointer to the current device path instance.
+ In addition, it returns the size in bytes of the current device path instance in Size,
+ and a pointer to the next device path instance in DevicePath.
+ If there are no more device path instances in DevicePath, then DevicePath will be set to NULL.
+
+--*/
+;
+
+UINTN
+EfiDevicePathSize (
+ IN EFI_DEVICE_PATH_PROTOCOL *DevPath
+ )
+/*++
+
+Routine Description:
+
+ Calculate the size of a whole device path.
+
+Arguments:
+
+ DevPath - The pointer to the device path data.
+
+Returns:
+
+ Size of device path data structure..
+
+--*/
+;
+
+EFI_DEVICE_PATH_PROTOCOL *
+EfiAppendDevicePath (
+ IN EFI_DEVICE_PATH_PROTOCOL *Src1,
+ IN EFI_DEVICE_PATH_PROTOCOL *Src2
+ )
+/*++
+
+Routine Description:
+ Function is used to append a Src1 and Src2 together.
+
+Arguments:
+ Src1 - A pointer to a device path data structure.
+
+ Src2 - A pointer to a device path data structure.
+
+Returns:
+
+ A pointer to the new device path is returned.
+ NULL is returned if space for the new device path could not be allocated from pool.
+ It is up to the caller to free the memory used by Src1 and Src2 if they are no longer needed.
+
+--*/
+;
+
+EFI_DEVICE_PATH_PROTOCOL *
+EfiDevicePathFromHandle (
+ IN EFI_HANDLE Handle
+ )
+/*++
+
+Routine Description:
+
+ Locate device path protocol interface on a device handle.
+
+Arguments:
+
+ Handle - The device handle
+
+Returns:
+
+ Device path protocol interface located.
+
+--*/
+;
+
+EFI_DEVICE_PATH_PROTOCOL *
+EfiDuplicateDevicePath (
+ IN EFI_DEVICE_PATH_PROTOCOL *DevPath
+ )
+/*++
+
+Routine Description:
+ Duplicate a new device path data structure from the old one.
+
+Arguments:
+ DevPath - A pointer to a device path data structure.
+
+Returns:
+ A pointer to the new allocated device path data.
+ Caller must free the memory used by DevicePath if it is no longer needed.
+
+--*/
+;
+
+EFI_DEVICE_PATH_PROTOCOL *
+EfiAppendDevicePathNode (
+ IN EFI_DEVICE_PATH_PROTOCOL *Src1,
+ IN EFI_DEVICE_PATH_PROTOCOL *Src2
+ )
+/*++
+
+Routine Description:
+ Function is used to append a device path node to the end of another device path.
+
+Arguments:
+ Src1 - A pointer to a device path data structure.
+
+ Src2 - A pointer to a device path data structure.
+
+Returns:
+ This function returns a pointer to the new device path.
+ If there is not enough temporary pool memory available to complete this function,
+ then NULL is returned.
+
+
+--*/
+;
+
+EFI_DEVICE_PATH_PROTOCOL *
+EfiFileDevicePath (
+ IN EFI_HANDLE Device OPTIONAL,
+ IN CHAR16 *FileName
+ )
+/*++
+
+Routine Description:
+ Create a device path that appends a MEDIA_DEVICE_PATH with
+ FileNameGuid to the device path of DeviceHandle.
+
+Arguments:
+ Device - Optional Device Handle to use as Root of the Device Path
+
+ FileName - FileName
+
+Returns:
+ EFI_DEVICE_PATH_PROTOCOL that was allocated from dynamic memory
+ or NULL pointer.
+
+--*/
+;
+
+EFI_DEVICE_PATH_PROTOCOL *
+EfiAppendDevicePathInstance (
+ IN EFI_DEVICE_PATH_PROTOCOL *Src,
+ IN EFI_DEVICE_PATH_PROTOCOL *Instance
+ )
+/*++
+
+Routine Description:
+
+ Append a device path instance to another.
+
+Arguments:
+
+ Src - The device path instance to be appended with.
+ Instance - The device path instance appending the other.
+
+Returns:
+
+ The contaction of these two.
+
+--*/
+;
+
+//
+// Lock.c
+//
+typedef struct {
+ EFI_TPL Tpl;
+ EFI_TPL OwnerTpl;
+ UINTN Lock;
+} EFI_LOCK;
+
+VOID
+EfiInitializeLock (
+ IN OUT EFI_LOCK *Lock,
+ IN EFI_TPL Priority
+ )
+/*++
+
+Routine Description:
+
+ Initialize a basic mutual exclusion lock. Each lock
+ provides mutual exclusion access at it's task priority
+ level. Since there is no-premption (at any TPL) or
+ multiprocessor support, acquiring the lock only consists
+ of raising to the locks TPL.
+
+ Note on a check build ASSERT()s are used to ensure proper
+ lock usage.
+
+Arguments:
+
+ Lock - The EFI_LOCK structure to initialize
+
+ Priority - The task priority level of the lock
+
+
+Returns:
+
+ An initialized Efi Lock structure.
+
+--*/
+;
+
+//
+// Macro to initialize the state of a lock when a lock variable is declared
+//
+#define EFI_INITIALIZE_LOCK_VARIABLE(Tpl) {Tpl,0,0}
+
+VOID
+EfiAcquireLock (
+ IN EFI_LOCK *Lock
+ )
+/*++
+
+Routine Description:
+
+ Raising to the task priority level of the mutual exclusion
+ lock, and then acquires ownership of the lock.
+
+Arguments:
+
+ Lock - The lock to acquire
+
+Returns:
+
+ None
+
+--*/
+;
+
+EFI_STATUS
+EfiAcquireLockOrFail (
+ IN EFI_LOCK *Lock
+ )
+/*++
+
+Routine Description:
+
+ Initialize a basic mutual exclusion lock. Each lock
+ provides mutual exclusion access at it's task priority
+ level. Since there is no-premption (at any TPL) or
+ multiprocessor support, acquiring the lock only consists
+ of raising to the locks TPL.
+
+Arguments:
+
+ Lock - The EFI_LOCK structure to initialize
+
+Returns:
+
+ EFI_SUCCESS - Lock Owned.
+ EFI_ACCESS_DENIED - Reentrant Lock Acquisition, Lock not Owned.
+
+--*/
+;
+
+VOID
+EfiReleaseLock (
+ IN EFI_LOCK *Lock
+ )
+/*++
+
+Routine Description:
+
+ Releases ownership of the mutual exclusion lock, and
+ restores the previous task priority level.
+
+Arguments:
+
+ Lock - The lock to release
+
+Returns:
+
+ None
+
+--*/
+;
+
+VOID *
+EfiLibAllocatePool (
+ IN UINTN AllocationSize
+ )
+/*++
+
+Routine Description:
+
+ Allocate EfiBootServicesData pool of size AllocationSize
+
+Arguments:
+
+ AllocationSize - Pool size
+
+Returns:
+
+ Pointer to the pool allocated
+
+--*/
+;
+
+VOID *
+EfiLibAllocateRuntimePool (
+ IN UINTN AllocationSize
+ )
+/*++
+
+Routine Description:
+
+ Allocate EfiRuntimeServicesData pool of size AllocationSize
+
+Arguments:
+
+ AllocationSize - Pool size
+
+Returns:
+
+ Pointer to the pool allocated
+
+--*/
+;
+
+VOID *
+EfiLibAllocateZeroPool (
+ IN UINTN AllocationSize
+ )
+/*++
+
+Routine Description:
+
+ Allocate EfiBootServicesData pool of size AllocationSize and set memory to zero.
+
+Arguments:
+
+ AllocationSize - Pool size
+
+Returns:
+
+ Pointer to the pool allocated
+
+--*/
+;
+
+VOID *
+EfiLibAllocateRuntimeZeroPool (
+ IN UINTN AllocationSize
+ )
+/*++
+
+Routine Description:
+
+ Allocate EfiRuntimeServicesData pool of size AllocationSize and set memory to zero.
+
+Arguments:
+
+ AllocationSize - Pool size
+
+Returns:
+
+ Pointer to the pool allocated
+
+--*/
+;
+
+VOID *
+EfiLibAllocateCopyPool (
+ IN UINTN AllocationSize,
+ IN VOID *Buffer
+ )
+/*++
+
+Routine Description:
+
+ Allocate BootServicesData pool and use a buffer provided by
+ caller to fill it.
+
+Arguments:
+
+ AllocationSize - The size to allocate
+
+ Buffer - Buffer that will be filled into the buffer allocated
+
+Returns:
+
+ Pointer of the buffer allocated.
+
+--*/
+;
+
+VOID *
+EfiLibAllocateRuntimeCopyPool (
+ IN UINTN AllocationSize,
+ IN VOID *Buffer
+ )
+/*++
+
+Routine Description:
+
+ Allocate RuntimeServicesData pool and use a buffer provided by
+ caller to fill it.
+
+Arguments:
+
+ AllocationSize - The size to allocate
+
+ Buffer - Buffer that will be filled into the buffer allocated
+
+Returns:
+
+ Pointer of the buffer allocated.
+
+--*/
+;
+
+//
+// Event.c
+//
+EFI_EVENT
+EfiLibCreateProtocolNotifyEvent (
+ IN EFI_GUID *ProtocolGuid,
+ IN EFI_TPL NotifyTpl,
+ IN EFI_EVENT_NOTIFY NotifyFunction,
+ IN VOID *NotifyContext,
+ OUT VOID **Registration
+ )
+/*++
+
+Routine Description:
+
+ Create a protocol notification event and return it.
+
+Arguments:
+
+ ProtocolGuid - Protocol to register notification event on.
+
+ NotifyTpl - Maximum TPL to single the NotifyFunction.
+
+ NotifyFunction - EFI notification routine.
+
+ NotifyContext - Context passed into Event when it is created.
+
+ Registration - Registration key returned from RegisterProtocolNotify().
+
+Returns:
+
+ The EFI_EVENT that has been registered to be signaled when a ProtocolGuid
+ is added to the system.
+
+--*/
+;
+
+EFI_STATUS
+EfiLibNamedEventSignal (
+ IN EFI_GUID *Name
+ )
+/*++
+
+Routine Description:
+ Signals a named event. All registered listeners will run.
+ The listeners should register using EfiLibNamedEventListen() function.
+
+ NOTE: For now, the named listening/signalling is implemented
+ on a protocol interface being installed and uninstalled.
+ In the future, this maybe implemented based on a dedicated mechanism.
+
+Arguments:
+ Name - Name to perform the signaling on. The name is a GUID.
+
+Returns:
+ EFI_SUCCESS if successfull.
+
+--*/
+;
+
+EFI_STATUS
+EfiLibNamedEventListen (
+ IN EFI_GUID * Name,
+ IN EFI_TPL NotifyTpl,
+ IN EFI_EVENT_NOTIFY NotifyFunction,
+ IN VOID *NotifyContext
+ )
+/*++
+
+Routine Description:
+ Listenes to signals on the name.
+ EfiLibNamedEventSignal() signals the event.
+
+ NOTE: For now, the named listening/signalling is implemented
+ on a protocol interface being installed and uninstalled.
+ In the future, this maybe implemented based on a dedicated mechanism.
+
+Arguments:
+ Name - Name to register the listener on.
+ NotifyTpl - Maximum TPL to singnal the NotifyFunction.
+ NotifyFunction - The listener routine.
+ NotifyContext - Context passed into the listener routine.
+
+Returns:
+ EFI_SUCCESS if successful.
+
+--*/
+;
+
+//
+// Handle.c
+//
+EFI_STATUS
+EfiLibLocateHandleProtocolByProtocols (
+ IN OUT EFI_HANDLE * Handle, OPTIONAL
+ OUT VOID **Interface, OPTIONAL
+ ...
+ )
+/*++
+Routine Description:
+
+ Function locates Protocol and/or Handle on which all Protocols specified
+ as a variable list are installed.
+ It supports continued search. The caller must assure that no handles are added
+ or removed while performing continued search, by e.g., rising the TPL and not
+ calling any handle routines. Otherwise the behavior is undefined.
+
+Arguments:
+
+ Handle - The address of handle to receive the handle on which protocols
+ indicated by the variable list are installed.
+ If points to NULL, all handles are searched. If pointing to a
+ handle returned from previous call, searches starting from next handle.
+ If NULL, the parameter is ignored.
+
+ Interface - The address of a pointer to a protocol interface that will receive
+ the interface indicated by first variable argument.
+ If NULL, the parameter is ignored.
+
+ ... - A variable argument list containing protocol GUIDs. Must end with NULL.
+
+Returns:
+
+ EFI_SUCCESS - All the protocols where found on same handle.
+ EFI_NOT_FOUND - A Handle with all the protocols installed was not found.
+ Other values as may be returned from LocateHandleBuffer() or HandleProtocol().
+
+--*/
+;
+
+//
+// Debug.c init
+//
+EFI_STATUS
+EfiDebugAssertInit (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Locate Debug Assert Protocol and set as mDebugAssert
+
+Arguments:
+
+ None
+
+Returns:
+
+ Status code
+
+--*/
+;
+
+//
+// Unicode String Support
+//
+EFI_STATUS
+EfiLibLookupUnicodeString (
+ CHAR8 *Language,
+ CHAR8 *SupportedLanguages,
+ EFI_UNICODE_STRING_TABLE *UnicodeStringTable,
+ CHAR16 **UnicodeString
+ )
+/*++
+
+Routine Description:
+
+ Translate a unicode string to a specified language if supported.
+
+Arguments:
+
+ Language - The name of language to translate to
+ SupportedLanguages - Supported languages set
+ UnicodeStringTable - Pointer of one item in translation dictionary
+ UnicodeString - The translated string
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Invalid parameter
+ EFI_UNSUPPORTED - System not supported this language or this string translation
+ EFI_SUCCESS - String successfully translated
+
+--*/
+;
+
+EFI_STATUS
+EfiLibAddUnicodeString (
+ CHAR8 *Language,
+ CHAR8 *SupportedLanguages,
+ EFI_UNICODE_STRING_TABLE **UnicodeStringTable,
+ CHAR16 *UnicodeString
+ )
+/*++
+
+Routine Description:
+
+ Add an translation to the dictionary if this language if supported.
+
+Arguments:
+
+ Language - The name of language to translate to
+ SupportedLanguages - Supported languages set
+ UnicodeStringTable - Translation dictionary
+ UnicodeString - The corresponding string for the language to be translated to
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Invalid parameter
+ EFI_UNSUPPORTED - System not supported this language
+ EFI_ALREADY_STARTED - Already has a translation item of this language
+ EFI_OUT_OF_RESOURCES - No enough buffer to be allocated
+ EFI_SUCCESS - String successfully translated
+
+--*/
+;
+
+EFI_STATUS
+EfiLibFreeUnicodeStringTable (
+ EFI_UNICODE_STRING_TABLE *UnicodeStringTable
+ )
+/*++
+
+Routine Description:
+
+ Free a string table.
+
+Arguments:
+
+ UnicodeStringTable - The string table to be freed.
+
+Returns:
+
+ EFI_SUCCESS - The table successfully freed.
+
+--*/
+;
+
+EFI_STATUS
+EfiLibReportStatusCode (
+ IN EFI_STATUS_CODE_TYPE Type,
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN UINT32 Instance,
+ IN EFI_GUID *CallerId OPTIONAL,
+ IN EFI_STATUS_CODE_DATA *Data OPTIONAL
+ )
+/*++
+
+Routine Description:
+
+ Report status code.
+
+Arguments:
+
+ Type - Code type
+ Value - Code value
+ Instance - Instance number
+ CallerId - Caller name
+ DevicePath - Device path that to be reported
+
+Returns:
+
+ Status code.
+
+ EFI_OUT_OF_RESOURCES - No enough buffer could be allocated
+
+--*/
+;
+
+EFI_STATUS
+ReportStatusCodeWithDevicePath (
+ IN EFI_STATUS_CODE_TYPE Type,
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN UINT32 Instance,
+ IN EFI_GUID * CallerId OPTIONAL,
+ IN EFI_DEVICE_PATH_PROTOCOL * DevicePath
+ )
+/*++
+
+Routine Description:
+
+ Report device path through status code.
+
+Arguments:
+
+ Type - Code type
+ Value - Code value
+ Instance - Instance number
+ CallerId - Caller name
+ DevicePath - Device path that to be reported
+
+Returns:
+
+ Status code.
+
+ EFI_OUT_OF_RESOURCES - No enough buffer could be allocated
+
+--*/
+;
+
+EFI_STATUS
+EFIAPI
+EfiCreateEventLegacyBoot (
+ IN EFI_TPL NotifyTpl,
+ IN EFI_EVENT_NOTIFY NotifyFunction,
+ IN VOID *NotifyContext,
+ OUT EFI_EVENT *LegacyBootEvent
+ )
+/*++
+
+Routine Description:
+ Create a Legacy Boot Event.
+ Tiano extended the CreateEvent Type enum to add a legacy boot event type.
+ This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was
+ added and now it's possible to not voilate the UEFI specification by
+ declaring a GUID for the legacy boot event class. This library supports
+ the R8.5/EFI 1.10 form and R8.6/UEFI 2.0 form and allows common code to
+ work both ways.
+
+Arguments:
+ LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex)
+
+Returns:
+ EFI_SUCCESS Event was created.
+ Other Event was not created.
+
+--*/
+;
+
+EFI_STATUS
+EFIAPI
+EfiCreateEventReadyToBoot (
+ IN EFI_TPL NotifyTpl,
+ IN EFI_EVENT_NOTIFY NotifyFunction,
+ IN VOID *NotifyContext,
+ OUT EFI_EVENT *ReadyToBootEvent
+ )
+/*++
+
+Routine Description:
+ Create a Read to Boot Event.
+
+ Tiano extended the CreateEvent Type enum to add a ready to boot event type.
+ This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was
+ added and now it's possible to not voilate the UEFI specification and use
+ the ready to boot event class defined in UEFI 2.0. This library supports
+ the R8.5/EFI 1.10 form and R8.6/UEFI 2.0 form and allows common code to
+ work both ways.
+
+Arguments:
+ @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex)
+
+Return:
+ EFI_SUCCESS - Event was created.
+ Other - Event was not created.
+
+--*/
+;
+
+VOID
+EFIAPI
+EfiInitializeFwVolDevicepathNode (
+ IN MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode,
+ IN EFI_GUID *NameGuid
+ )
+/*++
+Routine Description:
+ Initialize a Firmware Volume (FV) Media Device Path node.
+
+Arguments:
+ FvDevicePathNode - Pointer to a FV device path node to initialize
+ NameGuid - FV file name to use in FvDevicePathNode
+
+--*/
+;
+
+EFI_GUID *
+EFIAPI
+EfiGetNameGuidFromFwVolDevicePathNode (
+ IN MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode
+ )
+/*++
+Routine Description:
+ Check to see if the Firmware Volume (FV) Media Device Path is valid.
+
+Arguments:
+ FvDevicePathNode - Pointer to FV device path to check
+
+Return:
+ NULL - FvDevicePathNode is not valid.
+ Other - FvDevicePathNode is valid and pointer to NameGuid was returned.
+
+--*/
+;
+
+VOID
+EfiLibSafeFreePool (
+ IN VOID *Buffer
+ )
+/*++
+
+Routine Description:
+
+ Free pool safely.
+
+Arguments:
+
+ Buffer - The allocated pool entry to free
+
+Returns:
+
+ Pointer of the buffer allocated.
+
+--*/
+;
+
+EFI_STATUS
+EfiLibTestManagedDevice (
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE DriverBindingHandle,
+ IN EFI_GUID *ManagedProtocolGuid
+ )
+/*++
+
+Routine Description:
+
+ Test to see if the controller is managed by a specific driver.
+
+Arguments:
+
+ ControllerHandle - Handle for controller to test
+
+ DriverBindingHandle - Driver binding handle for controller
+
+ ManagedProtocolGuid - The protocol guid the driver opens on controller
+
+Returns:
+
+ EFI_SUCCESS - The controller is managed by the driver
+
+ EFI_UNSUPPORTED - The controller is not managed by the driver
+
+--*/
+;
+
+EFI_STATUS
+EfiLibTestChildHandle (
+ IN EFI_HANDLE ControllerHandle,
+ IN EFI_HANDLE ChildHandle,
+ IN EFI_GUID *ConsumedGuid
+ )
+/*++
+
+Routine Description:
+
+ Test to see if the child handle is the child of the controller
+
+Arguments:
+
+ ControllerHandle - Handle for controller (parent)
+
+ ChildHandle - Child handle to test
+
+ ConsumsedGuid - Protocol guid consumed by child from controller
+
+Returns:
+
+ EFI_SUCCESS - The child handle is the child of the controller
+
+ EFI_UNSUPPORTED - The child handle is not the child of the controller
+
+--*/
+;
+#endif
diff --git a/EDK/Foundation/Library/Dxe/Include/EfiHobLib.h b/EDK/Foundation/Library/Dxe/Include/EfiHobLib.h
new file mode 100644
index 0000000..787e872
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/Include/EfiHobLib.h
@@ -0,0 +1,299 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiHobLib.h
+
+Abstract:
+
+
+--*/
+
+#ifndef _EFI_HOB_LIB_H_
+#define _EFI_HOB_LIB_H_
+
+#include "PeiHob.h"
+
+VOID *
+GetHob (
+ IN UINT16 Type,
+ IN VOID *HobStart
+ )
+/*++
+
+Routine Description:
+
+ This function returns the first instance of a HOB type in a HOB list.
+
+Arguments:
+
+ Type The HOB type to return.
+ HobStart The first HOB in the HOB list.
+
+Returns:
+
+ HobStart There were no HOBs found with the requested type.
+ else Returns the first HOB with the matching type.
+
+--*/
+;
+
+UINTN
+GetHobListSize (
+ IN VOID *HobStart
+ )
+/*++
+
+Routine Description:
+
+ Get size of hob list.
+
+Arguments:
+
+ HobStart - Start pointer of hob list
+
+Returns:
+
+ Size of hob list.
+
+--*/
+;
+
+UINT32
+GetHobVersion (
+ IN VOID *HobStart
+ )
+/*++
+
+Routine Description:
+
+ Get hob version.
+
+Arguments:
+
+ HobStart - Start pointer of hob list
+
+Returns:
+
+ Hob version.
+
+--*/
+;
+
+EFI_STATUS
+GetHobBootMode (
+ IN VOID *HobStart,
+ OUT EFI_BOOT_MODE *BootMode
+ )
+/*++
+
+Routine Description:
+
+ Get current boot mode.
+
+Arguments:
+
+ HobStart - Start pointer of hob list
+
+ BootMode - Current boot mode recorded in PHIT hob
+
+Returns:
+
+ EFI_NOT_FOUND - Invalid hob header
+
+ EFI_SUCCESS - Boot mode found
+
+--*/
+;
+
+EFI_STATUS
+GetCpuHobInfo (
+ IN VOID *HobStart,
+ OUT UINT8 *SizeOfMemorySpace,
+ OUT UINT8 *SizeOfIoSpace
+ )
+/*++
+
+Routine Description:
+
+ Get information recorded in CPU hob (Memory space size, Io space size)
+
+Arguments:
+
+ HobStart - Start pointer of hob list
+
+ SizeOfMemorySpace - Size of memory size
+
+ SizeOfIoSpace - Size of IO size
+
+Returns:
+
+ EFI_NOT_FOUND - CPU hob not found
+
+ EFI_SUCCESS - CPU hob found and information got.
+
+--*/
+;
+
+EFI_STATUS
+GetDxeCoreHobInfo (
+ IN VOID *HobStart,
+ OUT EFI_PHYSICAL_ADDRESS *BaseAddress,
+ OUT UINT64 *Length,
+ OUT VOID **EntryPoint,
+ OUT EFI_GUID **FileName
+ )
+/*++
+
+Routine Description:
+
+ Get memory allocation hob created for DXE core and extract its information
+
+Arguments:
+
+ HobStart - Start pointer of the hob list
+
+ BaseAddress - Start address of memory allocated for DXE core
+
+ Length - Length of memory allocated for DXE core
+
+ EntryPoint - DXE core file name
+
+ FileName - FileName
+
+Returns:
+
+ EFI_NOT_FOUND - DxeCoreHob not found
+
+ EFI_SUCCESS - DxeCoreHob found and information got
+
+--*/
+;
+
+EFI_STATUS
+GetNextFirmwareVolumeHob (
+ IN OUT VOID **HobStart,
+ OUT EFI_PHYSICAL_ADDRESS *BaseAddress,
+ OUT UINT64 *Length
+ )
+/*++
+
+Routine Description:
+
+ Get next firmware volume hob from HobStart
+
+Arguments:
+
+ HobStart - Start pointer of hob list
+
+ BaseAddress - Start address of next firmware volume
+
+ Length - Length of next firmware volume
+
+Returns:
+
+ EFI_NOT_FOUND - Next firmware volume not found
+
+ EFI_SUCCESS - Next firmware volume found with address information
+
+--*/
+;
+
+//;;## ...AMI_OVERRIDE... Support PI1.x
+#if (PI_SPECIFICATION_VERSION >= 0x00010000)
+EFI_STATUS
+GetNextFirmwareVolume2Hob (
+ IN OUT VOID **HobStart,
+ OUT EFI_PHYSICAL_ADDRESS *BaseAddress,
+ OUT UINT64 *Length,
+ OUT EFI_GUID *FileName
+ )
+;
+#endif
+
+EFI_STATUS
+GetNextGuidHob (
+ IN OUT VOID **HobStart,
+ IN EFI_GUID * Guid,
+ OUT VOID **Buffer,
+ OUT UINTN *BufferSize OPTIONAL
+ )
+/*++
+
+Routine Description:
+ Get the next guid hob.
+
+Arguments:
+ HobStart A pointer to the start hob.
+ Guid A pointer to a guid.
+ Buffer A pointer to the buffer.
+ BufferSize Buffer size.
+
+Returns:
+ Status code.
+
+ EFI_NOT_FOUND - Next Guid hob not found
+
+ EFI_SUCCESS - Next Guid hob found and data for this Guid got
+
+--*/
+;
+
+EFI_STATUS
+GetPalEntryHobInfo (
+ IN VOID *HobStart,
+ OUT EFI_PHYSICAL_ADDRESS *PalEntry
+ )
+/*++
+
+Routine Description:
+
+ Get PAL entry from PalEntryHob
+
+Arguments:
+
+ HobStart - Start pointer of hob list
+
+ PalEntry - Pointer to PAL entry
+
+Returns:
+
+ Status code.
+
+--*/
+;
+
+EFI_STATUS
+GetIoPortSpaceAddressHobInfo (
+ IN VOID *HobStart,
+ OUT EFI_PHYSICAL_ADDRESS *IoPortSpaceAddress
+ )
+/*++
+
+Routine Description:
+
+ Get IO port space address from IoBaseHob.
+
+Arguments:
+
+ HobStart - Start pointer of hob list
+
+ IoPortSpaceAddress - IO port space address
+
+Returns:
+
+ Status code
+
+--*/
+;
+
+#endif
diff --git a/EDK/Foundation/Library/Dxe/Include/EfiMgmtModeRuntimeLib.h b/EDK/Foundation/Library/Dxe/Include/EfiMgmtModeRuntimeLib.h
new file mode 100644
index 0000000..89fb72e
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/Include/EfiMgmtModeRuntimeLib.h
@@ -0,0 +1,429 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiMgmtModeRuntimeLib.h
+
+Abstract:
+
+ Light weight lib to support EFI drivers.
+
+--*/
+
+#ifndef _EFI_RT_SUPPORT_LIB_H_
+#define _EFI_RT_SUPPORT_LIB_H_
+
+#ifndef EFI_LOAD_IMAGE_SMM
+#define EFI_LOAD_DRIVER_SMM FALSE
+#else
+#define EFI_LOAD_DRIVER_SMM TRUE
+#endif
+
+#ifndef EFI_NO_LOAD_IMAGE_RT
+#define EFI_NO_LOAD_DRIVER_RT FALSE
+#else
+#define EFI_NO_LOAD_DRIVER_RT TRUE
+#endif
+
+#include "EfiCommonLib.h"
+#include "LinkedList.h"
+#include "ProcDep.h"
+
+#include EFI_PROTOCOL_DEFINITION (CpuIo)
+#include EFI_PROTOCOL_DEFINITION (FirmwareVolumeBlock)
+
+//
+// Driver Lib Globals.
+//
+extern EFI_BOOT_SERVICES *gBS;
+extern EFI_SYSTEM_TABLE *gST;
+extern UINTN gRtErrorLevel;
+extern BOOLEAN mEfiLoadDriverSmm;
+extern BOOLEAN mEfiNoLoadDriverRt;
+extern EFI_DEVICE_PATH_PROTOCOL *mFilePath;
+
+//
+// Runtime Memory Allocation/De-Allocation tools (Should be used in Boot Phase only)
+//
+EFI_STATUS
+EfiAllocateRuntimeMemoryPool (
+ IN UINTN Size,
+ OUT VOID **Buffer
+ )
+/*++
+
+Routine Description:
+
+ Allocate EfiRuntimeServicesData pool of specified size.
+
+Arguments:
+
+ Size - Pool size
+ Buffer - Memory pointer for output
+
+Returns:
+
+ Status code
+
+--*/
+;
+
+EFI_STATUS
+EfiFreeRuntimeMemoryPool (
+ IN VOID *Buffer
+ )
+/*++
+
+Routine Description:
+
+ Free allocated pool
+
+Arguments:
+
+ Buffer - Pool to be freed
+
+Returns:
+
+ Status code
+
+--*/
+;
+
+EFI_STATUS
+EfiLocateProtocolHandleBuffers (
+ IN EFI_GUID *Protocol,
+ IN OUT UINTN *NumberHandles,
+ OUT EFI_HANDLE **Buffer
+ )
+/*++
+
+Routine Description:
+
+ Returns an array of handles that support the requested protocol in a buffer allocated from pool.
+
+Arguments:
+
+ Protocol - Provides the protocol to search by.
+ NumberHandles - The number of handles returned in Buffer.
+ Buffer - A pointer to the buffer to return the requested array of handles that
+ support Protocol.
+
+Returns:
+
+ Status code
+
+--*/
+;
+
+EFI_STATUS
+EfiHandleProtocol (
+ IN EFI_HANDLE Handle,
+ IN EFI_GUID *Protocol,
+ OUT VOID **Interface
+ )
+/*++
+
+Routine Description:
+
+ Queries a handle to determine if it supports a specified protocol.
+
+Arguments:
+
+ Handle - The handle being queried.
+ Protocol - The published unique identifier of the protocol.
+ Interface - Supplies the address where a pointer to the corresponding Protocol
+ Interface is returned. NULL will be returned in *Interface if a
+ structure is not associated with Protocol.
+
+Returns:
+
+ Status code
+
+--*/
+;
+
+EFI_STATUS
+EfiInstallProtocolInterface (
+ IN OUT EFI_HANDLE *Handle,
+ IN EFI_GUID *Protocol,
+ IN EFI_INTERFACE_TYPE InterfaceType,
+ IN VOID *Interface
+ )
+/*++
+
+Routine Description:
+
+ Installs a protocol interface on a device handle. If the handle does not exist, it is created and added
+to the list of handles in the system.
+
+Arguments:
+
+ Handle - A pointer to the EFI_HANDLE on which the interface is to be installed.
+ Protocol - The numeric ID of the protocol interface.
+ InterfaceType - Indicates whether Interface is supplied in native form.
+ Interface - A pointer to the protocol interface.
+
+Returns:
+
+ Status code
+
+--*/
+;
+
+EFI_STATUS
+EfiReinstallProtocolInterface (
+ IN EFI_HANDLE SmmProtocolHandle,
+ IN EFI_GUID *Protocol,
+ IN VOID *OldInterface,
+ IN VOID *NewInterface
+ )
+/*++
+
+Routine Description:
+
+ Reinstalls a protocol interface on a device handle.
+
+Arguments:
+
+ SmmProtocolHandle - Handle on which the interface is to be reinstalled.
+ Protocol - The numeric ID of the interface.
+ OldInterface - A pointer to the old interface.
+ NewInterface - A pointer to the new interface.
+
+Returns:
+
+ Status code
+
+--*/
+;
+
+EFI_STATUS
+EfiLocateProtocolInterface (
+ EFI_GUID *Protocol,
+ VOID *Registration, OPTIONAL
+ VOID **Interface
+ )
+/*++
+
+Routine Description:
+
+ Returns the first protocol instance that matches the given protocol.
+
+Arguments:
+
+ Protocol - Provides the protocol to search for.
+ Registration - Optional registration key returned from
+ RegisterProtocolNotify(). If Registration is NULL, then
+ it is ignored.
+ Interface - On return, a pointer to the first interface that matches Protocol and
+ Registration.
+
+Returns:
+
+ Status code
+
+--*/
+;
+
+EFI_STATUS
+UninstallProtocolInterface (
+ IN EFI_HANDLE SmmProtocolHandle,
+ IN EFI_GUID *Protocol,
+ IN VOID *Interface
+ )
+/*++
+
+Routine Description:
+
+ Removes a protocol interface from a device handle.
+
+Arguments:
+
+ SmmProtocolHandle - The handle on which the interface was installed.
+ Protocol - The numeric ID of the interface.
+ Interface - A pointer to the interface.
+
+Returns:
+
+ Status code
+
+--*/
+;
+
+EFI_STATUS
+EfiRegisterProtocolCallback (
+ IN EFI_EVENT_NOTIFY CallbackFunction,
+ IN VOID *Context,
+ IN EFI_GUID *ProtocolGuid,
+ IN EFI_TPL NotifyTpl,
+ OUT VOID **Registeration,
+ OUT EFI_EVENT *Event
+ )
+/*++
+
+Routine Description:
+
+ Register a callback function to be signaled whenever an interface is installed for
+ a specified protocol.
+
+Arguments:
+
+ CallbackFunction - Call back function
+ Context - Context of call back function
+ ProtocolGuid - The numeric ID of the protocol for which the callback function
+ is to be registered.
+ NotifyTpl - Notify tpl of callback function
+ Registeration - A pointer to a memory location to receive the registration value.
+ Event - Event that is to be signaled whenever a protocol interface is registered
+ for Protocol.
+
+Returns:
+
+ Status code
+
+--*/
+;
+
+EFI_STATUS
+EfiSignalProtocolEvent (
+ EFI_EVENT Event
+ )
+/*++
+
+Routine Description:
+
+ Signals an event.
+
+Arguments:
+
+ Event - The event to signal.
+
+Returns:
+
+ Status code
+
+--*/
+;
+
+EFI_STATUS
+EfiInstallVendorConfigurationTable (
+ IN EFI_GUID *Guid,
+ IN VOID *Table
+ )
+/*++
+
+Routine Description:
+
+ Adds, updates, or removes a configuration table entry from the EFI System Table.
+
+Arguments:
+
+ Guid - A pointer to the GUID for the entry to add, update, or remove.
+ Table - A pointer to the configuration table for the entry to add, update, or
+ remove. May be NULL.
+
+Returns:
+
+ Status code
+
+--*/
+;
+
+EFI_STATUS
+EfiGetVendorConfigurationTable (
+ IN EFI_GUID *Guid,
+ OUT VOID **Table
+ )
+/*++
+
+Routine Description:
+
+ Return the EFI 1.0 System Tabl entry with TableGuid
+
+Arguments:
+
+ Guid - Name of entry to return in the system table
+ Table - Pointer in EFI system table associated with TableGuid
+
+Returns:
+
+ EFI_SUCCESS - Table returned;
+ EFI_NOT_FOUND - TableGuid not in EFI system table
+
+--*/
+;
+
+EFI_STATUS
+EfiInitializeUtilsRuntimeDriverLib (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable,
+ IN EFI_EVENT_NOTIFY GoVirtualChildEvent
+ )
+/*++
+
+Routine Description:
+
+ Intialize runtime Driver Lib if it has not yet been initialized.
+
+Arguments:
+
+ ImageHandle - The firmware allocated handle for the EFI image.
+
+ SystemTable - A pointer to the EFI System Table.
+
+ GoVirtualChildEvent - Caller can register a virtual notification event.
+
+Returns:
+
+ EFI_STATUS always returns EFI_SUCCESS
+
+--*/
+;
+
+BOOLEAN
+EfiInManagementInterrupt (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Indicate whether the caller is already in SMM or not.
+
+Arguments:
+
+ None
+
+Returns:
+
+ TRUE - In SMM
+ FALSE - Not in SMM
+
+--*/
+;
+
+//
+// This MACRO initializes the RUNTIME invironment and optionally loads Image to SMM or Non-SMM space
+// based upon the presence of build flags EFI_LOAD_DRIVER_SMM and EFI_NO_LOAD_DRIVER_RT.
+//
+#define EFI_INITIALIZE_RUNTIME_DRIVER_LIB(ImageHandle, SystemTable, GoVirtualChildEvent, FilePath) \
+ mEfiLoadDriverSmm = EFI_LOAD_DRIVER_SMM; \
+ mEfiNoLoadDriverRt = EFI_NO_LOAD_DRIVER_RT; \
+ mFilePath = (EFI_DEVICE_PATH_PROTOCOL*) FilePath; \
+ EfiInitializeUtilsRuntimeDriverLib ((EFI_HANDLE) ImageHandle, (EFI_SYSTEM_TABLE*) SystemTable, (EFI_EVENT_NOTIFY) GoVirtualChildEvent); \
+ if (!EfiInManagementInterrupt()) { \
+ if (mEfiNoLoadDriverRt) { \
+ return EFI_SUCCESS; \
+ } \
+ }
+
+#endif
diff --git a/EDK/Foundation/Library/Dxe/Include/EfiPrintLib.h b/EDK/Foundation/Library/Dxe/Include/EfiPrintLib.h
new file mode 100644
index 0000000..1fca597
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/Include/EfiPrintLib.h
@@ -0,0 +1,326 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiPrintLib.h
+
+Abstract:
+
+ Light weight lib to support EFI drivers.
+
+--*/
+
+#ifndef _EFI_PRINT_LIB_H_
+#define _EFI_PRINT_LIB_H_
+
+#include EFI_PROTOCOL_DEFINITION(GraphicsOutput)
+#include EFI_PROTOCOL_DEFINITION(UgaDraw)
+#include EFI_PROTOCOL_DEFINITION(Print)
+
+UINTN
+ErrorPrint (
+ IN CONST CHAR16 *ErrorString,
+ IN CONST CHAR8 *Format,
+ ...
+ )
+/*++
+
+Routine Description:
+
+ Print function for a maximum of EFI_DRIVER_LIB_MAX_PRINT_BUFFER ascii
+ characters.
+
+Arguments:
+
+ ErrorString - Error message printed first
+
+ Format - Ascii format string see file header for more details.
+
+ ... - Vararg list consumed by processing Format.
+
+Returns:
+
+ Number of characters printed.
+
+--*/
+;
+
+VOID
+ErrorDumpHex (
+ IN UINTN Indent,
+ IN UINTN Offset,
+ IN UINTN DataSize,
+ IN VOID *UserData
+ )
+/*++
+
+Routine Description:
+
+ Dump error info by hex.
+
+Arguments:
+
+ Indent - Indent number
+ Offset - Offset number
+ DataSize - Size of user data
+ UserData - User data to dump
+
+Returns:
+
+ None
+
+--*/
+;
+
+UINTN
+Print (
+ IN CONST CHAR16 *Format,
+ ...
+ )
+/*++
+
+Routine Description:
+
+ Prints a formatted unicode string to the default console
+
+Arguments:
+
+ fmt - Format string
+
+Returns:
+
+ Length of string printed to the console
+
+--*/
+;
+
+UINTN
+PrintXY (
+ IN UINTN X,
+ IN UINTN Y,
+ IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Foreground, OPTIONAL
+ IN EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Background, OPTIONAL
+ IN CHAR16 *Fmt,
+ ...
+ )
+/*++
+
+Routine Description:
+
+ Prints a formatted unicode string to the default console
+
+Arguments:
+
+ X - X coordinate to start printing
+
+ Y - Y coordinate to start printing
+
+ ForeGround - Foreground color
+
+ BackGround - Background color
+
+ Fmt - Format string
+
+ ... - Print arguments
+
+Returns:
+
+ Length of string printed to the console
+
+--*/
+;
+
+UINTN
+Aprint (
+ IN CONST CHAR8 *Format,
+ ...
+ )
+/*++
+
+Routine Description:
+
+ Print function for a maximum of EFI_DRIVER_LIB_MAX_PRINT_BUFFER ascii
+ characters.
+
+Arguments:
+
+ Format - Ascii format string see file header for more details.
+
+ ... - Vararg list consumed by processing Format.
+
+Returns:
+
+ Number of characters printed.
+
+--*/
+;
+
+UINTN
+UPrint (
+ IN CONST CHAR16 *Format,
+ ...
+ )
+/*++
+
+Routine Description:
+
+ Print function for a maximum of EFI_DRIVER_LIB_MAX_PRINT_BUFFER ascii
+ characters.
+
+Arguments:
+
+ Format - Ascii format string see file header for more details.
+
+ ... - Vararg list consumed by processing Format.
+
+Returns:
+
+ Number of characters printed.
+
+--*/
+;
+
+UINTN
+VSPrint (
+ OUT CHAR16 *StartOfBuffer,
+ IN UINTN StrLen,
+ IN CONST CHAR16 *Format,
+ IN VA_LIST Marker
+ )
+/*++
+
+Routine Description:
+
+ Prints a formatted unicode string to a buffer
+
+Arguments:
+
+ StartOfBuffer - Output buffer to print the formatted string into
+ StrLen - Size of Str. String is truncated to this size.
+ A size of 0 means there is no limit
+ Format - The format string
+ Marker - Vararg list consumed by processing Format.
+
+Returns:
+
+ String length returned in buffer
+
+--*/
+;
+
+UINTN
+SPrint (
+ OUT CHAR16 *Buffer,
+ IN UINTN BufferSize,
+ IN CONST CHAR16 *Format,
+ ...
+ )
+/*++
+
+Routine Description:
+
+ SPrint function to process format and place the results in Buffer.
+
+Arguments:
+
+ Buffer - Wide char buffer to print the results of the parsing of Format into.
+
+ BufferSize - Maximum number of characters to put into buffer. Zero means no
+ limit.
+
+ Format - Format string see file header for more details.
+
+ ... - Vararg list consumed by processing Format.
+
+Returns:
+
+ Number of characters printed.
+
+--*/
+;
+
+//
+// BoxDraw support
+//
+BOOLEAN
+IsValidEfiCntlChar (
+ IN CHAR16 CharC
+ )
+/*++
+
+Routine Description:
+
+ Test whether a wide char is a valid control char.
+
+Arguments:
+
+ CharC - A char
+
+Returns:
+
+ TRUE - A control char
+
+ FALSE - Not a control char
+
+--*/
+;
+
+BOOLEAN
+IsValidAscii (
+ IN CHAR16 Ascii
+ )
+/*++
+
+Routine Description:
+
+ Test whether a wide char is a normal printable char
+
+Arguments:
+
+ Ascii - A char
+
+Returns:
+
+ True - A normal, printable char
+ FALSE - Not a normal, printable char
+
+--*/
+;
+
+BOOLEAN
+LibIsValidTextGraphics (
+ IN CHAR16 Graphic,
+ OUT CHAR8 *PcAnsi, OPTIONAL
+ OUT CHAR8 *Ascii OPTIONAL
+ )
+/*++
+
+Routine Description:
+
+ Detects if a Unicode char is for Box Drawing text graphics.
+
+Arguments:
+
+ Graphic - Unicode char to test.
+
+ PcAnsi - Optional pointer to return PCANSI equivalent of Graphic.
+
+ Ascii - Optional pointer to return Ascii equivalent of Graphic.
+
+Returns:
+
+ TRUE if Gpaphic is a supported Unicode Box Drawing character.
+
+--*/
+;
+
+#endif
diff --git a/EDK/Foundation/Library/Dxe/Include/EfiRegTableLib.h b/EDK/Foundation/Library/Dxe/Include/EfiRegTableLib.h
new file mode 100644
index 0000000..6df50d8
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/Include/EfiRegTableLib.h
@@ -0,0 +1,205 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiRegTableLib.h
+
+Abstract:
+
+ Definitions and macros for building register tables for chipset
+ initialization..
+
+ Components linking this lib must include CpuIo, PciRootBridgeIo, and
+ BootScriptSave protocols in their DPX.
+
+Revision History:
+
+--*/
+
+#ifndef EFI_REG_TABLE_H
+#define EFI_REG_TABLE_H
+
+#include "Tiano.h"
+#include "EfiScriptLib.h"
+#include EFI_PROTOCOL_CONSUMER (CpuIo)
+#include EFI_PROTOCOL_CONSUMER (PciRootBridgeIo)
+
+//
+// RegTable OpCodes are encoded as follows:
+//
+// |31----------------------------16|15---------8|7-------0|
+// \ \ \
+// \ \ \
+// 31:16 defined by Base OpCode---+ \ \
+// Opcode Flags---+ \
+// Base OpCode---+
+//
+#define OPCODE_BASE(OpCode) ((UINT8)((OpCode) & 0xFF))
+#define OPCODE_FLAGS(OpCode) ((UINT8)(((OpCode) >> 8) & 0xFF))
+#define OPCODE_EXTRA_DATA(OpCode) ((UINT16)((OpCode) >> 16))
+
+//
+// RegTable Base OpCodes
+//
+#define OP_TERMINATE_TABLE 0
+#define OP_MEM_WRITE 1
+#define OP_MEM_READ_MODIFY_WRITE 2
+#define OP_IO_WRITE 3
+#define OP_IO_READ_MODIFY_WRITE 4
+#define OP_PCI_WRITE 5
+#define OP_PCI_READ_MODIFY_WRITE 6
+#define OP_STALL 7
+
+//
+// RegTable OpCode Flags
+//
+#define OPCODE_FLAG_S3SAVE 1
+
+
+#define TERMINATE_TABLE { (UINT32) OP_TERMINATE_TABLE, (UINT32) 0, (UINT32) 0 }
+
+
+//
+// REG_TABLE_ENTRY_PCI_WRITE encodes the width in the upper bits of the OpCode
+// as one of the EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL_WIDTH values
+//
+typedef struct {
+ UINT32 OpCode;
+ UINT32 PciAddress;
+ UINT32 Data;
+} EFI_REG_TABLE_PCI_WRITE;
+
+#define PCI_WRITE(Bus, Dev, Fnc, Reg, Width, Data, S3Flag) \
+ { \
+ (UINT32) (OP_PCI_WRITE | ((S3Flag) << 8) | ((Width) << 16)), \
+ (UINT32) (EFI_PCI_ADDRESS ((Bus), (Dev), (Fnc), (Reg))), \
+ (UINT32) (Data), \
+ (UINT32) (0) \
+ }
+
+typedef struct {
+ UINT32 OpCode;
+ UINT32 PciAddress;
+ UINT32 OrMask;
+ UINT32 AndMask;
+} EFI_REG_TABLE_PCI_READ_MODIFY_WRITE;
+
+#define PCI_READ_MODIFY_WRITE(Bus, Dev, Fnc, Reg, Width, OrMask, AndMask, S3Flag) \
+ { \
+ (UINT32) (OP_PCI_READ_MODIFY_WRITE | ((S3Flag) << 8) | ((Width) << 16)), \
+ (UINT32) (EFI_PCI_ADDRESS ((Bus), (Dev), (Fnc), (Reg))), \
+ (UINT32) (OrMask), \
+ (UINT32) (AndMask) \
+ }
+
+typedef struct {
+ UINT32 OpCode;
+ UINT32 MemAddress;
+ UINT32 OrMask;
+ UINT32 AndMask;
+} EFI_REG_TABLE_MEM_READ_MODIFY_WRITE;
+
+#define MEM_READ_MODIFY_WRITE(Address, Width, OrMask, AndMask, S3Flag) \
+ { \
+ (UINT32) (OP_MEM_READ_MODIFY_WRITE | ((S3Flag) << 8) | ((Width) << 16)), \
+ (UINT32) (Address), \
+ (UINT32) (OrMask), \
+ (UINT32) (AndMask) \
+ }
+
+typedef struct {
+ UINT32 OpCode;
+ UINT32 Field2;
+ UINT32 Field3;
+ UINT32 Field4;
+} EFI_REG_TABLE_GENERIC;
+
+typedef union {
+ EFI_REG_TABLE_GENERIC Generic;
+ EFI_REG_TABLE_PCI_WRITE PciWrite;
+ EFI_REG_TABLE_PCI_READ_MODIFY_WRITE PciReadModifyWrite;
+ EFI_REG_TABLE_MEM_READ_MODIFY_WRITE MemReadModifyWrite;
+} EFI_REG_TABLE;
+
+VOID
+ProcessRegTablePci (
+ EFI_REG_TABLE * RegTableEntry,
+ EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL * PciRootBridgeIo,
+ EFI_CPU_IO_PROTOCOL * CpuIo
+ )
+/*++
+
+Routine Description:
+ Processes register table assuming which may contain PCI, IO, MEM, and STALL
+ entries.
+
+ No parameter checking is done so the caller must be careful about omitting
+ values for PciRootBridgeIo or CpuIo parameters. If the regtable does
+ not contain any PCI accesses, it is safe to omit the PciRootBridgeIo (supply
+ NULL). If the regtable does not contain any IO or Mem entries, it is safe to
+ omit the CpuIo (supply NULL).
+
+ The RegTableEntry parameter is not checked, but is required.
+
+ gBS is assumed to have been defined and is used when processing stalls.
+
+ The function processes each entry sequentially until an OP_TERMINATE_TABLE
+ entry is encountered.
+
+Arguments:
+ RegTableEntry - A pointer to the register table to process
+
+ PciRootBridgeIo - A pointer to the instance of PciRootBridgeIo that is used
+ when processing PCI table entries
+
+ CpuIo - A pointer to the instance of CpuIo that is used when processing IO and
+ MEM table entries
+
+Returns:
+ Nothing.
+
+--*/
+;
+
+VOID
+ProcessRegTableCpu (
+ EFI_REG_TABLE * RegTableEntry,
+ EFI_CPU_IO_PROTOCOL * CpuIo
+ )
+/*++
+
+Routine Description:
+ Processes register table assuming which may contain IO, MEM, and STALL
+ entries, but must NOT contain any PCI entries. Any PCI entries cause an
+ ASSERT in a DEBUG build and are skipped in a free build.
+
+ No parameter checking is done. Both RegTableEntry and CpuIo parameters are
+ required.
+
+ gBS is assumed to have been defined and is used when processing stalls.
+
+ The function processes each entry sequentially until an OP_TERMINATE_TABLE
+ entry is encountered.
+
+Arguments:
+ RegTableEntry - A pointer to the register table to process
+
+ CpuIo - A pointer to the instance of CpuIo that is used when processing IO and
+ MEM table entries
+
+Returns:
+ Nothing.
+
+--*/
+;
+
+#endif
diff --git a/EDK/Foundation/Library/Dxe/Include/EfiRuntimeLib.h b/EDK/Foundation/Library/Dxe/Include/EfiRuntimeLib.h
new file mode 100644
index 0000000..b2ae8a0
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/Include/EfiRuntimeLib.h
@@ -0,0 +1,1691 @@
+/*++
+
+Copyright (c) 2004 - 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiRuntimeLib.h
+
+Abstract:
+
+ Light weight lib to support EFI drivers.
+
+--*/
+
+#ifndef _EFI_RUNTIME_LIB_H_
+#define _EFI_RUNTIME_LIB_H_
+#define MAX_FVB_COUNT 16
+#include "EfiStatusCode.h"
+#include "EfiCommonLib.h"
+
+#include "LinkedList.h"
+#include "GetImage.h"
+#include "RtDevicePath.h"
+
+#include EFI_GUID_DEFINITION (DxeServices)
+#include EFI_GUID_DEFINITION (EventGroup)
+#include EFI_GUID_DEFINITION (EventLegacyBios)
+#include EFI_PROTOCOL_DEFINITION (CpuIo)
+#include EFI_PROTOCOL_DEFINITION (FirmwareVolume)
+#include EFI_PROTOCOL_DEFINITION (FirmwareVolume2) //;;## ...AMI_OVERRIDE... Support PI1.x
+#include EFI_PROTOCOL_DEFINITION (FirmwareVolumeBlock)
+#include EFI_PROTOCOL_DEFINITION (FvbExtension)
+#include "ProcDep.h"
+
+typedef struct {
+ EFI_HANDLE Handle;
+ EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb;
+ EFI_FVB_EXTENSION_PROTOCOL *FvbExtension;
+} FVB_ENTRY;
+
+//
+// Driver Lib Globals.
+//
+extern EFI_BOOT_SERVICES *gBS;
+extern EFI_SYSTEM_TABLE *gST;
+extern EFI_DXE_SERVICES *gDS;
+extern UINTN gRtErrorLevel;
+extern FVB_ENTRY *mFvbEntry;
+
+VOID
+EFIAPI
+EfiRuntimeLibFvbVirtualNotifyEvent (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+/*++
+
+Routine Description:
+
+ Notify function to convert pointers to Fvb functions after ExitBootServices
+
+Arguments:
+
+ Event - Event whose notification function is being invoked.
+ Context - Pointer to the notification function¡¯s context, which is
+ implementation-dependent.
+
+Returns:
+
+ None
+
+--*/
+;
+
+EFI_STATUS
+EfiInitializeRuntimeDriverLib (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable,
+ IN EFI_EVENT_NOTIFY RuntimeNotifyEventHandler
+ )
+/*++
+
+Routine Description:
+
+ Intialize Runtime Driver Lib if it has not yet been initialized.
+
+Arguments:
+
+ ImageHandle - The firmware allocated handle for the EFI image.
+
+ SystemTable - A pointer to the EFI System Table.
+
+ RuntimeNotifyEventHandler - Virtual address change notification event
+
+Returns:
+
+ EFI_STATUS always returns EFI_SUCCESS
+
+--*/
+;
+
+EFI_STATUS
+EfiShutdownRuntimeDriverLib (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ This routine will free some resources which have been allocated in
+ EfiInitializeRuntimeDriverLib(). If a runtime driver exits with an error,
+ it must call this routine to free the allocated resource before the exiting.
+
+Arguments:
+
+ None
+
+Returns:
+
+ EFI_SUCCESS - Shotdown the Runtime Driver Lib successfully
+ EFI_UNSUPPORTED - Runtime Driver lib was not initialized at all
+
+--*/
+;
+
+EFI_STATUS
+EfiInitializeSmmDriverLib (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+/*++
+
+Routine Description:
+
+ Intialize Smm Driver Lib if it has not yet been initialized.
+
+Arguments:
+
+ ImageHandle - The firmware allocated handle for the EFI image.
+
+ SystemTable - A pointer to the EFI System Table.
+
+Returns:
+
+ EFI_STATUS always returns EFI_SUCCESS
+
+--*/
+;
+
+EFI_STATUS
+EfiLibGetSystemConfigurationTable (
+ IN EFI_GUID *TableGuid,
+ IN OUT VOID **Table
+ )
+/*++
+
+Routine Description:
+
+ Return the EFI 1.0 System Tabl entry with TableGuid
+
+Arguments:
+
+ TableGuid - Name of entry to return in the system table
+ Table - Pointer in EFI system table associated with TableGuid
+
+Returns:
+
+ EFI_SUCCESS - Table returned;
+ EFI_NOT_FOUND - TableGuid not in EFI system table
+
+--*/
+;
+
+BOOLEAN
+EfiAtRuntime (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Am I at runtime?
+
+Arguments:
+
+ None
+
+Returns:
+
+ TRUE - At runtime
+ FALSE - Not at runtime
+
+--*/
+;
+
+BOOLEAN
+EfiGoneVirtual (
+ VOID
+ )
+/*++
+
+Routine Description:
+ Return TRUE if SetVirtualAddressMap () has been called
+
+Arguments:
+ NONE
+
+Returns:
+ TRUE - If SetVirtualAddressMap () has been called
+ FALSE - If SetVirtualAddressMap () has not been called
+
+--*/
+;
+
+EFI_STATUS
+EfiLibGetSystemConfigurationTable (
+ IN EFI_GUID *TableGuid,
+ IN OUT VOID **Table
+ )
+/*++
+
+
+
+Routine Description:
+
+
+
+ Get table from configuration table by name
+
+
+
+Arguments:
+
+
+
+ TableGuid - Table name to search
+
+
+
+ Table - Pointer to the table caller wants
+
+
+
+Returns:
+
+
+
+ EFI_NOT_FOUND - Not found the table
+
+
+
+ EFI_SUCCESS - Found the table
+
+
+
+--*/
+
+;
+
+EFI_EVENT
+RtEfiLibCreateProtocolNotifyEvent (
+ IN EFI_GUID *ProtocolGuid,
+ IN EFI_TPL NotifyTpl,
+ IN EFI_EVENT_NOTIFY NotifyFunction,
+ IN VOID *NotifyContext,
+ OUT VOID **Registration
+ )
+/*++
+
+Routine Description:
+
+ Create a protocol notification event and return it.
+
+Arguments:
+
+ ProtocolGuid - Protocol to register notification event on.
+
+ NotifyTpl - Maximum TPL to single the NotifyFunction.
+
+ NotifyFunction - EFI notification routine.
+
+ NotifyContext - Context passed into Event when it is created.
+
+ Registration - Registration key returned from RegisterProtocolNotify().
+
+Returns:
+
+ The EFI_EVENT that has been registered to be signaled when a ProtocolGuid
+ is added to the system.
+
+--*/
+;
+
+//
+// Lock.c
+//
+typedef struct {
+ EFI_TPL Tpl;
+ EFI_TPL OwnerTpl;
+ UINTN Lock;
+} EFI_LOCK;
+
+VOID
+EfiInitializeLock (
+ IN OUT EFI_LOCK *Lock,
+ IN EFI_TPL Priority
+ )
+/*++
+
+Routine Description:
+
+ Initialize a basic mutual exclusion lock. Each lock
+ provides mutual exclusion access at it's task priority
+ level. Since there is no-premption (at any TPL) or
+ multiprocessor support, acquiring the lock only consists
+ of raising to the locks TPL.
+
+ Note on a check build ASSERT()s are used to ensure proper
+ lock usage.
+
+Arguments:
+
+ Lock - The EFI_LOCK structure to initialize
+
+ Priority - The task priority level of the lock
+
+
+Returns:
+
+ An initialized Efi Lock structure.
+
+--*/
+;
+
+//
+// Macro to initialize the state of a lock when a lock variable is declared
+//
+#define EFI_INITIALIZE_LOCK_VARIABLE(Tpl) {Tpl,0,0}
+
+
+VOID
+EfiAcquireLock (
+ IN EFI_LOCK *Lock
+ )
+/*++
+
+Routine Description:
+
+ Raising to the task priority level of the mutual exclusion
+ lock, and then acquires ownership of the lock.
+
+Arguments:
+
+ Lock - The lock to acquire
+
+Returns:
+
+ Lock owned
+
+--*/
+;
+
+EFI_STATUS
+EfiAcquireLockOrFail (
+ IN EFI_LOCK *Lock
+ )
+/*++
+
+Routine Description:
+
+ Initialize a basic mutual exclusion lock. Each lock
+ provides mutual exclusion access at it's task priority
+ level. Since there is no-premption (at any TPL) or
+ multiprocessor support, acquiring the lock only consists
+ of raising to the locks TPL.
+
+Arguments:
+
+ Lock - The EFI_LOCK structure to initialize
+
+Returns:
+
+ EFI_SUCCESS - Lock Owned.
+ EFI_ACCESS_DENIED - Reentrant Lock Acquisition, Lock not Owned.
+
+--*/
+;
+
+VOID
+EfiReleaseLock (
+ IN EFI_LOCK *Lock
+ )
+/*++
+
+Routine Description:
+
+ Releases ownership of the mutual exclusion lock, and
+ restores the previous task priority level.
+
+Arguments:
+
+ Lock - The lock to release
+
+Returns:
+
+ None
+
+--*/
+;
+
+#define EfiCopyMem EfiCommonLibCopyMem
+#define EfiSetMem EfiCommonLibSetMem
+#define EfiZeroMem EfiCommonLibZeroMem
+
+INTN
+EfiCompareMem (
+ IN VOID *MemOne,
+ IN VOID *MemTwo,
+ IN UINTN Len
+ )
+/*++
+
+Routine Description:
+
+ Compares two memory buffers of a given length.
+
+Arguments:
+
+ MemOne - First memory buffer
+
+ MemTwo - Second memory buffer
+
+ Len - Length of Mem1 and Mem2 memory regions to compare
+
+Returns:
+
+ = 0 if MemOne == MemTwo
+
+ > 0 if MemOne > MemTwo
+
+ < 0 if MemOne < MemTwo
+
+--*/
+;
+
+//
+// Debug.c init
+//
+EFI_STATUS
+EfiDebugAssertInit (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Locate Debug Assert Protocol and set as mDebugAssert
+
+Arguments:
+
+ None
+
+Returns:
+
+ Status code
+
+--*/
+;
+
+//
+// Wrapper for EFI runtime functions
+//
+VOID
+EfiResetSystem (
+ IN EFI_RESET_TYPE ResetType,
+ IN EFI_STATUS ResetStatus,
+ IN UINTN DataSize,
+ IN CHAR16 *ResetData
+ )
+/*++
+
+Routine Description:
+
+ Resets the entire platform.
+
+Arguments:
+
+ ResetType - The type of reset to perform.
+ ResetStatus - The status code for the reset.
+ DataSize - The size, in bytes, of ResetData.
+ ResetData - A data buffer that includes a Null-terminated Unicode string, optionally
+ followed by additional binary data.
+
+Returns:
+
+ None
+
+--*/
+;
+
+EFI_STATUS
+EfiGetNextHighMonotonicCount (
+ OUT UINT32 *HighCount
+ )
+/*++
+
+Routine Description:
+
+ Returns the next high 32 bits of the platform¡¯s monotonic counter.
+
+Arguments:
+
+ HighCount - Pointer to returned value.
+
+Returns:
+
+ Status code
+
+--*/
+;
+
+EFI_STATUS
+EfiGetTime (
+ OUT EFI_TIME *Time,
+ OUT EFI_TIME_CAPABILITIES *Capabilities
+ )
+/*++
+
+Routine Description:
+
+ Returns the current time and date information, and the time-keeping
+ capabilities of the hardware platform.
+
+Arguments:
+
+ Time - A pointer to storage to receive a snapshot of the current time.
+ Capabilities - An optional pointer to a buffer to receive the real time clock device¡¯s
+ capabilities.
+
+Returns:
+
+ Status code
+
+--*/
+;
+
+EFI_STATUS
+EfiSetTime (
+ OUT EFI_TIME *Time
+ )
+/*++
+
+Routine Description:
+
+ Sets the current local time and date information.
+
+Arguments:
+
+ Time - A pointer to the current time.
+
+Returns:
+
+ Status code
+
+--*/
+;
+
+EFI_STATUS
+EfiGetWakeupTime (
+ OUT BOOLEAN *Enabled,
+ OUT BOOLEAN *Pending,
+ OUT EFI_TIME *Time
+ )
+/*++
+
+Routine Description:
+
+ Returns the current wakeup alarm clock setting.
+
+Arguments:
+
+ Enabled - Indicates if the alarm is currently enabled or disabled.
+ Pending - Indicates if the alarm signal is pending and requires acknowledgement.
+ Time - The current alarm setting.
+
+Returns:
+
+ Status code
+
+--*/
+;
+
+EFI_STATUS
+EfiSetWakeupTime (
+ IN BOOLEAN Enable,
+ IN EFI_TIME *Time
+ )
+/*++
+
+Routine Description:
+
+ Sets the system wakeup alarm clock time.
+
+Arguments:
+
+ Enable - Enable or disable the wakeup alarm.
+ Time - If Enable is TRUE, the time to set the wakeup alarm for.
+ If Enable is FALSE, then this parameter is optional, and may be NULL.
+
+Returns:
+
+ Status code
+
+--*/
+;
+
+EFI_STATUS
+EfiGetVariable (
+ IN CHAR16 *VariableName,
+ IN EFI_GUID * VendorGuid,
+ OUT UINT32 *Attributes OPTIONAL,
+ IN OUT UINTN *DataSize,
+ OUT VOID *Data
+ )
+/*++
+
+Routine Description:
+
+ Returns the value of a variable.
+
+Arguments:
+
+ VariableName - A Null-terminated Unicode string that is the name of the
+ vendor¡¯s variable.
+ VendorGuid - A unique identifier for the vendor.
+ Attributes - If not NULL, a pointer to the memory location to return the
+ attributes bitmask for the variable.
+ DataSize - On input, the size in bytes of the return Data buffer.
+ On output the size of data returned in Data.
+ Data - The buffer to return the contents of the variable.
+
+Returns:
+
+ Status code
+
+--*/
+;
+
+EFI_STATUS
+EfiGetNextVariableName (
+ IN OUT UINTN *VariableNameSize,
+ IN OUT CHAR16 *VariableName,
+ IN OUT EFI_GUID *VendorGuid
+ )
+/*++
+
+Routine Description:
+
+ Enumerates the current variable names.
+
+Arguments:
+
+ VariableNameSize - The size of the VariableName buffer.
+ VariableName - On input, supplies the last VariableName that was returned
+ by GetNextVariableName().
+ On output, returns the Nullterminated Unicode string of the
+ current variable.
+ VendorGuid - On input, supplies the last VendorGuid that was returned by
+ GetNextVariableName().
+ On output, returns the VendorGuid of the current variable.
+
+Returns:
+
+ Status code
+
+--*/
+;
+
+EFI_STATUS
+EfiSetVariable (
+ IN CHAR16 *VariableName,
+ IN EFI_GUID *VendorGuid,
+ IN UINT32 Attributes,
+ IN UINTN DataSize,
+ IN VOID *Data
+ )
+/*++
+
+Routine Description:
+
+ Sets the value of a variable.
+
+Arguments:
+
+ VariableName - A Null-terminated Unicode string that is the name of the
+ vendor¡¯s variable.
+ VendorGuid - A unique identifier for the vendor.
+ Attributes - Attributes bitmask to set for the variable.
+ DataSize - The size in bytes of the Data buffer.
+ Data - The contents for the variable.
+
+Returns:
+
+ Status code
+
+--*/
+;
+
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+
+EFI_STATUS
+EfiQueryVariableInfo (
+ IN UINT32 Attributes,
+ OUT UINT64 *MaximumVariableStorageSize,
+ OUT UINT64 *RemainingVariableStorageSize,
+ OUT UINT64 *MaximumVariableSize
+ )
+/*++
+
+Routine Description:
+
+ This code returns information about the EFI variables.
+
+Arguments:
+
+ Attributes Attributes bitmask to specify the type of variables
+ on which to return information.
+ MaximumVariableStorageSize Pointer to the maximum size of the storage space available
+ for the EFI variables associated with the attributes specified.
+ RemainingVariableStorageSize Pointer to the remaining size of the storage space available
+ for the EFI variables associated with the attributes specified.
+ MaximumVariableSize Pointer to the maximum size of the individual EFI variables
+ associated with the attributes specified.
+
+Returns:
+
+ Status code
+
+--*/
+;
+#endif
+
+
+EFI_STATUS
+EfiReportStatusCode (
+ IN EFI_STATUS_CODE_TYPE CodeType,
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN UINT32 Instance,
+ IN EFI_GUID * CallerId,
+ IN EFI_STATUS_CODE_DATA * Data OPTIONAL
+ )
+/*++
+
+Routine Description:
+
+ Status Code reporter
+
+Arguments:
+
+ CodeType - Type of Status Code.
+
+ Value - Value to output for Status Code.
+
+ Instance - Instance Number of this status code.
+
+ CallerId - ID of the caller of this status code.
+
+ Data - Optional data associated with this status code.
+
+Returns:
+
+ Status code
+
+--*/
+;
+
+EFI_STATUS
+EfiConvertPointer (
+ IN UINTN DebugDisposition,
+ IN OUT VOID *Address
+ )
+/*++
+
+Routine Description:
+
+ Determines the new virtual address that is to be used on subsequent memory accesses.
+
+Arguments:
+
+ DebugDisposition - Supplies type information for the pointer being converted.
+ Address - A pointer to a pointer that is to be fixed to be the value needed
+ for the new virtual address mappings being applied.
+
+Returns:
+
+ Status code
+
+--*/
+;
+
+EFI_STATUS
+EfiConvertList (
+ IN UINTN DebugDisposition,
+ IN OUT EFI_LIST_ENTRY *ListHead
+ )
+/*++
+
+Routine Description:
+
+ Conver the standard Lib double linked list to a virtual mapping.
+
+Arguments:
+
+ DebugDisposition - Argument to EfiConvertPointer (EFI 1.0 API)
+
+ ListHead - Head of linked list to convert
+
+Returns:
+
+ EFI_SUCCESS
+
+--*/
+;
+
+//
+// Base IO Class Functions
+//
+EFI_STATUS
+EfiIoRead (
+ IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
+ IN UINT64 Address,
+ IN UINTN Count,
+ IN OUT VOID *Buffer
+ )
+/*++
+
+Routine Description:
+ Perform an IO read into Buffer.
+
+Arguments:
+ Width - Width of read transaction, and repeat operation to use
+ Address - IO address to read
+ Count - Number of times to read the IO address.
+ Buffer - Buffer to read data into. size is Width * Count
+
+Returns:
+ Status code
+
+--*/
+;
+
+UINT8
+IoRead8 (
+ IN UINT64 Address
+ )
+/*++
+
+Routine Description:
+ Do a one byte IO read
+
+Arguments:
+ Address - IO address to read
+
+Returns:
+ Data read
+
+--*/
+;
+
+UINT16
+IoRead16 (
+ IN UINT64 Address
+ )
+/*++
+
+Routine Description:
+ Do a two byte IO read
+
+Arguments:
+ Address - IO address to read
+
+Returns:
+ Data read
+
+--*/
+;
+
+UINT32
+IoRead32 (
+ IN UINT64 Address
+ )
+/*++
+
+Routine Description:
+ Do a four byte IO read
+
+Arguments:
+ Address - IO address to read
+
+Returns:
+ Data read
+
+--*/
+;
+
+EFI_STATUS
+EfiIoWrite (
+ IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
+ IN UINT64 Address,
+ IN UINTN Count,
+ IN OUT VOID *Buffer
+ )
+/*++
+
+Routine Description:
+ Perform an IO write into Buffer.
+
+Arguments:
+ Width - Width of write transaction, and repeat operation to use
+ Address - IO address to write
+ Count - Number of times to write the IO address.
+ Buffer - Buffer to write data from. size is Width * Count
+
+Returns:
+ Status code
+
+--*/
+;
+
+VOID
+IoWrite8 (
+ IN UINT64 Address,
+ IN UINT8 Data
+ )
+/*++
+
+Routine Description:
+ Do a one byte IO write
+
+Arguments:
+ Address - IO address to write
+ Data - Data to write to Address
+
+Returns:
+ NONE
+
+--*/
+;
+
+VOID
+IoWrite16 (
+ IN UINT64 Address,
+ IN UINT16 Data
+ )
+/*++
+
+Routine Description:
+ Do a two byte IO write
+
+Arguments:
+ Address - IO address to write
+ Data - Data to write to Address
+
+Returns:
+ NONE
+
+--*/
+;
+
+VOID
+IoWrite32 (
+ IN UINT64 Address,
+ IN UINT32 Data
+ )
+/*++
+
+Routine Description:
+ Do a four byte IO write
+
+Arguments:
+ Address - IO address to write
+ Data - Data to write to Address
+
+Returns:
+ NONE
+
+--*/
+;
+
+EFI_STATUS
+EfiMemRead (
+ IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
+ IN UINT64 Address,
+ IN UINTN Count,
+ IN OUT VOID *Buffer
+ )
+/*++
+
+Routine Description:
+ Perform a Memory mapped IO read into Buffer.
+
+Arguments:
+ Width - Width of each read transaction.
+ Address - Memory mapped IO address to read
+ Count - Number of Width quanta to read
+ Buffer - Buffer to read data into. size is Width * Count
+
+Returns:
+ Status code
+
+--*/
+;
+
+UINT8
+MemRead8 (
+ IN UINT64 Address
+ )
+/*++
+
+Routine Description:
+ Do a one byte Memory mapped IO read
+
+Arguments:
+ Address - Memory mapped IO address to read
+
+Returns:
+ Data read
+
+--*/
+;
+
+UINT16
+MemRead16 (
+ IN UINT64 Address
+ )
+/*++
+
+Routine Description:
+ Do a two byte Memory mapped IO read
+
+Arguments:
+ Address - Memory mapped IO address to read
+
+Returns:
+ Data read
+
+--*/
+;
+
+UINT32
+MemRead32 (
+ IN UINT64 Address
+ )
+/*++
+
+Routine Description:
+ Do a four byte Memory mapped IO read
+
+Arguments:
+ Address - Memory mapped IO address to read
+
+Returns:
+ Data read
+
+--*/
+;
+
+UINT64
+MemRead64 (
+ IN UINT64 Address
+ )
+/*++
+
+Routine Description:
+ Do a eight byte Memory mapped IO read
+
+Arguments:
+ Address - Memory mapped IO address to read
+
+Returns:
+ Data read
+
+--*/
+;
+
+EFI_STATUS
+EfiMemWrite (
+ IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
+ IN UINT64 Address,
+ IN UINTN Count,
+ IN OUT VOID *Buffer
+ )
+/*++
+
+Routine Description:
+ Perform a memory mapped IO write into Buffer.
+
+Arguments:
+ Width - Width of write transaction, and repeat operation to use
+ Address - IO address to write
+ Count - Number of times to write the IO address.
+ Buffer - Buffer to write data from. size is Width * Count
+
+Returns:
+ Status code
+
+--*/
+;
+
+VOID
+MemWrite8 (
+ IN UINT64 Address,
+ IN UINT8 Data
+ )
+/*++
+
+Routine Description:
+ Do a one byte Memory mapped IO write
+
+Arguments:
+ Address - Memory mapped IO address to write
+ Data - Data to write to Address
+
+Returns:
+ NONE
+
+--*/
+;
+
+VOID
+MemWrite16 (
+ IN UINT64 Address,
+ IN UINT16 Data
+ )
+/*++
+
+Routine Description:
+ Do a two byte Memory mapped IO write
+
+Arguments:
+ Address - Memory mapped IO address to write
+ Data - Data to write to Address
+
+Returns:
+ NONE
+
+--*/
+;
+
+VOID
+MemWrite32 (
+ IN UINT64 Address,
+ IN UINT32 Data
+ )
+/*++
+
+Routine Description:
+ Do a four byte Memory mapped IO write
+
+Arguments:
+ Address - Memory mapped IO address to write
+ Data - Data to write to Address
+
+Returns:
+ NONE
+
+--*/
+;
+
+VOID
+MemWrite64 (
+ IN UINT64 Address,
+ IN UINT64 Data
+ )
+/*++
+
+Routine Description:
+ Do a eight byte Memory mapped IO write
+
+Arguments:
+ Address - Memory mapped IO address to write
+ Data - Data to write to Address
+
+Returns:
+ NONE
+
+--*/
+;
+
+//
+// Platform specific functions
+//
+UINT8
+PciRead8 (
+ UINT8 Segment,
+ UINT8 Bus,
+ UINT8 DevFunc,
+ UINT8 Register
+ )
+/*++
+
+Routine Description:
+ Perform an one byte PCI config cycle read
+
+Arguments:
+ Segment - PCI Segment ACPI _SEG
+ Bus - PCI Bus
+ DevFunc - PCI Device(7:3) and Func(2:0)
+ Register - PCI config space register
+
+Returns:
+ Data read from PCI config space
+
+--*/
+;
+
+UINT16
+PciRead16 (
+ UINT8 Segment,
+ UINT8 Bus,
+ UINT8 DevFunc,
+ UINT8 Register
+ )
+/*++
+
+Routine Description:
+ Perform an two byte PCI config cycle read
+
+Arguments:
+ Segment - PCI Segment ACPI _SEG
+ Bus - PCI Bus
+ DevFunc - PCI Device(7:3) and Func(2:0)
+ Register - PCI config space register
+
+Returns:
+ Data read from PCI config space
+
+--*/
+;
+
+UINT32
+PciRead32 (
+ UINT8 Segment,
+ UINT8 Bus,
+ UINT8 DevFunc,
+ UINT8 Register
+ )
+/*++
+
+Routine Description:
+ Perform an four byte PCI config cycle read
+
+Arguments:
+ Segment - PCI Segment ACPI _SEG
+ Bus - PCI Bus
+ DevFunc - PCI Device(7:3) and Func(2:0)
+ Register - PCI config space register
+
+Returns:
+ Data read from PCI config space
+
+--*/
+;
+
+VOID
+PciWrite8 (
+ UINT8 Segment,
+ UINT8 Bus,
+ UINT8 DevFunc,
+ UINT8 Register,
+ UINT8 Data
+ )
+/*++
+
+Routine Description:
+ Perform an one byte PCI config cycle write
+
+Arguments:
+ Segment - PCI Segment ACPI _SEG
+ Bus - PCI Bus
+ DevFunc - PCI Device(7:3) and Func(2:0)
+ Register - PCI config space register
+ Data - Data to write
+
+Returns:
+ NONE
+
+--*/
+;
+
+VOID
+PciWrite16 (
+ UINT8 Segment,
+ UINT8 Bus,
+ UINT8 DevFunc,
+ UINT8 Register,
+ UINT16 Data
+ )
+/*++
+
+Routine Description:
+ Perform an two byte PCI config cycle write
+
+Arguments:
+ Segment - PCI Segment ACPI _SEG
+ Bus - PCI Bus
+ DevFunc - PCI Device(7:3) and Func(2:0)
+ Register - PCI config space register
+ Data - Data to write
+
+Returns:
+ NONE
+
+--*/
+;
+
+VOID
+PciWrite32 (
+ UINT8 Segment,
+ UINT8 Bus,
+ UINT8 DevFunc,
+ UINT8 Register,
+ UINT32 Data
+ )
+/*++
+
+Routine Description:
+ Perform an four byte PCI config cycle write
+
+Arguments:
+ Segment - PCI Segment ACPI _SEG
+ Bus - PCI Bus
+ DevFunc - PCI Device(7:3) and Func(2:0)
+ Register - PCI config space register
+ Data - Data to write
+
+Returns:
+ NONE
+
+--*/
+;
+
+VOID
+EfiStall (
+ IN UINTN Microseconds
+ )
+/*++
+
+Routine Description:
+ Delay for at least the request number of microseconds
+
+Arguments:
+ Microseconds - Number of microseconds to delay.
+
+Returns:
+ NONE
+
+--*/
+;
+
+//
+// FVB Services.
+//
+EFI_STATUS
+EfiFvbInitialize (
+ VOID
+ )
+/*++
+
+Routine Description:
+ Initialize globals and register Fvb Protocol notification function.
+
+Arguments:
+ None
+
+Returns:
+ EFI_SUCCESS
+
+--*/
+;
+
+EFI_STATUS
+EfiFvbShutdown (
+ VOID
+ )
+/*++
+
+Routine Description:
+ Release resources allocated in EfiFvbInitialize.
+
+Arguments:
+ None
+
+Returns:
+ EFI_SUCCESS
+
+--*/
+;
+
+EFI_STATUS
+EfiFvbReadBlock (
+ IN UINTN Instance,
+ IN EFI_LBA Lba,
+ IN UINTN Offset,
+ IN OUT UINTN *NumBytes,
+ IN UINT8 *Buffer
+ )
+/*++
+
+Routine Description:
+ Reads specified number of bytes into a buffer from the specified block
+
+Arguments:
+ Instance - The FV instance to be read from
+ Lba - The logical block address to be read from
+ Offset - Offset into the block at which to begin reading
+ NumBytes - Pointer that on input contains the total size of
+ the buffer. On output, it contains the total number
+ of bytes read
+ Buffer - Pointer to a caller allocated buffer that will be
+ used to hold the data read
+
+Returns:
+ Status code
+
+--*/
+;
+
+EFI_STATUS
+EfiFvbWriteBlock (
+ IN UINTN Instance,
+ IN EFI_LBA Lba,
+ IN UINTN Offset,
+ IN OUT UINTN *NumBytes,
+ IN UINT8 *Buffer
+ )
+/*++
+
+Routine Description:
+ Writes specified number of bytes from the input buffer to the block
+
+Arguments:
+ Instance - The FV instance to be written to
+ Lba - The starting logical block index to write to
+ Offset - Offset into the block at which to begin writing
+ NumBytes - Pointer that on input contains the total size of
+ the buffer. On output, it contains the total number
+ of bytes actually written
+ Buffer - Pointer to a caller allocated buffer that contains
+ the source for the write
+
+Returns:
+ Status code
+
+--*/
+;
+
+EFI_STATUS
+EfiFvbEraseBlock (
+ IN UINTN Instance,
+ IN EFI_LBA Lba
+ )
+/*++
+
+Routine Description:
+ Erases and initializes a firmware volume block
+
+Arguments:
+ Instance - The FV instance to be erased
+ Lba - The logical block index to be erased
+
+Returns:
+ Status code
+
+--*/
+;
+
+EFI_STATUS
+EfiFvbGetVolumeAttributes (
+ IN UINTN Instance,
+ OUT EFI_FVB_ATTRIBUTES *Attributes
+ )
+/*++
+
+Routine Description:
+ Retrieves attributes, insures positive polarity of attribute bits, returns
+ resulting attributes in output parameter
+
+Arguments:
+ Instance - The FV instance whose attributes is going to be
+ returned
+ Attributes - Output buffer which contains attributes
+
+Returns:
+ Status code
+
+--*/
+;
+
+EFI_STATUS
+EfiFvbSetVolumeAttributes (
+ IN UINTN Instance,
+ IN EFI_FVB_ATTRIBUTES Attributes
+ )
+/*++
+
+Routine Description:
+ Modifies the current settings of the firmware volume according to the
+ input parameter.
+
+Arguments:
+ Instance - The FV instance whose attributes is going to be
+ modified
+ Attributes - It is a pointer to EFI_FVB_ATTRIBUTES
+ containing the desired firmware volume settings.
+
+Returns:
+ Status code
+
+--*/
+;
+
+EFI_STATUS
+EfiFvbGetPhysicalAddress (
+ IN UINTN Instance,
+ OUT EFI_PHYSICAL_ADDRESS *Address
+ )
+/*++
+
+Routine Description:
+ Retrieves the physical address of a memory mapped FV
+
+Arguments:
+ Instance - The FV instance whose base address is going to be
+ returned
+ Address - Pointer to a caller allocated EFI_PHYSICAL_ADDRESS
+ that on successful return, contains the base address
+ of the firmware volume.
+
+Returns:
+ Status code
+
+--*/
+;
+
+EFI_STATUS
+EfiFvbGetBlockSize (
+ IN UINTN Instance,
+ IN EFI_LBA Lba,
+ OUT UINTN *BlockSize,
+ OUT UINTN *NumOfBlocks
+ )
+/*++
+
+Routine Description:
+ Retrieve the size of a logical block
+
+Arguments:
+ Instance - The FV instance whose block size is going to be
+ returned
+ Lba - Indicates which block to return the size for.
+ BlockSize - A pointer to a caller allocated UINTN in which
+ the size of the block is returned
+ NumOfBlocks - a pointer to a caller allocated UINTN in which the
+ number of consecutive blocks starting with Lba is
+ returned. All blocks in this range have a size of
+ BlockSize
+
+Returns:
+ EFI_SUCCESS - The firmware volume was read successfully and
+ contents are in Buffer
+
+--*/
+;
+EFI_STATUS
+EfiFvbEraseCustomBlockRange (
+ IN UINTN Instance,
+ IN EFI_LBA StartLba,
+ IN UINTN OffsetStartLba,
+ IN EFI_LBA LastLba,
+ IN UINTN OffsetLastLba
+ )
+/*++
+
+Routine Description:
+ Erases and initializes a specified range of a firmware volume
+
+Arguments:
+ Instance - The FV instance to be erased
+ StartLba - The starting logical block index to be erased
+ OffsetStartLba - Offset into the starting block at which to
+ begin erasing
+ LastLba - The last logical block index to be erased
+ OffsetLastLba - Offset into the last block at which to end erasing
+
+Returns:
+ Status code
+
+--*/
+;
+
+EFI_STATUS
+EfiCpuFlushCache (
+ IN EFI_PHYSICAL_ADDRESS Start,
+ IN UINT64 Length
+ )
+/*++
+
+Routine Description:
+
+ Flush cache with specified range.
+
+Arguments:
+
+ Start - Start address
+ Length - Length in bytes
+
+Returns:
+
+ Status code
+
+--*/
+;
+
+EFI_STATUS
+EFIAPI
+RtEfiCreateEventLegacyBoot (
+ IN EFI_TPL NotifyTpl,
+ IN EFI_EVENT_NOTIFY NotifyFunction,
+ IN VOID *NotifyContext,
+ OUT EFI_EVENT *LegacyBootEvent
+ )
+/*++
+
+Routine Description:
+ Create a Legacy Boot Event.
+ Tiano extended the CreateEvent Type enum to add a legacy boot event type.
+ This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was
+ added and now it's possible to not voilate the UEFI specification by
+ declaring a GUID for the legacy boot event class. This library supports
+ the R8.5/EFI 1.10 form and R8.6/UEFI 2.0 form and allows common code to
+ work both ways.
+
+Arguments:
+ LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex)
+
+Returns:
+ EFI_SUCCESS Event was created.
+ Other Event was not created.
+
+--*/
+;
+
+EFI_STATUS
+EFIAPI
+RtEfiCreateEventReadyToBoot (
+ IN EFI_TPL NotifyTpl,
+ IN EFI_EVENT_NOTIFY NotifyFunction,
+ IN VOID *NotifyContext,
+ OUT EFI_EVENT *ReadyToBootEvent
+ )
+/*++
+
+Routine Description:
+ Create a Read to Boot Event.
+
+ Tiano extended the CreateEvent Type enum to add a ready to boot event type.
+ This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was
+ added and now it's possible to not voilate the UEFI specification and use
+ the ready to boot event class defined in UEFI 2.0. This library supports
+ the R8.5/EFI 1.10 form and R8.6/UEFI 2.0 form and allows common code to
+ work both ways.
+
+Arguments:
+ ReadyToBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex)
+
+Return:
+ EFI_SUCCESS - Event was created.
+ Other - Event was not created.
+
+--*/
+;
+
+#endif
diff --git a/EDK/Foundation/Library/Dxe/Include/EfiScriptLib.h b/EDK/Foundation/Library/Dxe/Include/EfiScriptLib.h
new file mode 100644
index 0000000..53b523f
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/Include/EfiScriptLib.h
@@ -0,0 +1,570 @@
+/*++
+
+Copyright (c) 2004 - 2008, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiScriptLib.h
+
+Abstract:
+
+
+--*/
+
+#ifndef _EFI_SCRIPT_LIB_H_
+#define _EFI_SCRIPT_LIB_H_
+
+#include "Tiano.h"
+#include "EfiCommonLib.h"
+#include "EfiBootScript.h"
+#include EFI_PROTOCOL_DEFINITION (BootScriptSave)
+
+
+EFI_STATUS
+EFIAPI
+BootScriptSaveInitialize (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+/*++
+
+Routine Description:
+
+ Intialize Boot Script Lib if it has not yet been initialized.
+
+Arguments:
+
+ ImageHandle - The firmware allocated handle for the EFI image.
+
+ SystemTable - A pointer to the EFI System Table.
+
+Returns:
+
+ EFI_STATUS always returns EFI_SUCCESS
+
+--*/
+;
+
+EFI_STATUS
+EFIAPI
+BootScriptSaveIoWrite (
+ IN UINT16 TableName,
+ IN EFI_BOOT_SCRIPT_WIDTH Width,
+ IN UINT64 Address,
+ IN UINTN Count,
+ IN VOID *Buffer
+ )
+/*++
+
+Routine Description:
+
+ Save I/O write to boot script with opcode EFI_BOOT_SCRIPT_IO_WRITE_OPCODE
+
+Arguments:
+
+ TableName - Desired boot script table
+
+ Width - The width of the I/O operations.
+
+ Address - The base address of the I/O operations.
+
+ Count - The number of I/O operations to perform.
+
+ Buffer - The source buffer from which to write data.
+
+Returns:
+
+ EFI_NOT_FOUND - BootScriptSave Protocol not exist.
+
+ EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
+
+--*/
+;
+
+EFI_STATUS
+EFIAPI
+BootScriptSaveIoReadWrite (
+ IN UINT16 TableName,
+ IN EFI_BOOT_SCRIPT_WIDTH Width,
+ IN UINT64 Address,
+ IN VOID *Data,
+ IN VOID *DataMask
+ )
+/*++
+
+Routine Description:
+
+ Save I/O modify to boot script with opcode EFI_BOOT_SCRIPT_IO_READ_WRITE_OPCODE
+
+Arguments:
+
+ TableName - Desired boot script table
+
+ Width - The width of the I/O operations.
+
+ Address - The base address of the I/O operations.
+
+ Data - A pointer to the data to be OR-ed.
+
+ DataMask - A pointer to the data mask to be AND-ed with the data read from the register.
+
+Returns:
+
+ EFI_NOT_FOUND - BootScriptSave Protocol not exist.
+
+ EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
+
+--*/
+;
+
+EFI_STATUS
+EFIAPI
+BootScriptSaveMemWrite (
+ IN UINT16 TableName,
+ IN EFI_BOOT_SCRIPT_WIDTH Width,
+ IN UINT64 Address,
+ IN UINTN Count,
+ IN VOID *Buffer
+ )
+/*++
+
+Routine Description:
+
+ Save memory write to boot script with opcode EFI_BOOT_SCRIPT_MEM_WRITE_OPCODE
+
+Arguments:
+
+ TableName - Desired boot script table
+
+ Width - The width of the memory operations.
+
+ Address - The base address of the memory operations.
+
+ Count - The number of memory operations to perform.
+
+ Buffer - The source buffer from which to write the data.
+
+Returns:
+
+ EFI_NOT_FOUND - BootScriptSave Protocol not exist.
+
+ EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
+
+--*/
+;
+
+EFI_STATUS
+EFIAPI
+BootScriptSaveMemReadWrite (
+ IN UINT16 TableName,
+ IN EFI_BOOT_SCRIPT_WIDTH Width,
+ IN UINT64 Address,
+ IN VOID *Data,
+ IN VOID *DataMask
+ )
+/*++
+
+Routine Description:
+
+ Save memory modify to boot script with opcode EFI_BOOT_SCRIPT_MEM_READ_WRITE_OPCODE
+
+Arguments:
+
+ TableName - Desired boot script table
+
+ Width - The width of the memory operations.
+
+ Address - The base address of the memory operations.
+
+ Data - A pointer to the data to be OR-ed.
+
+ DataMask - A pointer to the data mask to be AND-ed with the data read from the register.
+
+Returns:
+
+ EFI_NOT_FOUND - BootScriptSave Protocol not exist.
+
+ EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
+
+--*/
+;
+
+EFI_STATUS
+EFIAPI
+BootScriptSavePciCfgWrite (
+ IN UINT16 TableName,
+ IN EFI_BOOT_SCRIPT_WIDTH Width,
+ IN UINT64 Address,
+ IN UINTN Count,
+ IN VOID *Buffer
+ )
+/*++
+
+Routine Description:
+
+ Save PCI configuration space write operation to boot script with opcode
+ EFI_BOOT_SCRIPT_PCI_CONFIG_WRITE_OPCODE
+
+Arguments:
+
+ TableName - Desired boot script table
+
+ Width - The width of the PCI operations
+
+ Address - The address within the PCI configuration space.
+
+ Count - The number of PCI operations to perform.
+
+ Buffer - The source buffer from which to write the data.
+
+Returns:
+
+ EFI_NOT_FOUND - BootScriptSave Protocol not exist.
+
+ EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
+
+--*/
+;
+
+EFI_STATUS
+EFIAPI
+BootScriptSavePciCfgReadWrite (
+ IN UINT16 TableName,
+ IN EFI_BOOT_SCRIPT_WIDTH Width,
+ IN UINT64 Address,
+ IN VOID *Data,
+ IN VOID *DataMask
+ )
+/*++
+
+Routine Description:
+
+ Save PCI configuration space modify operation to boot script with opcode
+ EFI_BOOT_SCRIPT_PCI_CONFIG_READ_WRITE_OPCODE
+
+Arguments:
+
+ TableName - Desired boot script table
+
+ Width - The width of the PCI operations
+
+ Address - The address within the PCI configuration space.
+
+ Data - A pointer to the data to be OR-ed.
+
+ DataMask - A pointer to the data mask to be AND-ed with the data read from the register.
+
+Returns:
+
+ EFI_NOT_FOUND - BootScriptSave Protocol not exist.
+
+ EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
+
+--*/
+;
+;
+
+EFI_STATUS
+EFIAPI
+BootScriptSaveSmbusExecute (
+ IN UINT16 TableName,
+ IN EFI_SMBUS_DEVICE_ADDRESS SlaveAddress,
+ IN EFI_SMBUS_DEVICE_COMMAND Command,
+ IN EFI_SMBUS_OPERATION Operation,
+ IN BOOLEAN PecCheck,
+ IN UINTN *Length,
+ IN VOID *Buffer
+ )
+/*++
+
+Routine Description:
+
+ Save SMBus command execution to boot script with opcode
+ EFI_BOOT_SCRIPT_SMBUS_EXECUTE_OPCODE
+
+Arguments:
+
+ TableName - Desired boot script table
+ SlaveAddress - The SMBus address for the slave device that the operation is targeting.
+ Command - The command that is transmitted by the SMBus host controller to the
+ SMBus slave device.
+ Operation - Indicates which particular SMBus protocol it will use to execute the
+ SMBus transactions.
+ PecCheck - Defines if Packet Error Code (PEC) checking is required for this operation.
+ Length - A pointer to signify the number of bytes that this operation will do.
+ Buffer - Contains the value of data to execute to the SMBUS slave device.
+
+Returns:
+
+ EFI_NOT_FOUND - BootScriptSave Protocol not exist.
+
+ EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
+
+--*/
+;
+
+EFI_STATUS
+EFIAPI
+BootScriptSaveStall (
+ IN UINT16 TableName,
+ IN UINTN Duration
+ )
+/*++
+
+Routine Description:
+
+ Save execution stall on the processor to boot script with opcode
+ EFI_BOOT_SCRIPT_STALL_OPCODE
+
+Arguments:
+
+ TableName - Desired boot script table
+
+ Duration - Duration in microseconds of the stall.
+
+Returns:
+
+ EFI_NOT_FOUND - BootScriptSave Protocol not exist.
+
+ EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
+
+--*/
+;
+
+EFI_STATUS
+EFIAPI
+BootScriptSaveDispatch (
+ IN UINT16 TableName,
+ IN EFI_PHYSICAL_ADDRESS EntryPoint
+ )
+/*++
+
+Routine Description:
+
+ Save dispatching specified arbitrary code to boot script with opcode
+ EFI_BOOT_SCRIPT_DISPATCH_OPCODE
+
+Arguments:
+
+ TableName - Desired boot script table
+
+ EntryPoint - Entry point of the code to be dispatched.
+
+Returns:
+
+ EFI_NOT_FOUND - BootScriptSave Protocol not exist.
+
+ EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
+
+--*/
+;
+
+EFI_STATUS
+EFIAPI
+BootScriptMemPoll (
+ IN UINT16 TableName,
+ IN EFI_BOOT_SCRIPT_WIDTH Width,
+ IN UINT64 Address,
+ IN VOID *BitMask,
+ IN VOID *BitValue,
+ IN UINTN Duration,
+ IN UINTN LoopTimes
+ )
+/*++
+
+Routine Description:
+ Polling one memory mapping register
+
+Arguments:
+ TableName - Desired boot script table
+
+ Width - The width of the memory operations.
+
+ Address - The base address of the memory operations.
+
+ BitMask - A pointer to the bit mask to be AND-ed with the data read from the register.
+
+ BitValue - A pointer to the data value after to be Masked.
+
+ Duration - Duration in microseconds of the stall.
+
+ LoopTimes - The times of the register polling.
+
+Returns:
+
+ EFI_SUCCESS - The operation was executed successfully
+
+--*/
+;
+
+EFI_STATUS
+EFIAPI
+BootScriptSaveInformation (
+ IN UINT16 TableName,
+ IN UINT32 Length,
+ IN EFI_PHYSICAL_ADDRESS Buffer
+ )
+/*++
+
+Routine Description:
+
+ Save a Information Opcode record in table specified with TableName
+
+Arguments:
+
+ TableName - Desired boot script table
+ Length - Length of information in bytes
+ Buffer - Content of information that will be saved in script table
+
+Returns:
+
+ EFI_NOT_FOUND - BootScriptSave Protocol not exist.
+
+ EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
+
+--*/
+;
+
+EFI_STATUS
+EFIAPI
+BootScriptSaveInformationUnicodeString (
+ IN UINT16 TableName,
+ IN CHAR16 *String
+ )
+/*++
+
+Routine Description:
+
+ Save a Information Opcode record in table specified with TableName, the information
+ is a unicode string.
+
+Arguments:
+
+ TableName - Desired boot script table
+ String - The string that will be saved in script table
+
+Returns:
+
+ EFI_NOT_FOUND - BootScriptSave Protocol not exist.
+
+ EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
+
+--*/
+;
+
+EFI_STATUS
+EFIAPI
+BootScriptSaveInformationAsciiString (
+ IN UINT16 TableName,
+ IN CHAR8 *String
+ )
+/*++
+
+Routine Description:
+
+ Save a Information Opcode record in table specified with TableName, the information
+ is a ascii string.
+
+Arguments:
+
+ TableName - Desired boot script table
+ String - The string that will be saved in script table
+
+Returns:
+
+ EFI_NOT_FOUND - BootScriptSave Protocol not exist.
+
+ EFI_STATUS - BootScriptSave Protocol exist, always returns EFI_SUCCESS
+
+--*/
+;
+
+#ifdef EFI_S3_RESUME
+
+#define INITIALIZE_SCRIPT(ImageHandle, SystemTable) \
+ BootScriptSaveInitialize(ImageHandle, SystemTable)
+
+#define SCRIPT_IO_WRITE(TableName, Width, Address, Count, Buffer) \
+ BootScriptSaveIoWrite(TableName, Width, Address, Count, Buffer)
+
+#define SCRIPT_IO_READ_WRITE(TableName, Width, Address, Data, DataMask) \
+ BootScriptSaveIoReadWrite(TableName, Width, Address, Data, DataMask)
+
+#define SCRIPT_MEM_WRITE(TableName, Width, Address, Count, Buffer) \
+ BootScriptSaveMemWrite(TableName, Width, Address, Count, Buffer)
+
+#define SCRIPT_MEM_WRITE_THIS(TableName, Width, Address, Count) \
+ BootScriptSaveMemWrite(TableName, Width, Address, Count, (VOID*)(UINTN)Address)
+
+#define SCRIPT_MEM_READ_WRITE(TableName, Width, Address, Data, DataMask) \
+ BootScriptSaveMemReadWrite(TableName, Width, Address, Data, DataMask)
+
+#define SCRIPT_PCI_CFG_WRITE(TableName, Width, Address, Count, Buffer) \
+ BootScriptSavePciCfgWrite(TableName, Width, Address, Count, Buffer)
+
+#define SCRIPT_PCI_CFG_READ_WRITE(TableName, Width, Address, Data, DataMask) \
+ BootScriptSavePciCfgReadWrite(TableName, Width, Address, Data, DataMask)
+
+#define SCRIPT_SMBUS_EXECUTE(TableName, SlaveAddress, Command, Operation, PecCheck, Length, Buffer) \
+ BootScriptSaveSmbusExecute(TableName, SlaveAddress, Command, Operation, PecCheck, Length, Buffer)
+
+#define SCRIPT_STALL(TableName, Duration) \
+ BootScriptSaveStall(TableName, Duration)
+
+#define SCRIPT_DISPATCH(TableName, EntryPoint) \
+ BootScriptSaveDispatch(TableName, EntryPoint)
+
+#define SCRIPT_MEM_POLL(TableName, Width, Address, BitMask, BitValue, Duration, LoopTimes) \
+ BootScriptMemPoll(TableName, Width, Address, BitMask, BitValue, Duration, LoopTimes)
+
+#define SCRIPT_INFORMATION(TableName, Length, Buffer) \
+ BootScriptSaveInformation(TableName, Length, Buffer)
+
+#define SCRIPT_INFORMATION_UNICODE_STRING(TableName, String) \
+ BootScriptSaveInformationUnicodeString(TableName, String)
+
+#define SCRIPT_INFORMATION_ASCII_STRING(TableName, String) \
+ BootScriptSaveInformationAsciiString(TableName, String)
+
+#else
+
+#define INITIALIZE_SCRIPT(ImageHandle, SystemTable)
+
+#define SCRIPT_IO_WRITE(TableName, Width, Address, Count, Buffer)
+
+#define SCRIPT_IO_READ_WRITE(TableName, Width, Address, Data, DataMask)
+
+#define SCRIPT_MEM_WRITE(TableName, Width, Address, Count, Buffer)
+
+#define SCRIPT_MEM_WRITE_THIS(TableName, Width, Address, Count)
+
+#define SCRIPT_MEM_READ_WRITE(TableName, Width, Address, Data, DataMask)
+
+#define SCRIPT_PCI_CFG_WRITE(TableName, Width, Address, Count, Buffer)
+
+#define SCRIPT_PCI_CFG_READ_WRITE(TableName, Width, Address, Data, DataMask)
+
+#define SCRIPT_SMBUS_EXECUTE(TableName, SlaveAddress, Command, Operation, PecCheck, Length, Buffer)
+
+#define SCRIPT_STALL(TableName, Duration)
+
+#define SCRIPT_DISPATCH(TableName, EntryPoint)
+
+#define SCRIPT_MEM_POLL(TableName, Width, Address, BitMask, BitValue, Duration, LoopTimes)
+
+#define SCRIPT_INFORMATION(TableName, Length, Buffer)
+
+#define SCRIPT_INFORMATION_UNICODE_STRING(TableName, String)
+
+#define SCRIPT_INFORMATION_ASCII_STRING(TableName, String)
+
+#endif
+
+#endif
diff --git a/EDK/Foundation/Library/Dxe/Include/EfiSmmDriverLib.h b/EDK/Foundation/Library/Dxe/Include/EfiSmmDriverLib.h
new file mode 100644
index 0000000..5b6e74a
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/Include/EfiSmmDriverLib.h
@@ -0,0 +1,226 @@
+/*++
+
+Copyright (c) 2004 - 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiSmmDriverLib.h
+
+Abstract:
+
+ Light weight lib to support EFI Smm drivers.
+
+--*/
+
+#ifndef _EFI_SMM_DRIVER_LIB_H_
+#define _EFI_SMM_DRIVER_LIB_H_
+
+#include "Tiano.h"
+#include "GetImage.h"
+#include "EfiCommonLib.h"
+#include EFI_GUID_DEFINITION (EventLegacyBios)
+#include EFI_GUID_DEFINITION (EventGroup)
+#include EFI_PROTOCOL_DEFINITION (FirmwareVolume)
+#include EFI_PROTOCOL_DEFINITION (FirmwareVolume2) //;;## ...AMI_OVERRIDE... Support PI1.x
+#include EFI_PROTOCOL_DEFINITION (SmmBase)
+#include EFI_PROTOCOL_DEFINITION (SmmStatusCode)
+//
+// Driver Lib Globals.
+//
+extern EFI_BOOT_SERVICES *gBS;
+extern EFI_SYSTEM_TABLE *gST;
+extern EFI_RUNTIME_SERVICES *gRT;
+extern EFI_SMM_BASE_PROTOCOL *gSMM;
+extern EFI_SMM_STATUS_CODE_PROTOCOL *mSmmDebug;
+extern UINTN gErrorLevel;
+
+#define EfiCopyMem EfiCommonLibCopyMem
+#define EfiSetMem EfiCommonLibSetMem
+#define EfiZeroMem EfiCommonLibZeroMem
+
+EFI_STATUS
+EfiInitializeSmmDriverLib (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable,
+ IN OUT BOOLEAN *InSmm
+ )
+/*++
+
+Routine Description:
+
+ Intialize Smm Driver Lib if it has not yet been initialized.
+
+Arguments:
+
+ ImageHandle - The firmware allocated handle for the EFI image.
+
+ SystemTable - A pointer to the EFI System Table.
+
+ InSmm - If InSmm is NULL, it will not register Image to SMM.
+ If InSmm is not NULL, it will register Image to SMM and
+ return information on currently in SMM mode or not.
+
+Returns:
+
+ EFI_STATUS always returns EFI_SUCCESS
+
+--*/
+;
+
+VOID
+EfiDebugAssert (
+ IN CHAR8 *FileName,
+ IN INTN LineNumber,
+ IN CHAR8 *Description
+ )
+/*++
+
+Routine Description:
+
+ Worker function for ASSERT (). If Error Logging hub is loaded log ASSERT
+ information. If Error Logging hub is not loaded DEADLOOP ().
+
+Arguments:
+
+ FileName - File name of failing routine.
+
+ LineNumber - Line number of failing ASSERT().
+
+ Description - Description, usually the assertion,
+
+Returns:
+
+ None
+
+--*/
+;
+
+VOID
+EfiDebugVPrint (
+ IN UINTN ErrorLevel,
+ IN CHAR8 *Format,
+ IN VA_LIST Marker
+ )
+/*++
+
+Routine Description:
+
+ Worker function for DEBUG(). If Error Logging hub is loaded log ASSERT
+ information. If Error Logging hub is not loaded do nothing.
+
+Arguments:
+
+ ErrorLevel - If error level is set do the debug print.
+
+ Format - String to use for the print, followed by Print arguments.
+
+ Marker - VarArgs
+
+Returns:
+
+ None
+
+--*/
+;
+
+VOID
+EfiDebugPrint (
+ IN UINTN ErrorLevel,
+ IN CHAR8 *Format,
+ ...
+ )
+/*++
+
+Routine Description:
+
+ Worker function for DEBUG(). If Error Logging hub is loaded log ASSERT
+ information. If Error Logging hub is not loaded do nothing.
+
+Arguments:
+
+ ErrorLevel - If error level is set do the debug print.
+
+ Format - String to use for the print, followed by Print arguments.
+
+ ... - VAR args for Format
+
+Returns:
+
+ None
+
+--*/
+;
+
+EFI_STATUS
+EFIAPI
+SmmEfiCreateEventLegacyBoot (
+ IN EFI_TPL NotifyTpl,
+ IN EFI_EVENT_NOTIFY NotifyFunction,
+ IN VOID *NotifyContext,
+ OUT EFI_EVENT *LegacyBootEvent
+ )
+/*++
+
+Routine Description:
+ Create a Legacy Boot Event.
+ Tiano extended the CreateEvent Type enum to add a legacy boot event type.
+ This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was
+ added and now it's possible to not voilate the UEFI specification by
+ declaring a GUID for the legacy boot event class. This library supports
+ the R8.5/EFI 1.10 form and R8.6/UEFI 2.0 form and allows common code to
+ work both ways.
+
+Arguments:
+ LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex)
+
+Returns:
+ EFI_SUCCESS Event was created.
+ Other Event was not created.
+
+--*/
+;
+
+EFI_STATUS
+EFIAPI
+SmmEfiCreateEventReadyToBoot (
+ IN EFI_TPL NotifyTpl,
+ IN EFI_EVENT_NOTIFY NotifyFunction,
+ IN VOID *NotifyContext,
+ OUT EFI_EVENT *ReadyToBootEvent
+ )
+/*++
+
+Routine Description:
+ Create a Read to Boot Event.
+
+ Tiano extended the CreateEvent Type enum to add a ready to boot event type.
+ This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was
+ added and now it's possible to not voilate the UEFI specification and use
+ the ready to boot event class defined in UEFI 2.0. This library supports
+ the R8.5/EFI 1.10 form and R8.6/UEFI 2.0 form and allows common code to
+ work both ways.
+
+Arguments:
+ ReadyToBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex)
+
+Return:
+ EFI_SUCCESS - Event was created.
+ Other - Event was not created.
+
+--*/
+;
+
+//
+// These macros let code use the same name as boot service driver lib.
+//
+#define EfiCreateEventLegacyBoot SmmEfiCreateEventLegacyBoot
+#define EfiCreateEventReadyToBoot SmmEfiCreateEventReadyToBoot
+
+#endif
diff --git a/EDK/Foundation/Library/Dxe/Include/EfiUiLib.h b/EDK/Foundation/Library/Dxe/Include/EfiUiLib.h
new file mode 100644
index 0000000..0e2bc59
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/Include/EfiUiLib.h
@@ -0,0 +1,205 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+ EfiUiLib.h
+
+Abstract:
+ Collection of usefull UI functions.
+
+Revision History:
+
+--*/
+
+#ifndef _EFI_UI_LIB_H_
+#define _EFI_UI_LIB_H_
+
+#include "Tiano.h"
+#include "TianoTypes.h"
+#include "EfiDriverLib.h"
+
+CHAR16 *
+StrHzToString (
+ OUT CHAR16 *String,
+ IN UINT64 Val
+ )
+/*++
+
+Routine Description:
+ Converts frequency in Hz to Unicode string.
+ Three significant digits are delivered. Used for processor info display.
+
+Arguments:
+ String - string that will contain the frequency.
+ Val - value to convert, minimum is 100000 i.e., 0.1 MHz.
+
+Returns:
+ String that contains the frequency.
+
+--*/
+;
+
+CHAR16 *
+StrBytesToString (
+ OUT CHAR16 *String,
+ IN UINT64 Val
+ )
+/*++
+
+Routine Description:
+ Converts size in bytes to Unicode string.
+ Used for memory/cache size display.
+
+Arguments:
+ String - string that will contain the value
+ Val - value to convert in bytes
+
+Returns:
+ String that contains the value.
+
+--*/
+;
+
+CHAR16 *
+StrVersionToString (
+ OUT CHAR16 *String,
+ IN UINT8 Version
+ )
+/*++
+
+Routine Description:
+ Converts 8 bit version value to Unicode string.
+ The upper nibble contains the upper part, the lower nibble contains the minor part.
+ The output format is <major>.<minor>.
+
+Arguments:
+ String - string that will contain the version value
+ Version - Version value to convert
+
+Returns:
+ String that contains the version value.
+
+--*/
+;
+
+CHAR16 *
+StrMacToString (
+ OUT CHAR16 *String,
+ IN EFI_MAC_ADDRESS *MacAddr,
+ IN UINT32 AddrSize
+ )
+/*++
+
+Routine Description:
+ Converts MAC address to Unicode string.
+ The value is 64-bit and the resulting string will be 12
+ digit hex number in pairs of digits separated by dashes.
+
+Arguments:
+ String - string that will contain the value
+ MacAddr - MAC address to convert
+ AddrSize - Size of address
+
+Returns:
+ String that contains the value.
+
+--*/
+;
+
+CHAR16 *
+StrIp4AdrToString (
+ OUT CHAR16 *String,
+ IN EFI_IPv4_ADDRESS *Ip4Addr
+ )
+/*++
+
+Routine Description:
+ Converts IP v4 address to Unicode string.
+ The value is 64-bit and the resulting string will
+ be four decimal values 0-255 separated by dots.
+
+Arguments:
+ String - string that will contain the value
+ Ip4Addr - IP v4 address to convert from
+
+Returns:
+
+ String that contain the value
+
+--*/
+;
+
+EFI_STATUS
+StrStringToIp4Adr (
+ OUT EFI_IPv4_ADDRESS *Ip4Addr,
+ IN CHAR16 *String
+ )
+/*++
+
+Routine Description:
+ Parses and converts Unicode string to IP v4 address.
+ The value will 64-bit.
+ The string must be four decimal values 0-255 separated by dots.
+ The string is parsed and format verified.
+
+Arguments:
+ Ip4Addr - pointer to the variable to store the value to
+ String - string that contains the value to parse and convert
+
+Returns:
+ EFI_SUCCESS - if successful
+ EFI_INVALID_PARAMETER - if String contains invalid IP v4 format
+
+--*/
+;
+
+CHAR16 *
+Ascii2Unicode (
+ OUT CHAR16 *UnicodeStr,
+ IN CHAR8 *AsciiStr
+ )
+/*++
+
+Routine Description:
+ Converts ASCII characters to Unicode.
+
+Arguments:
+ UnicodeStr - the Unicode string to be written to. The buffer must be large enough.
+ AsciiStr - The ASCII string to be converted.
+
+Returns:
+ The address to the Unicode string - same as UnicodeStr.
+
+--*/
+;
+
+CHAR8 *
+Unicode2Ascii (
+ OUT CHAR8 *AsciiStr,
+ IN CHAR16 *UnicodeStr
+ )
+/*++
+
+Routine Description:
+ Converts ASCII characters to Unicode.
+ Assumes that the Unicode characters are only these defined in the ASCII set.
+
+Arguments:
+ AsciiStr - The ASCII string to be written to. The buffer must be large enough.
+ UnicodeStr - the Unicode string to be converted.
+
+Returns:
+ The address to the ASCII string - same as AsciiStr.
+
+--*/
+;
+
+#endif
diff --git a/EDK/Foundation/Library/Dxe/Include/EfiWinNtLib.h b/EDK/Foundation/Library/Dxe/Include/EfiWinNtLib.h
new file mode 100644
index 0000000..8f7bd57
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/Include/EfiWinNtLib.h
@@ -0,0 +1,75 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiWinNtLib.h
+
+Abstract:
+
+ Set up gWinNt pointer so we can call WinNT APIs.
+
+--*/
+
+#ifndef _EFI_WIN_NT_LIB_H_
+#define _EFI_WIN_NT_LIB_H_
+
+extern EFI_WIN_NT_THUNK_PROTOCOL *gWinNt;
+
+EFI_STATUS
+EfiInitializeWinNtDriverLib (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+/*++
+
+Routine Description:
+
+ Intialize gWinNt and initialize debug console.
+
+Arguments:
+
+ ImageHandle - The firmware allocated handle for the EFI image.
+
+ SystemTable - A pointer to the EFI System Table.
+
+Returns:
+
+ Status code
+
+--*/
+;
+
+//
+// NTDebugConsole Prototypes
+//
+VOID
+NtDebugConsoleInit (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Nt debug console initialize.
+
+Arguments:
+
+ None
+
+Returns:
+
+ None
+
+--*/
+;
+
+#endif
diff --git a/EDK/Foundation/Library/Dxe/Include/GetImage.h b/EDK/Foundation/Library/Dxe/Include/GetImage.h
new file mode 100644
index 0000000..0f22c5e
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/Include/GetImage.h
@@ -0,0 +1,104 @@
+/*++
+
+Copyright (c) 2006 - 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ GetImage.h
+
+Abstract:
+
+ Image data retrieval support for common use.
+
+--*/
+
+#ifndef _GET_IMAGE_H_
+#define _GET_IMAGE_H_
+#include "EfiImageFormat.h"
+
+EFI_STATUS
+GetImage (
+ IN EFI_GUID *NameGuid,
+ IN EFI_SECTION_TYPE SectionType,
+ OUT VOID **Buffer,
+ OUT UINTN *Size
+ )
+/*++
+
+Routine Description:
+ Enumerate all the FVs, and fill Buffer with the SectionType section content in NameGuid file.
+
+ Note:
+ 1. when SectionType is EFI_SECTION_PE32, it tries to read NameGuid file after failure on
+ reading EFI_SECTION_PE32 section.
+ 2. when SectionType is EFI_SECTION_TE, it tries to get EFI_SECTION_PE32 section after failure on
+ reading EFI_SECTION_TE section. If it's failed again, it tries to read NameGuid file.
+ 3. Callee allocates memory, which caller is responsible to free.
+
+Arguments:
+
+ NameGuid - Pointer to EFI_GUID, which is file name.
+ SectionType - Required section type.
+ Buffer - Pointer to a pointer in which the read content is returned.
+ Caller is responsible to free Buffer.
+ Size - Pointer to a UINTN, which indicates the size of returned *Buffer.
+
+Returns:
+ EFI_NOT_FOUND - Required content can not be found.
+ EFI_SUCCESS - Required content can be found, but whether the Buffer is filled
+ with section content or not depends on the Buffer and Size.
+--*/
+;
+
+EFI_STATUS
+GetImageEx (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_GUID *NameGuid,
+ IN EFI_SECTION_TYPE SectionType,
+ OUT VOID **Buffer,
+ OUT UINTN *Size,
+ BOOLEAN WithinImageFv
+ )
+/*++
+
+Routine Description:
+ Search FVs, and fill Buffer with the SectionType section content in NameGuid file.
+ If ImageHandle is not NULL, the FV from which the ImageHandle is loaded is searched
+ first. If WithinImageFv is TRUE, only the FV from which the ImageHandle is loaded
+ is searched. If ImageHandle is NULL or WithinImageFv is FALSE, all FVs in the system
+ is searched.
+
+ Note:
+ 1. when SectionType is EFI_SECTION_PE32, it tries to read NameGuid file after failure on
+ reading EFI_SECTION_PE32 section.
+ 2. when SectionType is EFI_SECTION_TE, it tries to get EFI_SECTION_PE32 section after failure on
+ reading EFI_SECTION_TE section. If it's failed again, it tries to read NameGuid file.
+ 3. Callee allocates memory, which caller is responsible to free.
+
+Arguments:
+
+ ImageHandle - The caller's driver image handle.
+ NameGuid - Pointer to EFI_GUID, which is file name.
+ SectionType - Required section type.
+ Buffer - Pointer to a pointer in which the read content is returned.
+ Caller is responsible to free Buffer.
+ Size - Pointer to a UINTN, which indicates the size of returned *Buffer.
+ WithinImageFv - Whether the search only performs on the FV from which the caller's
+ driver image is loaded.
+
+Returns:
+ EFI_INVALID_PARAMETER - ImageHandle is NULL and WithinImageFv is TRUE.
+ EFI_NOT_FOUND - Required content can not be found.
+ EFI_SUCCESS - Required content can be found, but whether the Buffer is filled
+ with section content or not depends on the Buffer and Size.
+--*/
+;
+
+#endif //_GET_IMAGE_H_
diff --git a/EDK/Foundation/Library/Dxe/Include/GraphicsLib.h b/EDK/Foundation/Library/Dxe/Include/GraphicsLib.h
new file mode 100644
index 0000000..02f1d97
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/Include/GraphicsLib.h
@@ -0,0 +1,181 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ GraphicsLib.h
+
+Abstract:
+
+
+--*/
+
+#ifndef _EFI_GRAPHICS_LIB_H_
+#define _EFI_GRAPHICS_LIB_H_
+
+#include EFI_PROTOCOL_DEFINITION (ConsoleControl)
+#include EFI_PROTOCOL_DEFINITION (FirmwareVolume)
+#include EFI_PROTOCOL_DEFINITION (GraphicsOutput)
+#include EFI_PROTOCOL_DEFINITION (UgaDraw)
+#include EFI_PROTOCOL_DEFINITION (EfiOEMBadging)
+
+#include EFI_GUID_DEFINITION (Bmp)
+
+EFI_STATUS
+GetGraphicsBitMapFromFV (
+ IN EFI_GUID *FileNameGuid,
+ OUT VOID **Image,
+ OUT UINTN *ImageSize
+ )
+/*++
+
+Routine Description:
+
+ Return the graphics image file named FileNameGuid into Image and return it's
+ size in ImageSize. All Firmware Volumes (FV) in the system are searched for the
+ file name.
+
+Arguments:
+
+ FileNameGuid - File Name of graphics file in the FV(s).
+
+ Image - Pointer to pointer to return graphics image. If NULL, a
+ buffer will be allocated.
+
+ ImageSize - Size of the graphics Image in bytes. Zero if no image found.
+
+
+Returns:
+
+ EFI_SUCCESS - Image and ImageSize are valid.
+ EFI_BUFFER_TOO_SMALL - Image not big enough. ImageSize has required size
+ EFI_NOT_FOUND - FileNameGuid not found
+
+--*/
+;
+
+EFI_STATUS
+ConvertBmpToGopBlt (
+ IN VOID *BmpImage,
+ IN UINTN BmpImageSize,
+ IN OUT VOID **GopBlt,
+ IN OUT UINTN *GopBltSize,
+ OUT UINTN *PixelHeight,
+ OUT UINTN *PixelWidth
+ )
+/*++
+
+Routine Description:
+
+ Convert a *.BMP graphics image to a GOP/UGA blt buffer. If a NULL Blt buffer
+ is passed in a GopBlt buffer will be allocated by this routine. If a GopBlt
+ buffer is passed in it will be used if it is big enough.
+
+Arguments:
+
+ BmpImage - Pointer to BMP file
+
+ BmpImageSize - Number of bytes in BmpImage
+
+ GopBlt - Buffer containing GOP version of BmpImage.
+
+ GopBltSize - Size of GopBlt in bytes.
+
+ PixelHeight - Height of GopBlt/BmpImage in pixels
+
+ PixelWidth - Width of GopBlt/BmpImage in pixels
+
+
+Returns:
+
+ EFI_SUCCESS - GopBlt and GopBltSize are returned.
+ EFI_UNSUPPORTED - BmpImage is not a valid *.BMP image
+ EFI_BUFFER_TOO_SMALL - The passed in GopBlt buffer is not big enough.
+ GopBltSize will contain the required size.
+ EFI_OUT_OF_RESOURCES - No enough buffer to allocate
+
+--*/
+;
+
+EFI_STATUS
+EnableQuietBoot (
+ IN EFI_GUID *LogoFile
+ )
+/*++
+
+Routine Description:
+
+ Use Console Control to turn off UGA based Simple Text Out consoles from going
+ to the UGA device. Put up LogoFile on every UGA device that is a console
+
+Arguments:
+
+ LogoFile - File name of logo to display on the center of the screen.
+
+
+Returns:
+
+ EFI_SUCCESS - ConsoleControl has been flipped to graphics and logo
+ displayed.
+ EFI_UNSUPPORTED - Logo not found
+
+--*/
+;
+
+EFI_STATUS
+DisableQuietBoot (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Use Console Control to turn on UGA based Simple Text Out consoles. The UGA
+ Simple Text Out screens will now be synced up with all non UGA output devices
+
+Arguments:
+
+ NONE
+
+Returns:
+
+ EFI_SUCCESS - UGA devices are back in text mode and synced up.
+ EFI_UNSUPPORTED - Logo not found
+
+--*/
+;
+
+EFI_STATUS
+LockKeyboards (
+ IN CHAR16 *Password
+ )
+/*++
+
+Routine Description:
+ Use Console Control Protocol to lock the Console In Spliter virtual handle.
+ This is the ConInHandle and ConIn handle in the EFI system table. All key
+ presses will be ignored until the Password is typed in. The only way to
+ disable the password is to type it in to a ConIn device.
+
+Arguments:
+ Password - Password used to lock ConIn device
+
+
+Returns:
+
+ EFI_SUCCESS - ConsoleControl has been flipped to graphics and logo
+ displayed.
+ EFI_UNSUPPORTED - Logo not found
+
+--*/
+;
+
+#endif
diff --git a/EDK/Foundation/Library/Dxe/Include/Ia32/CpuFuncs.h b/EDK/Foundation/Library/Dxe/Include/Ia32/CpuFuncs.h
new file mode 100644
index 0000000..affb3bd
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/Include/Ia32/CpuFuncs.h
@@ -0,0 +1,260 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ CpuFuncs.h
+
+Abstract:
+
+--*/
+
+#ifndef _CPU_FUNCS_H_
+#define _CPU_FUNCS_H_
+
+#define EFI_CPUID_SIGNATURE 0x0
+#define EFI_CPUID_VERSION_INFO 0x1
+#define EFI_CPUID_CACHE_INFO 0x2
+#define EFI_CPUID_SERIAL_NUMBER 0x3
+#define EFI_CPUID_EXTENDED_FUNCTION 0x80000000
+#define EFI_CPUID_EXTENDED_CPU_SIG 0x80000001
+#define EFI_CPUID_BRAND_STRING1 0x80000002
+#define EFI_CPUID_BRAND_STRING2 0x80000003
+#define EFI_CPUID_BRAND_STRING3 0x80000004
+
+//
+// CPUID version information masks
+// Note: leaving masks here is for the compatibility
+// use EfiCpuVersion (...) instead
+//
+#define EFI_CPUID_FAMILY 0x0F00
+#define EFI_CPUID_MODEL 0x00F0
+#define EFI_CPUID_STEPPING 0x000F
+
+#define EFI_CPUID_PENTIUM_M 0x0600
+#define EFI_CPUID_BANIAS 0x0090
+#define EFI_CPUID_DOTHAN 0x00D0
+#define EFI_CPUID_NETBURST 0x0F00
+
+#define EFI_MSR_IA32_PLATFORM_ID 0x17
+#define EFI_MSR_IA32_APIC_BASE 0x1B
+#define EFI_MSR_EBC_HARD_POWERON 0x2A
+#define EFI_MSR_EBC_SOFT_POWERON 0x2B
+#define BINIT_DRIVER_DISABLE 0x40
+#define INTERNAL_MCERR_DISABLE 0x20
+#define INITIATOR_MCERR_DISABLE 0x10
+#define EFI_MSR_EBC_FREQUENCY_ID 0x2C
+#define EFI_MSR_IA32_BIOS_UPDT_TRIG 0x79
+#define EFI_MSR_IA32_BIOS_SIGN_ID 0x8B
+#define EFI_MSR_PSB_CLOCK_STATUS 0xCD
+#define EFI_APIC_GLOBAL_ENABLE 0x800
+#define EFI_MSR_IA32_MISC_ENABLE 0x1A0
+#define LIMIT_CPUID_MAXVAL_ENABLE_BIT 0x00400000
+#define AUTOMATIC_THERMAL_CONTROL_ENABLE_BIT 0x00000008
+#define COMPATIBLE_FPU_OPCODE_ENABLE_BIT 0x00000004
+#define LOGICAL_PROCESSOR_PRIORITY_ENABLE_BIT 0x00000002
+#define FAST_STRING_ENABLE_BIT 0x00000001
+
+#define EFI_CACHE_VARIABLE_MTRR_BASE 0x200
+#define EFI_CACHE_VARIABLE_MTRR_END 0x20F
+#define EFI_CACHE_IA32_MTRR_DEF_TYPE 0x2FF
+#define EFI_CACHE_VALID_ADDRESS 0xFFFFFF000
+#define EFI_CACHE_MTRR_VALID 0x800
+#define EFI_CACHE_FIXED_MTRR_VALID 0x400
+#define EFI_MSR_VALID_MASK 0xFFFFFFFFF
+
+#define EFI_IA32_MTRR_FIX64K_00000 0x250
+#define EFI_IA32_MTRR_FIX16K_80000 0x258
+#define EFI_IA32_MTRR_FIX16K_A0000 0x259
+#define EFI_IA32_MTRR_FIX4K_C0000 0x268
+#define EFI_IA32_MTRR_FIX4K_C8000 0x269
+#define EFI_IA32_MTRR_FIX4K_D0000 0x26A
+#define EFI_IA32_MTRR_FIX4K_D8000 0x26B
+#define EFI_IA32_MTRR_FIX4K_E0000 0x26C
+#define EFI_IA32_MTRR_FIX4K_E8000 0x26D
+#define EFI_IA32_MTRR_FIX4K_F0000 0x26E
+#define EFI_IA32_MTRR_FIX4K_F8000 0x26F
+
+#define EFI_IA32_MCG_CAP 0x179
+#define EFI_IA32_MCG_CTL 0x17B
+#define EFI_IA32_MC0_CTL 0x400
+#define EFI_IA32_MC0_STATUS 0x401
+
+#define EFI_CACHE_UNCACHEABLE 0
+#define EFI_CACHE_WRITECOMBINING 1
+#define EFI_CACHE_WRITETHROUGH 4
+#define EFI_CACHE_WRITEPROTECTED 5
+#define EFI_CACHE_WRITEBACK 6
+
+//
+// Combine f(FamilyId), m(Model), s(SteppingId) to a single 32 bit number
+//
+#define EfiMakeCpuVersion(f, m, s) \
+ (((UINT32) (f) << 16) | ((UINT32) (m) << 8) | ((UINT32) (s)))
+
+typedef struct {
+ UINT32 HeaderVersion;
+ UINT32 UpdateRevision;
+ UINT32 Date;
+ UINT32 ProcessorId;
+ UINT32 Checksum;
+ UINT32 LoaderRevision;
+ UINT32 ProcessorFlags;
+ UINT32 DataSize;
+ UINT32 TotalSize;
+ UINT8 Reserved[12];
+} EFI_CPU_MICROCODE_HEADER;
+
+typedef struct {
+ UINT32 ExtSigCount;
+ UINT32 ExtChecksum;
+ UINT8 Reserved[12];
+ UINT32 ProcessorId;
+ UINT32 ProcessorFlags;
+ UINT32 Checksum;
+} EFI_CPU_MICROCODE_EXT_HEADER;
+
+typedef struct {
+ UINT32 RegEax;
+ UINT32 RegEbx;
+ UINT32 RegEcx;
+ UINT32 RegEdx;
+} EFI_CPUID_REGISTER;
+
+VOID
+EfiWriteMsr (
+ IN UINT32 Input,
+ IN UINT64 Value
+ )
+/*++
+
+Routine Description:
+
+ Write Cpu MSR
+
+Arguments:
+
+ Input -The index value to select the register
+ Value -The value to write to the selected register
+
+Returns:
+
+ None
+
+--*/
+;
+
+UINT64
+EfiReadMsr (
+ IN UINT32 Input
+ )
+/*++
+
+Routine Description:
+
+ Read Cpu MSR.
+
+Arguments:
+
+ Input: -The index value to select the register
+
+Returns:
+
+ Return the read data
+
+--*/
+;
+
+VOID
+EfiCpuid (
+ IN UINT32 RegEax,
+ OUT EFI_CPUID_REGISTER *Reg
+ )
+/*++
+
+Routine Description:
+
+ Get the Cpu info by excute the CPUID instruction.
+
+Arguments:
+
+ RegEax -The input value to put into register EAX
+ Reg -The Output value
+
+Returns:
+
+ None
+
+--*/
+;
+
+VOID
+EfiCpuVersion (
+ IN UINT16 *FamilyId, OPTIONAL
+ IN UINT8 *Model, OPTIONAL
+ IN UINT8 *SteppingId, OPTIONAL
+ IN UINT8 *Processor OPTIONAL
+ )
+/*++
+
+Routine Description:
+ Extract CPU detail version infomation
+
+Arguments:
+ FamilyId - FamilyId, including ExtendedFamilyId
+ Model - Model, including ExtendedModel
+ SteppingId - SteppingId
+ Processor - Processor
+
+--*/
+;
+
+UINT64
+EfiReadTsc (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Read Time stamp.
+
+Arguments:
+
+ None
+
+Returns:
+
+ Return the read data
+
+--*/
+;
+VOID
+EfiCpuidExt (
+ IN UINT32 RegisterInEax,
+ IN UINT32 CacheLevel,
+ OUT EFI_CPUID_REGISTER *Regs
+ )
+/*++
+Routine Description:
+ When RegisterInEax != 4, the functionality is the same as EfiCpuid.
+ When RegisterInEax == 4, the function return the deterministic cache
+ parameters by excuting the CPUID instruction
+Arguments:
+ RegisterInEax: - The input value to put into register EAX
+ CacheLevel: - The deterministic cache level
+ Regs: - The Output value
+Returns:
+ None
+--*/
+;
+
+#endif
diff --git a/EDK/Foundation/Library/Dxe/Include/Ia32/ProcDep.h b/EDK/Foundation/Library/Dxe/Include/Ia32/ProcDep.h
new file mode 100644
index 0000000..2e072d2
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/Include/Ia32/ProcDep.h
@@ -0,0 +1,26 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ ProcDep.h
+
+Abstract:
+
+ IA-32 specific Runtime Lib code. At this time there is non.
+ IPF has different code due to extra API requirements.
+
+--*/
+
+#ifndef _PROC_DEP_H_
+#define _PROC_DEP_H_
+
+#endif
diff --git a/EDK/Foundation/Library/Dxe/Include/Ia32EfiRuntimeDriverLib.h b/EDK/Foundation/Library/Dxe/Include/Ia32EfiRuntimeDriverLib.h
new file mode 100644
index 0000000..df833c4
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/Include/Ia32EfiRuntimeDriverLib.h
@@ -0,0 +1,111 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Ia32EfiRuntimeDriverLib.h
+
+Abstract:
+
+ Light weight lib to support IA32 EFI Libraries.
+
+--*/
+
+#ifndef _IA32_EFI_RUNTIME_LIB_H_
+#define _IA32_EFI_RUNTIME_LIB_H_
+
+#include "Tiano.h"
+#include "EfiRuntimeLib.h"
+#include EFI_PROTOCOL_DEFINITION (ExtendedSalGuid)
+
+typedef
+EFI_STATUS
+(EFIAPI *COMMON_PROC_ENTRY) (
+ IN UINTN FunctionId,
+ IN UINTN Arg2,
+ IN UINTN Arg3,
+ IN UINTN Arg4,
+ IN UINTN Arg5,
+ IN UINTN Arg6,
+ IN UINTN Arg7,
+ IN UINTN Arg8
+ );
+
+typedef struct {
+ COMMON_PROC_ENTRY CommonProcEntry;
+} COMMON_PROC_ENTRY_STRUCT;
+
+EFI_STATUS
+InstallPlatformRuntimeLib (
+ IN EFI_GUID *Guid,
+ IN COMMON_PROC_ENTRY_STRUCT *CommonEntry
+ )
+/*++
+
+Routine Description:
+
+ Install platform runtime lib.
+
+Arguments:
+
+ Guid - Guid for runtime lib
+ CommonEntry - Common entry
+
+Returns:
+
+ Status code
+
+--*/
+;
+
+EFI_STATUS
+GetPlatformRuntimeLib (
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+/*++
+
+Routine Description:
+
+ Get platform runtime lib.
+
+Arguments:
+
+ SystemTable - Pointer to system table
+
+Returns:
+
+ Status code
+
+--*/
+;
+
+EFI_STATUS
+ConvertPlatformRuntimeLibPtr (
+ IN EFI_RUNTIME_SERVICES *mRT
+ )
+/*++
+
+Routine Description:
+
+ Convert platform runtime lib pointer.
+
+Arguments:
+
+ mRT - Pointer to runtime service table.
+
+Returns:
+
+ Status code
+
+--*/
+;
+
+#endif
diff --git a/EDK/Foundation/Library/Dxe/Include/Ipf/CpuFuncs.h b/EDK/Foundation/Library/Dxe/Include/Ipf/CpuFuncs.h
new file mode 100644
index 0000000..3818170
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/Include/Ipf/CpuFuncs.h
@@ -0,0 +1,93 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ CpuFuncs.h
+
+Abstract:
+
+--*/
+
+#ifndef _CPU_FUNCS_H
+#define _CPU_FUNCS_H
+
+#define EFI_CPUID_SIGNATURE 0x0
+#define EFI_CPUID_VERSION_INFO 0x1
+#define EFI_CPUID_CACHE_INFO 0x2
+#define EFI_CPUID_SERIAL_NUMBER 0x3
+#define EFI_CPUID_EXTENDED_FUNCTION 0x80000000
+#define EFI_CPUID_EXTENDED_CPU_SIG 0x80000001
+#define EFI_CPUID_BRAND_STRING1 0x80000002
+#define EFI_CPUID_BRAND_STRING2 0x80000003
+#define EFI_CPUID_BRAND_STRING3 0x80000004
+
+#define EFI_MSR_IA32_APIC_BASE 0x1B
+#define EFI_MSR_EBC_HARD_POWERON 0x2A
+#define EFI_MSR_EBC_SOFT_POWERON 0x2B
+#define EFI_MSR_EBC_FREQUENCY_ID 0x2C
+#define EFI_MSR_IA32_BIOS_UPDT_TRIG 0x79
+#define EFI_MSR_IA32_BIOS_SIGN_ID 0x8B
+#define EFI_APIC_GLOBAL_ENABLE 0x800
+
+#define EFI_CACHE_VARIABLE_MTRR_BASE 0x200
+#define EFI_CACHE_VARIABLE_MTRR_END 0x20F
+#define EFI_CACHE_IA32_MTRR_DEF_TYPE 0x2FF
+#define EFI_CACHE_VALID_ADDRESS 0xFFFFFF000
+#define EFI_CACHE_MTRR_VALID 0x800
+#define EFI_CACHE_FIXED_MTRR_VALID 0x400
+#define EFI_MSR_VALID_MASK 0xFFFFFFFFF
+
+#define EFI_IA32_MTRR_FIX64K_00000 0x250
+#define EFI_IA32_MTRR_FIX16K_80000 0x258
+#define EFI_IA32_MTRR_FIX16K_A0000 0x259
+#define EFI_IA32_MTRR_FIX4K_C0000 0x268
+#define EFI_IA32_MTRR_FIX4K_C8000 0x269
+#define EFI_IA32_MTRR_FIX4K_D0000 0x26A
+#define EFI_IA32_MTRR_FIX4K_D8000 0x26B
+#define EFI_IA32_MTRR_FIX4K_E0000 0x26C
+#define EFI_IA32_MTRR_FIX4K_E8000 0x26D
+#define EFI_IA32_MTRR_FIX4K_F0000 0x26E
+#define EFI_IA32_MTRR_FIX4K_F8000 0x26F
+
+#define EFI_IA32_MCG_CAP 0x179
+#define EFI_IA32_MCG_CTL 0x17B
+#define EFI_IA32_MC0_CTL 0x400
+#define EFI_IA32_MC0_STATUS 0x401
+
+#define EFI_CACHE_UNCACHEABLE 0
+#define EFI_CACHE_WRITECOMBINING 1
+#define EFI_CACHE_WRITETHROUGH 4
+#define EFI_CACHE_WRITEPROTECTED 5
+#define EFI_CACHE_WRITEBACK 6
+
+UINT64
+EfiReadTsc (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Read Time stamp.
+
+Arguments:
+
+ None
+
+Returns:
+
+ Return the read data
+
+--*/
+;
+
+#endif
diff --git a/EDK/Foundation/Library/Dxe/Include/Ipf/EsalRuntimeLib.h b/EDK/Foundation/Library/Dxe/Include/Ipf/EsalRuntimeLib.h
new file mode 100644
index 0000000..7f29acf
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/Include/Ipf/EsalRuntimeLib.h
@@ -0,0 +1,1305 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EsalRuntimeLib.h
+
+Abstract:
+
+ SAL Driver Lib
+
+Revision History
+
+--*/
+
+#ifndef _ESAL_RUNTIME_LIB_H_
+#define _ESAL_RUNTIME_LIB_H_
+
+#include "SalApi.h"
+#include "EfiFirmwareVolumeHeader.h"
+
+#include EFI_PROTOCOL_DEFINITION (ExtendedSalBootService)
+#include EFI_PROTOCOL_DEFINITION (ExtendedSalGuid)
+#include EFI_PROTOCOL_DEFINITION (FirmwareVolumeBlock)
+
+VOID
+EsalRuntimeLibVirtualNotify (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ None
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+
+EFI_STATUS
+EsalInitializeRuntimeDriverLib (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ ImageHandle - Image Handle
+ SystemTable - the System Table
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+SAL_RETURN_REGS
+CallEsalService (
+ IN EFI_GUID *ClassGuid,
+ IN UINT64 FunctionId,
+ IN UINT64 Arg2,
+ IN UINT64 Arg3,
+ IN UINT64 Arg4,
+ IN UINT64 Arg5,
+ IN UINT64 Arg6,
+ IN UINT64 Arg7,
+ IN UINT64 Arg8
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ ClassGuid - TODO: add argument description
+ FunctionId - TODO: add argument description
+ Arg2 - TODO: add argument description
+ Arg3 - TODO: add argument description
+ Arg4 - TODO: add argument description
+ Arg5 - TODO: add argument description
+ Arg6 - TODO: add argument description
+ Arg7 - TODO: add argument description
+ Arg8 - TODO: add argument description
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+
+//
+// Assembly Functions
+//
+
+SAL_RETURN_REGS
+EsalGetEntryPoint (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ None
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+
+SAL_RETURN_REGS
+EsalSetPhysicalEntryPoint (
+ IN UINT64 EntryPoint,
+ IN UINT64 Gp
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ EntryPoint - TODO: add argument description
+ Gp - TODO: add argument description
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+
+SAL_RETURN_REGS
+EsalSetVirtualEntryPoint (
+ IN UINT64 EntryPoint,
+ IN UINT64 Gp
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ EntryPoint - TODO: add argument description
+ Gp - TODO: add argument description
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+
+SAL_RETURN_REGS
+EsalSetPhysicalModuleGlobal (
+ IN VOID *Global
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ Global - TODO: add argument description
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+
+SAL_RETURN_REGS
+EsalSetVirtualModuleGlobal (
+ IN VOID *Global
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ Global - TODO: add argument description
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+
+SAL_RETURN_REGS
+EsalGetModuleGlobal (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ None
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+
+SAL_RETURN_REGS
+GetIrrData (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ None
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+
+SAL_RETURN_REGS
+GetPsrData (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ None
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+
+SAL_RETURN_REGS
+GetProcIdData (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ None
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+
+VOID
+SwitchCpuStack (
+ IN UINT64 NewBsp,
+ IN UINT64 OldBsp
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ NewBsp - TODO: add argument description
+ OldBsp - TODO: add argument description
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+
+//
+// PAL PROC Class
+//
+
+SAL_RETURN_REGS
+SalPalProc (
+ IN UINT64 Arg1,
+ IN UINT64 Arg2,
+ IN UINT64 Arg3,
+ IN UINT64 Arg4
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ Arg1 - TODO: add argument description
+ Arg2 - TODO: add argument description
+ Arg3 - TODO: add argument description
+ Arg4 - TODO: add argument description
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+
+SAL_RETURN_REGS
+SalRegisterNewPalEntry (
+ IN BOOLEAN PhysicalPalAddress,
+ IN EFI_PHYSICAL_ADDRESS NewPalAddress
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ PhysicalPalAddress - TODO: add argument description
+ NewPalAddress - TODO: add argument description
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+
+SAL_RETURN_REGS
+SalGetPalEntryPointer (
+ IN BOOLEAN PhysicalPalAddress
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ PhysicalPalAddress - TODO: add argument description
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+
+//
+// SAL BASE Class
+//
+
+SAL_RETURN_REGS
+SalProcSetVectors (
+ IN UINT64 SalVectorType,
+ IN UINT64 PhyAddr1,
+ IN UINT64 Gp1,
+ IN UINT64 LengthCs1,
+ IN UINT64 PhyAddr2,
+ IN UINT64 Gp2,
+ IN UINT64 LengthCs2
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ SalVectorType - TODO: add argument description
+ PhyAddr1 - TODO: add argument description
+ Gp1 - TODO: add argument description
+ LengthCs1 - TODO: add argument description
+ PhyAddr2 - TODO: add argument description
+ Gp2 - TODO: add argument description
+ LengthCs2 - TODO: add argument description
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+
+SAL_RETURN_REGS
+SalProcMcRendez (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ None
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+
+SAL_RETURN_REGS
+SalProcMcSetParams (
+ IN UINT64 ParamType,
+ IN UINT64 IntOrMem,
+ IN UINT64 IntOrMemVal,
+ IN UINT64 Timeout,
+ IN UINT64 McaOpt
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ ParamType - TODO: add argument description
+ IntOrMem - TODO: add argument description
+ IntOrMemVal - TODO: add argument description
+ Timeout - TODO: add argument description
+ McaOpt - TODO: add argument description
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+
+SAL_RETURN_REGS
+EsalProcGetVectors (
+ IN UINT64 VectorType
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ VectorType - TODO: add argument description
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+
+SAL_RETURN_REGS
+EsalProcMcGetParams (
+ IN UINT64 ParamInfoType
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ ParamInfoType - TODO: add argument description
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+
+SAL_RETURN_REGS
+EsalProcMcGetMcParams (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ None
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+
+SAL_RETURN_REGS
+EsalProcGetMcCheckinFlags (
+ IN UINT64 ProcessorUnit
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ ProcessorUnit - TODO: add argument description
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+
+//
+// Sal Base Class enums
+//
+
+typedef enum {
+ McaVector,
+ BspInitVector,
+ BootRendezVector,
+ ApInitVector
+} ESAL_GET_VECTOR_TYPE;
+
+SAL_RETURN_REGS
+SalInitializeThreshold (
+ IN VOID *ThresholdStruct,
+ IN UINT64 Count,
+ IN UINT64 Duration
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ ThresholdStruct - TODO: add argument description
+ Count - TODO: add argument description
+ Duration - TODO: add argument description
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+
+SAL_RETURN_REGS
+SalBumpThresholdCount (
+ IN VOID *ThresholdStruct,
+ IN UINT64 Count,
+ IN UINT64 Duration
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ ThresholdStruct - TODO: add argument description
+ Count - TODO: add argument description
+ Duration - TODO: add argument description
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+
+SAL_RETURN_REGS
+SalGetThresholdCount (
+ IN VOID *ThresholdStruct,
+ IN UINT64 Count,
+ IN UINT64 Duration
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ ThresholdStruct - TODO: add argument description
+ Count - TODO: add argument description
+ Duration - TODO: add argument description
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+
+//
+// Common Lib Function
+//
+
+EFI_STATUS
+RegisterEsalFunction (
+ IN UINT64 FunctionId,
+ IN EFI_GUID *ClassGuid,
+ IN SAL_INTERNAL_EXTENDED_SAL_PROC Function,
+ IN VOID *ModuleGlobal
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ FunctionId - TODO: add argument description
+ ClassGuid - TODO: add argument description
+ Function - TODO: add argument description
+ ModuleGlobal - TODO: add argument description
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+
+EFI_STATUS
+RegisterEsalClass (
+ IN EFI_GUID *ClassGuid,
+ IN VOID *ModuleGlobal,
+ ...
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ ClassGuid - TODO: add argument description
+ ModuleGlobal - TODO: add argument description
+ ... - TODO: add argument description
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+
+//
+// MP Class Functions
+//
+SAL_RETURN_REGS
+LibMpAddCpuData (
+ IN UINT64 CpuGlobalId,
+ IN BOOLEAN Enabled,
+ IN UINT64 PalCompatability
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ CpuGlobalId - TODO: add argument description
+ Enabled - TODO: add argument description
+ PalCompatability - TODO: add argument description
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+
+SAL_RETURN_REGS
+LibMpRemoveCpuData (
+ IN UINT64 CpuGlobalId
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ CpuGlobalId - TODO: add argument description
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+
+SAL_RETURN_REGS
+LibMpModifyCpuData (
+ IN UINT64 CpuGlobalId,
+ IN BOOLEAN Enabled,
+ IN UINT64 PalCompatability
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ CpuGlobalId - TODO: add argument description
+ Enabled - TODO: add argument description
+ PalCompatability - TODO: add argument description
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+
+SAL_RETURN_REGS
+LibMpGetCpuDataByID (
+ IN UINT64 CpuGlobalId,
+ IN BOOLEAN IndexByEnabledCpu
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ CpuGlobalId - TODO: add argument description
+ IndexByEnabledCpu - TODO: add argument description
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+
+SAL_RETURN_REGS
+LibMpGetCpuDataByIndex (
+ IN UINT64 Index,
+ IN BOOLEAN IndexByEnabledCpu
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ Index - TODO: add argument description
+ IndexByEnabledCpu - TODO: add argument description
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+
+SAL_RETURN_REGS
+LibMpSendIpi (
+ IN UINT64 ProcessorNumber,
+ IN UINT64 VectorNumber,
+ IN EFI_DELIVERY_MODE DeliveryMode,
+ IN BOOLEAN IRFlag
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ ProcessorNumber - TODO: add argument description
+ VectorNumber - TODO: add argument description
+ DeliveryMode - TODO: add argument description
+ IRFlag - TODO: add argument description
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+
+SAL_RETURN_REGS
+LibMpCurrentProcessor (
+ IN BOOLEAN IndexByEnabledCpu
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ IndexByEnabledCpu - TODO: add argument description
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+
+SAL_RETURN_REGS
+LibGetNumProcessors (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ None
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+
+SAL_RETURN_REGS
+LibMpSaveMinStatePointer (
+ IN UINT64 CpuGlobalId,
+ IN EFI_PHYSICAL_ADDRESS MinStatePointer
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ CpuGlobalId - TODO: add argument description
+ MinStatePointer - TODO: add argument description
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+
+SAL_RETURN_REGS
+LibMpRestoreMinStatePointer (
+ IN UINT64 CpuGlobalId
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ CpuGlobalId - TODO: add argument description
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+
+//
+// MCA Class Functions
+//
+
+EFI_STATUS
+LibMcaGetStateInfo (
+ IN UINT64 CpuId,
+ OUT EFI_PHYSICAL_ADDRESS *StateBufferPointer,
+ OUT UINT64 *RequiredStateBufferSize
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ CpuId - TODO: add argument description
+ StateBufferPointer - TODO: add argument description
+ RequiredStateBufferSize - TODO: add argument description
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+
+EFI_STATUS
+LibMcaRegisterCpu (
+ IN UINT64 CpuId,
+ IN EFI_PHYSICAL_ADDRESS StateBufferAddress
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ CpuId - TODO: add argument description
+ StateBufferAddress - TODO: add argument description
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+
+//
+// FVB Variables Class
+//
+EFI_STATUS
+EsalReadBlock (
+ IN UINTN Instance,
+ IN EFI_LBA Lba,
+ IN UINTN Offset,
+ IN OUT UINTN *NumBytes,
+ IN UINT8 *Buffer
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ Instance - TODO: add argument description
+ Lba - TODO: add argument description
+ Offset - TODO: add argument description
+ NumBytes - TODO: add argument description
+ Buffer - TODO: add argument description
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+
+EFI_STATUS
+EsalWriteBlock (
+ IN UINTN Instance,
+ IN EFI_LBA Lba,
+ IN UINTN Offset,
+ IN OUT UINTN *NumBytes,
+ IN UINT8 *Buffer
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ Instance - TODO: add argument description
+ Lba - TODO: add argument description
+ Offset - TODO: add argument description
+ NumBytes - TODO: add argument description
+ Buffer - TODO: add argument description
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+
+EFI_STATUS
+EsalEraseBlock (
+ IN UINTN Instance,
+ IN UINTN Lba
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ Instance - TODO: add argument description
+ Lba - TODO: add argument description
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+
+EFI_STATUS
+EsalGetVolumeAttributes (
+ IN UINTN Instance,
+ OUT EFI_FVB_ATTRIBUTES *Attributes
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ Instance - TODO: add argument description
+ Attributes - TODO: add argument description
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+
+EFI_STATUS
+EsalSetVolumeAttributes (
+ IN UINTN Instance,
+ IN EFI_FVB_ATTRIBUTES Attributes
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ Instance - TODO: add argument description
+ Attributes - TODO: add argument description
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+
+EFI_STATUS
+EsalGetPhysicalAddress (
+ IN UINTN Instance,
+ OUT EFI_PHYSICAL_ADDRESS *Address
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ Instance - TODO: add argument description
+ Address - TODO: add argument description
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+
+EFI_STATUS
+EsalGetBlockSize (
+ IN UINTN Instance,
+ IN EFI_LBA Lba,
+ OUT UINTN *BlockSize,
+ OUT UINTN *NumOfBlocks
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ Instance - TODO: add argument description
+ Lba - TODO: add argument description
+ BlockSize - TODO: add argument description
+ NumOfBlocks - TODO: add argument description
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+
+//
+// SAL ELOG Functions
+//
+EFI_STATUS
+LibSalGetStateInfo (
+ IN UINT64 McaType,
+ IN UINT8 *McaBuffer,
+ OUT UINTN *Size
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ McaType - TODO: add argument description
+ McaBuffer - TODO: add argument description
+ Size - TODO: add argument description
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+
+EFI_STATUS
+LibSalGetStateInfoSize (
+ IN UINT64 McaType,
+ OUT UINTN *Size
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ McaType - TODO: add argument description
+ Size - TODO: add argument description
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+
+EFI_STATUS
+LibSalClearStateInfo (
+ IN UINT64 McaType
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ McaType - TODO: add argument description
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+
+EFI_STATUS
+LibEsalGetStateBuffer (
+ IN UINT64 McaType,
+ OUT UINT8 **McaBuffer,
+ OUT UINTN *Index
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ McaType - TODO: add argument description
+ McaBuffer - TODO: add argument description
+ Index - TODO: add argument description
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+
+EFI_STATUS
+LibEsalSaveStateBuffer (
+ IN UINT64 McaType
+ )
+/*++
+
+Routine Description:
+
+ TODO: Add function description
+
+Arguments:
+
+ McaType - TODO: add argument description
+
+Returns:
+
+ TODO: add return values
+
+--*/
+;
+
+#endif
diff --git a/EDK/Foundation/Library/Dxe/Include/Ipf/ProcDep.h b/EDK/Foundation/Library/Dxe/Include/Ipf/ProcDep.h
new file mode 100644
index 0000000..2df940f
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/Include/Ipf/ProcDep.h
@@ -0,0 +1,119 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ ProcDep.h
+
+Abstract:
+
+ IPF specific Runtime Lib code. IPF has a SAL API that does not
+ exit on IA-32. Thus
+
+--*/
+
+#ifndef _PROC_DEP_H_
+#define _PROC_DEP_H_
+
+#include EFI_PROTOCOL_DEFINITION (ExtendedSalGuid)
+#include EFI_PROTOCOL_DEFINITION (ExtendedSalBootService)
+#include "SalApi.h"
+
+EFI_STATUS
+RegisterEsalFunction (
+ IN UINT64 FunctionId,
+ IN EFI_GUID *ClassGuid,
+ IN SAL_INTERNAL_EXTENDED_SAL_PROC Function,
+ IN VOID *ModuleGlobal
+ )
+/*++
+
+Routine Description:
+
+ Register ESAL Class Function and it's asociated global.
+ This function is boot service only!
+
+Arguments:
+ FunctionId - ID of function to register
+ ClassGuid - GUID of function class
+ Function - Function to register under ClassGuid/FunctionId pair
+ ModuleGlobal - Module global for Function.
+
+Returns:
+ EFI_SUCCESS - If ClassGuid/FunctionId Function was registered.
+
+--*/
+;
+
+EFI_STATUS
+RegisterEsalClass (
+ IN EFI_GUID *ClassGuid,
+ IN VOID *ModuleGlobal,
+ ...
+ )
+/*++
+
+Routine Description:
+
+ Register ESAL Class and it's asociated global.
+ This function is boot service only!
+
+Arguments:
+ ClassGuid - GUID of function class
+ ModuleGlobal - Module global for Function.
+ .. - SAL_INTERNAL_EXTENDED_SAL_PROC and FunctionId pairs. NULL
+ indicates the end of the list.
+
+Returns:
+ EFI_SUCCESS - All members of ClassGuid registered
+
+--*/
+;
+
+SAL_RETURN_REGS
+EfiCallEsalService (
+ IN EFI_GUID *ClassGuid,
+ IN UINT64 FunctionId,
+ IN UINT64 Arg2,
+ IN UINT64 Arg3,
+ IN UINT64 Arg4,
+ IN UINT64 Arg5,
+ IN UINT64 Arg6,
+ IN UINT64 Arg7,
+ IN UINT64 Arg8
+ )
+/*++
+
+Routine Description:
+
+ Call module that is not linked direclty to this module. This code is IP
+ relative and hides the binding issues of virtual or physical calling. The
+ function that gets dispatched has extra arguments that include the registered
+ module global and a boolean flag to indicate if the system is in virutal mode.
+
+Arguments:
+ ClassGuid - GUID of function
+ FunctionId - Function in ClassGuid to call
+ Arg2 - Argument 2 ClassGuid/FunctionId defined
+ Arg3 - Argument 3 ClassGuid/FunctionId defined
+ Arg4 - Argument 4 ClassGuid/FunctionId defined
+ Arg5 - Argument 5 ClassGuid/FunctionId defined
+ Arg6 - Argument 6 ClassGuid/FunctionId defined
+ Arg7 - Argument 7 ClassGuid/FunctionId defined
+ Arg8 - Argument 8 ClassGuid/FunctionId defined
+
+Returns:
+ Status of ClassGuid/FuncitonId
+
+--*/
+;
+
+#endif
diff --git a/EDK/Foundation/Library/Dxe/Include/Ipf/SalDriverLib.h b/EDK/Foundation/Library/Dxe/Include/Ipf/SalDriverLib.h
new file mode 100644
index 0000000..c294706
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/Include/Ipf/SalDriverLib.h
@@ -0,0 +1,1454 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ SalDriverLib.h
+
+Abstract:
+
+ SAL Driver Lib
+
+Revision History
+
+--*/
+
+#ifndef _SAL_DRIVER_LIB_H_
+#define _SAL_DRIVER_LIB_H_
+
+#include "Tiano.h"
+#include "EfiDriverLib.h"
+#include "SalApi.h"
+
+#include EFI_PROTOCOL_DEFINITION (ExtendedSalBootService)
+#include EFI_PROTOCOL_DEFINITION (ExtendedSalGuid)
+
+//
+// Assembly Functions
+//
+SAL_RETURN_REGS
+LibGetEsalPhyData (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Get Esal global data in physical mode.
+
+Arguments:
+
+ None
+
+Returns:
+
+ Output regs
+
+--*/
+;
+
+SAL_RETURN_REGS
+LibGetEsalVirtData (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Get Esal global data in virtual mode.
+
+Arguments:
+
+ None
+
+Returns:
+
+ Output regs
+
+--*/
+;
+
+SAL_RETURN_REGS
+LibSetEsalPhyData (
+ IN VOID *Ptr,
+ IN UINT64 GP
+ )
+/*++
+
+Routine Description:
+
+ Set Esal global data in physical mode.
+
+Arguments:
+
+ Ptr - Pointer to the data
+ GP - Global pointer
+
+Returns:
+
+ Output regs
+
+--*/
+;
+
+SAL_RETURN_REGS
+LibSetEsalVirtData (
+ IN VOID *Ptr,
+ IN UINT64 GP
+ )
+/*++
+
+Routine Description:
+
+ Set Esal global data in virtual mode.
+
+Arguments:
+
+ Ptr - Pointer to the data
+ GP - Global pointer
+
+Returns:
+
+ Output regs
+
+--*/
+;
+
+SAL_RETURN_REGS
+LibGetGlobalPhyData (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Get Esal global data in physical mode.
+
+Arguments:
+
+ None
+
+Returns:
+
+ Output regs
+
+--*/
+;
+
+SAL_RETURN_REGS
+LibGetGlobalVirtData (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Get Esal global data in virtual mode.
+
+Arguments:
+
+ None
+
+Returns:
+
+ Output regs
+
+--*/
+;
+
+SAL_RETURN_REGS
+LibSetGlobalPhyData (
+ IN VOID *Ptr,
+ IN UINT64 GP
+ )
+/*++
+
+Routine Description:
+
+ Set Esal global data in physical mode.
+
+Arguments:
+
+ Ptr - Pointer to the data
+ GP - Global pointer
+
+Returns:
+
+ Output regs
+
+--*/
+;
+
+SAL_RETURN_REGS
+LibSetGlobalVirtData (
+ IN VOID *Ptr,
+ IN UINT64 GP
+ )
+/*++
+
+Routine Description:
+
+ Set Esal global data in virtual mode.
+
+Arguments:
+
+ Ptr - Pointer to the data
+ GP - Global pointer
+
+Returns:
+
+ Output regs
+
+--*/
+;
+
+SAL_RETURN_REGS
+GetIrrData (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Get interrupt request register.
+
+Arguments:
+
+ None
+
+Returns:
+
+ Output regs
+
+--*/
+;
+
+VOID
+PrepareApsForHandOverToOS (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Prepare AP info for hand over to OS.
+
+Arguments:
+
+ None
+
+Returns:
+
+ None
+
+--*/
+;
+
+VOID
+HandOverApsToOS (
+ IN UINT64 a1,
+ IN UINT64 a2,
+ IN UINT64 a3
+ )
+/*++
+
+Routine Description:
+
+ Hand over AP info to OS.
+
+Arguments:
+
+ a1 - Address to call into
+
+ a2 - GP
+
+ a3 - Undefined
+
+Returns:
+
+ None
+
+--*/
+;
+
+SAL_RETURN_REGS
+GetPsrData (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Get PSR register.
+
+Arguments:
+
+ None
+
+Returns:
+
+ Output regs.
+
+--*/
+;
+
+SAL_RETURN_REGS
+GetProcIdData (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Get LID
+
+Arguments:
+
+ None
+
+Returns:
+
+ Output regs
+
+--*/
+;
+
+VOID
+SwitchCpuStack (
+ IN UINT64 NewBsp,
+ IN UINT64 OldBsp
+ )
+/*++
+
+Routine Description:
+
+ Switch BSP
+
+Arguments:
+
+ NewBsp - New BSP index
+ OldBsp - Old BSP index
+
+Returns:
+
+ None
+
+--*/
+;
+
+//
+// SAL Reset Class
+//
+VOID
+SalResetSystem (
+ IN EFI_RESET_TYPE ResetType,
+ IN EFI_STATUS ResetStatus,
+ IN UINTN DataSize,
+ IN CHAR16 *ResetData
+ )
+/*++
+
+Routine Description:
+
+ Reset system
+
+Arguments:
+
+ ResetType - Reset type
+ ResetStatus - Reset status
+ DataSize - Size of ResetData
+ ResetData - Description string
+
+Returns:
+
+ None
+
+--*/
+;
+
+//
+// PAL PROC Class
+//
+SAL_RETURN_REGS
+SalPalProc (
+ IN UINT64 Arg1,
+ IN UINT64 Arg2,
+ IN UINT64 Arg3,
+ IN UINT64 Arg4
+ )
+/*++
+
+Routine Description:
+
+ Call pal proc.
+
+Arguments:
+
+ Arg1 - Pal call index
+ Arg2 - First arg
+ Arg3 - Second arg
+ Arg4 - Third arg
+
+Returns:
+
+ Output regs
+
+--*/
+;
+
+SAL_RETURN_REGS
+SalRegisterNewPalEntry (
+ IN BOOLEAN PhysicalPalAddress,
+ IN EFI_PHYSICAL_ADDRESS NewPalAddress
+ )
+/*++
+
+Routine Description:
+
+ Register Pal entry.
+
+Arguments:
+
+ PhysicalPalAddress - The address is physical or virtual
+ NewPalAddress - New Pal entry address
+
+Returns:
+
+ Output regs
+
+--*/
+;
+
+SAL_RETURN_REGS
+SalGetPalEntryPointer (
+ IN BOOLEAN PhysicalPalAddress
+ )
+/*++
+
+Routine Description:
+
+ Get Pal entry.
+
+Arguments:
+
+ PhysicalPalAddress - The address is physical or virtual
+
+Returns:
+
+ Output regs
+
+--*/
+;
+
+//
+// SAL MTC Class
+//
+EFI_STATUS
+SalGetNextHighMonotonicCount (
+ OUT UINT32 *HighCount
+ )
+/*++
+
+Routine Description:
+
+ Get next high 32 bits of monotonic count.
+
+Arguments:
+
+ HighCount - High 32 bits of monotonic count.
+
+Returns:
+
+ Status code
+
+--*/
+;
+
+//
+// SAL BASE Class
+//
+SAL_RETURN_REGS
+SalProcSetVectors (
+ IN UINT64 SalVectorType,
+ IN UINT64 PhyAddr1,
+ IN UINT64 Gp1,
+ IN UINT64 LengthCs1,
+ IN UINT64 PhyAddr2,
+ IN UINT64 Gp2,
+ IN UINT64 LengthCs2
+ )
+/*++
+
+Routine Description:
+
+ Set vectors.
+
+Arguments:
+
+ SalVectorType - Vector type
+ PhyAddr1 - OS MCA entry point
+ Gp1 - GP for OS MCA entry
+ LengthCs1 - Length of OS MCA
+ PhyAddr2 - OS INIT entry point
+ Gp2 - GP for OS Init entry
+ LengthCs2 - Length of OS INIT
+
+Returns:
+
+ Output regs
+
+--*/
+;
+
+SAL_RETURN_REGS
+SalProcMcRendez (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Mc rendezvous function.
+
+Arguments:
+
+ None
+
+Returns:
+
+ Output regs
+
+--*/
+;
+
+SAL_RETURN_REGS
+SalProcMcSetParams (
+ IN UINT64 ParamType,
+ IN UINT64 IntOrMem,
+ IN UINT64 IntOrMemVal,
+ IN UINT64 Timeout,
+ IN UINT64 McaOpt
+ )
+/*++
+
+Routine Description:
+
+ Set MCA parameters.
+
+Arguments:
+
+ ParamType - Parameter type
+ IntOrMem - Interrupt or memory address
+ IntOrMemVal - Interrupt number or memory address value
+ Timeout - Time out value
+ McaOpt - Option for MCA
+
+Returns:
+
+ Output regs
+
+--*/
+;
+
+SAL_RETURN_REGS
+EsalProcGetVectors (
+ IN UINT64 VectorType
+ )
+/*++
+
+Routine Description:
+
+ Get OS MCA vector.
+
+Arguments:
+
+ VectorType - Vector type
+
+Returns:
+
+ Output regs
+
+--*/
+;
+
+SAL_RETURN_REGS
+EsalProcMcGetParams (
+ IN UINT64 ParamInfoType
+ )
+/*++
+
+Routine Description:
+
+ Get MCA parameter.
+
+Arguments:
+
+ ParamInfoType - Parameter info type
+
+Returns:
+
+ Output regs
+
+--*/
+;
+
+SAL_RETURN_REGS
+EsalProcMcGetMcParams (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Get MCA parameter.
+
+Arguments:
+
+
+Returns:
+
+ Output regs
+
+--*/
+;
+
+SAL_RETURN_REGS
+EsalProcGetMcCheckinFlags (
+ IN UINT64 ProcessorUnit
+ )
+/*++
+
+Routine Description:
+
+ Get process status.
+
+Arguments:
+
+ ProcessorUnit - Processor Index
+
+Returns:
+
+ Output regs
+
+--*/
+;
+
+//
+// Sal Base Class enums
+//
+typedef enum {
+ McaVector,
+ BspInitVector,
+ BootRendezVector,
+ ApInitVector
+} ESAL_GET_VECTOR_TYPE;
+
+//
+// Sal RTC Class
+//
+EFI_STATUS
+SalGetTime (
+ OUT EFI_TIME *Time,
+ OUT EFI_TIME_CAPABILITIES *Capabilities
+ )
+/*++
+
+Routine Description:
+
+ Returns the current time and date information, and the time-keeping
+ capabilities of the hardware platform.
+
+Arguments:
+
+ Time - A pointer to storage to receive a snapshot of the current time.
+ Capabilities - An optional pointer to a buffer to receive the real time clock device¡¯s
+ capabilities.
+
+Returns:
+
+ Status code
+
+--*/
+;
+
+EFI_STATUS
+SalSetTime (
+ OUT EFI_TIME *Time
+ )
+/*++
+
+Routine Description:
+
+ Sets the current local time and date information.
+
+Arguments:
+
+ Time - A pointer to the current time.
+
+Returns:
+
+ Status code
+
+--*/
+;
+
+EFI_STATUS
+SalGetWakeupTime (
+ OUT BOOLEAN *Enabled,
+ OUT BOOLEAN *Pending,
+ OUT EFI_TIME *Time
+ )
+/*++
+
+Routine Description:
+
+ Returns the current wakeup alarm clock setting.
+
+Arguments:
+
+ Enabled - Indicates if the alarm is currently enabled or disabled.
+ Pending - Indicates if the alarm signal is pending and requires acknowledgement.
+ Time - The current alarm setting.
+
+Returns:
+
+ Status code
+
+--*/
+;
+
+EFI_STATUS
+SalSetWakeupTime (
+ IN BOOLEAN Enable,
+ IN EFI_TIME *Time
+ )
+/*++
+
+Routine Description:
+
+ Sets the system wakeup alarm clock time.
+
+Arguments:
+
+ Enable - Enable or disable the wakeup alarm.
+ Time - If Enable is TRUE, the time to set the wakeup alarm for.
+ If Enable is FALSE, then this parameter is optional, and may be NULL.
+
+Returns:
+
+ Status code
+
+--*/
+;
+
+SAL_RETURN_REGS
+SalInitializeThreshold (
+ IN VOID *ThresholdStruct,
+ IN UINT64 Count,
+ IN UINT64 Duration
+ )
+/*++
+
+Routine Description:
+
+ Init threshold structure.
+
+Arguments:
+
+ ThresholdStruct - Threshold structure
+ Count - Threshold count
+ Duration - Duration
+
+Returns:
+
+ Output regs
+
+--*/
+;
+
+SAL_RETURN_REGS
+SalBumpThresholdCount (
+ IN VOID *ThresholdStruct,
+ IN UINT64 Count,
+ IN UINT64 Duration
+ )
+/*++
+
+Routine Description:
+
+ Bump threshold count.
+
+Arguments:
+
+ ThresholdStruct - Threshold structure
+ Count - Threshold count
+ Duration - Duration
+
+Returns:
+
+ Output regs
+
+--*/
+;
+
+SAL_RETURN_REGS
+SalGetThresholdCount (
+ IN VOID *ThresholdStruct,
+ IN UINT64 Count,
+ IN UINT64 Duration
+ )
+/*++
+
+Routine Description:
+
+ Get threshold structure.
+
+Arguments:
+
+ ThresholdStruct - Threshold structure
+ Count - Threshold count
+ Duration - Duration
+
+Returns:
+
+ Output regs
+
+--*/
+;
+
+//
+// Common Lib Function
+//
+EFI_STATUS
+RegisterEsalFunction (
+ IN UINT64 FunctionId,
+ IN EFI_GUID *ClassGuid,
+ IN SAL_INTERNAL_EXTENDED_SAL_PROC Function,
+ IN VOID *ModuleGlobal
+ )
+/*++
+
+Routine Description:
+
+ Register ESAL Class Function and it's asociated global.
+ This function is boot service only!
+
+Arguments:
+ FunctionId - ID of function to register
+ ClassGuid - GUID of function class
+ Function - Function to register under ClassGuid/FunctionId pair
+ ModuleGlobal - Module global for Function.
+
+Returns:
+ EFI_SUCCESS - If ClassGuid/FunctionId Function was registered.
+
+--*/
+;
+
+EFI_STATUS
+EfiInitializeSalDriverLib (
+ IN BOOLEAN Runtime
+ )
+/*++
+
+Routine Description:
+
+ Initialize Sal driver lib.
+
+Arguments:
+ Runtime - At runtime or not?
+
+Returns:
+ Status code
+
+--*/
+;
+
+//
+// MCA PMI INIT Registeration Functions.
+//
+EFI_STATUS
+LibRegisterMcaFunction (
+ IN EFI_SAL_MCA_HANDLER McaHandler,
+ IN VOID *ModuleGlobal,
+ IN BOOLEAN MakeFirst,
+ IN BOOLEAN MakeLast
+ )
+/*++
+
+Routine Description:
+
+ Register MCA handler.
+
+Arguments:
+ McaHandler - MCA handler
+ ModuleGlobal - Module global for function
+ MakeFirst - Make it as first?
+ MakeLast - Make it as last?
+
+Returns:
+ Status code
+
+--*/
+;
+
+EFI_STATUS
+LibRegisterPmiFunction (
+ IN EFI_SAL_PMI_HANDLER PmiHandler,
+ IN VOID *ModuleGlobal,
+ IN BOOLEAN MakeFirst,
+ IN BOOLEAN MakeLast
+ )
+/*++
+
+Routine Description:
+
+ Register PMI handler.
+
+Arguments:
+ PmiHandler - PMI handler
+ ModuleGlobal - Module global for function
+ MakeFirst - Make it as first?
+ MakeLast - Make it as last?
+
+Returns:
+ Status code
+
+--*/
+;
+
+EFI_STATUS
+LibRegisterInitFunction (
+ IN EFI_SAL_INIT_HANDLER InitHandler,
+ IN VOID *ModuleGlobal,
+ IN BOOLEAN MakeFirst,
+ IN BOOLEAN MakeLast
+ )
+/*++
+
+Routine Description:
+
+ Register INIT handler.
+
+Arguments:
+ InitHandler - INIT handler
+ ModuleGlobal - Module global for function
+ MakeFirst - Make it as first?
+ MakeLast - Make it as last?
+
+Returns:
+ Status code
+
+--*/
+;
+
+//
+// Base IO Class Functions
+//
+EFI_STATUS
+ESalIoRead (
+ IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
+ IN UINT64 Address,
+ IN UINTN Count,
+ IN OUT VOID *Buffer
+ )
+/*++
+
+Routine Description:
+
+ Io read operation.
+
+Arguments:
+
+ Width - Width of read operation
+ Address - Start IO address to read
+ Count - Read count
+ Buffer - Buffer to store result
+
+Returns:
+
+ Status code
+
+--*/
+;
+
+EFI_STATUS
+ESalIoWrite (
+ IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
+ IN UINT64 Address,
+ IN UINTN Count,
+ IN OUT VOID *Buffer
+ )
+/*++
+
+Routine Description:
+
+ Io write operation.
+
+Arguments:
+
+ Width - Width of write operation
+ Address - Start IO address to write
+ Count - Write count
+ Buffer - Buffer to write to the address
+
+Returns:
+
+ Status code
+
+--*/
+;
+
+EFI_STATUS
+ESalMemRead (
+ IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
+ IN UINT64 Address,
+ IN UINTN Count,
+ IN OUT VOID *Buffer
+ )
+/*++
+
+Routine Description:
+ Perform a Memory mapped IO read into Buffer.
+
+Arguments:
+ Width - Width of each read transaction.
+ Address - Memory mapped IO address to read
+ Count - Number of Width quanta to read
+ Buffer - Buffer to read data into. size is Width * Count
+
+Returns:
+ Status code
+
+--*/
+;
+
+EFI_STATUS
+ESalMemWrite (
+ IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
+ IN UINT64 Address,
+ IN UINTN Count,
+ IN OUT VOID *Buffer
+ )
+/*++
+
+Routine Description:
+ Perform a memory mapped IO write into Buffer.
+
+Arguments:
+ Width - Width of write transaction, and repeat operation to use
+ Address - IO address to write
+ Count - Number of times to write the IO address.
+ Buffer - Buffer to write data from. size is Width * Count
+
+Returns:
+ Status code
+
+--*/
+;
+
+//
+// PCI Class Functions
+//
+SAL_RETURN_REGS
+SalPCIConfigRead (
+ IN UINT64 Address,
+ IN UINT64 Size
+ )
+/*++
+
+Routine Description:
+ Pci config space read.
+
+Arguments:
+ Address - PCI address to read
+ Size - Size to read
+
+Returns:
+ Output regs
+
+--*/
+;
+
+SAL_RETURN_REGS
+SalPCIConfigWrite (
+ IN UINT64 Address,
+ IN UINT64 Size,
+ IN UINT64 Value
+ )
+/*++
+
+Routine Description:
+ Pci config space write.
+
+Arguments:
+ Address - PCI address to write
+ Size - Size to write
+ Value - Value to write
+
+Returns:
+ Output regs
+
+--*/
+;
+
+//
+// MP Class Functions
+//
+SAL_RETURN_REGS
+LibMPAddCpuData (
+ IN UINT64 CpuGlobalId,
+ IN BOOLEAN Enabled,
+ IN UINT64 PalCompatability
+ )
+/*++
+
+Routine Description:
+ Add CPU data.
+
+Arguments:
+ CpuGlobalId - CPU ID
+ Enabled - Enabled or not
+ PalCompatability - Pal compatability
+
+Returns:
+ Output regs
+
+--*/
+;
+
+SAL_RETURN_REGS
+LibMPRemoveCpuData (
+ IN UINT64 CpuGlobalId
+ )
+/*++
+
+Routine Description:
+ Remove CPU data.
+
+Arguments:
+ CpuGlobalId - CPU ID
+
+Returns:
+ Output regs
+
+--*/
+;
+
+SAL_RETURN_REGS
+LibMPModifyCpuData (
+ IN UINT64 CpuGlobalId,
+ IN BOOLEAN Enabled,
+ IN UINT64 PalCompatability
+ )
+/*++
+
+Routine Description:
+ Modify CPU data.
+
+Arguments:
+ CpuGlobalId - CPU ID
+ Enabled - Enabled or not
+ PalCompatability - Pal compatability
+
+Returns:
+ Output regs
+
+--*/
+;
+
+SAL_RETURN_REGS
+LibMPGetCpuDataByID (
+ IN UINT64 CpuGlobalId,
+ IN BOOLEAN IndexByEnabledCpu
+ )
+/*++
+
+Routine Description:
+ Get CPU data.
+
+Arguments:
+ CpuGlobalId - CPU ID
+ IndexByEnabledCpu - Whether indexed by enabled CPU
+
+Returns:
+ Output regs
+
+--*/
+;
+
+SAL_RETURN_REGS
+LibMPGetCpuDataByIndex (
+ IN UINT64 Index,
+ IN BOOLEAN IndexByEnabledCpu
+ )
+/*++
+
+Routine Description:
+ Get CPU data.
+
+Arguments:
+ Index - CPU index
+ IndexByEnabledCpu - Whether indexed by enabled CPU
+
+Returns:
+ Output regs
+
+--*/
+;
+
+SAL_RETURN_REGS
+LibMPSendIpi (
+ IN UINT64 ProcessorNumber,
+ IN UINT64 VectorNumber,
+ IN EFI_DELIVERY_MODE DeliveryMode,
+ IN BOOLEAN IRFlag
+ )
+/*++
+
+Routine Description:
+ Send IPI.
+
+Arguments:
+ ProcessorNumber - Processor number
+ VectorNumber - Vector number
+ DeliveryMode - Delivery mode
+ IRFlag - Interrupt Redirection flag
+
+Returns:
+ Output regs
+
+--*/
+;
+
+SAL_RETURN_REGS
+LibMpCurrentProcessor (
+ IN BOOLEAN IndexByEnabledCpu
+ )
+/*++
+
+Routine Description:
+ Get current processor index.
+
+Arguments:
+ IndexByEnabledCpu - Whether indexed by enabled CPU
+
+Returns:
+ Output regs
+
+--*/
+;
+
+SAL_RETURN_REGS
+LibGetNumProcessors (
+ VOID
+ )
+/*++
+
+Routine Description:
+ Get number of processors.
+
+Arguments:
+ None
+
+Returns:
+ Output regs
+
+--*/
+;
+
+SAL_RETURN_REGS
+LibMpSaveMinStatePointer (
+ IN UINT64 CpuGlobalId,
+ IN EFI_PHYSICAL_ADDRESS MinStatePointer
+ )
+/*++
+
+Routine Description:
+ Register pointer to save min state.
+
+Arguments:
+ CpuGlobalId - CPU global ID
+ MinStatePointer - Pointer to save min state
+
+Returns:
+ Output regs
+
+--*/
+;
+
+SAL_RETURN_REGS
+LibMpRestoreMinStatePointer (
+ IN UINT64 CpuGlobalId
+ )
+/*++
+
+Routine Description:
+ Restore pointer to save min state.
+
+Arguments:
+ CpuGlobalId - CPU global ID
+
+Returns:
+ Output regs
+
+--*/
+;
+
+//
+// MCA Class Functions
+//
+EFI_STATUS
+LibMcaGetStateInfo (
+ IN UINT64 CpuId,
+ OUT EFI_PHYSICAL_ADDRESS *StateBufferPointer,
+ OUT UINT64 *RequiredStateBufferSize
+ )
+/*++
+
+Routine Description:
+ MCA get state info.
+
+Arguments:
+ CpuId - CPU ID
+ StateBufferPointer - Pointer of state buffer
+ RequiredStateBufferSize - Size of required state buffer
+
+Returns:
+ Status code
+
+--*/
+;
+
+EFI_STATUS
+LibMcaRegisterCpu (
+ IN UINT64 CpuId,
+ IN EFI_PHYSICAL_ADDRESS StateBufferAddress
+ )
+/*++
+
+Routine Description:
+ MCA register CPU state info.
+
+Arguments:
+ CpuId - CPU ID
+ StateBufferAddress - Pointer of state buffer
+
+Returns:
+ Status code
+
+--*/
+;
+
+//
+// SAL ELOG Functions
+//
+EFI_STATUS
+LibSalGetStateInfo (
+ IN UINT64 McaType,
+ IN UINT8 *McaBuffer,
+ OUT UINTN *Size
+ )
+/*++
+
+Routine Description:
+ Get state info.
+
+Arguments:
+ McaType - MCA type
+ McaBuffer - Info buffer provided by caller
+ Size - Size of info
+
+Returns:
+ Status code
+
+--*/
+;
+
+EFI_STATUS
+LibSalGetStateInfoSize (
+ IN UINT64 McaType,
+ OUT UINTN *Size
+ )
+/*++
+
+Routine Description:
+ Get state info size.
+
+Arguments:
+ McaType - MCA type
+ Size - Size required
+
+Returns:
+ Status code
+
+--*/
+;
+
+EFI_STATUS
+LibSalClearStateInfo (
+ IN UINT64 McaType
+ )
+/*++
+
+Routine Description:
+ Clear state info.
+
+Arguments:
+ McaType - MCA type
+
+Returns:
+ Status code
+
+--*/
+;
+
+EFI_STATUS
+LibEsalGetStateBuffer (
+ IN UINT64 McaType,
+ OUT UINT8 **McaBuffer,
+ OUT UINTN *Index
+ )
+/*++
+
+Routine Description:
+ Get state buffer.
+
+Arguments:
+ McaType - MCA type
+ McaBuffer - MCA buffer
+ Index - CPU index
+
+Returns:
+ Status code
+
+--*/
+;
+
+EFI_STATUS
+LibEsalSaveStateBuffer (
+ IN UINT64 McaType
+ )
+/*++
+
+Routine Description:
+ Save state buffer.
+
+Arguments:
+ McaType - MCA type
+
+Returns:
+ Status code
+
+--*/
+;
+
+#endif
diff --git a/EDK/Foundation/Library/Dxe/Include/LinkedList.h b/EDK/Foundation/Library/Dxe/Include/LinkedList.h
new file mode 100644
index 0000000..4e1d140
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/Include/LinkedList.h
@@ -0,0 +1,310 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ LinkedList.h
+
+Abstract:
+
+ This implementation of a linked list provides data structures for the
+ list itself and for list nodes. It provides operations for initializing
+ the list, modifying the list, and walking the list.
+
+--*/
+
+//
+// Prevent multiple includes in the same source file
+//
+#ifndef _LINKED_LIST_H_
+#define _LINKED_LIST_H_
+
+
+typedef struct _EFI_LIST_ENTRY {
+ struct _EFI_LIST_ENTRY *ForwardLink;
+ struct _EFI_LIST_ENTRY *BackLink;
+} EFI_LIST_ENTRY;
+
+typedef EFI_LIST_ENTRY EFI_LIST;
+typedef EFI_LIST_ENTRY EFI_LIST_NODE;
+
+#define INITIALIZE_LIST_HEAD_VARIABLE(ListHead) {&ListHead, &ListHead}
+
+//
+// EFI_FIELD_OFFSET - returns the byte offset to a field within a structure
+//
+
+#define EFI_FIELD_OFFSET(TYPE,Field) ((UINTN)(&(((TYPE *) 0)->Field)))
+
+//
+// A lock structure
+//
+
+typedef struct {
+ EFI_TPL Tpl;
+ EFI_TPL OwnerTpl;
+ UINTN Lock;
+} FLOCK;
+
+VOID
+InitializeListHead (
+ EFI_LIST_ENTRY *List
+ )
+/*++
+
+Routine Description:
+
+ Initialize the head of the List. The caller must allocate the memory
+ for the EFI_LIST. This function must be called before the other linked
+ list macros can be used.
+
+Arguments:
+
+ List - Pointer to list head to initialize
+
+Returns:
+
+ None.
+
+--*/
+;
+
+BOOLEAN
+IsListEmpty (
+ EFI_LIST_ENTRY *List
+ )
+/*++
+
+Routine Description:
+
+ Return TRUE is the list contains zero nodes. Otherzise return FALSE.
+ The list must have been initialized with InitializeListHead () before using
+ this function.
+
+Arguments:
+
+ List - Pointer to list head to test
+
+
+Returns:
+
+ Return TRUE is the list contains zero nodes. Otherzise return FALSE.
+
+--*/
+;
+
+VOID
+RemoveEntryList (
+ EFI_LIST_ENTRY *Entry
+ )
+/*++
+
+Routine Description:
+
+ Remove Node from the doubly linked list. It is the caller's responsibility
+ to free any memory used by the entry if needed. The list must have been
+ initialized with InitializeListHead () before using this function.
+
+Arguments:
+
+ Entry - Element to remove from the list.
+
+Returns:
+
+ None
+
+--*/
+;
+
+VOID
+InsertTailList (
+ EFI_LIST_ENTRY *ListHead,
+ EFI_LIST_ENTRY *Entry
+ )
+/*++
+
+Routine Description:
+
+ Insert a Node into the end of a doubly linked list. The list must have
+ been initialized with InitializeListHead () before using this function.
+
+Arguments:
+
+ ListHead - Head of doubly linked list
+
+ Entry - Element to insert at the end of the list.
+
+Returns:
+
+ None
+
+--*/
+;
+
+VOID
+InsertHeadList (
+ EFI_LIST_ENTRY *ListHead,
+ EFI_LIST_ENTRY *Entry
+ )
+/*++
+
+Routine Description:
+
+ Insert a Node into the start of a doubly linked list. The list must have
+ been initialized with InitializeListHead () before using this function.
+
+Arguments:
+
+ ListHead - Head of doubly linked list
+
+ Entry - Element to insert to beginning of list
+
+Returns:
+
+ None
+
+--*/
+;
+
+VOID
+SwapListEntries (
+ EFI_LIST_ENTRY *Entry1,
+ EFI_LIST_ENTRY *Entry2
+ )
+/*++
+
+Routine Description:
+
+ Swap the location of the two elements of a doubly linked list. Node2
+ is placed in front of Node1. The list must have been initialized with
+ InitializeListHead () before using this function.
+
+Arguments:
+
+ Entry1 - Element in the doubly linked list in front of Node2.
+
+ Entry2 - Element in the doubly linked list behind Node1.
+
+Returns:
+
+ None
+
+--*/
+;
+
+EFI_LIST_ENTRY *
+GetFirstNode (
+ EFI_LIST_ENTRY *List
+ )
+/*++
+
+Routine Description:
+
+ Return the first node pointed to by the list head. The list must
+ have been initialized with InitializeListHead () before using this
+ function and must contain data.
+
+Arguments:
+
+ List - The head of the doubly linked list.
+
+Returns:
+
+ Pointer to the first node, if the list contains nodes. The list will
+ return a null value--that is, the value of List--when the list is empty.
+ See the description of IsNull for more information.
+
+
+--*/
+;
+
+EFI_LIST_ENTRY *
+GetNextNode (
+ EFI_LIST_ENTRY *List,
+ EFI_LIST_ENTRY *Node
+ )
+/*++
+
+Routine Description:
+
+ Returns the node following Node in the list. The list must
+ have been initialized with InitializeListHead () before using this
+ function and must contain data.
+
+Arguments:
+
+ List - The head of the list. MUST NOT be the literal value NULL.
+ Node - The node in the list. This value MUST NOT be the literal value NULL.
+ See the description of IsNull for more information.
+
+Returns:
+
+ Pointer to the next node, if one exists. Otherwise, returns a null value,
+ which is actually a pointer to List.
+ See the description of IsNull for more information.
+
+--*/
+;
+
+BOOLEAN
+IsNull (
+ EFI_LIST_ENTRY *List,
+ EFI_LIST_ENTRY *Node
+ )
+/*++
+
+Routine Description:
+
+ Determines whether the given node is null. Note that Node is null
+ when its value is equal to the value of List. It is an error for
+ Node to be the literal value NULL [(VOID*)0x0].
+
+Arguments:
+
+ List - The head of the list. MUST NOT be the literal value NULL.
+ Node - The node to test. MUST NOT be the literal value NULL. See
+ the description above.
+
+Returns:
+
+ Returns true if the node is null.
+
+--*/
+;
+
+BOOLEAN
+IsNodeAtEnd (
+ EFI_LIST_ENTRY *List,
+ EFI_LIST_ENTRY *Node
+ )
+/*++
+
+Routine Description:
+
+ Determines whether the given node is at the end of the list. Used
+ to walk the list. The list must have been initialized with
+ InitializeListHead () before using this function and must contain
+ data.
+
+Arguments:
+
+ List - The head of the list. MUST NOT be the literal value NULL.
+ Node - The node to test. MUST NOT be the literal value NULL.
+ See the description of IsNull for more information.
+
+Returns:
+
+ Returns true if the list is the tail.
+
+--*/
+;
+
+#endif
diff --git a/EDK/Foundation/Library/Dxe/Include/RtDevicePath.h b/EDK/Foundation/Library/Dxe/Include/RtDevicePath.h
new file mode 100644
index 0000000..765b575
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/Include/RtDevicePath.h
@@ -0,0 +1,231 @@
+/*++
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ RtDevicePath.h
+
+Abstract:
+
+ Device Path services. The thing to remember is device paths are built out of
+ nodes. The device path is terminated by an end node that is length
+ sizeof(EFI_DEVICE_PATH_PROTOCOL). That would be why there is sizeof(EFI_DEVICE_PATH_PROTOCOL)
+ all over this file.
+
+ The only place where multi-instance device paths are supported is in
+ environment varibles. Multi-instance device paths should never be placed
+ on a Handle.
+
+--*/
+#ifndef _RT_DEVICE_PATH_H_
+#define _RT_DEVICE_PATH_H_
+
+BOOLEAN
+RtEfiIsDevicePathMultiInstance (
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ )
+/*++
+
+Routine Description:
+ Return TRUE is this is a multi instance device path.
+
+Arguments:
+ DevicePath - A pointer to a device path data structure.
+
+
+Returns:
+ TRUE - If DevicePath is multi instance.
+ FALSE - If DevicePath is not multi instance.
+
+--*/
+;
+
+EFI_DEVICE_PATH_PROTOCOL *
+RtEfiDevicePathInstance (
+ IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath,
+ OUT UINTN *Size
+ )
+/*++
+
+Routine Description:
+ Function retrieves the next device path instance from a device path data structure.
+
+Arguments:
+ DevicePath - A pointer to a device path data structure.
+
+ Size - A pointer to the size of a device path instance in bytes.
+
+Returns:
+
+ This function returns a pointer to the current device path instance.
+ In addition, it returns the size in bytes of the current device path instance in Size,
+ and a pointer to the next device path instance in DevicePath.
+ If there are no more device path instances in DevicePath, then DevicePath will be set to NULL.
+
+--*/
+;
+
+UINTN
+RtEfiDevicePathSize (
+ IN EFI_DEVICE_PATH_PROTOCOL *DevPath
+ )
+/*++
+
+Routine Description:
+
+ Calculate the size of a whole device path.
+
+Arguments:
+
+ DevPath - The pointer to the device path data.
+
+Returns:
+
+ Size of device path data structure..
+
+--*/
+;
+
+EFI_DEVICE_PATH_PROTOCOL *
+RtEfiAppendDevicePath (
+ IN EFI_DEVICE_PATH_PROTOCOL *Src1,
+ IN EFI_DEVICE_PATH_PROTOCOL *Src2
+ )
+/*++
+
+Routine Description:
+ Function is used to append a Src1 and Src2 together.
+
+Arguments:
+ Src1 - A pointer to a device path data structure.
+
+ Src2 - A pointer to a device path data structure.
+
+Returns:
+
+ A pointer to the new device path is returned.
+ NULL is returned if space for the new device path could not be allocated from pool.
+ It is up to the caller to free the memory used by Src1 and Src2 if they are no longer needed.
+
+--*/
+;
+
+EFI_DEVICE_PATH_PROTOCOL *
+RtEfiDevicePathFromHandle (
+ IN EFI_HANDLE Handle
+ )
+/*++
+
+Routine Description:
+
+ Locate device path protocol interface on a device handle.
+
+Arguments:
+
+ Handle - The device handle
+
+Returns:
+
+ Device path protocol interface located.
+
+--*/
+;
+
+EFI_DEVICE_PATH_PROTOCOL *
+RtEfiDuplicateDevicePath (
+ IN EFI_DEVICE_PATH_PROTOCOL *DevPath
+ )
+/*++
+
+Routine Description:
+ Duplicate a new device path data structure from the old one.
+
+Arguments:
+ DevPath - A pointer to a device path data structure.
+
+Returns:
+ A pointer to the new allocated device path data.
+ Caller must free the memory used by DevicePath if it is no longer needed.
+
+--*/
+;
+
+EFI_DEVICE_PATH_PROTOCOL *
+RtEfiAppendDevicePathNode (
+ IN EFI_DEVICE_PATH_PROTOCOL *Src1,
+ IN EFI_DEVICE_PATH_PROTOCOL *Src2
+ )
+/*++
+
+Routine Description:
+ Function is used to append a device path node to the end of another device path.
+
+Arguments:
+ Src1 - A pointer to a device path data structure.
+
+ Src2 - A pointer to a device path data structure.
+
+Returns:
+ This function returns a pointer to the new device path.
+ If there is not enough temporary pool memory available to complete this function,
+ then NULL is returned.
+
+
+--*/
+;
+
+EFI_DEVICE_PATH_PROTOCOL *
+RtEfiFileDevicePath (
+ IN EFI_HANDLE Device OPTIONAL,
+ IN CHAR16 *FileName
+ )
+/*++
+
+Routine Description:
+ Create a device path that appends a MEDIA_DEVICE_PATH with
+ FileNameGuid to the device path of DeviceHandle.
+
+Arguments:
+ Device - Optional Device Handle to use as Root of the Device Path
+
+ FileName - FileName
+
+Returns:
+ EFI_DEVICE_PATH_PROTOCOL that was allocated from dynamic memory
+ or NULL pointer.
+
+--*/
+;
+
+EFI_DEVICE_PATH_PROTOCOL *
+RtEfiAppendDevicePathInstance (
+ IN EFI_DEVICE_PATH_PROTOCOL *Src,
+ IN EFI_DEVICE_PATH_PROTOCOL *Instance
+ )
+/*++
+
+Routine Description:
+
+ Append a device path instance to another.
+
+Arguments:
+
+ Src - The device path instance to be appended with.
+ Instance - The device path instance appending the other.
+
+Returns:
+
+ The contaction of these two.
+
+--*/
+;
+
+#endif
diff --git a/EDK/Foundation/Library/Dxe/Include/SmmRuntimeLib.h b/EDK/Foundation/Library/Dxe/Include/SmmRuntimeLib.h
new file mode 100644
index 0000000..d60a029
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/Include/SmmRuntimeLib.h
@@ -0,0 +1,75 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ SmmRuntimeLib.h
+
+Abstract:
+
+ SMM Related prototypes that can be referenced for Preboot Configuration only.
+
+--*/
+
+#ifndef _SMM_RUNTIME_LIB_H_
+#define _SMM_RUNTIME_LIB_H_
+
+#include "Tiano.h"
+#include "EfiRuntimeLib.h"
+
+BOOLEAN
+EfiInSmm (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Test whether in Smm mode currently.
+
+Arguments:
+
+ None
+
+Returns:
+
+ TRUE - In Smm mode
+ FALSE - Not in Smm mode
+
+--*/
+;
+
+EFI_STATUS
+RegisterSmmRuntimeDriver (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable,
+ OUT EFI_HANDLE *SmmImageHandle
+ )
+/*++
+
+Routine Description:
+
+ Registers a Driver with the SMM.
+
+Arguments:
+
+ ImageHandle - The firmware allocated handle for the EFI image.
+ SystemTable - A pointer to the EFI System Table.
+ SmmImageHandle - Image handle returned by the SMM driver.
+
+Returns:
+
+ Status code
+
+--*/
+;
+
+#endif
diff --git a/EDK/Foundation/Library/Dxe/Include/x64/CpuFuncs.h b/EDK/Foundation/Library/Dxe/Include/x64/CpuFuncs.h
new file mode 100644
index 0000000..a39647d
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/Include/x64/CpuFuncs.h
@@ -0,0 +1,262 @@
+/*++
+
+Copyright (c) 2005 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ CpuFuncs.h
+
+Abstract:
+
+--*/
+
+#ifndef _CPU_FUNCS_H_
+#define _CPU_FUNCS_H_
+
+#define EFI_CPUID_SIGNATURE 0x0
+#define EFI_CPUID_VERSION_INFO 0x1
+#define EFI_CPUID_CACHE_INFO 0x2
+#define EFI_CPUID_SERIAL_NUMBER 0x3
+#define EFI_CPUID_EXTENDED_FUNCTION 0x80000000
+#define EFI_CPUID_EXTENDED_CPU_SIG 0x80000001
+#define EFI_CPUID_BRAND_STRING1 0x80000002
+#define EFI_CPUID_BRAND_STRING2 0x80000003
+#define EFI_CPUID_BRAND_STRING3 0x80000004
+
+//
+// CPUID version information masks
+// Note: leaving masks here is for the compatibility
+// use EfiCpuVersion (...) instead
+//
+
+#define EFI_CPUID_FAMILY 0x0F00
+#define EFI_CPUID_MODEL 0x00F0
+#define EFI_CPUID_STEPPING 0x000F
+
+#define EFI_CPUID_PENTIUM_M 0x0600
+#define EFI_CPUID_BANIAS 0x0090
+#define EFI_CPUID_DOTHAN 0x00D0
+#define EFI_CPUID_NETBURST 0x0F00
+
+#define EFI_MSR_IA32_PLATFORM_ID 0x17
+#define EFI_MSR_IA32_APIC_BASE 0x1B
+#define EFI_MSR_EBC_HARD_POWERON 0x2A
+#define EFI_MSR_EBC_SOFT_POWERON 0x2B
+#define BINIT_DRIVER_DISABLE 0x40
+#define INTERNAL_MCERR_DISABLE 0x20
+#define INITIATOR_MCERR_DISABLE 0x10
+#define EFI_MSR_EBC_FREQUENCY_ID 0x2C
+#define EFI_MSR_IA32_BIOS_UPDT_TRIG 0x79
+#define EFI_MSR_IA32_BIOS_SIGN_ID 0x8B
+#define EFI_MSR_PSB_CLOCK_STATUS 0xCD
+#define EFI_APIC_GLOBAL_ENABLE 0x800
+#define EFI_MSR_IA32_MISC_ENABLE 0x1A0
+#define LIMIT_CPUID_MAXVAL_ENABLE_BIT 0x00400000
+#define AUTOMATIC_THERMAL_CONTROL_ENABLE_BIT 0x00000008
+#define COMPATIBLE_FPU_OPCODE_ENABLE_BIT 0x00000004
+#define LOGICAL_PROCESSOR_PRIORITY_ENABLE_BIT 0x00000002
+#define FAST_STRING_ENABLE_BIT 0x00000001
+
+#define EFI_CACHE_VARIABLE_MTRR_BASE 0x200
+#define EFI_CACHE_VARIABLE_MTRR_END 0x20F
+#define EFI_CACHE_IA32_MTRR_DEF_TYPE 0x2FF
+#define EFI_CACHE_VALID_ADDRESS 0xFFFFFF000
+#define EFI_CACHE_MTRR_VALID 0x800
+#define EFI_CACHE_FIXED_MTRR_VALID 0x400
+#define EFI_MSR_VALID_MASK 0xFFFFFFFFF
+
+#define EFI_IA32_MTRR_FIX64K_00000 0x250
+#define EFI_IA32_MTRR_FIX16K_80000 0x258
+#define EFI_IA32_MTRR_FIX16K_A0000 0x259
+#define EFI_IA32_MTRR_FIX4K_C0000 0x268
+#define EFI_IA32_MTRR_FIX4K_C8000 0x269
+#define EFI_IA32_MTRR_FIX4K_D0000 0x26A
+#define EFI_IA32_MTRR_FIX4K_D8000 0x26B
+#define EFI_IA32_MTRR_FIX4K_E0000 0x26C
+#define EFI_IA32_MTRR_FIX4K_E8000 0x26D
+#define EFI_IA32_MTRR_FIX4K_F0000 0x26E
+#define EFI_IA32_MTRR_FIX4K_F8000 0x26F
+
+#define EFI_IA32_MCG_CAP 0x179
+#define EFI_IA32_MCG_CTL 0x17B
+#define EFI_IA32_MC0_CTL 0x400
+#define EFI_IA32_MC0_STATUS 0x401
+
+#define EFI_CACHE_UNCACHEABLE 0
+#define EFI_CACHE_WRITECOMBINING 1
+#define EFI_CACHE_WRITETHROUGH 4
+#define EFI_CACHE_WRITEPROTECTED 5
+#define EFI_CACHE_WRITEBACK 6
+
+//
+// Combine f(FamilyId), m(Model), s(SteppingId) to a single 32 bit number
+//
+#define EfiMakeCpuVersion(f, m, s) \
+ (((UINT32) (f) << 16) | ((UINT32) (m) << 8) | ((UINT32) (s)))
+
+
+typedef struct {
+ UINT32 HeaderVersion;
+ UINT32 UpdateRevision;
+ UINT32 Date;
+ UINT32 ProcessorId;
+ UINT32 Checksum;
+ UINT32 LoaderRevision;
+ UINT32 ProcessorFlags;
+ UINT32 DataSize;
+ UINT32 TotalSize;
+ UINT8 Reserved[12];
+} EFI_CPU_MICROCODE_HEADER;
+
+typedef struct {
+ UINT32 ExtSigCount;
+ UINT32 ExtChecksum;
+ UINT8 Reserved[12];
+ UINT32 ProcessorId;
+ UINT32 ProcessorFlags;
+ UINT32 Checksum;
+} EFI_CPU_MICROCODE_EXT_HEADER;
+
+typedef struct {
+ UINT32 RegEax;
+ UINT32 RegEbx;
+ UINT32 RegEcx;
+ UINT32 RegEdx;
+} EFI_CPUID_REGISTER;
+
+VOID
+EfiWriteMsr (
+ IN UINT32 Input,
+ IN UINT64 Value
+ )
+/*++
+
+Routine Description:
+
+ Write Cpu MSR
+
+Arguments:
+
+ Input -The index value to select the register
+ Value -The value to write to the selected register
+
+Returns:
+
+ None
+
+--*/
+;
+
+UINT64
+EfiReadMsr (
+ IN UINT32 Input
+ )
+/*++
+
+Routine Description:
+
+ Read Cpu MSR.
+
+Arguments:
+
+ Input: -The index value to select the register
+
+Returns:
+
+ Return the read data
+
+--*/
+;
+
+VOID
+EfiCpuid (
+ IN UINT32 RegEax,
+ OUT EFI_CPUID_REGISTER *Reg
+ )
+/*++
+
+Routine Description:
+
+ Get the Cpu info by excute the CPUID instruction.
+
+Arguments:
+
+ RegEax -The input value to put into register EAX
+ Reg -The Output value
+
+Returns:
+
+ None
+
+--*/
+;
+
+VOID
+EfiCpuVersion (
+ IN UINT16 *FamilyId, OPTIONAL
+ IN UINT8 *Model, OPTIONAL
+ IN UINT8 *SteppingId, OPTIONAL
+ IN UINT8 *Processor OPTIONAL
+ )
+/*++
+
+Routine Description:
+ Extract CPU detail version infomation
+
+Arguments:
+ FamilyId - FamilyId, including ExtendedFamilyId
+ Model - Model, including ExtendedModel
+ SteppingId - SteppingId
+ Processor - Processor
+
+--*/
+;
+
+UINT64
+EfiReadTsc (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Read Time stamp.
+
+Arguments:
+
+ None
+
+Returns:
+
+ Return the read data
+
+--*/
+;
+VOID
+EfiCpuidExt (
+ IN UINT32 RegisterInEax,
+ IN UINT32 CacheLevel,
+ OUT EFI_CPUID_REGISTER *Regs
+ )
+/*++
+Routine Description:
+ When RegisterInEax != 4, the functionality is the same as EfiCpuid.
+ When RegisterInEax == 4, the function return the deterministic cache
+ parameters by excuting the CPUID instruction
+Arguments:
+ RegisterInEax: - The input value to put into register EAX
+ CacheLevel: - The deterministic cache level
+ Regs: - The Output value
+Returns:
+ None
+--*/
+;
+
+#endif
diff --git a/EDK/Foundation/Library/Dxe/Include/x64/ProcDep.h b/EDK/Foundation/Library/Dxe/Include/x64/ProcDep.h
new file mode 100644
index 0000000..b3e3be4
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/Include/x64/ProcDep.h
@@ -0,0 +1,29 @@
+/*++
+
+Copyright (c) 2005, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ ProcDep.h
+
+Abstract:
+
+ x64 specific Runtime Lib code. At this time there is non.
+ IPF has different code due to extra API requirements.
+
+--*/
+
+#ifndef _PROC_DEP_H_
+#define _PROC_DEP_H_
+
+
+
+#endif
diff --git a/EDK/Foundation/Library/Dxe/Print/Ascii/PrintAscii.cif b/EDK/Foundation/Library/Dxe/Print/Ascii/PrintAscii.cif
new file mode 100644
index 0000000..3d79f4c
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/Print/Ascii/PrintAscii.cif
@@ -0,0 +1,9 @@
+<component>
+ name = "PrintAscii"
+ category = ModulePart
+ LocalRoot = "EDK\Foundation\Library\Dxe\Print\Ascii"
+ RefName = "PrintAscii"
+[files]
+"PrintWidth.h"
+"Sprint.c"
+<endComponent>
diff --git a/EDK/Foundation/Library/Dxe/Print/Ascii/PrintWidth.h b/EDK/Foundation/Library/Dxe/Print/Ascii/PrintWidth.h
new file mode 100644
index 0000000..07901dc
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/Print/Ascii/PrintWidth.h
@@ -0,0 +1,88 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PrintWidth.h
+
+Abstract:
+
+ Unicde option for generic width.
+ CHAR_W is Ascii
+ STRING_W is ""
+
+--*/
+
+#ifndef _PRINT_WIDTH_H_
+#define _PRINT_WIDTH_H_
+
+typedef CHAR8 CHAR_W;
+#define STRING_W(_s) _s
+
+#define ASPrint(Buffer, BufferSize, Format) SPrint (Buffer, BufferSize, Format)
+#define AvSPrint(Buffer, BufferSize, Format, Marker) VSPrint (Buffer, BufferSize, Format, Marker)
+
+UINTN
+UvSPrint (
+ OUT CHAR16 *StartOfBuffer,
+ IN UINTN StrLen,
+ IN CONST CHAR16 *Format,
+ IN VA_LIST Marker
+ )
+/*++
+
+Routine Description:
+
+ Internal implementation of USPrint.
+ Process format and place the results in Buffer for wide chars.
+
+Arguments:
+
+ StartOfBuffer - Wide char buffer to print the results of the parsing of Format into.
+ StrLen - Maximum number of characters to put into buffer.
+ Format - Format string
+ Marker - Vararg list consumed by processing Format.
+
+Returns:
+
+ Number of characters printed.
+
+--*/
+;
+
+UINTN
+USPrint (
+ OUT CHAR16 *Buffer,
+ IN UINTN BufferSize,
+ IN CONST CHAR16 *Format,
+ ...
+ )
+/*++
+
+Routine Description:
+
+ Process format and place the results in Buffer for wide chars.
+
+Arguments:
+
+ Buffer - Wide char buffer to print the results of the parsing of Format into.
+ BufferSize - Maximum number of characters to put into buffer.
+ Format - Format string
+ ... - Vararg list consumed by processing Format.
+
+Returns:
+
+ Number of characters printed.
+
+--*/
+;
+
+#endif
diff --git a/EDK/Foundation/Library/Dxe/Print/Ascii/Sprint.c b/EDK/Foundation/Library/Dxe/Print/Ascii/Sprint.c
new file mode 100644
index 0000000..bb4bb1e
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/Print/Ascii/Sprint.c
@@ -0,0 +1,144 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Sprint.c
+
+Abstract:
+
+ Basic Ascii AvSPrintf() function named VSPrint(). VSPrint() enables very
+ simple implemenation of SPrint() and Print() to support debug.
+
+ You can not Print more than EFI_DRIVER_LIB_MAX_PRINT_BUFFER characters at a
+ time. This makes the implementation very simple.
+
+ VSPrint, Print, SPrint format specification has the follwoing form
+
+ %[flags][width]type
+
+ flags:
+ '-' - Left justify
+ '+' - Prefix a sign
+ ' ' - Prefix a blank
+ ',' - Place commas in numberss
+ '0' - Prefix for width with zeros
+ 'l' - UINT64
+ 'L' - UINT64
+
+ width:
+ '*' - Get width from a UINTN argumnet from the argument list
+ Decimal number that represents width of print
+
+ type:
+ 'X' - argument is a UINTN hex number, prefix '0'
+ 'x' - argument is a hex number
+ 'd' - argument is a decimal number
+ 'a' - argument is an ascii string
+ 'S','s' - argument is an Unicode string
+ 'g' - argument is a pointer to an EFI_GUID
+ 't' - argument is a pointer to an EFI_TIME structure
+ 'c' - argument is an ascii character
+ 'r' - argument is EFI_STATUS
+ '%' - Print a %
+
+--*/
+
+#include "TianoCommon.h"
+#include "PrintWidth.h"
+#include "EfiPrintLib.h"
+#include "Print.h"
+
+
+UINTN
+USPrint (
+ OUT CHAR16 *Buffer,
+ IN UINTN BufferSize,
+ IN CONST CHAR16 *Format,
+ ...
+ )
+/*++
+
+Routine Description:
+
+ Process format and place the results in Buffer for wide chars.
+
+Arguments:
+
+ Buffer - Wide char buffer to print the results of the parsing of Format into.
+ BufferSize - Maximum number of characters to put into buffer.
+ Format - Format string
+ ... - Vararg list consumed by processing Format.
+
+Returns:
+
+ Number of characters printed.
+
+--*/
+{
+ UINTN Return;
+ VA_LIST Marker;
+
+ VA_START (Marker, Format);
+ Return = UnicodeVSPrint (Buffer, BufferSize, Format, Marker);
+ VA_END (Marker);
+
+ return Return;
+}
+
+
+UINTN
+UvSPrint (
+ OUT CHAR16 *Buffer,
+ IN UINTN BufferSize,
+ IN CONST CHAR16 *FormatString,
+ IN VA_LIST Marker
+ )
+/*++
+
+Routine Description:
+
+ Internal implementation of USPrint.
+ Process format and place the results in Buffer for wide chars.
+
+Arguments:
+
+ Buffer - Wide char buffer to print the results of the parsing of Format into.
+ BufferSize - Maximum number of characters to put into buffer.
+ FormatString - Format string
+ Marker - Vararg list consumed by processing Format.
+
+Returns:
+
+ Number of characters printed.
+
+--*/
+{
+ UINTN Index;
+ CHAR8 AsciiFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];
+ CHAR8 AsciiResult[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];
+
+ for (Index = 0; Index < EFI_DRIVER_LIB_MAX_PRINT_BUFFER && FormatString[Index] != '\0'; Index++) {
+ AsciiFormat[Index] = (CHAR8) FormatString[Index];
+ }
+
+ AsciiFormat[Index] = '\0';
+
+ Index = VSPrint (AsciiResult, EFI_DRIVER_LIB_MAX_PRINT_BUFFER, AsciiFormat, Marker);
+
+ for (Index = 0; (Index < (BufferSize - 1)) && AsciiResult[Index] != '\0'; Index++) {
+ Buffer[Index] = (CHAR16) AsciiResult[Index];
+ }
+
+ Buffer[Index] = '\0';
+
+ return Index++;
+}
diff --git a/EDK/Foundation/Library/Dxe/Print/BoxDraw.c b/EDK/Foundation/Library/Dxe/Print/BoxDraw.c
new file mode 100644
index 0000000..fdcd073
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/Print/BoxDraw.c
@@ -0,0 +1,212 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ BoxDraw.c
+
+Abstract:
+ Lib functions to support Box Draw Unicode code pages.
+
+
+
+Revision History
+
+--*/
+
+#include "Tiano.h"
+#include "EfiDriverLib.h"
+
+
+
+typedef struct {
+ CHAR16 Unicode;
+ CHAR8 PcAnsi;
+ CHAR8 Ascii;
+} UNICODE_TO_CHAR;
+
+
+//
+// This list is used to define the valid extend chars.
+// It also provides a mapping from Unicode to PCANSI or
+// ASCII. The ASCII mapping we just made up.
+//
+//
+
+static UNICODE_TO_CHAR UnicodeToPcAnsiOrAscii[] = {
+ BOXDRAW_HORIZONTAL, 0xc4, L'-',
+ BOXDRAW_VERTICAL, 0xb3, L'|',
+ BOXDRAW_DOWN_RIGHT, 0xda, L'/',
+ BOXDRAW_DOWN_LEFT, 0xbf, L'\\',
+ BOXDRAW_UP_RIGHT, 0xc0, L'\\',
+ BOXDRAW_UP_LEFT, 0xd9, L'/',
+ BOXDRAW_VERTICAL_RIGHT, 0xc3, L'|',
+ BOXDRAW_VERTICAL_LEFT, 0xb4, L'|',
+ BOXDRAW_DOWN_HORIZONTAL, 0xc2, L'+',
+ BOXDRAW_UP_HORIZONTAL, 0xc1, L'+',
+ BOXDRAW_VERTICAL_HORIZONTAL, 0xc5, L'+',
+ BOXDRAW_DOUBLE_HORIZONTAL, 0xcd, L'-',
+ BOXDRAW_DOUBLE_VERTICAL, 0xba, L'|',
+ BOXDRAW_DOWN_RIGHT_DOUBLE, 0xd5, L'/',
+ BOXDRAW_DOWN_DOUBLE_RIGHT, 0xd6, L'/',
+ BOXDRAW_DOUBLE_DOWN_RIGHT, 0xc9, L'/',
+ BOXDRAW_DOWN_LEFT_DOUBLE, 0xb8, L'\\',
+ BOXDRAW_DOWN_DOUBLE_LEFT, 0xb7, L'\\',
+ BOXDRAW_DOUBLE_DOWN_LEFT, 0xbb, L'\\',
+ BOXDRAW_UP_RIGHT_DOUBLE, 0xd4, L'\\',
+ BOXDRAW_UP_DOUBLE_RIGHT, 0xd3, L'\\',
+ BOXDRAW_DOUBLE_UP_RIGHT, 0xc8, L'\\',
+ BOXDRAW_UP_LEFT_DOUBLE, 0xbe, L'/',
+ BOXDRAW_UP_DOUBLE_LEFT, 0xbd, L'/',
+ BOXDRAW_DOUBLE_UP_LEFT, 0xbc, L'/',
+ BOXDRAW_VERTICAL_RIGHT_DOUBLE, 0xc6, L'|',
+ BOXDRAW_VERTICAL_DOUBLE_RIGHT, 0xc7, L'|',
+ BOXDRAW_DOUBLE_VERTICAL_RIGHT, 0xcc, L'|',
+ BOXDRAW_VERTICAL_LEFT_DOUBLE, 0xb5, L'|',
+ BOXDRAW_VERTICAL_DOUBLE_LEFT, 0xb6, L'|',
+ BOXDRAW_DOUBLE_VERTICAL_LEFT, 0xb9, L'|',
+ BOXDRAW_DOWN_HORIZONTAL_DOUBLE, 0xd1, L'+',
+ BOXDRAW_DOWN_DOUBLE_HORIZONTAL, 0xd2, L'+',
+ BOXDRAW_DOUBLE_DOWN_HORIZONTAL, 0xcb, L'+',
+ BOXDRAW_UP_HORIZONTAL_DOUBLE, 0xcf, L'+',
+ BOXDRAW_UP_DOUBLE_HORIZONTAL, 0xd0, L'+',
+ BOXDRAW_DOUBLE_UP_HORIZONTAL, 0xca, L'+',
+ BOXDRAW_VERTICAL_HORIZONTAL_DOUBLE, 0xd8, L'+',
+ BOXDRAW_VERTICAL_DOUBLE_HORIZONTAL, 0xd7, L'+',
+ BOXDRAW_DOUBLE_VERTICAL_HORIZONTAL, 0xce, L'+',
+
+ BLOCKELEMENT_FULL_BLOCK, 0xdb, L'*',
+ BLOCKELEMENT_LIGHT_SHADE, 0xb0, L'+',
+
+ GEOMETRICSHAPE_UP_TRIANGLE, 0x1e, L'^',
+ GEOMETRICSHAPE_RIGHT_TRIANGLE, 0x10, L'>',
+ GEOMETRICSHAPE_DOWN_TRIANGLE, 0x1f, L'v',
+ GEOMETRICSHAPE_LEFT_TRIANGLE, 0x11, L'<',
+
+ ARROW_LEFT, 0x3c, L'<',
+
+ ARROW_UP, 0x18, L'^',
+
+ ARROW_RIGHT, 0x3e, L'>',
+
+ ARROW_DOWN, 0x19, L'v',
+
+ 0x0000, 0x00
+};
+
+
+BOOLEAN
+LibIsValidTextGraphics (
+ IN CHAR16 Graphic,
+ OUT CHAR8 *PcAnsi, OPTIONAL
+ OUT CHAR8 *Ascii OPTIONAL
+ )
+/*++
+
+Routine Description:
+
+ Detects if a Unicode char is for Box Drawing text graphics.
+
+Arguments:
+
+ Grphic - Unicode char to test.
+
+ PcAnsi - Optional pointer to return PCANSI equivalent of Graphic.
+
+ Asci - Optional pointer to return Ascii equivalent of Graphic.
+
+Returns:
+
+ TRUE if Gpaphic is a supported Unicode Box Drawing character.
+
+--*/
+{
+ UNICODE_TO_CHAR *Table;
+
+ if ((((Graphic & 0xff00) != 0x2500) && ((Graphic & 0xff00) != 0x2100))) {
+
+ //
+ // Unicode drawing code charts are all in the 0x25xx range,
+ // arrows are 0x21xx
+ //
+ return FALSE;
+ }
+
+ for (Table = UnicodeToPcAnsiOrAscii; Table->Unicode != 0x0000; Table++) {
+ if (Graphic == Table->Unicode) {
+ if (PcAnsi != NULL) {
+ *PcAnsi = Table->PcAnsi;
+ }
+ if (Ascii != NULL) {
+ *Ascii = Table->Ascii;
+ }
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+
+BOOLEAN
+IsValidAscii (
+ IN CHAR16 Ascii
+ )
+/*++
+
+Routine Description:
+
+ Is it valid ascii char?
+
+Arguments:
+
+ Ascii - The char to check
+
+Returns:
+
+ TRUE - Is a ascii char
+ FALSE - Not a ascii char
+
+--*/
+{
+ if ((Ascii >= 0x20) && (Ascii <= 0x7f)) {
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
+BOOLEAN
+IsValidEfiCntlChar (
+ IN CHAR16 CharC
+ )
+/*++
+
+Routine Description:
+
+ Is it valid EFI control char?
+
+Arguments:
+
+ Ascii - The char to check
+
+Returns:
+
+ TRUE - Is a valid EFI control char
+ FALSE - Not a valid EFI control char
+
+--*/
+{
+ if (CharC == CHAR_NULL || CharC == CHAR_BACKSPACE || CharC == CHAR_LINEFEED || CharC == CHAR_CARRIAGE_RETURN) {
+ return TRUE;
+ }
+ return FALSE;
+}
+
diff --git a/EDK/Foundation/Library/Dxe/Print/Print.c b/EDK/Foundation/Library/Dxe/Print/Print.c
new file mode 100644
index 0000000..d939be5
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/Print/Print.c
@@ -0,0 +1,596 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Print.c
+
+Abstract:
+
+ Basic Ascii AvSPrintf() function named VSPrint(). VSPrint() enables very
+ simple implemenation of SPrint() and Print() to support debug.
+
+ You can not Print more than EFI_DRIVER_LIB_MAX_PRINT_BUFFER characters at a
+ time. This makes the implementation very simple.
+
+ VSPrint, Print, SPrint format specification has the follwoing form
+
+ %[flags][width]type
+
+ flags:
+ '-' - Left justify
+ '+' - Prefix a sign
+ ' ' - Prefix a blank
+ ',' - Place commas in numberss
+ '0' - Prefix for width with zeros
+ 'l' - UINT64
+ 'L' - UINT64
+
+ width:
+ '*' - Get width from a UINTN argumnet from the argument list
+ Decimal number that represents width of print
+
+ type:
+ 'X' - argument is a UINTN hex number, prefix '0'
+ 'x' - argument is a hex number
+ 'd' - argument is a decimal number
+ 'a' - argument is an ascii string
+ 'S','s' - argument is an Unicode string
+ 'g' - argument is a pointer to an EFI_GUID
+ 't' - argument is a pointer to an EFI_TIME structure
+ 'c' - argument is an ascii character
+ 'r' - argument is EFI_STATUS
+ '%' - Print a %
+
+--*/
+
+#include "TianoCommon.h"
+#include "EfiCommonLib.h"
+#include "PrintWidth.h"
+#include "EfiPrintLib.h"
+#include "Print.h"
+
+
+STATIC
+CHAR_W *
+GetFlagsAndWidth (
+ IN CHAR_W *Format,
+ OUT UINTN *Flags,
+ OUT UINTN *Width,
+ IN OUT VA_LIST *Marker
+ );
+
+STATIC
+UINTN
+GuidToString (
+ IN EFI_GUID *Guid,
+ IN OUT CHAR_W *Buffer,
+ IN UINTN BufferSize
+ );
+
+STATIC
+UINTN
+TimeToString (
+ IN EFI_TIME *Time,
+ IN OUT CHAR_W *Buffer,
+ IN UINTN BufferSize
+ );
+
+STATIC
+UINTN
+EfiStatusToString (
+ IN EFI_STATUS Status,
+ OUT CHAR_W *Buffer,
+ IN UINTN BufferSize
+ );
+
+STATIC
+UINTN
+Atoi (
+ CHAR_W *String
+ );
+
+
+
+UINTN
+SPrint (
+ OUT CHAR_W *Buffer,
+ IN UINTN BufferSize,
+ IN CONST CHAR_W *Format,
+ ...
+ )
+/*++
+
+Routine Description:
+
+ SPrint function to process format and place the results in Buffer.
+
+Arguments:
+
+ Buffer - Wide char buffer to print the results of the parsing of Format into.
+
+ BufferSize - Maximum number of characters to put into buffer. Zero means no
+ limit.
+
+ Format - Format string see file header for more details.
+
+ ... - Vararg list consumed by processing Format.
+
+Returns:
+
+ Number of characters printed.
+
+--*/
+{
+ UINTN Return;
+ VA_LIST Marker;
+
+ VA_START (Marker, Format);
+ Return = VSPrint (Buffer, BufferSize, Format, Marker);
+ VA_END (Marker);
+
+ return Return;
+}
+
+
+UINTN
+VSPrint (
+ OUT CHAR_W *StartOfBuffer,
+ IN UINTN BufferSize,
+ IN CONST CHAR_W *FormatString,
+ IN VA_LIST Marker
+ )
+/*++
+
+Routine Description:
+
+ VSPrint function to process format and place the results in Buffer. Since a
+ VA_LIST is used this rountine allows the nesting of Vararg routines. Thus
+ this is the main print working routine
+
+Arguments:
+
+ StartOfBuffer - Unicode buffer to print the results of the parsing of Format into.
+
+ BufferSize - Maximum number of characters to put into buffer. Zero means
+ no limit.
+
+ FormatString - Unicode format string see file header for more details.
+
+ Marker - Vararg list consumed by processing Format.
+
+Returns:
+
+ Number of characters printed.
+
+--*/
+{
+ CHAR16 TempBuffer[CHARACTER_NUMBER_FOR_VALUE];
+ CHAR_W *Buffer;
+ CHAR8 *AsciiStr;
+ CHAR16 *UnicodeStr;
+ CHAR_W *Format;
+ UINTN Index;
+ UINTN Flags;
+ UINTN Width;
+ UINTN Count;
+ UINTN NumberOfCharacters;
+ UINTN BufferLeft;
+ UINT64 Value;
+ EFI_GUID *TmpGUID;
+
+ //
+ // Process the format string. Stop if Buffer is over run.
+ //
+
+ Buffer = StartOfBuffer;
+ Format = (CHAR_W *)FormatString;
+ NumberOfCharacters = BufferSize/sizeof(CHAR_W);
+ BufferLeft = BufferSize;
+ for (Index = 0; (*Format != '\0') && (Index < NumberOfCharacters - 1); Format++) {
+ if (*Format != '%') {
+ if ((*Format == '\n') && (Index < NumberOfCharacters - 2)) {
+ //
+ // If carage return add line feed
+ //
+ Buffer[Index++] = '\r';
+ BufferLeft -= sizeof(CHAR_W);
+ }
+ Buffer[Index++] = *Format;
+ BufferLeft -= sizeof(CHAR_W);
+ } else {
+
+ //
+ // Now it's time to parse what follows after %
+ //
+ Format = GetFlagsAndWidth (Format, &Flags, &Width, &Marker);
+ switch (*Format) {
+ case 'X':
+ Flags |= PREFIX_ZERO;
+ Width = sizeof (UINT64) * 2;
+ //
+ // break skiped on purpose
+ //
+ case 'x':
+ if ((Flags & LONG_TYPE) == LONG_TYPE) {
+ Value = VA_ARG (Marker, UINT64);
+ } else {
+ Value = VA_ARG (Marker, UINTN);
+ Value &= 0xFFFFFFFF;
+ }
+
+ EfiValueToHexStr (TempBuffer, Value, Flags, Width);
+ UnicodeStr = TempBuffer;
+
+ for ( ;(*UnicodeStr != '\0') && (Index < NumberOfCharacters - 1); UnicodeStr++) {
+ Buffer[Index++] = *UnicodeStr;
+ }
+ break;
+
+ case 'd':
+ if ((Flags & LONG_TYPE) == LONG_TYPE) {
+ Value = VA_ARG (Marker, UINT64);
+ } else {
+ Value = (UINTN)VA_ARG (Marker, UINTN);
+ Value &= 0xFFFFFFFF;
+ Value = (INT32)Value;
+ }
+
+ EfiValueToString (TempBuffer, Value, Flags, Width);
+ UnicodeStr = TempBuffer;
+
+ for ( ;(*UnicodeStr != '\0') && (Index < NumberOfCharacters - 1); UnicodeStr++) {
+ Buffer[Index++] = *UnicodeStr;
+ }
+ break;
+
+ case 's':
+ case 'S':
+ UnicodeStr = (CHAR16 *)VA_ARG (Marker, CHAR_W *);
+ if (UnicodeStr == NULL) {
+ UnicodeStr = L"<null string>";
+ }
+ for (Count = 0 ;(*UnicodeStr != '\0') && (Index < NumberOfCharacters - 1); UnicodeStr++, Count++) {
+ Buffer[Index++] = *UnicodeStr;
+ }
+ //
+ // Add padding if needed
+ //
+ for (; (Count < Width) && (Index < NumberOfCharacters - 1); Count++) {
+ Buffer[Index++] = ' ';
+ }
+
+ break;
+
+ case 'a':
+ AsciiStr = (CHAR8 *)VA_ARG (Marker, CHAR8 *);
+ if (AsciiStr == NULL) {
+ AsciiStr = "<null string>";
+ }
+ for (Count = 0 ;(*AsciiStr != '\0') && (Index < NumberOfCharacters - 1); AsciiStr++, Count++) {
+ Buffer[Index++] = (CHAR_W)*AsciiStr;
+ }
+ //
+ // Add padding if needed
+ //
+ for (;(Count < Width) && (Index < NumberOfCharacters - 1); Count++) {
+ Buffer[Index++] = ' ';
+ }
+ break;
+
+ case 'c':
+ Buffer[Index++] = (CHAR_W)VA_ARG (Marker, UINTN);
+ break;
+
+ case 'g':
+ TmpGUID = VA_ARG (Marker, EFI_GUID *);
+ if (TmpGUID != NULL) {
+ Index += GuidToString (
+ TmpGUID,
+ &Buffer[Index],
+ BufferLeft
+ );
+ }
+ break;
+
+ case 't':
+ Index += TimeToString (
+ VA_ARG (Marker, EFI_TIME *),
+ &Buffer[Index],
+ BufferLeft
+ );
+ break;
+
+ case 'r':
+ Index += EfiStatusToString (
+ VA_ARG (Marker, EFI_STATUS),
+ &Buffer[Index],
+ BufferLeft
+ );
+ break;
+
+ case '%':
+ Buffer[Index++] = *Format;
+ break;
+
+ default:
+ //
+ // if the type is unknown print it to the screen
+ //
+ Buffer[Index++] = *Format;
+ }
+ BufferLeft = BufferSize - Index * sizeof(CHAR_W) ;
+ }
+ }
+ Buffer[Index++] = '\0';
+
+ return &Buffer[Index] - StartOfBuffer;
+}
+
+
+
+STATIC
+CHAR_W *
+GetFlagsAndWidth (
+ IN CHAR_W *Format,
+ OUT UINTN *Flags,
+ OUT UINTN *Width,
+ IN OUT VA_LIST *Marker
+ )
+/*++
+
+Routine Description:
+
+ VSPrint worker function that parses flag and width information from the
+ Format string and returns the next index into the Format string that needs
+ to be parsed. See file headed for details of Flag and Width.
+
+Arguments:
+
+ Format - Current location in the VSPrint format string.
+
+ Flags - Returns flags
+
+ Width - Returns width of element
+
+ Marker - Vararg list that may be paritally consumed and returned.
+
+Returns:
+
+ Pointer indexed into the Format string for all the information parsed
+ by this routine.
+
+--*/
+{
+ UINTN Count;
+ BOOLEAN Done;
+
+ *Flags = 0;
+ *Width = 0;
+ for (Done = FALSE; !Done; ) {
+ Format++;
+
+ switch (*Format) {
+
+ case '-': *Flags |= LEFT_JUSTIFY; break;
+ case '+': *Flags |= PREFIX_SIGN; break;
+ case ' ': *Flags |= PREFIX_BLANK; break;
+ case ',': *Flags |= COMMA_TYPE; break;
+ case 'L':
+ case 'l': *Flags |= LONG_TYPE; break;
+
+ case '*':
+ *Width = VA_ARG (*Marker, UINTN);
+ break;
+
+ case '0':
+ *Flags |= PREFIX_ZERO;
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ Count = 0;
+ do {
+ Count = (Count * 10) + *Format - '0';
+ Format++;
+ } while ((*Format >= '0') && (*Format <= '9'));
+ Format--;
+ *Width = Count;
+ break;
+
+ default:
+ Done = TRUE;
+ }
+ }
+ return Format;
+}
+
+STATIC
+UINTN
+GuidToString (
+ IN EFI_GUID *Guid,
+ IN CHAR_W *Buffer,
+ IN UINTN BufferSize
+ )
+/*++
+
+Routine Description:
+
+ VSPrint worker function that prints an EFI_GUID.
+
+Arguments:
+
+ Guid - Pointer to GUID to print.
+
+ Buffer - Buffe to print Guid into.
+
+ BufferSize - Size of Buffer.
+
+Returns:
+
+ Number of characters printed.
+
+--*/
+{
+ UINTN Size;
+
+ Size = SPrint (
+ Buffer,
+ BufferSize,
+ STRING_W ("%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x"),
+ (UINTN)Guid->Data1,
+ (UINTN)Guid->Data2,
+ (UINTN)Guid->Data3,
+ (UINTN)Guid->Data4[0],
+ (UINTN)Guid->Data4[1],
+ (UINTN)Guid->Data4[2],
+ (UINTN)Guid->Data4[3],
+ (UINTN)Guid->Data4[4],
+ (UINTN)Guid->Data4[5],
+ (UINTN)Guid->Data4[6],
+ (UINTN)Guid->Data4[7]
+ );
+
+ //
+ // SPrint will null terminate the string. The -1 skips the null
+ //
+ return Size - 1;
+}
+
+
+STATIC
+UINTN
+TimeToString (
+ IN EFI_TIME *Time,
+ OUT CHAR_W *Buffer,
+ IN UINTN BufferSize
+ )
+/*++
+
+Routine Description:
+
+ VSPrint worker function that prints EFI_TIME.
+
+Arguments:
+
+ Time - Pointer to EFI_TIME sturcture to print.
+
+ Buffer - Buffer to print Time into.
+
+ BufferSize - Size of Buffer.
+
+Returns:
+
+ Number of characters printed.
+
+--*/
+{
+ UINTN Size;
+
+ Size = SPrint (
+ Buffer,
+ BufferSize,
+ STRING_W ("%02d/%02d/%04d %02d:%02d"),
+ (UINTN)Time->Month,
+ (UINTN)Time->Day,
+ (UINTN)Time->Year,
+ (UINTN)Time->Hour,
+ (UINTN)Time->Minute
+ );
+
+ //
+ // SPrint will null terminate the string. The -1 skips the null
+ //
+ return Size - 1;
+}
+
+STATIC
+UINTN
+EfiStatusToString (
+ IN EFI_STATUS Status,
+ OUT CHAR_W *Buffer,
+ IN UINTN BufferSize
+ )
+/*++
+
+Routine Description:
+
+ VSPrint worker function that prints EFI_STATUS as a string. If string is
+ not known a hex value will be printed.
+
+Arguments:
+
+ Status - EFI_STATUS sturcture to print.
+
+ Buffer - Buffer to print EFI_STATUS message string into.
+
+ BufferSize - Size of Buffer.
+
+Returns:
+
+ Number of characters printed.
+
+--*/
+{
+ UINTN Size;
+ CHAR8 *Desc;
+
+ Desc = NULL;
+
+ //
+ // Can't use global Status String Array as UINTN is not constant for EBC
+ //
+ if (Status == EFI_SUCCESS) { Desc = "Success"; } else
+ if (Status == EFI_LOAD_ERROR) { Desc = "Load Error"; } else
+ if (Status == EFI_INVALID_PARAMETER) { Desc = "Invalid Parameter"; } else
+ if (Status == EFI_UNSUPPORTED) { Desc = "Unsupported"; } else
+ if (Status == EFI_BAD_BUFFER_SIZE) { Desc = "Bad Buffer Size"; } else
+ if (Status == EFI_BUFFER_TOO_SMALL) { Desc = "Buffer Too Small"; } else
+ if (Status == EFI_NOT_READY) { Desc = "Not Ready"; } else
+ if (Status == EFI_DEVICE_ERROR) { Desc = "Device Error"; } else
+ if (Status == EFI_WRITE_PROTECTED) { Desc = "Write Protected"; } else
+ if (Status == EFI_OUT_OF_RESOURCES) { Desc = "Out of Resources"; } else
+ if (Status == EFI_VOLUME_CORRUPTED) { Desc = "Volume Corrupt"; } else
+ if (Status == EFI_VOLUME_FULL) { Desc = "Volume Full"; } else
+ if (Status == EFI_NO_MEDIA) { Desc = "No Media"; } else
+ if (Status == EFI_MEDIA_CHANGED) { Desc = "Media changed"; } else
+ if (Status == EFI_NOT_FOUND) { Desc = "Not Found"; } else
+ if (Status == EFI_ACCESS_DENIED) { Desc = "Access Denied"; } else
+ if (Status == EFI_NO_RESPONSE) { Desc = "No Response"; } else
+ if (Status == EFI_NO_MAPPING) { Desc = "No mapping"; } else
+ if (Status == EFI_TIMEOUT) { Desc = "Time out"; } else
+ if (Status == EFI_NOT_STARTED) { Desc = "Not started"; } else
+ if (Status == EFI_ALREADY_STARTED) { Desc = "Already started"; } else
+ if (Status == EFI_ABORTED) { Desc = "Aborted"; } else
+ if (Status == EFI_ICMP_ERROR) { Desc = "ICMP Error"; } else
+ if (Status == EFI_TFTP_ERROR) { Desc = "TFTP Error"; } else
+ if (Status == EFI_PROTOCOL_ERROR) { Desc = "Protocol Error"; } else
+ if (Status == EFI_WARN_UNKNOWN_GLYPH) { Desc = "Warning Unknown Glyph"; } else
+ if (Status == EFI_WARN_DELETE_FAILURE) { Desc = "Warning Delete Failure"; } else
+ if (Status == EFI_WARN_WRITE_FAILURE) { Desc = "Warning Write Failure"; } else
+ if (Status == EFI_WARN_BUFFER_TOO_SMALL) { Desc = "Warning Buffer Too Small"; }
+
+ //
+ // If we found a match, copy the message to the user's buffer. Otherwise
+ // sprint the hex status code to their buffer.
+ //
+ if (Desc != NULL) {
+ Size = SPrint (Buffer, BufferSize, STRING_W ("%a"), Desc);
+ } else {
+ Size = SPrint (Buffer, BufferSize, STRING_W ("%X"), Status);
+ }
+ return Size - 1;
+}
diff --git a/EDK/Foundation/Library/Dxe/Print/Print.h b/EDK/Foundation/Library/Dxe/Print/Print.h
new file mode 100644
index 0000000..ad54aa8
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/Print/Print.h
@@ -0,0 +1,37 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Print.h
+
+Abstract:
+
+ Private data for Print.c
+
+--*/
+
+#ifndef _PRINT_H_
+#define _PRINT_H_
+
+#define LEFT_JUSTIFY 0x01
+#define PREFIX_SIGN 0x02
+#define PREFIX_BLANK 0x04
+#define COMMA_TYPE 0x08
+#define LONG_TYPE 0x10
+#define PREFIX_ZERO 0x20
+
+//
+// Largest number of characters that can be printed out.
+//
+#define EFI_DRIVER_LIB_MAX_PRINT_BUFFER (80 * 4)
+
+#endif
diff --git a/EDK/Foundation/Library/Dxe/Print/PrintLib.cif b/EDK/Foundation/Library/Dxe/Print/PrintLib.cif
new file mode 100644
index 0000000..4692aae
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/Print/PrintLib.cif
@@ -0,0 +1,19 @@
+<component>
+ name = "PrintLib"
+ category = ModulePart
+ LocalRoot = "EDK\Foundation\Library\Dxe\Print\"
+ RefName = "PrintLib"
+[files]
+"PrintLib.sdl"
+"PrintLib.mak"
+"BoxDraw.c"
+"Print.c"
+"Print.h"
+"StdErr.c"
+"PrintLib.inf"
+[parts]
+"PrintAscii"
+"PrintUnicode"
+"PrintAscii"
+"PrintUnicode"
+<endComponent>
diff --git a/EDK/Foundation/Library/Dxe/Print/PrintLib.inf b/EDK/Foundation/Library/Dxe/Print/PrintLib.inf
new file mode 100644
index 0000000..b06e272
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/Print/PrintLib.inf
@@ -0,0 +1,50 @@
+#/*++
+#
+# Copyright (c) 2004, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# PrintLib.inf
+#
+# Abstract:
+#
+# Component description file.
+#
+#--*/
+
+[defines]
+BASE_NAME = PrintLib
+COMPONENT_TYPE = LIBRARY
+
+[sources.common]
+ BoxDraw.c
+ Print.c
+ Print.h
+ StdErr.c
+ Unicode\PrintWidth.h
+ Unicode\SPrint.c
+
+[includes.common]
+ $(EDK_SOURCE)\Foundation
+ $(EDK_SOURCE)\Foundation\Framework
+ $(EDK_SOURCE)\Foundation\Efi
+ .
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Print\Unicode
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+
+[libraries.common]
+
+[nmake.common]
+ C_STD_INCLUDE=
diff --git a/EDK/Foundation/Library/Dxe/Print/PrintLib.mak b/EDK/Foundation/Library/Dxe/Print/PrintLib.mak
new file mode 100644
index 0000000..dc019ce
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/Print/PrintLib.mak
@@ -0,0 +1,70 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/PrintLib/PrintLib.mak 1 1/20/12 4:08a Jeffch $
+#
+# $Revision: 1 $
+#
+# $Date: 1/20/12 4:08a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/PrintLib/PrintLib.mak $
+#
+# 1 1/20/12 4:08a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 9/27/11 6:31a Wesleychen
+# Intel EDK initially releases.
+#
+# 2 9/02/09 3:52a Iminglin
+# EIP24919
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: PrintLib.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+$(PRINTLIB) : PrintLib
+
+$(BUILD_DIR)\PrintLib.lib : PrintLib
+
+PrintLib : $(BUILD_DIR)\PrintLib.mak PrintLibBin
+
+$(BUILD_DIR)\PrintLib.mak : $(PrintLib_DIR)\$(@B).cif $(PrintLib_DIR)\$(@B).mak $(BUILD_RULES) $(PrintLib_DIR)\Unicode\PrintUnicode.cif
+ $(CIF2MAK) $(PrintLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS) $(PrintLib_DIR)\Unicode\PrintUnicode.cif
+
+PrintLibBin :
+ $(MAKE) /$(MAKEFLAGS) $(EDK_DEFAULTS)\
+ /f $(BUILD_DIR)\PrintLib.mak all\
+ "MY_INCLUDES=/I$(PrintLib_DIR) /I$(PrintLib_DIR)\Unicode"\
+ TYPE=LIBRARY \
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
diff --git a/EDK/Foundation/Library/Dxe/Print/PrintLib.sdl b/EDK/Foundation/Library/Dxe/Print/PrintLib.sdl
new file mode 100644
index 0000000..6920785
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/Print/PrintLib.sdl
@@ -0,0 +1,26 @@
+TOKEN
+ Name = "PrintLib_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable PrintLib support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "PRINTLIB"
+ Value = "$(BUILD_DIR)\PrintLib.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "PrintLib_DIR"
+End
+
+MODULE
+ Help = "Includes PrintLib.mak to Project"
+ File = "PrintLib.mak"
+End
+
diff --git a/EDK/Foundation/Library/Dxe/Print/StdErr.c b/EDK/Foundation/Library/Dxe/Print/StdErr.c
new file mode 100644
index 0000000..14d6ba9
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/Print/StdErr.c
@@ -0,0 +1,287 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ StdErr.c
+
+Abstract:
+
+ Basic Ascii AvSPrintf() function named VSPrint(). VSPrint() enables very
+ simple implemenation of SPrint() and Print() to support debug.
+
+ You can not Print more than EFI_DRIVER_LIB_MAX_PRINT_BUFFER characters at a
+ time. This makes the implementation very simple.
+
+ VSPrint, Print, SPrint format specification has the follwoing form
+
+ %[flags][width]type
+
+ flags:
+ '-' - Left justify
+ '+' - Prefix a sign
+ ' ' - Prefix a blank
+ ',' - Place commas in numberss
+ '0' - Prefix for width with zeros
+ 'l' - UINT64
+ 'L' - UINT64
+
+ width:
+ '*' - Get width from a UINTN argumnet from the argument list
+ Decimal number that represents width of print
+
+ type:
+ 'X' - argument is a UINTN hex number, prefix '0'
+ 'x' - argument is a hex number
+ 'd' - argument is a decimal number
+ 'a' - argument is an ascii string
+ 'S','s' - argument is an Unicode string
+ 'g' - argument is a pointer to an EFI_GUID
+ 't' - argument is a pointer to an EFI_TIME structure
+ 'c' - argument is an ascii character
+ 'r' - argument is EFI_STATUS
+ '%' - Print a %
+
+--*/
+
+#include "Tiano.h"
+#include "EfiDriverLib.h"
+#include "EfiCommonLib.h"
+#include "EfiPrintLib.h"
+#include "Print.h"
+
+
+UINTN
+ErrorPrint (
+ IN CONST CHAR16 *ErrorString,
+ IN CONST CHAR8 *Format,
+ ...
+ )
+/*++
+
+Routine Description:
+
+ Print function for a maximum of EFI_DRIVER_LIB_MAX_PRINT_BUFFER ascii
+ characters.
+
+Arguments:
+
+ ErrorString - String of error infomation.
+
+ Format - Ascii format string see file header for more details.
+
+ ... - Vararg list consumed by processing Format.
+
+Returns:
+
+ Number of characters printed.
+
+--*/
+{
+ UINTN Return;
+ VA_LIST Marker;
+ UINTN Index;
+ UINTN MaxIndex;
+ //
+ // Increase array size of 'UnicodeFormat' and 'Buffer' by 1 as there is a possibility of buffer overflow.
+ //
+ CHAR16 Buffer[EFI_DRIVER_LIB_MAX_PRINT_BUFFER+1];
+ CHAR16 UnicodeFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER+1];
+
+ MaxIndex = EfiAsciiStrLen ((CHAR8 *) Format);
+ if (MaxIndex >= EFI_DRIVER_LIB_MAX_PRINT_BUFFER) {
+ //
+ // Format string was too long for use to process.
+ //
+ return 0;
+ }
+
+ if (ErrorString != '\0') {
+ if (gST->StdErr != NULL) {
+ //
+ // To be extra safe make sure StdErr has been initialized
+ //
+ gST->StdErr->SetAttribute (gST->StdErr, EFI_TEXT_ATTR (EFI_RED, EFI_BLACK));
+ gST->StdErr->OutputString (gST->StdErr, (CHAR16 *) ErrorString);
+ gST->StdErr->SetAttribute (gST->StdErr, EFI_TEXT_ATTR (EFI_WHITE, EFI_BLACK));
+ }
+ }
+
+ for (Index = 0; Index < MaxIndex; Index++) {
+ UnicodeFormat[Index] = (CHAR16) Format[Index];
+ }
+
+ UnicodeFormat[Index] = 0;
+
+ VA_START (Marker, Format);
+ Return = VSPrint (Buffer, sizeof (Buffer), UnicodeFormat, Marker);
+ VA_END (Marker);
+
+ //
+ // Need to convert to Unicode to do an OutputString
+ //
+
+ if (gST->StdErr != NULL) {
+ //
+ // To be extra safe make sure StdErr has been initialized
+ //
+ gST->StdErr->OutputString (gST->StdErr, Buffer);
+ }
+
+ return Return;
+}
+
+
+UINTN
+Aprint (
+ IN CONST CHAR8 *Format,
+ ...
+ )
+/*++
+
+Routine Description:
+
+ Print function for a maximum of EFI_DRIVER_LIB_MAX_PRINT_BUFFER ascii
+ characters.
+
+Arguments:
+
+ Format - Ascii format string see file header for more details.
+
+ ... - Vararg list consumed by processing Format.
+
+Returns:
+
+ Number of characters printed.
+
+--*/
+{
+ UINTN Return;
+ VA_LIST Marker;
+ UINTN Index;
+ UINTN MaxIndex;
+ CHAR16 Buffer[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];
+ CHAR16 UnicodeFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];
+
+ MaxIndex = EfiAsciiStrLen ((CHAR8 *) Format);
+ if (MaxIndex >= EFI_DRIVER_LIB_MAX_PRINT_BUFFER) {
+ //
+ // Format string was too long for use to process.
+ //
+ return 0;
+ }
+
+ for (Index = 0; Index < EFI_DRIVER_LIB_MAX_PRINT_BUFFER; Index++) {
+ UnicodeFormat[Index] = (CHAR16) Format[Index];
+ }
+
+ VA_START (Marker, Format);
+ Return = VSPrint (Buffer, sizeof (Buffer), UnicodeFormat, Marker);
+ VA_END (Marker);
+
+ //
+ // Need to convert to Unicode to do an OutputString
+ //
+
+ if (gST->ConOut != NULL) {
+ //
+ // To be extra safe make sure ConOut has been initialized
+ //
+ gST->ConOut->OutputString (gST->ConOut, Buffer);
+ }
+
+ return Return;
+}
+
+
+UINTN
+Print (
+ IN CONST CHAR16 *Format,
+ ...
+ )
+/*++
+
+Routine Description:
+
+ Print function for a maximum of EFI_DRIVER_LIB_MAX_PRINT_BUFFER ascii
+ characters.
+
+Arguments:
+
+ Format - Ascii format string see file header for more details.
+
+ ... - Vararg list consumed by processing Format.
+
+Returns:
+
+ Number of characters printed.
+
+--*/
+{
+ UINTN Return;
+ VA_LIST Marker;
+ CHAR16 Buffer[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];
+
+ VA_START (Marker, Format);
+ Return = VSPrint (Buffer, sizeof (Buffer), Format, Marker);
+ VA_END (Marker);
+
+ if (gST->ConOut != NULL) {
+ //
+ // To be extra safe make sure ConOut has been initialized
+ //
+ gST->ConOut->OutputString (gST->ConOut, Buffer);
+ }
+
+ return Return;
+}
+
+UINTN
+UPrint (
+ IN CONST CHAR16 *Format,
+ ...
+ )
+/*++
+
+Routine Description:
+
+ Print function for a maximum of EFI_DRIVER_LIB_MAX_PRINT_BUFFER ascii
+ characters.
+
+Arguments:
+
+ Format - Ascii format string see file header for more details.
+
+ ... - Vararg list consumed by processing Format.
+
+Returns:
+
+ Number of characters printed.
+
+--*/
+{
+ UINTN Return;
+ VA_LIST Marker;
+ CHAR16 Buffer[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];
+
+ VA_START (Marker, Format);
+ Return = VSPrint (Buffer, sizeof (Buffer), Format, Marker);
+ VA_END (Marker);
+
+ if (gST->ConOut != NULL) {
+ //
+ // To be extra safe make sure ConOut has been initialized
+ //
+ gST->ConOut->OutputString (gST->ConOut, Buffer);
+ }
+
+ return Return;
+}
diff --git a/EDK/Foundation/Library/Dxe/Print/Unicode/PrintUnicode.cif b/EDK/Foundation/Library/Dxe/Print/Unicode/PrintUnicode.cif
new file mode 100644
index 0000000..01c6e6d
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/Print/Unicode/PrintUnicode.cif
@@ -0,0 +1,9 @@
+<component>
+ name = "PrintUnicode"
+ category = ModulePart
+ LocalRoot = "EDK\Foundation\Library\Dxe\Print\Unicode"
+ RefName = "PrintUnicode"
+[files]
+"PrintWidth.h"
+"Sprint.c"
+<endComponent>
diff --git a/EDK/Foundation/Library/Dxe/Print/Unicode/PrintWidth.h b/EDK/Foundation/Library/Dxe/Print/Unicode/PrintWidth.h
new file mode 100644
index 0000000..fef9ea9
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/Print/Unicode/PrintWidth.h
@@ -0,0 +1,35 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PrintWidth.h
+
+Abstract:
+
+ Unicde option for generic width.
+ CHAR_W is Unicode
+ STRING_W is L""
+
+--*/
+
+#ifndef _PRINT_WIDTH_H_
+#define _PRINT_WIDTH_H_
+
+typedef CHAR16 CHAR_W;
+#define STRING_W(_s) L##_s
+
+#define USPrint(Buffer, BufferSize, Format) SPrint (Buffer, BufferSize, Format)
+#define UvSPrint(Buffer, BufferSize, Format, Marker) VSPrint (Buffer, BufferSize, Format, Marker)
+
+#include "EfiCommonLib.h"
+
+#endif
diff --git a/EDK/Foundation/Library/Dxe/Print/Unicode/Sprint.c b/EDK/Foundation/Library/Dxe/Print/Unicode/Sprint.c
new file mode 100644
index 0000000..e3b8738
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/Print/Unicode/Sprint.c
@@ -0,0 +1,147 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Sprint.c
+
+Abstract:
+
+ Basic Ascii AvSPrintf() function named VSPrint(). VSPrint() enables very
+ simple implemenation of SPrint() and Print() to support debug.
+
+ You can not Print more than EFI_DRIVER_LIB_MAX_PRINT_BUFFER characters at a
+ time. This makes the implementation very simple.
+
+ VSPrint, Print, SPrint format specification has the follwoing form
+
+ %[flags][width]type
+
+ flags:
+ '-' - Left justify
+ '+' - Prefix a sign
+ ' ' - Prefix a blank
+ ',' - Place commas in numberss
+ '0' - Prefix for width with zeros
+ 'l' - UINT64
+ 'L' - UINT64
+
+ width:
+ '*' - Get width from a UINTN argumnet from the argument list
+ Decimal number that represents width of print
+
+ type:
+ 'X' - argument is a UINTN hex number, prefix '0'
+ 'x' - argument is a hex number
+ 'd' - argument is a decimal number
+ 'a' - argument is an ascii string
+ 'S','s' - argument is an Unicode string
+ 'g' - argument is a pointer to an EFI_GUID
+ 't' - argument is a pointer to an EFI_TIME structure
+ 'c' - argument is an ascii character
+ 'r' - argument is EFI_STATUS
+ '%' - Print a %
+
+--*/
+
+#include "TianoCommon.h"
+#include "PrintWidth.h"
+#include "EfiPrintLib.h"
+#include "Print.h"
+
+
+UINTN
+ASPrint (
+ OUT CHAR8 *Buffer,
+ IN UINTN BufferSize,
+ IN CONST CHAR8 *Format,
+ ...
+ )
+/*++
+
+Routine Description:
+
+ Process format and place the results in Buffer for narrow chars.
+
+Arguments:
+
+ Buffer - Narrow char buffer to print the results of the parsing of Format into.
+ BufferSize - Maximum number of characters to put into buffer.
+ Format - Format string
+ ... - Vararg list consumed by processing Format.
+
+Returns:
+
+ Number of characters printed.
+
+--*/
+{
+ UINTN Return;
+ VA_LIST Marker;
+
+ VA_START (Marker, Format);
+ Return = AvSPrint (Buffer, BufferSize, Format, Marker);
+ VA_END (Marker);
+
+ return Return;
+}
+
+
+UINTN
+AvSPrint (
+ OUT CHAR8 *Buffer,
+ IN UINTN BufferSize,
+ IN CONST CHAR8 *FormatString,
+ IN VA_LIST Marker
+ )
+/*++
+
+Routine Description:
+
+ Internal implementation of ASPrint.
+ Process format and place the results in Buffer for narrow chars.
+
+Arguments:
+
+ Buffer - Narrow char buffer to print the results of the parsing of Format into.
+ BufferSize - Maximum number of characters to put into buffer.
+ FormatString - Format string
+ Marker - Vararg list consumed by processing Format.
+
+Returns:
+
+ Number of characters printed.
+
+--*/
+{
+ UINTN Index;
+ //
+ // Increase array size of 'UnicodeFormat' and 'UnicodeResult' by 1 as there is a possibility of buffer overflow.
+ //
+ CHAR16 UnicodeFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER+1];
+ CHAR16 UnicodeResult[EFI_DRIVER_LIB_MAX_PRINT_BUFFER+1];
+
+ for (Index = 0; Index < EFI_DRIVER_LIB_MAX_PRINT_BUFFER && FormatString[Index] != '\0'; Index++) {
+ UnicodeFormat[Index] = (CHAR16) FormatString[Index];
+ }
+
+ UnicodeFormat[Index] = '\0';
+
+ Index = VSPrint (UnicodeResult, sizeof (UnicodeResult)/sizeof (CHAR16), UnicodeFormat, Marker);
+
+ for (Index = 0; (Index < (BufferSize - 1)) && UnicodeResult[Index] != '\0'; Index++) {
+ Buffer[Index] = (CHAR8) UnicodeResult[Index];
+ }
+
+ Buffer[Index] = '\0';
+
+ return Index++;
+}
diff --git a/EDK/Foundation/Library/Dxe/PrintLite/Ascii/PrintLiteAscii.cif b/EDK/Foundation/Library/Dxe/PrintLite/Ascii/PrintLiteAscii.cif
new file mode 100644
index 0000000..e7d8a3f
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/PrintLite/Ascii/PrintLiteAscii.cif
@@ -0,0 +1,9 @@
+<component>
+ name = "PrintLiteAscii"
+ category = ModulePart
+ LocalRoot = "EDK\Foundation\Library\Dxe\PrintLite\Ascii"
+ RefName = "PrintLiteAscii"
+[files]
+"PrintWidth.h"
+"Sprint.c"
+<endComponent>
diff --git a/EDK/Foundation/Library/Dxe/PrintLite/Ascii/PrintWidth.h b/EDK/Foundation/Library/Dxe/PrintLite/Ascii/PrintWidth.h
new file mode 100644
index 0000000..07901dc
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/PrintLite/Ascii/PrintWidth.h
@@ -0,0 +1,88 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PrintWidth.h
+
+Abstract:
+
+ Unicde option for generic width.
+ CHAR_W is Ascii
+ STRING_W is ""
+
+--*/
+
+#ifndef _PRINT_WIDTH_H_
+#define _PRINT_WIDTH_H_
+
+typedef CHAR8 CHAR_W;
+#define STRING_W(_s) _s
+
+#define ASPrint(Buffer, BufferSize, Format) SPrint (Buffer, BufferSize, Format)
+#define AvSPrint(Buffer, BufferSize, Format, Marker) VSPrint (Buffer, BufferSize, Format, Marker)
+
+UINTN
+UvSPrint (
+ OUT CHAR16 *StartOfBuffer,
+ IN UINTN StrLen,
+ IN CONST CHAR16 *Format,
+ IN VA_LIST Marker
+ )
+/*++
+
+Routine Description:
+
+ Internal implementation of USPrint.
+ Process format and place the results in Buffer for wide chars.
+
+Arguments:
+
+ StartOfBuffer - Wide char buffer to print the results of the parsing of Format into.
+ StrLen - Maximum number of characters to put into buffer.
+ Format - Format string
+ Marker - Vararg list consumed by processing Format.
+
+Returns:
+
+ Number of characters printed.
+
+--*/
+;
+
+UINTN
+USPrint (
+ OUT CHAR16 *Buffer,
+ IN UINTN BufferSize,
+ IN CONST CHAR16 *Format,
+ ...
+ )
+/*++
+
+Routine Description:
+
+ Process format and place the results in Buffer for wide chars.
+
+Arguments:
+
+ Buffer - Wide char buffer to print the results of the parsing of Format into.
+ BufferSize - Maximum number of characters to put into buffer.
+ Format - Format string
+ ... - Vararg list consumed by processing Format.
+
+Returns:
+
+ Number of characters printed.
+
+--*/
+;
+
+#endif
diff --git a/EDK/Foundation/Library/Dxe/PrintLite/Ascii/Sprint.c b/EDK/Foundation/Library/Dxe/PrintLite/Ascii/Sprint.c
new file mode 100644
index 0000000..35a7d4b
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/PrintLite/Ascii/Sprint.c
@@ -0,0 +1,142 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Sprint.c
+
+Abstract:
+
+ Basic Ascii AvSPrintf() function named VSPrint(). VSPrint() enables very
+ simple implemenation of SPrint() and Print() to support debug.
+
+ You can not Print more than EFI_DRIVER_LIB_MAX_PRINT_BUFFER characters at a
+ time. This makes the implementation very simple.
+
+ VSPrint, Print, SPrint format specification has the follwoing form
+
+ %[flags][width]type
+
+ flags:
+ '-' - Left justify
+ '+' - Prefix a sign
+ ' ' - Prefix a blank
+ ',' - Place commas in numberss
+ '0' - Prefix for width with zeros
+ 'l' - UINT64
+ 'L' - UINT64
+
+ width:
+ '*' - Get width from a UINTN argumnet from the argument list
+ Decimal number that represents width of print
+
+ type:
+ 'X' - argument is a UINTN hex number, prefix '0'
+ 'x' - argument is a hex number
+ 'd' - argument is a decimal number
+ 'a' - argument is an ascii string
+ 'S','s' - argument is an Unicode string
+ 'g' - argument is a pointer to an EFI_GUID
+ 't' - argument is a pointer to an EFI_TIME structure
+ 'c' - argument is an ascii character
+ 'r' - argument is EFI_STATUS
+ '%' - Print a %
+
+--*/
+
+#include "TianoCommon.h"
+#include "PrintWidth.h"
+#include "EfiPrintLib.h"
+#include "Print.h"
+
+UINTN
+USPrint (
+ OUT CHAR16 *Buffer,
+ IN UINTN BufferSize,
+ IN CONST CHAR16 *Format,
+ ...
+ )
+/*++
+
+Routine Description:
+
+ Process format and place the results in Buffer for wide chars.
+
+Arguments:
+
+ Buffer - Wide char buffer to print the results of the parsing of Format into.
+ BufferSize - Maximum number of characters to put into buffer.
+ Format - Format string
+ ... - Vararg list consumed by processing Format.
+
+Returns:
+
+ Number of characters printed.
+
+--*/
+{
+ UINTN Return;
+ VA_LIST Marker;
+
+ VA_START (Marker, Format);
+ Return = UnicodeVSPrint (Buffer, BufferSize, Format, Marker);
+ VA_END (Marker);
+
+ return Return;
+}
+
+UINTN
+UvSPrint (
+ OUT CHAR16 *Buffer,
+ IN UINTN BufferSize,
+ IN CONST CHAR16 *FormatString,
+ IN VA_LIST Marker
+ )
+/*++
+
+Routine Description:
+
+ Internal implementation of USPrint.
+ Process format and place the results in Buffer for wide chars.
+
+Arguments:
+
+ Buffer - Wide char buffer to print the results of the parsing of Format into.
+ BufferSize - Maximum number of characters to put into buffer.
+ FormatString - Format string
+ Marker - Vararg list consumed by processing Format.
+
+Returns:
+
+ Number of characters printed.
+
+--*/
+{
+ UINTN Index;
+ CHAR8 AsciiFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];
+ CHAR8 AsciiResult[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];
+
+ for (Index = 0; Index < EFI_DRIVER_LIB_MAX_PRINT_BUFFER && FormatString[Index] != '\0'; Index++) {
+ AsciiFormat[Index] = (CHAR8) FormatString[Index];
+ }
+
+ AsciiFormat[Index] = '\0';
+
+ Index = VSPrint (AsciiResult, EFI_DRIVER_LIB_MAX_PRINT_BUFFER, AsciiFormat, Marker);
+
+ for (Index = 0; (Index < (BufferSize - 1)) && AsciiResult[Index] != '\0'; Index++) {
+ Buffer[Index] = (CHAR16) AsciiResult[Index];
+ }
+
+ Buffer[Index] = '\0';
+
+ return Index++;
+}
diff --git a/EDK/Foundation/Library/Dxe/PrintLite/BoxDraw.c b/EDK/Foundation/Library/Dxe/PrintLite/BoxDraw.c
new file mode 100644
index 0000000..560d92c
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/PrintLite/BoxDraw.c
@@ -0,0 +1,212 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ BoxDraw.c
+
+Abstract:
+ Lib functions to support Box Draw Unicode code pages.
+
+
+
+Revision History
+
+--*/
+
+#include "Tiano.h"
+#include "EfiDriverLib.h"
+
+
+
+typedef struct {
+ CHAR16 Unicode;
+ CHAR8 PcAnsi;
+ CHAR8 Ascii;
+} UNICODE_TO_CHAR;
+
+
+//
+// This list is used to define the valid extend chars.
+// It also provides a mapping from Unicode to PCANSI or
+// ASCII. The ASCII mapping we just made up.
+//
+//
+
+static UNICODE_TO_CHAR UnicodeToPcAnsiOrAscii[] = {
+ BOXDRAW_HORIZONTAL, 0xc4, L'-',
+ BOXDRAW_VERTICAL, 0xb3, L'|',
+ BOXDRAW_DOWN_RIGHT, 0xda, L'/',
+ BOXDRAW_DOWN_LEFT, 0xbf, L'\\',
+ BOXDRAW_UP_RIGHT, 0xc0, L'\\',
+ BOXDRAW_UP_LEFT, 0xd9, L'/',
+ BOXDRAW_VERTICAL_RIGHT, 0xc3, L'|',
+ BOXDRAW_VERTICAL_LEFT, 0xb4, L'|',
+ BOXDRAW_DOWN_HORIZONTAL, 0xc2, L'+',
+ BOXDRAW_UP_HORIZONTAL, 0xc1, L'+',
+ BOXDRAW_VERTICAL_HORIZONTAL, 0xc5, L'+',
+ BOXDRAW_DOUBLE_HORIZONTAL, 0xcd, L'-',
+ BOXDRAW_DOUBLE_VERTICAL, 0xba, L'|',
+ BOXDRAW_DOWN_RIGHT_DOUBLE, 0xd5, L'/',
+ BOXDRAW_DOWN_DOUBLE_RIGHT, 0xd6, L'/',
+ BOXDRAW_DOUBLE_DOWN_RIGHT, 0xc9, L'/',
+ BOXDRAW_DOWN_LEFT_DOUBLE, 0xb8, L'\\',
+ BOXDRAW_DOWN_DOUBLE_LEFT, 0xb7, L'\\',
+ BOXDRAW_DOUBLE_DOWN_LEFT, 0xbb, L'\\',
+ BOXDRAW_UP_RIGHT_DOUBLE, 0xd4, L'\\',
+ BOXDRAW_UP_DOUBLE_RIGHT, 0xd3, L'\\',
+ BOXDRAW_DOUBLE_UP_RIGHT, 0xc8, L'\\',
+ BOXDRAW_UP_LEFT_DOUBLE, 0xbe, L'/',
+ BOXDRAW_UP_DOUBLE_LEFT, 0xbd, L'/',
+ BOXDRAW_DOUBLE_UP_LEFT, 0xbc, L'/',
+ BOXDRAW_VERTICAL_RIGHT_DOUBLE, 0xc6, L'|',
+ BOXDRAW_VERTICAL_DOUBLE_RIGHT, 0xc7, L'|',
+ BOXDRAW_DOUBLE_VERTICAL_RIGHT, 0xcc, L'|',
+ BOXDRAW_VERTICAL_LEFT_DOUBLE, 0xb5, L'|',
+ BOXDRAW_VERTICAL_DOUBLE_LEFT, 0xb6, L'|',
+ BOXDRAW_DOUBLE_VERTICAL_LEFT, 0xb9, L'|',
+ BOXDRAW_DOWN_HORIZONTAL_DOUBLE, 0xd1, L'+',
+ BOXDRAW_DOWN_DOUBLE_HORIZONTAL, 0xd2, L'+',
+ BOXDRAW_DOUBLE_DOWN_HORIZONTAL, 0xcb, L'+',
+ BOXDRAW_UP_HORIZONTAL_DOUBLE, 0xcf, L'+',
+ BOXDRAW_UP_DOUBLE_HORIZONTAL, 0xd0, L'+',
+ BOXDRAW_DOUBLE_UP_HORIZONTAL, 0xca, L'+',
+ BOXDRAW_VERTICAL_HORIZONTAL_DOUBLE, 0xd8, L'+',
+ BOXDRAW_VERTICAL_DOUBLE_HORIZONTAL, 0xd7, L'+',
+ BOXDRAW_DOUBLE_VERTICAL_HORIZONTAL, 0xce, L'+',
+
+ BLOCKELEMENT_FULL_BLOCK, 0xdb, L'*',
+ BLOCKELEMENT_LIGHT_SHADE, 0xb0, L'+',
+
+ GEOMETRICSHAPE_UP_TRIANGLE, 0x1e, L'^',
+ GEOMETRICSHAPE_RIGHT_TRIANGLE, 0x10, L'>',
+ GEOMETRICSHAPE_DOWN_TRIANGLE, 0x1f, L'v',
+ GEOMETRICSHAPE_LEFT_TRIANGLE, 0x11, L'<',
+
+ ARROW_LEFT, 0x3c, L'<',
+
+ ARROW_UP, 0x18, L'^',
+
+ ARROW_RIGHT, 0x3e, L'>',
+
+ ARROW_DOWN, 0x19, L'v',
+
+ 0x0000, 0x00
+};
+
+
+BOOLEAN
+LibIsValidTextGraphics (
+ IN CHAR16 Graphic,
+ OUT CHAR8 *PcAnsi, OPTIONAL
+ OUT CHAR8 *Ascii OPTIONAL
+ )
+/*++
+
+Routine Description:
+
+ Detects if a Unicode char is for Box Drawing text graphics.
+
+Arguments:
+
+ Graphic - Unicode char to test.
+
+ PcAnsi - Optional pointer to return PCANSI equivalent of Graphic.
+
+ Asci - Optional pointer to return Ascii equivalent of Graphic.
+
+Returns:
+
+ TRUE if Gpaphic is a supported Unicode Box Drawing character.
+
+--*/
+{
+ UNICODE_TO_CHAR *Table;
+
+ if ((((Graphic & 0xff00) != 0x2500) && ((Graphic & 0xff00) != 0x2100))) {
+
+ //
+ // Unicode drawing code charts are all in the 0x25xx range,
+ // arrows are 0x21xx
+ //
+ return FALSE;
+ }
+
+ for (Table = UnicodeToPcAnsiOrAscii; Table->Unicode != 0x0000; Table++) {
+ if (Graphic == Table->Unicode) {
+ if (PcAnsi != NULL) {
+ *PcAnsi = Table->PcAnsi;
+ }
+ if (Ascii != NULL) {
+ *Ascii = Table->Ascii;
+ }
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+
+BOOLEAN
+IsValidAscii (
+ IN CHAR16 Ascii
+ )
+/*++
+
+Routine Description:
+
+ Is it valid ascii char?
+
+Arguments:
+
+ Ascii - The char to check
+
+Returns:
+
+ TRUE - Is a ascii char
+ FALSE - Not a ascii char
+
+--*/
+{
+ if ((Ascii >= 0x20) && (Ascii <= 0x7f)) {
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
+BOOLEAN
+IsValidEfiCntlChar (
+ IN CHAR16 CharC
+ )
+/*++
+
+Routine Description:
+
+ Is it valid EFI control char?
+
+Arguments:
+
+ CharC - The char to check
+
+Returns:
+
+ TRUE - Is a valid EFI control char
+ FALSE - Not a valid EFI control char
+
+--*/
+{
+ if (CharC == CHAR_NULL || CharC == CHAR_BACKSPACE || CharC == CHAR_LINEFEED || CharC == CHAR_CARRIAGE_RETURN) {
+ return TRUE;
+ }
+ return FALSE;
+}
+
diff --git a/EDK/Foundation/Library/Dxe/PrintLite/Print.c b/EDK/Foundation/Library/Dxe/PrintLite/Print.c
new file mode 100644
index 0000000..35b2327
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/PrintLite/Print.c
@@ -0,0 +1,194 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Print.c
+
+Abstract:
+
+ Basic Ascii AvSPrintf() function named VSPrint(). VSPrint() enables very
+ simple implemenation of SPrint() and Print() to support debug.
+
+ You can not Print more than EFI_DRIVER_LIB_MAX_PRINT_BUFFER characters at a
+ time. This makes the implementation very simple.
+
+ VSPrint, Print, SPrint format specification has the follwoing form
+
+ %[flags][width]type
+
+ flags:
+ '-' - Left justify
+ '+' - Prefix a sign
+ ' ' - Prefix a blank
+ ',' - Place commas in numberss
+ '0' - Prefix for width with zeros
+ 'l' - UINT64
+ 'L' - UINT64
+
+ width:
+ '*' - Get width from a UINTN argumnet from the argument list
+ Decimal number that represents width of print
+
+ type:
+ 'X' - argument is a UINTN hex number, prefix '0'
+ 'x' - argument is a hex number
+ 'd' - argument is a decimal number
+ 'a' - argument is an ascii string
+ 'S','s' - argument is an Unicode string
+ 'g' - argument is a pointer to an EFI_GUID
+ 't' - argument is a pointer to an EFI_TIME structure
+ 'c' - argument is an ascii character
+ 'r' - argument is EFI_STATUS
+ '%' - Print a %
+
+--*/
+
+#include "Tiano.h"
+#include "EfiDriverLib.h"
+#include "TianoCommon.h"
+#include "EfiCommonLib.h"
+#include "PrintWidth.h"
+#include "EfiPrintLib.h"
+#include "Print.h"
+
+#ifndef EFI_PRINT_LITE
+STATIC
+CHAR_W *
+GetFlagsAndWidth (
+ IN CHAR_W *Format,
+ OUT UINTN *Flags,
+ OUT UINTN *Width,
+ IN OUT VA_LIST *Marker
+ );
+
+STATIC
+UINTN
+GuidToString (
+ IN EFI_GUID *Guid,
+ IN OUT CHAR_W *Buffer,
+ IN UINTN BufferSize
+ );
+
+STATIC
+UINTN
+TimeToString (
+ IN EFI_TIME *Time,
+ IN OUT CHAR_W *Buffer,
+ IN UINTN BufferSize
+ );
+
+STATIC
+UINTN
+EfiStatusToString (
+ IN EFI_STATUS Status,
+ OUT CHAR_W *Buffer,
+ IN UINTN BufferSize
+ );
+
+#endif
+STATIC
+UINTN
+Atoi (
+ CHAR_W *String
+ );
+
+UINTN
+SPrint (
+ OUT CHAR_W *Buffer,
+ IN UINTN BufferSize,
+ IN CONST CHAR_W *Format,
+ ...
+ )
+/*++
+
+Routine Description:
+
+ SPrint function to process format and place the results in Buffer.
+
+Arguments:
+
+ Buffer - Wide char buffer to print the results of the parsing of Format into.
+
+ BufferSize - Maximum number of characters to put into buffer. Zero means no
+ limit.
+
+ Format - Format string see file header for more details.
+
+ ... - Vararg list consumed by processing Format.
+
+Returns:
+
+ Number of characters printed.
+
+--*/
+{
+ UINTN Return;
+ VA_LIST Marker;
+
+ VA_START (Marker, Format);
+ Return = VSPrint (Buffer, BufferSize, Format, Marker);
+ VA_END (Marker);
+
+ return Return;
+}
+
+UINTN
+VSPrint (
+ OUT CHAR_W *StartOfBuffer,
+ IN UINTN BufferSize,
+ IN CONST CHAR_W *FormatString,
+ IN VA_LIST Marker
+ )
+/*++
+
+Routine Description:
+
+ VSPrint function to process format and place the results in Buffer. Since a
+ VA_LIST is used this rountine allows the nesting of Vararg routines. Thus
+ this is the main print working routine
+
+Arguments:
+
+ StartOfBuffer - Unicode buffer to print the results of the parsing of Format into.
+
+ BufferSize - Maximum number of characters to put into buffer. Zero means
+ no limit.
+
+ FormatString - Unicode format string see file header for more details.
+
+ Marker - Vararg list consumed by processing Format.
+
+Returns:
+
+ Number of characters printed.
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_PRINT_PROTOCOL *PrintProtocol;
+
+ Status = gBS->LocateProtocol (
+ &gEfiPrintProtocolGuid,
+ NULL,
+ (VOID*)&PrintProtocol
+ );
+ if (EFI_ERROR (Status)) {
+ return 0;
+ } else {
+ return PrintProtocol->VSPrint (
+ StartOfBuffer,
+ BufferSize,
+ FormatString,
+ Marker
+ );
+ }
+}
diff --git a/EDK/Foundation/Library/Dxe/PrintLite/Print.h b/EDK/Foundation/Library/Dxe/PrintLite/Print.h
new file mode 100644
index 0000000..ad54aa8
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/PrintLite/Print.h
@@ -0,0 +1,37 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Print.h
+
+Abstract:
+
+ Private data for Print.c
+
+--*/
+
+#ifndef _PRINT_H_
+#define _PRINT_H_
+
+#define LEFT_JUSTIFY 0x01
+#define PREFIX_SIGN 0x02
+#define PREFIX_BLANK 0x04
+#define COMMA_TYPE 0x08
+#define LONG_TYPE 0x10
+#define PREFIX_ZERO 0x20
+
+//
+// Largest number of characters that can be printed out.
+//
+#define EFI_DRIVER_LIB_MAX_PRINT_BUFFER (80 * 4)
+
+#endif
diff --git a/EDK/Foundation/Library/Dxe/PrintLite/PrintLib.inf b/EDK/Foundation/Library/Dxe/PrintLite/PrintLib.inf
new file mode 100644
index 0000000..876271d
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/PrintLite/PrintLib.inf
@@ -0,0 +1,51 @@
+#/*++
+#
+# Copyright (c) 2004, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# PrintLib.inf
+#
+# Abstract:
+#
+# Component description file.
+#
+#--*/
+
+[defines]
+BASE_NAME = PrintLibLite
+COMPONENT_TYPE = LIBRARY
+
+[sources.common]
+ BoxDraw.c
+ Print.c
+ Print.h
+ StdErr.c
+ Unicode\PrintWidth.h
+ Unicode\SPrint.c
+
+[includes.common]
+ $(EDK_SOURCE)\Foundation
+ $(EDK_SOURCE)\Foundation\Framework
+ $(EDK_SOURCE)\Foundation\Efi
+ .
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Print\Unicode
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+
+[libraries.common]
+ EdkProtocolLib
+
+[nmake.common]
+ C_STD_INCLUDE=
diff --git a/EDK/Foundation/Library/Dxe/PrintLite/PrintLibLite.cif b/EDK/Foundation/Library/Dxe/PrintLite/PrintLibLite.cif
new file mode 100644
index 0000000..9acf21e
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/PrintLite/PrintLibLite.cif
@@ -0,0 +1,19 @@
+<component>
+ name = "PrintLibLite"
+ category = ModulePart
+ LocalRoot = "EDK\Foundation\Library\Dxe\PrintLite\"
+ RefName = "PrintLibLite"
+[files]
+"PrintLibLite.sdl"
+"PrintLibLite.mak"
+"BoxDraw.c"
+"Print.c"
+"Print.h"
+"StdErr.c"
+"PrintLib.inf"
+[parts]
+"PrintLiteAscii"
+"PrintLiteUnicode"
+"PrintLiteAscii"
+"PrintLiteUnicode"
+<endComponent>
diff --git a/EDK/Foundation/Library/Dxe/PrintLite/PrintLibLite.mak b/EDK/Foundation/Library/Dxe/PrintLite/PrintLibLite.mak
new file mode 100644
index 0000000..bac6c40
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/PrintLite/PrintLibLite.mak
@@ -0,0 +1,70 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/PrintLibLite/PrintLibLite.mak 1 1/20/12 4:09a Jeffch $
+#
+# $Revision: 1 $
+#
+# $Date: 1/20/12 4:09a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/PrintLibLite/PrintLibLite.mak $
+#
+# 1 1/20/12 4:09a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 9/27/11 6:31a Wesleychen
+# Intel EDK initially releases.
+#
+# 2 9/02/09 3:53a Iminglin
+# EIP24919
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: PrintLibLite.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+$(PRINTLIBLITE) : PrintLibLite
+
+$(BUILD_DIR)\PrintLibLite.lib : PrintLibLite
+
+PrintLibLite : $(BUILD_DIR)\PrintLibLite.mak PrintLibLiteBin
+
+$(BUILD_DIR)\PrintLibLite.mak : $(PrintLibLite_DIR)\$(@B).cif $(PrintLibLite_DIR)\$(@B).mak $(BUILD_RULES) $(PrintLibLite_DIR)\Unicode\PrintLiteUnicode.cif
+ $(CIF2MAK) $(PrintLibLite_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS) $(PrintLibLite_DIR)\Unicode\PrintLiteUnicode.cif
+
+PrintLibLiteBin : $(EDKPROTOCOLLIB)
+ $(MAKE) /$(MAKEFLAGS) $(EDK_DEFAULTS)\
+ /f $(BUILD_DIR)\PrintLibLite.mak all\
+ "MY_INCLUDES=/I$(PrintLibLite_DIR) /I$(PrintLibLite_DIR)\Unicode"\
+ TYPE=LIBRARY \
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#********************************************************************** \ No newline at end of file
diff --git a/EDK/Foundation/Library/Dxe/PrintLite/PrintLibLite.sdl b/EDK/Foundation/Library/Dxe/PrintLite/PrintLibLite.sdl
new file mode 100644
index 0000000..c41267d
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/PrintLite/PrintLibLite.sdl
@@ -0,0 +1,26 @@
+TOKEN
+ Name = "PrintLibLite_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable PrintLibLite support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "PRINTLIBLITE"
+ Value = "$(BUILD_DIR)\PrintLibLite.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "PrintLibLite_DIR"
+End
+
+MODULE
+ Help = "Includes PrintLibLite.mak to Project"
+ File = "PrintLibLite.mak"
+End
+
diff --git a/EDK/Foundation/Library/Dxe/PrintLite/StdErr.c b/EDK/Foundation/Library/Dxe/PrintLite/StdErr.c
new file mode 100644
index 0000000..14d6ba9
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/PrintLite/StdErr.c
@@ -0,0 +1,287 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ StdErr.c
+
+Abstract:
+
+ Basic Ascii AvSPrintf() function named VSPrint(). VSPrint() enables very
+ simple implemenation of SPrint() and Print() to support debug.
+
+ You can not Print more than EFI_DRIVER_LIB_MAX_PRINT_BUFFER characters at a
+ time. This makes the implementation very simple.
+
+ VSPrint, Print, SPrint format specification has the follwoing form
+
+ %[flags][width]type
+
+ flags:
+ '-' - Left justify
+ '+' - Prefix a sign
+ ' ' - Prefix a blank
+ ',' - Place commas in numberss
+ '0' - Prefix for width with zeros
+ 'l' - UINT64
+ 'L' - UINT64
+
+ width:
+ '*' - Get width from a UINTN argumnet from the argument list
+ Decimal number that represents width of print
+
+ type:
+ 'X' - argument is a UINTN hex number, prefix '0'
+ 'x' - argument is a hex number
+ 'd' - argument is a decimal number
+ 'a' - argument is an ascii string
+ 'S','s' - argument is an Unicode string
+ 'g' - argument is a pointer to an EFI_GUID
+ 't' - argument is a pointer to an EFI_TIME structure
+ 'c' - argument is an ascii character
+ 'r' - argument is EFI_STATUS
+ '%' - Print a %
+
+--*/
+
+#include "Tiano.h"
+#include "EfiDriverLib.h"
+#include "EfiCommonLib.h"
+#include "EfiPrintLib.h"
+#include "Print.h"
+
+
+UINTN
+ErrorPrint (
+ IN CONST CHAR16 *ErrorString,
+ IN CONST CHAR8 *Format,
+ ...
+ )
+/*++
+
+Routine Description:
+
+ Print function for a maximum of EFI_DRIVER_LIB_MAX_PRINT_BUFFER ascii
+ characters.
+
+Arguments:
+
+ ErrorString - String of error infomation.
+
+ Format - Ascii format string see file header for more details.
+
+ ... - Vararg list consumed by processing Format.
+
+Returns:
+
+ Number of characters printed.
+
+--*/
+{
+ UINTN Return;
+ VA_LIST Marker;
+ UINTN Index;
+ UINTN MaxIndex;
+ //
+ // Increase array size of 'UnicodeFormat' and 'Buffer' by 1 as there is a possibility of buffer overflow.
+ //
+ CHAR16 Buffer[EFI_DRIVER_LIB_MAX_PRINT_BUFFER+1];
+ CHAR16 UnicodeFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER+1];
+
+ MaxIndex = EfiAsciiStrLen ((CHAR8 *) Format);
+ if (MaxIndex >= EFI_DRIVER_LIB_MAX_PRINT_BUFFER) {
+ //
+ // Format string was too long for use to process.
+ //
+ return 0;
+ }
+
+ if (ErrorString != '\0') {
+ if (gST->StdErr != NULL) {
+ //
+ // To be extra safe make sure StdErr has been initialized
+ //
+ gST->StdErr->SetAttribute (gST->StdErr, EFI_TEXT_ATTR (EFI_RED, EFI_BLACK));
+ gST->StdErr->OutputString (gST->StdErr, (CHAR16 *) ErrorString);
+ gST->StdErr->SetAttribute (gST->StdErr, EFI_TEXT_ATTR (EFI_WHITE, EFI_BLACK));
+ }
+ }
+
+ for (Index = 0; Index < MaxIndex; Index++) {
+ UnicodeFormat[Index] = (CHAR16) Format[Index];
+ }
+
+ UnicodeFormat[Index] = 0;
+
+ VA_START (Marker, Format);
+ Return = VSPrint (Buffer, sizeof (Buffer), UnicodeFormat, Marker);
+ VA_END (Marker);
+
+ //
+ // Need to convert to Unicode to do an OutputString
+ //
+
+ if (gST->StdErr != NULL) {
+ //
+ // To be extra safe make sure StdErr has been initialized
+ //
+ gST->StdErr->OutputString (gST->StdErr, Buffer);
+ }
+
+ return Return;
+}
+
+
+UINTN
+Aprint (
+ IN CONST CHAR8 *Format,
+ ...
+ )
+/*++
+
+Routine Description:
+
+ Print function for a maximum of EFI_DRIVER_LIB_MAX_PRINT_BUFFER ascii
+ characters.
+
+Arguments:
+
+ Format - Ascii format string see file header for more details.
+
+ ... - Vararg list consumed by processing Format.
+
+Returns:
+
+ Number of characters printed.
+
+--*/
+{
+ UINTN Return;
+ VA_LIST Marker;
+ UINTN Index;
+ UINTN MaxIndex;
+ CHAR16 Buffer[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];
+ CHAR16 UnicodeFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];
+
+ MaxIndex = EfiAsciiStrLen ((CHAR8 *) Format);
+ if (MaxIndex >= EFI_DRIVER_LIB_MAX_PRINT_BUFFER) {
+ //
+ // Format string was too long for use to process.
+ //
+ return 0;
+ }
+
+ for (Index = 0; Index < EFI_DRIVER_LIB_MAX_PRINT_BUFFER; Index++) {
+ UnicodeFormat[Index] = (CHAR16) Format[Index];
+ }
+
+ VA_START (Marker, Format);
+ Return = VSPrint (Buffer, sizeof (Buffer), UnicodeFormat, Marker);
+ VA_END (Marker);
+
+ //
+ // Need to convert to Unicode to do an OutputString
+ //
+
+ if (gST->ConOut != NULL) {
+ //
+ // To be extra safe make sure ConOut has been initialized
+ //
+ gST->ConOut->OutputString (gST->ConOut, Buffer);
+ }
+
+ return Return;
+}
+
+
+UINTN
+Print (
+ IN CONST CHAR16 *Format,
+ ...
+ )
+/*++
+
+Routine Description:
+
+ Print function for a maximum of EFI_DRIVER_LIB_MAX_PRINT_BUFFER ascii
+ characters.
+
+Arguments:
+
+ Format - Ascii format string see file header for more details.
+
+ ... - Vararg list consumed by processing Format.
+
+Returns:
+
+ Number of characters printed.
+
+--*/
+{
+ UINTN Return;
+ VA_LIST Marker;
+ CHAR16 Buffer[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];
+
+ VA_START (Marker, Format);
+ Return = VSPrint (Buffer, sizeof (Buffer), Format, Marker);
+ VA_END (Marker);
+
+ if (gST->ConOut != NULL) {
+ //
+ // To be extra safe make sure ConOut has been initialized
+ //
+ gST->ConOut->OutputString (gST->ConOut, Buffer);
+ }
+
+ return Return;
+}
+
+UINTN
+UPrint (
+ IN CONST CHAR16 *Format,
+ ...
+ )
+/*++
+
+Routine Description:
+
+ Print function for a maximum of EFI_DRIVER_LIB_MAX_PRINT_BUFFER ascii
+ characters.
+
+Arguments:
+
+ Format - Ascii format string see file header for more details.
+
+ ... - Vararg list consumed by processing Format.
+
+Returns:
+
+ Number of characters printed.
+
+--*/
+{
+ UINTN Return;
+ VA_LIST Marker;
+ CHAR16 Buffer[EFI_DRIVER_LIB_MAX_PRINT_BUFFER];
+
+ VA_START (Marker, Format);
+ Return = VSPrint (Buffer, sizeof (Buffer), Format, Marker);
+ VA_END (Marker);
+
+ if (gST->ConOut != NULL) {
+ //
+ // To be extra safe make sure ConOut has been initialized
+ //
+ gST->ConOut->OutputString (gST->ConOut, Buffer);
+ }
+
+ return Return;
+}
diff --git a/EDK/Foundation/Library/Dxe/PrintLite/Unicode/PrintLiteUnicode.cif b/EDK/Foundation/Library/Dxe/PrintLite/Unicode/PrintLiteUnicode.cif
new file mode 100644
index 0000000..8e55a78
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/PrintLite/Unicode/PrintLiteUnicode.cif
@@ -0,0 +1,9 @@
+<component>
+ name = "PrintLiteUnicode"
+ category = ModulePart
+ LocalRoot = "EDK\Foundation\Library\Dxe\PrintLite\Unicode"
+ RefName = "PrintLiteUnicode"
+[files]
+"PrintWidth.h"
+"Sprint.c"
+<endComponent>
diff --git a/EDK/Foundation/Library/Dxe/PrintLite/Unicode/PrintWidth.h b/EDK/Foundation/Library/Dxe/PrintLite/Unicode/PrintWidth.h
new file mode 100644
index 0000000..fef9ea9
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/PrintLite/Unicode/PrintWidth.h
@@ -0,0 +1,35 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PrintWidth.h
+
+Abstract:
+
+ Unicde option for generic width.
+ CHAR_W is Unicode
+ STRING_W is L""
+
+--*/
+
+#ifndef _PRINT_WIDTH_H_
+#define _PRINT_WIDTH_H_
+
+typedef CHAR16 CHAR_W;
+#define STRING_W(_s) L##_s
+
+#define USPrint(Buffer, BufferSize, Format) SPrint (Buffer, BufferSize, Format)
+#define UvSPrint(Buffer, BufferSize, Format, Marker) VSPrint (Buffer, BufferSize, Format, Marker)
+
+#include "EfiCommonLib.h"
+
+#endif
diff --git a/EDK/Foundation/Library/Dxe/PrintLite/Unicode/Sprint.c b/EDK/Foundation/Library/Dxe/PrintLite/Unicode/Sprint.c
new file mode 100644
index 0000000..e3b8738
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/PrintLite/Unicode/Sprint.c
@@ -0,0 +1,147 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Sprint.c
+
+Abstract:
+
+ Basic Ascii AvSPrintf() function named VSPrint(). VSPrint() enables very
+ simple implemenation of SPrint() and Print() to support debug.
+
+ You can not Print more than EFI_DRIVER_LIB_MAX_PRINT_BUFFER characters at a
+ time. This makes the implementation very simple.
+
+ VSPrint, Print, SPrint format specification has the follwoing form
+
+ %[flags][width]type
+
+ flags:
+ '-' - Left justify
+ '+' - Prefix a sign
+ ' ' - Prefix a blank
+ ',' - Place commas in numberss
+ '0' - Prefix for width with zeros
+ 'l' - UINT64
+ 'L' - UINT64
+
+ width:
+ '*' - Get width from a UINTN argumnet from the argument list
+ Decimal number that represents width of print
+
+ type:
+ 'X' - argument is a UINTN hex number, prefix '0'
+ 'x' - argument is a hex number
+ 'd' - argument is a decimal number
+ 'a' - argument is an ascii string
+ 'S','s' - argument is an Unicode string
+ 'g' - argument is a pointer to an EFI_GUID
+ 't' - argument is a pointer to an EFI_TIME structure
+ 'c' - argument is an ascii character
+ 'r' - argument is EFI_STATUS
+ '%' - Print a %
+
+--*/
+
+#include "TianoCommon.h"
+#include "PrintWidth.h"
+#include "EfiPrintLib.h"
+#include "Print.h"
+
+
+UINTN
+ASPrint (
+ OUT CHAR8 *Buffer,
+ IN UINTN BufferSize,
+ IN CONST CHAR8 *Format,
+ ...
+ )
+/*++
+
+Routine Description:
+
+ Process format and place the results in Buffer for narrow chars.
+
+Arguments:
+
+ Buffer - Narrow char buffer to print the results of the parsing of Format into.
+ BufferSize - Maximum number of characters to put into buffer.
+ Format - Format string
+ ... - Vararg list consumed by processing Format.
+
+Returns:
+
+ Number of characters printed.
+
+--*/
+{
+ UINTN Return;
+ VA_LIST Marker;
+
+ VA_START (Marker, Format);
+ Return = AvSPrint (Buffer, BufferSize, Format, Marker);
+ VA_END (Marker);
+
+ return Return;
+}
+
+
+UINTN
+AvSPrint (
+ OUT CHAR8 *Buffer,
+ IN UINTN BufferSize,
+ IN CONST CHAR8 *FormatString,
+ IN VA_LIST Marker
+ )
+/*++
+
+Routine Description:
+
+ Internal implementation of ASPrint.
+ Process format and place the results in Buffer for narrow chars.
+
+Arguments:
+
+ Buffer - Narrow char buffer to print the results of the parsing of Format into.
+ BufferSize - Maximum number of characters to put into buffer.
+ FormatString - Format string
+ Marker - Vararg list consumed by processing Format.
+
+Returns:
+
+ Number of characters printed.
+
+--*/
+{
+ UINTN Index;
+ //
+ // Increase array size of 'UnicodeFormat' and 'UnicodeResult' by 1 as there is a possibility of buffer overflow.
+ //
+ CHAR16 UnicodeFormat[EFI_DRIVER_LIB_MAX_PRINT_BUFFER+1];
+ CHAR16 UnicodeResult[EFI_DRIVER_LIB_MAX_PRINT_BUFFER+1];
+
+ for (Index = 0; Index < EFI_DRIVER_LIB_MAX_PRINT_BUFFER && FormatString[Index] != '\0'; Index++) {
+ UnicodeFormat[Index] = (CHAR16) FormatString[Index];
+ }
+
+ UnicodeFormat[Index] = '\0';
+
+ Index = VSPrint (UnicodeResult, sizeof (UnicodeResult)/sizeof (CHAR16), UnicodeFormat, Marker);
+
+ for (Index = 0; (Index < (BufferSize - 1)) && UnicodeResult[Index] != '\0'; Index++) {
+ Buffer[Index] = (CHAR8) UnicodeResult[Index];
+ }
+
+ Buffer[Index] = '\0';
+
+ return Index++;
+}
diff --git a/EDK/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiEfiIfrSupportLib.cif b/EDK/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiEfiIfrSupportLib.cif
new file mode 100644
index 0000000..7a843fc
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiEfiIfrSupportLib.cif
@@ -0,0 +1,15 @@
+<component>
+ name = "UefiEfiIfrSupportLib"
+ category = ModulePart
+ LocalRoot = "EDK\Foundation\Library\Dxe\UefiEfiIfrSupportLib\"
+ RefName = "UefiEfiIfrSupportLib"
+[files]
+"UefiEfiIfrSupportLib.sdl"
+"UefiEfiIfrSupportLib.mak"
+"UefiIfrCommon.c"
+"UefiIfrForm.c"
+"UefiIfrLibrary.h"
+"UefiIfrOpCodeCreation.c"
+"UefiIfrString.c"
+"UefiEfiIfrSupportLib.inf"
+<endComponent>
diff --git a/EDK/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiEfiIfrSupportLib.inf b/EDK/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiEfiIfrSupportLib.inf
new file mode 100644
index 0000000..cc26951
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiEfiIfrSupportLib.inf
@@ -0,0 +1,49 @@
+#/*++
+#
+# Copyright (c) 2007, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# UfiIfrSupportLib.inf
+#
+# Abstract:
+#
+# Component description file.
+#
+#--*/
+
+[defines]
+BASE_NAME = UefiEfiIfrSupportLib
+COMPONENT_TYPE = LIBRARY
+
+[sources.common]
+ UefiIfrCommon.c
+ UefiIfrForm.c
+ UefiIfrString.c
+ UefiIfrOpCodeCreation.c
+ UefiIfrLibrary.h
+
+[includes.common]
+ $(EDK_SOURCE)\Foundation\Efi
+ $(EDK_SOURCE)\Foundation\Framework
+ $(EDK_SOURCE)\Foundation
+ .
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+
+[libraries.common]
+ EfiGuidLib
+ EdkFrameworkProtocolLib
+
+[nmake.common]
diff --git a/EDK/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiEfiIfrSupportLib.mak b/EDK/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiEfiIfrSupportLib.mak
new file mode 100644
index 0000000..991cd72
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiEfiIfrSupportLib.mak
@@ -0,0 +1,70 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/UefiEfiIfrSupportLib/UefiEfiIfrSupportLib.mak 1 1/20/12 4:13a Jeffch $
+#
+# $Revision: 1 $
+#
+# $Date: 1/20/12 4:13a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/UefiEfiIfrSupportLib/UefiEfiIfrSupportLib.mak $
+#
+# 1 1/20/12 4:13a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 9/27/11 6:35a Wesleychen
+# Intel EDK initially releases.
+#
+# 2 9/02/09 3:55a Iminglin
+# EIP24919
+#
+#**********************************************************************
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: UefiEfiIfrSupportLib.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+$(UEFIEFIIFRSUPPORTLIB) : UefiEfiIfrSupportLib
+
+$(BUILD_DIR)\UefiEfiIfrSupportLib.lib : UefiEfiIfrSupportLib
+
+UefiEfiIfrSupportLib : $(BUILD_DIR)\UefiEfiIfrSupportLib.mak UefiEfiIfrSupportLibBin
+
+$(BUILD_DIR)\UefiEfiIfrSupportLib.mak : $(UefiEfiIfrSupportLib_DIR)\$(@B).cif $(UefiEfiIfrSupportLib_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(UefiEfiIfrSupportLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+UefiEfiIfrSupportLibBin : $(EFIGUIDLIB) $(EDKFRAMEWORKPROTOCOLLIB)
+ $(MAKE) /$(MAKEFLAGS) $(EDK_DEFAULTS)\
+ /f $(BUILD_DIR)\UefiEfiIfrSupportLib.mak all\
+ TYPE=LIBRARY \
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#********************************************************************** \ No newline at end of file
diff --git a/EDK/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiEfiIfrSupportLib.sdl b/EDK/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiEfiIfrSupportLib.sdl
new file mode 100644
index 0000000..f7135b8
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiEfiIfrSupportLib.sdl
@@ -0,0 +1,26 @@
+TOKEN
+ Name = "UefiEfiIfrSupportLib_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable UefiEfiIfrSupportLib support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "UEFIEFIIFRSUPPORTLIB"
+ Value = "$(BUILD_DIR)\UefiEfiIfrSupportLib.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "UefiEfiIfrSupportLib_DIR"
+End
+
+MODULE
+ Help = "Includes UefiEfiIfrSupportLib.mak to Project"
+ File = "UefiEfiIfrSupportLib.mak"
+End
+
diff --git a/EDK/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrCommon.c b/EDK/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrCommon.c
new file mode 100644
index 0000000..d2a66e0
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrCommon.c
@@ -0,0 +1,762 @@
+/*++
+
+Copyright (c) 2007 - 2011, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ UefiIfrCommon.c
+
+Abstract:
+
+ Common Library Routines to assist handle HII elements.
+
+--*/
+
+#include "UefiIfrLibrary.h"
+
+//
+// Hii vendor device path template
+//
+HII_VENDOR_DEVICE_PATH mHiiVendorDevicePathTemplate = {
+ {
+ {
+ {
+ HARDWARE_DEVICE_PATH,
+ HW_VENDOR_DP,
+ (UINT8) (sizeof (HII_VENDOR_DEVICE_PATH_NODE)),
+ (UINT8) ((sizeof (HII_VENDOR_DEVICE_PATH_NODE)) >> 8)
+ },
+ EFI_IFR_TIANO_GUID,
+ },
+ 0,
+ 0
+ },
+ {
+ END_DEVICE_PATH_TYPE,
+ END_ENTIRE_DEVICE_PATH_SUBTYPE,
+ END_DEVICE_PATH_LENGTH,
+ 0
+ }
+};
+
+//
+// Hii relative protocols
+//
+BOOLEAN mHiiProtocolsInitialized = FALSE;
+
+EFI_HII_DATABASE_PROTOCOL *gIfrLibHiiDatabase;
+EFI_HII_STRING_PROTOCOL *gIfrLibHiiString;
+
+VOID
+LocateHiiProtocols (
+ VOID
+ )
+/*++
+
+Routine Description:
+ This function locate Hii relative protocols for later usage.
+
+Arguments:
+ None.
+
+Returns:
+ None.
+
+--*/
+{
+ EFI_STATUS Status;
+
+ if (mHiiProtocolsInitialized) {
+ return;
+ }
+
+ Status = gBS->LocateProtocol (&gEfiHiiDatabaseProtocolGuid, NULL, &gIfrLibHiiDatabase);
+ ASSERT_EFI_ERROR (Status);
+
+ Status = gBS->LocateProtocol (&gEfiHiiStringProtocolGuid, NULL, &gIfrLibHiiString);
+ ASSERT_EFI_ERROR (Status);
+
+ mHiiProtocolsInitialized = TRUE;
+}
+
+EFI_HII_PACKAGE_LIST_HEADER *
+PreparePackageList (
+ IN UINTN NumberOfPackages,
+ IN EFI_GUID *GuidId,
+ ...
+ )
+/*++
+
+Routine Description:
+ Assemble EFI_HII_PACKAGE_LIST according to the passed in packages.
+
+Arguments:
+ NumberOfPackages - Number of packages.
+ GuidId - Package GUID.
+
+Returns:
+ Pointer of EFI_HII_PACKAGE_LIST_HEADER.
+
+--*/
+{
+ VA_LIST Marker;
+ EFI_HII_PACKAGE_LIST_HEADER *PackageListHeader;
+ UINT8 *PackageListData;
+ UINT32 PackageListLength;
+ UINT32 PackageLength;
+ EFI_HII_PACKAGE_HEADER PackageHeader;
+ UINT8 *PackageArray;
+ UINTN Index;
+
+ PackageListLength = sizeof (EFI_HII_PACKAGE_LIST_HEADER);
+
+ VA_START (Marker, GuidId);
+ for (Index = 0; Index < NumberOfPackages; Index++) {
+ EfiCopyMem (&PackageLength, VA_ARG (Marker, VOID *), sizeof (UINT32));
+ PackageListLength += (PackageLength - sizeof (UINT32));
+ }
+ VA_END (Marker);
+
+ //
+ // Include the lenght of EFI_HII_PACKAGE_END
+ //
+ PackageListLength += sizeof (EFI_HII_PACKAGE_HEADER);
+ PackageListHeader = EfiLibAllocateZeroPool (PackageListLength);
+ ASSERT (PackageListHeader != NULL);
+ EfiCopyMem (&PackageListHeader->PackageListGuid, GuidId, sizeof (EFI_GUID));
+ PackageListHeader->PackageLength = PackageListLength;
+
+ PackageListData = ((UINT8 *) PackageListHeader) + sizeof (EFI_HII_PACKAGE_LIST_HEADER);
+
+ VA_START (Marker, GuidId);
+ for (Index = 0; Index < NumberOfPackages; Index++) {
+ PackageArray = (UINT8 *) VA_ARG (Marker, VOID *);
+ EfiCopyMem (&PackageLength, PackageArray, sizeof (UINT32));
+ PackageLength -= sizeof (UINT32);
+ PackageArray += sizeof (UINT32);
+ EfiCopyMem (PackageListData, PackageArray, PackageLength);
+ PackageListData += PackageLength;
+ }
+ VA_END (Marker);
+
+ //
+ // Append EFI_HII_PACKAGE_END
+ //
+ PackageHeader.Type = EFI_HII_PACKAGE_END;
+ PackageHeader.Length = sizeof (EFI_HII_PACKAGE_HEADER);
+ EfiCopyMem (PackageListData, &PackageHeader, PackageHeader.Length);
+
+ return PackageListHeader;
+}
+
+EFI_STATUS
+CreateHiiDriverHandle (
+ OUT EFI_HANDLE *DriverHandle
+ )
+/*++
+
+Routine Description:
+ The HII driver handle passed in for HiiDatabase.NewPackageList() requires
+ that there should be DevicePath Protocol installed on it.
+ This routine create a virtual Driver Handle by installing a vendor device
+ path on it, so as to use it to invoke HiiDatabase.NewPackageList().
+
+Arguments:
+ DriverHandle - Handle to be returned
+
+Returns:
+ EFI_SUCCESS - Handle destroy success.
+ EFI_OUT_OF_RESOURCES - Not enough memory.
+
+--*/
+{
+ EFI_STATUS Status;
+ HII_VENDOR_DEVICE_PATH_NODE *VendorDevicePath;
+
+ VendorDevicePath = EfiLibAllocateCopyPool (sizeof (HII_VENDOR_DEVICE_PATH), &mHiiVendorDevicePathTemplate);
+ if (VendorDevicePath == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ //
+ // Use memory address as unique ID to distinguish from different device paths
+ //
+ VendorDevicePath->UniqueId = (UINT64) ((UINTN) VendorDevicePath);
+
+ *DriverHandle = NULL;
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ DriverHandle,
+ &gEfiDevicePathProtocolGuid,
+ VendorDevicePath,
+ NULL
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+DestroyHiiDriverHandle (
+ IN EFI_HANDLE DriverHandle
+ )
+/*++
+
+Routine Description:
+ Destroy the Driver Handle created by CreateHiiDriverHandle().
+
+Arguments:
+ DriverHandle - Handle returned by CreateHiiDriverHandle()
+
+Returns:
+ EFI_SUCCESS - Handle destroy success.
+ other - Handle destroy fail.
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+
+ Status = gBS->HandleProtocol (
+ DriverHandle,
+ &gEfiDevicePathProtocolGuid,
+ &DevicePath
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Status = gBS->UninstallProtocolInterface (
+ DriverHandle,
+ &gEfiDevicePathProtocolGuid,
+ DevicePath
+ );
+ gBS->FreePool (DevicePath);
+ return Status;
+}
+
+EFI_HII_HANDLE
+DevicePathToHiiHandle (
+ IN EFI_HII_DATABASE_PROTOCOL *HiiDatabase,
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ )
+/*++
+
+Routine Description:
+ Find HII Handle associated with given Device Path.
+
+Arguments:
+ HiiDatabase - Point to EFI_HII_DATABASE_PROTOCOL instance.
+ DevicePath - Device Path associated with the HII package list handle.
+
+Returns:
+ Handle - HII package list Handle associated with the Device Path.
+ NULL - Hii Package list handle is not found.
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_DEVICE_PATH_PROTOCOL *TmpDevicePath;
+ UINTN BufferSize;
+ UINTN HandleCount;
+ UINTN Index;
+ EFI_HANDLE *Handles;
+ EFI_HANDLE Handle;
+ UINTN Size;
+ EFI_HANDLE DriverHandle;
+ EFI_HII_HANDLE *HiiHandles;
+ EFI_HII_HANDLE HiiHandle;
+
+ //
+ // Locate Device Path Protocol handle buffer
+ //
+ Status = gBS->LocateHandleBuffer (
+ ByProtocol,
+ &gEfiDevicePathProtocolGuid,
+ NULL,
+ &HandleCount,
+ &Handles
+ );
+ if (EFI_ERROR (Status)) {
+ return NULL;
+ }
+
+ //
+ // Search Driver Handle by Device Path
+ //
+ DriverHandle = NULL;
+ BufferSize = EfiDevicePathSize (DevicePath);
+ for(Index = 0; Index < HandleCount; Index++) {
+ Handle = Handles[Index];
+ gBS->HandleProtocol (Handle, &gEfiDevicePathProtocolGuid, &TmpDevicePath);
+
+ //
+ // Check whether DevicePath match
+ //
+ Size = EfiDevicePathSize (TmpDevicePath);
+ if ((Size == BufferSize) && EfiCompareMem (DevicePath, TmpDevicePath, Size) == 0) {
+ DriverHandle = Handle;
+ break;
+ }
+ }
+ gBS->FreePool (Handles);
+
+ if (DriverHandle == NULL) {
+ return NULL;
+ }
+
+ //
+ // Retrieve all Hii Handles from HII database
+ //
+ BufferSize = 0x1000;
+ HiiHandles = EfiLibAllocatePool (BufferSize);
+ ASSERT (HiiHandles != NULL);
+ Status = HiiDatabase->ListPackageLists (
+ HiiDatabase,
+ EFI_HII_PACKAGE_TYPE_ALL,
+ NULL,
+ &BufferSize,
+ HiiHandles
+ );
+ if (Status == EFI_BUFFER_TOO_SMALL) {
+ gBS->FreePool (HiiHandles);
+ HiiHandles = EfiLibAllocatePool (BufferSize);
+ ASSERT (HiiHandles != NULL);
+
+ Status = HiiDatabase->ListPackageLists (
+ HiiDatabase,
+ EFI_HII_PACKAGE_TYPE_ALL,
+ NULL,
+ &BufferSize,
+ HiiHandles
+ );
+ }
+
+ if (EFI_ERROR (Status)) {
+ gBS->FreePool (HiiHandles);
+ return NULL;
+ }
+
+ //
+ // Search Hii Handle by Driver Handle
+ //
+ HiiHandle = NULL;
+ HandleCount = BufferSize / sizeof (EFI_HII_HANDLE);
+ for (Index = 0; Index < HandleCount; Index++) {
+ Status = HiiDatabase->GetPackageListHandle (
+ HiiDatabase,
+ HiiHandles[Index],
+ &Handle
+ );
+ if (!EFI_ERROR (Status) && (Handle == DriverHandle)) {
+ HiiHandle = HiiHandles[Index];
+ break;
+ }
+ }
+
+ gBS->FreePool (HiiHandles);
+ return HiiHandle;
+}
+
+EFI_STATUS
+GetHiiHandles (
+ IN OUT UINTN *HandleBufferLength,
+ OUT EFI_HII_HANDLE **HiiHandleBuffer
+ )
+/*++
+
+Routine Description:
+ Determines the handles that are currently active in the database.
+ It's the caller's responsibility to free handle buffer.
+
+Arguments:
+ HiiDatabase - A pointer to the EFI_HII_DATABASE_PROTOCOL instance.
+ HandleBufferLength - On input, a pointer to the length of the handle buffer. On output,
+ the length of the handle buffer that is required for the handles found.
+ HiiHandleBuffer - Pointer to an array of Hii Handles returned.
+
+Returns:
+ EFI_SUCCESS - Get an array of Hii Handles successfully.
+ EFI_INVALID_PARAMETER - Hii is NULL.
+ EFI_NOT_FOUND - Database not found.
+
+--*/
+{
+ UINTN BufferLength;
+ EFI_STATUS Status;
+
+ BufferLength = 0;
+
+ LocateHiiProtocols ();
+
+ //
+ // Try to find the actual buffer size for HiiHandle Buffer.
+ //
+ Status = gIfrLibHiiDatabase->ListPackageLists (
+ gIfrLibHiiDatabase,
+ EFI_HII_PACKAGE_TYPE_ALL,
+ NULL,
+ &BufferLength,
+ *HiiHandleBuffer
+ );
+
+ if (Status == EFI_BUFFER_TOO_SMALL) {
+ *HiiHandleBuffer = EfiLibAllocateZeroPool (BufferLength);
+ Status = gIfrLibHiiDatabase->ListPackageLists (
+ gIfrLibHiiDatabase,
+ EFI_HII_PACKAGE_TYPE_ALL,
+ NULL,
+ &BufferLength,
+ *HiiHandleBuffer
+ );
+ //
+ // we should not fail here.
+ //
+ ASSERT_EFI_ERROR (Status);
+ }
+
+ *HandleBufferLength = BufferLength;
+
+ return Status;
+}
+
+EFI_STATUS
+ExtractGuidFromHiiHandle (
+ IN EFI_HII_HANDLE Handle,
+ OUT EFI_GUID *Guid
+ )
+/*++
+
+Routine Description:
+ Extract Hii package list GUID for given HII handle.
+
+Arguments:
+ HiiHandle - Hii handle
+ Guid - Package list GUID
+
+Returns:
+ EFI_SUCCESS - Successfully extract GUID from Hii database.
+
+--*/
+{
+ EFI_STATUS Status;
+ UINTN BufferSize;
+ EFI_HII_DATABASE_PROTOCOL *HiiDatabase;
+ EFI_HII_PACKAGE_LIST_HEADER *HiiPackageList;
+
+ //
+ // Locate HII Database protocol
+ //
+ Status = gBS->LocateProtocol (
+ &gEfiHiiDatabaseProtocolGuid,
+ NULL,
+ &HiiDatabase
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ //
+ // Get HII PackageList
+ //
+ BufferSize = 0;
+ HiiPackageList = NULL;
+ Status = HiiDatabase->ExportPackageLists (HiiDatabase, Handle, &BufferSize, HiiPackageList);
+ if (Status == EFI_BUFFER_TOO_SMALL) {
+ HiiPackageList = EfiLibAllocatePool (BufferSize);
+ ASSERT (HiiPackageList != NULL);
+
+ Status = HiiDatabase->ExportPackageLists (HiiDatabase, Handle, &BufferSize, HiiPackageList);
+ }
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ //
+ // Extract GUID
+ //
+ EfiCopyMem (Guid, &HiiPackageList->PackageListGuid, sizeof (EFI_GUID));
+
+ gBS->FreePool (HiiPackageList);
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+ExtractClassFromHiiHandle (
+ IN EFI_HII_HANDLE Handle,
+ OUT UINT16 *Class,
+ OUT EFI_STRING_ID *FormSetTitle,
+ OUT EFI_STRING_ID *FormSetHelp
+ )
+/*++
+
+Routine Description:
+ Extract formset class for given HII handle.
+
+Arguments:
+ HiiHandle - Hii handle
+ Class - Class of the formset
+ FormSetTitle - Formset title string
+ FormSetHelp - Formset help string
+
+Returns:
+ EFI_SUCCESS - Successfully extract Class for specified Hii handle.
+ EFI_NOT_FOUND - Class not found.
+
+--*/
+{
+ EFI_STATUS Status;
+ UINTN BufferSize;
+ EFI_HII_DATABASE_PROTOCOL *HiiDatabase;
+ EFI_HII_PACKAGE_LIST_HEADER *HiiPackageList;
+ UINT8 *Package;
+ UINT8 *FormSet;
+ UINT8 *OpCodeData;
+ UINT32 Offset;
+ UINT32 Offset2;
+ UINT32 PackageListLength;
+ EFI_HII_PACKAGE_HEADER PackageHeader;
+ BOOLEAN ClassFound;
+
+ *Class = EFI_NON_DEVICE_CLASS;
+ *FormSetTitle = 0;
+ *FormSetHelp = 0;
+ ClassFound = FALSE;
+
+ //
+ // Locate HII Database protocol
+ //
+ Status = gBS->LocateProtocol (
+ &gEfiHiiDatabaseProtocolGuid,
+ NULL,
+ &HiiDatabase
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ //
+ // Get HII PackageList
+ //
+ BufferSize = 0;
+ HiiPackageList = NULL;
+ Status = HiiDatabase->ExportPackageLists (HiiDatabase, Handle, &BufferSize, HiiPackageList);
+ if (Status == EFI_BUFFER_TOO_SMALL) {
+ HiiPackageList = EfiLibAllocatePool (BufferSize);
+ ASSERT (HiiPackageList != NULL);
+
+ Status = HiiDatabase->ExportPackageLists (HiiDatabase, Handle, &BufferSize, HiiPackageList);
+ }
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ //
+ // Get Form package from this HII package List
+ //
+ Offset = sizeof (EFI_HII_PACKAGE_LIST_HEADER);
+ Offset2 = 0;
+ FormSet = NULL;
+ EfiCopyMem (&PackageListLength, &HiiPackageList->PackageLength, sizeof (UINT32));
+
+ while (Offset < PackageListLength) {
+ Package = ((UINT8 *) HiiPackageList) + Offset;
+ EfiCopyMem (&PackageHeader, Package, sizeof (EFI_HII_PACKAGE_HEADER));
+
+ if (PackageHeader.Type == EFI_HII_PACKAGE_FORMS) {
+ //
+ // Search Class Opcode in this Form Package
+ //
+ Offset2 = sizeof (EFI_HII_PACKAGE_HEADER);
+ while (Offset2 < PackageHeader.Length) {
+ OpCodeData = Package + Offset2;
+ if (OpCodeData == NULL) {
+ return EFI_NOT_FOUND;
+ }
+
+ if (((EFI_IFR_OP_HEADER *) OpCodeData)->OpCode == EFI_IFR_FORM_SET_OP) {
+ //
+ // Find FormSet OpCode
+ //
+ EfiCopyMem (FormSetTitle, &((EFI_IFR_FORM_SET *) OpCodeData)->FormSetTitle, sizeof (EFI_STRING_ID));
+ EfiCopyMem (FormSetHelp, &((EFI_IFR_FORM_SET *) OpCodeData)->Help, sizeof (EFI_STRING_ID));
+ }
+
+ if ((((EFI_IFR_OP_HEADER *) OpCodeData)->OpCode == EFI_IFR_GUID_OP) &&
+ (EfiCompareGuid (&mIfrVendorGuid, &((EFI_IFR_GUID *) OpCodeData)->Guid)) &&
+ (((EFI_IFR_GUID_CLASS *) OpCodeData)->ExtendOpCode == EFI_IFR_EXTEND_OP_CLASS)
+ ) {
+ //
+ // Find GUIDed Class OpCode
+ //
+ EfiCopyMem (Class, &((EFI_IFR_GUID_CLASS *) OpCodeData)->Class, sizeof (UINT16));
+
+ //
+ // Till now, we ought to have found the formset Opcode
+ //
+ ClassFound = TRUE;
+ break;
+ }
+
+ Offset2 += ((EFI_IFR_OP_HEADER *) OpCodeData)->Length;
+ }
+
+ if (Offset2 < PackageHeader.Length) {
+ //
+ // Target formset found
+ //
+ break;
+ }
+ }
+
+ Offset += PackageHeader.Length;
+ }
+
+ gBS->FreePool (HiiPackageList);
+
+ return ClassFound ? EFI_SUCCESS : EFI_NOT_FOUND;
+}
+
+EFI_STATUS
+ExtractClassGuidFromHiiHandle (
+ IN EFI_HII_HANDLE Handle,
+ OUT UINT8 *NumberOfClassGuid,
+ OUT EFI_GUID **ClassGuid,
+ OUT EFI_STRING_ID *FormSetTitle,
+ OUT EFI_STRING_ID *FormSetHelp
+ )
+/*++
+
+Routine Description:
+ Extract formset ClassGuid for given HII handle.
+
+Arguments:
+ HiiHandle - Hii handle
+ NumberOfClassGuid - Number of ClassGuid
+ ClassGuid - Pointer to callee allocated buffer, an array of ClassGuid
+ FormSetTitle - Formset title string
+ FormSetHelp - Formset help string
+
+Returns:
+ EFI_SUCCESS - Successfully extract Class for specified Hii handle.
+
+--*/
+{
+ EFI_STATUS Status;
+ UINTN BufferSize;
+ EFI_HII_DATABASE_PROTOCOL *HiiDatabase;
+ EFI_HII_PACKAGE_LIST_HEADER *HiiPackageList;
+ UINT8 *Package;
+ UINT8 *FormSet;
+ UINT8 *OpCodeData;
+ UINT32 Offset;
+ UINT32 Offset2;
+ UINT32 PackageListLength;
+ EFI_HII_PACKAGE_HEADER PackageHeader;
+
+ if (NumberOfClassGuid == NULL || ClassGuid == NULL || FormSetTitle == NULL || FormSetHelp == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ *NumberOfClassGuid = 0;
+ *ClassGuid = NULL;
+ *FormSetTitle = 0;
+ *FormSetHelp = 0;
+
+ //
+ // Locate HII Database protocol
+ //
+ Status = gBS->LocateProtocol (
+ &gEfiHiiDatabaseProtocolGuid,
+ NULL,
+ &HiiDatabase
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ //
+ // Get HII PackageList
+ //
+ BufferSize = 0;
+ HiiPackageList = NULL;
+ Status = HiiDatabase->ExportPackageLists (HiiDatabase, Handle, &BufferSize, HiiPackageList);
+ if (Status == EFI_BUFFER_TOO_SMALL) {
+ HiiPackageList = EfiLibAllocatePool (BufferSize);
+ ASSERT (HiiPackageList != NULL);
+
+ Status = HiiDatabase->ExportPackageLists (HiiDatabase, Handle, &BufferSize, HiiPackageList);
+ }
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ //
+ // Get Form package from this HII package List
+ //
+ Offset = sizeof (EFI_HII_PACKAGE_LIST_HEADER);
+ Offset2 = 0;
+ FormSet = NULL;
+ EfiCopyMem (&PackageListLength, &HiiPackageList->PackageLength, sizeof (UINT32));
+
+ while (Offset < PackageListLength) {
+ Package = ((UINT8 *) HiiPackageList) + Offset;
+ EfiCopyMem (&PackageHeader, Package, sizeof (EFI_HII_PACKAGE_HEADER));
+
+ if (PackageHeader.Type == EFI_HII_PACKAGE_FORMS) {
+ //
+ // Search Class Opcode in this Form Package
+ //
+ Offset2 = sizeof (EFI_HII_PACKAGE_HEADER);
+ while (Offset2 < PackageHeader.Length) {
+ OpCodeData = Package + Offset2;
+ if (OpCodeData == NULL) {
+ return EFI_NOT_FOUND;
+ }
+
+ if (((EFI_IFR_OP_HEADER *) OpCodeData)->OpCode == EFI_IFR_FORM_SET_OP) {
+ //
+ // Find FormSet OpCode
+ //
+ EfiCopyMem (FormSetTitle, &((EFI_IFR_FORM_SET *) OpCodeData)->FormSetTitle, sizeof (EFI_STRING_ID));
+ EfiCopyMem (FormSetHelp, &((EFI_IFR_FORM_SET *) OpCodeData)->Help, sizeof (EFI_STRING_ID));
+ if (((EFI_IFR_OP_HEADER *) OpCodeData)->Length > ((UINTN) &((EFI_IFR_FORM_SET *) 0)->Flags)) {
+ //
+ // New version of formset OpCode
+ //
+ *NumberOfClassGuid = ((EFI_IFR_FORM_SET *) OpCodeData)->Flags & 0x3;
+ *ClassGuid = EfiLibAllocateCopyPool (
+ *NumberOfClassGuid * sizeof (EFI_GUID),
+ ((EFI_IFR_FORM_SET *) OpCodeData)->ClassGuid
+ );
+ }
+ break;
+ }
+
+ Offset2 += ((EFI_IFR_OP_HEADER *) OpCodeData)->Length;
+ }
+
+ if (Offset2 < PackageHeader.Length) {
+ //
+ // Target formset found
+ //
+ break;
+ }
+ }
+
+ Offset += PackageHeader.Length;
+ }
+
+ gBS->FreePool (HiiPackageList);
+
+ return EFI_SUCCESS;
+}
diff --git a/EDK/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrForm.c b/EDK/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrForm.c
new file mode 100644
index 0000000..0fe6582
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrForm.c
@@ -0,0 +1,2249 @@
+/*++
+
+Copyright (c) 2007 - 2008, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ UefiIfrForm.c
+
+Abstract:
+
+ Common Library Routines to assist handle HII elements.
+
+--*/
+
+#include "UefiIfrLibrary.h"
+
+//
+// Fake <ConfigHdr>
+//
+UINT16 mFakeConfigHdr[] = L"GUID=00000000000000000000000000000000&NAME=0000&PATH=0";
+
+STATIC
+EFI_STATUS
+GetPackageDataFromPackageList (
+ IN EFI_HII_PACKAGE_LIST_HEADER *HiiPackageList,
+ IN UINT32 PackageIndex,
+ OUT UINT32 *BufferLen,
+ OUT EFI_HII_PACKAGE_HEADER **Buffer
+ )
+{
+ UINT32 Index;
+ EFI_HII_PACKAGE_HEADER *Package;
+ UINT32 Offset;
+ UINT32 PackageListLength;
+ EFI_HII_PACKAGE_HEADER PackageHeader = {0, 0};
+
+ ASSERT(HiiPackageList != NULL);
+
+ if ((BufferLen == NULL) || (Buffer == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Package = NULL;
+ Index = 0;
+ Offset = sizeof (EFI_HII_PACKAGE_LIST_HEADER);
+ EfiCopyMem (&PackageListLength, &HiiPackageList->PackageLength, sizeof (UINT32));
+ while (Offset < PackageListLength) {
+ Package = (EFI_HII_PACKAGE_HEADER *) (((UINT8 *) HiiPackageList) + Offset);
+ EfiCopyMem (&PackageHeader, Package, sizeof (EFI_HII_PACKAGE_HEADER));
+ if (Index == PackageIndex) {
+ break;
+ }
+ Offset += PackageHeader.Length;
+ Index++;
+ }
+ if (Offset >= PackageListLength) {
+ //
+ // no package found in this Package List
+ //
+ return EFI_NOT_FOUND;
+ }
+
+ *BufferLen = PackageHeader.Length;
+ *Buffer = Package;
+ return EFI_SUCCESS;
+}
+
+STATIC
+EFI_STATUS
+UpdateFormPackageData (
+ IN EFI_GUID *FormSetGuid,
+ IN EFI_FORM_ID FormId,
+ IN EFI_HII_PACKAGE_HEADER *Package,
+ IN UINT32 PackageLength,
+ IN UINT16 Label,
+ IN BOOLEAN Insert,
+ IN EFI_HII_UPDATE_DATA *Data,
+ OUT UINT8 **TempBuffer,
+ OUT UINT32 *TempBufferSize
+ )
+{
+ UINT8 *BufferPos;
+ EFI_HII_PACKAGE_HEADER PackageHeader;
+ UINT32 Offset;
+ EFI_IFR_OP_HEADER *IfrOpHdr;
+ BOOLEAN GetFormSet;
+ BOOLEAN GetForm;
+ UINT8 ExtendOpCode;
+ UINT16 LabelNumber;
+ BOOLEAN Updated;
+
+ if ((TempBuffer == NULL) || (TempBufferSize == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ *TempBufferSize = PackageLength;
+ if (Data != NULL) {
+ *TempBufferSize += Data->Offset;
+ }
+ *TempBuffer = EfiLibAllocateZeroPool (*TempBufferSize);
+ if (*TempBuffer == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ EfiCopyMem (*TempBuffer, Package, sizeof (EFI_HII_PACKAGE_HEADER));
+ *TempBufferSize = sizeof (EFI_HII_PACKAGE_HEADER);
+ BufferPos = *TempBuffer + sizeof (EFI_HII_PACKAGE_HEADER);
+
+ EfiCopyMem (&PackageHeader, Package, sizeof (EFI_HII_PACKAGE_HEADER));
+ IfrOpHdr = (EFI_IFR_OP_HEADER *)((UINT8 *) Package + sizeof (EFI_HII_PACKAGE_HEADER));
+ Offset = sizeof (EFI_HII_PACKAGE_HEADER);
+ GetFormSet = (FormSetGuid == NULL) ? TRUE : FALSE;
+ GetForm = FALSE;
+ Updated = FALSE;
+
+ while (!Updated && Offset < PackageHeader.Length) {
+ EfiCopyMem (BufferPos, IfrOpHdr, IfrOpHdr->Length);
+ BufferPos += IfrOpHdr->Length;
+ *TempBufferSize += IfrOpHdr->Length;
+
+ switch (IfrOpHdr->OpCode) {
+ case EFI_IFR_FORM_SET_OP :
+ if (FormSetGuid != NULL) {
+ if (EfiCompareMem (&((EFI_IFR_FORM_SET *) IfrOpHdr)->Guid, FormSetGuid, sizeof (EFI_GUID)) == 0) {
+ GetFormSet = TRUE;
+ } else {
+ GetFormSet = FALSE;
+ }
+ }
+ break;
+
+ case EFI_IFR_FORM_OP:
+ if (EfiCompareMem (&((EFI_IFR_FORM *) IfrOpHdr)->FormId, &FormId, sizeof (EFI_FORM_ID)) == 0) {
+ GetForm = TRUE;
+ } else {
+ GetForm = FALSE;
+ }
+ break;
+
+ case EFI_IFR_GUID_OP :
+ if (!GetFormSet || !GetForm) {
+ //
+ // Go to the next Op-Code
+ //
+ break;
+ }
+
+ if (!EfiCompareGuid (&((EFI_IFR_GUID *) IfrOpHdr)->Guid, &mIfrVendorGuid)) {
+ //
+ // GUID mismatch, skip this op-code
+ //
+ break;
+ }
+
+ ExtendOpCode = ((EFI_IFR_GUID_LABEL *) IfrOpHdr)->ExtendOpCode;
+ EfiCopyMem (&LabelNumber, &((EFI_IFR_GUID_LABEL *)IfrOpHdr)->Number, sizeof (UINT16));
+ if ((ExtendOpCode != EFI_IFR_EXTEND_OP_LABEL) || (LabelNumber != Label)) {
+ //
+ // Go to the next Op-Code
+ //
+ break;
+ }
+
+ if (Insert) {
+ //
+ // Insert data after current Label, skip myself
+ //
+ Offset += IfrOpHdr->Length;
+ IfrOpHdr = (EFI_IFR_OP_HEADER *) ((CHAR8 *) (IfrOpHdr) + IfrOpHdr->Length);
+ } else {
+ //
+ // Replace data between two paired Label, try to find the next Label.
+ //
+ while (TRUE) {
+ Offset += IfrOpHdr->Length;
+ //
+ // Search the next label and Fail if not label found.
+ //
+ if (Offset >= PackageHeader.Length) {
+ goto Fail;
+ }
+ IfrOpHdr = (EFI_IFR_OP_HEADER *) ((CHAR8 *) (IfrOpHdr) + IfrOpHdr->Length);
+ if (IfrOpHdr->OpCode == EFI_IFR_GUID_OP) {
+ ExtendOpCode = ((EFI_IFR_GUID_LABEL *) IfrOpHdr)->ExtendOpCode;
+ if (EfiCompareGuid (&((EFI_IFR_GUID *) IfrOpHdr)->Guid, &mIfrVendorGuid) && ExtendOpCode == EFI_IFR_EXTEND_OP_LABEL) {
+ break;
+ }
+ }
+ }
+ }
+
+ //
+ // Fill in the update data
+ //
+ if (Data != NULL) {
+ EfiCopyMem (BufferPos, Data->Data, Data->Offset);
+ BufferPos += Data->Offset;
+ *TempBufferSize += Data->Offset;
+ }
+
+ //
+ // Copy the reset data
+ //
+ EfiCopyMem (BufferPos, IfrOpHdr, PackageHeader.Length - Offset);
+ *TempBufferSize += PackageHeader.Length - Offset;
+
+ Updated = TRUE;
+ break;
+ default :
+ break;
+ }
+
+ //
+ // Go to the next Op-Code
+ //
+ Offset += IfrOpHdr->Length;
+ IfrOpHdr = (EFI_IFR_OP_HEADER *) ((CHAR8 *) (IfrOpHdr) + IfrOpHdr->Length);
+ }
+
+ //
+ // Update the package length.
+ //
+ PackageHeader.Length = *TempBufferSize;
+ EfiCopyMem (*TempBuffer, &PackageHeader, sizeof (EFI_HII_PACKAGE_HEADER));
+
+Fail:
+ if (!Updated) {
+ gBS->FreePool (*TempBuffer);
+ *TempBufferSize = 0;
+ return EFI_NOT_FOUND;
+ }
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+IfrLibInitUpdateData (
+ IN OUT EFI_HII_UPDATE_DATA *UpdateData,
+ IN UINT32 BufferSize
+ )
+/*++
+
+Routine Description:
+ This function initialize the data structure for dynamic opcode.
+
+Arguments:
+ UpdateData - The adding data;
+ BufferSize - Length of the buffer to fill dynamic opcodes.
+
+Returns:
+ EFI_SUCCESS - Update data is initialized.
+ EFI_INVALID_PARAMETER - UpdateData is NULL.
+ EFI_OUT_OF_RESOURCES - No enough memory to allocate.
+
+--*/
+{
+ if (UpdateData == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ UpdateData->BufferSize = BufferSize;
+ UpdateData->Offset = 0;
+ UpdateData->Data = EfiLibAllocatePool (BufferSize);
+
+ return (UpdateData->Data != NULL) ? EFI_SUCCESS : EFI_OUT_OF_RESOURCES;
+}
+
+EFI_STATUS
+IfrLibFreeUpdateData (
+ IN EFI_HII_UPDATE_DATA *UpdateData
+ )
+/*++
+
+Routine Description:
+ This function free the resource of update data.
+
+Arguments:
+ UpdateData - The adding data;
+
+Returns:
+ EFI_SUCCESS - Resource in UpdateData is released.
+ EFI_INVALID_PARAMETER - UpdateData is NULL.
+
+--*/
+{
+ EFI_STATUS Status;
+
+ if (UpdateData == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = gBS->FreePool (UpdateData->Data);
+ UpdateData->Data = NULL;
+
+ return Status;
+}
+
+EFI_STATUS
+IfrLibUpdateForm (
+ IN EFI_HII_HANDLE Handle,
+ IN EFI_GUID *FormSetGuid, OPTIONAL
+ IN EFI_FORM_ID FormId,
+ IN UINT16 Label,
+ IN BOOLEAN Insert,
+ IN EFI_HII_UPDATE_DATA *Data
+ )
+/*++
+
+Routine Description:
+ This function allows the caller to update a form that has
+ previously been registered with the EFI HII database.
+
+Arguments:
+ Handle - Hii Handle
+ FormSetGuid - The formset should be updated.
+ FormId - The form should be updated.
+ Label - Update information starting immediately after this label in the IFR
+ Insert - If TRUE and Data is not NULL, insert data after Label.
+ If FALSE, replace opcodes between two labels with Data
+ Data - The adding data; If NULL, remove opcodes between two Label.
+
+Returns:
+ EFI_SUCCESS - Update success.
+ Other - Update fail.
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_HII_DATABASE_PROTOCOL *HiiDatabase;
+ EFI_HII_PACKAGE_LIST_HEADER *HiiPackageList;
+ UINT32 Index;
+ EFI_HII_PACKAGE_LIST_HEADER *UpdateBuffer;
+ UINTN BufferSize;
+ UINT8 *UpdateBufferPos;
+ EFI_HII_PACKAGE_HEADER PackageHeader;
+ EFI_HII_PACKAGE_HEADER *Package;
+ UINT32 PackageLength;
+ EFI_HII_PACKAGE_HEADER *TempBuffer;
+ UINT32 TempBufferSize;
+ BOOLEAN Updated;
+
+ if (Data == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ LocateHiiProtocols ();
+ HiiDatabase = gIfrLibHiiDatabase;
+
+ //
+ // Get the orginal package list
+ //
+ BufferSize = 0;
+ HiiPackageList = NULL;
+ Status = HiiDatabase->ExportPackageLists (HiiDatabase, Handle, &BufferSize, HiiPackageList);
+ if (Status == EFI_BUFFER_TOO_SMALL) {
+ HiiPackageList = EfiLibAllocatePool (BufferSize);
+ ASSERT (HiiPackageList != NULL);
+
+ Status = HiiDatabase->ExportPackageLists (HiiDatabase, Handle, &BufferSize, HiiPackageList);
+ if (EFI_ERROR (Status)) {
+ gBS->FreePool (HiiPackageList);
+ return Status;
+ }
+ }
+
+ //
+ // Calculate and allocate space for retrieval of IFR data
+ //
+ BufferSize += Data->Offset;
+ UpdateBuffer = EfiLibAllocateZeroPool (BufferSize);
+ if (UpdateBuffer == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ UpdateBufferPos = (UINT8 *) UpdateBuffer;
+
+ //
+ // copy the package list header
+ //
+ EfiCopyMem (UpdateBufferPos, HiiPackageList, sizeof (EFI_HII_PACKAGE_LIST_HEADER));
+ UpdateBufferPos += sizeof (EFI_HII_PACKAGE_LIST_HEADER);
+
+ Updated = FALSE;
+ for (Index = 0; ; Index++) {
+ Status = GetPackageDataFromPackageList (HiiPackageList, Index, &PackageLength, &Package);
+ if (Status == EFI_SUCCESS) {
+ EfiCopyMem (&PackageHeader, Package, sizeof (EFI_HII_PACKAGE_HEADER));
+ if ((PackageHeader.Type == EFI_HII_PACKAGE_FORMS) && !Updated) {
+ Status = UpdateFormPackageData (FormSetGuid, FormId, Package, PackageLength, Label, Insert, Data, (UINT8 **)&TempBuffer, &TempBufferSize);
+ if (!EFI_ERROR(Status)) {
+ if (FormSetGuid == NULL) {
+ Updated = TRUE;
+ }
+ EfiCopyMem (UpdateBufferPos, TempBuffer, TempBufferSize);
+ UpdateBufferPos += TempBufferSize;
+ gBS->FreePool (TempBuffer);
+ continue;
+ }
+ }
+
+ EfiCopyMem (UpdateBufferPos, Package, PackageLength);
+ UpdateBufferPos += PackageLength;
+ } else if (Status == EFI_NOT_FOUND) {
+ break;
+ } else {
+ gBS->FreePool (HiiPackageList);
+ return Status;
+ }
+ }
+
+ //
+ // Update package list length
+ //
+ BufferSize = UpdateBufferPos - (UINT8 *) UpdateBuffer;
+ EfiCopyMem (&UpdateBuffer->PackageLength, &BufferSize, sizeof (UINT32));
+
+ gBS->FreePool (HiiPackageList);
+
+ return HiiDatabase->UpdatePackageList (HiiDatabase, Handle, UpdateBuffer);
+}
+
+EFI_STATUS
+IfrLibCreatePopUp (
+ IN UINTN NumberOfLines,
+ OUT EFI_INPUT_KEY *KeyValue,
+ IN CHAR16 *String,
+ ...
+ )
+/*++
+
+Routine Description:
+ Draw a dialog and return the selected key.
+
+Arguments:
+ NumberOfLines - The number of lines for the dialog box
+ KeyValue - The EFI_KEY value returned if HotKey is TRUE..
+ String - Pointer to the first string in the list
+ ... - A series of (quantity == NumberOfLines) text strings which
+ will be used to construct the dialog box
+
+Returns:
+ EFI_SUCCESS - Displayed dialog and received user interaction
+ EFI_INVALID_PARAMETER - One of the parameters was invalid.
+
+--*/
+{
+ UINTN Index;
+ UINTN Count;
+ UINTN Start;
+ UINTN End;
+ UINTN Top;
+ UINTN Bottom;
+ CHAR16 *StringPtr;
+ UINTN LeftColumn;
+ UINTN RightColumn;
+ UINTN TopRow;
+ UINTN BottomRow;
+ UINTN DimensionsWidth;
+ UINTN DimensionsHeight;
+ VA_LIST Marker;
+ EFI_INPUT_KEY Key;
+ UINTN LargestString;
+ CHAR16 *StackString;
+ EFI_STATUS Status;
+ UINTN StringLen;
+ CHAR16 *LineBuffer;
+ CHAR16 **StringArray;
+ EFI_EVENT TimerEvent;
+ EFI_EVENT WaitList[2];
+ UINTN CurrentAttribute;
+ EFI_SIMPLE_TEXT_OUT_PROTOCOL *ConOut;
+
+ if ((KeyValue == NULL) || (String == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ TopRow = 0;
+ BottomRow = 0;
+ LeftColumn = 0;
+ RightColumn = 0;
+
+ ConOut = gST->ConOut;
+ ConOut->QueryMode (ConOut, ConOut->Mode->Mode, &RightColumn, &BottomRow);
+
+ DimensionsWidth = RightColumn - LeftColumn;
+ DimensionsHeight = BottomRow - TopRow;
+
+ CurrentAttribute = ConOut->Mode->Attribute;
+
+ LineBuffer = EfiLibAllocateZeroPool (DimensionsWidth * sizeof (CHAR16));
+ ASSERT (LineBuffer != NULL);
+
+ //
+ // Determine the largest string in the dialog box
+ // Notice we are starting with 1 since String is the first string
+ //
+ StringArray = EfiLibAllocateZeroPool (NumberOfLines * sizeof (CHAR16 *));
+ LargestString = EfiStrLen (String);
+ StringArray[0] = String;
+
+ VA_START (Marker, String);
+ for (Index = 1; Index < NumberOfLines; Index++) {
+ StackString = VA_ARG (Marker, CHAR16 *);
+
+ if (StackString == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ StringArray[Index] = StackString;
+ StringLen = EfiStrLen (StackString);
+ if (StringLen > LargestString) {
+ LargestString = StringLen;
+ }
+ }
+
+ if ((LargestString + 2) > DimensionsWidth) {
+ LargestString = DimensionsWidth - 2;
+ }
+
+ //
+ // Subtract the PopUp width from total Columns, allow for one space extra on
+ // each end plus a border.
+ //
+ Start = (DimensionsWidth - LargestString - 2) / 2 + LeftColumn + 1;
+ End = Start + LargestString + 1;
+
+ Top = ((DimensionsHeight - NumberOfLines - 2) / 2) + TopRow - 1;
+ Bottom = Top + NumberOfLines + 2;
+
+ //
+ // Disable cursor
+ //
+ ConOut->EnableCursor (ConOut, FALSE);
+ ConOut->SetAttribute (ConOut, EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE);
+
+ StringPtr = &LineBuffer[0];
+ *StringPtr++ = BOXDRAW_DOWN_RIGHT;
+ for (Index = 0; Index < LargestString; Index++) {
+ *StringPtr++ = BOXDRAW_HORIZONTAL;
+ }
+ *StringPtr++ = BOXDRAW_DOWN_LEFT;
+ *StringPtr = L'\0';
+
+ ConOut->SetCursorPosition (ConOut, Start, Top);
+ ConOut->OutputString (ConOut, LineBuffer);
+
+ for (Index = 0; Index < NumberOfLines; Index++) {
+ StringPtr = &LineBuffer[0];
+ *StringPtr++ = BOXDRAW_VERTICAL;
+
+ for (Count = 0; Count < LargestString; Count++) {
+ StringPtr[Count] = L' ';
+ }
+
+ StringLen = EfiStrLen (StringArray[Index]);
+ if (StringLen > LargestString) {
+ StringLen = LargestString;
+ }
+ EfiCopyMem (
+ StringPtr + ((LargestString - StringLen) / 2),
+ StringArray[Index],
+ StringLen * sizeof (CHAR16)
+ );
+ StringPtr += LargestString;
+
+ *StringPtr++ = BOXDRAW_VERTICAL;
+ *StringPtr = L'\0';
+
+ ConOut->SetCursorPosition (ConOut, Start, Top + 1 + Index);
+ ConOut->OutputString (ConOut, LineBuffer);
+ }
+
+ StringPtr = &LineBuffer[0];
+ *StringPtr++ = BOXDRAW_UP_RIGHT;
+ for (Index = 0; Index < LargestString; Index++) {
+ *StringPtr++ = BOXDRAW_HORIZONTAL;
+ }
+ *StringPtr++ = BOXDRAW_UP_LEFT;
+ *StringPtr = L'\0';
+
+ ConOut->SetCursorPosition (ConOut, Start, Top + NumberOfLines + 1);
+ ConOut->OutputString (ConOut, LineBuffer);
+
+ do {
+ Status = gBS->CreateEvent (EFI_EVENT_TIMER, 0, NULL, NULL, &TimerEvent);
+
+ //
+ // Set a timer event of 1 second expiration
+ //
+ gBS->SetTimer (
+ TimerEvent,
+ TimerRelative,
+ 10000000
+ );
+
+ //
+ // Wait for the keystroke event or the timer
+ //
+ WaitList[0] = gST->ConIn->WaitForKey;
+ WaitList[1] = TimerEvent;
+ Status = gBS->WaitForEvent (2, WaitList, &Index);
+
+ //
+ // Check for the timer expiration
+ //
+ if (!EFI_ERROR (Status) && Index == 1) {
+ Status = EFI_TIMEOUT;
+ }
+
+ gBS->CloseEvent (TimerEvent);
+ } while (Status == EFI_TIMEOUT);
+
+ Status = gST->ConIn->ReadKeyStroke (gST->ConIn, &Key);
+ EfiCopyMem (KeyValue, &Key, sizeof (EFI_INPUT_KEY));
+
+ ConOut->SetAttribute (ConOut, CurrentAttribute);
+ ConOut->EnableCursor (ConOut, TRUE);
+
+ return Status;
+}
+
+EFI_STATUS
+ExtractDefault(
+ IN VOID *Buffer,
+ IN UINTN *BufferSize,
+ UINTN Number,
+ ...
+ )
+/*++
+
+ Routine Description:
+
+ Configure the buffer accrording to ConfigBody strings.
+
+ Arguments:
+ DefaultId - the ID of default.
+ Buffer - the start address of buffer.
+ BufferSize - the size of buffer.
+ Number - the number of the strings.
+
+ Returns:
+ EFI_BUFFER_TOO_SMALL - the BufferSize is too small to operate.
+ EFI_INVALID_PARAMETER - Buffer is NULL or BufferSize is 0.
+ EFI_SUCCESS - Operation successful.
+
+--*/
+{
+ VA_LIST Args;
+ UINTN Index;
+ UINT32 TotalLen;
+ UINT8 *BufCfgArray;
+ UINT8 *BufferPos;
+ UINT16 Offset;
+ UINT16 Width;
+ UINT8 *Value;
+
+ if ((Buffer == NULL) || (BufferSize == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Offset = 0;
+ Width = 0;
+ Value = NULL;
+
+ VA_START (Args, Number);
+ for (Index = 0; Index < Number; Index++) {
+ BufCfgArray = (UINT8 *) VA_ARG (Args, VOID *);
+ EfiCopyMem (&TotalLen, BufCfgArray, sizeof (UINT32));
+ BufferPos = BufCfgArray + sizeof (UINT32);
+
+ while ((UINT32)(BufferPos - BufCfgArray) < TotalLen) {
+ EfiCopyMem (&Offset, BufferPos, sizeof (UINT16));
+ BufferPos += sizeof (UINT16);
+ EfiCopyMem (&Width, BufferPos, sizeof (UINT16));
+ BufferPos += sizeof (UINT16);
+ Value = BufferPos;
+ BufferPos += Width;
+
+ if ((UINTN)(Offset + Width) > *BufferSize) {
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ EfiCopyMem ((UINT8 *)Buffer + Offset, Value, Width);
+ }
+ }
+ VA_END (Args);
+
+ *BufferSize = (UINTN)Offset;
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+ExtractBlockName (
+ IN UINT8 *Buffer,
+ OUT CHAR16 **BlockName
+ )
+/*++
+
+ Routine Description:
+
+ Extract block name from the array generated by VFR compiler. The name of
+ this array is "Vfr + <StorageName> + BlockName", e.g. "VfrMyIfrNVDataBlockName".
+ Format of this array is:
+ Array length | 4-bytes
+ Offset | 2-bytes
+ Width | 2-bytes
+ Offset | 2-bytes
+ Width | 2-bytes
+ ... ...
+
+ Arguments:
+ Buffer - Array generated by VFR compiler.
+ BlockName - The returned <BlockName>
+
+ Returns:
+ EFI_OUT_OF_RESOURCES - Run out of memory resource.
+ EFI_INVALID_PARAMETER - Buffer is NULL or BlockName is NULL.
+ EFI_SUCCESS - Operation successful.
+
+--*/
+{
+ UINTN Index;
+ UINT32 Length;
+ UINT32 BlockNameNumber;
+ UINTN HexStringBufferLen;
+ CHAR16 *StringPtr;
+
+ if ((Buffer == NULL) || (BlockName == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // Calculate number of Offset/Width pair
+ //
+ EfiCopyMem (&Length, Buffer, sizeof (UINT32));
+ BlockNameNumber = (Length - sizeof (UINT32)) / (sizeof (UINT16) * 2);
+
+ //
+ // <BlockName> ::= &OFFSET=1234&WIDTH=1234
+ // | 8 | 4 | 7 | 4 |
+ //
+ StringPtr = EfiLibAllocateZeroPool ((BlockNameNumber * (8 + 4 + 7 + 4) + 1) * sizeof (CHAR16));
+ *BlockName = StringPtr;
+ if (StringPtr == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ Buffer += sizeof (UINT32);
+ for (Index = 0; Index < BlockNameNumber; Index++) {
+ EfiStrCpy (StringPtr, L"&OFFSET=");
+ StringPtr += 8;
+
+ HexStringBufferLen = 5;
+ BufToHexString (StringPtr, &HexStringBufferLen, Buffer, sizeof (UINT16));
+ Buffer += sizeof (UINT16);
+ StringPtr += 4;
+
+ EfiStrCpy (StringPtr, L"&WIDTH=");
+ StringPtr += 7;
+
+ HexStringBufferLen = 5;
+ BufToHexString (StringPtr, &HexStringBufferLen, Buffer, sizeof (UINT16));
+ Buffer += sizeof (UINT16);
+ StringPtr += 4;
+ }
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+ExtractBlockConfig (
+ IN UINT8 *Buffer,
+ OUT CHAR16 **BlockConfig
+ )
+/*++
+
+ Routine Description:
+
+ Extract block config from the array generated by VFR compiler. The name of
+ this array is "Vfr + <StorageName> + Default<HexCh>4", e.g. "VfrMyIfrNVDataDefault0000".
+
+ Arguments:
+ Buffer - Array generated by VFR compiler.
+ BlockConfig - The returned <BlockConfig>
+
+ Returns:
+ EFI_OUT_OF_RESOURCES - Run out of memory resource.
+ EFI_INVALID_PARAMETER - Buffer is NULL or BlockConfig is NULL.
+ EFI_SUCCESS - Operation successful.
+
+--*/
+{
+ UINT32 Length;
+ UINT16 Width;
+ UINTN HexStringBufferLen;
+ CHAR16 *StringPtr;
+ UINT8 *BufferEnd;
+ CHAR16 *StringEnd;
+ EFI_STATUS Status;
+
+ if ((Buffer == NULL) || (BlockConfig == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // Calculate length of AltResp string
+ // Format of Default value array is:
+ // Array length | 4-bytes
+ // Offset | 2-bytes
+ // Width | 2-bytes
+ // Value | Variable length
+ // Offset | 2-bytes
+ // Width | 2-bytes
+ // Value | Variable length
+ // ... ...
+ // When value is 1 byte in length, overhead of AltResp string will be maximum,
+ // BlockConfig ::= <&OFFSET=1234&WIDTH=1234&VALUE=12>+
+ // | 8 | 4 | 7 | 4 | 7 |2|
+ // so the maximum length of BlockConfig could be calculated as:
+ // (ArrayLength / 5) * (8 + 4 + 7 + 4 + 7 + 2) = ArrayLength * 6.4 < ArrayLength * 7
+ //
+ EfiCopyMem (&Length, Buffer, sizeof (UINT32));
+ BufferEnd = Buffer + Length;
+ StringPtr = EfiLibAllocatePool (Length * 7 * sizeof (CHAR16));
+ *BlockConfig = StringPtr;
+ if (StringPtr == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ StringEnd = StringPtr + (Length * 7);
+
+ Buffer += sizeof (UINT32);
+ while (Buffer < BufferEnd) {
+ EfiStrCpy (StringPtr, L"&OFFSET=");
+ StringPtr += 8;
+
+ HexStringBufferLen = 5;
+ BufToHexString (StringPtr, &HexStringBufferLen, Buffer, sizeof (UINT16));
+ Buffer += sizeof (UINT16);
+ StringPtr += 4;
+
+ EfiStrCpy (StringPtr, L"&WIDTH=");
+ StringPtr += 7;
+
+ HexStringBufferLen = 5;
+ BufToHexString (StringPtr, &HexStringBufferLen, Buffer, sizeof (UINT16));
+ EfiCopyMem (&Width, Buffer, sizeof (UINT16));
+ Buffer += sizeof (UINT16);
+ StringPtr += 4;
+
+ EfiStrCpy (StringPtr, L"&VALUE=");
+ StringPtr += 7;
+
+ HexStringBufferLen = StringEnd - StringPtr;
+ Status = BufToHexString (StringPtr, &HexStringBufferLen, Buffer, Width);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ Buffer += Width;
+ StringPtr += (Width * 2);
+ }
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+ConstructConfigAltResp (
+ IN EFI_STRING ConfigRequest, OPTIONAL
+ OUT EFI_STRING *Progress,
+ OUT EFI_STRING *ConfigAltResp,
+ IN EFI_GUID *Guid,
+ IN CHAR16 *Name,
+ IN EFI_HANDLE *DriverHandle,
+ IN VOID *BufferStorage,
+ IN UINTN BufferStorageSize,
+ IN VOID *BlockNameArray, OPTIONAL
+ IN UINTN NumberAltCfg,
+ ...
+//IN UINT16 AltCfgId,
+//IN VOID *DefaultValueArray,
+ )
+/*++
+
+ Routine Description:
+
+ Construct <ConfigAltResp> for a buffer storage.
+
+ Arguments:
+ ConfigRequest - The Config request string. If set to NULL, all the
+ configurable elements will be extracted from BlockNameArray.
+ ConfigAltResp - The returned <ConfigAltResp>.
+ Progress - On return, points to a character in the Request.
+ Guid - GUID of the buffer storage.
+ Name - Name of the buffer storage.
+ DriverHandle - The DriverHandle which is used to invoke HiiDatabase
+ protocol interface NewPackageList().
+ BufferStorage - Content of the buffer storage.
+ BufferStorageSize - Length in bytes of the buffer storage.
+ BlockNameArray - Array generated by VFR compiler.
+ NumberAltCfg - Number of Default value array generated by VFR compiler.
+ The sequential input parameters will be number of
+ AltCfgId and DefaultValueArray pairs. When set to 0,
+ there will be no <AltResp>.
+
+ Returns:
+ EFI_OUT_OF_RESOURCES - Run out of memory resource.
+ EFI_INVALID_PARAMETER - ConfigAltResp is NULL.
+ EFI_SUCCESS - Operation successful.
+
+--*/
+{
+ EFI_STATUS Status;
+ CHAR16 *ConfigHdr;
+ CHAR16 *BlockName;
+ CHAR16 *DescHdr;
+ CHAR16 *StringPtr;
+ CHAR16 **AltCfg;
+ UINT16 AltCfgId;
+ VOID *DefaultValueArray;
+ UINTN StrBufferLen;
+ EFI_STRING ConfigResp;
+ EFI_STRING TempStr;
+ VA_LIST Args;
+ UINTN AltRespLen;
+ UINTN Index;
+ BOOLEAN NeedFreeConfigRequest;
+ EFI_HII_CONFIG_ROUTING_PROTOCOL *HiiConfigRouting;
+
+ if (ConfigAltResp == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // Construct <ConfigHdr> : "GUID=...&NAME=...&PATH=..."
+ //
+ ConfigHdr = NULL;
+ StrBufferLen = 0;
+ Status = ConstructConfigHdr (
+ ConfigHdr,
+ &StrBufferLen,
+ Guid,
+ Name,
+ DriverHandle
+ );
+ if (Status == EFI_BUFFER_TOO_SMALL) {
+ ConfigHdr = EfiLibAllocateZeroPool (StrBufferLen);
+ Status = ConstructConfigHdr (
+ ConfigHdr,
+ &StrBufferLen,
+ Guid,
+ Name,
+ DriverHandle
+ );
+ }
+
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ //
+ // Construct <ConfigResp>
+ //
+ NeedFreeConfigRequest = FALSE;
+ if (ConfigRequest == NULL) {
+ //
+ // If ConfigRequest is set to NULL, export all configurable elements in BlockNameArray
+ //
+ Status = ExtractBlockName (BlockNameArray, &BlockName);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ ConfigRequest = EfiLibAllocateZeroPool (EfiStrSize (ConfigHdr) + EfiStrSize (BlockName) - sizeof (CHAR16));
+ EfiStrCpy (ConfigRequest, ConfigHdr);
+ EfiStrCat (ConfigRequest, BlockName);
+ NeedFreeConfigRequest = TRUE;
+ }
+
+ Status = gBS->LocateProtocol (&gEfiHiiConfigRoutingProtocolGuid, NULL, &HiiConfigRouting);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Status = HiiConfigRouting->BlockToConfig (
+ HiiConfigRouting,
+ ConfigRequest,
+ BufferStorage,
+ BufferStorageSize,
+ &ConfigResp,
+ (Progress == NULL) ? &TempStr : Progress
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ //
+ // Construct <AltResp>
+ //
+ DescHdr = EfiLibAllocateZeroPool (NumberAltCfg * 16 * sizeof (CHAR16));
+ StringPtr = DescHdr;
+ AltCfg = EfiLibAllocateZeroPool (NumberAltCfg * sizeof (CHAR16 *));
+ AltRespLen = 0;
+ VA_START (Args, NumberAltCfg);
+ for (Index = 0; Index < NumberAltCfg; Index++) {
+ AltCfgId = (UINT16) VA_ARG (Args, UINT16);
+ DefaultValueArray = (UINT8 *) VA_ARG (Args, VOID *);
+
+ //
+ // '&' <ConfigHdr>
+ //
+ AltRespLen += (EfiStrLen (ConfigHdr) + 1);
+
+ StringPtr = DescHdr + Index * 16;
+ EfiStrCpy (StringPtr, L"&ALTCFG=");
+ AltRespLen += (8 + sizeof (UINT16) * 2);
+
+ StrBufferLen = 5;
+ BufToHexString (StringPtr + 8, &StrBufferLen, (UINT8 *) &AltCfgId, sizeof (UINT16));
+ Status = ExtractBlockConfig (DefaultValueArray, &AltCfg[Index]);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ AltRespLen += EfiStrLen (AltCfg[Index]);
+ }
+ VA_END (Args);
+
+ //
+ // Generate the final <ConfigAltResp>
+ //
+ StrBufferLen = (EfiStrLen ((CHAR16 *) ConfigResp) + AltRespLen + 1) * sizeof (CHAR16);
+ TempStr = EfiLibAllocateZeroPool (StrBufferLen);
+ *ConfigAltResp = TempStr;
+ if (TempStr == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ //
+ // <ConfigAltResp> ::= <ConfigResp> ['&' <AltResp>]*
+ //
+ EfiStrCpy (TempStr, ConfigResp);
+ for (Index = 0; Index < NumberAltCfg; Index++) {
+ EfiStrCat (TempStr, L"&");
+ EfiStrCat (TempStr, ConfigHdr);
+ EfiStrCat (TempStr, DescHdr + Index * 16);
+ EfiStrCat (TempStr, AltCfg[Index]);
+
+ gBS->FreePool (AltCfg[Index]);
+ }
+
+ if (NeedFreeConfigRequest) {
+ gBS->FreePool (ConfigRequest);
+ }
+ gBS->FreePool (ConfigHdr);
+ gBS->FreePool (ConfigResp);
+ gBS->FreePool (DescHdr);
+ gBS->FreePool (AltCfg);
+
+ return EFI_SUCCESS;
+}
+
+STATIC
+VOID
+SwapBuffer (
+ IN OUT UINT8 *Buffer,
+ IN UINTN BufferSize
+ )
+/*++
+
+Routine Description:
+ Swap bytes in the buffer.
+
+Arguments:
+ Buffer - Binary buffer.
+ BufferSize - Size of the buffer in bytes.
+
+Returns:
+ None.
+
+--*/
+{
+ UINTN Index;
+ UINT8 Temp;
+ UINTN SwapCount;
+
+ SwapCount = BufferSize / 2;
+ for (Index = 0; Index < SwapCount; Index++) {
+ Temp = Buffer[Index];
+ Buffer[Index] = Buffer[BufferSize - 1 - Index];
+ Buffer[BufferSize - 1 - Index] = Temp;
+ }
+}
+
+VOID
+ToLower (
+ IN OUT CHAR16 *Str
+ )
+/*++
+
+Routine Description:
+ Converts the unicode character of the string from uppercase to lowercase.
+
+Arguments:
+ Str - String to be converted
+
+Returns:
+
+--*/
+{
+ CHAR16 *Ptr;
+
+ for (Ptr = Str; *Ptr != L'\0'; Ptr++) {
+ if (*Ptr >= L'A' && *Ptr <= L'Z') {
+ *Ptr = (CHAR16) (*Ptr - L'A' + L'a');
+ }
+ }
+}
+
+EFI_STATUS
+BufferToHexString (
+ IN OUT CHAR16 *Str,
+ IN UINT8 *Buffer,
+ IN UINTN BufferSize
+ )
+/*++
+
+Routine Description:
+ Converts binary buffer to Unicode string in reversed byte order from BufToHexString().
+
+Arguments:
+ Str - String for output
+ Buffer - Binary buffer.
+ BufferSize - Size of the buffer in bytes.
+
+Returns:
+ EFI_SUCCESS - The function completed successfully.
+
+--*/
+{
+ EFI_STATUS Status;
+ UINT8 *NewBuffer;
+ UINTN StrBufferLen;
+
+ NewBuffer = EfiLibAllocateCopyPool (BufferSize, Buffer);
+ SwapBuffer (NewBuffer, BufferSize);
+
+ StrBufferLen = BufferSize * 2 + 1;
+ Status = BufToHexString (Str, &StrBufferLen, NewBuffer, BufferSize);
+
+ gBS->FreePool (NewBuffer);
+ //
+ // Convert the uppercase to lowercase since <HexAf> is defined in lowercase format.
+ //
+ ToLower (Str);
+
+ return Status;
+}
+
+EFI_STATUS
+HexStringToBuffer (
+ IN OUT UINT8 *Buffer,
+ IN OUT UINTN *BufferSize,
+ IN CHAR16 *Str
+ )
+/*++
+
+Routine Description:
+ Converts Hex String to binary buffer in reversed byte order from HexStringToBuf().
+
+Arguments:
+ Buffer - Pointer to buffer that receives the data.
+ BufferSize - Length in bytes of the buffer to hold converted data.
+ If routine return with EFI_SUCCESS, containing length of converted data.
+ If routine return with EFI_BUFFER_TOO_SMALL, containg length of buffer desired.
+ Str - String to be converted from.
+
+Returns:
+ EFI_SUCCESS - The function completed successfully.
+
+--*/
+{
+ EFI_STATUS Status;
+ UINTN ConvertedStrLen;
+
+ ConvertedStrLen = 0;
+ Status = HexStringToBuf (Buffer, BufferSize, Str, &ConvertedStrLen);
+ if (!EFI_ERROR (Status)) {
+ SwapBuffer (Buffer, (ConvertedStrLen + 1) / 2);
+ }
+
+ return Status;
+}
+
+EFI_STATUS
+ConfigStringToUnicode (
+ IN OUT CHAR16 *UnicodeString,
+ IN OUT UINTN *StrBufferLen,
+ IN CHAR16 *ConfigString
+ )
+/*++
+
+Routine Description:
+ Convert binary representation Config string (e.g. "0041004200430044") to the
+ original string (e.g. "ABCD"). Config string appears in <ConfigHdr> (i.e.
+ "&NAME=<string>"), or Name/Value pair in <ConfigBody> (i.e. "label=<string>").
+
+Arguments:
+ UnicodeString - Original Unicode string.
+ StrBufferLen - On input: Length in bytes of buffer to hold the Unicode string.
+ Includes tailing '\0' character.
+ On output:
+ If return EFI_SUCCESS, containing length of Unicode string buffer.
+ If return EFI_BUFFER_TOO_SMALL, containg length of string buffer desired.
+ ConfigString - Binary representation of Unicode String, <string> := (<HexCh>4)+
+
+Returns:
+ EFI_SUCCESS - Routine success.
+ EFI_BUFFER_TOO_SMALL - The string buffer is too small.
+
+--*/
+{
+ UINTN Index;
+ UINTN Len;
+ UINTN BufferSize;
+ CHAR16 BackupChar;
+
+ Len = EfiStrLen (ConfigString) / 4;
+ BufferSize = (Len + 1) * sizeof (CHAR16);
+
+ if (*StrBufferLen < BufferSize) {
+ *StrBufferLen = BufferSize;
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ *StrBufferLen = BufferSize;
+
+ for (Index = 0; Index < Len; Index++) {
+ BackupChar = ConfigString[4];
+ ConfigString[4] = L'\0';
+
+ HexStringToBuf ((UINT8 *) UnicodeString, &BufferSize, ConfigString, NULL);
+
+ ConfigString[4] = BackupChar;
+
+ ConfigString += 4;
+ UnicodeString += 1;
+ }
+
+ //
+ // Add tailing '\0' character
+ //
+ *UnicodeString = L'\0';
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+UnicodeToConfigString (
+ IN OUT CHAR16 *ConfigString,
+ IN OUT UINTN *StrBufferLen,
+ IN CHAR16 *UnicodeString
+ )
+/*++
+
+Routine Description:
+ Convert Unicode string to binary representation Config string, e.g.
+ "ABCD" => "0041004200430044". Config string appears in <ConfigHdr> (i.e.
+ "&NAME=<string>"), or Name/Value pair in <ConfigBody> (i.e. "label=<string>").
+
+Arguments:
+ ConfigString - Binary representation of Unicode String, <string> := (<HexCh>4)+
+ StrBufferLen - On input: Length in bytes of buffer to hold the Unicode string.
+ Includes tailing '\0' character.
+ On output:
+ If return EFI_SUCCESS, containing length of Unicode string buffer.
+ If return EFI_BUFFER_TOO_SMALL, containg length of string buffer desired.
+ UnicodeString - Original Unicode string.
+
+Returns:
+ EFI_SUCCESS - Routine success.
+ EFI_BUFFER_TOO_SMALL - The string buffer is too small.
+
+--*/
+{
+ UINTN Index;
+ UINTN Len;
+ UINTN BufferSize;
+ CHAR16 *String;
+
+ Len = EfiStrLen (UnicodeString);
+ BufferSize = (Len * 4 + 1) * sizeof (CHAR16);
+
+ if (*StrBufferLen < BufferSize) {
+ *StrBufferLen = BufferSize;
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ *StrBufferLen = BufferSize;
+ String = ConfigString;
+
+ for (Index = 0; Index < Len; Index++) {
+ BufToHexString (ConfigString, &BufferSize, (UINT8 *) UnicodeString, 2);
+
+ ConfigString += 4;
+ UnicodeString += 1;
+ }
+
+ //
+ // Add tailing '\0' character
+ //
+ *ConfigString = L'\0';
+
+ //
+ // Convert the uppercase to lowercase since <HexAf> is defined in lowercase format.
+ //
+ ToLower (String);
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+ConstructConfigHdr (
+ IN OUT CHAR16 *ConfigHdr,
+ IN OUT UINTN *StrBufferLen,
+ IN EFI_GUID *Guid,
+ IN CHAR16 *Name, OPTIONAL
+ IN EFI_HANDLE *DriverHandle
+ )
+/*++
+
+Routine Description:
+ Construct <ConfigHdr> using routing information GUID/NAME/PATH.
+
+Arguments:
+ ConfigHdr - Pointer to the ConfigHdr string.
+ StrBufferLen - On input: Length in bytes of buffer to hold the ConfigHdr string.
+ Includes tailing '\0' character.
+ On output:
+ If return EFI_SUCCESS, containing length of ConfigHdr string buffer.
+ If return EFI_BUFFER_TOO_SMALL, containg length of string buffer desired.
+ Guid - Routing information: GUID.
+ Name - Routing information: NAME.
+ DriverHandle - Driver handle which contains the routing information: PATH.
+
+Returns:
+ EFI_SUCCESS - Routine success.
+ EFI_BUFFER_TOO_SMALL - The ConfigHdr string buffer is too small.
+
+--*/
+{
+ EFI_STATUS Status;
+ UINTN NameStrLen;
+ UINTN DevicePathSize;
+ UINTN BufferSize;
+ CHAR16 *StrPtr;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+
+ if (Name == NULL) {
+ //
+ // There will be no "NAME" in <ConfigHdr> for Name/Value storage
+ //
+ NameStrLen = 0;
+ } else {
+ //
+ // For buffer storage
+ //
+ NameStrLen = EfiStrLen (Name);
+ }
+
+ //
+ // Retrieve DevicePath Protocol associated with this HiiPackageList
+ //
+ Status = gBS->HandleProtocol (
+ DriverHandle,
+ &gEfiDevicePathProtocolGuid,
+ &DevicePath
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ DevicePathSize = EfiDevicePathSize (DevicePath);
+
+ //
+ // GUID=<HexCh>32&NAME=<Char>NameStrLen&PATH=<HexChar>DevicePathStrLen <NULL>
+ // | 5 | 32 | 6 | NameStrLen*4 | 6 | DevicePathStrLen | 1 |
+ //
+ BufferSize = (5 + 32 + 6 + NameStrLen * 4 + 6 + DevicePathSize * 2 + 1) * sizeof (CHAR16);
+ if (*StrBufferLen < BufferSize) {
+ *StrBufferLen = BufferSize;
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ *StrBufferLen = BufferSize;
+
+ StrPtr = ConfigHdr;
+
+ EfiStrCpy (StrPtr, L"GUID=");
+ StrPtr += 5;
+ BufferToHexString (StrPtr, (UINT8 *) Guid, sizeof (EFI_GUID));
+ StrPtr += 32;
+
+ //
+ // Convert name string, e.g. name "ABCD" => "&NAME=0041004200430044"
+ //
+ EfiStrCpy (StrPtr, L"&NAME=");
+ StrPtr += 6;
+ if (Name != NULL) {
+ BufferSize = (NameStrLen * 4 + 1) * sizeof (CHAR16);
+ UnicodeToConfigString (StrPtr, &BufferSize, Name);
+ StrPtr += (NameStrLen * 4);
+ }
+
+ EfiStrCpy (StrPtr, L"&PATH=");
+ StrPtr += 6;
+ BufferToHexString (StrPtr, (UINT8 *) DevicePath, DevicePathSize);
+
+ return EFI_SUCCESS;
+}
+
+BOOLEAN
+IsConfigHdrMatch (
+ IN EFI_STRING ConfigString,
+ IN EFI_GUID *StorageGuid, OPTIONAL
+ IN CHAR16 *StorageName OPTIONAL
+ )
+/*++
+
+Routine Description:
+ Determines if the Routing data (Guid and Name) is correct in <ConfigHdr>.
+
+Arguments:
+ ConfigString - Either <ConfigRequest> or <ConfigResp>.
+ StorageGuid - GUID of the storage.
+ StorageName - Name of the stoarge.
+
+Returns:
+ TRUE - Routing information is correct in ConfigString.
+ FALSE - Routing information is incorrect in ConfigString.
+
+--*/
+{
+ EFI_STATUS Status;
+ BOOLEAN Match;
+ EFI_GUID Guid;
+ CHAR16 *Name;
+ CHAR16 *StrPtr;
+ UINTN BufferSize;
+
+ //
+ // <ConfigHdr> ::=
+ // GUID=<HexCh>32&NAME=<Char>NameStrLen&PATH=<HexChar>DevicePathStrLen <NULL>
+ // | 5 | 32 | 6 | NameStrLen*4 | 6 | DevicePathStrLen | 1 |
+ //
+ if (EfiStrLen (ConfigString) <= (5 + 32 + 6)) {
+ return FALSE;
+ }
+
+ //
+ // Compare GUID
+ //
+ if (StorageGuid != NULL) {
+
+ StrPtr = ConfigString + 5 + 32;
+ if (*StrPtr != L'&') {
+ return FALSE;
+ }
+ *StrPtr = L'\0';
+
+ BufferSize = sizeof (EFI_GUID);
+ Status = HexStringToBuffer (
+ (UINT8 *) &Guid,
+ &BufferSize,
+ ConfigString + 5
+ );
+ *StrPtr = L'&';
+
+ if (EFI_ERROR (Status)) {
+ return FALSE;
+ }
+
+ if (!EfiCompareGuid (&Guid, StorageGuid)) {
+ return FALSE;
+ }
+ }
+
+ //
+ // Compare Name
+ //
+ Match = TRUE;
+ if (StorageName != NULL) {
+ StrPtr = ConfigString + 5 + 32 + 6;
+ while (*StrPtr != L'\0' && *StrPtr != L'&') {
+ StrPtr++;
+ }
+ if (*StrPtr != L'&') {
+ return FALSE;
+ }
+
+ *StrPtr = L'\0';
+ BufferSize = (((UINTN) StrPtr) - ((UINTN) &ConfigString[5 + 32 + 6])) / 4 + sizeof (CHAR16);
+ Name = EfiLibAllocatePool (BufferSize);
+ ASSERT (Name != NULL);
+ Status = ConfigStringToUnicode (
+ Name,
+ &BufferSize,
+ ConfigString + 5 + 32 + 6
+ );
+ *StrPtr = L'&';
+
+ if (EFI_ERROR (Status) || (EfiStrCmp (Name, StorageName) != 0)) {
+ Match = FALSE;
+ }
+ gBS->FreePool (Name);
+ }
+
+ return Match;
+}
+
+BOOLEAN
+FindBlockName (
+ IN OUT CHAR16 *String,
+ UINTN Offset,
+ UINTN Width
+ )
+/*++
+
+Routine Description:
+ Search BlockName "&OFFSET=Offset&WIDTH=Width" in a string.
+
+Arguments:
+ String - The string to be searched in.
+ Offset - Offset in BlockName.
+ Width - Width in BlockName.
+
+Returns:
+ TRUE - Block name found.
+ FALSE - Block name not found.
+
+--*/
+{
+ EFI_STATUS Status;
+ UINTN Data;
+ UINTN BufferSize;
+ UINTN ConvertedStrLen;
+
+ while ((String = EfiStrStr (String, L"&OFFSET=")) != NULL) {
+ //
+ // Skip '&OFFSET='
+ //
+ String = String + 8;
+
+ Data = 0;
+ BufferSize = sizeof (UINTN);
+ Status = HexStringToBuf ((UINT8 *) &Data, &BufferSize, String, &ConvertedStrLen);
+ if (EFI_ERROR (Status)) {
+ return FALSE;
+ }
+ String = String + ConvertedStrLen;
+
+ if (Data != Offset) {
+ continue;
+ }
+
+ if (EfiStrnCmp (String, L"&WIDTH=", 7) != 0) {
+ return FALSE;
+ }
+ String = String + 7;
+
+ Data = 0;
+ BufferSize = sizeof (UINTN);
+ Status = HexStringToBuf ((UINT8 *) &Data, &BufferSize, String, &ConvertedStrLen);
+ if (EFI_ERROR (Status)) {
+ return FALSE;
+ }
+ if (Data == Width) {
+ return TRUE;
+ }
+
+ String = String + ConvertedStrLen;
+ }
+
+ return FALSE;
+}
+
+EFI_STATUS
+GetBrowserData (
+ EFI_GUID *VariableGuid, OPTIONAL
+ CHAR16 *VariableName, OPTIONAL
+ UINTN *BufferSize,
+ UINT8 *Buffer
+ )
+/*++
+
+Routine Description:
+ This routine is invoked by ConfigAccess.Callback() to retrived uncommitted data from Form Browser.
+
+Arguments:
+ VariableGuid - An optional field to indicate the target variable GUID name to use.
+ VariableName - An optional field to indicate the target human-readable variable name.
+ BufferSize - On input: Length in bytes of buffer to hold retrived data.
+ On output:
+ If return EFI_BUFFER_TOO_SMALL, containg length of buffer desired.
+ Buffer - Buffer to hold retrived data.
+
+Returns:
+ EFI_SUCCESS - Routine success.
+ EFI_BUFFER_TOO_SMALL - The intput buffer is too small.
+
+--*/
+{
+ EFI_STATUS Status;
+ CHAR16 *ConfigHdr;
+ CHAR16 *ConfigResp;
+ CHAR16 *StringPtr;
+ UINTN HeaderLen;
+ UINTN BufferLen;
+ CHAR16 *Progress;
+ EFI_FORM_BROWSER2_PROTOCOL *FormBrowser2;
+ EFI_HII_CONFIG_ROUTING_PROTOCOL *HiiConfigRouting;
+
+ //
+ // Locate protocols for use
+ //
+ Status = gBS->LocateProtocol (&gEfiFormBrowser2ProtocolGuid, NULL, &FormBrowser2);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Status = gBS->LocateProtocol (&gEfiHiiConfigRoutingProtocolGuid, NULL, &HiiConfigRouting);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ //
+ // Retrive formset storage data from Form Browser
+ //
+ ConfigHdr = mFakeConfigHdr;
+ HeaderLen = EfiStrLen (ConfigHdr);
+
+ BufferLen = 0x4000;
+ ConfigResp = EfiLibAllocateZeroPool (BufferLen + (HeaderLen + 1) * sizeof (CHAR16));
+
+ StringPtr = ConfigResp + HeaderLen;
+ *StringPtr = L'&';
+ StringPtr++;
+
+ Status = FormBrowser2->BrowserCallback (
+ FormBrowser2,
+ &BufferLen,
+ StringPtr,
+ TRUE,
+ VariableGuid,
+ VariableName
+ );
+ if (Status == EFI_BUFFER_TOO_SMALL) {
+ gBS->FreePool (ConfigResp);
+ ConfigResp = EfiLibAllocateZeroPool (BufferLen + (HeaderLen + 1) * sizeof (CHAR16));
+
+ StringPtr = ConfigResp + HeaderLen;
+ *StringPtr = L'&';
+ StringPtr++;
+
+ Status = FormBrowser2->BrowserCallback (
+ FormBrowser2,
+ &BufferLen,
+ StringPtr,
+ TRUE,
+ VariableGuid,
+ VariableName
+ );
+ }
+ if (EFI_ERROR (Status)) {
+ gBS->FreePool (ConfigResp);
+ return Status;
+ }
+ EfiCopyMem (ConfigResp, ConfigHdr, HeaderLen * sizeof (UINT16));
+
+ //
+ // Convert <ConfigResp> to buffer data
+ //
+ Status = HiiConfigRouting->ConfigToBlock (
+ HiiConfigRouting,
+ ConfigResp,
+ Buffer,
+ BufferSize,
+ &Progress
+ );
+ gBS->FreePool (ConfigResp);
+
+ return Status;
+}
+
+EFI_STATUS
+SetBrowserData (
+ EFI_GUID *VariableGuid, OPTIONAL
+ CHAR16 *VariableName, OPTIONAL
+ UINTN BufferSize,
+ UINT8 *Buffer,
+ CHAR16 *RequestElement OPTIONAL
+ )
+/*++
+
+Routine Description:
+ This routine is invoked by ConfigAccess.Callback() to update uncommitted data of Form Browser.
+
+Arguments:
+ VariableGuid - An optional field to indicate the target variable GUID name to use.
+ VariableName - An optional field to indicate the target human-readable variable name.
+ BufferSize - Length in bytes of buffer to hold retrived data.
+ Buffer - Buffer to hold retrived data.
+ RequestElement - An optional field to specify which part of the buffer data
+ will be send back to Browser. If NULL, the whole buffer of
+ data will be committed to Browser.
+ <RequestElement> ::= &OFFSET=<Number>&WIDTH=<Number>*
+
+Returns:
+ EFI_SUCCESS - Routine success.
+ Other - Updating Browser uncommitted data failed.
+
+--*/
+{
+ EFI_STATUS Status;
+ CHAR16 *ConfigHdr;
+ CHAR16 *ConfigResp;
+ CHAR16 *StringPtr;
+ UINTN HeaderLen;
+ UINTN BufferLen;
+ CHAR16 *Progress;
+ EFI_FORM_BROWSER2_PROTOCOL *FormBrowser2;
+ EFI_HII_CONFIG_ROUTING_PROTOCOL *HiiConfigRouting;
+ CHAR16 BlockName[33];
+ CHAR16 *ConfigRequest;
+ CHAR16 *Request;
+
+ //
+ // Locate protocols for use
+ //
+ Status = gBS->LocateProtocol (&gEfiFormBrowser2ProtocolGuid, NULL, &FormBrowser2);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Status = gBS->LocateProtocol (&gEfiHiiConfigRoutingProtocolGuid, NULL, &HiiConfigRouting);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ //
+ // Prepare <ConfigRequest>
+ //
+ ConfigHdr = mFakeConfigHdr;
+ HeaderLen = EfiStrLen (ConfigHdr);
+
+ if (RequestElement == NULL) {
+ //
+ // RequestElement not specified, use "&OFFSET=0&WIDTH=<BufferSize>" as <BlockName>
+ //
+ BlockName[0] = L'\0';
+ EfiStrCpy (BlockName, L"&OFFSET=0&WIDTH=");
+
+ //
+ // String lenghth of L"&OFFSET=0&WIDTH=" is 16
+ //
+ StringPtr = BlockName + 16;
+ BufferLen = sizeof (BlockName) - (16 * sizeof (CHAR16));
+ BufToHexString (StringPtr, &BufferLen, (UINT8 *) &BufferSize, sizeof (UINTN));
+
+ Request = BlockName;
+ } else {
+ Request = RequestElement;
+ }
+
+ BufferLen = HeaderLen * sizeof (CHAR16) + EfiStrSize (Request);
+ ConfigRequest = EfiLibAllocateZeroPool (BufferLen);
+
+ EfiCopyMem (ConfigRequest, ConfigHdr, HeaderLen * sizeof (CHAR16));
+ StringPtr = ConfigRequest + HeaderLen;
+ EfiStrCpy (StringPtr, Request);
+
+ //
+ // Convert buffer to <ConfigResp>
+ //
+ Status = HiiConfigRouting->BlockToConfig (
+ HiiConfigRouting,
+ ConfigRequest,
+ Buffer,
+ BufferSize,
+ &ConfigResp,
+ &Progress
+ );
+ if (EFI_ERROR (Status)) {
+ gBS->FreePool (ConfigRequest);
+ return Status;
+ }
+
+ //
+ // Skip <ConfigHdr> and '&'
+ //
+ StringPtr = ConfigResp + HeaderLen + 1;
+
+ //
+ // Change uncommitted data in Browser
+ //
+ Status = FormBrowser2->BrowserCallback (
+ FormBrowser2,
+ &BufferSize,
+ StringPtr,
+ FALSE,
+ VariableGuid,
+ VariableName
+ );
+ gBS->FreePool (ConfigResp);
+ gBS->FreePool (ConfigRequest);
+ return Status;
+}
+
+BOOLEAN
+HiiSetToDefaults (
+ IN CONST EFI_STRING Request, OPTIONAL
+ IN UINT16 DefaultId
+ )
+/*++
+
+Routine Description:
+ Reset the default value specified by DefaultId to the driver
+ configuration got by Request string.
+
+ NULL request string support depends on the ExportConfig interface of
+ HiiConfigRouting protocol in UEFI specification.
+
+Arguments:
+ Request - A null-terminated Unicode string in
+ <MultiConfigRequest> format. It can be NULL.
+ If it is NULL, all configuration for the
+ entirety of the current HII database will be reset.
+ DefaultId - Specifies the type of defaults to retrieve.
+
+Returns:
+ TURE - The default value is set successfully.
+ FALSE - The default value can't be found and set.
+
+--*/
+{
+ EFI_STRING ConfigAltResp;
+ EFI_STRING ConfigAltHdr;
+ EFI_STRING ConfigResp;
+ EFI_STRING Progress;
+ EFI_STRING StringPtr;
+ EFI_STRING StringHdr;
+ EFI_STRING CurString;
+ EFI_STATUS Status;
+ EFI_HII_HANDLE HiiHandle;
+ CHAR16 OrigChar;
+ UINT32 Index;
+ EFI_GUID *VarGuid;
+ EFI_STRING VarName;
+ EFI_STRING_ID DefaultName;
+ UINTN BufferSize;
+ UINT8 *PackageData;
+ UINTN IfrOffset;
+ EFI_IFR_OP_HEADER *IfrOpHdr;
+ EFI_HII_PACKAGE_LIST_HEADER *HiiPackageList;
+ UINT32 PackageOffset;
+ UINTN PackageListLength;
+ EFI_HII_PACKAGE_HEADER PacakgeHeader;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ EFI_HII_CONFIG_ROUTING_PROTOCOL *HiiConfigRouting;
+
+ DEBUG ((EFI_D_ERROR, "HiiSetToDefaults - enter\n"));
+
+ Status = gBS->LocateProtocol (&gEfiHiiConfigRoutingProtocolGuid, NULL, (VOID **) &HiiConfigRouting);
+ if (EFI_ERROR (Status)) {
+ return FALSE;
+ }
+ LocateHiiProtocols ();
+
+ ConfigAltResp = NULL;
+ ConfigResp = NULL;
+ VarGuid = NULL;
+ VarName = NULL;
+ DevicePath = NULL;
+ ConfigAltHdr = NULL;
+ CurString = NULL;
+ Index = 0;
+ BufferSize = 0;
+ OrigChar = 0;
+ HiiHandle = NULL;
+ PackageData = NULL;
+ HiiPackageList = NULL;
+
+ //
+ // Get the full requested value and deault value string.
+ //
+ if (Request != NULL) {
+ Status = HiiConfigRouting->ExtractConfig (
+ HiiConfigRouting,
+ Request,
+ &Progress,
+ &ConfigAltResp
+ );
+ } else {
+ Status = HiiConfigRouting->ExportConfig (
+ HiiConfigRouting,
+ &ConfigAltResp
+ );
+ }
+
+ if (EFI_ERROR (Status)) {
+ return FALSE;
+ }
+ DEBUG ((EFI_D_ERROR, "HiiSetToDefaults - start\n"));
+ StringPtr = ConfigAltResp;
+
+ while (StringPtr != L'\0') {
+ //
+ // 1. Find <ConfigHdr> GUID=...&NAME=...&PATH=...
+ //
+ StringHdr = StringPtr;
+
+ if (EfiStrnCmp (StringPtr, L"GUID=", (sizeof(L"GUID=")/sizeof(CHAR16)) - 1) != 0) {
+ Status = EFI_INVALID_PARAMETER;
+ goto Done;
+ }
+ StringPtr += (sizeof(L"GUID=")/sizeof(CHAR16)) - 1;
+ CurString = StringPtr;
+ while (*StringPtr != L'\0' && EfiStrnCmp (StringPtr, L"&NAME=", (sizeof(L"&NAME=")/sizeof(CHAR16)) - 1) != 0) {
+ StringPtr++;
+ }
+ if (*StringPtr == L'\0') {
+ Status = EFI_INVALID_PARAMETER;
+ goto Done;
+ }
+
+ //
+ // Get Guid value
+ //
+ BufferSize = sizeof (EFI_GUID);
+ VarGuid = EfiLibAllocatePool (BufferSize);
+ OrigChar = *StringPtr;
+ *StringPtr = L'\0';
+ Status = HexStringToBuffer ((UINT8 *) VarGuid, &BufferSize, CurString);
+ *StringPtr = OrigChar;
+ if (EFI_ERROR (Status)) {
+ goto Done;
+ }
+
+ //
+ // Get Name value VarName
+ //
+ StringPtr += (sizeof(L"&NAME=")/sizeof(CHAR16)) - 1;
+ CurString = StringPtr;
+ while (*StringPtr != L'\0' && EfiStrnCmp (StringPtr, L"&PATH=", (sizeof(L"&PATH=")/sizeof(CHAR16)) - 1) != 0) {
+ StringPtr++;
+ }
+ if (*StringPtr == L'\0') {
+ Status = EFI_INVALID_PARAMETER;
+ goto Done;
+ }
+ OrigChar = *StringPtr;
+ *StringPtr = L'\0';
+ BufferSize = 0;
+ Status = ConfigStringToUnicode (VarName, &BufferSize, CurString);
+ if (Status == EFI_BUFFER_TOO_SMALL) {
+ VarName = EfiLibAllocatePool (BufferSize);
+ Status = ConfigStringToUnicode (VarName, &BufferSize, CurString);
+ }
+ *StringPtr = OrigChar;
+ if (EFI_ERROR (Status)) {
+ goto Done;
+ }
+
+ //
+ // Get Path value DevicePath
+ //
+ StringPtr += (sizeof(L"&PATH=")/sizeof(CHAR16)) - 1;
+ CurString = StringPtr;
+ for (; *StringPtr != L'\0' && *StringPtr != L'&'; StringPtr++);
+ OrigChar = *StringPtr;
+ *StringPtr = L'\0';
+ Status = HexStringToBuffer ((UINT8 *) DevicePath, &BufferSize, CurString);
+ if (Status == EFI_BUFFER_TOO_SMALL) {
+ DevicePath = EfiLibAllocatePool (BufferSize);
+ Status = HexStringToBuffer ((UINT8 *) DevicePath, &BufferSize, CurString);
+ }
+ *StringPtr = OrigChar;
+
+ if (EFI_ERROR (Status)) {
+ goto Done;
+ }
+
+ //
+ // Get the Driver handle by the got device path.
+ //
+ HiiHandle = DevicePathToHiiHandle (gIfrLibHiiDatabase, DevicePath);
+ if (HiiHandle == NULL) {
+ //
+ // This request string has no its Hii package.
+ // Its default value and validating can't execute by parsing IFR data.
+ // Directly jump into the next ConfigAltResp string for another pair Guid, Name, and Path.
+ //
+ Status = EFI_SUCCESS;
+ goto NextConfigAltResp;
+ }
+
+ //
+ // 2. Get DefaultName string ID by parsing the PacakgeList
+ //
+
+ //
+ // Get HiiPackage by HiiHandle
+ //
+ PackageListLength = 0;
+ HiiPackageList = NULL;
+ Status = gIfrLibHiiDatabase->ExportPackageLists (gIfrLibHiiDatabase, HiiHandle, &PackageListLength, HiiPackageList);
+
+ //
+ // The return status should always be EFI_BUFFER_TOO_SMALL as input buffer's size is 0.
+ //
+ if (Status != EFI_BUFFER_TOO_SMALL) {
+ Status = EFI_INVALID_PARAMETER;
+ goto Done;
+ }
+
+ HiiPackageList = EfiLibAllocatePool (PackageListLength);
+ if (HiiPackageList == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Done;
+ }
+
+ //
+ // Get PackageList on HiiHandle
+ //
+ Status = gIfrLibHiiDatabase->ExportPackageLists (gIfrLibHiiDatabase, HiiHandle, &PackageListLength, HiiPackageList);
+ if (EFI_ERROR (Status)) {
+ goto Done;
+ }
+
+ //
+ // Parse the form package and get the default name string ID.
+ //
+ PackageOffset = sizeof (EFI_HII_PACKAGE_LIST_HEADER);
+ Status = EFI_NOT_FOUND;
+ while (PackageOffset < PackageListLength) {
+ EfiCopyMem (&PacakgeHeader, (UINT8 *) HiiPackageList + PackageOffset, sizeof (PacakgeHeader));
+
+ //
+ // Parse IFR opcode to get default store opcode
+ //
+ if (PacakgeHeader.Type == EFI_HII_PACKAGE_FORMS) {
+ IfrOffset = sizeof (PacakgeHeader);
+ PackageData = (UINT8 *) HiiPackageList + PackageOffset;
+ while (IfrOffset < PacakgeHeader.Length) {
+ IfrOpHdr = (EFI_IFR_OP_HEADER *) (PackageData + IfrOffset);
+ //
+ // Match DefaultId to find its DefaultName
+ //
+ if (IfrOpHdr->OpCode == EFI_IFR_DEFAULTSTORE_OP) {
+ if (((EFI_IFR_DEFAULTSTORE *) IfrOpHdr)->DefaultId == DefaultId) {
+ DefaultName = ((EFI_IFR_DEFAULTSTORE *) IfrOpHdr)->DefaultName;
+ Status = EFI_SUCCESS;
+ break;
+ }
+ }
+ IfrOffset += IfrOpHdr->Length;
+ }
+ //
+ // Only one form is in a package list.
+ //
+ break;
+ }
+
+ //
+ // Go to next package.
+ //
+ PackageOffset += PacakgeHeader.Length;
+ }
+
+ //
+ // Not found the matched default string ID
+ //
+ if (EFI_ERROR (Status)) {
+ Status = EFI_SUCCESS;
+ goto NextConfigAltResp;
+ }
+
+ //
+ // 3. Call ConfigRouting GetAltCfg(ConfigRoute, <ConfigResponse>, Guid, Name, DevicePath, AltCfgId, AltCfgResp)
+ // Get the default configuration string according to the found default name string ID.
+ //
+ Status = HiiConfigRouting->GetAltConfig (
+ HiiConfigRouting,
+ ConfigAltResp,
+ VarGuid,
+ VarName,
+ DevicePath,
+ &DefaultName, // it can be NULL to get the current setting.
+ &ConfigResp
+ );
+
+ //
+ // The required setting can't be found. So, it is not required to be validated and set.
+ //
+ if (EFI_ERROR (Status)) {
+ Status = EFI_SUCCESS;
+ goto NextConfigAltResp;
+ }
+ //
+ // Only the ConfigHdr is found. Not any block data is found. No data is required to be validated and set.
+ //
+ if (EfiStrStr (ConfigResp, L"&OFFSET=") == NULL) {
+ goto NextConfigAltResp;
+ }
+
+ //
+ // 4. Set the default configuration information or Validate current setting by parse IFR code.
+ // Current Setting is in ConfigResp, will be set into buffer, then check it again.
+ //
+ //
+ // Set the default configuration information.
+ //
+ Status = HiiConfigRouting->RouteConfig (HiiConfigRouting, ConfigResp, &Progress);
+
+ if (EFI_ERROR (Status)) {
+ goto Done;
+ }
+
+NextConfigAltResp:
+ //
+ // Free the allocated pacakge buffer and the got ConfigResp string.
+ //
+ if (HiiPackageList != NULL) {
+ gBS->FreePool (HiiPackageList);
+ HiiPackageList = NULL;
+ }
+
+ if (ConfigResp != NULL) {
+ gBS->FreePool (ConfigResp);
+ ConfigResp = NULL;
+ }
+
+ //
+ // Free the allocated buffer.
+ //
+ gBS->FreePool (VarGuid);
+ VarGuid = NULL;
+
+ gBS->FreePool (VarName);
+ VarName = NULL;
+
+ gBS->FreePool (DevicePath);
+ DevicePath = NULL;
+
+ //
+ // 5. Jump to next ConfigAltResp for another Guid, Name, Path.
+ //
+
+ //
+ // Get and Skip ConfigHdr
+ //
+ while (*StringPtr != L'\0' && *StringPtr != L'&') {
+ StringPtr++;
+ }
+ if (*StringPtr == L'\0') {
+ break;
+ }
+
+ //
+ // Construct ConfigAltHdr string "&<ConfigHdr>&ALTCFG=\0"
+ // | 1 | EfiStrLen (ConfigHdr) | 8 | 1 |
+ //
+ ConfigAltHdr = EfiLibAllocateZeroPool ((1 + StringPtr - StringHdr + 8 + 1) * sizeof (CHAR16));
+ if (ConfigAltHdr == NULL) {
+ Status = EFI_OUT_OF_RESOURCES;
+ goto Done;
+ }
+ EfiStrCpy (ConfigAltHdr, L"&");
+ EfiStrnCat (ConfigAltHdr, StringHdr, StringPtr - StringHdr);
+ EfiStrCat (ConfigAltHdr, L"&ALTCFG=");
+
+ //
+ // Skip all AltResp (AltConfigHdr ConfigBody) for the same ConfigHdr
+ //
+ while ((StringHdr = EfiStrStr (StringPtr, ConfigAltHdr)) != NULL) {
+ StringPtr = StringHdr + EfiStrLen (ConfigAltHdr);
+ if (*StringPtr == L'\0') {
+ break;
+ }
+ }
+
+ //
+ // Free the allocated ConfigAltHdr string
+ //
+ gBS->FreePool (ConfigAltHdr);
+ if (*StringPtr == L'\0') {
+ break;
+ }
+
+ //
+ // Find &GUID as the next ConfigHdr
+ //
+ StringPtr = EfiStrStr (StringPtr, L"&GUID");
+ if (StringPtr == NULL) {
+ break;
+ }
+
+ //
+ // Skip char '&'
+ //
+ StringPtr ++;
+ }
+ DEBUG ((EFI_D_ERROR, "HiiSetToDefaults - end\n"));
+
+Done:
+ if (VarGuid != NULL) {
+ gBS->FreePool (VarGuid);
+ }
+
+ if (VarName != NULL) {
+ gBS->FreePool (VarName);
+ }
+
+ if (DevicePath != NULL) {
+ gBS->FreePool (DevicePath);
+ }
+
+ if (ConfigResp != NULL) {
+ gBS->FreePool (ConfigResp);
+ }
+
+ if (ConfigAltResp != NULL) {
+ gBS->FreePool (ConfigAltResp);
+ }
+
+ if (HiiPackageList != NULL) {
+ gBS->FreePool (HiiPackageList);
+ }
+
+ if (EFI_ERROR (Status)) {
+ return FALSE;
+ }
+
+ return TRUE;
+}
diff --git a/EDK/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrLibrary.h b/EDK/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrLibrary.h
new file mode 100644
index 0000000..3baf851
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrLibrary.h
@@ -0,0 +1,1370 @@
+/*++
+
+Copyright (c) 2007 - 2008, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ UefiIfrLibrary.h
+
+Abstract:
+
+ The file contain all library function for Ifr Operations.
+
+--*/
+
+#ifndef _IFRLIBRARY_H
+#define _IFRLIBRARY_H
+
+#include "Tiano.h"
+#include "EfiDriverLib.h"
+#include "TianoHii.h"
+
+#include EFI_PROTOCOL_DEFINITION (HiiFont)
+#include EFI_PROTOCOL_DEFINITION (HiiImage)
+#include EFI_PROTOCOL_DEFINITION (HiiString)
+#include EFI_PROTOCOL_DEFINITION (HiiDatabase)
+#include EFI_PROTOCOL_DEFINITION (HiiConfigRouting)
+#include EFI_PROTOCOL_DEFINITION (HiiConfigAccess)
+#include EFI_PROTOCOL_DEFINITION (FormBrowser2)
+#include EFI_PROTOCOL_DEFINITION (SimpleTextOut)
+
+#include EFI_GUID_DEFINITION (GlobalVariable)
+
+#define IFR_LIB_DEFAULT_STRING_SIZE 0x200
+
+//
+// The architectural variable "Lang" and "LangCodes" are deprecated in UEFI
+// specification. While, UEFI specification also states that these deprecated
+// variables may be provided for backwards compatibility.
+// If "LANG_SUPPORT" is defined, "Lang" and "LangCodes" will be produced;
+// If "LANG_SUPPORT" is undefined, "Lang" and "LangCodes" will not be produced.
+//
+#define LANG_SUPPORT
+
+#define EFI_LANGUAGE_VARIABLE L"Lang"
+#define EFI_LANGUAGE_CODES_VARIABLE L"LangCodes"
+
+#define UEFI_LANGUAGE_VARIABLE L"PlatformLang"
+#define UEFI_LANGUAGE_CODES_VARIABLE L"PlatformLangCodes"
+
+//
+// Limited buffer size recommended by RFC4646 (4.3. Length Considerations)
+// (42 characters plus a NULL terminator)
+//
+#define RFC_3066_ENTRY_SIZE (42 + 1)
+#define ISO_639_2_ENTRY_SIZE 3
+
+#define INVALID_VARSTORE_ID 0
+
+#define QUESTION_FLAGS (EFI_IFR_FLAG_READ_ONLY | EFI_IFR_FLAG_CALLBACK | EFI_IFR_FLAG_RESET_REQUIRED | EFI_IFR_FLAG_OPTIONS_ONLY)
+#define QUESTION_FLAGS_MASK (~QUESTION_FLAGS)
+
+extern EFI_GUID mIfrVendorGuid;
+extern EFI_HII_DATABASE_PROTOCOL *gIfrLibHiiDatabase;
+extern EFI_HII_STRING_PROTOCOL *gIfrLibHiiString;
+
+#pragma pack(1)
+typedef struct {
+ EFI_STRING_ID StringToken;
+ EFI_IFR_TYPE_VALUE Value;
+ UINT8 Flags;
+} IFR_OPTION;
+#pragma pack()
+
+#pragma pack(1)
+typedef struct {
+ VENDOR_DEVICE_PATH VendorDevicePath;
+ UINT32 Reserved;
+ UINT64 UniqueId;
+} HII_VENDOR_DEVICE_PATH_NODE;
+#pragma pack()
+
+typedef struct {
+ HII_VENDOR_DEVICE_PATH_NODE Node;
+ EFI_DEVICE_PATH_PROTOCOL End;
+} HII_VENDOR_DEVICE_PATH;
+
+typedef struct {
+ //
+ // Buffer size allocated for Data.
+ //
+ UINT32 BufferSize;
+
+ //
+ // Offset in Data to append the newly created opcode binary.
+ // It will be adjusted automatically in Create***OpCode(), and should be
+ // initialized to 0 before invocation of a serial of Create***OpCode()
+ //
+ UINT32 Offset;
+
+ //
+ // The destination buffer for created op-codes
+ //
+ UINT8 *Data;
+} EFI_HII_UPDATE_DATA;
+
+VOID
+LocateHiiProtocols (
+ VOID
+ )
+/*++
+
+Routine Description:
+ This function locate Hii relative protocols for later usage.
+
+Arguments:
+ None.
+
+Returns:
+ None.
+
+--*/
+;
+
+//
+// Exported Library functions
+//
+EFI_STATUS
+CreateEndOpCode (
+ IN OUT EFI_HII_UPDATE_DATA *Data
+ )
+/*++
+
+Routine Description:
+ Create EFI_IFR_END_OP opcode.
+
+Arguments:
+ Data - Destination for the created opcode binary
+
+Returns:
+ EFI_SUCCESS - Opcode create success
+
+--*/
+;
+
+EFI_STATUS
+CreateDefaultOpCode (
+ IN EFI_IFR_TYPE_VALUE *Value,
+ IN UINT8 Type,
+ IN OUT EFI_HII_UPDATE_DATA *Data
+ )
+/*++
+
+Routine Description:
+ Create EFI_IFR_DEFAULT_OP opcode.
+
+Arguments:
+ Value - Value for the default
+ Type - Type for the default
+ Data - Destination for the created opcode binary
+
+Returns:
+ EFI_SUCCESS - Opcode create success
+
+--*/
+;
+
+EFI_STATUS
+CreateActionOpCode (
+ IN EFI_QUESTION_ID QuestionId,
+ IN EFI_STRING_ID Prompt,
+ IN EFI_STRING_ID Help,
+ IN UINT8 QuestionFlags,
+ IN EFI_STRING_ID QuestionConfig,
+ IN OUT EFI_HII_UPDATE_DATA *Data
+ )
+/*++
+
+Routine Description:
+ Create EFI_IFR_ACTION_OP opcode.
+
+Arguments:
+ QuestionId - Question ID
+ Prompt - String ID for Prompt
+ Help - String ID for Help
+ QuestionFlags - Flags in Question Header
+ QuestionConfig - String ID for configuration
+ Data - Destination for the created opcode binary
+
+Returns:
+ EFI_SUCCESS - Opcode create success
+
+--*/
+;
+
+EFI_STATUS
+CreateSubTitleOpCode (
+ IN EFI_STRING_ID Prompt,
+ IN EFI_STRING_ID Help,
+ IN UINT8 Flags,
+ IN UINT8 Scope,
+ IN OUT EFI_HII_UPDATE_DATA *Data
+ )
+/*++
+
+Routine Description:
+ Create EFI_IFR_SUBTITLE_OP opcode.
+
+Arguments:
+ Prompt - String ID for Prompt
+ Help - String ID for Help
+ Flags - Subtitle opcode flags
+ Scope - Subtitle Scope bit
+ Data - Destination for the created opcode binary
+
+Returns:
+ EFI_SUCCESS - Opcode create success
+
+--*/
+;
+
+EFI_STATUS
+CreateTextOpCode (
+ IN EFI_STRING_ID Prompt,
+ IN EFI_STRING_ID Help,
+ IN EFI_STRING_ID TextTwo,
+ IN OUT EFI_HII_UPDATE_DATA *Data
+ )
+/*++
+
+Routine Description:
+ Create EFI_IFR_TEXT_OP opcode.
+
+Arguments:
+ Prompt - String ID for Prompt
+ Help - String ID for Help
+ TextTwo - String ID for text two
+ Data - Destination for the created opcode binary
+
+Returns:
+ EFI_SUCCESS - Opcode create success
+
+--*/
+;
+
+EFI_STATUS
+CreateGotoOpCode (
+ IN EFI_FORM_ID FormId,
+ IN EFI_STRING_ID Prompt,
+ IN EFI_STRING_ID Help,
+ IN UINT8 QuestionFlags,
+ IN EFI_QUESTION_ID QuestionId,
+ IN OUT EFI_HII_UPDATE_DATA *Data
+ )
+/*++
+
+Routine Description:
+ Create EFI_IFR_REF_OP opcode.
+
+Arguments:
+ FormId - Destination Form ID
+ Prompt - String ID for Prompt
+ Help - String ID for Help
+ QuestionFlags - Flags in Question Header
+ QuestionId - Question ID
+ Data - Destination for the created opcode binary
+
+Returns:
+ EFI_SUCCESS - Opcode create success
+
+--*/
+;
+
+EFI_STATUS
+CreateOneOfOptionOpCode (
+ IN UINTN OptionCount,
+ IN IFR_OPTION *OptionsList,
+ IN UINT8 Type,
+ IN OUT EFI_HII_UPDATE_DATA *Data
+ )
+;
+
+EFI_STATUS
+CreateOneOfOpCode (
+ IN EFI_QUESTION_ID QuestionId,
+ IN EFI_VARSTORE_ID VarStoreId,
+ IN UINT16 VarOffset,
+ IN EFI_STRING_ID Prompt,
+ IN EFI_STRING_ID Help,
+ IN UINT8 QuestionFlags,
+ IN UINT8 OneOfFlags,
+ IN IFR_OPTION *OptionsList,
+ IN UINTN OptionCount,
+ IN OUT EFI_HII_UPDATE_DATA *Data
+ )
+/*++
+
+Routine Description:
+ Create EFI_IFR_ONE_OF_OP opcode.
+
+Arguments:
+ QuestionId - Question ID
+ VarStoreId - Storage ID
+ VarOffset - Offset in Storage
+ Prompt - String ID for Prompt
+ Help - String ID for Help
+ QuestionFlags - Flags in Question Header
+ OneOfFlags - Flags for oneof opcode
+ OptionsList - List of options
+ OptionCount - Number of options in option list
+ Data - Destination for the created opcode binary
+
+Returns:
+ EFI_SUCCESS - Opcode create success
+
+--*/
+;
+
+EFI_STATUS
+CreateOrderedListOpCode (
+ IN EFI_QUESTION_ID QuestionId,
+ IN EFI_VARSTORE_ID VarStoreId,
+ IN UINT16 VarOffset,
+ IN EFI_STRING_ID Prompt,
+ IN EFI_STRING_ID Help,
+ IN UINT8 QuestionFlags,
+ IN UINT8 Flags,
+ IN UINT8 DataType,
+ IN UINT8 MaxContainers,
+ IN IFR_OPTION *OptionsList,
+ IN UINTN OptionCount,
+ IN OUT EFI_HII_UPDATE_DATA *Data
+ )
+/*++
+
+Routine Description:
+ Create EFI_IFR_ORDERED_LIST_OP opcode.
+
+Arguments:
+ QuestionId - Question ID
+ VarStoreId - Storage ID
+ VarOffset - Offset in Storage
+ Prompt - String ID for Prompt
+ Help - String ID for Help
+ QuestionFlags - Flags in Question Header
+ Flags - Flags for ordered list opcode
+ DataType - Type for option value
+ MaxContainers - Maximum count for options in this ordered list
+ OptionsList - List of options
+ OptionCount - Number of options in option list
+ Data - Destination for the created opcode binary
+
+Returns:
+ EFI_SUCCESS - Opcode create success
+
+--*/
+;
+
+EFI_STATUS
+CreateCheckBoxOpCode (
+ IN EFI_QUESTION_ID QuestionId,
+ IN EFI_VARSTORE_ID VarStoreId,
+ IN UINT16 VarOffset,
+ IN EFI_STRING_ID Prompt,
+ IN EFI_STRING_ID Help,
+ IN UINT8 QuestionFlags,
+ IN UINT8 CheckBoxFlags,
+ IN OUT EFI_HII_UPDATE_DATA *Data
+ )
+/*++
+
+Routine Description:
+ Create EFI_IFR_CHECKBOX_OP opcode.
+
+Arguments:
+ QuestionId - Question ID
+ VarStoreId - Storage ID
+ VarOffset - Offset in Storage
+ Prompt - String ID for Prompt
+ Help - String ID for Help
+ QuestionFlags - Flags in Question Header
+ CheckBoxFlags - Flags for checkbox opcode
+ Data - Destination for the created opcode binary
+
+Returns:
+ EFI_SUCCESS - Opcode create success
+
+--*/
+;
+
+EFI_STATUS
+CreateNumericOpCode (
+ IN EFI_QUESTION_ID QuestionId,
+ IN EFI_VARSTORE_ID VarStoreId,
+ IN UINT16 VarOffset,
+ IN EFI_STRING_ID Prompt,
+ IN EFI_STRING_ID Help,
+ IN UINT8 QuestionFlags,
+ IN UINT8 NumericFlags,
+ IN UINT64 Minimum,
+ IN UINT64 Maximum,
+ IN UINT64 Step,
+ IN UINT64 Default,
+ IN OUT EFI_HII_UPDATE_DATA *Data
+ )
+/*++
+
+Routine Description:
+ Create EFI_IFR_NUMERIC_OP opcode.
+
+Arguments:
+ QuestionId - Question ID
+ VarStoreId - Storage ID
+ VarOffset - Offset in Storage
+ Prompt - String ID for Prompt
+ Help - String ID for Help
+ QuestionFlags - Flags in Question Header
+ NumericFlags - Flags for numeric opcode
+ Minimum - Numeric minimum value
+ Maximum - Numeric maximum value
+ Step - Numeric step for edit
+ Default - Numeric default value
+ Data - Destination for the created opcode binary
+
+Returns:
+ EFI_SUCCESS - Opcode create success
+
+--*/
+;
+
+EFI_STATUS
+CreateStringOpCode (
+ IN EFI_QUESTION_ID QuestionId,
+ IN EFI_VARSTORE_ID VarStoreId,
+ IN UINT16 VarOffset,
+ IN EFI_STRING_ID Prompt,
+ IN EFI_STRING_ID Help,
+ IN UINT8 QuestionFlags,
+ IN UINT8 StringFlags,
+ IN UINT8 MinSize,
+ IN UINT8 MaxSize,
+ IN OUT EFI_HII_UPDATE_DATA *Data
+ )
+/*++
+
+Routine Description:
+ Create EFI_IFR_STRING_OP opcode.
+
+Arguments:
+ QuestionId - Question ID
+ VarStoreId - Storage ID
+ VarOffset - Offset in Storage
+ Prompt - String ID for Prompt
+ Help - String ID for Help
+ QuestionFlags - Flags in Question Header
+ StringFlags - Flags for string opcode
+ MinSize - String minimum length
+ MaxSize - String maximum length
+ Data - Destination for the created opcode binary
+
+Returns:
+ EFI_SUCCESS - Opcode create success
+
+--*/
+;
+
+EFI_STATUS
+CreateBannerOpCode (
+ IN EFI_STRING_ID Title,
+ IN UINT16 LineNumber,
+ IN UINT8 Alignment,
+ IN OUT EFI_HII_UPDATE_DATA *Data
+ )
+/*++
+
+Routine Description:
+ Create GUIDed opcode for banner.
+
+Arguments:
+ Title - String ID for title
+ LineNumber - Line number for this banner
+ Alignment - Alignment for this banner, left, center or right
+ Data - Destination for the created opcode binary
+
+Returns:
+ EFI_SUCCESS - Opcode create success
+
+--*/
+;
+
+EFI_HII_PACKAGE_LIST_HEADER *
+PreparePackageList (
+ IN UINTN NumberOfPackages,
+ IN EFI_GUID *GuidId,
+ ...
+ )
+/*++
+
+Routine Description:
+ Assemble EFI_HII_PACKAGE_LIST according to the passed in packages.
+
+Arguments:
+ NumberOfPackages - Number of packages.
+ GuidId - Package GUID.
+
+Returns:
+ Pointer of EFI_HII_PACKAGE_LIST_HEADER.
+
+--*/
+;
+
+EFI_STATUS
+CreateHiiDriverHandle (
+ OUT EFI_HANDLE *DriverHandle
+ )
+/*++
+
+Routine Description:
+ The HII driver handle passed in for HiiDatabase.NewPackageList() requires
+ that there should be DevicePath Protocol installed on it.
+ This routine create a virtual Driver Handle by installing a vendor device
+ path on it, so as to use it to invoke HiiDatabase.NewPackageList().
+
+Arguments:
+ DriverHandle - Handle to be returned
+
+Returns:
+ EFI_SUCCESS - Handle destroy success.
+ EFI_OUT_OF_RESOURCES - Not enough memory.
+
+--*/
+;
+
+EFI_STATUS
+DestroyHiiDriverHandle (
+ IN EFI_HANDLE DriverHandle
+ )
+/*++
+
+Routine Description:
+ Destroy the Driver Handle created by CreateHiiDriverHandle().
+
+Arguments:
+ DriverHandle - Handle returned by CreateHiiDriverHandle()
+
+Returns:
+ EFI_SUCCESS - Handle destroy success.
+ other - Handle destroy fail.
+
+--*/
+;
+
+EFI_HII_HANDLE
+DevicePathToHiiHandle (
+ IN EFI_HII_DATABASE_PROTOCOL *HiiDatabase,
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ )
+/*++
+
+Routine Description:
+ Find HII Handle associated with given Device Path.
+
+Arguments:
+ HiiDatabase - Point to EFI_HII_DATABASE_PROTOCOL instance.
+ DevicePath - Device Path associated with the HII package list handle.
+
+Returns:
+ Handle - HII package list Handle associated with the Device Path.
+ NULL - Hii Package list handle is not found.
+
+--*/
+;
+
+EFI_STATUS
+ExtractDefault(
+ IN VOID *Buffer,
+ IN UINTN *BufferSize,
+ UINTN Number,
+ ...
+ )
+/*++
+
+ Routine Description:
+ Configure the buffer accrording to ConfigBody strings.
+
+ Arguments:
+ DefaultId - the ID of default.
+ Buffer - the start address of buffer.
+ BufferSize - the size of buffer.
+ Number - the number of the strings.
+
+ Returns:
+ EFI_BUFFER_TOO_SMALL - the BufferSize is too small to operate.
+ EFI_INVALID_PARAMETER - Buffer is NULL or BufferSize is 0.
+ EFI_SUCCESS - Operation successful.
+
+--*/
+;
+
+EFI_STATUS
+ConstructConfigAltResp (
+ IN EFI_STRING ConfigRequest, OPTIONAL
+ OUT EFI_STRING *Progress,
+ OUT EFI_STRING *ConfigAltResp,
+ IN EFI_GUID *Guid,
+ IN CHAR16 *Name,
+ IN EFI_HANDLE *DriverHandle,
+ IN VOID *BufferStorage,
+ IN UINTN BufferStorageSize,
+ IN VOID *BlockNameArray, OPTIONAL
+ IN UINTN NumberAltCfg,
+ ...
+//IN UINT16 AltCfgId,
+//IN VOID *DefaultValueArray,
+ )
+/*++
+
+ Routine Description:
+
+ Construct <ConfigAltResp> for a buffer storage.
+
+ Arguments:
+ ConfigRequest - The Config request string. If set to NULL, all the
+ configurable elements will be extracted from BlockNameArray.
+ ConfigAltResp - The returned <ConfigAltResp>.
+ Progress - On return, points to a character in the Request.
+ Guid - GUID of the buffer storage.
+ Name - Name of the buffer storage.
+ DriverHandle - The DriverHandle which is used to invoke HiiDatabase
+ protocol interface NewPackageList().
+ BufferStorage - Content of the buffer storage.
+ BufferStorageSize - Length in bytes of the buffer storage.
+ BlockNameArray - Array generated by VFR compiler.
+ NumberAltCfg - Number of Default value array generated by VFR compiler.
+ The sequential input parameters will be number of
+ AltCfgId and DefaultValueArray pairs. When set to 0,
+ there will be no <AltResp>.
+
+ Returns:
+ EFI_OUT_OF_RESOURCES - Run out of memory resource.
+ EFI_INVALID_PARAMETER - ConfigAltResp is NULL.
+ EFI_SUCCESS - Operation successful.
+
+--*/
+;
+
+EFI_STATUS
+ExtractGuidFromHiiHandle (
+ IN EFI_HII_HANDLE Handle,
+ OUT EFI_GUID *Guid
+ )
+/*++
+
+Routine Description:
+ Extract Hii package list GUID for given HII handle.
+
+Arguments:
+ HiiHandle - Hii handle
+ Guid - Package list GUID
+
+Returns:
+ EFI_SUCCESS - Successfully extract GUID from Hii database.
+
+--*/
+;
+
+EFI_STATUS
+ExtractClassFromHiiHandle (
+ IN EFI_HII_HANDLE Handle,
+ OUT UINT16 *Class,
+ OUT EFI_STRING_ID *FormSetTitle,
+ OUT EFI_STRING_ID *FormSetHelp
+ )
+/*++
+
+Routine Description:
+ Extract formset class for given HII handle.
+
+Arguments:
+ HiiHandle - Hii handle
+ Class - Class of the formset
+ FormSetTitle - Formset title string
+ FormSetHelp - Formset help string
+
+Returns:
+ EFI_SUCCESS - Successfully extract Class for specified Hii handle.
+
+--*/
+;
+
+EFI_STATUS
+ExtractClassGuidFromHiiHandle (
+ IN EFI_HII_HANDLE Handle,
+ OUT UINT8 *NumberOfClassGuid,
+ OUT EFI_GUID **ClassGuid,
+ OUT EFI_STRING_ID *FormSetTitle,
+ OUT EFI_STRING_ID *FormSetHelp
+ )
+/*++
+
+Routine Description:
+ Extract formset ClassGuid for given HII handle.
+
+Arguments:
+ HiiHandle - Hii handle
+ NumberOfClassGuid - Number of ClassGuid
+ ClassGuid - Pointer to callee allocated buffer, an array of ClassGuid
+ FormSetTitle - Formset title string
+ FormSetHelp - Formset help string
+
+Returns:
+ EFI_SUCCESS - Successfully extract Class for specified Hii handle.
+
+--*/
+;
+
+VOID
+ToLower (
+ IN OUT CHAR16 *Str
+ )
+/*++
+
+Routine Description:
+ Converts the unicode character from uppercase to lowercase.
+
+Arguments:
+ Str - String to be converted
+
+Returns:
+
+--*/
+;
+
+EFI_STATUS
+BufferToHexString (
+ IN OUT CHAR16 *Str,
+ IN UINT8 *Buffer,
+ IN UINTN BufferSize
+ )
+/*++
+
+Routine Description:
+ Converts binary buffer to Unicode string in reversed byte order to BufToHexString().
+
+Arguments:
+ Str - String for output
+ Buffer - Binary buffer.
+ BufferSize - Size of the buffer in bytes.
+
+Returns:
+ EFI_SUCCESS - The function completed successfully.
+
+--*/
+;
+
+EFI_STATUS
+HexStringToBuffer (
+ IN OUT UINT8 *Buffer,
+ IN OUT UINTN *BufferSize,
+ IN CHAR16 *Str
+ )
+/*++
+
+Routine Description:
+ Converts Hex String to binary buffer in reversed byte order to HexStringToBuf().
+
+Arguments:
+ Buffer - Pointer to buffer that receives the data.
+ BufferSize - Length in bytes of the buffer to hold converted data.
+ If routine return with EFI_SUCCESS, containing length of converted data.
+ If routine return with EFI_BUFFER_TOO_SMALL, containg length of buffer desired.
+ Str - String to be converted from.
+
+Returns:
+ EFI_SUCCESS - The function completed successfully.
+
+--*/
+;
+
+EFI_STATUS
+ConfigStringToUnicode (
+ IN OUT CHAR16 *UnicodeString,
+ IN OUT UINTN *StrBufferLen,
+ IN CHAR16 *ConfigString
+ )
+/*++
+
+Routine Description:
+ Convert binary representation Config string (e.g. "0041004200430044") to the
+ original string (e.g. "ABCD"). Config string appears in <ConfigHdr> (i.e.
+ "&NAME=<string>"), or Name/Value pair in <ConfigBody> (i.e. "label=<string>").
+
+Arguments:
+ UnicodeString - Original Unicode string.
+ StrBufferLen - On input: Length in bytes of buffer to hold the Unicode string.
+ Includes tailing '\0' character.
+ On output:
+ If return EFI_SUCCESS, containing length of Unicode string buffer.
+ If return EFI_BUFFER_TOO_SMALL, containg length of string buffer desired.
+ ConfigString - Binary representation of Unicode String, <string> := (<HexCh>4)+
+
+Returns:
+ EFI_SUCCESS - Routine success.
+ EFI_BUFFER_TOO_SMALL - The string buffer is too small.
+
+--*/
+;
+
+EFI_STATUS
+UnicodeToConfigString (
+ IN OUT CHAR16 *ConfigString,
+ IN OUT UINTN *StrBufferLen,
+ IN CHAR16 *UnicodeString
+ )
+/*++
+
+Routine Description:
+ Convert Unicode string to binary representation Config string, e.g.
+ "ABCD" => "0041004200430044". Config string appears in <ConfigHdr> (i.e.
+ "&NAME=<string>"), or Name/Value pair in <ConfigBody> (i.e. "label=<string>").
+
+Arguments:
+ ConfigString - Binary representation of Unicode String, <string> := (<HexCh>4)+
+ StrBufferLen - On input: Length in bytes of buffer to hold the Unicode string.
+ Includes tailing '\0' character.
+ On output:
+ If return EFI_SUCCESS, containing length of Unicode string buffer.
+ If return EFI_BUFFER_TOO_SMALL, containg length of string buffer desired.
+ UnicodeString - Original Unicode string.
+
+Returns:
+ EFI_SUCCESS - Routine success.
+ EFI_BUFFER_TOO_SMALL - The string buffer is too small.
+
+--*/
+;
+
+EFI_STATUS
+ConstructConfigHdr (
+ IN OUT CHAR16 *ConfigHdr,
+ IN OUT UINTN *StrBufferLen,
+ IN EFI_GUID *Guid,
+ IN CHAR16 *Name, OPTIONAL
+ IN EFI_HANDLE *DriverHandle
+ )
+/*++
+
+Routine Description:
+ Construct <ConfigHdr> using routing information GUID/NAME/PATH.
+
+Arguments:
+ ConfigHdr - Pointer to the ConfigHdr string.
+ StrBufferLen - On input: Length in bytes of buffer to hold the ConfigHdr string. Includes tailing '\0' character.
+ On output:
+ If return EFI_SUCCESS, containing length of ConfigHdr string buffer.
+ If return EFI_BUFFER_TOO_SMALL, containg length of string buffer desired.
+ Guid - Routing information: GUID.
+ Name - Routing information: NAME.
+ DriverHandle - Driver handle which contains the routing information: PATH.
+
+Returns:
+ EFI_SUCCESS - Routine success.
+ EFI_BUFFER_TOO_SMALL - The ConfigHdr string buffer is too small.
+
+--*/
+;
+
+BOOLEAN
+IsConfigHdrMatch (
+ IN EFI_STRING ConfigString,
+ IN EFI_GUID *StorageGuid, OPTIONAL
+ IN CHAR16 *StorageName OPTIONAL
+ )
+/*++
+
+Routine Description:
+ Determines if the Routing data (Guid and Name) is correct in <ConfigHdr>.
+
+Arguments:
+ ConfigString - Either <ConfigRequest> or <ConfigResp>.
+ StorageGuid - GUID of the storage.
+ StorageName - Name of the stoarge.
+
+Returns:
+ TRUE - Routing information is correct in ConfigString.
+ FALSE - Routing information is incorrect in ConfigString.
+
+--*/
+;
+
+BOOLEAN
+FindBlockName (
+ IN OUT CHAR16 *String,
+ UINTN Offset,
+ UINTN Width
+ )
+/*++
+
+Routine Description:
+ Search BlockName "&OFFSET=Offset&WIDTH=Width" in a string.
+
+Arguments:
+ String - The string to be searched in.
+ Offset - Offset in BlockName.
+ Width - Width in BlockName.
+
+Returns:
+ TRUE - Block name found.
+ FALSE - Block name not found.
+
+--*/
+;
+
+EFI_STATUS
+GetBrowserData (
+ EFI_GUID *VariableGuid, OPTIONAL
+ CHAR16 *VariableName, OPTIONAL
+ UINTN *BufferSize,
+ UINT8 *Buffer
+ )
+/*++
+
+Routine Description:
+ This routine is invoked by ConfigAccess.Callback() to retrived uncommitted data from Form Browser.
+
+Arguments:
+ VariableGuid - An optional field to indicate the target variable GUID name to use.
+ VariableName - An optional field to indicate the target human-readable variable name.
+ BufferSize - On input: Length in bytes of buffer to hold retrived data.
+ On output:
+ If return EFI_BUFFER_TOO_SMALL, containg length of buffer desired.
+ Buffer - Buffer to hold retrived data.
+
+Returns:
+ EFI_SUCCESS - Routine success.
+ EFI_BUFFER_TOO_SMALL - The intput buffer is too small.
+
+--*/
+;
+
+EFI_STATUS
+GetHiiHandles (
+ IN OUT UINTN *HandleBufferLength,
+ OUT EFI_HII_HANDLE **HiiHandleBuffer
+ )
+/*++
+
+Routine Description:
+ Determines the handles that are currently active in the database.
+ It's the caller's responsibility to free handle buffer.
+
+Arguments:
+ HiiDatabase - A pointer to the EFI_HII_DATABASE_PROTOCOL instance.
+ HandleBufferLength - On input, a pointer to the length of the handle buffer. On output,
+ the length of the handle buffer that is required for the handles found.
+ HiiHandleBuffer - Pointer to an array of Hii Handles returned.
+
+Returns:
+ EFI_SUCCESS - Get an array of Hii Handles successfully.
+ EFI_INVALID_PARAMETER - Hii is NULL.
+ EFI_NOT_FOUND - Database not found.
+
+--*/
+;
+
+EFI_STATUS
+SetBrowserData (
+ EFI_GUID *VariableGuid, OPTIONAL
+ CHAR16 *VariableName, OPTIONAL
+ UINTN BufferSize,
+ UINT8 *Buffer,
+ CHAR16 *RequestElement OPTIONAL
+ )
+/*++
+
+Routine Description:
+ This routine is invoked by ConfigAccess.Callback() to update uncommitted data of Form Browser.
+
+Arguments:
+ VariableGuid - An optional field to indicate the target variable GUID name to use.
+ VariableName - An optional field to indicate the target human-readable variable name.
+ BufferSize - Length in bytes of buffer to hold retrived data.
+ Buffer - Buffer to hold retrived data.
+ RequestElement - An optional field to specify which part of the buffer data
+ will be send back to Browser. If NULL, the whole buffer of
+ data will be committed to Browser.
+ <RequestElement> ::= &OFFSET=<Number>&WIDTH=<Number>*
+
+Returns:
+ EFI_SUCCESS - Routine success.
+ Other - Updating Browser uncommitted data failed.
+
+--*/
+;
+
+EFI_STATUS
+ConvertRfc3066LanguageToIso639Language (
+ CHAR8 *LanguageRfc3066,
+ CHAR8 *LanguageIso639
+ )
+/*++
+
+Routine Description:
+ Convert language code from RFC3066 to ISO639-2.
+
+Arguments:
+ LanguageRfc3066 - RFC3066 language code.
+ LanguageIso639 - ISO639-2 language code.
+
+Returns:
+ EFI_SUCCESS - Language code converted.
+ EFI_NOT_FOUND - Language code not found.
+
+--*/
+;
+
+CHAR8 *
+Rfc3066ToIso639 (
+ CHAR8 *SupportedLanguages
+ )
+/*++
+
+Routine Description:
+ Convert language code list from RFC3066 to ISO639-2, e.g. "en-US;fr-FR" will
+ be converted to "engfra".
+
+Arguments:
+ SupportedLanguages - The RFC3066 language list.
+
+Returns:
+ The ISO639-2 language list.
+
+--*/
+;
+
+EFI_STATUS
+GetCurrentLanguage (
+ OUT CHAR8 *Lang
+ )
+/*++
+
+Routine Description:
+ Determine what is the current language setting
+
+Arguments:
+ Lang - Pointer of system language
+
+Returns:
+ Status code
+
+--*/
+;
+
+VOID
+GetNextLanguage (
+ IN OUT CHAR8 **LangCode,
+ OUT CHAR8 *Lang
+ )
+/*++
+
+Routine Description:
+ Get next language from language code list.
+
+Arguments:
+ LangCode - The language code.
+ Lang - Returned language.
+
+Returns:
+ None.
+
+--*/
+;
+
+CHAR8 *
+GetSupportedLanguages (
+ IN EFI_HII_HANDLE HiiHandle
+ )
+/*++
+
+Routine Description:
+ This function returns the list of supported languages, in the format specified
+ in UEFI specification Appendix M.
+
+Arguments:
+ HiiHandle - The HII package list handle.
+
+Returns:
+ The supported languages.
+
+--*/
+;
+
+UINT16
+GetSupportedLanguageNumber (
+ IN EFI_HII_HANDLE HiiHandle
+ )
+/*++
+
+Routine Description:
+ This function returns the number of supported languages
+
+Arguments:
+ HiiHandle - The HII package list handle.
+
+Returns:
+ The number of supported languages.
+
+--*/
+;
+
+EFI_STATUS
+GetStringFromHandle (
+ IN EFI_HII_HANDLE HiiHandle,
+ IN EFI_STRING_ID StringId,
+ OUT EFI_STRING *String
+ )
+/*++
+
+Routine Description:
+ Get string specified by StringId form the HiiHandle.
+
+Arguments:
+ HiiHandle - The HII handle of package list.
+ StringId - The String ID.
+ String - The output string.
+
+Returns:
+ EFI_NOT_FOUND - String is not found.
+ EFI_SUCCESS - Operation is successful.
+ EFI_OUT_OF_RESOURCES - There is not enought memory in the system.
+ EFI_INVALID_PARAMETER - The String is NULL.
+
+--*/
+;
+
+EFI_STATUS
+GetStringFromToken (
+ IN EFI_GUID *ProducerGuid,
+ IN EFI_STRING_ID StringId,
+ OUT EFI_STRING *String
+ )
+/*++
+
+Routine Description:
+ Get the string given the StringId and String package Producer's Guid.
+
+Arguments:
+ ProducerGuid - The Guid of String package list.
+ StringId - The String ID.
+ String - The output string.
+
+Returns:
+ EFI_NOT_FOUND - String is not found.
+ EFI_SUCCESS - Operation is successful.
+ EFI_OUT_OF_RESOURCES - There is not enought memory in the system.
+
+--*/
+;
+
+EFI_STATUS
+IfrLibNewString (
+ IN EFI_HII_HANDLE PackageList,
+ OUT EFI_STRING_ID *StringId,
+ IN CONST EFI_STRING String
+ )
+/*++
+
+ Routine Description:
+ This function adds the string into String Package of each language.
+
+ Arguments:
+ PackageList - Handle of the package list where this string will be added.
+ StringId - On return, contains the new strings id, which is unique within PackageList.
+ String - Points to the new null-terminated string.
+
+ Returns:
+ EFI_SUCCESS - The new string was added successfully.
+ EFI_NOT_FOUND - The specified PackageList could not be found in database.
+ EFI_OUT_OF_RESOURCES - Could not add the string due to lack of resources.
+ EFI_INVALID_PARAMETER - String is NULL or StringId is NULL is NULL.
+
+--*/
+;
+
+EFI_STATUS
+IfrLibGetString (
+ IN EFI_HII_HANDLE PackageList,
+ IN EFI_STRING_ID StringId,
+ OUT EFI_STRING String,
+ IN OUT UINTN *StringSize
+ )
+/*++
+
+ Routine Description:
+ This function try to retrieve string from String package of current language.
+ If fail, it try to retrieve string from String package of first language it support.
+
+ Arguments:
+ PackageList - The package list in the HII database to search for the specified string.
+ StringId - The string's id, which is unique within PackageList.
+ String - Points to the new null-terminated string.
+ StringSize - On entry, points to the size of the buffer pointed to by String, in bytes. On return,
+ points to the length of the string, in bytes.
+
+ Returns:
+ EFI_SUCCESS - The string was returned successfully.
+ EFI_NOT_FOUND - The string specified by StringId is not available.
+ EFI_BUFFER_TOO_SMALL - The buffer specified by StringLength is too small to hold the string.
+ EFI_INVALID_PARAMETER - The String or StringSize was NULL.
+
+--*/
+;
+
+EFI_STATUS
+IfrLibSetString (
+ IN EFI_HII_HANDLE PackageList,
+ IN EFI_STRING_ID StringId,
+ IN CONST EFI_STRING String
+ )
+/*++
+
+ Routine Description:
+ This function updates the string in String package of current language.
+
+ Arguments:
+ PackageList - The package list containing the strings.
+ StringId - The string's id, which is unique within PackageList.
+ String - Points to the new null-terminated string.
+
+ Returns:
+ EFI_SUCCESS - The string was updated successfully.
+ EFI_NOT_FOUND - The string specified by StringId is not in the database.
+ EFI_INVALID_PARAMETER - The String was NULL.
+ EFI_OUT_OF_RESOURCES - The system is out of resources to accomplish the task.
+
+--*/
+;
+
+EFI_STATUS
+IfrLibCreatePopUp (
+ IN UINTN NumberOfLines,
+ OUT EFI_INPUT_KEY *KeyValue,
+ IN CHAR16 *String,
+ ...
+ )
+/*++
+
+Routine Description:
+ Draw a dialog and return the selected key.
+
+Arguments:
+ NumberOfLines - The number of lines for the dialog box
+ KeyValue - The EFI_KEY value returned if HotKey is TRUE..
+ String - Pointer to the first string in the list
+ ... - A series of (quantity == NumberOfLines) text strings which
+ will be used to construct the dialog box
+
+Returns:
+ EFI_SUCCESS - Displayed dialog and received user interaction
+ EFI_INVALID_PARAMETER - One of the parameters was invalid.
+
+--*/
+;
+
+EFI_STATUS
+IfrLibInitUpdateData (
+ IN OUT EFI_HII_UPDATE_DATA *UpdateData,
+ IN UINT32 BufferSize
+ )
+/*++
+
+Routine Description:
+ This function initialize the data structure for dynamic opcode.
+
+Arguments:
+ UpdateData - The adding data;
+ BufferSize - Length of the buffer to fill dynamic opcodes.
+
+Returns:
+ EFI_SUCCESS - Update data is initialized.
+ EFI_INVALID_PARAMETER - UpdateData is NULL.
+ EFI_OUT_OF_RESOURCES - No enough memory to allocate.
+
+--*/
+;
+
+EFI_STATUS
+IfrLibFreeUpdateData (
+ IN EFI_HII_UPDATE_DATA *UpdateData
+ )
+/*++
+
+Routine Description:
+ This function free the resource of update data.
+
+Arguments:
+ UpdateData - The adding data;
+
+Returns:
+ EFI_SUCCESS - Resource in UpdateData is released.
+ EFI_INVALID_PARAMETER - UpdateData is NULL.
+
+--*/
+;
+
+EFI_STATUS
+IfrLibUpdateForm (
+ IN EFI_HII_HANDLE Handle,
+ IN EFI_GUID *FormSetGuid, OPTIONAL
+ IN EFI_FORM_ID FormId,
+ IN UINT16 Label,
+ IN BOOLEAN Insert,
+ IN EFI_HII_UPDATE_DATA *Data
+ )
+/*++
+
+Routine Description:
+ This function allows the caller to update a form that has
+ previously been registered with the EFI HII database.
+
+Arguments:
+ Handle - Hii Handle
+ FormSetGuid - The formset should be updated.
+ FormId - The form should be updated.
+ Label - Update information starting immediately after this label in the IFR
+ Insert - If TRUE and Data is not NULL, insert data after Label.
+ If FALSE, replace opcodes between two labels with Data.
+ Data - The adding data; If NULL, remove opcodes between two Label.
+
+Returns:
+ EFI_SUCCESS - Update success.
+ Other - Update fail.
+
+--*/
+;
+
+BOOLEAN
+HiiSetToDefaults (
+ IN CONST EFI_STRING Request, OPTIONAL
+ IN UINT16 DefaultId
+ )
+/*++
+
+Routine Description:
+ Reset the default value specified by DefaultId to the driver
+ configuration got by Request string.
+
+ NULL request string support depends on the ExportConfig interface of
+ HiiConfigRouting protocol in UEFI specification.
+
+Arguments:
+ Request - A null-terminated Unicode string in
+ <MultiConfigRequest> format. It can be NULL.
+ If it is NULL, all configuration for the
+ entirety of the current HII database will be reset.
+ DefaultId - Specifies the type of defaults to retrieve.
+
+Returns:
+ TURE - The default value is set successfully.
+ FALSE - The default value can't be found and set.
+
+--*/
+;
+#endif
diff --git a/EDK/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrOpCodeCreation.c b/EDK/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrOpCodeCreation.c
new file mode 100644
index 0000000..e6b37b8
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrOpCodeCreation.c
@@ -0,0 +1,638 @@
+/*++
+
+Copyright (c) 2007 - 2009, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ UefiIfrOpCodeCreation.c
+
+Abstract:
+
+ Library Routines to create IFR independent of string data - assume tokens already exist
+ Primarily to be used for exporting op-codes at a label in pre-defined forms.
+
+Revision History:
+
+--*/
+
+#include "UefiIfrLibrary.h"
+
+EFI_GUID mIfrVendorGuid = EFI_IFR_TIANO_GUID;
+
+STATIC
+BOOLEAN
+IsValidQuestionFlags (
+ IN UINT8 Flags
+ )
+{
+ return (Flags & (~QUESTION_FLAGS)) ? FALSE : TRUE;
+}
+
+STATIC
+BOOLEAN
+IsValidValueType (
+ IN UINT8 Type
+ )
+{
+ return (Type <= EFI_IFR_TYPE_OTHER) ? TRUE : FALSE;
+}
+
+STATIC
+BOOLEAN
+IsValidNumricFlags (
+ IN UINT8 Flags
+ )
+{
+ if (Flags & ~(EFI_IFR_NUMERIC_SIZE | EFI_IFR_DISPLAY)) {
+ return FALSE;
+ }
+
+ if ((Flags & EFI_IFR_DISPLAY) > EFI_IFR_DISPLAY_UINT_HEX) {
+ return FALSE;
+ }
+
+ return TRUE;
+}
+
+STATIC
+BOOLEAN
+IsValidCheckboxFlags (
+ IN UINT8 Flags
+ )
+{
+ return (Flags <= EFI_IFR_CHECKBOX_DEFAULT_MFG) ? TRUE : FALSE;
+}
+
+EFI_STATUS
+CreateEndOpCode (
+ IN OUT EFI_HII_UPDATE_DATA *Data
+ )
+{
+ EFI_IFR_END End;
+ UINT8 *LocalBuffer;
+
+ ASSERT (Data != NULL && Data->Data != NULL);
+
+ if (Data->Offset + sizeof (EFI_IFR_END) > Data->BufferSize) {
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ End.Header.Length = sizeof (EFI_IFR_END);
+ End.Header.OpCode = EFI_IFR_END_OP;
+ End.Header.Scope = 0;
+
+ LocalBuffer = (UINT8 *) Data->Data + Data->Offset;
+ EfiCopyMem (LocalBuffer, &End, sizeof (EFI_IFR_END));
+ Data->Offset += sizeof (EFI_IFR_END);
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+CreateDefaultOpCode (
+ IN EFI_IFR_TYPE_VALUE *Value,
+ IN UINT8 Type,
+ IN OUT EFI_HII_UPDATE_DATA *Data
+ )
+{
+ EFI_IFR_DEFAULT Default;
+ UINT8 *LocalBuffer;
+
+ ASSERT (Data != NULL && Data->Data != NULL);
+
+ if ((Value == NULL) || !IsValidValueType (Type)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (Data->Offset + sizeof (EFI_IFR_DEFAULT) > Data->BufferSize) {
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ Default.Header.OpCode = EFI_IFR_DEFAULT_OP;
+ Default.Header.Length = sizeof (EFI_IFR_DEFAULT);
+ Default.Header.Scope = 0;
+ Default.Type = Type;
+ Default.DefaultId = EFI_HII_DEFAULT_CLASS_STANDARD;
+ EfiCopyMem (&Default.Value, Value, sizeof(EFI_IFR_TYPE_VALUE));
+
+ LocalBuffer = (UINT8 *) Data->Data + Data->Offset;
+ EfiCopyMem (LocalBuffer, &Default, sizeof (EFI_IFR_DEFAULT));
+ Data->Offset += sizeof (EFI_IFR_DEFAULT);
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+CreateActionOpCode (
+ IN EFI_QUESTION_ID QuestionId,
+ IN EFI_STRING_ID Prompt,
+ IN EFI_STRING_ID Help,
+ IN UINT8 QuestionFlags,
+ IN EFI_STRING_ID QuestionConfig,
+ IN OUT EFI_HII_UPDATE_DATA *Data
+ )
+{
+ EFI_IFR_ACTION Action;
+ UINT8 *LocalBuffer;
+
+ ASSERT (Data != NULL && Data->Data != NULL);
+
+ if (!IsValidQuestionFlags (QuestionFlags)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (Data->Offset + sizeof (EFI_IFR_ACTION) > Data->BufferSize) {
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ Action.Header.OpCode = EFI_IFR_ACTION_OP;
+ Action.Header.Length = sizeof (EFI_IFR_ACTION);
+ Action.Header.Scope = 0;
+ Action.Question.QuestionId = QuestionId;
+ Action.Question.Header.Prompt = Prompt;
+ Action.Question.Header.Help = Help;
+ Action.Question.VarStoreId = INVALID_VARSTORE_ID;
+ Action.Question.Flags = QuestionFlags;
+ Action.QuestionConfig = QuestionConfig;
+
+ LocalBuffer = (UINT8 *) Data->Data + Data->Offset;
+ EfiCopyMem (LocalBuffer, &Action, sizeof (EFI_IFR_ACTION));
+ Data->Offset += sizeof (EFI_IFR_ACTION);
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+CreateSubTitleOpCode (
+ IN EFI_STRING_ID Prompt,
+ IN EFI_STRING_ID Help,
+ IN UINT8 Flags,
+ IN UINT8 Scope,
+ IN OUT EFI_HII_UPDATE_DATA *Data
+ )
+{
+ EFI_IFR_SUBTITLE Subtitle;
+ UINT8 *LocalBuffer;
+
+ ASSERT (Data != NULL && Data->Data != NULL);
+
+ if (Data->Offset + sizeof (EFI_IFR_SUBTITLE) > Data->BufferSize) {
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ Subtitle.Header.OpCode = EFI_IFR_SUBTITLE_OP;
+ Subtitle.Header.Length = sizeof (EFI_IFR_SUBTITLE);
+ Subtitle.Header.Scope = Scope;
+ Subtitle.Statement.Prompt = Prompt;
+ Subtitle.Statement.Help = Help;
+ Subtitle.Flags = Flags;
+
+ LocalBuffer = (UINT8 *) Data->Data + Data->Offset;
+ EfiCopyMem (LocalBuffer, &Subtitle, sizeof (EFI_IFR_SUBTITLE));
+ Data->Offset += sizeof (EFI_IFR_SUBTITLE);
+
+ return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+CreateTextOpCode (
+ IN EFI_STRING_ID Prompt,
+ IN EFI_STRING_ID Help,
+ IN EFI_STRING_ID TextTwo,
+ IN OUT EFI_HII_UPDATE_DATA *Data
+ )
+{
+ EFI_IFR_TEXT Text;
+ UINT8 *LocalBuffer;
+
+ ASSERT (Data != NULL && Data->Data != NULL);
+
+ if (Data->Offset + sizeof (EFI_IFR_TEXT) > Data->BufferSize) {
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ Text.Header.OpCode = EFI_IFR_TEXT_OP;
+ Text.Header.Length = sizeof (EFI_IFR_TEXT);
+ Text.Header.Scope = 0;
+ Text.Statement.Prompt = Prompt;
+ Text.Statement.Help = Help;
+ Text.TextTwo = TextTwo;
+
+ LocalBuffer = (UINT8 *) Data->Data + Data->Offset;
+ EfiCopyMem (LocalBuffer, &Text, sizeof (EFI_IFR_TEXT));
+ Data->Offset += sizeof (EFI_IFR_TEXT);
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+CreateGotoOpCode (
+ IN EFI_FORM_ID FormId,
+ IN EFI_STRING_ID Prompt,
+ IN EFI_STRING_ID Help,
+ IN UINT8 QuestionFlags,
+ IN EFI_QUESTION_ID QuestionId,
+ IN OUT EFI_HII_UPDATE_DATA *Data
+ )
+{
+ EFI_IFR_REF Goto;
+ UINT8 *LocalBuffer;
+
+ ASSERT (Data != NULL && Data->Data != NULL);
+
+ if (!IsValidQuestionFlags (QuestionFlags)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (Data->Offset + sizeof (EFI_IFR_REF) > Data->BufferSize) {
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ Goto.Header.OpCode = EFI_IFR_REF_OP;
+ Goto.Header.Length = sizeof (EFI_IFR_REF);
+ Goto.Header.Scope = 0;
+ Goto.Question.Header.Prompt = Prompt;
+ Goto.Question.Header.Help = Help;
+ Goto.Question.VarStoreId = INVALID_VARSTORE_ID;
+ Goto.Question.QuestionId = QuestionId;
+ Goto.Question.Flags = QuestionFlags;
+ Goto.FormId = FormId;
+
+ LocalBuffer = (UINT8 *) Data->Data + Data->Offset;
+ EfiCopyMem (LocalBuffer, &Goto, sizeof (EFI_IFR_REF));
+ Data->Offset += sizeof (EFI_IFR_REF);
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+CreateOneOfOptionOpCode (
+ IN UINTN OptionCount,
+ IN IFR_OPTION *OptionsList,
+ IN UINT8 Type,
+ IN OUT EFI_HII_UPDATE_DATA *Data
+ )
+{
+ UINTN Index;
+ UINT8 *LocalBuffer;
+ EFI_IFR_ONE_OF_OPTION OneOfOption;
+
+ ASSERT (Data != NULL && Data->Data != NULL);
+
+ if ((OptionCount != 0) && (OptionsList == NULL)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (Data->Offset + OptionCount * sizeof (EFI_IFR_ONE_OF_OPTION) > Data->BufferSize) {
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ for (Index = 0; Index < OptionCount; Index++) {
+ OneOfOption.Header.OpCode = EFI_IFR_ONE_OF_OPTION_OP;
+ OneOfOption.Header.Length = sizeof (EFI_IFR_ONE_OF_OPTION);
+ OneOfOption.Header.Scope = 0;
+
+ OneOfOption.Option = OptionsList[Index].StringToken;
+ OneOfOption.Value = OptionsList[Index].Value;
+ OneOfOption.Flags = OptionsList[Index].Flags & (EFI_IFR_OPTION_DEFAULT | EFI_IFR_OPTION_DEFAULT_MFG);
+ OneOfOption.Type = Type;
+
+ LocalBuffer = (UINT8 *) Data->Data + Data->Offset;
+ EfiCopyMem (LocalBuffer, &OneOfOption, sizeof (EFI_IFR_ONE_OF_OPTION));
+ Data->Offset += sizeof (EFI_IFR_ONE_OF_OPTION);
+ }
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+CreateOneOfOpCode (
+ IN EFI_QUESTION_ID QuestionId,
+ IN EFI_VARSTORE_ID VarStoreId,
+ IN UINT16 VarOffset,
+ IN EFI_STRING_ID Prompt,
+ IN EFI_STRING_ID Help,
+ IN UINT8 QuestionFlags,
+ IN UINT8 OneOfFlags,
+ IN IFR_OPTION *OptionsList,
+ IN UINTN OptionCount,
+ IN OUT EFI_HII_UPDATE_DATA *Data
+ )
+{
+ UINTN Length;
+ EFI_IFR_ONE_OF OneOf;
+ UINT8 *LocalBuffer;
+
+ ASSERT (Data != NULL && Data->Data != NULL);
+
+ if (!IsValidNumricFlags (OneOfFlags) ||
+ !IsValidQuestionFlags (QuestionFlags) ||
+ ((OptionCount != 0) && (OptionsList == NULL))) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Length = sizeof (EFI_IFR_ONE_OF) + OptionCount * sizeof (EFI_IFR_ONE_OF_OPTION) + sizeof (EFI_IFR_END);
+ if (Data->Offset + Length > Data->BufferSize) {
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ OneOf.Header.OpCode = EFI_IFR_ONE_OF_OP;
+ OneOf.Header.Length = sizeof (EFI_IFR_ONE_OF);
+ OneOf.Header.Scope = 1;
+ OneOf.Question.Header.Prompt = Prompt;
+ OneOf.Question.Header.Help = Help;
+ OneOf.Question.QuestionId = QuestionId;
+ OneOf.Question.VarStoreId = VarStoreId;
+ OneOf.Question.VarStoreInfo.VarOffset = VarOffset;
+ OneOf.Question.Flags = QuestionFlags;
+ OneOf.Flags = OneOfFlags;
+ EfiZeroMem ((VOID *) &OneOf.data, sizeof (MINMAXSTEP_DATA));
+
+ LocalBuffer = (UINT8 *) Data->Data + Data->Offset;
+ EfiCopyMem (LocalBuffer, &OneOf, sizeof (EFI_IFR_ONE_OF));
+ Data->Offset += sizeof (EFI_IFR_ONE_OF);
+
+ CreateOneOfOptionOpCode (OptionCount, OptionsList, (OneOfFlags & EFI_IFR_NUMERIC_SIZE), Data);
+
+ CreateEndOpCode (Data);
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+CreateOrderedListOpCode (
+ IN EFI_QUESTION_ID QuestionId,
+ IN EFI_VARSTORE_ID VarStoreId,
+ IN UINT16 VarOffset,
+ IN EFI_STRING_ID Prompt,
+ IN EFI_STRING_ID Help,
+ IN UINT8 QuestionFlags,
+ IN UINT8 OrderedListFlags,
+ IN UINT8 DataType,
+ IN UINT8 MaxContainers,
+ IN IFR_OPTION *OptionsList,
+ IN UINTN OptionCount,
+ IN OUT EFI_HII_UPDATE_DATA *Data
+ )
+{
+ UINTN Length;
+ EFI_IFR_ORDERED_LIST OrderedList;
+ UINT8 *LocalBuffer;
+
+ ASSERT (Data != NULL && Data->Data != NULL);
+
+ if (!IsValidQuestionFlags (QuestionFlags) ||
+ ((OptionCount != 0) && (OptionsList == NULL))) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if ((OrderedListFlags & (~(EFI_IFR_UNIQUE_SET | EFI_IFR_NO_EMPTY_SET))) != 0) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Length = sizeof (EFI_IFR_ORDERED_LIST) + OptionCount * sizeof (EFI_IFR_ONE_OF_OPTION) + sizeof (EFI_IFR_END);
+ if (Data->Offset + Length > Data->BufferSize) {
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ OrderedList.Header.OpCode = EFI_IFR_ORDERED_LIST_OP;
+ OrderedList.Header.Length = sizeof (EFI_IFR_ORDERED_LIST);
+ OrderedList.Header.Scope = 1;
+ OrderedList.Question.Header.Prompt = Prompt;
+ OrderedList.Question.Header.Help = Help;
+ OrderedList.Question.QuestionId = QuestionId;
+ OrderedList.Question.VarStoreId = VarStoreId;
+ OrderedList.Question.VarStoreInfo.VarOffset = VarOffset;
+ OrderedList.Question.Flags = QuestionFlags;
+ OrderedList.MaxContainers = MaxContainers;
+ OrderedList.Flags = OrderedListFlags;
+
+ LocalBuffer = (UINT8 *) Data->Data + Data->Offset;
+ EfiCopyMem (LocalBuffer, &OrderedList, sizeof (EFI_IFR_ORDERED_LIST));
+ Data->Offset += sizeof (EFI_IFR_ORDERED_LIST);
+
+ CreateOneOfOptionOpCode (OptionCount, OptionsList, DataType, Data);
+
+ CreateEndOpCode (Data);
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+CreateCheckBoxOpCode (
+ IN EFI_QUESTION_ID QuestionId,
+ IN EFI_VARSTORE_ID VarStoreId,
+ IN UINT16 VarOffset,
+ IN EFI_STRING_ID Prompt,
+ IN EFI_STRING_ID Help,
+ IN UINT8 QuestionFlags,
+ IN UINT8 CheckBoxFlags,
+ IN OUT EFI_HII_UPDATE_DATA *Data
+ )
+{
+ EFI_IFR_CHECKBOX CheckBox;
+ UINT8 *LocalBuffer;
+
+ ASSERT (Data != NULL && Data->Data != NULL);
+
+ if (!IsValidQuestionFlags (QuestionFlags) || !IsValidCheckboxFlags (CheckBoxFlags)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (Data->Offset + sizeof (EFI_IFR_CHECKBOX) > Data->BufferSize) {
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ CheckBox.Header.OpCode = EFI_IFR_CHECKBOX_OP;
+ CheckBox.Header.Length = sizeof (EFI_IFR_CHECKBOX);
+ CheckBox.Header.Scope = 0;
+ CheckBox.Question.QuestionId = QuestionId;
+ CheckBox.Question.VarStoreId = VarStoreId;
+ CheckBox.Question.VarStoreInfo.VarOffset = VarOffset;
+ CheckBox.Question.Header.Prompt = Prompt;
+ CheckBox.Question.Header.Help = Help;
+ CheckBox.Question.Flags = QuestionFlags;
+ CheckBox.Flags = CheckBoxFlags;
+
+ LocalBuffer = (UINT8 *) Data->Data + Data->Offset;
+ EfiCopyMem (LocalBuffer, &CheckBox, sizeof (EFI_IFR_CHECKBOX));
+ Data->Offset += sizeof (EFI_IFR_CHECKBOX);
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+CreateNumericOpCode (
+ IN EFI_QUESTION_ID QuestionId,
+ IN EFI_VARSTORE_ID VarStoreId,
+ IN UINT16 VarOffset,
+ IN EFI_STRING_ID Prompt,
+ IN EFI_STRING_ID Help,
+ IN UINT8 QuestionFlags,
+ IN UINT8 NumericFlags,
+ IN UINT64 Minimum,
+ IN UINT64 Maximum,
+ IN UINT64 Step,
+ IN UINT64 Default,
+ IN OUT EFI_HII_UPDATE_DATA *Data
+ )
+{
+ UINTN Length;
+ EFI_STATUS Status;
+ EFI_IFR_NUMERIC Numeric;
+ MINMAXSTEP_DATA MinMaxStep;
+ EFI_IFR_TYPE_VALUE DefaultValue;
+ UINT8 *LocalBuffer;
+
+ ASSERT (Data != NULL && Data->Data != NULL);
+
+ if (!IsValidQuestionFlags (QuestionFlags) || !IsValidNumricFlags (NumericFlags)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Length = sizeof (EFI_IFR_NUMERIC) + sizeof (EFI_IFR_DEFAULT) + sizeof (EFI_IFR_END);
+ if (Data->Offset + sizeof (EFI_IFR_CHECKBOX) > Data->BufferSize) {
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ Numeric.Header.OpCode = EFI_IFR_NUMERIC_OP;
+ Numeric.Header.Length = sizeof (EFI_IFR_NUMERIC);
+ Numeric.Header.Scope = 1;
+ Numeric.Question.QuestionId = QuestionId;
+ Numeric.Question.VarStoreId = VarStoreId;
+ Numeric.Question.VarStoreInfo.VarOffset = VarOffset;
+ Numeric.Question.Header.Prompt = Prompt;
+ Numeric.Question.Header.Help = Help;
+ Numeric.Question.Flags = QuestionFlags;
+ Numeric.Flags = NumericFlags;
+
+ switch (NumericFlags & EFI_IFR_NUMERIC_SIZE) {
+ case EFI_IFR_NUMERIC_SIZE_1:
+ MinMaxStep.u8.MinValue = (UINT8) Minimum;
+ MinMaxStep.u8.MaxValue = (UINT8) Maximum;
+ MinMaxStep.u8.Step = (UINT8) Step;
+ break;
+
+ case EFI_IFR_NUMERIC_SIZE_2:
+ MinMaxStep.u16.MinValue = (UINT16) Minimum;
+ MinMaxStep.u16.MaxValue = (UINT16) Maximum;
+ MinMaxStep.u16.Step = (UINT16) Step;
+ break;
+
+ case EFI_IFR_NUMERIC_SIZE_4:
+ MinMaxStep.u32.MinValue = (UINT32) Minimum;
+ MinMaxStep.u32.MaxValue = (UINT32) Maximum;
+ MinMaxStep.u32.Step = (UINT32) Step;
+ break;
+
+ case EFI_IFR_NUMERIC_SIZE_8:
+ MinMaxStep.u64.MinValue = Minimum;
+ MinMaxStep.u64.MaxValue = Maximum;
+ MinMaxStep.u64.Step = Step;
+ break;
+ }
+
+ EfiCopyMem (&Numeric.data, &MinMaxStep, sizeof (MINMAXSTEP_DATA));
+
+ LocalBuffer = (UINT8 *) Data->Data + Data->Offset;
+ EfiCopyMem (LocalBuffer, &Numeric, sizeof (EFI_IFR_NUMERIC));
+ Data->Offset += sizeof (EFI_IFR_NUMERIC);
+
+ DefaultValue.u64 = Default;
+ Status = CreateDefaultOpCode (&DefaultValue, (NumericFlags & EFI_IFR_NUMERIC_SIZE), Data);
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
+
+ CreateEndOpCode (Data);
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+CreateStringOpCode (
+ IN EFI_QUESTION_ID QuestionId,
+ IN EFI_VARSTORE_ID VarStoreId,
+ IN UINT16 VarOffset,
+ IN EFI_STRING_ID Prompt,
+ IN EFI_STRING_ID Help,
+ IN UINT8 QuestionFlags,
+ IN UINT8 StringFlags,
+ IN UINT8 MinSize,
+ IN UINT8 MaxSize,
+ IN OUT EFI_HII_UPDATE_DATA *Data
+ )
+{
+ EFI_IFR_STRING String;
+ UINT8 *LocalBuffer;
+
+ ASSERT (Data != NULL && Data->Data != NULL);
+
+ if (!IsValidQuestionFlags (QuestionFlags) || (StringFlags & (~EFI_IFR_STRING_MULTI_LINE))) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (Data->Offset + sizeof (EFI_IFR_STRING) > Data->BufferSize) {
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ String.Header.OpCode = EFI_IFR_STRING_OP;
+ String.Header.Length = sizeof (EFI_IFR_STRING);
+ String.Header.Scope = 0;
+ String.Question.Header.Prompt = Prompt;
+ String.Question.Header.Help = Help;
+ String.Question.QuestionId = QuestionId;
+ String.Question.VarStoreId = VarStoreId;
+ String.Question.VarStoreInfo.VarOffset = VarOffset;
+ String.Question.Flags = QuestionFlags;
+ String.MinSize = MinSize;
+ String.MaxSize = MaxSize;
+ String.Flags = StringFlags;
+
+ LocalBuffer = (UINT8 *) Data->Data + Data->Offset;
+ EfiCopyMem (LocalBuffer, &String, sizeof (EFI_IFR_STRING));
+ Data->Offset += sizeof (EFI_IFR_STRING);
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+CreateBannerOpCode (
+ IN EFI_STRING_ID Title,
+ IN UINT16 LineNumber,
+ IN UINT8 Alignment,
+ IN OUT EFI_HII_UPDATE_DATA *Data
+ )
+{
+ EFI_IFR_GUID_BANNER Banner;
+ UINT8 *LocalBuffer;
+
+ ASSERT (Data != NULL && Data->Data != NULL);
+
+ if (Data->Offset + sizeof (EFI_IFR_GUID_BANNER) > Data->BufferSize) {
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ Banner.Header.OpCode = EFI_IFR_GUID_OP;
+ Banner.Header.Length = sizeof (EFI_IFR_GUID_BANNER);
+ Banner.Header.Scope = 0;
+ EfiCopyMem (&Banner.Guid, &mIfrVendorGuid, sizeof (EFI_IFR_GUID));
+ Banner.ExtendOpCode = EFI_IFR_EXTEND_OP_BANNER;
+ Banner.Title = Title;
+ Banner.LineNumber = LineNumber;
+ Banner.Alignment = Alignment;
+
+ LocalBuffer = (UINT8 *) Data->Data + Data->Offset;
+ EfiCopyMem (LocalBuffer, &Banner, sizeof (EFI_IFR_GUID_BANNER));
+ Data->Offset += sizeof (EFI_IFR_GUID_BANNER);
+
+ return EFI_SUCCESS;
+}
diff --git a/EDK/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrString.c b/EDK/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrString.c
new file mode 100644
index 0000000..5341941
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/UefiEfiIfrSupportLib/UefiIfrString.c
@@ -0,0 +1,729 @@
+/*++
+
+Copyright (c) 2007 - 2011, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ UefiIfrString.c
+
+Abstract:
+
+ Common Library Routines to assist to handle String and Language.
+
+--*/
+
+#include "UefiIfrLibrary.h"
+
+//
+// Lookup table of ISO639-2 3 character language codes to ISO 639-1 2 character language codes
+// Each entry is 5 CHAR8 values long. The first 3 CHAR8 values are the ISO 639-2 code.
+// The last 2 CHAR8 values are the ISO 639-1 code.
+//
+CHAR8 Iso639ToRfc3066ConversionTable[] =
+"\
+aaraa\
+abkab\
+afraf\
+amham\
+araar\
+asmas\
+aymay\
+azeaz\
+bakba\
+belbe\
+benbn\
+bihbh\
+bisbi\
+bodbo\
+brebr\
+bulbg\
+catca\
+cescs\
+corkw\
+cosco\
+cymcy\
+danda\
+deude\
+dzodz\
+ellel\
+engen\
+epoeo\
+estet\
+euseu\
+faofo\
+fasfa\
+fijfj\
+finfi\
+frafr\
+fryfy\
+gaiga\
+gdhgd\
+glggl\
+grngn\
+gujgu\
+hauha\
+hebhe\
+hinhi\
+hrvhr\
+hunhu\
+hyehy\
+ikuiu\
+ileie\
+inaia\
+indid\
+ipkik\
+islis\
+itait\
+jawjw\
+jpnja\
+kalkl\
+kankn\
+kasks\
+katka\
+kazkk\
+khmkm\
+kinrw\
+kirky\
+korko\
+kurku\
+laolo\
+latla\
+lavlv\
+linln\
+litlt\
+ltzlb\
+malml\
+marmr\
+mkdmk\
+mlgmg\
+mltmt\
+molmo\
+monmn\
+mrimi\
+msams\
+myamy\
+nauna\
+nepne\
+nldnl\
+norno\
+ocioc\
+ormom\
+panpa\
+polpl\
+porpt\
+pusps\
+quequ\
+rohrm\
+ronro\
+runrn\
+rusru\
+sagsg\
+sansa\
+sinsi\
+slksk\
+slvsl\
+smise\
+smosm\
+snasn\
+sndsd\
+somso\
+sotst\
+spaes\
+sqisq\
+srpsr\
+sswss\
+sunsu\
+swasw\
+swesv\
+tamta\
+tattt\
+telte\
+tgktg\
+tgltl\
+thath\
+tsnts\
+tuktk\
+twitw\
+uigug\
+ukruk\
+urdur\
+uzbuz\
+vievi\
+volvo\
+wolwo\
+xhoxh\
+yidyi\
+zhaza\
+zhozh\
+zulzu\
+";
+
+EFI_STATUS
+ConvertRfc3066LanguageToIso639Language (
+ CHAR8 *LanguageRfc3066,
+ CHAR8 *LanguageIso639
+ )
+/*++
+
+Routine Description:
+ Convert language code from RFC3066 to ISO639-2.
+
+Arguments:
+ LanguageRfc3066 - RFC3066 language code.
+ LanguageIso639 - ISO639-2 language code.
+
+Returns:
+ EFI_SUCCESS - Language code converted.
+ EFI_NOT_FOUND - Language code not found.
+
+--*/
+{
+ UINTN Index;
+
+ if ((LanguageRfc3066[2] != '-') && (LanguageRfc3066[2] != 0)) {
+ EfiCopyMem (LanguageIso639, LanguageRfc3066, 3);
+ return EFI_SUCCESS;
+ }
+
+ for (Index = 0; Iso639ToRfc3066ConversionTable[Index] != 0; Index += 5) {
+ if (EfiCompareMem (LanguageRfc3066, &Iso639ToRfc3066ConversionTable[Index + 3], 2) == 0) {
+ EfiCopyMem (LanguageIso639, &Iso639ToRfc3066ConversionTable[Index], 3);
+ return EFI_SUCCESS;
+ }
+ }
+
+ return EFI_NOT_FOUND;
+}
+
+CHAR8 *
+Rfc3066ToIso639 (
+ CHAR8 *SupportedLanguages
+ )
+/*++
+
+Routine Description:
+ Convert language code list from RFC3066 to ISO639-2, e.g. "en-US;fr-FR" will
+ be converted to "engfra".
+
+Arguments:
+ SupportedLanguages - The RFC3066 language list.
+
+Returns:
+ The ISO639-2 language list.
+
+--*/
+{
+ CHAR8 *Languages;
+ CHAR8 *ReturnValue;
+ CHAR8 *LangCodes;
+ CHAR8 LangRfc3066[RFC_3066_ENTRY_SIZE];
+ CHAR8 LangIso639[ISO_639_2_ENTRY_SIZE];
+ EFI_STATUS Status;
+
+ ReturnValue = EfiLibAllocateZeroPool (EfiAsciiStrSize (SupportedLanguages));
+ if (ReturnValue == NULL) {
+ return ReturnValue;
+ }
+
+ Languages = ReturnValue;
+ LangCodes = SupportedLanguages;
+ while (*LangCodes != 0) {
+ GetNextLanguage (&LangCodes, LangRfc3066);
+
+ Status = ConvertRfc3066LanguageToIso639Language (LangRfc3066, LangIso639);
+ if (!EFI_ERROR (Status)) {
+ EfiCopyMem (Languages, LangIso639, 3);
+ Languages = Languages + 3;
+ }
+ }
+
+ return ReturnValue;
+}
+
+EFI_STATUS
+GetCurrentLanguage (
+ OUT CHAR8 *Lang
+ )
+/*++
+
+Routine Description:
+ Determine what is the current language setting
+
+Arguments:
+ Lang - Pointer of system language
+
+Returns:
+ Status code
+
+--*/
+{
+ EFI_STATUS Status;
+ UINTN Size;
+
+ //
+ // Get current language setting
+ //
+ Size = RFC_3066_ENTRY_SIZE;
+ Status = gRT->GetVariable (
+ L"PlatformLang",
+ &gEfiGlobalVariableGuid,
+ NULL,
+ &Size,
+ Lang
+ );
+
+ if (EFI_ERROR (Status)) {
+ EfiAsciiStrCpy (Lang, "en-US");
+ }
+
+ return Status;
+}
+
+VOID
+GetNextLanguage (
+ IN OUT CHAR8 **LangCode,
+ OUT CHAR8 *Lang
+ )
+/*++
+
+Routine Description:
+ Get next language from language code list (with separator ';').
+
+Arguments:
+ LangCode - On input: point to first language in the list. On output: point to
+ next language in the list, or NULL if no more language in the list.
+ Lang - The first language in the list.
+
+Returns:
+ None.
+
+--*/
+{
+ UINTN Index;
+ CHAR8 *StringPtr;
+
+ if (LangCode == NULL || *LangCode == NULL) {
+ *Lang = 0;
+ return;
+ }
+
+ Index = 0;
+ StringPtr = *LangCode;
+ while (StringPtr[Index] != 0 && StringPtr[Index] != ';') {
+ Index++;
+ }
+
+ EfiCopyMem (Lang, StringPtr, Index);
+ Lang[Index] = 0;
+
+ if (StringPtr[Index] == ';') {
+ Index++;
+ }
+ *LangCode = StringPtr + Index;
+}
+
+CHAR8 *
+GetSupportedLanguages (
+ IN EFI_HII_HANDLE HiiHandle
+ )
+/*++
+
+Routine Description:
+ This function returns the list of supported languages, in the format specified
+ in UEFI specification Appendix M.
+
+Arguments:
+ HiiHandle - The HII package list handle.
+
+Returns:
+ The supported languages.
+
+--*/
+{
+ EFI_STATUS Status;
+ UINTN BufferSize;
+ CHAR8 *LanguageString;
+
+ LocateHiiProtocols ();
+
+ //
+ // Collect current supported Languages for given HII handle
+ //
+ BufferSize = 0x1000;
+ LanguageString = EfiLibAllocatePool (BufferSize);
+ Status = gIfrLibHiiString->GetLanguages (gIfrLibHiiString, HiiHandle, LanguageString, &BufferSize);
+ if (Status == EFI_BUFFER_TOO_SMALL) {
+ gBS->FreePool (LanguageString);
+ LanguageString = EfiLibAllocatePool (BufferSize);
+ Status = gIfrLibHiiString->GetLanguages (gIfrLibHiiString, HiiHandle, LanguageString, &BufferSize);
+ }
+
+ if (EFI_ERROR (Status)) {
+ LanguageString = NULL;
+ }
+
+ return LanguageString;
+}
+
+UINT16
+GetSupportedLanguageNumber (
+ IN EFI_HII_HANDLE HiiHandle
+ )
+/*++
+
+Routine Description:
+ This function returns the number of supported languages
+
+Arguments:
+ HiiHandle - The HII package list handle.
+
+Returns:
+ The number of supported languages.
+
+--*/
+{
+ CHAR8 *Languages;
+ CHAR8 *LanguageString;
+ UINT16 LangNumber;
+ CHAR8 Lang[RFC_3066_ENTRY_SIZE];
+
+ Languages = GetSupportedLanguages (HiiHandle);
+ if (Languages == NULL) {
+ return 0;
+ }
+
+ LangNumber = 0;
+ LanguageString = Languages;
+ while (*LanguageString != 0) {
+ GetNextLanguage (&LanguageString, Lang);
+ LangNumber++;
+ }
+ gBS->FreePool (Languages);
+
+ return LangNumber;
+}
+
+EFI_STATUS
+GetStringFromHandle (
+ IN EFI_HII_HANDLE HiiHandle,
+ IN EFI_STRING_ID StringId,
+ OUT EFI_STRING *String
+ )
+/*++
+
+Routine Description:
+ Get string specified by StringId form the HiiHandle.
+
+Arguments:
+ HiiHandle - The HII handle of package list.
+ StringId - The String ID.
+ String - The output string.
+
+Returns:
+ EFI_NOT_FOUND - String is not found.
+ EFI_SUCCESS - Operation is successful.
+ EFI_OUT_OF_RESOURCES - There is not enought memory in the system.
+ EFI_INVALID_PARAMETER - The String is NULL.
+
+--*/
+{
+ EFI_STATUS Status;
+ UINTN StringSize;
+
+ if (String == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ StringSize = IFR_LIB_DEFAULT_STRING_SIZE;
+ *String = EfiLibAllocateZeroPool (StringSize);
+ if (*String == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ Status = IfrLibGetString (HiiHandle, StringId, *String, &StringSize);
+ if (Status == EFI_BUFFER_TOO_SMALL) {
+ gBS->FreePool (*String);
+ *String = EfiLibAllocateZeroPool (StringSize);
+ if (*String == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ Status = IfrLibGetString (HiiHandle, StringId, *String, &StringSize);
+ }
+
+ return Status;
+}
+
+EFI_STATUS
+GetStringFromToken (
+ IN EFI_GUID *ProducerGuid,
+ IN EFI_STRING_ID StringId,
+ OUT EFI_STRING *String
+ )
+/*++
+
+Routine Description:
+ Get the string given the StringId and String package Producer's Guid.
+
+Arguments:
+ ProducerGuid - The Guid of String package list.
+ StringId - The String ID.
+ String - The output string.
+
+Returns:
+ EFI_NOT_FOUND - String is not found.
+ EFI_SUCCESS - Operation is successful.
+ EFI_OUT_OF_RESOURCES - There is not enought memory in the system.
+
+--*/
+{
+ EFI_STATUS Status;
+ UINTN Index;
+ UINTN HandleBufferLen;
+ EFI_HII_HANDLE *HiiHandleBuffer;
+ EFI_GUID Guid;
+
+ Status = GetHiiHandles (&HandleBufferLen, &HiiHandleBuffer);
+ if (HiiHandleBuffer == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
+ for (Index = 0; Index < (HandleBufferLen / sizeof (EFI_HII_HANDLE)); Index++) {
+ Status = ExtractGuidFromHiiHandle (HiiHandleBuffer[Index], &Guid);
+ if (EFI_ERROR(Status)) {
+ return Status;
+ }
+ if (EfiCompareGuid (&Guid, ProducerGuid) == TRUE) {
+ break;
+ }
+ }
+
+ if (Index >= (HandleBufferLen / sizeof (EFI_HII_HANDLE))) {
+ Status = EFI_NOT_FOUND;
+ goto Out;
+ }
+
+ Status = GetStringFromHandle (HiiHandleBuffer[Index], StringId, String);
+
+Out:
+ if (HiiHandleBuffer != NULL) {
+ gBS->FreePool (HiiHandleBuffer);
+ }
+ return Status;
+}
+
+EFI_STATUS
+IfrLibNewString (
+ IN EFI_HII_HANDLE PackageList,
+ OUT EFI_STRING_ID *StringId,
+ IN CONST EFI_STRING String
+ )
+/*++
+
+ Routine Description:
+ This function adds the string into String Package of each language.
+
+ Arguments:
+ PackageList - Handle of the package list where this string will be added.
+ StringId - On return, contains the new strings id, which is unique within PackageList.
+ String - Points to the new null-terminated string.
+
+ Returns:
+ EFI_SUCCESS - The new string was added successfully.
+ EFI_NOT_FOUND - The specified PackageList could not be found in database.
+ EFI_OUT_OF_RESOURCES - Could not add the string due to lack of resources.
+ EFI_INVALID_PARAMETER - String is NULL or StringId is NULL is NULL.
+
+--*/
+{
+ EFI_STATUS Status;
+ CHAR8 *Languages;
+ CHAR8 *LangStrings;
+ CHAR8 Lang[RFC_3066_ENTRY_SIZE];
+
+ Status = EFI_SUCCESS;
+
+ LocateHiiProtocols ();
+
+ Languages = GetSupportedLanguages (PackageList);
+ if (Languages == NULL) {
+ return EFI_NOT_FOUND;
+ }
+
+
+ if (StringId == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+ *StringId = 0;
+
+ LangStrings = Languages;
+ while (*LangStrings != 0) {
+ GetNextLanguage (&LangStrings, Lang);
+
+ if (*StringId == 0) {
+ Status = gIfrLibHiiString->NewString (
+ gIfrLibHiiString,
+ PackageList,
+ StringId,
+ Lang,
+ NULL,
+ String,
+ NULL
+ );
+ } else {
+ Status = gIfrLibHiiString->SetString (
+ gIfrLibHiiString,
+ PackageList,
+ *StringId,
+ Lang,
+ String,
+ NULL
+ );
+ }
+
+ if (EFI_ERROR (Status)) {
+ break;
+ }
+ }
+
+ gBS->FreePool (Languages);
+
+ return Status;
+}
+
+EFI_STATUS
+IfrLibGetString (
+ IN EFI_HII_HANDLE PackageList,
+ IN EFI_STRING_ID StringId,
+ OUT EFI_STRING String,
+ IN OUT UINTN *StringSize
+ )
+/*++
+
+ Routine Description:
+ This function try to retrieve string from String package of current language.
+ If fail, it try to retrieve string from String package of first language it support.
+
+ Arguments:
+ PackageList - The package list in the HII database to search for the specified string.
+ StringId - The string's id, which is unique within PackageList.
+ String - Points to the new null-terminated string.
+ StringSize - On entry, points to the size of the buffer pointed to by String, in bytes. On return,
+ points to the length of the string, in bytes.
+
+ Returns:
+ EFI_SUCCESS - The string was returned successfully.
+ EFI_NOT_FOUND - The string specified by StringId is not available.
+ EFI_BUFFER_TOO_SMALL - The buffer specified by StringLength is too small to hold the string.
+ EFI_INVALID_PARAMETER - The String or StringSize was NULL.
+
+--*/
+{
+ EFI_STATUS Status;
+ CHAR8 *Languages;
+ CHAR8 *LangStrings;
+ CHAR8 Lang[RFC_3066_ENTRY_SIZE];
+ CHAR8 CurrentLang[RFC_3066_ENTRY_SIZE];
+
+ LocateHiiProtocols ();
+
+ GetCurrentLanguage (CurrentLang);
+
+ Status = gIfrLibHiiString->GetString (
+ gIfrLibHiiString,
+ CurrentLang,
+ PackageList,
+ StringId,
+ String,
+ StringSize,
+ NULL
+ );
+
+ if (EFI_ERROR (Status) && (Status != EFI_BUFFER_TOO_SMALL)) {
+ Languages = GetSupportedLanguages (PackageList);
+ LangStrings = Languages;
+ GetNextLanguage (&LangStrings, Lang);
+ gBS->FreePool (Languages);
+
+ Status = gIfrLibHiiString->GetString (
+ gIfrLibHiiString,
+ Lang,
+ PackageList,
+ StringId,
+ String,
+ StringSize,
+ NULL
+ );
+ }
+
+ return Status;
+}
+
+EFI_STATUS
+IfrLibSetString (
+ IN EFI_HII_HANDLE PackageList,
+ IN EFI_STRING_ID StringId,
+ IN CONST EFI_STRING String
+ )
+/*++
+
+ Routine Description:
+ This function updates the string in String package of each language.
+
+ Arguments:
+ PackageList - The package list containing the strings.
+ StringId - The string's id, which is unique within PackageList.
+ String - Points to the new null-terminated string.
+
+ Returns:
+ EFI_SUCCESS - The string was updated successfully.
+ EFI_NOT_FOUND - The string specified by StringId is not in the database.
+ EFI_INVALID_PARAMETER - The String was NULL.
+ EFI_OUT_OF_RESOURCES - The system is out of resources to accomplish the task.
+
+--*/
+{
+ EFI_STATUS Status;
+ CHAR8 *Languages;
+ CHAR8 *LangStrings;
+ CHAR8 Lang[RFC_3066_ENTRY_SIZE];
+
+ Status = EFI_SUCCESS;
+
+ LocateHiiProtocols ();
+
+ Languages = GetSupportedLanguages (PackageList);
+ if (Languages == NULL) {
+ return EFI_NOT_FOUND;
+ }
+
+ LangStrings = Languages;
+ while (*LangStrings != 0) {
+ GetNextLanguage (&LangStrings, Lang);
+
+ Status = gIfrLibHiiString->SetString (
+ gIfrLibHiiString,
+ PackageList,
+ StringId,
+ Lang,
+ String,
+ NULL
+ );
+ if (EFI_ERROR (Status)) {
+ break;
+ }
+ }
+
+ gBS->FreePool (Languages);
+
+ return Status;
+}
+
diff --git a/EDK/Foundation/Library/Dxe/hob/hob.c b/EDK/Foundation/Library/Dxe/hob/hob.c
new file mode 100644
index 0000000..c228c37
--- /dev/null
+++ b/EDK/Foundation/Library/Dxe/hob/hob.c
@@ -0,0 +1,542 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ hob.c
+
+Abstract:
+
+ Support for hob operation
+
+--*/
+
+#include "Tiano.h"
+#include "EfiDriverLib.h"
+#include "PeiHob.h"
+#include EFI_GUID_DEFINITION (IoBaseHob)
+#include EFI_GUID_DEFINITION (MemoryAllocationHob)
+
+VOID *
+GetHob (
+ IN UINT16 Type,
+ IN VOID *HobStart
+ )
+/*++
+
+Routine Description:
+
+ This function returns the first instance of a HOB type in a HOB list.
+
+Arguments:
+
+ Type The HOB type to return.
+ HobStart The first HOB in the HOB list.
+
+Returns:
+
+ HobStart There were no HOBs found with the requested type.
+ else Returns the first HOB with the matching type.
+
+--*/
+{
+ EFI_PEI_HOB_POINTERS Hob;
+
+ Hob.Raw = HobStart;
+ //
+ // Return input if not found
+ //
+ if (HobStart == NULL) {
+ return HobStart;
+ }
+
+ //
+ // Parse the HOB list, stop if end of list or matching type found.
+ //
+ while (!END_OF_HOB_LIST (Hob)) {
+
+ if (Hob.Header->HobType == Type) {
+ break;
+ }
+
+ Hob.Raw = GET_NEXT_HOB (Hob);
+ }
+
+ //
+ // Return input if not found
+ //
+ if (END_OF_HOB_LIST (Hob)) {
+ return HobStart;
+ }
+
+ return (VOID *) (Hob.Raw);
+}
+
+UINTN
+GetHobListSize (
+ IN VOID *HobStart
+ )
+/*++
+
+Routine Description:
+
+ Get size of hob list.
+
+Arguments:
+
+ HobStart - Start pointer of hob list
+
+Returns:
+
+ Size of hob list.
+
+--*/
+{
+ EFI_PEI_HOB_POINTERS Hob;
+ UINTN Size;
+
+ Hob.Raw = HobStart;
+ Size = 0;
+
+ while (Hob.Header->HobType != EFI_HOB_TYPE_END_OF_HOB_LIST) {
+ Size += Hob.Header->HobLength;
+ Hob.Raw += Hob.Header->HobLength;
+ }
+
+ Size += Hob.Header->HobLength;
+
+ return Size;
+}
+
+UINT32
+GetHobVersion (
+ IN VOID *HobStart
+ )
+/*++
+
+Routine Description:
+
+ Get hob version.
+
+Arguments:
+
+ HobStart - Start pointer of hob list
+
+Returns:
+
+ Hob version.
+
+--*/
+{
+ EFI_PEI_HOB_POINTERS Hob;
+
+ Hob.Raw = HobStart;
+ return Hob.HandoffInformationTable->Version;
+}
+
+EFI_STATUS
+GetHobBootMode (
+ IN VOID *HobStart,
+ OUT EFI_BOOT_MODE *BootMode
+ )
+/*++
+
+Routine Description:
+
+ Get current boot mode.
+
+Arguments:
+
+ HobStart - Start pointer of hob list
+
+ BootMode - Current boot mode recorded in PHIT hob
+
+Returns:
+
+ EFI_NOT_FOUND - Invalid hob header
+
+ EFI_SUCCESS - Boot mode found
+
+--*/
+{
+ EFI_PEI_HOB_POINTERS Hob;
+
+ Hob.Raw = HobStart;
+ if (Hob.Header->HobType != EFI_HOB_TYPE_HANDOFF) {
+ return EFI_NOT_FOUND;
+ }
+
+ *BootMode = Hob.HandoffInformationTable->BootMode;
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+GetCpuHobInfo (
+ IN VOID *HobStart,
+ OUT UINT8 *SizeOfMemorySpace,
+ OUT UINT8 *SizeOfIoSpace
+ )
+/*++
+
+Routine Description:
+
+ Get information recorded in CPU hob (Memory space size, Io space size)
+
+Arguments:
+
+ HobStart - Start pointer of hob list
+
+ SizeOfMemorySpace - Size of memory size
+
+ SizeOfIoSpace - Size of IO size
+
+Returns:
+
+ EFI_NOT_FOUND - CPU hob not found
+
+ EFI_SUCCESS - CPU hob found and information got.
+
+--*/
+{
+ EFI_PEI_HOB_POINTERS CpuHob;
+
+ CpuHob.Raw = HobStart;
+ CpuHob.Raw = GetHob (EFI_HOB_TYPE_CPU, CpuHob.Raw);
+ if (CpuHob.Header->HobType != EFI_HOB_TYPE_CPU) {
+ return EFI_NOT_FOUND;
+ }
+
+ *SizeOfMemorySpace = CpuHob.Cpu->SizeOfMemorySpace;
+ *SizeOfIoSpace = CpuHob.Cpu->SizeOfIoSpace;
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+GetDxeCoreHobInfo (
+ IN VOID *HobStart,
+ OUT EFI_PHYSICAL_ADDRESS *BaseAddress,
+ OUT UINT64 *Length,
+ OUT VOID **EntryPoint,
+ OUT EFI_GUID **FileName
+ )
+/*++
+
+Routine Description:
+
+ Get memory allocation hob created for DXE core and extract its information
+
+Arguments:
+
+ HobStart - Start pointer of the hob list
+ BaseAddress - Start address of memory allocated for DXE core
+ Length - Length of memory allocated for DXE core
+ EntryPoint - DXE core file name
+ FileName - File Name
+
+Returns:
+
+ EFI_NOT_FOUND - DxeCoreHob not found
+ EFI_SUCCESS - DxeCoreHob found and information got
+
+--*/
+{
+ EFI_PEI_HOB_POINTERS DxeCoreHob;
+
+
+ DxeCoreHob.Raw = HobStart;
+ DxeCoreHob.Raw = GetHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, DxeCoreHob.Raw);
+ while (DxeCoreHob.Header->HobType == EFI_HOB_TYPE_MEMORY_ALLOCATION &&
+ !EfiCompareGuid (&DxeCoreHob.MemoryAllocationModule->MemoryAllocationHeader.Name,
+ &gEfiHobMemeryAllocModuleGuid)) {
+
+ DxeCoreHob.Raw = GET_NEXT_HOB (DxeCoreHob);
+ DxeCoreHob.Raw = GetHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, DxeCoreHob.Raw);
+
+ }
+
+ if (DxeCoreHob.Header->HobType != EFI_HOB_TYPE_MEMORY_ALLOCATION) {
+ return EFI_NOT_FOUND;
+ }
+
+ *BaseAddress = DxeCoreHob.MemoryAllocationModule->MemoryAllocationHeader.MemoryBaseAddress;
+ *Length = DxeCoreHob.MemoryAllocationModule->MemoryAllocationHeader.MemoryLength;
+ *EntryPoint = (VOID *) (UINTN) DxeCoreHob.MemoryAllocationModule->EntryPoint;
+ *FileName = &DxeCoreHob.MemoryAllocationModule->ModuleName;
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+GetNextFirmwareVolumeHob (
+ IN OUT VOID **HobStart,
+ OUT EFI_PHYSICAL_ADDRESS *BaseAddress,
+ OUT UINT64 *Length
+ )
+/*++
+
+Routine Description:
+
+ Get next firmware volume hob from HobStart
+
+Arguments:
+
+ HobStart - Start pointer of hob list
+
+ BaseAddress - Start address of next firmware volume
+
+ Length - Length of next firmware volume
+
+Returns:
+
+ EFI_NOT_FOUND - Next firmware volume not found
+
+ EFI_SUCCESS - Next firmware volume found with address information
+
+--*/
+{
+ EFI_PEI_HOB_POINTERS FirmwareVolumeHob;
+
+ FirmwareVolumeHob.Raw = *HobStart;
+ if (END_OF_HOB_LIST (FirmwareVolumeHob)) {
+ return EFI_NOT_FOUND;
+ }
+
+ FirmwareVolumeHob.Raw = GetHob (EFI_HOB_TYPE_FV, *HobStart);
+ if (FirmwareVolumeHob.Header->HobType != EFI_HOB_TYPE_FV) {
+ return EFI_NOT_FOUND;
+ }
+
+ *BaseAddress = FirmwareVolumeHob.FirmwareVolume->BaseAddress;
+ *Length = FirmwareVolumeHob.FirmwareVolume->Length;
+
+ *HobStart = GET_NEXT_HOB (FirmwareVolumeHob);
+
+ return EFI_SUCCESS;
+}
+
+//;;## ...AMI_OVERRIDE... Support PI1.x
+#if (PI_SPECIFICATION_VERSION >= 0x00010000)
+EFI_STATUS
+GetNextFirmwareVolume2Hob (
+ IN OUT VOID **HobStart,
+ OUT EFI_PHYSICAL_ADDRESS *BaseAddress,
+ OUT UINT64 *Length,
+ OUT EFI_GUID *FileName
+ )
+/*++
+
+Routine Description:
+
+ Get next firmware volume2 hob from HobStart
+
+Arguments:
+
+ HobStart - Start pointer of hob list
+
+ BaseAddress - Start address of next firmware volume
+
+ Length - Length of next firmware volume
+
+Returns:
+
+ EFI_NOT_FOUND - Next firmware volume not found
+
+ EFI_SUCCESS - Next firmware volume found with address information
+
+--*/
+{
+ EFI_PEI_HOB_POINTERS FirmwareVolumeHob;
+
+ FirmwareVolumeHob.Raw = *HobStart;
+ if (END_OF_HOB_LIST (FirmwareVolumeHob)) {
+ return EFI_NOT_FOUND;
+ }
+
+ FirmwareVolumeHob.Raw = GetHob (EFI_HOB_TYPE_FV2, *HobStart);
+ if (FirmwareVolumeHob.Header->HobType != EFI_HOB_TYPE_FV2) {
+ return EFI_NOT_FOUND;
+ }
+
+ *BaseAddress = FirmwareVolumeHob.FirmwareVolume2->BaseAddress;
+ *Length = FirmwareVolumeHob.FirmwareVolume2->Length;
+ EfiCommonLibCopyMem(FileName,&FirmwareVolumeHob.FirmwareVolume2->FileName,sizeof(EFI_GUID));
+
+ *HobStart = GET_NEXT_HOB (FirmwareVolumeHob);
+
+ return EFI_SUCCESS;
+}
+#endif
+
+EFI_STATUS
+GetNextGuidHob (
+ IN OUT VOID **HobStart,
+ IN EFI_GUID * Guid,
+ OUT VOID **Buffer,
+ OUT UINTN *BufferSize OPTIONAL
+ )
+/*++
+
+Routine Description:
+ Get the next guid hob.
+
+Arguments:
+ HobStart A pointer to the start hob.
+ Guid A pointer to a guid.
+ Buffer A pointer to the buffer.
+ BufferSize Buffer size.
+
+Returns:
+ Status code.
+
+ EFI_NOT_FOUND - Next Guid hob not found
+
+ EFI_SUCCESS - Next Guid hob found and data for this Guid got
+
+ EFI_INVALID_PARAMETER - invalid parameter
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_PEI_HOB_POINTERS GuidHob;
+
+ if (Buffer == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ for (Status = EFI_NOT_FOUND; EFI_ERROR (Status);) {
+
+ GuidHob.Raw = *HobStart;
+ if (END_OF_HOB_LIST (GuidHob)) {
+ return EFI_NOT_FOUND;
+ }
+
+ GuidHob.Raw = GetHob (EFI_HOB_TYPE_GUID_EXTENSION, *HobStart);
+ if (GuidHob.Header->HobType == EFI_HOB_TYPE_GUID_EXTENSION) {
+ if (EfiCompareGuid (Guid, &GuidHob.Guid->Name)) {
+ Status = EFI_SUCCESS;
+ *Buffer = (VOID *) ((UINT8 *) (&GuidHob.Guid->Name) + sizeof (EFI_GUID));
+ if (BufferSize != NULL) {
+ *BufferSize = GuidHob.Header->HobLength - sizeof (EFI_HOB_GUID_TYPE);
+ }
+ }
+ }
+
+ *HobStart = GET_NEXT_HOB (GuidHob);
+ }
+
+ return Status;
+}
+
+
+#define PAL_ENTRY_HOB {0xe53cb8cc, 0xd62c, 0x4f74, 0xbd, 0xda, 0x31, 0xe5, 0x8d, 0xe5, 0x3e, 0x2}
+EFI_GUID gPalEntryHob = PAL_ENTRY_HOB;
+
+EFI_STATUS
+GetPalEntryHobInfo (
+ IN VOID *HobStart,
+ OUT EFI_PHYSICAL_ADDRESS *PalEntry
+ )
+/*++
+
+Routine Description:
+
+ Get PAL entry from PalEntryHob
+
+Arguments:
+
+ HobStart - Start pointer of hob list
+
+ PalEntry - Pointer to PAL entry
+
+Returns:
+
+ Status code.
+
+--*/
+{
+ VOID *Buffer;
+ UINTN BufferSize;
+ EFI_STATUS Status;
+ VOID *HobStart2;
+
+ //
+ // Initialize 'Buffer' to NULL before usage
+ //
+ Buffer = NULL;
+ HobStart2 = HobStart;
+ Status = GetNextGuidHob (
+ &HobStart2,
+ &gPalEntryHob,
+ &Buffer,
+ &BufferSize
+ );
+ if (EFI_ERROR (Status) || (Buffer == NULL)) {
+ //
+ // Failed to get HOB for gPalEntryHob
+ //
+ return Status;
+ }
+
+ *PalEntry = *((EFI_PHYSICAL_ADDRESS *) Buffer);
+ return Status;
+}
+
+
+EFI_STATUS
+GetIoPortSpaceAddressHobInfo (
+ IN VOID *HobStart,
+ OUT EFI_PHYSICAL_ADDRESS *IoPortSpaceAddress
+ )
+/*++
+
+Routine Description:
+
+ Get IO port space address from IoBaseHob.
+
+Arguments:
+
+ HobStart - Start pointer of hob list
+
+ IoPortSpaceAddress - IO port space address
+
+Returns:
+
+ Status code
+
+--*/
+{
+
+ VOID *Buffer;
+ UINTN BufferSize;
+ EFI_STATUS Status;
+ VOID *HobStart2;
+
+ //
+ // Initialize 'Buffer' to NULL before usage
+ //
+ Buffer = NULL;
+ HobStart2 = HobStart;
+ Status = GetNextGuidHob (
+ &HobStart2,
+ &gEfiIoBaseHobGuid,
+ &Buffer,
+ &BufferSize
+ );
+ if (EFI_ERROR (Status) || (Buffer == NULL)) {
+ //
+ // Failed to get HOB for gEfiIoBaseHobGuid
+ //
+ return Status;
+ }
+
+ *IoPortSpaceAddress = *((EFI_PHYSICAL_ADDRESS *) Buffer);
+ return Status;
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/EntryPoints/EdkIIGlueDxeDriverEntryPoint.c b/EDK/Foundation/Library/EdkIIGlueLib/EntryPoints/EdkIIGlueDxeDriverEntryPoint.c
new file mode 100644
index 0000000..07db3b2
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/EntryPoints/EdkIIGlueDxeDriverEntryPoint.c
@@ -0,0 +1,592 @@
+/*++
+
+Copyright (c) 2004 - 2011, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ EdkIIGlueDxeDriverEntryPoint.c
+
+Abstract:
+
+ DXE Driver entry point template file
+
+--*/
+
+#include "EdkIIGlueDxe.h"
+#include "Common/EdkIIGlueDependencies.h"
+
+//
+// Check definitions in .inf file to determine __EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__
+//
+// __EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__
+// 1: only install ComponentName, DriverConfiguration and DriverDiagnostics
+// 2: only install ComponentName2, DriverConfiguration2 and DriverDiagnostics2
+// 3: install all including ComponentName, DriverConfiguration, DriverDiagnostics AND
+// ComponentName2, DriverConfiguration2 and DriverDiagnostics2
+// 4: install automatically according to EFI_SPECIFICATION_VERSION:
+// if EFI_SPECIFICATION_VERSION < 0x00020000: only install ComponentName, DriverConfiguration and DriverDiagnostics
+// if EFI_SPECIFICATION_VERSION >= 0x00020000: only install ComponentName2, DriverConfiguration2 and DriverDiagnostics2
+//
+#ifdef __EDKII_GLUE_DRIVER_MODEL_VERSION_1_DEFINED__
+#undef __EDKII_GLUE_DRIVER_MODEL_VERSION_1_DEFINED__
+#endif
+
+#ifdef __EDKII_GLUE_DRIVER_MODEL_VERSION_2_DEFINED__
+#undef __EDKII_GLUE_DRIVER_MODEL_VERSION_2_DEFINED__
+#endif
+
+#ifdef __EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__
+#undef __EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__
+#endif
+
+#if defined(__EDKII_GLUE_COMPONENT_NAME_PROTOCOL_INSTANCE__) || defined(__EDKII_GLUE_DRIVER_CONFIGURATION_PROTOCOL_INSTANCE__) || defined(__EDKII_GLUE_DRIVER_DIAGNOSTICS_PROTOCOL_INSTANCE__)
+#define __EDKII_GLUE_DRIVER_MODEL_VERSION_1_DEFINED__
+#endif
+
+#if defined(__EDKII_GLUE_COMPONENT_NAME2_PROTOCOL_INSTANCE__) || defined(__EDKII_GLUE_DRIVER_CONFIGURATION2_PROTOCOL_INSTANCE__) || defined(__EDKII_GLUE_DRIVER_DIAGNOSTICS2_PROTOCOL_INSTANCE__)
+#define __EDKII_GLUE_DRIVER_MODEL_VERSION_2_DEFINED__
+#endif
+
+#if defined(__EDKII_GLUE_DRIVER_MODEL_VERSION_1_DEFINED__) && !defined(__EDKII_GLUE_DRIVER_MODEL_VERSION_2_DEFINED__) && !defined(__EDKII_GLUE_DRIVER_MODEL_AUTO_SELECT_PROTOCOLS_BY_EFI_VERSION__)
+#define __EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ 1
+#endif
+
+#if !defined(__EDKII_GLUE_DRIVER_MODEL_VERSION_1_DEFINED__) && defined(__EDKII_GLUE_DRIVER_MODEL_VERSION_2_DEFINED__) && !defined(__EDKII_GLUE_DRIVER_MODEL_AUTO_SELECT_PROTOCOLS_BY_EFI_VERSION__)
+#define __EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ 2
+#endif
+
+#if defined(__EDKII_GLUE_DRIVER_MODEL_VERSION_1_DEFINED__) && defined(__EDKII_GLUE_DRIVER_MODEL_VERSION_2_DEFINED__) && !defined(__EDKII_GLUE_DRIVER_MODEL_AUTO_SELECT_PROTOCOLS_BY_EFI_VERSION__)
+#define __EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ 3
+#endif
+
+//
+// To use Auto-Select, it must be:
+// 1. both Protocol and Protocol2 are defined
+// 2. The Protocol and Protocol2 must use same names, for example, gDriverControllerName as __EDKII_GLUE_COMPONENT_NAME_PROTOCOL_INSTANCE__ and __EDKII_GLUE_COMPONENT_NAME2_PROTOCOL_INSTANCE__
+//
+#if defined(__EDKII_GLUE_DRIVER_MODEL_AUTO_SELECT_PROTOCOLS_BY_EFI_VERSION__)
+#if !(defined(__EDKII_GLUE_DRIVER_MODEL_VERSION_1_DEFINED__) && defined(__EDKII_GLUE_DRIVER_MODEL_VERSION_2_DEFINED__))
+#error "To use Auto-Select please define both Protocol and Protocol2 instances"
+#endif
+#define __EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ 4
+#endif
+
+#if (__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 4)
+#undef __EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+#define __EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ 2
+#else
+#define __EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ 1
+#endif
+#endif
+
+#if (__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 1)
+UINT8 _gEdkIIGlueDriverModelProtocolSelection = 1;
+#elif (__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 2)
+UINT8 _gEdkIIGlueDriverModelProtocolSelection = 2;
+#elif (__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 3)
+UINT8 _gEdkIIGlueDriverModelProtocolSelection = 3;
+#else
+UINT8 _gEdkIIGlueDriverModelProtocolSelection = 0;
+#endif
+
+//
+// Driver Model related definitions.
+// LIMITATION: only support one instance of Driver Model protocols per driver.
+// In case where multiple Driver Model protocols need to be installed in a single driver,
+// manually edit this file and compile/link the modified file with the driver.
+//
+#if defined(__EDKII_GLUE_DRIVER_BINDING_PROTOCOL_INSTANCE__)
+extern EFI_DRIVER_BINDING_PROTOCOL __EDKII_GLUE_DRIVER_BINDING_PROTOCOL_INSTANCE__;
+#endif
+
+#if (__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 1) || (__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 3)
+#if defined(__EDKII_GLUE_COMPONENT_NAME_PROTOCOL_INSTANCE__)
+extern EFI_COMPONENT_NAME_PROTOCOL __EDKII_GLUE_COMPONENT_NAME_PROTOCOL_INSTANCE__;
+#endif
+
+#if defined(__EDKII_GLUE_DRIVER_CONFIGURATION_PROTOCOL_INSTANCE__)
+extern EFI_DRIVER_CONFIGURATION_PROTOCOL __EDKII_GLUE_DRIVER_CONFIGURATION_PROTOCOL_INSTANCE__;
+#endif
+#endif
+
+#if defined(__EDKII_GLUE_DRIVER_DIAGNOSTICS_PROTOCOL_INSTANCE__)
+extern EFI_DRIVER_DIAGNOSTICS_PROTOCOL __EDKII_GLUE_DRIVER_DIAGNOSTICS_PROTOCOL_INSTANCE__;
+#endif
+
+#if (__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 2) || (__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 3)
+#if defined(__EDKII_GLUE_COMPONENT_NAME2_PROTOCOL_INSTANCE__)
+extern EFI_COMPONENT_NAME2_PROTOCOL __EDKII_GLUE_COMPONENT_NAME2_PROTOCOL_INSTANCE__;
+#endif
+
+#if defined(__EDKII_GLUE_DRIVER_CONFIGURATION2_PROTOCOL_INSTANCE__)
+extern EFI_DRIVER_CONFIGURATION2_PROTOCOL __EDKII_GLUE_DRIVER_CONFIGURATION2_PROTOCOL_INSTANCE__;
+#endif
+
+#if defined(__EDKII_GLUE_DRIVER_DIAGNOSTICS2_PROTOCOL_INSTANCE__)
+extern EFI_DRIVER_DIAGNOSTICS2_PROTOCOL __EDKII_GLUE_DRIVER_DIAGNOSTICS2_PROTOCOL_INSTANCE__;
+#endif
+#endif
+
+GLOBAL_REMOVE_IF_UNREFERENCED const EFI_DRIVER_MODEL_PROTOCOL_LIST _gDriverModelProtocolList[] = {
+ {
+#ifdef __EDKII_GLUE_DRIVER_BINDING_PROTOCOL_INSTANCE__
+ &__EDKII_GLUE_DRIVER_BINDING_PROTOCOL_INSTANCE__,
+#else
+ NULL,
+#endif
+
+#if defined(__EDKII_GLUE_COMPONENT_NAME_PROTOCOL_INSTANCE__) && !(__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 2)
+ &__EDKII_GLUE_COMPONENT_NAME_PROTOCOL_INSTANCE__,
+#else
+ NULL,
+#endif
+
+#if defined(__EDKII_GLUE_DRIVER_CONFIGURATION_PROTOCOL_INSTANCE__) && !(__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 2)
+ &__EDKII_GLUE_DRIVER_CONFIGURATION_PROTOCOL_INSTANCE__,
+#else
+ NULL,
+#endif
+
+#if defined(__EDKII_GLUE_DRIVER_DIAGNOSTICS_PROTOCOL_INSTANCE__) && !(__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 2)
+ &__EDKII_GLUE_DRIVER_DIAGNOSTICS_PROTOCOL_INSTANCE__,
+#else
+ NULL,
+#endif
+
+#if defined(__EDKII_GLUE_COMPONENT_NAME2_PROTOCOL_INSTANCE__) && !(__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 1)
+ &__EDKII_GLUE_COMPONENT_NAME2_PROTOCOL_INSTANCE__,
+#else
+ NULL,
+#endif
+
+#if defined(__EDKII_GLUE_DRIVER_CONFIGURATION2_PROTOCOL_INSTANCE__) && !(__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 1)
+ &__EDKII_GLUE_DRIVER_CONFIGURATION2_PROTOCOL_INSTANCE__,
+#else
+ NULL,
+#endif
+
+#if defined(__EDKII_GLUE_DRIVER_DIAGNOSTICS2_PROTOCOL_INSTANCE__) && !(__EDKII_GLUE_DRIVER_MODEL_PROTOCOL_SELECTION__ == 1)
+ &__EDKII_GLUE_DRIVER_DIAGNOSTICS2_PROTOCOL_INSTANCE__,
+#else
+ NULL,
+#endif
+ }
+};
+
+//
+// Global Interface for Debug Mask Protocol
+//
+EFI_DEBUG_MASK_PROTOCOL *gDebugMaskInterface = NULL;
+
+//
+// NOTE: Limitation:
+// Only one handler for SetVirtualAddressMap Event and ExitBootServices Event each
+//
+
+#ifdef __EDKII_GLUE_SET_VIRTUAL_ADDRESS_MAP_EVENT_HANDLER__
+VOID
+__EDKII_GLUE_SET_VIRTUAL_ADDRESS_MAP_EVENT_HANDLER__ (
+ EFI_HANDLE ImageHandle,
+ EFI_SYSTEM_TABLE *SystemTable
+ );
+#endif
+
+/**
+ Enrty point to DXE Driver.
+
+ @param ImageHandle ImageHandle of the loaded driver.
+ @param SystemTable Pointer to the EFI System Table.
+
+ @retval EFI_SUCCESS One or more of the drivers returned a success code.
+ @retval !EFI_SUCESS The return status from the last driver entry point in the list.
+
+**/
+
+GLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverSetVirtualAddressMapEvent[] = {
+#ifdef __EDKII_GLUE_SET_VIRTUAL_ADDRESS_MAP_EVENT_HANDLER__
+ __EDKII_GLUE_SET_VIRTUAL_ADDRESS_MAP_EVENT_HANDLER__,
+#endif
+ NULL
+};
+
+GLOBAL_REMOVE_IF_UNREFERENCED const EFI_EVENT_NOTIFY _gDriverExitBootServicesEvent[] = {
+#ifdef __EDKII_GLUE_EXTI_BOOT_SERVICES_EVENT__HANDLER__
+ __EDKII_GLUE_EXTI_BOOT_SERVICES_EVENT__HANDLER__,
+#endif
+ NULL
+};
+
+
+//
+// Module Unload Handler
+//
+
+#ifdef __EDKII_GLUE_MODULE_UNLOAD_HANDLER__
+EFI_STATUS
+EFIAPI
+__EDKII_GLUE_MODULE_UNLOAD_HANDLER__ (
+ EFI_HANDLE ImageHandle
+ );
+#endif
+
+EFI_STATUS
+EFIAPI
+ProcessModuleUnloadList (
+ EFI_HANDLE ImageHandle
+ )
+{
+#ifdef __EDKII_GLUE_MODULE_UNLOAD_HANDLER__
+ return (__EDKII_GLUE_MODULE_UNLOAD_HANDLER__ (ImageHandle));
+#else
+ return EFI_SUCCESS;
+#endif
+}
+
+#ifdef __EDKII_GLUE_EFI_CALLER_ID_GUID__
+ GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiCallerIdGuid = __EDKII_GLUE_EFI_CALLER_ID_GUID__;
+#endif
+
+//
+// Library constructors
+//
+VOID
+ProcessLibraryConstructorList (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+//
+// Declare "Status" if any of the following libraries are used
+//
+#if defined(__EDKII_GLUE_DXE_HOB_LIB__) \
+ || defined(__EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__) \
+ || defined(__EDKII_GLUE_UEFI_DRIVER_MODEL_LIB__) \
+ || defined(__EDKII_GLUE_EDK_DXE_RUNTIME_DRIVER_LIB__) \
+ || defined(__EDKII_GLUE_DXE_SERVICES_TABLE_LIB__) \
+ || defined(__EDKII_GLUE_DXE_SMBUS_LIB__) \
+ || defined(__EDKII_GLUE_UEFI_RUNTIME_SERVICES_TABLE_LIB__) \
+ || defined(__EDKII_GLUE_SMM_RUNTIME_DXE_REPORT_STATUS_CODE_LIB__)
+ EFI_STATUS Status;
+#endif
+
+//
+// EdkII Glue Library Constructors:
+// NOTE: the constructors must be called according to dependency order
+//
+// UefiBootServicesTableLib UefiBootServicesTableLibConstructor()
+// UefiRuntimeServicesTableLib UefiRuntimeServicesTableLibConstructor()
+// DxeServicesTableLib DxeServicesTableLibConstructor()
+// EdkDxeRuntimeDriverLib RuntimeDriverLibConstruct()
+// SmmRuntimeDxeReportStatusCodeLib ReportStatusCodeLibConstruct()
+// DxeHobLib HobLibConstructor()
+// UefiDriverModelLib UefiDriverModelLibConstructor()
+// DxeSmbusLib SmbusLibConstructor()
+//
+#ifdef __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__
+ Status = UefiBootServicesTableLibConstructor (ImageHandle, SystemTable);
+ ASSERT_EFI_ERROR (Status);
+#endif
+
+#ifdef __EDKII_GLUE_UEFI_RUNTIME_SERVICES_TABLE_LIB__
+ Status = UefiRuntimeServicesTableLibConstructor (ImageHandle, SystemTable);
+ ASSERT_EFI_ERROR (Status);
+#endif
+
+#ifdef __EDKII_GLUE_DXE_SERVICES_TABLE_LIB__
+ Status = DxeServicesTableLibConstructor (ImageHandle, SystemTable);
+ ASSERT_EFI_ERROR (Status);
+#endif
+
+#ifdef __EDKII_GLUE_EDK_DXE_RUNTIME_DRIVER_LIB__
+ Status = RuntimeDriverLibConstruct (ImageHandle, SystemTable);
+ ASSERT_EFI_ERROR (Status);
+#endif
+
+#ifdef __EDKII_GLUE_SMM_RUNTIME_DXE_REPORT_STATUS_CODE_LIB__
+ Status = ReportStatusCodeLibConstruct (ImageHandle, SystemTable);
+ ASSERT_EFI_ERROR (Status);
+#endif
+
+#ifdef __EDKII_GLUE_UEFI_DRIVER_MODEL_LIB__
+ Status = UefiDriverModelLibConstructor (ImageHandle, SystemTable);
+ ASSERT_EFI_ERROR (Status);
+#endif
+
+#ifdef __EDKII_GLUE_DXE_HOB_LIB__
+ Status = HobLibConstructor (ImageHandle, SystemTable);
+ ASSERT_EFI_ERROR (Status);
+#endif
+
+#ifdef __EDKII_GLUE_DXE_SMBUS_LIB__
+ Status = SmbusLibConstructor (ImageHandle, SystemTable);
+ ASSERT_EFI_ERROR (Status);
+#endif
+
+}
+
+//
+// Library Destructors
+//
+VOID
+ProcessLibraryDestructorList (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+//
+// NOTE: the destructors must be called according to dependency order
+//
+#if defined(__EDKII_GLUE_UEFI_DRIVER_MODEL_LIB__) \
+ || defined(__EDKII_GLUE_SMM_RUNTIME_DXE_REPORT_STATUS_CODE_LIB__) \
+ || defined(__EDKII_GLUE_EDK_DXE_RUNTIME_DRIVER_LIB__)
+ EFI_STATUS Status;
+#endif
+
+#ifdef __EDKII_GLUE_UEFI_DRIVER_MODEL_LIB__
+ Status = UefiDriverModelLibDestructor (ImageHandle, SystemTable);
+ ASSERT_EFI_ERROR (Status);
+#endif
+
+#ifdef __EDKII_GLUE_SMM_RUNTIME_DXE_REPORT_STATUS_CODE_LIB__
+ Status = ReportStatusCodeLibDestruct (ImageHandle, SystemTable);
+ ASSERT_EFI_ERROR (Status);
+#endif
+
+#ifdef __EDKII_GLUE_EDK_DXE_RUNTIME_DRIVER_LIB__
+ Status = RuntimeDriverLibDeconstruct ();
+ ASSERT_EFI_ERROR (Status);
+#endif
+}
+
+
+/**
+ Unload function that is registered in the LoadImage protocol. It un-installs
+ protocols produced and deallocates pool used by the driver. Called by the core
+ when unloading the driver.
+
+ @param ImageHandle
+
+ @retval EFI_SUCCESS
+
+**/
+EFI_STATUS
+EFIAPI
+_DriverUnloadHandler (
+ EFI_HANDLE ImageHandle
+ )
+{
+ EFI_STATUS Status;
+
+ //
+ // If an UnloadImage() handler is specified, then call it
+ //
+ Status = ProcessModuleUnloadList (ImageHandle);
+
+ //
+ // If the driver specific unload handler does not return an error, then call all of the
+ // library destructors. If the unload handler returned an error, then the driver can not be
+ // unloaded, and the library destructors should not be called
+ //
+ if (!EFI_ERROR (Status)) {
+ //
+ // NOTE: To allow passing in gST here, any library instance having a destructor
+ // must depend on EfiDriverLib
+ //
+#if defined(__EDKII_GLUE_UEFI_DRIVER_MODEL_LIB__) \
+ || defined(__EDKII_GLUE_EDK_DXE_RUNTIME_DRIVER_LIB__)
+ ProcessLibraryDestructorList (ImageHandle, gST);
+#endif
+ }
+
+ //
+ // Return the status from the driver specific unload handler
+ //
+ return Status;
+}
+
+EFI_DRIVER_ENTRY_POINT (_ModuleEntryPoint);
+
+//
+// Module Entry Point
+//
+#ifdef __EDKII_GLUE_MODULE_ENTRY_POINT__
+EFI_STATUS
+EFIAPI
+__EDKII_GLUE_MODULE_ENTRY_POINT__ (
+ EFI_HANDLE ImageHandle,
+ EFI_SYSTEM_TABLE *SystemTable
+ );
+#endif
+
+/**
+ Enrty point to DXE Driver.
+
+ @param ImageHandle ImageHandle of the loaded driver.
+ @param SystemTable Pointer to the EFI System Table.
+
+ @retval EFI_SUCCESS One or more of the drivers returned a success code.
+ @retval !EFI_SUCESS The return status from the last driver entry point in the list.
+
+**/
+EFI_STATUS
+EFIAPI
+_ModuleEntryPoint (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ EFI_STATUS Status;
+ EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
+
+// if (_gUefiDriverRevision != 0) {
+// //
+// // Make sure that the EFI/UEFI spec revision of the platform is >= EFI/UEFI spec revision of the driver
+// //
+// if (SystemTable->Hdr.Revision < _gUefiDriverRevision) {
+// return EFI_INCOMPATIBLE_VERSION;
+// }
+// }
+
+// DEBUG ((EFI_D_ERROR, "EdkII Glue Driver Entry - 0\n"));
+
+ //
+ // Call constructor for all libraries
+ //
+ ProcessLibraryConstructorList (ImageHandle, SystemTable);
+ Status = SystemTable->BootServices->HandleProtocol (
+ ImageHandle,
+ &gEfiRuntimeDebugMaskProtocolGuid,
+ (VOID **)&gDebugMaskInterface
+ );
+ if (EFI_ERROR(Status)) {
+ Status = SystemTable->BootServices->HandleProtocol (
+ ImageHandle,
+ &gEfiDebugMaskProtocolGuid,
+ (VOID **)&gDebugMaskInterface
+ );
+ if (EFI_ERROR(Status)) {
+ gDebugMaskInterface = NULL;
+ }
+ }
+ //
+ // Install unload handler...
+ //
+ Status = SystemTable->BootServices->HandleProtocol (
+ ImageHandle,
+ &gEfiLoadedImageProtocolGuid,
+ (VOID **)&LoadedImage
+ );
+ ASSERT_EFI_ERROR (Status);
+ LoadedImage->Unload = _DriverUnloadHandler;
+
+ //
+ // Call the driver entry point
+ //
+ #ifdef __EDKII_GLUE_MODULE_ENTRY_POINT__
+ Status = (__EDKII_GLUE_MODULE_ENTRY_POINT__ (ImageHandle, SystemTable));
+ #else
+ Status = EFI_SUCCESS;
+ #endif
+
+ //
+ // If all of the drivers returned errors, then invoke all of the library destructors
+ //
+ if (EFI_ERROR (Status)) {
+ ProcessLibraryDestructorList (ImageHandle, SystemTable);
+ }
+
+ //
+ // Return the cummalative return status code from all of the driver entry points
+ //
+ return Status;
+}
+
+
+/**
+ Enrty point wrapper of DXE Driver.
+
+ @param ImageHandle ImageHandle of the loaded driver.
+ @param SystemTable Pointer to the EFI System Table.
+
+ @retval EFI_SUCCESS One or more of the drivers returned a success code.
+ @retval !EFI_SUCESS The return status from the last driver entry point in the list.
+
+**/
+EFI_STATUS
+EFIAPI
+EfiMain (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ return _ModuleEntryPoint (ImageHandle, SystemTable);
+}
+
+//
+// Guids not present in R8.6 code base
+//
+
+//
+// Protocol/Arch Protocol GUID globals
+//
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gUefiDriverConfigurationProtocolGuid = { 0xbfd7dc1d, 0x24f1, 0x40d9, { 0x82, 0xe7, 0x2e, 0x09, 0xbb, 0x6b, 0x4e, 0xbe } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gUefiDriverDiagnosticsProtocolGuid = { 0x4d330321, 0x025f, 0x4aac, { 0x90, 0xd8, 0x5e, 0xd9, 0x00, 0x17, 0x3b, 0x63 } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiArpProtocolGuid = { 0xf4b427bb, 0xba21, 0x4f16, { 0xbc, 0x4e, 0x43, 0xe4, 0x16, 0xab, 0x61, 0x9c } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiArpServiceBindingProtocolGuid = { 0xf44c00ee, 0x1f2c, 0x4a00, { 0xaa, 0x09, 0x1c, 0x9f, 0x3e, 0x08, 0x00, 0xa3 } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDhcp4ProtocolGuid = { 0x8a219718, 0x4ef5, 0x4761, { 0x91, 0xc8, 0xc0, 0xf0, 0x4b, 0xda, 0x9e, 0x56 } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDhcp4ServiceBindingProtocolGuid = { 0x9d9a39d8, 0xbd42, 0x4a73, { 0xa4, 0xd5, 0x8e, 0xe9, 0x4b, 0xe1, 0x13, 0x80 } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiIp4ProtocolGuid = { 0x41d94cd2, 0x35b6, 0x455a, { 0x82, 0x58, 0xd4, 0xe5, 0x13, 0x34, 0xaa, 0xdd } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiIp4ServiceBindingProtocolGuid = { 0xc51711e7, 0xb4bf, 0x404a, { 0xbf, 0xb8, 0x0a, 0x04, 0x8e, 0xf1, 0xff, 0xe4 } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiIp4ConfigProtocolGuid = { 0x3b95aa31, 0x3793, 0x434b, { 0x86, 0x67, 0xc8, 0x07, 0x08, 0x92, 0xe0, 0x5e } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiManagedNetworkProtocolGuid = { 0x3b95aa31, 0x3793, 0x434b, { 0x86, 0x67, 0xc8, 0x07, 0x08, 0x92, 0xe0, 0x5e } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiManagedNetworkServiceBindingProtocolGuid = { 0xf36ff770, 0xa7e1, 0x42cf, { 0x9e, 0xd2, 0x56, 0xf0, 0xf2, 0x71, 0xf4, 0x4c } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiMtftp4ProtocolGuid = { 0x3ad9df29, 0x4501, 0x478d, { 0xb1, 0xf8, 0x7f, 0x7f, 0xe7, 0x0e, 0x50, 0xf3 } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiMtftp4ServiceBindingProtocolGuid = { 0x2FE800BE, 0x8F01, 0x4aa6, { 0x94, 0x6B, 0xD7, 0x13, 0x88, 0xE1, 0x83, 0x3F } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiTcp4ProtocolGuid = { 0x65530BC7, 0xA359, 0x410f, { 0xB0, 0x10, 0x5A, 0xAD, 0xC7, 0xEC, 0x2B, 0x62 } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiTcp4ServiceBindingProtocolGuid = { 0x00720665, 0x67EB, 0x4a99, { 0xBA, 0xF7, 0xD3, 0xC3, 0x3A, 0x1C, 0x7C, 0xC9 } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiUdp4ProtocolGuid = { 0x3ad9df29, 0x4501, 0x478d, { 0xb1, 0xf8, 0x7f, 0x7f, 0xe7, 0x0e, 0x50, 0xf3 } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiUdp4ServiceBindingProtocolGuid = { 0x83f01464, 0x99bd, 0x45e5, { 0xb3, 0x83, 0xaf, 0x63, 0x05, 0xd8, 0xe9, 0xe6 } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiAuthenticationInfoProtocolGuid = { 0x7671d9d0, 0x53db, 0x4173, { 0xaa, 0x69, 0x23, 0x27, 0xf2, 0x1f, 0x0b, 0xc7 } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDevicePathFromTextProtocolGuid = { 0x5c99a21, 0xc70f, 0x4ad2, { 0x8a, 0x5f, 0x35, 0xdf, 0x33, 0x43, 0xf5, 0x1e } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDevicePathToTextProtocolGuid = { 0x8b843e20, 0x8132, 0x4852, { 0x90, 0xcc, 0x55, 0x1a, 0x4e, 0x4a, 0x7f, 0x1c } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDevicePathUtilitiesProtocolGuid = { 0x379be4e, 0xd706, 0x437d, { 0xb0, 0x37, 0xed, 0xb8, 0x2f, 0xb7, 0x72, 0xa4 } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashProtocolGuid = { 0xc5184932, 0xdba5, 0x46db, { 0xa5, 0xba, 0xcc, 0x0b, 0xda, 0x9c, 0x14, 0x35 } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashServiceBindingProtocolGuid = { 0x42881c98, 0xa4f3, 0x44b0, { 0xa3, 0x9d, 0xdf, 0xa1, 0x86, 0x67, 0xd8, 0xcd } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiIScsiInitiatorNameProtocolGuid = { 0xa6a72875, 0x2962, 0x4c18, { 0x9f, 0x46, 0x8d, 0xa6, 0x44, 0xcc, 0xfe, 0x00 } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiExtScsiPassThruProtocolGuid = { 0x1d3de7f0, 0x0807, 0x424f, { 0xaa, 0x69, 0x11, 0xa5, 0x4e, 0x19, 0xa4, 0x6f } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiTapeIoProtocolGuid = { 0x1e93e633, 0xd65a, 0x459e, { 0xab, 0x84, 0x93, 0xd9, 0xec, 0x26, 0x6d, 0x18 } };
+#if (EFI_SPECIFICATION_VERSION < 0x00020000)
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiUsb2HcProtocolGuid = { 0x3e745226, 0x9818, 0x45b6, { 0xa2, 0xac, 0xd7, 0xcd, 0x0e, 0x8b, 0xa2, 0xbc } };
+#endif
+
+//
+// PPI GUID globals
+//
+
+//
+// GUID globals
+//
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHobMemoryAllocBspStoreGuid = { 0x564b33cd, 0xc92a, 0x4593, { 0x90, 0xbf, 0x24, 0x73, 0xe4, 0x3c, 0x63, 0x22 } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHobMemoryAllocStackGuid = { 0x4ed4bf27, 0x4092, 0x42e9, { 0x80, 0x7d, 0x52, 0x7b, 0x1d, 0x00, 0xc9, 0xbd } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHobMemoryAllocModuleGuid = { 0xf8e21975, 0x0899, 0x4f58, { 0xa4, 0xbe, 0x55, 0x25, 0xa9, 0xc6, 0xd7, 0x7a } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiAuthenticationChapRadiusGuid = { 0xd6062b50, 0x15ca, 0x11da, { 0x92, 0x19, 0x00, 0x10, 0x83, 0xff, 0xca, 0x4d } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiAuthenticationChapLocalGuid = { 0xc280c73e, 0x15ca, 0x11da, { 0xb0, 0xca, 0x00, 0x10, 0x83, 0xff, 0xca, 0x4d } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmSha1Guid = { 0x2ae9d80f, 0x3fb2, 0x4095, { 0xb7, 0xb1, 0xe9, 0x31, 0x57, 0xb9, 0x46, 0xb6 } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmSha224Guid = { 0x8df01a06, 0x9bd5, 0x4bf7, { 0xb0, 0x21, 0xdb, 0x4f, 0xd9, 0xcc, 0xf4, 0x5b } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmSha256Guid = { 0x51aa59de, 0xfdf2, 0x4ea3, { 0xbc, 0x63, 0x87, 0x5f, 0xb7, 0x84, 0x2e, 0xe9 } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmSha384Guid = { 0xefa96432, 0xde33, 0x4dd2, { 0xae, 0xe6, 0x32, 0x8c, 0x33, 0xdf, 0x77, 0x7a } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmSha512Guid = { 0xcaa4381e, 0x750c, 0x4770, { 0xb8, 0x70, 0x7a, 0x23, 0xb4, 0xe4, 0x21, 0x30 } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmMD5Guid = { 0xaf7c79c, 0x65b5, 0x4319, { 0xb0, 0xae, 0x44, 0xec, 0x48, 0x4e, 0x4a, 0xd7 } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gBootObjectAuthorizationParmsetGuid = { 0xedd35e31, 0x7b9, 0x11d2, { 0x83, 0xa3, 0x00, 0xa0, 0xc9, 0x1f, 0xad, 0xcf } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gSmmCommunicateHeaderGuid = { 0xf328e36c, 0x23b6, 0x4a95, { 0x85, 0x4b, 0x32, 0xe1, 0x95, 0x34, 0xcd, 0x75 } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiCapsuleGuid = { 0x3B6686BD, 0x0D76, 0x4030, { 0xB7, 0x0E, 0xB5, 0x51, 0x9E, 0x2F, 0xC5, 0xA0 } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiConfigFileNameGuid = { 0x98B8D59B, 0xE8BA, 0x48EE, { 0x98, 0xDD, 0xC2, 0x95, 0x39, 0x2F, 0x1E, 0xDB } };
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/EntryPoints/EdkIIGluePeimEntryPoint.c b/EDK/Foundation/Library/EdkIIGlueLib/EntryPoints/EdkIIGluePeimEntryPoint.c
new file mode 100644
index 0000000..fb4c542
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/EntryPoints/EdkIIGluePeimEntryPoint.c
@@ -0,0 +1,180 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ EdkIIGluePeimEntryPoint.c
+
+Abstract:
+
+ PEIM entry point template file
+
+--*/
+
+#include "EdkIIGluePeim.h"
+#include "Common/EdkIIGlueDependencies.h"
+
+
+#ifdef __EDKII_GLUE_EFI_CALLER_ID_GUID__
+ GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiCallerIdGuid = __EDKII_GLUE_EFI_CALLER_ID_GUID__;
+#endif
+
+//
+// Library constructors
+//
+VOID
+ProcessLibraryConstructorList (
+ IN EFI_FFS_FILE_HEADER *FfsHeader,
+ IN EFI_PEI_SERVICES **PeiServices
+ )
+{
+//
+// Declare "Status" if any of the following libraries are used
+//
+#if defined(__EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__) \
+ || defined(__EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB__)
+ EFI_STATUS Status;
+#endif
+
+//
+// EdkII Glue Library Constructors:
+// PeiServicesTablePointerLib PeiServicesTablePointerLibConstructor()
+// PeiServicesTablePointerLibMm7 PeiServicesTablePointerLibConstructor()
+//
+
+#if defined(__EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__) \
+ || defined(__EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB__)
+ Status = PeiServicesTablePointerLibConstructor (FfsHeader, PeiServices);
+ ASSERT_EFI_ERROR (Status);
+#endif
+}
+
+EFI_PEIM_ENTRY_POINT (_ModuleEntryPoint);
+
+EFI_STATUS
+EFIAPI
+__EDKII_GLUE_MODULE_ENTRY_POINT__ (
+ IN EFI_FFS_FILE_HEADER *FfsHeader,
+ IN EFI_PEI_SERVICES **PeiServices
+ );
+
+/**
+ Image entry point of Peim.
+
+ @param FfsHeader Pointer to FFS header the loaded driver.
+ @param PeiServices Pointer to the PEI services.
+
+ @return Status returned by entry points of Peims.
+
+--*/
+EFI_STATUS
+EFIAPI
+_ModuleEntryPoint (
+ IN EFI_FFS_FILE_HEADER *FfsHeader,
+ IN EFI_PEI_SERVICES **PeiServices
+ )
+{
+// if (_gPeimRevision != 0) {
+// //
+// // Make sure that the PEI spec revision of the platform is >= PEI spec revision of the driver
+// //
+// ASSERT ((*PeiServices)->Hdr.Revision >= _gPeimRevision);
+// }
+
+ //
+ // Call constructor for all libraries
+ //
+ ProcessLibraryConstructorList (FfsHeader, PeiServices);
+
+ //
+ // Call the driver entry point
+ //
+ return __EDKII_GLUE_MODULE_ENTRY_POINT__ (FfsHeader, PeiServices);
+}
+
+
+/**
+ Wrapper of Peim image entry point.
+
+ @param FfsHeader Pointer to FFS header the loaded driver.
+ @param PeiServices Pointer to the PEI services.
+
+ @return Status returned by entry points of Peims.
+
+**/
+EFI_STATUS
+EFIAPI
+EfiMain (
+ IN EFI_FFS_FILE_HEADER *FfsHeader,
+ IN EFI_PEI_SERVICES **PeiServices
+ )
+{
+ return _ModuleEntryPoint (FfsHeader, PeiServices);
+}
+
+//
+// Guids not present in R8.6 code base
+//
+
+//
+// Protocol/Arch Protocol GUID globals
+//
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gUefiDriverConfigurationProtocolGuid = { 0xbfd7dc1d, 0x24f1, 0x40d9, { 0x82, 0xe7, 0x2e, 0x09, 0xbb, 0x6b, 0x4e, 0xbe } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gUefiDriverDiagnosticsProtocolGuid = { 0x4d330321, 0x025f, 0x4aac, { 0x90, 0xd8, 0x5e, 0xd9, 0x00, 0x17, 0x3b, 0x63 } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiArpProtocolGuid = { 0xf4b427bb, 0xba21, 0x4f16, { 0xbc, 0x4e, 0x43, 0xe4, 0x16, 0xab, 0x61, 0x9c } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiArpServiceBindingProtocolGuid = { 0xf44c00ee, 0x1f2c, 0x4a00, { 0xaa, 0x09, 0x1c, 0x9f, 0x3e, 0x08, 0x00, 0xa3 } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDhcp4ProtocolGuid = { 0x8a219718, 0x4ef5, 0x4761, { 0x91, 0xc8, 0xc0, 0xf0, 0x4b, 0xda, 0x9e, 0x56 } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDhcp4ServiceBindingProtocolGuid = { 0x9d9a39d8, 0xbd42, 0x4a73, { 0xa4, 0xd5, 0x8e, 0xe9, 0x4b, 0xe1, 0x13, 0x80 } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiIp4ProtocolGuid = { 0x41d94cd2, 0x35b6, 0x455a, { 0x82, 0x58, 0xd4, 0xe5, 0x13, 0x34, 0xaa, 0xdd } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiIp4ServiceBindingProtocolGuid = { 0xc51711e7, 0xb4bf, 0x404a, { 0xbf, 0xb8, 0x0a, 0x04, 0x8e, 0xf1, 0xff, 0xe4 } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiIp4ConfigProtocolGuid = { 0x3b95aa31, 0x3793, 0x434b, { 0x86, 0x67, 0xc8, 0x07, 0x08, 0x92, 0xe0, 0x5e } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiManagedNetworkProtocolGuid = { 0x3b95aa31, 0x3793, 0x434b, { 0x86, 0x67, 0xc8, 0x07, 0x08, 0x92, 0xe0, 0x5e } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiManagedNetworkServiceBindingProtocolGuid = { 0xf36ff770, 0xa7e1, 0x42cf, { 0x9e, 0xd2, 0x56, 0xf0, 0xf2, 0x71, 0xf4, 0x4c } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiMtftp4ProtocolGuid = { 0x3ad9df29, 0x4501, 0x478d, { 0xb1, 0xf8, 0x7f, 0x7f, 0xe7, 0x0e, 0x50, 0xf3 } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiMtftp4ServiceBindingProtocolGuid = { 0x2FE800BE, 0x8F01, 0x4aa6, { 0x94, 0x6B, 0xD7, 0x13, 0x88, 0xE1, 0x83, 0x3F } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiTcp4ProtocolGuid = { 0x65530BC7, 0xA359, 0x410f, { 0xB0, 0x10, 0x5A, 0xAD, 0xC7, 0xEC, 0x2B, 0x62 } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiTcp4ServiceBindingProtocolGuid = { 0x00720665, 0x67EB, 0x4a99, { 0xBA, 0xF7, 0xD3, 0xC3, 0x3A, 0x1C, 0x7C, 0xC9 } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiUdp4ProtocolGuid = { 0x3ad9df29, 0x4501, 0x478d, { 0xb1, 0xf8, 0x7f, 0x7f, 0xe7, 0x0e, 0x50, 0xf3 } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiUdp4ServiceBindingProtocolGuid = { 0x83f01464, 0x99bd, 0x45e5, { 0xb3, 0x83, 0xaf, 0x63, 0x05, 0xd8, 0xe9, 0xe6 } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiAuthenticationInfoProtocolGuid = { 0x7671d9d0, 0x53db, 0x4173, { 0xaa, 0x69, 0x23, 0x27, 0xf2, 0x1f, 0x0b, 0xc7 } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDevicePathFromTextProtocolGuid = { 0x5c99a21, 0xc70f, 0x4ad2, { 0x8a, 0x5f, 0x35, 0xdf, 0x33, 0x43, 0xf5, 0x1e } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDevicePathToTextProtocolGuid = { 0x8b843e20, 0x8132, 0x4852, { 0x90, 0xcc, 0x55, 0x1a, 0x4e, 0x4a, 0x7f, 0x1c } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDevicePathUtilitiesProtocolGuid = { 0x379be4e, 0xd706, 0x437d, { 0xb0, 0x37, 0xed, 0xb8, 0x2f, 0xb7, 0x72, 0xa4 } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashProtocolGuid = { 0xc5184932, 0xdba5, 0x46db, { 0xa5, 0xba, 0xcc, 0x0b, 0xda, 0x9c, 0x14, 0x35 } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashServiceBindingProtocolGuid = { 0x42881c98, 0xa4f3, 0x44b0, { 0xa3, 0x9d, 0xdf, 0xa1, 0x86, 0x67, 0xd8, 0xcd } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiIScsiInitiatorNameProtocolGuid = { 0xa6a72875, 0x2962, 0x4c18, { 0x9f, 0x46, 0x8d, 0xa6, 0x44, 0xcc, 0xfe, 0x00 } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiExtScsiPassThruProtocolGuid = { 0x1d3de7f0, 0x0807, 0x424f, { 0xaa, 0x69, 0x11, 0xa5, 0x4e, 0x19, 0xa4, 0x6f } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiTapeIoProtocolGuid = { 0x1e93e633, 0xd65a, 0x459e, { 0xab, 0x84, 0x93, 0xd9, 0xec, 0x26, 0x6d, 0x18 } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiUsb2HcProtocolGuid = { 0x3e745226, 0x9818, 0x45b6, { 0xa2, 0xac, 0xd7, 0xcd, 0x0e, 0x8b, 0xa2, 0xbc } };
+
+//
+// PPI GUID globals
+//
+
+//
+// GUID globals
+//
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHobMemoryAllocBspStoreGuid = { 0x564b33cd, 0xc92a, 0x4593, { 0x90, 0xbf, 0x24, 0x73, 0xe4, 0x3c, 0x63, 0x22 } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHobMemoryAllocStackGuid = { 0x4ed4bf27, 0x4092, 0x42e9, { 0x80, 0x7d, 0x52, 0x7b, 0x1d, 0x00, 0xc9, 0xbd } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHobMemoryAllocModuleGuid = { 0xf8e21975, 0x0899, 0x4f58, { 0xa4, 0xbe, 0x55, 0x25, 0xa9, 0xc6, 0xd7, 0x7a } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiAuthenticationChapRadiusGuid = { 0xd6062b50, 0x15ca, 0x11da, { 0x92, 0x19, 0x00, 0x10, 0x83, 0xff, 0xca, 0x4d } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiAuthenticationChapLocalGuid = { 0xc280c73e, 0x15ca, 0x11da, { 0xb0, 0xca, 0x00, 0x10, 0x83, 0xff, 0xca, 0x4d } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmSha1Guid = { 0x2ae9d80f, 0x3fb2, 0x4095, { 0xb7, 0xb1, 0xe9, 0x31, 0x57, 0xb9, 0x46, 0xb6 } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmSha224Guid = { 0x8df01a06, 0x9bd5, 0x4bf7, { 0xb0, 0x21, 0xdb, 0x4f, 0xd9, 0xcc, 0xf4, 0x5b } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmSha256Guid = { 0x51aa59de, 0xfdf2, 0x4ea3, { 0xbc, 0x63, 0x87, 0x5f, 0xb7, 0x84, 0x2e, 0xe9 } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmSha384Guid = { 0xefa96432, 0xde33, 0x4dd2, { 0xae, 0xe6, 0x32, 0x8c, 0x33, 0xdf, 0x77, 0x7a } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmSha512Guid = { 0xcaa4381e, 0x750c, 0x4770, { 0xb8, 0x70, 0x7a, 0x23, 0xb4, 0xe4, 0x21, 0x30 } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmMD5Guid = { 0xaf7c79c, 0x65b5, 0x4319, { 0xb0, 0xae, 0x44, 0xec, 0x48, 0x4e, 0x4a, 0xd7 } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gBootObjectAuthorizationParmsetGuid = { 0xedd35e31, 0x7b9, 0x11d2, { 0x83, 0xa3, 0x00, 0xa0, 0xc9, 0x1f, 0xad, 0xcf } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gSmmCommunicateHeaderGuid = { 0xf328e36c, 0x23b6, 0x4a95, { 0x85, 0x4b, 0x32, 0xe1, 0x95, 0x34, 0xcd, 0x75 } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiCapsuleGuid = { 0x3B6686BD, 0x0D76, 0x4030, { 0xB7, 0x0E, 0xB5, 0x51, 0x9E, 0x2F, 0xC5, 0xA0 } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiConfigFileNameGuid = { 0x98B8D59B, 0xE8BA, 0x48EE, { 0x98, 0xDD, 0xC2, 0x95, 0x39, 0x2F, 0x1E, 0xDB } };
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/EntryPoints/EdkIIGlueSmmDriverEntryPoint.c b/EDK/Foundation/Library/EdkIIGlueLib/EntryPoints/EdkIIGlueSmmDriverEntryPoint.c
new file mode 100644
index 0000000..a0a5cc9
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/EntryPoints/EdkIIGlueSmmDriverEntryPoint.c
@@ -0,0 +1,493 @@
+/*++
+
+Copyright (c) 2004 - 2011, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ EdkIIGlueSmmDriverEntryPoint.c
+
+Abstract:
+
+ Smm Driver entry point template file
+
+--*/
+
+#include "EdkIIGlueDxe.h"
+#include "Common/EdkIIGlueDependencies.h"
+
+
+//
+// Module Unload Handler
+//
+#ifdef __EDKII_GLUE_MODULE_UNLOAD_HANDLER__
+EFI_STATUS
+EFIAPI
+__EDKII_GLUE_MODULE_UNLOAD_HANDLER__ (
+ EFI_HANDLE ImageHandle
+ );
+#endif
+
+EFI_STATUS
+EFIAPI
+ProcessModuleUnloadList (
+ EFI_HANDLE ImageHandle
+ )
+{
+#ifdef __EDKII_GLUE_MODULE_UNLOAD_HANDLER__
+ return (__EDKII_GLUE_MODULE_UNLOAD_HANDLER__ (ImageHandle));
+#else
+ return EFI_SUCCESS;
+#endif
+}
+
+#ifdef __EDKII_GLUE_EFI_CALLER_ID_GUID__
+ GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiCallerIdGuid = __EDKII_GLUE_EFI_CALLER_ID_GUID__;
+#endif
+
+//
+// Global Interface for Debug Mask Protocol
+//
+EFI_DEBUG_MASK_PROTOCOL *gDebugMaskInterface = NULL;
+
+//
+// Library constructors
+//
+VOID
+ProcessLibraryConstructorList (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+//
+// Declare "Status" if any of the following libraries are used
+//
+#if defined(__EDKII_GLUE_DXE_HOB_LIB__) \
+ || defined(__EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__) \
+ || defined(__EDKII_GLUE_DXE_SERVICES_TABLE_LIB__) \
+ || defined(__EDKII_GLUE_DXE_SMBUS_LIB__) \
+ || defined(__EDKII_GLUE_UEFI_RUNTIME_SERVICES_TABLE_LIB__) \
+ || defined(__EDKII_GLUE_SMM_RUNTIME_DXE_REPORT_STATUS_CODE_LIB__)
+ EFI_STATUS Status;
+#endif
+
+//
+// EdkII Glue Library Constructors:
+// NOTE: the constructors must be called according to dependency order
+//
+// UefiBootServicesTableLib UefiBootServicesTableLibConstructor()
+// EdkDxeRuntimeDriverLib RuntimeDriverLibConstruct()
+// SmmRuntimeDxeReportStatusCodeLib ReportStatusCodeLibConstruct()
+// DxeHobLib HobLibConstructor()
+// UefiDriverModelLib UefiDriverModelLibConstructor()
+// DxeSmbusLib SmbusLibConstructor()
+// DxeServicesTableLib DxeServicesTableLibConstructor()
+// UefiRuntimeServicesTableLib UefiRuntimeServicesTableLibConstructor()
+// check here: check lib usage
+#ifdef __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__
+ Status = UefiBootServicesTableLibConstructor (ImageHandle, SystemTable);
+ ASSERT_EFI_ERROR (Status);
+#endif
+
+#ifdef __EDKII_GLUE_UEFI_RUNTIME_SERVICES_TABLE_LIB__
+ Status = UefiRuntimeServicesTableLibConstructor (ImageHandle, SystemTable);
+ ASSERT_EFI_ERROR (Status);
+#endif
+
+#ifdef __EDKII_GLUE_DXE_SERVICES_TABLE_LIB__
+ Status = DxeServicesTableLibConstructor (ImageHandle, SystemTable);
+ ASSERT_EFI_ERROR (Status);
+#endif
+
+#ifdef __EDKII_GLUE_SMM_RUNTIME_DXE_REPORT_STATUS_CODE_LIB__
+ Status = ReportStatusCodeLibConstruct (ImageHandle, SystemTable);
+ ASSERT_EFI_ERROR (Status);
+#endif
+
+#ifdef __EDKII_GLUE_DXE_HOB_LIB__
+ Status = HobLibConstructor (ImageHandle, SystemTable);
+ ASSERT_EFI_ERROR (Status);
+#endif
+
+#ifdef __EDKII_GLUE_DXE_SMBUS_LIB__
+ Status = SmbusLibConstructor (ImageHandle, SystemTable);
+ ASSERT_EFI_ERROR (Status);
+#endif
+}
+
+//
+// Library destructors
+//
+VOID
+ProcessLibraryDestructorList (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+#if defined (__EDKII_GLUE_SMM_RUNTIME_DXE_REPORT_STATUS_CODE_LIB__)
+ EFI_STATUS Status;
+#endif
+
+//
+// NOTE: the destructors must be called according to dependency order
+//
+#ifdef __EDKII_GLUE_SMM_RUNTIME_DXE_REPORT_STATUS_CODE_LIB__
+ Status = ReportStatusCodeLibDestruct (ImageHandle, SystemTable);
+ ASSERT_EFI_ERROR (Status);
+#endif
+}
+
+EFI_BOOT_SERVICES *mBS;
+
+/**
+ This function returns the size, in bytes,
+ of the device path data structure specified by DevicePath.
+ If DevicePath is NULL, then 0 is returned.
+
+ @param DevicePath A pointer to a device path data structure.
+
+ @return The size of a device path in bytes.
+
+**/
+STATIC
+UINTN
+EFIAPI
+SmmGetDevicePathSize (
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ )
+{
+ CONST EFI_DEVICE_PATH_PROTOCOL *Start;
+
+ if (DevicePath == NULL) {
+ return 0;
+ }
+
+ //
+ // Search for the end of the device path structure
+ //
+ Start = DevicePath;
+ while (!EfiIsDevicePathEnd (DevicePath)) {
+ DevicePath = EfiNextDevicePathNode (DevicePath);
+ }
+
+ //
+ // Compute the size and add back in the size of the end device path structure
+ //
+ return ((UINTN) DevicePath - (UINTN) Start) + sizeof (EFI_DEVICE_PATH_PROTOCOL);
+}
+
+/**
+ This function appends the device path SecondDevicePath
+ to every device path instance in FirstDevicePath.
+
+ @param FirstDevicePath A pointer to a device path data structure.
+
+ @param SecondDevicePath A pointer to a device path data structure.
+
+ @return A pointer to the new device path is returned.
+ NULL is returned if space for the new device path could not be allocated from pool.
+ It is up to the caller to free the memory used by FirstDevicePath and SecondDevicePath
+ if they are no longer needed.
+
+**/
+EFI_DEVICE_PATH_PROTOCOL *
+EFIAPI
+SmmAppendDevicePath (
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *FirstDevicePath,
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *SecondDevicePath
+ )
+{
+ EFI_STATUS Status;
+ UINTN Size;
+ UINTN Size1;
+ UINTN Size2;
+ EFI_DEVICE_PATH_PROTOCOL *NewDevicePath;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath2;
+
+ ASSERT (FirstDevicePath != NULL && SecondDevicePath != NULL);
+
+ //
+ // Allocate space for the combined device path. It only has one end node of
+ // length EFI_DEVICE_PATH_PROTOCOL
+ //
+ Size1 = SmmGetDevicePathSize (FirstDevicePath);
+ Size2 = SmmGetDevicePathSize (SecondDevicePath);
+ Size = Size1 + Size2 - sizeof (EFI_DEVICE_PATH_PROTOCOL);
+
+ Status = (mBS->AllocatePool) (EfiBootServicesData, Size, (VOID **) &NewDevicePath);
+
+ if (EFI_SUCCESS == Status) {
+ (mBS->CopyMem) ((VOID *) NewDevicePath, (VOID *) FirstDevicePath, Size1);
+ //
+ // Over write Src1 EndNode and do the copy
+ //
+ DevicePath2 = (EFI_DEVICE_PATH_PROTOCOL *) ((CHAR8 *) NewDevicePath + (Size1 - sizeof (EFI_DEVICE_PATH_PROTOCOL)));
+ (mBS->CopyMem) ((VOID *) DevicePath2, (VOID *) SecondDevicePath, Size2);
+ }
+
+ return NewDevicePath;
+}
+
+/**
+ Unload function that is registered in the LoadImage protocol. It un-installs
+ protocols produced and deallocates pool used by the driver. Called by the core
+ when unloading the driver.
+
+ @param ImageHandle ImageHandle of the unloaded driver
+
+ @return Status of the ProcessModuleUnloadList.
+
+**/
+EFI_STATUS
+EFIAPI
+_DriverUnloadHandler (
+ EFI_HANDLE ImageHandle
+ )
+{
+ EFI_STATUS Status;
+
+ //
+ // Call the unload handlers for all the modules
+ //
+ Status = ProcessModuleUnloadList (ImageHandle);
+
+ //
+ // If the driver specific unload handler does not return an error, then call all of the
+ // library destructors. If the unload handler returned an error, then the driver can not be
+ // unloaded, and the library destructors should not be called
+ //
+ if (!EFI_ERROR (Status)) {
+ //
+ // NOTE: To allow passing in gST here, any library instance having a destructor
+ // must depend on EfiDriverLib
+ //
+ }
+
+ //
+ // Return the status from the driver specific unload handler
+ //
+ return Status;
+}
+
+EFI_DRIVER_ENTRY_POINT (_ModuleEntryPoint);
+
+//
+// Module Entry Point
+//
+#ifdef __EDKII_GLUE_MODULE_ENTRY_POINT__
+EFI_STATUS
+EFIAPI
+__EDKII_GLUE_MODULE_ENTRY_POINT__ (
+ EFI_HANDLE ImageHandle,
+ EFI_SYSTEM_TABLE *SystemTable
+ );
+#endif
+
+/**
+ Enrty point to DXE SMM Driver.
+
+ @param ImageHandle ImageHandle of the loaded driver.
+ @param SystemTable Pointer to the EFI System Table.
+
+ @retval EFI_SUCCESS One or more of the drivers returned a success code.
+ @retval !EFI_SUCESS The return status from the last driver entry point in the list.
+
+**/
+EFI_STATUS
+EFIAPI
+_ModuleEntryPoint (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ EFI_STATUS Status;
+ EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
+ EFI_SMM_BASE_PROTOCOL *SmmBase;
+ BOOLEAN InSmm;
+ EFI_DEVICE_PATH_PROTOCOL *CompleteFilePath;
+ EFI_DEVICE_PATH_PROTOCOL *ImageDevicePath;
+ EFI_HANDLE Handle;
+
+ //
+ // Cache a pointer to the Boot Services Table
+ //
+ mBS = SystemTable->BootServices;
+
+ //
+ // Retrieve the Loaded Image Protocol
+ //
+ Status = mBS->HandleProtocol (
+ ImageHandle,
+ &gEfiLoadedImageProtocolGuid,
+ (VOID*)&LoadedImage
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // Retrieve SMM Base Protocol
+ //
+ Status = mBS->LocateProtocol (
+ &gEfiSmmBaseProtocolGuid,
+ NULL,
+ (VOID **) &SmmBase
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // Check to see if we are already in SMM
+ //
+ SmmBase->InSmm (SmmBase, &InSmm);
+
+ //
+ //
+ //
+ if (!InSmm) {
+ //
+ // Retrieve the Device Path Protocol from the DeviceHandle tha this driver was loaded from
+ //
+ Status = mBS->HandleProtocol (
+ LoadedImage->DeviceHandle,
+ &gEfiDevicePathProtocolGuid,
+ (VOID*)&ImageDevicePath
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // Build the full device path to the currently execuing image
+ //
+ CompleteFilePath = SmmAppendDevicePath (ImageDevicePath, LoadedImage->FilePath);
+
+ //
+ // Load the image in memory to SMRAM; it will automatically generate the
+ // SMI.
+ //
+ Status = SmmBase->Register (SmmBase, CompleteFilePath, NULL, 0, &Handle, FALSE);
+ ASSERT_EFI_ERROR (Status);
+ return Status;
+ }
+
+ //
+ // Call constructor for all libraries
+ //
+ ProcessLibraryConstructorList (ImageHandle, SystemTable);
+
+ Status = mBS->HandleProtocol (
+ ImageHandle,
+ &gEfiSmmDebugMaskProtocolGuid,
+ (VOID **)&gDebugMaskInterface
+ );
+ if (EFI_ERROR(Status)) {
+ gDebugMaskInterface = NULL;
+ }
+
+ //
+ // Install the unload handler
+ //
+ Status = mBS->HandleProtocol (
+ ImageHandle,
+ &gEfiLoadedImageProtocolGuid,
+ (VOID **)&LoadedImage
+ );
+ ASSERT_EFI_ERROR (Status);
+ LoadedImage->Unload = _DriverUnloadHandler;
+
+ //
+ // Call the list of driver entry points
+ //
+ #ifdef __EDKII_GLUE_MODULE_ENTRY_POINT__
+ Status = (__EDKII_GLUE_MODULE_ENTRY_POINT__ (ImageHandle, SystemTable));
+ #else
+ Status = EFI_SUCCESS;
+ #endif
+
+ if (EFI_ERROR (Status)) {
+ ProcessLibraryDestructorList (ImageHandle, SystemTable);
+ }
+
+ return Status;
+}
+
+/**
+ Enrty point wrapper of DXE SMM Driver.
+
+ @param ImageHandle ImageHandle of the loaded driver.
+ @param SystemTable Pointer to the EFI System Table.
+
+ @retval EFI_SUCCESS One or more of the drivers returned a success code.
+ @retval !EFI_SUCESS The return status from the last driver entry point in the list.
+
+**/
+EFI_STATUS
+EFIAPI
+EfiMain (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ return _ModuleEntryPoint (ImageHandle, SystemTable);
+}
+
+//
+// Guids not present in R8.6 code base
+//
+
+//
+// Protocol/Arch Protocol GUID globals
+//
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gUefiDriverConfigurationProtocolGuid = { 0xbfd7dc1d, 0x24f1, 0x40d9, { 0x82, 0xe7, 0x2e, 0x09, 0xbb, 0x6b, 0x4e, 0xbe } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gUefiDriverDiagnosticsProtocolGuid = { 0x4d330321, 0x025f, 0x4aac, { 0x90, 0xd8, 0x5e, 0xd9, 0x00, 0x17, 0x3b, 0x63 } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiArpProtocolGuid = { 0xf4b427bb, 0xba21, 0x4f16, { 0xbc, 0x4e, 0x43, 0xe4, 0x16, 0xab, 0x61, 0x9c } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiArpServiceBindingProtocolGuid = { 0xf44c00ee, 0x1f2c, 0x4a00, { 0xaa, 0x09, 0x1c, 0x9f, 0x3e, 0x08, 0x00, 0xa3 } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDhcp4ProtocolGuid = { 0x8a219718, 0x4ef5, 0x4761, { 0x91, 0xc8, 0xc0, 0xf0, 0x4b, 0xda, 0x9e, 0x56 } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDhcp4ServiceBindingProtocolGuid = { 0x9d9a39d8, 0xbd42, 0x4a73, { 0xa4, 0xd5, 0x8e, 0xe9, 0x4b, 0xe1, 0x13, 0x80 } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiIp4ProtocolGuid = { 0x41d94cd2, 0x35b6, 0x455a, { 0x82, 0x58, 0xd4, 0xe5, 0x13, 0x34, 0xaa, 0xdd } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiIp4ServiceBindingProtocolGuid = { 0xc51711e7, 0xb4bf, 0x404a, { 0xbf, 0xb8, 0x0a, 0x04, 0x8e, 0xf1, 0xff, 0xe4 } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiIp4ConfigProtocolGuid = { 0x3b95aa31, 0x3793, 0x434b, { 0x86, 0x67, 0xc8, 0x07, 0x08, 0x92, 0xe0, 0x5e } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiManagedNetworkProtocolGuid = { 0x3b95aa31, 0x3793, 0x434b, { 0x86, 0x67, 0xc8, 0x07, 0x08, 0x92, 0xe0, 0x5e } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiManagedNetworkServiceBindingProtocolGuid = { 0xf36ff770, 0xa7e1, 0x42cf, { 0x9e, 0xd2, 0x56, 0xf0, 0xf2, 0x71, 0xf4, 0x4c } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiMtftp4ProtocolGuid = { 0x3ad9df29, 0x4501, 0x478d, { 0xb1, 0xf8, 0x7f, 0x7f, 0xe7, 0x0e, 0x50, 0xf3 } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiMtftp4ServiceBindingProtocolGuid = { 0x2FE800BE, 0x8F01, 0x4aa6, { 0x94, 0x6B, 0xD7, 0x13, 0x88, 0xE1, 0x83, 0x3F } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiTcp4ProtocolGuid = { 0x65530BC7, 0xA359, 0x410f, { 0xB0, 0x10, 0x5A, 0xAD, 0xC7, 0xEC, 0x2B, 0x62 } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiTcp4ServiceBindingProtocolGuid = { 0x00720665, 0x67EB, 0x4a99, { 0xBA, 0xF7, 0xD3, 0xC3, 0x3A, 0x1C, 0x7C, 0xC9 } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiUdp4ProtocolGuid = { 0x3ad9df29, 0x4501, 0x478d, { 0xb1, 0xf8, 0x7f, 0x7f, 0xe7, 0x0e, 0x50, 0xf3 } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiUdp4ServiceBindingProtocolGuid = { 0x83f01464, 0x99bd, 0x45e5, { 0xb3, 0x83, 0xaf, 0x63, 0x05, 0xd8, 0xe9, 0xe6 } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiAuthenticationInfoProtocolGuid = { 0x7671d9d0, 0x53db, 0x4173, { 0xaa, 0x69, 0x23, 0x27, 0xf2, 0x1f, 0x0b, 0xc7 } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDevicePathFromTextProtocolGuid = { 0x5c99a21, 0xc70f, 0x4ad2, { 0x8a, 0x5f, 0x35, 0xdf, 0x33, 0x43, 0xf5, 0x1e } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDevicePathToTextProtocolGuid = { 0x8b843e20, 0x8132, 0x4852, { 0x90, 0xcc, 0x55, 0x1a, 0x4e, 0x4a, 0x7f, 0x1c } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiDevicePathUtilitiesProtocolGuid = { 0x379be4e, 0xd706, 0x437d, { 0xb0, 0x37, 0xed, 0xb8, 0x2f, 0xb7, 0x72, 0xa4 } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashProtocolGuid = { 0xc5184932, 0xdba5, 0x46db, { 0xa5, 0xba, 0xcc, 0x0b, 0xda, 0x9c, 0x14, 0x35 } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashServiceBindingProtocolGuid = { 0x42881c98, 0xa4f3, 0x44b0, { 0xa3, 0x9d, 0xdf, 0xa1, 0x86, 0x67, 0xd8, 0xcd } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiIScsiInitiatorNameProtocolGuid = { 0xa6a72875, 0x2962, 0x4c18, { 0x9f, 0x46, 0x8d, 0xa6, 0x44, 0xcc, 0xfe, 0x00 } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiExtScsiPassThruProtocolGuid = { 0x1d3de7f0, 0x0807, 0x424f, { 0xaa, 0x69, 0x11, 0xa5, 0x4e, 0x19, 0xa4, 0x6f } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiTapeIoProtocolGuid = { 0x1e93e633, 0xd65a, 0x459e, { 0xab, 0x84, 0x93, 0xd9, 0xec, 0x26, 0x6d, 0x18 } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiUsb2HcProtocolGuid = { 0x3e745226, 0x9818, 0x45b6, { 0xa2, 0xac, 0xd7, 0xcd, 0x0e, 0x8b, 0xa2, 0xbc } };
+
+//
+// PPI GUID globals
+//
+
+//
+// GUID globals
+//
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHobMemoryAllocBspStoreGuid = { 0x564b33cd, 0xc92a, 0x4593, { 0x90, 0xbf, 0x24, 0x73, 0xe4, 0x3c, 0x63, 0x22 } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHobMemoryAllocStackGuid = { 0x4ed4bf27, 0x4092, 0x42e9, { 0x80, 0x7d, 0x52, 0x7b, 0x1d, 0x00, 0xc9, 0xbd } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHobMemoryAllocModuleGuid = { 0xf8e21975, 0x0899, 0x4f58, { 0xa4, 0xbe, 0x55, 0x25, 0xa9, 0xc6, 0xd7, 0x7a } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiAuthenticationChapRadiusGuid = { 0xd6062b50, 0x15ca, 0x11da, { 0x92, 0x19, 0x00, 0x10, 0x83, 0xff, 0xca, 0x4d } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiAuthenticationChapLocalGuid = { 0xc280c73e, 0x15ca, 0x11da, { 0xb0, 0xca, 0x00, 0x10, 0x83, 0xff, 0xca, 0x4d } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmSha1Guid = { 0x2ae9d80f, 0x3fb2, 0x4095, { 0xb7, 0xb1, 0xe9, 0x31, 0x57, 0xb9, 0x46, 0xb6 } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmSha224Guid = { 0x8df01a06, 0x9bd5, 0x4bf7, { 0xb0, 0x21, 0xdb, 0x4f, 0xd9, 0xcc, 0xf4, 0x5b } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmSha256Guid = { 0x51aa59de, 0xfdf2, 0x4ea3, { 0xbc, 0x63, 0x87, 0x5f, 0xb7, 0x84, 0x2e, 0xe9 } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmSha384Guid = { 0xefa96432, 0xde33, 0x4dd2, { 0xae, 0xe6, 0x32, 0x8c, 0x33, 0xdf, 0x77, 0x7a } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmSha512Guid = { 0xcaa4381e, 0x750c, 0x4770, { 0xb8, 0x70, 0x7a, 0x23, 0xb4, 0xe4, 0x21, 0x30 } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiHashAlgorithmMD5Guid = { 0xaf7c79c, 0x65b5, 0x4319, { 0xb0, 0xae, 0x44, 0xec, 0x48, 0x4e, 0x4a, 0xd7 } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gBootObjectAuthorizationParmsetGuid = { 0xedd35e31, 0x7b9, 0x11d2, { 0x83, 0xa3, 0x00, 0xa0, 0xc9, 0x1f, 0xad, 0xcf } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gSmmCommunicateHeaderGuid = { 0xf328e36c, 0x23b6, 0x4a95, { 0x85, 0x4b, 0x32, 0xe1, 0x95, 0x34, 0xcd, 0x75 } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiCapsuleGuid = { 0x3B6686BD, 0x0D76, 0x4030, { 0xB7, 0x0E, 0xB5, 0x51, 0x9E, 0x2F, 0xC5, 0xA0 } };
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_GUID gEfiConfigFileNameGuid = { 0x98B8D59B, 0xE8BA, 0x48EE, { 0x98, 0xDD, 0xC2, 0x95, 0x39, 0x2F, 0x1E, 0xDB } };
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/AutoGen.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/AutoGen.h
new file mode 100644
index 0000000..626ffed
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/AutoGen.h
@@ -0,0 +1,37 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ AutoGen.h
+
+Abstract:
+
+ This file is used by .dxe file. To write common .dxs for R8.x and R9, a
+ header file named AutoGen.h musted be present. Here the AutoGen.h isn't
+ auto-generated by any tool.
+
+--*/
+
+#ifndef __EDKII_GLUELIB_AUTOGEN_H__
+#define __EDKII_GLUELIB_AUTOGEN_H__
+
+
+//
+// Users can use this macro in .dxs file
+//
+#ifndef BUILD_WITH_GLUELIB
+ #define BUILD_WITH_GLUELIB
+#endif
+
+
+#endif
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueBaseTypes.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueBaseTypes.h
new file mode 100644
index 0000000..81180e9
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueBaseTypes.h
@@ -0,0 +1,90 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ EdkIIGlueBaseTypes.h
+
+Abstract:
+
+ Defines additional data types for use by Base modules
+
+--*/
+
+#ifndef __EDKII_GLUE_BASE_TYPES_H__
+#define __EDKII_GLUE_BASE_TYPES_H__
+
+#include "..\EdkIIGlueConfig.h"
+
+#define BREAKPOINT EFI_BREAKPOINT
+#define DEADLOOP EFI_DEADLOOP
+
+#define MAX_BIT EFI_MAX_BIT
+#define MAX_ADDRESS EFI_MAX_ADDRESS
+
+#ifndef UINT8_MAX
+ #define UINT8_MAX 0xff
+#endif
+
+//
+// EFI Error Codes common to all execution phases
+//
+
+typedef INTN RETURN_STATUS;
+
+///
+/// Set the upper bit to indicate EFI Error.
+///
+#define ENCODE_ERROR(a) (MAX_BIT | (a))
+
+#define ENCODE_WARNING(a) (a)
+#define RETURN_ERROR(a) ((a) < 0)
+
+#define RETURN_SUCCESS 0
+#define RETURN_LOAD_ERROR ENCODE_ERROR (1)
+#define RETURN_INVALID_PARAMETER ENCODE_ERROR (2)
+#define RETURN_UNSUPPORTED ENCODE_ERROR (3)
+#define RETURN_BAD_BUFFER_SIZE ENCODE_ERROR (4)
+#define RETURN_BUFFER_TOO_SMALL ENCODE_ERROR (5)
+#define RETURN_NOT_READY ENCODE_ERROR (6)
+#define RETURN_DEVICE_ERROR ENCODE_ERROR (7)
+#define RETURN_WRITE_PROTECTED ENCODE_ERROR (8)
+#define RETURN_OUT_OF_RESOURCES ENCODE_ERROR (9)
+#define RETURN_VOLUME_CORRUPTED ENCODE_ERROR (10)
+#define RETURN_VOLUME_FULL ENCODE_ERROR (11)
+#define RETURN_NO_MEDIA ENCODE_ERROR (12)
+#define RETURN_MEDIA_CHANGED ENCODE_ERROR (13)
+#define RETURN_NOT_FOUND ENCODE_ERROR (14)
+#define RETURN_ACCESS_DENIED ENCODE_ERROR (15)
+#define RETURN_NO_RESPONSE ENCODE_ERROR (16)
+#define RETURN_NO_MAPPING ENCODE_ERROR (17)
+#define RETURN_TIMEOUT ENCODE_ERROR (18)
+#define RETURN_NOT_STARTED ENCODE_ERROR (19)
+#define RETURN_ALREADY_STARTED ENCODE_ERROR (20)
+#define RETURN_ABORTED ENCODE_ERROR (21)
+#define RETURN_ICMP_ERROR ENCODE_ERROR (22)
+#define RETURN_TFTP_ERROR ENCODE_ERROR (23)
+#define RETURN_PROTOCOL_ERROR ENCODE_ERROR (24)
+#define RETURN_INCOMPATIBLE_VERSION ENCODE_ERROR (25)
+#define RETURN_SECURITY_VIOLATION ENCODE_ERROR (26)
+#define RETURN_CRC_ERROR ENCODE_ERROR (27)
+#define RETURN_END_OF_MEDIA ENCODE_ERROR (28)
+#define RETURN_END_OF_FILE ENCODE_ERROR (31)
+
+#define RETURN_WARN_UNKNOWN_GLYPH ENCODE_WARNING (1)
+#define RETURN_WARN_DELETE_FAILURE ENCODE_WARNING (2)
+#define RETURN_WARN_WRITE_FAILURE ENCODE_WARNING (3)
+#define RETURN_WARN_BUFFER_TOO_SMALL ENCODE_WARNING (4)
+
+typedef UINT64 PHYSICAL_ADDRESS;
+
+#endif
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueDefinitionChangesBase.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueDefinitionChangesBase.h
new file mode 100644
index 0000000..aafcdd2
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueDefinitionChangesBase.h
@@ -0,0 +1,118 @@
+/*++
+
+Copyright (c) 2004 - 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ EdkIIGlueDefinitionChangesBase.h
+
+Abstract:
+
+ Data structure definition changes from EDK to EDKII
+
+--*/
+
+#ifndef __EDKII_GLUE_DEFINITION_CHANGES_BASE_H__
+#define __EDKII_GLUE_DEFINITION_CHANGES_BASE_H__
+
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
+#include "TianoHii.h"
+#else
+#include "EfiInternalFormRepresentation.h"
+#endif
+#include "EfiPxe.h"
+
+
+// ----------------------------------------------------------------------------------
+// Data Hub Record GUID Name changes
+// ----------------------------------------------------------------------------------
+#define gEfiProcessorSubClassGuid gProcessorSubClassName
+#define gEfiCacheSubClassGuid gCacheSubClassName
+#define gEfiMiscSubClassGuid gMiscSubClassName
+#define gEfiProcessorProducerGuid gProcessorProducerGuid
+#define gEfiMemoryProducerGuid gMemoryProducerGuid
+#define gEfiMiscProducerGuid gMiscProducerGuid
+
+
+// ----------------------------------------------------------------------------------
+// Hob.h: Get the data and data size field of GUID
+// ----------------------------------------------------------------------------------
+#define GET_GUID_HOB_DATA(GuidHob) ((VOID *) (((UINT8 *) &((GuidHob)->Name)) + sizeof (EFI_GUID)))
+#define GET_GUID_HOB_DATA_SIZE(GuidHob) (((GuidHob)->Header).HobLength - sizeof (EFI_HOB_GUID_TYPE))
+
+// ----------------------------------------------------------------------------------
+// InternalFormRepresentation.h:
+// ----------------------------------------------------------------------------------
+#if (EFI_SPECIFICATION_VERSION < 0x0002000A)
+typedef struct {
+ EFI_IFR_OP_HEADER Header;
+ UINT16 QuestionId; // The ID designating what the question is about...sucked in from a #define, likely in the form of a variable name
+ UINT8 Width; // The Size of the Data being saved
+ STRING_REF Prompt; // The String Token for the Prompt
+ STRING_REF Help; // The string Token for the context-help
+ UINT8 Flags; // For now, if non-zero, means that it is the default option, - further definition likely
+ UINT16 Key; // Value to be passed to caller to identify this particular op-code
+} EFI_IFR_CHECKBOX;
+
+typedef struct {
+ EFI_IFR_OP_HEADER Header;
+ UINT8 Flags;
+} EFI_IFR_GRAY_OUT;
+
+typedef struct {
+ EFI_IFR_OP_HEADER Header;
+} EFI_IFR_END_EXPR;
+#endif
+
+// ------------------------
+// define GUID as EFI_GUID
+// ------------------------
+typedef EFI_GUID GUID;
+
+
+// -------------------
+// EdkII Names - Edk Names
+// -------------------
+#define EFI_GLOBAL_VARIABLE EFI_GLOBAL_VARIABLE_GUID
+#define MPS_TABLE_GUID EFI_MPS_TABLE_GUID
+#define SAL_SYSTEM_TABLE_GUID EFI_SAL_SYSTEM_TABLE_GUID
+#define SMBIOS_TABLE_GUID EFI_SMBIOS_TABLE_GUID
+#define EFI_OPTIONAL_PTR EFI_OPTIONAL_POINTER
+#define PXE_FRAME_TYPE_FILTERED_MULTICAST PXE_FRAME_TYPE_MULTICAST
+#define IMAGE_FILE_MACHINE_I386 EFI_IMAGE_MACHINE_IA32
+#define IMAGE_FILE_MACHINE_IA64 EFI_IMAGE_MACHINE_IA64
+#define IMAGE_FILE_MACHINE_EBC EFI_IMAGE_MACHINE_EBC
+#define IMAGE_FILE_MACHINE_X64 EFI_IMAGE_MACHINE_X64
+#define EVENT_TIMER EFI_EVENT_TIMER
+#define EVENT_RUNTIME EFI_EVENT_RUNTIME
+#define EVENT_RUNTIME_CONTEXT EFI_EVENT_RUNTIME_CONTEXT
+#define EVENT_NOTIFY_WAIT EFI_EVENT_NOTIFY_WAIT
+#define EVENT_NOTIFY_SIGNAL EFI_EVENT_NOTIFY_SIGNAL
+#define EVENT_SIGNAL_EXIT_BOOT_SERVICES EFI_EVENT_SIGNAL_EXIT_BOOT_SERVICES
+#define EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE
+#define TPL_APPLICATION EFI_TPL_APPLICATION
+#define TPL_CALLBACK EFI_TPL_CALLBACK
+#define TPL_NOTIFY EFI_TPL_NOTIFY
+#define TPL_HIGH_LEVEL EFI_TPL_HIGH_LEVEL
+
+//
+// Typos in R8.x
+//
+#define gEfiHobMemoryAllocModuleGuid gEfiHobMemeryAllocModuleGuid
+#define gEfiHobMemoryAllocStackGuid gEfiHobMemeryAllocStackGuid
+#define gEfiHobMemoryAllocBspStoreGuid gEfiHobMemeryAllocBspStoreGuid
+
+//
+// typedef Edk types - EdkII types
+//
+typedef PXE_CPB_START PXE_CPB_START_30;
+
+#endif
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueDefinitionChangesDxe.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueDefinitionChangesDxe.h
new file mode 100644
index 0000000..dcedbe5
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueDefinitionChangesDxe.h
@@ -0,0 +1,95 @@
+/*++
+
+Copyright (c) 2004 - 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ EdkIIGlueDefinitionChangesDxe.h
+
+Abstract:
+
+ Data structure definition changes from EDK to EDKII
+
+--*/
+
+#ifndef __EDKII_GLUE_DEFINITION_CHANGES_DXE_H__
+#define __EDKII_GLUE_DEFINITION_CHANGES_DXE_H__
+
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
+#include "TianoHii.h"
+#else
+#include "EfiInternalFormRepresentation.h"
+#endif
+
+#include "EdkIIGlueDefinitionChangesBase.h"
+
+#if (TIANO_RELEASE_VERSION <= 0x00080005)
+ #define gEfiStatusCodeRuntimeProtocolGuid gEfiStatusCodeArchProtocolGuid
+#endif
+
+//
+// typedef Edk types - EdkII types
+//
+typedef EFI_MEMORY_ARRAY_START_ADDRESS EFI_MEMORY_ARRAY_START_ADDRESS_DATA;
+typedef EFI_MEMORY_DEVICE_START_ADDRESS EFI_MEMORY_DEVICE_START_ADDRESS_DATA;
+typedef EFI_MISC_LAST_PCI_BUS EFI_MISC_LAST_PCI_BUS_DATA;
+typedef EFI_MISC_BIOS_VENDOR EFI_MISC_BIOS_VENDOR_DATA;
+typedef EFI_MISC_SYSTEM_MANUFACTURER EFI_MISC_SYSTEM_MANUFACTURER_DATA;
+typedef EFI_MISC_BASE_BOARD_MANUFACTURER EFI_MISC_BASE_BOARD_MANUFACTURER_DATA;
+typedef EFI_MISC_CHASSIS_MANUFACTURER EFI_MISC_CHASSIS_MANUFACTURER_DATA;
+typedef EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA;
+typedef EFI_MISC_SYSTEM_SLOT_DESIGNATION EFI_MISC_SYSTEM_SLOT_DESIGNATION_DATA;
+typedef EFI_MISC_ONBOARD_DEVICE EFI_MISC_ONBOARD_DEVICE_DATA;
+typedef EFI_MISC_ONBOARD_DEVICE_TYPE_DATA EFI_MISC_PORTING_DEVICE_TYPE_DATA;
+typedef EFI_MISC_OEM_STRING EFI_MISC_OEM_STRING_DATA;
+typedef EFI_MISC_SYSTEM_OPTION_STRING EFI_MISC_SYSTEM_OPTION_STRING_DATA;
+typedef EFI_MISC_NUMBER_OF_INSTALLABLE_LANGUAGES EFI_MISC_NUMBER_OF_INSTALLABLE_LANGUAGES_DATA;
+typedef EFI_MISC_SYSTEM_LANGUAGE_STRING EFI_MISC_SYSTEM_LANGUAGE_STRING_DATA;
+typedef EFI_MISC_BIS_ENTRY_POINT EFI_MISC_BIS_ENTRY_POINT_DATA;
+typedef EFI_MISC_BOOT_INFORMATION_STATUS EFI_MISC_BOOT_INFORMATION_STATUS_DATA;
+typedef EFI_MISC_SYSTEM_POWER_SUPPLY EFI_MISC_SYSTEM_POWER_SUPPLY_DATA ;
+typedef EFI_MISC_SMBIOS_STRUCT_ENCAPSULATION EFI_MISC_SMBIOS_STRUCT_ENCAPSULATION_DATA;
+
+// -------------------
+// EdkII Names - Edk Names
+// -------------------
+#define gEfiAcpiSupportProtocolGuid gEfiAcpiSupportGuid
+#define gEfiLoadPeImageProtocolGuid gEfiLoadPeImageGuid
+#if (EFI_SPECIFICATION_VERSION < 0x0002000A)
+#define EFI_GLYPH_NON_SPACING GLYPH_NON_SPACING
+#define EFI_GLYPH_WIDE GLYPH_NON_BREAKING
+#endif
+#define BOOT_OBJECT_AUTHORIZATION_PARMSET_GUID BOOT_OBJECT_AUTHORIZATION_PARMSET_GUIDVALUE
+#define EFI_EBC_PROTOCOL_GUID EFI_EBC_INTERPRETER_PROTOCOL_GUID
+#define EFI_FILE_SYSTEM_VOLUME_LABEL_ID EFI_FILE_SYSTEM_VOLUME_LABEL_INFO_ID_GUID
+#define EFI_LOADED_IMAGE_PROTOCOL_REVISION EFI_LOADED_IMAGE_INFORMATION_REVISION
+#define EFI_LOAD_FILE_PROTOCOL_GUID LOAD_FILE_PROTOCOL_GUID
+#define EFI_PXE_BASE_CODE_PROTOCOL_REVISION EFI_PXE_BASE_CODE_INTERFACE_REVISION
+#define EFI_PXE_BASE_CODE_CALLBACK_PROTOCOL_REVISION EFI_PXE_BASE_CODE_CALLBACK_INTERFACE_REVISION
+#define EFI_SERIAL_IO_PROTOCOL_REVISION SERIAL_IO_INTERFACE_REVISION
+#define EFI_FILE_PROTOCOL_REVISION EFI_FILE_HANDLE_REVISION
+#define EFI_SIMPLE_TEXT_INPUT_PROTOCOL_GUID EFI_SIMPLE_TEXT_IN_PROTOCOL_GUID
+
+
+//
+// typedef Edk types - EdkII types
+//
+typedef EFI_VOLUME_OPEN EFI_SIMPLE_FILE_SYSTEM_PROTOCOL_OPEN_VOLUME;
+typedef EFI_TEXT_OUTPUT_STRING EFI_TEXT_STRING;
+#if (EFI_SPECIFICATION_VERSION < 0x0002000A)
+typedef SCREEN_DESCRIPTOR EFI_SCREEN_DESCRIPTOR;
+#endif
+typedef EFI_SIMPLE_TEXT_IN_PROTOCOL EFI_SIMPLE_TEXT_INPUT_PROTOCOL;
+typedef EFI_SIMPLE_TEXT_OUT_PROTOCOL EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL;
+//typedef EFI_TO_LEGACY16_INIT_TABLE EFI_TO_COMPATIBILITY16_INIT_TABLE;
+//typedef DISPATCH_OPROM_TABLE EFI_DISPATCH_OPROM_TABLE;
+
+#endif
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueDefinitionChangesPeim.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueDefinitionChangesPeim.h
new file mode 100644
index 0000000..373c9b4
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueDefinitionChangesPeim.h
@@ -0,0 +1,165 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ EdkIIGlueDefinitionChangesPeim.h
+
+Abstract:
+
+ Data structure definition changes from EDK to EDKII
+
+--*/
+
+#ifndef __EDKII_GLUE_DEFINITION_CHANGES_PEIM_H__
+#define __EDKII_GLUE_DEFINITION_CHANGES_PEIM_H__
+
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
+#include "TianoHii.h"
+#else
+#include "EfiInternalFormRepresentation.h"
+#endif
+
+#include "EdkIIGlueDefinitionChangesBase.h"
+
+#include "EfiPciCfg.h"
+
+//
+// typedef Edk types - EdkII types
+//
+typedef EFI_MEMORY_ARRAY_START_ADDRESS EFI_MEMORY_ARRAY_START_ADDRESS_DATA;
+typedef EFI_MEMORY_DEVICE_START_ADDRESS EFI_MEMORY_DEVICE_START_ADDRESS_DATA;
+typedef EFI_MISC_LAST_PCI_BUS EFI_MISC_LAST_PCI_BUS_DATA;
+typedef EFI_MISC_BIOS_VENDOR EFI_MISC_BIOS_VENDOR_DATA;
+typedef EFI_MISC_SYSTEM_MANUFACTURER EFI_MISC_SYSTEM_MANUFACTURER_DATA;
+typedef EFI_MISC_BASE_BOARD_MANUFACTURER EFI_MISC_BASE_BOARD_MANUFACTURER_DATA;
+typedef EFI_MISC_CHASSIS_MANUFACTURER EFI_MISC_CHASSIS_MANUFACTURER_DATA;
+typedef EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR EFI_MISC_PORT_INTERNAL_CONNECTOR_DESIGNATOR_DATA;
+typedef EFI_MISC_SYSTEM_SLOT_DESIGNATION EFI_MISC_SYSTEM_SLOT_DESIGNATION_DATA;
+typedef EFI_MISC_ONBOARD_DEVICE EFI_MISC_ONBOARD_DEVICE_DATA;
+typedef EFI_MISC_ONBOARD_DEVICE_TYPE_DATA EFI_MISC_PORTING_DEVICE_TYPE_DATA;
+typedef EFI_MISC_OEM_STRING EFI_MISC_OEM_STRING_DATA;
+typedef EFI_MISC_SYSTEM_OPTION_STRING EFI_MISC_SYSTEM_OPTION_STRING_DATA;
+typedef EFI_MISC_NUMBER_OF_INSTALLABLE_LANGUAGES EFI_MISC_NUMBER_OF_INSTALLABLE_LANGUAGES_DATA;
+typedef EFI_MISC_SYSTEM_LANGUAGE_STRING EFI_MISC_SYSTEM_LANGUAGE_STRING_DATA;
+typedef EFI_MISC_BIS_ENTRY_POINT EFI_MISC_BIS_ENTRY_POINT_DATA;
+typedef EFI_MISC_BOOT_INFORMATION_STATUS EFI_MISC_BOOT_INFORMATION_STATUS_DATA;
+typedef EFI_MISC_SYSTEM_POWER_SUPPLY EFI_MISC_SYSTEM_POWER_SUPPLY_DATA ;
+typedef EFI_MISC_SMBIOS_STRUCT_ENCAPSULATION EFI_MISC_SMBIOS_STRUCT_ENCAPSULATION_DATA;
+
+// -------------------
+// EdkII Names - Edk Names
+// -------------------
+#define gEfiPeiCpuIoPpiInServiceTableGuid gPeiCpuIoPpiInServiceTableGuid
+#define gEfiEndOfPeiSignalPpiGuid gEndOfPeiSignalPpiGuid
+#define gEfiPeiFvFileLoaderPpiGuid gPeiFvFileLoaderPpiGuid
+#define gEfiPeiMasterBootModePpiGuid gPeiMasterBootModePpiGuid
+#define gEfiPeiMemoryDiscoveredPpiGuid gPeiMemoryDiscoveredPpiGuid
+#define gEfiPciCfgPpiInServiceTableGuid gPeiPciCfgPpiInServiceTableGuid
+#define gEfiPeiReadOnlyVariablePpiGuid gPeiReadOnlyVariablePpiGuid
+#define gEfiPeiRecoveryModulePpiGuid gPeiRecoveryModulePpiGuid
+#define gEfiPeiResetPpiGuid gPeiResetPpiGuid
+#define gEfiPeiS3ResumePpiGuid gPeiS3ResumePpiGuid
+#define gEfiPeiSectionExtractionPpiGuid gPeiSectionExtractionPpiGuid
+#define gEfiPeiSecurityPpiGuid gPeiSecurityPpiGuid
+#define gEfiPeiStatusCodePpiGuid gPeiStatusCodePpiGuid
+#define gEfiPeiBootScriptExecuterPpiGuid gPeiBootScriptExecuterPpiGuid
+#define gEfiPeiSmbusPpiGuid gPeiSmbusPpiGuid
+#define gEfiPeiBlockIoPpiGuid gPeiBlockIoPpiGuid
+#define gEfiPeiDeviceRecoveryModulePpiGuid gPeiDeviceRecoveryModulePpiGuid
+#define gEfiPeiStallPpiGuid gPeiStallPpiGuid
+#define gEfiPeiPciCfgPpiInServiceTableGuid gPeiPciCfgPpiInServiceTableGuid
+#define gEfiPeiAtaControllerPpiGuid gPeiAtaControllerPpiGuid
+#define EFI_PEI_CPU_IO_PPI_INSTALLED_GUID PEI_CPU_IO_PPI_GUID
+#define EFI_PEI_RESET_PPI_GUID PEI_RESET_PPI_GUID
+#define EFI_PEI_PCI_CFG_PPI_INSTALLED_GUID PEI_PCI_CFG_PPI_GUID
+#define EFI_PEI_REPORT_PROGRESS_CODE_PPI_GUID PEI_STATUS_CODE_PPI_GUID
+#define EFI_PEI_BOOT_IN_RECOVERY_MODE_PEIM_PPI PEI_BOOT_IN_RECOVERY_MODE_PEIM_PPI
+#define EFI_PEI_END_OF_PEI_PHASE_PPI_GUID PEI_END_OF_PEI_PHASE_PPI_GUID
+#define EFI_PEI_MASTER_BOOT_MODE_PEIM_PPI PEI_MASTER_BOOT_MODE_PEIM_PPI
+#define EFI_PEI_PERMANENT_MEMORY_INSTALLED_PPI_GUID PEI_PERMANENT_MEMORY_INSTALLED_PPI_GUID
+#define EFI_PEI_READ_ONLY_VARIABLE_ACCESS_PPI_GUID PEI_READ_ONLY_VARIABLE_ACCESS_PPI_GUID
+#define EFI_PEI_RECOVERY_MODULE_PPI_GUID PEI_RECOVERY_MODULE_INTERFACE_PPI
+#define EFI_PEI_S3_RESUME_PPI_GUID PEI_S3_RESUME_PPI_GUID
+#define EFI_PEI_SECURITY_PPI_GUID PEI_SECURITY_PPI_GUID
+#define EFI_PEI_STALL_PPI_GUID PEI_STALL_PPI_GUID
+#define EFI_PEI_SMBUS_PPI_GUID PEI_SMBUS_PPI_GUID
+#define EFI_PEI_BOOT_SCRIPT_EXECUTER_PPI_GUID PEI_BOOT_SCRIPT_EXECUTER_PPI_GUID
+#define EFI_PEI_FIND_FV_PPI_GUID EFI_FIND_FV_PPI_GUID
+#define EFI_PEI_VIRTUAL_BLOCK_IO_PPI PEI_BLOCK_IO_PPI_GUID
+#define EFI_PEI_DEVICE_RECOVERY_MODULE_PPI_GUID PEI_DEVICE_RECOVERY_MODULE_INTERFACE_PPI
+
+
+//
+// typedef Edk types - EdkII types
+//
+typedef PEI_RECOVERY_MODULE_INTERFACE EFI_PEI_RECOVERY_MODULE_PPI;
+typedef PEI_CPU_IO_PPI EFI_PEI_CPU_IO_PPI;
+typedef PEI_STALL_PPI EFI_PEI_STALL_PPI;
+typedef PEI_SMBUS_PPI EFI_PEI_SMBUS_PPI;
+typedef PEI_READ_ONLY_VARIABLE_PPI EFI_PEI_READ_ONLY_VARIABLE_PPI;
+typedef PEI_PCI_CFG_PPI EFI_PEI_PCI_CFG_PPI;
+typedef PEI_STATUS_CODE_PPI EFI_PEI_PROGRESS_CODE_PPI;
+typedef PEI_CPU_IO_PPI_WIDTH EFI_PEI_CPU_IO_PPI_WIDTH;
+typedef PEI_CPU_IO_PPI_IO_MEM EFI_PEI_CPU_IO_PPI_IO_MEM;
+typedef PEI_CPU_IO_PPI_ACCESS EFI_PEI_CPU_IO_PPI_ACCESS;
+typedef PEI_CPU_IO_PPI_IO_READ8 EFI_PEI_CPU_IO_PPI_IO_READ8;
+typedef PEI_CPU_IO_PPI_IO_READ16 EFI_PEI_CPU_IO_PPI_IO_READ16;
+typedef PEI_CPU_IO_PPI_IO_READ32 EFI_PEI_CPU_IO_PPI_IO_READ32;
+typedef PEI_CPU_IO_PPI_IO_READ64 EFI_PEI_CPU_IO_PPI_IO_READ64;
+typedef PEI_CPU_IO_PPI_IO_WRITE8 EFI_PEI_CPU_IO_PPI_IO_WRITE8;
+typedef PEI_CPU_IO_PPI_IO_WRITE16 EFI_PEI_CPU_IO_PPI_IO_WRITE16;
+typedef PEI_CPU_IO_PPI_IO_WRITE32 EFI_PEI_CPU_IO_PPI_IO_WRITE32;
+typedef PEI_CPU_IO_PPI_IO_WRITE64 EFI_PEI_CPU_IO_PPI_IO_WRITE64;
+typedef PEI_CPU_IO_PPI_MEM_READ8 EFI_PEI_CPU_IO_PPI_MEM_READ8;
+typedef PEI_CPU_IO_PPI_MEM_READ16 EFI_PEI_CPU_IO_PPI_MEM_READ16;
+typedef PEI_CPU_IO_PPI_MEM_READ32 EFI_PEI_CPU_IO_PPI_MEM_READ32;
+typedef PEI_CPU_IO_PPI_MEM_READ64 EFI_PEI_CPU_IO_PPI_MEM_READ64;
+typedef PEI_CPU_IO_PPI_MEM_WRITE8 EFI_PEI_CPU_IO_PPI_MEM_WRITE8;
+typedef PEI_CPU_IO_PPI_MEM_WRITE16 EFI_PEI_CPU_IO_PPI_MEM_WRITE16;
+typedef PEI_CPU_IO_PPI_MEM_WRITE32 EFI_PEI_CPU_IO_PPI_MEM_WRITE32;
+typedef PEI_CPU_IO_PPI_MEM_WRITE64 EFI_PEI_CPU_IO_PPI_MEM_WRITE64;
+//;;## ...AMI_OVERRIDE... Support PI1.x typedef PEI_PCI_CFG_PPI_WIDTH EFI_PEI_PCI_CFG_PPI_WIDTH;
+//;;## ...AMI_OVERRIDE... Support PI1.x typedef PEI_PCI_CFG_PPI_PCI_ADDRESS EFI_PEI_PCI_CFG_PPI_PCI_ADDRESS;
+typedef PEI_GET_VARIABLE EFI_PEI_GET_VARIABLE;
+typedef PEI_GET_NEXT_VARIABLE_NAME EFI_PEI_GET_NEXT_VARIABLE_NAME;
+typedef PEI_LOAD_RECOVERY_CAPSULE EFI_PEI_LOAD_RECOVERY_CAPSULE;
+typedef PEI_RESET_PPI EFI_PEI_RESET_PPI;
+typedef PEI_S3_RESUME_PPI EFI_PEI_S3_RESUME_PPI;
+typedef PEI_S3_RESUME_PPI_RESTORE_CONFIG EFI_PEI_S3_RESUME_PPI_RESTORE_CONFIG;
+typedef SEC_PLATFORM_INFORMATION EFI_SEC_PLATFORM_INFORMATION;
+typedef PEI_SECURITY_PPI EFI_PEI_SECURITY_PPI;
+typedef PEI_SECURITY_AUTHENTICATION_STATE EFI_PEI_SECURITY_AUTHENTICATION_STATE;
+typedef PEI_STALL EFI_PEI_STALL;
+typedef PEI_SMBUS_PPI_EXECUTE_OPERATION EFI_PEI_SMBUS_PPI_EXECUTE_OPERATION;
+typedef PEI_SMBUS_NOTIFY_FUNCTION EFI_PEI_SMBUS_NOTIFY_FUNCTION;
+typedef PEI_SMBUS_PPI_ARP_DEVICE EFI_PEI_SMBUS_PPI_ARP_DEVICE;
+typedef PEI_SMBUS_PPI_GET_ARP_MAP EFI_PEI_SMBUS_PPI_GET_ARP_MAP;
+typedef PEI_SMBUS_PPI_NOTIFY EFI_PEI_SMBUS_PPI_NOTIFY;
+typedef PEI_BOOT_SCRIPT_EXECUTE EFI_PEI_BOOT_SCRIPT_EXECUTE;
+typedef PEI_BOOT_SCRIPT_EXECUTER_PPI EFI_PEI_BOOT_SCRIPT_EXECUTER_PPI;
+typedef EFI_FIND_FV_FINDFV EFI_PEI_FIND_FV_FINDFV;
+typedef EFI_FIND_FV_PPI EFI_PEI_FIND_FV_PPI;
+typedef PEI_RECOVERY_BLOCK_IO_INTERFACE EFI_PEI_RECOVERY_BLOCK_IO_PPI;
+typedef PEI_LBA EFI_PEI_LBA;
+typedef PEI_BLOCK_IO_MEDIA EFI_PEI_BLOCK_IO_MEDIA;
+typedef PEI_BLOCK_DEVICE_TYPE EFI_PEI_BLOCK_DEVICE_TYPE;
+typedef PEI_GET_NUMBER_BLOCK_DEVICES EFI_PEI_GET_NUMBER_BLOCK_DEVICES;
+typedef PEI_GET_DEVICE_MEDIA_INFORMATION EFI_PEI_GET_DEVICE_MEDIA_INFORMATION;
+typedef PEI_READ_BLOCKS EFI_PEI_READ_BLOCKS;
+typedef PEI_DEVICE_RECOVERY_MODULE_INTERFACE EFI_PEI_DEVICE_RECOVERY_MODULE_PPI;
+typedef PEI_DEVICE_GET_NUMBER_RECOVERY_CAPSULE EFI_PEI_DEVICE_GET_NUMBER_RECOVERY_CAPSULE;
+typedef PEI_DEVICE_GET_RECOVERY_CAPSULE_INFO EFI_PEI_DEVICE_GET_RECOVERY_CAPSULE_INFO;
+typedef PEI_DEVICE_LOAD_RECOVERY_CAPSULE EFI_PEI_DEVICE_LOAD_RECOVERY_CAPSULE;
+
+
+#endif
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueDependencies.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueDependencies.h
new file mode 100644
index 0000000..3d5aafe
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Common/EdkIIGlueDependencies.h
@@ -0,0 +1,698 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ EdkIIGlueDepedencies.h
+
+Abstract:
+
+ Header file that lists dependency relations among library instances
+
+--*/
+
+#ifndef __EDKII_GLUE_DEPENDENCIES_H__
+#define __EDKII_GLUE_DEPENDENCIES_H__
+
+
+//
+// Declarations of dependencies among EdkII Glue Library instances and R8 Libraries
+// Pay attention to the order of following #define structures
+//
+
+
+//
+// PeiDxeDebugLibReportStatusCode
+// Actually almost every module and GlueLib instance needs this library, but GlueLib
+// instances don't have to list this library in their own inf files. Module inf
+// does this.
+//
+#if defined(__EDKII_GLUE_PEI_DEBUG_LIB_REPORT_STATUS_CODE__) || defined(__EDKII_GLUE_DXE_DEBUG_LIB_REPORT_STATUS_CODE__)
+ #ifndef __EDKII_GLUE_BASE_LIB__
+ #define __EDKII_GLUE_BASE_LIB__
+ #endif
+ #ifndef __EDKII_GLUE_BASE_MEMORY_LIB__
+ #define __EDKII_GLUE_BASE_MEMORY_LIB__
+ #endif
+#endif
+
+//
+// BaseDebugLibNull
+//
+#ifdef __EDKII_GLUE_BASE_DEBUG_LIB_NULL__
+ #ifndef __EDKII_GLUE_BASE_LIB__
+ #define __EDKII_GLUE_BASE_LIB__
+ #endif
+ #ifndef __EDKII_GLUE_BASE_MEMORY_LIB__
+ #define __EDKII_GLUE_BASE_MEMORY_LIB__
+ #endif
+ #ifndef __EDKII_GLUE_BASE_PRINT_LIB__
+ #define __EDKII_GLUE_BASE_PRINT_LIB__
+ #endif
+#endif
+
+//
+// EdkDxeRuntimeDriverLib
+//
+#ifdef __EDKII_GLUE_EDK_DXE_RUNTIME_DRIVER_LIB__
+ #ifndef __EDKII_GLUE_UEFI_LIB__
+ #define __EDKII_GLUE_UEFI_LIB__
+ #endif
+ #ifndef __EDKII_GLUE_BASE_LIB__
+ #define __EDKII_GLUE_BASE_LIB__
+ #endif
+ #ifndef __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__
+ #define __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__
+ #endif
+#endif
+
+
+//
+// BasePciLibCf8
+//
+#ifdef __EDKII_GLUE_BASE_PCI_LIB_CF8__
+ #ifndef __EDKII_GLUE_BASE_PCI_CF8_LIB__
+ #define __EDKII_GLUE_BASE_PCI_CF8_LIB__
+ #endif
+#endif
+
+//
+// BasePciLibPciExpress
+//
+#ifdef __EDKII_GLUE_BASE_PCI_LIB_PCI_EXPRESS__
+ #ifndef __EDKII_GLUE_BASE_PCI_EXPRESS_LIB__
+ #define __EDKII_GLUE_BASE_PCI_EXPRESS_LIB__
+ #endif
+#endif
+
+//
+// BasePciCf8Lib
+//
+#ifdef __EDKII_GLUE_BASE_PCI_CF8_LIB__
+ #ifndef __EDKII_GLUE_BASE_IO_LIB_INTRINSIC__
+ #define __EDKII_GLUE_BASE_IO_LIB_INTRINSIC__
+ #endif
+#endif
+
+// BasePciExpressLib
+//
+#ifdef __EDKII_GLUE_BASE_PCI_EXPRESS_LIB__
+ #ifndef __EDKII_GLUE_BASE_IO_LIB_INTRINSIC__
+ #define __EDKII_GLUE_BASE_IO_LIB_INTRINSIC__
+ #endif
+#endif
+
+//
+// BaseTimerLibLocalApic
+//
+#ifdef __EDKII_GLUE_BASE_TIMER_LIB_LOCAL_APIC__
+ #ifndef __EDKII_GLUE_BASE_LIB__
+ #define __EDKII_GLUE_BASE_LIB__
+ #endif
+ #ifndef __EDKII_GLUE_BASE_IO_LIB_INTRINSIC__
+ #define __EDKII_GLUE_BASE_IO_LIB_INTRINSIC__
+ #endif
+#endif
+
+//
+// DxeReportStatusCodeLib
+//
+#ifdef __EDKII_GLUE_DXE_REPORT_STATUS_CODE_LIB__
+ #ifndef __EDKII_GLUE_BASE_LIB__
+ #define __EDKII_GLUE_BASE_LIB__
+ #endif
+ #ifndef __EDKII_GLUE_BASE_IO_LIB_INTRINSIC__
+ #define __EDKII_GLUE_BASE_IO_LIB_INTRINSIC__
+ #endif
+ #ifndef __EDKII_GLUE_BASE_MEMORY_LIB__
+ #define __EDKII_GLUE_BASE_MEMORY_LIB__
+ #endif
+ #ifndef __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__
+ #define __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__
+ #endif
+ #ifndef __EDKII_GLUE_UEFI_RUNTIME_SERVICES_TABLE_LIB__
+ #define __EDKII_GLUE_UEFI_RUNTIME_SERVICES_TABLE_LIB__
+ #endif
+#endif
+
+//
+// SmmRuntimeDxeReportStatusCodeLib - typically used by SMM driver and Runtime driver
+//
+#ifdef __EDKII_GLUE_SMM_RUNTIME_DXE_REPORT_STATUS_CODE_LIB__
+ #ifndef __EDKII_GLUE_BASE_LIB__
+ #define __EDKII_GLUE_BASE_LIB__
+ #endif
+ #ifndef __EDKII_GLUE_BASE_MEMORY_LIB__
+ #define __EDKII_GLUE_BASE_MEMORY_LIB__
+ #endif
+ #ifndef __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__
+ #define __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__
+ #endif
+ #ifndef __EDKII_GLUE_UEFI_RUNTIME_SERVICES_TABLE_LIB__
+ #define __EDKII_GLUE_UEFI_RUNTIME_SERVICES_TABLE_LIB__
+ #endif
+#endif
+
+//
+// PeiReportStatusCodeLib
+//
+#ifdef __EDKII_GLUE_PEI_REPORT_STATUS_CODE_LIB__
+ #ifndef __EDKII_GLUE_BASE_LIB__
+ #define __EDKII_GLUE_BASE_LIB__
+ #endif
+ #ifndef __EDKII_GLUE_BASE_MEMORY_LIB__
+ #define __EDKII_GLUE_BASE_MEMORY_LIB__
+ #endif
+ #ifndef __EDKII_GLUE_BASE_IO_LIB_INTRINSIC__
+ #define __EDKII_GLUE_BASE_IO_LIB_INTRINSIC__
+ #endif
+ #ifndef __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__
+ #define __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__
+ #endif
+ //
+ // If necessary, __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__ can be
+ // replaced with __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB__
+ //
+#endif
+
+//
+// BasePeCoffLib
+//
+#ifdef __EDKII_GLUE_BASE_PE_COFF_LIB__
+ #ifndef __EDKII_GLUE_BASE_MEMORY_LIB__
+ #define __EDKII_GLUE_BASE_MEMORY_LIB__
+ #endif
+#endif
+
+//
+// BaseUefiDecompressLib
+//
+#ifdef __EDKII_GLUE_BASE_UEFI_DECOMPRESS_LIB__
+ #ifndef __EDKII_GLUE_BASE_MEMORY_LIB__
+ #define __EDKII_GLUE_BASE_MEMORY_LIB__
+ #endif
+#endif
+
+//
+// DxeHobLib
+//
+#ifdef __EDKII_GLUE_DXE_HOB_LIB__
+ #ifndef __EDKII_GLUE_BASE_MEMORY_LIB__
+ #define __EDKII_GLUE_BASE_MEMORY_LIB__
+ #endif
+ #ifndef __EDKII_GLUE_UEFI_LIB__
+ #define __EDKII_GLUE_UEFI_LIB__
+ #endif
+#endif
+
+//
+// HiiLib
+//
+#ifdef __EDKII_GLUE_HII_LIB__
+ #ifndef __EDKII_GLUE_DXE_MEMORY_ALLOCATION_LIB__
+ #define __EDKII_GLUE_DXE_MEMORY_ALLOCATION_LIB__
+ #endif
+#endif
+
+//
+// UefiDevicePathLib
+//
+#ifdef __EDKII_GLUE_UEFI_DEVICE_PATH_LIB__
+ #ifndef __EDKII_GLUE_BASE_MEMORY_LIB__
+ #define __EDKII_GLUE_BASE_MEMORY_LIB__
+ #endif
+ #ifndef __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__
+ #define __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__
+ #endif
+ #ifndef __EDKII_GLUE_DXE_MEMORY_ALLOCATION_LIB__
+ #define __EDKII_GLUE_DXE_MEMORY_ALLOCATION_LIB__
+ #endif
+#endif
+
+//
+// DxeServicesTableLib
+//
+#ifdef __EDKII_GLUE_DXE_SERVICES_TABLE_LIB__
+ #ifndef __EDKII_GLUE_UEFI_LIB__
+ #define __EDKII_GLUE_UEFI_LIB__
+ #endif
+#endif
+
+//
+// UefiLib
+//
+#ifdef __EDKII_GLUE_UEFI_LIB__
+ #ifndef __EDKII_GLUE_BASE_LIB__
+ #define __EDKII_GLUE_BASE_LIB__
+ #endif
+ #ifndef __EDKII_GLUE_BASE_MEMORY_LIB__
+ #define __EDKII_GLUE_BASE_MEMORY_LIB__
+ #endif
+ #ifndef __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__
+ #define __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__
+ #endif
+ #ifndef __EDKII_GLUE_DXE_MEMORY_ALLOCATION_LIB__
+ #define __EDKII_GLUE_DXE_MEMORY_ALLOCATION_LIB__
+ #endif
+#endif
+
+//
+// DxeMemoryAllocationLib
+//
+#ifdef __EDKII_GLUE_DXE_MEMORY_ALLOCATION_LIB__
+ #ifndef __EDKII_GLUE_BASE_MEMORY_LIB__
+ #define __EDKII_GLUE_BASE_MEMORY_LIB__
+ #endif
+ #ifndef __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__
+ #define __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__
+ #endif
+#endif
+
+//
+// DxeSmbusLib
+//
+#ifdef __EDKII_GLUE_DXE_SMBUS_LIB__
+ #ifndef __EDKII_GLUE_BASE_MEMORY_LIB__
+ #define __EDKII_GLUE_BASE_MEMORY_LIB__
+ #endif
+ #ifndef __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__
+ #define __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__
+ #endif
+#endif
+
+//
+// PeiHobLib
+//
+#ifdef __EDKII_GLUE_PEI_HOB_LIB__
+ #ifndef __EDKII_GLUE_BASE_MEMORY_LIB__
+ #define __EDKII_GLUE_BASE_MEMORY_LIB__
+ #endif
+ #ifndef __EDKII_GLUE_PEI_SERVICES_LIB__
+ #define __EDKII_GLUE_PEI_SERVICES_LIB__
+ #endif
+#endif
+
+//
+// PeiMemoryAllocationLib
+//
+#ifdef __EDKII_GLUE_PEI_MEMORY_ALLOCATION_LIB__
+ #ifndef __EDKII_GLUE_BASE_MEMORY_LIB__
+ #define __EDKII_GLUE_BASE_MEMORY_LIB__
+ #endif
+ #ifndef __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__
+ #define __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__
+ #endif
+ //
+ // If necessary, __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__ can be
+ // replaced with __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB__
+ //
+#endif
+
+//
+// PeiResourcePublicationLib
+//
+#ifdef __EDKII_GLUE_PEI_RESOURCE_PUBLICATION_LIB__
+ #ifndef __EDKII_GLUE_PEI_SERVICES_LIB__
+ #define __EDKII_GLUE_PEI_SERVICES_LIB__
+ #endif
+#endif
+
+//
+// PeiServicesLib
+//
+#ifdef __EDKII_GLUE_PEI_SERVICES_LIB__
+ #ifndef __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__
+ #define __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__
+ #endif
+ //
+ // If necessary, __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__ can be
+ // replaced with __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB__
+ //
+#endif
+
+//
+// PeiSmbusLib
+//
+#ifdef __EDKII_GLUE_PEI_SMBUS_LIB__
+ #ifndef __EDKII_GLUE_BASE_MEMORY_LIB__
+ #define __EDKII_GLUE_BASE_MEMORY_LIB__
+ #endif
+ #ifndef __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__
+ #define __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__
+ #endif
+ //
+ // If necessary, __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__ can be
+ // replaced with __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB__
+ //
+#endif
+
+//
+// PeiServicesTablePointerLibMm7
+//
+#ifdef __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__
+ #ifndef __EDKII_GLUE_BASE_LIB__
+ #define __EDKII_GLUE_BASE_LIB__
+ #endif
+#endif
+
+//
+// UefiDriverModelLib
+//
+#ifdef __EDKII_GLUE_UEFI_DRIVER_MODEL_LIB__
+ #ifndef __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__
+ #define __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__
+ #endif
+#endif
+
+
+//
+// UefiBootServicesTableLib
+#ifdef __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__
+#endif
+
+//
+// BasePrintLib
+//
+#ifdef __EDKII_GLUE_BASE_PRINT_LIB__
+ #ifndef __EDKII_GLUE_BASE_LIB__
+ #define __EDKII_GLUE_BASE_LIB__
+ #endif
+#endif
+
+//
+// BaseMemoryLib
+//
+#ifdef __EDKII_GLUE_BASE_MEMORY_LIB__
+ #ifndef __EDKII_GLUE_BASE_LIB__
+ #define __EDKII_GLUE_BASE_LIB__
+ #endif
+#endif
+
+//
+// BasePostCodeLibPort80
+//
+#ifdef __EDKII_GLUE_BASE_POST_CODE_LIB_PORT_80__
+ #ifndef __EDKII_GLUE_BASE_IO_LIB_INTRINSIC__
+ #define __EDKII_GLUE_BASE_IO_LIB_INTRINSIC__
+ #endif
+#endif
+
+//
+// BaseIoLibIntrinsic
+//
+#ifdef __EDKII_GLUE_BASE_IO_LIB_INTRINSIC__
+ #ifndef __EDKII_GLUE_BASE_LIB__
+ #define __EDKII_GLUE_BASE_LIB__
+ #endif
+#endif
+
+//
+// BaseCacheMaintenanceLib
+//
+#ifdef __EDKII_GLUE_BASE_CACHE_MAINTENANCE_LIB__
+ #ifndef __EDKII_GLUE_BASE_LIB__
+ #define __EDKII_GLUE_BASE_LIB__
+ #endif
+#endif
+
+//
+// BaseLib
+//
+#ifdef __EDKII_GLUE_BASE_LIB__
+#endif
+
+//
+// UefiRuntimeServicesTableLib
+//
+#ifdef __EDKII_GLUE_UEFI_RUNTIME_SERVICES_TABLE_LIB__
+
+#endif
+
+//
+// BasePeCoffGetEntryPointLib
+//
+#ifdef __EDKII_GLUE_BASE_PE_COFF_GET_ENTRY_POINT_LIB__
+#endif
+
+//
+// PeiServicesTablePointerLib
+//
+#ifdef __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB__
+#endif
+
+//
+// BasePostCodeLibDebug
+//
+#ifdef __EDKII_GLUE_BASE_POST_CODE_LIB_DEBUG__
+ //
+ // A DebugLib instance
+ // Usually either EdkIIGluePeiDebugLibReportStatusCodeLib or EdkIIGlueDxeDebugLibReportStatusCodeLib is listed in module inf
+ //
+#endif
+
+//
+// PeiDxePostCodeLibReportStatusCode
+//
+#ifdef __EDKII_GLUE_PEI_DXE_POST_CODE_LIB_REPORT_STATUS_CODE__
+ //
+ // PEI or DXE ReportStatusCodeLib instance
+ // Usually EdkIIGluePei/DxeReportStatusCodeLib is listed in module inf
+ //
+#endif
+
+
+//
+// Check against multiple instances of same library class being used
+//
+#if defined(__EDKII_GLUE_PEI_DEBUG_LIB_REPORT_STATUS_CODE__) && defined(__EDKII_GLUE_BASE_DEBUG_LIB_NULL__)
+ #error EdkIIGluePeiDebugLibReportStatusCode and EdkIIGlueBaseDebugLibNull: can only be mutual exclusively used.
+#endif
+
+#if defined(__EDKII_GLUE_DXE_DEBUG_LIB_REPORT_STATUS_CODE__) && defined(__EDKII_GLUE_BASE_DEBUG_LIB_NULL__)
+ #error EdkIIGlueDxeDebugLibReportStatusCode and EdkIIGlueBaseDebugLibNull: can only be mutual exclusively used.
+#endif
+
+#if defined(__EDKII_GLUE_PEI_DEBUG_LIB_REPORT_STATUS_CODE__) && defined(__EDKII_GLUE_DXE_DEBUG_LIB_REPORT_STATUS_CODE__)
+ #error EdkIIGluePeiDebugLibReportStatusCode and EdkIIGlueDxeDebugLibReportStatusCode: can only be mutual exclusively used.
+#endif
+
+#if defined(__EDKII_GLUE_BASE_PCI_LIB_PCI_EXPRESS__) && defined(__EDKII_GLUE_BASE_PCI_LIB_CF8__)
+ #error EdkIIGluePciLibPciExpress and EdkIIGluePciLibCf8: can only be mutual exclusively used.
+#endif
+
+#if defined (__EDKII_GLUE_DXE_HOB_LIB__) && defined(__EDKII_GLUE_PEI_HOB_LIB__)
+ #error EdkIIGlueDxeHobLib and EdkIIGluePeiHobLib: can only be mutual exclusively used.
+#endif
+
+#if defined(__EDKII_GLUE_BASE_POST_CODE_LIB_PORT_80__) && defined(__EDKII_GLUE_BASE_POST_CODE_LIB_DEBUG__)
+ #error EdkIIGlueBasePostCodeLibPort80 and EdkIIGlueBasePostCodeLibDebug: can only be mutual exclusively used.
+#endif
+
+#if defined(__EDKII_GLUE_BASE_POST_CODE_LIB_PORT_80__) && defined(__EDKII_GLUE_PEI_DXE_POST_CODE_LIB_REPORT_STATUS_CODE__)
+ #error EdkIIGlueBasePostCodeLibPort80 and EdkIIGluePeiDxePostCodeLibReportStatusCode: can only be mutual exclusively used.
+#endif
+
+#if defined(__EDKII_GLUE_BASE_POST_CODE_LIB_DEBUG__) && defined(__EDKII_GLUE_PEI_DXE_POST_CODE_LIB_REPORT_STATUS_CODE__)
+ #error EdkIIGlueBasePostCodeLibDebug and EdkIIGluePeiDxePostCodeLibReportStatusCode: can only be mutual exclusively used.
+#endif
+
+#if defined(__EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB__) && defined(__EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__)
+ #error EdkIIGluePeiServicesTablePointerLib and EdkIIGluePeiServicesTablePointerLibMm7: can only be mutual exclusively used.
+#endif
+
+#if defined(__EDKII_GLUE_DXE_REPORT_STATUS_CODE_LIB__) && defined(__EDKII_GLUE_PEI_REPORT_STATUS_CODE_LIB__)
+ #error EdkIIGlueDxeReportStatusCodeLib and EdkIIGluePeiReportStatusCodeLib: can only be mutual exclusively used.
+#endif
+
+#if defined(__EDKII_GLUE_SMM_RUNTIME_DXE_REPORT_STATUS_CODE_LIB__) && defined(__EDKII_GLUE_PEI_REPORT_STATUS_CODE_LIB__)
+ #error EdkIIGlueSmmRuntimeDxeReportStatusCodeLib and EdkIIGluePeiReportStatusCodeLib: can only be mutual exclusively used.
+#endif
+
+#if defined(__EDKII_GLUE_DXE_REPORT_STATUS_CODE_LIB__) && defined(__EDKII_GLUE_SMM_RUNTIME_DXE_REPORT_STATUS_CODE_LIB__)
+ #error EdkIIGlueDxeReportStatusCodeLib and EdkIIGlueSmmRuntimeDxeReportStatusCodeLib: can only be mutual exclusively used.
+#endif
+
+#if defined(__EDKII_GLUE_DXE_MEMORY_ALLOCATION_LIB__) && defined(__EDKII_GLUE_PEI_MEMORY_ALLOCATION_LIB__)
+ #error EdkIIGlueDxeMemoryAllocationLib and EdkIIGluePeiMemoryAllocationLib: can only be mutual exclusively used.
+#endif
+
+#if defined(__EDKII_GLUE_DXE_SMBUS_LIB__) && defined(__EDKII_GLUE_PEI_SMBUS_LIB__)
+ #error EdkIIGlueDxeSmbusLib and EdkIIGluePeiSmbusLib: can only be mutual exclusively used.
+#endif
+
+//
+// Some instances must be supplied
+//
+#ifdef __EDKII_GLUE_PEI_DEBUG_LIB_REPORT_STATUS_CODE__
+ #if !defined(__EDKII_GLUE_PEI_REPORT_STATUS_CODE_LIB__)
+ #error You use EdkIIGluePeiDebugLibReportStatusCode, \
+ so EdkIIGluePeiReportStatusCodeLib must be supplied
+ #endif
+#endif
+
+#ifdef __EDKII_GLUE_DXE_DEBUG_LIB_REPORT_STATUS_CODE__
+ #if !defined(__EDKII_GLUE_DXE_REPORT_STATUS_CODE_LIB__) \
+ && !defined(__EDKII_GLUE_SMM_RUNTIME_DXE_REPORT_STATUS_CODE_LIB__)
+ #error You use EdkIIGlueDxeDebugLibReportStatusCode, \
+ so either EdkIIGlueDxeReportStatusCodeLib, or EdkIIGlueSmmRuntimeDxeReportStatusCodeLib must be supplied
+ #endif
+#endif
+
+#ifdef __EDKII_GLUE_BASE_POST_CODE_LIB_DEBUG__
+ #if !defined(__EDKII_GLUE_PEI_DEBUG_LIB_REPORT_STATUS_CODE__) \
+ && !defined(__EDKII_GLUE_DXE_DEBUG_LIB_REPORT_STATUS_CODE__) \
+ && !defined(__EDKII_GLUE_BASE_DEBUG_LIB_NULL__)
+ #error You use EdkIIGlueBasePostCodeLibDebug, so either EdkIIGluePeiDebugLibReportStatusCode, EdkIIGlueDxeDebugLibReportStatusCode, \
+ or EdkIIGlueBaseDebugLibNull must be supplied
+ #endif
+#endif
+
+//
+// EdkIIGlueUefiDriverModelLib used, but no Driver Binding Protocol defined
+//
+#ifdef __EDKII_GLUE_UEFI_DRIVER_MODEL_LIB__
+ #ifndef __EDKII_GLUE_DRIVER_BINDING_PROTOCOL_INSTANCE__
+ #error "EdkIIGlueUefiDriverModelLib used, but no Driver Binding Protocol defined. Please define __EDKII_GLUE_DRIVER_BINDING_PROTOCOL_INSTANCE__."
+ #endif
+#endif
+
+//
+// EdkII Glue Library Constructors:
+// NOTE: the constructors must be called according to dependency order
+//
+// UefiBootServicesTableLib UefiBootServicesTableLibConstructor()
+// UefiRuntimeServicesTableLib UefiRuntimeServicesTableLibConstructor()
+// EdkDxeRuntimeDriverLib RuntimeDriverLibConstruct()
+// SmmRuntimeDxeReportStatusCodeLib ReportStatusCodeLibConstruct()
+// DxeHobLib HobLibConstructor()
+// UefiDriverModelLib UefiDriverModelLibConstructor()
+// PeiServicesTablePointerLib PeiServicesTablePointerLibConstructor()
+// PeiServicesTablePointerLibMm7 PeiServicesTablePointerLibConstructor()
+// DxeSmbusLib SmbusLibConstructor()
+// DxeServicesTableLib DxeServicesTableLibConstructor()
+//
+
+#ifdef __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB__
+EFI_STATUS
+UefiBootServicesTableLibConstructor (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ );
+#endif
+
+#ifdef __EDKII_GLUE_UEFI_RUNTIME_SERVICES_TABLE_LIB__
+EFI_STATUS
+UefiRuntimeServicesTableLibConstructor (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ );
+#endif
+
+#ifdef __EDKII_GLUE_EDK_DXE_RUNTIME_DRIVER_LIB__
+EFI_STATUS
+RuntimeDriverLibConstruct (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ );
+#endif
+
+#ifdef __EDKII_GLUE_SMM_RUNTIME_DXE_REPORT_STATUS_CODE_LIB__
+EFI_STATUS
+EFIAPI
+ReportStatusCodeLibConstruct (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ );
+#endif
+
+#ifdef __EDKII_GLUE_DXE_HOB_LIB__
+EFI_STATUS
+HobLibConstructor (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ );
+#endif
+
+#ifdef __EDKII_GLUE_UEFI_DRIVER_MODEL_LIB__
+EFI_STATUS
+UefiDriverModelLibConstructor (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ );
+#endif
+
+#ifdef __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB__
+EFI_STATUS
+PeiServicesTablePointerLibConstructor (
+ IN EFI_FFS_FILE_HEADER *FfsHeader,
+ IN EFI_PEI_SERVICES **PeiServices
+ );
+#endif
+
+#ifdef __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_MM7__
+EFI_STATUS
+PeiServicesTablePointerLibConstructor (
+ IN EFI_FFS_FILE_HEADER *FfsHeader,
+ IN EFI_PEI_SERVICES **PeiServices
+ );
+#endif
+
+#ifdef __EDKII_GLUE_DXE_SMBUS_LIB__
+EFI_STATUS
+EFIAPI
+SmbusLibConstructor (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ );
+#endif
+
+#ifdef __EDKII_GLUE_DXE_SERVICES_TABLE_LIB__
+EFI_STATUS
+DxeServicesTableLibConstructor (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ );
+#endif
+
+//
+// EdkII Glue Library Destructors:
+// NOTE: the destructors must be called according to dependency order
+//
+// UefiDriverModelLibDestructor UefiDriverModelLibDestructor()
+// SmmRuntimeDxeReportStatusCodeLib ReportStatusCodeLibDestruct()
+// EdkDxeRuntimeDriverLib RuntimeDriverLibDeconstruct()
+//
+#ifdef __EDKII_GLUE_UEFI_DRIVER_MODEL_LIB__
+EFI_STATUS
+UefiDriverModelLibDestructor (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ );
+#endif
+
+#ifdef __EDKII_GLUE_SMM_RUNTIME_DXE_REPORT_STATUS_CODE_LIB__
+EFI_STATUS
+EFIAPI
+ReportStatusCodeLibDestruct (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ );
+#endif
+
+#ifdef __EDKII_GLUE_EDK_DXE_RUNTIME_DRIVER_LIB__
+EFI_STATUS
+RuntimeDriverLibDeconstruct (
+ VOID
+ );
+#endif
+
+#endif
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/DxeDepex.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/DxeDepex.h
new file mode 100644
index 0000000..24d2d07
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/DxeDepex.h
@@ -0,0 +1,34 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ DxeDepex.h
+
+Abstract:
+
+ This file is used by .dxs file. To write common .dxs for R8.x and R9, a
+ header file named DxeDepex.h musted be present.
+
+--*/
+
+
+#ifndef __EDKII_GLUELIB_DXEDEPEX_H__
+#define __EDKII_GLUELIB_DXEDEPEX_H__
+
+
+//
+// this file is used by .dxs file, just a place holder
+//
+
+
+#endif
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueBase.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueBase.h
new file mode 100644
index 0000000..d24c581
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueBase.h
@@ -0,0 +1,98 @@
+/*++
+
+Copyright (c) 2004 - 2011, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ EdkIIGlueBase.h
+
+Abstract:
+
+ Root include file for Base modules
+
+--*/
+
+#ifndef __EDKII_GLUE_BASE_H__
+#define __EDKII_GLUE_BASE_H__
+
+//
+// Using this header means building with EdkIIGlueLib
+//
+#ifndef BUILD_WITH_EDKII_GLUE_LIB
+ #define BUILD_WITH_EDKII_GLUE_LIB
+#endif
+
+#ifndef BUILD_WITH_GLUELIB
+ #define BUILD_WITH_GLUELIB
+#endif
+
+//
+// General Type & API definitions
+//
+
+#include "EfiBind.h"
+#include "EfiTypes.h"
+#include "EfiError.h"
+#include "Common\EdkIIGlueBaseTypes.h"
+#include "EfiImage.h"
+#include "EfiPeOptionalHeader.h"
+#include "EfiStdArg.h"
+#include "EfiDebug.h"
+#include "EdkIIGlueProcessorBind.h"
+
+//
+// Some Status Code data type definitions are in TianoSpecTypes.h in R8.5
+//
+#if (TIANO_RELEASE_VERSION <= 0x00080005)
+#include "TianoSpecTypes.h"
+#endif
+#include "EfiStatusCode.h"
+
+//
+// R8.x Library headers used by EdkII Glue Libraries
+//
+#include "LinkedList.h"
+#include "EfiCommonLib.h"
+
+#include "Common\EdkIIGlueDefinitionChangesBase.h"
+
+//
+// EdkII Glue Library Class headers
+//
+
+#include "Library\EdkIIGlueBaseLib.h"
+#include "Library\EdkIIGlueBaseMemoryLib.h"
+#include "Library\EdkIIGlueCacheMaintenanceLib.h"
+#include "Library\EdkIIGlueIoLib.h"
+#include "Library\EdkIIGluePciCf8Lib.h"
+#include "Library\EdkIIGluePciExpressLib.h"
+#include "Library\EdkIIGluePciLib.h"
+#include "Library\EdkIIGluePeCoffGetEntryPointLib.h"
+#include "Library\EdkIIGluePeCoffLib.h"
+#include "Library\EdkIIGluePostCodeLib.h"
+#include "Library\EdkIIGluePrintLib.h"
+#include "Library\EdkIIGlueTimerLib.h"
+#include "Library\EdkIIGlueUefiDecompressLib.h"
+#include "Library\EdkIIGlueDebugLib.h"
+
+//
+// Publish MDE Library PCDs
+//
+#include "Pcd\EdkIIGluePcdBaseLib.h"
+#include "Pcd\EdkIIGluePcdDebugLib.h"
+#include "Pcd\EdkIIGluePcdIoLib.h"
+#include "Pcd\EdkIIGluePcdPciExpressLib.h"
+#include "Pcd\EdkIIGluePcdPostCodeLib.h"
+#include "Pcd\EdkIIGluePcdReportStatusCodeLib.h"
+#include "Pcd\EdkIIGluePcdTimerLib.h"
+#include "Pcd\EdkIIGluePcdPerformanceLib.h"
+
+#endif
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueConfig.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueConfig.h
new file mode 100644
index 0000000..5dabdff
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueConfig.h
@@ -0,0 +1,173 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ EdkIIGlueConfig.h
+
+Abstract:
+
+ Configurable items provided by GlueLib
+
+--*/
+
+#ifndef __EDKII_GLUE_CONFIG_H__
+#define __EDKII_GLUE_CONFIG_H__
+
+#include "EdkIIGlueProcessorBind.h"
+
+//
+// Glue Library version
+//
+// 0x3000 - the 3rd release
+// 0x5000 - support IPF. Jan, 2007
+// 0x6000 - support EBC. Feb, 2007
+// 0x7000 - size reduction, Jun, 2007
+// 0x7100 - backward compatibility supported, Jun, 2007
+//
+// For reference only, don't change the value
+//
+#define EDKII_GLUE_LIBRARY_VERSION 0x7100
+
+
+//
+// Check to make sure EFI_SPECIFICATION_VERSION and TIANO_RELEASE_VERSION are defined.
+//
+#if !defined(EFI_SPECIFICATION_VERSION)
+ #error EFI_SPECIFICATION_VERSION not defined
+#elif !defined(TIANO_RELEASE_VERSION)
+ #error TIANO_RELEASE_VERSION not defined
+#elif (TIANO_RELEASE_VERSION == 0)
+ #error TIANO_RELEASE_VERSION can not be zero
+#endif
+
+
+//
+// Glue Library debug flag
+//
+// Controls debug ON/OFF of GlueLib itself, no
+// effect on any other libraries or modules
+//
+// Values:
+// FALSE : debug off
+// any TRUE value : debug on
+//
+#define EDKII_GLUE_LIBRARY_DEBUG_ENABLE 0
+
+
+//
+// max unicode string length
+//
+#define EDKII_GLUE_MaximumUnicodeStringLength 1000000
+
+//
+// max ascii string length
+//
+#define EDKII_GLUE_MaximumAsciiStringLength 1000000
+
+//
+// spin lock timeout
+//
+#define EDKII_GLUE_SpinLockTimeout 10000000
+
+//
+// max linked list length
+//
+#define EDKII_GLUE_MaximumLinkedListLength 1000000
+
+//
+// debug print level
+//
+#ifndef EDKII_GLUE_DebugPrintErrorLevel
+#define EDKII_GLUE_DebugPrintErrorLevel EFI_D_ERROR
+#endif
+
+//
+// debug propery mask
+//
+#ifndef EDKII_GLUE_DebugPropertyMask
+#define EDKII_GLUE_DebugPropertyMask ( DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED \
+ | DEBUG_PROPERTY_DEBUG_PRINT_ENABLED \
+ | DEBUG_PROPERTY_DEBUG_CODE_ENABLED \
+ | DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED \
+ | DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED \
+ )
+#endif
+
+//
+// clear memory value
+//
+#define EDKII_GLUE_DebugClearMemoryValue 0xAF
+
+//
+// pci express base address
+//
+#ifndef EDKII_GLUE_PciExpressBaseAddress
+#define EDKII_GLUE_PciExpressBaseAddress 0xE0000000
+#endif
+
+//
+//
+// This value is FSB Clock frequency. Its unit is Hz and its
+// default value is 200000000, that means FSB frequency is 200Mhz.
+//
+#ifndef EDKII_GLUE_FSBClock
+#define EDKII_GLUE_FSBClock 200000000
+#endif
+
+//
+// This Value is MSR offset for platform information in hex
+//
+#ifndef EDKII_GLUE_PlatformInfoMsr
+#define EDKII_GLUE_PlatformInfoMsr 0xCE
+#endif
+
+//
+// This Value is MSR offset for APIC Base in hex
+//
+#ifndef EDKII_GLUE_XAPICBaseMsr
+#define EDKII_GLUE_XAPICBaseMsr 0x1B
+#endif
+
+//
+// This Value is MSR offset for EXT XAPIC Logical APIC ID in hex
+//
+#ifndef EDKII_GLUE_ExtXAPICLogicalAPICIdMsr
+#define EDKII_GLUE_ExtXAPICLogicalAPICIdMsr 0x802
+#endif
+
+//
+// post code property mask
+//
+#define EDKII_GLUE_PostCodePropertyMask ( POST_CODE_PROPERTY_POST_CODE_ENABLED \
+ | POST_CODE_PROPERTY_POST_CODE_DESCRIPTION_ENABLED \
+ )
+
+//
+// status code property mask
+//
+#define EDKII_GLUE_ReportStatusCodePropertyMask ( REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED \
+ | REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED \
+ | REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED \
+ )
+
+//
+// for IPF only
+// The base address of IPF IO Block
+//
+#ifdef MDE_CPU_IPF
+#ifndef EDKII_GLUE_IoBlockBaseAddressForIpf
+#define EDKII_GLUE_IoBlockBaseAddressForIpf 0x0ffffc000000
+#endif
+#endif
+
+#endif
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueDxe.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueDxe.h
new file mode 100644
index 0000000..2a631fc
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueDxe.h
@@ -0,0 +1,256 @@
+/*++
+
+Copyright (c) 2004 - 2011, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ EdkIIGlueDxe.h
+
+Abstract:
+
+ Root include file for DXE modules
+
+--*/
+
+#ifndef __EDKII_GLUE_DXE_H__
+#define __EDKII_GLUE_DXE_H__
+
+
+//
+// General Type & API definitions
+//
+
+#include "Tiano.h"
+#include "BootMode.h"
+#include "EfiBootScript.h"
+#include "EfiCapsule.h"
+#include "EfiDependency.h"
+#include "EfiImageFormat.h"
+#include "EfiImage.h"
+#include "EfiPeOptionalHeader.h"
+#include "EfiFirmwareVolumeHeader.h"
+#include "EfiFirmwareFileSystem.h"
+#include "PeiHob.h"
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
+#include "TianoHii.h"
+#else
+#include "EfiInternalFormRepresentation.h"
+#endif
+#include "EfiStatusCode.h"
+
+//
+// GUID definitions
+//
+
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+#include EFI_GUID_DEFINITION (EventGroup)
+#include EFI_GUID_DEFINITION (EventLegacybios)
+#include EFI_GUID_DEFINITION (FrameworkDevicePath)
+
+#include EFI_PROTOCOL_DEFINITION (EdidActive)
+#include EFI_PROTOCOL_DEFINITION (EdidDiscovered)
+#include EFI_PROTOCOL_DEFINITION (EdidOverride)
+#include EFI_PROTOCOL_DEFINITION (GraphicsOutput)
+#include EFI_PROTOCOL_DEFINITION (Hash)
+#include EFI_PROTOCOL_DEFINITION (ScsiPassThruExt)
+#include EFI_PROTOCOL_DEFINITION (TapeIo)
+#endif
+
+#include EFI_GUID_DEFINITION (Acpi)
+#include EFI_GUID_DEFINITION (AcpiTableStorage)
+#include EFI_GUID_DEFINITION (Apriori)
+#include EFI_GUID_DEFINITION (Capsule)
+#include EFI_GUID_DEFINITION (DataHubRecords)
+#include EFI_GUID_DEFINITION (DebugImageInfoTable)
+#include EFI_GUID_DEFINITION (DxeServices)
+#include EFI_GUID_DEFINITION (FirmwareFileSystem)
+#include EFI_GUID_DEFINITION (GlobalVariable)
+#include EFI_GUID_DEFINITION (Gpt)
+#include EFI_GUID_DEFINITION (Hob)
+#include EFI_GUID_DEFINITION (MemoryAllocationHob)
+#include EFI_GUID_DEFINITION (Mps)
+#include EFI_GUID_DEFINITION (PcAnsi)
+#include EFI_GUID_DEFINITION (SalSystemTable)
+#include EFI_GUID_DEFINITION (Smbios)
+//#include EFI_GUID_DEFINITION (SmmCommunicate)
+#include EFI_GUID_DEFINITION (SmramMemoryReserve)
+//
+// *** NOTE ***: StatusCodeDataTypeId definition differences need to be
+// resolved when porting a module to real EDK II
+//
+#include EFI_GUID_DEFINITION (StatusCodeDataTypeId)
+
+//
+// Protocol definitions
+//
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
+#include EFI_PROTOCOL_DEFINITION (FormBrowser2)
+#include EFI_PROTOCOL_DEFINITION (HiiConfigAccess)
+#include EFI_PROTOCOL_DEFINITION (HiiConfigRouting)
+#include EFI_PROTOCOL_DEFINITION (HiiDatabase)
+#include EFI_PROTOCOL_DEFINITION (HiiFont)
+#include EFI_PROTOCOL_DEFINITION (HiiImage)
+#include EFI_PROTOCOL_DEFINITION (HiiString)
+#endif
+
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+#include EFI_PROTOCOL_DEFINITION (DevicePathFromText)
+#include EFI_PROTOCOL_DEFINITION (DevicePathToText)
+#include EFI_PROTOCOL_DEFINITION (DevicePathUtilities)
+#include EFI_PROTOCOL_DEFINITION (Dhcp4)
+#include EFI_PROTOCOL_DEFINITION (Ip4)
+#include EFI_PROTOCOL_DEFINITION (Ip4Config)
+#include EFI_PROTOCOL_DEFINITION (IScsiInitiatorName)
+#include EFI_PROTOCOL_DEFINITION (UsbHostController)
+#include EFI_PROTOCOL_DEFINITION (ManagedNetwork)
+#include EFI_PROTOCOL_DEFINITION (Mtftp4)
+#include EFI_PROTOCOL_DEFINITION (ServiceBinding)
+#include EFI_PROTOCOL_DEFINITION (Tcp4)
+#include EFI_PROTOCOL_DEFINITION (Udp4)
+#include EFI_PROTOCOL_DEFINITION (Arp)
+// check here: currently not implementated
+//#include EFI_PROTOCOL_DEFINITION (AuthenticationInfo)
+#endif
+
+#include EFI_PROTOCOL_DEFINITION (AcpiSupport)
+#include EFI_PROTOCOL_DEFINITION (Bis)
+#include EFI_PROTOCOL_DEFINITION (BlockIo)
+#include EFI_PROTOCOL_DEFINITION (BootScriptSave)
+#include EFI_PROTOCOL_DEFINITION (BusSpecificDriverOverride)
+#include EFI_PROTOCOL_DEFINITION (ComponentName)
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+#include EFI_PROTOCOL_DEFINITION (ComponentName2)
+#endif
+#include EFI_PROTOCOL_DEFINITION (CpuIo)
+#include EFI_PROTOCOL_DEFINITION (DataHub)
+#include EFI_PROTOCOL_DEFINITION (DebugPort)
+#include EFI_PROTOCOL_DEFINITION (DebugSupport)
+#include EFI_PROTOCOL_DEFINITION (Decompress)
+#include EFI_PROTOCOL_DEFINITION (DeviceIo)
+#include EFI_PROTOCOL_DEFINITION (DevicePath)
+#include EFI_PROTOCOL_DEFINITION (DiskIo)
+#include EFI_PROTOCOL_DEFINITION (DriverBinding)
+#include EFI_PROTOCOL_DEFINITION (DriverConfiguration)
+#include EFI_PROTOCOL_DEFINITION (DriverDiagnostics)
+#include EFI_PROTOCOL_DEFINITION (Ebc)
+#include EFI_PROTOCOL_DEFINITION (EfiNetworkInterfaceIdentifier)
+#include EFI_PROTOCOL_DEFINITION (FileInfo)
+#include EFI_PROTOCOL_DEFINITION (FileSystemInfo)
+#include EFI_PROTOCOL_DEFINITION (FileSystemVolumeLabelInfo)
+#include EFI_PROTOCOL_DEFINITION (FirmwareVolume)
+#include EFI_PROTOCOL_DEFINITION (FirmwareVolumeBlock)
+#include EFI_PROTOCOL_DEFINITION (FirmwareVolumeDispatch)
+#if (EFI_SPECIFICATION_VERSION < 0x0002000A)
+#include EFI_PROTOCOL_DEFINITION (FormBrowser)
+#include EFI_PROTOCOL_DEFINITION (FormCallback)
+#endif
+#include EFI_PROTOCOL_DEFINITION (GuidedSectionExtraction)
+#if (EFI_SPECIFICATION_VERSION < 0x0002000A)
+#include EFI_PROTOCOL_DEFINITION (Hii)
+#endif
+#include EFI_PROTOCOL_DEFINITION (IdeControllerInit)
+#include EFI_PROTOCOL_DEFINITION (IncompatiblePciDeviceSupport)
+#include EFI_PROTOCOL_DEFINITION (Legacy8259)
+#include EFI_PROTOCOL_DEFINITION (LegacyBios)
+#include EFI_PROTOCOL_DEFINITION (LegacyBiosPlatform)
+#include EFI_PROTOCOL_DEFINITION (LegacyInterrupt)
+#include EFI_PROTOCOL_DEFINITION (LegacyRegion)
+#include EFI_PROTOCOL_DEFINITION (LoadedImage)
+#include EFI_PROTOCOL_DEFINITION (LoadFile)
+#include EFI_PROTOCOL_DEFINITION (PciHostBridgeResourceAllocation)
+#include EFI_PROTOCOL_DEFINITION (PciHotplugInit)
+#include EFI_PROTOCOL_DEFINITION (PciIo)
+#include EFI_PROTOCOL_DEFINITION (PciPlatform)
+#include EFI_PROTOCOL_DEFINITION (PciRootBridgeIo)
+#include EFI_PROTOCOL_DEFINITION (PlatformDriverOverride)
+#include EFI_PROTOCOL_DEFINITION (PxeBaseCode)
+#include EFI_PROTOCOL_DEFINITION (PxeBaseCodeCallBack)
+#include EFI_PROTOCOL_DEFINITION (ScsiIo)
+#include EFI_PROTOCOL_DEFINITION (ScsiPassThru)
+#include EFI_PROTOCOL_DEFINITION (SectionExtraction)
+#include EFI_PROTOCOL_DEFINITION (SerialIo)
+#include EFI_PROTOCOL_DEFINITION (SimpleFilesystem)
+#include EFI_PROTOCOL_DEFINITION (SimpleNetwork)
+#include EFI_PROTOCOL_DEFINITION (SimplePointer)
+#include EFI_PROTOCOL_DEFINITION (SimpleTextIn)
+#include EFI_PROTOCOL_DEFINITION (SimpleTextOut)
+#include EFI_PROTOCOL_DEFINITION (Smbus)
+#include EFI_PROTOCOL_DEFINITION (SmmAccess)
+#include EFI_PROTOCOL_DEFINITION (SmmBase)
+#include EFI_PROTOCOL_DEFINITION (SmmControl)
+#include EFI_PROTOCOL_DEFINITION (SmmGpiDispatch)
+#include EFI_PROTOCOL_DEFINITION (SmmIchnDispatch)
+#include EFI_PROTOCOL_DEFINITION (SmmPeriodicTimerDispatch)
+#include EFI_PROTOCOL_DEFINITION (SmmPowerButtonDispatch)
+#include EFI_PROTOCOL_DEFINITION (SmmStandbyButtonDispatch)
+#include EFI_PROTOCOL_DEFINITION (SmmStatusCode)
+#include EFI_PROTOCOL_DEFINITION (SmmSwDispatch)
+#include EFI_PROTOCOL_DEFINITION (SmmSxDispatch)
+#include EFI_PROTOCOL_DEFINITION (SmmUsbDispatch)
+#include EFI_PROTOCOL_DEFINITION (UgaDraw)
+#include EFI_PROTOCOL_DEFINITION (UnicodeCollation)
+#include EFI_PROTOCOL_DEFINITION (UsbHostController)
+#include EFI_PROTOCOL_DEFINITION (UsbIo)
+#include EFI_PROTOCOL_DEFINITION (SecurityPolicy)
+#include EFI_PROTOCOL_DEFINITION (LoadPe32Image)
+
+//
+// Arch Protocol definitions
+//
+
+#include EFI_ARCH_PROTOCOL_DEFINITION (Bds)
+#include EFI_ARCH_PROTOCOL_DEFINITION (Cpu)
+#include EFI_ARCH_PROTOCOL_DEFINITION (Metronome)
+#include EFI_ARCH_PROTOCOL_DEFINITION (Monotoniccounter)
+#include EFI_ARCH_PROTOCOL_DEFINITION (RealTimeClock)
+#include EFI_ARCH_PROTOCOL_DEFINITION (Reset)
+#include EFI_ARCH_PROTOCOL_DEFINITION (Runtime)
+#include EFI_ARCH_PROTOCOL_DEFINITION (Security)
+#include EFI_ARCH_PROTOCOL_DEFINITION (StatusCode)
+#include EFI_ARCH_PROTOCOL_DEFINITION (Timer)
+#include EFI_ARCH_PROTOCOL_DEFINITION (Variable)
+#include EFI_ARCH_PROTOCOL_DEFINITION (Variablewrite)
+#include EFI_ARCH_PROTOCOL_DEFINITION (WatchdogTimer)
+
+//
+// R8.x Library headers used by EdkII Glue Libraries
+//
+#include "EfiDriverLib.h"
+#include "EfiCapsule.h"
+
+#include "Common\EdkIIGlueDefinitionChangesDxe.h"
+
+
+//
+// EdkII Glue Library Class headers
+//
+
+#include "EdkIIGlueBase.h"
+#include "Library\EdkIIGlueDebugLib.h"
+#include "Library\EdkIIGluePostCodeLib.h"
+#include "Library\EdkIIGlueReportStatusCodeLib.h"
+#include "Library\EdkIIGlueHiiLib.h"
+#include "Library\EdkIIGlueHobLib.h"
+#include "Library\EdkIIGlueMemoryAllocationLib.h"
+#include "Library\EdkIIGlueSmbusLib.h"
+#include "Library\EdkIIGlueDxeRuntimeDriverLib.h"
+#include "Library\EdkIIGlueDxeServicesTableLib.h"
+#include "Library\EdkIIGlueDxeSmmDriverEntryPoint.h"
+#include "Library\EdkIIGlueDevicePathLib.h"
+#include "Library\EdkIIGlueUefiLib.h"
+#include "Library\EdkIIGlueUefiDecompressLib.h"
+#include "Library\EdkIIGlueUefiDriverModelLib.h"
+#include "Library\EdkIIGlueUefiBootServicesTableLib.h"
+#include "Library\EdkIIGlueUefiDriverEntryPoint.h"
+#include "Library\EdkIIGlueUefiRuntimeServicesTableLib.h"
+#include "Library\EdkIIGlueFirmwarePerformanceLib.h"
+
+#endif
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueInclude.cif b/EDK/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueInclude.cif
new file mode 100644
index 0000000..f85ea5d
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueInclude.cif
@@ -0,0 +1,64 @@
+<component>
+ name = "EdkIIGlueInclude"
+ category = ModulePart
+ LocalRoot = "EDK\Foundation\Library\EdkIIGlueLib\Include\"
+ RefName = "EdkIIGlueInclude"
+[files]
+"AutoGen.h"
+"DxeDepex.h"
+"EdkIIGlueBase.h"
+"EdkIIGlueConfig.h"
+"EdkIIGlueDxe.h"
+"EdkIIGluePeim.h"
+"EdkIIGlueUefi.h"
+"PeimDepex.h"
+"Common\EdkIIGlueBaseTypes.h"
+"Common\EdkIIGlueDefinitionChangesBase.h"
+"Common\EdkIIGlueDefinitionChangesDxe.h"
+"Common\EdkIIGlueDefinitionChangesPeim.h"
+"Common\EdkIIGlueDependencies.h"
+"Ia32\EdkIIGlueProcessorBind.h"
+"Library\EdkIIGlueBaseLib.h"
+"Library\EdkIIGlueBaseMemoryLib.h"
+"Library\EdkIIGlueCacheMaintenanceLib.h"
+"Library\EdkIIGlueDebugLib.h"
+"Library\EdkIIGlueDevicePathLib.h"
+"Library\EdkIIGlueDxeRuntimeDriverLib.h"
+"Library\EdkIIGlueDxeServicesTableLib.h"
+"Library\EdkIIGlueDxeSmmDriverEntryPoint.h"
+"Library\EdkIIGlueHiiLib.h"
+"Library\EdkIIGlueHobLib.h"
+"Library\EdkIIGlueIoLib.h"
+"Library\EdkIIGlueMemoryAllocationLib.h"
+"Library\EdkIIGluePciCf8Lib.h"
+"Library\EdkIIGluePciExpressLib.h"
+"Library\EdkIIGluePciLib.h"
+"Library\EdkIIGluePeCoffGetEntryPointLib.h"
+"Library\EdkIIGluePeCoffLib.h"
+"Library\EdkIIGluePeimEntryPoint.h"
+"Library\EdkIIGluePeiServicesLib.h"
+"Library\EdkIIGluePeiServicesTablePointerLib.h"
+"Library\EdkIIGluePostCodeLib.h"
+"Library\EdkIIGluePrintLib.h"
+"Library\EdkIIGlueReportStatusCodeLib.h"
+"Library\EdkIIGlueResourcePublicationLib.h"
+"Library\EdkIIGlueSmbusLib.h"
+"Library\EdkIIGlueTimerLib.h"
+"Library\EdkIIGlueUefiBootServicesTableLib.h"
+"Library\EdkIIGlueUefiDecompressLib.h"
+"Library\EdkIIGlueUefiDriverEntryPoint.h"
+"Library\EdkIIGlueUefiDriverModelLib.h"
+"Library\EdkIIGlueUefiLib.h"
+"Library\EdkIIGlueUefiRuntimeServicesTableLib.h"
+"Library\EdkIIGlueFirmwarePerformanceLib.h"
+"Pcd\EdkIIGluePcd.h"
+"Pcd\EdkIIGluePcdBaseLib.h"
+"Pcd\EdkIIGluePcdDebugLib.h"
+"Pcd\EdkIIGluePcdPciExpressLib.h"
+"Pcd\EdkIIGluePcdPostCodeLib.h"
+"Pcd\EdkIIGluePcdReportStatusCodeLib.h"
+"x64\EdkIIGlueProcessorBind.h"
+"Pcd\EdkIIGluePcdIoLib.h"
+"Pcd\EdkIIGluePcdTimerLib.h"
+"Pcd\EdkIIGluePcdPerformanceLib.h"
+<endComponent>
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/EdkIIGluePeim.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/EdkIIGluePeim.h
new file mode 100644
index 0000000..a106568
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/EdkIIGluePeim.h
@@ -0,0 +1,114 @@
+/*++
+
+Copyright (c) 2004 - 2011, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ EdkIIGluePeim.h
+
+Abstract:
+
+ Root include file for PEI Modules
+
+**/
+
+
+#ifndef __EDKII_GLUE_PEIM_H__
+#define __EDKII_GLUE_PEIM_H__
+
+
+//
+// Check to make sure TIANO_RELEASE_VERSION is defined
+//
+#if !defined(TIANO_RELEASE_VERSION)
+ #error TIANO_RELEASE_VERSION not defined
+#elif (TIANO_RELEASE_VERSION == 0)
+ #error TIANO_RELEASE_VERSION can not be zero
+#endif
+
+//
+// General Type & API definitions
+//
+
+#include "Pei.h"
+#include "EfiBootScript.h"
+#include "EfiImage.h"
+#include "EfiPeOptionalHeader.h"
+#include "EfiCapsule.h"
+#include EFI_PROTOCOL_DEFINITION (DevicePath)
+#include "TianoDevicePath.h"
+
+//
+// GUID definitions
+//
+
+#include EFI_GUID_DEFINITION (Apriori)
+#include EFI_GUID_DEFINITION (Capsule)
+#include EFI_GUID_DEFINITION (DxeServices)
+#include EFI_GUID_DEFINITION (Hob)
+#include EFI_GUID_DEFINITION (MemoryAllocationHob)
+#include EFI_GUID_DEFINITION (FirmwareFileSystem)
+#include EFI_GUID_DEFINITION (SmramMemoryReserve)
+#include EFI_GUID_DEFINITION (DataHubRecords)
+//
+// *** NOTE ***: StatusCodeDataTypeId definition differences need to be
+// resolved when porting a module to real EDK II
+//
+#include EFI_GUID_DEFINITION (StatusCodeDataTypeId)
+
+//
+// Ppi definitions
+//
+
+#include EFI_PPI_DEFINITION (BlockIo)
+#include EFI_PPI_DEFINITION (BootInRecoveryMode)
+#include EFI_PPI_DEFINITION (BootScriptExecuter)
+#include EFI_PPI_DEFINITION (CpuIo)
+#include EFI_PPI_DEFINITION (DeviceRecoveryModule)
+#include EFI_PPI_DEFINITION (DxeIpl)
+#include EFI_PPI_DEFINITION (EndOfPeiSignal)
+#include EFI_PPI_DEFINITION (FindFv)
+#include EFI_PPI_DEFINITION (LoadFile)
+#include EFI_PPI_DEFINITION (BootMode)
+#include EFI_PPI_DEFINITION (MemoryDiscovered)
+#include EFI_PPI_DEFINITION (PciCfg)
+#include EFI_PPI_DEFINITION (Variable)
+#include EFI_PPI_DEFINITION (RecoveryModule)
+#include EFI_PPI_DEFINITION (Reset)
+#include EFI_PPI_DEFINITION (S3Resume)
+#include EFI_PPI_DEFINITION (SecPlatforminformation)
+#include EFI_PPI_DEFINITION (SectionExtraction)
+#include EFI_PPI_DEFINITION (Security)
+#include EFI_PPI_DEFINITION (Smbus)
+#include EFI_PPI_DEFINITION (Stall)
+#include EFI_PPI_DEFINITION (StatusCode)
+
+
+#include "Common\EdkIIGlueDefinitionChangesPeim.h"
+
+//
+// EdkII Glue Library Class headers
+//
+
+#include "EdkIIGlueBase.h"
+#include "Library\EdkIIGlueDebugLib.h"
+#include "Library\EdkIIGluePostCodeLib.h"
+#include "Library\EdkIIGlueReportStatusCodeLib.h"
+#include "Library\EdkIIGlueHobLib.h"
+#include "Library\EdkIIGlueMemoryAllocationLib.h"
+#include "Library\EdkIIGlueSmbusLib.h"
+#include "Library\EdkIIGluePeiServicesLib.h"
+#include "Library\EdkIIGluePeiServicesTablePointerLib.h"
+#include "Library\EdkIIGlueResourcePublicationLib.h"
+#include "Library\EdkIIGluePeimEntryPoint.h"
+#include "Library\EdkIIGlueFirmwarePerformanceLib.h"
+
+#endif
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueUefi.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueUefi.h
new file mode 100644
index 0000000..5ed0f1e
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/EdkIIGlueUefi.h
@@ -0,0 +1,178 @@
+/*++
+
+Copyright (c) 2004 - 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ EdkIIGlueUefi.h
+
+Abstract:
+
+ Root include file for UEFI modules.
+
+**/
+
+
+#ifndef __EDKII_GLUE_UEFI_H__
+#define __EDKII_GLUE_UEFI_H__
+
+
+//
+// Check to make sure EFI_SPECIFICATION_VERSION and TIANO_RELEASE_VERSION are defined.
+// also check for legal combinations
+//
+#if !defined(EFI_SPECIFICATION_VERSION)
+ #error EFI_SPECIFICATION_VERSION not defined
+#elif !defined(TIANO_RELEASE_VERSION)
+ #error TIANO_RELEASE_VERSION not defined
+#elif TIANO_RELEASE_VERSION == 0x00000000
+
+//
+// UEFI mode with no Tiano extensions is legal
+//
+#elif (TIANO_RELEASE_VERSION <= 0x00080005) && (EFI_SPECIFICATION_VERSION >= 0x00020000)
+ #error Illegal combination of EFI_SPECIFICATION_VERSION and EDK_RELEASE_VERSION versions
+#endif
+
+//
+// General Type & API definitions
+//
+
+#include "EfiSpec.h"
+#include "EfiPxe.h"
+
+
+//
+// Protocols from EFI 1.10 that got thier names fixed in UEFI 2.0
+//
+#include EFI_PROTOCOL_DEFINITION(LoadedImage)
+#include EFI_PROTOCOL_DEFINITION(SimpleTextIn)
+#include EFI_PROTOCOL_DEFINITION(SimpleTextOut)
+#include EFI_PROTOCOL_DEFINITION(SerialIo)
+#include EFI_PROTOCOL_DEFINITION(LoadFile)
+#include EFI_PROTOCOL_DEFINITION(SimpleFileSystem)
+#include EFI_PROTOCOL_DEFINITION(DiskIo)
+#include EFI_PROTOCOL_DEFINITION(BlockIo)
+#include EFI_PROTOCOL_DEFINITION(UnicodeCollation)
+#include EFI_PROTOCOL_DEFINITION(SimpleNetwork)
+#include EFI_PROTOCOL_DEFINITION(EfiNetworkInterfaceIdentifier)
+#include EFI_PROTOCOL_DEFINITION(PxeBaseCode)
+#include EFI_PROTOCOL_DEFINITION(PxeBaseCodeCallBack)
+
+//
+// EFI 1.10 Protocols
+//
+#include EFI_PROTOCOL_DEFINITION(Bis)
+#include EFI_PROTOCOL_DEFINITION(BusSpecificDriverOverride)
+#include EFI_PROTOCOL_DEFINITION(ComponentName)
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+#include EFI_PROTOCOL_DEFINITION (ComponentName2)
+#endif
+#include EFI_PROTOCOL_DEFINITION(DebugPort)
+#include EFI_PROTOCOL_DEFINITION(DebugSupport)
+#include EFI_PROTOCOL_DEFINITION(Decompress)
+#include EFI_PROTOCOL_DEFINITION(DriverBinding)
+#include EFI_PROTOCOL_DEFINITION(DriverConfiguration)
+#include EFI_PROTOCOL_DEFINITION(DriverDiagnostics)
+#include EFI_PROTOCOL_DEFINITION(Ebc)
+#include EFI_PROTOCOL_DEFINITION(EfiNetworkInterfaceIdentifier)
+#include EFI_PROTOCOL_DEFINITION(FileInfo)
+#include EFI_PROTOCOL_DEFINITION(FileSystemInfo)
+#include EFI_PROTOCOL_DEFINITION(FileSystemVolumeLabelInfo)
+#include EFI_PROTOCOL_DEFINITION(PciIo)
+#include EFI_PROTOCOL_DEFINITION(PciRootBridgeIo)
+#include EFI_PROTOCOL_DEFINITION(PlatformDriverOverride)
+#include EFI_PROTOCOL_DEFINITION(SimplePointer)
+#include EFI_PROTOCOL_DEFINITION(ScsiPassThru)
+#include EFI_PROTOCOL_DEFINITION(UsbIo)
+#include EFI_PROTOCOL_DEFINITION(UsbHostController)
+#include EFI_PROTOCOL_DEFINITION(UgaDraw)
+
+//
+// EFI 1.10 GUIDs
+//
+#include EFI_GUID_DEFINITION(Acpi)
+#include EFI_GUID_DEFINITION(DebugImageInfoTable)
+#include EFI_GUID_DEFINITION(GlobalVariable)
+#include EFI_GUID_DEFINITION(Gpt)
+#include EFI_GUID_DEFINITION(PcAnsi)
+#include EFI_GUID_DEFINITION(SmBios)
+#include EFI_GUID_DEFINITION(SalSystemTable)
+
+
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+//
+// UEFI 2.0 Protocols and GUIDs
+//
+// check here: currently not implementated
+//#include EFI_PROTOCOL_DEFINITION(AuthenticationInfo)
+#include EFI_PROTOCOL_DEFINITION(DevicePathUtilities)
+#include EFI_PROTOCOL_DEFINITION(DevicePathToText)
+#include EFI_PROTOCOL_DEFINITION(DevicePathFromText)
+#include EFI_PROTOCOL_DEFINITION(GraphicsOutput)
+#include EFI_PROTOCOL_DEFINITION(EdidDiscovered)
+#include EFI_PROTOCOL_DEFINITION(EdidActive)
+#include EFI_PROTOCOL_DEFINITION(EdidOverride)
+#include EFI_PROTOCOL_DEFINITION(ScsiIo)
+#include EFI_PROTOCOL_DEFINITION(ScsiPassThruExt)
+#include EFI_PROTOCOL_DEFINITION(IScsiInitiatorName)
+#include EFI_PROTOCOL_DEFINITION(UsbHostController)
+#include EFI_PROTOCOL_DEFINITION(TapeIo)
+#include EFI_PROTOCOL_DEFINITION(ManagedNetwork)
+#include EFI_PROTOCOL_DEFINITION(Arp)
+#include EFI_PROTOCOL_DEFINITION(Dhcp4)
+#include EFI_PROTOCOL_DEFINITION(IP4)
+#include EFI_PROTOCOL_DEFINITION(IP4Config)
+#include EFI_PROTOCOL_DEFINITION(Tcp4)
+#include EFI_PROTOCOL_DEFINITION(Udp4)
+#include EFI_PROTOCOL_DEFINITION(Mtftp4)
+#include EFI_PROTOCOL_DEFINITION(ServiceBinding)
+#include EFI_PROTOCOL_DEFINITION(Hash)
+#include EFI_GUID_DEFINITION(EventGroup)
+//#include <Guid/WinCertificateUefi.h>
+#endif
+
+#if (TIANO_RELEASE_VERSION > 0x00080005)
+//
+// Need due to R8.5 Tiano contamination of UEFI enumes.
+// There is a UEFI library that does things the new way and the old way
+// This is why these definitions are need in Uefi.h
+//
+#include EFI_GUID_DEFINITION (EventLegacyBios)
+#include EFI_GUID_DEFINITION (FrameworkDevicePath)
+#endif
+
+//
+// R8.x Library headers used by EdkII Glue Libraries
+//
+#include "TianoSpecTypes.h"
+#include "TianoSpecApi.h"
+#include "TianoSpecDevicePath.h"
+#include "EfiDriverLib.h"
+
+#include "Common\EdkIIGlueDefinitionChangesBase.h"
+
+//
+// EdkII Glue Library Class headers
+//
+
+#include "EdkIIGlueBase.h"
+#include "Library\EdkIIGlueUefiDecompressLib.h"
+#include "Library\EdkIIGlueDevicePathLib.h"
+#include "Library\EdkIIGlueUefiBootServicesTableLib.h"
+#include "Library\EdkIIGlueUefiDriverEntryPoint.h"
+#include "Library\EdkIIGlueUefiDriverModelLib.h"
+#include "Library\EdkIIGlueUefiLib.h"
+#include "Library\EdkIIGlueUefiRuntimeServicesTableLib.h"
+
+extern UINT8 _gEdkIIGlueDriverModelProtocolSelection;
+
+#endif
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Ia32/EdkIIGlueProcessorBind.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Ia32/EdkIIGlueProcessorBind.h
new file mode 100644
index 0000000..55a1e96
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Ia32/EdkIIGlueProcessorBind.h
@@ -0,0 +1,41 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ EdkIIGlueProcessorBind.h
+
+Abstract:
+
+ Processor specific definitions
+
+--*/
+
+#ifndef __EDKII_GLUE_PROCESSOR_BIND_H__
+#define __EDKII_GLUE_PROCESSOR_BIND_H__
+
+//
+// The Microsoft* C compiler can removed references to unreferenced data items
+// if the /OPT:REF linker option is used. We defined a macro as this is a
+// a non standard extension
+//
+#if _MSC_EXTENSIONS
+ #define GLOBAL_REMOVE_IF_UNREFERENCED __declspec(selectany)
+#else
+ #define GLOBAL_REMOVE_IF_UNREFERENCED
+#endif
+
+#ifndef MDE_CPU_IA32
+ #define MDE_CPU_IA32
+#endif
+
+#endif
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueBaseLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueBaseLib.h
new file mode 100644
index 0000000..7eadcf0
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueBaseLib.h
@@ -0,0 +1,5109 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ EdkIIGlueBaseLib.h
+
+Abstract:
+
+ Memory-only library functions with no library constructor/destructor
+
+--*/
+
+#ifndef __EDKII_GLUE_BASE_LIB_H__
+#define __EDKII_GLUE_BASE_LIB_H__
+
+
+//
+// String Functions
+//
+#define StrCpy(_Dest, _Source) GlueStrCpy(_Dest, _Source)
+#define StrnCpy(_Dest, _Source, _Length) GlueStrnCpy(_Dest, _Source, _Length)
+#define StrLen(_String) GlueStrLen(_String)
+#define StrSize(_String) GlueStrSize(_String)
+#define StrCmp(_FristString, _SecondString) GlueStrCmp(_FristString, _SecondString)
+#define StrnCmp(_FirstString, _SecondString, _Length) GlueStrnCmp(_FirstString, _SecondString, _Length)
+#define StrCat(_Dest, _Source) GlueStrCat(_Dest, _Source)
+#define StrnCat(_Dest, _Source, _Length) GlueStrnCat(_Dest, _Source, _Length)
+
+//
+// Linked List
+//
+#define InitializeListHead(_ListHead) GlueInitializeListHead(_ListHead)
+#define InsertHeadList(_ListHead, _Entry ) GlueInsertHeadList(_ListHead, _Entry)
+#define InsertTailList(_ListHead, _Entry) GlueInsertTailList(_ListHead, _Entry)
+#define GetFirstNode(_List) GlueGetFirstNode(_List)
+#define GetNextNode(_List, _Node) GlueGetNextNode(_List, _Node)
+#define IsListEmpty(_ListHead) GlueIsListEmpty(_ListHead)
+#define IsNull(_List, _Node) GlueIsNull(_List, _Node)
+#define IsNodeAtEnd(_List, _Node) GlueIsNodeAtEnd(_List, _Node)
+#define SwapListEntries(_FirstEntry, _SecondEntry) GlueSwapListEntries(_FirstEntry, _SecondEntry)
+#define RemoveEntryList(_Entry) GlueRemoveEntryList(_Entry)
+
+//
+// Math Functions
+//
+#define LShiftU64(_Op, _Count) GlueLShiftU64(_Op, _Count)
+#define RShiftU64(_Op, _Count) GlueRShiftU64(_Op, _Count)
+#define MultU64x32(_Multiplicand, _Multiplier) GlueMultU64x32(_Multiplicand, _Multiplier)
+#define DivU64x32(_Dividend, _Divisor) GlueDivU64x32(_Dividend, _Divisor)
+
+//
+// Others
+//
+#define GetInterruptState() GlueGetInterruptState()
+
+
+//
+// Definitions for architecture specific types
+// These include SPIN_LOCK and BASE_LIBRARY_JUMP_BUFFER
+//
+
+//
+// SPIN_LOCK
+//
+typedef VOLATILE UINTN SPIN_LOCK;
+
+#if defined (MDE_CPU_IA32)
+//
+// IA32 context buffer used by SetJump() and LongJump()
+//
+typedef struct {
+ UINT32 Ebx;
+ UINT32 Esi;
+ UINT32 Edi;
+ UINT32 Ebp;
+ UINT32 Esp;
+ UINT32 Eip;
+} BASE_LIBRARY_JUMP_BUFFER;
+
+#elif defined (MDE_CPU_IPF)
+//
+// IPF context buffer used by SetJump() and LongJump()
+//
+typedef struct {
+ UINT64 F2[2];
+ UINT64 F3[2];
+ UINT64 F4[2];
+ UINT64 F5[2];
+ UINT64 F16[2];
+ UINT64 F17[2];
+ UINT64 F18[2];
+ UINT64 F19[2];
+ UINT64 F20[2];
+ UINT64 F21[2];
+ UINT64 F22[2];
+ UINT64 F23[2];
+ UINT64 F24[2];
+ UINT64 F25[2];
+ UINT64 F26[2];
+ UINT64 F27[2];
+ UINT64 F28[2];
+ UINT64 F29[2];
+ UINT64 F30[2];
+ UINT64 F31[2];
+ UINT64 R4;
+ UINT64 R5;
+ UINT64 R6;
+ UINT64 R7;
+ UINT64 SP;
+ UINT64 BR0;
+ UINT64 BR1;
+ UINT64 BR2;
+ UINT64 BR3;
+ UINT64 BR4;
+ UINT64 BR5;
+ UINT64 InitialUNAT;
+ UINT64 AfterSpillUNAT;
+ UINT64 PFS;
+ UINT64 BSP;
+ UINT64 Predicates;
+ UINT64 LoopCount;
+ UINT64 FPSR;
+} BASE_LIBRARY_JUMP_BUFFER;
+
+#elif defined (MDE_CPU_X64)
+//
+// X64 context buffer used by SetJump() and LongJump()
+//
+typedef struct {
+ UINT64 Rbx;
+ UINT64 Rsp;
+ UINT64 Rbp;
+ UINT64 Rdi;
+ UINT64 Rsi;
+ UINT64 R12;
+ UINT64 R13;
+ UINT64 R14;
+ UINT64 R15;
+ UINT64 Rip;
+} BASE_LIBRARY_JUMP_BUFFER;
+
+#elif defined (MDE_CPU_EBC)
+//
+// EBC context buffer used by SetJump() and LongJump()
+//
+typedef struct {
+ UINT64 R0;
+ UINT64 R1;
+ UINT64 R2;
+ UINT64 R3;
+ UINT64 IP;
+} BASE_LIBRARY_JUMP_BUFFER;
+
+#else
+#error Unknown Processor Type
+#endif
+
+//
+// String Services
+//
+
+/**
+ Copies one Null-terminated Unicode string to another Null-terminated Unicode
+ string and returns the new Unicode string.
+
+ This function copies the contents of the Unicode string Source to the Unicode
+ string Destination, and returns Destination. If Source and Destination
+ overlap, then the results are undefined.
+
+ If Destination is NULL, then ASSERT().
+ If Source is NULL, then ASSERT().
+ If Source and Destination overlap, then ASSERT().
+ If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
+ PcdMaximumUnicodeStringLength Unicode characters not including the
+ Null-terminator, then ASSERT().
+
+ @param Destination Pointer to a Null-terminated Unicode string.
+ @param Source Pointer to a Null-terminated Unicode string.
+
+ @return Destiantion
+
+**/
+CHAR16 *
+EFIAPI
+GlueStrCpy (
+ OUT CHAR16 *Destination,
+ IN CONST CHAR16 *Source
+ );
+/**
+ Copies one Null-terminated Unicode string with a maximum length to another
+ Null-terminated Unicode string with a maximum length and returns the new
+ Unicode string.
+
+ This function copies the contents of the Unicode string Source to the Unicode
+ string Destination, and returns Destination. At most, Length Unicode
+ characters are copied from Source to Destination. If Length is 0, then
+ Destination is returned unmodified. If Length is greater that the number of
+ Unicode characters in Source, then Destination is padded with Null Unicode
+ characters. If Source and Destination overlap, then the results are
+ undefined.
+
+ If Destination is NULL, then ASSERT().
+ If Source is NULL, then ASSERT().
+ If Source and Destination overlap, then ASSERT().
+ If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
+ PcdMaximumUnicodeStringLength Unicode characters not including the
+ Null-terminator, then ASSERT().
+
+ @param Destination Pointer to a Null-terminated Unicode string.
+ @param Source Pointer to a Null-terminated Unicode string.
+ @param Length Maximum number of Unicode characters to copy.
+
+ @return Destination
+
+**/
+CHAR16 *
+EFIAPI
+GlueStrnCpy (
+ OUT CHAR16 *Destination,
+ IN CONST CHAR16 *Source,
+ IN UINTN Length
+ );
+/**
+ Returns the length of a Null-terminated Unicode string.
+
+ This function returns the number of Unicode characters in the Null-terminated
+ Unicode string specified by String.
+
+ If String is NULL, then ASSERT().
+ If PcdMaximumUnicodeStringLength is not zero, and String contains more than
+ PcdMaximumUnicodeStringLength Unicode characters not including the
+ Null-terminator, then ASSERT().
+
+ @param String Pointer to a Null-terminated Unicode string.
+
+ @return The length of String.
+
+**/
+UINTN
+EFIAPI
+GlueStrLen (
+ IN CONST CHAR16 *String
+ );
+/**
+ Returns the size of a Null-terminated Unicode string in bytes, including the
+ Null terminator.
+
+ This function returns the size, in bytes, of the Null-terminated Unicode
+ string specified by String.
+
+ If String is NULL, then ASSERT().
+ If PcdMaximumUnicodeStringLength is not zero, and String contains more than
+ PcdMaximumUnicodeStringLength Unicode characters not including the
+ Null-terminator, then ASSERT().
+
+ @param String Pointer to a Null-terminated Unicode string.
+
+ @return The size of String.
+
+**/
+UINTN
+EFIAPI
+GlueStrSize (
+ IN CONST CHAR16 *String
+ );
+/**
+ Compares two Null-terminated Unicode strings, and returns the difference
+ between the first mismatched Unicode characters.
+
+ This function compares the Null-terminated Unicode string FirstString to the
+ Null-terminated Unicode string SecondString. If FirstString is identical to
+ SecondString, then 0 is returned. Otherwise, the value returned is the first
+ mismatched Unicode character in SecondString subtracted from the first
+ mismatched Unicode character in FirstString.
+
+ If FirstString is NULL, then ASSERT().
+ If SecondString is NULL, then ASSERT().
+ If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more
+ than PcdMaximumUnicodeStringLength Unicode characters not including the
+ Null-terminator, then ASSERT().
+ If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more
+ than PcdMaximumUnicodeStringLength Unicode characters not including the
+ Null-terminator, then ASSERT().
+
+ @param FirstString Pointer to a Null-terminated Unicode string.
+ @param SecondString Pointer to a Null-terminated Unicode string.
+
+ @retval 0 FirstString is identical to SecondString.
+ @retval !=0 FirstString is not identical to SecondString.
+
+**/
+INTN
+EFIAPI
+GlueStrCmp (
+ IN CONST CHAR16 *FirstString,
+ IN CONST CHAR16 *SecondString
+ );
+/**
+ Compares two Null-terminated Unicode strings with maximum lengths, and
+ returns the difference between the first mismatched Unicode characters.
+
+ This function compares the Null-terminated Unicode string FirstString to the
+ Null-terminated Unicode string SecondString. At most, Length Unicode
+ characters will be compared. If Length is 0, then 0 is returned. If
+ FirstString is identical to SecondString, then 0 is returned. Otherwise, the
+ value returned is the first mismatched Unicode character in SecondString
+ subtracted from the first mismatched Unicode character in FirstString.
+
+ If FirstString is NULL, then ASSERT().
+ If SecondString is NULL, then ASSERT().
+ If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more
+ than PcdMaximumUnicodeStringLength Unicode characters not including the
+ Null-terminator, then ASSERT().
+ If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more
+ than PcdMaximumUnicodeStringLength Unicode characters not including the
+ Null-terminator, then ASSERT().
+
+ @param FirstString Pointer to a Null-terminated Unicode string.
+ @param SecondString Pointer to a Null-terminated Unicode string.
+ @param Length Maximum number of Unicode characters to compare.
+
+ @retval 0 FirstString is identical to SecondString.
+ @retval !=0 FirstString is not identical to SecondString.
+
+**/
+INTN
+EFIAPI
+GlueStrnCmp (
+ IN CONST CHAR16 *FirstString,
+ IN CONST CHAR16 *SecondString,
+ IN UINTN Length
+ );
+/**
+ Concatenates one Null-terminated Unicode string to another Null-terminated
+ Unicode string, and returns the concatenated Unicode string.
+
+ This function concatenates two Null-terminated Unicode strings. The contents
+ of Null-terminated Unicode string Source are concatenated to the end of
+ Null-terminated Unicode string Destination. The Null-terminated concatenated
+ Unicode String is returned. If Source and Destination overlap, then the
+ results are undefined.
+
+ If Destination is NULL, then ASSERT().
+ If Source is NULL, then ASSERT().
+ If Source and Destination overlap, then ASSERT().
+ If PcdMaximumUnicodeStringLength is not zero, and Destination contains more
+ than PcdMaximumUnicodeStringLength Unicode characters not including the
+ Null-terminator, then ASSERT().
+ If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
+ PcdMaximumUnicodeStringLength Unicode characters not including the
+ Null-terminator, then ASSERT().
+ If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination
+ and Source results in a Unicode string with more than
+ PcdMaximumUnicodeStringLength Unicode characters not including the
+ Null-terminator, then ASSERT().
+
+ @param Destination Pointer to a Null-terminated Unicode string.
+ @param Source Pointer to a Null-terminated Unicode string.
+
+ @return Destination
+
+**/
+CHAR16 *
+EFIAPI
+GlueStrCat (
+ IN OUT CHAR16 *Destination,
+ IN CONST CHAR16 *Source
+ );
+/**
+ Concatenates one Null-terminated Unicode string with a maximum length to the
+ end of another Null-terminated Unicode string, and returns the concatenated
+ Unicode string.
+
+ This function concatenates two Null-terminated Unicode strings. The contents
+ of Null-terminated Unicode string Source are concatenated to the end of
+ Null-terminated Unicode string Destination, and Destination is returned. At
+ most, Length Unicode characters are concatenated from Source to the end of
+ Destination, and Destination is always Null-terminated. If Length is 0, then
+ Destination is returned unmodified. If Source and Destination overlap, then
+ the results are undefined.
+
+ If Destination is NULL, then ASSERT().
+ If Source is NULL, then ASSERT().
+ If Source and Destination overlap, then ASSERT().
+ If PcdMaximumUnicodeStringLength is not zero, and Destination contains more
+ than PcdMaximumUnicodeStringLength Unicode characters not including the
+ Null-terminator, then ASSERT().
+ If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
+ PcdMaximumUnicodeStringLength Unicode characters not including the
+ Null-terminator, then ASSERT().
+ If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination
+ and Source results in a Unicode string with more than
+ PcdMaximumUnicodeStringLength Unicode characters not including the
+ Null-terminator, then ASSERT().
+
+ @param Destination Pointer to a Null-terminated Unicode string.
+ @param Source Pointer to a Null-terminated Unicode string.
+ @param Length Maximum number of Unicode characters to concatenate from
+ Source.
+
+ @return Destination
+
+**/
+CHAR16 *
+EFIAPI
+GlueStrnCat (
+ IN OUT CHAR16 *Destination,
+ IN CONST CHAR16 *Source,
+ IN UINTN Length
+ );
+
+//;;## ...AMI_OVERRIDE... Support Unicode Str To Ascii Str start.
+/**
+ Convert one Null-terminated Unicode string to a Null-terminated
+ ASCII string and returns the ASCII string.
+
+ This function converts the content of the Unicode string Source
+ to the ASCII string Destination by copying the lower 8 bits of
+ each Unicode character. It returns Destination.
+
+ If any Unicode characters in Source contain non-zero value in
+ the upper 8 bits, then ASSERT().
+
+ If Destination is NULL, then ASSERT().
+ If Source is NULL, then ASSERT().
+ If Source is not aligned on a 16-bit boundary, then ASSERT().
+ If Source and Destination overlap, then ASSERT().
+
+ If PcdMaximumUnicodeStringLength is not zero, and Source contains
+ more than PcdMaximumUnicodeStringLength Unicode characters not including
+ the Null-terminator, then ASSERT().
+
+ If PcdMaximumAsciiStringLength is not zero, and Source contains more
+ than PcdMaximumAsciiStringLength Unicode characters not including the
+ Null-terminator, then ASSERT().
+
+ @param Source Pointer to a Null-terminated Unicode string.
+ @param Destination Pointer to a Null-terminated ASCII string.
+
+ @reture Destination
+
+**/
+CHAR8 *
+EFIAPI
+UnicodeStrToAsciiStr (
+ IN CONST CHAR16 *Source,
+ OUT CHAR8 *Destination
+ );
+//;;## ...AMI_OVERRIDE... Support Unicode Str To Ascii Str end.
+
+/**
+ Copies one Null-terminated ASCII string to another Null-terminated ASCII
+ string and returns the new ASCII string.
+
+ This function copies the contents of the ASCII string Source to the ASCII
+ string Destination, and returns Destination. If Source and Destination
+ overlap, then the results are undefined.
+
+ If Destination is NULL, then ASSERT().
+ If Source is NULL, then ASSERT().
+ If Source and Destination overlap, then ASSERT().
+ If PcdMaximumAsciiStringLength is not zero and Source contains more than
+ PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
+ then ASSERT().
+
+ @param Destination Pointer to a Null-terminated ASCII string.
+ @param Source Pointer to a Null-terminated ASCII string.
+
+ @return Destination
+
+**/
+CHAR8 *
+EFIAPI
+AsciiStrCpy (
+ OUT CHAR8 *Destination,
+ IN CONST CHAR8 *Source
+ );
+/**
+ Copies one Null-terminated ASCII string with a maximum length to another
+ Null-terminated ASCII string with a maximum length and returns the new ASCII
+ string.
+
+ This function copies the contents of the ASCII string Source to the ASCII
+ string Destination, and returns Destination. At most, Length ASCII characters
+ are copied from Source to Destination. If Length is 0, then Destination is
+ returned unmodified. If Length is greater that the number of ASCII characters
+ in Source, then Destination is padded with Null ASCII characters. If Source
+ and Destination overlap, then the results are undefined.
+
+ If Destination is NULL, then ASSERT().
+ If Source is NULL, then ASSERT().
+ If Source and Destination overlap, then ASSERT().
+ If PcdMaximumAsciiStringLength is not zero, and Source contains more than
+ PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
+ then ASSERT().
+
+ @param Destination Pointer to a Null-terminated ASCII string.
+ @param Source Pointer to a Null-terminated ASCII string.
+ @param Length Maximum number of ASCII characters to copy.
+
+ @return Destination
+
+**/
+CHAR8 *
+EFIAPI
+AsciiStrnCpy (
+ OUT CHAR8 *Destination,
+ IN CONST CHAR8 *Source,
+ IN UINTN Length
+ );
+/**
+ Returns the length of a Null-terminated ASCII string.
+
+ This function returns the number of ASCII characters in the Null-terminated
+ ASCII string specified by String.
+
+ If String is NULL, then ASSERT().
+ If PcdMaximumAsciiStringLength is not zero and String contains more than
+ PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
+ then ASSERT().
+
+ @param String Pointer to a Null-terminated ASCII string.
+
+ @return The length of String.
+
+**/
+UINTN
+EFIAPI
+AsciiStrLen (
+ IN CONST CHAR8 *String
+ );
+/**
+ Returns the size of a Null-terminated ASCII string in bytes, including the
+ Null terminator.
+
+ This function returns the size, in bytes, of the Null-terminated ASCII string
+ specified by String.
+
+ If String is NULL, then ASSERT().
+ If PcdMaximumAsciiStringLength is not zero and String contains more than
+ PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
+ then ASSERT().
+
+ @param String Pointer to a Null-terminated ASCII string.
+
+ @return The size of String.
+
+**/
+UINTN
+EFIAPI
+AsciiStrSize (
+ IN CONST CHAR8 *String
+ );
+/**
+ Compares two Null-terminated ASCII strings, and returns the difference
+ between the first mismatched ASCII characters.
+
+ This function compares the Null-terminated ASCII string FirstString to the
+ Null-terminated ASCII string SecondString. If FirstString is identical to
+ SecondString, then 0 is returned. Otherwise, the value returned is the first
+ mismatched ASCII character in SecondString subtracted from the first
+ mismatched ASCII character in FirstString.
+
+ If FirstString is NULL, then ASSERT().
+ If SecondString is NULL, then ASSERT().
+ If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
+ PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
+ then ASSERT().
+ If PcdMaximumAsciiStringLength is not zero and SecondString contains more
+ than PcdMaximumAsciiStringLength ASCII characters not including the
+ Null-terminator, then ASSERT().
+
+ @param FirstString Pointer to a Null-terminated ASCII string.
+ @param SecondString Pointer to a Null-terminated ASCII string.
+
+ @retval 0 FirstString is identical to SecondString.
+ @retval !=0 FirstString is not identical to SecondString.
+
+**/
+INTN
+EFIAPI
+AsciiStrCmp (
+ IN CONST CHAR8 *FirstString,
+ IN CONST CHAR8 *SecondString
+ );
+/**
+ Performs a case insensitive comparison of two Null-terminated ASCII strings,
+ and returns the difference between the first mismatched ASCII characters.
+
+ This function performs a case insensitive comparison of the Null-terminated
+ ASCII string FirstString to the Null-terminated ASCII string SecondString. If
+ FirstString is identical to SecondString, then 0 is returned. Otherwise, the
+ value returned is the first mismatched lower case ASCII character in
+ SecondString subtracted from the first mismatched lower case ASCII character
+ in FirstString.
+
+ If FirstString is NULL, then ASSERT().
+ If SecondString is NULL, then ASSERT().
+ If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
+ PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
+ then ASSERT().
+ If PcdMaximumAsciiStringLength is not zero and SecondString contains more
+ than PcdMaximumAsciiStringLength ASCII characters not including the
+ Null-terminator, then ASSERT().
+
+ @param FirstString Pointer to a Null-terminated ASCII string.
+ @param SecondString Pointer to a Null-terminated ASCII string.
+
+ @retval 0 FirstString is identical to SecondString using case insensitive
+ comparisons.
+ @retval !=0 FirstString is not identical to SecondString using case
+ insensitive comparisons.
+
+**/
+INTN
+EFIAPI
+AsciiStriCmp (
+ IN CONST CHAR8 *FirstString,
+ IN CONST CHAR8 *SecondString
+ );
+/**
+ Compares two Null-terminated ASCII strings with maximum lengths, and returns
+ the difference between the first mismatched ASCII characters.
+
+ This function compares the Null-terminated ASCII string FirstString to the
+ Null-terminated ASCII string SecondString. At most, Length ASCII characters
+ will be compared. If Length is 0, then 0 is returned. If FirstString is
+ identical to SecondString, then 0 is returned. Otherwise, the value returned
+ is the first mismatched ASCII character in SecondString subtracted from the
+ first mismatched ASCII character in FirstString.
+
+ If FirstString is NULL, then ASSERT().
+ If SecondString is NULL, then ASSERT().
+ If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
+ PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
+ then ASSERT().
+ If PcdMaximumAsciiStringLength is not zero and SecondString contains more than
+ PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
+ then ASSERT().
+
+ @param FirstString Pointer to a Null-terminated ASCII string.
+ @param SecondString Pointer to a Null-terminated ASCII string.
+
+ @retval 0 FirstString is identical to SecondString.
+ @retval !=0 FirstString is not identical to SecondString.
+
+**/
+INTN
+EFIAPI
+AsciiStrnCmp (
+ IN CONST CHAR8 *FirstString,
+ IN CONST CHAR8 *SecondString,
+ IN UINTN Length
+ );
+/**
+ Concatenates one Null-terminated ASCII string to another Null-terminated
+ ASCII string, and returns the concatenated ASCII string.
+
+ This function concatenates two Null-terminated ASCII strings. The contents of
+ Null-terminated ASCII string Source are concatenated to the end of Null-
+ terminated ASCII string Destination. The Null-terminated concatenated ASCII
+ String is returned.
+
+ If Destination is NULL, then ASSERT().
+ If Source is NULL, then ASSERT().
+ If PcdMaximumAsciiStringLength is not zero and Destination contains more than
+ PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
+ then ASSERT().
+ If PcdMaximumAsciiStringLength is not zero and Source contains more than
+ PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
+ then ASSERT().
+ If PcdMaximumAsciiStringLength is not zero and concatenating Destination and
+ Source results in a ASCII string with more than PcdMaximumAsciiStringLength
+ ASCII characters, then ASSERT().
+
+ @param Destination Pointer to a Null-terminated ASCII string.
+ @param Source Pointer to a Null-terminated ASCII string.
+
+ @return Destination
+
+**/
+CHAR8 *
+EFIAPI
+AsciiStrCat (
+ IN OUT CHAR8 *Destination,
+ IN CONST CHAR8 *Source
+ );
+/**
+ Concatenates one Null-terminated ASCII string with a maximum length to the
+ end of another Null-terminated ASCII string, and returns the concatenated
+ ASCII string.
+
+ This function concatenates two Null-terminated ASCII strings. The contents
+ of Null-terminated ASCII string Source are concatenated to the end of Null-
+ terminated ASCII string Destination, and Destination is returned. At most,
+ Length ASCII characters are concatenated from Source to the end of
+ Destination, and Destination is always Null-terminated. If Length is 0, then
+ Destination is returned unmodified. If Source and Destination overlap, then
+ the results are undefined.
+
+ If Destination is NULL, then ASSERT().
+ If Source is NULL, then ASSERT().
+ If Source and Destination overlap, then ASSERT().
+ If PcdMaximumAsciiStringLength is not zero, and Destination contains more than
+ PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
+ then ASSERT().
+ If PcdMaximumAsciiStringLength is not zero, and Source contains more than
+ PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
+ then ASSERT().
+ If PcdMaximumAsciiStringLength is not zero, and concatenating Destination and
+ Source results in a ASCII string with more than PcdMaximumAsciiStringLength
+ ASCII characters not including the Null-terminator, then ASSERT().
+
+ @param Destination Pointer to a Null-terminated ASCII string.
+ @param Source Pointer to a Null-terminated ASCII string.
+ @param Length Maximum number of ASCII characters to concatenate from
+ Source.
+
+ @return Destination
+
+**/
+CHAR8 *
+EFIAPI
+AsciiStrnCat (
+ IN OUT CHAR8 *Destination,
+ IN CONST CHAR8 *Source,
+ IN UINTN Length
+ );
+/**
+ Converts an 8-bit value to an 8-bit BCD value.
+
+ Converts the 8-bit value specified by Value to BCD. The BCD value is
+ returned.
+
+ If Value >= 100, then ASSERT().
+
+ @param Value The 8-bit value to convert to BCD. Range 0..99.
+
+ @return The BCD value
+
+**/
+UINT8
+EFIAPI
+DecimalToBcd8 (
+ IN UINT8 Value
+ );
+
+/**
+ Converts an 8-bit BCD value to an 8-bit value.
+
+ Converts the 8-bit BCD value specified by Value to an 8-bit value. The 8-bit
+ value is returned.
+
+ If Value >= 0xA0, then ASSERT().
+ If (Value & 0x0F) >= 0x0A, then ASSERT().
+
+ @param Value The 8-bit BCD value to convert to an 8-bit value.
+
+ @return The 8-bit value is returned.
+
+**/
+UINT8
+EFIAPI
+BcdToDecimal8 (
+ IN UINT8 Value
+ );
+
+//
+// LIST_ENTRY definition
+//
+typedef struct _LIST_ENTRY LIST_ENTRY;
+
+struct _LIST_ENTRY {
+ LIST_ENTRY *ForwardLink;
+ LIST_ENTRY *BackLink;
+};
+
+//
+// Linked List Functions and Macros
+//
+
+/**
+ Initializes the head node of a doubly linked list that is declared as a
+ global variable in a module.
+
+ Initializes the forward and backward links of a new linked list. After
+ initializing a linked list with this macro, the other linked list functions
+ may be used to add and remove nodes from the linked list. This macro results
+ in smaller executables by initializing the linked list in the data section,
+ instead if calling the InitializeListHead() function to perform the
+ equivalent operation.
+
+ @param ListHead The head note of a list to initiailize.
+
+**/
+#define INITIALIZE_LIST_HEAD_VARIABLE(ListHead) {&ListHead, &ListHead}
+
+/**
+ Initializes the head node of a doubly linked list, and returns the pointer to
+ the head node of the doubly linked list.
+
+ Initializes the forward and backward links of a new linked list. After
+ initializing a linked list with this function, the other linked list
+ functions may be used to add and remove nodes from the linked list. It is up
+ to the caller of this function to allocate the memory for ListHead.
+
+ If ListHead is NULL, then ASSERT().
+
+ @param ListHead A pointer to the head node of a new doubly linked list.
+
+ @return ListHead
+
+**/
+LIST_ENTRY *
+EFIAPI
+GlueInitializeListHead (
+ IN LIST_ENTRY *ListHead
+ );
+
+/**
+ Adds a node to the beginning of a doubly linked list, and returns the pointer
+ to the head node of the doubly linked list.
+
+ Adds the node Entry at the beginning of the doubly linked list denoted by
+ ListHead, and returns ListHead.
+
+ If ListHead is NULL, then ASSERT().
+ If Entry is NULL, then ASSERT().
+ If ListHead was not initialized with InitializeListHead(), then ASSERT().
+ If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number
+ of nodes in ListHead, including the ListHead node, is greater than or
+ equal to PcdMaximumLinkedListLength, then ASSERT().
+
+ @param ListHead A pointer to the head node of a doubly linked list.
+ @param Entry A pointer to a node that is to be inserted at the beginning
+ of a doubly linked list.
+
+ @return ListHead
+
+**/
+LIST_ENTRY *
+EFIAPI
+GlueInsertHeadList (
+ IN LIST_ENTRY *ListHead,
+ IN LIST_ENTRY *Entry
+ );
+
+/**
+ Adds a node to the end of a doubly linked list, and returns the pointer to
+ the head node of the doubly linked list.
+
+ Adds the node Entry to the end of the doubly linked list denoted by ListHead,
+ and returns ListHead.
+
+ If ListHead is NULL, then ASSERT().
+ If Entry is NULL, then ASSERT().
+ If ListHead was not initialized with InitializeListHead(), then ASSERT().
+ If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number
+ of nodes in ListHead, including the ListHead node, is greater than or
+ equal to PcdMaximumLinkedListLength, then ASSERT().
+
+ @param ListHead A pointer to the head node of a doubly linked list.
+ @param Entry A pointer to a node that is to be added at the end of the
+ doubly linked list.
+
+ @return ListHead
+
+**/
+LIST_ENTRY *
+EFIAPI
+GlueInsertTailList (
+ IN LIST_ENTRY *ListHead,
+ IN LIST_ENTRY *Entry
+ );
+
+/**
+ Retrieves the first node of a doubly linked list.
+
+ Returns the first node of a doubly linked list. List must have been
+ initialized with InitializeListHead(). If List is empty, then NULL is
+ returned.
+
+ If List is NULL, then ASSERT().
+ If List was not initialized with InitializeListHead(), then ASSERT().
+ If PcdMaximumLinkedListLenth is not zero, and the number of nodes
+ in List, including the List node, is greater than or equal to
+ PcdMaximumLinkedListLength, then ASSERT().
+
+ @param List A pointer to the head node of a doubly linked list.
+
+ @return The first node of a doubly linked list.
+ @retval NULL The list is empty.
+
+**/
+LIST_ENTRY *
+EFIAPI
+GlueGetFirstNode (
+ IN CONST LIST_ENTRY *List
+ );
+
+/**
+ Retrieves the next node of a doubly linked list.
+
+ Returns the node of a doubly linked list that follows Node. List must have
+ been initialized with InitializeListHead(). If List is empty, then List is
+ returned.
+
+ If List is NULL, then ASSERT().
+ If Node is NULL, then ASSERT().
+ If List was not initialized with InitializeListHead(), then ASSERT().
+ If PcdMaximumLinkedListLenth is not zero, and List contains more than
+ PcdMaximumLinkedListLenth nodes, then ASSERT().
+ If Node is not a node in List, then ASSERT().
+
+ @param List A pointer to the head node of a doubly linked list.
+ @param Node A pointer to a node in the doubly linked list.
+
+ @return Pointer to the next node if one exists. Otherwise a null value which
+ is actually List is returned.
+
+**/
+LIST_ENTRY *
+EFIAPI
+GlueGetNextNode (
+ IN CONST LIST_ENTRY *List,
+ IN CONST LIST_ENTRY *Node
+ );
+
+/**
+ Checks to see if a doubly linked list is empty or not.
+
+ Checks to see if the doubly linked list is empty. If the linked list contains
+ zero nodes, this function returns TRUE. Otherwise, it returns FALSE.
+
+ If ListHead is NULL, then ASSERT().
+ If ListHead was not initialized with InitializeListHead(), then ASSERT().
+ If PcdMaximumLinkedListLenth is not zero, and the number of nodes
+ in List, including the List node, is greater than or equal to
+ PcdMaximumLinkedListLength, then ASSERT().
+
+ @param ListHead A pointer to the head node of a doubly linked list.
+
+ @retval TRUE The linked list is empty.
+ @retval FALSE The linked list is not empty.
+
+**/
+BOOLEAN
+EFIAPI
+GlueIsListEmpty (
+ IN CONST LIST_ENTRY *ListHead
+ );
+
+/**
+ Determines if a node in a doubly linked list is null.
+
+ Returns FALSE if Node is one of the nodes in the doubly linked list specified
+ by List. Otherwise, TRUE is returned. List must have been initialized with
+ InitializeListHead().
+
+ If List is NULL, then ASSERT().
+ If Node is NULL, then ASSERT().
+ If List was not initialized with InitializeListHead(), then ASSERT().
+ If PcdMaximumLinkedListLenth is not zero, and the number of nodes
+ in List, including the List node, is greater than or equal to
+ PcdMaximumLinkedListLength, then ASSERT().
+ If Node is not a node in List and Node is not equal to List, then ASSERT().
+
+ @param List A pointer to the head node of a doubly linked list.
+ @param Node A pointer to a node in the doubly linked list.
+
+ @retval TRUE Node is one of the nodes in the doubly linked list.
+ @retval FALSE Node is not one of the nodes in the doubly linked list.
+
+**/
+BOOLEAN
+EFIAPI
+GlueIsNull (
+ IN CONST LIST_ENTRY *List,
+ IN CONST LIST_ENTRY *Node
+ );
+
+/**
+ Determines if a node the last node in a doubly linked list.
+
+ Returns TRUE if Node is the last node in the doubly linked list specified by
+ List. Otherwise, FALSE is returned. List must have been initialized with
+ InitializeListHead().
+
+ If List is NULL, then ASSERT().
+ If Node is NULL, then ASSERT().
+ If List was not initialized with InitializeListHead(), then ASSERT().
+ If PcdMaximumLinkedListLenth is not zero, and the number of nodes
+ in List, including the List node, is greater than or equal to
+ PcdMaximumLinkedListLength, then ASSERT().
+ If Node is not a node in List, then ASSERT().
+
+ @param List A pointer to the head node of a doubly linked list.
+ @param Node A pointer to a node in the doubly linked list.
+
+ @retval TRUE Node is the last node in the linked list.
+ @retval FALSE Node is not the last node in the linked list.
+
+**/
+BOOLEAN
+EFIAPI
+GlueIsNodeAtEnd (
+ IN CONST LIST_ENTRY *List,
+ IN CONST LIST_ENTRY *Node
+ );
+
+/**
+ Swaps the location of two nodes in a doubly linked list, and returns the
+ first node after the swap.
+
+ If FirstEntry is identical to SecondEntry, then SecondEntry is returned.
+ Otherwise, the location of the FirstEntry node is swapped with the location
+ of the SecondEntry node in a doubly linked list. SecondEntry must be in the
+ same double linked list as FirstEntry and that double linked list must have
+ been initialized with InitializeListHead(). SecondEntry is returned after the
+ nodes are swapped.
+
+ If FirstEntry is NULL, then ASSERT().
+ If SecondEntry is NULL, then ASSERT().
+ If SecondEntry and FirstEntry are not in the same linked list, then ASSERT().
+ If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
+ linked list containing the FirstEntry and SecondEntry nodes, including
+ the FirstEntry and SecondEntry nodes, is greater than or equal to
+ PcdMaximumLinkedListLength, then ASSERT().
+
+ @param FirstEntry A pointer to a node in a linked list.
+ @param SecondEntry A pointer to another node in the same linked list.
+
+**/
+LIST_ENTRY *
+EFIAPI
+GlueSwapListEntries (
+ IN LIST_ENTRY *FirstEntry,
+ IN LIST_ENTRY *SecondEntry
+ );
+
+/**
+ Removes a node from a doubly linked list, and returns the node that follows
+ the removed node.
+
+ Removes the node Entry from a doubly linked list. It is up to the caller of
+ this function to release the memory used by this node if that is required. On
+ exit, the node following Entry in the doubly linked list is returned. If
+ Entry is the only node in the linked list, then the head node of the linked
+ list is returned.
+
+ If Entry is NULL, then ASSERT().
+ If Entry is the head node of an empty list, then ASSERT().
+ If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
+ linked list containing Entry, including the Entry node, is greater than
+ or equal to PcdMaximumLinkedListLength, then ASSERT().
+
+ @param Entry A pointer to a node in a linked list
+
+ @return Entry
+
+**/
+LIST_ENTRY *
+EFIAPI
+GlueRemoveEntryList (
+ IN CONST LIST_ENTRY *Entry
+ );
+
+//
+// Math Services
+//
+
+/**
+ Shifts a 64-bit integer left between 0 and 63 bits. The low bits are filled
+ with zeros. The shifted value is returned.
+
+ This function shifts the 64-bit value Operand to the left by Count bits. The
+ low Count bits are set to zero. The shifted value is returned.
+
+ If Count is greater than 63, then ASSERT().
+
+ @param Operand The 64-bit operand to shift left.
+ @param Count The number of bits to shift left.
+
+ @return Operand << Count
+
+**/
+UINT64
+EFIAPI
+GlueLShiftU64 (
+ IN UINT64 Operand,
+ IN UINTN Count
+ );
+
+/**
+ Shifts a 64-bit integer right between 0 and 63 bits. This high bits are
+ filled with zeros. The shifted value is returned.
+
+ This function shifts the 64-bit value Operand to the right by Count bits. The
+ high Count bits are set to zero. The shifted value is returned.
+
+ If Count is greater than 63, then ASSERT().
+
+ @param Operand The 64-bit operand to shift right.
+ @param Count The number of bits to shift right.
+
+ @return Operand >> Count
+
+**/
+UINT64
+EFIAPI
+GlueRShiftU64 (
+ IN UINT64 Operand,
+ IN UINTN Count
+ );
+
+/**
+ Shifts a 64-bit integer right between 0 and 63 bits. The high bits are filled
+ with original integer's bit 63. The shifted value is returned.
+
+ This function shifts the 64-bit value Operand to the right by Count bits. The
+ high Count bits are set to bit 63 of Operand. The shifted value is returned.
+
+ If Count is greater than 63, then ASSERT().
+
+ @param Operand The 64-bit operand to shift right.
+ @param Count The number of bits to shift right.
+
+ @return Operand >> Count
+
+**/
+UINT64
+EFIAPI
+ARShiftU64 (
+ IN UINT64 Operand,
+ IN UINTN Count
+ );
+
+/**
+ Rotates a 32-bit integer left between 0 and 31 bits, filling the low bits
+ with the high bits that were rotated.
+
+ This function rotates the 32-bit value Operand to the left by Count bits. The
+ low Count bits are fill with the high Count bits of Operand. The rotated
+ value is returned.
+
+ If Count is greater than 31, then ASSERT().
+
+ @param Operand The 32-bit operand to rotate left.
+ @param Count The number of bits to rotate left.
+
+ @return Operand <<< Count
+
+**/
+UINT32
+EFIAPI
+LRotU32 (
+ IN UINT32 Operand,
+ IN UINTN Count
+ );
+
+/**
+ Rotates a 32-bit integer right between 0 and 31 bits, filling the high bits
+ with the low bits that were rotated.
+
+ This function rotates the 32-bit value Operand to the right by Count bits.
+ The high Count bits are fill with the low Count bits of Operand. The rotated
+ value is returned.
+
+ If Count is greater than 31, then ASSERT().
+
+ @param Operand The 32-bit operand to rotate right.
+ @param Count The number of bits to rotate right.
+
+ @return Operand >>> Count
+
+**/
+UINT32
+EFIAPI
+RRotU32 (
+ IN UINT32 Operand,
+ IN UINTN Count
+ );
+
+/**
+ Rotates a 64-bit integer left between 0 and 63 bits, filling the low bits
+ with the high bits that were rotated.
+
+ This function rotates the 64-bit value Operand to the left by Count bits. The
+ low Count bits are fill with the high Count bits of Operand. The rotated
+ value is returned.
+
+ If Count is greater than 63, then ASSERT().
+
+ @param Operand The 64-bit operand to rotate left.
+ @param Count The number of bits to rotate left.
+
+ @return Operand <<< Count
+
+**/
+UINT64
+EFIAPI
+LRotU64 (
+ IN UINT64 Operand,
+ IN UINTN Count
+ );
+
+/**
+ Rotates a 64-bit integer right between 0 and 63 bits, filling the high bits
+ with the high low bits that were rotated.
+
+ This function rotates the 64-bit value Operand to the right by Count bits.
+ The high Count bits are fill with the low Count bits of Operand. The rotated
+ value is returned.
+
+ If Count is greater than 63, then ASSERT().
+
+ @param Operand The 64-bit operand to rotate right.
+ @param Count The number of bits to rotate right.
+
+ @return Operand >>> Count
+
+**/
+UINT64
+EFIAPI
+RRotU64 (
+ IN UINT64 Operand,
+ IN UINTN Count
+ );
+
+/**
+ Returns the bit position of the lowest bit set in a 32-bit value.
+
+ This function computes the bit position of the lowest bit set in the 32-bit
+ value specified by Operand. If Operand is zero, then -1 is returned.
+ Otherwise, a value between 0 and 31 is returned.
+
+ @param Operand The 32-bit operand to evaluate.
+
+ @return Position of the lowest bit set in Operand if found.
+ @retval -1 Operand is zero.
+
+**/
+INTN
+EFIAPI
+LowBitSet32 (
+ IN UINT32 Operand
+ );
+
+/**
+ Returns the bit position of the lowest bit set in a 64-bit value.
+
+ This function computes the bit position of the lowest bit set in the 64-bit
+ value specified by Operand. If Operand is zero, then -1 is returned.
+ Otherwise, a value between 0 and 63 is returned.
+
+ @param Operand The 64-bit operand to evaluate.
+
+ @return Position of the lowest bit set in Operand if found.
+ @retval -1 Operand is zero.
+
+**/
+INTN
+EFIAPI
+LowBitSet64 (
+ IN UINT64 Operand
+ );
+
+/**
+ Returns the bit position of the highest bit set in a 32-bit value. Equivalent
+ to log2(x).
+
+ This function computes the bit position of the highest bit set in the 32-bit
+ value specified by Operand. If Operand is zero, then -1 is returned.
+ Otherwise, a value between 0 and 31 is returned.
+
+ @param Operand The 32-bit operand to evaluate.
+
+ @return Position of the highest bit set in Operand if found.
+ @retval -1 Operand is zero.
+
+**/
+INTN
+EFIAPI
+HighBitSet32 (
+ IN UINT32 Operand
+ );
+
+/**
+ Returns the bit position of the highest bit set in a 64-bit value. Equivalent
+ to log2(x).
+
+ This function computes the bit position of the highest bit set in the 64-bit
+ value specified by Operand. If Operand is zero, then -1 is returned.
+ Otherwise, a value between 0 and 63 is returned.
+
+ @param Operand The 64-bit operand to evaluate.
+
+ @return Position of the highest bit set in Operand if found.
+ @retval -1 Operand is zero.
+
+**/
+INTN
+EFIAPI
+HighBitSet64 (
+ IN UINT64 Operand
+ );
+
+/**
+ Returns the value of the highest bit set in a 32-bit value. Equivalent to
+ 1 << HighBitSet32(x).
+
+ This function computes the value of the highest bit set in the 32-bit value
+ specified by Operand. If Operand is zero, then zero is returned.
+
+ @param Operand The 32-bit operand to evaluate.
+
+ @return 1 << HighBitSet32(Operand)
+ @retval 0 Operand is zero.
+
+**/
+UINT32
+EFIAPI
+GetPowerOfTwo32 (
+ IN UINT32 Operand
+ );
+
+/**
+ Returns the value of the highest bit set in a 64-bit value. Equivalent to
+ 1 << HighBitSet64(x).
+
+ This function computes the value of the highest bit set in the 64-bit value
+ specified by Operand. If Operand is zero, then zero is returned.
+
+ @param Operand The 64-bit operand to evaluate.
+
+ @return 1 << HighBitSet64(Operand)
+ @retval 0 Operand is zero.
+
+**/
+UINT64
+EFIAPI
+GetPowerOfTwo64 (
+ IN UINT64 Operand
+ );
+
+/**
+ Switches the endianess of a 16-bit integer.
+
+ This function swaps the bytes in a 16-bit unsigned value to switch the value
+ from little endian to big endian or vice versa. The byte swapped value is
+ returned.
+
+ @param Operand A 16-bit unsigned value.
+
+ @return The byte swaped Operand.
+
+**/
+UINT16
+EFIAPI
+SwapBytes16 (
+ IN UINT16 Value
+ );
+
+/**
+ Switches the endianess of a 32-bit integer.
+
+ This function swaps the bytes in a 32-bit unsigned value to switch the value
+ from little endian to big endian or vice versa. The byte swapped value is
+ returned.
+
+ @param Operand A 32-bit unsigned value.
+
+ @return The byte swaped Operand.
+
+**/
+UINT32
+EFIAPI
+SwapBytes32 (
+ IN UINT32 Value
+ );
+
+/**
+ Switches the endianess of a 64-bit integer.
+
+ This function swaps the bytes in a 64-bit unsigned value to switch the value
+ from little endian to big endian or vice versa. The byte swapped value is
+ returned.
+
+ @param Operand A 64-bit unsigned value.
+
+ @return The byte swaped Operand.
+
+**/
+UINT64
+EFIAPI
+SwapBytes64 (
+ IN UINT64 Value
+ );
+
+/**
+ Multiples a 64-bit unsigned integer by a 32-bit unsigned integer and
+ generates a 64-bit unsigned result.
+
+ This function multiples the 64-bit unsigned value Multiplicand by the 32-bit
+ unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
+ bit unsigned result is returned.
+
+ If the result overflows, then ASSERT().
+
+ @param Multiplicand A 64-bit unsigned value.
+ @param Multiplier A 32-bit unsigned value.
+
+ @return Multiplicand * Multiplier
+
+**/
+UINT64
+EFIAPI
+GlueMultU64x32 (
+ IN UINT64 Multiplicand,
+ IN UINT32 Multiplier
+ );
+
+/**
+ Multiples a 64-bit unsigned integer by a 64-bit unsigned integer and
+ generates a 64-bit unsigned result.
+
+ This function multiples the 64-bit unsigned value Multiplicand by the 64-bit
+ unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
+ bit unsigned result is returned.
+
+ If the result overflows, then ASSERT().
+
+ @param Multiplicand A 64-bit unsigned value.
+ @param Multiplier A 64-bit unsigned value.
+
+ @return Multiplicand * Multiplier
+
+**/
+UINT64
+EFIAPI
+MultU64x64 (
+ IN UINT64 Multiplicand,
+ IN UINT64 Multiplier
+ );
+
+/**
+ Multiples a 64-bit signed integer by a 64-bit signed integer and generates a
+ 64-bit signed result.
+
+ This function multiples the 64-bit signed value Multiplicand by the 64-bit
+ signed value Multiplier and generates a 64-bit signed result. This 64-bit
+ signed result is returned.
+
+ If the result overflows, then ASSERT().
+
+ @param Multiplicand A 64-bit signed value.
+ @param Multiplier A 64-bit signed value.
+
+ @return Multiplicand * Multiplier
+
+**/
+INT64
+EFIAPI
+MultS64x64 (
+ IN INT64 Multiplicand,
+ IN INT64 Multiplier
+ );
+
+/**
+ Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
+ a 64-bit unsigned result.
+
+ This function divides the 64-bit unsigned value Dividend by the 32-bit
+ unsigned value Divisor and generates a 64-bit unsigned quotient. This
+ function returns the 64-bit unsigned quotient.
+
+ If Divisor is 0, then ASSERT().
+
+ @param Dividend A 64-bit unsigned value.
+ @param Divisor A 32-bit unsigned value.
+
+ @return Dividend / Divisor
+
+**/
+UINT64
+EFIAPI
+GlueDivU64x32 (
+ IN UINT64 Dividend,
+ IN UINT32 Divisor
+ );
+
+/**
+ Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
+ a 32-bit unsigned remainder.
+
+ This function divides the 64-bit unsigned value Dividend by the 32-bit
+ unsigned value Divisor and generates a 32-bit remainder. This function
+ returns the 32-bit unsigned remainder.
+
+ If Divisor is 0, then ASSERT().
+
+ @param Dividend A 64-bit unsigned value.
+ @param Divisor A 32-bit unsigned value.
+
+ @return Dividend % Divisor
+
+**/
+UINT32
+EFIAPI
+ModU64x32 (
+ IN UINT64 Dividend,
+ IN UINT32 Divisor
+ );
+
+/**
+ Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
+ a 64-bit unsigned result and an optional 32-bit unsigned remainder.
+
+ This function divides the 64-bit unsigned value Dividend by the 32-bit
+ unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
+ is not NULL, then the 32-bit unsigned remainder is returned in Remainder.
+ This function returns the 64-bit unsigned quotient.
+
+ If Divisor is 0, then ASSERT().
+
+ @param Dividend A 64-bit unsigned value.
+ @param Divisor A 32-bit unsigned value.
+ @param Remainder A pointer to a 32-bit unsigned value. This parameter is
+ optional and may be NULL.
+
+ @return Dividend / Divisor
+
+**/
+UINT64
+EFIAPI
+DivU64x32Remainder (
+ IN UINT64 Dividend,
+ IN UINT32 Divisor,
+ OUT UINT32 *Remainder OPTIONAL
+ );
+
+/**
+ Divides a 64-bit unsigned integer by a 64-bit unsigned integer and generates
+ a 64-bit unsigned result and an optional 64-bit unsigned remainder.
+
+ This function divides the 64-bit unsigned value Dividend by the 64-bit
+ unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
+ is not NULL, then the 64-bit unsigned remainder is returned in Remainder.
+ This function returns the 64-bit unsigned quotient.
+
+ If Divisor is 0, then ASSERT().
+
+ @param Dividend A 64-bit unsigned value.
+ @param Divisor A 64-bit unsigned value.
+ @param Remainder A pointer to a 64-bit unsigned value. This parameter is
+ optional and may be NULL.
+
+ @return Dividend / Divisor
+
+**/
+UINT64
+EFIAPI
+DivU64x64Remainder (
+ IN UINT64 Dividend,
+ IN UINT64 Divisor,
+ OUT UINT64 *Remainder OPTIONAL
+ );
+
+/**
+ Divides a 64-bit signed integer by a 64-bit signed integer and generates a
+ 64-bit signed result and a optional 64-bit signed remainder.
+
+ This function divides the 64-bit signed value Dividend by the 64-bit signed
+ value Divisor and generates a 64-bit signed quotient. If Remainder is not
+ NULL, then the 64-bit signed remainder is returned in Remainder. This
+ function returns the 64-bit signed quotient.
+
+ If Divisor is 0, then ASSERT().
+
+ @param Dividend A 64-bit signed value.
+ @param Divisor A 64-bit signed value.
+ @param Remainder A pointer to a 64-bit signed value. This parameter is
+ optional and may be NULL.
+
+ @return Dividend / Divisor
+
+**/
+INT64
+EFIAPI
+DivS64x64Remainder (
+ IN INT64 Dividend,
+ IN INT64 Divisor,
+ OUT INT64 *Remainder OPTIONAL
+ );
+
+/**
+ Reads a 16-bit value from memory that may be unaligned.
+
+ This function returns the 16-bit value pointed to by Buffer. The function
+ guarantees that the read operation does not produce an alignment fault.
+
+ If the Buffer is NULL, then ASSERT().
+
+ @param Buffer Pointer to a 16-bit value that may be unaligned.
+
+ @return *Uint16
+
+**/
+UINT16
+EFIAPI
+ReadUnaligned16 (
+ IN CONST UINT16 *Uint16
+ );
+
+/**
+ Writes a 16-bit value to memory that may be unaligned.
+
+ This function writes the 16-bit value specified by Value to Buffer. Value is
+ returned. The function guarantees that the write operation does not produce
+ an alignment fault.
+
+ If the Buffer is NULL, then ASSERT().
+
+ @param Buffer Pointer to a 16-bit value that may be unaligned.
+ @param Value 16-bit value to write to Buffer.
+
+ @return Value
+
+**/
+UINT16
+EFIAPI
+WriteUnaligned16 (
+ OUT UINT16 *Uint16,
+ IN UINT16 Value
+ );
+
+/**
+ Reads a 24-bit value from memory that may be unaligned.
+
+ This function returns the 24-bit value pointed to by Buffer. The function
+ guarantees that the read operation does not produce an alignment fault.
+
+ If the Buffer is NULL, then ASSERT().
+
+ @param Buffer Pointer to a 24-bit value that may be unaligned.
+
+ @return The value read.
+
+**/
+UINT32
+EFIAPI
+ReadUnaligned24 (
+ IN CONST UINT32 *Buffer
+ );
+
+/**
+ Writes a 24-bit value to memory that may be unaligned.
+
+ This function writes the 24-bit value specified by Value to Buffer. Value is
+ returned. The function guarantees that the write operation does not produce
+ an alignment fault.
+
+ If the Buffer is NULL, then ASSERT().
+
+ @param Buffer Pointer to a 24-bit value that may be unaligned.
+ @param Value 24-bit value to write to Buffer.
+
+ @return The value written.
+
+**/
+UINT32
+EFIAPI
+WriteUnaligned24 (
+ OUT UINT32 *Buffer,
+ IN UINT32 Value
+ );
+
+/**
+ Reads a 32-bit value from memory that may be unaligned.
+
+ This function returns the 32-bit value pointed to by Buffer. The function
+ guarantees that the read operation does not produce an alignment fault.
+
+ If the Buffer is NULL, then ASSERT().
+
+ @param Buffer Pointer to a 32-bit value that may be unaligned.
+
+ @return *Uint32
+
+**/
+UINT32
+EFIAPI
+ReadUnaligned32 (
+ IN CONST UINT32 *Uint32
+ );
+
+/**
+ Writes a 32-bit value to memory that may be unaligned.
+
+ This function writes the 32-bit value specified by Value to Buffer. Value is
+ returned. The function guarantees that the write operation does not produce
+ an alignment fault.
+
+ If the Buffer is NULL, then ASSERT().
+
+ @param Buffer Pointer to a 32-bit value that may be unaligned.
+ @param Value 32-bit value to write to Buffer.
+
+ @return Value
+
+**/
+UINT32
+EFIAPI
+WriteUnaligned32 (
+ OUT UINT32 *Uint32,
+ IN UINT32 Value
+ );
+
+/**
+ Reads a 64-bit value from memory that may be unaligned.
+
+ This function returns the 64-bit value pointed to by Buffer. The function
+ guarantees that the read operation does not produce an alignment fault.
+
+ If the Buffer is NULL, then ASSERT().
+
+ @param Buffer Pointer to a 64-bit value that may be unaligned.
+
+ @return *Uint64
+
+**/
+UINT64
+EFIAPI
+ReadUnaligned64 (
+ IN CONST UINT64 *Uint64
+ );
+
+/**
+ Writes a 64-bit value to memory that may be unaligned.
+
+ This function writes the 64-bit value specified by Value to Buffer. Value is
+ returned. The function guarantees that the write operation does not produce
+ an alignment fault.
+
+ If the Buffer is NULL, then ASSERT().
+
+ @param Buffer Pointer to a 64-bit value that may be unaligned.
+ @param Value 64-bit value to write to Buffer.
+
+ @return Value
+
+**/
+UINT64
+EFIAPI
+WriteUnaligned64 (
+ OUT UINT64 *Uint64,
+ IN UINT64 Value
+ );
+
+//
+// Bit Field Functions
+//
+
+/**
+ Returns a bit field from an 8-bit value.
+
+ Returns the bitfield specified by the StartBit and the EndBit from Operand.
+
+ If 8-bit operations are not supported, then ASSERT().
+ If StartBit is greater than 7, then ASSERT().
+ If EndBit is greater than 7, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Operand Operand on which to perform the bitfield operation.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..7.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..7.
+
+ @return The bit field read.
+
+**/
+UINT8
+EFIAPI
+BitFieldRead8 (
+ IN UINT8 Operand,
+ IN UINTN StartBit,
+ IN UINTN EndBit
+ );
+
+/**
+ Writes a bit field to an 8-bit value, and returns the result.
+
+ Writes Value to the bit field specified by the StartBit and the EndBit in
+ Operand. All other bits in Operand are preserved. The new 8-bit value is
+ returned.
+
+ If 8-bit operations are not supported, then ASSERT().
+ If StartBit is greater than 7, then ASSERT().
+ If EndBit is greater than 7, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Operand Operand on which to perform the bitfield operation.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..7.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..7.
+ @param Value New value of the bit field.
+
+ @return The new 8-bit value.
+
+**/
+UINT8
+EFIAPI
+BitFieldWrite8 (
+ IN UINT8 Operand,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT8 Value
+ );
+
+/**
+ Reads a bit field from an 8-bit value, performs a bitwise OR, and returns the
+ result.
+
+ Performs a bitwise inclusive OR between the bit field specified by StartBit
+ and EndBit in Operand and the value specified by OrData. All other bits in
+ Operand are preserved. The new 8-bit value is returned.
+
+ If 8-bit operations are not supported, then ASSERT().
+ If StartBit is greater than 7, then ASSERT().
+ If EndBit is greater than 7, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Operand Operand on which to perform the bitfield operation.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..7.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..7.
+ @param OrData The value to OR with the read value from the value
+
+ @return The new 8-bit value.
+
+**/
+UINT8
+EFIAPI
+BitFieldOr8 (
+ IN UINT8 Operand,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT8 OrData
+ );
+
+/**
+ Reads a bit field from an 8-bit value, performs a bitwise AND, and returns
+ the result.
+
+ Performs a bitwise AND between the bit field specified by StartBit and EndBit
+ in Operand and the value specified by AndData. All other bits in Operand are
+ preserved. The new 8-bit value is returned.
+
+ If 8-bit operations are not supported, then ASSERT().
+ If StartBit is greater than 7, then ASSERT().
+ If EndBit is greater than 7, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Operand Operand on which to perform the bitfield operation.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..7.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..7.
+ @param AndData The value to AND with the read value from the value.
+
+ @return The new 8-bit value.
+
+**/
+UINT8
+EFIAPI
+BitFieldAnd8 (
+ IN UINT8 Operand,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT8 AndData
+ );
+
+/**
+ Reads a bit field from an 8-bit value, performs a bitwise AND followed by a
+ bitwise OR, and returns the result.
+
+ Performs a bitwise AND between the bit field specified by StartBit and EndBit
+ in Operand and the value specified by AndData, followed by a bitwise
+ inclusive OR with value specified by OrData. All other bits in Operand are
+ preserved. The new 8-bit value is returned.
+
+ If 8-bit operations are not supported, then ASSERT().
+ If StartBit is greater than 7, then ASSERT().
+ If EndBit is greater than 7, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Operand Operand on which to perform the bitfield operation.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..7.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..7.
+ @param AndData The value to AND with the read value from the value.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The new 8-bit value.
+
+**/
+UINT8
+EFIAPI
+BitFieldAndThenOr8 (
+ IN UINT8 Operand,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT8 AndData,
+ IN UINT8 OrData
+ );
+
+/**
+ Returns a bit field from a 16-bit value.
+
+ Returns the bitfield specified by the StartBit and the EndBit from Operand.
+
+ If 16-bit operations are not supported, then ASSERT().
+ If StartBit is greater than 15, then ASSERT().
+ If EndBit is greater than 15, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Operand Operand on which to perform the bitfield operation.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..15.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..15.
+
+ @return The bit field read.
+
+**/
+UINT16
+EFIAPI
+BitFieldRead16 (
+ IN UINT16 Operand,
+ IN UINTN StartBit,
+ IN UINTN EndBit
+ );
+
+/**
+ Writes a bit field to a 16-bit value, and returns the result.
+
+ Writes Value to the bit field specified by the StartBit and the EndBit in
+ Operand. All other bits in Operand are preserved. The new 16-bit value is
+ returned.
+
+ If 16-bit operations are not supported, then ASSERT().
+ If StartBit is greater than 15, then ASSERT().
+ If EndBit is greater than 15, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Operand Operand on which to perform the bitfield operation.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..15.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..15.
+ @param Value New value of the bit field.
+
+ @return The new 16-bit value.
+
+**/
+UINT16
+EFIAPI
+BitFieldWrite16 (
+ IN UINT16 Operand,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT16 Value
+ );
+
+/**
+ Reads a bit field from a 16-bit value, performs a bitwise OR, and returns the
+ result.
+
+ Performs a bitwise inclusive OR between the bit field specified by StartBit
+ and EndBit in Operand and the value specified by OrData. All other bits in
+ Operand are preserved. The new 16-bit value is returned.
+
+ If 16-bit operations are not supported, then ASSERT().
+ If StartBit is greater than 15, then ASSERT().
+ If EndBit is greater than 15, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Operand Operand on which to perform the bitfield operation.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..15.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..15.
+ @param OrData The value to OR with the read value from the value
+
+ @return The new 16-bit value.
+
+**/
+UINT16
+EFIAPI
+BitFieldOr16 (
+ IN UINT16 Operand,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT16 OrData
+ );
+
+/**
+ Reads a bit field from a 16-bit value, performs a bitwise AND, and returns
+ the result.
+
+ Performs a bitwise AND between the bit field specified by StartBit and EndBit
+ in Operand and the value specified by AndData. All other bits in Operand are
+ preserved. The new 16-bit value is returned.
+
+ If 16-bit operations are not supported, then ASSERT().
+ If StartBit is greater than 15, then ASSERT().
+ If EndBit is greater than 15, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Operand Operand on which to perform the bitfield operation.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..15.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..15.
+ @param AndData The value to AND with the read value from the value
+
+ @return The new 16-bit value.
+
+**/
+UINT16
+EFIAPI
+BitFieldAnd16 (
+ IN UINT16 Operand,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT16 AndData
+ );
+
+/**
+ Reads a bit field from a 16-bit value, performs a bitwise AND followed by a
+ bitwise OR, and returns the result.
+
+ Performs a bitwise AND between the bit field specified by StartBit and EndBit
+ in Operand and the value specified by AndData, followed by a bitwise
+ inclusive OR with value specified by OrData. All other bits in Operand are
+ preserved. The new 16-bit value is returned.
+
+ If 16-bit operations are not supported, then ASSERT().
+ If StartBit is greater than 15, then ASSERT().
+ If EndBit is greater than 15, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Operand Operand on which to perform the bitfield operation.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..15.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..15.
+ @param AndData The value to AND with the read value from the value.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The new 16-bit value.
+
+**/
+UINT16
+EFIAPI
+BitFieldAndThenOr16 (
+ IN UINT16 Operand,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT16 AndData,
+ IN UINT16 OrData
+ );
+
+/**
+ Returns a bit field from a 32-bit value.
+
+ Returns the bitfield specified by the StartBit and the EndBit from Operand.
+
+ If 32-bit operations are not supported, then ASSERT().
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Operand Operand on which to perform the bitfield operation.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+
+ @return The bit field read.
+
+**/
+UINT32
+EFIAPI
+BitFieldRead32 (
+ IN UINT32 Operand,
+ IN UINTN StartBit,
+ IN UINTN EndBit
+ );
+
+/**
+ Writes a bit field to a 32-bit value, and returns the result.
+
+ Writes Value to the bit field specified by the StartBit and the EndBit in
+ Operand. All other bits in Operand are preserved. The new 32-bit value is
+ returned.
+
+ If 32-bit operations are not supported, then ASSERT().
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Operand Operand on which to perform the bitfield operation.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+ @param Value New value of the bit field.
+
+ @return The new 32-bit value.
+
+**/
+UINT32
+EFIAPI
+BitFieldWrite32 (
+ IN UINT32 Operand,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT32 Value
+ );
+
+/**
+ Reads a bit field from a 32-bit value, performs a bitwise OR, and returns the
+ result.
+
+ Performs a bitwise inclusive OR between the bit field specified by StartBit
+ and EndBit in Operand and the value specified by OrData. All other bits in
+ Operand are preserved. The new 32-bit value is returned.
+
+ If 32-bit operations are not supported, then ASSERT().
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Operand Operand on which to perform the bitfield operation.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+ @param OrData The value to OR with the read value from the value
+
+ @return The new 32-bit value.
+
+**/
+UINT32
+EFIAPI
+BitFieldOr32 (
+ IN UINT32 Operand,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT32 OrData
+ );
+
+/**
+ Reads a bit field from a 32-bit value, performs a bitwise AND, and returns
+ the result.
+
+ Performs a bitwise AND between the bit field specified by StartBit and EndBit
+ in Operand and the value specified by AndData. All other bits in Operand are
+ preserved. The new 32-bit value is returned.
+
+ If 32-bit operations are not supported, then ASSERT().
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Operand Operand on which to perform the bitfield operation.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+ @param AndData The value to AND with the read value from the value
+
+ @return The new 32-bit value.
+
+**/
+UINT32
+EFIAPI
+BitFieldAnd32 (
+ IN UINT32 Operand,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT32 AndData
+ );
+
+/**
+ Reads a bit field from a 32-bit value, performs a bitwise AND followed by a
+ bitwise OR, and returns the result.
+
+ Performs a bitwise AND between the bit field specified by StartBit and EndBit
+ in Operand and the value specified by AndData, followed by a bitwise
+ inclusive OR with value specified by OrData. All other bits in Operand are
+ preserved. The new 32-bit value is returned.
+
+ If 32-bit operations are not supported, then ASSERT().
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Operand Operand on which to perform the bitfield operation.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+ @param AndData The value to AND with the read value from the value.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The new 32-bit value.
+
+**/
+UINT32
+EFIAPI
+BitFieldAndThenOr32 (
+ IN UINT32 Operand,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT32 AndData,
+ IN UINT32 OrData
+ );
+
+/**
+ Returns a bit field from a 64-bit value.
+
+ Returns the bitfield specified by the StartBit and the EndBit from Operand.
+
+ If 64-bit operations are not supported, then ASSERT().
+ If StartBit is greater than 63, then ASSERT().
+ If EndBit is greater than 63, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Operand Operand on which to perform the bitfield operation.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..63.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..63.
+
+ @return The bit field read.
+
+**/
+UINT64
+EFIAPI
+BitFieldRead64 (
+ IN UINT64 Operand,
+ IN UINTN StartBit,
+ IN UINTN EndBit
+ );
+
+/**
+ Writes a bit field to a 64-bit value, and returns the result.
+
+ Writes Value to the bit field specified by the StartBit and the EndBit in
+ Operand. All other bits in Operand are preserved. The new 64-bit value is
+ returned.
+
+ If 64-bit operations are not supported, then ASSERT().
+ If StartBit is greater than 63, then ASSERT().
+ If EndBit is greater than 63, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Operand Operand on which to perform the bitfield operation.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..63.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..63.
+ @param Value New value of the bit field.
+
+ @return The new 64-bit value.
+
+**/
+UINT64
+EFIAPI
+BitFieldWrite64 (
+ IN UINT64 Operand,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT64 Value
+ );
+
+/**
+ Reads a bit field from a 64-bit value, performs a bitwise OR, and returns the
+ result.
+
+ Performs a bitwise inclusive OR between the bit field specified by StartBit
+ and EndBit in Operand and the value specified by OrData. All other bits in
+ Operand are preserved. The new 64-bit value is returned.
+
+ If 64-bit operations are not supported, then ASSERT().
+ If StartBit is greater than 63, then ASSERT().
+ If EndBit is greater than 63, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Operand Operand on which to perform the bitfield operation.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..63.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..63.
+ @param OrData The value to OR with the read value from the value
+
+ @return The new 64-bit value.
+
+**/
+UINT64
+EFIAPI
+BitFieldOr64 (
+ IN UINT64 Operand,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT64 OrData
+ );
+
+/**
+ Reads a bit field from a 64-bit value, performs a bitwise AND, and returns
+ the result.
+
+ Performs a bitwise AND between the bit field specified by StartBit and EndBit
+ in Operand and the value specified by AndData. All other bits in Operand are
+ preserved. The new 64-bit value is returned.
+
+ If 64-bit operations are not supported, then ASSERT().
+ If StartBit is greater than 63, then ASSERT().
+ If EndBit is greater than 63, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Operand Operand on which to perform the bitfield operation.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..63.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..63.
+ @param AndData The value to AND with the read value from the value
+
+ @return The new 64-bit value.
+
+**/
+UINT64
+EFIAPI
+BitFieldAnd64 (
+ IN UINT64 Operand,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT64 AndData
+ );
+
+/**
+ Reads a bit field from a 64-bit value, performs a bitwise AND followed by a
+ bitwise OR, and returns the result.
+
+ Performs a bitwise AND between the bit field specified by StartBit and EndBit
+ in Operand and the value specified by AndData, followed by a bitwise
+ inclusive OR with value specified by OrData. All other bits in Operand are
+ preserved. The new 64-bit value is returned.
+
+ If 64-bit operations are not supported, then ASSERT().
+ If StartBit is greater than 63, then ASSERT().
+ If EndBit is greater than 63, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Operand Operand on which to perform the bitfield operation.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..63.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..63.
+ @param AndData The value to AND with the read value from the value.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The new 64-bit value.
+
+**/
+UINT64
+EFIAPI
+BitFieldAndThenOr64 (
+ IN UINT64 Operand,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT64 AndData,
+ IN UINT64 OrData
+ );
+
+//
+// Base Library Synchronization Functions
+//
+
+/**
+ Retrieves the architecture specific spin lock alignment requirements for
+ optimal spin lock performance.
+
+ This function retrieves the spin lock alignment requirements for optimal
+ performance on a given CPU architecture. The spin lock alignment must be a
+ power of two and is returned by this function. If there are no alignment
+ requirements, then 1 must be returned. The spin lock synchronization
+ functions must function correctly if the spin lock size and alignment values
+ returned by this function are not used at all. These values are hints to the
+ consumers of the spin lock synchronization functions to obtain optimal spin
+ lock performance.
+
+ @return The architecture specific spin lock alignment.
+
+**/
+UINTN
+EFIAPI
+GetSpinLockProperties (
+ VOID
+ );
+
+/**
+ Initializes a spin lock to the released state and returns the spin lock.
+
+ This function initializes the spin lock specified by SpinLock to the released
+ state, and returns SpinLock. Optimal performance can be achieved by calling
+ GetSpinLockProperties() to determine the size and alignment requirements for
+ SpinLock.
+
+ If SpinLock is NULL, then ASSERT().
+
+ @param SpinLock A pointer to the spin lock to initialize to the released
+ state.
+
+ @return SpinLock
+
+**/
+SPIN_LOCK *
+EFIAPI
+InitializeSpinLock (
+ IN SPIN_LOCK *SpinLock
+ );
+
+/**
+ Waits until a spin lock can be placed in the acquired state.
+
+ This function checks the state of the spin lock specified by SpinLock. If
+ SpinLock is in the released state, then this function places SpinLock in the
+ acquired state and returns SpinLock. Otherwise, this function waits
+ indefinitely for the spin lock to be released, and then places it in the
+ acquired state and returns SpinLock. All state transitions of SpinLock must
+ be performed using MP safe mechanisms.
+
+ If SpinLock is NULL, then ASSERT().
+ If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().
+ If PcdSpinLockTimeout is not zero, and SpinLock is can not be acquired in
+ PcdSpinLockTimeout microseconds, then ASSERT().
+
+ @param SpinLock A pointer to the spin lock to place in the acquired state.
+
+ @return SpinLock
+
+**/
+SPIN_LOCK *
+EFIAPI
+AcquireSpinLock (
+ IN SPIN_LOCK *SpinLock
+ );
+
+/**
+ Attempts to place a spin lock in the acquired state.
+
+ This function checks the state of the spin lock specified by SpinLock. If
+ SpinLock is in the released state, then this function places SpinLock in the
+ acquired state and returns TRUE. Otherwise, FALSE is returned. All state
+ transitions of SpinLock must be performed using MP safe mechanisms.
+
+ If SpinLock is NULL, then ASSERT().
+ If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().
+
+ @param SpinLock A pointer to the spin lock to place in the acquired state.
+
+ @retval TRUE SpinLock was placed in the acquired state.
+ @retval FALSE SpinLock could not be acquired.
+
+**/
+BOOLEAN
+EFIAPI
+AcquireSpinLockOrFail (
+ IN SPIN_LOCK *SpinLock
+ );
+
+/**
+ Releases a spin lock.
+
+ This function places the spin lock specified by SpinLock in the release state
+ and returns SpinLock.
+
+ If SpinLock is NULL, then ASSERT().
+ If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().
+
+ @param SpinLock A pointer to the spin lock to release.
+
+ @return SpinLock
+
+**/
+SPIN_LOCK *
+EFIAPI
+ReleaseSpinLock (
+ IN SPIN_LOCK *SpinLock
+ );
+
+/**
+ Performs an atomic increment of an 32-bit unsigned integer.
+
+ Performs an atomic increment of the 32-bit unsigned integer specified by
+ Value and returns the incremented value. The increment operation must be
+ performed using MP safe mechanisms. The state of the return value is not
+ guaranteed to be MP safe.
+
+ If Value is NULL, then ASSERT().
+
+ @param Value A pointer to the 32-bit value to increment.
+
+ @return The incremented value.
+
+**/
+UINT32
+EFIAPI
+InterlockedIncrement (
+ IN UINT32 *Value
+ );
+
+/**
+ Performs an atomic decrement of an 32-bit unsigned integer.
+
+ Performs an atomic decrement of the 32-bit unsigned integer specified by
+ Value and returns the decremented value. The decrement operation must be
+ performed using MP safe mechanisms. The state of the return value is not
+ guaranteed to be MP safe.
+
+ If Value is NULL, then ASSERT().
+
+ @param Value A pointer to the 32-bit value to decrement.
+
+ @return The decremented value.
+
+**/
+UINT32
+EFIAPI
+InterlockedDecrement (
+ IN UINT32 *Value
+ );
+
+/**
+ Performs an atomic compare exchange operation on a 32-bit unsigned integer.
+
+ Performs an atomic compare exchange operation on the 32-bit unsigned integer
+ specified by Value. If Value is equal to CompareValue, then Value is set to
+ ExchangeValue and CompareValue is returned. If Value is not equal to CompareValue,
+ then Value is returned. The compare exchange operation must be performed using
+ MP safe mechanisms.
+
+ If Value is NULL, then ASSERT().
+
+ @param Value A pointer to the 32-bit value for the compare exchange
+ operation.
+ @param CompareValue 32-bit value used in compare operation.
+ @param ExchangeValue 32-bit value used in exchange operation.
+
+ @return The original *Value before exchange.
+
+**/
+UINT32
+EFIAPI
+InterlockedCompareExchange32 (
+ IN OUT VOLATILE UINT32 *Value,
+ IN UINT32 CompareValue,
+ IN UINT32 ExchangeValue
+ );
+
+/**
+ Performs an atomic compare exchange operation on a 64-bit unsigned integer.
+
+ Performs an atomic compare exchange operation on the 64-bit unsigned integer specified
+ by Value. If Value is equal to CompareValue, then Value is set to ExchangeValue and
+ CompareValue is returned. If Value is not equal to CompareValue, then Value is returned.
+ The compare exchange operation must be performed using MP safe mechanisms.
+
+ If Value is NULL, then ASSERT().
+
+ @param Value A pointer to the 64-bit value for the compare exchange
+ operation.
+ @param CompareValue 64-bit value used in compare operation.
+ @param ExchangeValue 64-bit value used in exchange operation.
+
+ @return The original *Value before exchange.
+
+**/
+UINT64
+EFIAPI
+InterlockedCompareExchange64 (
+ IN OUT VOLATILE UINT64 *Value,
+ IN UINT64 CompareValue,
+ IN UINT64 ExchangeValue
+ );
+
+/**
+ Performs an atomic compare exchange operation on a pointer value.
+
+ Performs an atomic compare exchange operation on the pointer value specified
+ by Value. If Value is equal to CompareValue, then Value is set to
+ ExchangeValue and CompareValue is returned. If Value is not equal to
+ CompareValue, then Value is returned. The compare exchange operation must be
+ performed using MP safe mechanisms.
+
+ If Value is NULL, then ASSERT().
+
+ @param Value A pointer to the pointer value for the compare exchange
+ operation.
+ @param CompareValue Pointer value used in compare operation.
+ @param ExchangeValue Pointer value used in exchange operation.
+
+**/
+VOID *
+EFIAPI
+InterlockedCompareExchangePointer (
+ IN OUT VOLATILE VOID **Value,
+ IN VOID *CompareValue,
+ IN VOID *ExchangeValue
+ );
+
+//
+// Base Library CPU Functions
+//
+typedef
+VOID
+(EFIAPI *SWITCH_STACK_ENTRY_POINT) (
+ IN VOID *Context1, OPTIONAL
+ IN VOID *Context2 OPTIONAL
+ );
+
+/**
+ Used to serialize load and store operations.
+
+ All loads and stores that proceed calls to this function are guaranteed to be
+ globally visible when this function returns.
+
+**/
+VOID
+EFIAPI
+MemoryFence (
+ VOID
+ );
+
+/**
+ Saves the current CPU context that can be restored with a call to LongJump()
+ and returns 0.
+
+ Saves the current CPU context in the buffer specified by JumpBuffer and
+ returns 0. The initial call to SetJump() must always return 0. Subsequent
+ calls to LongJump() cause a non-zero value to be returned by SetJump().
+
+ If JumpBuffer is NULL, then ASSERT().
+ For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
+
+ @param JumpBuffer A pointer to CPU context buffer.
+
+ @retval 0 Indicates a return from SetJump().
+
+**/
+UINTN
+EFIAPI
+SetJump (
+ OUT BASE_LIBRARY_JUMP_BUFFER *JumpBuffer
+ );
+
+/**
+ Restores the CPU context that was saved with SetJump().
+
+ Restores the CPU context from the buffer specified by JumpBuffer. This
+ function never returns to the caller. Instead is resumes execution based on
+ the state of JumpBuffer.
+
+ If JumpBuffer is NULL, then ASSERT().
+ For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
+ If Value is 0, then ASSERT().
+
+ @param JumpBuffer A pointer to CPU context buffer.
+ @param Value The value to return when the SetJump() context is
+ restored and must be non-zero.
+
+**/
+VOID
+EFIAPI
+LongJump (
+ IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer,
+ IN UINTN Value
+ );
+
+/**
+ Enables CPU interrupts.
+
+ Enables CPU interrupts.
+
+**/
+VOID
+EFIAPI
+EnableInterrupts (
+ VOID
+ );
+
+/**
+ Disables CPU interrupts.
+
+ Disables CPU interrupts.
+
+**/
+VOID
+EFIAPI
+DisableInterrupts (
+ VOID
+ );
+
+/**
+ Disables CPU interrupts and returns the interrupt state prior to the disable
+ operation.
+
+ Disables CPU interrupts and returns the interrupt state prior to the disable
+ operation.
+
+ @retval TRUE CPU interrupts were enabled on entry to this call.
+ @retval FALSE CPU interrupts were disabled on entry to this call.
+
+**/
+BOOLEAN
+EFIAPI
+SaveAndDisableInterrupts (
+ VOID
+ );
+
+/**
+ Enables CPU interrupts for the smallest window required to capture any
+ pending interrupts.
+
+ Enables CPU interrupts for the smallest window required to capture any
+ pending interrupts.
+
+**/
+VOID
+EFIAPI
+EnableDisableInterrupts (
+ VOID
+ );
+
+/**
+ Retrieves the current CPU interrupt state.
+
+ Retrieves the current CPU interrupt state. Returns TRUE is interrupts are
+ currently enabled. Otherwise returns FALSE.
+
+ @retval TRUE CPU interrupts are enabled.
+ @retval FALSE CPU interrupts are disabled.
+
+**/
+BOOLEAN
+EFIAPI
+GlueGetInterruptState (
+ VOID
+ );
+
+/**
+ Set the current CPU interrupt state.
+
+ Sets the current CPU interrupt state to the state specified by
+ InterruptState. If InterruptState is TRUE, then interrupts are enabled. If
+ InterruptState is FALSE, then interrupts are disabled. InterruptState is
+ returned.
+
+ @param InterruptState TRUE if interrupts should enabled. FALSE if
+ interrupts should be disabled.
+
+ @return InterruptState
+
+**/
+BOOLEAN
+EFIAPI
+SetInterruptState (
+ IN BOOLEAN InterruptState
+ );
+
+/**
+ Places the CPU in a sleep state until an interrupt is received.
+
+ Places the CPU in a sleep state until an interrupt is received. If interrupts
+ are disabled prior to calling this function, then the CPU will be placed in a
+ sleep state indefinitely.
+
+**/
+VOID
+EFIAPI
+CpuSleep (
+ VOID
+ );
+
+/**
+ Requests CPU to pause for a short period of time.
+
+ Requests CPU to pause for a short period of time. Typically used in MP
+ systems to prevent memory starvation while waiting for a spin lock.
+
+**/
+VOID
+EFIAPI
+CpuPause (
+ VOID
+ );
+
+/**
+ Flushes all the Translation Lookaside Buffers(TLB) entries in a CPU.
+
+ Flushes all the Translation Lookaside Buffers(TLB) entries in a CPU.
+
+**/
+VOID
+EFIAPI
+CpuFlushTlb (
+ VOID
+ );
+
+/**
+ Transfers control to a function starting with a new stack.
+
+ Transfers control to the function specified by EntryPoint using the new stack
+ specified by NewStack and passing in the parameters specified by Context1 and
+ Context2. Context1 and Context2 are optional and may be NULL. The function
+ EntryPoint must never return.
+
+ If EntryPoint is NULL, then ASSERT().
+ If NewStack is NULL, then ASSERT().
+
+ @param EntryPoint A pointer to function to call with the new stack.
+ @param Context1 A pointer to the context to pass into the EntryPoint
+ function.
+ @param Context2 A pointer to the context to pass into the EntryPoint
+ function.
+ @param NewStack A pointer to the new stack to use for the EntryPoint
+ function.
+
+**/
+VOID
+EFIAPI
+SwitchStack (
+ IN SWITCH_STACK_ENTRY_POINT EntryPoint,
+ IN VOID *Context1, OPTIONAL
+ IN VOID *Context2, OPTIONAL
+ IN VOID *NewStack
+ );
+
+/**
+ Generates a breakpoint on the CPU.
+
+ Generates a breakpoint on the CPU. The breakpoint must be implemented such
+ that code can resume normal execution after the breakpoint.
+
+**/
+VOID
+EFIAPI
+CpuBreakpoint (
+ VOID
+ );
+
+/**
+ Executes an infinite loop.
+
+ Forces the CPU to execute an infinite loop. A debugger may be used to skip
+ past the loop and the code that follows the loop must execute properly. This
+ implies that the infinite loop must not cause the code that follow it to be
+ optimized away.
+
+**/
+VOID
+EFIAPI
+CpuDeadLoop (
+ VOID
+ );
+
+//
+// IA32 and X64 Specific Functions
+//
+//
+// Byte packed structure for 16-bit Real Mode EFLAGS
+//
+typedef union {
+ struct {
+ UINT32 CF:1; // Carry Flag
+ UINT32 Reserved_0:1; // Reserved
+ UINT32 PF:1; // Parity Flag
+ UINT32 Reserved_1:1; // Reserved
+ UINT32 AF:1; // Auxiliary Carry Flag
+ UINT32 Reserved_2:1; // Reserved
+ UINT32 ZF:1; // Zero Flag
+ UINT32 SF:1; // Sign Flag
+ UINT32 TF:1; // Trap Flag
+ UINT32 IF:1; // Interrupt Enable Flag
+ UINT32 DF:1; // Direction Flag
+ UINT32 OF:1; // Overflow Flag
+ UINT32 IOPL:2; // I/O Privilege Level
+ UINT32 NT:1; // Nested Task
+ UINT32 Reserved_3:1; // Reserved
+ } Bits;
+ UINT16 Uint16;
+} IA32_FLAGS16;
+
+//
+// Byte packed structure for EFLAGS/RFLAGS
+// 32-bits on IA-32
+// 64-bits on X64. The upper 32-bits on X64 are reserved
+//
+typedef union {
+ struct {
+ UINT32 CF:1; // Carry Flag
+ UINT32 Reserved_0:1; // Reserved
+ UINT32 PF:1; // Parity Flag
+ UINT32 Reserved_1:1; // Reserved
+ UINT32 AF:1; // Auxiliary Carry Flag
+ UINT32 Reserved_2:1; // Reserved
+ UINT32 ZF:1; // Zero Flag
+ UINT32 SF:1; // Sign Flag
+ UINT32 TF:1; // Trap Flag
+ UINT32 IF:1; // Interrupt Enable Flag
+ UINT32 DF:1; // Direction Flag
+ UINT32 OF:1; // Overflow Flag
+ UINT32 IOPL:2; // I/O Privilege Level
+ UINT32 NT:1; // Nested Task
+ UINT32 Reserved_3:1; // Reserved
+ UINT32 RF:1; // Resume Flag
+ UINT32 VM:1; // Virtual 8086 Mode
+ UINT32 AC:1; // Alignment Check
+ UINT32 VIF:1; // Virtual Interrupt Flag
+ UINT32 VIP:1; // Virtual Interrupt Pending
+ UINT32 ID:1; // ID Flag
+ UINT32 Reserved_4:10; // Reserved
+ } Bits;
+ UINTN UintN;
+} IA32_EFLAGS32;
+
+//
+// Byte packed structure for Control Register 0 (CR0)
+// 32-bits on IA-32
+// 64-bits on X64. The upper 32-bits on X64 are reserved
+//
+typedef union {
+ struct {
+ UINT32 PE:1; // Protection Enable
+ UINT32 MP:1; // Monitor Coprocessor
+ UINT32 EM:1; // Emulation
+ UINT32 TS:1; // Task Switched
+ UINT32 ET:1; // Extension Type
+ UINT32 NE:1; // Numeric Error
+ UINT32 Reserved_0:10; // Reserved
+ UINT32 WP:1; // Write Protect
+ UINT32 Reserved_1:1; // Reserved
+ UINT32 AM:1; // Alignment Mask
+ UINT32 Reserved_2:10; // Reserved
+ UINT32 NW:1; // Mot Write-through
+ UINT32 CD:1; // Cache Disable
+ UINT32 PG:1; // Paging
+ } Bits;
+ UINTN UintN;
+} IA32_CR0;
+
+//
+// Byte packed structure for Control Register 4 (CR4)
+// 32-bits on IA-32
+// 64-bits on X64. The upper 32-bits on X64 are reserved
+//
+typedef union {
+ struct {
+ UINT32 VME:1; // Virtual-8086 Mode Extensions
+ UINT32 PVI:1; // Protected-Mode Virtual Interrupts
+ UINT32 TSD:1; // Time Stamp Disable
+ UINT32 DE:1; // Debugging Extensions
+ UINT32 PSE:1; // Page Size Extensions
+ UINT32 PAE:1; // Physical Address Extension
+ UINT32 MCE:1; // Machine Check Enable
+ UINT32 PGE:1; // Page Global Enable
+ UINT32 PCE:1; // Performance Monitoring Counter
+ // Enable
+ UINT32 OSFXSR:1; // Operating System Support for
+ // FXSAVE and FXRSTOR instructions
+ UINT32 OSXMMEXCPT:1; // Operating System Support for
+ // Unmasked SIMD Floating Point
+ // Exceptions
+ UINT32 Reserved_0:2; // Reserved
+ UINT32 VMXE:1; // VMX Enable
+ UINT32 Reserved_1:18; // Reseved
+ } Bits;
+ UINTN UintN;
+} IA32_CR4;
+
+//
+// Byte packed structure for an IDTR, GDTR, LDTR descriptor
+/// @bug How to make this structure byte-packed in a compiler independent way?
+//
+#pragma pack (1)
+typedef struct {
+ UINT16 Limit;
+ UINTN Base;
+} IA32_DESCRIPTOR;
+#pragma pack ()
+
+#define IA32_IDT_GATE_TYPE_TASK 0x85
+#define IA32_IDT_GATE_TYPE_INTERRUPT_16 0x86
+#define IA32_IDT_GATE_TYPE_TRAP_16 0x87
+#define IA32_IDT_GATE_TYPE_INTERRUPT_32 0x8E
+#define IA32_IDT_GATE_TYPE_TRAP_32 0x8F
+
+//
+// Byte packed structure for an Interrupt Gate Descriptor
+//
+typedef union {
+ struct {
+ UINT32 OffsetLow:16; // Offset bits 15..0
+ UINT32 Selector:16; // Selector
+ UINT32 Reserved_0:8; // Reserved
+ UINT32 GateType:8; // Gate Type. See #defines above
+ UINT32 OffsetHigh:16; // Offset bits 31..16
+ } Bits;
+ UINT64 Uint64;
+} IA32_IDT_GATE_DESCRIPTOR;
+
+//
+// Byte packed structure for an FP/SSE/SSE2 context
+//
+typedef struct {
+ UINT8 Buffer[512];
+} IA32_FX_BUFFER;
+
+//
+// Structures for the 16-bit real mode thunks
+//
+typedef struct {
+ UINT32 Reserved1;
+ UINT32 Reserved2;
+ UINT32 Reserved3;
+ UINT32 Reserved4;
+ UINT8 BL;
+ UINT8 BH;
+ UINT16 Reserved5;
+ UINT8 DL;
+ UINT8 DH;
+ UINT16 Reserved6;
+ UINT8 CL;
+ UINT8 CH;
+ UINT16 Reserved7;
+ UINT8 AL;
+ UINT8 AH;
+ UINT16 Reserved8;
+} IA32_BYTE_REGS;
+
+typedef struct {
+ UINT16 DI;
+ UINT16 Reserved1;
+ UINT16 SI;
+ UINT16 Reserved2;
+ UINT16 BP;
+ UINT16 Reserved3;
+ UINT16 SP;
+ UINT16 Reserved4;
+ UINT16 BX;
+ UINT16 Reserved5;
+ UINT16 DX;
+ UINT16 Reserved6;
+ UINT16 CX;
+ UINT16 Reserved7;
+ UINT16 AX;
+ UINT16 Reserved8;
+} IA32_WORD_REGS;
+
+typedef struct {
+ UINT32 EDI;
+ UINT32 ESI;
+ UINT32 EBP;
+ UINT32 ESP;
+ UINT32 EBX;
+ UINT32 EDX;
+ UINT32 ECX;
+ UINT32 EAX;
+ UINT16 DS;
+ UINT16 ES;
+ UINT16 FS;
+ UINT16 GS;
+ IA32_EFLAGS32 EFLAGS;
+ UINT32 Eip;
+ UINT16 CS;
+ UINT16 SS;
+} IA32_DWORD_REGS;
+
+typedef union {
+ IA32_DWORD_REGS E;
+ IA32_WORD_REGS X;
+ IA32_BYTE_REGS H;
+} IA32_REGISTER_SET;
+
+//
+// Byte packed structure for an 16-bit real mode thunks
+//
+typedef struct {
+ IA32_REGISTER_SET *RealModeState;
+ VOID *RealModeBuffer;
+ UINT32 RealModeBufferSize;
+ UINT32 ThunkAttributes;
+} THUNK_CONTEXT;
+
+#define THUNK_ATTRIBUTE_BIG_REAL_MODE 0x00000001
+#define THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 0x00000002
+#define THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL 0x00000004
+
+/**
+ Retrieves CPUID information.
+
+ Executes the CPUID instruction with EAX set to the value specified by Index.
+ This function always returns Index.
+ If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
+ If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
+ If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
+ If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
+ This function is only available on IA-32 and X64.
+
+ @param Index The 32-bit value to load into EAX prior to invoking the CPUID
+ instruction.
+ @param Eax Pointer to the 32-bit EAX value returned by the CPUID
+ instruction. This is an optional parameter that may be NULL.
+ @param Ebx Pointer to the 32-bit EBX value returned by the CPUID
+ instruction. This is an optional parameter that may be NULL.
+ @param Ecx Pointer to the 32-bit ECX value returned by the CPUID
+ instruction. This is an optional parameter that may be NULL.
+ @param Edx Pointer to the 32-bit EDX value returned by the CPUID
+ instruction. This is an optional parameter that may be NULL.
+
+ @return Index
+
+**/
+UINT32
+EFIAPI
+AsmCpuid (
+ IN UINT32 Index,
+ OUT UINT32 *Eax, OPTIONAL
+ OUT UINT32 *Ebx, OPTIONAL
+ OUT UINT32 *Ecx, OPTIONAL
+ OUT UINT32 *Edx OPTIONAL
+ );
+
+/**
+ Retrieves CPUID information using an extended leaf identifier.
+
+ Executes the CPUID instruction with EAX set to the value specified by Index
+ and ECX set to the value specified by SubIndex. This function always returns
+ Index. This function is only available on IA-32 and x64.
+
+ If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.
+ If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.
+ If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.
+ If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.
+
+ @param Index The 32-bit value to load into EAX prior to invoking the
+ CPUID instruction.
+ @param SubIndex The 32-bit value to load into ECX prior to invoking the
+ CPUID instruction.
+ @param Eax Pointer to the 32-bit EAX value returned by the CPUID
+ instruction. This is an optional parameter that may be
+ NULL.
+ @param Ebx Pointer to the 32-bit EBX value returned by the CPUID
+ instruction. This is an optional parameter that may be
+ NULL.
+ @param Ecx Pointer to the 32-bit ECX value returned by the CPUID
+ instruction. This is an optional parameter that may be
+ NULL.
+ @param Edx Pointer to the 32-bit EDX value returned by the CPUID
+ instruction. This is an optional parameter that may be
+ NULL.
+
+ @return Index
+
+**/
+UINT32
+EFIAPI
+AsmCpuidEx (
+ IN UINT32 Index,
+ IN UINT32 SubIndex,
+ OUT UINT32 *Eax, OPTIONAL
+ OUT UINT32 *Ebx, OPTIONAL
+ OUT UINT32 *Ecx, OPTIONAL
+ OUT UINT32 *Edx OPTIONAL
+ );
+
+/**
+ Returns the lower 32-bits of a Machine Specific Register(MSR).
+
+ Reads and returns the lower 32-bits of the MSR specified by Index.
+ No parameter checking is performed on Index, and some Index values may cause
+ CPU exceptions. The caller must either guarantee that Index is valid, or the
+ caller must set up exception handlers to catch the exceptions. This function
+ is only available on IA-32 and X64.
+
+ @param Index The 32-bit MSR index to read.
+
+ @return The lower 32 bits of the MSR identified by Index.
+
+**/
+UINT32
+EFIAPI
+AsmReadMsr32 (
+ IN UINT32 Index
+ );
+
+/**
+ Zero-extend a 32-bit value and writes it to a Machine Specific Register(MSR).
+
+ Writes the 32-bit value specified by Value to the MSR specified by Index. The
+ upper 32-bits of the MSR write are set to zero. The 32-bit value written to
+ the MSR is returned. No parameter checking is performed on Index or Value,
+ and some of these may cause CPU exceptions. The caller must either guarantee
+ that Index and Value are valid, or the caller must establish proper exception
+ handlers. This function is only available on IA-32 and X64.
+
+ @param Index The 32-bit MSR index to write.
+ @param Value The 32-bit value to write to the MSR.
+
+ @return Value
+
+**/
+UINT32
+EFIAPI
+AsmWriteMsr32 (
+ IN UINT32 Index,
+ IN UINT32 Value
+ );
+
+/**
+ Reads a 64-bit MSR, performs a bitwise inclusive OR on the lower 32-bits, and
+ writes the result back to the 64-bit MSR.
+
+ Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR
+ between the lower 32-bits of the read result and the value specified by
+ OrData, and writes the result to the 64-bit MSR specified by Index. The lower
+ 32-bits of the value written to the MSR is returned. No parameter checking is
+ performed on Index or OrData, and some of these may cause CPU exceptions. The
+ caller must either guarantee that Index and OrData are valid, or the caller
+ must establish proper exception handlers. This function is only available on
+ IA-32 and X64.
+
+ @param Index The 32-bit MSR index to write.
+ @param OrData The value to OR with the read value from the MSR.
+
+ @return The lower 32-bit value written to the MSR.
+
+**/
+UINT32
+EFIAPI
+AsmMsrOr32 (
+ IN UINT32 Index,
+ IN UINT32 OrData
+ );
+
+/**
+ Reads a 64-bit MSR, performs a bitwise AND on the lower 32-bits, and writes
+ the result back to the 64-bit MSR.
+
+ Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
+ lower 32-bits of the read result and the value specified by AndData, and
+ writes the result to the 64-bit MSR specified by Index. The lower 32-bits of
+ the value written to the MSR is returned. No parameter checking is performed
+ on Index or AndData, and some of these may cause CPU exceptions. The caller
+ must either guarantee that Index and AndData are valid, or the caller must
+ establish proper exception handlers. This function is only available on IA-32
+ and X64.
+
+ @param Index The 32-bit MSR index to write.
+ @param AndData The value to AND with the read value from the MSR.
+
+ @return The lower 32-bit value written to the MSR.
+
+**/
+UINT32
+EFIAPI
+AsmMsrAnd32 (
+ IN UINT32 Index,
+ IN UINT32 AndData
+ );
+
+/**
+ Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise inclusive OR
+ on the lower 32-bits, and writes the result back to the 64-bit MSR.
+
+ Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
+ lower 32-bits of the read result and the value specified by AndData
+ preserving the upper 32-bits, performs a bitwise inclusive OR between the
+ result of the AND operation and the value specified by OrData, and writes the
+ result to the 64-bit MSR specified by Address. The lower 32-bits of the value
+ written to the MSR is returned. No parameter checking is performed on Index,
+ AndData, or OrData, and some of these may cause CPU exceptions. The caller
+ must either guarantee that Index, AndData, and OrData are valid, or the
+ caller must establish proper exception handlers. This function is only
+ available on IA-32 and X64.
+
+ @param Index The 32-bit MSR index to write.
+ @param AndData The value to AND with the read value from the MSR.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The lower 32-bit value written to the MSR.
+
+**/
+UINT32
+EFIAPI
+AsmMsrAndThenOr32 (
+ IN UINT32 Index,
+ IN UINT32 AndData,
+ IN UINT32 OrData
+ );
+
+/**
+ Reads a bit field of an MSR.
+
+ Reads the bit field in the lower 32-bits of a 64-bit MSR. The bit field is
+ specified by the StartBit and the EndBit. The value of the bit field is
+ returned. The caller must either guarantee that Index is valid, or the caller
+ must set up exception handlers to catch the exceptions. This function is only
+ available on IA-32 and X64.
+
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Index The 32-bit MSR index to read.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+
+ @return The bit field read from the MSR.
+
+**/
+UINT32
+EFIAPI
+AsmMsrBitFieldRead32 (
+ IN UINT32 Index,
+ IN UINTN StartBit,
+ IN UINTN EndBit
+ );
+
+/**
+ Writes a bit field to an MSR.
+
+ Writes Value to a bit field in the lower 32-bits of a 64-bit MSR. The bit
+ field is specified by the StartBit and the EndBit. All other bits in the
+ destination MSR are preserved. The lower 32-bits of the MSR written is
+ returned. Extra left bits in Value are stripped. The caller must either
+ guarantee that Index and the data written is valid, or the caller must set up
+ exception handlers to catch the exceptions. This function is only available
+ on IA-32 and X64.
+
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Index The 32-bit MSR index to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+ @param Value New value of the bit field.
+
+ @return The lower 32-bit of the value written to the MSR.
+
+**/
+UINT32
+EFIAPI
+AsmMsrBitFieldWrite32 (
+ IN UINT32 Index,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT32 Value
+ );
+
+/**
+ Reads a bit field in a 64-bit MSR, performs a bitwise OR, and writes the
+ result back to the bit field in the 64-bit MSR.
+
+ Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR
+ between the read result and the value specified by OrData, and writes the
+ result to the 64-bit MSR specified by Index. The lower 32-bits of the value
+ written to the MSR are returned. Extra left bits in OrData are stripped. The
+ caller must either guarantee that Index and the data written is valid, or
+ the caller must set up exception handlers to catch the exceptions. This
+ function is only available on IA-32 and X64.
+
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Index The 32-bit MSR index to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+ @param OrData The value to OR with the read value from the MSR.
+
+ @return The lower 32-bit of the value written to the MSR.
+
+**/
+UINT32
+EFIAPI
+AsmMsrBitFieldOr32 (
+ IN UINT32 Index,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT32 OrData
+ );
+
+/**
+ Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
+ result back to the bit field in the 64-bit MSR.
+
+ Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
+ read result and the value specified by AndData, and writes the result to the
+ 64-bit MSR specified by Index. The lower 32-bits of the value written to the
+ MSR are returned. Extra left bits in AndData are stripped. The caller must
+ either guarantee that Index and the data written is valid, or the caller must
+ set up exception handlers to catch the exceptions. This function is only
+ available on IA-32 and X64.
+
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Index The 32-bit MSR index to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+ @param AndData The value to AND with the read value from the MSR.
+
+ @return The lower 32-bit of the value written to the MSR.
+
+**/
+UINT32
+EFIAPI
+AsmMsrBitFieldAnd32 (
+ IN UINT32 Index,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT32 AndData
+ );
+
+/**
+ Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
+ bitwise inclusive OR, and writes the result back to the bit field in the
+ 64-bit MSR.
+
+ Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by a
+ bitwise inclusive OR between the read result and the value specified by
+ AndData, and writes the result to the 64-bit MSR specified by Index. The
+ lower 32-bits of the value written to the MSR are returned. Extra left bits
+ in both AndData and OrData are stripped. The caller must either guarantee
+ that Index and the data written is valid, or the caller must set up exception
+ handlers to catch the exceptions. This function is only available on IA-32
+ and X64.
+
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Index The 32-bit MSR index to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+ @param AndData The value to AND with the read value from the MSR.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The lower 32-bit of the value written to the MSR.
+
+**/
+UINT32
+EFIAPI
+AsmMsrBitFieldAndThenOr32 (
+ IN UINT32 Index,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT32 AndData,
+ IN UINT32 OrData
+ );
+
+/**
+ Returns a 64-bit Machine Specific Register(MSR).
+
+ Reads and returns the 64-bit MSR specified by Index. No parameter checking is
+ performed on Index, and some Index values may cause CPU exceptions. The
+ caller must either guarantee that Index is valid, or the caller must set up
+ exception handlers to catch the exceptions. This function is only available
+ on IA-32 and X64.
+
+ @param Index The 32-bit MSR index to read.
+
+ @return The value of the MSR identified by Index.
+
+**/
+UINT64
+EFIAPI
+AsmReadMsr64 (
+ IN UINT32 Index
+ );
+
+/**
+ Writes a 64-bit value to a Machine Specific Register(MSR), and returns the
+ value.
+
+ Writes the 64-bit value specified by Value to the MSR specified by Index. The
+ 64-bit value written to the MSR is returned. No parameter checking is
+ performed on Index or Value, and some of these may cause CPU exceptions. The
+ caller must either guarantee that Index and Value are valid, or the caller
+ must establish proper exception handlers. This function is only available on
+ IA-32 and X64.
+
+ @param Index The 32-bit MSR index to write.
+ @param Value The 64-bit value to write to the MSR.
+
+ @return Value
+
+**/
+UINT64
+EFIAPI
+AsmWriteMsr64 (
+ IN UINT32 Index,
+ IN UINT64 Value
+ );
+
+/**
+ Reads a 64-bit MSR, performs a bitwise inclusive OR, and writes the result
+ back to the 64-bit MSR.
+
+ Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR
+ between the read result and the value specified by OrData, and writes the
+ result to the 64-bit MSR specified by Index. The value written to the MSR is
+ returned. No parameter checking is performed on Index or OrData, and some of
+ these may cause CPU exceptions. The caller must either guarantee that Index
+ and OrData are valid, or the caller must establish proper exception handlers.
+ This function is only available on IA-32 and X64.
+
+ @param Index The 32-bit MSR index to write.
+ @param OrData The value to OR with the read value from the MSR.
+
+ @return The value written back to the MSR.
+
+**/
+UINT64
+EFIAPI
+AsmMsrOr64 (
+ IN UINT32 Index,
+ IN UINT64 OrData
+ );
+
+/**
+ Reads a 64-bit MSR, performs a bitwise AND, and writes the result back to the
+ 64-bit MSR.
+
+ Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
+ read result and the value specified by OrData, and writes the result to the
+ 64-bit MSR specified by Index. The value written to the MSR is returned. No
+ parameter checking is performed on Index or OrData, and some of these may
+ cause CPU exceptions. The caller must either guarantee that Index and OrData
+ are valid, or the caller must establish proper exception handlers. This
+ function is only available on IA-32 and X64.
+
+ @param Index The 32-bit MSR index to write.
+ @param AndData The value to AND with the read value from the MSR.
+
+ @return The value written back to the MSR.
+
+**/
+UINT64
+EFIAPI
+AsmMsrAnd64 (
+ IN UINT32 Index,
+ IN UINT64 AndData
+ );
+
+/**
+ Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise inclusive
+ OR, and writes the result back to the 64-bit MSR.
+
+ Reads the 64-bit MSR specified by Index, performs a bitwise AND between read
+ result and the value specified by AndData, performs a bitwise inclusive OR
+ between the result of the AND operation and the value specified by OrData,
+ and writes the result to the 64-bit MSR specified by Index. The value written
+ to the MSR is returned. No parameter checking is performed on Index, AndData,
+ or OrData, and some of these may cause CPU exceptions. The caller must either
+ guarantee that Index, AndData, and OrData are valid, or the caller must
+ establish proper exception handlers. This function is only available on IA-32
+ and X64.
+
+ @param Index The 32-bit MSR index to write.
+ @param AndData The value to AND with the read value from the MSR.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the MSR.
+
+**/
+UINT64
+EFIAPI
+AsmMsrAndThenOr64 (
+ IN UINT32 Index,
+ IN UINT64 AndData,
+ IN UINT64 OrData
+ );
+
+/**
+ Reads a bit field of an MSR.
+
+ Reads the bit field in the 64-bit MSR. The bit field is specified by the
+ StartBit and the EndBit. The value of the bit field is returned. The caller
+ must either guarantee that Index is valid, or the caller must set up
+ exception handlers to catch the exceptions. This function is only available
+ on IA-32 and X64.
+
+ If StartBit is greater than 63, then ASSERT().
+ If EndBit is greater than 63, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Index The 32-bit MSR index to read.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..63.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..63.
+
+ @return The value read from the MSR.
+
+**/
+UINT64
+EFIAPI
+AsmMsrBitFieldRead64 (
+ IN UINT32 Index,
+ IN UINTN StartBit,
+ IN UINTN EndBit
+ );
+
+/**
+ Writes a bit field to an MSR.
+
+ Writes Value to a bit field in a 64-bit MSR. The bit field is specified by
+ the StartBit and the EndBit. All other bits in the destination MSR are
+ preserved. The MSR written is returned. Extra left bits in Value are
+ stripped. The caller must either guarantee that Index and the data written is
+ valid, or the caller must set up exception handlers to catch the exceptions.
+ This function is only available on IA-32 and X64.
+
+ If StartBit is greater than 63, then ASSERT().
+ If EndBit is greater than 63, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Index The 32-bit MSR index to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..63.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..63.
+ @param Value New value of the bit field.
+
+ @return The value written back to the MSR.
+
+**/
+UINT64
+EFIAPI
+AsmMsrBitFieldWrite64 (
+ IN UINT32 Index,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT64 Value
+ );
+
+/**
+ Reads a bit field in a 64-bit MSR, performs a bitwise inclusive OR, and
+ writes the result back to the bit field in the 64-bit MSR.
+
+ Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR
+ between the read result and the value specified by OrData, and writes the
+ result to the 64-bit MSR specified by Index. The value written to the MSR is
+ returned. Extra left bits in OrData are stripped. The caller must either
+ guarantee that Index and the data written is valid, or the caller must set up
+ exception handlers to catch the exceptions. This function is only available
+ on IA-32 and X64.
+
+ If StartBit is greater than 63, then ASSERT().
+ If EndBit is greater than 63, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Index The 32-bit MSR index to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..63.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..63.
+ @param OrData The value to OR with the read value from the bit field.
+
+ @return The value written back to the MSR.
+
+**/
+UINT64
+EFIAPI
+AsmMsrBitFieldOr64 (
+ IN UINT32 Index,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT64 OrData
+ );
+
+/**
+ Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
+ result back to the bit field in the 64-bit MSR.
+
+ Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
+ read result and the value specified by AndData, and writes the result to the
+ 64-bit MSR specified by Index. The value written to the MSR is returned.
+ Extra left bits in AndData are stripped. The caller must either guarantee
+ that Index and the data written is valid, or the caller must set up exception
+ handlers to catch the exceptions. This function is only available on IA-32
+ and X64.
+
+ If StartBit is greater than 63, then ASSERT().
+ If EndBit is greater than 63, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Index The 32-bit MSR index to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..63.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..63.
+ @param AndData The value to AND with the read value from the bit field.
+
+ @return The value written back to the MSR.
+
+**/
+UINT64
+EFIAPI
+AsmMsrBitFieldAnd64 (
+ IN UINT32 Index,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT64 AndData
+ );
+
+/**
+ Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
+ bitwise inclusive OR, and writes the result back to the bit field in the
+ 64-bit MSR.
+
+ Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by
+ a bitwise inclusive OR between the read result and the value specified by
+ AndData, and writes the result to the 64-bit MSR specified by Index. The
+ value written to the MSR is returned. Extra left bits in both AndData and
+ OrData are stripped. The caller must either guarantee that Index and the data
+ written is valid, or the caller must set up exception handlers to catch the
+ exceptions. This function is only available on IA-32 and X64.
+
+ If StartBit is greater than 63, then ASSERT().
+ If EndBit is greater than 63, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Index The 32-bit MSR index to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..63.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..63.
+ @param AndData The value to AND with the read value from the bit field.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the MSR.
+
+**/
+UINT64
+EFIAPI
+AsmMsrBitFieldAndThenOr64 (
+ IN UINT32 Index,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT64 AndData,
+ IN UINT64 OrData
+ );
+
+/**
+ Reads the current value of the EFLAGS register.
+
+ Reads and returns the current value of the EFLAGS register. This function is
+ only available on IA-32 and X64. This returns a 32-bit value on IA-32 and a
+ 64-bit value on X64.
+
+ @return EFLAGS on IA-32 or RFLAGS on X64.
+
+**/
+UINTN
+EFIAPI
+AsmReadEflags (
+ VOID
+ );
+
+/**
+ Reads the current value of the Control Register 0 (CR0).
+
+ Reads and returns the current value of CR0. This function is only available
+ on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
+ X64.
+
+ @return The value of the Control Register 0 (CR0).
+
+**/
+UINTN
+EFIAPI
+AsmReadCr0 (
+ VOID
+ );
+
+/**
+ Reads the current value of the Control Register 2 (CR2).
+
+ Reads and returns the current value of CR2. This function is only available
+ on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
+ X64.
+
+ @return The value of the Control Register 2 (CR2).
+
+**/
+UINTN
+EFIAPI
+AsmReadCr2 (
+ VOID
+ );
+
+/**
+ Reads the current value of the Control Register 3 (CR3).
+
+ Reads and returns the current value of CR3. This function is only available
+ on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
+ X64.
+
+ @return The value of the Control Register 3 (CR3).
+
+**/
+UINTN
+EFIAPI
+AsmReadCr3 (
+ VOID
+ );
+
+/**
+ Reads the current value of the Control Register 4 (CR4).
+
+ Reads and returns the current value of CR4. This function is only available
+ on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
+ X64.
+
+ @return The value of the Control Register 4 (CR4).
+
+**/
+UINTN
+EFIAPI
+AsmReadCr4 (
+ VOID
+ );
+
+/**
+ Writes a value to Control Register 0 (CR0).
+
+ Writes and returns a new value to CR0. This function is only available on
+ IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
+
+ @param Cr0 The value to write to CR0.
+
+ @return The value written to CR0.
+
+**/
+UINTN
+EFIAPI
+AsmWriteCr0 (
+ UINTN Cr0
+ );
+
+/**
+ Writes a value to Control Register 2 (CR2).
+
+ Writes and returns a new value to CR2. This function is only available on
+ IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
+
+ @param Cr2 The value to write to CR2.
+
+ @return The value written to CR2.
+
+**/
+UINTN
+EFIAPI
+AsmWriteCr2 (
+ UINTN Cr2
+ );
+
+/**
+ Writes a value to Control Register 3 (CR3).
+
+ Writes and returns a new value to CR3. This function is only available on
+ IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
+
+ @param Cr3 The value to write to CR3.
+
+ @return The value written to CR3.
+
+**/
+UINTN
+EFIAPI
+AsmWriteCr3 (
+ UINTN Cr3
+ );
+
+/**
+ Writes a value to Control Register 4 (CR4).
+
+ Writes and returns a new value to CR4. This function is only available on
+ IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
+
+ @param Cr4 The value to write to CR4.
+
+ @return The value written to CR4.
+
+**/
+UINTN
+EFIAPI
+AsmWriteCr4 (
+ UINTN Cr4
+ );
+
+/**
+ Reads the current value of Debug Register 0 (DR0).
+
+ Reads and returns the current value of DR0. This function is only available
+ on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
+ X64.
+
+ @return The value of Debug Register 0 (DR0).
+
+**/
+UINTN
+EFIAPI
+AsmReadDr0 (
+ VOID
+ );
+
+/**
+ Reads the current value of Debug Register 1 (DR1).
+
+ Reads and returns the current value of DR1. This function is only available
+ on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
+ X64.
+
+ @return The value of Debug Register 1 (DR1).
+
+**/
+UINTN
+EFIAPI
+AsmReadDr1 (
+ VOID
+ );
+
+/**
+ Reads the current value of Debug Register 2 (DR2).
+
+ Reads and returns the current value of DR2. This function is only available
+ on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
+ X64.
+
+ @return The value of Debug Register 2 (DR2).
+
+**/
+UINTN
+EFIAPI
+AsmReadDr2 (
+ VOID
+ );
+
+/**
+ Reads the current value of Debug Register 3 (DR3).
+
+ Reads and returns the current value of DR3. This function is only available
+ on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
+ X64.
+
+ @return The value of Debug Register 3 (DR3).
+
+**/
+UINTN
+EFIAPI
+AsmReadDr3 (
+ VOID
+ );
+
+/**
+ Reads the current value of Debug Register 4 (DR4).
+
+ Reads and returns the current value of DR4. This function is only available
+ on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
+ X64.
+
+ @return The value of Debug Register 4 (DR4).
+
+**/
+UINTN
+EFIAPI
+AsmReadDr4 (
+ VOID
+ );
+
+/**
+ Reads the current value of Debug Register 5 (DR5).
+
+ Reads and returns the current value of DR5. This function is only available
+ on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
+ X64.
+
+ @return The value of Debug Register 5 (DR5).
+
+**/
+UINTN
+EFIAPI
+AsmReadDr5 (
+ VOID
+ );
+
+/**
+ Reads the current value of Debug Register 6 (DR6).
+
+ Reads and returns the current value of DR6. This function is only available
+ on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
+ X64.
+
+ @return The value of Debug Register 6 (DR6).
+
+**/
+UINTN
+EFIAPI
+AsmReadDr6 (
+ VOID
+ );
+
+/**
+ Reads the current value of Debug Register 7 (DR7).
+
+ Reads and returns the current value of DR7. This function is only available
+ on IA-32 and X64. This returns a 32-bit value on IA-32 and a 64-bit value on
+ X64.
+
+ @return The value of Debug Register 7 (DR7).
+
+**/
+UINTN
+EFIAPI
+AsmReadDr7 (
+ VOID
+ );
+
+/**
+ Writes a value to Debug Register 0 (DR0).
+
+ Writes and returns a new value to DR0. This function is only available on
+ IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
+
+ @param Dr0 The value to write to Dr0.
+
+ @return The value written to Debug Register 0 (DR0).
+
+**/
+UINTN
+EFIAPI
+AsmWriteDr0 (
+ UINTN Dr0
+ );
+
+/**
+ Writes a value to Debug Register 1 (DR1).
+
+ Writes and returns a new value to DR1. This function is only available on
+ IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
+
+ @param Dr1 The value to write to Dr1.
+
+ @return The value written to Debug Register 1 (DR1).
+
+**/
+UINTN
+EFIAPI
+AsmWriteDr1 (
+ UINTN Dr1
+ );
+
+/**
+ Writes a value to Debug Register 2 (DR2).
+
+ Writes and returns a new value to DR2. This function is only available on
+ IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
+
+ @param Dr2 The value to write to Dr2.
+
+ @return The value written to Debug Register 2 (DR2).
+
+**/
+UINTN
+EFIAPI
+AsmWriteDr2 (
+ UINTN Dr2
+ );
+
+/**
+ Writes a value to Debug Register 3 (DR3).
+
+ Writes and returns a new value to DR3. This function is only available on
+ IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
+
+ @param Dr3 The value to write to Dr3.
+
+ @return The value written to Debug Register 3 (DR3).
+
+**/
+UINTN
+EFIAPI
+AsmWriteDr3 (
+ UINTN Dr3
+ );
+
+/**
+ Writes a value to Debug Register 4 (DR4).
+
+ Writes and returns a new value to DR4. This function is only available on
+ IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
+
+ @param Dr4 The value to write to Dr4.
+
+ @return The value written to Debug Register 4 (DR4).
+
+**/
+UINTN
+EFIAPI
+AsmWriteDr4 (
+ UINTN Dr4
+ );
+
+/**
+ Writes a value to Debug Register 5 (DR5).
+
+ Writes and returns a new value to DR5. This function is only available on
+ IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
+
+ @param Dr5 The value to write to Dr5.
+
+ @return The value written to Debug Register 5 (DR5).
+
+**/
+UINTN
+EFIAPI
+AsmWriteDr5 (
+ UINTN Dr5
+ );
+
+/**
+ Writes a value to Debug Register 6 (DR6).
+
+ Writes and returns a new value to DR6. This function is only available on
+ IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
+
+ @param Dr6 The value to write to Dr6.
+
+ @return The value written to Debug Register 6 (DR6).
+
+**/
+UINTN
+EFIAPI
+AsmWriteDr6 (
+ UINTN Dr6
+ );
+
+/**
+ Writes a value to Debug Register 7 (DR7).
+
+ Writes and returns a new value to DR7. This function is only available on
+ IA-32 and X64. This writes a 32-bit value on IA-32 and a 64-bit value on X64.
+
+ @param Dr7 The value to write to Dr7.
+
+ @return The value written to Debug Register 7 (DR7).
+
+**/
+UINTN
+EFIAPI
+AsmWriteDr7 (
+ UINTN Dr7
+ );
+
+/**
+ Reads the current value of Code Segment Register (CS).
+
+ Reads and returns the current value of CS. This function is only available on
+ IA-32 and X64.
+
+ @return The current value of CS.
+
+**/
+UINT16
+EFIAPI
+AsmReadCs (
+ VOID
+ );
+
+/**
+ Reads the current value of Data Segment Register (DS).
+
+ Reads and returns the current value of DS. This function is only available on
+ IA-32 and X64.
+
+ @return The current value of DS.
+
+**/
+UINT16
+EFIAPI
+AsmReadDs (
+ VOID
+ );
+
+/**
+ Reads the current value of Extra Segment Register (ES).
+
+ Reads and returns the current value of ES. This function is only available on
+ IA-32 and X64.
+
+ @return The current value of ES.
+
+**/
+UINT16
+EFIAPI
+AsmReadEs (
+ VOID
+ );
+
+/**
+ Reads the current value of FS Data Segment Register (FS).
+
+ Reads and returns the current value of FS. This function is only available on
+ IA-32 and X64.
+
+ @return The current value of FS.
+
+**/
+UINT16
+EFIAPI
+AsmReadFs (
+ VOID
+ );
+
+/**
+ Reads the current value of GS Data Segment Register (GS).
+
+ Reads and returns the current value of GS. This function is only available on
+ IA-32 and X64.
+
+ @return The current value of GS.
+
+**/
+UINT16
+EFIAPI
+AsmReadGs (
+ VOID
+ );
+
+/**
+ Reads the current value of Stack Segment Register (SS).
+
+ Reads and returns the current value of SS. This function is only available on
+ IA-32 and X64.
+
+ @return The current value of SS.
+
+**/
+UINT16
+EFIAPI
+AsmReadSs (
+ VOID
+ );
+
+/**
+ Reads the current value of Task Register (TR).
+
+ Reads and returns the current value of TR. This function is only available on
+ IA-32 and X64.
+
+ @return The current value of TR.
+
+**/
+UINT16
+EFIAPI
+AsmReadTr (
+ VOID
+ );
+
+/**
+ Reads the current Global Descriptor Table Register(GDTR) descriptor.
+
+ Reads and returns the current GDTR descriptor and returns it in Gdtr. This
+ function is only available on IA-32 and X64.
+
+ If Gdtr is NULL, then ASSERT().
+
+ @param Gdtr Pointer to a GDTR descriptor.
+
+**/
+VOID
+EFIAPI
+AsmReadGdtr (
+ OUT IA32_DESCRIPTOR *Gdtr
+ );
+
+/**
+ Writes the current Global Descriptor Table Register (GDTR) descriptor.
+
+ Writes and the current GDTR descriptor specified by Gdtr. This function is
+ only available on IA-32 and X64.
+
+ If Gdtr is NULL, then ASSERT().
+
+ @param Gdtr Pointer to a GDTR descriptor.
+
+**/
+VOID
+EFIAPI
+AsmWriteGdtr (
+ IN CONST IA32_DESCRIPTOR *Gdtr
+ );
+
+/**
+ Reads the current Interrupt Descriptor Table Register(GDTR) descriptor.
+
+ Reads and returns the current IDTR descriptor and returns it in Idtr. This
+ function is only available on IA-32 and X64.
+
+ If Idtr is NULL, then ASSERT().
+
+ @param Idtr Pointer to a IDTR descriptor.
+
+**/
+VOID
+EFIAPI
+AsmReadIdtr (
+ OUT IA32_DESCRIPTOR *Idtr
+ );
+
+/**
+ Writes the current Interrupt Descriptor Table Register(GDTR) descriptor.
+
+ Writes the current IDTR descriptor and returns it in Idtr. This function is
+ only available on IA-32 and X64.
+
+ If Idtr is NULL, then ASSERT().
+
+ @param Idtr Pointer to a IDTR descriptor.
+
+**/
+VOID
+EFIAPI
+AsmWriteIdtr (
+ IN CONST IA32_DESCRIPTOR *Idtr
+ );
+
+/**
+ Reads the current Local Descriptor Table Register(LDTR) selector.
+
+ Reads and returns the current 16-bit LDTR descriptor value. This function is
+ only available on IA-32 and X64.
+
+ @return The current selector of LDT.
+
+**/
+UINT16
+EFIAPI
+AsmReadLdtr (
+ VOID
+ );
+
+/**
+ Writes the current Local Descriptor Table Register (GDTR) selector.
+
+ Writes and the current LDTR descriptor specified by Ldtr. This function is
+ only available on IA-32 and X64.
+
+ @param Ldtr 16-bit LDTR selector value.
+
+**/
+VOID
+EFIAPI
+AsmWriteLdtr (
+ IN UINT16 Ldtr
+ );
+
+/**
+ Save the current floating point/SSE/SSE2 context to a buffer.
+
+ Saves the current floating point/SSE/SSE2 state to the buffer specified by
+ Buffer. Buffer must be aligned on a 16-byte boundary. This function is only
+ available on IA-32 and X64.
+
+ If Buffer is NULL, then ASSERT().
+ If Buffer is not aligned on a 16-byte boundary, then ASSERT().
+
+ @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context.
+
+**/
+VOID
+EFIAPI
+AsmFxSave (
+ OUT IA32_FX_BUFFER *Buffer
+ );
+
+/**
+ Restores the current floating point/SSE/SSE2 context from a buffer.
+
+ Restores the current floating point/SSE/SSE2 state from the buffer specified
+ by Buffer. Buffer must be aligned on a 16-byte boundary. This function is
+ only available on IA-32 and X64.
+
+ If Buffer is NULL, then ASSERT().
+ If Buffer is not aligned on a 16-byte boundary, then ASSERT().
+ If Buffer was not saved with AsmFxSave(), then ASSERT().
+
+ @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context.
+
+**/
+VOID
+EFIAPI
+AsmFxRestore (
+ IN CONST IA32_FX_BUFFER *Buffer
+ );
+
+/**
+ Reads the current value of 64-bit MMX Register #0 (MM0).
+
+ Reads and returns the current value of MM0. This function is only available
+ on IA-32 and X64.
+
+ @return The current value of MM0.
+
+**/
+UINT64
+EFIAPI
+AsmReadMm0 (
+ VOID
+ );
+
+/**
+ Reads the current value of 64-bit MMX Register #1 (MM1).
+
+ Reads and returns the current value of MM1. This function is only available
+ on IA-32 and X64.
+
+ @return The current value of MM1.
+
+**/
+UINT64
+EFIAPI
+AsmReadMm1 (
+ VOID
+ );
+
+/**
+ Reads the current value of 64-bit MMX Register #2 (MM2).
+
+ Reads and returns the current value of MM2. This function is only available
+ on IA-32 and X64.
+
+ @return The current value of MM2.
+
+**/
+UINT64
+EFIAPI
+AsmReadMm2 (
+ VOID
+ );
+
+/**
+ Reads the current value of 64-bit MMX Register #3 (MM3).
+
+ Reads and returns the current value of MM3. This function is only available
+ on IA-32 and X64.
+
+ @return The current value of MM3.
+
+**/
+UINT64
+EFIAPI
+AsmReadMm3 (
+ VOID
+ );
+
+/**
+ Reads the current value of 64-bit MMX Register #4 (MM4).
+
+ Reads and returns the current value of MM4. This function is only available
+ on IA-32 and X64.
+
+ @return The current value of MM4.
+
+**/
+UINT64
+EFIAPI
+AsmReadMm4 (
+ VOID
+ );
+
+/**
+ Reads the current value of 64-bit MMX Register #5 (MM5).
+
+ Reads and returns the current value of MM5. This function is only available
+ on IA-32 and X64.
+
+ @return The current value of MM5.
+
+**/
+UINT64
+EFIAPI
+AsmReadMm5 (
+ VOID
+ );
+
+/**
+ Reads the current value of 64-bit MMX Register #6 (MM6).
+
+ Reads and returns the current value of MM6. This function is only available
+ on IA-32 and X64.
+
+ @return The current value of MM6.
+
+**/
+UINT64
+EFIAPI
+AsmReadMm6 (
+ VOID
+ );
+
+/**
+ Reads the current value of 64-bit MMX Register #7 (MM7).
+
+ Reads and returns the current value of MM7. This function is only available
+ on IA-32 and X64.
+
+ @return The current value of MM7.
+
+**/
+UINT64
+EFIAPI
+AsmReadMm7 (
+ VOID
+ );
+
+/**
+ Writes the current value of 64-bit MMX Register #0 (MM0).
+
+ Writes the current value of MM0. This function is only available on IA32 and
+ X64.
+
+ @param Value The 64-bit value to write to MM0.
+
+**/
+VOID
+EFIAPI
+AsmWriteMm0 (
+ IN UINT64 Value
+ );
+
+/**
+ Writes the current value of 64-bit MMX Register #1 (MM1).
+
+ Writes the current value of MM1. This function is only available on IA32 and
+ X64.
+
+ @param Value The 64-bit value to write to MM1.
+
+**/
+VOID
+EFIAPI
+AsmWriteMm1 (
+ IN UINT64 Value
+ );
+
+/**
+ Writes the current value of 64-bit MMX Register #2 (MM2).
+
+ Writes the current value of MM2. This function is only available on IA32 and
+ X64.
+
+ @param Value The 64-bit value to write to MM2.
+
+**/
+VOID
+EFIAPI
+AsmWriteMm2 (
+ IN UINT64 Value
+ );
+
+/**
+ Writes the current value of 64-bit MMX Register #3 (MM3).
+
+ Writes the current value of MM3. This function is only available on IA32 and
+ X64.
+
+ @param Value The 64-bit value to write to MM3.
+
+**/
+VOID
+EFIAPI
+AsmWriteMm3 (
+ IN UINT64 Value
+ );
+
+/**
+ Writes the current value of 64-bit MMX Register #4 (MM4).
+
+ Writes the current value of MM4. This function is only available on IA32 and
+ X64.
+
+ @param Value The 64-bit value to write to MM4.
+
+**/
+VOID
+EFIAPI
+AsmWriteMm4 (
+ IN UINT64 Value
+ );
+
+/**
+ Writes the current value of 64-bit MMX Register #5 (MM5).
+
+ Writes the current value of MM5. This function is only available on IA32 and
+ X64.
+
+ @param Value The 64-bit value to write to MM5.
+
+**/
+VOID
+EFIAPI
+AsmWriteMm5 (
+ IN UINT64 Value
+ );
+
+/**
+ Writes the current value of 64-bit MMX Register #6 (MM6).
+
+ Writes the current value of MM6. This function is only available on IA32 and
+ X64.
+
+ @param Value The 64-bit value to write to MM6.
+
+**/
+VOID
+EFIAPI
+AsmWriteMm6 (
+ IN UINT64 Value
+ );
+
+/**
+ Writes the current value of 64-bit MMX Register #7 (MM7).
+
+ Writes the current value of MM7. This function is only available on IA32 and
+ X64.
+
+ @param Value The 64-bit value to write to MM7.
+
+**/
+VOID
+EFIAPI
+AsmWriteMm7 (
+ IN UINT64 Value
+ );
+
+/**
+ Reads the current value of Time Stamp Counter (TSC).
+
+ Reads and returns the current value of TSC. This function is only available
+ on IA-32 and X64.
+
+ @return The current value of TSC
+
+**/
+UINT64
+EFIAPI
+AsmReadTsc (
+ VOID
+ );
+
+/**
+ Reads the current value of a Performance Counter (PMC).
+
+ Reads and returns the current value of performance counter specified by
+ Index. This function is only available on IA-32 and X64.
+
+ @param Index The 32-bit Performance Counter index to read.
+
+ @return The value of the PMC specified by Index.
+
+**/
+UINT64
+EFIAPI
+AsmReadPmc (
+ IN UINT32 Index
+ );
+
+/**
+ Sets up a monitor buffer that is used by AsmMwait().
+
+ Executes a MONITOR instruction with the register state specified by Eax, Ecx
+ and Edx. Returns Eax. This function is only available on IA-32 and X64.
+
+ @param Eax The value to load into EAX or RAX before executing the MONITOR
+ instruction.
+ @param Ecx The value to load into ECX or RCX before executing the MONITOR
+ instruction.
+ @param Edx The value to load into EDX or RDX before executing the MONITOR
+ instruction.
+
+ @return Eax
+
+**/
+UINTN
+EFIAPI
+AsmMonitor (
+ IN UINTN Eax,
+ IN UINTN Ecx,
+ IN UINTN Edx
+ );
+
+/**
+ Executes an MWAIT instruction.
+
+ Executes an MWAIT instruction with the register state specified by Eax and
+ Ecx. Returns Eax. This function is only available on IA-32 and X64.
+
+ @param Eax The value to load into EAX or RAX before executing the MONITOR
+ instruction.
+ @param Ecx The value to load into ECX or RCX before executing the MONITOR
+ instruction.
+
+ @return Eax
+
+**/
+UINTN
+EFIAPI
+AsmMwait (
+ IN UINTN Eax,
+ IN UINTN Ecx
+ );
+
+/**
+ Executes a WBINVD instruction.
+
+ Executes a WBINVD instruction. This function is only available on IA-32 and
+ X64.
+
+**/
+VOID
+EFIAPI
+AsmWbinvd (
+ VOID
+ );
+
+/**
+ Executes a INVD instruction.
+
+ Executes a INVD instruction. This function is only available on IA-32 and
+ X64.
+
+**/
+VOID
+EFIAPI
+AsmInvd (
+ VOID
+ );
+
+/**
+ Flushes a cache line from all the instruction and data caches within the
+ coherency domain of the CPU.
+
+ Flushed the cache line specified by LinearAddress, and returns LinearAddress.
+ This function is only available on IA-32 and X64.
+
+ @param LinearAddress The address of the cache line to flush. If the CPU is
+ in a physical addressing mode, then LinearAddress is a
+ physical address. If the CPU is in a virtual
+ addressing mode, then LinearAddress is a virtual
+ address.
+
+ @return LinearAddress
+**/
+VOID *
+EFIAPI
+AsmFlushCacheLine (
+ IN VOID *LinearAddress
+ );
+
+/**
+ Enables the 32-bit paging mode on the CPU.
+
+ Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
+ must be properly initialized prior to calling this service. This function
+ assumes the current execution mode is 32-bit protected mode. This function is
+ only available on IA-32. After the 32-bit paging mode is enabled, control is
+ transferred to the function specified by EntryPoint using the new stack
+ specified by NewStack and passing in the parameters specified by Context1 and
+ Context2. Context1 and Context2 are optional and may be NULL. The function
+ EntryPoint must never return.
+
+ If the current execution mode is not 32-bit protected mode, then ASSERT().
+ If EntryPoint is NULL, then ASSERT().
+ If NewStack is NULL, then ASSERT().
+
+ There are a number of constraints that must be followed before calling this
+ function:
+ 1) Interrupts must be disabled.
+ 2) The caller must be in 32-bit protected mode with flat descriptors. This
+ means all descriptors must have a base of 0 and a limit of 4GB.
+ 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat
+ descriptors.
+ 4) CR3 must point to valid page tables that will be used once the transition
+ is complete, and those page tables must guarantee that the pages for this
+ function and the stack are identity mapped.
+
+ @param EntryPoint A pointer to function to call with the new stack after
+ paging is enabled.
+ @param Context1 A pointer to the context to pass into the EntryPoint
+ function as the first parameter after paging is enabled.
+ @param Context2 A pointer to the context to pass into the EntryPoint
+ function as the second parameter after paging is enabled.
+ @param NewStack A pointer to the new stack to use for the EntryPoint
+ function after paging is enabled.
+
+**/
+VOID
+EFIAPI
+AsmEnablePaging32 (
+ IN SWITCH_STACK_ENTRY_POINT EntryPoint,
+ IN VOID *Context1, OPTIONAL
+ IN VOID *Context2, OPTIONAL
+ IN VOID *NewStack
+ );
+
+/**
+ Disables the 32-bit paging mode on the CPU.
+
+ Disables the 32-bit paging mode on the CPU and returns to 32-bit protected
+ mode. This function assumes the current execution mode is 32-paged protected
+ mode. This function is only available on IA-32. After the 32-bit paging mode
+ is disabled, control is transferred to the function specified by EntryPoint
+ using the new stack specified by NewStack and passing in the parameters
+ specified by Context1 and Context2. Context1 and Context2 are optional and
+ may be NULL. The function EntryPoint must never return.
+
+ If the current execution mode is not 32-bit paged mode, then ASSERT().
+ If EntryPoint is NULL, then ASSERT().
+ If NewStack is NULL, then ASSERT().
+
+ There are a number of constraints that must be followed before calling this
+ function:
+ 1) Interrupts must be disabled.
+ 2) The caller must be in 32-bit paged mode.
+ 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode.
+ 4) CR3 must point to valid page tables that guarantee that the pages for
+ this function and the stack are identity mapped.
+
+ @param EntryPoint A pointer to function to call with the new stack after
+ paging is disabled.
+ @param Context1 A pointer to the context to pass into the EntryPoint
+ function as the first parameter after paging is disabled.
+ @param Context2 A pointer to the context to pass into the EntryPoint
+ function as the second parameter after paging is
+ disabled.
+ @param NewStack A pointer to the new stack to use for the EntryPoint
+ function after paging is disabled.
+
+**/
+VOID
+EFIAPI
+AsmDisablePaging32 (
+ IN SWITCH_STACK_ENTRY_POINT EntryPoint,
+ IN VOID *Context1, OPTIONAL
+ IN VOID *Context2, OPTIONAL
+ IN VOID *NewStack
+ );
+
+/**
+ Enables the 64-bit paging mode on the CPU.
+
+ Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
+ must be properly initialized prior to calling this service. This function
+ assumes the current execution mode is 32-bit protected mode with flat
+ descriptors. This function is only available on IA-32. After the 64-bit
+ paging mode is enabled, control is transferred to the function specified by
+ EntryPoint using the new stack specified by NewStack and passing in the
+ parameters specified by Context1 and Context2. Context1 and Context2 are
+ optional and may be 0. The function EntryPoint must never return.
+
+ If the current execution mode is not 32-bit protected mode with flat
+ descriptors, then ASSERT().
+ If EntryPoint is 0, then ASSERT().
+ If NewStack is 0, then ASSERT().
+
+ @param Cs The 16-bit selector to load in the CS before EntryPoint
+ is called. The descriptor in the GDT that this selector
+ references must be setup for long mode.
+ @param EntryPoint The 64-bit virtual address of the function to call with
+ the new stack after paging is enabled.
+ @param Context1 The 64-bit virtual address of the context to pass into
+ the EntryPoint function as the first parameter after
+ paging is enabled.
+ @param Context2 The 64-bit virtual address of the context to pass into
+ the EntryPoint function as the second parameter after
+ paging is enabled.
+ @param NewStack The 64-bit virtual address of the new stack to use for
+ the EntryPoint function after paging is enabled.
+
+**/
+VOID
+EFIAPI
+AsmEnablePaging64 (
+ IN UINT16 CodeSelector,
+ IN UINT64 EntryPoint,
+ IN UINT64 Context1, OPTIONAL
+ IN UINT64 Context2, OPTIONAL
+ IN UINT64 NewStack
+ );
+
+/**
+ Disables the 64-bit paging mode on the CPU.
+
+ Disables the 64-bit paging mode on the CPU and returns to 32-bit protected
+ mode. This function assumes the current execution mode is 64-paging mode.
+ This function is only available on X64. After the 64-bit paging mode is
+ disabled, control is transferred to the function specified by EntryPoint
+ using the new stack specified by NewStack and passing in the parameters
+ specified by Context1 and Context2. Context1 and Context2 are optional and
+ may be 0. The function EntryPoint must never return.
+
+ If the current execution mode is not 64-bit paged mode, then ASSERT().
+ If EntryPoint is 0, then ASSERT().
+ If NewStack is 0, then ASSERT().
+
+ @param Cs The 16-bit selector to load in the CS before EntryPoint
+ is called. The descriptor in the GDT that this selector
+ references must be setup for 32-bit protected mode.
+ @param EntryPoint The 64-bit virtual address of the function to call with
+ the new stack after paging is disabled.
+ @param Context1 The 64-bit virtual address of the context to pass into
+ the EntryPoint function as the first parameter after
+ paging is disabled.
+ @param Context2 The 64-bit virtual address of the context to pass into
+ the EntryPoint function as the second parameter after
+ paging is disabled.
+ @param NewStack The 64-bit virtual address of the new stack to use for
+ the EntryPoint function after paging is disabled.
+
+**/
+VOID
+EFIAPI
+AsmDisablePaging64 (
+ IN UINT16 CodeSelector,
+ IN UINT32 EntryPoint,
+ IN UINT32 Context1, OPTIONAL
+ IN UINT32 Context2, OPTIONAL
+ IN UINT32 NewStack
+ );
+
+//
+// 16-bit thunking services
+//
+
+/**
+ Retrieves the properties for 16-bit thunk functions.
+
+ Computes the size of the buffer and stack below 1MB required to use the
+ AsmPrepareThunk16(), AsmThunk16() and AsmPrepareAndThunk16() functions. This
+ buffer size is returned in RealModeBufferSize, and the stack size is returned
+ in ExtraStackSize. If parameters are passed to the 16-bit real mode code,
+ then the actual minimum stack size is ExtraStackSize plus the maximum number
+ of bytes that need to be passed to the 16-bit real mode code.
+
+ If RealModeBufferSize is NULL, then ASSERT().
+ If ExtraStackSize is NULL, then ASSERT().
+
+ @param RealModeBufferSize A pointer to the size of the buffer below 1MB
+ required to use the 16-bit thunk functions.
+ @param ExtraStackSize A pointer to the extra size of stack below 1MB
+ that the 16-bit thunk functions require for
+ temporary storage in the transition to and from
+ 16-bit real mode.
+
+**/
+VOID
+EFIAPI
+AsmGetThunk16Properties (
+ OUT UINT32 *RealModeBufferSize,
+ OUT UINT32 *ExtraStackSize
+ );
+
+/**
+ Prepares all structures a code required to use AsmThunk16().
+
+ Prepares all structures and code required to use AsmThunk16().
+
+ If ThunkContext is NULL, then ASSERT().
+
+ @param ThunkContext A pointer to the context structure that describes the
+ 16-bit real mode code to call.
+
+**/
+VOID
+EFIAPI
+AsmPrepareThunk16 (
+ OUT THUNK_CONTEXT *ThunkContext
+ );
+
+/**
+ Transfers control to a 16-bit real mode entry point and returns the results.
+
+ Transfers control to a 16-bit real mode entry point and returns the results.
+ AsmPrepareThunk16() must be called with ThunkContext before this function is
+ used.
+
+ If ThunkContext is NULL, then ASSERT().
+ If AsmPrepareThunk16() was not previously called with ThunkContext, then ASSERT().
+
+ @param ThunkContext A pointer to the context structure that describes the
+ 16-bit real mode code to call.
+
+**/
+VOID
+EFIAPI
+AsmThunk16 (
+ IN OUT THUNK_CONTEXT *ThunkContext
+ );
+
+/**
+ Prepares all structures and code for a 16-bit real mode thunk, transfers
+ control to a 16-bit real mode entry point, and returns the results.
+
+ Prepares all structures and code for a 16-bit real mode thunk, transfers
+ control to a 16-bit real mode entry point, and returns the results. If the
+ caller only need to perform a single 16-bit real mode thunk, then this
+ service should be used. If the caller intends to make more than one 16-bit
+ real mode thunk, then it is more efficient if AsmPrepareThunk16() is called
+ once and AsmThunk16() can be called for each 16-bit real mode thunk.
+
+ If ThunkContext is NULL, then ASSERT().
+
+ @param ThunkContext A pointer to the context structure that describes the
+ 16-bit real mode code to call.
+
+**/
+VOID
+EFIAPI
+AsmPrepareAndThunk16 (
+ IN OUT THUNK_CONTEXT *ThunkContext
+ );
+
+/**
+ Transfers control to a function starting with a new stack.
+
+ Transfers control to the function specified by EntryPoint using the new stack
+ specified by NewStack and passing in the parameters specified by Context1 and
+ Context2. Context1 and Context2 are optional and may be NULL. The function
+ EntryPoint must never return.
+
+ If EntryPoint is NULL, then ASSERT().
+ If NewStack is NULL, then ASSERT().
+
+ @param EntryPoint A pointer to function to call with the new stack.
+ @param Context1 A pointer to the context to pass into the EntryPoint
+ function.
+ @param Context2 A pointer to the context to pass into the EntryPoint
+ function.
+ @param NewStack A pointer to the new stack to use for the EntryPoint
+ function.
+ @param NewBsp A pointer to the new memory location for RSE backing
+ store.
+
+**/
+VOID
+EFIAPI
+AsmSwitchStackAndBackingStore (
+ IN SWITCH_STACK_ENTRY_POINT EntryPoint,
+ IN VOID *Context1, OPTIONAL
+ IN VOID *Context2, OPTIONAL
+ IN VOID *NewStack,
+ IN VOID *NewBsp
+ );
+
+#endif
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueBaseMemoryLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueBaseMemoryLib.h
new file mode 100644
index 0000000..cd9468f
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueBaseMemoryLib.h
@@ -0,0 +1,391 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ EdkIIGlueBaseMemoryLib.h
+
+Abstract:
+
+ Memory-only library functions with no library constructor/destructor
+
+--*/
+
+#ifndef __EDKII_GLUE_BASE_MEMORY_LIB_H__
+#define __EDKII_GLUE_BASE_MEMORY_LIB_H__
+
+
+#define CopyMem(_DESTINATIONBUFFER, _SOURCEBUFFER, _LENGTH) GlueCopyMem(_DESTINATIONBUFFER, _SOURCEBUFFER, _LENGTH)
+#define ZeroMem(_BUFFER, _LENGTH) GlueZeroMem(_BUFFER, _LENGTH)
+#define SetMem(_BUFFER, _LENGTH, _VALUE) GlueSetMem(_BUFFER, _LENGTH, _VALUE)
+#define CompareMem(_DESTINATIONBUFFER, _SOURCEBUFFER, _LENGTH) GlueCompareMem(_DESTINATIONBUFFER, _SOURCEBUFFER, _LENGTH)
+#define CompareGuid(_GUID1, _GUID2) GlueCompareGuid(_GUID1, _GUID2)
+
+
+/**
+ Copies a source buffer to a destination buffer, and returns the destination buffer.
+
+ This function copies Length bytes from SourceBuffer to DestinationBuffer, and returns
+ DestinationBuffer. The implementation must be reentrant, and it must handle the case
+ where SourceBuffer overlaps DestinationBuffer.
+ If Length is greater than (MAX_ADDRESS - DestinationBuffer + 1), then ASSERT().
+ If Length is greater than (MAX_ADDRESS - SourceBuffer + 1), then ASSERT().
+
+ @param DestinationBuffer Pointer to the destination buffer of the memory copy.
+ @param SourceBuffer Pointer to the source buffer of the memory copy.
+ @param Length Number of bytes to copy from SourceBuffer to DestinationBuffer.
+
+ @return DestinationBuffer.
+
+**/
+VOID *
+EFIAPI
+GlueCopyMem (
+ OUT VOID *DestinationBuffer,
+ IN CONST VOID *SourceBuffer,
+ IN UINTN Length
+ );
+
+/**
+ Fills a target buffer with a byte value, and returns the target buffer.
+
+ This function fills Length bytes of Buffer with Value, and returns Buffer.
+ If Length is greater than (MAX_ADDRESS ?Buffer + 1), then ASSERT().
+
+ @param Buffer Memory to set.
+ @param Length Number of bytes to set.
+ @param Value Value of the set operation.
+
+ @return Buffer.
+
+**/
+VOID *
+EFIAPI
+GlueSetMem (
+ OUT VOID *Buffer,
+ IN UINTN Length,
+ IN UINT8 Value
+ );
+
+/**
+ Fills a target buffer with a 16-bit value, and returns the target buffer.
+
+ This function fills Length bytes of Buffer with the 16-bit value specified by
+ Value, and returns Buffer. Value is repeated every 16-bits in for Length
+ bytes of Buffer.
+
+ If Length > 0 and Buffer is NULL, then ASSERT().
+ If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
+ If Buffer is not aligned on a 16-bit boundary, then ASSERT().
+ If Length is not aligned on a 16-bit boundary, then ASSERT().
+
+ @param Buffer Pointer to the target buffer to fill.
+ @param Length Number of bytes in Buffer to fill.
+ @param Value Value with which to fill Length bytes of Buffer.
+
+ @return Buffer.
+
+**/
+VOID *
+EFIAPI
+SetMem16 (
+ OUT VOID *Buffer,
+ IN UINTN Length,
+ IN UINT16 Value
+ );
+
+/**
+ Fills a target buffer with a 32-bit value, and returns the target buffer.
+
+ This function fills Length bytes of Buffer with the 32-bit value specified by
+ Value, and returns Buffer. Value is repeated every 32-bits in for Length
+ bytes of Buffer.
+
+ If Length > 0 and Buffer is NULL, then ASSERT().
+ If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
+ If Buffer is not aligned on a 32-bit boundary, then ASSERT().
+ If Length is not aligned on a 32-bit boundary, then ASSERT().
+
+ @param Buffer Pointer to the target buffer to fill.
+ @param Length Number of bytes in Buffer to fill.
+ @param Value Value with which to fill Length bytes of Buffer.
+
+ @return Buffer.
+
+**/
+VOID *
+EFIAPI
+SetMem32 (
+ OUT VOID *Buffer,
+ IN UINTN Length,
+ IN UINT32 Value
+ );
+
+/**
+ Fills a target buffer with a 64-bit value, and returns the target buffer.
+
+ This function fills Length bytes of Buffer with the 64-bit value specified by
+ Value, and returns Buffer. Value is repeated every 64-bits in for Length
+ bytes of Buffer.
+
+ If Length > 0 and Buffer is NULL, then ASSERT().
+ If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
+ If Buffer is not aligned on a 64-bit boundary, then ASSERT().
+ If Length is not aligned on a 64-bit boundary, then ASSERT().
+
+ @param Buffer Pointer to the target buffer to fill.
+ @param Length Number of bytes in Buffer to fill.
+ @param Value Value with which to fill Length bytes of Buffer.
+
+ @return Buffer.
+
+**/
+VOID *
+EFIAPI
+SetMem64 (
+ OUT VOID *Buffer,
+ IN UINTN Length,
+ IN UINT64 Value
+ );
+
+/**
+ Fills a target buffer with zeros, and returns the target buffer.
+
+ This function fills Length bytes of Buffer with zeros, and returns Buffer.
+ If Length > 0 and Buffer is NULL, then ASSERT().
+ If Length is greater than (MAX_ADDRESS ?Buffer + 1), then ASSERT().
+
+ @param Buffer Pointer to the target buffer to fill with zeros.
+ @param Length Number of bytes in Buffer to fill with zeros.
+
+ @return Buffer.
+
+**/
+VOID *
+EFIAPI
+GlueZeroMem (
+ OUT VOID *Buffer,
+ IN UINTN Length
+ );
+
+/**
+ Compares the contents of two buffers.
+
+ This function compares Length bytes of SourceBuffer to Length bytes of DestinationBuffer.
+ If all Length bytes of the two buffers are identical, then 0 is returned. Otherwise, the
+ value returned is the first mismatched byte in SourceBuffer subtracted from the first
+ mismatched byte in DestinationBuffer.
+ If Length > 0 and DestinationBuffer is NULL and Length > 0, then ASSERT().
+ If Length > 0 and SourceBuffer is NULL and Length > 0, then ASSERT().
+ If Length is greater than (MAX_ADDRESS - DestinationBuffer + 1), then ASSERT().
+ If Length is greater than (MAX_ADDRESS - SourceBuffer + 1), then ASSERT().
+
+ @param DestinationBuffer Pointer to the destination buffer to compare.
+ @param SourceBuffer Pointer to the source buffer to compare.
+ @param Length Number of bytes to compare.
+
+ @return 0 All Length bytes of the two buffers are identical.
+ @retval Non-zero The first mismatched byte in SourceBuffer subtracted from the first
+ mismatched byte in DestinationBuffer.
+
+**/
+INTN
+EFIAPI
+GlueCompareMem (
+ IN CONST VOID *DestinationBuffer,
+ IN CONST VOID *SourceBuffer,
+ IN UINTN Length
+ );
+
+/**
+ Scans a target buffer for an 8-bit value, and returns a pointer to the matching 8-bit value
+ in the target buffer.
+
+ This function searches target the buffer specified by Buffer and Length from the lowest
+ address to the highest address for an 8-bit value that matches Value. If a match is found,
+ then a pointer to the matching byte in the target buffer is returned. If no match is found,
+ then NULL is returned. If Length is 0, then NULL is returned.
+ If Length > 0 and Buffer is NULL, then ASSERT().
+ If Length is greater than (MAX_ADDRESS ?Buffer + 1), then ASSERT().
+
+ @param Buffer Pointer to the target buffer to scan.
+ @param Length Number of bytes in Buffer to scan.
+ @param Value Value to search for in the target buffer.
+
+ @return A pointer to the matching byte in the target buffer or NULL otherwise.
+
+**/
+VOID *
+EFIAPI
+ScanMem8 (
+ IN CONST VOID *Buffer,
+ IN UINTN Length,
+ IN UINT8 Value
+ );
+
+/**
+ Scans a target buffer for a 16-bit value, and returns a pointer to the matching 16-bit value
+ in the target buffer.
+
+ This function searches target the buffer specified by Buffer and Length from the lowest
+ address to the highest address for a 16-bit value that matches Value. If a match is found,
+ then a pointer to the matching byte in the target buffer is returned. If no match is found,
+ then NULL is returned. If Length is 0, then NULL is returned.
+ If Length > 0 and Buffer is NULL, then ASSERT().
+ If Buffer is not aligned on a 16-bit boundary, then ASSERT().
+ If Length is not aligned on a 16-bit boundary, then ASSERT().
+ If Length is greater than (MAX_ADDRESS ?Buffer + 1), then ASSERT().
+
+ @param Buffer Pointer to the target buffer to scan.
+ @param Length Number of bytes in Buffer to scan.
+ @param Value Value to search for in the target buffer.
+
+ @return A pointer to the matching byte in the target buffer or NULL otherwise.
+
+**/
+VOID *
+EFIAPI
+ScanMem16 (
+ IN CONST VOID *Buffer,
+ IN UINTN Length,
+ IN UINT16 Value
+ );
+
+/**
+ Scans a target buffer for a 32-bit value, and returns a pointer to the matching 32-bit value
+ in the target buffer.
+
+ This function searches target the buffer specified by Buffer and Length from the lowest
+ address to the highest address for a 32-bit value that matches Value. If a match is found,
+ then a pointer to the matching byte in the target buffer is returned. If no match is found,
+ then NULL is returned. If Length is 0, then NULL is returned.
+ If Length > 0 and Buffer is NULL, then ASSERT().
+ If Buffer is not aligned on a 32-bit boundary, then ASSERT().
+ If Length is not aligned on a 32-bit boundary, then ASSERT().
+ If Length is greater than (MAX_ADDRESS ?Buffer + 1), then ASSERT().
+
+ @param Buffer Pointer to the target buffer to scan.
+ @param Length Number of bytes in Buffer to scan.
+ @param Value Value to search for in the target buffer.
+
+ @return A pointer to the matching byte in the target buffer or NULL otherwise.
+
+**/
+VOID *
+EFIAPI
+ScanMem32 (
+ IN CONST VOID *Buffer,
+ IN UINTN Length,
+ IN UINT32 Value
+ );
+
+/**
+ Scans a target buffer for a 64-bit value, and returns a pointer to the matching 64-bit value
+ in the target buffer.
+
+ This function searches target the buffer specified by Buffer and Length from the lowest
+ address to the highest address for a 64-bit value that matches Value. If a match is found,
+ then a pointer to the matching byte in the target buffer is returned. If no match is found,
+ then NULL is returned. If Length is 0, then NULL is returned.
+ If Length > 0 and Buffer is NULL, then ASSERT().
+ If Buffer is not aligned on a 64-bit boundary, then ASSERT().
+ If Length is not aligned on a 64-bit boundary, then ASSERT().
+ If Length is greater than (MAX_ADDRESS ?Buffer + 1), then ASSERT().
+
+ @param Buffer Pointer to the target buffer to scan.
+ @param Length Number of bytes in Buffer to scan.
+ @param Value Value to search for in the target buffer.
+
+ @return A pointer to the matching byte in the target buffer or NULL otherwise.
+
+**/
+VOID *
+EFIAPI
+ScanMem64 (
+ IN CONST VOID *Buffer,
+ IN UINTN Length,
+ IN UINT64 Value
+ );
+
+/**
+ Copies a source GUID to a destination GUID.
+
+ This function copies the contents of the 128-bit GUID specified by SourceGuid to
+ DestinationGuid, and returns DestinationGuid.
+ If DestinationGuid is NULL, then ASSERT().
+ If SourceGuid is NULL, then ASSERT().
+
+ @param DestinationGuid Pointer to the destination GUID.
+ @param SourceGuid Pointer to the source GUID.
+
+ @return DestinationGuid.
+
+**/
+GUID *
+EFIAPI
+CopyGuid (
+ OUT GUID *DestinationGuid,
+ IN CONST GUID *SourceGuid
+ );
+
+/**
+ Compares two GUIDs.
+
+ This function compares Guid1 to Guid2. If the GUIDs are identical then TRUE is returned.
+ If there are any bit differences in the two GUIDs, then FALSE is returned.
+ If Guid1 is NULL, then ASSERT().
+ If Guid2 is NULL, then ASSERT().
+
+ @param Guid1 A pointer to a 128 bit GUID.
+ @param Guid2 A pointer to a 128 bit GUID.
+
+ @retval TRUE Guid1 and Guid2 are identical.
+ @retval FALSE Guid1 and Guid2 are not identical.
+
+**/
+BOOLEAN
+EFIAPI
+GlueCompareGuid (
+ IN CONST GUID *Guid1,
+ IN CONST GUID *Guid2
+ );
+
+/**
+ Scans a target buffer for a GUID, and returns a pointer to the matching GUID
+ in the target buffer.
+
+ This function searches target the buffer specified by Buffer and Length from
+ the lowest address to the highest address at 128-bit increments for the 128-bit
+ GUID value that matches Guid. If a match is found, then a pointer to the matching
+ GUID in the target buffer is returned. If no match is found, then NULL is returned.
+ If Length is 0, then NULL is returned.
+ If Length > 0 and Buffer is NULL, then ASSERT().
+ If Buffer is not aligned on a 32-bit boundary, then ASSERT().
+ If Length is not aligned on a 128-bit boundary, then ASSERT().
+ If Length is greater than (MAX_ADDRESS ?Buffer + 1), then ASSERT().
+
+ @param Buffer Pointer to the target buffer to scan.
+ @param Length Number of bytes in Buffer to scan.
+ @param Guid Value to search for in the target buffer.
+
+ @return A pointer to the matching Guid in the target buffer or NULL otherwise.
+
+**/
+VOID *
+EFIAPI
+ScanGuid (
+ IN CONST VOID *Buffer,
+ IN UINTN Length,
+ IN CONST GUID *Guid
+ );
+
+#endif
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueCacheMaintenanceLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueCacheMaintenanceLib.h
new file mode 100644
index 0000000..48c244c
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueCacheMaintenanceLib.h
@@ -0,0 +1,224 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ EdkIIGlueCacheMaintenanceLib.h
+
+Abstract:
+
+ Cache Maintenance Functions
+
+--*/
+
+#ifndef __EDKII_GLUE_CACHE_MAINTENANCE_LIB_H__
+#define __EDKII_GLUE_CACHE_MAINTENANCE_LIB_H__
+
+
+#define InvalidateInstructionCache() GlueInvalidateInstructionCache()
+
+
+/**
+ Invalidates the entire instruction cache in cache coherency domain of the
+ calling CPU.
+
+ Invalidates the entire instruction cache in cache coherency domain of the
+ calling CPU.
+
+**/
+VOID
+EFIAPI
+GlueInvalidateInstructionCache (
+ VOID
+ );
+
+/**
+ Invalidates a range of instruction cache lines in the cache coherency domain
+ of the calling CPU.
+
+ Invalidates the instruction cache lines specified by Address and Length. If
+ Address is not aligned on a cache line boundary, then entire instruction
+ cache line containing Address is invalidated. If Address + Length is not
+ aligned on a cache line boundary, then the entire instruction cache line
+ containing Address + Length -1 is invalidated. This function may choose to
+ invalidate the entire instruction cache if that is more efficient than
+ invalidating the specified range. If Length is 0, the no instruction cache
+ lines are invalidated. Address is returned.
+
+ If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().
+
+ @param Address The base address of the instruction cache lines to
+ invalidate. If the CPU is in a physical addressing mode, then
+ Address is a physical address. If the CPU is in a virtual
+ addressing mode, then Address is a virtual address.
+
+ @param Length The number of bytes to invalidate from the instruction cache.
+
+ @return Address
+
+**/
+VOID *
+EFIAPI
+InvalidateInstructionCacheRange (
+ IN VOID *Address,
+ IN UINTN Length
+ );
+
+/**
+ Writes Back and Invalidates the entire data cache in cache coherency domain
+ of the calling CPU.
+
+ Writes Back and Invalidates the entire data cache in cache coherency domain
+ of the calling CPU. This function guarantees that all dirty cache lines are
+ written back to system memory, and also invalidates all the data cache lines
+ in the cache coherency domain of the calling CPU.
+
+**/
+VOID
+EFIAPI
+WriteBackInvalidateDataCache (
+ VOID
+ );
+
+/**
+ Writes Back and Invalidates a range of data cache lines in the cache
+ coherency domain of the calling CPU.
+
+ Writes Back and Invalidate the data cache lines specified by Address and
+ Length. If Address is not aligned on a cache line boundary, then entire data
+ cache line containing Address is written back and invalidated. If Address +
+ Length is not aligned on a cache line boundary, then the entire data cache
+ line containing Address + Length -1 is written back and invalidated. This
+ function may choose to write back and invalidate the entire data cache if
+ that is more efficient than writing back and invalidating the specified
+ range. If Length is 0, the no data cache lines are written back and
+ invalidated. Address is returned.
+
+ If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().
+
+ @param Address The base address of the data cache lines to write back and
+ invalidate. If the CPU is in a physical addressing mode, then
+ Address is a physical address. If the CPU is in a virtual
+ addressing mode, then Address is a virtual address.
+ @param Length The number of bytes to write back and invalidate from the
+ data cache.
+
+ @return Address
+
+**/
+VOID *
+EFIAPI
+WriteBackInvalidateDataCacheRange (
+ IN VOID *Address,
+ IN UINTN Length
+ );
+
+/**
+ Writes Back the entire data cache in cache coherency domain of the calling
+ CPU.
+
+ Writes Back the entire data cache in cache coherency domain of the calling
+ CPU. This function guarantees that all dirty cache lines are written back to
+ system memory. This function may also invalidate all the data cache lines in
+ the cache coherency domain of the calling CPU.
+
+**/
+VOID
+EFIAPI
+WriteBackDataCache (
+ VOID
+ );
+
+/**
+ Writes Back a range of data cache lines in the cache coherency domain of the
+ calling CPU.
+
+ Writes Back the data cache lines specified by Address and Length. If Address
+ is not aligned on a cache line boundary, then entire data cache line
+ containing Address is written back. If Address + Length is not aligned on a
+ cache line boundary, then the entire data cache line containing Address +
+ Length -1 is written back. This function may choose to write back the entire
+ data cache if that is more efficient than writing back the specified range.
+ If Length is 0, the no data cache lines are written back. This function may
+ also invalidate all the data cache lines in the specified range of the cache
+ coherency domain of the calling CPU. Address is returned.
+
+ If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().
+
+ @param Address The base address of the data cache lines to write back. If
+ the CPU is in a physical addressing mode, then Address is a
+ physical address. If the CPU is in a virtual addressing
+ mode, then Address is a virtual address.
+ @param Length The number of bytes to write back from the data cache.
+
+ @return Address
+
+**/
+VOID *
+EFIAPI
+WriteBackDataCacheRange (
+ IN VOID *Address,
+ IN UINTN Length
+ );
+
+/**
+ Invalidates the entire data cache in cache coherency domain of the calling
+ CPU.
+
+ Invalidates the entire data cache in cache coherency domain of the calling
+ CPU. This function must be used with care because dirty cache lines are not
+ written back to system memory. It is typically used for cache diagnostics. If
+ the CPU does not support invalidation of the entire data cache, then a write
+ back and invalidate operation should be performed on the entire data cache.
+
+**/
+VOID
+EFIAPI
+InvalidateDataCache (
+ VOID
+ );
+
+/**
+ Invalidates a range of data cache lines in the cache coherency domain of the
+ calling CPU.
+
+ Invalidates the data cache lines specified by Address and Length. If Address
+ is not aligned on a cache line boundary, then entire data cache line
+ containing Address is invalidated. If Address + Length is not aligned on a
+ cache line boundary, then the entire data cache line containing Address +
+ Length -1 is invalidated. This function must never invalidate any cache lines
+ outside the specified range. If Length is 0, the no data cache lines are
+ invalidated. Address is returned. This function must be used with care
+ because dirty cache lines are not written back to system memory. It is
+ typically used for cache diagnostics. If the CPU does not support
+ invalidation of a data cache range, then a write back and invalidate
+ operation should be performed on the data cache range.
+
+ If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().
+
+ @param Address The base address of the data cache lines to invalidate. If
+ the CPU is in a physical addressing mode, then Address is a
+ physical address. If the CPU is in a virtual addressing mode,
+ then Address is a virtual address.
+ @param Length The number of bytes to invalidate from the data cache.
+
+ @return Address
+
+**/
+VOID *
+EFIAPI
+InvalidateDataCacheRange (
+ IN VOID *Address,
+ IN UINTN Length
+ );
+
+#endif
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDebugLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDebugLib.h
new file mode 100644
index 0000000..b7cd4a9
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDebugLib.h
@@ -0,0 +1,575 @@
+/*++
+
+Copyright (c) 2004 - 2011, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ EdkIIGlueDebugLib.h
+
+Abstract:
+
+ Public include file for the Debug Library
+
+--*/
+
+#ifndef __EDKII_GLUE_DEBUG_LIB_H__
+#define __EDKII_GLUE_DEBUG_LIB_H__
+
+//
+// To use EdkII code, these R8.x macros are undefined
+//
+#undef ASSERT
+#undef DEBUG
+#undef ASSERT_EFI_ERROR
+#undef ASSERT_PROTOCOL_ALREADY_INSTALLED
+#undef DEBUG_CODE
+#undef CR
+
+//
+// Declare bits for PcdDebugPropertyMask
+//
+#define DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED 0x01
+#define DEBUG_PROPERTY_DEBUG_PRINT_ENABLED 0x02
+#define DEBUG_PROPERTY_DEBUG_CODE_ENABLED 0x04
+#define DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED 0x08
+#define DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED 0x10
+#define DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED 0x20
+
+//
+// Declare bits for PcdDebugPrintErrorLevel and the ErrorLevel parameter of DebugPrint()
+//
+#define EFI_D_INIT 0x00000001 // Initialization style messages
+#define EFI_D_WARN 0x00000002 // Warnings
+#define EFI_D_LOAD 0x00000004 // Load events
+#define EFI_D_FS 0x00000008 // EFI File system
+#define EFI_D_POOL 0x00000010 // Alloc & Free's
+#define EFI_D_PAGE 0x00000020 // Alloc & Free's
+#define EFI_D_INFO 0x00000040 // Informational debug messages
+#define EFI_D_VARIABLE 0x00000100 // Variable
+#define EFI_D_BM 0x00000400 // Boot Manager (BDS)
+#define EFI_D_BLKIO 0x00001000 // BlkIo Driver
+#define EFI_D_NET 0x00004000 // SNI Driver
+#define EFI_D_UNDI 0x00010000 // UNDI Driver
+#define EFI_D_LOADFILE 0x00020000 // UNDI Driver
+#define EFI_D_EVENT 0x00080000 // Event messages
+#define EFI_D_VERBOSE 0x00400000 // Detailed debug messages that may significantly impact boot performance
+#define EFI_D_ERROR 0x80000000 // Error
+
+/**
+
+ Gets the error level.
+
+ If DebugMaskInterface is not NULL, return the error level from DebugMaskInterface.
+
+ If DebugMaskInterface is NULL, return the default define DebugPrintErrorLevel error level.
+
+ @retval Debug Message Error Level
+
+**/
+UINTN
+EFIAPI
+EdkIIGlueGetDebugPrintErrorLevel (
+ VOID
+ );
+
+/**
+
+ Prints a debug message to the debug output device if the specified error level is enabled.
+
+ If any bit in ErrorLevel is also set in PcdDebugPrintErrorLevel, then print
+ the message specified by Format and the associated variable argument list to
+ the debug output device.
+
+ If Format is NULL, then ASSERT().
+
+ @param ErrorLevel The error level of the debug message.
+ @param Format Format string for the debug message to print.
+
+**/
+VOID
+EFIAPI
+DebugPrint (
+ IN UINTN ErrorLevel,
+ IN CONST CHAR8 *Format,
+ ...
+ );
+
+
+/**
+
+ Prints an assert message containing a filename, line number, and description.
+ This may be followed by a breakpoint or a dead loop.
+
+ Print a message of the form "ASSERT <FileName>(<LineNumber>): <Description>\n"
+ to the debug output device. If DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED bit of
+ PcdDebugProperyMask is set then CpuBreakpoint() is called. Otherwise, if
+ DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED bit of PcdDebugProperyMask is set then
+ CpuDeadLoop() is called. If neither of these bits are set, then this function
+ returns immediately after the message is printed to the debug output device.
+ DebugAssert() must actively prevent recusrsion. If DebugAssert() is called while
+ processing another DebugAssert(), then DebugAssert() must return immediately.
+
+ If FileName is NULL, then a <FileName> string of ?NULL) Filename?is printed.
+
+ If Description is NULL, then a <Description> string of ?NULL) Description?is printed.
+
+ @param FileName Pointer to the name of the source file that generated the assert condition.
+ @param LineNumber The line number in the source file that generated the assert condition
+ @param Description Pointer to the description of the assert condition.
+
+**/
+VOID
+EFIAPI
+DebugAssert (
+ IN CONST CHAR8 *FileName,
+ IN UINTN LineNumber,
+ IN CONST CHAR8 *Description
+ );
+
+
+/**
+
+ Fills a target buffer with PcdDebugClearMemoryValue, and returns the target buffer.
+
+ This function fills Length bytes of Buffer with the value specified by
+ PcdDebugClearMemoryValue, and returns Buffer.
+
+ If Buffer is NULL, then ASSERT().
+
+ If Length is greater than (MAX_ADDRESS ?Buffer + 1), then ASSERT().
+
+ @param Buffer Pointer to the target buffer to fill with PcdDebugClearMemoryValue.
+ @param Length Number of bytes in Buffer to fill with zeros PcdDebugClearMemoryValue.
+
+ @return Buffer
+
+**/
+VOID *
+EFIAPI
+DebugClearMemory (
+ OUT VOID *Buffer,
+ IN UINTN Length
+ );
+
+
+/**
+
+ Returns TRUE if ASSERT() macros are enabled.
+
+ This function returns TRUE if the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of
+ PcdDebugProperyMask is set. Otherwise FALSE is returned.
+
+ @retval TRUE The DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is set.
+ @retval FALSE The DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is clear.
+
+**/
+BOOLEAN
+EFIAPI
+DebugAssertEnabled (
+ VOID
+ );
+
+
+/**
+
+ Returns TRUE if DEBUG()macros are enabled.
+
+ This function returns TRUE if the DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of
+ PcdDebugProperyMask is set. Otherwise FALSE is returned.
+
+ @retval TRUE The DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of PcdDebugProperyMask is set.
+ @retval FALSE The DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of PcdDebugProperyMask is clear.
+
+**/
+BOOLEAN
+EFIAPI
+DebugPrintEnabled (
+ VOID
+ );
+
+
+/**
+
+ Returns TRUE if DEBUG_CODE()macros are enabled.
+
+ This function returns TRUE if the DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of
+ PcdDebugProperyMask is set. Otherwise FALSE is returned.
+
+ @retval TRUE The DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is set.
+ @retval FALSE The DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is clear.
+
+**/
+BOOLEAN
+EFIAPI
+DebugCodeEnabled (
+ VOID
+ );
+
+
+/**
+
+ Returns TRUE if DEBUG_CLEAR_MEMORY()macro is enabled.
+
+ This function returns TRUE if the DEBUG_PROPERTY_DEBUG_CLEAR_MEMORY_ENABLED bit of
+ PcdDebugProperyMask is set. Otherwise FALSE is returned.
+
+ @retval TRUE The DEBUG_PROPERTY_DEBUG_CLEAR_MEMORY_ENABLED bit of PcdDebugProperyMask is set.
+ @retval FALSE The DEBUG_PROPERTY_DEBUG_CLEAR_MEMORY_ENABLED bit of PcdDebugProperyMask is clear.
+
+**/
+BOOLEAN
+EFIAPI
+DebugClearMemoryEnabled (
+ VOID
+ );
+
+
+/**
+
+ Internal worker macro that calls DebugAssert().
+
+ This macro calls DebugAssert() passing in the filename, line number, and
+ expression that evailated to FALSE.
+
+ @param Expression Boolean expression that evailated to FALSE
+
+**/
+#ifdef EFI_DEBUG
+#define _ASSERT(Expression) DebugAssert (__FILE__, __LINE__, #Expression)
+#else
+#define _ASSERT(Expression)
+
+#endif
+
+/**
+
+ Internal worker macro that calls DebugPrint().
+
+ This macro calls DebugPrint() passing in the debug error level, a format
+ string, and a variable argument list.
+
+ @param Expression Expression containing an error level, a format string,
+ and a variable argument list based on the format string.
+
+**/
+#ifdef EFI_DEBUG
+#define _DEBUG(Expression) DebugPrint Expression
+#else
+#define _DEBUG(Expression)
+
+#endif
+
+/**
+
+ Macro that calls DebugAssert() if a expression evaluates to FALSE.
+
+ If the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is set,
+ then this macro evaluates the Boolean expression specified by Expression. If
+ Expression evaluates to FALSE, then DebugAssert() is called passing in the
+ source filename, source line number, and Expression.
+
+ @param Expression Boolean expression
+
+**/
+#ifdef EDKII_GLUE_LIBRARY_IMPLEMENTATION
+ // Glue Library internal
+
+ #if EDKII_GLUE_LIBRARY_DEBUG_ENABLE
+ #ifdef EFI_DEBUG
+ #define ASSERT(Expression) \
+ do { \
+ if (DebugAssertEnabled ()) { \
+ if (!(Expression)) { \
+ _ASSERT (Expression); \
+ } \
+ } \
+ } while (FALSE)
+ #endif
+ #else
+ #define ASSERT(Expression) do{} while(0)
+ #endif
+
+#else
+ // External usage
+
+ #ifdef EFI_DEBUG
+ #define ASSERT(Expression) \
+ do { \
+ if (DebugAssertEnabled ()) { \
+ if (!(Expression)) { \
+ _ASSERT (Expression); \
+ } \
+ } \
+ } while (FALSE)
+ #else
+ #define ASSERT(Expression) do{} while(0)
+ #endif
+
+#endif
+
+/**
+
+ Macro that calls DebugPrint().
+
+ If the DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of PcdDebugProperyMask is set,
+ then this macro passes Expression to DebugPrint().
+
+ @param Expression Expression containing an error level, a format string,
+ and a variable argument list based on the format string.
+
+
+**/
+#ifdef EDKII_GLUE_LIBRARY_IMPLEMENTATION
+ // Glue Library internal
+
+ #if EDKII_GLUE_LIBRARY_DEBUG_ENABLE
+ #ifdef EFI_DEBUG
+ #define DEBUG(Expression) \
+ do { \
+ if (DebugPrintEnabled ()) { \
+ _DEBUG (Expression); \
+ } \
+ } while (FALSE)
+ #endif
+ #else
+ #define DEBUG(Expression) do{} while(0)
+ #endif
+
+#else
+ // External usage
+
+ #ifdef EFI_DEBUG
+ #define DEBUG(Expression) \
+ do { \
+ if (DebugPrintEnabled ()) { \
+ _DEBUG (Expression); \
+ } \
+ } while (FALSE)
+ #else
+ #define DEBUG(Expression) do{} while(0)
+ #endif
+
+#endif
+
+
+/**
+
+ Macro that calls DebugAssert() if an EFI_STATUS evaluates to an error code.
+
+ If the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is set,
+ then this macro evaluates the EFI_STATUS value specified by StatusParameter.
+ If StatusParameter is an error code, then DebugAssert() is called passing in
+ the source filename, source line number, and StatusParameter.
+
+ @param StatusParameter EFI_STATUS value to evaluate.
+
+**/
+#ifdef EDKII_GLUE_LIBRARY_IMPLEMENTATION
+ // Glue Library internal
+
+ #if EDKII_GLUE_LIBRARY_DEBUG_ENABLE
+ #ifdef EFI_DEBUG
+ #define ASSERT_EFI_ERROR(StatusParameter) \
+ do { \
+ if (DebugAssertEnabled ()) { \
+ if (EFI_ERROR (StatusParameter)) { \
+ DEBUG ((EFI_D_ERROR, "\nASSERT_EFI_ERROR, Status = %r (0x%08X)\n", \
+ StatusParameter, StatusParameter)); \
+ _ASSERT (!EFI_ERROR (StatusParameter)); \
+ } \
+ } \
+ } while (FALSE)
+ #endif
+ #else
+ #define ASSERT_EFI_ERROR(Expression) do{} while(0)
+ #endif
+
+#else
+ // External usage
+
+ #ifdef EFI_DEBUG
+ #define ASSERT_EFI_ERROR(StatusParameter) \
+ do { \
+ if (DebugAssertEnabled ()) { \
+ if (EFI_ERROR (StatusParameter)) { \
+ DEBUG ((EFI_D_ERROR, "\nASSERT_EFI_ERROR, Status = %r (0x%08X)\n", \
+ StatusParameter, StatusParameter)); \
+ _ASSERT (!EFI_ERROR (StatusParameter)); \
+ } \
+ } \
+ } while (FALSE)
+ #else
+ #define ASSERT_EFI_ERROR(Expression) do{} while(0)
+ #endif
+
+#endif
+
+
+/**
+
+ Macro that calls DebugAssert() if a protocol is already installed in the
+ handle database.
+
+ If the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is clear,
+ then return.
+
+ If Handle is NULL, then a check is made to see if the protocol specified by Guid
+ is present on any handle in the handle database. If Handle is not NULL, then
+ a check is made to see if the protocol specified by Guid is present on the
+ handle specified by Handle. If the check finds the protocol, then DebugAssert()
+ is called passing in the source filename, source line number, and Guid.
+
+ If Guid is NULL, then ASSERT().
+
+ @param Handle The handle to check for the protocol. This is an optional
+ parameter that may be NULL. If it is NULL, then the entire
+ handle database is searched.
+
+ @param Guid Pointer to a protocol GUID.
+
+**/
+#ifdef EFI_DEBUG
+#define ASSERT_PROTOCOL_ALREADY_INSTALLED(Handle, Guid) \
+ do { \
+ if (DebugAssertEnabled ()) { \
+ VOID *Instance; \
+ ASSERT (Guid != NULL); \
+ if (Handle == NULL) { \
+ if (!EFI_ERROR (gBS->LocateProtocol ((EFI_GUID *)Guid, NULL, &Instance))) { \
+ _ASSERT (Guid already installed in database); \
+ } \
+ } else { \
+ if (!EFI_ERROR (gBS->HandleProtocol (Handle, (EFI_GUID *)Guid, &Instance))) { \
+ _ASSERT (Guid already installed on Handle); \
+ } \
+ } \
+ } \
+ } while (FALSE)
+#else
+#define ASSERT_PROTOCOL_ALREADY_INSTALLED(Handle, Guid) \
+ do {} while(0);
+#endif
+
+
+/**
+ Macro that marks the beginning of debug source code.
+
+ If the DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is set,
+ then this macro marks the beginning of source code that is included in a module.
+ Otherwise, the source lines between DEBUG_CODE_BEGIN() and DEBUG_CODE_END()
+ are not included in a module.
+
+**/
+#define DEBUG_CODE_BEGIN() do { if (DebugCodeEnabled ()) { UINT8 __DebugCodeLocal
+
+
+/**
+
+ Macro that marks the end of debug source code.
+
+ If the DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is set,
+ then this macro marks the end of source code that is included in a module.
+ Otherwise, the source lines between DEBUG_CODE_BEGIN() and DEBUG_CODE_END()
+ are not included in a module.
+
+**/
+#define DEBUG_CODE_END() __DebugCodeLocal = 0; } } while (FALSE)
+
+
+/**
+
+ Macro that declares a section of debug source code.
+
+ If the DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is set,
+ then the source code specified by Expression is included in a module.
+ Otherwise, the source specified by Expression is not included in a module.
+
+**/
+#define DEBUG_CODE(Expression) \
+ DEBUG_CODE_BEGIN (); \
+ Expression \
+ DEBUG_CODE_END ()
+
+
+/**
+
+ Macro that calls DebugClearMemory() to clear a buffer to a default value.
+
+ If the DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED bit of PcdDebugProperyMask is set,
+ then this macro calls DebugClearMemory() passing in Address and Length.
+
+ @param Address Pointer to a buffer.
+ @param Length The number of bytes in the buffer to set.
+
+**/
+#define DEBUG_CLEAR_MEMORY(Address, Length) \
+ do { \
+ if (DebugClearMemoryEnabled ()) { \
+ DebugClearMemory (Address, Length); \
+ } \
+ } while (FALSE)
+
+
+/**
+
+ Macro that calls DebugAssert() if the containing record does not have a
+ matching signature. If the signatures matches, then a pointer to the data
+ structure that contains a specified field of that data structure is returned.
+ This is a light weight method hide information by placing a public data
+ structure inside a larger private data structure and using a pointer to the
+ public data structure to retrieve a pointer to the private data structure.
+
+ If the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is clear,
+ then this macro computes the offset, in bytes, of field specified by Field
+ from the beginning of the data structure specified by TYPE. This offset is
+ subtracted from Record, and is used to return a pointer to a data structure
+ of the type specified by TYPE.
+
+ If the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is set,
+ then this macro computes the offset, in bytes, of field specified by Field from
+ the beginning of the data structure specified by TYPE. This offset is
+ subtracted from Record, and is used to compute a pointer to a data structure of
+ the type specified by TYPE. The Signature field of the data structure specified
+ by TYPE is compared to TestSignature. If the signatures match, then a pointer
+ to the pointer to a data structure of the type specified by TYPE is returned.
+ If the signatures do not match, then DebugAssert() is called with a description
+ of "CR has a bad signature" and Record is returned.
+
+ If the data type specified by TYPE does not contain the field specified by Field,
+ then the module will not compile.
+
+ If TYPE does not contain a field called Signature, then the module will not
+ compile.
+
+ @param Record Pointer to the field specified by Field within a data
+ structure of type TYPE.
+
+ @param TYPE The name of the data structure type to return This
+ data structure must contain the field specified by Field.
+
+ @param Field The name of the field in the data structure specified
+ by TYPE to which Record points.
+
+ @param TestSignature The 32-bit signature value to match.
+
+**/
+#ifdef EFI_DEBUG
+ #define CR(Record, TYPE, Field, TestSignature) \
+ (DebugAssertEnabled () && (_CR (Record, TYPE, Field)->Signature != TestSignature)) ? \
+ (TYPE *) (_ASSERT (CR has Bad Signature), Record) : \
+ _CR (Record, TYPE, Field)
+#else
+ #define CR(Record, TYPE, Field, TestSignature) \
+ _CR (Record, TYPE, Field)
+#endif
+
+
+#endif
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDevicePathLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDevicePathLib.h
new file mode 100644
index 0000000..2c2a730
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDevicePathLib.h
@@ -0,0 +1,269 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ EdkIIGlueDevicePathLib.h
+
+Abstract:
+
+ Public header file for Device Path Lib
+
+--*/
+
+#ifndef __EDKII_GLUE_DEVICE_PATH_LIB_H__
+#define __EDKII_GLUE_DEVICE_PATH_LIB_H__
+
+
+#define GetDevicePathSize(_DEVICEPATH) GlueGetDevicePathSize(_DEVICEPATH)
+#define DuplicateDevicePath(_DEVICEPATH) GlueDuplicateDevicePath(_DEVICEPATH)
+#define AppendDevicePath(_FIRSTPATH, _SECONDPATH) GlueAppendDevicePath(_FIRSTPATH, _SECONDPATH)
+#define AppendDevicePathNode(_DEVICEPATH, _DEVICEPATHNODE) GlueAppendDevicePathNode(_DEVICEPATH, _DEVICEPATHNODE)
+#define AppendDevicePathInstance(_SOURCE, _INSTANCE) GlueAppendDevicePathInstance(_SOURCE,_INSTANCE)
+#define GetNextDevicePathInstance(_DEVICEPATH, _SIZE) GlueGetNextDevicePathInstance(_DEVICEPATH, _SIZE)
+#define IsDevicePathMultiInstance(_DEVICEPATH) GlueIsDevicePathMultiInstance(_DEVICEPATH)
+#define DevicePathFromHandle(_HANDLE) GlueDevicePathFromHandle(_HANDLE)
+#define FileDevicePath(_DEVICE, _FILENAME) GlueFileDevicePath(_DEVICE, _FILENAME)
+
+
+/**
+ Returns the size of a device path in bytes.
+
+ This function returns the size, in bytes, of the device path data structure specified by
+ DevicePath including the end of device path node. If DevicePath is NULL, then 0 is returned.
+
+ @param DevicePath A pointer to a device path data structure.
+
+ @return The size of a device path in bytes.
+
+**/
+UINTN
+EFIAPI
+GlueGetDevicePathSize (
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ );
+
+/**
+ Creates a new device path by appending a second device path to a first device path.
+
+ This function allocates space for a new copy of the device path specified by DevicePath. If
+ DevicePath is NULL, then NULL is returned. If the memory is successfully allocated, then the
+ contents of DevicePath are copied to the newly allocated buffer, and a pointer to that buffer
+ is returned. Otherwise, NULL is returned.
+
+ @param DevicePath A pointer to a device path data structure.
+
+ @return A pointer to the duplicated device path.
+
+**/
+EFI_DEVICE_PATH_PROTOCOL *
+EFIAPI
+GlueDuplicateDevicePath (
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ );
+
+/**
+ Creates a new device path by appending a second device path to a first device path.
+
+ This function creates a new device path by appending a copy of SecondDevicePath to a copy of
+ FirstDevicePath in a newly allocated buffer. Only the end-of-device-path device node from
+ SecondDevicePath is retained. The newly created device path is returned.
+ If FirstDevicePath is NULL, then it is ignored, and a duplicate of SecondDevicePath is returned.
+ If SecondDevicePath is NULL, then it is ignored, and a duplicate of FirstDevicePath is returned.
+ If both FirstDevicePath and SecondDevicePath are NULL, then NULL is returned.
+ If there is not enough memory for the newly allocated buffer, then NULL is returned.
+ The memory for the new device path is allocated from EFI boot services memory. It is the
+ responsibility of the caller to free the memory allocated.
+
+ @param FirstDevicePath A pointer to a device path data structure.
+ @param SecondDevicePath A pointer to a device path data structure.
+
+ @return A pointer to the new device path.
+
+**/
+EFI_DEVICE_PATH_PROTOCOL *
+EFIAPI
+GlueAppendDevicePath (
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *FirstDevicePath, OPTIONAL
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *SecondDevicePath OPTIONAL
+ );
+
+/**
+ Creates a new path by appending the device node to the device path.
+
+ This function creates a new device path by appending a copy of the device node specified by
+ DevicePathNode to a copy of the device path specified by DevicePath in an allocated buffer.
+ The end-of-device-path device node is moved after the end of the appended device node.
+ If DevicePath is NULL, then NULL is returned.
+ If DevicePathNode is NULL, then NULL is returned.
+ If there is not enough memory to allocate space for the new device path, then NULL is returned.
+ The memory is allocated from EFI boot services memory. It is the responsibility of the caller to
+ free the memory allocated.
+
+ @param DevicePath A pointer to a device path data structure.
+ @param DevicePathNode A pointer to a single device path node.
+
+ @return A pointer to the new device path.
+
+**/
+EFI_DEVICE_PATH_PROTOCOL *
+EFIAPI
+GlueAppendDevicePathNode (
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, OPTIONAL
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathNode OPTIONAL
+ );
+
+/**
+ Creates a new device path by appending the specified device path instance to the specified device
+ path.
+
+ This function creates a new device path by appending a copy of the device path instance specified
+ by DevicePathInstance to a copy of the device path secified by DevicePath in a allocated buffer.
+ The end-of-device-path device node is moved after the end of the appended device path instance
+ and a new end-of-device-path-instance node is inserted between.
+ If DevicePath is NULL, then a copy if DevicePathInstance is returned.
+ If DevicePathInstance is NULL, then NULL is returned.
+ If there is not enough memory to allocate space for the new device path, then NULL is returned.
+ The memory is allocated from EFI boot services memory. It is the responsibility of the caller to
+ free the memory allocated.
+
+ @param DevicePath A pointer to a device path data structure.
+ @param DevicePathInstance A pointer to a device path instance.
+
+ @return A pointer to the new device path.
+
+**/
+EFI_DEVICE_PATH_PROTOCOL *
+EFIAPI
+GlueAppendDevicePathInstance (
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, OPTIONAL
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathInstance OPTIONAL
+ );
+
+/**
+ Creates a copy of the current device path instance and returns a pointer to the next device path
+ instance.
+
+ This function creates a copy of the current device path instance. It also updates DevicePath to
+ point to the next device path instance in the device path (or NULL if no more) and updates Size
+ to hold the size of the device path instance copy.
+ If DevicePath is NULL, then NULL is returned.
+ If there is not enough memory to allocate space for the new device path, then NULL is returned.
+ The memory is allocated from EFI boot services memory. It is the responsibility of the caller to
+ free the memory allocated.
+ If Size is NULL, then ASSERT().
+
+ @param DevicePath On input, this holds the pointer to the current device path
+ instance. On output, this holds the pointer to the next device
+ path instance or NULL if there are no more device path
+ instances in the device path pointer to a device path data
+ structure.
+ @param Size On output, this holds the size of the device path instance, in
+ bytes or zero, if DevicePath is NULL.
+
+ @return A pointer to the current device path instance.
+
+**/
+EFI_DEVICE_PATH_PROTOCOL *
+EFIAPI
+GlueGetNextDevicePathInstance (
+ IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath,
+ OUT UINTN *Size
+ );
+
+/**
+ Creates a copy of the current device path instance and returns a pointer to the next device path
+ instance.
+
+ This function creates a new device node in a newly allocated buffer of size NodeLength and
+ initializes the device path node header with NodeType and NodeSubType. The new device path node
+ is returned.
+ If NodeLength is smaller than a device path header, then NULL is returned.
+ If there is not enough memory to allocate space for the new device path, then NULL is returned.
+ The memory is allocated from EFI boot services memory. It is the responsibility of the caller to
+ free the memory allocated.
+
+ @param NodeType The device node type for the new device node.
+ @param NodeSubType The device node sub-type for the new device node.
+ @param NodeLength The length of the new device node.
+
+ @return The new device path.
+
+**/
+EFI_DEVICE_PATH_PROTOCOL *
+EFIAPI
+CreateDeviceNode (
+ IN UINT8 NodeType,
+ IN UINT8 NodeSubType,
+ IN UINT16 NodeLength
+ );
+
+/**
+ Determines if a device path is single or multi-instance.
+
+ This function returns TRUE if the device path specified by DevicePath is multi-instance.
+ Otherwise, FALSE is returned. If DevicePath is NULL, then FALSE is returned.
+
+ @param DevicePath A pointer to a device path data structure.
+
+ @retval TRUE DevicePath is multi-instance.
+ @retval FALSE DevicePath is not multi-instance or DevicePath is NULL.
+
+**/
+BOOLEAN
+EFIAPI
+GlueIsDevicePathMultiInstance (
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ );
+
+/**
+ Retrieves the device path protocol from a handle.
+
+ This function returns the device path protocol from the handle specified by Handle. If Handle is
+ NULL or Handle does not contain a device path protocol, then NULL is returned.
+
+ @param Handle The handle from which to retrieve the device path protocol.
+
+ @return The device path protocol from the handle specified by Handle.
+
+**/
+EFI_DEVICE_PATH_PROTOCOL *
+EFIAPI
+GlueDevicePathFromHandle (
+ IN EFI_HANDLE Handle
+ );
+
+/**
+ Allocates a device path for a file and appends it to an existing device path.
+
+ If Device is a valid device handle that contains a device path protocol, then a device path for
+ the file specified by FileName is allocated and appended to the device path associated with the
+ handle Device. The allocated device path is returned. If Device is NULL or Device is a handle
+ that does not support the device path protocol, then a device path containing a single device
+ path node for the file specified by FileName is allocated and returned.
+ If FileName is NULL, then ASSERT().
+
+ @param Device A pointer to a device handle. This parameter is optional and
+ may be NULL.
+ @param FileName A pointer to a Null-terminated Unicode string.
+
+ @return The allocated device path.
+
+**/
+EFI_DEVICE_PATH_PROTOCOL *
+EFIAPI
+GlueFileDevicePath (
+ IN EFI_HANDLE Device, OPTIONAL
+ IN CONST CHAR16 *FileName
+ );
+
+#endif
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDxeRuntimeDriverLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDxeRuntimeDriverLib.h
new file mode 100644
index 0000000..2ec3f4f
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDxeRuntimeDriverLib.h
@@ -0,0 +1,451 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ EdkIIGlueDxeRuntimeDriverLib.h
+
+Abstract:
+
+ Library that abstracts runtime services
+
+--*/
+
+#ifndef __EDKII_GLUE_DXE_RUNTIME_DRIVER_LIB_H__
+#define __EDKII_GLUE_DXE_RUNTIME_DRIVER_LIB_H__
+
+#if (EFI_SPECIFICATION_VERSION < 0x00020000)
+
+typedef struct {
+ EFI_GUID CapsuleGuid;
+ UINT32 HeaderSize;
+ UINT32 Flags;
+ UINT32 CapsuleImageSize;
+} UEFI_CAPSULE_HEADER;
+
+#else
+
+typedef EFI_CAPSULE_HEADER UEFI_CAPSULE_HEADER;
+
+#endif
+
+extern const EFI_EVENT_NOTIFY _gDriverExitBootServicesEvent[];
+
+extern const EFI_EVENT_NOTIFY _gDriverSetVirtualAddressMapEvent[];
+
+/**
+ Check to see if the execute context is in Runtime phase or not.
+
+ @param None.
+
+ @retval TRUE The driver is in SMM.
+ @retval FALSE The driver is not in SMM.
+
+**/
+BOOLEAN
+EFIAPI
+EfiAtRuntime (
+ VOID
+ );
+
+/**
+ Check to see if the SetVirtualAddressMsp() is invoked or not.
+
+ @retval TRUE SetVirtualAddressMsp() has been called.
+ @retval FALSE SetVirtualAddressMsp() has not been called.
+
+**/
+BOOLEAN
+EFIAPI
+EfiGoneVirtual (
+ VOID
+ );
+
+/**
+ Return current time and date information, and time-keeping
+ capabilities of hardware platform.
+
+ @param Time A pointer to storage to receive a snapshot of the current time.
+ @param Capabilities An optional pointer to a buffer to receive the real time clock device¡¯s
+ capabilities.
+
+ @retval EFI_SUCCESS Success to execute the function.
+ @retval !EFI_SUCCESS Failed to e3xecute the function.
+
+**/
+EFI_STATUS
+EFIAPI
+EfiGetTime (
+ OUT EFI_TIME *Time,
+ OUT EFI_TIME_CAPABILITIES *Capabilities
+ );
+
+/**
+ Set current time and date information.
+
+ @param Time A pointer to cache of time setting.
+
+ @retval EFI_SUCCESS Success to execute the function.
+ @retval !EFI_SUCCESS Failed to execute the function.
+
+**/
+EFI_STATUS
+EFIAPI
+EfiSetTime (
+ IN EFI_TIME *Time
+ );
+
+/**
+ Return current wakeup alarm clock setting.
+
+ @param Enabled Indicate if the alarm clock is enabled or disabled.
+ @param Pending Indicate if the alarm signal is pending and requires acknowledgement.
+ @param Time Current alarm clock setting.
+
+ @retval EFI_SUCCESS Success to execute the function.
+ @retval !EFI_SUCCESS Failed to e3xecute the function.
+
+**/
+EFI_STATUS
+EFIAPI
+EfiGetWakeupTime (
+ OUT BOOLEAN *Enabled,
+ OUT BOOLEAN *Pending,
+ OUT EFI_TIME *Time
+ );
+
+/**
+ Set current wakeup alarm clock.
+
+ @param Enable Enable or disable current alarm clock..
+ @param Time Point to alarm clock setting.
+
+ @retval EFI_SUCCESS Success to execute the function.
+ @retval !EFI_SUCCESS Failed to e3xecute the function.
+
+**/
+EFI_STATUS
+EFIAPI
+EfiSetWakeupTime (
+ IN BOOLEAN Enable,
+ IN EFI_TIME *Time
+ );
+
+/**
+ Return value of variable.
+
+ @param VariableName the name of the vendor's variable, it's a
+ Null-Terminated Unicode String
+ @param VendorGuid Unify identifier for vendor.
+ @param Attributes Point to memory location to return the attributes of variable. If the point
+ is NULL, the parameter would be ignored.
+ @param DataSize As input, point to the maxinum size of return Data-Buffer.
+ As output, point to the actual size of the returned Data-Buffer.
+ @param Data Point to return Data-Buffer.
+
+ @retval EFI_SUCCESS Success to execute the function.
+ @retval !EFI_SUCCESS Failed to e3xecute the function.
+
+**/
+EFI_STATUS
+EFIAPI
+EfiGetVariable (
+ IN CHAR16 *VariableName,
+ IN EFI_GUID *VendorGuid,
+ OUT UINT32 *Attributes,
+ IN OUT UINTN *DataSize,
+ OUT VOID *Data
+ )
+;
+
+/**
+ Enumerates variable's name.
+
+ @param VariableNameSize As input, point to maxinum size of variable name.
+ As output, point to actual size of varaible name.
+ @param VariableName As input, supplies the last VariableName that was returned by
+ GetNextVariableName().
+ As output, returns the name of variable. The name
+ string is Null-Terminated Unicode string.
+ @param VendorGuid As input, supplies the last VendorGuid that was returned by
+ GetNextVriableName().
+ As output, returns the VendorGuid of the current variable.
+
+ @retval EFI_SUCCESS Success to execute the function.
+ @retval !EFI_SUCCESS Failed to e3xecute the function.
+
+**/
+EFI_STATUS
+EFIAPI
+EfiGetNextVariableName (
+ IN OUT UINTN *VariableNameSize,
+ IN OUT CHAR16 *VariableName,
+ IN OUT EFI_GUID *VendorGuid
+ );
+
+/**
+ Sets value of variable.
+
+ @param VariableName the name of the vendor's variable, it's a
+ Null-Terminated Unicode String
+ @param VendorGuid Unify identifier for vendor.
+ @param Attributes Point to memory location to return the attributes of variable. If the point
+ is NULL, the parameter would be ignored.
+ @param DataSize The size in bytes of Data-Buffer.
+ @param Data Point to the content of the variable.
+
+ @retval EFI_SUCCESS Success to execute the function.
+ @retval !EFI_SUCCESS Failed to e3xecute the function.
+
+**/
+EFI_STATUS
+EFIAPI
+EfiSetVariable (
+ IN CHAR16 *VariableName,
+ IN EFI_GUID *VendorGuid,
+ IN UINT32 Attributes,
+ IN UINTN DataSize,
+ IN VOID *Data
+ );
+
+/**
+ Returns the next high 32 bits of platform's monotonic counter.
+
+ @param HighCount Pointer to returned value.
+
+ @retval EFI_SUCCESS Success to execute the function.
+ @retval !EFI_SUCCESS Failed to e3xecute the function.
+
+**/
+EFI_STATUS
+EFIAPI
+EfiGetNextHighMonotonicCount (
+ OUT UINT32 *HighCount
+ );
+
+/**
+ Resets the entire platform.
+
+ @param ResetType The type of reset to perform.
+ @param ResetStatus The status code for reset.
+ @param DataSize The size in bytes of reset data.
+ @param ResetData Pointer to data buffer that includes
+ Null-Terminated Unicode string.
+
+ @retval EFI_SUCCESS Success to execute the function.
+ @retval !EFI_SUCCESS Failed to e3xecute the function.
+
+**/
+VOID
+EfiResetSystem (
+ IN EFI_RESET_TYPE ResetType,
+ IN EFI_STATUS ResetStatus,
+ IN UINTN DataSize,
+ IN CHAR16 *ResetData
+ );
+
+/**
+ Determines the new virtual address that is to be used on subsequent memory accesses.
+
+ @param DebugDisposition Supplies type information for the pointer being converted.
+ @param Address The pointer to a pointer that is to be fixed to be the
+ value needed for the new virtual address mapping being
+ applied.
+
+ @retval EFI_SUCCESS Success to execute the function.
+ @retval !EFI_SUCCESS Failed to e3xecute the function.
+
+**/
+EFI_STATUS
+EFIAPI
+EfiConvertPointer (
+ IN UINTN DebugDisposition,
+ IN OUT VOID *Address
+ );
+
+
+/**
+ Change the runtime addressing mode of EFI firmware from physical to virtual.
+
+ @param MemoryMapSize The size in bytes of VirtualMap.
+ @param DescriptorSize The size in bytes of an entry in the VirtualMap.
+ @param DescriptorVersion The version of the structure entries in VirtualMap.
+ @param VirtualMap An array of memory descriptors which contain new virtual
+ address mapping information for all runtime ranges. Type
+ EFI_MEMORY_DESCRIPTOR is defined in the
+ GetMemoryMap() function description.
+
+ @retval EFI_SUCCESS The virtual address map has been applied.
+ @retval EFI_UNSUPPORTED EFI firmware is not at runtime, or the EFI firmware is already in
+ virtual address mapped mode.
+ @retval EFI_INVALID_PARAMETER DescriptorSize or DescriptorVersion is
+ invalid.
+ @retval EFI_NO_MAPPING A virtual address was not supplied for a range in the memory
+ map that requires a mapping.
+ @retval EFI_NOT_FOUND A virtual address was supplied for an address that is not found
+ in the memory map.
+**/
+EFI_STATUS
+EFIAPI
+EfiSetVirtualAddressMap (
+ IN UINTN MemoryMapSize,
+ IN UINTN DescriptorSize,
+ IN UINT32 DescriptorVersion,
+ IN CONST EFI_MEMORY_DESCRIPTOR *VirtualMap
+ );
+
+
+/**
+ Conver the standard Lib double linked list to a virtual mapping.
+
+ @param DebugDisposition Supplies type information for the pointer being converted.
+ @param ListHead Head of linked list to convert.
+
+ @retval EFI_SUCCESS Success to execute the function.
+ @retval !EFI_SUCCESS Failed to e3xecute the function.
+
+**/
+EFI_STATUS
+EFIAPI
+EfiConvertList (
+ IN UINTN DebugDisposition,
+ IN OUT LIST_ENTRY *ListHead
+ );
+
+
+/**
+
+ Passes capsules to the firmware with both virtual and physical mapping.
+ Depending on the intended consumption, the firmware may
+ process the capsule immediately. If the payload should persist across a
+ system reset, the reset value returned from EFI_QueryCapsuleCapabilities must
+ be passed into ResetSystem() and will cause the capsule to be processed by
+ the firmware as part of the reset process.
+
+ @param CapsuleHeaderArray Virtual pointer to an array of virtual pointers to the capsules
+ being passed into update capsule. Each capsules is assumed to
+ stored in contiguous virtual memory. The capsules in the
+ CapsuleHeaderArray must be the same capsules as the
+ ScatterGatherList. The CapsuleHeaderArray must
+ have the capsules in the same order as the ScatterGatherList.
+ @param CapsuleCount Number of pointers to EFI_CAPSULE_HEADER in
+ CaspuleHeaderArray.
+ @param ScatterGatherList Physical pointer to a set of
+ EFI_CAPSULE_BLOCK_DESCRIPTOR that describes the
+ location in physical memory of a set of capsules. See Related
+ Definitions for an explanation of how more than one capsule is
+ passed via this interface. The capsules in the
+ ScatterGatherList must be in the same order as the
+ CapsuleHeaderArray. This parameter is only referenced if
+ the capsules are defined to persist across system reset.
+
+ @retval EFI_SUCCESS Valid capsule was passed. I Valid capsule was passed. If
+ CAPSULE_FLAGS_PERSIT_ACROSS_RESET is not set, the
+ capsule has been successfully processed by the firmware.
+ @retval EFI_INVALID_PARAMETER CapsuleSize is NULL or ResetTye is NULL.
+ @retval EFI_DEVICE_ERROR The capsule update was started, but failed due to a device error.
+
+**/
+EFI_STATUS
+EFIAPI
+EfiUpdateCapsule (
+ IN UEFI_CAPSULE_HEADER **CapsuleHeaderArray,
+ IN UINTN CapsuleCount,
+ IN EFI_PHYSICAL_ADDRESS ScatterGatherList
+ );
+
+
+/**
+
+ The QueryCapsuleCapabilities() function allows a caller to test to see if a capsule or
+ capsules can be updated via UpdateCapsule(). The Flags values in the capsule header and
+ size of the entire capsule is checked.
+ If the caller needs to query for generic capsule capability a fake EFI_CAPSULE_HEADER can be
+ constructed where CapsuleImageSize is equal to HeaderSize that is equal to sizeof
+ (EFI_CAPSULE_HEADER). To determine reset requirements,
+ CAPSULE_FLAGS_PERSIST_ACROSS_RESET should be set in the Flags field of the
+ EFI_CAPSULE_HEADER.
+ The firmware must support any capsule that has the
+ CAPSULE_FLAGS_PERSIST_ACROSS_RESET flag set in EFI_CAPSULE_HEADER. The
+ firmware sets the policy for what capsules are supported that do not have the
+ CAPSULE_FLAGS_PERSIST_ACROSS_RESET flag set.
+
+ @param CapsuleHeaderArray Virtual pointer to an array of virtual pointers to the capsules
+ being passed into update capsule. The capsules are assumed to
+ stored in contiguous virtual memory.
+ @param CapsuleCount Number of pointers to EFI_CAPSULE_HEADER in
+ CaspuleHeaderArray.
+ @param MaxiumCapsuleSize On output the maximum size that UpdateCapsule() can
+ support as an argument to UpdateCapsule() via
+ CapsuleHeaderArray and ScatterGatherList.
+ Undefined on input.
+ @param ResetType Returns the type of reset required for the capsule update.
+
+ @retval EFI_SUCCESS Valid answer returned..
+ @retval EFI_INVALID_PARAMETER MaximumCapsuleSize is NULL.
+ @retval EFI_UNSUPPORTED The capsule type is not supported on this platform, and
+ MaximumCapsuleSize and ResetType are undefined.
+
+**/
+EFI_STATUS
+EFIAPI
+EfiQueryCapsuleCapabilities (
+ IN UEFI_CAPSULE_HEADER **CapsuleHeaderArray,
+ IN UINTN CapsuleCount,
+ OUT UINT64 *MaximumCapsuleSize,
+ OUT EFI_RESET_TYPE *ResetType
+ );
+
+
+/**
+
+ The QueryVariableInfo() function allows a caller to obtain the information about the
+ maximum size of the storage space available for the EFI variables, the remaining size of the storage
+ space available for the EFI variables and the maximum size of each individual EFI variable,
+ associated with the attributes specified.
+ The returned MaximumVariableStorageSize, RemainingVariableStorageSize,
+ MaximumVariableSize information may change immediately after the call based on other
+ runtime activities including asynchronous error events. Also, these values associated with different
+ attributes are not additive in nature.
+
+ @param Attributes Attributes bitmask to specify the type of variables on
+ which to return information. Refer to the
+ GetVariable() function description.
+ @param MaximumVariableStorageSize
+ On output the maximum size of the storage space
+ available for the EFI variables associated with the
+ attributes specified.
+ @param RemainingVariableStorageSize
+ Returns the remaining size of the storage space
+ available for the EFI variables associated with the
+ attributes specified..
+ @param MaximumVariableSize Returns the maximum size of the individual EFI
+ variables associated with the attributes specified.
+
+ @retval EFI_SUCCESS Valid answer returned.
+ @retval EFI_INVALID_PARAMETER An invalid combination of attribute bits was supplied.
+ @retval EFI_UNSUPPORTED EFI_UNSUPPORTED The attribute is not supported on this platform, and the
+ MaximumVariableStorageSize,
+ RemainingVariableStorageSize, MaximumVariableSize
+ are undefined.
+**/
+EFI_STATUS
+EFIAPI
+EfiQueryVariableInfo (
+ IN UINT32 Attrubutes,
+ OUT UINT64 *MaximumVariableStorageSize,
+ OUT UINT64 *RemainingVariableStorageSize,
+ OUT UINT64 *MaximumVariableSize
+ );
+
+#endif
+
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDxeServicesTableLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDxeServicesTableLib.h
new file mode 100644
index 0000000..4660dc6
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDxeServicesTableLib.h
@@ -0,0 +1,32 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ EdkIIGlueDxeServicesTableLib.h
+
+Abstract:
+
+ Library that provides a global pointer to the DXE Services Table
+
+--*/
+
+#ifndef __EDKII_GLUE_DXE_SERVICES_TABLE_LIB_H__
+#define __EDKII_GLUE_DXE_SERVICES_TABLE_LIB_H__
+
+//
+// Cache copy of the DXE Services Table
+//
+extern EFI_DXE_SERVICES *gDS;
+
+#endif
+
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDxeSmmDriverEntryPoint.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDxeSmmDriverEntryPoint.h
new file mode 100644
index 0000000..2592afc
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueDxeSmmDriverEntryPoint.h
@@ -0,0 +1,147 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EdkIIGlueDxeSmmDriverEntryPoint.h
+
+Abstract:
+
+ Public header file for DXE SMM Driver Entry Point Lib
+
+--*/
+
+#ifndef __EDKII_GLUE_MODULE_ENTRY_POINT_H__
+#define __EDKII_GLUE_MODULE_ENTRY_POINT_H__
+
+//
+// Declare the EFI/UEFI Specification Revision to which this driver is implemented
+//
+extern const UINT32 _gUefiDriverRevision;
+
+//
+// Declare the number of entry points in the image.
+//
+extern const UINT8 _gDriverEntryPointCount;
+
+//
+// Declare the number of unload handler in the image.
+//
+extern const UINT8 _gDriverUnloadImageCount;
+
+/**
+ Enrty point to DXE SMM Driver.
+
+ @param ImageHandle ImageHandle of the loaded driver.
+ @param SystemTable Pointer to the EFI System Table.
+
+ @retval EFI_SUCCESS One or more of the drivers returned a success code.
+ @retval !EFI_SUCESS The return status from the last driver entry point in the list.
+
+**/
+EFI_STATUS
+EFIAPI
+_ModuleEntryPoint (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ );
+
+/**
+ Enrty point wrapper of DXE SMM Driver.
+
+ @param ImageHandle ImageHandle of the loaded driver.
+ @param SystemTable Pointer to the EFI System Table.
+
+ @retval EFI_SUCCESS One or more of the drivers returned a success code.
+ @retval !EFI_SUCESS The return status from the last driver entry point in the list.
+
+**/
+EFI_STATUS
+EFIAPI
+EfiMain (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ );
+
+/**
+ Computes the cummulative return status for the driver entry point and perform
+ a long jump back into DriverEntryPoint().
+
+ @param Status Status returned by the driver that is exiting.
+
+**/
+VOID
+EFIAPI
+ExitDriver (
+ IN EFI_STATUS Status
+ );
+
+/**
+ Call constructs for all libraries. Automatics Generated by tool.
+
+ @param ImageHandle ImageHandle of the loaded driver.
+ @param SystemTable Pointer to the EFI System Table.
+
+**/
+VOID
+EFIAPI
+ProcessLibraryConstructorList (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ );
+
+/**
+ Call destructors for all libraries. Automatics Generated by tool.
+
+ @param ImageHandle ImageHandle of the loaded driver.
+ @param SystemTable Pointer to the EFI System Table.
+
+**/
+VOID
+EFIAPI
+ProcessLibraryDestructorList (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ );
+
+
+/**
+ Call the list of driver entry points. Automatics Generated by tool.
+
+ @param ImageHandle ImageHandle of the loaded driver.
+ @param SystemTable Pointer to the EFI System Table.
+
+ @return Status returned by entry points of drivers.
+
+**/
+EFI_STATUS
+EFIAPI
+ProcessModuleEntryPointList (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ );
+
+
+/**
+ Call the unload handlers for all the modules. Automatics Generated by tool.
+
+ @param ImageHandle ImageHandle of the loaded driver.
+
+ @return Status returned by unload handlers of drivers.
+
+**/
+EFI_STATUS
+EFIAPI
+ProcessModuleUnloadList (
+ IN EFI_HANDLE ImageHandle
+ );
+
+#endif
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueFirmwarePerformanceLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueFirmwarePerformanceLib.h
new file mode 100644
index 0000000..668599e
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueFirmwarePerformanceLib.h
@@ -0,0 +1,155 @@
+/*++
+
+Copyright (c) 2011, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EdkIIGluePerformanceLib.h
+
+Abstract:
+
+ Public header file for Firmware Performance Lib
+
+
+--*/
+
+#ifndef __EDKII_GLUE_FIRMWARE_PERFORMANCE_LIB_H_
+#define __EDKII_GLUE_FIRMWARE_PERFORMANCE_LIB_H_
+
+EFI_STATUS
+StartMeasure (
+ IN VOID *Handle,
+ IN UINT16 *Token,
+ IN UINT16 *Module,
+ IN UINT64 TimeStamp
+ )
+/*++
+
+Routine Description:
+
+ Start measurement according to token field and insert into pre-allocated buffer
+
+Arguments:
+
+ Handle - Handle to measure
+ Token - Token to measure
+ Module - Module to measure
+ Timestamp - Ticker as start tick
+
+Returns:
+
+ EFI_SUCCESS - Located protocol successfully, and buffer is updated with new record
+ EFI_NOT_FOUND - Failure in update
+
+--*/
+;
+
+EFI_STATUS
+EndMeasure (
+ IN VOID *Handle,
+ IN UINT16 *Token,
+ IN UINT16 *Module,
+ IN UINT64 TimeStamp
+ )
+/*++
+
+Routine Description:
+
+ End measurement according to token field and insert into pre-allocated buffer
+
+Arguments:
+
+ Handle - Handle to stop
+ Token - Token to stop
+ Module - Module to stop
+ Timestamp - Ticker as end tick
+
+Returns:
+
+ EFI_SUCCESS - Located protocol successfully, and buffer is updated with new record
+ EFI_NOT_FOUND - Failure in update
+
+--*/
+;
+
+EFI_STATUS
+StartMeasureEx (
+ IN VOID *Handle,
+ IN UINT16 *Token,
+ IN UINT16 *Module,
+ IN UINT64 TimeStamp,
+ IN UINT16 Identifier
+ )
+/*++
+
+Routine Description:
+
+ Start extended measurement according to token field and insert into pre-allocated buffer
+
+Arguments:
+
+ Handle - Handle to stop
+ Token - Token to stop
+ Module - Module to stop
+ Timestamp - Ticker as end tick
+ Identifier - Identifier for a given record
+Returns:
+
+ EFI_SUCCESS - Located protocol successfully, and buffer is updated with new record
+ EFI_NOT_FOUND - Failure in update
+
+--*/
+;
+
+EFI_STATUS
+EndMeasureEx (
+ IN VOID *Handle,
+ IN UINT16 *Token,
+ IN UINT16 *Module,
+ IN UINT64 TimeStamp,
+ IN UINT16 Identifier
+ )
+/*++
+
+Routine Description:
+
+ End extended measurement according to token field and insert into pre-allocated buffer
+
+Arguments:
+
+ Handle - Handle to stop
+ Token - Token to stop
+ Module - Module to stop
+ Timestamp - Ticker as end tick
+ Identifier - Identifier for a given record
+
+Returns:
+
+ EFI_SUCCESS - Located protocol successfully, and buffer is updated with new record
+ EFI_NOT_FOUND - Failure in update
+
+--*/
+;
+
+#ifdef FIRMWARE_PERFORMANCE
+#define PERF_START(Handle, Token, Module, TimeStamp) StartMeasure (Handle, Token, Module, TimeStamp)
+#define PERF_END(Handle, Token, Module, TimeStamp) EndMeasure (Handle, Token, Module, TimeStamp)
+#define PERF_START_EX(Handle, Token, Module, TimeStamp, Identifier) StartMeasureEx (Handle, Token, Module, TimeStamp, Identifier)
+#define PERF_END_EX(Handle, Token, Module, TimeStamp, Identifier) EndMeasureEx (Handle, Token, Module, TimeStamp, Identifier)
+#define PERF_CODE(code) code
+#else
+#define PERF_START(Handle, Token, Module, TimeStamp)
+#define PERF_END(Handle, Token, Module, TimeStamp)
+#define PERF_START_EX(Handle, Token, Module, TimeStamp, Identifier)
+#define PERF_END_EX(Handle, Token, Module, TimeStamp, Identifier)
+#define PERF_CODE(code)
+#endif
+
+#endif \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueHiiLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueHiiLib.h
new file mode 100644
index 0000000..fb9ce47
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueHiiLib.h
@@ -0,0 +1,55 @@
+/*++
+
+Copyright (c) 2004 - 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ EdkIIGlueHiiLib.h
+
+Abstract:
+
+ Public header file for Hii Lib
+
+--*/
+
+#ifndef __EDKII_GLUE_HII_LIB_H__
+#define __EDKII_GLUE_HII_LIB_H__
+
+#if (EFI_SPECIFICATION_VERSION < 0x0002000A)
+
+#define PreparePackages GluePreparePackages
+
+
+/**
+ This function allocates pool for an EFI_HII_PACKAGES structure
+ with enough space for the variable argument list of package pointers.
+ The allocated structure is initialized using NumberOfPackages, Guid,
+ and the variable length argument list of package pointers.
+
+ @param NumberOfPackages The number of HII packages to prepare.
+ @param Guid Package GUID.
+
+ @return
+ The allocated and initialized packages.
+
+**/
+EFI_HII_PACKAGES *
+EFIAPI
+GluePreparePackages (
+ IN UINTN NumberOfPackages,
+ IN CONST EFI_GUID *Guid OPTIONAL,
+ ...
+ )
+;
+
+#endif
+
+#endif
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueHobLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueHobLib.h
new file mode 100644
index 0000000..6c03086
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueHobLib.h
@@ -0,0 +1,384 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ EdkIIGlueHobLib.h
+
+Abstract:
+
+ Public header file for Hob Lib
+
+--*/
+
+#ifndef __EDKII_GLUE_HOB_LIB_H__
+#define __EDKII_GLUE_HOB_LIB_H__
+
+
+#define GetFirstGuidHob(_GUID) GlueGetFirstGuidHob(_GUID)
+#define GetNextGuidHob(_GUID, _HobStart) GlueGetNextGuidHob(_GUID, _HobStart)
+#define BuildModuleHob(_MODULENAME, _MEMORYALLOCATIONMODULE, _MODULELENGTH, _ENTRYPOINT) GlueBuildModuleHob(_MODULENAME, _MEMORYALLOCATIONMODULE, _MODULELENGTH, _ENTRYPOINT)
+#define BuildMemoryAllocationHob(_BASEADDRESS, _LENGTH, _MEMORYTYPE) GlueBuildMemoryAllocationHob(_BASEADDRESS, _LENGTH, _MEMORYTYPE)
+
+
+/**
+ Returns the pointer to the HOB list.
+
+ This function returns the pointer to first HOB in the list.
+
+ @return The pointer to the HOB list.
+
+**/
+VOID *
+EFIAPI
+GetHobList (
+ VOID
+ )
+;
+
+/**
+ Returns the next instance of a HOB type from the starting HOB.
+
+ This function searches the first instance of a HOB type from the starting HOB pointer.
+ If there does not exist such HOB type from the starting HOB pointer, it will return NULL.
+ In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer
+ unconditionally: it returns HobStart back if HobStart itself meets the requirement;
+ caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart.
+ If HobStart is NULL, then ASSERT().
+
+ @param Type The HOB type to return.
+ @param HobStart The starting HOB pointer to search from.
+
+ @return The next instance of a HOB type from the starting HOB.
+
+**/
+VOID *
+EFIAPI
+GetNextHob (
+ IN UINT16 Type,
+ IN CONST VOID *HobStart
+ )
+;
+
+/**
+ Returns the first instance of a HOB type among the whole HOB list.
+
+ This function searches the first instance of a HOB type among the whole HOB list.
+ If there does not exist such HOB type in the HOB list, it will return NULL.
+
+ @param Type The HOB type to return.
+
+ @return The next instance of a HOB type from the starting HOB.
+
+**/
+VOID *
+EFIAPI
+GetFirstHob (
+ IN UINT16 Type
+ )
+;
+
+/**
+ This function searches the first instance of a HOB from the starting HOB pointer.
+ Such HOB should satisfy two conditions:
+ its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid.
+ If there does not exist such HOB from the starting HOB pointer, it will return NULL.
+ Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE ()
+ to extract the data section and its size info respectively.
+ In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer
+ unconditionally: it returns HobStart back if HobStart itself meets the requirement;
+ caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart.
+ If Guid is NULL, then ASSERT().
+ If HobStart is NULL, then ASSERT().
+
+ @param Guid The GUID to match with in the HOB list.
+ @param HobStart A pointer to a Guid.
+
+ @return The next instance of the matched GUID HOB from the starting HOB.
+
+**/
+VOID *
+EFIAPI
+GlueGetNextGuidHob (
+ IN CONST EFI_GUID *Guid,
+ IN CONST VOID *HobStart
+ )
+;
+
+/**
+ This function searches the first instance of a HOB among the whole HOB list.
+ Such HOB should satisfy two conditions:
+ its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid.
+ If there does not exist such HOB from the starting HOB pointer, it will return NULL.
+ Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE ()
+ to extract the data section and its size info respectively.
+ If Guid is NULL, then ASSERT().
+
+ @param Guid The GUID to match with in the HOB list.
+
+ @return The first instance of the matched GUID HOB among the whole HOB list.
+
+**/
+VOID *
+EFIAPI
+GlueGetFirstGuidHob (
+ IN CONST EFI_GUID *Guid
+ )
+;
+
+/**
+ Get the Boot Mode from the HOB list.
+
+ This function returns the system boot mode information from the
+ PHIT HOB in HOB list.
+
+ @param VOID
+
+ @return The Boot Mode.
+
+**/
+EFI_BOOT_MODE
+EFIAPI
+GetBootModeHob (
+ VOID
+ )
+;
+
+/**
+ Builds a HOB for a loaded PE32 module.
+
+ This function builds a HOB for a loaded PE32 module.
+ It can only be invoked during PEI phase;
+ for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
+ If ModuleName is NULL, then ASSERT().
+ If there is no additional space for HOB creation, then ASSERT().
+
+ @param ModuleName The GUID File Name of the module.
+ @param MemoryAllocationModule The 64 bit physical address of the module.
+ @param ModuleLength The length of the module in bytes.
+ @param EntryPoint The 64 bit physical address of the module entry point.
+
+**/
+VOID
+EFIAPI
+GlueBuildModuleHob (
+ IN CONST EFI_GUID *ModuleName,
+ IN EFI_PHYSICAL_ADDRESS MemoryAllocationModule,
+ IN UINT64 ModuleLength,
+ IN EFI_PHYSICAL_ADDRESS EntryPoint
+ )
+;
+
+/**
+ Builds a HOB that describes a chunk of system memory.
+
+ This function builds a HOB that describes a chunk of system memory.
+ It can only be invoked during PEI phase;
+ for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
+ If there is no additional space for HOB creation, then ASSERT().
+
+ @param ResourceType The type of resource described by this HOB.
+ @param ResourceAttribute The resource attributes of the memory described by this HOB.
+ @param PhysicalStart The 64 bit physical address of memory described by this HOB.
+ @param NumberOfBytes The length of the memory described by this HOB in bytes.
+
+**/
+VOID
+EFIAPI
+BuildResourceDescriptorHob (
+ IN EFI_RESOURCE_TYPE ResourceType,
+ IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute,
+ IN EFI_PHYSICAL_ADDRESS PhysicalStart,
+ IN UINT64 NumberOfBytes
+ )
+;
+
+/**
+ Builds a GUID HOB with a certain data length.
+
+ This function builds a customized HOB tagged with a GUID for identification
+ and returns the start address of GUID HOB data so that caller can fill the customized data.
+ The HOB Header and Name field is already stripped.
+ It can only be invoked during PEI phase;
+ for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
+ If Guid is NULL, then ASSERT().
+ If there is no additional space for HOB creation, then ASSERT().
+ If DataLength >= (0x10000 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().
+
+ @param Guid The GUID to tag the customized HOB.
+ @param DataLength The size of the data payload for the GUID HOB.
+
+ @return The start address of GUID HOB data.
+
+**/
+VOID *
+EFIAPI
+BuildGuidHob (
+ IN CONST EFI_GUID *Guid,
+ IN UINTN DataLength
+ )
+;
+
+/**
+ Copies a data buffer to a newly-built HOB.
+
+ This function builds a customized HOB tagged with a GUID for identification,
+ copies the input data to the HOB data field and returns the start address of the GUID HOB data.
+ The HOB Header and Name field is already stripped.
+ It can only be invoked during PEI phase;
+ for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
+ If Guid is NULL, then ASSERT().
+ If Data is NULL and DataLength > 0, then ASSERT().
+ If there is no additional space for HOB creation, then ASSERT().
+ If DataLength >= (0x10000 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().
+
+ @param Guid The GUID to tag the customized HOB.
+ @param Data The data to be copied into the data field of the GUID HOB.
+ @param DataLength The size of the data payload for the GUID HOB.
+
+ @return The start address of GUID HOB data.
+
+**/
+VOID *
+EFIAPI
+BuildGuidDataHob (
+ IN CONST EFI_GUID *Guid,
+ IN VOID *Data,
+ IN UINTN DataLength
+ )
+;
+
+/**
+ Builds a Firmware Volume HOB.
+
+ This function builds a Firmware Volume HOB.
+ It can only be invoked during PEI phase;
+ for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
+ If there is no additional space for HOB creation, then ASSERT().
+
+ @param BaseAddress The base address of the Firmware Volume.
+ @param Length The size of the Firmware Volume in bytes.
+
+**/
+VOID
+EFIAPI
+BuildFvHob (
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length
+ )
+;
+
+/**
+ Builds a Capsule Volume HOB.
+
+ This function builds a Capsule Volume HOB.
+ It can only be invoked during PEI phase;
+ for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
+ If there is no additional space for HOB creation, then ASSERT().
+
+ @param BaseAddress The base address of the Capsule Volume.
+ @param Length The size of the Capsule Volume in bytes.
+
+**/
+VOID
+EFIAPI
+BuildCvHob (
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length
+ )
+;
+
+/**
+ Builds a HOB for the CPU.
+
+ This function builds a HOB for the CPU.
+ It can only be invoked during PEI phase;
+ for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
+ If there is no additional space for HOB creation, then ASSERT().
+
+ @param SizeOfMemorySpace The maximum physical memory addressability of the processor.
+ @param SizeOfIoSpace The maximum physical I/O addressability of the processor.
+
+**/
+VOID
+EFIAPI
+BuildCpuHob (
+ IN UINT8 SizeOfMemorySpace,
+ IN UINT8 SizeOfIoSpace
+ )
+;
+
+/**
+ Builds a HOB for the Stack.
+
+ This function builds a HOB for the stack.
+ It can only be invoked during PEI phase;
+ for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
+ If there is no additional space for HOB creation, then ASSERT().
+
+ @param BaseAddress The 64 bit physical address of the Stack.
+ @param Length The length of the stack in bytes.
+
+**/
+VOID
+EFIAPI
+BuildStackHob (
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length
+ )
+;
+
+/**
+ Builds a HOB for the BSP store.
+
+ This function builds a HOB for BSP store.
+ It can only be invoked during PEI phase;
+ for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
+ If there is no additional space for HOB creation, then ASSERT().
+
+ @param BaseAddress The 64 bit physical address of the BSP.
+ @param Length The length of the BSP store in bytes.
+ @param MemoryType Type of memory allocated by this HOB.
+
+**/
+VOID
+EFIAPI
+BuildBspStoreHob (
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length,
+ IN EFI_MEMORY_TYPE MemoryType
+ )
+;
+
+/**
+ Builds a HOB for the memory allocation.
+
+ This function builds a HOB for the memory allocation.
+ It can only be invoked during PEI phase;
+ for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
+ If there is no additional space for HOB creation, then ASSERT().
+
+ @param BaseAddress The 64 bit physical address of the memory.
+ @param Length The length of the memory allocation in bytes.
+ @param MemoryType Type of memory allocated by this HOB.
+
+**/
+VOID
+EFIAPI
+GlueBuildMemoryAllocationHob (
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length,
+ IN EFI_MEMORY_TYPE MemoryType
+ )
+;
+
+#endif
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueIoLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueIoLib.h
new file mode 100644
index 0000000..73f1df2
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueIoLib.h
@@ -0,0 +1,2326 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ EdkIIGlueIoLib.h
+
+Abstract:
+
+ Public header file for IO Lib
+
+--*/
+
+#ifndef __EDKII_GLUE_IO_LIB_H__
+#define __EDKII_GLUE_IO_LIB_H__
+
+
+#define IoRead8(_PORT) GlueIoRead8(_PORT)
+#define IoWrite8(_PORT,_VALUE) GlueIoWrite8(_PORT,_VALUE)
+#define IoRead16(_PORT) GlueIoRead16(_PORT)
+#define IoWrite16(_PORT,_VALUE) GlueIoWrite16(_PORT,_VALUE)
+#define IoRead32(_PORT) GlueIoRead32(_PORT)
+#define IoWrite32(_PORT,_VALUE) GlueIoWrite32(_PORT,_VALUE)
+
+
+#define IO_LIB_ADDRESS(Segment,Port) \
+ ( ((Port) & 0xffff) | (((Segment) & 0xffff) << 16) )
+
+/**
+ Reads an 8-bit I/O port.
+
+ Reads the 8-bit I/O port specified by Port. The 8-bit read value is returned.
+ This function must guarantee that all I/O read and write operations are
+ serialized.
+
+ If 8-bit I/O port operations are not supported, then ASSERT().
+
+ @param Port The I/O port to read.
+
+ @return The value read.
+
+**/
+UINT8
+EFIAPI
+GlueIoRead8 (
+ IN UINTN Port
+ );
+
+/**
+ Writes an 8-bit I/O port.
+
+ Writes the 8-bit I/O port specified by Port with the value specified by Value
+ and returns Value. This function must guarantee that all I/O read and write
+ operations are serialized.
+
+ If 8-bit I/O port operations are not supported, then ASSERT().
+
+ @param Port The I/O port to write.
+ @param Value The value to write to the I/O port.
+
+ @return The value written the I/O port.
+
+**/
+UINT8
+EFIAPI
+GlueIoWrite8 (
+ IN UINTN Port,
+ IN UINT8 Value
+ );
+
+/**
+ Reads an 8-bit I/O port, performs a bitwise inclusive OR, and writes the
+ result back to the 8-bit I/O port.
+
+ Reads the 8-bit I/O port specified by Port, performs a bitwise inclusive OR
+ between the read result and the value specified by OrData, and writes the
+ result to the 8-bit I/O port specified by Port. The value written to the I/O
+ port is returned. This function must guarantee that all I/O read and write
+ operations are serialized.
+
+ If 8-bit I/O port operations are not supported, then ASSERT().
+
+ @param Port The I/O port to write.
+ @param OrData The value to OR with the read value from the I/O port.
+
+ @return The value written back to the I/O port.
+
+**/
+UINT8
+EFIAPI
+IoOr8 (
+ IN UINTN Port,
+ IN UINT8 OrData
+ );
+
+/**
+ Reads an 8-bit I/O port, performs a bitwise AND, and writes the result back
+ to the 8-bit I/O port.
+
+ Reads the 8-bit I/O port specified by Port, performs a bitwise AND between
+ the read result and the value specified by AndData, and writes the result to
+ the 8-bit I/O port specified by Port. The value written to the I/O port is
+ returned. This function must guarantee that all I/O read and write operations
+ are serialized.
+
+ If 8-bit I/O port operations are not supported, then ASSERT().
+
+ @param Port The I/O port to write.
+ @param AndData The value to AND with the read value from the I/O port.
+
+ @return The value written back to the I/O port.
+
+**/
+UINT8
+EFIAPI
+IoAnd8 (
+ IN UINTN Port,
+ IN UINT8 AndData
+ );
+
+/**
+ Reads an 8-bit I/O port, performs a bitwise AND followed by a bitwise
+ inclusive OR, and writes the result back to the 8-bit I/O port.
+
+ Reads the 8-bit I/O port specified by Port, performs a bitwise AND between
+ the read result and the value specified by AndData, performs a bitwise OR
+ between the result of the AND operation and the value specified by OrData,
+ and writes the result to the 8-bit I/O port specified by Port. The value
+ written to the I/O port is returned. This function must guarantee that all
+ I/O read and write operations are serialized.
+
+ If 8-bit I/O port operations are not supported, then ASSERT().
+
+ @param Port The I/O port to write.
+ @param AndData The value to AND with the read value from the I/O port.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the I/O port.
+
+**/
+UINT8
+EFIAPI
+IoAndThenOr8 (
+ IN UINTN Port,
+ IN UINT8 AndData,
+ IN UINT8 OrData
+ );
+
+/**
+ Reads a bit field of an I/O register.
+
+ Reads the bit field in an 8-bit I/O register. The bit field is specified by
+ the StartBit and the EndBit. The value of the bit field is returned.
+
+ If 8-bit I/O port operations are not supported, then ASSERT().
+ If StartBit is greater than 7, then ASSERT().
+ If EndBit is greater than 7, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Port The I/O port to read.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..7.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..7.
+
+ @return The value read.
+
+**/
+UINT8
+EFIAPI
+IoBitFieldRead8 (
+ IN UINTN Port,
+ IN UINTN StartBit,
+ IN UINTN EndBit
+ );
+
+/**
+ Writes a bit field to an I/O register.
+
+ Writes Value to the bit field of the I/O register. The bit field is specified
+ by the StartBit and the EndBit. All other bits in the destination I/O
+ register are preserved. The value written to the I/O port is returned. Extra
+ left bits in Value are stripped.
+
+ If 8-bit I/O port operations are not supported, then ASSERT().
+ If StartBit is greater than 7, then ASSERT().
+ If EndBit is greater than 7, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Port The I/O port to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..7.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..7.
+ @param Value New value of the bit field.
+
+ @return The value written back to the I/O port.
+
+**/
+UINT8
+EFIAPI
+IoBitFieldWrite8 (
+ IN UINTN Port,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT8 Value
+ );
+
+/**
+ Reads a bit field in an 8-bit port, performs a bitwise OR, and writes the
+ result back to the bit field in the 8-bit port.
+
+ Reads the 8-bit I/O port specified by Port, performs a bitwise inclusive OR
+ between the read result and the value specified by OrData, and writes the
+ result to the 8-bit I/O port specified by Port. The value written to the I/O
+ port is returned. This function must guarantee that all I/O read and write
+ operations are serialized. Extra left bits in OrData are stripped.
+
+ If 8-bit I/O port operations are not supported, then ASSERT().
+ If StartBit is greater than 7, then ASSERT().
+ If EndBit is greater than 7, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Port The I/O port to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..7.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..7.
+ @param OrData The value to OR with the read value from the I/O port.
+
+ @return The value written back to the I/O port.
+
+**/
+UINT8
+EFIAPI
+IoBitFieldOr8 (
+ IN UINTN Port,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT8 OrData
+ );
+
+/**
+ Reads a bit field in an 8-bit port, performs a bitwise AND, and writes the
+ result back to the bit field in the 8-bit port.
+
+ Reads the 8-bit I/O port specified by Port, performs a bitwise AND between
+ the read result and the value specified by AndData, and writes the result to
+ the 8-bit I/O port specified by Port. The value written to the I/O port is
+ returned. This function must guarantee that all I/O read and write operations
+ are serialized. Extra left bits in AndData are stripped.
+
+ If 8-bit I/O port operations are not supported, then ASSERT().
+ If StartBit is greater than 7, then ASSERT().
+ If EndBit is greater than 7, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Port The I/O port to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..7.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..7.
+ @param AndData The value to AND with the read value from the I/O port.
+
+ @return The value written back to the I/O port.
+
+**/
+UINT8
+EFIAPI
+IoBitFieldAnd8 (
+ IN UINTN Port,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT8 AndData
+ );
+
+/**
+ Reads a bit field in an 8-bit port, performs a bitwise AND followed by a
+ bitwise inclusive OR, and writes the result back to the bit field in the
+ 8-bit port.
+
+ Reads the 8-bit I/O port specified by Port, performs a bitwise AND followed
+ by a bitwise inclusive OR between the read result and the value specified by
+ AndData, and writes the result to the 8-bit I/O port specified by Port. The
+ value written to the I/O port is returned. This function must guarantee that
+ all I/O read and write operations are serialized. Extra left bits in both
+ AndData and OrData are stripped.
+
+ If 8-bit I/O port operations are not supported, then ASSERT().
+ If StartBit is greater than 7, then ASSERT().
+ If EndBit is greater than 7, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Port The I/O port to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..7.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..7.
+ @param AndData The value to AND with the read value from the I/O port.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the I/O port.
+
+**/
+UINT8
+EFIAPI
+IoBitFieldAndThenOr8 (
+ IN UINTN Port,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT8 AndData,
+ IN UINT8 OrData
+ );
+
+/**
+ Reads a 16-bit I/O port.
+
+ Reads the 16-bit I/O port specified by Port. The 16-bit read value is returned.
+ This function must guarantee that all I/O read and write operations are
+ serialized.
+
+ If 16-bit I/O port operations are not supported, then ASSERT().
+
+ @param Port The I/O port to read.
+
+ @return The value read.
+
+**/
+UINT16
+EFIAPI
+GlueIoRead16 (
+ IN UINTN Port
+ );
+
+/**
+ Writes a 16-bit I/O port.
+
+ Writes the 16-bit I/O port specified by Port with the value specified by Value
+ and returns Value. This function must guarantee that all I/O read and write
+ operations are serialized.
+
+ If 16-bit I/O port operations are not supported, then ASSERT().
+
+ @param Port The I/O port to write.
+ @param Value The value to write to the I/O port.
+
+ @return The value written the I/O port.
+
+**/
+UINT16
+EFIAPI
+GlueIoWrite16 (
+ IN UINTN Port,
+ IN UINT16 Value
+ );
+
+/**
+ Reads a 16-bit I/O port, performs a bitwise inclusive OR, and writes the
+ result back to the 16-bit I/O port.
+
+ Reads the 16-bit I/O port specified by Port, performs a bitwise inclusive OR
+ between the read result and the value specified by OrData, and writes the
+ result to the 16-bit I/O port specified by Port. The value written to the I/O
+ port is returned. This function must guarantee that all I/O read and write
+ operations are serialized.
+
+ If 16-bit I/O port operations are not supported, then ASSERT().
+
+ @param Port The I/O port to write.
+ @param OrData The value to OR with the read value from the I/O port.
+
+ @return The value written back to the I/O port.
+
+**/
+UINT16
+EFIAPI
+IoOr16 (
+ IN UINTN Port,
+ IN UINT16 OrData
+ );
+
+/**
+ Reads a 16-bit I/O port, performs a bitwise AND, and writes the result back
+ to the 16-bit I/O port.
+
+ Reads the 16-bit I/O port specified by Port, performs a bitwise AND between
+ the read result and the value specified by AndData, and writes the result to
+ the 16-bit I/O port specified by Port. The value written to the I/O port is
+ returned. This function must guarantee that all I/O read and write operations
+ are serialized.
+
+ If 16-bit I/O port operations are not supported, then ASSERT().
+
+ @param Port The I/O port to write.
+ @param AndData The value to AND with the read value from the I/O port.
+
+ @return The value written back to the I/O port.
+
+**/
+UINT16
+EFIAPI
+IoAnd16 (
+ IN UINTN Port,
+ IN UINT16 AndData
+ );
+
+/**
+ Reads a 16-bit I/O port, performs a bitwise AND followed by a bitwise
+ inclusive OR, and writes the result back to the 16-bit I/O port.
+
+ Reads the 16-bit I/O port specified by Port, performs a bitwise AND between
+ the read result and the value specified by AndData, performs a bitwise OR
+ between the result of the AND operation and the value specified by OrData,
+ and writes the result to the 16-bit I/O port specified by Port. The value
+ written to the I/O port is returned. This function must guarantee that all
+ I/O read and write operations are serialized.
+
+ If 16-bit I/O port operations are not supported, then ASSERT().
+
+ @param Port The I/O port to write.
+ @param AndData The value to AND with the read value from the I/O port.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the I/O port.
+
+**/
+UINT16
+EFIAPI
+IoAndThenOr16 (
+ IN UINTN Port,
+ IN UINT16 AndData,
+ IN UINT16 OrData
+ );
+
+/**
+ Reads a bit field of an I/O register.
+
+ Reads the bit field in a 16-bit I/O register. The bit field is specified by
+ the StartBit and the EndBit. The value of the bit field is returned.
+
+ If 16-bit I/O port operations are not supported, then ASSERT().
+ If StartBit is greater than 15, then ASSERT().
+ If EndBit is greater than 15, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Port The I/O port to read.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..15.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..15.
+
+ @return The value read.
+
+**/
+UINT16
+EFIAPI
+IoBitFieldRead16 (
+ IN UINTN Port,
+ IN UINTN StartBit,
+ IN UINTN EndBit
+ );
+
+/**
+ Writes a bit field to an I/O register.
+
+ Writes Value to the bit field of the I/O register. The bit field is specified
+ by the StartBit and the EndBit. All other bits in the destination I/O
+ register are preserved. The value written to the I/O port is returned. Extra
+ left bits in Value are stripped.
+
+ If 16-bit I/O port operations are not supported, then ASSERT().
+ If StartBit is greater than 15, then ASSERT().
+ If EndBit is greater than 15, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Port The I/O port to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..15.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..15.
+ @param Value New value of the bit field.
+
+ @return The value written back to the I/O port.
+
+**/
+UINT16
+EFIAPI
+IoBitFieldWrite16 (
+ IN UINTN Port,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT16 Value
+ );
+
+/**
+ Reads a bit field in a 16-bit port, performs a bitwise OR, and writes the
+ result back to the bit field in the 16-bit port.
+
+ Reads the 16-bit I/O port specified by Port, performs a bitwise inclusive OR
+ between the read result and the value specified by OrData, and writes the
+ result to the 16-bit I/O port specified by Port. The value written to the I/O
+ port is returned. This function must guarantee that all I/O read and write
+ operations are serialized. Extra left bits in OrData are stripped.
+
+ If 16-bit I/O port operations are not supported, then ASSERT().
+ If StartBit is greater than 15, then ASSERT().
+ If EndBit is greater than 15, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Port The I/O port to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..15.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..15.
+ @param OrData The value to OR with the read value from the I/O port.
+
+ @return The value written back to the I/O port.
+
+**/
+UINT16
+EFIAPI
+IoBitFieldOr16 (
+ IN UINTN Port,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT16 OrData
+ );
+
+/**
+ Reads a bit field in a 16-bit port, performs a bitwise AND, and writes the
+ result back to the bit field in the 16-bit port.
+
+ Reads the 16-bit I/O port specified by Port, performs a bitwise AND between
+ the read result and the value specified by AndData, and writes the result to
+ the 16-bit I/O port specified by Port. The value written to the I/O port is
+ returned. This function must guarantee that all I/O read and write operations
+ are serialized. Extra left bits in AndData are stripped.
+
+ If 16-bit I/O port operations are not supported, then ASSERT().
+ If StartBit is greater than 15, then ASSERT().
+ If EndBit is greater than 15, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Port The I/O port to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..15.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..15.
+ @param AndData The value to AND with the read value from the I/O port.
+
+ @return The value written back to the I/O port.
+
+**/
+UINT16
+EFIAPI
+IoBitFieldAnd16 (
+ IN UINTN Port,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT16 AndData
+ );
+
+/**
+ Reads a bit field in a 16-bit port, performs a bitwise AND followed by a
+ bitwise inclusive OR, and writes the result back to the bit field in the
+ 16-bit port.
+
+ Reads the 16-bit I/O port specified by Port, performs a bitwise AND followed
+ by a bitwise inclusive OR between the read result and the value specified by
+ AndData, and writes the result to the 16-bit I/O port specified by Port. The
+ value written to the I/O port is returned. This function must guarantee that
+ all I/O read and write operations are serialized. Extra left bits in both
+ AndData and OrData are stripped.
+
+ If 16-bit I/O port operations are not supported, then ASSERT().
+ If StartBit is greater than 15, then ASSERT().
+ If EndBit is greater than 15, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Port The I/O port to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..15.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..15.
+ @param AndData The value to AND with the read value from the I/O port.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the I/O port.
+
+**/
+UINT16
+EFIAPI
+IoBitFieldAndThenOr16 (
+ IN UINTN Port,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT16 AndData,
+ IN UINT16 OrData
+ );
+
+/**
+ Reads a 32-bit I/O port.
+
+ Reads the 32-bit I/O port specified by Port. The 32-bit read value is returned.
+ This function must guarantee that all I/O read and write operations are
+ serialized.
+
+ If 32-bit I/O port operations are not supported, then ASSERT().
+
+ @param Port The I/O port to read.
+
+ @return The value read.
+
+**/
+UINT32
+EFIAPI
+GlueIoRead32 (
+ IN UINTN Port
+ );
+
+/**
+ Writes a 32-bit I/O port.
+
+ Writes the 32-bit I/O port specified by Port with the value specified by Value
+ and returns Value. This function must guarantee that all I/O read and write
+ operations are serialized.
+
+ If 32-bit I/O port operations are not supported, then ASSERT().
+
+ @param Port The I/O port to write.
+ @param Value The value to write to the I/O port.
+
+ @return The value written the I/O port.
+
+**/
+UINT32
+EFIAPI
+GlueIoWrite32 (
+ IN UINTN Port,
+ IN UINT32 Value
+ );
+
+/**
+ Reads a 32-bit I/O port, performs a bitwise inclusive OR, and writes the
+ result back to the 32-bit I/O port.
+
+ Reads the 32-bit I/O port specified by Port, performs a bitwise inclusive OR
+ between the read result and the value specified by OrData, and writes the
+ result to the 32-bit I/O port specified by Port. The value written to the I/O
+ port is returned. This function must guarantee that all I/O read and write
+ operations are serialized.
+
+ If 32-bit I/O port operations are not supported, then ASSERT().
+
+ @param Port The I/O port to write.
+ @param OrData The value to OR with the read value from the I/O port.
+
+ @return The value written back to the I/O port.
+
+**/
+UINT32
+EFIAPI
+IoOr32 (
+ IN UINTN Port,
+ IN UINT32 OrData
+ );
+
+/**
+ Reads a 32-bit I/O port, performs a bitwise AND, and writes the result back
+ to the 32-bit I/O port.
+
+ Reads the 32-bit I/O port specified by Port, performs a bitwise AND between
+ the read result and the value specified by AndData, and writes the result to
+ the 32-bit I/O port specified by Port. The value written to the I/O port is
+ returned. This function must guarantee that all I/O read and write operations
+ are serialized.
+
+ If 32-bit I/O port operations are not supported, then ASSERT().
+
+ @param Port The I/O port to write.
+ @param AndData The value to AND with the read value from the I/O port.
+
+ @return The value written back to the I/O port.
+
+**/
+UINT32
+EFIAPI
+IoAnd32 (
+ IN UINTN Port,
+ IN UINT32 AndData
+ );
+
+/**
+ Reads a 32-bit I/O port, performs a bitwise AND followed by a bitwise
+ inclusive OR, and writes the result back to the 32-bit I/O port.
+
+ Reads the 32-bit I/O port specified by Port, performs a bitwise AND between
+ the read result and the value specified by AndData, performs a bitwise OR
+ between the result of the AND operation and the value specified by OrData,
+ and writes the result to the 32-bit I/O port specified by Port. The value
+ written to the I/O port is returned. This function must guarantee that all
+ I/O read and write operations are serialized.
+
+ If 32-bit I/O port operations are not supported, then ASSERT().
+
+ @param Port The I/O port to write.
+ @param AndData The value to AND with the read value from the I/O port.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the I/O port.
+
+**/
+UINT32
+EFIAPI
+IoAndThenOr32 (
+ IN UINTN Port,
+ IN UINT32 AndData,
+ IN UINT32 OrData
+ );
+
+/**
+ Reads a bit field of an I/O register.
+
+ Reads the bit field in a 32-bit I/O register. The bit field is specified by
+ the StartBit and the EndBit. The value of the bit field is returned.
+
+ If 32-bit I/O port operations are not supported, then ASSERT().
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Port The I/O port to read.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+
+ @return The value read.
+
+**/
+UINT32
+EFIAPI
+IoBitFieldRead32 (
+ IN UINTN Port,
+ IN UINTN StartBit,
+ IN UINTN EndBit
+ );
+
+/**
+ Writes a bit field to an I/O register.
+
+ Writes Value to the bit field of the I/O register. The bit field is specified
+ by the StartBit and the EndBit. All other bits in the destination I/O
+ register are preserved. The value written to the I/O port is returned. Extra
+ left bits in Value are stripped.
+
+ If 32-bit I/O port operations are not supported, then ASSERT().
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Port The I/O port to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+ @param Value New value of the bit field.
+
+ @return The value written back to the I/O port.
+
+**/
+UINT32
+EFIAPI
+IoBitFieldWrite32 (
+ IN UINTN Port,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT32 Value
+ );
+
+/**
+ Reads a bit field in a 32-bit port, performs a bitwise OR, and writes the
+ result back to the bit field in the 32-bit port.
+
+ Reads the 32-bit I/O port specified by Port, performs a bitwise inclusive OR
+ between the read result and the value specified by OrData, and writes the
+ result to the 32-bit I/O port specified by Port. The value written to the I/O
+ port is returned. This function must guarantee that all I/O read and write
+ operations are serialized. Extra left bits in OrData are stripped.
+
+ If 32-bit I/O port operations are not supported, then ASSERT().
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Port The I/O port to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+ @param OrData The value to OR with the read value from the I/O port.
+
+ @return The value written back to the I/O port.
+
+**/
+UINT32
+EFIAPI
+IoBitFieldOr32 (
+ IN UINTN Port,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT32 OrData
+ );
+
+/**
+ Reads a bit field in a 32-bit port, performs a bitwise AND, and writes the
+ result back to the bit field in the 32-bit port.
+
+ Reads the 32-bit I/O port specified by Port, performs a bitwise AND between
+ the read result and the value specified by AndData, and writes the result to
+ the 32-bit I/O port specified by Port. The value written to the I/O port is
+ returned. This function must guarantee that all I/O read and write operations
+ are serialized. Extra left bits in AndData are stripped.
+
+ If 32-bit I/O port operations are not supported, then ASSERT().
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Port The I/O port to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+ @param AndData The value to AND with the read value from the I/O port.
+
+ @return The value written back to the I/O port.
+
+**/
+UINT32
+EFIAPI
+IoBitFieldAnd32 (
+ IN UINTN Port,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT32 AndData
+ );
+
+/**
+ Reads a bit field in a 32-bit port, performs a bitwise AND followed by a
+ bitwise inclusive OR, and writes the result back to the bit field in the
+ 32-bit port.
+
+ Reads the 32-bit I/O port specified by Port, performs a bitwise AND followed
+ by a bitwise inclusive OR between the read result and the value specified by
+ AndData, and writes the result to the 32-bit I/O port specified by Port. The
+ value written to the I/O port is returned. This function must guarantee that
+ all I/O read and write operations are serialized. Extra left bits in both
+ AndData and OrData are stripped.
+
+ If 32-bit I/O port operations are not supported, then ASSERT().
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Port The I/O port to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+ @param AndData The value to AND with the read value from the I/O port.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the I/O port.
+
+**/
+UINT32
+EFIAPI
+IoBitFieldAndThenOr32 (
+ IN UINTN Port,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT32 AndData,
+ IN UINT32 OrData
+ );
+
+/**
+ Reads a 64-bit I/O port.
+
+ Reads the 64-bit I/O port specified by Port. The 64-bit read value is returned.
+ This function must guarantee that all I/O read and write operations are
+ serialized.
+
+ If 64-bit I/O port operations are not supported, then ASSERT().
+
+ @param Port The I/O port to read.
+
+ @return The value read.
+
+**/
+UINT64
+EFIAPI
+IoRead64 (
+ IN UINTN Port
+ );
+
+/**
+ Writes a 64-bit I/O port.
+
+ Writes the 64-bit I/O port specified by Port with the value specified by Value
+ and returns Value. This function must guarantee that all I/O read and write
+ operations are serialized.
+
+ If 64-bit I/O port operations are not supported, then ASSERT().
+
+ @param Port The I/O port to write.
+ @param Value The value to write to the I/O port.
+
+ @return The value written the I/O port.
+
+**/
+UINT64
+EFIAPI
+IoWrite64 (
+ IN UINTN Port,
+ IN UINT64 Value
+ );
+
+/**
+ Reads a 64-bit I/O port, performs a bitwise inclusive OR, and writes the
+ result back to the 64-bit I/O port.
+
+ Reads the 64-bit I/O port specified by Port, performs a bitwise inclusive OR
+ between the read result and the value specified by OrData, and writes the
+ result to the 64-bit I/O port specified by Port. The value written to the I/O
+ port is returned. This function must guarantee that all I/O read and write
+ operations are serialized.
+
+ If 64-bit I/O port operations are not supported, then ASSERT().
+
+ @param Port The I/O port to write.
+ @param OrData The value to OR with the read value from the I/O port.
+
+ @return The value written back to the I/O port.
+
+**/
+UINT64
+EFIAPI
+IoOr64 (
+ IN UINTN Port,
+ IN UINT64 OrData
+ );
+
+/**
+ Reads a 64-bit I/O port, performs a bitwise AND, and writes the result back
+ to the 64-bit I/O port.
+
+ Reads the 64-bit I/O port specified by Port, performs a bitwise AND between
+ the read result and the value specified by AndData, and writes the result to
+ the 64-bit I/O port specified by Port. The value written to the I/O port is
+ returned. This function must guarantee that all I/O read and write operations
+ are serialized.
+
+ If 64-bit I/O port operations are not supported, then ASSERT().
+
+ @param Port The I/O port to write.
+ @param AndData The value to AND with the read value from the I/O port.
+
+ @return The value written back to the I/O port.
+
+**/
+UINT64
+EFIAPI
+IoAnd64 (
+ IN UINTN Port,
+ IN UINT64 AndData
+ );
+
+/**
+ Reads a 64-bit I/O port, performs a bitwise AND followed by a bitwise
+ inclusive OR, and writes the result back to the 64-bit I/O port.
+
+ Reads the 64-bit I/O port specified by Port, performs a bitwise AND between
+ the read result and the value specified by AndData, performs a bitwise OR
+ between the result of the AND operation and the value specified by OrData,
+ and writes the result to the 64-bit I/O port specified by Port. The value
+ written to the I/O port is returned. This function must guarantee that all
+ I/O read and write operations are serialized.
+
+ If 64-bit I/O port operations are not supported, then ASSERT().
+
+ @param Port The I/O port to write.
+ @param AndData The value to AND with the read value from the I/O port.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the I/O port.
+
+**/
+UINT64
+EFIAPI
+IoAndThenOr64 (
+ IN UINTN Port,
+ IN UINT64 AndData,
+ IN UINT64 OrData
+ );
+
+/**
+ Reads a bit field of an I/O register.
+
+ Reads the bit field in a 64-bit I/O register. The bit field is specified by
+ the StartBit and the EndBit. The value of the bit field is returned.
+
+ If 64-bit I/O port operations are not supported, then ASSERT().
+ If StartBit is greater than 63, then ASSERT().
+ If EndBit is greater than 63, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Port The I/O port to read.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..63.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..63.
+
+ @return The value read.
+
+**/
+UINT64
+EFIAPI
+IoBitFieldRead64 (
+ IN UINTN Port,
+ IN UINTN StartBit,
+ IN UINTN EndBit
+ );
+
+/**
+ Writes a bit field to an I/O register.
+
+ Writes Value to the bit field of the I/O register. The bit field is specified
+ by the StartBit and the EndBit. All other bits in the destination I/O
+ register are preserved. The value written to the I/O port is returned. Extra
+ left bits in Value are stripped.
+
+ If 64-bit I/O port operations are not supported, then ASSERT().
+ If StartBit is greater than 63, then ASSERT().
+ If EndBit is greater than 63, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Port The I/O port to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..63.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..63.
+ @param Value New value of the bit field.
+
+ @return The value written back to the I/O port.
+
+**/
+UINT64
+EFIAPI
+IoBitFieldWrite64 (
+ IN UINTN Port,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT64 Value
+ );
+
+/**
+ Reads a bit field in a 64-bit port, performs a bitwise OR, and writes the
+ result back to the bit field in the 64-bit port.
+
+ Reads the 64-bit I/O port specified by Port, performs a bitwise inclusive OR
+ between the read result and the value specified by OrData, and writes the
+ result to the 64-bit I/O port specified by Port. The value written to the I/O
+ port is returned. This function must guarantee that all I/O read and write
+ operations are serialized. Extra left bits in OrData are stripped.
+
+ If 64-bit I/O port operations are not supported, then ASSERT().
+ If StartBit is greater than 63, then ASSERT().
+ If EndBit is greater than 63, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Port The I/O port to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..63.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..63.
+ @param OrData The value to OR with the read value from the I/O port.
+
+ @return The value written back to the I/O port.
+
+**/
+UINT64
+EFIAPI
+IoBitFieldOr64 (
+ IN UINTN Port,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT64 OrData
+ );
+
+/**
+ Reads a bit field in a 64-bit port, performs a bitwise AND, and writes the
+ result back to the bit field in the 64-bit port.
+
+ Reads the 64-bit I/O port specified by Port, performs a bitwise AND between
+ the read result and the value specified by AndData, and writes the result to
+ the 64-bit I/O port specified by Port. The value written to the I/O port is
+ returned. This function must guarantee that all I/O read and write operations
+ are serialized. Extra left bits in AndData are stripped.
+
+ If 64-bit I/O port operations are not supported, then ASSERT().
+ If StartBit is greater than 63, then ASSERT().
+ If EndBit is greater than 63, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Port The I/O port to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..63.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..63.
+ @param AndData The value to AND with the read value from the I/O port.
+
+ @return The value written back to the I/O port.
+
+**/
+UINT64
+EFIAPI
+IoBitFieldAnd64 (
+ IN UINTN Port,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT64 AndData
+ );
+
+/**
+ Reads a bit field in a 64-bit port, performs a bitwise AND followed by a
+ bitwise inclusive OR, and writes the result back to the bit field in the
+ 64-bit port.
+
+ Reads the 64-bit I/O port specified by Port, performs a bitwise AND followed
+ by a bitwise inclusive OR between the read result and the value specified by
+ AndData, and writes the result to the 64-bit I/O port specified by Port. The
+ value written to the I/O port is returned. This function must guarantee that
+ all I/O read and write operations are serialized. Extra left bits in both
+ AndData and OrData are stripped.
+
+ If 64-bit I/O port operations are not supported, then ASSERT().
+ If StartBit is greater than 63, then ASSERT().
+ If EndBit is greater than 63, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Port The I/O port to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..63.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..63.
+ @param AndData The value to AND with the read value from the I/O port.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the I/O port.
+
+**/
+UINT64
+EFIAPI
+IoBitFieldAndThenOr64 (
+ IN UINTN Port,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT64 AndData,
+ IN UINT64 OrData
+ );
+
+/**
+ Reads an 8-bit MMIO register.
+
+ Reads the 8-bit MMIO register specified by Address. The 8-bit read value is
+ returned. This function must guarantee that all MMIO read and write
+ operations are serialized.
+
+ If 8-bit MMIO register operations are not supported, then ASSERT().
+
+ @param Address The MMIO register to read.
+
+ @return The value read.
+
+**/
+UINT8
+EFIAPI
+MmioRead8 (
+ IN UINTN Address
+ );
+
+/**
+ Writes an 8-bit MMIO register.
+
+ Writes the 8-bit MMIO register specified by Address with the value specified
+ by Value and returns Value. This function must guarantee that all MMIO read
+ and write operations are serialized.
+
+ If 8-bit MMIO register operations are not supported, then ASSERT().
+
+ @param Address The MMIO register to write.
+ @param Value The value to write to the MMIO register.
+
+**/
+UINT8
+EFIAPI
+MmioWrite8 (
+ IN UINTN Address,
+ IN UINT8 Value
+ );
+
+/**
+ Reads an 8-bit MMIO register, performs a bitwise inclusive OR, and writes the
+ result back to the 8-bit MMIO register.
+
+ Reads the 8-bit MMIO register specified by Address, performs a bitwise
+ inclusive OR between the read result and the value specified by OrData, and
+ writes the result to the 8-bit MMIO register specified by Address. The value
+ written to the MMIO register is returned. This function must guarantee that
+ all MMIO read and write operations are serialized.
+
+ If 8-bit MMIO register operations are not supported, then ASSERT().
+
+ @param Address The MMIO register to write.
+ @param OrData The value to OR with the read value from the MMIO register.
+
+ @return The value written back to the MMIO register.
+
+**/
+UINT8
+EFIAPI
+MmioOr8 (
+ IN UINTN Address,
+ IN UINT8 OrData
+ );
+
+/**
+ Reads an 8-bit MMIO register, performs a bitwise AND, and writes the result
+ back to the 8-bit MMIO register.
+
+ Reads the 8-bit MMIO register specified by Address, performs a bitwise AND
+ between the read result and the value specified by AndData, and writes the
+ result to the 8-bit MMIO register specified by Address. The value written to
+ the MMIO register is returned. This function must guarantee that all MMIO
+ read and write operations are serialized.
+
+ If 8-bit MMIO register operations are not supported, then ASSERT().
+
+ @param Address The MMIO register to write.
+ @param AndData The value to AND with the read value from the MMIO register.
+
+ @return The value written back to the MMIO register.
+
+**/
+UINT8
+EFIAPI
+MmioAnd8 (
+ IN UINTN Address,
+ IN UINT8 AndData
+ );
+
+/**
+ Reads an 8-bit MMIO register, performs a bitwise AND followed by a bitwise
+ inclusive OR, and writes the result back to the 8-bit MMIO register.
+
+ Reads the 8-bit MMIO register specified by Address, performs a bitwise AND
+ between the read result and the value specified by AndData, performs a
+ bitwise OR between the result of the AND operation and the value specified by
+ OrData, and writes the result to the 8-bit MMIO register specified by
+ Address. The value written to the MMIO register is returned. This function
+ must guarantee that all MMIO read and write operations are serialized.
+
+ If 8-bit MMIO register operations are not supported, then ASSERT().
+
+
+ @param Address The MMIO register to write.
+ @param AndData The value to AND with the read value from the MMIO register.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the MMIO register.
+
+**/
+UINT8
+EFIAPI
+MmioAndThenOr8 (
+ IN UINTN Address,
+ IN UINT8 AndData,
+ IN UINT8 OrData
+ );
+
+/**
+ Reads a bit field of a MMIO register.
+
+ Reads the bit field in an 8-bit MMIO register. The bit field is specified by
+ the StartBit and the EndBit. The value of the bit field is returned.
+
+ If 8-bit MMIO register operations are not supported, then ASSERT().
+ If StartBit is greater than 7, then ASSERT().
+ If EndBit is greater than 7, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address MMIO register to read.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..7.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..7.
+
+ @return The value read.
+
+**/
+UINT8
+EFIAPI
+MmioBitFieldRead8 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit
+ );
+
+/**
+ Writes a bit field to a MMIO register.
+
+ Writes Value to the bit field of the MMIO register. The bit field is
+ specified by the StartBit and the EndBit. All other bits in the destination
+ MMIO register are preserved. The new value of the 8-bit register is returned.
+
+ If 8-bit MMIO register operations are not supported, then ASSERT().
+ If StartBit is greater than 7, then ASSERT().
+ If EndBit is greater than 7, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address MMIO register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..7.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..7.
+ @param Value New value of the bit field.
+
+ @return The value written back to the MMIO register.
+
+**/
+UINT8
+EFIAPI
+MmioBitFieldWrite8 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT8 Value
+ );
+
+/**
+ Reads a bit field in an 8-bit MMIO register, performs a bitwise OR, and
+ writes the result back to the bit field in the 8-bit MMIO register.
+
+ Reads the 8-bit MMIO register specified by Address, performs a bitwise
+ inclusive OR between the read result and the value specified by OrData, and
+ writes the result to the 8-bit MMIO register specified by Address. The value
+ written to the MMIO register is returned. This function must guarantee that
+ all MMIO read and write operations are serialized. Extra left bits in OrData
+ are stripped.
+
+ If 8-bit MMIO register operations are not supported, then ASSERT().
+ If StartBit is greater than 7, then ASSERT().
+ If EndBit is greater than 7, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address MMIO register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..7.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..7.
+ @param OrData The value to OR with read value from the MMIO register.
+
+ @return The value written back to the MMIO register.
+
+**/
+UINT8
+EFIAPI
+MmioBitFieldOr8 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT8 OrData
+ );
+
+/**
+ Reads a bit field in an 8-bit MMIO register, performs a bitwise AND, and
+ writes the result back to the bit field in the 8-bit MMIO register.
+
+ Reads the 8-bit MMIO register specified by Address, performs a bitwise AND
+ between the read result and the value specified by AndData, and writes the
+ result to the 8-bit MMIO register specified by Address. The value written to
+ the MMIO register is returned. This function must guarantee that all MMIO
+ read and write operations are serialized. Extra left bits in AndData are
+ stripped.
+
+ If 8-bit MMIO register operations are not supported, then ASSERT().
+ If StartBit is greater than 7, then ASSERT().
+ If EndBit is greater than 7, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address MMIO register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..7.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..7.
+ @param AndData The value to AND with read value from the MMIO register.
+
+ @return The value written back to the MMIO register.
+
+**/
+UINT8
+EFIAPI
+MmioBitFieldAnd8 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT8 AndData
+ );
+
+/**
+ Reads a bit field in an 8-bit MMIO register, performs a bitwise AND followed
+ by a bitwise inclusive OR, and writes the result back to the bit field in the
+ 8-bit MMIO register.
+
+ Reads the 8-bit MMIO register specified by Address, performs a bitwise AND
+ followed by a bitwise inclusive OR between the read result and the value
+ specified by AndData, and writes the result to the 8-bit MMIO register
+ specified by Address. The value written to the MMIO register is returned.
+ This function must guarantee that all MMIO read and write operations are
+ serialized. Extra left bits in both AndData and OrData are stripped.
+
+ If 8-bit MMIO register operations are not supported, then ASSERT().
+ If StartBit is greater than 7, then ASSERT().
+ If EndBit is greater than 7, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address MMIO register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..7.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..7.
+ @param AndData The value to AND with read value from the MMIO register.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the MMIO register.
+
+**/
+UINT8
+EFIAPI
+MmioBitFieldAndThenOr8 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT8 AndData,
+ IN UINT8 OrData
+ );
+
+/**
+ Reads a 16-bit MMIO register.
+
+ Reads the 16-bit MMIO register specified by Address. The 16-bit read value is
+ returned. This function must guarantee that all MMIO read and write
+ operations are serialized.
+
+ If 16-bit MMIO register operations are not supported, then ASSERT().
+
+ @param Address The MMIO register to read.
+
+ @return The value read.
+
+**/
+UINT16
+EFIAPI
+MmioRead16 (
+ IN UINTN Address
+ );
+
+/**
+ Writes a 16-bit MMIO register.
+
+ Writes the 16-bit MMIO register specified by Address with the value specified
+ by Value and returns Value. This function must guarantee that all MMIO read
+ and write operations are serialized.
+
+ If 16-bit MMIO register operations are not supported, then ASSERT().
+
+ @param Address The MMIO register to write.
+ @param Value The value to write to the MMIO register.
+
+**/
+UINT16
+EFIAPI
+MmioWrite16 (
+ IN UINTN Address,
+ IN UINT16 Value
+ );
+
+/**
+ Reads a 16-bit MMIO register, performs a bitwise inclusive OR, and writes the
+ result back to the 16-bit MMIO register.
+
+ Reads the 16-bit MMIO register specified by Address, performs a bitwise
+ inclusive OR between the read result and the value specified by OrData, and
+ writes the result to the 16-bit MMIO register specified by Address. The value
+ written to the MMIO register is returned. This function must guarantee that
+ all MMIO read and write operations are serialized.
+
+ If 16-bit MMIO register operations are not supported, then ASSERT().
+
+ @param Address The MMIO register to write.
+ @param OrData The value to OR with the read value from the MMIO register.
+
+ @return The value written back to the MMIO register.
+
+**/
+UINT16
+EFIAPI
+MmioOr16 (
+ IN UINTN Address,
+ IN UINT16 OrData
+ );
+
+/**
+ Reads a 16-bit MMIO register, performs a bitwise AND, and writes the result
+ back to the 16-bit MMIO register.
+
+ Reads the 16-bit MMIO register specified by Address, performs a bitwise AND
+ between the read result and the value specified by AndData, and writes the
+ result to the 16-bit MMIO register specified by Address. The value written to
+ the MMIO register is returned. This function must guarantee that all MMIO
+ read and write operations are serialized.
+
+ If 16-bit MMIO register operations are not supported, then ASSERT().
+
+ @param Address The MMIO register to write.
+ @param AndData The value to AND with the read value from the MMIO register.
+
+ @return The value written back to the MMIO register.
+
+**/
+UINT16
+EFIAPI
+MmioAnd16 (
+ IN UINTN Address,
+ IN UINT16 AndData
+ );
+
+/**
+ Reads a 16-bit MMIO register, performs a bitwise AND followed by a bitwise
+ inclusive OR, and writes the result back to the 16-bit MMIO register.
+
+ Reads the 16-bit MMIO register specified by Address, performs a bitwise AND
+ between the read result and the value specified by AndData, performs a
+ bitwise OR between the result of the AND operation and the value specified by
+ OrData, and writes the result to the 16-bit MMIO register specified by
+ Address. The value written to the MMIO register is returned. This function
+ must guarantee that all MMIO read and write operations are serialized.
+
+ If 16-bit MMIO register operations are not supported, then ASSERT().
+
+
+ @param Address The MMIO register to write.
+ @param AndData The value to AND with the read value from the MMIO register.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the MMIO register.
+
+**/
+UINT16
+EFIAPI
+MmioAndThenOr16 (
+ IN UINTN Address,
+ IN UINT16 AndData,
+ IN UINT16 OrData
+ );
+
+/**
+ Reads a bit field of a MMIO register.
+
+ Reads the bit field in a 16-bit MMIO register. The bit field is specified by
+ the StartBit and the EndBit. The value of the bit field is returned.
+
+ If 16-bit MMIO register operations are not supported, then ASSERT().
+ If StartBit is greater than 15, then ASSERT().
+ If EndBit is greater than 15, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address MMIO register to read.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..15.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..15.
+
+ @return The value read.
+
+**/
+UINT16
+EFIAPI
+MmioBitFieldRead16 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit
+ );
+
+/**
+ Writes a bit field to a MMIO register.
+
+ Writes Value to the bit field of the MMIO register. The bit field is
+ specified by the StartBit and the EndBit. All other bits in the destination
+ MMIO register are preserved. The new value of the 16-bit register is returned.
+
+ If 16-bit MMIO register operations are not supported, then ASSERT().
+ If StartBit is greater than 15, then ASSERT().
+ If EndBit is greater than 15, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address MMIO register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..15.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..15.
+ @param Value New value of the bit field.
+
+ @return The value written back to the MMIO register.
+
+**/
+UINT16
+EFIAPI
+MmioBitFieldWrite16 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT16 Value
+ );
+
+/**
+ Reads a bit field in a 16-bit MMIO register, performs a bitwise OR, and
+ writes the result back to the bit field in the 16-bit MMIO register.
+
+ Reads the 16-bit MMIO register specified by Address, performs a bitwise
+ inclusive OR between the read result and the value specified by OrData, and
+ writes the result to the 16-bit MMIO register specified by Address. The value
+ written to the MMIO register is returned. This function must guarantee that
+ all MMIO read and write operations are serialized. Extra left bits in OrData
+ are stripped.
+
+ If 16-bit MMIO register operations are not supported, then ASSERT().
+ If StartBit is greater than 15, then ASSERT().
+ If EndBit is greater than 15, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address MMIO register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..15.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..15.
+ @param OrData The value to OR with read value from the MMIO register.
+
+ @return The value written back to the MMIO register.
+
+**/
+UINT16
+EFIAPI
+MmioBitFieldOr16 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT16 OrData
+ );
+
+/**
+ Reads a bit field in a 16-bit MMIO register, performs a bitwise AND, and
+ writes the result back to the bit field in the 16-bit MMIO register.
+
+ Reads the 16-bit MMIO register specified by Address, performs a bitwise AND
+ between the read result and the value specified by AndData, and writes the
+ result to the 16-bit MMIO register specified by Address. The value written to
+ the MMIO register is returned. This function must guarantee that all MMIO
+ read and write operations are serialized. Extra left bits in AndData are
+ stripped.
+
+ If 16-bit MMIO register operations are not supported, then ASSERT().
+ If StartBit is greater than 15, then ASSERT().
+ If EndBit is greater than 15, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address MMIO register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..15.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..15.
+ @param AndData The value to AND with read value from the MMIO register.
+
+ @return The value written back to the MMIO register.
+
+**/
+UINT16
+EFIAPI
+MmioBitFieldAnd16 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT16 AndData
+ );
+
+/**
+ Reads a bit field in a 16-bit MMIO register, performs a bitwise AND followed
+ by a bitwise inclusive OR, and writes the result back to the bit field in the
+ 16-bit MMIO register.
+
+ Reads the 16-bit MMIO register specified by Address, performs a bitwise AND
+ followed by a bitwise inclusive OR between the read result and the value
+ specified by AndData, and writes the result to the 16-bit MMIO register
+ specified by Address. The value written to the MMIO register is returned.
+ This function must guarantee that all MMIO read and write operations are
+ serialized. Extra left bits in both AndData and OrData are stripped.
+
+ If 16-bit MMIO register operations are not supported, then ASSERT().
+ If StartBit is greater than 15, then ASSERT().
+ If EndBit is greater than 15, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address MMIO register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..15.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..15.
+ @param AndData The value to AND with read value from the MMIO register.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the MMIO register.
+
+**/
+UINT16
+EFIAPI
+MmioBitFieldAndThenOr16 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT16 AndData,
+ IN UINT16 OrData
+ );
+
+/**
+ Reads a 32-bit MMIO register.
+
+ Reads the 32-bit MMIO register specified by Address. The 32-bit read value is
+ returned. This function must guarantee that all MMIO read and write
+ operations are serialized.
+
+ If 32-bit MMIO register operations are not supported, then ASSERT().
+
+ @param Address The MMIO register to read.
+
+ @return The value read.
+
+**/
+UINT32
+EFIAPI
+MmioRead32 (
+ IN UINTN Address
+ );
+
+/**
+ Writes a 32-bit MMIO register.
+
+ Writes the 32-bit MMIO register specified by Address with the value specified
+ by Value and returns Value. This function must guarantee that all MMIO read
+ and write operations are serialized.
+
+ If 32-bit MMIO register operations are not supported, then ASSERT().
+
+ @param Address The MMIO register to write.
+ @param Value The value to write to the MMIO register.
+
+**/
+UINT32
+EFIAPI
+MmioWrite32 (
+ IN UINTN Address,
+ IN UINT32 Value
+ );
+
+/**
+ Reads a 32-bit MMIO register, performs a bitwise inclusive OR, and writes the
+ result back to the 32-bit MMIO register.
+
+ Reads the 32-bit MMIO register specified by Address, performs a bitwise
+ inclusive OR between the read result and the value specified by OrData, and
+ writes the result to the 32-bit MMIO register specified by Address. The value
+ written to the MMIO register is returned. This function must guarantee that
+ all MMIO read and write operations are serialized.
+
+ If 32-bit MMIO register operations are not supported, then ASSERT().
+
+ @param Address The MMIO register to write.
+ @param OrData The value to OR with the read value from the MMIO register.
+
+ @return The value written back to the MMIO register.
+
+**/
+UINT32
+EFIAPI
+MmioOr32 (
+ IN UINTN Address,
+ IN UINT32 OrData
+ );
+
+/**
+ Reads a 32-bit MMIO register, performs a bitwise AND, and writes the result
+ back to the 32-bit MMIO register.
+
+ Reads the 32-bit MMIO register specified by Address, performs a bitwise AND
+ between the read result and the value specified by AndData, and writes the
+ result to the 32-bit MMIO register specified by Address. The value written to
+ the MMIO register is returned. This function must guarantee that all MMIO
+ read and write operations are serialized.
+
+ If 32-bit MMIO register operations are not supported, then ASSERT().
+
+ @param Address The MMIO register to write.
+ @param AndData The value to AND with the read value from the MMIO register.
+
+ @return The value written back to the MMIO register.
+
+**/
+UINT32
+EFIAPI
+MmioAnd32 (
+ IN UINTN Address,
+ IN UINT32 AndData
+ );
+
+/**
+ Reads a 32-bit MMIO register, performs a bitwise AND followed by a bitwise
+ inclusive OR, and writes the result back to the 32-bit MMIO register.
+
+ Reads the 32-bit MMIO register specified by Address, performs a bitwise AND
+ between the read result and the value specified by AndData, performs a
+ bitwise OR between the result of the AND operation and the value specified by
+ OrData, and writes the result to the 32-bit MMIO register specified by
+ Address. The value written to the MMIO register is returned. This function
+ must guarantee that all MMIO read and write operations are serialized.
+
+ If 32-bit MMIO register operations are not supported, then ASSERT().
+
+
+ @param Address The MMIO register to write.
+ @param AndData The value to AND with the read value from the MMIO register.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the MMIO register.
+
+**/
+UINT32
+EFIAPI
+MmioAndThenOr32 (
+ IN UINTN Address,
+ IN UINT32 AndData,
+ IN UINT32 OrData
+ );
+
+/**
+ Reads a bit field of a MMIO register.
+
+ Reads the bit field in a 32-bit MMIO register. The bit field is specified by
+ the StartBit and the EndBit. The value of the bit field is returned.
+
+ If 32-bit MMIO register operations are not supported, then ASSERT().
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address MMIO register to read.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+
+ @return The value read.
+
+**/
+UINT32
+EFIAPI
+MmioBitFieldRead32 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit
+ );
+
+/**
+ Writes a bit field to a MMIO register.
+
+ Writes Value to the bit field of the MMIO register. The bit field is
+ specified by the StartBit and the EndBit. All other bits in the destination
+ MMIO register are preserved. The new value of the 32-bit register is returned.
+
+ If 32-bit MMIO register operations are not supported, then ASSERT().
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address MMIO register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+ @param Value New value of the bit field.
+
+ @return The value written back to the MMIO register.
+
+**/
+UINT32
+EFIAPI
+MmioBitFieldWrite32 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT32 Value
+ );
+
+/**
+ Reads a bit field in a 32-bit MMIO register, performs a bitwise OR, and
+ writes the result back to the bit field in the 32-bit MMIO register.
+
+ Reads the 32-bit MMIO register specified by Address, performs a bitwise
+ inclusive OR between the read result and the value specified by OrData, and
+ writes the result to the 32-bit MMIO register specified by Address. The value
+ written to the MMIO register is returned. This function must guarantee that
+ all MMIO read and write operations are serialized. Extra left bits in OrData
+ are stripped.
+
+ If 32-bit MMIO register operations are not supported, then ASSERT().
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address MMIO register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+ @param OrData The value to OR with read value from the MMIO register.
+
+ @return The value written back to the MMIO register.
+
+**/
+UINT32
+EFIAPI
+MmioBitFieldOr32 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT32 OrData
+ );
+
+/**
+ Reads a bit field in a 32-bit MMIO register, performs a bitwise AND, and
+ writes the result back to the bit field in the 32-bit MMIO register.
+
+ Reads the 32-bit MMIO register specified by Address, performs a bitwise AND
+ between the read result and the value specified by AndData, and writes the
+ result to the 32-bit MMIO register specified by Address. The value written to
+ the MMIO register is returned. This function must guarantee that all MMIO
+ read and write operations are serialized. Extra left bits in AndData are
+ stripped.
+
+ If 32-bit MMIO register operations are not supported, then ASSERT().
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address MMIO register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+ @param AndData The value to AND with read value from the MMIO register.
+
+ @return The value written back to the MMIO register.
+
+**/
+UINT32
+EFIAPI
+MmioBitFieldAnd32 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT32 AndData
+ );
+
+/**
+ Reads a bit field in a 32-bit MMIO register, performs a bitwise AND followed
+ by a bitwise inclusive OR, and writes the result back to the bit field in the
+ 32-bit MMIO register.
+
+ Reads the 32-bit MMIO register specified by Address, performs a bitwise AND
+ followed by a bitwise inclusive OR between the read result and the value
+ specified by AndData, and writes the result to the 32-bit MMIO register
+ specified by Address. The value written to the MMIO register is returned.
+ This function must guarantee that all MMIO read and write operations are
+ serialized. Extra left bits in both AndData and OrData are stripped.
+
+ If 32-bit MMIO register operations are not supported, then ASSERT().
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address MMIO register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+ @param AndData The value to AND with read value from the MMIO register.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the MMIO register.
+
+**/
+UINT32
+EFIAPI
+MmioBitFieldAndThenOr32 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT32 AndData,
+ IN UINT32 OrData
+ );
+
+/**
+ Reads a 64-bit MMIO register.
+
+ Reads the 64-bit MMIO register specified by Address. The 64-bit read value is
+ returned. This function must guarantee that all MMIO read and write
+ operations are serialized.
+
+ If 64-bit MMIO register operations are not supported, then ASSERT().
+
+ @param Address The MMIO register to read.
+
+ @return The value read.
+
+**/
+UINT64
+EFIAPI
+MmioRead64 (
+ IN UINTN Address
+ );
+
+/**
+ Writes a 64-bit MMIO register.
+
+ Writes the 64-bit MMIO register specified by Address with the value specified
+ by Value and returns Value. This function must guarantee that all MMIO read
+ and write operations are serialized.
+
+ If 64-bit MMIO register operations are not supported, then ASSERT().
+
+ @param Address The MMIO register to write.
+ @param Value The value to write to the MMIO register.
+
+**/
+UINT64
+EFIAPI
+MmioWrite64 (
+ IN UINTN Address,
+ IN UINT64 Value
+ );
+
+/**
+ Reads a 64-bit MMIO register, performs a bitwise inclusive OR, and writes the
+ result back to the 64-bit MMIO register.
+
+ Reads the 64-bit MMIO register specified by Address, performs a bitwise
+ inclusive OR between the read result and the value specified by OrData, and
+ writes the result to the 64-bit MMIO register specified by Address. The value
+ written to the MMIO register is returned. This function must guarantee that
+ all MMIO read and write operations are serialized.
+
+ If 64-bit MMIO register operations are not supported, then ASSERT().
+
+ @param Address The MMIO register to write.
+ @param OrData The value to OR with the read value from the MMIO register.
+
+ @return The value written back to the MMIO register.
+
+**/
+UINT64
+EFIAPI
+MmioOr64 (
+ IN UINTN Address,
+ IN UINT64 OrData
+ );
+
+/**
+ Reads a 64-bit MMIO register, performs a bitwise AND, and writes the result
+ back to the 64-bit MMIO register.
+
+ Reads the 64-bit MMIO register specified by Address, performs a bitwise AND
+ between the read result and the value specified by AndData, and writes the
+ result to the 64-bit MMIO register specified by Address. The value written to
+ the MMIO register is returned. This function must guarantee that all MMIO
+ read and write operations are serialized.
+
+ If 64-bit MMIO register operations are not supported, then ASSERT().
+
+ @param Address The MMIO register to write.
+ @param AndData The value to AND with the read value from the MMIO register.
+
+ @return The value written back to the MMIO register.
+
+**/
+UINT64
+EFIAPI
+MmioAnd64 (
+ IN UINTN Address,
+ IN UINT64 AndData
+ );
+
+/**
+ Reads a 64-bit MMIO register, performs a bitwise AND followed by a bitwise
+ inclusive OR, and writes the result back to the 64-bit MMIO register.
+
+ Reads the 64-bit MMIO register specified by Address, performs a bitwise AND
+ between the read result and the value specified by AndData, performs a
+ bitwise OR between the result of the AND operation and the value specified by
+ OrData, and writes the result to the 64-bit MMIO register specified by
+ Address. The value written to the MMIO register is returned. This function
+ must guarantee that all MMIO read and write operations are serialized.
+
+ If 64-bit MMIO register operations are not supported, then ASSERT().
+
+
+ @param Address The MMIO register to write.
+ @param AndData The value to AND with the read value from the MMIO register.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the MMIO register.
+
+**/
+UINT64
+EFIAPI
+MmioAndThenOr64 (
+ IN UINTN Address,
+ IN UINT64 AndData,
+ IN UINT64 OrData
+ );
+
+/**
+ Reads a bit field of a MMIO register.
+
+ Reads the bit field in a 64-bit MMIO register. The bit field is specified by
+ the StartBit and the EndBit. The value of the bit field is returned.
+
+ If 64-bit MMIO register operations are not supported, then ASSERT().
+ If StartBit is greater than 63, then ASSERT().
+ If EndBit is greater than 63, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address MMIO register to read.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..63.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..63.
+
+ @return The value read.
+
+**/
+UINT64
+EFIAPI
+MmioBitFieldRead64 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit
+ );
+
+/**
+ Writes a bit field to a MMIO register.
+
+ Writes Value to the bit field of the MMIO register. The bit field is
+ specified by the StartBit and the EndBit. All other bits in the destination
+ MMIO register are preserved. The new value of the 64-bit register is returned.
+
+ If 64-bit MMIO register operations are not supported, then ASSERT().
+ If StartBit is greater than 63, then ASSERT().
+ If EndBit is greater than 63, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address MMIO register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..63.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..63.
+ @param Value New value of the bit field.
+
+ @return The value written back to the MMIO register.
+
+**/
+UINT64
+EFIAPI
+MmioBitFieldWrite64 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT64 Value
+ );
+
+/**
+ Reads a bit field in a 64-bit MMIO register, performs a bitwise OR, and
+ writes the result back to the bit field in the 64-bit MMIO register.
+
+ Reads the 64-bit MMIO register specified by Address, performs a bitwise
+ inclusive OR between the read result and the value specified by OrData, and
+ writes the result to the 64-bit MMIO register specified by Address. The value
+ written to the MMIO register is returned. This function must guarantee that
+ all MMIO read and write operations are serialized. Extra left bits in OrData
+ are stripped.
+
+ If 64-bit MMIO register operations are not supported, then ASSERT().
+ If StartBit is greater than 63, then ASSERT().
+ If EndBit is greater than 63, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address MMIO register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..63.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..63.
+ @param OrData The value to OR with read value from the MMIO register.
+
+ @return The value written back to the MMIO register.
+
+**/
+UINT64
+EFIAPI
+MmioBitFieldOr64 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT64 OrData
+ );
+
+/**
+ Reads a bit field in a 64-bit MMIO register, performs a bitwise AND, and
+ writes the result back to the bit field in the 64-bit MMIO register.
+
+ Reads the 64-bit MMIO register specified by Address, performs a bitwise AND
+ between the read result and the value specified by AndData, and writes the
+ result to the 64-bit MMIO register specified by Address. The value written to
+ the MMIO register is returned. This function must guarantee that all MMIO
+ read and write operations are serialized. Extra left bits in AndData are
+ stripped.
+
+ If 64-bit MMIO register operations are not supported, then ASSERT().
+ If StartBit is greater than 63, then ASSERT().
+ If EndBit is greater than 63, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address MMIO register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..63.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..63.
+ @param AndData The value to AND with read value from the MMIO register.
+
+ @return The value written back to the MMIO register.
+
+**/
+UINT64
+EFIAPI
+MmioBitFieldAnd64 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT64 AndData
+ );
+
+/**
+ Reads a bit field in a 64-bit MMIO register, performs a bitwise AND followed
+ by a bitwise inclusive OR, and writes the result back to the bit field in the
+ 64-bit MMIO register.
+
+ Reads the 64-bit MMIO register specified by Address, performs a bitwise AND
+ followed by a bitwise inclusive OR between the read result and the value
+ specified by AndData, and writes the result to the 64-bit MMIO register
+ specified by Address. The value written to the MMIO register is returned.
+ This function must guarantee that all MMIO read and write operations are
+ serialized. Extra left bits in both AndData and OrData are stripped.
+
+ If 64-bit MMIO register operations are not supported, then ASSERT().
+ If StartBit is greater than 63, then ASSERT().
+ If EndBit is greater than 63, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address MMIO register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..63.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..63.
+ @param AndData The value to AND with read value from the MMIO register.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the MMIO register.
+
+**/
+UINT64
+EFIAPI
+MmioBitFieldAndThenOr64 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT64 AndData,
+ IN UINT64 OrData
+ );
+
+#endif
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueMemoryAllocationLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueMemoryAllocationLib.h
new file mode 100644
index 0000000..395ee4a
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueMemoryAllocationLib.h
@@ -0,0 +1,637 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ EdkIIGlueMemoryAllocationLib.h
+
+Abstract:
+
+ Public header file for Memory Allocation Lib
+
+--*/
+
+#ifndef __EDKII_GLUE_MEMORY_ALLOCATION_LIB_H__
+#define __EDKII_GLUE_MEMORY_ALLOCATION_LIB_H__
+
+
+#define AllocatePages(_PAGES) GlueAllocatePages(_PAGES)
+#define FreePages(_BUFFER, _PAGES) GlueFreePages(_BUFFER, _PAGES)
+#define AllocatePool(_SIZE) GlueAllocatePool(_SIZE)
+#define AllocateZeroPool(_ALLOCATIONSIZE) GlueAllocateZeroPool(_ALLOCATIONSIZE)
+#define AllocateCopyPool(_ALLOCATIONSIZE, _BUFFER) GlueAllocateCopyPool(_ALLOCATIONSIZE, _BUFFER)
+#define FreePool(_BUFFER) GlueFreePool(_BUFFER)
+
+
+/**
+ Allocates one or more 4KB pages of type EfiBootServicesData.
+
+ Allocates the number of 4KB pages of type EfiBootServicesData and returns a pointer to the
+ allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL
+ is returned. If there is not enough memory remaining to satisfy the request, then NULL is
+ returned.
+
+ @param Pages The number of 4 KB pages to allocate.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+GlueAllocatePages (
+ IN UINTN Pages
+ );
+
+/**
+ Allocates one or more 4KB pages of type EfiRuntimeServicesData.
+
+ Allocates the number of 4KB pages of type EfiRuntimeServicesData and returns a pointer to the
+ allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL
+ is returned. If there is not enough memory remaining to satisfy the request, then NULL is
+ returned.
+
+ @param Pages The number of 4 KB pages to allocate.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateRuntimePages (
+ IN UINTN Pages
+ );
+
+/**
+ Allocates one or more 4KB pages of type EfiReservedMemoryType.
+
+ Allocates the number of 4KB pages of type EfiReservedMemoryType and returns a pointer to the
+ allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL
+ is returned. If there is not enough memory remaining to satisfy the request, then NULL is
+ returned.
+
+ @param Pages The number of 4 KB pages to allocate.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateReservedPages (
+ IN UINTN Pages
+ );
+
+/**
+ Frees one or more 4KB pages that were previously allocated with one of the page allocation
+ functions in the Memory Allocation Library.
+
+ Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer. Buffer
+ must have been allocated on a previous call to the page allocation services of the Memory
+ Allocation Library.
+ If Buffer was not allocated with a page allocation function in the Memory Allocation Library,
+ then ASSERT().
+ If Pages is zero, then ASSERT().
+
+ @param Buffer Pointer to the buffer of pages to free.
+ @param Pages The number of 4 KB pages to free.
+
+**/
+VOID
+EFIAPI
+GlueFreePages (
+ IN VOID *Buffer,
+ IN UINTN Pages
+ );
+
+/**
+ Allocates one or more 4KB pages of type EfiBootServicesData at a specified alignment.
+
+ Allocates the number of 4KB pages specified by Pages of type EfiBootServicesData with an
+ alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is
+ returned. If there is not enough memory at the specified alignment remaining to satisfy the
+ request, then NULL is returned.
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().
+
+ @param Pages The number of 4 KB pages to allocate.
+ @param Alignment The requested alignment of the allocation. Must be a power of two.
+ If Alignment is zero, then byte alignment is used.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateAlignedPages (
+ IN UINTN Pages,
+ IN UINTN Alignment
+ );
+
+/**
+ Allocates one or more 4KB pages of type EfiRuntimeServicesData at a specified alignment.
+
+ Allocates the number of 4KB pages specified by Pages of type EfiRuntimeServicesData with an
+ alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is
+ returned. If there is not enough memory at the specified alignment remaining to satisfy the
+ request, then NULL is returned.
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().
+
+ @param Pages The number of 4 KB pages to allocate.
+ @param Alignment The requested alignment of the allocation. Must be a power of two.
+ If Alignment is zero, then byte alignment is used.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateAlignedRuntimePages (
+ IN UINTN Pages,
+ IN UINTN Alignment
+ );
+
+/**
+ Allocates one or more 4KB pages of type EfiReservedMemoryType at a specified alignment.
+
+ Allocates the number of 4KB pages specified by Pages of type EfiReservedMemoryType with an
+ alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is
+ returned. If there is not enough memory at the specified alignment remaining to satisfy the
+ request, then NULL is returned.
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().
+
+ @param Pages The number of 4 KB pages to allocate.
+ @param Alignment The requested alignment of the allocation. Must be a power of two.
+ If Alignment is zero, then byte alignment is used.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateAlignedReservedPages (
+ IN UINTN Pages,
+ IN UINTN Alignment
+ );
+
+/**
+ Frees one or more 4KB pages that were previously allocated with one of the aligned page
+ allocation functions in the Memory Allocation Library.
+
+ Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer. Buffer
+ must have been allocated on a previous call to the aligned page allocation services of the Memory
+ Allocation Library.
+ If Buffer was not allocated with an aligned page allocation function in the Memory Allocation
+ Library, then ASSERT().
+ If Pages is zero, then ASSERT().
+
+ @param Buffer Pointer to the buffer of pages to free.
+ @param Pages The number of 4 KB pages to free.
+
+**/
+VOID
+EFIAPI
+FreeAlignedPages (
+ IN VOID *Buffer,
+ IN UINTN Pages
+ );
+
+/**
+ Allocates a buffer of type EfiBootServicesData.
+
+ Allocates the number bytes specified by AllocationSize of type EfiBootServicesData and returns a
+ pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is
+ returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.
+
+ @param AllocationSize The number of bytes to allocate.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+GlueAllocatePool (
+ IN UINTN AllocationSize
+ );
+
+/**
+ Allocates a buffer of type EfiRuntimeServicesData.
+
+ Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData and returns
+ a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is
+ returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.
+
+ @param AllocationSize The number of bytes to allocate.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateRuntimePool (
+ IN UINTN AllocationSize
+ );
+
+/**
+ Allocates a buffer of type EfieservedMemoryType.
+
+ Allocates the number bytes specified by AllocationSize of type EfieservedMemoryType and returns
+ a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is
+ returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.
+
+ @param AllocationSize The number of bytes to allocate.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateReservedPool (
+ IN UINTN AllocationSize
+ );
+
+/**
+ Allocates and zeros a buffer of type EfiBootServicesData.
+
+ Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, clears the
+ buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a
+ valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the
+ request, then NULL is returned.
+
+ @param AllocationSize The number of bytes to allocate and zero.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+GlueAllocateZeroPool (
+ IN UINTN AllocationSize
+ );
+
+/**
+ Allocates and zeros a buffer of type EfiRuntimeServicesData.
+
+ Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, clears the
+ buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a
+ valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the
+ request, then NULL is returned.
+
+ @param AllocationSize The number of bytes to allocate and zero.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateRuntimeZeroPool (
+ IN UINTN AllocationSize
+ );
+
+/**
+ Allocates and zeros a buffer of type EfiReservedMemoryType.
+
+ Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, clears the
+ buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a
+ valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the
+ request, then NULL is returned.
+
+ @param AllocationSize The number of bytes to allocate and zero.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateReservedZeroPool (
+ IN UINTN AllocationSize
+ );
+
+/**
+ Copies a buffer to an allocated buffer of type EfiBootServicesData.
+
+ Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, copies
+ AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
+ allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
+ is not enough memory remaining to satisfy the request, then NULL is returned.
+ If Buffer is NULL, then ASSERT().
+ If AllocationSize is greater than (MAX_ADDRESS ?Buffer + 1), then ASSERT().
+
+ @param AllocationSize The number of bytes to allocate and zero.
+ @param Buffer The buffer to copy to the allocated buffer.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+GlueAllocateCopyPool (
+ IN UINTN AllocationSize,
+ IN CONST VOID *Buffer
+ );
+
+/**
+ Copies a buffer to an allocated buffer of type EfiRuntimeServicesData.
+
+ Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, copies
+ AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
+ allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
+ is not enough memory remaining to satisfy the request, then NULL is returned.
+ If Buffer is NULL, then ASSERT().
+ If AllocationSize is greater than (MAX_ADDRESS ?Buffer + 1), then ASSERT().
+
+ @param AllocationSize The number of bytes to allocate and zero.
+ @param Buffer The buffer to copy to the allocated buffer.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateRuntimeCopyPool (
+ IN UINTN AllocationSize,
+ IN CONST VOID *Buffer
+ );
+
+/**
+ Copies a buffer to an allocated buffer of type EfiReservedMemoryType.
+
+ Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, copies
+ AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
+ allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
+ is not enough memory remaining to satisfy the request, then NULL is returned.
+ If Buffer is NULL, then ASSERT().
+ If AllocationSize is greater than (MAX_ADDRESS ?Buffer + 1), then ASSERT().
+
+ @param AllocationSize The number of bytes to allocate and zero.
+ @param Buffer The buffer to copy to the allocated buffer.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateReservedCopyPool (
+ IN UINTN AllocationSize,
+ IN CONST VOID *Buffer
+ );
+
+/**
+ Frees a buffer that was previously allocated with one of the pool allocation functions in the
+ Memory Allocation Library.
+
+ Frees the buffer specified by Buffer. Buffer must have been allocated on a previous call to the
+ pool allocation services of the Memory Allocation Library.
+ If Buffer was not allocated with a pool allocation function in the Memory Allocation Library,
+ then ASSERT().
+
+ @param Buffer Pointer to the buffer to free.
+
+**/
+VOID
+EFIAPI
+GlueFreePool (
+ IN VOID *Buffer
+ );
+
+/**
+ Allocates a buffer of type EfiBootServicesData at a specified alignment.
+
+ Allocates the number bytes specified by AllocationSize of type EfiBootServicesData with an
+ alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0,
+ then a valid buffer of 0 size is returned. If there is not enough memory at the specified
+ alignment remaining to satisfy the request, then NULL is returned.
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().
+
+ @param AllocationSize The number of bytes to allocate.
+ @param Alignment The requested alignment of the allocation. Must be a power of two.
+ If Alignment is zero, then byte alignment is used.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateAlignedPool (
+ IN UINTN AllocationSize,
+ IN UINTN Alignment
+ );
+
+/**
+ Allocates a buffer of type EfiRuntimeServicesData at a specified alignment.
+
+ Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData with an
+ alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0,
+ then a valid buffer of 0 size is returned. If there is not enough memory at the specified
+ alignment remaining to satisfy the request, then NULL is returned.
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().
+
+ @param AllocationSize The number of bytes to allocate.
+ @param Alignment The requested alignment of the allocation. Must be a power of two.
+ If Alignment is zero, then byte alignment is used.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateAlignedRuntimePool (
+ IN UINTN AllocationSize,
+ IN UINTN Alignment
+ );
+
+/**
+ Allocates a buffer of type EfieservedMemoryType at a specified alignment.
+
+ Allocates the number bytes specified by AllocationSize of type EfieservedMemoryType with an
+ alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0,
+ then a valid buffer of 0 size is returned. If there is not enough memory at the specified
+ alignment remaining to satisfy the request, then NULL is returned.
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().
+
+ @param AllocationSize The number of bytes to allocate.
+ @param Alignment The requested alignment of the allocation. Must be a power of two.
+ If Alignment is zero, then byte alignment is used.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateAlignedReservedPool (
+ IN UINTN AllocationSize,
+ IN UINTN Alignment
+ );
+
+/**
+ Allocates and zeros a buffer of type EfiBootServicesData at a specified alignment.
+
+ Allocates the number bytes specified by AllocationSize of type EfiBootServicesData with an
+ alignment specified by Alignment, clears the buffer with zeros, and returns a pointer to the
+ allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
+ is not enough memory at the specified alignment remaining to satisfy the request, then NULL is
+ returned.
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().
+
+ @param AllocationSize The number of bytes to allocate.
+ @param Alignment The requested alignment of the allocation. Must be a power of two.
+ If Alignment is zero, then byte alignment is used.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateAlignedZeroPool (
+ IN UINTN AllocationSize,
+ IN UINTN Alignment
+ );
+
+/**
+ Allocates and zeros a buffer of type EfiRuntimeServicesData at a specified alignment.
+
+ Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData with an
+ alignment specified by Alignment, clears the buffer with zeros, and returns a pointer to the
+ allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
+ is not enough memory at the specified alignment remaining to satisfy the request, then NULL is
+ returned.
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().
+
+ @param AllocationSize The number of bytes to allocate.
+ @param Alignment The requested alignment of the allocation. Must be a power of two.
+ If Alignment is zero, then byte alignment is used.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateAlignedRuntimeZeroPool (
+ IN UINTN AllocationSize,
+ IN UINTN Alignment
+ );
+
+/**
+ Allocates and zeros a buffer of type EfieservedMemoryType at a specified alignment.
+
+ Allocates the number bytes specified by AllocationSize of type EfieservedMemoryType with an
+ alignment specified by Alignment, clears the buffer with zeros, and returns a pointer to the
+ allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
+ is not enough memory at the specified alignment remaining to satisfy the request, then NULL is
+ returned.
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().
+
+ @param AllocationSize The number of bytes to allocate.
+ @param Alignment The requested alignment of the allocation. Must be a power of two.
+ If Alignment is zero, then byte alignment is used.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateAlignedReservedZeroPool (
+ IN UINTN AllocationSize,
+ IN UINTN Alignment
+ );
+
+/**
+ Copies a buffer to an allocated buffer of type EfiBootServicesData at a specified alignment.
+
+ Allocates the number bytes specified by AllocationSize of type EfiBootServicesData type with an
+ alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0,
+ then a valid buffer of 0 size is returned. If there is not enough memory at the specified
+ alignment remaining to satisfy the request, then NULL is returned.
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().
+
+ @param AllocationSize The number of bytes to allocate.
+ @param Buffer The buffer to copy to the allocated buffer.
+ @param Alignment The requested alignment of the allocation. Must be a power of two.
+ If Alignment is zero, then byte alignment is used.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateAlignedCopyPool (
+ IN UINTN AllocationSize,
+ IN CONST VOID *Buffer,
+ IN UINTN Alignment
+ );
+
+/**
+ Copies a buffer to an allocated buffer of type EfiRuntimeServicesData at a specified alignment.
+
+ Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData type with an
+ alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0,
+ then a valid buffer of 0 size is returned. If there is not enough memory at the specified
+ alignment remaining to satisfy the request, then NULL is returned.
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().
+
+ @param AllocationSize The number of bytes to allocate.
+ @param Buffer The buffer to copy to the allocated buffer.
+ @param Alignment The requested alignment of the allocation. Must be a power of two.
+ If Alignment is zero, then byte alignment is used.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateAlignedRuntimeCopyPool (
+ IN UINTN AllocationSize,
+ IN CONST VOID *Buffer,
+ IN UINTN Alignment
+ );
+
+/**
+ Copies a buffer to an allocated buffer of type EfiReservedMemoryType at a specified alignment.
+
+ Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType type with an
+ alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0,
+ then a valid buffer of 0 size is returned. If there is not enough memory at the specified
+ alignment remaining to satisfy the request, then NULL is returned.
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().
+
+ @param AllocationSize The number of bytes to allocate.
+ @param Buffer The buffer to copy to the allocated buffer.
+ @param Alignment The requested alignment of the allocation. Must be a power of two.
+ If Alignment is zero, then byte alignment is used.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateAlignedReservedCopyPool (
+ IN UINTN AllocationSize,
+ IN CONST VOID *Buffer,
+ IN UINTN Alignment
+ );
+
+/**
+ Frees a buffer that was previously allocated with one of the aligned pool allocation functions
+ in the Memory Allocation Library.
+
+ Frees the buffer specified by Buffer. Buffer must have been allocated on a previous call to the
+ aligned pool allocation services of the Memory Allocation Library.
+ If Buffer was not allocated with an aligned pool allocation function in the Memory Allocation
+ Library, then ASSERT().
+
+ @param Buffer Pointer to the buffer to free.
+
+**/
+VOID
+EFIAPI
+FreeAlignedPool (
+ IN VOID *Buffer
+ );
+
+#endif
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePciCf8Lib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePciCf8Lib.h
new file mode 100644
index 0000000..7bd22ab
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePciCf8Lib.h
@@ -0,0 +1,1055 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ EdkIIGluePciCf8Lib.h
+
+Abstract:
+
+ Public header file for Pci Cf8 Lib
+
+--*/
+
+#ifndef __EDKII_GLUE_PCI_CF8_LIB_H__
+#define __EDKII_GLUE_PCI_CF8_LIB_H__
+
+
+/**
+ Macro that converts PCI Bus, PCI Device, PCI Function and PCI Register to an
+ address that can be passed to the PCI Library functions.
+
+ Computes an address that is compatible with the PCI Library functions. The
+ unused upper bits of Bus, Device, Function and Register are stripped prior to
+ the generation of the address.
+
+ @param Bus PCI Bus number. Range 0..255.
+ @param Device PCI Device number. Range 0..31.
+ @param Function PCI Function number. Range 0..7.
+ @param Register PCI Register number. Range 0..255.
+
+ @return The encode PCI address.
+
+**/
+#define PCI_CF8_LIB_ADDRESS(Bus,Device,Function,Offset) \
+ (((Offset) & 0xfff) | (((Function) & 0x07) << 12) | (((Device) & 0x1f) << 15) | (((Bus) & 0xff) << 20))
+
+/**
+ Reads an 8-bit PCI configuration register.
+
+ Reads and returns the 8-bit PCI configuration register specified by Address.
+ This function must guarantee that all PCI read and write operations are
+ serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If the register specified by Address >= 0x100, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+
+ @return The read value from the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciCf8Read8 (
+ IN UINTN Address
+ );
+
+/**
+ Writes an 8-bit PCI configuration register.
+
+ Writes the 8-bit PCI configuration register specified by Address with the
+ value specified by Value. Value is returned. This function must guarantee
+ that all PCI read and write operations are serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If the register specified by Address >= 0x100, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param Value The value to write.
+
+ @return The value written to the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciCf8Write8 (
+ IN UINTN Address,
+ IN UINT8 Data
+ );
+
+/**
+ Performs a bitwise inclusive OR of an 8-bit PCI configuration register with
+ an 8-bit value.
+
+ Reads the 8-bit PCI configuration register specified by Address, performs a
+ bitwise inclusive OR between the read result and the value specified by
+ OrData, and writes the result to the 8-bit PCI configuration register
+ specified by Address. The value written to the PCI configuration register is
+ returned. This function must guarantee that all PCI read and write operations
+ are serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If the register specified by Address >= 0x100, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param OrData The value to OR with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciCf8Or8 (
+ IN UINTN Address,
+ IN UINT8 OrData
+ );
+
+/**
+ Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit
+ value.
+
+ Reads the 8-bit PCI configuration register specified by Address, performs a
+ bitwise AND between the read result and the value specified by AndData, and
+ writes the result to the 8-bit PCI configuration register specified by
+ Address. The value written to the PCI configuration register is returned.
+ This function must guarantee that all PCI read and write operations are
+ serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If the register specified by Address >= 0x100, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param AndData The value to AND with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciCf8And8 (
+ IN UINTN Address,
+ IN UINT8 AndData
+ );
+
+/**
+ Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit
+ value, followed a bitwise inclusive OR with another 8-bit value.
+
+ Reads the 8-bit PCI configuration register specified by Address, performs a
+ bitwise AND between the read result and the value specified by AndData,
+ performs a bitwise inclusive OR between the result of the AND operation and
+ the value specified by OrData, and writes the result to the 8-bit PCI
+ configuration register specified by Address. The value written to the PCI
+ configuration register is returned. This function must guarantee that all PCI
+ read and write operations are serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If the register specified by Address >= 0x100, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param AndData The value to AND with the PCI configuration register.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciCf8AndThenOr8 (
+ IN UINTN Address,
+ IN UINT8 AndData,
+ IN UINT8 OrData
+ );
+
+/**
+ Reads a bit field of a PCI configuration register.
+
+ Reads the bit field in an 8-bit PCI configuration register. The bit field is
+ specified by the StartBit and the EndBit. The value of the bit field is
+ returned.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If the register specified by Address >= 0x100, then ASSERT().
+ If StartBit is greater than 7, then ASSERT().
+ If EndBit is greater than 7, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to read.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..7.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..7.
+
+ @return The value of the bit field read from the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciCf8BitFieldRead8 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit
+ );
+
+/**
+ Writes a bit field to a PCI configuration register.
+
+ Writes Value to the bit field of the PCI configuration register. The bit
+ field is specified by the StartBit and the EndBit. All other bits in the
+ destination PCI configuration register are preserved. The new value of the
+ 8-bit register is returned.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If the register specified by Address >= 0x100, then ASSERT().
+ If StartBit is greater than 7, then ASSERT().
+ If EndBit is greater than 7, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..7.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..7.
+ @param Value New value of the bit field.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciCf8BitFieldWrite8 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT8 Value
+ );
+
+/**
+ Reads a bit field in an 8-bit PCI configuration, performs a bitwise OR, and
+ writes the result back to the bit field in the 8-bit port.
+
+ Reads the 8-bit PCI configuration register specified by Address, performs a
+ bitwise inclusive OR between the read result and the value specified by
+ OrData, and writes the result to the 8-bit PCI configuration register
+ specified by Address. The value written to the PCI configuration register is
+ returned. This function must guarantee that all PCI read and write operations
+ are serialized. Extra left bits in OrData are stripped.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If the register specified by Address >= 0x100, then ASSERT().
+ If StartBit is greater than 7, then ASSERT().
+ If EndBit is greater than 7, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..7.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..7.
+ @param OrData The value to OR with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciCf8BitFieldOr8 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT8 OrData
+ );
+
+/**
+ Reads a bit field in an 8-bit PCI configuration register, performs a bitwise
+ AND, and writes the result back to the bit field in the 8-bit register.
+
+ Reads the 8-bit PCI configuration register specified by Address, performs a
+ bitwise AND between the read result and the value specified by AndData, and
+ writes the result to the 8-bit PCI configuration register specified by
+ Address. The value written to the PCI configuration register is returned.
+ This function must guarantee that all PCI read and write operations are
+ serialized. Extra left bits in AndData are stripped.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If the register specified by Address >= 0x100, then ASSERT().
+ If StartBit is greater than 7, then ASSERT().
+ If EndBit is greater than 7, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..7.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..7.
+ @param AndData The value to AND with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciCf8BitFieldAnd8 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT8 AndData
+ );
+
+/**
+ Reads a bit field in an 8-bit port, performs a bitwise AND followed by a
+ bitwise inclusive OR, and writes the result back to the bit field in the
+ 8-bit port.
+
+ Reads the 8-bit PCI configuration register specified by Address, performs a
+ bitwise AND followed by a bitwise inclusive OR between the read result and
+ the value specified by AndData, and writes the result to the 8-bit PCI
+ configuration register specified by Address. The value written to the PCI
+ configuration register is returned. This function must guarantee that all PCI
+ read and write operations are serialized. Extra left bits in both AndData and
+ OrData are stripped.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If the register specified by Address >= 0x100, then ASSERT().
+ If StartBit is greater than 7, then ASSERT().
+ If EndBit is greater than 7, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..7.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..7.
+ @param AndData The value to AND with the PCI configuration register.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciCf8BitFieldAndThenOr8 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT8 AndData,
+ IN UINT8 OrData
+ );
+
+/**
+ Reads a 16-bit PCI configuration register.
+
+ Reads and returns the 16-bit PCI configuration register specified by Address.
+ This function must guarantee that all PCI read and write operations are
+ serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 16-bit boundary, then ASSERT().
+ If the register specified by Address >= 0x100, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+
+ @return The read value from the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciCf8Read16 (
+ IN UINTN Address
+ );
+
+/**
+ Writes a 16-bit PCI configuration register.
+
+ Writes the 16-bit PCI configuration register specified by Address with the
+ value specified by Value. Value is returned. This function must guarantee
+ that all PCI read and write operations are serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 16-bit boundary, then ASSERT().
+ If the register specified by Address >= 0x100, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param Value The value to write.
+
+ @return The value written to the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciCf8Write16 (
+ IN UINTN Address,
+ IN UINT16 Data
+ );
+
+/**
+ Performs a bitwise inclusive OR of a 16-bit PCI configuration register with
+ a 16-bit value.
+
+ Reads the 16-bit PCI configuration register specified by Address, performs a
+ bitwise inclusive OR between the read result and the value specified by
+ OrData, and writes the result to the 16-bit PCI configuration register
+ specified by Address. The value written to the PCI configuration register is
+ returned. This function must guarantee that all PCI read and write operations
+ are serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 16-bit boundary, then ASSERT().
+ If the register specified by Address >= 0x100, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param OrData The value to OR with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciCf8Or16 (
+ IN UINTN Address,
+ IN UINT16 OrData
+ );
+
+/**
+ Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit
+ value.
+
+ Reads the 16-bit PCI configuration register specified by Address, performs a
+ bitwise AND between the read result and the value specified by AndData, and
+ writes the result to the 16-bit PCI configuration register specified by
+ Address. The value written to the PCI configuration register is returned.
+ This function must guarantee that all PCI read and write operations are
+ serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 16-bit boundary, then ASSERT().
+ If the register specified by Address >= 0x100, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param AndData The value to AND with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciCf8And16 (
+ IN UINTN Address,
+ IN UINT16 AndData
+ );
+
+/**
+ Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit
+ value, followed a bitwise inclusive OR with another 16-bit value.
+
+ Reads the 16-bit PCI configuration register specified by Address, performs a
+ bitwise AND between the read result and the value specified by AndData,
+ performs a bitwise inclusive OR between the result of the AND operation and
+ the value specified by OrData, and writes the result to the 16-bit PCI
+ configuration register specified by Address. The value written to the PCI
+ configuration register is returned. This function must guarantee that all PCI
+ read and write operations are serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 16-bit boundary, then ASSERT().
+ If the register specified by Address >= 0x100, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param AndData The value to AND with the PCI configuration register.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciCf8AndThenOr16 (
+ IN UINTN Address,
+ IN UINT16 AndData,
+ IN UINT16 OrData
+ );
+
+/**
+ Reads a bit field of a PCI configuration register.
+
+ Reads the bit field in a 16-bit PCI configuration register. The bit field is
+ specified by the StartBit and the EndBit. The value of the bit field is
+ returned.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 16-bit boundary, then ASSERT().
+ If the register specified by Address >= 0x100, then ASSERT().
+ If StartBit is greater than 15, then ASSERT().
+ If EndBit is greater than 15, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to read.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..15.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..15.
+
+ @return The value of the bit field read from the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciCf8BitFieldRead16 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit
+ );
+
+/**
+ Writes a bit field to a PCI configuration register.
+
+ Writes Value to the bit field of the PCI configuration register. The bit
+ field is specified by the StartBit and the EndBit. All other bits in the
+ destination PCI configuration register are preserved. The new value of the
+ 16-bit register is returned.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 16-bit boundary, then ASSERT().
+ If the register specified by Address >= 0x100, then ASSERT().
+ If StartBit is greater than 15, then ASSERT().
+ If EndBit is greater than 15, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..15.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..15.
+ @param Value New value of the bit field.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciCf8BitFieldWrite16 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT16 Value
+ );
+
+/**
+ Reads a bit field in a 16-bit PCI configuration, performs a bitwise OR, and
+ writes the result back to the bit field in the 16-bit port.
+
+ Reads the 16-bit PCI configuration register specified by Address, performs a
+ bitwise inclusive OR between the read result and the value specified by
+ OrData, and writes the result to the 16-bit PCI configuration register
+ specified by Address. The value written to the PCI configuration register is
+ returned. This function must guarantee that all PCI read and write operations
+ are serialized. Extra left bits in OrData are stripped.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 16-bit boundary, then ASSERT().
+ If the register specified by Address >= 0x100, then ASSERT().
+ If StartBit is greater than 15, then ASSERT().
+ If EndBit is greater than 15, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..15.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..15.
+ @param OrData The value to OR with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciCf8BitFieldOr16 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT16 OrData
+ );
+
+/**
+ Reads a bit field in a 16-bit PCI configuration register, performs a bitwise
+ AND, and writes the result back to the bit field in the 16-bit register.
+
+ Reads the 16-bit PCI configuration register specified by Address, performs a
+ bitwise AND between the read result and the value specified by AndData, and
+ writes the result to the 16-bit PCI configuration register specified by
+ Address. The value written to the PCI configuration register is returned.
+ This function must guarantee that all PCI read and write operations are
+ serialized. Extra left bits in AndData are stripped.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 16-bit boundary, then ASSERT().
+ If the register specified by Address >= 0x100, then ASSERT().
+ If StartBit is greater than 15, then ASSERT().
+ If EndBit is greater than 15, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..15.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..15.
+ @param AndData The value to AND with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciCf8BitFieldAnd16 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT16 AndData
+ );
+
+/**
+ Reads a bit field in a 16-bit port, performs a bitwise AND followed by a
+ bitwise inclusive OR, and writes the result back to the bit field in the
+ 16-bit port.
+
+ Reads the 16-bit PCI configuration register specified by Address, performs a
+ bitwise AND followed by a bitwise inclusive OR between the read result and
+ the value specified by AndData, and writes the result to the 16-bit PCI
+ configuration register specified by Address. The value written to the PCI
+ configuration register is returned. This function must guarantee that all PCI
+ read and write operations are serialized. Extra left bits in both AndData and
+ OrData are stripped.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 16-bit boundary, then ASSERT().
+ If the register specified by Address >= 0x100, then ASSERT().
+ If StartBit is greater than 15, then ASSERT().
+ If EndBit is greater than 15, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..15.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..15.
+ @param AndData The value to AND with the PCI configuration register.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciCf8BitFieldAndThenOr16 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT16 AndData,
+ IN UINT16 OrData
+ );
+
+/**
+ Reads a 32-bit PCI configuration register.
+
+ Reads and returns the 32-bit PCI configuration register specified by Address.
+ This function must guarantee that all PCI read and write operations are
+ serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 32-bit boundary, then ASSERT().
+ If the register specified by Address >= 0x100, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+
+ @return The read value from the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciCf8Read32 (
+ IN UINTN Address
+ );
+
+/**
+ Writes a 32-bit PCI configuration register.
+
+ Writes the 32-bit PCI configuration register specified by Address with the
+ value specified by Value. Value is returned. This function must guarantee
+ that all PCI read and write operations are serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 32-bit boundary, then ASSERT().
+ If the register specified by Address >= 0x100, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param Value The value to write.
+
+ @return The value written to the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciCf8Write32 (
+ IN UINTN Address,
+ IN UINT32 Data
+ );
+
+/**
+ Performs a bitwise inclusive OR of a 32-bit PCI configuration register with
+ a 32-bit value.
+
+ Reads the 32-bit PCI configuration register specified by Address, performs a
+ bitwise inclusive OR between the read result and the value specified by
+ OrData, and writes the result to the 32-bit PCI configuration register
+ specified by Address. The value written to the PCI configuration register is
+ returned. This function must guarantee that all PCI read and write operations
+ are serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 32-bit boundary, then ASSERT().
+ If the register specified by Address >= 0x100, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param OrData The value to OR with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciCf8Or32 (
+ IN UINTN Address,
+ IN UINT32 OrData
+ );
+
+/**
+ Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit
+ value.
+
+ Reads the 32-bit PCI configuration register specified by Address, performs a
+ bitwise AND between the read result and the value specified by AndData, and
+ writes the result to the 32-bit PCI configuration register specified by
+ Address. The value written to the PCI configuration register is returned.
+ This function must guarantee that all PCI read and write operations are
+ serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 32-bit boundary, then ASSERT().
+ If the register specified by Address >= 0x100, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param AndData The value to AND with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciCf8And32 (
+ IN UINTN Address,
+ IN UINT32 AndData
+ );
+
+/**
+ Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit
+ value, followed a bitwise inclusive OR with another 32-bit value.
+
+ Reads the 32-bit PCI configuration register specified by Address, performs a
+ bitwise AND between the read result and the value specified by AndData,
+ performs a bitwise inclusive OR between the result of the AND operation and
+ the value specified by OrData, and writes the result to the 32-bit PCI
+ configuration register specified by Address. The value written to the PCI
+ configuration register is returned. This function must guarantee that all PCI
+ read and write operations are serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 32-bit boundary, then ASSERT().
+ If the register specified by Address >= 0x100, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param AndData The value to AND with the PCI configuration register.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciCf8AndThenOr32 (
+ IN UINTN Address,
+ IN UINT32 AndData,
+ IN UINT32 OrData
+ );
+
+/**
+ Reads a bit field of a PCI configuration register.
+
+ Reads the bit field in a 32-bit PCI configuration register. The bit field is
+ specified by the StartBit and the EndBit. The value of the bit field is
+ returned.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 32-bit boundary, then ASSERT().
+ If the register specified by Address >= 0x100, then ASSERT().
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to read.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+
+ @return The value of the bit field read from the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciCf8BitFieldRead32 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit
+ );
+
+/**
+ Writes a bit field to a PCI configuration register.
+
+ Writes Value to the bit field of the PCI configuration register. The bit
+ field is specified by the StartBit and the EndBit. All other bits in the
+ destination PCI configuration register are preserved. The new value of the
+ 32-bit register is returned.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 32-bit boundary, then ASSERT().
+ If the register specified by Address >= 0x100, then ASSERT().
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+ @param Value New value of the bit field.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciCf8BitFieldWrite32 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT32 Value
+ );
+
+/**
+ Reads a bit field in a 32-bit PCI configuration, performs a bitwise OR, and
+ writes the result back to the bit field in the 32-bit port.
+
+ Reads the 32-bit PCI configuration register specified by Address, performs a
+ bitwise inclusive OR between the read result and the value specified by
+ OrData, and writes the result to the 32-bit PCI configuration register
+ specified by Address. The value written to the PCI configuration register is
+ returned. This function must guarantee that all PCI read and write operations
+ are serialized. Extra left bits in OrData are stripped.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 32-bit boundary, then ASSERT().
+ If the register specified by Address >= 0x100, then ASSERT().
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+ @param OrData The value to OR with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciCf8BitFieldOr32 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT32 OrData
+ );
+
+/**
+ Reads a bit field in a 32-bit PCI configuration register, performs a bitwise
+ AND, and writes the result back to the bit field in the 32-bit register.
+
+ Reads the 32-bit PCI configuration register specified by Address, performs a
+ bitwise AND between the read result and the value specified by AndData, and
+ writes the result to the 32-bit PCI configuration register specified by
+ Address. The value written to the PCI configuration register is returned.
+ This function must guarantee that all PCI read and write operations are
+ serialized. Extra left bits in AndData are stripped.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 32-bit boundary, then ASSERT().
+ If the register specified by Address >= 0x100, then ASSERT().
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+ @param AndData The value to AND with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciCf8BitFieldAnd32 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT32 AndData
+ );
+
+/**
+ Reads a bit field in a 32-bit port, performs a bitwise AND followed by a
+ bitwise inclusive OR, and writes the result back to the bit field in the
+ 32-bit port.
+
+ Reads the 32-bit PCI configuration register specified by Address, performs a
+ bitwise AND followed by a bitwise inclusive OR between the read result and
+ the value specified by AndData, and writes the result to the 32-bit PCI
+ configuration register specified by Address. The value written to the PCI
+ configuration register is returned. This function must guarantee that all PCI
+ read and write operations are serialized. Extra left bits in both AndData and
+ OrData are stripped.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 32-bit boundary, then ASSERT().
+ If the register specified by Address >= 0x100, then ASSERT().
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+ @param AndData The value to AND with the PCI configuration register.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciCf8BitFieldAndThenOr32 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT32 AndData,
+ IN UINT32 OrData
+ );
+
+/**
+ Reads a range of PCI configuration registers into a caller supplied buffer.
+
+ Reads the range of PCI configuration registers specified by StartAddress and
+ Size into the buffer specified by Buffer. This function only allows the PCI
+ configuration registers from a single PCI function to be read. Size is
+ returned. When possible 32-bit PCI configuration read cycles are used to read
+ from StartAdress to StartAddress + Size. Due to alignment restrictions, 8-bit
+ and 16-bit PCI configuration read cycles may be used at the beginning and the
+ end of the range.
+
+ If StartAddress > 0x0FFFFFFF, then ASSERT().
+ If the register specified by StartAddress >= 0x100, then ASSERT().
+ If ((StartAddress & 0xFFF) + Size) > 0x100, then ASSERT().
+ If Size > 0 and Buffer is NULL, then ASSERT().
+
+ @param StartAddress Starting address that encodes the PCI Bus, Device,
+ Function and Register.
+ @param Size Size in bytes of the transfer.
+ @param Buffer Pointer to a buffer receiving the data read.
+
+ @return Size
+
+**/
+UINTN
+EFIAPI
+PciCf8ReadBuffer (
+ IN UINTN StartAddress,
+ IN UINTN Size,
+ OUT VOID *Buffer
+ );
+
+/**
+ Copies the data in a caller supplied buffer to a specified range of PCI
+ configuration space.
+
+ Writes the range of PCI configuration registers specified by StartAddress and
+ Size from the buffer specified by Buffer. This function only allows the PCI
+ configuration registers from a single PCI function to be written. Size is
+ returned. When possible 32-bit PCI configuration write cycles are used to
+ write from StartAdress to StartAddress + Size. Due to alignment restrictions,
+ 8-bit and 16-bit PCI configuration write cycles may be used at the beginning
+ and the end of the range.
+
+ If StartAddress > 0x0FFFFFFF, then ASSERT().
+ If the register specified by StartAddress >= 0x100, then ASSERT().
+ If ((StartAddress & 0xFFF) + Size) > 0x100, then ASSERT().
+ If Size > 0 and Buffer is NULL, then ASSERT().
+
+ @param StartAddress Starting address that encodes the PCI Bus, Device,
+ Function and Register.
+ @param Size Size in bytes of the transfer.
+ @param Buffer Pointer to a buffer containing the data to write.
+
+ @return Size
+
+**/
+UINTN
+EFIAPI
+PciCf8WriteBuffer (
+ IN UINTN StartAddress,
+ IN UINTN Size,
+ IN VOID *Buffer
+ );
+
+#endif
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePciExpressLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePciExpressLib.h
new file mode 100644
index 0000000..4fe4668
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePciExpressLib.h
@@ -0,0 +1,1023 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ EdkIIGluePciExpressLib.h
+
+Abstract:
+
+ Public header file for Pci Express Lib
+
+--*/
+
+#ifndef __EDKII_GLUE_PCI_EXPRESS_LIB_H__
+#define __EDKII_GLUE_PCI_EXPRESS_LIB_H__
+
+
+/**
+ Macro that converts PCI Bus, PCI Device, PCI Function and PCI Register to an
+ address that can be passed to the PCI Library functions.
+
+ Computes an address that is compatible with the PCI Library functions. The
+ unused upper bits of Bus, Device, Function and Register are stripped prior to
+ the generation of the address.
+
+ @param Bus PCI Bus number. Range 0..255.
+ @param Device PCI Device number. Range 0..31.
+ @param Function PCI Function number. Range 0..7.
+ @param Register PCI Register number. Range 0..4095.
+
+ @return The encode PCI address.
+
+**/
+#define PCI_EXPRESS_LIB_ADDRESS(Bus,Device,Function,Offset) \
+ (((Offset) & 0xfff) | (((Function) & 0x07) << 12) | (((Device) & 0x1f) << 15) | (((Bus) & 0xff) << 20))
+
+/**
+ Reads an 8-bit PCI configuration register.
+
+ Reads and returns the 8-bit PCI configuration register specified by Address.
+ This function must guarantee that all PCI read and write operations are
+ serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+
+ @return The read value from the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciExpressRead8 (
+ IN UINTN Address
+ );
+
+/**
+ Writes an 8-bit PCI configuration register.
+
+ Writes the 8-bit PCI configuration register specified by Address with the
+ value specified by Value. Value is returned. This function must guarantee
+ that all PCI read and write operations are serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param Value The value to write.
+
+ @return The value written to the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciExpressWrite8 (
+ IN UINTN Address,
+ IN UINT8 Data
+ );
+
+/**
+ Performs a bitwise inclusive OR of an 8-bit PCI configuration register with
+ an 8-bit value.
+
+ Reads the 8-bit PCI configuration register specified by Address, performs a
+ bitwise inclusive OR between the read result and the value specified by
+ OrData, and writes the result to the 8-bit PCI configuration register
+ specified by Address. The value written to the PCI configuration register is
+ returned. This function must guarantee that all PCI read and write operations
+ are serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param OrData The value to OR with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciExpressOr8 (
+ IN UINTN Address,
+ IN UINT8 OrData
+ );
+
+/**
+ Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit
+ value.
+
+ Reads the 8-bit PCI configuration register specified by Address, performs a
+ bitwise AND between the read result and the value specified by AndData, and
+ writes the result to the 8-bit PCI configuration register specified by
+ Address. The value written to the PCI configuration register is returned.
+ This function must guarantee that all PCI read and write operations are
+ serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param AndData The value to AND with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciExpressAnd8 (
+ IN UINTN Address,
+ IN UINT8 AndData
+ );
+
+/**
+ Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit
+ value, followed a bitwise inclusive OR with another 8-bit value.
+
+ Reads the 8-bit PCI configuration register specified by Address, performs a
+ bitwise AND between the read result and the value specified by AndData,
+ performs a bitwise inclusive OR between the result of the AND operation and
+ the value specified by OrData, and writes the result to the 8-bit PCI
+ configuration register specified by Address. The value written to the PCI
+ configuration register is returned. This function must guarantee that all PCI
+ read and write operations are serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param AndData The value to AND with the PCI configuration register.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciExpressAndThenOr8 (
+ IN UINTN Address,
+ IN UINT8 AndData,
+ IN UINT8 OrData
+ );
+
+/**
+ Reads a bit field of a PCI configuration register.
+
+ Reads the bit field in an 8-bit PCI configuration register. The bit field is
+ specified by the StartBit and the EndBit. The value of the bit field is
+ returned.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If StartBit is greater than 7, then ASSERT().
+ If EndBit is greater than 7, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to read.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..7.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..7.
+
+ @return The value of the bit field read from the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciExpressBitFieldRead8 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit
+ );
+
+/**
+ Writes a bit field to a PCI configuration register.
+
+ Writes Value to the bit field of the PCI configuration register. The bit
+ field is specified by the StartBit and the EndBit. All other bits in the
+ destination PCI configuration register are preserved. The new value of the
+ 8-bit register is returned.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If StartBit is greater than 7, then ASSERT().
+ If EndBit is greater than 7, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..7.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..7.
+ @param Value New value of the bit field.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciExpressBitFieldWrite8 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT8 Value
+ );
+
+/**
+ Reads a bit field in an 8-bit PCI configuration, performs a bitwise OR, and
+ writes the result back to the bit field in the 8-bit port.
+
+ Reads the 8-bit PCI configuration register specified by Address, performs a
+ bitwise inclusive OR between the read result and the value specified by
+ OrData, and writes the result to the 8-bit PCI configuration register
+ specified by Address. The value written to the PCI configuration register is
+ returned. This function must guarantee that all PCI read and write operations
+ are serialized. Extra left bits in OrData are stripped.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If StartBit is greater than 7, then ASSERT().
+ If EndBit is greater than 7, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..7.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..7.
+ @param OrData The value to OR with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciExpressBitFieldOr8 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT8 OrData
+ );
+
+/**
+ Reads a bit field in an 8-bit PCI configuration register, performs a bitwise
+ AND, and writes the result back to the bit field in the 8-bit register.
+
+ Reads the 8-bit PCI configuration register specified by Address, performs a
+ bitwise AND between the read result and the value specified by AndData, and
+ writes the result to the 8-bit PCI configuration register specified by
+ Address. The value written to the PCI configuration register is returned.
+ This function must guarantee that all PCI read and write operations are
+ serialized. Extra left bits in AndData are stripped.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If StartBit is greater than 7, then ASSERT().
+ If EndBit is greater than 7, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..7.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..7.
+ @param AndData The value to AND with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciExpressBitFieldAnd8 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT8 AndData
+ );
+
+/**
+ Reads a bit field in an 8-bit port, performs a bitwise AND followed by a
+ bitwise inclusive OR, and writes the result back to the bit field in the
+ 8-bit port.
+
+ Reads the 8-bit PCI configuration register specified by Address, performs a
+ bitwise AND followed by a bitwise inclusive OR between the read result and
+ the value specified by AndData, and writes the result to the 8-bit PCI
+ configuration register specified by Address. The value written to the PCI
+ configuration register is returned. This function must guarantee that all PCI
+ read and write operations are serialized. Extra left bits in both AndData and
+ OrData are stripped.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If StartBit is greater than 7, then ASSERT().
+ If EndBit is greater than 7, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..7.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..7.
+ @param AndData The value to AND with the PCI configuration register.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciExpressBitFieldAndThenOr8 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT8 AndData,
+ IN UINT8 OrData
+ );
+
+/**
+ Reads a 16-bit PCI configuration register.
+
+ Reads and returns the 16-bit PCI configuration register specified by Address.
+ This function must guarantee that all PCI read and write operations are
+ serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 16-bit boundary, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+
+ @return The read value from the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciExpressRead16 (
+ IN UINTN Address
+ );
+
+/**
+ Writes a 16-bit PCI configuration register.
+
+ Writes the 16-bit PCI configuration register specified by Address with the
+ value specified by Value. Value is returned. This function must guarantee
+ that all PCI read and write operations are serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 16-bit boundary, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param Value The value to write.
+
+ @return The value written to the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciExpressWrite16 (
+ IN UINTN Address,
+ IN UINT16 Data
+ );
+
+/**
+ Performs a bitwise inclusive OR of a 16-bit PCI configuration register with
+ a 16-bit value.
+
+ Reads the 16-bit PCI configuration register specified by Address, performs a
+ bitwise inclusive OR between the read result and the value specified by
+ OrData, and writes the result to the 16-bit PCI configuration register
+ specified by Address. The value written to the PCI configuration register is
+ returned. This function must guarantee that all PCI read and write operations
+ are serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 16-bit boundary, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param OrData The value to OR with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciExpressOr16 (
+ IN UINTN Address,
+ IN UINT16 OrData
+ );
+
+/**
+ Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit
+ value.
+
+ Reads the 16-bit PCI configuration register specified by Address, performs a
+ bitwise AND between the read result and the value specified by AndData, and
+ writes the result to the 16-bit PCI configuration register specified by
+ Address. The value written to the PCI configuration register is returned.
+ This function must guarantee that all PCI read and write operations are
+ serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 16-bit boundary, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param AndData The value to AND with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciExpressAnd16 (
+ IN UINTN Address,
+ IN UINT16 AndData
+ );
+
+/**
+ Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit
+ value, followed a bitwise inclusive OR with another 16-bit value.
+
+ Reads the 16-bit PCI configuration register specified by Address, performs a
+ bitwise AND between the read result and the value specified by AndData,
+ performs a bitwise inclusive OR between the result of the AND operation and
+ the value specified by OrData, and writes the result to the 16-bit PCI
+ configuration register specified by Address. The value written to the PCI
+ configuration register is returned. This function must guarantee that all PCI
+ read and write operations are serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 16-bit boundary, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param AndData The value to AND with the PCI configuration register.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciExpressAndThenOr16 (
+ IN UINTN Address,
+ IN UINT16 AndData,
+ IN UINT16 OrData
+ );
+
+/**
+ Reads a bit field of a PCI configuration register.
+
+ Reads the bit field in a 16-bit PCI configuration register. The bit field is
+ specified by the StartBit and the EndBit. The value of the bit field is
+ returned.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 16-bit boundary, then ASSERT().
+ If StartBit is greater than 15, then ASSERT().
+ If EndBit is greater than 15, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to read.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..15.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..15.
+
+ @return The value of the bit field read from the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciExpressBitFieldRead16 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit
+ );
+
+/**
+ Writes a bit field to a PCI configuration register.
+
+ Writes Value to the bit field of the PCI configuration register. The bit
+ field is specified by the StartBit and the EndBit. All other bits in the
+ destination PCI configuration register are preserved. The new value of the
+ 16-bit register is returned.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 16-bit boundary, then ASSERT().
+ If StartBit is greater than 15, then ASSERT().
+ If EndBit is greater than 15, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..15.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..15.
+ @param Value New value of the bit field.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciExpressBitFieldWrite16 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT16 Value
+ );
+
+/**
+ Reads a bit field in a 16-bit PCI configuration, performs a bitwise OR, and
+ writes the result back to the bit field in the 16-bit port.
+
+ Reads the 16-bit PCI configuration register specified by Address, performs a
+ bitwise inclusive OR between the read result and the value specified by
+ OrData, and writes the result to the 16-bit PCI configuration register
+ specified by Address. The value written to the PCI configuration register is
+ returned. This function must guarantee that all PCI read and write operations
+ are serialized. Extra left bits in OrData are stripped.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 16-bit boundary, then ASSERT().
+ If StartBit is greater than 15, then ASSERT().
+ If EndBit is greater than 15, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..15.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..15.
+ @param OrData The value to OR with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciExpressBitFieldOr16 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT16 OrData
+ );
+
+/**
+ Reads a bit field in a 16-bit PCI configuration register, performs a bitwise
+ AND, and writes the result back to the bit field in the 16-bit register.
+
+ Reads the 16-bit PCI configuration register specified by Address, performs a
+ bitwise AND between the read result and the value specified by AndData, and
+ writes the result to the 16-bit PCI configuration register specified by
+ Address. The value written to the PCI configuration register is returned.
+ This function must guarantee that all PCI read and write operations are
+ serialized. Extra left bits in AndData are stripped.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 16-bit boundary, then ASSERT().
+ If StartBit is greater than 15, then ASSERT().
+ If EndBit is greater than 15, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..15.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..15.
+ @param AndData The value to AND with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciExpressBitFieldAnd16 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT16 AndData
+ );
+
+/**
+ Reads a bit field in a 16-bit port, performs a bitwise AND followed by a
+ bitwise inclusive OR, and writes the result back to the bit field in the
+ 16-bit port.
+
+ Reads the 16-bit PCI configuration register specified by Address, performs a
+ bitwise AND followed by a bitwise inclusive OR between the read result and
+ the value specified by AndData, and writes the result to the 16-bit PCI
+ configuration register specified by Address. The value written to the PCI
+ configuration register is returned. This function must guarantee that all PCI
+ read and write operations are serialized. Extra left bits in both AndData and
+ OrData are stripped.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 16-bit boundary, then ASSERT().
+ If StartBit is greater than 15, then ASSERT().
+ If EndBit is greater than 15, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..15.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..15.
+ @param AndData The value to AND with the PCI configuration register.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciExpressBitFieldAndThenOr16 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT16 AndData,
+ IN UINT16 OrData
+ );
+
+/**
+ Reads a 32-bit PCI configuration register.
+
+ Reads and returns the 32-bit PCI configuration register specified by Address.
+ This function must guarantee that all PCI read and write operations are
+ serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 32-bit boundary, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+
+ @return The read value from the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciExpressRead32 (
+ IN UINTN Address
+ );
+
+/**
+ Writes a 32-bit PCI configuration register.
+
+ Writes the 32-bit PCI configuration register specified by Address with the
+ value specified by Value. Value is returned. This function must guarantee
+ that all PCI read and write operations are serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 32-bit boundary, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param Value The value to write.
+
+ @return The value written to the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciExpressWrite32 (
+ IN UINTN Address,
+ IN UINT32 Data
+ );
+
+/**
+ Performs a bitwise inclusive OR of a 32-bit PCI configuration register with
+ a 32-bit value.
+
+ Reads the 32-bit PCI configuration register specified by Address, performs a
+ bitwise inclusive OR between the read result and the value specified by
+ OrData, and writes the result to the 32-bit PCI configuration register
+ specified by Address. The value written to the PCI configuration register is
+ returned. This function must guarantee that all PCI read and write operations
+ are serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 32-bit boundary, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param OrData The value to OR with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciExpressOr32 (
+ IN UINTN Address,
+ IN UINT32 OrData
+ );
+
+/**
+ Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit
+ value.
+
+ Reads the 32-bit PCI configuration register specified by Address, performs a
+ bitwise AND between the read result and the value specified by AndData, and
+ writes the result to the 32-bit PCI configuration register specified by
+ Address. The value written to the PCI configuration register is returned.
+ This function must guarantee that all PCI read and write operations are
+ serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 32-bit boundary, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param AndData The value to AND with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciExpressAnd32 (
+ IN UINTN Address,
+ IN UINT32 AndData
+ );
+
+/**
+ Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit
+ value, followed a bitwise inclusive OR with another 32-bit value.
+
+ Reads the 32-bit PCI configuration register specified by Address, performs a
+ bitwise AND between the read result and the value specified by AndData,
+ performs a bitwise inclusive OR between the result of the AND operation and
+ the value specified by OrData, and writes the result to the 32-bit PCI
+ configuration register specified by Address. The value written to the PCI
+ configuration register is returned. This function must guarantee that all PCI
+ read and write operations are serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 32-bit boundary, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param AndData The value to AND with the PCI configuration register.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciExpressAndThenOr32 (
+ IN UINTN Address,
+ IN UINT32 AndData,
+ IN UINT32 OrData
+ );
+
+/**
+ Reads a bit field of a PCI configuration register.
+
+ Reads the bit field in a 32-bit PCI configuration register. The bit field is
+ specified by the StartBit and the EndBit. The value of the bit field is
+ returned.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 32-bit boundary, then ASSERT().
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to read.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+
+ @return The value of the bit field read from the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciExpressBitFieldRead32 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit
+ );
+
+/**
+ Writes a bit field to a PCI configuration register.
+
+ Writes Value to the bit field of the PCI configuration register. The bit
+ field is specified by the StartBit and the EndBit. All other bits in the
+ destination PCI configuration register are preserved. The new value of the
+ 32-bit register is returned.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 32-bit boundary, then ASSERT().
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+ @param Value New value of the bit field.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciExpressBitFieldWrite32 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT32 Value
+ );
+
+/**
+ Reads a bit field in a 32-bit PCI configuration, performs a bitwise OR, and
+ writes the result back to the bit field in the 32-bit port.
+
+ Reads the 32-bit PCI configuration register specified by Address, performs a
+ bitwise inclusive OR between the read result and the value specified by
+ OrData, and writes the result to the 32-bit PCI configuration register
+ specified by Address. The value written to the PCI configuration register is
+ returned. This function must guarantee that all PCI read and write operations
+ are serialized. Extra left bits in OrData are stripped.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 32-bit boundary, then ASSERT().
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+ @param OrData The value to OR with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciExpressBitFieldOr32 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT32 OrData
+ );
+
+/**
+ Reads a bit field in a 32-bit PCI configuration register, performs a bitwise
+ AND, and writes the result back to the bit field in the 32-bit register.
+
+ Reads the 32-bit PCI configuration register specified by Address, performs a
+ bitwise AND between the read result and the value specified by AndData, and
+ writes the result to the 32-bit PCI configuration register specified by
+ Address. The value written to the PCI configuration register is returned.
+ This function must guarantee that all PCI read and write operations are
+ serialized. Extra left bits in AndData are stripped.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 32-bit boundary, then ASSERT().
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+ @param AndData The value to AND with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciExpressBitFieldAnd32 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT32 AndData
+ );
+
+/**
+ Reads a bit field in a 32-bit port, performs a bitwise AND followed by a
+ bitwise inclusive OR, and writes the result back to the bit field in the
+ 32-bit port.
+
+ Reads the 32-bit PCI configuration register specified by Address, performs a
+ bitwise AND followed by a bitwise inclusive OR between the read result and
+ the value specified by AndData, and writes the result to the 32-bit PCI
+ configuration register specified by Address. The value written to the PCI
+ configuration register is returned. This function must guarantee that all PCI
+ read and write operations are serialized. Extra left bits in both AndData and
+ OrData are stripped.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 32-bit boundary, then ASSERT().
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+ @param AndData The value to AND with the PCI configuration register.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciExpressBitFieldAndThenOr32 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT32 AndData,
+ IN UINT32 OrData
+ );
+
+/**
+ Reads a range of PCI configuration registers into a caller supplied buffer.
+
+ Reads the range of PCI configuration registers specified by StartAddress and
+ Size into the buffer specified by Buffer. This function only allows the PCI
+ configuration registers from a single PCI function to be read. Size is
+ returned. When possible 32-bit PCI configuration read cycles are used to read
+ from StartAdress to StartAddress + Size. Due to alignment restrictions, 8-bit
+ and 16-bit PCI configuration read cycles may be used at the beginning and the
+ end of the range.
+
+ If StartAddress > 0x0FFFFFFF, then ASSERT().
+ If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT().
+ If Size > 0 and Buffer is NULL, then ASSERT().
+
+ @param StartAddress Starting address that encodes the PCI Bus, Device,
+ Function and Register.
+ @param Size Size in bytes of the transfer.
+ @param Buffer Pointer to a buffer receiving the data read.
+
+ @return Size
+
+**/
+UINTN
+EFIAPI
+PciExpressReadBuffer (
+ IN UINTN StartAddress,
+ IN UINTN Size,
+ OUT VOID *Buffer
+ );
+
+/**
+ Copies the data in a caller supplied buffer to a specified range of PCI
+ configuration space.
+
+ Writes the range of PCI configuration registers specified by StartAddress and
+ Size from the buffer specified by Buffer. This function only allows the PCI
+ configuration registers from a single PCI function to be written. Size is
+ returned. When possible 32-bit PCI configuration write cycles are used to
+ write from StartAdress to StartAddress + Size. Due to alignment restrictions,
+ 8-bit and 16-bit PCI configuration write cycles may be used at the beginning
+ and the end of the range.
+
+ If StartAddress > 0x0FFFFFFF, then ASSERT().
+ If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT().
+ If Size > 0 and Buffer is NULL, then ASSERT().
+
+ @param StartAddress Starting address that encodes the PCI Bus, Device,
+ Function and Register.
+ @param Size Size in bytes of the transfer.
+ @param Buffer Pointer to a buffer containing the data to write.
+
+ @return Size
+
+**/
+UINTN
+EFIAPI
+PciExpressWriteBuffer (
+ IN UINTN StartAddress,
+ IN UINTN Size,
+ IN VOID *Buffer
+ );
+
+#endif
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePciLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePciLib.h
new file mode 100644
index 0000000..26193dd
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePciLib.h
@@ -0,0 +1,1019 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ EdkIIGluePciLib.h
+
+Abstract:
+
+ Public header file for Pci Lib
+
+--*/
+
+#ifndef __EDKII_GLUE_PCI_LIB_H__
+#define __EDKII_GLUE_PCI_LIB_H__
+
+/**
+ Macro that converts PCI Bus, PCI Device, PCI Function and PCI Register to an
+ address that can be passed to the PCI Library functions.
+
+ @param Bus PCI Bus number. Range 0..255.
+ @param Device PCI Device number. Range 0..31.
+ @param Function PCI Function number. Range 0..7.
+ @param Register PCI Register number. Range 0..255 for PCI. Range 0..4095
+ for PCI Express.
+
+ @return The encoded PCI address.
+
+**/
+#define PCI_LIB_ADDRESS(Bus,Device,Function,Offset) \
+ (((Offset) & 0xfff) | (((Function) & 0x07) << 12) | (((Device) & 0x1f) << 15) | (((Bus) & 0xff) << 20))
+
+/**
+ Reads an 8-bit PCI configuration register.
+
+ Reads and returns the 8-bit PCI configuration register specified by Address.
+ This function must guarantee that all PCI read and write operations are
+ serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+
+ @return The read value from the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciRead8 (
+ IN UINTN Address
+ );
+
+/**
+ Writes an 8-bit PCI configuration register.
+
+ Writes the 8-bit PCI configuration register specified by Address with the
+ value specified by Value. Value is returned. This function must guarantee
+ that all PCI read and write operations are serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param Value The value to write.
+
+ @return The value written to the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciWrite8 (
+ IN UINTN Address,
+ IN UINT8 Data
+ );
+
+/**
+ Performs a bitwise inclusive OR of an 8-bit PCI configuration register with
+ an 8-bit value.
+
+ Reads the 8-bit PCI configuration register specified by Address, performs a
+ bitwise inclusive OR between the read result and the value specified by
+ OrData, and writes the result to the 8-bit PCI configuration register
+ specified by Address. The value written to the PCI configuration register is
+ returned. This function must guarantee that all PCI read and write operations
+ are serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param OrData The value to OR with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciOr8 (
+ IN UINTN Address,
+ IN UINT8 OrData
+ );
+
+/**
+ Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit
+ value.
+
+ Reads the 8-bit PCI configuration register specified by Address, performs a
+ bitwise AND between the read result and the value specified by AndData, and
+ writes the result to the 8-bit PCI configuration register specified by
+ Address. The value written to the PCI configuration register is returned.
+ This function must guarantee that all PCI read and write operations are
+ serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param AndData The value to AND with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciAnd8 (
+ IN UINTN Address,
+ IN UINT8 AndData
+ );
+
+/**
+ Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit
+ value, followed a bitwise inclusive OR with another 8-bit value.
+
+ Reads the 8-bit PCI configuration register specified by Address, performs a
+ bitwise AND between the read result and the value specified by AndData,
+ performs a bitwise inclusive OR between the result of the AND operation and
+ the value specified by OrData, and writes the result to the 8-bit PCI
+ configuration register specified by Address. The value written to the PCI
+ configuration register is returned. This function must guarantee that all PCI
+ read and write operations are serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param AndData The value to AND with the PCI configuration register.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciAndThenOr8 (
+ IN UINTN Address,
+ IN UINT8 AndData,
+ IN UINT8 OrData
+ );
+
+/**
+ Reads a bit field of a PCI configuration register.
+
+ Reads the bit field in an 8-bit PCI configuration register. The bit field is
+ specified by the StartBit and the EndBit. The value of the bit field is
+ returned.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If StartBit is greater than 7, then ASSERT().
+ If EndBit is greater than 7, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to read.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..7.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..7.
+
+ @return The value of the bit field read from the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciBitFieldRead8 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit
+ );
+
+/**
+ Writes a bit field to a PCI configuration register.
+
+ Writes Value to the bit field of the PCI configuration register. The bit
+ field is specified by the StartBit and the EndBit. All other bits in the
+ destination PCI configuration register are preserved. The new value of the
+ 8-bit register is returned.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If StartBit is greater than 7, then ASSERT().
+ If EndBit is greater than 7, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..7.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..7.
+ @param Value New value of the bit field.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciBitFieldWrite8 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT8 Value
+ );
+
+/**
+ Reads a bit field in an 8-bit PCI configuration, performs a bitwise OR, and
+ writes the result back to the bit field in the 8-bit port.
+
+ Reads the 8-bit PCI configuration register specified by Address, performs a
+ bitwise inclusive OR between the read result and the value specified by
+ OrData, and writes the result to the 8-bit PCI configuration register
+ specified by Address. The value written to the PCI configuration register is
+ returned. This function must guarantee that all PCI read and write operations
+ are serialized. Extra left bits in OrData are stripped.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If StartBit is greater than 7, then ASSERT().
+ If EndBit is greater than 7, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..7.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..7.
+ @param OrData The value to OR with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciBitFieldOr8 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT8 OrData
+ );
+
+/**
+ Reads a bit field in an 8-bit PCI configuration register, performs a bitwise
+ AND, and writes the result back to the bit field in the 8-bit register.
+
+ Reads the 8-bit PCI configuration register specified by Address, performs a
+ bitwise AND between the read result and the value specified by AndData, and
+ writes the result to the 8-bit PCI configuration register specified by
+ Address. The value written to the PCI configuration register is returned.
+ This function must guarantee that all PCI read and write operations are
+ serialized. Extra left bits in AndData are stripped.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If StartBit is greater than 7, then ASSERT().
+ If EndBit is greater than 7, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..7.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..7.
+ @param AndData The value to AND with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciBitFieldAnd8 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT8 AndData
+ );
+
+/**
+ Reads a bit field in an 8-bit port, performs a bitwise AND followed by a
+ bitwise inclusive OR, and writes the result back to the bit field in the
+ 8-bit port.
+
+ Reads the 8-bit PCI configuration register specified by Address, performs a
+ bitwise AND followed by a bitwise inclusive OR between the read result and
+ the value specified by AndData, and writes the result to the 8-bit PCI
+ configuration register specified by Address. The value written to the PCI
+ configuration register is returned. This function must guarantee that all PCI
+ read and write operations are serialized. Extra left bits in both AndData and
+ OrData are stripped.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If StartBit is greater than 7, then ASSERT().
+ If EndBit is greater than 7, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..7.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..7.
+ @param AndData The value to AND with the PCI configuration register.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciBitFieldAndThenOr8 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT8 AndData,
+ IN UINT8 OrData
+ );
+
+/**
+ Reads a 16-bit PCI configuration register.
+
+ Reads and returns the 16-bit PCI configuration register specified by Address.
+ This function must guarantee that all PCI read and write operations are
+ serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 16-bit boundary, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+
+ @return The read value from the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciRead16 (
+ IN UINTN Address
+ );
+
+/**
+ Writes a 16-bit PCI configuration register.
+
+ Writes the 16-bit PCI configuration register specified by Address with the
+ value specified by Value. Value is returned. This function must guarantee
+ that all PCI read and write operations are serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 16-bit boundary, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param Value The value to write.
+
+ @return The value written to the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciWrite16 (
+ IN UINTN Address,
+ IN UINT16 Data
+ );
+
+/**
+ Performs a bitwise inclusive OR of a 16-bit PCI configuration register with
+ a 16-bit value.
+
+ Reads the 16-bit PCI configuration register specified by Address, performs a
+ bitwise inclusive OR between the read result and the value specified by
+ OrData, and writes the result to the 16-bit PCI configuration register
+ specified by Address. The value written to the PCI configuration register is
+ returned. This function must guarantee that all PCI read and write operations
+ are serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 16-bit boundary, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param OrData The value to OR with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciOr16 (
+ IN UINTN Address,
+ IN UINT16 OrData
+ );
+
+/**
+ Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit
+ value.
+
+ Reads the 16-bit PCI configuration register specified by Address, performs a
+ bitwise AND between the read result and the value specified by AndData, and
+ writes the result to the 16-bit PCI configuration register specified by
+ Address. The value written to the PCI configuration register is returned.
+ This function must guarantee that all PCI read and write operations are
+ serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 16-bit boundary, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param AndData The value to AND with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciAnd16 (
+ IN UINTN Address,
+ IN UINT16 AndData
+ );
+
+/**
+ Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit
+ value, followed a bitwise inclusive OR with another 16-bit value.
+
+ Reads the 16-bit PCI configuration register specified by Address, performs a
+ bitwise AND between the read result and the value specified by AndData,
+ performs a bitwise inclusive OR between the result of the AND operation and
+ the value specified by OrData, and writes the result to the 16-bit PCI
+ configuration register specified by Address. The value written to the PCI
+ configuration register is returned. This function must guarantee that all PCI
+ read and write operations are serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 16-bit boundary, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param AndData The value to AND with the PCI configuration register.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciAndThenOr16 (
+ IN UINTN Address,
+ IN UINT16 AndData,
+ IN UINT16 OrData
+ );
+
+/**
+ Reads a bit field of a PCI configuration register.
+
+ Reads the bit field in a 16-bit PCI configuration register. The bit field is
+ specified by the StartBit and the EndBit. The value of the bit field is
+ returned.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 16-bit boundary, then ASSERT().
+ If StartBit is greater than 15, then ASSERT().
+ If EndBit is greater than 15, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to read.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..15.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..15.
+
+ @return The value of the bit field read from the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciBitFieldRead16 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit
+ );
+
+/**
+ Writes a bit field to a PCI configuration register.
+
+ Writes Value to the bit field of the PCI configuration register. The bit
+ field is specified by the StartBit and the EndBit. All other bits in the
+ destination PCI configuration register are preserved. The new value of the
+ 16-bit register is returned.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 16-bit boundary, then ASSERT().
+ If StartBit is greater than 15, then ASSERT().
+ If EndBit is greater than 15, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..15.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..15.
+ @param Value New value of the bit field.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciBitFieldWrite16 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT16 Value
+ );
+
+/**
+ Reads a bit field in a 16-bit PCI configuration, performs a bitwise OR, and
+ writes the result back to the bit field in the 16-bit port.
+
+ Reads the 16-bit PCI configuration register specified by Address, performs a
+ bitwise inclusive OR between the read result and the value specified by
+ OrData, and writes the result to the 16-bit PCI configuration register
+ specified by Address. The value written to the PCI configuration register is
+ returned. This function must guarantee that all PCI read and write operations
+ are serialized. Extra left bits in OrData are stripped.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 16-bit boundary, then ASSERT().
+ If StartBit is greater than 15, then ASSERT().
+ If EndBit is greater than 15, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..15.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..15.
+ @param OrData The value to OR with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciBitFieldOr16 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT16 OrData
+ );
+
+/**
+ Reads a bit field in a 16-bit PCI configuration register, performs a bitwise
+ AND, and writes the result back to the bit field in the 16-bit register.
+
+ Reads the 16-bit PCI configuration register specified by Address, performs a
+ bitwise AND between the read result and the value specified by AndData, and
+ writes the result to the 16-bit PCI configuration register specified by
+ Address. The value written to the PCI configuration register is returned.
+ This function must guarantee that all PCI read and write operations are
+ serialized. Extra left bits in AndData are stripped.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 16-bit boundary, then ASSERT().
+ If StartBit is greater than 15, then ASSERT().
+ If EndBit is greater than 15, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..15.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..15.
+ @param AndData The value to AND with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciBitFieldAnd16 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT16 AndData
+ );
+
+/**
+ Reads a bit field in a 16-bit port, performs a bitwise AND followed by a
+ bitwise inclusive OR, and writes the result back to the bit field in the
+ 16-bit port.
+
+ Reads the 16-bit PCI configuration register specified by Address, performs a
+ bitwise AND followed by a bitwise inclusive OR between the read result and
+ the value specified by AndData, and writes the result to the 16-bit PCI
+ configuration register specified by Address. The value written to the PCI
+ configuration register is returned. This function must guarantee that all PCI
+ read and write operations are serialized. Extra left bits in both AndData and
+ OrData are stripped.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 16-bit boundary, then ASSERT().
+ If StartBit is greater than 15, then ASSERT().
+ If EndBit is greater than 15, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..15.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..15.
+ @param AndData The value to AND with the PCI configuration register.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciBitFieldAndThenOr16 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT16 AndData,
+ IN UINT16 OrData
+ );
+
+/**
+ Reads a 32-bit PCI configuration register.
+
+ Reads and returns the 32-bit PCI configuration register specified by Address.
+ This function must guarantee that all PCI read and write operations are
+ serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 32-bit boundary, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+
+ @return The read value from the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciRead32 (
+ IN UINTN Address
+ );
+
+/**
+ Writes a 32-bit PCI configuration register.
+
+ Writes the 32-bit PCI configuration register specified by Address with the
+ value specified by Value. Value is returned. This function must guarantee
+ that all PCI read and write operations are serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 32-bit boundary, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param Value The value to write.
+
+ @return The value written to the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciWrite32 (
+ IN UINTN Address,
+ IN UINT32 Data
+ );
+
+/**
+ Performs a bitwise inclusive OR of a 32-bit PCI configuration register with
+ a 32-bit value.
+
+ Reads the 32-bit PCI configuration register specified by Address, performs a
+ bitwise inclusive OR between the read result and the value specified by
+ OrData, and writes the result to the 32-bit PCI configuration register
+ specified by Address. The value written to the PCI configuration register is
+ returned. This function must guarantee that all PCI read and write operations
+ are serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 32-bit boundary, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param OrData The value to OR with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciOr32 (
+ IN UINTN Address,
+ IN UINT32 OrData
+ );
+
+/**
+ Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit
+ value.
+
+ Reads the 32-bit PCI configuration register specified by Address, performs a
+ bitwise AND between the read result and the value specified by AndData, and
+ writes the result to the 32-bit PCI configuration register specified by
+ Address. The value written to the PCI configuration register is returned.
+ This function must guarantee that all PCI read and write operations are
+ serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 32-bit boundary, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param AndData The value to AND with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciAnd32 (
+ IN UINTN Address,
+ IN UINT32 AndData
+ );
+
+/**
+ Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit
+ value, followed a bitwise inclusive OR with another 32-bit value.
+
+ Reads the 32-bit PCI configuration register specified by Address, performs a
+ bitwise AND between the read result and the value specified by AndData,
+ performs a bitwise inclusive OR between the result of the AND operation and
+ the value specified by OrData, and writes the result to the 32-bit PCI
+ configuration register specified by Address. The value written to the PCI
+ configuration register is returned. This function must guarantee that all PCI
+ read and write operations are serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 32-bit boundary, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param AndData The value to AND with the PCI configuration register.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciAndThenOr32 (
+ IN UINTN Address,
+ IN UINT32 AndData,
+ IN UINT32 OrData
+ );
+
+/**
+ Reads a bit field of a PCI configuration register.
+
+ Reads the bit field in a 32-bit PCI configuration register. The bit field is
+ specified by the StartBit and the EndBit. The value of the bit field is
+ returned.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 32-bit boundary, then ASSERT().
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to read.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+
+ @return The value of the bit field read from the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciBitFieldRead32 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit
+ );
+
+/**
+ Writes a bit field to a PCI configuration register.
+
+ Writes Value to the bit field of the PCI configuration register. The bit
+ field is specified by the StartBit and the EndBit. All other bits in the
+ destination PCI configuration register are preserved. The new value of the
+ 32-bit register is returned.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 32-bit boundary, then ASSERT().
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+ @param Value New value of the bit field.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciBitFieldWrite32 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT32 Value
+ );
+
+/**
+ Reads a bit field in a 32-bit PCI configuration, performs a bitwise OR, and
+ writes the result back to the bit field in the 32-bit port.
+
+ Reads the 32-bit PCI configuration register specified by Address, performs a
+ bitwise inclusive OR between the read result and the value specified by
+ OrData, and writes the result to the 32-bit PCI configuration register
+ specified by Address. The value written to the PCI configuration register is
+ returned. This function must guarantee that all PCI read and write operations
+ are serialized. Extra left bits in OrData are stripped.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 32-bit boundary, then ASSERT().
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+ @param OrData The value to OR with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciBitFieldOr32 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT32 OrData
+ );
+
+/**
+ Reads a bit field in a 32-bit PCI configuration register, performs a bitwise
+ AND, and writes the result back to the bit field in the 32-bit register.
+
+ Reads the 32-bit PCI configuration register specified by Address, performs a
+ bitwise AND between the read result and the value specified by AndData, and
+ writes the result to the 32-bit PCI configuration register specified by
+ Address. The value written to the PCI configuration register is returned.
+ This function must guarantee that all PCI read and write operations are
+ serialized. Extra left bits in AndData are stripped.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 32-bit boundary, then ASSERT().
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+ @param AndData The value to AND with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciBitFieldAnd32 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT32 AndData
+ );
+
+/**
+ Reads a bit field in a 32-bit port, performs a bitwise AND followed by a
+ bitwise inclusive OR, and writes the result back to the bit field in the
+ 32-bit port.
+
+ Reads the 32-bit PCI configuration register specified by Address, performs a
+ bitwise AND followed by a bitwise inclusive OR between the read result and
+ the value specified by AndData, and writes the result to the 32-bit PCI
+ configuration register specified by Address. The value written to the PCI
+ configuration register is returned. This function must guarantee that all PCI
+ read and write operations are serialized. Extra left bits in both AndData and
+ OrData are stripped.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 32-bit boundary, then ASSERT().
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+ @param AndData The value to AND with the PCI configuration register.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciBitFieldAndThenOr32 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT32 AndData,
+ IN UINT32 OrData
+ );
+
+/**
+ Reads a range of PCI configuration registers into a caller supplied buffer.
+
+ Reads the range of PCI configuration registers specified by StartAddress and
+ Size into the buffer specified by Buffer. This function only allows the PCI
+ configuration registers from a single PCI function to be read. Size is
+ returned. When possible 32-bit PCI configuration read cycles are used to read
+ from StartAdress to StartAddress + Size. Due to alignment restrictions, 8-bit
+ and 16-bit PCI configuration read cycles may be used at the beginning and the
+ end of the range.
+
+ If StartAddress > 0x0FFFFFFF, then ASSERT().
+ If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT().
+ If Size > 0 and Buffer is NULL, then ASSERT().
+
+ @param StartAddress Starting address that encodes the PCI Bus, Device,
+ Function and Register.
+ @param Size Size in bytes of the transfer.
+ @param Buffer Pointer to a buffer receiving the data read.
+
+ @return Size
+
+**/
+UINTN
+EFIAPI
+PciReadBuffer (
+ IN UINTN StartAddress,
+ IN UINTN Size,
+ OUT VOID *Buffer
+ );
+
+/**
+ Copies the data in a caller supplied buffer to a specified range of PCI
+ configuration space.
+
+ Writes the range of PCI configuration registers specified by StartAddress and
+ Size from the buffer specified by Buffer. This function only allows the PCI
+ configuration registers from a single PCI function to be written. Size is
+ returned. When possible 32-bit PCI configuration write cycles are used to
+ write from StartAdress to StartAddress + Size. Due to alignment restrictions,
+ 8-bit and 16-bit PCI configuration write cycles may be used at the beginning
+ and the end of the range.
+
+ If StartAddress > 0x0FFFFFFF, then ASSERT().
+ If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT().
+ If Size > 0 and Buffer is NULL, then ASSERT().
+
+ @param StartAddress Starting address that encodes the PCI Bus, Device,
+ Function and Register.
+ @param Size Size in bytes of the transfer.
+ @param Buffer Pointer to a buffer containing the data to write.
+
+ @return Size
+
+**/
+UINTN
+EFIAPI
+PciWriteBuffer (
+ IN UINTN StartAddress,
+ IN UINTN Size,
+ IN VOID *Buffer
+ );
+
+#endif
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeCoffGetEntryPointLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeCoffGetEntryPointLib.h
new file mode 100644
index 0000000..a82ea3c
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeCoffGetEntryPointLib.h
@@ -0,0 +1,93 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ EdkIIGluePeCoffGetEntryPointLib.h
+
+Abstract:
+
+ Public header file for PeCoff Get Entry Point Lib
+
+--*/
+
+#ifndef __EDKII_GLUE_PE_COFF_GET_ENTRY_POINT_LIB_H__
+#define __EDKII_GLUE_PE_COFF_GET_ENTRY_POINT_LIB_H__
+
+/**
+ Retrieves and returns a pointer to the entry point to a PE/COFF image that has been loaded
+ into system memory with the PE/COFF Loader Library functions.
+
+ Retrieves the entry point to the PE/COFF image specified by Pe32Data and returns this entry
+ point in EntryPoint. If the entry point could not be retrieved from the PE/COFF image, then
+ return RETURN_INVALID_PARAMETER. Otherwise return RETURN_SUCCESS.
+ If Pe32Data is NULL, then ASSERT().
+ If EntryPoint is NULL, then ASSERT().
+
+ @param Pe32Data Pointer to the PE/COFF image that is loaded in system memory.
+ @param EntryPoint Pointer to entry point to the PE/COFF image to return.
+
+ @retval RETURN_SUCCESS EntryPoint was returned.
+ @retval RETURN_INVALID_PARAMETER The entry point could not be found in the PE/COFF image.
+
+**/
+RETURN_STATUS
+EFIAPI
+PeCoffLoaderGetEntryPoint (
+ IN VOID *Pe32Data,
+ OUT VOID **EntryPoint
+ );
+
+/**
+ Returns the machine type of a PE/COFF image.
+
+ Returns the machine type from the PE/COFF image specified by Pe32Data.
+ If Pe32Data is NULL, then ASSERT().
+
+ @param Pe32Data Pointer to the PE/COFF image that is loaded in system
+ memory.
+
+ @return Machine type or zero if not a valid iamge.
+
+**/
+UINT16
+EFIAPI
+PeCoffLoaderGetMachineType (
+ IN VOID *Pe32Data
+ );
+
+/**
+ Returns a pointer to the PDB file name for a PE/COFF image that has been
+ loaded into system memory with the PE/COFF Loader Library functions.
+
+ Returns the PDB file name for the PE/COFF image specified by Pe32Data. If
+ the PE/COFF image specified by Pe32Data is not a valid, then NULL is
+ returned. If the PE/COFF image specified by Pe32Data does not contain a
+ debug directory entry, then NULL is returned. If the debug directory entry
+ in the PE/COFF image specified by Pe32Data does not contain a PDB file name,
+ then NULL is returned.
+ If Pe32Data is NULL, then ASSERT().
+
+ @param Pe32Data Pointer to the PE/COFF image that is loaded in system
+ memory.
+
+ @return The PDB file name for the PE/COFF image specified by Pe32Data or NULL
+ if it cannot be retrieved.
+
+**/
+VOID *
+EFIAPI
+PeCoffLoaderGetPdbPointer (
+ IN VOID *Pe32Data
+ );
+
+#endif
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeCoffLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeCoffLib.h
new file mode 100644
index 0000000..4c1f59f
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeCoffLib.h
@@ -0,0 +1,227 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ EdkIIGluePeCoffLib.h
+
+Abstract:
+
+ Public header file for PeCoff Lib
+
+--*/
+
+#ifndef __EDKII_GLUE_BASE_PE_COFF_LIB_H__
+#define __EDKII_GLUE_BASE_PE_COFF_LIB_H__
+
+
+#define PeCoffLoaderGetImageInfo(_IMAGECONTEXT) GluePeCoffLoaderGetImageInfo(_IMAGECONTEXT)
+#define PeCoffLoaderRelocateImage(_IMAGECONTEXT) GluePeCoffLoaderRelocateImage(_IMAGECONTEXT)
+#define PeCoffLoaderLoadImage(_IMAGECONTEXT) GluePeCoffLoaderLoadImage(_IMAGECONTEXT)
+#define PeCoffLoaderGetPeHeader(_IMAGECONTEXT, _HDR) GluePeCoffLoaderGetPeHeader(_IMAGECONTEXT, _HDR)
+#define PeCoffLoaderImageAddress(_IMAGECONTEXT, _ADR) GluePeCoffLoaderImageAddress(_IMAGECONTEXT, _ADR)
+#define PeCoffLoaderRelocateImage(_IMAGECONTEXT) GluePeCoffLoaderRelocateImage(_IMAGECONTEXT)
+#define PeCoffLoaderRelocateImageEx(_RELOC, _FIXUP, _FIXUPDATA, _ADJUST) \
+ GluePeCoffLoaderRelocateImageEx(_RELOC, _FIXUP, _FIXUPDATA, _ADJUST)
+#define PeHotRelocateImageEx(_RELOC, _FIXUP, _FIXUPDATA, _ADJUST) \
+ GluePeHotRelocateImageEx(_RELOC, _FIXUP, _FIXUPDATA, _ADJUST)
+
+
+//
+// Return status codes from the PE/COFF Loader services
+// BUGBUG: Find where used and see if can be replaced by RETURN_STATUS codes
+//
+#define IMAGE_ERROR_SUCCESS 0
+#define IMAGE_ERROR_IMAGE_READ 1
+#define IMAGE_ERROR_INVALID_PE_HEADER_SIGNATURE 2
+#define IMAGE_ERROR_INVALID_MACHINE_TYPE 3
+#define IMAGE_ERROR_INVALID_SUBSYSTEM 4
+#define IMAGE_ERROR_INVALID_IMAGE_ADDRESS 5
+#define IMAGE_ERROR_INVALID_IMAGE_SIZE 6
+#define IMAGE_ERROR_INVALID_SECTION_ALIGNMENT 7
+#define IMAGE_ERROR_SECTION_NOT_LOADED 8
+#define IMAGE_ERROR_FAILED_RELOCATION 9
+#define IMAGE_ERROR_FAILED_ICACHE_FLUSH 10
+
+//
+// PE/COFF Loader Read Function passed in by caller
+//
+typedef
+RETURN_STATUS
+(EFIAPI *PE_COFF_LOADER_READ_FILE) (
+ IN VOID *FileHandle,
+ IN UINTN FileOffset,
+ IN OUT UINTN *ReadSize,
+ OUT VOID *Buffer
+ );
+
+//
+// Context structure used while PE/COFF image is being loaded and relocated
+//
+typedef struct {
+ PHYSICAL_ADDRESS ImageAddress;
+ UINT64 ImageSize;
+ PHYSICAL_ADDRESS DestinationAddress;
+ PHYSICAL_ADDRESS EntryPoint;
+ PE_COFF_LOADER_READ_FILE ImageRead;
+ VOID *Handle;
+ VOID *FixupData;
+ UINT32 SectionAlignment;
+ UINT32 PeCoffHeaderOffset;
+ UINT32 DebugDirectoryEntryRva;
+ VOID *CodeView;
+ CHAR8 *PdbPointer;
+ UINTN SizeOfHeaders;
+ UINT32 ImageCodeMemoryType;
+ UINT32 ImageDataMemoryType;
+ UINT32 ImageError;
+ UINTN FixupDataSize;
+ UINT16 Machine;
+ UINT16 ImageType;
+ BOOLEAN RelocationsStripped;
+ BOOLEAN IsTeImage;
+} PE_COFF_LOADER_IMAGE_CONTEXT;
+
+
+/**
+ Retrieves information about a PE/COFF image.
+
+ Computes the PeCoffHeaderOffset, ImageAddress, ImageSize, DestinationAddress, CodeView,
+ PdbPointer, RelocationsStripped, SectionAlignment, SizeOfHeaders, and DebugDirectoryEntryRva
+ fields of the ImageContext structure. If ImageContext is NULL, then return RETURN_INVALID_PARAMETER.
+ If the PE/COFF image accessed through the ImageRead service in the ImageContext structure is not
+ a supported PE/COFF image type, then return RETURN_UNSUPPORTED. If any errors occur while
+ computing the fields of ImageContext, then the error status is returned in the ImageError field of
+ ImageContext.
+
+ @param ImageContext Pointer to the image context structure that describes the PE/COFF
+ image that needs to be examined by this function.
+
+ @retval RETURN_SUCCESS The information on the PE/COFF image was collected.
+ @retval RETURN_INVALID_PARAMETER ImageContext is NULL.
+ @retval RETURN_UNSUPPORTED The PE/COFF image is not supported.
+
+**/
+RETURN_STATUS
+EFIAPI
+GluePeCoffLoaderGetImageInfo (
+ IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
+ )
+;
+
+/**
+ Applies relocation fixups to a PE/COFF image that was loaded with PeCoffLoaderLoadImage().
+
+ If the DestinationAddress field of ImageContext is 0, then use the ImageAddress field of
+ ImageContext as the relocation base address. Otherwise, use the DestinationAddress field
+ of ImageContext as the relocation base address. The caller must allocate the relocation
+ fixup log buffer and fill in the FixupData field of ImageContext prior to calling this function.
+ If ImageContext is NULL, then ASSERT().
+
+ @param ImageContext Pointer to the image context structure that describes the PE/COFF
+ image that is being relocated.
+
+ @retval RETURN_SUCCESS The PE/COFF image was relocated.
+ Extended status information is in the ImageError field of ImageContext.
+ @retval RETURN_LOAD_ERROR The image in not a valid PE/COFF image.
+ Extended status information is in the ImageError field of ImageContext.
+ @retval RETURN_UNSUPPORTED A relocation record type is not supported.
+ Extended status information is in the ImageError field of ImageContext.
+
+**/
+RETURN_STATUS
+EFIAPI
+GluePeCoffLoaderRelocateImage (
+ IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
+ )
+;
+
+/**
+ Loads a PE/COFF image into memory.
+
+ Loads the PE/COFF image accessed through the ImageRead service of ImageContext into the buffer
+ specified by the ImageAddress and ImageSize fields of ImageContext. The caller must allocate
+ the load buffer and fill in the ImageAddress and ImageSize fields prior to calling this function.
+ The EntryPoint, FixupDataSize, CodeView, and PdbPointer fields of ImageContext are computed.
+ If ImageContext is NULL, then ASSERT().
+
+ @param ImageContext Pointer to the image context structure that describes the PE/COFF
+ image that is being loaded.
+
+ @retval RETURN_SUCCESS The PE/COFF image was loaded into the buffer specified by
+ the ImageAddress and ImageSize fields of ImageContext.
+ Extended status information is in the ImageError field of ImageContext.
+ @retval RETURN_BUFFER_TOO_SMALL The caller did not provide a large enough buffer.
+ Extended status information is in the ImageError field of ImageContext.
+ @retval RETURN_LOAD_ERROR The PE/COFF image is an EFI Runtime image with no relocations.
+ Extended status information is in the ImageError field of ImageContext.
+ @retval RETURN_INVALID_PARAMETER The image address is invalid.
+ Extended status information is in the ImageError field of ImageContext.
+
+**/
+RETURN_STATUS
+EFIAPI
+GluePeCoffLoaderLoadImage (
+ IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
+ )
+;
+
+
+/**
+ ImageRead function that operates on a memory buffer whos base is passed into
+ FileHandle.
+
+ @param FileHandle Ponter to baes of the input stream
+ @param FileOffset Offset to the start of the buffer
+ @param ReadSize Number of bytes to copy into the buffer
+ @param Buffer Location to place results of read
+
+ @retval RETURN_SUCCESS Data is read from FileOffset from the Handle into
+ the buffer.
+**/
+RETURN_STATUS
+EFIAPI
+PeCoffLoaderImageReadFromMemory (
+ IN VOID *FileHandle,
+ IN UINTN FileOffset,
+ IN OUT UINTN *ReadSize,
+ OUT VOID *Buffer
+ )
+;
+
+
+/**
+ Reapply fixups on a fixed up PE32/PE32+ image to allow virutal calling at EFI
+ runtime.
+
+ PE_COFF_LOADER_IMAGE_CONTEXT.FixupData stores information needed to reapply
+ the fixups with a virtual mapping.
+
+
+ @param ImageBase Base address of relocated image
+ @param VirtImageBase Virtual mapping for ImageBase
+ @param ImageSize Size of the image to relocate
+ @param RelocationData Location to place results of read
+
+**/
+VOID
+EFIAPI
+PeCoffLoaderRelocateImageForRuntime (
+ IN PHYSICAL_ADDRESS ImageBase,
+ IN PHYSICAL_ADDRESS VirtImageBase,
+ IN UINTN ImageSize,
+ IN VOID *RelocationData
+ )
+;
+
+
+#endif
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeiServicesLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeiServicesLib.h
new file mode 100644
index 0000000..32e6574
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeiServicesLib.h
@@ -0,0 +1,361 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ EdkIIGluePeiServicesLib.h
+
+Abstract:
+
+ Public header file for PEI Services Lib
+
+--*/
+
+#ifndef __EDKII_GLUE_PEI_SERVICES_LIB_H__
+#define __EDKII_GLUE_PEI_SERVICES_LIB_H__
+
+/**
+ This service enables a given PEIM to register an interface into the PEI Foundation.
+
+ @param PpiList A pointer to the list of interfaces that the caller shall install.
+
+ @retval EFI_SUCCESS The interface was successfully installed.
+ @retval EFI_INVALID_PARAMETER The PpiList pointer is NULL.
+ @retval EFI_INVALID_PARAMETER Any of the PEI PPI descriptors in the list do not have the
+ EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field.
+ @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database.
+
+**/
+EFI_STATUS
+EFIAPI
+PeiServicesInstallPpi (
+ IN EFI_PEI_PPI_DESCRIPTOR *PpiList
+ );
+
+/**
+ This service enables PEIMs to replace an entry in the PPI database with an alternate entry.
+
+ @param OldPpi Pointer to the old PEI PPI Descriptors.
+ @param NewPpi Pointer to the new PEI PPI Descriptors.
+
+ @retval EFI_SUCCESS The interface was successfully installed.
+ @retval EFI_INVALID_PARAMETER The OldPpi or NewPpi is NULL.
+ @retval EFI_INVALID_PARAMETER Any of the PEI PPI descriptors in the list do not have the
+ EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field.
+ @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database.
+ @retval EFI_NOT_FOUND The PPI for which the reinstallation was requested has not been
+ installed.
+
+**/
+EFI_STATUS
+EFIAPI
+PeiServicesReInstallPpi (
+ IN EFI_PEI_PPI_DESCRIPTOR *OldPpi,
+ IN EFI_PEI_PPI_DESCRIPTOR *NewPpi
+ );
+
+/**
+ This service enables PEIMs to discover a given instance of an interface.
+
+ @param Guid A pointer to the GUID whose corresponding interface needs to be
+ found.
+ @param Instance The N-th instance of the interface that is required.
+ @param PpiDescriptor A pointer to instance of the EFI_PEI_PPI_DESCRIPTOR.
+ @param Ppi A pointer to the instance of the interface.
+
+ @retval EFI_SUCCESS The interface was successfully returned.
+ @retval EFI_NOT_FOUND The PPI descriptor is not found in the database.
+
+**/
+EFI_STATUS
+EFIAPI
+PeiServicesLocatePpi (
+ IN EFI_GUID *Guid,
+ IN UINTN Instance,
+ IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor,
+ IN OUT VOID **Ppi
+ );
+
+/**
+ This service enables PEIMs to register a given service to be invoked when another service is
+ installed or reinstalled.
+
+ @param NotifyList A pointer to the list of notification interfaces that the caller
+ shall install.
+
+ @retval EFI_SUCCESS The interface was successfully installed.
+ @retval EFI_INVALID_PARAMETER The NotifyList pointer is NULL.
+ @retval EFI_INVALID_PARAMETER Any of the PEI notify descriptors in the list do not have the
+ EFI_PEI_PPI_DESCRIPTOR_NOTIFY_TYPES bit set in the Flags field.
+ @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database.
+
+**/
+EFI_STATUS
+EFIAPI
+PeiServicesNotifyPpi (
+ IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyList
+ );
+
+/**
+ This service enables PEIMs to ascertain the present value of the boot mode.
+
+ @param BootMode A pointer to contain the value of the boot mode.
+
+ @retval EFI_SUCCESS The boot mode was returned successfully.
+ @retval EFI_INVALID_PARAMETER BootMode is NULL.
+
+**/
+EFI_STATUS
+EFIAPI
+PeiServicesGetBootMode (
+ IN OUT EFI_BOOT_MODE *BootMode
+ );
+
+/**
+ This service enables PEIMs to update the boot mode variable.
+
+ @param BootMode The value of the boot mode to set.
+
+ @retval EFI_SUCCESS The value was successfully updated
+
+**/
+EFI_STATUS
+EFIAPI
+PeiServicesSetBootMode (
+ IN EFI_BOOT_MODE BootMode
+ );
+
+/**
+ This service enables a PEIM to ascertain the address of the list of HOBs in memory.
+
+ @param HobList A pointer to the list of HOBs that the PEI Foundation will initialize.
+
+ @retval EFI_SUCCESS The list was successfully returned.
+ @retval EFI_NOT_AVAILABLE_YET The HOB list is not yet published.
+
+**/
+EFI_STATUS
+EFIAPI
+PeiServicesGetHobList (
+ IN OUT VOID **HobList
+ );
+
+/**
+ This service enables PEIMs to create various types of HOBs.
+
+ @param Type The type of HOB to be installed.
+ @param Length The length of the HOB to be added.
+ @param Hob The address of a pointer that will contain the HOB header.
+
+ @retval EFI_SUCCESS The HOB was successfully created.
+ @retval EFI_OUT_OF_RESOURCES There is no additional space for HOB creation.
+
+**/
+EFI_STATUS
+EFIAPI
+PeiServicesCreateHob (
+ IN UINT16 Type,
+ IN UINT16 Length,
+ IN OUT VOID **Hob
+ );
+
+//;;## ...AMI_OVERRIDE... Support PI1.x
+#if (PI_SPECIFICATION_VERSION < 0x00010000)
+/**
+ This service enables PEIMs to discover additional firmware volumes.
+
+ @param Instance This instance of the firmware volume to find. The value 0 is the
+ Boot Firmware Volume (BFV).
+ @param FwVolHeader Pointer to the firmware volume header of the volume to return.
+
+ @retval EFI_SUCCESS The volume was found.
+ @retval EFI_NOT_FOUND The volume was not found.
+ @retval EFI_INVALID_PARAMETER FwVolHeader is NULL.
+
+**/
+EFI_STATUS
+EFIAPI
+PeiServicesFfsFindNextVolume (
+ IN UINTN Instance,
+ IN OUT EFI_FIRMWARE_VOLUME_HEADER **FwVolHeader
+ );
+
+/**
+ This service enables PEIMs to discover additional firmware files.
+
+ @param SearchType A filter to find files only of this type.
+ @param FwVolHeader Pointer to the firmware volume header of the volume to search.
+ This parameter must point to a valid FFS volume.
+ @param FileHeader Pointer to the current file from which to begin searching.
+
+ @retval EFI_SUCCESS The file was found.
+ @retval EFI_NOT_FOUND The file was not found.
+ @retval EFI_NOT_FOUND The header checksum was not zero.
+
+**/
+EFI_STATUS
+EFIAPI
+PeiServicesFfsFindNextFile (
+ IN EFI_FV_FILETYPE SearchType,
+ IN EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader,
+ IN OUT EFI_FFS_FILE_HEADER **FileHeader
+ );
+
+/**
+ This service enables PEIMs to discover sections of a given type within a valid FFS file.
+
+ @param SearchType The value of the section type to find.
+ @param FfsFileHeader A pointer to the file header that contains the set of sections to
+ be searched.
+ @param SectionData A pointer to the discovered section, if successful.
+
+ @retval EFI_SUCCESS The section was found.
+ @retval EFI_NOT_FOUND The section was not found.
+
+**/
+EFI_STATUS
+EFIAPI
+PeiServicesFfsFindSectionData (
+ IN EFI_SECTION_TYPE SectionType,
+ IN EFI_FFS_FILE_HEADER *FfsFileHeader,
+ IN OUT VOID **SectionData
+ );
+#endif
+
+/**
+ This service enables PEIMs to register the permanent memory configuration
+ that has been initialized with the PEI Foundation.
+
+ @param MemoryBegin The value of a region of installed memory.
+ @param MemoryLength The corresponding length of a region of installed memory.
+
+ @retval EFI_SUCCESS The region was successfully installed in a HOB.
+ @retval EFI_INVALID_PARAMETER MemoryBegin and MemoryLength are illegal for this system.
+ @retval EFI_OUT_OF_RESOURCES There is no additional space for HOB creation.
+
+**/
+EFI_STATUS
+EFIAPI
+PeiServicesInstallPeiMemory (
+ IN EFI_PHYSICAL_ADDRESS MemoryBegin,
+ IN UINT64 MemoryLength
+ );
+
+/**
+ This service enables PEIMs to allocate memory after the permanent memory has been installed by a
+ PEIM.
+
+ @param MemoryType Type of memory to allocate.
+ @param Pages Number of pages to allocate.
+ @param Memory Pointer of memory allocated.
+
+ @retval EFI_SUCCESS The memory range was successfully allocated.
+ @retval EFI_INVALID_PARAMETER Type is not equal to AllocateAnyPages.
+ @retval EFI_NOT_AVAILABLE_YET Called with permanent memory not available.
+ @retval EFI_OUT_OF_RESOURCES The pages could not be allocated.
+
+**/
+EFI_STATUS
+EFIAPI
+PeiServicesAllocatePages (
+ IN EFI_MEMORY_TYPE MemoryType,
+ IN UINTN Pages,
+ IN OUT EFI_PHYSICAL_ADDRESS *Memory
+ );
+
+/**
+ This service allocates memory from the Hand-Off Block (HOB) heap.
+
+ @param Size The number of bytes to allocate from the pool.
+ @param Buffer If the call succeeds, a pointer to a pointer to the allocate
+ buffer; undefined otherwise.
+
+ @retval EFI_SUCCESS The allocation was successful
+ @retval EFI_OUT_OF_RESOURCES There is not enough heap to allocate the requested size.
+
+**/
+EFI_STATUS
+EFIAPI
+PeiServicesAllocatePool (
+ IN UINTN Size,
+ OUT VOID **Buffer
+ );
+
+/**
+ This service resets the entire platform, including all processors and devices, and reboots the
+ system.
+
+ @retval EFI_NOT_AVAILABLE_YET The service has not been installed yet.
+
+**/
+EFI_STATUS
+EFIAPI
+PeiServicesResetSystem (
+ VOID
+ );
+
+/**
+ PCI read-modify-write operations.
+
+ PIWG's PI specification replaces Inte's EFI Specification 1.10.
+ EFI_PEI_PCI_CFG_PPI defined in Inte's EFI Specification 1.10 is replaced by
+ EFI_PEI_PCI_CFG2_PPI in PI 1.0. "Modify" function in these two PPI are not
+ compatibile with each other.
+
+ For Framework code that make the following call:
+ PciCfg->Modify (
+ PeiServices,
+ PciCfg,
+ Width,
+ Address,
+ SetBits,
+ ClearBits
+ );
+ it will be updated to the following code which call this library API:
+ PeiLibPciCfgModify (
+ PeiServices,
+ PciCfg,
+ Width,
+ Address,
+ SetBits,
+ ClearBits
+ );
+
+ @param PeiServices An indirect pointer to the PEI Services Table
+ published by the PEI Foundation.
+ @param PciCfg A pointer to the this pointer of EFI_PEI_PCI_CFG_PPI.
+ This parameter is unused as a place holder to make
+ the parameter list identical to PEI_PCI_CFG_PPI_RW.
+ @param Width The width of the access. Enumerated in bytes. Type
+ EFI_PEI_PCI_CFG_PPI_WIDTH is defined in Read().
+ @param Address The physical address of the access.
+ @param SetBits Points to value to bitwise-OR with the read configuration value.
+ The size of the value is determined by Width.
+ @param ClearBits Points to the value to negate and bitwise-AND with the read configuration value.
+ The size of the value is determined by Width.
+
+ @retval EFI_SUCCESS The function completed successfully.
+ @retval EFI_DEVICE_ERROR There was a problem with the transaction.
+**/
+EFI_STATUS
+EFIAPI
+PeiLibPciCfgModify (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_PCI_CFG_PPI *PciCfg,
+ IN PEI_PCI_CFG_PPI_WIDTH Width,
+ IN UINT64 Address,
+ IN UINTN SetBits,
+ IN UINTN ClearBits
+ )
+;
+
+#endif
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeiServicesTablePointerLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeiServicesTablePointerLib.h
new file mode 100644
index 0000000..7214558
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeiServicesTablePointerLib.h
@@ -0,0 +1,41 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ EdkIIGluePeiServicesTablePointerLib.h
+
+Abstract:
+
+ Public header file for PEI Services Table Pointer Lib
+
+--*/
+
+#ifndef __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_H__
+#define __EDKII_GLUE_PEI_SERVICES_TABLE_POINTER_LIB_H__
+
+/**
+ The function returns the pointer to PEI services.
+
+ The function returns the pointer to PEI services.
+ It will ASSERT() if the pointer to PEI services is NULL.
+
+ @retval The pointer to PeiServices.
+
+**/
+EFI_PEI_SERVICES **
+GetPeiServicesTablePointer (
+ VOID
+ );
+
+#endif
+
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeimEntryPoint.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeimEntryPoint.h
new file mode 100644
index 0000000..6febd76
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePeimEntryPoint.h
@@ -0,0 +1,111 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ EdkIIGluePeimEntryPoint.h
+
+Abstract:
+
+ Public header file for PEIM Entry Point Lib
+
+--*/
+
+#ifndef __EDKII_GLUE_PEIM_ENTRY_POINT_H__
+#define __EDKII_GLUE_PEIM_ENTRY_POINT_H__
+
+//
+// Declare the EFI/UEFI Specification Revision to which this driver is implemented
+//
+extern const UINT32 _gPeimRevision;
+
+/**
+ Image entry point of Peim.
+
+ @param FfsHeader Pointer to FFS header the loaded driver.
+ @param PeiServices Pointer to the PEI services.
+
+ @return Status returned by entry points of Peims.
+
+**/
+EFI_STATUS
+EFIAPI
+_ModuleEntryPoint (
+ IN EFI_FFS_FILE_HEADER *FfsHeader,
+ IN EFI_PEI_SERVICES **PeiServices
+ );
+
+
+/**
+ Wrapper of Peim image entry point.
+
+ @param FfsHeader Pointer to FFS header the loaded driver.
+ @param PeiServices Pointer to the PEI services.
+
+ @return Status returned by entry points of Peims.
+
+**/
+EFI_STATUS
+EFIAPI
+EfiMain (
+ IN EFI_FFS_FILE_HEADER *FfsHeader,
+ IN EFI_PEI_SERVICES **PeiServices
+ );
+
+
+/**
+ Call constructs for all libraries. Automatics Generated by tool.
+
+ @param FfsHeader Pointer to FFS header the loaded driver.
+ @param PeiServices Pointer to the PEI services.
+
+**/
+VOID
+EFIAPI
+ProcessLibraryConstructorList (
+ IN EFI_FFS_FILE_HEADER *FfsHeader,
+ IN EFI_PEI_SERVICES **PeiServices
+ );
+
+
+/**
+ Call destructors for all libraries. Automatics Generated by tool.
+
+ @param FfsHeader Pointer to FFS header the loaded driver.
+ @param PeiServices Pointer to the PEI services.
+
+**/
+VOID
+EFIAPI
+ProcessLibraryDestructorList (
+ IN EFI_FFS_FILE_HEADER *FfsHeader,
+ IN EFI_PEI_SERVICES **PeiServices
+ );
+
+
+/**
+ Call the list of driver entry points. Automatics Generated by tool.
+
+ @param FfsHeader Pointer to FFS header the loaded driver.
+ @param PeiServices Pointer to the PEI services.
+
+ @return Status returned by entry points of drivers.
+
+**/
+EFI_STATUS
+EFIAPI
+ProcessModuleEntryPointList (
+ IN EFI_FFS_FILE_HEADER *FfsHeader,
+ IN EFI_PEI_SERVICES **PeiServices
+ );
+
+#endif
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePostCodeLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePostCodeLib.h
new file mode 100644
index 0000000..2f561db
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePostCodeLib.h
@@ -0,0 +1,165 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ EdkIIGluePostCodeLib.h
+
+Abstract:
+
+ Public header file for Post Code Lib
+
+--*/
+
+#ifndef __EDKII_GLUE_POST_CODE_LIB_H__
+#define __EDKII_GLUE_POST_CODE_LIB_H__
+
+
+#define PostCode(_VALUE) GluePostCode(_VALUE)
+#define PostCodeWithDescription(_VALUE, _DESC) GluePostCodeWithDescription(_VALUE, _DESC)
+#define PostCodeEnabled() GluePostCodeEnabled()
+#define PostCodeDescriptionEnabled() GluePostCodeDescriptionEnabled()
+
+
+#define POST_CODE_PROPERTY_POST_CODE_ENABLED 0x00000008
+#define POST_CODE_PROPERTY_POST_CODE_DESCRIPTION_ENABLED 0x00000010
+
+/**
+ Sends an 32-bit value to a POST card.
+
+ Sends the 32-bit value specified by Value to a POST card, and returns Value.
+ Some implementations of this library function may perform I/O operations
+ directly to a POST card device. Other implementations may send Value to
+ ReportStatusCode(), and the status code reporting mechanism will eventually
+ display the 32-bit value on the status reporting device.
+
+ PostCode() must actively prevent recursion. If PostCode() is called while
+ processing another any other Report Status Code Library function, then
+ PostCode() must return Value immediately.
+
+ @param Value The 32-bit value to write to the POST card.
+
+ @return Value
+
+**/
+UINT32
+EFIAPI
+GluePostCode (
+ IN UINT32 Value
+ );
+
+
+/**
+ Sends an 32-bit value to a POST and associated ASCII string.
+
+ Sends the 32-bit value specified by Value to a POST card, and returns Value.
+ If Description is not NULL, then the ASCII string specified by Description is
+ also passed to the handler that displays the POST card value. Some
+ implementations of this library function may perform I/O operations directly
+ to a POST card device. Other implementations may send Value to ReportStatusCode(),
+ and the status code reporting mechanism will eventually display the 32-bit
+ value on the status reporting device.
+
+ PostCodeWithDescription()must actively prevent recursion. If
+ PostCodeWithDescription() is called while processing another any other Report
+ Status Code Library function, then PostCodeWithDescription() must return Value
+ immediately.
+
+ @param Value The 32-bit value to write to the POST card.
+ @param Description Pointer to an ASCII string that is a description of the
+ POST code value. This is an optional parameter that may
+ be NULL.
+
+ @return Value
+
+**/
+UINT32
+EFIAPI
+GluePostCodeWithDescription (
+ IN UINT32 Value,
+ IN CONST CHAR8 *Description OPTIONAL
+ );
+
+
+/**
+ Returns TRUE if POST Codes are enabled.
+
+ This function returns TRUE if the POST_CODE_PROPERTY_POST_CODE_ENABLED
+ bit of PcdPostCodePropertyMask is set. Otherwise FALSE is returned.
+
+ @retval TRUE The POST_CODE_PROPERTY_POST_CODE_ENABLED bit of
+ PcdPostCodeProperyMask is set.
+ @retval FALSE The POST_CODE_PROPERTY_POST_CODE_ENABLED bit of
+ PcdPostCodeProperyMask is clear.
+
+**/
+BOOLEAN
+EFIAPI
+GluePostCodeEnabled (
+ VOID
+ );
+
+
+/**
+ Returns TRUE if POST code descriptions are enabled.
+
+ This function returns TRUE if the
+ POST_CODE_PROPERTY_POST_CODE_ENABLED bit of
+ PcdPostCodePropertyMask is set. Otherwise FALSE is returned.
+
+ @retval TRUE The POST_CODE_PROPERTY_POST_CODE_ENABLED
+ bit of PcdPostCodeProperyMask is set.
+ @retval FALSE The POST_CODE_PROPERTY_POST_CODE_ENABLED
+ bit of PcdPostCodeProperyMask is clear.
+
+**/
+BOOLEAN
+EFIAPI
+GluePostCodeDescriptionEnabled (
+ VOID
+ );
+
+
+/**
+ Sends an 32-bit value to a POST card.
+
+ If POST codes are enabled in PcdPostCodeProperyMask, then call PostCode()
+ passing in Value. Value is returned.
+
+ @param Value The 32-bit value to write to the POST card.
+
+ @return Value
+
+**/
+#define POST_CODE(Value) PostCodeEnabled() ? PostCode(Value) : Value
+
+/**
+ Sends an 32-bit value to a POST and associated ASCII string.
+
+ If POST codes and POST code descriptions are enabled in
+ PcdPostCodeProperyMask, then call PostCodeWithDescription() passing in
+ Value and Description. If only POST codes are enabled, then call PostCode()
+ passing in Value. Value is returned.
+
+ @param Value The 32-bit value to write to the POST card.
+ @param Description Pointer to an ASCII string that is a description of the
+ POST code value.
+
+**/
+#define POST_CODE_WITH_DESCRIPTION(Value,Description) \
+ PostCodeEnabled() ? \
+ (PostCodeDescriptionEnabled() ? \
+ PostCodeWithDescription(Value,Description) : \
+ PostCode(Value)) : \
+ Value
+
+#endif
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePrintLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePrintLib.h
new file mode 100644
index 0000000..314f578
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGluePrintLib.h
@@ -0,0 +1,481 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ EdkIIGluePrintLib.h
+
+Abstract:
+
+ Public header file Print Lib
+
+--*/
+
+#ifndef __EDKII_GLUE_PRINT_LIB_H__
+#define __EDKII_GLUE_PRINT_LIB_H__
+
+///
+/// Define the maximum number of characters that are required to
+/// encode a decimal, hexidecimal, GUID, or TIME value with a NULL
+/// terminator.
+///
+/// Maximum Length Decimal String = 28
+/// "-9,223,372,036,854,775,808"
+/// Maximum Length Hexidecimal String = 17
+/// "FFFFFFFFFFFFFFFF"
+/// Maximum Length GUID = 37
+/// "00000000-0000-0000-0000-000000000000"
+/// Maximum Length TIME = 18
+/// "12/12/2006 12:12"
+///
+#define MAXIMUM_VALUE_CHARACTERS 38
+
+///
+/// Flags bitmask values use in UnicodeValueToString() and
+/// AsciiValueToString()
+///
+#define LEFT_JUSTIFY 0x01
+#define COMMA_TYPE 0x08
+#define PREFIX_ZERO 0x20
+#define RADIX_HEX 0x80
+
+/**
+ Produces a Null-terminated Unicode string in an output buffer based on
+ a Null-terminated Unicode format string and a VA_LIST argument list
+
+ Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer
+ and BufferSize.
+ The Unicode string is produced by parsing the format string specified by FormatString.
+ Arguments are pulled from the variable argument list specified by Marker based on the
+ contents of the format string.
+ The number of Unicode characters in the produced output buffer is returned not including
+ the Null-terminator.
+ If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.
+
+ If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().
+ If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().
+ If BufferSize > 1 and FormatString is NULL, then ASSERT().
+ If BufferSize > 1 and FormatString is not aligned on a 16-bit boundary, then ASSERT().
+ If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
+ PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
+ ASSERT().
+ If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string
+ contains more than PcdMaximumUnicodeStringLength Unicode characters not including the
+ Null-terminator, then ASSERT().
+
+ @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
+ Unicode string.
+ @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
+ @param FormatString Null-terminated Unicode format string.
+ @param Marker VA_LIST marker for the variable argument list.
+
+ @return The number of Unicode characters in the produced output buffer not including the
+ Null-terminator.
+
+**/
+UINTN
+EFIAPI
+UnicodeVSPrint (
+ OUT CHAR16 *StartOfBuffer,
+ IN UINTN BufferSize,
+ IN CONST CHAR16 *FormatString,
+ IN VA_LIST Marker
+ );
+
+/**
+ Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated
+ Unicode format string and variable argument list.
+
+ Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer
+ and BufferSize.
+ The Unicode string is produced by parsing the format string specified by FormatString.
+ Arguments are pulled from the variable argument list based on the contents of the format string.
+ The number of Unicode characters in the produced output buffer is returned not including
+ the Null-terminator.
+ If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.
+
+ If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().
+ If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().
+ If BufferSize > 1 and FormatString is NULL, then ASSERT().
+ If BufferSize > 1 and FormatString is not aligned on a 16-bit boundary, then ASSERT().
+ If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
+ PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
+ ASSERT().
+ If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string
+ contains more than PcdMaximumUnicodeStringLength Unicode characters not including the
+ Null-terminator, then ASSERT().
+
+ @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
+ Unicode string.
+ @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
+ @param FormatString Null-terminated Unicode format string.
+
+ @return The number of Unicode characters in the produced output buffer not including the
+ Null-terminator.
+
+**/
+UINTN
+EFIAPI
+UnicodeSPrint (
+ OUT CHAR16 *StartOfBuffer,
+ IN UINTN BufferSize,
+ IN CONST CHAR16 *FormatString,
+ ...
+ );
+
+/**
+ Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated
+ ASCII format string and a VA_LIST argument list
+
+ Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer
+ and BufferSize.
+ The Unicode string is produced by parsing the format string specified by FormatString.
+ Arguments are pulled from the variable argument list specified by Marker based on the
+ contents of the format string.
+ The number of Unicode characters in the produced output buffer is returned not including
+ the Null-terminator.
+ If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.
+
+ If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().
+ If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().
+ If BufferSize > 1 and FormatString is NULL, then ASSERT().
+ If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
+ PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then
+ ASSERT().
+ If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string
+ contains more than PcdMaximumUnicodeStringLength Unicode characters not including the
+ Null-terminator, then ASSERT().
+
+ @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
+ Unicode string.
+ @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
+ @param FormatString Null-terminated Unicode format string.
+ @param Marker VA_LIST marker for the variable argument list.
+
+ @return The number of Unicode characters in the produced output buffer not including the
+ Null-terminator.
+
+**/
+UINTN
+EFIAPI
+UnicodeVSPrintAsciiFormat (
+ OUT CHAR16 *StartOfBuffer,
+ IN UINTN BufferSize,
+ IN CONST CHAR8 *FormatString,
+ IN VA_LIST Marker
+ );
+
+/**
+ Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated
+ ASCII format string and variable argument list.
+
+ Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer
+ and BufferSize.
+ The Unicode string is produced by parsing the format string specified by FormatString.
+ Arguments are pulled from the variable argument list based on the contents of the
+ format string.
+ The number of Unicode characters in the produced output buffer is returned not including
+ the Null-terminator.
+ If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.
+
+ If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().
+ If BufferSize > 1 and StartOfBuffer is not aligned on a 16-bit boundary, then ASSERT().
+ If BufferSize > 1 and FormatString is NULL, then ASSERT().
+ If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
+ PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then
+ ASSERT().
+ If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string
+ contains more than PcdMaximumUnicodeStringLength Unicode characters not including the
+ Null-terminator, then ASSERT().
+
+ @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
+ Unicode string.
+ @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
+ @param FormatString Null-terminated Unicode format string.
+
+ @return The number of Unicode characters in the produced output buffer not including the
+ Null-terminator.
+
+**/
+UINTN
+EFIAPI
+UnicodeSPrintAsciiFormat (
+ OUT CHAR16 *StartOfBuffer,
+ IN UINTN BufferSize,
+ IN CONST CHAR8 *FormatString,
+ ...
+ );
+
+/**
+ Converts a decimal value to a Null-terminated Unicode string.
+
+ Converts the decimal number specified by Value to a Null-terminated Unicode
+ string specified by Buffer containing at most Width characters. No padding of spaces
+ is ever performed. If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.
+ The number of Unicode characters in Buffer is returned not including the Null-terminator.
+ If the conversion contains more than Width characters, then only the first
+ Width characters are returned, and the total number of characters
+ required to perform the conversion is returned.
+ Additional conversion parameters are specified in Flags.
+
+ The Flags bit LEFT_JUSTIFY is always ignored.
+ All conversions are left justified in Buffer.
+ If Width is 0, PREFIX_ZERO is ignored in Flags.
+ If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas
+ are inserted every 3rd digit starting from the right.
+ If HEX_RADIX is set in Flags, then the output buffer will be
+ formatted in hexadecimal format.
+ If Value is < 0 and HEX_RADIX is not set in Flags, then the fist character in Buffer is a '-'.
+ If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored,
+ then Buffer is padded with '0' characters so the combination of the optional '-'
+ sign character, '0' characters, digit characters for Value, and the Null-terminator
+ add up to Width characters.
+ If both COMMA_TYPE and HEX_RADIX are set in Flags, then ASSERT().
+ If Buffer is NULL, then ASSERT().
+ If Buffer is not aligned on a 16-bit boundary, then ASSERT().
+ If unsupported bits are set in Flags, then ASSERT().
+ If both COMMA_TYPE and HEX_RADIX are set in Flags, then ASSERT().
+ If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()
+
+ @param Buffer Pointer to the output buffer for the produced Null-terminated
+ Unicode string.
+ @param Flags The bitmask of flags that specify left justification, zero pad, and commas.
+ @param Value The 64-bit signed value to convert to a string.
+ @param Width The maximum number of Unicode characters to place in Buffer, not including
+ the Null-terminator.
+
+ @return The number of Unicode characters in Buffer not including the Null-terminator.
+
+**/
+UINTN
+EFIAPI
+UnicodeValueToString (
+ IN OUT CHAR16 *Buffer,
+ IN UINTN Flags,
+ IN INT64 Value,
+ IN UINTN Width
+ );
+
+/**
+ Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
+ ASCII format string and a VA_LIST argument list.
+
+ Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
+ and BufferSize.
+ The ASCII string is produced by parsing the format string specified by FormatString.
+ Arguments are pulled from the variable argument list specified by Marker based on
+ the contents of the format string.
+ The number of ASCII characters in the produced output buffer is returned not including
+ the Null-terminator.
+ If BufferSize is 0, then no output buffer is produced and 0 is returned.
+
+ If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().
+ If BufferSize > 0 and FormatString is NULL, then ASSERT().
+ If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
+ PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then
+ ASSERT().
+ If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string
+ contains more than PcdMaximumAsciiStringLength ASCII characters not including the
+ Null-terminator, then ASSERT().
+
+ @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
+ ASCII string.
+ @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
+ @param FormatString Null-terminated Unicode format string.
+ @param Marker VA_LIST marker for the variable argument list.
+
+ @return The number of ASCII characters in the produced output buffer not including the
+ Null-terminator.
+
+**/
+UINTN
+EFIAPI
+AsciiVSPrint (
+ OUT CHAR8 *StartOfBuffer,
+ IN UINTN BufferSize,
+ IN CONST CHAR8 *FormatString,
+ IN VA_LIST Marker
+ );
+
+/**
+ Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
+ ASCII format string and variable argument list.
+
+ Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
+ and BufferSize.
+ The ASCII string is produced by parsing the format string specified by FormatString.
+ Arguments are pulled from the variable argument list based on the contents of the
+ format string.
+ The number of ASCII characters in the produced output buffer is returned not including
+ the Null-terminator.
+ If BufferSize is 0, then no output buffer is produced and 0 is returned.
+
+ If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().
+ If BufferSize > 0 and FormatString is NULL, then ASSERT().
+ If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
+ PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then
+ ASSERT().
+ If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string
+ contains more than PcdMaximumAsciiStringLength ASCII characters not including the
+ Null-terminator, then ASSERT().
+
+ @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
+ ASCII string.
+ @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
+ @param FormatString Null-terminated Unicode format string.
+
+ @return The number of ASCII characters in the produced output buffer not including the
+ Null-terminator.
+
+**/
+UINTN
+EFIAPI
+AsciiSPrint (
+ OUT CHAR8 *StartOfBuffer,
+ IN UINTN BufferSize,
+ IN CONST CHAR8 *FormatString,
+ ...
+ );
+
+/**
+ Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
+ ASCII format string and a VA_LIST argument list.
+
+ Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
+ and BufferSize.
+ The ASCII string is produced by parsing the format string specified by FormatString.
+ Arguments are pulled from the variable argument list specified by Marker based on
+ the contents of the format string.
+ The number of ASCII characters in the produced output buffer is returned not including
+ the Null-terminator.
+ If BufferSize is 0, then no output buffer is produced and 0 is returned.
+
+ If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().
+ If BufferSize > 0 and FormatString is NULL, then ASSERT().
+ If BufferSize > 0 and FormatString is not aligned on a 16-bit boundary, then ASSERT().
+ If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
+ PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
+ ASSERT().
+ If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string
+ contains more than PcdMaximumAsciiStringLength ASCII characters not including the
+ Null-terminator, then ASSERT().
+
+ @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
+ ASCII string.
+ @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
+ @param FormatString Null-terminated Unicode format string.
+ @param Marker VA_LIST marker for the variable argument list.
+
+ @return The number of ASCII characters in the produced output buffer not including the
+ Null-terminator.
+
+**/
+UINTN
+EFIAPI
+AsciiVSPrintUnicodeFormat (
+ OUT CHAR8 *StartOfBuffer,
+ IN UINTN BufferSize,
+ IN CONST CHAR16 *FormatString,
+ IN VA_LIST Marker
+ );
+
+/**
+ Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
+ ASCII format string and variable argument list.
+
+ Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
+ and BufferSize.
+ The ASCII string is produced by parsing the format string specified by FormatString.
+ Arguments are pulled from the variable argument list based on the contents of the
+ format string.
+ The number of ASCII characters in the produced output buffer is returned not including
+ the Null-terminator.
+ If BufferSize is 0, then no output buffer is produced and 0 is returned.
+
+ If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().
+ If BufferSize > 0 and FormatString is NULL, then ASSERT().
+ If BufferSize > 0 and FormatString is not aligned on a 16-bit boundary, then ASSERT().
+ If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
+ PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
+ ASSERT().
+ If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string
+ contains more than PcdMaximumAsciiStringLength ASCII characters not including the
+ Null-terminator, then ASSERT().
+
+ @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
+ ASCII string.
+ @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
+ @param FormatString Null-terminated Unicode format string.
+
+ @return The number of ASCII characters in the produced output buffer not including the
+ Null-terminator.
+
+**/
+UINTN
+EFIAPI
+AsciiSPrintUnicodeFormat (
+ OUT CHAR8 *StartOfBuffer,
+ IN UINTN BufferSize,
+ IN CONST CHAR16 *FormatString,
+ ...
+ );
+
+/**
+ Converts a decimal value to a Null-terminated ASCII string.
+
+ Converts the decimal number specified by Value to a Null-terminated ASCII string
+ specified by Buffer containing at most Width characters. No padding of spaces
+ is ever performed.
+ If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.
+ The number of ASCII characters in Buffer is returned not including the Null-terminator.
+ If the conversion contains more than Width characters, then only the first Width
+ characters are returned, and the total number of characters required to perform
+ the conversion is returned.
+ Additional conversion parameters are specified in Flags.
+ The Flags bit LEFT_JUSTIFY is always ignored.
+ All conversions are left justified in Buffer.
+ If Width is 0, PREFIX_ZERO is ignored in Flags.
+ If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas
+ are inserted every 3rd digit starting from the right.
+ If HEX_RADIX is set in Flags, then the output buffer will be
+ formatted in hexadecimal format.
+ If Value is < 0 and HEX_RADIX is not set in Flags, then the fist character in Buffer is a '-'.
+ If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored,
+ then Buffer is padded with '0' characters so the combination of the optional '-'
+ sign character, '0' characters, digit characters for Value, and the Null-terminator
+ add up to Width characters.
+
+ If Buffer is NULL, then ASSERT().
+ If unsupported bits are set in Flags, then ASSERT().
+ If both COMMA_TYPE and HEX_RADIX are set in Flags, then ASSERT().
+ If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()
+
+ @param Buffer Pointer to the output buffer for the produced Null-terminated
+ ASCII string.
+ @param Flags The bitmask of flags that specify left justification, zero pad, and commas.
+ @param Value The 64-bit signed value to convert to a string.
+ @param Width The maximum number of ASCII characters to place in Buffer, not including
+ the Null-terminator.
+
+ @return The number of ASCII characters in Buffer not including the Null-terminator.
+
+**/
+UINTN
+EFIAPI
+AsciiValueToString (
+ IN OUT CHAR8 *Buffer,
+ IN UINTN Flags,
+ IN INT64 Value,
+ IN UINTN Width
+ );
+
+#endif
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueReportStatusCodeLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueReportStatusCodeLib.h
new file mode 100644
index 0000000..aaad1a0
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueReportStatusCodeLib.h
@@ -0,0 +1,659 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ EdkIIGlueReportStatusCodeLib.h
+
+Abstract:
+
+ Public header file for Report Status Code Lib
+
+--*/
+
+#ifndef __EDKII_GLUE_REPORT_STATUS_CODE_LIB_H__
+#define __EDKII_GLUE_REPORT_STATUS_CODE_LIB_H__
+
+
+
+#define CodeTypeToPostCode(_CODETYPE, _VALUE, _POSTCODE) GlueCodeTypeToPostCode(_CODETYPE, _VALUE, _POSTCODE)
+#define ReportStatusCodeExtractAssertInfo(_CODETYPE, _VALUE, _DATA, _FILENAME, _DESC, _LINENUMBER) \
+ GlueReportStatusCodeExtractAssertInfo(_CODETYPE, _VALUE, _DATA, _FILENAME, _DESC, _LINENUMBER)
+#define ReportStatusCodeExtractDebugInfo(_DATA, _ERRORLEVEL, _MARKER, _FORMAT) \
+ GlueReportStatusCodeExtractDebugInfo(_DATA, _ERRORLEVEL, _MARKER, _FORMAT)
+#define ReportStatusCode(_TYPE, _VALUE) GlueReportStatusCode(_TYPE, _VALUE)
+#define ReportStatusCodeWithDevicePath(_TYPE, _VALUE, _DEVICEPATH) \
+ GlueReportStatusCodeWithDevicePath(_TYPE, _VALUE, _DEVICEPATH)
+#define ReportStatusCodeWithExtendedData(_TYPE, _VALUE, _EXDATA, _EXDATASIZE) \
+ GlueReportStatusCodeWithExtendedData(_TYPE, _VALUE, _EXDATA, _EXDATASIZE)
+#define ReportStatusCodeEx(_TYPE, _VALUE, _INSTANCE, _CALLERID, _EXDATAGUID, _EXDATA, _EXDATASIZE) \
+ GlueReportStatusCodeEx(_TYPE, _VALUE, _INSTANCE, _CALLERID, _EXDATAGUID, _EXDATA, _EXDATASIZE)
+#define ReportProgressCodeEnabled() GlueReportProgressCodeEnabled()
+#define ReportErrorCodeEnabled() GlueReportErrorCodeEnabled()
+#define ReportDebugCodeEnabled() GlueReportDebugCodeEnabled()
+
+
+//
+// Declare bits for PcdReportStatusCodePropertyMask
+//
+#define REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED 0x00000001
+#define REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED 0x00000002
+#define REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED 0x00000004
+
+//
+// Extended Data structure definitions with EFI_STATUS_CODE_DATA headers removed
+//
+
+///
+/// Voltage Extended Error Data
+///
+typedef struct {
+ EFI_EXP_BASE10_DATA Voltage;
+ EFI_EXP_BASE10_DATA Threshold;
+} REPORT_STATUS_CODE_LIBRARY_COMPUTING_UNIT_VOLTAGE_ERROR_DATA;
+
+///
+/// Microcode Update Extended Error Data
+///
+typedef struct {
+ UINT32 Version;
+} REPORT_STATUS_CODE_LIBRARY_COMPUTING_UNIT_MICROCODE_UPDATE_ERROR_DATA;
+
+///
+/// Asynchronous Timer Extended Error Data
+///
+typedef struct {
+ EFI_EXP_BASE10_DATA TimerLimit;
+} REPORT_STATUS_CODE_LIBRARY_COMPUTING_UNIT_TIMER_EXPIRED_ERROR_DATA;
+
+///
+/// Host Processor Mismatch Extended Error Data
+///
+typedef struct {
+ UINT32 Instance;
+ UINT16 Attributes;
+} REPORT_STATUS_CODE_LIBRARY_HOST_PROCESSOR_MISMATCH_ERROR_DATA;
+
+///
+/// Thermal Extended Error Data
+///
+typedef struct {
+ EFI_EXP_BASE10_DATA Temperature;
+ EFI_EXP_BASE10_DATA Threshold;
+} REPORT_STATUS_CODE_LIBRARY_COMPUTING_UNIT_THERMAL_ERROR_DATA;
+
+///
+/// Processor Disabled Extended Error Data
+///
+typedef struct {
+ UINT32 Cause;
+ BOOLEAN SoftwareDisabled;
+} REPORT_STATUS_CODE_LIBRARY_COMPUTING_UNIT_CPU_DISABLED_ERROR_DATA;
+
+///
+/// Embedded cache init extended data
+///
+typedef struct {
+ UINT32 Level;
+ EFI_INIT_CACHE_TYPE Type;
+} REPORT_STATUS_CODE_LIBRARY_CACHE_INIT_DATA;
+
+///
+/// Memory Extended Error Data
+///
+typedef struct {
+ EFI_MEMORY_ERROR_GRANULARITY Granularity;
+ EFI_MEMORY_ERROR_OPERATION Operation;
+ UINTN Syndrome;
+ EFI_PHYSICAL_ADDRESS Address;
+ UINTN Resolution;
+} REPORT_STATUS_CODE_LIBRARY_MEMORY_EXTENDED_ERROR_DATA;
+
+///
+/// DIMM number
+///
+typedef struct {
+ UINT16 Array;
+ UINT16 Device;
+} REPORT_STATUS_CODE_LIBRARY_STATUS_CODE_DIMM_NUMBER;
+
+///
+/// Memory Module Mismatch Extended Error Data
+///
+typedef struct {
+ EFI_STATUS_CODE_DIMM_NUMBER Instance;
+} REPORT_STATUS_CODE_LIBRARY_MEMORY_MODULE_MISMATCH_ERROR_DATA;
+
+///
+/// Memory Range Extended Data
+///
+typedef struct {
+ EFI_PHYSICAL_ADDRESS Start;
+ EFI_PHYSICAL_ADDRESS Length;
+} REPORT_STATUS_CODE_LIBRARY_MEMORY_RANGE_EXTENDED_DATA;
+
+///
+/// Device handle Extended Data. Used for many
+/// errors and progress codes to point to the device.
+///
+typedef struct {
+ EFI_HANDLE Handle;
+} REPORT_STATUS_CODE_LIBRARY_DEVICE_HANDLE_EXTENDED_DATA;
+
+typedef struct {
+ UINT8 *DevicePath;
+} REPORT_STATUS_CODE_LIBRARY_DEVICE_PATH_EXTENDED_DATA;
+
+typedef struct {
+ EFI_HANDLE ControllerHandle;
+ EFI_HANDLE DriverBindingHandle;
+ UINT16 DevicePathSize;
+ UINT8 *RemainingDevicePath;
+} REPORT_STATUS_CODE_LIBRARY_STATUS_CODE_START_EXTENDED_DATA;
+
+///
+/// Resource Allocation Failure Extended Error Data
+///
+typedef struct {
+ UINT32 Bar;
+ UINT16 DevicePathSize;
+ UINT16 ReqResSize;
+ UINT16 AllocResSize;
+ UINT8 *DevicePath;
+ UINT8 *ReqRes;
+ UINT8 *AllocRes;
+} REPORT_STATUS_CODE_LIBRARY_RESOURCE_ALLOC_FAILURE_ERROR_DATA;
+
+///
+/// Extended Error Data for Assert
+///
+typedef struct {
+ UINT32 LineNumber;
+ UINT32 FileNameSize;
+ EFI_STATUS_CODE_STRING_DATA *FileName;
+} REPORT_STATUS_CODE_LIBRARY_DEBUG_ASSERT_DATA;
+
+///
+/// System Context Data EBC/IA32/IPF
+///
+typedef struct {
+ EFI_STATUS_CODE_EXCEP_SYSTEM_CONTEXT Context;
+} REPORT_STATUS_CODE_LIBRARY_STATUS_CODE_EXCEP_EXTENDED_DATA;
+
+///
+/// Legacy Oprom extended data
+///
+typedef struct {
+ EFI_HANDLE DeviceHandle;
+ EFI_PHYSICAL_ADDRESS RomImageBase;
+} REPORT_STATUS_CODE_LIBRARY_LEGACY_OPROM_EXTENDED_DATA;
+
+//
+// Extern for the modules Caller ID GUID
+//
+extern EFI_GUID gEfiCallerIdGuid;
+
+/**
+ Converts a status code to an 8-bit POST code value.
+
+ Converts the status code specified by CodeType and Value to an 8-bit POST code
+ and returns the 8-bit POST code in PostCode. If CodeType is an
+ EFI_PROGRESS_CODE or CodeType is an EFI_ERROR_CODE, then bits 0..4 of PostCode
+ are set to bits 16..20 of Value, and bits 5..7 of PostCode are set to bits
+ 24..26 of Value., and TRUE is returned. Otherwise, FALSE is returned.
+
+ If PostCode is NULL, then ASSERT().
+
+ @param CodeType The type of status code being converted.
+ @param Value The status code value being converted.
+ @param PostCode A pointer to the 8-bit POST code value to return.
+
+ @retval TRUE The status code specified by CodeType and Value was converted
+ to an 8-bit POST code and returned in PostCode.
+ @retval FALSE The status code specified by CodeType and Value could not be
+ converted to an 8-bit POST code value.
+
+**/
+BOOLEAN
+EFIAPI
+GlueCodeTypeToPostCode (
+ IN EFI_STATUS_CODE_TYPE CodeType,
+ IN EFI_STATUS_CODE_VALUE Value,
+ OUT UINT8 *PostCode
+ );
+
+
+/**
+ Extracts ASSERT() information from a status code structure.
+
+ Converts the status code specified by CodeType, Value, and Data to the ASSERT()
+ arguments specified by Filename, Description, and LineNumber. If CodeType is
+ an EFI_ERROR_CODE, and CodeType has a severity of EFI_ERROR_UNRECOVERED, and
+ Value has an operation mask of EFI_SW_EC_ILLEGAL_SOFTWARE_STATE, extract
+ Filename, Description, and LineNumber from the optional data area of the
+ status code buffer specified by Data. The optional data area of Data contains
+ a Null-terminated ASCII string for the FileName, followed by a Null-terminated
+ ASCII string for the Description, followed by a 32-bit LineNumber. If the
+ ASSERT() information could be extracted from Data, then return TRUE.
+ Otherwise, FALSE is returned.
+
+ If Data is NULL, then ASSERT().
+ If Filename is NULL, then ASSERT().
+ If Description is NULL, then ASSERT().
+ If LineNumber is NULL, then ASSERT().
+
+ @param CodeType The type of status code being converted.
+ @param Value The status code value being converted.
+ @param Data Pointer to status code data buffer.
+ @param Filename Pointer to the source file name that generated the ASSERT().
+ @param Description Pointer to the description of the ASSERT().
+ @param LineNumber Pointer to source line number that generated the ASSERT().
+
+ @retval TRUE The status code specified by CodeType, Value, and Data was
+ converted ASSERT() arguments specified by Filename, Description,
+ and LineNumber.
+ @retval FALSE The status code specified by CodeType, Value, and Data could
+ not be converted to ASSERT() arguments.
+
+**/
+BOOLEAN
+EFIAPI
+GlueReportStatusCodeExtractAssertInfo (
+ IN EFI_STATUS_CODE_TYPE CodeType,
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN CONST EFI_STATUS_CODE_DATA *Data,
+ OUT CHAR8 **Filename,
+ OUT CHAR8 **Description,
+ OUT UINT32 *LineNumber
+ );
+
+
+/**
+ Extracts DEBUG() information from a status code structure.
+
+ Converts the status code specified by Data to the DEBUG() arguments specified
+ by ErrorLevel, Marker, and Format. If type GUID in Data is
+ EFI_STATUS_CODE_DATA_TYPE_DEBUG_GUID, then extract ErrorLevel, Marker, and
+ Format from the optional data area of the status code buffer specified by Data.
+ The optional data area of Data contains a 32-bit ErrorLevel followed by Marker
+ which is 12 UINTN parameters, followed by a Null-terminated ASCII string for
+ the Format. If the DEBUG() information could be extracted from Data, then
+ return TRUE. Otherwise, FALSE is returned.
+
+ If Data is NULL, then ASSERT().
+ If ErrorLevel is NULL, then ASSERT().
+ If Marker is NULL, then ASSERT().
+ If Format is NULL, then ASSERT().
+
+ @param Data Pointer to status code data buffer.
+ @param ErrorLevel Pointer to error level mask for a debug message.
+ @param Marker Pointer to the variable argument list associated with Format.
+ @param Format Pointer to a Null-terminated ASCII format string of a
+ debug message.
+
+ @retval TRUE The status code specified by Data was converted DEBUG() arguments
+ specified by ErrorLevel, Marker, and Format.
+ @retval FALSE The status code specified by Data could not be converted to
+ DEBUG() arguments.
+
+**/
+BOOLEAN
+EFIAPI
+GlueReportStatusCodeExtractDebugInfo (
+ IN CONST EFI_STATUS_CODE_DATA *Data,
+ OUT UINT32 *ErrorLevel,
+ OUT VA_LIST *Marker,
+ OUT CHAR8 **Format
+ );
+
+
+/**
+ Reports a status code.
+
+ Reports the status code specified by the parameters Type and Value. Status
+ code also require an instance, caller ID, and extended data. This function
+ passed in a zero instance, NULL extended data, and a caller ID of
+ gEfiCallerIdGuid, which is the GUID for the module.
+
+ ReportStatusCode()must actively prevent recusrsion. If ReportStatusCode()
+ is called while processing another any other Report Status Code Library function,
+ then ReportStatusCode() must return immediately.
+
+ @param Type Status code type.
+ @param Value Status code value.
+
+ @retval EFI_SUCCESS The status code was reported.
+ @retval EFI_DEVICE_ERROR There status code could not be reported due to a
+ device error.
+ @retval EFI_UNSUPPORTED Report status code is not supported
+
+**/
+EFI_STATUS
+EFIAPI
+GlueReportStatusCode (
+ IN EFI_STATUS_CODE_TYPE Type,
+ IN EFI_STATUS_CODE_VALUE Value
+ );
+
+
+/**
+ Reports a status code with a Device Path Protocol as the extended data.
+
+ Allocates and fills in the extended data section of a status code with the
+ Device Path Protocol specified by DevicePath. This function is responsible
+ for allocating a buffer large enough for the standard header and the device
+ path. The standard header is filled in with a GUID of
+ gEfiStatusCodeSpecificDataGuid. The status code is reported with a zero
+ instance and a caller ID of gEfiCallerIdGuid.
+
+ ReportStatusCodeWithDevicePath()must actively prevent recursion. If
+ ReportStatusCodeWithDevicePath() is called while processing another any other
+ Report Status Code Library function, then ReportStatusCodeWithDevicePath()
+ must return EFI_DEVICE_ERROR immediately.
+
+ If DevicePath is NULL, then ASSERT().
+
+ @param Type Status code type.
+ @param Value Status code value.
+ @param DevicePath Pointer to the Device Path Protocol to be reported.
+
+ @retval EFI_SUCCESS The status code was reported with the extended
+ data specified by DevicePath.
+ @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the
+ extended data section.
+ @retval EFI_UNSUPPORTED Report status code is not supported
+
+**/
+EFI_STATUS
+EFIAPI
+GlueReportStatusCodeWithDevicePath (
+ IN EFI_STATUS_CODE_TYPE Type,
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ );
+
+
+/**
+ Reports a status code with an extended data buffer.
+
+ Allocates and fills in the extended data section of a status code with the
+ extended data specified by ExtendedData and ExtendedDataSize. ExtendedData
+ is assumed to be one of the data structures specified in Related Definitions.
+ These data structure do not have the standard header, so this function is
+ responsible for allocating a buffer large enough for the standard header and
+ the extended data passed into this function. The standard header is filled
+ in with a GUID of gEfiStatusCodeSpecificDataGuid. The status code is reported
+ with a zero instance and a caller ID of gEfiCallerIdGuid.
+
+ ReportStatusCodeWithExtendedData()must actively prevent recursion. If
+ ReportStatusCodeWithExtendedData() is called while processing another any other
+ Report Status Code Library function, then ReportStatusCodeWithExtendedData()
+ must return EFI_DEVICE_ERROR immediately.
+
+ If ExtendedData is NULL, then ASSERT().
+ If ExtendedDataSize is 0, then ASSERT().
+
+ @param Type Status code type.
+ @param Value Status code value.
+ @param ExtendedData Pointer to the extended data buffer to be reported.
+ @param ExtendedDataSize The size, in bytes, of the extended data buffer to
+ be reported.
+
+ @retval EFI_SUCCESS The status code was reported with the extended
+ data specified by ExtendedData and ExtendedDataSize.
+ @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the
+ extended data section.
+ @retval EFI_UNSUPPORTED Report status code is not supported
+
+**/
+EFI_STATUS
+EFIAPI
+GlueReportStatusCodeWithExtendedData (
+ IN EFI_STATUS_CODE_TYPE Type,
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN CONST VOID *ExtendedData,
+ IN UINTN ExtendedDataSize
+ );
+
+
+/**
+ Reports a status code with full parameters.
+
+ The function reports a status code. If ExtendedData is NULL and ExtendedDataSize
+ is 0, then an extended data buffer is not reported. If ExtendedData is not
+ NULL and ExtendedDataSize is not 0, then an extended data buffer is allocated.
+ ExtendedData is assumed not have the standard status code header, so this function
+ is responsible for allocating a buffer large enough for the standard header and
+ the extended data passed into this function. The standard header is filled in
+ with a GUID specified by ExtendedDataGuid. If ExtendedDataGuid is NULL, then a
+ GUID of gEfiStatusCodeSpecificDatauid is used. The status code is reported with
+ an instance specified by Instance and a caller ID specified by CallerId. If
+ CallerId is NULL, then a caller ID of gEfiCallerIdGuid is used.
+
+ ReportStatusCodeEx()must actively prevent recursion. If ReportStatusCodeEx()
+ is called while processing another any other Report Status Code Library function,
+ then ReportStatusCodeEx() must return EFI_DEVICE_ERROR immediately.
+
+ If ExtendedData is NULL and ExtendedDataSize is not zero, then ASSERT().
+ If ExtendedData is not NULL and ExtendedDataSize is zero, then ASSERT().
+
+ @param Type Status code type.
+ @param Value Status code value.
+ @param Instance Status code instance number.
+ @param CallerId Pointer to a GUID that identifies the caller of this
+ function. If this parameter is NULL, then a caller
+ ID of gEfiCallerIdGuid is used.
+ @param ExtendedDataGuid Pointer to the GUID for the extended data buffer.
+ If this parameter is NULL, then a the status code
+ standard header is filled in with
+ gEfiStatusCodeSpecificDataGuid.
+ @param ExtendedData Pointer to the extended data buffer. This is an
+ optional parameter that may be NULL.
+ @param ExtendedDataSize The size, in bytes, of the extended data buffer.
+
+ @retval EFI_SUCCESS The status code was reported.
+ @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate
+ the extended data section if it was specified.
+ @retval EFI_UNSUPPORTED Report status code is not supported
+
+**/
+EFI_STATUS
+EFIAPI
+GlueReportStatusCodeEx (
+ IN EFI_STATUS_CODE_TYPE Type,
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN UINT32 Instance,
+ IN CONST EFI_GUID *CallerId OPTIONAL,
+ IN CONST EFI_GUID *ExtendedDataGuid OPTIONAL,
+ IN CONST VOID *ExtendedData OPTIONAL,
+ IN UINTN ExtendedDataSize
+ );
+
+
+/**
+ Returns TRUE if status codes of type EFI_PROGRESS_CODE are enabled
+
+ This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED
+ bit of PcdReportStatusCodeProperyMask is set. Otherwise FALSE is returned.
+
+ @retval TRUE The REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED bit of
+ PcdReportStatusCodeProperyMask is set.
+ @retval FALSE The REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED bit of
+ PcdReportStatusCodeProperyMask is clear.
+
+**/
+BOOLEAN
+EFIAPI
+GlueReportProgressCodeEnabled (
+ VOID
+ );
+
+
+/**
+ Returns TRUE if status codes of type EFI_ERROR_CODE are enabled
+
+ This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED
+ bit of PcdReportStatusCodeProperyMask is set. Otherwise FALSE is returned.
+
+ @retval TRUE The REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED bit of
+ PcdReportStatusCodeProperyMask is set.
+ @retval FALSE The REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED bit of
+ PcdReportStatusCodeProperyMask is clear.
+
+**/
+BOOLEAN
+EFIAPI
+GlueReportErrorCodeEnabled (
+ VOID
+ );
+
+
+/**
+ Returns TRUE if status codes of type EFI_DEBUG_CODE are enabled
+
+ This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED
+ bit of PcdReportStatusCodeProperyMask is set. Otherwise FALSE is returned.
+
+ @retval TRUE The REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED bit of
+ PcdReportStatusCodeProperyMask is set.
+ @retval FALSE The REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED bit of
+ PcdReportStatusCodeProperyMask is clear.
+
+**/
+BOOLEAN
+EFIAPI
+GlueReportDebugCodeEnabled (
+ VOID
+ );
+
+
+/**
+ Reports a status code with minimal parameters if the status code type is enabled.
+
+ If the status code type specified by Type is enabled in
+ PcdReportStatusCodeProperyMask, then call ReportStatusCode() passing in Type
+ and Value.
+
+ @param Type Status code type.
+ @param Value Status code value.
+
+ @retval EFI_SUCCESS The status code was reported.
+ @retval EFI_DEVICE_ERROR There status code could not be reported due to a device error.
+ @retval EFI_UNSUPPORTED Report status code is not supported
+
+**/
+#define REPORT_STATUS_CODE(Type,Value) \
+ (ReportProgressCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ? \
+ ReportStatusCode(Type,Value) : \
+ (ReportErrorCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ? \
+ ReportStatusCode(Type,Value) : \
+ (ReportDebugCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE) ? \
+ ReportStatusCode(Type,Value) : \
+ EFI_UNSUPPORTED
+
+
+/**
+ Reports a status code with a Device Path Protocol as the extended data if the
+ status code type is enabled.
+
+ If the status code type specified by Type is enabled in
+ PcdReportStatusCodeProperyMask, then call ReportStatusCodeWithDevicePath()
+ passing in Type, Value, and DevicePath.
+
+ @param Type Status code type.
+ @param Value Status code value.
+ @param DevicePath Pointer to the Device Path Protocol to be reported.
+
+ @retval EFI_SUCCESS The status code was reported with the extended
+ data specified by DevicePath.
+ @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the
+ extended data section.
+ @retval EFI_UNSUPPORTED Report status code is not supported
+
+**/
+#define REPORT_STATUS_CODE_WITH_DEVICE_PATH(Type,Value,DevicePathParameter) \
+ (ReportProgressCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ? \
+ ReportStatusCodeWithDevicePath(Type,Value,DevicePathParameter) : \
+ (ReportErrorCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ? \
+ ReportStatusCodeWithDevicePath(Type,Value,DevicePathParameter) : \
+ (ReportDebugCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE) ? \
+ ReportStatusCodeWithDevicePath(Type,Value,DevicePathParameter) : \
+ EFI_UNSUPPORTED
+
+
+/**
+ Reports a status code with an extended data buffer if the status code type
+ is enabled.
+
+ If the status code type specified by Type is enabled in
+ PcdReportStatusCodeProperyMask, then call ReportStatusCodeWithExtendedData()
+ passing in Type, Value, ExtendedData, and ExtendedDataSize.
+
+ @param Type Status code type.
+ @param Value Status code value.
+ @param ExtendedData Pointer to the extended data buffer to be reported.
+ @param ExtendedDataSize The size, in bytes, of the extended data buffer to
+ be reported.
+
+ @retval EFI_SUCCESS The status code was reported with the extended
+ data specified by ExtendedData and ExtendedDataSize.
+ @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the
+ extended data section.
+ @retval EFI_UNSUPPORTED Report status code is not supported
+
+**/
+#define REPORT_STATUS_CODE_WITH_EXTENDED_DATA(Type,Value,ExtendedData,ExtendedDataSize) \
+ (ReportProgressCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ? \
+ ReportStatusCodeWithExtendedData(Type,Value,ExtendedData,ExtendedDataSize) : \
+ (ReportErrorCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ? \
+ ReportStatusCodeWithExtendedData(Type,Value,ExtendedData,ExtendedDataSize) : \
+ (ReportDebugCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE) ? \
+ ReportStatusCodeWithExtendedData(Type,Value,ExtendedData,ExtendedDataSize) : \
+ EFI_UNSUPPORTED
+
+/**
+ Reports a status code specifying all parameters if the status code type is enabled.
+
+ If the status code type specified by Type is enabled in
+ PcdReportStatusCodeProperyMask, then call ReportStatusCodeEx() passing in Type,
+ Value, Instance, CallerId, ExtendedDataGuid, ExtendedData, and ExtendedDataSize.
+
+ @param Type Status code type.
+ @param Value Status code value.
+ @param Instance Status code instance number.
+ @param CallerId Pointer to a GUID that identifies the caller of this
+ function. If this parameter is NULL, then a caller
+ ID of gEfiCallerIdGuid is used.
+ @param ExtendedDataGuid Pointer to the GUID for the extended data buffer.
+ If this parameter is NULL, then a the status code
+ standard header is filled in with
+ gEfiStatusCodeSpecificDataGuid.
+ @param ExtendedData Pointer to the extended data buffer. This is an
+ optional parameter that may be NULL.
+ @param ExtendedDataSize The size, in bytes, of the extended data buffer.
+
+ @retval EFI_SUCCESS The status code was reported.
+ @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the
+ extended data section if it was specified.
+ @retval EFI_UNSUPPORTED Report status code is not supported
+
+**/
+#define REPORT_STATUS_CODE_EX(Type,Value,Instance,CallerId,ExtendedDataGuid,ExtendedData,ExtendedDataSize) \
+ (ReportProgressCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ? \
+ ReportStatusCodeEx(Type,Value,Instance,CallerId,ExtendedDataGuid,ExtendedData,ExtendedDataSize) : \
+ (ReportErrorCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ? \
+ ReportStatusCodeEx(Type,Value,Instance,CallerId,ExtendedDataGuid,ExtendedData,ExtendedDataSize) : \
+ (ReportDebugCodeEnabled() && ((Type) & EFI_STATUS_CODE_TYPE_MASK) == EFI_DEBUG_CODE) ? \
+ ReportStatusCodeEx(Type,Value,Instance,CallerId,ExtendedDataGuid,ExtendedData,ExtendedDataSize) : \
+ EFI_UNSUPPORTED
+
+#endif
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueResourcePublicationLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueResourcePublicationLib.h
new file mode 100644
index 0000000..36b78db
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueResourcePublicationLib.h
@@ -0,0 +1,50 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ EdkIIGlueResourcePublicationLib.h
+
+Abstract:
+
+ Public header file for Resource Publication Lib
+
+--*/
+
+#ifndef __EDKII_GLUE_RESOURCE_PUBLICATION_LIB_H__
+#define __EDKII_GLUE_RESOURCE_PUBLICATION_LIB_H__
+
+/**
+
+ Declares the presence of permanent system memory in the platform.
+
+ Declares that the system memory buffer specified by MemoryBegin and MemoryLength
+ as permanent memory that may be used for general purpose use by software.
+ The amount of memory available to software may be less than MemoryLength
+ if published memory has alignment restrictions.
+
+ @param MemoryBegin The start address of the memory being declared.
+ @param MemoryLength The number of bytes of memory being declared.
+
+ @retval RETURN_SUCCESS The memory buffer was published.
+ @retval RETURN_OUT_OF_RESOURCES There are not enough resources to publish the memory buffer
+
+**/
+RETURN_STATUS
+EFIAPI
+PublishSystemMemory (
+ IN PHYSICAL_ADDRESS MemoryBegin,
+ IN UINT64 MemoryLength
+ )
+;
+
+#endif
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueSmbusLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueSmbusLib.h
new file mode 100644
index 0000000..8fd2f33
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueSmbusLib.h
@@ -0,0 +1,394 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ EdkIIGlueSmbusLib.h
+
+Abstract:
+
+ Public header file for Smbus Lib
+
+--*/
+
+#ifndef __EDKII_GLUE_SMBUS_LIB_H__
+#define __EDKII_GLUE_SMBUS_LIB_H__
+
+//
+// PEC BIT is bit 22 in SMBUS address
+//
+#define SMBUS_LIB_PEC_BIT (1 << 22)
+
+/**
+ Macro that converts SMBUS slave address, SMBUS command, SMBUS data length,
+ and PEC to a value that can be passed to the SMBUS Library functions.
+
+ Computes an address that is compatible with the SMBUS Library functions.
+ The unused upper bits of SlaveAddress, Command, and Length are stripped
+ prior to the generation of the address.
+
+ @param SlaveAddress SMBUS Slave Address. Range 0..127.
+ @param Command SMBUS Command. Range 0..255.
+ @param Length SMBUS Data Length. Range 0..32.
+ @param Pec TRUE if Packet Error Checking is enabled. Otherwise FALSE.
+
+**/
+#define SMBUS_LIB_ADDRESS(SlaveAddress,Command,Length,Pec) \
+ ( ((Pec) ? SMBUS_LIB_PEC_BIT: 0) | \
+ (((SlaveAddress) & 0x7f) << 1) | \
+ (((Command) & 0xff) << 8) | \
+ (((Length) & 0x3f) << 16) \
+ )
+
+/**
+ Executes an SMBUS quick read command.
+
+ Executes an SMBUS quick read command on the SMBUS device specified by SmBusAddress.
+ Only the SMBUS slave address field of SmBusAddress is required.
+ If Status is not NULL, then the status of the executed command is returned in Status.
+ If PEC is set in SmBusAddress, then ASSERT().
+ If Command in SmBusAddress is not zero, then ASSERT().
+ If Length in SmBusAddress is not zero, then ASSERT().
+ If any reserved bits of SmBusAddress are set, then ASSERT().
+
+ @param SmBusAddress Address that encodes the SMBUS Slave Address,
+ SMBUS Command, SMBUS Data Length, and PEC.
+ @param Status Return status for the executed command.
+ This is an optional parameter and may be NULL.
+
+**/
+VOID
+EFIAPI
+SmBusQuickRead (
+ IN UINTN SmBusAddress,
+ OUT RETURN_STATUS *Status OPTIONAL
+ )
+;
+
+/**
+ Executes an SMBUS quick write command.
+
+ Executes an SMBUS quick write command on the SMBUS device specified by SmBusAddress.
+ Only the SMBUS slave address field of SmBusAddress is required.
+ If Status is not NULL, then the status of the executed command is returned in Status.
+ If PEC is set in SmBusAddress, then ASSERT().
+ If Command in SmBusAddress is not zero, then ASSERT().
+ If Length in SmBusAddress is not zero, then ASSERT().
+ If any reserved bits of SmBusAddress are set, then ASSERT().
+
+ @param SmBusAddress Address that encodes the SMBUS Slave Address,
+ SMBUS Command, SMBUS Data Length, and PEC.
+ @param Status Return status for the executed command.
+ This is an optional parameter and may be NULL.
+
+**/
+VOID
+EFIAPI
+SmBusQuickWrite (
+ IN UINTN SmBusAddress,
+ OUT RETURN_STATUS *Status OPTIONAL
+ )
+;
+
+/**
+ Executes an SMBUS receive byte command.
+
+ Executes an SMBUS receive byte command on the SMBUS device specified by SmBusAddress.
+ Only the SMBUS slave address field of SmBusAddress is required.
+ The byte received from the SMBUS is returned.
+ If Status is not NULL, then the status of the executed command is returned in Status.
+ If Command in SmBusAddress is not zero, then ASSERT().
+ If Length in SmBusAddress is not zero, then ASSERT().
+ If any reserved bits of SmBusAddress are set, then ASSERT().
+
+ @param SmBusAddress Address that encodes the SMBUS Slave Address,
+ SMBUS Command, SMBUS Data Length, and PEC.
+ @param Status Return status for the executed command.
+ This is an optional parameter and may be NULL.
+
+ @return The byte received from the SMBUS.
+
+**/
+UINT8
+EFIAPI
+SmBusReceiveByte (
+ IN UINTN SmBusAddress,
+ OUT RETURN_STATUS *Status OPTIONAL
+ )
+;
+
+/**
+ Executes an SMBUS send byte command.
+
+ Executes an SMBUS send byte command on the SMBUS device specified by SmBusAddress.
+ The byte specified by Value is sent.
+ Only the SMBUS slave address field of SmBusAddress is required. Value is returned.
+ If Status is not NULL, then the status of the executed command is returned in Status.
+ If Command in SmBusAddress is not zero, then ASSERT().
+ If Length in SmBusAddress is not zero, then ASSERT().
+ If any reserved bits of SmBusAddress are set, then ASSERT().
+
+ @param SmBusAddress Address that encodes the SMBUS Slave Address,
+ SMBUS Command, SMBUS Data Length, and PEC.
+ @param Value The 8-bit value to send.
+ @param Status Return status for the executed command.
+ This is an optional parameter and may be NULL.
+
+ @return The parameter of Value.
+
+**/
+UINT8
+EFIAPI
+SmBusSendByte (
+ IN UINTN SmBusAddress,
+ IN UINT8 Value,
+ OUT RETURN_STATUS *Status OPTIONAL
+ )
+;
+
+/**
+ Executes an SMBUS read data byte command.
+
+ Executes an SMBUS read data byte command on the SMBUS device specified by SmBusAddress.
+ Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.
+ The 8-bit value read from the SMBUS is returned.
+ If Status is not NULL, then the status of the executed command is returned in Status.
+ If Length in SmBusAddress is not zero, then ASSERT().
+ If any reserved bits of SmBusAddress are set, then ASSERT().
+
+ @param SmBusAddress Address that encodes the SMBUS Slave Address,
+ SMBUS Command, SMBUS Data Length, and PEC.
+ @param Status Return status for the executed command.
+ This is an optional parameter and may be NULL.
+
+ @return The byte read from the SMBUS.
+
+**/
+UINT8
+EFIAPI
+SmBusReadDataByte (
+ IN UINTN SmBusAddress,
+ OUT RETURN_STATUS *Status OPTIONAL
+ )
+;
+
+/**
+ Executes an SMBUS write data byte command.
+
+ Executes an SMBUS write data byte command on the SMBUS device specified by SmBusAddress.
+ The 8-bit value specified by Value is written.
+ Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.
+ Value is returned.
+ If Status is not NULL, then the status of the executed command is returned in Status.
+ If Length in SmBusAddress is not zero, then ASSERT().
+ If any reserved bits of SmBusAddress are set, then ASSERT().
+
+ @param SmBusAddress Address that encodes the SMBUS Slave Address,
+ SMBUS Command, SMBUS Data Length, and PEC.
+ @param Value The 8-bit value to write.
+ @param Status Return status for the executed command.
+ This is an optional parameter and may be NULL.
+
+ @return The parameter of Value.
+
+**/
+UINT8
+EFIAPI
+SmBusWriteDataByte (
+ IN UINTN SmBusAddress,
+ IN UINT8 Value,
+ OUT RETURN_STATUS *Status OPTIONAL
+ )
+;
+
+/**
+ Executes an SMBUS read data word command.
+
+ Executes an SMBUS read data word command on the SMBUS device specified by SmBusAddress.
+ Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.
+ The 16-bit value read from the SMBUS is returned.
+ If Status is not NULL, then the status of the executed command is returned in Status.
+ If Length in SmBusAddress is not zero, then ASSERT().
+ If any reserved bits of SmBusAddress are set, then ASSERT().
+
+ @param SmBusAddress Address that encodes the SMBUS Slave Address,
+ SMBUS Command, SMBUS Data Length, and PEC.
+ @param Status Return status for the executed command.
+ This is an optional parameter and may be NULL.
+
+ @return The byte read from the SMBUS.
+
+**/
+UINT16
+EFIAPI
+SmBusReadDataWord (
+ IN UINTN SmBusAddress,
+ OUT RETURN_STATUS *Status OPTIONAL
+ )
+;
+
+/**
+ Executes an SMBUS write data word command.
+
+ Executes an SMBUS write data word command on the SMBUS device specified by SmBusAddress.
+ The 16-bit value specified by Value is written.
+ Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.
+ Value is returned.
+ If Status is not NULL, then the status of the executed command is returned in Status.
+ If Length in SmBusAddress is not zero, then ASSERT().
+ If any reserved bits of SmBusAddress are set, then ASSERT().
+
+ @param SmBusAddress Address that encodes the SMBUS Slave Address,
+ SMBUS Command, SMBUS Data Length, and PEC.
+ @param Value The 16-bit value to write.
+ @param Status Return status for the executed command.
+ This is an optional parameter and may be NULL.
+
+ @return The parameter of Value.
+
+**/
+UINT16
+EFIAPI
+SmBusWriteDataWord (
+ IN UINTN SmBusAddress,
+ IN UINT16 Value,
+ OUT RETURN_STATUS *Status OPTIONAL
+ )
+;
+
+/**
+ Executes an SMBUS process call command.
+
+ Executes an SMBUS process call command on the SMBUS device specified by SmBusAddress.
+ The 16-bit value specified by Value is written.
+ Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.
+ The 16-bit value returned by the process call command is returned.
+ If Status is not NULL, then the status of the executed command is returned in Status.
+ If Length in SmBusAddress is not zero, then ASSERT().
+ If any reserved bits of SmBusAddress are set, then ASSERT().
+
+ @param SmBusAddress Address that encodes the SMBUS Slave Address,
+ SMBUS Command, SMBUS Data Length, and PEC.
+ @param Value The 16-bit value to write.
+ @param Status Return status for the executed command.
+ This is an optional parameter and may be NULL.
+
+ @return The 16-bit value returned by the process call command.
+
+**/
+UINT16
+EFIAPI
+SmBusProcessCall (
+ IN UINTN SmBusAddress,
+ IN UINT16 Value,
+ OUT RETURN_STATUS *Status OPTIONAL
+ )
+;
+
+/**
+ Executes an SMBUS read block command.
+
+ Executes an SMBUS read block command on the SMBUS device specified by SmBusAddress.
+ Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.
+ Bytes are read from the SMBUS and stored in Buffer.
+ The number of bytes read is returned, and will never return a value larger than 32-bytes.
+ If Status is not NULL, then the status of the executed command is returned in Status.
+ It is the caller's responsibility to make sure Buffer is large enough for the total number of bytes read.
+ SMBUS supports a maximum transfer size of 32 bytes, so Buffer does not need to be any larger than 32 bytes.
+ If Length in SmBusAddress is not zero, then ASSERT().
+ If Buffer is NULL, then ASSERT().
+ If any reserved bits of SmBusAddress are set, then ASSERT().
+
+ @param SmBusAddress Address that encodes the SMBUS Slave Address,
+ SMBUS Command, SMBUS Data Length, and PEC.
+ @param Buffer Pointer to the buffer to store the bytes read from the SMBUS.
+ @param Status Return status for the executed command.
+ This is an optional parameter and may be NULL.
+
+ @return The number of bytes read.
+
+**/
+UINTN
+EFIAPI
+SmBusReadBlock (
+ IN UINTN SmBusAddress,
+ OUT VOID *Buffer,
+ OUT RETURN_STATUS *Status OPTIONAL
+ )
+;
+
+/**
+ Executes an SMBUS write block command.
+
+ Executes an SMBUS write block command on the SMBUS device specified by SmBusAddress.
+ The SMBUS slave address, SMBUS command, and SMBUS length fields of SmBusAddress are required.
+ Bytes are written to the SMBUS from Buffer.
+ The number of bytes written is returned, and will never return a value larger than 32-bytes.
+ If Status is not NULL, then the status of the executed command is returned in Status.
+ If Length in SmBusAddress is zero or greater than 32, then ASSERT().
+ If Buffer is NULL, then ASSERT().
+ If any reserved bits of SmBusAddress are set, then ASSERT().
+
+ @param SmBusAddress Address that encodes the SMBUS Slave Address,
+ SMBUS Command, SMBUS Data Length, and PEC.
+ @param Buffer Pointer to the buffer to store the bytes read from the SMBUS.
+ @param Status Return status for the executed command.
+ This is an optional parameter and may be NULL.
+
+ @return The number of bytes written.
+
+**/
+UINTN
+EFIAPI
+SmBusWriteBlock (
+ IN UINTN SmBusAddress,
+ OUT VOID *Buffer,
+ OUT RETURN_STATUS *Status OPTIONAL
+ )
+;
+
+/**
+ Executes an SMBUS block process call command.
+
+ Executes an SMBUS block process call command on the SMBUS device specified by SmBusAddress.
+ The SMBUS slave address, SMBUS command, and SMBUS length fields of SmBusAddress are required.
+ Bytes are written to the SMBUS from WriteBuffer. Bytes are then read from the SMBUS into ReadBuffer.
+ If Status is not NULL, then the status of the executed command is returned in Status.
+ It is the caller's responsibility to make sure ReadBuffer is large enough for the total number of bytes read.
+ SMBUS supports a maximum transfer size of 32 bytes, so Buffer does not need to be any larger than 32 bytes.
+ If Length in SmBusAddress is zero or greater than 32, then ASSERT().
+ If WriteBuffer is NULL, then ASSERT().
+ If ReadBuffer is NULL, then ASSERT().
+ If any reserved bits of SmBusAddress are set, then ASSERT().
+
+ @param SmBusAddress Address that encodes the SMBUS Slave Address,
+ SMBUS Command, SMBUS Data Length, and PEC.
+ @param WriteBuffer Pointer to the buffer of bytes to write to the SMBUS.
+ @param ReadBuffer Pointer to the buffer of bytes to read from the SMBUS.
+ @param Status Return status for the executed command.
+ This is an optional parameter and may be NULL.
+
+ @return The number of bytes written.
+
+**/
+UINTN
+EFIAPI
+SmBusBlockProcessCall (
+ IN UINTN SmBusAddress,
+ IN VOID *WriteBuffer,
+ OUT VOID *ReadBuffer,
+ OUT RETURN_STATUS *Status OPTIONAL
+ )
+;
+
+
+#endif
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueTimerLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueTimerLib.h
new file mode 100644
index 0000000..822ad5f
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueTimerLib.h
@@ -0,0 +1,130 @@
+/*++
+
+Copyright (c) 2004 - 2011, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ EdkIIGlueTimerLib.h
+
+Abstract:
+
+ Public header file for Timer Lib
+
+--*/
+
+#ifndef __EDKII_GLUE_TIMER_LIB_H__
+#define __EDKII_GLUE_TIMER_LIB_H__
+
+/**
+ Stalls the CPU for at least the given number of microseconds.
+
+ Stalls the CPU for the number of microseconds specified by MicroSeconds.
+
+ @param MicroSeconds The minimum number of microseconds to delay.
+
+ @return MicroSeconds
+
+**/
+UINTN
+EFIAPI
+MicroSecondDelay (
+ IN UINTN MicroSeconds
+ );
+
+/**
+ Stalls the CPU for at least the given number of nanoseconds.
+
+ Stalls the CPU for the number of nanoseconds specified by NanoSeconds.
+
+ @param NanoSeconds The minimum number of nanoseconds to delay.
+
+ @return NanoSeconds
+
+**/
+UINTN
+EFIAPI
+NanoSecondDelay (
+ IN UINTN NanoSeconds
+ );
+
+/**
+ Retrieves the current value of a 64-bit free running performance counter.
+
+ Retrieves the current value of a 64-bit free running performance counter. The
+ counter can either count up by 1 or count down by 1. If the physical
+ performance counter counts by a larger increment, then the counter values
+ must be translated. The properties of the counter can be retrieved from
+ GetPerformanceCounterProperties().
+
+ @return The current value of the free running performance counter.
+
+**/
+UINT64
+EFIAPI
+GetPerformanceCounter (
+ VOID
+ );
+
+/**
+ Retrieves the 64-bit frequency in Hz and the range of performance counter
+ values.
+
+ If StartValue is not NULL, then the value that the performance counter starts
+ with immediately after is it rolls over is returned in StartValue. If
+ EndValue is not NULL, then the value that the performance counter end with
+ immediately before it rolls over is returned in EndValue. The 64-bit
+ frequency of the performance counter in Hz is always returned. If StartValue
+ is less than EndValue, then the performance counter counts up. If StartValue
+ is greater than EndValue, then the performance counter counts down. For
+ example, a 64-bit free running counter that counts up would have a StartValue
+ of 0 and an EndValue of 0xFFFFFFFFFFFFFFFF. A 24-bit free running counter
+ that counts down would have a StartValue of 0xFFFFFF and an EndValue of 0.
+
+ @param StartValue The value the performance counter starts with when it
+ rolls over.
+ @param EndValue The value that the performance counter ends with before
+ it rolls over.
+
+ @return The frequency in Hz.
+
+**/
+UINT64
+EFIAPI
+GetPerformanceCounterProperties (
+ IN UINT64 *StartValue, OPTIONAL
+ IN UINT64 *EndValue OPTIONAL
+ );
+
+/**
+ Converts TSC value into nano second value.
+
+ @param TimeStamp - TSC timer ticker
+
+ @return UINT64 value in naosecond unit converted from TSC ticker
+
+**/
+UINT64
+GetTimeInNanoSec (
+ UINT64 Timestamp
+ );
+
+/**
+ Retrieves current APIC ID.
+
+ @return UINT32 value of APIC ID
+
+**/
+UINT32
+GetApicId (
+ VOID
+ );
+
+#endif \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiBootServicesTableLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiBootServicesTableLib.h
new file mode 100644
index 0000000..d7b8c0e
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiBootServicesTableLib.h
@@ -0,0 +1,41 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ EdkIIGlueUefiBootServicesTableLib.h
+
+Abstract:
+
+ Public header file for UEFI Boot Services Table Lib
+
+--*/
+
+#ifndef __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB_H__
+#define __EDKII_GLUE_UEFI_BOOT_SERVICES_TABLE_LIB_H__
+
+//
+// Cache the Image Handle
+//
+extern EFI_HANDLE gImageHandle;
+
+//
+// Cache pointer to the EFI System Table
+//
+extern EFI_SYSTEM_TABLE *gST;
+
+//
+// Cache pointer to the EFI Boot Services Table
+//
+extern EFI_BOOT_SERVICES *gBS;
+
+#endif
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiDecompressLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiDecompressLib.h
new file mode 100644
index 0000000..2f23b6b
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiDecompressLib.h
@@ -0,0 +1,113 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ EdkIIGlueUefiDecompressLib.h
+
+Abstract:
+
+ Public header file for UEFI Decompress Lib
+
+--*/
+
+#ifndef __EDKII_GLUE_UEFI_DECPOMPRESS_LIB_H__
+#define __EDKII_GLUE_UEFI_DECPOMPRESS_LIB_H__
+
+#define FillBuf(_SD, _NUMOFBITS) GlueFillBuf(_SD, _NUMOFBITS)
+#define GetBits(_SD, _NUMOFBITS) GlueGetBits(_SD, _NUMOFBITS)
+#define MakeTable(_SD, _NUMOFCHAR, _BITLEN, _TABLEBITS, _TABLE) GlueMakeTable(_SD, _NUMOFCHAR, _BITLEN, _TABLEBITS, _TABLE)
+#define DecodeP(_SD) GlueDecodeP(_SD)
+#define ReadPTLen( _SD, _NN, _NBIT, _SPECIAL) GlueReadPTLen( _SD, _NN, _NBIT, _SPECIAL)
+#define ReadCLen(_SD) GlueReadCLen(_SD)
+#define DecodeC(_SD) GlueDecodeC(_SD)
+#define Decode(_SD) GlueDecode(_SD)
+
+
+
+/**
+ Retrieves the size of the uncompressed buffer and the size of the scratch buffer.
+
+ Retrieves the size of the uncompressed buffer and the temporary scratch buffer
+ required to decompress the buffer specified by Source and SourceSize.
+ If the size of the uncompressed buffer or the size of the scratch buffer cannot
+ be determined from the compressed data specified by Source and SourceData,
+ then RETURN_INVALID_PARAMETER is returned. Otherwise, the size of the uncompressed
+ buffer is returned in DestinationSize, the size of the scratch buffer is returned
+ in ScratchSize, and RETURN_SUCCESS is returned.
+ This function does not have scratch buffer available to perform a thorough
+ checking of the validity of the source data. It just retrieves the "Original Size"
+ field from the beginning bytes of the source data and output it as DestinationSize.
+ And ScratchSize is specific to the decompression implementation.
+
+ If Source is NULL, then ASSERT().
+ If DestinationSize is NULL, then ASSERT().
+ If ScratchSize is NULL, then ASSERT().
+
+ @param Source The source buffer containing the compressed data.
+ @param SourceSize The size, in bytes, of the source buffer.
+ @param DestinationSize A pointer to the size, in bytes, of the uncompressed buffer
+ that will be generated when the compressed buffer specified
+ by Source and SourceSize is decompressed..
+ @param ScratchSize A pointer to the size, in bytes, of the scratch buffer that
+ is required to decompress the compressed buffer specified
+ by Source and SourceSize.
+
+ @retval RETURN_SUCCESS The size of destination buffer and the size of scratch
+ buffer are successull retrieved.
+ @retval RETURN_INVALID_PARAMETER The source data is corrupted
+
+**/
+RETURN_STATUS
+EFIAPI
+UefiDecompressGetInfo (
+ IN CONST VOID *Source,
+ IN UINT32 SourceSize,
+ OUT UINT32 *DestinationSize,
+ OUT UINT32 *ScratchSize
+ );
+
+/**
+ Decompresses a compressed source buffer.
+
+ This function is designed so that the decompression algorithm can be implemented
+ without using any memory services. As a result, this function is not allowed to
+ call any memory allocation services in its implementation. It is the caller¡¯s r
+ esponsibility to allocate and free the Destination and Scratch buffers.
+ If the compressed source data specified by Source is sucessfully decompressed
+ into Destination, then RETURN_SUCCESS is returned. If the compressed source data
+ specified by Source is not in a valid compressed data format,
+ then RETURN_INVALID_PARAMETER is returned.
+
+ If Source is NULL, then ASSERT().
+ If Destination is NULL, then ASSERT().
+ If the required scratch buffer size > 0 and Scratch is NULL, then ASSERT().
+
+ @param Source The source buffer containing the compressed data.
+ @param Destination The destination buffer to store the decompressed data
+ @param Scratch A temporary scratch buffer that is used to perform the decompression.
+ This is an optional parameter that may be NULL if the
+ required scratch buffer size is 0.
+
+ @retval RETURN_SUCCESS Decompression is successfull
+ @retval RETURN_INVALID_PARAMETER The source data is corrupted
+
+**/
+RETURN_STATUS
+EFIAPI
+UefiDecompress (
+ IN CONST VOID *Source,
+ IN OUT VOID *Destination,
+ IN OUT VOID *Scratch
+ );
+
+#endif
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiDriverEntryPoint.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiDriverEntryPoint.h
new file mode 100644
index 0000000..edc195b
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiDriverEntryPoint.h
@@ -0,0 +1,162 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ EdkIIGlueUefiDriverEntryPoint.h
+
+Abstract:
+
+ Public header file for UEFI Driver Entry Point Lib
+
+--*/
+
+#ifndef __EDKII_GLUE_UEFI_DRIVER_ENTRY_POINT_H__
+#define __EDKII_GLUE_UEFI_DRIVER_ENTRY_POINT_H__
+
+//
+// Declare the EFI/UEFI Specification Revision to which this driver is implemented
+//
+extern const UINT32 _gUefiDriverRevision;
+
+//
+// Declare the number of entry points in the image.
+//
+extern const UINT8 _gDriverEntryPointCount;
+
+//
+// Declare the number of unload handler in the image.
+//
+extern const UINT8 _gDriverUnloadImageCount;
+
+//
+// Declare the arrary of Boot Sevice Exit Event callbacks .
+//
+extern const EFI_EVENT_NOTIFY _gDriverExitBootServicesEvent[];
+
+//
+// Declare the arrary of Virtual Address Change Event callbacks .
+//
+extern const EFI_EVENT_NOTIFY _gDriverSetVirtualAddressMapEvent[];
+
+/**
+ Enrty point to DXE SMM Driver.
+
+ @param ImageHandle ImageHandle of the loaded driver.
+ @param SystemTable Pointer to the EFI System Table.
+
+ @retval EFI_SUCCESS One or more of the drivers returned a success code.
+ @retval !EFI_SUCESS The return status from the last driver entry point in the list.
+
+**/
+EFI_STATUS
+EFIAPI
+_ModuleEntryPoint (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ );
+
+
+/**
+ Enrty point wrapper of DXE Driver.
+
+ @param ImageHandle ImageHandle of the loaded driver.
+ @param SystemTable Pointer to the EFI System Table.
+
+ @retval EFI_SUCCESS One or more of the drivers returned a success code.
+ @retval !EFI_SUCESS The return status from the last driver entry point in the list.
+
+**/
+EFI_STATUS
+EFIAPI
+EfiMain (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ );
+
+
+/**
+ Computes the cummulative return status for the driver entry point and perform
+ a long jump back into DriverEntryPoint().
+
+ @param Status Status returned by the driver that is exiting.
+
+**/
+VOID
+EFIAPI
+ExitDriver (
+ IN EFI_STATUS Status
+ );
+
+
+/**
+ Call constructs for all libraries. Automatics Generated by tool.
+
+ @param ImageHandle ImageHandle of the loaded driver.
+ @param SystemTable Pointer to the EFI System Table.
+
+**/
+VOID
+EFIAPI
+ProcessLibraryConstructorList (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ );
+
+
+/**
+ Call destructors for all libraries. Automatics Generated by tool.
+
+ @param ImageHandle ImageHandle of the loaded driver.
+ @param SystemTable Pointer to the EFI System Table.
+
+**/
+VOID
+EFIAPI
+ProcessLibraryDestructorList (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ );
+
+/**
+ Call the list of driver entry points. Automatics Generated by tool.
+
+ @param ImageHandle ImageHandle of the loaded driver.
+ @param SystemTable Pointer to the EFI System Table.
+
+ @return Status returned by entry points of drivers.
+
+**/
+
+EFI_STATUS
+EFIAPI
+ProcessModuleEntryPointList (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ );
+
+
+/**
+ Call the unload handlers for all the modules. Automatics Generated by tool.
+
+ @param ImageHandle ImageHandle of the loaded driver.
+
+ @return Status returned by unload handlers of drivers.
+
+**/
+EFI_STATUS
+EFIAPI
+ProcessModuleUnloadList (
+ IN EFI_HANDLE ImageHandle
+ );
+
+#endif
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiDriverModelLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiDriverModelLib.h
new file mode 100644
index 0000000..0fa33ea
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiDriverModelLib.h
@@ -0,0 +1,52 @@
+/*++
+
+Copyright (c) 2004 - 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ EdkIIGlueUefiDriverModelLib.h
+
+Abstract:
+
+ Public header file for UEFI Driver Model Lib
+
+--*/
+
+#ifndef __EDKII_GLUE_UEFI_DRIVER_MODEL_LIB_H__
+#define __EDKII_GLUE_UEFI_DRIVER_MODEL_LIB_H__
+
+//
+// Declare bitmask values for the protocols that are enabled
+//
+#define UEFI_DRIVER_MODEL_LIBRARY_COMPONENT_NAME_PROTOCOL_ENABLED 0x01
+#define UEFI_DRIVER_MODEL_LIBRARY_DRIVER_DIAGNOSTICS_PROTOCOL_ENABLED 0x02
+#define UEFI_DRIVER_MODEL_LIBRARY_DRIVER_CONFIGURATION_PROTOCOL_ENABLED 0x04
+
+//
+// Data structure that declares pointers to the Driver Model
+// Protocols.
+//
+typedef struct {
+ const EFI_DRIVER_BINDING_PROTOCOL *DriverBinding;
+ const EFI_COMPONENT_NAME_PROTOCOL *ComponentName;
+ const EFI_DRIVER_CONFIGURATION_PROTOCOL *DriverConfiguration;
+ const EFI_DRIVER_DIAGNOSTICS_PROTOCOL *DriverDiagnostics;
+ const EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2;
+ const EFI_DRIVER_CONFIGURATION2_PROTOCOL *DriverConfiguration2;
+ const EFI_DRIVER_DIAGNOSTICS2_PROTOCOL *DriverDiagnostics2;
+} EFI_DRIVER_MODEL_PROTOCOL_LIST;
+
+//
+// UEFI Driver Model Protocols arrary
+//
+extern const EFI_DRIVER_MODEL_PROTOCOL_LIST _gDriverModelProtocolList[];
+
+#endif
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiLib.h
new file mode 100644
index 0000000..946fabd
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiLib.h
@@ -0,0 +1,590 @@
+/*++
+
+Copyright (c) 2004 - 2011, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ EdkIIGlueUefiLib.h
+
+Abstract:
+
+ Public header file for UEFI Lib
+
+--*/
+
+#ifndef __EDKII_GLUE_UEFI_LIB_H__
+#define __EDKII_GLUE_UEFI_LIB_H__
+
+
+#define EfiInitializeLock(_LOCK, _PRIORITY) GlueEfiInitializeLock(_LOCK, _PRIORITY)
+#define EfiAcquireLock(_LOCK) GlueEfiAcquireLock(_LOCK)
+#define EfiAcquireLockOrFail(_LOCK) GlueEfiAcquireLockOrFail(_LOCK)
+#define EfiReleaseLock(_LOCK) GlueEfiReleaseLock(_LOCK)
+#define GetGlyphWidth(_UNICODECHAR) GlueGetGlyphWidth(_UNICODECHAR)
+#define EfiCreateEventLegacyBoot(_LEGACYBOOT) GlueEfiCreateEventLegacyBoot(_LEGACYBOOT)
+#define EfiCreateEventReadyToBoot(_READYTOBOOTEVENT) GlueEfiCreateEventReadyToBoot(_READYTOBOOTEVENT)
+#define EfiGetNameGuidFromFwVolDevicePathNode(_FVDEVICEPATHNODE) GlueEfiGetNameGuidFromFwVolDevicePathNode(_FVDEVICEPATHNODE)
+#define EfiInitializeFwVolDevicepathNode(_FVDEVICEPATHNODE, _NAMEGUID) GlueEfiInitializeFwVolDevicepathNode(_FVDEVICEPATHNODE, _NAMEGUID)
+
+
+//
+// Unicode String Table
+//
+typedef struct {
+ CHAR8 *Language;
+ CHAR16 *UnicodeString;
+} GLUE_EFI_UNICODE_STRING_TABLE;
+
+//
+// EFI Lock Status
+//
+typedef enum {
+ EfiLockUninitialized = 0,
+ EfiLockReleased = 1,
+ EfiLockAcquired = 2
+} EFI_LOCK_STATE;
+
+//
+// EFI Lock
+//
+typedef struct {
+ EFI_TPL Tpl;
+ EFI_TPL OwnerTpl;
+ EFI_LOCK_STATE Lock;
+} GLUE_EFI_LOCK;
+
+/**
+ This function searches the list of configuration tables stored in the EFI System
+ Table for a table with a GUID that matches TableGuid. If a match is found,
+ then a pointer to the configuration table is returned in Table, and EFI_SUCCESS
+ is returned. If a matching GUID is not found, then EFI_NOT_FOUND is returned.
+
+ @param TableGuid Pointer to table's GUID type..
+ @param Table Pointer to the table associated with TableGuid in the EFI System Table.
+
+ @retval EFI_SUCCESS A configuration table matching TableGuid was found.
+ @retval EFI_NOT_FOUND A configuration table matching TableGuid could not be found.
+
+**/
+EFI_STATUS
+EFIAPI
+EfiGetSystemConfigurationTable (
+ IN EFI_GUID *TableGuid,
+ OUT VOID **Table
+ );
+
+/**
+ This function causes the notification function to be executed for every protocol
+ of type ProtocolGuid instance that exists in the system when this function is
+ invoked. In addition, every time a protocol of type ProtocolGuid instance is
+ installed or reinstalled, the notification function is also executed.
+
+ @param ProtocolGuid Supplies GUID of the protocol upon whose installation the event is fired.
+ @param NotifyTpl Supplies the task priority level of the event notifications.
+ @param NotifyFunction Supplies the function to notify when the event is signaled.
+ @param NotifyContext The context parameter to pass to NotifyFunction.
+ @param Registration A pointer to a memory location to receive the registration value.
+
+ @return The notification event that was created.
+
+**/
+EFI_EVENT
+EFIAPI
+EfiCreateProtocolNotifyEvent(
+ IN EFI_GUID *ProtocolGuid,
+ IN EFI_TPL NotifyTpl,
+ IN EFI_EVENT_NOTIFY NotifyFunction,
+ IN VOID *NotifyContext, OPTIONAL
+ OUT VOID **Registration
+ );
+
+/**
+ This function creates an event using NotifyTpl, NoifyFunction, and NotifyContext.
+ This event is signaled with EfiNamedEventSignal(). This provide the ability for
+ one or more listeners on the same event named by the GUID specified by Name.
+
+ @param Name Supplies GUID name of the event.
+ @param NotifyTpl Supplies the task priority level of the event notifications.
+ @param NotifyFunction Supplies the function to notify when the event is signaled.
+ @param NotifyContext The context parameter to pass to NotifyFunction.
+ @param Registration A pointer to a memory location to receive the registration value.
+
+ @retval EFI_SUCCESS A named event was created.
+ @retval EFI_OUT_OF_RESOURCES There are not enough resource to create the named event.
+
+**/
+EFI_STATUS
+EFIAPI
+EfiNamedEventListen (
+ IN CONST EFI_GUID *Name,
+ IN EFI_TPL NotifyTpl,
+ IN EFI_EVENT_NOTIFY NotifyFunction,
+ IN CONST VOID *NotifyContext, OPTIONAL
+ OUT VOID *Registration OPTIONAL
+ );
+
+/**
+ This function signals the named event specified by Name. The named event must
+ have been created with EfiNamedEventListen().
+
+ @param Name Supplies GUID name of the event.
+
+ @retval EFI_SUCCESS A named event was signaled.
+ @retval EFI_OUT_OF_RESOURCES There are not enough resource to signal the named event.
+
+**/
+EFI_STATUS
+EFIAPI
+EfiNamedEventSignal (
+ IN CONST EFI_GUID *Name
+ );
+
+/**
+ This function initializes a basic mutual exclusion lock to the released state
+ and returns the lock. Each lock provides mutual exclusion access at its task
+ priority level. Since there is no preemption or multiprocessor support in EFI,
+ acquiring the lock only consists of raising to the locks TPL.
+
+ @param Lock A pointer to the lock data structure to initialize.
+ @param Priority EFI TPL associated with the lock.
+
+ @return The lock.
+
+**/
+EFI_LOCK *
+EFIAPI
+GlueEfiInitializeLock (
+ IN OUT EFI_LOCK *Lock,
+ IN EFI_TPL Priority
+ );
+
+/**
+ This macro initializes the contents of a basic mutual exclusion lock to the
+ released state. Each lock provides mutual exclusion access at its task
+ priority level. Since there is no preemption or multiprocessor support in EFI,
+ acquiring the lock only consists of raising to the locks TPL.
+
+ @param Lock A pointer to the lock data structure to initialize.
+ @param Priority The task priority level of the lock.
+
+ @return The lock.
+
+**/
+#ifdef EFI_INITIALIZE_LOCK_VARIABLE
+#undef EFI_INITIALIZE_LOCK_VARIABLE
+#endif
+
+#define EFI_INITIALIZE_LOCK_VARIABLE(Priority) \
+ {Priority, EFI_TPL_APPLICATION, EfiLockReleased }
+
+
+/**
+
+ Macro that calls DebugAssert() if an EFI_LOCK structure is not in the locked state.
+
+ If the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is set,
+ then this macro evaluates the EFI_LOCK structure specified by Lock. If Lock
+ is not in the locked state, then DebugAssert() is called passing in the source
+ filename, source line number, and Lock.
+
+ If Lock is NULL, then ASSERT().
+
+ @param LockParameter A pointer to the lock to acquire.
+
+**/
+#ifdef ASSERT_LOCKED
+#undef ASSERT_LOCKED
+#endif
+
+#define ASSERT_LOCKED(LockParameter) \
+ do { \
+ if (DebugAssertEnabled ()) { \
+ ASSERT (LockParameter != NULL); \
+ if ((LockParameter)->Lock != EfiLockAcquired) { \
+ _ASSERT (LockParameter not locked); \
+ } \
+ } \
+ } while (FALSE)
+
+
+/**
+ This function raises the system¡¯s current task priority level to the task
+ priority level of the mutual exclusion lock. Then, it places the lock in the
+ acquired state.
+
+ @param Priority The task priority level of the lock.
+
+**/
+VOID
+EFIAPI
+GlueEfiAcquireLock (
+ IN EFI_LOCK *Lock
+ );
+
+/**
+ This function raises the system¡¯s current task priority level to the task
+ priority level of the mutual exclusion lock. Then, it attempts to place the
+ lock in the acquired state.
+
+ @param Lock A pointer to the lock to acquire.
+
+ @retval EFI_SUCCESS The lock was acquired.
+ @retval EFI_ACCESS_DENIED The lock could not be acquired because it is already owned.
+
+**/
+EFI_STATUS
+EFIAPI
+GlueEfiAcquireLockOrFail (
+ IN EFI_LOCK *Lock
+ );
+
+/**
+ This function transitions a mutual exclusion lock from the acquired state to
+ the released state, and restores the system¡¯s task priority level to its
+ previous level.
+
+ @param Lock A pointer to the lock to release.
+
+**/
+VOID
+EFIAPI
+GlueEfiReleaseLock (
+ IN EFI_LOCK *Lock
+ );
+
+/**
+ This function looks up a Unicode string in UnicodeStringTable. If Language is
+ a member of SupportedLanguages and a Unicode string is found in UnicodeStringTable
+ that matches the language code specified by Language, then it is returned in
+ UnicodeString.
+
+ @param Language A pointer to the ISO 639-2 language code for the
+ Unicode string to look up and return.
+ @param SupportedLanguages A pointer to the set of ISO 639-2 language codes
+ that the Unicode string table supports. Language
+ must be a member of this set.
+ @param UnicodeStringTable A pointer to the table of Unicode strings.
+ @param UnicodeString A pointer to the Unicode string from UnicodeStringTable
+ that matches the language specified by Language.
+
+ @retval EFI_SUCCESS The Unicode string that matches the language
+ specified by Language was found
+ in the table of Unicoide strings UnicodeStringTable,
+ and it was returned in UnicodeString.
+ @retval EFI_INVALID_PARAMETER Language is NULL.
+ @retval EFI_INVALID_PARAMETER UnicodeString is NULL.
+ @retval EFI_UNSUPPORTED SupportedLanguages is NULL.
+ @retval EFI_UNSUPPORTED UnicodeStringTable is NULL.
+ @retval EFI_UNSUPPORTED The language specified by Language is not a
+ member of SupportedLanguages.
+ @retval EFI_UNSUPPORTED The language specified by Language is not
+ supported by UnicodeStringTable.
+
+**/
+EFI_STATUS
+EFIAPI
+LookupUnicodeString (
+ IN CONST CHAR8 *Language,
+ IN CONST CHAR8 *SupportedLanguages,
+ IN CONST EFI_UNICODE_STRING_TABLE *UnicodeStringTable,
+ OUT CHAR16 **UnicodeString
+ );
+
+/**
+ This function adds a Unicode string to UnicodeStringTable.
+ If Language is a member of SupportedLanguages then UnicodeString is added to
+ UnicodeStringTable. New buffers are allocated for both Language and
+ UnicodeString. The contents of Language and UnicodeString are copied into
+ these new buffers. These buffers are automatically freed when
+ FreeUnicodeStringTable() is called.
+
+ @param Language A pointer to the ISO 639-2 language code for the Unicode
+ string to add.
+ @param SupportedLanguages A pointer to the set of ISO 639-2 language codes
+ that the Unicode string table supports.
+ Language must be a member of this set.
+ @param UnicodeStringTable A pointer to the table of Unicode strings.
+ @param UnicodeString A pointer to the Unicode string to add.
+
+ @retval EFI_SUCCESS The Unicode string that matches the language
+ specified by Language was found in the table of
+ Unicode strings UnicodeStringTable, and it was
+ returned in UnicodeString.
+ @retval EFI_INVALID_PARAMETER Language is NULL.
+ @retval EFI_INVALID_PARAMETER UnicodeString is NULL.
+ @retval EFI_INVALID_PARAMETER UnicodeString is an empty string.
+ @retval EFI_UNSUPPORTED SupportedLanguages is NULL.
+ @retval EFI_ALREADY_STARTED A Unicode string with language Language is
+ already present in UnicodeStringTable.
+ @retval EFI_OUT_OF_RESOURCES There is not enough memory to add another
+ Unicode string to UnicodeStringTable.
+ @retval EFI_UNSUPPORTED The language specified by Language is not a
+ member of SupportedLanguages.
+
+**/
+EFI_STATUS
+EFIAPI
+AddUnicodeString (
+ IN CONST CHAR8 *Language,
+ IN CONST CHAR8 *SupportedLanguages,
+ IN EFI_UNICODE_STRING_TABLE **UnicodeStringTable,
+ IN CONST CHAR16 *UnicodeString
+ );
+
+/**
+ This function frees the table of Unicode strings in UnicodeStringTable.
+ If UnicodeStringTable is NULL, then EFI_SUCCESS is returned.
+ Otherwise, each language code, and each Unicode string in the Unicode string
+ table are freed, and EFI_SUCCESS is returned.
+
+ @param UnicodeStringTable A pointer to the table of Unicode strings.
+
+ @retval EFI_SUCCESS The Unicode string table was freed.
+
+**/
+EFI_STATUS
+EFIAPI
+FreeUnicodeStringTable (
+ IN EFI_UNICODE_STRING_TABLE *UnicodeStringTable
+ );
+
+/**
+ This function computes and returns the width of the Unicode character
+ specified by UnicodeChar.
+
+ @param UnicodeChar A Unicode character.
+
+ @retval 0 The width if UnicodeChar could not be determined.
+ @retval 1 UnicodeChar is a narrow glyph.
+ @retval 2 UnicodeChar is a wide glyph.
+
+**/
+
+EFI_GUID *
+GetGuidFromHandle (
+ EFI_HANDLE Handle
+ );
+/*++
+
+Routine Description:
+
+ retrieves GUID name from Handle
+
+Arguments:
+
+ Handle - Handle of image
+
+Returns:
+
+ Pointer to GUID name
+
+--*/
+
+UINTN
+EFIAPI
+GlueGetGlyphWidth (
+ IN CHAR16 UnicodeChar
+ );
+
+/**
+ This function computes and returns the display length of
+ the Null-terminated Unicode string specified by String.
+ If String is NULL, then 0 is returned.
+ If any of the widths of the Unicode characters in String
+ can not be determined, then 0 is returned.
+
+ @param String A pointer to a Null-terminated Unicode string.
+
+ @return The display length of the Null-terminated Unicode string specified by String.
+
+**/
+UINTN
+EFIAPI
+UnicodeStringDisplayLength (
+ IN CONST CHAR16 *String
+ );
+
+//
+// Functions that abstract early Framework contamination of UEFI.
+//
+/**
+ Signal a Ready to Boot Event.
+
+ Create a Ready to Boot Event. Signal it and close it. This causes other
+ events of the same event group to be signaled in other modules.
+
+**/
+VOID
+EFIAPI
+EfiSignalEventReadyToBoot (
+ VOID
+ );
+
+/**
+ Signal a Legacy Boot Event.
+
+ Create a legacy Boot Event. Signal it and close it. This causes other
+ events of the same event group to be signaled in other modules.
+
+**/
+VOID
+EFIAPI
+EfiSignalEventLegacyBoot (
+ VOID
+ );
+
+/**
+ Create a Legacy Boot Event.
+
+ Tiano extended the CreateEvent Type enum to add a legacy boot event type.
+ This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was
+ added and now it's possible to not voilate the UEFI specification by
+ declaring a GUID for the legacy boot event class. This library supports
+ the EDK/EFI 1.10 form and EDK II/UEFI 2.0 form and allows common code to
+ work both ways.
+
+ @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
+
+ @retval EFI_SUCCESS Event was created.
+ @retval Other Event was not created.
+
+**/
+EFI_STATUS
+EFIAPI
+GlueEfiCreateEventLegacyBoot (
+ OUT EFI_EVENT *LegacyBootEvent
+ );
+
+/**
+ Create an EFI event in the Legacy Boot Event Group and allows
+ the caller to specify a notification function.
+
+ This function abstracts the creation of the Legacy Boot Event.
+ The Framework moved from a proprietary to UEFI 2.0 based mechanism.
+ This library abstracts the caller from how this event is created to prevent
+ to code form having to change with the version of the specification supported.
+ If LegacyBootEvent is NULL, then ASSERT().
+
+ @param NotifyTpl The task priority level of the event.
+ @param NotifyFunction The notification function to call when the event is signaled.
+ @param NotifyContext The content to pass to NotifyFunction when the event is signaled.
+ @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
+
+ @retval EFI_SUCCESS Event was created.
+ @retval Other Event was not created.
+
+**/
+EFI_STATUS
+EFIAPI
+EfiCreateEventLegacyBootEx (
+ IN EFI_TPL NotifyTpl,
+ IN EFI_EVENT_NOTIFY NotifyFunction, OPTIONAL
+ IN VOID *NotifyContext, OPTIONAL
+ OUT EFI_EVENT *LegacyBootEvent
+ );
+
+/**
+ Create a Read to Boot Event.
+
+ Tiano extended the CreateEvent Type enum to add a ready to boot event type.
+ This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was
+ added and now it's possible to not voilate the UEFI specification and use
+ the ready to boot event class defined in UEFI 2.0. This library supports
+ the EDK/EFI 1.10 form and EDKII/UEFI 2.0 form and allows common code to
+ work both ways.
+
+ @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
+
+ @retval EFI_SUCCESS Event was created.
+ @retval Other Event was not created.
+
+**/
+EFI_STATUS
+EFIAPI
+GlueEfiCreateEventReadyToBoot (
+ OUT EFI_EVENT *ReadyToBootEvent
+ );
+
+/**
+ Create an EFI event in the Ready To Boot Event Group and allows
+ the caller to specify a notification function.
+
+ This function abstracts the creation of the Ready to Boot Event.
+ The Framework moved from a proprietary to UEFI 2.0 based mechanism.
+ This library abstracts the caller from how this event is created to prevent
+ to code form having to change with the version of the specification supported.
+ If ReadyToBootEvent is NULL, then ASSERT().
+
+ @param NotifyTpl The task priority level of the event.
+ @param NotifyFunction The notification function to call when the event is signaled.
+ @param NotifyContext The content to pass to NotifyFunction when the event is signaled.
+ @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
+
+ @retval EFI_SUCCESS Event was created.
+ @retval Other Event was not created.
+
+**/
+EFI_STATUS
+EFIAPI
+EfiCreateEventReadyToBootEx (
+ IN EFI_TPL NotifyTpl,
+ IN EFI_EVENT_NOTIFY NotifyFunction, OPTIONAL
+ IN VOID *NotifyContext, OPTIONAL
+ OUT EFI_EVENT *ReadyToBootEvent
+ );
+
+/**
+ Initialize a Firmware Volume (FV) Media Device Path node.
+
+ Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum
+ so as we move to UEFI 2.0 support we must use a mechanism that conforms with
+ the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed
+ device path is defined for Tiano extensions of device path. If the code
+ is compiled to conform with the UEFI 2.0 specification use the new device path
+ else use the old form for backwards compatability.
+
+ @param FvDevicePathNode Pointer to a FV device path node to initialize
+ @param NameGuid FV file name to use in FvDevicePathNode
+
+**/
+VOID
+EFIAPI
+GlueEfiInitializeFwVolDevicepathNode (
+ IN OUT MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode,
+ IN CONST EFI_GUID *NameGuid
+ );
+
+/**
+ Check to see if the Firmware Volume (FV) Media Device Path is valid
+
+ Tiano extended the EFI 1.10 device path nodes. Tiano does not own this enum
+ so as we move to UEFI 2.0 support we must use a mechanism that conforms with
+ the UEFI 2.0 specification to define the FV device path. An UEFI GUIDed
+ device path is defined for Tiano extensions of device path. If the code
+ is compiled to conform with the UEFI 2.0 specification use the new device path
+ else use the old form for backwards compatability. The return value to this
+ function points to a location in FvDevicePathNode and it does not allocate
+ new memory for the GUID pointer that is returned.
+
+ @param FvDevicePathNode Pointer to FV device path to check.
+
+ @retval NULL FvDevicePathNode is not valid.
+ @retval Other FvDevicePathNode is valid and pointer to NameGuid was returned.
+
+**/
+EFI_GUID *
+EFIAPI
+GlueEfiGetNameGuidFromFwVolDevicePathNode (
+ IN CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode
+ );
+
+
+#endif
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiRuntimeServicesTableLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiRuntimeServicesTableLib.h
new file mode 100644
index 0000000..6fb2ea3
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Library/EdkIIGlueUefiRuntimeServicesTableLib.h
@@ -0,0 +1,31 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ EdkIIGlueUefiRuntimeServicesTableLib.h
+
+Abstract:
+
+ Library that provides a global pointer to the UEFI Runtime Services Tables
+
+--*/
+
+#ifndef __EDKII_GLUE_UEFI_RUNTIME_SERVICES_TABLE_LIB_H__
+#define __EDKII_GLUE_UEFI_RUNTIME_SERVICES_TABLE_LIB_H__
+
+//
+// Cached copy of the EFI Runtime Services Table
+//
+extern EFI_RUNTIME_SERVICES *gRT;
+
+#endif
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcd.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcd.h
new file mode 100644
index 0000000..238d37e
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcd.h
@@ -0,0 +1,42 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ EdkIIGluePcd.h
+
+Abstract:
+
+ Fixed-at-build PCD macro expansion definitions
+
+--*/
+
+#ifndef __EDKII_GLUE_PCD_H__
+#define __EDKII_GLUE_PCD_H__
+
+//
+// Redefine Pcd functions into compile time hardcoded values
+//
+#define FixedPcdGet8(TokenName) __EDKII_GLUE_PCD_##TokenName##__
+#define FixedPcdGet16(TokenName) __EDKII_GLUE_PCD_##TokenName##__
+#define FixedPcdGet32(TokenName) __EDKII_GLUE_PCD_##TokenName##__
+#define FixedPcdGet64(TokenName) __EDKII_GLUE_PCD_##TokenName##__
+#define FixedPcdGetBool(TokenName) __EDKII_GLUE_PCD_##TokenName##__
+
+#define PcdGet8(TokenName) __EDKII_GLUE_PCD_##TokenName##__
+#define PcdGet16(TokenName) __EDKII_GLUE_PCD_##TokenName##__
+#define PcdGet32(TokenName) __EDKII_GLUE_PCD_##TokenName##__
+#define PcdGet64(TokenName) __EDKII_GLUE_PCD_##TokenName##__
+#define PcdGetPtr(TokenName) __EDKII_GLUE_PCD_##TokenName##__
+#define PcdGetBool(TokenName) __EDKII_GLUE_PCD_##TokenName##__
+
+#endif
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdBaseLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdBaseLib.h
new file mode 100644
index 0000000..3047ae2
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdBaseLib.h
@@ -0,0 +1,52 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ EdkIIGluePcdBaseLib.h
+
+Abstract:
+
+ PCD vadues for library customization
+
+--*/
+
+#ifndef __EDKII_GLUE_PCD_BASE_LIB_H__
+#define __EDKII_GLUE_PCD_BASE_LIB_H__
+
+//
+// Following Pcd values are hard coded at compile time.
+// Override these through compiler option "/D" in PlatformTools.env if needed
+//
+
+#ifndef __EDKII_GLUE_PCD_PcdMaximumUnicodeStringLength__
+#define __EDKII_GLUE_PCD_PcdMaximumUnicodeStringLength__ EDKII_GLUE_MaximumUnicodeStringLength
+#endif
+
+#ifndef __EDKII_GLUE_PCD_PcdMaximumAsciiStringLength__
+#define __EDKII_GLUE_PCD_PcdMaximumAsciiStringLength__ EDKII_GLUE_MaximumAsciiStringLength
+#endif
+
+//
+// SpinLock Pcds
+//
+#ifndef __EDKII_GLUE_PCD_PcdSpinLockTimeout__
+#define __EDKII_GLUE_PCD_PcdSpinLockTimeout__ EDKII_GLUE_SpinLockTimeout
+#endif
+
+// Linked List
+#ifndef __EDKII_GLUE_PCD_PcdMaximumLinkedListLength__
+#define __EDKII_GLUE_PCD_PcdMaximumLinkedListLength__ EDKII_GLUE_MaximumLinkedListLength
+#endif
+
+#include "Pcd/EdkIIGluePcd.h"
+#endif
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdDebugLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdDebugLib.h
new file mode 100644
index 0000000..44431c4
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdDebugLib.h
@@ -0,0 +1,50 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ EdkIIGluePcdDebugLib.h
+
+Abstract:
+
+ PCD values for library customization
+
+--*/
+
+#ifndef __EDKII_GLUE_PCD_DEBUG_LIB_H__
+#define __EDKII_GLUE_PCD_DEBUG_LIB_H__
+
+//
+// Following Pcd values are hard coded at compile time.
+// Override these through compiler option "/D" in PlatformTools.env if needed
+//
+
+
+//
+// Debug Pcds
+//
+#ifndef __EDKII_GLUE_PCD_PcdDebugPrintErrorLevel__
+#define __EDKII_GLUE_PCD_PcdDebugPrintErrorLevel__ EdkIIGlueGetDebugPrintErrorLevel()
+#endif
+
+
+#ifndef __EDKII_GLUE_PCD_PcdDebugPropertyMask__
+#define __EDKII_GLUE_PCD_PcdDebugPropertyMask__ EDKII_GLUE_DebugPropertyMask
+#endif
+
+
+#ifndef __EDKII_GLUE_PCD_PcdDebugClearMemoryValue__
+#define __EDKII_GLUE_PCD_PcdDebugClearMemoryValue__ EDKII_GLUE_DebugClearMemoryValue
+#endif
+
+#include "Pcd/EdkIIGluePcd.h"
+#endif
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdIoLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdIoLib.h
new file mode 100644
index 0000000..320073d
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdIoLib.h
@@ -0,0 +1,42 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ EdkIIGluePcdIoLib.h
+
+Abstract:
+
+ PCD values for library customization
+
+--*/
+
+#ifndef __EDKII_GLUE_PCD_IO_LIB_H__
+#define __EDKII_GLUE_PCD_IO_LIB_H__
+
+//
+// Following Pcd values are hard coded at compile time.
+// Override these through compiler option "/D" in PlatformTools.env if needed
+//
+
+
+//
+// IoBlockBaseAddressForIpf Pcd
+//
+#ifdef MDE_CPU_IPF
+#ifndef __EDKII_GLUE_PCD_PcdIoBlockBaseAddressForIpf__
+#define __EDKII_GLUE_PCD_PcdIoBlockBaseAddressForIpf__ EDKII_GLUE_IoBlockBaseAddressForIpf
+#endif
+#endif
+
+#include "Pcd/EdkIIGluePcd.h"
+#endif
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdPciExpressLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdPciExpressLib.h
new file mode 100644
index 0000000..3d7392d
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdPciExpressLib.h
@@ -0,0 +1,40 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ EdkIIGluePcdPciExpressLib.h
+
+Abstract:
+
+ PCD values for library customization
+
+--*/
+
+#ifndef __EDKII_GLUE_PCD_PCI_EXPRESS_LIB_H__
+#define __EDKII_GLUE_PCD_PCI_EXPRESS_LIB_H__
+
+//
+// Following Pcd values are hard coded at compile time.
+// Override these through compiler option "/D" in PlatformTools.env if needed
+//
+
+
+//
+// PciExpress Pcds
+//
+#ifndef __EDKII_GLUE_PCD_PcdPciExpressBaseAddress__
+#define __EDKII_GLUE_PCD_PcdPciExpressBaseAddress__ EDKII_GLUE_PciExpressBaseAddress
+#endif
+
+#include "Pcd/EdkIIGluePcd.h"
+#endif
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdPerformanceLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdPerformanceLib.h
new file mode 100644
index 0000000..d2599ea
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdPerformanceLib.h
@@ -0,0 +1,47 @@
+/*++
+
+Copyright (c) 2011, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ EdkIIGluePcdPerformanceLib.h
+
+Abstract:
+
+ PCD values for library customization
+
+--*/
+
+#ifndef __EDKII_GLUE_PCD_PERFORMANCE_LIB_H__
+#define __EDKII_GLUE_PCD_PERFORMANCE_LIB_H__
+
+//
+// Following Pcd values are hard coded at compile time.
+// Override these through compiler option "/D" in PlatformTools.env if needed
+//
+
+//
+// Performance Lib Pcds
+//
+#ifndef __EDKII_GLUE_PCD_PlatformInfoMsr__
+#define __EDKII_GLUE_PCD_PlatformInfoMsr__ EDKII_GLUE_PlatformInfoMsr
+#endif
+
+#ifndef __EDKII_GLUE_PCD_XAPICBaseMsr__
+#define __EDKII_GLUE_PCD_XAPICBaseMsr__ EDKII_GLUE_XAPICBaseMsr
+#endif
+
+#ifndef __EDKII_GLUE_PCD_ExtXAPICLogicalAPICIdMsr__
+#define __EDKII_GLUE_PCD_ExtXAPICLogicalAPICIdMsr__ EDKII_GLUE_ExtXAPICLogicalAPICIdMsr
+#endif
+
+#include "Pcd/EdkIIGluePcd.h"
+#endif
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdPostCodeLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdPostCodeLib.h
new file mode 100644
index 0000000..6314f3d
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdPostCodeLib.h
@@ -0,0 +1,40 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ EdkIIGluePcdPostCodeLib.h
+
+Abstract:
+
+ PCD values for library customization
+
+--*/
+
+#ifndef __EDKII_GLUE_PCD_POST_CODE_LIB_H__
+#define __EDKII_GLUE_PCD_POST_CODE_LIB_H__
+
+//
+// Following Pcd values are hard coded at compile time.
+// Override these through compiler option "/D" in PlatformTools.env if needed
+//
+
+//
+// PostCode Pcds
+//
+#ifndef __EDKII_GLUE_PCD_PcdPostCodePropertyMask__
+#define __EDKII_GLUE_PCD_PcdPostCodePropertyMask__ EDKII_GLUE_PostCodePropertyMask
+#endif
+
+#include "Pcd/EdkIIGluePcd.h"
+
+#endif
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdReportStatusCodeLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdReportStatusCodeLib.h
new file mode 100644
index 0000000..25481a4
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdReportStatusCodeLib.h
@@ -0,0 +1,40 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ EdkIIGluePcdReportStatusCodeLib.h
+
+Abstract:
+
+ Pcd values for library customization
+
+--*/
+
+#ifndef __EDKII_GLUE_PCD_REPORT_STATUS_CODE_LIB_H__
+#define __EDKII_GLUE_PCD_REPORT_STATUS_CODE_LIB_H__
+
+//
+// Following Pcd values are hard coded at compile time.
+// Override these through compiler option "/D" in PlatformTools.env if needed
+//
+
+//
+// ReportStatusCode Pcds
+//
+#ifndef __EDKII_GLUE_PCD_PcdReportStatusCodePropertyMask__
+#define __EDKII_GLUE_PCD_PcdReportStatusCodePropertyMask__ EDKII_GLUE_ReportStatusCodePropertyMask
+#endif
+
+#include "Pcd/EdkIIGluePcd.h"
+
+#endif
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdTimerLib.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdTimerLib.h
new file mode 100644
index 0000000..2cc6ac3
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/Pcd/EdkIIGluePcdTimerLib.h
@@ -0,0 +1,40 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ EdkIIGluePcdTimerLib.h
+
+Abstract:
+
+ PCD values for library customization
+
+--*/
+
+#ifndef __EDKII_GLUE_PCD_TIMER_LIB_H__
+#define __EDKII_GLUE_PCD_TIMER_LIB_H__
+
+//
+// Following Pcd values are hard coded at compile time.
+// Override these through compiler option "/D" in PlatformTools.env if needed
+//
+
+
+//
+// Timer Lib Pcds
+//
+#ifndef __EDKII_GLUE_PCD_PcdFSBClock__
+#define __EDKII_GLUE_PCD_PcdFSBClock__ EDKII_GLUE_FSBClock
+#endif
+
+#include "Pcd/EdkIIGluePcd.h"
+#endif
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/PeimDepex.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/PeimDepex.h
new file mode 100644
index 0000000..f27d5ec
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/PeimDepex.h
@@ -0,0 +1,34 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ PeimDepex.h
+
+Abstract:
+
+ This file is used by .dxs file. To write common .dxs for R8.x and R9, a
+ header file named PeimDepex.h musted be present.
+
+--*/
+
+
+#ifndef __EDKII_GLUELIB_PEIMDEPEX_H__
+#define __EDKII_GLUELIB_PEIMDEPEX_H__
+
+
+//
+// this file is used by .dxs file, just a place holder
+//
+
+
+#endif
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Include/x64/EdkIIGlueProcessorBind.h b/EDK/Foundation/Library/EdkIIGlueLib/Include/x64/EdkIIGlueProcessorBind.h
new file mode 100644
index 0000000..4363dda
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Include/x64/EdkIIGlueProcessorBind.h
@@ -0,0 +1,41 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ EdkIIGlueProcessorBind.h
+
+Abstract:
+
+ Processor specific definitions
+
+--*/
+
+#ifndef __EDKII_GLUE_PROCESSOR_BIND_H__
+#define __EDKII_GLUE_PROCESSOR_BIND_H__
+
+//
+// The Microsoft* C compiler can removed references to unreferenced data items
+// if the /OPT:REF linker option is used. We defined a macro as this is a
+// a non standard extension
+//
+#if _MSC_EXTENSIONS
+ #define GLOBAL_REMOVE_IF_UNREFERENCED __declspec(selectany)
+#else
+ #define GLOBAL_REMOVE_IF_UNREFERENCED
+#endif
+
+#ifndef MDE_CPU_X64
+ #define MDE_CPU_X64
+#endif
+
+#endif
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf
new file mode 100644
index 0000000..15c2656
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseCacheMaintenanceLib/BaseCacheMaintenanceLib.inf
@@ -0,0 +1,76 @@
+#/*++
+#
+# Copyright (c) 2004 - 2006, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# BaseCacheMaintenanceLib.inf
+#
+# Abstract:
+#
+# Component description file for BaseCacheMaintenanceLib.
+#
+#--*/
+
+[defines]
+BASE_NAME = EdkIIGlueBaseCacheMaintenanceLib
+COMPONENT_TYPE = LIBRARY
+
+[sources.common]
+
+[sources.ia32]
+ x86Cache.c
+
+[sources.x64]
+ x86Cache.c
+
+[sources.ipf]
+
+[sources.ebc]
+
+[includes.common]
+ .
+ ..\..\Include
+ ..\..\Include\Library
+ $(EDK_SOURCE)\Foundation
+ $(EDK_SOURCE)\Foundation\Framework
+ $(EDK_SOURCE)\Foundation\Efi
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+ $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include
+
+[libraries.common]
+ EdkIIGlueBaseLib
+
+[libraries.ia32]
+
+
+[libraries.x64]
+
+
+[nmake.common]
+ C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION
+ LIB_STD_FLAGS = /NOLOGO /IGNORE:4006
+
+[nmake.ia32]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32
+
+[nmake.x64]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64
+
+[nmake.ipf]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF
+
+[nmake.ebc]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseCacheMaintenanceLib/EdkIIGlueBaseCacheMaintenanceLib.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseCacheMaintenanceLib/EdkIIGlueBaseCacheMaintenanceLib.cif
new file mode 100644
index 0000000..44016b9
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseCacheMaintenanceLib/EdkIIGlueBaseCacheMaintenanceLib.cif
@@ -0,0 +1,11 @@
+<component>
+ name = "EdkIIGlueBaseCacheMaintenanceLib"
+ category = ModulePart
+ LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\BaseCacheMaintenanceLib"
+ RefName = "EdkIIGlueBaseCacheMaintenanceLib"
+[files]
+"EdkIIGlueBaseCacheMaintenanceLib.sdl"
+"EdkIIGlueBaseCacheMaintenanceLib.mak"
+"BaseCacheMaintenanceLib.inf"
+"x86Cache.c"
+<endComponent> \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseCacheMaintenanceLib/EdkIIGlueBaseCacheMaintenanceLib.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseCacheMaintenanceLib/EdkIIGlueBaseCacheMaintenanceLib.mak
new file mode 100644
index 0000000..99b73ce
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseCacheMaintenanceLib/EdkIIGlueBaseCacheMaintenanceLib.mak
@@ -0,0 +1,90 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueBaseCacheMaintenanceLib/EdkIIGlueBaseCacheMaintenanceLib.mak 1 1/20/12 3:48a Jeffch $
+#
+# $Revision: 1 $
+#
+# $Date: 1/20/12 3:48a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueBaseCacheMaintenanceLib/EdkIIGlueBaseCacheMaintenanceLib.mak $
+#
+# 1 1/20/12 3:48a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 1/20/12 3:27a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 9/27/11 6:09a Wesleychen
+# Intel EDK initially releases.
+#
+# 1 9/18/09 1:49a Iminglin
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: EdkIIGlueBaseCacheMaintenanceLib.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+
+!IF "$(PROCESSOR)"=="IA32" || "$(PROCESSOR)"=="x64"
+EdkIIGlueBaseCacheMaintenanceLib_OBJECTS=\
+$$(BUILD_DIR)\$(EdkIIGlueBaseCacheMaintenanceLib_DIR)\x86Cache.obj
+!ENDIF
+
+$(EdkIIGlueBaseCacheMaintenanceLib_LIB) : EdkIIGlueBaseCacheMaintenanceLib
+
+EdkIIGlueBaseCacheMaintenanceLib : $(BUILD_DIR)\EdkIIGlueBaseCacheMaintenanceLib.mak EdkIIGlueBaseCacheMaintenanceLibBin
+
+$(BUILD_DIR)\EdkIIGlueBaseCacheMaintenanceLib.mak : $(EdkIIGlueBaseCacheMaintenanceLib_DIR)\$(@B).cif $(EdkIIGlueBaseCacheMaintenanceLib_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(EdkIIGlueBaseCacheMaintenanceLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+EdkIIGlueBaseCacheMaintenanceLibBin : $(EdkIIGlueBaseLib_LIB)
+!IF "$(x64_BUILD)"=="1"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGlueBaseCacheMaintenanceLib.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBaseCacheMaintenanceLib_LIB)"\
+ "OBJECTS=$(EdkIIGlueBaseCacheMaintenanceLib_OBJECTS)"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\IA32\
+ /f $(BUILD_DIR)\EdkIIGlueBaseCacheMaintenanceLib.mak all\
+ TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBaseCacheMaintenanceLib_LIB)"\
+ "OBJECTS=$(EdkIIGlueBaseCacheMaintenanceLib_OBJECTS)"
+!ELSE
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGlueBaseCacheMaintenanceLib.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBaseCacheMaintenanceLib_LIB)"\
+ "OBJECTS=$(EdkIIGlueBaseCacheMaintenanceLib_OBJECTS)"
+!ENDIF
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseCacheMaintenanceLib/EdkIIGlueBaseCacheMaintenanceLib.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseCacheMaintenanceLib/EdkIIGlueBaseCacheMaintenanceLib.sdl
new file mode 100644
index 0000000..3d51d7c
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseCacheMaintenanceLib/EdkIIGlueBaseCacheMaintenanceLib.sdl
@@ -0,0 +1,26 @@
+TOKEN
+ Name = "EdkIIGlueBaseCacheMaintenanceLib_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable EdkIIGlueBaseCacheMaintenanceLib support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "EdkIIGlueBaseCacheMaintenanceLib_LIB"
+ Value = "$$(LIB_BUILD_DIR)\EdkIIGlueBaseCacheMaintenanceLib.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "EdkIIGlueBaseCacheMaintenanceLib_DIR"
+End
+
+MODULE
+ Help = "Includes EdkIIGlueBaseCacheMaintenanceLib.mak to Project"
+ File = "EdkIIGlueBaseCacheMaintenanceLib.mak"
+End
+
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseCacheMaintenanceLib/x86Cache.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseCacheMaintenanceLib/x86Cache.c
new file mode 100644
index 0000000..9abbf39
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseCacheMaintenanceLib/x86Cache.c
@@ -0,0 +1,254 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ x86Cache.c
+
+Abstract:
+
+ Cache Maintenance Functions.
+
+--*/
+
+#include "EdkIIGlueBase.h"
+
+/**
+ Invalidates the entire instruction cache in cache coherency domain of the
+ calling CPU.
+
+ Invalidates the entire instruction cache in cache coherency domain of the
+ calling CPU.
+
+**/
+VOID
+EFIAPI
+GlueInvalidateInstructionCache (
+ VOID
+ )
+{
+}
+
+/**
+ Invalidates a range of instruction cache lines in the cache coherency domain
+ of the calling CPU.
+
+ Invalidates the instruction cache lines specified by Address and Length. If
+ Address is not aligned on a cache line boundary, then entire instruction
+ cache line containing Address is invalidated. If Address + Length is not
+ aligned on a cache line boundary, then the entire instruction cache line
+ containing Address + Length -1 is invalidated. This function may choose to
+ invalidate the entire instruction cache if that is more efficient than
+ invalidating the specified range. If Length is 0, the no instruction cache
+ lines are invalidated. Address is returned.
+
+ If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().
+
+ @param Address The base address of the instruction cache lines to
+ invalidate. If the CPU is in a physical addressing mode, then
+ Address is a physical address. If the CPU is in a virtual
+ addressing mode, then Address is a virtual address.
+
+ @param Length The number of bytes to invalidate from the instruction cache.
+
+ @return Address
+
+**/
+VOID *
+EFIAPI
+InvalidateInstructionCacheRange (
+ IN VOID *Address,
+ IN UINTN Length
+ )
+{
+ ASSERT (Length <= MAX_ADDRESS - (UINTN)Address + 1);
+ return Address;
+}
+
+/**
+ Writes Back and Invalidates the entire data cache in cache coherency domain
+ of the calling CPU.
+
+ Writes Back and Invalidates the entire data cache in cache coherency domain
+ of the calling CPU. This function guarantees that all dirty cache lines are
+ written back to system memory, and also invalidates all the data cache lines
+ in the cache coherency domain of the calling CPU.
+
+**/
+VOID
+EFIAPI
+WriteBackInvalidateDataCache (
+ VOID
+ )
+{
+ AsmWbinvd ();
+}
+
+/**
+ Writes Back and Invalidates a range of data cache lines in the cache
+ coherency domain of the calling CPU.
+
+ Writes Back and Invalidate the data cache lines specified by Address and
+ Length. If Address is not aligned on a cache line boundary, then entire data
+ cache line containing Address is written back and invalidated. If Address +
+ Length is not aligned on a cache line boundary, then the entire data cache
+ line containing Address + Length -1 is written back and invalidated. This
+ function may choose to write back and invalidate the entire data cache if
+ that is more efficient than writing back and invalidating the specified
+ range. If Length is 0, the no data cache lines are written back and
+ invalidated. Address is returned.
+
+ If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().
+
+ @param Address The base address of the data cache lines to write back and
+ invalidate. If the CPU is in a physical addressing mode, then
+ Address is a physical address. If the CPU is in a virtual
+ addressing mode, then Address is a virtual address.
+ @param Length The number of bytes to write back and invalidate from the
+ data cache.
+
+ @return Address
+
+**/
+VOID *
+EFIAPI
+WriteBackInvalidateDataCacheRange (
+ IN VOID *Address,
+ IN UINTN Length
+ )
+{
+ UINT8 (*Uint8Ptr)[32];
+
+ ASSERT (Length <= MAX_ADDRESS - (UINTN)Address + 1);
+
+ Uint8Ptr = Address;
+ while (Length > sizeof (*Uint8Ptr)) {
+ AsmFlushCacheLine (Uint8Ptr++);
+ Length -= sizeof (*Uint8Ptr);
+ }
+ if (Length > 0) {
+ AsmFlushCacheLine (Uint8Ptr);
+ AsmFlushCacheLine (&(*Uint8Ptr)[Length - 1]);
+ }
+ return Address;
+}
+
+/**
+ Writes Back the entire data cache in cache coherency domain of the calling
+ CPU.
+
+ Writes Back the entire data cache in cache coherency domain of the calling
+ CPU. This function guarantees that all dirty cache lines are written back to
+ system memory. This function may also invalidate all the data cache lines in
+ the cache coherency domain of the calling CPU.
+
+**/
+VOID
+EFIAPI
+WriteBackDataCache (
+ VOID
+ )
+{
+ WriteBackInvalidateDataCache ();
+}
+
+/**
+ Writes Back a range of data cache lines in the cache coherency domain of the
+ calling CPU.
+
+ Writes Back the data cache lines specified by Address and Length. If Address
+ is not aligned on a cache line boundary, then entire data cache line
+ containing Address is written back. If Address + Length is not aligned on a
+ cache line boundary, then the entire data cache line containing Address +
+ Length -1 is written back. This function may choose to write back the entire
+ data cache if that is more efficient than writing back the specified range.
+ If Length is 0, the no data cache lines are written back. This function may
+ also invalidate all the data cache lines in the specified range of the cache
+ coherency domain of the calling CPU. Address is returned.
+
+ If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().
+
+ @param Address The base address of the data cache lines to write back. If
+ the CPU is in a physical addressing mode, then Address is a
+ physical address. If the CPU is in a virtual addressing
+ mode, then Address is a virtual address.
+ @param Length The number of bytes to write back from the data cache.
+
+ @return Address
+
+**/
+VOID *
+EFIAPI
+WriteBackDataCacheRange (
+ IN VOID *Address,
+ IN UINTN Length
+ )
+{
+ return WriteBackInvalidateDataCacheRange (Address, Length);
+}
+
+/**
+ Invalidates the entire data cache in cache coherency domain of the calling
+ CPU.
+
+ Invalidates the entire data cache in cache coherency domain of the calling
+ CPU. This function must be used with care because dirty cache lines are not
+ written back to system memory. It is typically used for cache diagnostics. If
+ the CPU does not support invalidation of the entire data cache, then a write
+ back and invalidate operation should be performed on the entire data cache.
+
+**/
+VOID
+EFIAPI
+InvalidateDataCache (
+ VOID
+ )
+{
+ AsmInvd ();
+}
+
+/**
+ Invalidates a range of data cache lines in the cache coherency domain of the
+ calling CPU.
+
+ Invalidates the data cache lines specified by Address and Length. If Address
+ is not aligned on a cache line boundary, then entire data cache line
+ containing Address is invalidated. If Address + Length is not aligned on a
+ cache line boundary, then the entire data cache line containing Address +
+ Length -1 is invalidated. This function must never invalidate any cache lines
+ outside the specified range. If Length is 0, the no data cache lines are
+ invalidated. Address is returned. This function must be used with care
+ because dirty cache lines are not written back to system memory. It is
+ typically used for cache diagnostics. If the CPU does not support
+ invalidation of a data cache range, then a write back and invalidate
+ operation should be performed on the data cache range.
+
+ If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().
+
+ @param Address The base address of the data cache lines to invalidate. If
+ the CPU is in a physical addressing mode, then Address is a
+ physical address. If the CPU is in a virtual addressing mode,
+ then Address is a virtual address.
+ @param Length The number of bytes to invalidate from the data cache.
+
+ @return Address
+
+**/
+VOID *
+EFIAPI
+InvalidateDataCacheRange (
+ IN VOID *Address,
+ IN UINTN Length
+ )
+{
+ return WriteBackInvalidateDataCacheRange (Address, Length);
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseDebugLibNull/BaseDebugLibNull.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseDebugLibNull/BaseDebugLibNull.inf
new file mode 100644
index 0000000..1733099
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseDebugLibNull/BaseDebugLibNull.inf
@@ -0,0 +1,77 @@
+#/*++
+#
+# Copyright (c) 2004 - 2006, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# BaseDebugLibNull.inf
+#
+# Abstract:
+#
+# Component description file for BaseDebugLibNull.
+#
+#--*/
+
+[defines]
+BASE_NAME = EdkIIGlueBaseDebugLibNull
+COMPONENT_TYPE = LIBRARY
+
+[sources.common]
+ DebugLib.c
+
+[sources.ia32]
+
+[sources.x64]
+
+[sources.ipf]
+
+[sources.ebc]
+
+[includes.common]
+ .
+ ..\..\Include
+ ..\..\Include\Library
+ $(EDK_SOURCE)\Foundation
+ $(EDK_SOURCE)\Foundation\Framework
+ $(EDK_SOURCE)\Foundation\Efi
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+ $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include
+
+[libraries.common]
+ EdkIIGlueBaseLib
+ EdkIIGlueBaseMemoryLib
+ EdkIIGlueBasePrintLib
+
+[libraries.ia32]
+
+
+[libraries.x64]
+
+
+[nmake.common]
+ C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION
+ LIB_STD_FLAGS = /NOLOGO /IGNORE:4006
+
+[nmake.ia32]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32
+
+[nmake.x64]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64
+
+[nmake.ipf]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF
+
+[nmake.ebc]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseDebugLibNull/DebugLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseDebugLibNull/DebugLib.c
new file mode 100644
index 0000000..c2865e2
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseDebugLibNull/DebugLib.c
@@ -0,0 +1,236 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ DebugLib.c
+
+Abstract:
+
+ Base Debug Library that uses PrintLib to print messages to a memory buffer.
+
+--*/
+
+#include "EdkIIGlueBase.h"
+#include "Pcd\EdkIIGluePcdDebugLib.h"
+
+//
+// Define the maximum debug and assert message length that this library supports
+//
+#define MAX_DEBUG_MESSAGE_LENGTH 0x100
+
+/**
+
+ Prints a debug message to the debug output device if the specified error level is enabled.
+
+ If any bit in ErrorLevel is also set in PcdDebugPrintErrorLevel, then print
+ the message specified by Format and the associated variable argument list to
+ the debug output device.
+
+ If Format is NULL, then ASSERT().
+
+ @param ErrorLevel The error level of the debug message.
+ @param Format Format string for the debug message to print.
+
+**/
+VOID
+EFIAPI
+DebugPrint (
+ IN UINTN ErrorLevel,
+ IN CONST CHAR8 *Format,
+ ...
+ )
+{
+ CHAR8 Buffer[MAX_DEBUG_MESSAGE_LENGTH];
+ VA_LIST Marker;
+
+ //
+ // If Format is NULL, then ASSERT().
+ //
+ ASSERT (Format != NULL);
+
+ //
+ // Print the assert message to a buffer
+ //
+ VA_START (Marker, Format);
+ AsciiVSPrint (Buffer, sizeof (Buffer), Format, Marker);
+ VA_END (Marker);
+}
+
+
+/**
+
+ Prints an assert message containing a filename, line number, and description.
+ This may be followed by a breakpoint or a dead loop.
+
+ Print a message of the form "ASSERT <FileName>(<LineNumber>): <Description>\n"
+ to the debug output device. If DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED bit of
+ PcdDebugProperyMask is set then CpuBreakpoint() is called. Otherwise, if
+ DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED bit of PcdDebugProperyMask is set then
+ CpuDeadLoop() is called. If neither of these bits are set, then this function
+ returns immediately after the message is printed to the debug output device.
+ DebugAssert() must actively prevent recusrsion. If DebugAssert() is called while
+ processing another DebugAssert(), then DebugAssert() must return immediately.
+
+ If FileName is NULL, then a <FileName> string of "(NULL) Filename" is printed.
+
+ If Description is NULL, then a <Description> string of "(NULL) Description" is printed.
+
+ @param FileName Pointer to the name of the source file that generated the assert condition.
+ @param LineNumber The line number in the source file that generated the assert condition
+ @param Description Pointer to the description of the assert condition.
+
+**/
+VOID
+EFIAPI
+DebugAssert (
+ IN CONST CHAR8 *FileName,
+ IN UINTN LineNumber,
+ IN CONST CHAR8 *Description
+ )
+{
+ CHAR8 Buffer[MAX_DEBUG_MESSAGE_LENGTH];
+
+ //
+ // Print the assert message to a buffer
+ //
+ AsciiSPrint (Buffer, sizeof (Buffer), "ASSERT %s(%d): %s\n", FileName, LineNumber, Description);
+
+ //
+ // Generate a Breakpoint, DeadLoop, or NOP based on PCD settings
+ //
+ if ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED) != 0) {
+ CpuBreakpoint ();
+ } else if ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED) != 0) {
+ CpuDeadLoop ();
+ }
+}
+
+
+/**
+
+ Fills a target buffer with PcdDebugClearMemoryValue, and returns the target buffer.
+
+ This function fills Length bytes of Buffer with the value specified by
+ PcdDebugClearMemoryValue, and returns Buffer.
+
+ If Buffer is NULL, then ASSERT().
+
+ If Length is greater than (MAX_ADDRESS ?Buffer + 1), then ASSERT().
+
+ @param Buffer Pointer to the target buffer to fill with PcdDebugClearMemoryValue.
+ @param Length Number of bytes in Buffer to fill with zeros PcdDebugClearMemoryValue.
+
+ @return Buffer
+
+**/
+VOID *
+EFIAPI
+DebugClearMemory (
+ OUT VOID *Buffer,
+ IN UINTN Length
+ )
+{
+ //
+ // If Buffer is NULL, then ASSERT().
+ //
+ ASSERT (Buffer != NULL);
+
+ //
+ // SetMem() checks for the the ASSERT() condition on Length and returns Buffer
+ //
+ return SetMem (Buffer, Length, PcdGet8(PcdDebugClearMemoryValue));
+}
+
+
+/**
+
+ Returns TRUE if ASSERT() macros are enabled.
+
+ This function returns TRUE if the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of
+ PcdDebugProperyMask is set. Otherwise FALSE is returned.
+
+ @retval TRUE The DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is set.
+ @retval FALSE The DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is clear.
+
+**/
+BOOLEAN
+EFIAPI
+DebugAssertEnabled (
+ VOID
+ )
+{
+ return ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED) != 0);
+}
+
+
+/**
+
+ Returns TRUE if DEBUG()macros are enabled.
+
+ This function returns TRUE if the DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of
+ PcdDebugProperyMask is set. Otherwise FALSE is returned.
+
+ @retval TRUE The DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of PcdDebugProperyMask is set.
+ @retval FALSE The DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of PcdDebugProperyMask is clear.
+
+**/
+BOOLEAN
+EFIAPI
+DebugPrintEnabled (
+ VOID
+ )
+{
+ return ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_PRINT_ENABLED) != 0);
+}
+
+
+/**
+
+ Returns TRUE if DEBUG_CODE()macros are enabled.
+
+ This function returns TRUE if the DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of
+ PcdDebugProperyMask is set. Otherwise FALSE is returned.
+
+ @retval TRUE The DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is set.
+ @retval FALSE The DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is clear.
+
+**/
+BOOLEAN
+EFIAPI
+DebugCodeEnabled (
+ VOID
+ )
+{
+ return ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_CODE_ENABLED) != 0);
+}
+
+
+/**
+
+ Returns TRUE if DEBUG_CLEAR_MEMORY()macro is enabled.
+
+ This function returns TRUE if the DEBUG_PROPERTY_DEBUG_CLEAR_MEMORY_ENABLED bit of
+ PcdDebugProperyMask is set. Otherwise FALSE is returned.
+
+ @retval TRUE The DEBUG_PROPERTY_DEBUG_CLEAR_MEMORY_ENABLED bit of PcdDebugProperyMask is set.
+ @retval FALSE The DEBUG_PROPERTY_DEBUG_CLEAR_MEMORY_ENABLED bit of PcdDebugProperyMask is clear.
+
+**/
+BOOLEAN
+EFIAPI
+DebugClearMemoryEnabled (
+ VOID
+ )
+{
+ return ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED) != 0);
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseDebugLibNull/EdkIIGlueBaseDebugLibNull.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseDebugLibNull/EdkIIGlueBaseDebugLibNull.cif
new file mode 100644
index 0000000..5ff52c7
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseDebugLibNull/EdkIIGlueBaseDebugLibNull.cif
@@ -0,0 +1,11 @@
+<component>
+ name = "EdkIIGlueBaseDebugLibNull"
+ category = ModulePart
+ LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\BaseDebugLibNull"
+ RefName = "EdkIIGlueBaseDebugLibNull"
+[files]
+"EdkIIGlueBaseDebugLibNull.sdl"
+"EdkIIGlueBaseDebugLibNull.mak"
+"BaseDebugLibNull.inf"
+"DebugLib.c"
+<endComponent>
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseDebugLibNull/EdkIIGlueBaseDebugLibNull.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseDebugLibNull/EdkIIGlueBaseDebugLibNull.mak
new file mode 100644
index 0000000..6b47770
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseDebugLibNull/EdkIIGlueBaseDebugLibNull.mak
@@ -0,0 +1,83 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueBaseDebugLibNull/EdkIIGlueBaseDebugLibNull.mak 1 1/20/12 3:48a Jeffch $
+#
+# $Revision: 1 $
+#
+# $Date: 1/20/12 3:48a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueBaseDebugLibNull/EdkIIGlueBaseDebugLibNull.mak $
+#
+# 1 1/20/12 3:48a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 1/20/12 3:27a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 9/27/11 6:09a Wesleychen
+# Intel EDK initially releases.
+#
+# 1 9/18/09 1:50a Iminglin
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: EdkIIGlueBaseDebugLibNull.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+
+
+$(EdkIIGlueBaseDebugLibNull_LIB) : EdkIIGlueBaseDebugLibNull
+
+EdkIIGlueBaseDebugLibNull : $(BUILD_DIR)\EdkIIGlueBaseDebugLibNull.mak EdkIIGlueBaseDebugLibNullBin
+
+$(BUILD_DIR)\EdkIIGlueBaseDebugLibNull.mak : $(EdkIIGlueBaseDebugLibNull_DIR)\$(@B).cif $(EdkIIGlueBaseDebugLibNull_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(EdkIIGlueBaseDebugLibNull_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+EdkIIGlueBaseDebugLibNullBin : $(EdkIIGlueBaseLib_LIB) $(EdkIIGlueBaseMemoryLib_LIB) $(EdkIIGlueBasePrintLib_LIB)
+!IF "$(x64_BUILD)"=="1"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGlueBaseDebugLibNull.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBaseDebugLibNull_LIB)"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\IA32\
+ /f $(BUILD_DIR)\EdkIIGlueBaseDebugLibNull.mak all\
+ TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBaseDebugLibNull_LIB)"
+!ELSE
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGlueBaseDebugLibNull.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBaseDebugLibNull_LIB)"
+!ENDIF
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseDebugLibNull/EdkIIGlueBaseDebugLibNull.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseDebugLibNull/EdkIIGlueBaseDebugLibNull.sdl
new file mode 100644
index 0000000..0e71af1
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseDebugLibNull/EdkIIGlueBaseDebugLibNull.sdl
@@ -0,0 +1,26 @@
+TOKEN
+ Name = "EdkIIGlueBaseDebugLibNull_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable BaseDebugLibNull support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "EdkIIGlueBaseDebugLibNull_LIB"
+ Value = "$$(LIB_BUILD_DIR)\EdkIIGlueBaseDebugLibNull.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "EdkIIGlueBaseDebugLibNull_DIR"
+End
+
+MODULE
+ Help = "Includes EdkIIGlueBaseDebugLibNull.mak to Project"
+ File = "EdkIIGlueBaseDebugLibNull.mak"
+End
+
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf
new file mode 100644
index 0000000..b111552
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/BaseIoLibIntrinsic.inf
@@ -0,0 +1,77 @@
+#/*++
+#
+# Copyright (c) 2004 - 2006, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# BaseIoLibIntrinsic.inf
+#
+# Abstract:
+#
+# Component description file for BaseIoLibIntrinsic.
+#
+#--*/
+
+[defines]
+BASE_NAME = EdkIIGlueBaseIoLibIntrinsic
+COMPONENT_TYPE = LIBRARY
+
+[sources.common]
+ IoLib.c
+ IoLibMsc.c
+ IoHighLevel.c
+
+[sources.ia32]
+
+[sources.x64]
+
+[sources.ipf]
+
+[sources.ebc]
+
+[includes.common]
+ .
+ ..\..\Include
+ ..\..\include\Library
+ $(EDK_SOURCE)\Foundation
+ $(EDK_SOURCE)\Foundation\Framework
+ $(EDK_SOURCE)\Foundation\Efi
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+ $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include
+
+[libraries.common]
+ EdkIIGlueBaseLib
+
+[libraries.ia32]
+
+
+[libraries.x64]
+
+
+[nmake.common]
+ C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION
+ LIB_STD_FLAGS = /NOLOGO /IGNORE:4006
+
+[nmake.ia32]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32
+
+[nmake.x64]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64
+
+[nmake.ipf]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF
+
+[nmake.ebc]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/EdkIIGlueBaseIoLibIntrinsic.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/EdkIIGlueBaseIoLibIntrinsic.cif
new file mode 100644
index 0000000..785361c
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/EdkIIGlueBaseIoLibIntrinsic.cif
@@ -0,0 +1,13 @@
+<component>
+ name = "EdkIIGlueBaseIoLibIntrinsic"
+ category = ModulePart
+ LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\BaseIoLibIntrinsic"
+ RefName = "EdkIIGlueBaseIoLibIntrinsic"
+[files]
+"EdkIIGlueBaseIoLibIntrinsic.sdl"
+"EdkIIGlueBaseIoLibIntrinsic.mak"
+"BaseIoLibIntrinsic.inf"
+"IoHighLevel.c"
+"IoLib.c"
+"IoLibMsc.c"
+<endComponent>
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/EdkIIGlueBaseIoLibIntrinsic.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/EdkIIGlueBaseIoLibIntrinsic.mak
new file mode 100644
index 0000000..3f4aba2
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/EdkIIGlueBaseIoLibIntrinsic.mak
@@ -0,0 +1,95 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueBaseIoLibIntrinsic/EdkIIGlueBaseIoLibIntrinsic.mak 1 1/20/12 3:48a Jeffch $
+#
+# $Revision: 1 $
+#
+# $Date: 1/20/12 3:48a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueBaseIoLibIntrinsic/EdkIIGlueBaseIoLibIntrinsic.mak $
+#
+# 1 1/20/12 3:48a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 1/20/12 3:27a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 9/27/11 6:10a Wesleychen
+# Intel EDK initially releases.
+#
+# 1 9/18/09 1:50a Iminglin
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: EdkIIGlueBaseIoLibIntrinsic.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+
+
+EDKIIGLUEBASEIOLIBINTRINSIC_OBJECTS=
+
+!IF "$(PROCESSOR)"=="IA32" || "$(PROCESSOR)"=="x64"
+EDKIIGLUEBASEIOLIBINTRINSIC_OBJECTS=$(EDKIIGLUEBASEIOLIBINTRINSIC_OBJECTS)\
+$$(BUILD_DIR)\$(EdkIIGlueBaseIoLibIntrinsic_DIR)\IoLib.obj\
+$$(BUILD_DIR)\$(EdkIIGlueBaseIoLibIntrinsic_DIR)\IoLibMsc.obj\
+$$(BUILD_DIR)\$(EdkIIGlueBaseIoLibIntrinsic_DIR)\IoHighLevel.obj
+!ENDIF
+
+$(EdkIIGlueBaseIoLibIntrinsic_LIB) : EdkIIGlueBaseIoLibIntrinsic
+
+EdkIIGlueBaseIoLibIntrinsic : $(BUILD_DIR)\EdkIIGlueBaseIoLibIntrinsic.mak EdkIIGlueBaseIoLibIntrinsicBin
+
+$(BUILD_DIR)\EdkIIGlueBaseIoLibIntrinsic.mak : $(EdkIIGlueBaseIoLibIntrinsic_DIR)\$(@B).cif $(EdkIIGlueBaseIoLibIntrinsic_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(EdkIIGlueBaseIoLibIntrinsic_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+EdkIIGlueBaseIoLibIntrinsicBin : $(EdkIIGlueBaseLib_LIB)
+!IF "$(x64_BUILD)"=="1"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGlueBaseIoLibIntrinsic.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBaseIoLibIntrinsic_LIB)"\
+ "OBJECTS=$(EDKIIGLUEBASEIOLIBINTRINSIC_OBJECTS)"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\IA32\
+ /f $(BUILD_DIR)\EdkIIGlueBaseIoLibIntrinsic.mak all\
+ TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBaseIoLibIntrinsic_LIB)"\
+ "OBJECTS=$(EDKIIGLUEBASEIOLIBINTRINSIC_OBJECTS)"
+!ELSE
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGlueBaseIoLibIntrinsic.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBaseIoLibIntrinsic_LIB)"\
+ "OBJECTS=$(EDKIIGLUEBASEIOLIBINTRINSIC_OBJECTS)"
+!ENDIF
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/EdkIIGlueBaseIoLibIntrinsic.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/EdkIIGlueBaseIoLibIntrinsic.sdl
new file mode 100644
index 0000000..b94f6dc
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/EdkIIGlueBaseIoLibIntrinsic.sdl
@@ -0,0 +1,26 @@
+TOKEN
+ Name = "EdkIIGlueBaseIoLibIntrinsic_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable EdkIIGlueBaseIoLibIntrinsic support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "EdkIIGlueBaseIoLibIntrinsic_LIB"
+ Value = "$$(LIB_BUILD_DIR)\EdkIIGlueBaseIoLibIntrinsic.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "EdkIIGlueBaseIoLibIntrinsic_DIR"
+End
+
+MODULE
+ Help = "Includes EdkIIGlueBaseIoLibIntrinsic.mak to Project"
+ File = "EdkIIGlueBaseIoLibIntrinsic.mak"
+End
+
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/IoHighLevel.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/IoHighLevel.c
new file mode 100644
index 0000000..debc9e0
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/IoHighLevel.c
@@ -0,0 +1,2280 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ IoHighLevel.c
+
+Abstract:
+
+ High-level Io/Mmio functions.
+
+ All assertions for bit field operations are handled bit field functions in the
+ Base Library.
+
+ The following IoLib instances share the same version of this file:
+
+ BaseIoLibIntrinsic
+ DxeIoLibCpuIo
+ PeiIoLibCpuIo
+
+--*/
+
+#include "EdkIIGlueBase.h"
+
+/**
+ Reads an 8-bit I/O port, performs a bitwise inclusive OR, and writes the
+ result back to the 8-bit I/O port.
+
+ Reads the 8-bit I/O port specified by Port, performs a bitwise inclusive OR
+ between the read result and the value specified by OrData, and writes the
+ result to the 8-bit I/O port specified by Port. The value written to the I/O
+ port is returned. This function must guarantee that all I/O read and write
+ operations are serialized.
+
+ If 8-bit I/O port operations are not supported, then ASSERT().
+
+ @param Port The I/O port to write.
+ @param OrData The value to OR with the read value from the I/O port.
+
+ @return The value written back to the I/O port.
+
+**/
+UINT8
+EFIAPI
+IoOr8 (
+ IN UINTN Port,
+ IN UINT8 OrData
+ )
+{
+ return IoWrite8 (Port, IoRead8 (Port) | OrData);
+}
+
+/**
+ Reads an 8-bit I/O port, performs a bitwise AND, and writes the result back
+ to the 8-bit I/O port.
+
+ Reads the 8-bit I/O port specified by Port, performs a bitwise AND between
+ the read result and the value specified by AndData, and writes the result to
+ the 8-bit I/O port specified by Port. The value written to the I/O port is
+ returned. This function must guarantee that all I/O read and write operations
+ are serialized.
+
+ If 8-bit I/O port operations are not supported, then ASSERT().
+
+ @param Port The I/O port to write.
+ @param AndData The value to AND with the read value from the I/O port.
+
+ @return The value written back to the I/O port.
+
+**/
+UINT8
+EFIAPI
+IoAnd8 (
+ IN UINTN Port,
+ IN UINT8 AndData
+ )
+{
+ return IoWrite8 (Port, IoRead8 (Port) & AndData);
+}
+
+/**
+ Reads an 8-bit I/O port, performs a bitwise AND followed by a bitwise
+ inclusive OR, and writes the result back to the 8-bit I/O port.
+
+ Reads the 8-bit I/O port specified by Port, performs a bitwise AND between
+ the read result and the value specified by AndData, performs a bitwise OR
+ between the result of the AND operation and the value specified by OrData,
+ and writes the result to the 8-bit I/O port specified by Port. The value
+ written to the I/O port is returned. This function must guarantee that all
+ I/O read and write operations are serialized.
+
+ If 8-bit I/O port operations are not supported, then ASSERT().
+
+ @param Port The I/O port to write.
+ @param AndData The value to AND with the read value from the I/O port.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the I/O port.
+
+**/
+UINT8
+EFIAPI
+IoAndThenOr8 (
+ IN UINTN Port,
+ IN UINT8 AndData,
+ IN UINT8 OrData
+ )
+{
+ return IoWrite8 (Port, (IoRead8 (Port) & AndData) | OrData);
+}
+
+/**
+ Reads a bit field of an I/O register.
+
+ Reads the bit field in an 8-bit I/O register. The bit field is specified by
+ the StartBit and the EndBit. The value of the bit field is returned.
+
+ If 8-bit I/O port operations are not supported, then ASSERT().
+ If StartBit is greater than 7, then ASSERT().
+ If EndBit is greater than 7, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Port The I/O port to read.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..7.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..7.
+
+ @return The value read.
+
+**/
+UINT8
+EFIAPI
+IoBitFieldRead8 (
+ IN UINTN Port,
+ IN UINTN StartBit,
+ IN UINTN EndBit
+ )
+{
+ return BitFieldRead8 (IoRead8 (Port), StartBit, EndBit);
+}
+
+/**
+ Writes a bit field to an I/O register.
+
+ Writes Value to the bit field of the I/O register. The bit field is specified
+ by the StartBit and the EndBit. All other bits in the destination I/O
+ register are preserved. The value written to the I/O port is returned. Extra
+ left bits in Value are stripped.
+
+ If 8-bit I/O port operations are not supported, then ASSERT().
+ If StartBit is greater than 7, then ASSERT().
+ If EndBit is greater than 7, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Port The I/O port to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..7.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..7.
+ @param Value New value of the bit field.
+
+ @return The value written back to the I/O port.
+
+**/
+UINT8
+EFIAPI
+IoBitFieldWrite8 (
+ IN UINTN Port,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT8 Value
+ )
+{
+ return IoWrite8 (
+ Port,
+ BitFieldWrite8 (IoRead8 (Port), StartBit, EndBit, Value)
+ );
+}
+
+/**
+ Reads a bit field in an 8-bit port, performs a bitwise OR, and writes the
+ result back to the bit field in the 8-bit port.
+
+ Reads the 8-bit I/O port specified by Port, performs a bitwise inclusive OR
+ between the read result and the value specified by OrData, and writes the
+ result to the 8-bit I/O port specified by Port. The value written to the I/O
+ port is returned. This function must guarantee that all I/O read and write
+ operations are serialized. Extra left bits in OrData are stripped.
+
+ If 8-bit I/O port operations are not supported, then ASSERT().
+ If StartBit is greater than 7, then ASSERT().
+ If EndBit is greater than 7, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Port The I/O port to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..7.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..7.
+ @param OrData The value to OR with the read value from the I/O port.
+
+ @return The value written back to the I/O port.
+
+**/
+UINT8
+EFIAPI
+IoBitFieldOr8 (
+ IN UINTN Port,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT8 OrData
+ )
+{
+ return IoWrite8 (
+ Port,
+ BitFieldOr8 (IoRead8 (Port), StartBit, EndBit, OrData)
+ );
+}
+
+/**
+ Reads a bit field in an 8-bit port, performs a bitwise AND, and writes the
+ result back to the bit field in the 8-bit port.
+
+ Reads the 8-bit I/O port specified by Port, performs a bitwise AND between
+ the read result and the value specified by AndData, and writes the result to
+ the 8-bit I/O port specified by Port. The value written to the I/O port is
+ returned. This function must guarantee that all I/O read and write operations
+ are serialized. Extra left bits in AndData are stripped.
+
+ If 8-bit I/O port operations are not supported, then ASSERT().
+ If StartBit is greater than 7, then ASSERT().
+ If EndBit is greater than 7, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Port The I/O port to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..7.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..7.
+ @param AndData The value to AND with the read value from the I/O port.
+
+ @return The value written back to the I/O port.
+
+**/
+UINT8
+EFIAPI
+IoBitFieldAnd8 (
+ IN UINTN Port,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT8 AndData
+ )
+{
+ return IoWrite8 (
+ Port,
+ BitFieldAnd8 (IoRead8 (Port), StartBit, EndBit, AndData)
+ );
+}
+
+/**
+ Reads a bit field in an 8-bit port, performs a bitwise AND followed by a
+ bitwise inclusive OR, and writes the result back to the bit field in the
+ 8-bit port.
+
+ Reads the 8-bit I/O port specified by Port, performs a bitwise AND followed
+ by a bitwise inclusive OR between the read result and the value specified by
+ AndData, and writes the result to the 8-bit I/O port specified by Port. The
+ value written to the I/O port is returned. This function must guarantee that
+ all I/O read and write operations are serialized. Extra left bits in both
+ AndData and OrData are stripped.
+
+ If 8-bit I/O port operations are not supported, then ASSERT().
+ If StartBit is greater than 7, then ASSERT().
+ If EndBit is greater than 7, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Port The I/O port to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..7.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..7.
+ @param AndData The value to AND with the read value from the I/O port.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the I/O port.
+
+**/
+UINT8
+EFIAPI
+IoBitFieldAndThenOr8 (
+ IN UINTN Port,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT8 AndData,
+ IN UINT8 OrData
+ )
+{
+ return IoWrite8 (
+ Port,
+ BitFieldAndThenOr8 (IoRead8 (Port), StartBit, EndBit, AndData, OrData)
+ );
+}
+
+/**
+ Reads a 16-bit I/O port, performs a bitwise inclusive OR, and writes the
+ result back to the 16-bit I/O port.
+
+ Reads the 16-bit I/O port specified by Port, performs a bitwise inclusive OR
+ between the read result and the value specified by OrData, and writes the
+ result to the 16-bit I/O port specified by Port. The value written to the I/O
+ port is returned. This function must guarantee that all I/O read and write
+ operations are serialized.
+
+ If 16-bit I/O port operations are not supported, then ASSERT().
+
+ @param Port The I/O port to write.
+ @param OrData The value to OR with the read value from the I/O port.
+
+ @return The value written back to the I/O port.
+
+**/
+UINT16
+EFIAPI
+IoOr16 (
+ IN UINTN Port,
+ IN UINT16 OrData
+ )
+{
+ return IoWrite16 (Port, IoRead16 (Port) | OrData);
+}
+
+/**
+ Reads a 16-bit I/O port, performs a bitwise AND, and writes the result back
+ to the 16-bit I/O port.
+
+ Reads the 16-bit I/O port specified by Port, performs a bitwise AND between
+ the read result and the value specified by AndData, and writes the result to
+ the 16-bit I/O port specified by Port. The value written to the I/O port is
+ returned. This function must guarantee that all I/O read and write operations
+ are serialized.
+
+ If 16-bit I/O port operations are not supported, then ASSERT().
+
+ @param Port The I/O port to write.
+ @param AndData The value to AND with the read value from the I/O port.
+
+ @return The value written back to the I/O port.
+
+**/
+UINT16
+EFIAPI
+IoAnd16 (
+ IN UINTN Port,
+ IN UINT16 AndData
+ )
+{
+ return IoWrite16 (Port, IoRead16 (Port) & AndData);
+}
+
+/**
+ Reads a 16-bit I/O port, performs a bitwise AND followed by a bitwise
+ inclusive OR, and writes the result back to the 16-bit I/O port.
+
+ Reads the 16-bit I/O port specified by Port, performs a bitwise AND between
+ the read result and the value specified by AndData, performs a bitwise OR
+ between the result of the AND operation and the value specified by OrData,
+ and writes the result to the 16-bit I/O port specified by Port. The value
+ written to the I/O port is returned. This function must guarantee that all
+ I/O read and write operations are serialized.
+
+ If 16-bit I/O port operations are not supported, then ASSERT().
+
+ @param Port The I/O port to write.
+ @param AndData The value to AND with the read value from the I/O port.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the I/O port.
+
+**/
+UINT16
+EFIAPI
+IoAndThenOr16 (
+ IN UINTN Port,
+ IN UINT16 AndData,
+ IN UINT16 OrData
+ )
+{
+ return IoWrite16 (Port, (IoRead16 (Port) & AndData) | OrData);
+}
+
+/**
+ Reads a bit field of an I/O register.
+
+ Reads the bit field in a 16-bit I/O register. The bit field is specified by
+ the StartBit and the EndBit. The value of the bit field is returned.
+
+ If 16-bit I/O port operations are not supported, then ASSERT().
+ If StartBit is greater than 15, then ASSERT().
+ If EndBit is greater than 15, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Port The I/O port to read.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..15.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..15.
+
+ @return The value read.
+
+**/
+UINT16
+EFIAPI
+IoBitFieldRead16 (
+ IN UINTN Port,
+ IN UINTN StartBit,
+ IN UINTN EndBit
+ )
+{
+ return BitFieldRead16 (IoRead16 (Port), StartBit, EndBit);
+}
+
+/**
+ Writes a bit field to an I/O register.
+
+ Writes Value to the bit field of the I/O register. The bit field is specified
+ by the StartBit and the EndBit. All other bits in the destination I/O
+ register are preserved. The value written to the I/O port is returned. Extra
+ left bits in Value are stripped.
+
+ If 16-bit I/O port operations are not supported, then ASSERT().
+ If StartBit is greater than 15, then ASSERT().
+ If EndBit is greater than 15, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Port The I/O port to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..15.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..15.
+ @param Value New value of the bit field.
+
+ @return The value written back to the I/O port.
+
+**/
+UINT16
+EFIAPI
+IoBitFieldWrite16 (
+ IN UINTN Port,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT16 Value
+ )
+{
+ return IoWrite16 (
+ Port,
+ BitFieldWrite16 (IoRead16 (Port), StartBit, EndBit, Value)
+ );
+}
+
+/**
+ Reads a bit field in a 16-bit port, performs a bitwise OR, and writes the
+ result back to the bit field in the 16-bit port.
+
+ Reads the 16-bit I/O port specified by Port, performs a bitwise inclusive OR
+ between the read result and the value specified by OrData, and writes the
+ result to the 16-bit I/O port specified by Port. The value written to the I/O
+ port is returned. This function must guarantee that all I/O read and write
+ operations are serialized. Extra left bits in OrData are stripped.
+
+ If 16-bit I/O port operations are not supported, then ASSERT().
+ If StartBit is greater than 15, then ASSERT().
+ If EndBit is greater than 15, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Port The I/O port to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..15.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..15.
+ @param OrData The value to OR with the read value from the I/O port.
+
+ @return The value written back to the I/O port.
+
+**/
+UINT16
+EFIAPI
+IoBitFieldOr16 (
+ IN UINTN Port,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT16 OrData
+ )
+{
+ return IoWrite16 (
+ Port,
+ BitFieldOr16 (IoRead16 (Port), StartBit, EndBit, OrData)
+ );
+}
+
+/**
+ Reads a bit field in a 16-bit port, performs a bitwise AND, and writes the
+ result back to the bit field in the 16-bit port.
+
+ Reads the 16-bit I/O port specified by Port, performs a bitwise AND between
+ the read result and the value specified by AndData, and writes the result to
+ the 16-bit I/O port specified by Port. The value written to the I/O port is
+ returned. This function must guarantee that all I/O read and write operations
+ are serialized. Extra left bits in AndData are stripped.
+
+ If 16-bit I/O port operations are not supported, then ASSERT().
+ If StartBit is greater than 15, then ASSERT().
+ If EndBit is greater than 15, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Port The I/O port to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..15.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..15.
+ @param AndData The value to AND with the read value from the I/O port.
+
+ @return The value written back to the I/O port.
+
+**/
+UINT16
+EFIAPI
+IoBitFieldAnd16 (
+ IN UINTN Port,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT16 AndData
+ )
+{
+ return IoWrite16 (
+ Port,
+ BitFieldAnd16 (IoRead16 (Port), StartBit, EndBit, AndData)
+ );
+}
+
+/**
+ Reads a bit field in a 16-bit port, performs a bitwise AND followed by a
+ bitwise inclusive OR, and writes the result back to the bit field in the
+ 16-bit port.
+
+ Reads the 16-bit I/O port specified by Port, performs a bitwise AND followed
+ by a bitwise inclusive OR between the read result and the value specified by
+ AndData, and writes the result to the 16-bit I/O port specified by Port. The
+ value written to the I/O port is returned. This function must guarantee that
+ all I/O read and write operations are serialized. Extra left bits in both
+ AndData and OrData are stripped.
+
+ If 16-bit I/O port operations are not supported, then ASSERT().
+ If StartBit is greater than 15, then ASSERT().
+ If EndBit is greater than 15, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Port The I/O port to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..15.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..15.
+ @param AndData The value to AND with the read value from the I/O port.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the I/O port.
+
+**/
+UINT16
+EFIAPI
+IoBitFieldAndThenOr16 (
+ IN UINTN Port,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT16 AndData,
+ IN UINT16 OrData
+ )
+{
+ return IoWrite16 (
+ Port,
+ BitFieldAndThenOr16 (IoRead16 (Port), StartBit, EndBit, AndData, OrData)
+ );
+}
+
+/**
+ Reads a 32-bit I/O port, performs a bitwise inclusive OR, and writes the
+ result back to the 32-bit I/O port.
+
+ Reads the 32-bit I/O port specified by Port, performs a bitwise inclusive OR
+ between the read result and the value specified by OrData, and writes the
+ result to the 32-bit I/O port specified by Port. The value written to the I/O
+ port is returned. This function must guarantee that all I/O read and write
+ operations are serialized.
+
+ If 32-bit I/O port operations are not supported, then ASSERT().
+
+ @param Port The I/O port to write.
+ @param OrData The value to OR with the read value from the I/O port.
+
+ @return The value written back to the I/O port.
+
+**/
+UINT32
+EFIAPI
+IoOr32 (
+ IN UINTN Port,
+ IN UINT32 OrData
+ )
+{
+ return IoWrite32 (Port, IoRead32 (Port) | OrData);
+}
+
+/**
+ Reads a 32-bit I/O port, performs a bitwise AND, and writes the result back
+ to the 32-bit I/O port.
+
+ Reads the 32-bit I/O port specified by Port, performs a bitwise AND between
+ the read result and the value specified by AndData, and writes the result to
+ the 32-bit I/O port specified by Port. The value written to the I/O port is
+ returned. This function must guarantee that all I/O read and write operations
+ are serialized.
+
+ If 32-bit I/O port operations are not supported, then ASSERT().
+
+ @param Port The I/O port to write.
+ @param AndData The value to AND with the read value from the I/O port.
+
+ @return The value written back to the I/O port.
+
+**/
+UINT32
+EFIAPI
+IoAnd32 (
+ IN UINTN Port,
+ IN UINT32 AndData
+ )
+{
+ return IoWrite32 (Port, IoRead32 (Port) & AndData);
+}
+
+/**
+ Reads a 32-bit I/O port, performs a bitwise AND followed by a bitwise
+ inclusive OR, and writes the result back to the 32-bit I/O port.
+
+ Reads the 32-bit I/O port specified by Port, performs a bitwise AND between
+ the read result and the value specified by AndData, performs a bitwise OR
+ between the result of the AND operation and the value specified by OrData,
+ and writes the result to the 32-bit I/O port specified by Port. The value
+ written to the I/O port is returned. This function must guarantee that all
+ I/O read and write operations are serialized.
+
+ If 32-bit I/O port operations are not supported, then ASSERT().
+
+ @param Port The I/O port to write.
+ @param AndData The value to AND with the read value from the I/O port.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the I/O port.
+
+**/
+UINT32
+EFIAPI
+IoAndThenOr32 (
+ IN UINTN Port,
+ IN UINT32 AndData,
+ IN UINT32 OrData
+ )
+{
+ return IoWrite32 (Port, (IoRead32 (Port) & AndData) | OrData);
+}
+
+/**
+ Reads a bit field of an I/O register.
+
+ Reads the bit field in a 32-bit I/O register. The bit field is specified by
+ the StartBit and the EndBit. The value of the bit field is returned.
+
+ If 32-bit I/O port operations are not supported, then ASSERT().
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Port The I/O port to read.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+
+ @return The value read.
+
+**/
+UINT32
+EFIAPI
+IoBitFieldRead32 (
+ IN UINTN Port,
+ IN UINTN StartBit,
+ IN UINTN EndBit
+ )
+{
+ return BitFieldRead32 (IoRead32 (Port), StartBit, EndBit);
+}
+
+/**
+ Writes a bit field to an I/O register.
+
+ Writes Value to the bit field of the I/O register. The bit field is specified
+ by the StartBit and the EndBit. All other bits in the destination I/O
+ register are preserved. The value written to the I/O port is returned. Extra
+ left bits in Value are stripped.
+
+ If 32-bit I/O port operations are not supported, then ASSERT().
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Port The I/O port to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+ @param Value New value of the bit field.
+
+ @return The value written back to the I/O port.
+
+**/
+UINT32
+EFIAPI
+IoBitFieldWrite32 (
+ IN UINTN Port,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT32 Value
+ )
+{
+ return IoWrite32 (
+ Port,
+ BitFieldWrite32 (IoRead32 (Port), StartBit, EndBit, Value)
+ );
+}
+
+/**
+ Reads a bit field in a 32-bit port, performs a bitwise OR, and writes the
+ result back to the bit field in the 32-bit port.
+
+ Reads the 32-bit I/O port specified by Port, performs a bitwise inclusive OR
+ between the read result and the value specified by OrData, and writes the
+ result to the 32-bit I/O port specified by Port. The value written to the I/O
+ port is returned. This function must guarantee that all I/O read and write
+ operations are serialized. Extra left bits in OrData are stripped.
+
+ If 32-bit I/O port operations are not supported, then ASSERT().
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Port The I/O port to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+ @param OrData The value to OR with the read value from the I/O port.
+
+ @return The value written back to the I/O port.
+
+**/
+UINT32
+EFIAPI
+IoBitFieldOr32 (
+ IN UINTN Port,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT32 OrData
+ )
+{
+ return IoWrite32 (
+ Port,
+ BitFieldOr32 (IoRead32 (Port), StartBit, EndBit, OrData)
+ );
+}
+
+/**
+ Reads a bit field in a 32-bit port, performs a bitwise AND, and writes the
+ result back to the bit field in the 32-bit port.
+
+ Reads the 32-bit I/O port specified by Port, performs a bitwise AND between
+ the read result and the value specified by AndData, and writes the result to
+ the 32-bit I/O port specified by Port. The value written to the I/O port is
+ returned. This function must guarantee that all I/O read and write operations
+ are serialized. Extra left bits in AndData are stripped.
+
+ If 32-bit I/O port operations are not supported, then ASSERT().
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Port The I/O port to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+ @param AndData The value to AND with the read value from the I/O port.
+
+ @return The value written back to the I/O port.
+
+**/
+UINT32
+EFIAPI
+IoBitFieldAnd32 (
+ IN UINTN Port,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT32 AndData
+ )
+{
+ return IoWrite32 (
+ Port,
+ BitFieldAnd32 (IoRead32 (Port), StartBit, EndBit, AndData)
+ );
+}
+
+/**
+ Reads a bit field in a 32-bit port, performs a bitwise AND followed by a
+ bitwise inclusive OR, and writes the result back to the bit field in the
+ 32-bit port.
+
+ Reads the 32-bit I/O port specified by Port, performs a bitwise AND followed
+ by a bitwise inclusive OR between the read result and the value specified by
+ AndData, and writes the result to the 32-bit I/O port specified by Port. The
+ value written to the I/O port is returned. This function must guarantee that
+ all I/O read and write operations are serialized. Extra left bits in both
+ AndData and OrData are stripped.
+
+ If 32-bit I/O port operations are not supported, then ASSERT().
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Port The I/O port to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+ @param AndData The value to AND with the read value from the I/O port.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the I/O port.
+
+**/
+UINT32
+EFIAPI
+IoBitFieldAndThenOr32 (
+ IN UINTN Port,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT32 AndData,
+ IN UINT32 OrData
+ )
+{
+ return IoWrite32 (
+ Port,
+ BitFieldAndThenOr32 (IoRead32 (Port), StartBit, EndBit, AndData, OrData)
+ );
+}
+
+/**
+ Reads a 64-bit I/O port, performs a bitwise inclusive OR, and writes the
+ result back to the 64-bit I/O port.
+
+ Reads the 64-bit I/O port specified by Port, performs a bitwise inclusive OR
+ between the read result and the value specified by OrData, and writes the
+ result to the 64-bit I/O port specified by Port. The value written to the I/O
+ port is returned. This function must guarantee that all I/O read and write
+ operations are serialized.
+
+ If 64-bit I/O port operations are not supported, then ASSERT().
+
+ @param Port The I/O port to write.
+ @param OrData The value to OR with the read value from the I/O port.
+
+ @return The value written back to the I/O port.
+
+**/
+UINT64
+EFIAPI
+IoOr64 (
+ IN UINTN Port,
+ IN UINT64 OrData
+ )
+{
+ return IoWrite64 (Port, IoRead64 (Port) | OrData);
+}
+
+/**
+ Reads a 64-bit I/O port, performs a bitwise AND, and writes the result back
+ to the 64-bit I/O port.
+
+ Reads the 64-bit I/O port specified by Port, performs a bitwise AND between
+ the read result and the value specified by AndData, and writes the result to
+ the 64-bit I/O port specified by Port. The value written to the I/O port is
+ returned. This function must guarantee that all I/O read and write operations
+ are serialized.
+
+ If 64-bit I/O port operations are not supported, then ASSERT().
+
+ @param Port The I/O port to write.
+ @param AndData The value to AND with the read value from the I/O port.
+
+ @return The value written back to the I/O port.
+
+**/
+UINT64
+EFIAPI
+IoAnd64 (
+ IN UINTN Port,
+ IN UINT64 AndData
+ )
+{
+ return IoWrite64 (Port, IoRead64 (Port) & AndData);
+}
+
+/**
+ Reads a 64-bit I/O port, performs a bitwise AND followed by a bitwise
+ inclusive OR, and writes the result back to the 64-bit I/O port.
+
+ Reads the 64-bit I/O port specified by Port, performs a bitwise AND between
+ the read result and the value specified by AndData, performs a bitwise OR
+ between the result of the AND operation and the value specified by OrData,
+ and writes the result to the 64-bit I/O port specified by Port. The value
+ written to the I/O port is returned. This function must guarantee that all
+ I/O read and write operations are serialized.
+
+ If 64-bit I/O port operations are not supported, then ASSERT().
+
+ @param Port The I/O port to write.
+ @param AndData The value to AND with the read value from the I/O port.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the I/O port.
+
+**/
+UINT64
+EFIAPI
+IoAndThenOr64 (
+ IN UINTN Port,
+ IN UINT64 AndData,
+ IN UINT64 OrData
+ )
+{
+ return IoWrite64 (Port, (IoRead64 (Port) & AndData) | OrData);
+}
+
+/**
+ Reads a bit field of an I/O register.
+
+ Reads the bit field in a 64-bit I/O register. The bit field is specified by
+ the StartBit and the EndBit. The value of the bit field is returned.
+
+ If 64-bit I/O port operations are not supported, then ASSERT().
+ If StartBit is greater than 63, then ASSERT().
+ If EndBit is greater than 63, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Port The I/O port to read.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..63.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..63.
+
+ @return The value read.
+
+**/
+UINT64
+EFIAPI
+IoBitFieldRead64 (
+ IN UINTN Port,
+ IN UINTN StartBit,
+ IN UINTN EndBit
+ )
+{
+ return BitFieldRead64 (IoRead64 (Port), StartBit, EndBit);
+}
+
+/**
+ Writes a bit field to an I/O register.
+
+ Writes Value to the bit field of the I/O register. The bit field is specified
+ by the StartBit and the EndBit. All other bits in the destination I/O
+ register are preserved. The value written to the I/O port is returned. Extra
+ left bits in Value are stripped.
+
+ If 64-bit I/O port operations are not supported, then ASSERT().
+ If StartBit is greater than 63, then ASSERT().
+ If EndBit is greater than 63, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Port The I/O port to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..63.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..63.
+ @param Value New value of the bit field.
+
+ @return The value written back to the I/O port.
+
+**/
+UINT64
+EFIAPI
+IoBitFieldWrite64 (
+ IN UINTN Port,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT64 Value
+ )
+{
+ return IoWrite64 (
+ Port,
+ BitFieldWrite64 (IoRead64 (Port), StartBit, EndBit, Value)
+ );
+}
+
+/**
+ Reads a bit field in a 64-bit port, performs a bitwise OR, and writes the
+ result back to the bit field in the 64-bit port.
+
+ Reads the 64-bit I/O port specified by Port, performs a bitwise inclusive OR
+ between the read result and the value specified by OrData, and writes the
+ result to the 64-bit I/O port specified by Port. The value written to the I/O
+ port is returned. This function must guarantee that all I/O read and write
+ operations are serialized. Extra left bits in OrData are stripped.
+
+ If 64-bit I/O port operations are not supported, then ASSERT().
+ If StartBit is greater than 63, then ASSERT().
+ If EndBit is greater than 63, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Port The I/O port to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..63.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..63.
+ @param OrData The value to OR with the read value from the I/O port.
+
+ @return The value written back to the I/O port.
+
+**/
+UINT64
+EFIAPI
+IoBitFieldOr64 (
+ IN UINTN Port,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT64 OrData
+ )
+{
+ return IoWrite64 (
+ Port,
+ BitFieldOr64 (IoRead64 (Port), StartBit, EndBit, OrData)
+ );
+}
+
+/**
+ Reads a bit field in a 64-bit port, performs a bitwise AND, and writes the
+ result back to the bit field in the 64-bit port.
+
+ Reads the 64-bit I/O port specified by Port, performs a bitwise AND between
+ the read result and the value specified by AndData, and writes the result to
+ the 64-bit I/O port specified by Port. The value written to the I/O port is
+ returned. This function must guarantee that all I/O read and write operations
+ are serialized. Extra left bits in AndData are stripped.
+
+ If 64-bit I/O port operations are not supported, then ASSERT().
+ If StartBit is greater than 63, then ASSERT().
+ If EndBit is greater than 63, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Port The I/O port to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..63.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..63.
+ @param AndData The value to AND with the read value from the I/O port.
+
+ @return The value written back to the I/O port.
+
+**/
+UINT64
+EFIAPI
+IoBitFieldAnd64 (
+ IN UINTN Port,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT64 AndData
+ )
+{
+ return IoWrite64 (
+ Port,
+ BitFieldAnd64 (IoRead64 (Port), StartBit, EndBit, AndData)
+ );
+}
+
+/**
+ Reads a bit field in a 64-bit port, performs a bitwise AND followed by a
+ bitwise inclusive OR, and writes the result back to the bit field in the
+ 64-bit port.
+
+ Reads the 64-bit I/O port specified by Port, performs a bitwise AND followed
+ by a bitwise inclusive OR between the read result and the value specified by
+ AndData, and writes the result to the 64-bit I/O port specified by Port. The
+ value written to the I/O port is returned. This function must guarantee that
+ all I/O read and write operations are serialized. Extra left bits in both
+ AndData and OrData are stripped.
+
+ If 64-bit I/O port operations are not supported, then ASSERT().
+ If StartBit is greater than 63, then ASSERT().
+ If EndBit is greater than 63, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Port The I/O port to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..63.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..63.
+ @param AndData The value to AND with the read value from the I/O port.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the I/O port.
+
+**/
+UINT64
+EFIAPI
+IoBitFieldAndThenOr64 (
+ IN UINTN Port,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT64 AndData,
+ IN UINT64 OrData
+ )
+{
+ return IoWrite64 (
+ Port,
+ BitFieldAndThenOr64 (IoRead64 (Port), StartBit, EndBit, AndData, OrData)
+ );
+}
+
+/**
+ Reads an 8-bit MMIO register, performs a bitwise inclusive OR, and writes the
+ result back to the 8-bit MMIO register.
+
+ Reads the 8-bit MMIO register specified by Address, performs a bitwise
+ inclusive OR between the read result and the value specified by OrData, and
+ writes the result to the 8-bit MMIO register specified by Address. The value
+ written to the MMIO register is returned. This function must guarantee that
+ all MMIO read and write operations are serialized.
+
+ If 8-bit MMIO register operations are not supported, then ASSERT().
+
+ @param Address The MMIO register to write.
+ @param OrData The value to OR with the read value from the MMIO register.
+
+ @return The value written back to the MMIO register.
+
+**/
+UINT8
+EFIAPI
+MmioOr8 (
+ IN UINTN Address,
+ IN UINT8 OrData
+ )
+{
+ return MmioWrite8 (Address, MmioRead8 (Address) | OrData);
+}
+
+/**
+ Reads an 8-bit MMIO register, performs a bitwise AND, and writes the result
+ back to the 8-bit MMIO register.
+
+ Reads the 8-bit MMIO register specified by Address, performs a bitwise AND
+ between the read result and the value specified by AndData, and writes the
+ result to the 8-bit MMIO register specified by Address. The value written to
+ the MMIO register is returned. This function must guarantee that all MMIO
+ read and write operations are serialized.
+
+ If 8-bit MMIO register operations are not supported, then ASSERT().
+
+ @param Address The MMIO register to write.
+ @param AndData The value to AND with the read value from the MMIO register.
+
+ @return The value written back to the MMIO register.
+
+**/
+UINT8
+EFIAPI
+MmioAnd8 (
+ IN UINTN Address,
+ IN UINT8 AndData
+ )
+{
+ return MmioWrite8 (Address, MmioRead8 (Address) & AndData);
+}
+
+/**
+ Reads an 8-bit MMIO register, performs a bitwise AND followed by a bitwise
+ inclusive OR, and writes the result back to the 8-bit MMIO register.
+
+ Reads the 8-bit MMIO register specified by Address, performs a bitwise AND
+ between the read result and the value specified by AndData, performs a
+ bitwise OR between the result of the AND operation and the value specified by
+ OrData, and writes the result to the 8-bit MMIO register specified by
+ Address. The value written to the MMIO register is returned. This function
+ must guarantee that all MMIO read and write operations are serialized.
+
+ If 8-bit MMIO register operations are not supported, then ASSERT().
+
+
+ @param Address The MMIO register to write.
+ @param AndData The value to AND with the read value from the MMIO register.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the MMIO register.
+
+**/
+UINT8
+EFIAPI
+MmioAndThenOr8 (
+ IN UINTN Address,
+ IN UINT8 AndData,
+ IN UINT8 OrData
+ )
+{
+ return MmioWrite8 (Address, (MmioRead8 (Address) & AndData) | OrData);
+}
+
+/**
+ Reads a bit field of a MMIO register.
+
+ Reads the bit field in an 8-bit MMIO register. The bit field is specified by
+ the StartBit and the EndBit. The value of the bit field is returned.
+
+ If 8-bit MMIO register operations are not supported, then ASSERT().
+ If StartBit is greater than 7, then ASSERT().
+ If EndBit is greater than 7, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address MMIO register to read.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..7.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..7.
+
+ @return The value read.
+
+**/
+UINT8
+EFIAPI
+MmioBitFieldRead8 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit
+ )
+{
+ return BitFieldRead8 (MmioRead8 (Address), StartBit, EndBit);
+}
+
+/**
+ Writes a bit field to a MMIO register.
+
+ Writes Value to the bit field of the MMIO register. The bit field is
+ specified by the StartBit and the EndBit. All other bits in the destination
+ MMIO register are preserved. The new value of the 8-bit register is returned.
+
+ If 8-bit MMIO register operations are not supported, then ASSERT().
+ If StartBit is greater than 7, then ASSERT().
+ If EndBit is greater than 7, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address MMIO register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..7.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..7.
+ @param Value New value of the bit field.
+
+ @return The value written back to the MMIO register.
+
+**/
+UINT8
+EFIAPI
+MmioBitFieldWrite8 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT8 Value
+ )
+{
+ return MmioWrite8 (
+ Address,
+ BitFieldWrite8 (MmioRead8 (Address), StartBit, EndBit, Value)
+ );
+}
+
+/**
+ Reads a bit field in an 8-bit MMIO register, performs a bitwise OR, and
+ writes the result back to the bit field in the 8-bit MMIO register.
+
+ Reads the 8-bit MMIO register specified by Address, performs a bitwise
+ inclusive OR between the read result and the value specified by OrData, and
+ writes the result to the 8-bit MMIO register specified by Address. The value
+ written to the MMIO register is returned. This function must guarantee that
+ all MMIO read and write operations are serialized. Extra left bits in OrData
+ are stripped.
+
+ If 8-bit MMIO register operations are not supported, then ASSERT().
+ If StartBit is greater than 7, then ASSERT().
+ If EndBit is greater than 7, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address MMIO register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..7.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..7.
+ @param OrData The value to OR with read value from the MMIO register.
+
+ @return The value written back to the MMIO register.
+
+**/
+UINT8
+EFIAPI
+MmioBitFieldOr8 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT8 OrData
+ )
+{
+ return MmioWrite8 (
+ Address,
+ BitFieldOr8 (MmioRead8 (Address), StartBit, EndBit, OrData)
+ );
+}
+
+/**
+ Reads a bit field in an 8-bit MMIO register, performs a bitwise AND, and
+ writes the result back to the bit field in the 8-bit MMIO register.
+
+ Reads the 8-bit MMIO register specified by Address, performs a bitwise AND
+ between the read result and the value specified by AndData, and writes the
+ result to the 8-bit MMIO register specified by Address. The value written to
+ the MMIO register is returned. This function must guarantee that all MMIO
+ read and write operations are serialized. Extra left bits in AndData are
+ stripped.
+
+ If 8-bit MMIO register operations are not supported, then ASSERT().
+ If StartBit is greater than 7, then ASSERT().
+ If EndBit is greater than 7, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address MMIO register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..7.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..7.
+ @param AndData The value to AND with read value from the MMIO register.
+
+ @return The value written back to the MMIO register.
+
+**/
+UINT8
+EFIAPI
+MmioBitFieldAnd8 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT8 AndData
+ )
+{
+ return MmioWrite8 (
+ Address,
+ BitFieldAnd8 (MmioRead8 (Address), StartBit, EndBit, AndData)
+ );
+}
+
+/**
+ Reads a bit field in an 8-bit MMIO register, performs a bitwise AND followed
+ by a bitwise inclusive OR, and writes the result back to the bit field in the
+ 8-bit MMIO register.
+
+ Reads the 8-bit MMIO register specified by Address, performs a bitwise AND
+ followed by a bitwise inclusive OR between the read result and the value
+ specified by AndData, and writes the result to the 8-bit MMIO register
+ specified by Address. The value written to the MMIO register is returned.
+ This function must guarantee that all MMIO read and write operations are
+ serialized. Extra left bits in both AndData and OrData are stripped.
+
+ If 8-bit MMIO register operations are not supported, then ASSERT().
+ If StartBit is greater than 7, then ASSERT().
+ If EndBit is greater than 7, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address MMIO register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..7.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..7.
+ @param AndData The value to AND with read value from the MMIO register.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the MMIO register.
+
+**/
+UINT8
+EFIAPI
+MmioBitFieldAndThenOr8 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT8 AndData,
+ IN UINT8 OrData
+ )
+{
+ return MmioWrite8 (
+ Address,
+ BitFieldAndThenOr8 (MmioRead8 (Address), StartBit, EndBit, AndData, OrData)
+ );
+}
+
+/**
+ Reads a 16-bit MMIO register, performs a bitwise inclusive OR, and writes the
+ result back to the 16-bit MMIO register.
+
+ Reads the 16-bit MMIO register specified by Address, performs a bitwise
+ inclusive OR between the read result and the value specified by OrData, and
+ writes the result to the 16-bit MMIO register specified by Address. The value
+ written to the MMIO register is returned. This function must guarantee that
+ all MMIO read and write operations are serialized.
+
+ If 16-bit MMIO register operations are not supported, then ASSERT().
+
+ @param Address The MMIO register to write.
+ @param OrData The value to OR with the read value from the MMIO register.
+
+ @return The value written back to the MMIO register.
+
+**/
+UINT16
+EFIAPI
+MmioOr16 (
+ IN UINTN Address,
+ IN UINT16 OrData
+ )
+{
+ return MmioWrite16 (Address, MmioRead16 (Address) | OrData);
+}
+
+/**
+ Reads a 16-bit MMIO register, performs a bitwise AND, and writes the result
+ back to the 16-bit MMIO register.
+
+ Reads the 16-bit MMIO register specified by Address, performs a bitwise AND
+ between the read result and the value specified by AndData, and writes the
+ result to the 16-bit MMIO register specified by Address. The value written to
+ the MMIO register is returned. This function must guarantee that all MMIO
+ read and write operations are serialized.
+
+ If 16-bit MMIO register operations are not supported, then ASSERT().
+
+ @param Address The MMIO register to write.
+ @param AndData The value to AND with the read value from the MMIO register.
+
+ @return The value written back to the MMIO register.
+
+**/
+UINT16
+EFIAPI
+MmioAnd16 (
+ IN UINTN Address,
+ IN UINT16 AndData
+ )
+{
+ return MmioWrite16 (Address, MmioRead16 (Address) & AndData);
+}
+
+/**
+ Reads a 16-bit MMIO register, performs a bitwise AND followed by a bitwise
+ inclusive OR, and writes the result back to the 16-bit MMIO register.
+
+ Reads the 16-bit MMIO register specified by Address, performs a bitwise AND
+ between the read result and the value specified by AndData, performs a
+ bitwise OR between the result of the AND operation and the value specified by
+ OrData, and writes the result to the 16-bit MMIO register specified by
+ Address. The value written to the MMIO register is returned. This function
+ must guarantee that all MMIO read and write operations are serialized.
+
+ If 16-bit MMIO register operations are not supported, then ASSERT().
+
+
+ @param Address The MMIO register to write.
+ @param AndData The value to AND with the read value from the MMIO register.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the MMIO register.
+
+**/
+UINT16
+EFIAPI
+MmioAndThenOr16 (
+ IN UINTN Address,
+ IN UINT16 AndData,
+ IN UINT16 OrData
+ )
+{
+ return MmioWrite16 (Address, (MmioRead16 (Address) & AndData) | OrData);
+}
+
+/**
+ Reads a bit field of a MMIO register.
+
+ Reads the bit field in a 16-bit MMIO register. The bit field is specified by
+ the StartBit and the EndBit. The value of the bit field is returned.
+
+ If 16-bit MMIO register operations are not supported, then ASSERT().
+ If StartBit is greater than 15, then ASSERT().
+ If EndBit is greater than 15, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address MMIO register to read.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..15.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..15.
+
+ @return The value read.
+
+**/
+UINT16
+EFIAPI
+MmioBitFieldRead16 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit
+ )
+{
+ return BitFieldRead16 (MmioRead16 (Address), StartBit, EndBit);
+}
+
+/**
+ Writes a bit field to a MMIO register.
+
+ Writes Value to the bit field of the MMIO register. The bit field is
+ specified by the StartBit and the EndBit. All other bits in the destination
+ MMIO register are preserved. The new value of the 16-bit register is returned.
+
+ If 16-bit MMIO register operations are not supported, then ASSERT().
+ If StartBit is greater than 15, then ASSERT().
+ If EndBit is greater than 15, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address MMIO register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..15.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..15.
+ @param Value New value of the bit field.
+
+ @return The value written back to the MMIO register.
+
+**/
+UINT16
+EFIAPI
+MmioBitFieldWrite16 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT16 Value
+ )
+{
+ return MmioWrite16 (
+ Address,
+ BitFieldWrite16 (MmioRead16 (Address), StartBit, EndBit, Value)
+ );
+}
+
+/**
+ Reads a bit field in a 16-bit MMIO register, performs a bitwise OR, and
+ writes the result back to the bit field in the 16-bit MMIO register.
+
+ Reads the 16-bit MMIO register specified by Address, performs a bitwise
+ inclusive OR between the read result and the value specified by OrData, and
+ writes the result to the 16-bit MMIO register specified by Address. The value
+ written to the MMIO register is returned. This function must guarantee that
+ all MMIO read and write operations are serialized. Extra left bits in OrData
+ are stripped.
+
+ If 16-bit MMIO register operations are not supported, then ASSERT().
+ If StartBit is greater than 15, then ASSERT().
+ If EndBit is greater than 15, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address MMIO register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..15.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..15.
+ @param OrData The value to OR with read value from the MMIO register.
+
+ @return The value written back to the MMIO register.
+
+**/
+UINT16
+EFIAPI
+MmioBitFieldOr16 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT16 OrData
+ )
+{
+ return MmioWrite16 (
+ Address,
+ BitFieldOr16 (MmioRead16 (Address), StartBit, EndBit, OrData)
+ );
+}
+
+/**
+ Reads a bit field in a 16-bit MMIO register, performs a bitwise AND, and
+ writes the result back to the bit field in the 16-bit MMIO register.
+
+ Reads the 16-bit MMIO register specified by Address, performs a bitwise AND
+ between the read result and the value specified by AndData, and writes the
+ result to the 16-bit MMIO register specified by Address. The value written to
+ the MMIO register is returned. This function must guarantee that all MMIO
+ read and write operations are serialized. Extra left bits in AndData are
+ stripped.
+
+ If 16-bit MMIO register operations are not supported, then ASSERT().
+ If StartBit is greater than 15, then ASSERT().
+ If EndBit is greater than 15, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address MMIO register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..15.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..15.
+ @param AndData The value to AND with read value from the MMIO register.
+
+ @return The value written back to the MMIO register.
+
+**/
+UINT16
+EFIAPI
+MmioBitFieldAnd16 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT16 AndData
+ )
+{
+ return MmioWrite16 (
+ Address,
+ BitFieldAnd16 (MmioRead16 (Address), StartBit, EndBit, AndData)
+ );
+}
+
+/**
+ Reads a bit field in a 16-bit MMIO register, performs a bitwise AND followed
+ by a bitwise inclusive OR, and writes the result back to the bit field in the
+ 16-bit MMIO register.
+
+ Reads the 16-bit MMIO register specified by Address, performs a bitwise AND
+ followed by a bitwise inclusive OR between the read result and the value
+ specified by AndData, and writes the result to the 16-bit MMIO register
+ specified by Address. The value written to the MMIO register is returned.
+ This function must guarantee that all MMIO read and write operations are
+ serialized. Extra left bits in both AndData and OrData are stripped.
+
+ If 16-bit MMIO register operations are not supported, then ASSERT().
+ If StartBit is greater than 15, then ASSERT().
+ If EndBit is greater than 15, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address MMIO register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..15.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..15.
+ @param AndData The value to AND with read value from the MMIO register.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the MMIO register.
+
+**/
+UINT16
+EFIAPI
+MmioBitFieldAndThenOr16 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT16 AndData,
+ IN UINT16 OrData
+ )
+{
+ return MmioWrite16 (
+ Address,
+ BitFieldAndThenOr16 (MmioRead16 (Address), StartBit, EndBit, AndData, OrData)
+ );
+}
+
+/**
+ Reads a 32-bit MMIO register, performs a bitwise inclusive OR, and writes the
+ result back to the 32-bit MMIO register.
+
+ Reads the 32-bit MMIO register specified by Address, performs a bitwise
+ inclusive OR between the read result and the value specified by OrData, and
+ writes the result to the 32-bit MMIO register specified by Address. The value
+ written to the MMIO register is returned. This function must guarantee that
+ all MMIO read and write operations are serialized.
+
+ If 32-bit MMIO register operations are not supported, then ASSERT().
+
+ @param Address The MMIO register to write.
+ @param OrData The value to OR with the read value from the MMIO register.
+
+ @return The value written back to the MMIO register.
+
+**/
+UINT32
+EFIAPI
+MmioOr32 (
+ IN UINTN Address,
+ IN UINT32 OrData
+ )
+{
+ return MmioWrite32 (Address, MmioRead32 (Address) | OrData);
+}
+
+/**
+ Reads a 32-bit MMIO register, performs a bitwise AND, and writes the result
+ back to the 32-bit MMIO register.
+
+ Reads the 32-bit MMIO register specified by Address, performs a bitwise AND
+ between the read result and the value specified by AndData, and writes the
+ result to the 32-bit MMIO register specified by Address. The value written to
+ the MMIO register is returned. This function must guarantee that all MMIO
+ read and write operations are serialized.
+
+ If 32-bit MMIO register operations are not supported, then ASSERT().
+
+ @param Address The MMIO register to write.
+ @param AndData The value to AND with the read value from the MMIO register.
+
+ @return The value written back to the MMIO register.
+
+**/
+UINT32
+EFIAPI
+MmioAnd32 (
+ IN UINTN Address,
+ IN UINT32 AndData
+ )
+{
+ return MmioWrite32 (Address, MmioRead32 (Address) & AndData);
+}
+
+/**
+ Reads a 32-bit MMIO register, performs a bitwise AND followed by a bitwise
+ inclusive OR, and writes the result back to the 32-bit MMIO register.
+
+ Reads the 32-bit MMIO register specified by Address, performs a bitwise AND
+ between the read result and the value specified by AndData, performs a
+ bitwise OR between the result of the AND operation and the value specified by
+ OrData, and writes the result to the 32-bit MMIO register specified by
+ Address. The value written to the MMIO register is returned. This function
+ must guarantee that all MMIO read and write operations are serialized.
+
+ If 32-bit MMIO register operations are not supported, then ASSERT().
+
+
+ @param Address The MMIO register to write.
+ @param AndData The value to AND with the read value from the MMIO register.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the MMIO register.
+
+**/
+UINT32
+EFIAPI
+MmioAndThenOr32 (
+ IN UINTN Address,
+ IN UINT32 AndData,
+ IN UINT32 OrData
+ )
+{
+ return MmioWrite32 (Address, (MmioRead32 (Address) & AndData) | OrData);
+}
+
+/**
+ Reads a bit field of a MMIO register.
+
+ Reads the bit field in a 32-bit MMIO register. The bit field is specified by
+ the StartBit and the EndBit. The value of the bit field is returned.
+
+ If 32-bit MMIO register operations are not supported, then ASSERT().
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address MMIO register to read.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+
+ @return The value read.
+
+**/
+UINT32
+EFIAPI
+MmioBitFieldRead32 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit
+ )
+{
+ return BitFieldRead32 (MmioRead32 (Address), StartBit, EndBit);
+}
+
+/**
+ Writes a bit field to a MMIO register.
+
+ Writes Value to the bit field of the MMIO register. The bit field is
+ specified by the StartBit and the EndBit. All other bits in the destination
+ MMIO register are preserved. The new value of the 32-bit register is returned.
+
+ If 32-bit MMIO register operations are not supported, then ASSERT().
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address MMIO register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+ @param Value New value of the bit field.
+
+ @return The value written back to the MMIO register.
+
+**/
+UINT32
+EFIAPI
+MmioBitFieldWrite32 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT32 Value
+ )
+{
+ return MmioWrite32 (
+ Address,
+ BitFieldWrite32 (MmioRead32 (Address), StartBit, EndBit, Value)
+ );
+}
+
+/**
+ Reads a bit field in a 32-bit MMIO register, performs a bitwise OR, and
+ writes the result back to the bit field in the 32-bit MMIO register.
+
+ Reads the 32-bit MMIO register specified by Address, performs a bitwise
+ inclusive OR between the read result and the value specified by OrData, and
+ writes the result to the 32-bit MMIO register specified by Address. The value
+ written to the MMIO register is returned. This function must guarantee that
+ all MMIO read and write operations are serialized. Extra left bits in OrData
+ are stripped.
+
+ If 32-bit MMIO register operations are not supported, then ASSERT().
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address MMIO register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+ @param OrData The value to OR with read value from the MMIO register.
+
+ @return The value written back to the MMIO register.
+
+**/
+UINT32
+EFIAPI
+MmioBitFieldOr32 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT32 OrData
+ )
+{
+ return MmioWrite32 (
+ Address,
+ BitFieldOr32 (MmioRead32 (Address), StartBit, EndBit, OrData)
+ );
+}
+
+/**
+ Reads a bit field in a 32-bit MMIO register, performs a bitwise AND, and
+ writes the result back to the bit field in the 32-bit MMIO register.
+
+ Reads the 32-bit MMIO register specified by Address, performs a bitwise AND
+ between the read result and the value specified by AndData, and writes the
+ result to the 32-bit MMIO register specified by Address. The value written to
+ the MMIO register is returned. This function must guarantee that all MMIO
+ read and write operations are serialized. Extra left bits in AndData are
+ stripped.
+
+ If 32-bit MMIO register operations are not supported, then ASSERT().
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address MMIO register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+ @param AndData The value to AND with read value from the MMIO register.
+
+ @return The value written back to the MMIO register.
+
+**/
+UINT32
+EFIAPI
+MmioBitFieldAnd32 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT32 AndData
+ )
+{
+ return MmioWrite32 (
+ Address,
+ BitFieldAnd32 (MmioRead32 (Address), StartBit, EndBit, AndData)
+ );
+}
+
+/**
+ Reads a bit field in a 32-bit MMIO register, performs a bitwise AND followed
+ by a bitwise inclusive OR, and writes the result back to the bit field in the
+ 32-bit MMIO register.
+
+ Reads the 32-bit MMIO register specified by Address, performs a bitwise AND
+ followed by a bitwise inclusive OR between the read result and the value
+ specified by AndData, and writes the result to the 32-bit MMIO register
+ specified by Address. The value written to the MMIO register is returned.
+ This function must guarantee that all MMIO read and write operations are
+ serialized. Extra left bits in both AndData and OrData are stripped.
+
+ If 32-bit MMIO register operations are not supported, then ASSERT().
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address MMIO register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+ @param AndData The value to AND with read value from the MMIO register.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the MMIO register.
+
+**/
+UINT32
+EFIAPI
+MmioBitFieldAndThenOr32 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT32 AndData,
+ IN UINT32 OrData
+ )
+{
+ return MmioWrite32 (
+ Address,
+ BitFieldAndThenOr32 (MmioRead32 (Address), StartBit, EndBit, AndData, OrData)
+ );
+}
+
+/**
+ Reads a 64-bit MMIO register, performs a bitwise inclusive OR, and writes the
+ result back to the 64-bit MMIO register.
+
+ Reads the 64-bit MMIO register specified by Address, performs a bitwise
+ inclusive OR between the read result and the value specified by OrData, and
+ writes the result to the 64-bit MMIO register specified by Address. The value
+ written to the MMIO register is returned. This function must guarantee that
+ all MMIO read and write operations are serialized.
+
+ If 64-bit MMIO register operations are not supported, then ASSERT().
+
+ @param Address The MMIO register to write.
+ @param OrData The value to OR with the read value from the MMIO register.
+
+ @return The value written back to the MMIO register.
+
+**/
+UINT64
+EFIAPI
+MmioOr64 (
+ IN UINTN Address,
+ IN UINT64 OrData
+ )
+{
+ return MmioWrite64 (Address, MmioRead64 (Address) | OrData);
+}
+
+/**
+ Reads a 64-bit MMIO register, performs a bitwise AND, and writes the result
+ back to the 64-bit MMIO register.
+
+ Reads the 64-bit MMIO register specified by Address, performs a bitwise AND
+ between the read result and the value specified by AndData, and writes the
+ result to the 64-bit MMIO register specified by Address. The value written to
+ the MMIO register is returned. This function must guarantee that all MMIO
+ read and write operations are serialized.
+
+ If 64-bit MMIO register operations are not supported, then ASSERT().
+
+ @param Address The MMIO register to write.
+ @param AndData The value to AND with the read value from the MMIO register.
+
+ @return The value written back to the MMIO register.
+
+**/
+UINT64
+EFIAPI
+MmioAnd64 (
+ IN UINTN Address,
+ IN UINT64 AndData
+ )
+{
+ return MmioWrite64 (Address, MmioRead64 (Address) & AndData);
+}
+
+/**
+ Reads a 64-bit MMIO register, performs a bitwise AND followed by a bitwise
+ inclusive OR, and writes the result back to the 64-bit MMIO register.
+
+ Reads the 64-bit MMIO register specified by Address, performs a bitwise AND
+ between the read result and the value specified by AndData, performs a
+ bitwise OR between the result of the AND operation and the value specified by
+ OrData, and writes the result to the 64-bit MMIO register specified by
+ Address. The value written to the MMIO register is returned. This function
+ must guarantee that all MMIO read and write operations are serialized.
+
+ If 64-bit MMIO register operations are not supported, then ASSERT().
+
+
+ @param Address The MMIO register to write.
+ @param AndData The value to AND with the read value from the MMIO register.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the MMIO register.
+
+**/
+UINT64
+EFIAPI
+MmioAndThenOr64 (
+ IN UINTN Address,
+ IN UINT64 AndData,
+ IN UINT64 OrData
+ )
+{
+ return MmioWrite64 (Address, (MmioRead64 (Address) & AndData) | OrData);
+}
+
+/**
+ Reads a bit field of a MMIO register.
+
+ Reads the bit field in a 64-bit MMIO register. The bit field is specified by
+ the StartBit and the EndBit. The value of the bit field is returned.
+
+ If 64-bit MMIO register operations are not supported, then ASSERT().
+ If StartBit is greater than 63, then ASSERT().
+ If EndBit is greater than 63, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address MMIO register to read.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..63.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..63.
+
+ @return The value read.
+
+**/
+UINT64
+EFIAPI
+MmioBitFieldRead64 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit
+ )
+{
+ return BitFieldRead64 (MmioRead64 (Address), StartBit, EndBit);
+}
+
+/**
+ Writes a bit field to a MMIO register.
+
+ Writes Value to the bit field of the MMIO register. The bit field is
+ specified by the StartBit and the EndBit. All other bits in the destination
+ MMIO register are preserved. The new value of the 64-bit register is returned.
+
+ If 64-bit MMIO register operations are not supported, then ASSERT().
+ If StartBit is greater than 63, then ASSERT().
+ If EndBit is greater than 63, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address MMIO register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..63.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..63.
+ @param Value New value of the bit field.
+
+ @return The value written back to the MMIO register.
+
+**/
+UINT64
+EFIAPI
+MmioBitFieldWrite64 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT64 Value
+ )
+{
+ return MmioWrite64 (
+ Address,
+ BitFieldWrite64 (MmioRead64 (Address), StartBit, EndBit, Value)
+ );
+}
+
+/**
+ Reads a bit field in a 64-bit MMIO register, performs a bitwise OR, and
+ writes the result back to the bit field in the 64-bit MMIO register.
+
+ Reads the 64-bit MMIO register specified by Address, performs a bitwise
+ inclusive OR between the read result and the value specified by OrData, and
+ writes the result to the 64-bit MMIO register specified by Address. The value
+ written to the MMIO register is returned. This function must guarantee that
+ all MMIO read and write operations are serialized. Extra left bits in OrData
+ are stripped.
+
+ If 64-bit MMIO register operations are not supported, then ASSERT().
+ If StartBit is greater than 63, then ASSERT().
+ If EndBit is greater than 63, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address MMIO register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..63.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..63.
+ @param OrData The value to OR with read value from the MMIO register.
+
+ @return The value written back to the MMIO register.
+
+**/
+UINT64
+EFIAPI
+MmioBitFieldOr64 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT64 OrData
+ )
+{
+ return MmioWrite64 (
+ Address,
+ BitFieldOr64 (MmioRead64 (Address), StartBit, EndBit, OrData)
+ );
+}
+
+/**
+ Reads a bit field in a 64-bit MMIO register, performs a bitwise AND, and
+ writes the result back to the bit field in the 64-bit MMIO register.
+
+ Reads the 64-bit MMIO register specified by Address, performs a bitwise AND
+ between the read result and the value specified by AndData, and writes the
+ result to the 64-bit MMIO register specified by Address. The value written to
+ the MMIO register is returned. This function must guarantee that all MMIO
+ read and write operations are serialized. Extra left bits in AndData are
+ stripped.
+
+ If 64-bit MMIO register operations are not supported, then ASSERT().
+ If StartBit is greater than 63, then ASSERT().
+ If EndBit is greater than 63, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address MMIO register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..63.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..63.
+ @param AndData The value to AND with read value from the MMIO register.
+
+ @return The value written back to the MMIO register.
+
+**/
+UINT64
+EFIAPI
+MmioBitFieldAnd64 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT64 AndData
+ )
+{
+ return MmioWrite64 (
+ Address,
+ BitFieldAnd64 (MmioRead64 (Address), StartBit, EndBit, AndData)
+ );
+}
+
+/**
+ Reads a bit field in a 64-bit MMIO register, performs a bitwise AND followed
+ by a bitwise inclusive OR, and writes the result back to the bit field in the
+ 64-bit MMIO register.
+
+ Reads the 64-bit MMIO register specified by Address, performs a bitwise AND
+ followed by a bitwise inclusive OR between the read result and the value
+ specified by AndData, and writes the result to the 64-bit MMIO register
+ specified by Address. The value written to the MMIO register is returned.
+ This function must guarantee that all MMIO read and write operations are
+ serialized. Extra left bits in both AndData and OrData are stripped.
+
+ If 64-bit MMIO register operations are not supported, then ASSERT().
+ If StartBit is greater than 63, then ASSERT().
+ If EndBit is greater than 63, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address MMIO register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..63.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..63.
+ @param AndData The value to AND with read value from the MMIO register.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the MMIO register.
+
+**/
+UINT64
+EFIAPI
+MmioBitFieldAndThenOr64 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT64 AndData,
+ IN UINT64 OrData
+ )
+{
+ return MmioWrite64 (
+ Address,
+ BitFieldAndThenOr64 (MmioRead64 (Address), StartBit, EndBit, AndData, OrData)
+ );
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/IoLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/IoLib.c
new file mode 100644
index 0000000..b56f2cb
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/IoLib.c
@@ -0,0 +1,74 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ IoLib.c
+
+Abstract:
+
+ Common I/O Library routines.
+
+--*/
+
+#include "EdkIIGlueBase.h"
+
+/**
+ Reads a 64-bit I/O port.
+
+ Reads the 64-bit I/O port specified by Port. The 64-bit read value is returned.
+ This function must guarantee that all I/O read and write operations are
+ serialized.
+
+ If 64-bit I/O port operations are not supported, then ASSERT().
+
+ @param Port The I/O port to read.
+
+ @return The value read.
+
+**/
+UINT64
+EFIAPI
+IoRead64 (
+ IN UINTN Port
+ )
+{
+ ASSERT (FALSE);
+ return 0;
+}
+
+/**
+ Writes a 64-bit I/O port.
+
+ Writes the 64-bit I/O port specified by Port with the value specified by Value
+ and returns Value. This function must guarantee that all I/O read and write
+ operations are serialized.
+
+ If 64-bit I/O port operations are not supported, then ASSERT().
+
+ @param Port The I/O port to write.
+ @param Value The value to write to the I/O port.
+
+ @return The value written the I/O port.
+
+**/
+UINT64
+EFIAPI
+IoWrite64 (
+ IN UINTN Port,
+ IN UINT64 Value
+ )
+{
+ ASSERT (FALSE);
+ return 0;
+}
+
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/IoLibMsc.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/IoLibMsc.c
new file mode 100644
index 0000000..ea3eafb
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseIoLibIntrinsic/IoLibMsc.c
@@ -0,0 +1,436 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ IoLibMsc.c
+
+Abstract:
+
+ I/O Library. This file has compiler specifics for Microsft C as there is no
+ ANSI C standard for doing IO.
+
+ MSC - uses intrinsic functions and the optimize will remove the function call
+ overhead.
+
+ We don't advocate putting compiler specifics in libraries or drivers but there
+ is no other way to make this work.
+
+--*/
+
+#include "EdkIIGlueBase.h"
+
+#if _MSC_EXTENSIONS
+
+//
+// Microsoft Visual Studio 7.1 Function Prototypes for I/O Intrinsics
+//
+int _inp (unsigned short port);
+unsigned short _inpw (unsigned short port);
+unsigned long _inpd (unsigned short port);
+int _outp (unsigned short port, int databyte );
+unsigned short _outpw (unsigned short port, unsigned short dataword );
+unsigned long _outpd (unsigned short port, unsigned long dataword );
+void _ReadWriteBarrier (void);
+
+#pragma intrinsic(_inp)
+#pragma intrinsic(_inpw)
+#pragma intrinsic(_inpd)
+#pragma intrinsic(_outp)
+#pragma intrinsic(_outpw)
+#pragma intrinsic(_outpd)
+#pragma intrinsic(_ReadWriteBarrier)
+
+//
+// _ReadWriteBarrier() forces memory reads and writes to complete at the point
+// in the call. This is only a hint to the compiler and does emit code.
+// In past versions of the compiler, _ReadWriteBarrier was enforced only
+// locally and did not affect functions up the call tree. In Visual C++
+// 2005, _ReadWriteBarrier is enforced all the way up the call tree.
+//
+
+/**
+ Reads an 8-bit I/O port.
+
+ Reads the 8-bit I/O port specified by Port. The 8-bit read value is returned.
+ This function must guarantee that all I/O read and write operations are
+ serialized.
+
+ If 8-bit I/O port operations are not supported, then ASSERT().
+
+ @param Port The I/O port to read.
+
+ @return The value read.
+
+**/
+UINT8
+EFIAPI
+GlueIoRead8 (
+ IN UINTN Port
+ )
+{
+ UINT8 Value;
+
+ _ReadWriteBarrier ();
+ Value = (UINT8)_inp ((UINT16)Port);
+ _ReadWriteBarrier ();
+ return Value;
+}
+
+/**
+ Writes an 8-bit I/O port.
+
+ Writes the 8-bit I/O port specified by Port with the value specified by Value
+ and returns Value. This function must guarantee that all I/O read and write
+ operations are serialized.
+
+ If 8-bit I/O port operations are not supported, then ASSERT().
+
+ @param Port The I/O port to write.
+ @param Value The value to write to the I/O port.
+
+ @return The value written the I/O port.
+
+**/
+UINT8
+EFIAPI
+GlueIoWrite8 (
+ IN UINTN Port,
+ IN UINT8 Value
+ )
+{
+ _ReadWriteBarrier ();
+ (UINT8)_outp ((UINT16)Port, Value);
+ _ReadWriteBarrier ();
+ return Value;
+}
+
+/**
+ Reads a 16-bit I/O port.
+
+ Reads the 16-bit I/O port specified by Port. The 16-bit read value is returned.
+ This function must guarantee that all I/O read and write operations are
+ serialized.
+
+ If 16-bit I/O port operations are not supported, then ASSERT().
+
+ @param Port The I/O port to read.
+
+ @return The value read.
+
+**/
+UINT16
+EFIAPI
+GlueIoRead16 (
+ IN UINTN Port
+ )
+{
+ UINT16 Value;
+
+ ASSERT ((Port & 1) == 0);
+ _ReadWriteBarrier ();
+ Value = _inpw ((UINT16)Port);
+ _ReadWriteBarrier ();
+ return Value;
+}
+
+/**
+ Writes a 16-bit I/O port.
+
+ Writes the 16-bit I/O port specified by Port with the value specified by Value
+ and returns Value. This function must guarantee that all I/O read and write
+ operations are serialized.
+
+ If 16-bit I/O port operations are not supported, then ASSERT().
+
+ @param Port The I/O port to write.
+ @param Value The value to write to the I/O port.
+
+ @return The value written the I/O port.
+
+**/
+UINT16
+EFIAPI
+GlueIoWrite16 (
+ IN UINTN Port,
+ IN UINT16 Value
+ )
+{
+ ASSERT ((Port & 1) == 0);
+ _ReadWriteBarrier ();
+ _outpw ((UINT16)Port, Value);
+ _ReadWriteBarrier ();
+ return Value;
+}
+
+/**
+ Reads a 32-bit I/O port.
+
+ Reads the 32-bit I/O port specified by Port. The 32-bit read value is returned.
+ This function must guarantee that all I/O read and write operations are
+ serialized.
+
+ If 32-bit I/O port operations are not supported, then ASSERT().
+
+ @param Port The I/O port to read.
+
+ @return The value read.
+
+**/
+UINT32
+EFIAPI
+GlueIoRead32 (
+ IN UINTN Port
+ )
+{
+ UINT32 Value;
+
+ ASSERT ((Port & 3) == 0);
+ _ReadWriteBarrier ();
+ Value = _inpd ((UINT16)Port);
+ _ReadWriteBarrier ();
+ return Value;
+}
+
+/**
+ Writes a 32-bit I/O port.
+
+ Writes the 32-bit I/O port specified by Port with the value specified by Value
+ and returns Value. This function must guarantee that all I/O read and write
+ operations are serialized.
+
+ If 32-bit I/O port operations are not supported, then ASSERT().
+
+ @param Port The I/O port to write.
+ @param Value The value to write to the I/O port.
+
+ @return The value written the I/O port.
+
+**/
+UINT32
+EFIAPI
+GlueIoWrite32 (
+ IN UINTN Port,
+ IN UINT32 Value
+ )
+{
+ ASSERT ((Port & 3) == 0);
+ _ReadWriteBarrier ();
+ _outpd ((UINT16)Port, Value);
+ _ReadWriteBarrier ();
+ return Value;
+}
+
+
+/**
+ Reads an 8-bit MMIO register.
+
+ Reads the 8-bit MMIO register specified by Address. The 8-bit read value is
+ returned. This function must guarantee that all MMIO read and write
+ operations are serialized.
+
+ If 8-bit MMIO register operations are not supported, then ASSERT().
+
+ @param Address The MMIO register to read.
+
+ @return The value read.
+
+**/
+UINT8
+EFIAPI
+MmioRead8 (
+ IN UINTN Address
+ )
+{
+ UINT8 Value;
+
+ Value = *(volatile UINT8*)Address;
+ return Value;
+}
+
+/**
+ Writes an 8-bit MMIO register.
+
+ Writes the 8-bit MMIO register specified by Address with the value specified
+ by Value and returns Value. This function must guarantee that all MMIO read
+ and write operations are serialized.
+
+ If 8-bit MMIO register operations are not supported, then ASSERT().
+
+ @param Address The MMIO register to write.
+ @param Value The value to write to the MMIO register.
+
+**/
+UINT8
+EFIAPI
+MmioWrite8 (
+ IN UINTN Address,
+ IN UINT8 Value
+ )
+{
+ return *(volatile UINT8*)Address = Value;
+}
+
+/**
+ Reads a 16-bit MMIO register.
+
+ Reads the 16-bit MMIO register specified by Address. The 16-bit read value is
+ returned. This function must guarantee that all MMIO read and write
+ operations are serialized.
+
+ If 16-bit MMIO register operations are not supported, then ASSERT().
+
+ @param Address The MMIO register to read.
+
+ @return The value read.
+
+**/
+UINT16
+EFIAPI
+MmioRead16 (
+ IN UINTN Address
+ )
+{
+ UINT16 Value;
+
+ ASSERT ((Address & 1) == 0);
+ Value = *(volatile UINT16*)Address;
+ return Value;
+}
+
+/**
+ Writes a 16-bit MMIO register.
+
+ Writes the 16-bit MMIO register specified by Address with the value specified
+ by Value and returns Value. This function must guarantee that all MMIO read
+ and write operations are serialized.
+
+ If 16-bit MMIO register operations are not supported, then ASSERT().
+
+ @param Address The MMIO register to write.
+ @param Value The value to write to the MMIO register.
+
+**/
+UINT16
+EFIAPI
+MmioWrite16 (
+ IN UINTN Address,
+ IN UINT16 Value
+ )
+{
+ ASSERT ((Address & 1) == 0);
+ return *(volatile UINT16*)Address = Value;
+}
+
+/**
+ Reads a 32-bit MMIO register.
+
+ Reads the 32-bit MMIO register specified by Address. The 32-bit read value is
+ returned. This function must guarantee that all MMIO read and write
+ operations are serialized.
+
+ If 32-bit MMIO register operations are not supported, then ASSERT().
+
+ @param Address The MMIO register to read.
+
+ @return The value read.
+
+**/
+UINT32
+EFIAPI
+MmioRead32 (
+ IN UINTN Address
+ )
+{
+ UINT32 Value;
+
+ ASSERT ((Address & 3) == 0);
+ Value = *(volatile UINT32*)Address;
+ return Value;
+}
+
+/**
+ Writes a 32-bit MMIO register.
+
+ Writes the 32-bit MMIO register specified by Address with the value specified
+ by Value and returns Value. This function must guarantee that all MMIO read
+ and write operations are serialized.
+
+ If 32-bit MMIO register operations are not supported, then ASSERT().
+
+ @param Address The MMIO register to write.
+ @param Value The value to write to the MMIO register.
+
+**/
+UINT32
+EFIAPI
+MmioWrite32 (
+ IN UINTN Address,
+ IN UINT32 Value
+ )
+{
+ ASSERT ((Address & 3) == 0);
+ return *(volatile UINT32*)Address = Value;
+}
+
+/**
+ Reads a 64-bit MMIO register.
+
+ Reads the 64-bit MMIO register specified by Address. The 64-bit read value is
+ returned. This function must guarantee that all MMIO read and write
+ operations are serialized.
+
+ If 64-bit MMIO register operations are not supported, then ASSERT().
+
+ @param Address The MMIO register to read.
+
+ @return The value read.
+
+**/
+UINT64
+EFIAPI
+MmioRead64 (
+ IN UINTN Address
+ )
+{
+ UINT64 Value;
+
+ ASSERT ((Address & 7) == 0);
+ Value = *(volatile UINT64*)Address;
+ return Value;
+}
+
+/**
+ Writes a 64-bit MMIO register.
+
+ Writes the 64-bit MMIO register specified by Address with the value specified
+ by Value and returns Value. This function must guarantee that all MMIO read
+ and write operations are serialized.
+
+ If 64-bit MMIO register operations are not supported, then ASSERT().
+
+ @param Address The MMIO register to write.
+ @param Value The value to write to the MMIO register.
+
+**/
+UINT64
+EFIAPI
+MmioWrite64 (
+ IN UINTN Address,
+ IN UINT64 Value
+ )
+{
+ ASSERT ((Address & 7) == 0);
+ return *(volatile UINT64*)Address = Value;
+}
+
+#endif
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/ARShiftU64.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/ARShiftU64.c
new file mode 100644
index 0000000..5f57b9d
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/ARShiftU64.c
@@ -0,0 +1,49 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ ARShiftU64.c
+
+Abstract:
+
+ Math worker functions.
+
+--*/
+
+#include "BaseLibInternal.h"
+
+/**
+ Shifts a 64-bit integer right between 0 and 63 bits. The high bits are filled
+ with original integer's bit 63. The shifted value is returned.
+
+ This function shifts the 64-bit value Operand to the right by Count bits. The
+ high Count bits are set to bit 63 of Operand. The shifted value is returned.
+
+ If Count is greater than 63, then ASSERT().
+
+ @param Operand The 64-bit operand to shift right.
+ @param Count The number of bits to shift right.
+
+ @return Operand arithmetically shifted right by Count
+
+**/
+UINT64
+EFIAPI
+ARShiftU64 (
+ IN UINT64 Operand,
+ IN UINTN Count
+ )
+{
+ ASSERT (Count < sizeof (Operand) * 8);
+ return InternalMathARShiftU64 (Operand, Count);
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/BaseLib.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/BaseLib.inf
new file mode 100644
index 0000000..824cdfd
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/BaseLib.inf
@@ -0,0 +1,335 @@
+#/*++
+#
+# Copyright (c) 2004 - 2006, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# BaseLib.inf
+#
+# Abstract:
+#
+# Component description file for BaseLib.
+#
+#--*/
+
+[defines]
+BASE_NAME = EdkIIGlueBaseLib
+COMPONENT_TYPE = LIBRARY
+
+[sources.common]
+ String.c
+ LinkedList.c
+ Synchronization.c
+ Cpu.c
+ CpuDeadLoop.c
+ BitField.c
+ ARShiftU64.c
+ DivS64x64Remainder.c
+ DivU64x32.c
+ DivU64x32Remainder.c
+ DivU64x64Remainder.c
+ GetPowerOfTwo32.c
+ GetPowerOfTwo64.c
+ HighBitSet32.c
+ HighBitSet64.c
+ LowBitSet32.c
+ LowBitSet64.c
+ LRotU32.c
+ LRotU64.c
+ LShiftU64.c
+ ModU64x32.c
+ MultS64x64.c
+ MultU64x32.c
+ MultU64x64.c
+ RRotU32.c
+ RRotU64.c
+ RShiftU64.c
+ SetJump.c
+ LongJump.c
+ SwapBytes16.c
+ SwapBytes32.c
+ SwapBytes64.c
+ SwitchStack.c
+
+[sources.ia32]
+ x86DisablePaging32.c
+ x86DisablePaging64.c
+ x86EnablePaging32.c
+ x86EnablePaging64.c
+ x86FxRestore.c
+ x86FxSave.c
+ x86GetInterruptState.c
+ x86MemoryFence.c
+ x86Msr.c
+ x86ReadGdtr.c
+ x86ReadIdtr.c
+ x86Thunk.c
+ x86WriteGdtr.c
+ x86WriteIdtr.c
+ Unaligned.c
+ Ia32\Non-existing.c
+ Ia32\InternalSwitchStack.c
+ Ia32\LShiftU64.asm
+ Ia32\RShiftU64.asm
+ Ia32\ARShiftU64.asm
+ Ia32\LRotU64.asm
+ Ia32\RRotU64.asm
+ Ia32\MultU64x32.asm
+ Ia32\MultU64x64.asm
+ Ia32\DivU64x32.asm
+ Ia32\ModU64x32.asm
+ Ia32\DivU64x32Remainder.asm
+ Ia32\DivU64x64Remainder.asm
+ Ia32\DivS64x64Remainder.c
+ Ia32\SwapBytes64.asm
+ Ia32\SetJump.asm
+ Ia32\LongJump.asm
+ Ia32\CpuId.asm
+ Ia32\CpuIdEx.asm
+ Ia32\ReadEflags.asm
+ Ia32\ReadMsr64.asm
+ Ia32\WriteMsr64.asm
+ Ia32\ReadCr0.asm
+ Ia32\ReadCr2.asm
+ Ia32\ReadCr3.asm
+ Ia32\ReadCr4.asm
+ Ia32\WriteCr0.asm
+ Ia32\WriteCr2.asm
+ Ia32\WriteCr3.asm
+ Ia32\WriteCr4.asm
+ Ia32\ReadDr0.asm
+ Ia32\ReadDr1.asm
+ Ia32\ReadDr2.asm
+ Ia32\ReadDr3.asm
+ Ia32\ReadDr4.asm
+ Ia32\ReadDr5.asm
+ Ia32\ReadDr6.asm
+ Ia32\ReadDr7.asm
+ Ia32\WriteDr0.asm
+ Ia32\WriteDr1.asm
+ Ia32\WriteDr2.asm
+ Ia32\WriteDr3.asm
+ Ia32\WriteDr4.asm
+ Ia32\WriteDr5.asm
+ Ia32\WriteDr6.asm
+ Ia32\WriteDr7.asm
+ Ia32\ReadCs.asm
+ Ia32\ReadDs.asm
+ Ia32\ReadEs.asm
+ Ia32\ReadFs.asm
+ Ia32\ReadGs.asm
+ Ia32\ReadSs.asm
+ Ia32\ReadTr.asm
+ Ia32\ReadGdtr.asm
+ Ia32\WriteGdtr.asm
+ Ia32\ReadIdtr.asm
+ Ia32\WriteIdtr.asm
+ Ia32\ReadLdtr.asm
+ Ia32\WriteLdtr.asm
+ Ia32\FxSave.asm
+ Ia32\FxRestore.asm
+ Ia32\ReadMm0.asm
+ Ia32\ReadMm1.asm
+ Ia32\ReadMm2.asm
+ Ia32\ReadMm3.asm
+ Ia32\ReadMm4.asm
+ Ia32\ReadMm5.asm
+ Ia32\ReadMm6.asm
+ Ia32\ReadMm7.asm
+ Ia32\WriteMm0.asm
+ Ia32\WriteMm1.asm
+ Ia32\WriteMm2.asm
+ Ia32\WriteMm3.asm
+ Ia32\WriteMm4.asm
+ Ia32\WriteMm5.asm
+ Ia32\WriteMm6.asm
+ Ia32\WriteMm7.asm
+ Ia32\ReadTsc.asm
+ Ia32\ReadPmc.asm
+ Ia32\Monitor.asm
+ Ia32\Mwait.asm
+ Ia32\EnablePaging32.asm
+ Ia32\DisablePaging32.asm
+ Ia32\EnablePaging64.asm
+ Ia32\Wbinvd.asm
+ Ia32\Invd.asm
+ Ia32\FlushCacheLine.asm
+ Ia32\InterlockedIncrement.asm
+ Ia32\InterlockedDecrement.asm
+ Ia32\InterlockedCompareExchange32.asm
+ Ia32\InterlockedCompareExchange64.asm
+ Ia32\EnableInterrupts.asm
+ Ia32\DisableInterrupts.asm
+ Ia32\EnableDisableInterrupts.asm
+ Ia32\CpuSleep.asm
+ Ia32\CpuPause.asm
+ Ia32\CpuBreakpoint.asm
+ Ia32\CpuFlushTlb.asm
+ Ia32\Thunk16.asm
+
+[sources.x64]
+ x86DisablePaging32.c
+ x86DisablePaging64.c
+ x86EnablePaging32.c
+ x86EnablePaging64.c
+ x86FxRestore.c
+ x86FxSave.c
+ x86GetInterruptState.c
+ x86MemoryFence.c
+ x86Msr.c
+ x86ReadGdtr.c
+ x86ReadIdtr.c
+ x86Thunk.c
+ x86WriteGdtr.c
+ x86WriteIdtr.c
+ Unaligned.c
+ Math64.c
+ X64\Non-existing.c
+ X64\SwitchStack.asm
+ X64\SetJump.asm
+ X64\LongJump.asm
+ X64\CpuId.asm
+ X64\CpuIdEx.asm
+ X64\ReadEflags.asm
+ X64\ReadMsr64.asm
+ X64\WriteMsr64.asm
+ X64\ReadCr0.asm
+ X64\ReadCr2.asm
+ X64\ReadCr3.asm
+ X64\ReadCr4.asm
+ X64\WriteCr0.asm
+ X64\WriteCr2.asm
+ X64\WriteCr3.asm
+ X64\WriteCr4.asm
+ X64\ReadDr0.asm
+ X64\ReadDr1.asm
+ X64\ReadDr2.asm
+ X64\ReadDr3.asm
+ X64\ReadDr4.asm
+ X64\ReadDr5.asm
+ X64\ReadDr6.asm
+ X64\ReadDr7.asm
+ X64\WriteDr0.asm
+ X64\WriteDr1.asm
+ X64\WriteDr2.asm
+ X64\WriteDr3.asm
+ X64\WriteDr4.asm
+ X64\WriteDr5.asm
+ X64\WriteDr6.asm
+ X64\WriteDr7.asm
+ X64\ReadCs.asm
+ X64\ReadDs.asm
+ X64\ReadEs.asm
+ X64\ReadFs.asm
+ X64\ReadGs.asm
+ X64\ReadSs.asm
+ X64\ReadTr.asm
+ X64\ReadGdtr.asm
+ X64\WriteGdtr.asm
+ X64\ReadIdtr.asm
+ X64\WriteIdtr.asm
+ X64\ReadLdtr.asm
+ X64\WriteLdtr.asm
+ X64\FxSave.asm
+ X64\FxRestore.asm
+ X64\ReadMm0.asm
+ X64\ReadMm1.asm
+ X64\ReadMm2.asm
+ X64\ReadMm3.asm
+ X64\ReadMm4.asm
+ X64\ReadMm5.asm
+ X64\ReadMm6.asm
+ X64\ReadMm7.asm
+ X64\WriteMm0.asm
+ X64\WriteMm1.asm
+ X64\WriteMm2.asm
+ X64\WriteMm3.asm
+ X64\WriteMm4.asm
+ X64\WriteMm5.asm
+ X64\WriteMm6.asm
+ X64\WriteMm7.asm
+ X64\ReadTsc.asm
+ X64\ReadPmc.asm
+ X64\Monitor.asm
+ X64\Mwait.asm
+ X64\EnablePaging64.asm
+ X64\DisablePaging64.asm
+ X64\Wbinvd.asm
+ X64\Invd.asm
+ X64\FlushCacheLine.asm
+ X64\InterlockedIncrement.asm
+ X64\InterlockedDecrement.asm
+ X64\InterlockedCompareExchange32.asm
+ X64\InterlockedCompareExchange64.asm
+ X64\EnableInterrupts.asm
+ X64\DisableInterrupts.asm
+ X64\EnableDisableInterrupts.asm
+ X64\CpuSleep.asm
+ X64\CpuPause.asm
+ X64\CpuBreakpoint.asm
+ X64\CpuFlushTlb.asm
+ X64\Thunk16.asm
+
+[sources.ipf]
+
+[sources.ebc]
+
+
+[includes.common]
+ .
+ ..\..\Include
+ ..\..\Include\Library
+ $(EDK_SOURCE)\Foundation
+ $(EDK_SOURCE)\Foundation\Framework
+ $(EDK_SOURCE)\Foundation\Efi
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+ $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include
+
+[includes.IA32]
+ ..\..\Include\Ia32
+
+[includes.X64]
+ ..\..\Include\x64
+
+
+[libraries.common]
+#
+# Actually, BaesLib may refer
+# BaseTimerLibLocalApic::GetPerformanceCounter()in AcquireSpinLock()
+# BaseMemoryLib::ZeroMem() in StrnCpy()
+#
+
+
+[libraries.ia32]
+
+
+[libraries.x64]
+
+
+[nmake.common]
+ C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION
+ LIB_STD_FLAGS = /NOLOGO /IGNORE:4006
+
+[nmake.ia32]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32
+
+[nmake.x64]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64
+
+[nmake.ipf]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF
+
+[nmake.ebc]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/BaseLibInternal.h b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/BaseLibInternal.h
new file mode 100644
index 0000000..e67143f
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/BaseLibInternal.h
@@ -0,0 +1,586 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ BaseLibInternals.h
+
+Abstract:
+
+ Declaration of internal functions in BaseLib.
+
+--*/
+
+#ifndef __BASE_LIB_INTERNALS_H__
+#define __BASE_LIB_INTERNALS_H__
+
+#include "EdkIIGlueBase.h"
+
+//
+// Math functions
+//
+
+/**
+ Shifts a 64-bit integer left between 0 and 63 bits. The low bits
+ are filled with zeros. The shifted value is returned.
+
+ This function shifts the 64-bit value Operand to the left by Count bits. The
+ low Count bits are set to zero. The shifted value is returned.
+
+ @param Operand The 64-bit operand to shift left.
+ @param Count The number of bits to shift left.
+
+ @return Operand << Count
+
+**/
+UINT64
+EFIAPI
+InternalMathLShiftU64 (
+ IN UINT64 Operand,
+ IN UINTN Count
+ );
+
+/**
+ Shifts a 64-bit integer right between 0 and 63 bits. This high bits
+ are filled with zeros. The shifted value is returned.
+
+ This function shifts the 64-bit value Operand to the right by Count bits. The
+ high Count bits are set to zero. The shifted value is returned.
+
+ @param Operand The 64-bit operand to shift right.
+ @param Count The number of bits to shift right.
+
+ @return Operand >> Count
+
+**/
+UINT64
+EFIAPI
+InternalMathRShiftU64 (
+ IN UINT64 Operand,
+ IN UINTN Count
+ );
+
+/**
+ Shifts a 64-bit integer right between 0 and 63 bits. The high bits
+ are filled with original integer's bit 63. The shifted value is returned.
+
+ This function shifts the 64-bit value Operand to the right by Count bits. The
+ high Count bits are set to bit 63 of Operand. The shifted value is returned.
+
+ @param Operand The 64-bit operand to shift right.
+ @param Count The number of bits to shift right.
+
+ @return Operand arithmetically shifted right by Count
+
+**/
+UINT64
+EFIAPI
+InternalMathARShiftU64 (
+ IN UINT64 Operand,
+ IN UINTN Count
+ );
+
+/**
+ Rotates a 64-bit integer left between 0 and 63 bits, filling
+ the low bits with the high bits that were rotated.
+
+ This function rotates the 64-bit value Operand to the left by Count bits. The
+ low Count bits are fill with the high Count bits of Operand. The rotated
+ value is returned.
+
+ @param Operand The 64-bit operand to rotate left.
+ @param Count The number of bits to rotate left.
+
+ @return Operand <<< Count
+
+**/
+UINT64
+EFIAPI
+InternalMathLRotU64 (
+ IN UINT64 Operand,
+ IN UINTN Count
+ );
+
+/**
+ Rotates a 64-bit integer right between 0 and 63 bits, filling
+ the high bits with the high low bits that were rotated.
+
+ This function rotates the 64-bit value Operand to the right by Count bits.
+ The high Count bits are fill with the low Count bits of Operand. The rotated
+ value is returned.
+
+ @param Operand The 64-bit operand to rotate right.
+ @param Count The number of bits to rotate right.
+
+ @return Operand >>> Count
+
+**/
+UINT64
+EFIAPI
+InternalMathRRotU64 (
+ IN UINT64 Operand,
+ IN UINTN Count
+ );
+
+/**
+ Switches the endianess of a 64-bit integer.
+
+ This function swaps the bytes in a 64-bit unsigned value to switch the value
+ from little endian to big endian or vice versa. The byte swapped value is
+ returned.
+
+ @param Operand A 64-bit unsigned value.
+
+ @return The byte swaped Operand.
+
+**/
+UINT64
+EFIAPI
+InternalMathSwapBytes64 (
+ IN UINT64 Operand
+ );
+
+/**
+ Multiples a 64-bit unsigned integer by a 32-bit unsigned integer
+ and generates a 64-bit unsigned result.
+
+ This function multiples the 64-bit unsigned value Multiplicand by the 32-bit
+ unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
+ bit unsigned result is returned.
+
+ @param Multiplicand A 64-bit unsigned value.
+ @param Multiplier A 32-bit unsigned value.
+
+ @return Multiplicand * Multiplier
+
+**/
+UINT64
+EFIAPI
+InternalMathMultU64x32 (
+ IN UINT64 Multiplicand,
+ IN UINT32 Multiplier
+ );
+
+/**
+ Multiples a 64-bit unsigned integer by a 64-bit unsigned integer
+ and generates a 64-bit unsigned result.
+
+ This function multiples the 64-bit unsigned value Multiplicand by the 64-bit
+ unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
+ bit unsigned result is returned.
+
+ @param Multiplicand A 64-bit unsigned value.
+ @param Multiplier A 64-bit unsigned value.
+
+ @return Multiplicand * Multiplier
+
+**/
+UINT64
+EFIAPI
+InternalMathMultU64x64 (
+ IN UINT64 Multiplicand,
+ IN UINT64 Multiplier
+ );
+
+/**
+ Divides a 64-bit unsigned integer by a 32-bit unsigned integer and
+ generates a 64-bit unsigned result.
+
+ This function divides the 64-bit unsigned value Dividend by the 32-bit
+ unsigned value Divisor and generates a 64-bit unsigned quotient. This
+ function returns the 64-bit unsigned quotient.
+
+ @param Dividend A 64-bit unsigned value.
+ @param Divisor A 32-bit unsigned value.
+
+ @return Dividend / Divisor
+
+**/
+UINT64
+EFIAPI
+InternalMathDivU64x32 (
+ IN UINT64 Dividend,
+ IN UINT32 Divisor
+ );
+
+/**
+ Divides a 64-bit unsigned integer by a 32-bit unsigned integer and
+ generates a 32-bit unsigned remainder.
+
+ This function divides the 64-bit unsigned value Dividend by the 32-bit
+ unsigned value Divisor and generates a 32-bit remainder. This function
+ returns the 32-bit unsigned remainder.
+
+ @param Dividend A 64-bit unsigned value.
+ @param Divisor A 32-bit unsigned value.
+
+ @return Dividend % Divisor
+
+**/
+UINT32
+EFIAPI
+InternalMathModU64x32 (
+ IN UINT64 Dividend,
+ IN UINT32 Divisor
+ );
+
+/**
+ Divides a 64-bit unsigned integer by a 32-bit unsigned integer and
+ generates a 64-bit unsigned result and an optional 32-bit unsigned remainder.
+
+ This function divides the 64-bit unsigned value Dividend by the 32-bit
+ unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
+ is not NULL, then the 32-bit unsigned remainder is returned in Remainder.
+ This function returns the 64-bit unsigned quotient.
+
+ @param Dividend A 64-bit unsigned value.
+ @param Divisor A 32-bit unsigned value.
+ @param Remainder A pointer to a 32-bit unsigned value. This parameter is
+ optional and may be NULL.
+
+ @return Dividend / Divisor
+
+**/
+UINT64
+EFIAPI
+InternalMathDivRemU64x32 (
+ IN UINT64 Dividend,
+ IN UINT32 Divisor,
+ OUT UINT32 *Remainder
+ );
+
+/**
+ Divides a 64-bit unsigned integer by a 64-bit unsigned integer and
+ generates a 64-bit unsigned result and an optional 64-bit unsigned remainder.
+
+ This function divides the 64-bit unsigned value Dividend by the 64-bit
+ unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
+ is not NULL, then the 64-bit unsigned remainder is returned in Remainder.
+ This function returns the 64-bit unsigned quotient.
+
+ @param Dividend A 64-bit unsigned value.
+ @param Divisor A 64-bit unsigned value.
+ @param Remainder A pointer to a 64-bit unsigned value. This parameter is
+ optional and may be NULL.
+
+ @return Dividend / Divisor
+
+**/
+UINT64
+EFIAPI
+InternalMathDivRemU64x64 (
+ IN UINT64 Dividend,
+ IN UINT64 Divisor,
+ OUT UINT64 *Remainder
+ );
+
+/**
+ Divides a 64-bit signed integer by a 64-bit signed integer and
+ generates a 64-bit signed result and a optional 64-bit signed remainder.
+
+ This function divides the 64-bit unsigned value Dividend by the 64-bit
+ unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
+ is not NULL, then the 64-bit unsigned remainder is returned in Remainder.
+ This function returns the 64-bit unsigned quotient.
+
+ @param Dividend A 64-bit signed value.
+ @param Divisor A 64-bit signed value.
+ @param Remainder A pointer to a 64-bit signed value. This parameter is
+ optional and may be NULL.
+
+ @return Dividend / Divisor
+
+**/
+INT64
+InternalMathDivRemS64x64 (
+ IN INT64 Dividend,
+ IN INT64 Divisor,
+ OUT INT64 *Remainder OPTIONAL
+ );
+
+/**
+ Transfers control to a function starting with a new stack.
+
+ Transfers control to the function specified by EntryPoint using the new stack
+ specified by NewStack and passing in the parameters specified by Context1 and
+ Context2. Context1 and Context2 are optional and may be NULL. The function
+ EntryPoint must never return.
+
+ @param EntryPoint A pointer to function to call with the new stack.
+ @param Context1 A pointer to the context to pass into the EntryPoint
+ function.
+ @param Context2 A pointer to the context to pass into the EntryPoint
+ function.
+ @param NewStack A pointer to the new stack to use for the EntryPoint
+ function.
+
+**/
+VOID
+EFIAPI
+InternalSwitchStack (
+ IN SWITCH_STACK_ENTRY_POINT EntryPoint,
+ IN VOID *Context1,
+ IN VOID *Context2,
+ IN VOID *NewStack
+ );
+
+//
+// Ia32 and x64 specific functions
+//
+
+/**
+ Reads the current Global Descriptor Table Register(GDTR) descriptor.
+
+ Reads and returns the current GDTR descriptor and returns it in Gdtr. This
+ function is only available on IA-32 and X64.
+
+ @param Gdtr Pointer to a GDTR descriptor.
+
+**/
+VOID
+EFIAPI
+InternalX86ReadGdtr (
+ OUT IA32_DESCRIPTOR *Gdtr
+ );
+
+/**
+ Writes the current Global Descriptor Table Register (GDTR) descriptor.
+
+ Writes and the current GDTR descriptor specified by Gdtr. This function is
+ only available on IA-32 and X64.
+
+ @param Gdtr Pointer to a GDTR descriptor.
+
+**/
+VOID
+EFIAPI
+InternalX86WriteGdtr (
+ IN CONST IA32_DESCRIPTOR *Gdtr
+ );
+
+/**
+ Reads the current Interrupt Descriptor Table Register(GDTR) descriptor.
+
+ Reads and returns the current IDTR descriptor and returns it in Idtr. This
+ function is only available on IA-32 and X64.
+
+ @param Idtr Pointer to a IDTR descriptor.
+
+**/
+VOID
+EFIAPI
+InternalX86ReadIdtr (
+ OUT IA32_DESCRIPTOR *Idtr
+ );
+
+/**
+ Writes the current Interrupt Descriptor Table Register(GDTR) descriptor.
+
+ Writes the current IDTR descriptor and returns it in Idtr. This function is
+ only available on IA-32 and X64.
+
+ @param Idtr Pointer to a IDTR descriptor.
+
+**/
+VOID
+EFIAPI
+InternalX86WriteIdtr (
+ IN CONST IA32_DESCRIPTOR *Idtr
+ );
+
+/**
+ Save the current floating point/SSE/SSE2 context to a buffer.
+
+ Saves the current floating point/SSE/SSE2 state to the buffer specified by
+ Buffer. Buffer must be aligned on a 16-byte boundary. This function is only
+ available on IA-32 and X64.
+
+ @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context.
+
+**/
+VOID
+EFIAPI
+InternalX86FxSave (
+ OUT IA32_FX_BUFFER *Buffer
+ );
+
+/**
+ Restores the current floating point/SSE/SSE2 context from a buffer.
+
+ Restores the current floating point/SSE/SSE2 state from the buffer specified
+ by Buffer. Buffer must be aligned on a 16-byte boundary. This function is
+ only available on IA-32 and X64.
+
+ @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context.
+
+**/
+VOID
+EFIAPI
+InternalX86FxRestore (
+ IN CONST IA32_FX_BUFFER *Buffer
+ );
+
+/**
+ Enables the 32-bit paging mode on the CPU.
+
+ Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
+ must be properly initialized prior to calling this service. This function
+ assumes the current execution mode is 32-bit protected mode. This function is
+ only available on IA-32. After the 32-bit paging mode is enabled, control is
+ transferred to the function specified by EntryPoint using the new stack
+ specified by NewStack and passing in the parameters specified by Context1 and
+ Context2. Context1 and Context2 are optional and may be NULL. The function
+ EntryPoint must never return.
+
+ There are a number of constraints that must be followed before calling this
+ function:
+ 1) Interrupts must be disabled.
+ 2) The caller must be in 32-bit protected mode with flat descriptors. This
+ means all descriptors must have a base of 0 and a limit of 4GB.
+ 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat
+ descriptors.
+ 4) CR3 must point to valid page tables that will be used once the transition
+ is complete, and those page tables must guarantee that the pages for this
+ function and the stack are identity mapped.
+
+ @param EntryPoint A pointer to function to call with the new stack after
+ paging is enabled.
+ @param Context1 A pointer to the context to pass into the EntryPoint
+ function as the first parameter after paging is enabled.
+ @param Context2 A pointer to the context to pass into the EntryPoint
+ function as the second parameter after paging is enabled.
+ @param NewStack A pointer to the new stack to use for the EntryPoint
+ function after paging is enabled.
+
+**/
+VOID
+EFIAPI
+InternalX86EnablePaging32 (
+ IN SWITCH_STACK_ENTRY_POINT EntryPoint,
+ IN VOID *Context1, OPTIONAL
+ IN VOID *Context2, OPTIONAL
+ IN VOID *NewStack
+ );
+
+/**
+ Disables the 32-bit paging mode on the CPU.
+
+ Disables the 32-bit paging mode on the CPU and returns to 32-bit protected
+ mode. This function assumes the current execution mode is 32-paged protected
+ mode. This function is only available on IA-32. After the 32-bit paging mode
+ is disabled, control is transferred to the function specified by EntryPoint
+ using the new stack specified by NewStack and passing in the parameters
+ specified by Context1 and Context2. Context1 and Context2 are optional and
+ may be NULL. The function EntryPoint must never return.
+
+ There are a number of constraints that must be followed before calling this
+ function:
+ 1) Interrupts must be disabled.
+ 2) The caller must be in 32-bit paged mode.
+ 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode.
+ 4) CR3 must point to valid page tables that guarantee that the pages for
+ this function and the stack are identity mapped.
+
+ @param EntryPoint A pointer to function to call with the new stack after
+ paging is disabled.
+ @param Context1 A pointer to the context to pass into the EntryPoint
+ function as the first parameter after paging is disabled.
+ @param Context2 A pointer to the context to pass into the EntryPoint
+ function as the second parameter after paging is
+ disabled.
+ @param NewStack A pointer to the new stack to use for the EntryPoint
+ function after paging is disabled.
+
+**/
+VOID
+EFIAPI
+InternalX86DisablePaging32 (
+ IN SWITCH_STACK_ENTRY_POINT EntryPoint,
+ IN VOID *Context1, OPTIONAL
+ IN VOID *Context2, OPTIONAL
+ IN VOID *NewStack
+ );
+
+/**
+ Enables the 64-bit paging mode on the CPU.
+
+ Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
+ must be properly initialized prior to calling this service. This function
+ assumes the current execution mode is 32-bit protected mode with flat
+ descriptors. This function is only available on IA-32. After the 64-bit
+ paging mode is enabled, control is transferred to the function specified by
+ EntryPoint using the new stack specified by NewStack and passing in the
+ parameters specified by Context1 and Context2. Context1 and Context2 are
+ optional and may be 0. The function EntryPoint must never return.
+
+ @param Cs The 16-bit selector to load in the CS before EntryPoint
+ is called. The descriptor in the GDT that this selector
+ references must be setup for long mode.
+ @param EntryPoint The 64-bit virtual address of the function to call with
+ the new stack after paging is enabled.
+ @param Context1 The 64-bit virtual address of the context to pass into
+ the EntryPoint function as the first parameter after
+ paging is enabled.
+ @param Context2 The 64-bit virtual address of the context to pass into
+ the EntryPoint function as the second parameter after
+ paging is enabled.
+ @param NewStack The 64-bit virtual address of the new stack to use for
+ the EntryPoint function after paging is enabled.
+
+**/
+VOID
+EFIAPI
+InternalX86EnablePaging64 (
+ IN UINT16 Cs,
+ IN UINT64 EntryPoint,
+ IN UINT64 Context1, OPTIONAL
+ IN UINT64 Context2, OPTIONAL
+ IN UINT64 NewStack
+ );
+
+/**
+ Disables the 64-bit paging mode on the CPU.
+
+ Disables the 64-bit paging mode on the CPU and returns to 32-bit protected
+ mode. This function assumes the current execution mode is 64-paging mode.
+ This function is only available on X64. After the 64-bit paging mode is
+ disabled, control is transferred to the function specified by EntryPoint
+ using the new stack specified by NewStack and passing in the parameters
+ specified by Context1 and Context2. Context1 and Context2 are optional and
+ may be 0. The function EntryPoint must never return.
+
+ @param Cs The 16-bit selector to load in the CS before EntryPoint
+ is called. The descriptor in the GDT that this selector
+ references must be setup for 32-bit protected mode.
+ @param EntryPoint The 64-bit virtual address of the function to call with
+ the new stack after paging is disabled.
+ @param Context1 The 64-bit virtual address of the context to pass into
+ the EntryPoint function as the first parameter after
+ paging is disabled.
+ @param Context2 The 64-bit virtual address of the context to pass into
+ the EntryPoint function as the second parameter after
+ paging is disabled.
+ @param NewStack The 64-bit virtual address of the new stack to use for
+ the EntryPoint function after paging is disabled.
+
+**/
+VOID
+EFIAPI
+InternalX86DisablePaging64 (
+ IN UINT16 Cs,
+ IN UINT32 EntryPoint,
+ IN UINT32 Context1, OPTIONAL
+ IN UINT32 Context2, OPTIONAL
+ IN UINT32 NewStack
+ );
+
+#endif
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/BitField.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/BitField.c
new file mode 100644
index 0000000..a98e187
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/BitField.c
@@ -0,0 +1,861 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ BitField.c
+
+Abstract:
+
+ Bit field functions of BaseLib.
+
+--*/
+
+#include "BaseLibInternal.h"
+
+/**
+ Worker function that returns a bit field from Operand
+
+ Returns the bitfield specified by the StartBit and the EndBit from Operand.
+
+ @param Operand Operand on which to perform the bitfield operation.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+
+ @return The bit field read.
+
+**/
+unsigned int
+BitFieldReadUint (
+ IN unsigned int Operand,
+ IN UINTN StartBit,
+ IN UINTN EndBit
+ )
+{
+ //
+ // ~((unsigned int)-2 << EndBit) is a mask in which bit[0] thru bit[EndBit]
+ // are 1's while bit[EndBit + 1] thru the most significant bit are 0's.
+ //
+ return (Operand & ~((unsigned int)-2 << EndBit)) >> StartBit;
+}
+
+/**
+ Worker function that reads a bit field from Operand, performs a bitwise OR,
+ and returns the result.
+
+ Performs a bitwise OR between the bit field specified by StartBit and EndBit
+ in Operand and the value specified by AndData. All other bits in Operand are
+ preserved. The new value is returned.
+
+ @param Operand Operand on which to perform the bitfield operation.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ @param OrData The value to OR with the read value from the value
+
+ @return The new value.
+
+**/
+unsigned int
+BitFieldOrUint (
+ IN unsigned int Operand,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN unsigned int OrData
+ )
+{
+ //
+ // ~((unsigned int)-2 << EndBit) is a mask in which bit[0] thru bit[EndBit]
+ // are 1's while bit[EndBit + 1] thru the most significant bit are 0's.
+ //
+ return Operand | ((OrData << StartBit) & ~((unsigned int) -2 << EndBit));
+}
+
+/**
+ Worker function that reads a bit field from Operand, performs a bitwise AND,
+ and returns the result.
+
+ Performs a bitwise AND between the bit field specified by StartBit and EndBit
+ in Operand and the value specified by AndData. All other bits in Operand are
+ preserved. The new value is returned.
+
+ @param Operand Operand on which to perform the bitfield operation.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ @param AndData The value to And with the read value from the value
+
+ @return The new value.
+
+**/
+unsigned int
+BitFieldAndUint (
+ IN unsigned int Operand,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN unsigned int AndData
+ )
+{
+ //
+ // ~((unsigned int)-2 << EndBit) is a mask in which bit[0] thru bit[EndBit]
+ // are 1's while bit[EndBit + 1] thru the most significant bit are 0's.
+ //
+ return Operand & ~((~AndData << StartBit) & ~((unsigned int) -2 << EndBit));
+}
+
+/**
+ Returns a bit field from an 8-bit value.
+
+ Returns the bitfield specified by the StartBit and the EndBit from Operand.
+
+ If 8-bit operations are not supported, then ASSERT().
+ If StartBit is greater than 7, then ASSERT().
+ If EndBit is greater than 7, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Operand Operand on which to perform the bitfield operation.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..7.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..7.
+
+ @return The bit field read.
+
+**/
+UINT8
+EFIAPI
+BitFieldRead8 (
+ IN UINT8 Operand,
+ IN UINTN StartBit,
+ IN UINTN EndBit
+ )
+{
+// ASSERT (EndBit < sizeof (Operand) * 8);
+// ASSERT (StartBit <= EndBit);
+ return (UINT8)BitFieldReadUint (Operand, StartBit, EndBit);
+}
+
+/**
+ Writes a bit field to an 8-bit value, and returns the result.
+
+ Writes Value to the bit field specified by the StartBit and the EndBit in
+ Operand. All other bits in Operand are preserved. The new 8-bit value is
+ returned.
+
+ If 8-bit operations are not supported, then ASSERT().
+ If StartBit is greater than 7, then ASSERT().
+ If EndBit is greater than 7, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Operand Operand on which to perform the bitfield operation.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..7.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..7.
+ @param Value New value of the bit field.
+
+ @return The new 8-bit value.
+
+**/
+UINT8
+EFIAPI
+BitFieldWrite8 (
+ IN UINT8 Operand,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT8 Value
+ )
+{
+// ASSERT (EndBit < sizeof (Operand) * 8);
+// ASSERT (StartBit <= EndBit);
+ return BitFieldAndThenOr8 (Operand, StartBit, EndBit, 0, Value);
+}
+
+/**
+ Reads a bit field from an 8-bit value, performs a bitwise OR, and returns the
+ result.
+
+ Performs a bitwise inclusive OR between the bit field specified by StartBit
+ and EndBit in Operand and the value specified by OrData. All other bits in
+ Operand are preserved. The new 8-bit value is returned.
+
+ If 8-bit operations are not supported, then ASSERT().
+ If StartBit is greater than 7, then ASSERT().
+ If EndBit is greater than 7, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Operand Operand on which to perform the bitfield operation.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..7.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..7.
+ @param OrData The value to OR with the read value from the value
+
+ @return The new 8-bit value.
+
+**/
+UINT8
+EFIAPI
+BitFieldOr8 (
+ IN UINT8 Operand,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT8 OrData
+ )
+{
+// ASSERT (EndBit < sizeof (Operand) * 8);
+// ASSERT (StartBit <= EndBit);
+ return (UINT8)BitFieldOrUint (Operand, StartBit, EndBit, OrData);
+}
+
+/**
+ Reads a bit field from an 8-bit value, performs a bitwise AND, and returns
+ the result.
+
+ Performs a bitwise AND between the bit field specified by StartBit and EndBit
+ in Operand and the value specified by AndData. All other bits in Operand are
+ preserved. The new 8-bit value is returned.
+
+ If 8-bit operations are not supported, then ASSERT().
+ If StartBit is greater than 7, then ASSERT().
+ If EndBit is greater than 7, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Operand Operand on which to perform the bitfield operation.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..7.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..7.
+ @param AndData The value to AND with the read value from the value.
+
+ @return The new 8-bit value.
+
+**/
+UINT8
+EFIAPI
+BitFieldAnd8 (
+ IN UINT8 Operand,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT8 AndData
+ )
+{
+// ASSERT (EndBit < sizeof (Operand) * 8);
+// ASSERT (StartBit <= EndBit);
+ return (UINT8)BitFieldAndUint (Operand, StartBit, EndBit, AndData);
+}
+
+/**
+ Reads a bit field from an 8-bit value, performs a bitwise AND followed by a
+ bitwise OR, and returns the result.
+
+ Performs a bitwise AND between the bit field specified by StartBit and EndBit
+ in Operand and the value specified by AndData, followed by a bitwise
+ inclusive OR with value specified by OrData. All other bits in Operand are
+ preserved. The new 8-bit value is returned.
+
+ If 8-bit operations are not supported, then ASSERT().
+ If StartBit is greater than 7, then ASSERT().
+ If EndBit is greater than 7, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Operand Operand on which to perform the bitfield operation.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..7.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..7.
+ @param AndData The value to AND with the read value from the value.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The new 8-bit value.
+
+**/
+UINT8
+EFIAPI
+BitFieldAndThenOr8 (
+ IN UINT8 Operand,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT8 AndData,
+ IN UINT8 OrData
+ )
+{
+// ASSERT (EndBit < sizeof (Operand) * 8);
+// ASSERT (StartBit <= EndBit);
+ return BitFieldOr8 (
+ BitFieldAnd8 (Operand, StartBit, EndBit, AndData),
+ StartBit,
+ EndBit,
+ OrData
+ );
+}
+
+/**
+ Returns a bit field from a 16-bit value.
+
+ Returns the bitfield specified by the StartBit and the EndBit from Operand.
+
+ If 16-bit operations are not supported, then ASSERT().
+ If StartBit is greater than 15, then ASSERT().
+ If EndBit is greater than 15, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Operand Operand on which to perform the bitfield operation.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..15.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..15.
+
+ @return The bit field read.
+
+**/
+UINT16
+EFIAPI
+BitFieldRead16 (
+ IN UINT16 Operand,
+ IN UINTN StartBit,
+ IN UINTN EndBit
+ )
+{
+// ASSERT (EndBit < sizeof (Operand) * 8);
+// ASSERT (StartBit <= EndBit);
+ return (UINT16)BitFieldReadUint (Operand, StartBit, EndBit);
+}
+
+/**
+ Writes a bit field to a 16-bit value, and returns the result.
+
+ Writes Value to the bit field specified by the StartBit and the EndBit in
+ Operand. All other bits in Operand are preserved. The new 16-bit value is
+ returned.
+
+ If 16-bit operations are not supported, then ASSERT().
+ If StartBit is greater than 15, then ASSERT().
+ If EndBit is greater than 15, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Operand Operand on which to perform the bitfield operation.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..15.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..15.
+ @param Value New value of the bit field.
+
+ @return The new 16-bit value.
+
+**/
+UINT16
+EFIAPI
+BitFieldWrite16 (
+ IN UINT16 Operand,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT16 Value
+ )
+{
+// ASSERT (EndBit < sizeof (Operand) * 8);
+// ASSERT (StartBit <= EndBit);
+ return BitFieldAndThenOr16 (Operand, StartBit, EndBit, 0, Value);
+}
+
+/**
+ Reads a bit field from a 16-bit value, performs a bitwise OR, and returns the
+ result.
+
+ Performs a bitwise inclusive OR between the bit field specified by StartBit
+ and EndBit in Operand and the value specified by OrData. All other bits in
+ Operand are preserved. The new 16-bit value is returned.
+
+ If 16-bit operations are not supported, then ASSERT().
+ If StartBit is greater than 15, then ASSERT().
+ If EndBit is greater than 15, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Operand Operand on which to perform the bitfield operation.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..15.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..15.
+ @param OrData The value to OR with the read value from the value
+
+ @return The new 16-bit value.
+
+**/
+UINT16
+EFIAPI
+BitFieldOr16 (
+ IN UINT16 Operand,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT16 OrData
+ )
+{
+// ASSERT (EndBit < sizeof (Operand) * 8);
+// ASSERT (StartBit <= EndBit);
+ return (UINT16)BitFieldOrUint (Operand, StartBit, EndBit, OrData);
+}
+
+/**
+ Reads a bit field from a 16-bit value, performs a bitwise AND, and returns
+ the result.
+
+ Performs a bitwise AND between the bit field specified by StartBit and EndBit
+ in Operand and the value specified by AndData. All other bits in Operand are
+ preserved. The new 16-bit value is returned.
+
+ If 16-bit operations are not supported, then ASSERT().
+ If StartBit is greater than 15, then ASSERT().
+ If EndBit is greater than 15, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Operand Operand on which to perform the bitfield operation.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..15.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..15.
+ @param AndData The value to AND with the read value from the value
+
+ @return The new 16-bit value.
+
+**/
+UINT16
+EFIAPI
+BitFieldAnd16 (
+ IN UINT16 Operand,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT16 AndData
+ )
+{
+// ASSERT (EndBit < sizeof (Operand) * 8);
+// ASSERT (StartBit <= EndBit);
+ return (UINT16)BitFieldAndUint (Operand, StartBit, EndBit, AndData);
+}
+
+/**
+ Reads a bit field from a 16-bit value, performs a bitwise AND followed by a
+ bitwise OR, and returns the result.
+
+ Performs a bitwise AND between the bit field specified by StartBit and EndBit
+ in Operand and the value specified by AndData, followed by a bitwise
+ inclusive OR with value specified by OrData. All other bits in Operand are
+ preserved. The new 16-bit value is returned.
+
+ If 16-bit operations are not supported, then ASSERT().
+ If StartBit is greater than 15, then ASSERT().
+ If EndBit is greater than 15, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Operand Operand on which to perform the bitfield operation.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..15.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..15.
+ @param AndData The value to AND with the read value from the value.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The new 16-bit value.
+
+**/
+UINT16
+EFIAPI
+BitFieldAndThenOr16 (
+ IN UINT16 Operand,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT16 AndData,
+ IN UINT16 OrData
+ )
+{
+// ASSERT (EndBit < sizeof (Operand) * 8);
+// ASSERT (StartBit <= EndBit);
+ return BitFieldOr16 (
+ BitFieldAnd16 (Operand, StartBit, EndBit, AndData),
+ StartBit,
+ EndBit,
+ OrData
+ );
+}
+
+/**
+ Returns a bit field from a 32-bit value.
+
+ Returns the bitfield specified by the StartBit and the EndBit from Operand.
+
+ If 32-bit operations are not supported, then ASSERT().
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Operand Operand on which to perform the bitfield operation.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+
+ @return The bit field read.
+
+**/
+UINT32
+EFIAPI
+BitFieldRead32 (
+ IN UINT32 Operand,
+ IN UINTN StartBit,
+ IN UINTN EndBit
+ )
+{
+// ASSERT (EndBit < sizeof (Operand) * 8);
+// ASSERT (StartBit <= EndBit);
+ return (UINT32)BitFieldReadUint (Operand, StartBit, EndBit);
+}
+
+/**
+ Writes a bit field to a 32-bit value, and returns the result.
+
+ Writes Value to the bit field specified by the StartBit and the EndBit in
+ Operand. All other bits in Operand are preserved. The new 32-bit value is
+ returned.
+
+ If 32-bit operations are not supported, then ASSERT().
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Operand Operand on which to perform the bitfield operation.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+ @param Value New value of the bit field.
+
+ @return The new 32-bit value.
+
+**/
+UINT32
+EFIAPI
+BitFieldWrite32 (
+ IN UINT32 Operand,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT32 Value
+ )
+{
+// ASSERT (EndBit < sizeof (Operand) * 8);
+// ASSERT (StartBit <= EndBit);
+ return BitFieldAndThenOr32 (Operand, StartBit, EndBit, 0, Value);
+}
+
+/**
+ Reads a bit field from a 32-bit value, performs a bitwise OR, and returns the
+ result.
+
+ Performs a bitwise inclusive OR between the bit field specified by StartBit
+ and EndBit in Operand and the value specified by OrData. All other bits in
+ Operand are preserved. The new 32-bit value is returned.
+
+ If 32-bit operations are not supported, then ASSERT().
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Operand Operand on which to perform the bitfield operation.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+ @param OrData The value to OR with the read value from the value
+
+ @return The new 32-bit value.
+
+**/
+UINT32
+EFIAPI
+BitFieldOr32 (
+ IN UINT32 Operand,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT32 OrData
+ )
+{
+// ASSERT (EndBit < sizeof (Operand) * 8);
+// ASSERT (StartBit <= EndBit);
+ return (UINT32)BitFieldOrUint (Operand, StartBit, EndBit, OrData);
+}
+
+/**
+ Reads a bit field from a 32-bit value, performs a bitwise AND, and returns
+ the result.
+
+ Performs a bitwise AND between the bit field specified by StartBit and EndBit
+ in Operand and the value specified by AndData. All other bits in Operand are
+ preserved. The new 32-bit value is returned.
+
+ If 32-bit operations are not supported, then ASSERT().
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Operand Operand on which to perform the bitfield operation.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+ @param AndData The value to AND with the read value from the value
+
+ @return The new 32-bit value.
+
+**/
+UINT32
+EFIAPI
+BitFieldAnd32 (
+ IN UINT32 Operand,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT32 AndData
+ )
+{
+// ASSERT (EndBit < sizeof (Operand) * 8);
+// ASSERT (StartBit <= EndBit);
+ return (UINT32)BitFieldAndUint (Operand, StartBit, EndBit, AndData);
+}
+
+/**
+ Reads a bit field from a 32-bit value, performs a bitwise AND followed by a
+ bitwise OR, and returns the result.
+
+ Performs a bitwise AND between the bit field specified by StartBit and EndBit
+ in Operand and the value specified by AndData, followed by a bitwise
+ inclusive OR with value specified by OrData. All other bits in Operand are
+ preserved. The new 32-bit value is returned.
+
+ If 32-bit operations are not supported, then ASSERT().
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Operand Operand on which to perform the bitfield operation.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+ @param AndData The value to AND with the read value from the value.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The new 32-bit value.
+
+**/
+UINT32
+EFIAPI
+BitFieldAndThenOr32 (
+ IN UINT32 Operand,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT32 AndData,
+ IN UINT32 OrData
+ )
+{
+// ASSERT (EndBit < sizeof (Operand) * 8);
+// ASSERT (StartBit <= EndBit);
+ return BitFieldOr32 (
+ BitFieldAnd32 (Operand, StartBit, EndBit, AndData),
+ StartBit,
+ EndBit,
+ OrData
+ );
+}
+
+/**
+ Returns a bit field from a 64-bit value.
+
+ Returns the bitfield specified by the StartBit and the EndBit from Operand.
+
+ If 64-bit operations are not supported, then ASSERT().
+ If StartBit is greater than 63, then ASSERT().
+ If EndBit is greater than 63, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Operand Operand on which to perform the bitfield operation.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..63.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..63.
+
+ @return The bit field read.
+
+**/
+UINT64
+EFIAPI
+BitFieldRead64 (
+ IN UINT64 Operand,
+ IN UINTN StartBit,
+ IN UINTN EndBit
+ )
+{
+// ASSERT (EndBit < sizeof (Operand) * 8);
+// ASSERT (StartBit <= EndBit);
+ return RShiftU64 (Operand & ~LShiftU64 ((UINT64)-2, EndBit), StartBit);
+}
+
+/**
+ Writes a bit field to a 64-bit value, and returns the result.
+
+ Writes Value to the bit field specified by the StartBit and the EndBit in
+ Operand. All other bits in Operand are preserved. The new 64-bit value is
+ returned.
+
+ If 64-bit operations are not supported, then ASSERT().
+ If StartBit is greater than 63, then ASSERT().
+ If EndBit is greater than 63, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Operand Operand on which to perform the bitfield operation.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..63.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..63.
+ @param Value New value of the bit field.
+
+ @return The new 64-bit value.
+
+**/
+UINT64
+EFIAPI
+BitFieldWrite64 (
+ IN UINT64 Operand,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT64 Value
+ )
+{
+// ASSERT (EndBit < sizeof (Operand) * 8);
+// ASSERT (StartBit <= EndBit);
+ return BitFieldAndThenOr64 (Operand, StartBit, EndBit, 0, Value);
+}
+
+/**
+ Reads a bit field from a 64-bit value, performs a bitwise OR, and returns the
+ result.
+
+ Performs a bitwise inclusive OR between the bit field specified by StartBit
+ and EndBit in Operand and the value specified by OrData. All other bits in
+ Operand are preserved. The new 64-bit value is returned.
+
+ If 64-bit operations are not supported, then ASSERT().
+ If StartBit is greater than 63, then ASSERT().
+ If EndBit is greater than 63, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Operand Operand on which to perform the bitfield operation.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..63.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..63.
+ @param OrData The value to OR with the read value from the value
+
+ @return The new 64-bit value.
+
+**/
+UINT64
+EFIAPI
+BitFieldOr64 (
+ IN UINT64 Operand,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT64 OrData
+ )
+{
+// ASSERT (EndBit < sizeof (Operand) * 8);
+// ASSERT (StartBit <= EndBit);
+ return Operand |
+ (LShiftU64 (OrData, StartBit) & ~LShiftU64 ((UINT64)-2, EndBit));
+}
+
+/**
+ Reads a bit field from a 64-bit value, performs a bitwise AND, and returns
+ the result.
+
+ Performs a bitwise AND between the bit field specified by StartBit and EndBit
+ in Operand and the value specified by AndData. All other bits in Operand are
+ preserved. The new 64-bit value is returned.
+
+ If 64-bit operations are not supported, then ASSERT().
+ If StartBit is greater than 63, then ASSERT().
+ If EndBit is greater than 63, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Operand Operand on which to perform the bitfield operation.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..63.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..63.
+ @param AndData The value to AND with the read value from the value
+
+ @return The new 64-bit value.
+
+**/
+UINT64
+EFIAPI
+BitFieldAnd64 (
+ IN UINT64 Operand,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT64 AndData
+ )
+{
+// ASSERT (EndBit < sizeof (Operand) * 8);
+// ASSERT (StartBit <= EndBit);
+ return Operand &
+ ~(LShiftU64 (~AndData, StartBit) & ~LShiftU64 ((UINT64)-2, EndBit));
+}
+
+/**
+ Reads a bit field from a 64-bit value, performs a bitwise AND followed by a
+ bitwise OR, and returns the result.
+
+ Performs a bitwise AND between the bit field specified by StartBit and EndBit
+ in Operand and the value specified by AndData, followed by a bitwise
+ inclusive OR with value specified by OrData. All other bits in Operand are
+ preserved. The new 64-bit value is returned.
+
+ If 64-bit operations are not supported, then ASSERT().
+ If StartBit is greater than 63, then ASSERT().
+ If EndBit is greater than 63, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Operand Operand on which to perform the bitfield operation.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..63.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..63.
+ @param AndData The value to AND with the read value from the value.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The new 64-bit value.
+
+**/
+UINT64
+EFIAPI
+BitFieldAndThenOr64 (
+ IN UINT64 Operand,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT64 AndData,
+ IN UINT64 OrData
+ )
+{
+// ASSERT (EndBit < sizeof (Operand) * 8);
+// ASSERT (StartBit <= EndBit);
+ return BitFieldOr64 (
+ BitFieldAnd64 (Operand, StartBit, EndBit, AndData),
+ StartBit,
+ EndBit,
+ OrData
+ );
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Cpu.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Cpu.c
new file mode 100644
index 0000000..79d0739
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Cpu.c
@@ -0,0 +1,75 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ Cpu.c
+
+Abstract:
+
+ Base Library CPU Functions for all architectures.
+
+--*/
+
+#include "BaseLibInternal.h"
+
+/**
+ Disables CPU interrupts and returns the interrupt state prior to the disable
+ operation.
+
+ Disables CPU interrupts and returns the interrupt state prior to the disable
+ operation.
+
+ @retval TRUE CPU interrupts were enabled on entry to this call.
+ @retval FALSE CPU interrupts were disabled on entry to this call.
+
+**/
+BOOLEAN
+EFIAPI
+SaveAndDisableInterrupts (
+ VOID
+ )
+{
+ BOOLEAN InterruptState;
+
+ InterruptState = GetInterruptState ();
+ DisableInterrupts ();
+ return InterruptState;
+}
+
+/**
+ Set the current CPU interrupt state.
+
+ Sets the current CPU interrupt state to the state specified by
+ InterruptState. If InterruptState is TRUE, then interrupts are enabled. If
+ InterruptState is FALSE, then interrupts are disabled. InterruptState is
+ returned.
+
+ @param InterruptState TRUE if interrupts should enabled. FALSE if
+ interrupts should be disabled.
+
+ @return InterruptState
+
+**/
+BOOLEAN
+EFIAPI
+SetInterruptState (
+ IN BOOLEAN InterruptState
+ )
+{
+ if (InterruptState) {
+ EnableInterrupts ();
+ } else {
+ DisableInterrupts ();
+ }
+ return InterruptState;
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/CpuDeadLoop.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/CpuDeadLoop.c
new file mode 100644
index 0000000..e5e7f6d
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/CpuDeadLoop.c
@@ -0,0 +1,42 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ CpuDeadLoop.c
+
+Abstract:
+
+ Base Library CPU Functions for all architectures.
+
+--*/
+
+#include "BaseLibInternal.h"
+
+/**
+ Executes an infinite loop.
+
+ Forces the CPU to execute an infinite loop. A debugger may be used to skip
+ past the loop and the code that follows the loop must execute properly. This
+ implies that the infinite loop must not cause the code that follow it to be
+ optimized away.
+
+**/
+VOID
+EFIAPI
+CpuDeadLoop (
+ VOID
+ )
+{
+ volatile UINTN Index;
+
+ for (Index = 0; Index == 0;);
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/DivS64x64Remainder.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/DivS64x64Remainder.c
new file mode 100644
index 0000000..bdea3e0
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/DivS64x64Remainder.c
@@ -0,0 +1,54 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ DivS64x64Remainder.c
+
+Abstract:
+
+ Math worker functions.
+
+--*/
+
+#include "BaseLibInternal.h"
+
+/**
+ Divides a 64-bit signed integer by a 64-bit signed integer and generates a
+ 64-bit signed result and a optional 64-bit signed remainder.
+
+ This function divides the 64-bit signed value Dividend by the 64-bit signed
+ value Divisor and generates a 64-bit signed quotient. If Remainder is not
+ NULL, then the 64-bit signed remainder is returned in Remainder. This
+ function returns the 64-bit signed quotient.
+
+ If Divisor is 0, then ASSERT().
+
+ @param Dividend A 64-bit signed value.
+ @param Divisor A 64-bit signed value.
+ @param Remainder A pointer to a 64-bit signed value. This parameter is
+ optional and may be NULL.
+
+ @return Dividend / Divisor
+
+**/
+INT64
+EFIAPI
+DivS64x64Remainder (
+ IN INT64 Dividend,
+ IN INT64 Divisor,
+ OUT INT64 *Remainder OPTIONAL
+ )
+{
+ ASSERT (Divisor != 0);
+ return InternalMathDivRemS64x64 (Dividend, Divisor, Remainder);
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/DivU64x32.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/DivU64x32.c
new file mode 100644
index 0000000..4dbddb8
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/DivU64x32.c
@@ -0,0 +1,50 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ DivU64x32.c
+
+Abstract:
+
+ Math worker functions.
+
+--*/
+
+#include "BaseLibInternal.h"
+
+/**
+ Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
+ a 64-bit unsigned result.
+
+ This function divides the 64-bit unsigned value Dividend by the 32-bit
+ unsigned value Divisor and generates a 64-bit unsigned quotient. This
+ function returns the 64-bit unsigned quotient.
+
+ If Divisor is 0, then ASSERT().
+
+ @param Dividend A 64-bit unsigned value.
+ @param Divisor A 32-bit unsigned value.
+
+ @return Dividend / Divisor
+
+**/
+UINT64
+EFIAPI
+GlueDivU64x32 (
+ IN UINT64 Dividend,
+ IN UINT32 Divisor
+ )
+{
+ ASSERT (Divisor != 0);
+ return InternalMathDivU64x32 (Dividend, Divisor);
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/DivU64x32Remainder.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/DivU64x32Remainder.c
new file mode 100644
index 0000000..57a24d2
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/DivU64x32Remainder.c
@@ -0,0 +1,54 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ DivU64x32Remainder.c
+
+Abstract:
+
+ Math worker functions
+
+--*/
+
+#include "BaseLibInternal.h"
+
+/**
+ Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
+ a 64-bit unsigned result and an optional 32-bit unsigned remainder.
+
+ This function divides the 64-bit unsigned value Dividend by the 32-bit
+ unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
+ is not NULL, then the 32-bit unsigned remainder is returned in Remainder.
+ This function returns the 64-bit unsigned quotient.
+
+ If Divisor is 0, then ASSERT().
+
+ @param Dividend A 64-bit unsigned value.
+ @param Divisor A 32-bit unsigned value.
+ @param Remainder A pointer to a 32-bit unsigned value. This parameter is
+ optional and may be NULL.
+
+ @return Dividend / Divisor
+
+**/
+UINT64
+EFIAPI
+DivU64x32Remainder (
+ IN UINT64 Dividend,
+ IN UINT32 Divisor,
+ OUT UINT32 *Remainder OPTIONAL
+ )
+{
+ ASSERT (Divisor != 0);
+ return InternalMathDivRemU64x32 (Dividend, Divisor, Remainder);
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/DivU64x64Remainder.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/DivU64x64Remainder.c
new file mode 100644
index 0000000..961b4d0
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/DivU64x64Remainder.c
@@ -0,0 +1,53 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ DivU64x64Remainder.c
+
+Abstract:
+
+ Math worker functions.
+
+--*/
+
+#include "BaseLibInternal.h"
+
+/**
+ Divides a 64-bit unsigned integer by a 64-bit unsigned integer and generates
+ a 64-bit unsigned result and an optional 64-bit unsigned remainder.
+
+ This function divides the 64-bit unsigned value Dividend by the 64-bit
+ unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
+ is not NULL, then the 64-bit unsigned remainder is returned in Remainder.
+ This function returns the 64-bit unsigned quotient.
+
+ If Divisor is 0, then ASSERT().
+
+ @param Dividend A 64-bit unsigned value.
+ @param Divisor A 64-bit unsigned value.
+ @param Remainder A pointer to a 64-bit unsigned value. This parameter is
+ optional and may be NULL.
+
+ @return Dividend / Divisor
+
+**/
+UINT64
+EFIAPI
+DivU64x64Remainder (
+ IN UINT64 Dividend,
+ IN UINT64 Divisor,
+ OUT UINT64 *Remainder OPTIONAL
+ )
+{
+ ASSERT (Divisor != 0);
+ return InternalMathDivRemU64x64 (Dividend, Divisor, Remainder);
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/EdkIIGlueBaseLib.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/EdkIIGlueBaseLib.cif
new file mode 100644
index 0000000..d0a478f
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/EdkIIGlueBaseLib.cif
@@ -0,0 +1,47 @@
+<component>
+ name = "EdkIIGlueBaseLib"
+ category = ModulePart
+ LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\BaseLib"
+ RefName = "EdkIIGlueBaseLib"
+[files]
+"EdkIIGlueBaseLib.sdl"
+"EdkIIGlueBaseLib.mak"
+"BaseLib.inf"
+"String.c"
+"LinkedList.c"
+"Synchronization.c"
+"Cpu.c"
+"CpuDeadLoop.c"
+"BitField.c"
+"ARShiftU64.c"
+"DivS64x64Remainder.c"
+"DivU64x32.c"
+"DivU64x32Remainder.c"
+"DivU64x64Remainder.c"
+"GetPowerOfTwo32.c"
+"GetPowerOfTwo64.c"
+"HighBitSet32.c"
+"HighBitSet64.c"
+"LowBitSet32.c"
+"LowBitSet64.c"
+"LRotU32.c"
+"LRotU64.c"
+"LShiftU64.c"
+"ModU64x32.c"
+"MultS64x64.c"
+"MultU64x32.c"
+"MultU64x64.c"
+"RRotU32.c"
+"RRotU64.c"
+"RShiftU64.c"
+"SetJump.c"
+"LongJump.c"
+"SwapBytes16.c"
+"SwapBytes32.c"
+"SwapBytes64.c"
+"SwitchStack.c"
+"BaseLibInternal.h"
+[parts]
+"EdkIIGlueBaseLibIA32"
+"EdkIIGlueBaseLibX64"
+<endComponent>
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/EdkIIGlueBaseLib.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/EdkIIGlueBaseLib.mak
new file mode 100644
index 0000000..30458df
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/EdkIIGlueBaseLib.mak
@@ -0,0 +1,106 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueBaseLib/EdkIIGlueBaseLib.mak 1 1/20/12 3:48a Jeffch $
+#
+# $Revision: 1 $
+#
+# $Date: 1/20/12 3:48a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueBaseLib/EdkIIGlueBaseLib.mak $
+#
+# 1 1/20/12 3:48a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 1/20/12 3:28a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 9/27/11 6:10a Wesleychen
+# Intel EDK initially releases.
+#
+# 1 9/18/09 1:50a Iminglin
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: EdkIIGlueBaseLib.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+
+
+!IF "$(PROCESSOR)"=="IA32"
+EdkIIGlueBaseLib_PORCESSOR_CIF=$(EdkIIGlueBaseLib_DIR)\EdkIIGlueBaseLibIa32.cif
+!ELSEIF "$(PROCESSOR)"=="x64"
+EdkIIGlueBaseLib_PORCESSOR_PEI_CIF=$(EdkIIGlueBaseLib_DIR)\EdkIIGlueBaseLibIa32.cif
+EdkIIGlueBaseLib_PORCESSOR_DXE_CIF=$(EdkIIGlueBaseLib_DIR)\EdkIIGlueBaseLibX64.cif
+!ENDIF
+
+$(EdkIIGlueBaseLib_LIB) : EdkIIGlueBaseLib
+
+!IF "$(x64_BUILD)"=="1"
+EdkIIGlueBaseLib : $(BUILD_DIR)\EdkIIGlueBaseLib.mak $(BUILD_DIR)\EdkIIGlueBaseLibPei.mak EdkIIGlueBaseLibBin
+
+$(BUILD_DIR)\EdkIIGlueBaseLib.mak : $(EdkIIGlueBaseLib_DIR)\EdkIIGlueBaseLib.cif $(EdkIIGlueBaseLib_DIR)\EdkIIGlueBaseLib.mak $(BUILD_RULES) $(EdkIIGlueBaseLib_PORCESSOR_DXE_CIF)
+ $(CIF2MAK) $(EdkIIGlueBaseLib_DIR)\EdkIIGlueBaseLib.cif $(CIF2MAK_DEFAULTS) $(EdkIIGlueBaseLib_PORCESSOR_DXE_CIF)
+
+$(BUILD_DIR)\EdkIIGlueBaseLibPei.mak : $(EdkIIGlueBaseLib_DIR)\EdkIIGlueBaseLib.cif $(EdkIIGlueBaseLib_DIR)\EdkIIGlueBaseLib.mak $(BUILD_RULES) $(EdkIIGlueBaseLib_PORCESSOR_PEI_CIF)
+ $(CIF2MAK) $(EdkIIGlueBaseLib_DIR)\EdkIIGlueBaseLib.cif $(CIF2MAK_DEFAULTS) $(EdkIIGlueBaseLib_PORCESSOR_PEI_CIF)
+!ELSE
+EdkIIGlueBaseLib : $(BUILD_DIR)\EdkIIGlueBaseLib.mak EdkIIGlueBaseLibBin
+
+$(BUILD_DIR)\EdkIIGlueBaseLib.mak : $(EdkIIGlueBaseLib_DIR)\EdkIIGlueBaseLib.cif $(EdkIIGlueBaseLib_DIR)\EdkIIGlueBaseLib.mak $(BUILD_RULES) $(EdkIIGlueBaseLib_PORCESSOR_CIF)
+ $(CIF2MAK) $(EdkIIGlueBaseLib_DIR)\EdkIIGlueBaseLib.cif $(CIF2MAK_DEFAULTS) $(EdkIIGlueBaseLib_PORCESSOR_CIF)
+!ENDIF
+
+EdkIIGlueBaseLibBin :
+!IF "$(x64_BUILD)"=="1"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGlueBaseLib.mak all\
+ "MY_INCLUDES=/I$(EdkIIGlueBaseLib_DIR)"\
+ "MY_DEFINES=/D"CPU_STACK_ALIGNMENT=2""\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBaseLib_LIB)"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\IA32\
+ /f $(BUILD_DIR)\EdkIIGlueBaseLibPei.mak all\
+ "MY_INCLUDES=/I$(EdkIIGlueBaseLib_DIR)"\
+ "MY_DEFINES=/D"CPU_STACK_ALIGNMENT=2""\
+ TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBaseLib_LIB)"
+!ELSE
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGlueBaseLib.mak all\
+ "MY_INCLUDES=/I$(EdkIIGlueBaseLib_DIR)"\
+ "MY_DEFINES=/D"CPU_STACK_ALIGNMENT=2""\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBaseLib_LIB)"
+!ENDIF
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/EdkIIGlueBaseLib.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/EdkIIGlueBaseLib.sdl
new file mode 100644
index 0000000..5d37d81
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/EdkIIGlueBaseLib.sdl
@@ -0,0 +1,25 @@
+TOKEN
+ Name = "EdkIIGlueBaseLib_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable EdkIIGlueBaseLib support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "EdkIIGlueBaseLib_LIB"
+ Value = "$$(LIB_BUILD_DIR)\EdkIIGlueBaseLib.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "EdkIIGlueBaseLib_DIR"
+End
+
+MODULE
+ Help = "Includes EdkIIGlueBaseLib.mak to Project"
+ File = "EdkIIGlueBaseLib.mak"
+End
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/EdkIIGlueBaseLibIA32.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/EdkIIGlueBaseLibIA32.cif
new file mode 100644
index 0000000..40856ca
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/EdkIIGlueBaseLibIA32.cif
@@ -0,0 +1,121 @@
+<component>
+ name = "EdkIIGlueBaseLibIA32"
+ category = ModulePart
+ LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\BaseLib"
+ RefName = "EdkIIGlueBaseLibIA32"
+[files]
+"x86DisablePaging32.c"
+"x86DisablePaging64.c"
+"x86EnablePaging32.c"
+"x86EnablePaging64.c"
+"x86FxRestore.c"
+"x86FxSave.c"
+"x86GetInterruptState.c"
+"x86MemoryFence.c"
+"x86Msr.c"
+"x86ReadGdtr.c"
+"x86ReadIdtr.c"
+"x86Thunk.c"
+"x86WriteGdtr.c"
+"x86WriteIdtr.c"
+"Unaligned.c"
+"Ia32\Non-existing.c"
+"Ia32\InternalSwitchStack.c"
+"Ia32\LShiftU64.asm"
+"Ia32\RShiftU64.asm"
+"Ia32\ARShiftU64.asm"
+"Ia32\LRotU64.asm"
+"Ia32\RRotU64.asm"
+"Ia32\MultU64x32.asm"
+"Ia32\MultU64x64.asm"
+"Ia32\DivU64x32.asm"
+"Ia32\ModU64x32.asm"
+"Ia32\DivU64x32Remainder.asm"
+"Ia32\DivU64x64Remainder.asm"
+"Ia32\DivS64x64Remainder.c"
+"Ia32\SwapBytes64.asm"
+"Ia32\SetJump.asm"
+"Ia32\LongJump.asm"
+"Ia32\CpuId.asm"
+"Ia32\CpuIdEx.asm"
+"Ia32\ReadEflags.asm"
+"Ia32\ReadMsr64.asm"
+"Ia32\WriteMsr64.asm"
+"Ia32\ReadCr0.asm"
+"Ia32\ReadCr2.asm"
+"Ia32\ReadCr3.asm"
+"Ia32\ReadCr4.asm"
+"Ia32\WriteCr0.asm"
+"Ia32\WriteCr2.asm"
+"Ia32\WriteCr3.asm"
+"Ia32\WriteCr4.asm"
+"Ia32\ReadDr0.asm"
+"Ia32\ReadDr1.asm"
+"Ia32\ReadDr2.asm"
+"Ia32\ReadDr3.asm"
+"Ia32\ReadDr4.asm"
+"Ia32\ReadDr5.asm"
+"Ia32\ReadDr6.asm"
+"Ia32\ReadDr7.asm"
+"Ia32\WriteDr0.asm"
+"Ia32\WriteDr1.asm"
+"Ia32\WriteDr2.asm"
+"Ia32\WriteDr3.asm"
+"Ia32\WriteDr4.asm"
+"Ia32\WriteDr5.asm"
+"Ia32\WriteDr6.asm"
+"Ia32\WriteDr7.asm"
+"Ia32\ReadCs.asm"
+"Ia32\ReadDs.asm"
+"Ia32\ReadEs.asm"
+"Ia32\ReadFs.asm"
+"Ia32\ReadGs.asm"
+"Ia32\ReadSs.asm"
+"Ia32\ReadTr.asm"
+"Ia32\ReadGdtr.asm"
+"Ia32\WriteGdtr.asm"
+"Ia32\ReadIdtr.asm"
+"Ia32\WriteIdtr.asm"
+"Ia32\ReadLdtr.asm"
+"Ia32\WriteLdtr.asm"
+"Ia32\FxSave.asm"
+"Ia32\FxRestore.asm"
+"Ia32\ReadMm0.asm"
+"Ia32\ReadMm1.asm"
+"Ia32\ReadMm2.asm"
+"Ia32\ReadMm3.asm"
+"Ia32\ReadMm4.asm"
+"Ia32\ReadMm5.asm"
+"Ia32\ReadMm6.asm"
+"Ia32\ReadMm7.asm"
+"Ia32\WriteMm0.asm"
+"Ia32\WriteMm1.asm"
+"Ia32\WriteMm2.asm"
+"Ia32\WriteMm3.asm"
+"Ia32\WriteMm4.asm"
+"Ia32\WriteMm5.asm"
+"Ia32\WriteMm6.asm"
+"Ia32\WriteMm7.asm"
+"Ia32\ReadTsc.asm"
+"Ia32\ReadPmc.asm"
+"Ia32\Monitor.asm"
+"Ia32\Mwait.asm"
+"Ia32\EnablePaging32.asm"
+"Ia32\DisablePaging32.asm"
+"Ia32\EnablePaging64.asm"
+"Ia32\Wbinvd.asm"
+"Ia32\Invd.asm"
+"Ia32\FlushCacheLine.asm"
+"Ia32\InterlockedIncrement.asm"
+"Ia32\InterlockedDecrement.asm"
+"Ia32\InterlockedCompareExchange32.asm"
+"Ia32\InterlockedCompareExchange64.asm"
+"Ia32\EnableInterrupts.asm"
+"Ia32\DisableInterrupts.asm"
+"Ia32\EnableDisableInterrupts.asm"
+"Ia32\CpuSleep.asm"
+"Ia32\CpuPause.asm"
+"Ia32\CpuBreakpoint.asm"
+"Ia32\CpuFlushTlb.asm"
+"Ia32\Thunk16.asm"
+<endComponent>
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/EdkIIGlueBaseLibX64.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/EdkIIGlueBaseLibX64.cif
new file mode 100644
index 0000000..1dd7619
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/EdkIIGlueBaseLibX64.cif
@@ -0,0 +1,108 @@
+<component>
+ name = "EdkIIGlueBaseLibX64"
+ category = ModulePart
+ LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\BaseLib"
+ RefName = "EdkIIGlueBaseLibX64"
+[files]
+"x86DisablePaging32.c"
+"x86DisablePaging64.c"
+"x86EnablePaging32.c"
+"x86EnablePaging64.c"
+"x86FxRestore.c"
+"x86FxSave.c"
+"x86GetInterruptState.c"
+"x86MemoryFence.c"
+"x86Msr.c"
+"x86ReadGdtr.c"
+"x86ReadIdtr.c"
+"x86Thunk.c"
+"x86WriteGdtr.c"
+"x86WriteIdtr.c"
+"Unaligned.c"
+"Math64.c"
+"X64\Non-existing.c"
+"X64\SwitchStack.asm"
+"X64\SetJump.asm"
+"X64\LongJump.asm"
+"X64\CpuId.asm"
+"X64\CpuIdEx.asm"
+"X64\ReadEflags.asm"
+"X64\ReadMsr64.asm"
+"X64\WriteMsr64.asm"
+"X64\ReadCr0.asm"
+"X64\ReadCr2.asm"
+"X64\ReadCr3.asm"
+"X64\ReadCr4.asm"
+"X64\WriteCr0.asm"
+"X64\WriteCr2.asm"
+"X64\WriteCr3.asm"
+"X64\WriteCr4.asm"
+"X64\ReadDr0.asm"
+"X64\ReadDr1.asm"
+"X64\ReadDr2.asm"
+"X64\ReadDr3.asm"
+"X64\ReadDr4.asm"
+"X64\ReadDr5.asm"
+"X64\ReadDr6.asm"
+"X64\ReadDr7.asm"
+"X64\WriteDr0.asm"
+"X64\WriteDr1.asm"
+"X64\WriteDr2.asm"
+"X64\WriteDr3.asm"
+"X64\WriteDr4.asm"
+"X64\WriteDr5.asm"
+"X64\WriteDr6.asm"
+"X64\WriteDr7.asm"
+"X64\ReadCs.asm"
+"X64\ReadDs.asm"
+"X64\ReadEs.asm"
+"X64\ReadFs.asm"
+"X64\ReadGs.asm"
+"X64\ReadSs.asm"
+"X64\ReadTr.asm"
+"X64\ReadGdtr.asm"
+"X64\WriteGdtr.asm"
+"X64\ReadIdtr.asm"
+"X64\WriteIdtr.asm"
+"X64\ReadLdtr.asm"
+"X64\WriteLdtr.asm"
+"X64\FxSave.asm"
+"X64\FxRestore.asm"
+"X64\ReadMm0.asm"
+"X64\ReadMm1.asm"
+"X64\ReadMm2.asm"
+"X64\ReadMm3.asm"
+"X64\ReadMm4.asm"
+"X64\ReadMm5.asm"
+"X64\ReadMm6.asm"
+"X64\ReadMm7.asm"
+"X64\WriteMm0.asm"
+"X64\WriteMm1.asm"
+"X64\WriteMm2.asm"
+"X64\WriteMm3.asm"
+"X64\WriteMm4.asm"
+"X64\WriteMm5.asm"
+"X64\WriteMm6.asm"
+"X64\WriteMm7.asm"
+"X64\ReadTsc.asm"
+"X64\ReadPmc.asm"
+"X64\Monitor.asm"
+"X64\Mwait.asm"
+"X64\EnablePaging64.asm"
+"X64\DisablePaging64.asm"
+"X64\Wbinvd.asm"
+"X64\Invd.asm"
+"X64\FlushCacheLine.asm"
+"X64\InterlockedIncrement.asm"
+"X64\InterlockedDecrement.asm"
+"X64\InterlockedCompareExchange32.asm"
+"X64\InterlockedCompareExchange64.asm"
+"X64\EnableInterrupts.asm"
+"X64\DisableInterrupts.asm"
+"X64\EnableDisableInterrupts.asm"
+"X64\CpuSleep.asm"
+"X64\CpuPause.asm"
+"X64\CpuBreakpoint.asm"
+"X64\CpuFlushTlb.asm"
+"X64\Thunk16.asm"
+<endComponent>
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/GetPowerOfTwo32.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/GetPowerOfTwo32.c
new file mode 100644
index 0000000..2b8c47b
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/GetPowerOfTwo32.c
@@ -0,0 +1,48 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ GetPowerOfTwo32.c
+
+Abstract:
+
+ Math worker functions.
+
+--*/
+
+#include "BaseLibInternal.h"
+
+/**
+ Returns the value of the highest bit set in a 32-bit value. Equivalent to
+ 1 << HighBitSet32(x).
+
+ This function computes the value of the highest bit set in the 32-bit value
+ specified by Operand. If Operand is zero, then zero is returned.
+
+ @param Operand The 32-bit operand to evaluate.
+
+ @return 1 << HighBitSet32(Operand)
+ @retval 0 Operand is zero.
+
+**/
+UINT32
+EFIAPI
+GetPowerOfTwo32 (
+ IN UINT32 Operand
+ )
+{
+ if (Operand == 0) {
+ return 0;
+ }
+
+ return 1ul << HighBitSet32 (Operand);
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/GetPowerOfTwo64.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/GetPowerOfTwo64.c
new file mode 100644
index 0000000..9b1f081
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/GetPowerOfTwo64.c
@@ -0,0 +1,49 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ GetPowerOfTwo64.c
+
+Abstract:
+
+ Math worker functions.
+
+--*/
+
+#include "BaseLibInternal.h"
+
+/**
+ Returns the value of the highest bit set in a 64-bit value. Equivalent to
+ 1 << HighBitSet64(x).
+
+ This function computes the value of the highest bit set in the 64-bit value
+ specified by Operand. If Operand is zero, then zero is returned.
+
+ @param Operand The 64-bit operand to evaluate.
+
+ @return 1 << HighBitSet64(Operand)
+ @retval 0 Operand is zero.
+
+**/
+UINT64
+EFIAPI
+GetPowerOfTwo64 (
+ IN UINT64 Operand
+ )
+{
+ if (Operand == 0) {
+ return 0;
+ }
+
+ return LShiftU64 (1, HighBitSet64 (Operand));
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/HighBitSet32.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/HighBitSet32.c
new file mode 100644
index 0000000..7db1a02
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/HighBitSet32.c
@@ -0,0 +1,49 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ HighBitSet32.c
+
+Abstract:
+
+ Math worker functions.
+
+--*/
+
+#include "BaseLibInternal.h"
+
+/**
+ Returns the bit position of the highest bit set in a 32-bit value. Equivalent
+ to log2(x).
+
+ This function computes the bit position of the highest bit set in the 32-bit
+ value specified by Operand. If Operand is zero, then -1 is returned.
+ Otherwise, a value between 0 and 31 is returned.
+
+ @param Operand The 32-bit operand to evaluate.
+
+ @return Position of the highest bit set in Operand if found.
+ @retval -1 Operand is zero.
+
+**/
+INTN
+EFIAPI
+HighBitSet32 (
+ IN UINT32 Operand
+ )
+{
+ INTN BitIndex;
+
+ for (BitIndex = -1; Operand != 0; BitIndex++, Operand >>= 1);
+ return BitIndex;
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/HighBitSet64.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/HighBitSet64.c
new file mode 100644
index 0000000..807871b
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/HighBitSet64.c
@@ -0,0 +1,51 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ HighBitSet64.c
+
+Abstract:
+
+ Math worker functions.
+
+--*/
+
+#include "BaseLibInternal.h"
+
+/**
+ Returns the bit position of the highest bit set in a 64-bit value. Equivalent
+ to log2(x).
+
+ This function computes the bit position of the highest bit set in the 64-bit
+ value specified by Operand. If Operand is zero, then -1 is returned.
+ Otherwise, a value between 0 and 63 is returned.
+
+ @param Operand The 64-bit operand to evaluate.
+
+ @return Position of the highest bit set in Operand if found.
+ @retval -1 Operand is zero.
+
+**/
+INTN
+EFIAPI
+HighBitSet64 (
+ IN UINT64 Operand
+ )
+{
+ INTN BitIndex;
+
+ for (BitIndex = -1;
+ Operand != 0;
+ BitIndex++, Operand = RShiftU64 (Operand, 1));
+ return BitIndex;
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ARShiftU64.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ARShiftU64.asm
new file mode 100644
index 0000000..3885bbc
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ARShiftU64.asm
@@ -0,0 +1,44 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ARShiftU64.asm
+;
+; Abstract:
+;
+; 64-bit arithmetic right shift function for IA-32
+;
+;------------------------------------------------------------------------------
+
+ .686
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; UINT64
+; EFIAPI
+; InternalMathARShiftU64 (
+; IN UINT64 Operand,
+; IN UINTN Count
+; );
+;------------------------------------------------------------------------------
+InternalMathARShiftU64 PROC
+ mov cl, [esp + 12]
+ mov eax, [esp + 8]
+ cdq
+ test cl, 32
+ cmovz edx, eax
+ cmovz eax, [esp + 4]
+ shrd eax, edx, cl
+ sar edx, cl
+ ret
+InternalMathARShiftU64 ENDP
+
+ END \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuBreakpoint.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuBreakpoint.asm
new file mode 100644
index 0000000..2f5c181
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuBreakpoint.asm
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; CpuBreakpoint.Asm
+;
+; Abstract:
+;
+; CpuBreakpoint function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .686
+ .model flat
+ .xmm
+ .code
+
+;------------------------------------------------------------------------------
+; VOID
+; EFIAPI
+; CpuBreakpoint (
+; VOID
+; );
+;------------------------------------------------------------------------------
+_CpuBreakpoint PROC
+ int 3
+ ret
+_CpuBreakpoint ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuFlushTlb.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuFlushTlb.asm
new file mode 100644
index 0000000..acf3833
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuFlushTlb.asm
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; CpuFlushTlb.Asm
+;
+; Abstract:
+;
+; CpuFlushTlb function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .386p
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; VOID
+; EFIAPI
+; CpuFlushTlb (
+; VOID
+; );
+;------------------------------------------------------------------------------
+CpuFlushTlb PROC
+ mov eax, cr3
+ mov cr3, eax
+ ret
+CpuFlushTlb ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuId.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuId.asm
new file mode 100644
index 0000000..9b87d60
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuId.asm
@@ -0,0 +1,64 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; CpuId.Asm
+;
+; Abstract:
+;
+; AsmCpuid function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .586P
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; VOID
+; EFIAPI
+; AsmCpuid (
+; IN UINT32 RegisterInEax,
+; OUT UINT32 *RegisterOutEax OPTIONAL,
+; OUT UINT32 *RegisterOutEbx OPTIONAL,
+; OUT UINT32 *RegisterOutEcx OPTIONAL,
+; OUT UINT32 *RegisterOutEdx OPTIONAL
+; );
+;------------------------------------------------------------------------------
+AsmCpuid PROC USES ebx
+ push ebp
+ mov ebp, esp
+ mov eax, [ebp + 12]
+ cpuid
+ push ecx
+ mov ecx, [ebp + 16]
+ jecxz @F
+ mov [ecx], eax
+@@:
+ mov ecx, [ebp + 20]
+ jecxz @F
+ mov [ecx], ebx
+@@:
+ mov ecx, [ebp + 24]
+ jecxz @F
+ pop [ecx]
+@@:
+ mov ecx, [ebp + 28]
+ jecxz @F
+ mov [ecx], edx
+@@:
+ mov eax, [ebp + 12]
+ leave
+ ret
+AsmCpuid ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuIdEx.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuIdEx.asm
new file mode 100644
index 0000000..4c52315
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuIdEx.asm
@@ -0,0 +1,66 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; CpuIdEx.Asm
+;
+; Abstract:
+;
+; AsmCpuidEx function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .686
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; UINT32
+; EFIAPI
+; AsmCpuidEx (
+; IN UINT32 RegisterInEax,
+; IN UINT32 RegisterInEcx,
+; OUT UINT32 *RegisterOutEax OPTIONAL,
+; OUT UINT32 *RegisterOutEbx OPTIONAL,
+; OUT UINT32 *RegisterOutEcx OPTIONAL,
+; OUT UINT32 *RegisterOutEdx OPTIONAL
+; )
+;------------------------------------------------------------------------------
+AsmCpuidEx PROC USES ebx
+ push ebp
+ mov ebp, esp
+ mov eax, [ebp + 12]
+ mov ecx, [ebp + 16]
+ cpuid
+ push ecx
+ mov ecx, [ebp + 20]
+ jecxz @F
+ mov [ecx], eax
+@@:
+ mov ecx, [ebp + 24]
+ jecxz @F
+ mov [ecx], ebx
+@@:
+ mov ecx, [ebp + 28]
+ jecxz @F
+ pop [ecx]
+@@:
+ mov edx, [ebp + 32]
+ jecxz @F
+ mov [ecx], edx
+@@:
+ mov eax, [ebp + 12]
+ leave
+ ret
+AsmCpuidEx ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuPause.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuPause.asm
new file mode 100644
index 0000000..46b8a19
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuPause.asm
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; CpuPause.Asm
+;
+; Abstract:
+;
+; CpuPause function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .686
+ .model flat,C
+ .xmm
+ .code
+
+;------------------------------------------------------------------------------
+; VOID
+; EFIAPI
+; CpuPause (
+; VOID
+; );
+;------------------------------------------------------------------------------
+CpuPause PROC
+ pause
+ ret
+CpuPause ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuSleep.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuSleep.asm
new file mode 100644
index 0000000..0f72a5d
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/CpuSleep.asm
@@ -0,0 +1,38 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; CpuSleep.Asm
+;
+; Abstract:
+;
+; CpuSleep function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .386
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; VOID
+; EFIAPI
+; CpuSleep (
+; VOID
+; );
+;------------------------------------------------------------------------------
+CpuSleep PROC
+ hlt
+ ret
+CpuSleep ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DisableInterrupts.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DisableInterrupts.asm
new file mode 100644
index 0000000..ca1e775
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DisableInterrupts.asm
@@ -0,0 +1,38 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; DisableInterrupts.Asm
+;
+; Abstract:
+;
+; DisableInterrupts function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .386p
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; VOID
+; EFIAPI
+; DisableInterrupts (
+; VOID
+; );
+;------------------------------------------------------------------------------
+DisableInterrupts PROC
+ cli
+ ret
+DisableInterrupts ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DisablePaging32.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DisablePaging32.asm
new file mode 100644
index 0000000..ab77ec0
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DisablePaging32.asm
@@ -0,0 +1,55 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; DisablePaging32.Asm
+;
+; Abstract:
+;
+; AsmDisablePaging32 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .386
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; VOID
+; EFIAPI
+; InternalX86DisablePaging32 (
+; IN SWITCH_STACK_ENTRY_POINT EntryPoint,
+; IN VOID *Context1, OPTIONAL
+; IN VOID *Context2, OPTIONAL
+; IN VOID *NewStack
+; );
+;------------------------------------------------------------------------------
+InternalX86DisablePaging32 PROC
+ mov ebx, [esp + 4]
+ mov ecx, [esp + 8]
+ mov edx, [esp + 12]
+ pushfd
+ pop edi ; save EFLAGS to edi
+ cli
+ mov eax, cr0
+ btr eax, 31
+ mov esp, [esp + 16]
+ mov cr0, eax
+ push edi
+ popfd ; restore EFLAGS from edi
+ push edx
+ push ecx
+ call ebx
+ jmp $ ; EntryPoint() should not return
+InternalX86DisablePaging32 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DivS64x64Remainder.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DivS64x64Remainder.c
new file mode 100644
index 0000000..d9df26e
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DivS64x64Remainder.c
@@ -0,0 +1,60 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ DivS64x64Remainder.c
+
+Abstract:
+
+ Integer division worker functions for Ia32.
+
+--*/
+
+#include "..\BaseLibInternal.h"
+
+/**
+ Worker function that Divides a 64-bit signed integer by a 64-bit signed integer and
+ generates a 64-bit signed result and a optional 64-bit signed remainder.
+
+ This function divides the 64-bit unsigned value Dividend by the 64-bit
+ unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
+ is not NULL, then the 64-bit unsigned remainder is returned in Remainder.
+ This function returns the 64-bit unsigned quotient.
+
+ @param Dividend A 64-bit signed value.
+ @param Divisor A 64-bit signed value.
+ @param Remainder A pointer to a 64-bit signed value. This parameter is
+ optional and may be NULL.
+
+ @return Dividend / Divisor
+
+**/
+INT64
+InternalMathDivRemS64x64 (
+ IN INT64 Dividend,
+ IN INT64 Divisor,
+ OUT INT64 *Remainder OPTIONAL
+ )
+{
+ INT64 Quot;
+
+ Quot = InternalMathDivRemU64x64 (
+ Dividend >= 0 ? Dividend : -Dividend,
+ Divisor >= 0 ? Divisor : -Divisor,
+ (UINT64 *) Remainder
+ );
+ if (Remainder != NULL && Dividend < 0) {
+ *Remainder = -*Remainder;
+ }
+ return (Dividend ^ Divisor) >= 0 ? Quot : -Quot;
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DivU64x32.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DivU64x32.asm
new file mode 100644
index 0000000..999c8ad
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DivU64x32.asm
@@ -0,0 +1,44 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; DivU64x32.asm
+;
+; Abstract:
+;
+; Calculate the quotient of a 64-bit integer by a 32-bit integer
+;
+;------------------------------------------------------------------------------
+
+ .386
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; UINT64
+; EFIAPI
+; InternalMathDivU64x32 (
+; IN UINT64 Dividend,
+; IN UINT32 Divisor
+; );
+;------------------------------------------------------------------------------
+InternalMathDivU64x32 PROC
+ mov eax, [esp + 8]
+ mov ecx, [esp + 12]
+ xor edx, edx
+ div ecx
+ push eax ; save quotient on stack
+ mov eax, [esp + 8]
+ div ecx
+ pop edx ; restore high-order dword of the quotient
+ ret
+InternalMathDivU64x32 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DivU64x32Remainder.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DivU64x32Remainder.asm
new file mode 100644
index 0000000..a9f58b9
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DivU64x32Remainder.asm
@@ -0,0 +1,49 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; DivError.asm
+;
+; Abstract:
+;
+; Set error flag for all division functions
+;
+;------------------------------------------------------------------------------
+
+ .386
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; UINT64
+; EFIAPI
+; InternalMathDivRemU64x32 (
+; IN UINT64 Dividend,
+; IN UINT32 Divisor,
+; OUT UINT32 *Remainder
+; );
+;------------------------------------------------------------------------------
+InternalMathDivRemU64x32 PROC
+ mov ecx, [esp + 12]
+ mov eax, [esp + 8]
+ xor edx, edx
+ div ecx
+ push eax
+ mov eax, [esp + 8]
+ div ecx
+ mov ecx, [esp + 20]
+ jecxz @F ; abandon remainder if Remainder == NULL
+ mov [ecx], edx
+@@:
+ pop edx
+ ret
+InternalMathDivRemU64x32 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DivU64x64Remainder.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DivU64x64Remainder.asm
new file mode 100644
index 0000000..eb16032
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/DivU64x64Remainder.asm
@@ -0,0 +1,90 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; DivU64x64Remainder.asm
+;
+; Abstract:
+;
+; Calculate the quotient of a 64-bit integer by a 64-bit integer and returns
+; both the quotient and the remainder
+;
+;------------------------------------------------------------------------------
+
+ .386
+ .model flat,C
+ .code
+
+EXTERN InternalMathDivRemU64x32:PROC
+
+;------------------------------------------------------------------------------
+; UINT64
+; EFIAPI
+; InternalMathDivRemU64x64 (
+; IN UINT64 Dividend,
+; IN UINT64 Divisor,
+; OUT UINT64 *Remainder OPTIONAL
+; );
+;------------------------------------------------------------------------------
+InternalMathDivRemU64x64 PROC
+ mov ecx, [esp + 16]
+ test ecx, ecx
+ jnz _@DivRemU64x64 ; call _@DivRemU64x64 if Divisor > 2^32
+ mov ecx, [esp + 20]
+ jecxz @F
+ and dword ptr [ecx + 4], 0
+ mov [esp + 16], ecx
+@@:
+ jmp InternalMathDivRemU64x32
+InternalMathDivRemU64x64 ENDP
+
+_@DivRemU64x64 PROC USES ebx esi edi
+ mov edx, dword ptr [esp + 20]
+ mov eax, dword ptr [esp + 16] ; edx:eax <- dividend
+ mov edi, edx
+ mov esi, eax ; edi:esi <- dividend
+ mov ebx, dword ptr [esp + 24] ; ecx:ebx <- divisor
+@@:
+ shr edx, 1
+ rcr eax, 1
+ shrd ebx, ecx, 1
+ shr ecx, 1
+ jnz @B
+ div ebx
+ mov ebx, eax ; ebx <- quotient
+ mov ecx, [esp + 28]
+ mul dword ptr [esp + 24]
+ imul ecx, ebx
+ add edx, ecx
+ mov ecx, dword ptr [esp + 32]
+ jc @TooLarge ; product > 2^64
+ cmp edi, edx ; compare high 32 bits
+ ja @Correct
+ jb @TooLarge ; product > dividend
+ cmp esi, eax
+ jae @Correct ; product <= dividend
+@TooLarge:
+ dec ebx ; adjust quotient by -1
+ jecxz @Return ; return if Remainder == NULL
+ sub eax, dword ptr [esp + 24]
+ sbb edx, dword ptr [esp + 28]
+@Correct:
+ jecxz @Return
+ sub esi, eax
+ sbb edi, edx ; edi:esi <- remainder
+ mov [ecx], esi
+ mov [ecx + 4], edi
+@Return:
+ mov eax, ebx ; eax <- quotient
+ xor edx, edx
+ ret
+_@DivRemU64x64 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/EnableDisableInterrupts.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/EnableDisableInterrupts.asm
new file mode 100644
index 0000000..80a07e6
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/EnableDisableInterrupts.asm
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; EnableDisableInterrupts.Asm
+;
+; Abstract:
+;
+; EnableDisableInterrupts function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .386p
+ .model flat
+ .code
+
+;------------------------------------------------------------------------------
+; VOID
+; EFIAPI
+; EnableDisableInterrupts (
+; VOID
+; );
+;------------------------------------------------------------------------------
+_EnableDisableInterrupts PROC
+ sti
+ cli
+ ret
+_EnableDisableInterrupts ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/EnableInterrupts.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/EnableInterrupts.asm
new file mode 100644
index 0000000..961bb32
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/EnableInterrupts.asm
@@ -0,0 +1,38 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; EnableInterrupts.Asm
+;
+; Abstract:
+;
+; EnableInterrupts function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .386p
+ .model flat
+ .code
+
+;------------------------------------------------------------------------------
+; VOID
+; EFIAPI
+; EnableInterrupts (
+; VOID
+; );
+;------------------------------------------------------------------------------
+_EnableInterrupts PROC
+ sti
+ ret
+_EnableInterrupts ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/EnablePaging32.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/EnablePaging32.asm
new file mode 100644
index 0000000..16d4ae1
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/EnablePaging32.asm
@@ -0,0 +1,55 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; EnablePaging32.Asm
+;
+; Abstract:
+;
+; AsmEnablePaging32 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .386
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; VOID
+; EFIAPI
+; InternalX86EnablePaging32 (
+; IN SWITCH_STACK_ENTRY_POINT EntryPoint,
+; IN VOID *Context1, OPTIONAL
+; IN VOID *Context2, OPTIONAL
+; IN VOID *NewStack
+; );
+;------------------------------------------------------------------------------
+InternalX86EnablePaging32 PROC
+ mov ebx, [esp + 4]
+ mov ecx, [esp + 8]
+ mov edx, [esp + 12]
+ pushfd
+ pop edi
+ cli
+ mov eax, cr0
+ bts eax, 31
+ mov esp, [esp + 16]
+ mov cr0, eax
+ push edi
+ popfd
+ push edx
+ push ecx
+ call ebx
+ jmp $
+InternalX86EnablePaging32 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/EnablePaging64.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/EnablePaging64.asm
new file mode 100644
index 0000000..ce30372
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/EnablePaging64.asm
@@ -0,0 +1,66 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; EnablePaging64.Asm
+;
+; Abstract:
+;
+; AsmEnablePaging64 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .686p
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; VOID
+; EFIAPI
+; InternalX86EnablePaging64 (
+; IN UINT16 Cs,
+; IN UINT64 EntryPoint,
+; IN UINT64 Context1, OPTIONAL
+; IN UINT64 Context2, OPTIONAL
+; IN UINT64 NewStack
+; );
+;------------------------------------------------------------------------------
+InternalX86EnablePaging64 PROC
+ cli
+ mov [esp], @F ; offset for far retf, seg is the 1st arg
+ mov eax, cr4
+ or al, (1 SHL 5)
+ mov cr4, eax ; enable PAE
+ mov ecx, 0c0000080h
+ rdmsr
+ or ah, 1 ; set LME
+ wrmsr
+ mov eax, cr0
+ bts eax, 31
+ mov cr0, eax ; enable paging
+ retf
+@@: ; long mode starts here
+ DB 67h, 48h
+ mov ebx, [esp] ; mov rbx, [esp]
+ DB 67h, 48h
+ mov ecx, [esp + 8] ; mov rcx, [esp + 8]
+ DB 67h, 48h
+ mov edx, [esp + 10h] ; mov rdx, [esp + 10h]
+ DB 67h, 48h
+ mov esp, [esp + 18h] ; mov rsp, [esp + 18h]
+ DB 48h
+ add esp, -20h ; add rsp, -20h
+ call ebx ; call rbx
+ jmp $
+InternalX86EnablePaging64 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/FlushCacheLine.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/FlushCacheLine.asm
new file mode 100644
index 0000000..b6ba954
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/FlushCacheLine.asm
@@ -0,0 +1,40 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; FlushCacheLine.Asm
+;
+; Abstract:
+;
+; AsmFlushCacheLine function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .586P
+ .model flat,C
+ .xmm
+ .code
+
+;------------------------------------------------------------------------------
+; VOID *
+; EFIAPI
+; AsmFlushCacheLine (
+; IN VOID *LinearAddress
+; );
+;------------------------------------------------------------------------------
+AsmFlushCacheLine PROC
+ mov eax, [esp + 4]
+ clflush [eax]
+ ret
+AsmFlushCacheLine ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/FxRestore.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/FxRestore.asm
new file mode 100644
index 0000000..f1c4f1d
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/FxRestore.asm
@@ -0,0 +1,40 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; FxRestore.Asm
+;
+; Abstract:
+;
+; AsmFxRestore function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .586
+ .model flat,C
+ .xmm
+ .code
+
+;------------------------------------------------------------------------------
+; VOID
+; EFIAPI
+; InternalX86FxRestore (
+; IN CONST IA32_FX_BUFFER *Buffer
+; );
+;------------------------------------------------------------------------------
+InternalX86FxRestore PROC
+ mov eax, [esp + 4]
+ fxrstor [eax]
+ ret
+InternalX86FxRestore ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/FxSave.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/FxSave.asm
new file mode 100644
index 0000000..ebdb6ba
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/FxSave.asm
@@ -0,0 +1,40 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; FxSave.Asm
+;
+; Abstract:
+;
+; AsmFxSave function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .586
+ .model flat,C
+ .xmm
+ .code
+
+;------------------------------------------------------------------------------
+; VOID
+; EFIAPI
+; InternalX86FxSave (
+; OUT IA32_FX_BUFFER *Buffer
+; );
+;------------------------------------------------------------------------------
+InternalX86FxSave PROC
+ mov eax, [esp + 4]
+ fxsave [eax]
+ ret
+InternalX86FxSave ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/InterlockedCompareExchange32.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/InterlockedCompareExchange32.asm
new file mode 100644
index 0000000..c18f136
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/InterlockedCompareExchange32.asm
@@ -0,0 +1,43 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; InterlockedCompareExchange32.Asm
+;
+; Abstract:
+;
+; InterlockedCompareExchange32 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .486
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; UINT32
+; EFIAPI
+; InternalSyncCompareExchange32 (
+; IN UINT32 *Value,
+; IN UINT32 CompareValue,
+; IN UINT32 ExchangeValue
+; );
+;------------------------------------------------------------------------------
+InternalSyncCompareExchange32 PROC
+ mov ecx, [esp + 4]
+ mov eax, [esp + 8]
+ mov edx, [esp + 12]
+ lock cmpxchg [ecx], edx
+ ret
+InternalSyncCompareExchange32 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/InterlockedCompareExchange64.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/InterlockedCompareExchange64.asm
new file mode 100644
index 0000000..965f195
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/InterlockedCompareExchange64.asm
@@ -0,0 +1,45 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; InterlockedCompareExchange64.Asm
+;
+; Abstract:
+;
+; InterlockedCompareExchange64 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .586P
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; UINT64
+; EFIAPI
+; InternalSyncCompareExchange64 (
+; IN UINT64 *Value,
+; IN UINT64 CompareValue,
+; IN UINT64 ExchangeValue
+; );
+;------------------------------------------------------------------------------
+InternalSyncCompareExchange64 PROC USES esi ebx
+ mov esi, [esp + 12]
+ mov eax, [esp + 16]
+ mov edx, [esp + 20]
+ mov ebx, [esp + 24]
+ mov ecx, [esp + 28]
+ lock cmpxchg8b qword ptr [esi]
+ ret
+InternalSyncCompareExchange64 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/InterlockedDecrement.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/InterlockedDecrement.asm
new file mode 100644
index 0000000..d84e8e6
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/InterlockedDecrement.asm
@@ -0,0 +1,40 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; InterlockedDecrement.Asm
+;
+; Abstract:
+;
+; InterlockedDecrement function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .386
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; UINT32
+; EFIAPI
+; InternalSyncDecrement (
+; IN UINT32 *Value
+; );
+;------------------------------------------------------------------------------
+InternalSyncDecrement PROC
+ mov eax, [esp + 4]
+ lock dec dword ptr [eax]
+ mov eax, [eax]
+ ret
+InternalSyncDecrement ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/InterlockedIncrement.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/InterlockedIncrement.asm
new file mode 100644
index 0000000..dff11e1
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/InterlockedIncrement.asm
@@ -0,0 +1,40 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; InterlockedIncrement.Asm
+;
+; Abstract:
+;
+; InterlockedIncrement function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .386
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; UINT32
+; EFIAPI
+; InternalSyncIncrement (
+; IN UINT32 *Value
+; );
+;------------------------------------------------------------------------------
+InternalSyncIncrement PROC
+ mov eax, [esp + 4]
+ lock inc dword ptr [eax]
+ mov eax, [eax]
+ ret
+InternalSyncIncrement ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/InternalSwitchStack.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/InternalSwitchStack.c
new file mode 100644
index 0000000..0f777d2
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/InternalSwitchStack.c
@@ -0,0 +1,60 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ InternalSwitchStack.c
+
+Abstract:
+
+ SwitchStack() function for IA-32.
+
+--*/
+
+#include "..\BaseLibInternal.h"
+
+/**
+ Transfers control to a function starting with a new stack.
+
+ Transfers control to the function specified by EntryPoint using the new stack
+ specified by NewStack and passing in the parameters specified by Context1 and
+ Context2. Context1 and Context2 are optional and may be NULL. The function
+ EntryPoint must never return.
+
+ @param EntryPoint A pointer to function to call with the new stack.
+ @param Context1 A pointer to the context to pass into the EntryPoint
+ function.
+ @param Context2 A pointer to the context to pass into the EntryPoint
+ function.
+ @param NewStack A pointer to the new stack to use for the EntryPoint
+ function.
+
+**/
+VOID
+EFIAPI
+InternalSwitchStack (
+ IN SWITCH_STACK_ENTRY_POINT EntryPoint,
+ IN VOID *Context1,
+ IN VOID *Context2,
+ IN VOID *NewStack
+ )
+{
+ BASE_LIBRARY_JUMP_BUFFER JumpBuffer;
+
+ JumpBuffer.Eip = (UINTN)EntryPoint;
+ JumpBuffer.Esp = (UINTN)NewStack - sizeof (VOID*);
+ JumpBuffer.Esp -= sizeof (Context1) + sizeof (Context2);
+ ((VOID**)JumpBuffer.Esp)[1] = Context1;
+ ((VOID**)JumpBuffer.Esp)[2] = Context2;
+
+ LongJump (&JumpBuffer, (UINTN)-1);
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Invd.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Invd.asm
new file mode 100644
index 0000000..8f3ba9b
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Invd.asm
@@ -0,0 +1,38 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; Invd.Asm
+;
+; Abstract:
+;
+; AsmInvd function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .486p
+ .model flat
+ .code
+
+;------------------------------------------------------------------------------
+; VOID
+; EFIAPI
+; AsmInvd (
+; VOID
+; );
+;------------------------------------------------------------------------------
+_AsmInvd PROC
+ invd
+ ret
+_AsmInvd ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/LRotU64.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/LRotU64.asm
new file mode 100644
index 0000000..9a9307a
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/LRotU64.asm
@@ -0,0 +1,47 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; LRotU64.asm
+;
+; Abstract:
+;
+; 64-bit left rotation for Ia32
+;
+;------------------------------------------------------------------------------
+
+ .686
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; UINT64
+; EFIAPI
+; InternalMathLRotU64 (
+; IN UINT64 Operand,
+; IN UINTN Count
+; );
+;------------------------------------------------------------------------------
+InternalMathLRotU64 PROC USES ebx
+ mov cl, [esp + 16]
+ mov edx, [esp + 12]
+ mov eax, [esp + 8]
+ shld ebx, edx, cl
+ shld edx, eax, cl
+ ror ebx, cl
+ shld eax, ebx, cl
+ test cl, 32 ; Count >= 32?
+ cmovnz ecx, eax
+ cmovnz eax, edx
+ cmovnz edx, ecx
+ ret
+InternalMathLRotU64 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/LShiftU64.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/LShiftU64.asm
new file mode 100644
index 0000000..4b71204
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/LShiftU64.asm
@@ -0,0 +1,44 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; LShiftU64.asm
+;
+; Abstract:
+;
+; 64-bit left shift function for IA-32
+;
+;------------------------------------------------------------------------------
+
+ .686
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; UINT64
+; EFIAPI
+; InternalMathLShiftU64 (
+; IN UINT64 Operand,
+; IN UINTN Count
+; );
+;------------------------------------------------------------------------------
+InternalMathLShiftU64 PROC
+ mov cl, [esp + 12]
+ xor eax, eax
+ mov edx, [esp + 4]
+ test cl, 32 ; Count >= 32?
+ cmovz eax, edx
+ cmovz edx, [esp + 8]
+ shld edx, eax, cl
+ shl eax, cl
+ ret
+InternalMathLShiftU64 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/LongJump.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/LongJump.asm
new file mode 100644
index 0000000..5a46082
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/LongJump.asm
@@ -0,0 +1,44 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; LongJump.Asm
+;
+; Abstract:
+;
+; Implementation of _LongJump() on IA-32.
+;
+;------------------------------------------------------------------------------
+
+ .386
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; VOID
+; EFIAPI
+; InternalLongJump (
+; IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer,
+; IN UINTN Value
+; );
+;------------------------------------------------------------------------------
+InternalLongJump PROC
+ pop eax ; skip return address
+ pop edx ; edx <- JumpBuffer
+ pop eax ; eax <- Value
+ mov ebx, [edx]
+ mov esi, [edx + 4]
+ mov edi, [edx + 8]
+ mov ebp, [edx + 12]
+ mov esp, [edx + 16]
+ jmp dword ptr [edx + 20]
+InternalLongJump ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ModU64x32.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ModU64x32.asm
new file mode 100644
index 0000000..db06549
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ModU64x32.asm
@@ -0,0 +1,43 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; DivU64x32.asm
+;
+; Abstract:
+;
+; Calculate the remainder of a 64-bit integer by a 32-bit integer
+;
+;------------------------------------------------------------------------------
+
+ .386
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; UINT32
+; EFIAPI
+; InternalMathModU64x32 (
+; IN UINT64 Dividend,
+; IN UINT32 Divisor
+; );
+;------------------------------------------------------------------------------
+InternalMathModU64x32 PROC
+ mov eax, [esp + 8]
+ mov ecx, [esp + 12]
+ xor edx, edx
+ div ecx
+ mov eax, [esp + 4]
+ div ecx
+ mov eax, edx
+ ret
+InternalMathModU64x32 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Monitor.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Monitor.asm
new file mode 100644
index 0000000..f06048c
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Monitor.asm
@@ -0,0 +1,43 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; Monitor.Asm
+;
+; Abstract:
+;
+; AsmMonitor function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .686
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; UINTN
+; EFIAPI
+; AsmMonitor (
+; IN UINTN Eax,
+; IN UINTN Ecx,
+; IN UINTN Edx
+; );
+;------------------------------------------------------------------------------
+AsmMonitor PROC
+ mov eax, [esp + 4]
+ mov ecx, [esp + 8]
+ mov edx, [esp + 12]
+ DB 0fh, 1, 0c8h ; monitor
+ ret
+AsmMonitor ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/MultU64x32.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/MultU64x32.asm
new file mode 100644
index 0000000..c8970ec
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/MultU64x32.asm
@@ -0,0 +1,41 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; MultU64x32.asm
+;
+; Abstract:
+;
+; Calculate the product of a 64-bit integer and a 32-bit integer
+;
+;------------------------------------------------------------------------------
+
+ .386
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; UINT64
+; EFIAPI
+; InternalMathMultU64x32 (
+; IN UINT64 Multiplicand,
+; IN UINT32 Multiplier
+; );
+;------------------------------------------------------------------------------
+InternalMathMultU64x32 PROC
+ mov ecx, [esp + 12]
+ mov eax, ecx
+ imul ecx, [esp + 8] ; overflow not detectable
+ mul dword ptr [esp + 4]
+ add edx, ecx
+ ret
+InternalMathMultU64x32 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/MultU64x64.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/MultU64x64.asm
new file mode 100644
index 0000000..7d6acae
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/MultU64x64.asm
@@ -0,0 +1,45 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; MultU64x64.asm
+;
+; Abstract:
+;
+; Calculate the product of a 64-bit integer and another 64-bit integer
+;
+;------------------------------------------------------------------------------
+
+ .386
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; UINT64
+; EFIAPI
+; InternalMathMultU64x64 (
+; IN UINT64 Multiplicand,
+; IN UINT64 Multiplier
+; );
+;------------------------------------------------------------------------------
+InternalMathMultU64x64 PROC USES ebx
+ mov ebx, [esp + 8]
+ mov edx, [esp + 16]
+ mov ecx, ebx
+ mov eax, edx
+ imul ebx, [esp + 20]
+ imul edx, [esp + 12]
+ add ebx, edx
+ mul ecx
+ add edx, ebx
+ ret
+InternalMathMultU64x64 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Mwait.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Mwait.asm
new file mode 100644
index 0000000..0e97013
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Mwait.asm
@@ -0,0 +1,41 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; Mwait.Asm
+;
+; Abstract:
+;
+; AsmMwait function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .686
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; UINTN
+; EFIAPI
+; AsmMwait (
+; IN UINTN Eax,
+; IN UINTN Ecx
+; );
+;------------------------------------------------------------------------------
+AsmMwait PROC
+ mov eax, [esp + 4]
+ mov ecx, [esp + 8]
+ DB 0fh, 1, 0c9h ; mwait
+ ret
+AsmMwait ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Non-existing.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Non-existing.c
new file mode 100644
index 0000000..e0c32c1
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Non-existing.c
@@ -0,0 +1,66 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ Non-existing.c
+
+Abstract:
+
+ Non-existing BaseLib functions on Ia32
+
+--*/
+
+#include "..\BaseLibInternal.h"
+
+
+/**
+ Disables the 64-bit paging mode on the CPU.
+
+ Disables the 64-bit paging mode on the CPU and returns to 32-bit protected
+ mode. This function assumes the current execution mode is 64-paging mode.
+ This function is only available on X64. After the 64-bit paging mode is
+ disabled, control is transferred to the function specified by EntryPoint
+ using the new stack specified by NewStack and passing in the parameters
+ specified by Context1 and Context2. Context1 and Context2 are optional and
+ may be 0. The function EntryPoint must never return.
+
+ @param Cs The 16-bit selector to load in the CS before EntryPoint
+ is called. The descriptor in the GDT that this selector
+ references must be setup for 32-bit protected mode.
+ @param EntryPoint The 64-bit virtual address of the function to call with
+ the new stack after paging is disabled.
+ @param Context1 The 64-bit virtual address of the context to pass into
+ the EntryPoint function as the first parameter after
+ paging is disabled.
+ @param Context2 The 64-bit virtual address of the context to pass into
+ the EntryPoint function as the second parameter after
+ paging is disabled.
+ @param NewStack The 64-bit virtual address of the new stack to use for
+ the EntryPoint function after paging is disabled.
+
+**/
+VOID
+EFIAPI
+InternalX86DisablePaging64 (
+ IN UINT16 CodeSelector,
+ IN UINT32 EntryPoint,
+ IN UINT32 Context1, OPTIONAL
+ IN UINT32 Context2, OPTIONAL
+ IN UINT32 NewStack
+ )
+{
+ //
+ // This function cannot work on IA32 platform
+ //
+ ASSERT (FALSE);
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/RRotU64.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/RRotU64.asm
new file mode 100644
index 0000000..5cac1ba
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/RRotU64.asm
@@ -0,0 +1,47 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; RRotU64.asm
+;
+; Abstract:
+;
+; 64-bit right rotation for Ia32
+;
+;------------------------------------------------------------------------------
+
+ .686
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; UINT64
+; EFIAPI
+; InternalMathRRotU64 (
+; IN UINT64 Operand,
+; IN UINTN Count
+; );
+;------------------------------------------------------------------------------
+InternalMathRRotU64 PROC USES ebx
+ mov cl, [esp + 16]
+ mov eax, [esp + 8]
+ mov edx, [esp + 12]
+ shrd ebx, eax, cl
+ shrd eax, edx, cl
+ rol ebx, cl
+ shrd edx, ebx, cl
+ test cl, 32 ; Count >= 32?
+ cmovnz ecx, eax
+ cmovnz eax, edx
+ cmovnz edx, ecx
+ ret
+InternalMathRRotU64 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/RShiftU64.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/RShiftU64.asm
new file mode 100644
index 0000000..3b4b45c
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/RShiftU64.asm
@@ -0,0 +1,44 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; RShiftU64.asm
+;
+; Abstract:
+;
+; 64-bit logical right shift function for IA-32
+;
+;------------------------------------------------------------------------------
+
+ .686
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; UINT64
+; EFIAPI
+; InternalMathRShiftU64 (
+; IN UINT64 Operand,
+; IN UINTN Count
+; );
+;------------------------------------------------------------------------------
+InternalMathRShiftU64 PROC
+ mov cl, [esp + 12]
+ xor edx, edx
+ mov eax, [esp + 8]
+ test cl, 32
+ cmovz edx, eax
+ cmovz eax, [esp + 4]
+ shrd eax, edx, cl
+ shr edx, cl
+ ret
+InternalMathRShiftU64 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadCr0.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadCr0.asm
new file mode 100644
index 0000000..39b9f92
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadCr0.asm
@@ -0,0 +1,38 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ReadCr0.Asm
+;
+; Abstract:
+;
+; AsmReadCr0 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .386p
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; UINTN
+; EFIAPI
+; AsmReadCr0 (
+; VOID
+; );
+;------------------------------------------------------------------------------
+AsmReadCr0 PROC
+ mov eax, cr0
+ ret
+AsmReadCr0 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadCr2.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadCr2.asm
new file mode 100644
index 0000000..22cd069
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadCr2.asm
@@ -0,0 +1,38 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ReadCr2.Asm
+;
+; Abstract:
+;
+; AsmReadCr2 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .386p
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; UINTN
+; EFIAPI
+; AsmReadCr2 (
+; VOID
+; );
+;------------------------------------------------------------------------------
+AsmReadCr2 PROC
+ mov eax, cr2
+ ret
+AsmReadCr2 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadCr3.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadCr3.asm
new file mode 100644
index 0000000..56f0103
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadCr3.asm
@@ -0,0 +1,38 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ReadCr3.Asm
+;
+; Abstract:
+;
+; AsmReadCr3 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .386p
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; UINTN
+; EFIAPI
+; AsmReadCr3 (
+; VOID
+; );
+;------------------------------------------------------------------------------
+AsmReadCr3 PROC
+ mov eax, cr3
+ ret
+AsmReadCr3 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadCr4.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadCr4.asm
new file mode 100644
index 0000000..61832ed
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadCr4.asm
@@ -0,0 +1,38 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ReadCr4.Asm
+;
+; Abstract:
+;
+; AsmReadCr4 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .586p
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; UINTN
+; EFIAPI
+; AsmReadCr4 (
+; VOID
+; );
+;------------------------------------------------------------------------------
+AsmReadCr4 PROC
+ mov eax, cr4
+ ret
+AsmReadCr4 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadCs.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadCs.asm
new file mode 100644
index 0000000..a7f189e
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadCs.asm
@@ -0,0 +1,38 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ReadCs.Asm
+;
+; Abstract:
+;
+; AsmReadCs function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .386
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; UINT16
+; EFIAPI
+; AsmReadCs (
+; VOID
+; );
+;------------------------------------------------------------------------------
+AsmReadCs PROC
+ mov eax, cs
+ ret
+AsmReadCs ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr0.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr0.asm
new file mode 100644
index 0000000..b9d1fbb
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr0.asm
@@ -0,0 +1,38 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ReadDr0.Asm
+;
+; Abstract:
+;
+; AsmReadDr0 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .586p
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; UINTN
+; EFIAPI
+; AsmReadDr0 (
+; VOID
+; );
+;------------------------------------------------------------------------------
+AsmReadDr0 PROC
+ mov eax, dr0
+ ret
+AsmReadDr0 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr1.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr1.asm
new file mode 100644
index 0000000..f7367d9
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr1.asm
@@ -0,0 +1,38 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ReadDr1.Asm
+;
+; Abstract:
+;
+; AsmReadDr1 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .586p
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; UINTN
+; EFIAPI
+; AsmReadDr1 (
+; VOID
+; );
+;------------------------------------------------------------------------------
+AsmReadDr1 PROC
+ mov eax, dr1
+ ret
+AsmReadDr1 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr2.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr2.asm
new file mode 100644
index 0000000..04c55f4
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr2.asm
@@ -0,0 +1,38 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ReadDr2.Asm
+;
+; Abstract:
+;
+; AsmReadDr2 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .586p
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; UINTN
+; EFIAPI
+; AsmReadDr2 (
+; VOID
+; );
+;------------------------------------------------------------------------------
+AsmReadDr2 PROC
+ mov eax, dr2
+ ret
+AsmReadDr2 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr3.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr3.asm
new file mode 100644
index 0000000..50a96ff
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr3.asm
@@ -0,0 +1,38 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ReadDr3.Asm
+;
+; Abstract:
+;
+; AsmReadDr3 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .586p
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; UINTN
+; EFIAPI
+; AsmReadDr3 (
+; VOID
+; );
+;------------------------------------------------------------------------------
+AsmReadDr3 PROC
+ mov eax, dr3
+ ret
+AsmReadDr3 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr4.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr4.asm
new file mode 100644
index 0000000..2e822e5
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr4.asm
@@ -0,0 +1,38 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ReadDr4.Asm
+;
+; Abstract:
+;
+; AsmReadDr4 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .586p
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; UINTN
+; EFIAPI
+; AsmReadDr4 (
+; VOID
+; );
+;------------------------------------------------------------------------------
+AsmReadDr4 PROC
+ DB 0fh, 21h, 0e0h
+ ret
+AsmReadDr4 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr5.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr5.asm
new file mode 100644
index 0000000..fec5b2b
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr5.asm
@@ -0,0 +1,38 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ReadDr5.Asm
+;
+; Abstract:
+;
+; AsmReadDr5 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .586p
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; UINTN
+; EFIAPI
+; AsmReadDr5 (
+; VOID
+; );
+;------------------------------------------------------------------------------
+AsmReadDr5 PROC
+ DB 0fh, 21h, 0e8h
+ ret
+AsmReadDr5 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr6.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr6.asm
new file mode 100644
index 0000000..09cbb15
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr6.asm
@@ -0,0 +1,38 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ReadDr6.Asm
+;
+; Abstract:
+;
+; AsmReadDr6 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .586p
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; UINTN
+; EFIAPI
+; AsmReadDr6 (
+; VOID
+; );
+;------------------------------------------------------------------------------
+AsmReadDr6 PROC
+ mov eax, dr6
+ ret
+AsmReadDr6 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr7.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr7.asm
new file mode 100644
index 0000000..aab8a8f
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDr7.asm
@@ -0,0 +1,38 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ReadDr7.Asm
+;
+; Abstract:
+;
+; AsmReadDr7 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .586p
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; UINTN
+; EFIAPI
+; AsmReadDr7 (
+; VOID
+; );
+;------------------------------------------------------------------------------
+AsmReadDr7 PROC
+ mov eax, dr7
+ ret
+AsmReadDr7 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDs.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDs.asm
new file mode 100644
index 0000000..ca942b8
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadDs.asm
@@ -0,0 +1,38 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ReadDs.Asm
+;
+; Abstract:
+;
+; AsmReadDs function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .386
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; UINT16
+; EFIAPI
+; AsmReadDs (
+; VOID
+; );
+;------------------------------------------------------------------------------
+AsmReadDs PROC
+ mov eax, ds
+ ret
+AsmReadDs ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadEflags.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadEflags.asm
new file mode 100644
index 0000000..8ef9ec3
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadEflags.asm
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ReadEflags.Asm
+;
+; Abstract:
+;
+; AsmReadEflags function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .386
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; UINTN
+; EFIAPI
+; AsmReadEflags (
+; VOID
+; );
+;------------------------------------------------------------------------------
+AsmReadEflags PROC
+ pushfd
+ pop eax
+ ret
+AsmReadEflags ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadEs.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadEs.asm
new file mode 100644
index 0000000..4c0d3b7
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadEs.asm
@@ -0,0 +1,38 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ReadEs.Asm
+;
+; Abstract:
+;
+; AsmReadEs function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .386
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; UINT16
+; EFIAPI
+; AsmReadEs (
+; VOID
+; );
+;------------------------------------------------------------------------------
+AsmReadEs PROC
+ mov eax, es
+ ret
+AsmReadEs ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadFs.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadFs.asm
new file mode 100644
index 0000000..7e54318
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadFs.asm
@@ -0,0 +1,38 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ReadFs.Asm
+;
+; Abstract:
+;
+; AsmReadFs function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .386
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; UINT16
+; EFIAPI
+; AsmReadFs (
+; VOID
+; );
+;------------------------------------------------------------------------------
+AsmReadFs PROC
+ mov eax, fs
+ ret
+AsmReadFs ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadGdtr.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadGdtr.asm
new file mode 100644
index 0000000..9cf0314
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadGdtr.asm
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ReadGdtr.Asm
+;
+; Abstract:
+;
+; AsmReadGdtr function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .386
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; VOID
+; EFIAPI
+; InternalX86ReadGdtr (
+; OUT IA32_DESCRIPTOR *Gdtr
+; );
+;------------------------------------------------------------------------------
+InternalX86ReadGdtr PROC
+ mov eax, [esp + 4]
+ sgdt fword ptr [eax]
+ ret
+InternalX86ReadGdtr ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadGs.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadGs.asm
new file mode 100644
index 0000000..40e9531
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadGs.asm
@@ -0,0 +1,38 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ReadGs.Asm
+;
+; Abstract:
+;
+; AsmReadGs function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .386
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; UINT16
+; EFIAPI
+; AsmReadGs (
+; VOID
+; );
+;------------------------------------------------------------------------------
+AsmReadGs PROC
+ mov eax, gs
+ ret
+AsmReadGs ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadIdtr.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadIdtr.asm
new file mode 100644
index 0000000..e459392
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadIdtr.asm
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ReadIdtr.Asm
+;
+; Abstract:
+;
+; AsmReadIdtr function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .386
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; VOID
+; EFIAPI
+; InternalX86ReadIdtr (
+; OUT IA32_DESCRIPTOR *Idtr
+; );
+;------------------------------------------------------------------------------
+InternalX86ReadIdtr PROC
+ mov eax, [esp + 4]
+ sidt fword ptr [eax]
+ ret
+InternalX86ReadIdtr ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadLdtr.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadLdtr.asm
new file mode 100644
index 0000000..0097adc
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadLdtr.asm
@@ -0,0 +1,38 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ReadLdtr.Asm
+;
+; Abstract:
+;
+; AsmReadLdtr function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .386
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; UINT16
+; EFIAPI
+; AsmReadLdtr (
+; VOID
+; );
+;------------------------------------------------------------------------------
+AsmReadLdtr PROC
+ sldt ax
+ ret
+AsmReadLdtr ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm0.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm0.asm
new file mode 100644
index 0000000..b5098af
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm0.asm
@@ -0,0 +1,43 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ReadMm0.Asm
+;
+; Abstract:
+;
+; AsmReadMm0 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .586
+ .model flat,C
+ .mmx
+ .code
+
+;------------------------------------------------------------------------------
+; UINT64
+; EFIAPI
+; AsmReadMm0 (
+; VOID
+; );
+;------------------------------------------------------------------------------
+AsmReadMm0 PROC
+ push eax
+ push eax
+ movq [esp], mm0
+ pop eax
+ pop edx
+ ret
+AsmReadMm0 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm1.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm1.asm
new file mode 100644
index 0000000..ac67159
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm1.asm
@@ -0,0 +1,43 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ReadMm1.Asm
+;
+; Abstract:
+;
+; AsmReadMm1 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .586
+ .model flat,C
+ .mmx
+ .code
+
+;------------------------------------------------------------------------------
+; UINT64
+; EFIAPI
+; AsmReadMm1 (
+; VOID
+; );
+;------------------------------------------------------------------------------
+AsmReadMm1 PROC
+ push eax
+ push eax
+ movq [esp], mm1
+ pop eax
+ pop edx
+ ret
+AsmReadMm1 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm2.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm2.asm
new file mode 100644
index 0000000..fed7997
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm2.asm
@@ -0,0 +1,43 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ReadMm2.Asm
+;
+; Abstract:
+;
+; AsmReadMm2 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .586
+ .model flat,C
+ .mmx
+ .code
+
+;------------------------------------------------------------------------------
+; UINT64
+; EFIAPI
+; AsmReadMm2 (
+; VOID
+; );
+;------------------------------------------------------------------------------
+AsmReadMm2 PROC
+ push eax
+ push eax
+ movq [esp], mm2
+ pop eax
+ pop edx
+ ret
+AsmReadMm2 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm3.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm3.asm
new file mode 100644
index 0000000..3a230b1
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm3.asm
@@ -0,0 +1,43 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ReadMm3.Asm
+;
+; Abstract:
+;
+; AsmReadMm3 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .586
+ .model flat,C
+ .mmx
+ .code
+
+;------------------------------------------------------------------------------
+; UINT64
+; EFIAPI
+; AsmReadMm3 (
+; VOID
+; );
+;------------------------------------------------------------------------------
+AsmReadMm3 PROC
+ push eax
+ push eax
+ movq [esp], mm3
+ pop eax
+ pop edx
+ ret
+AsmReadMm3 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm4.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm4.asm
new file mode 100644
index 0000000..f71ed15
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm4.asm
@@ -0,0 +1,43 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ReadMm4.Asm
+;
+; Abstract:
+;
+; AsmReadMm4 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .586
+ .model flat,C
+ .mmx
+ .code
+
+;------------------------------------------------------------------------------
+; UINT64
+; EFIAPI
+; AsmReadMm4 (
+; VOID
+; );
+;------------------------------------------------------------------------------
+AsmReadMm4 PROC
+ push eax
+ push eax
+ movq [esp], mm4
+ pop eax
+ pop edx
+ ret
+AsmReadMm4 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm5.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm5.asm
new file mode 100644
index 0000000..47a4f62
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm5.asm
@@ -0,0 +1,43 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ReadMm5.Asm
+;
+; Abstract:
+;
+; AsmReadMm5 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .586
+ .model flat,C
+ .mmx
+ .code
+
+;------------------------------------------------------------------------------
+; UINT64
+; EFIAPI
+; AsmReadMm5 (
+; VOID
+; );
+;------------------------------------------------------------------------------
+AsmReadMm5 PROC
+ push eax
+ push eax
+ movq [esp], mm5
+ pop eax
+ pop edx
+ ret
+AsmReadMm5 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm6.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm6.asm
new file mode 100644
index 0000000..cd450a5
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm6.asm
@@ -0,0 +1,43 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ReadMm6.Asm
+;
+; Abstract:
+;
+; AsmReadMm6 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .586
+ .model flat,C
+ .mmx
+ .code
+
+;------------------------------------------------------------------------------
+; UINT64
+; EFIAPI
+; AsmReadMm6 (
+; VOID
+; );
+;------------------------------------------------------------------------------
+AsmReadMm6 PROC
+ push eax
+ push eax
+ movq [esp], mm6
+ pop eax
+ pop edx
+ ret
+AsmReadMm6 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm7.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm7.asm
new file mode 100644
index 0000000..1460c85
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMm7.asm
@@ -0,0 +1,43 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ReadMm7.Asm
+;
+; Abstract:
+;
+; AsmReadMm7 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .586
+ .model flat,C
+ .mmx
+ .code
+
+;------------------------------------------------------------------------------
+; UINT64
+; EFIAPI
+; AsmReadMm7 (
+; VOID
+; );
+;------------------------------------------------------------------------------
+AsmReadMm7 PROC
+ push eax
+ push eax
+ movq [esp], mm7
+ pop eax
+ pop edx
+ ret
+AsmReadMm7 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMsr64.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMsr64.asm
new file mode 100644
index 0000000..003d8b5
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadMsr64.asm
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ReadMsr64.Asm
+;
+; Abstract:
+;
+; AsmReadMsr64 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .586p
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; UINT64
+; EFIAPI
+; AsmReadMsr64 (
+; IN UINT64 Index
+; );
+;------------------------------------------------------------------------------
+AsmReadMsr64 PROC
+ mov ecx, [esp + 4]
+ rdmsr
+ ret
+AsmReadMsr64 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadPmc.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadPmc.asm
new file mode 100644
index 0000000..e51dee1
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadPmc.asm
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ReadPmc.Asm
+;
+; Abstract:
+;
+; AsmReadPmc function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .586p
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; UINT64
+; EFIAPI
+; AsmReadPmc (
+; IN UINT32 PmcIndex
+; );
+;------------------------------------------------------------------------------
+AsmReadPmc PROC
+ mov ecx, [esp + 4]
+ rdpmc
+ ret
+AsmReadPmc ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadSs.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadSs.asm
new file mode 100644
index 0000000..741ed42
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadSs.asm
@@ -0,0 +1,38 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ReadSs.Asm
+;
+; Abstract:
+;
+; AsmReadSs function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .386
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; UINT16
+; EFIAPI
+; AsmReadSs (
+; VOID
+; );
+;------------------------------------------------------------------------------
+AsmReadSs PROC
+ mov eax, ss
+ ret
+AsmReadSs ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadTr.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadTr.asm
new file mode 100644
index 0000000..6f2060c
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadTr.asm
@@ -0,0 +1,38 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ReadTr.Asm
+;
+; Abstract:
+;
+; AsmReadTr function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .386
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; UINT16
+; EFIAPI
+; AsmReadTr (
+; VOID
+; );
+;------------------------------------------------------------------------------
+AsmReadTr PROC
+ str ax
+ ret
+AsmReadTr ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadTsc.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadTsc.asm
new file mode 100644
index 0000000..ab75959
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/ReadTsc.asm
@@ -0,0 +1,38 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ReadTsc.Asm
+;
+; Abstract:
+;
+; AsmReadTsc function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .586p
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; UINT64
+; EFIAPI
+; AsmReadTsc (
+; VOID
+; );
+;------------------------------------------------------------------------------
+AsmReadTsc PROC
+ rdtsc
+ ret
+AsmReadTsc ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/SetJump.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/SetJump.asm
new file mode 100644
index 0000000..39c81e9
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/SetJump.asm
@@ -0,0 +1,49 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; SetJump.Asm
+;
+; Abstract:
+;
+; Implementation of SetJump() on IA-32.
+;
+;------------------------------------------------------------------------------
+
+ .386
+ .model flat,C
+ .code
+
+InternalAssertJumpBuffer PROTO C
+
+;------------------------------------------------------------------------------
+; UINTN
+; EFIAPI
+; SetJump (
+; OUT BASE_LIBRARY_JUMP_BUFFER *JumpBuffer
+; );
+;------------------------------------------------------------------------------
+SetJump PROC
+ push [esp + 4]
+ call InternalAssertJumpBuffer
+ pop ecx
+ pop ecx
+ mov edx, [esp]
+ mov [edx], ebx
+ mov [edx + 4], esi
+ mov [edx + 8], edi
+ mov [edx + 12], ebp
+ mov [edx + 16], esp
+ mov [edx + 20], ecx
+ xor eax, eax
+ jmp ecx
+SetJump ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/SwapBytes64.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/SwapBytes64.asm
new file mode 100644
index 0000000..679973d
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/SwapBytes64.asm
@@ -0,0 +1,41 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; CpuId.Asm
+;
+; Abstract:
+;
+; AsmCpuid function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .586
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; UINT64
+; EFIAPI
+; InternalMathSwapBytes64 (
+; IN UINT64 Operand
+; );
+;------------------------------------------------------------------------------
+InternalMathSwapBytes64 PROC
+ mov eax, [esp + 8]
+ mov edx, [esp + 4]
+ bswap eax
+ bswap edx
+ ret
+InternalMathSwapBytes64 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Thunk16.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Thunk16.asm
new file mode 100644
index 0000000..3223d53
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Thunk16.asm
@@ -0,0 +1,241 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; Thunk.asm
+;
+; Abstract:
+;
+; Real mode thunk
+;
+;------------------------------------------------------------------------------
+
+ .686p
+ .model flat,C
+
+EXTERNDEF C m16Start:BYTE
+EXTERNDEF C m16Size:WORD
+EXTERNDEF C mThunk16Attr:WORD
+EXTERNDEF C m16Gdt:WORD
+EXTERNDEF C m16GdtrBase:WORD
+EXTERNDEF C mTransition:WORD
+
+THUNK_ATTRIBUTE_BIG_REAL_MODE EQU 1
+THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 EQU 2
+THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL EQU 4
+
+;
+; Here is the layout of the real mode stack. _ToUserCode() is responsible for
+; loading all these registers from real mode stack.
+;
+IA32_REGS STRUC 4t
+_EDI DD ?
+_ESI DD ?
+_EBP DD ?
+_ESP DD ?
+_EBX DD ?
+_EDX DD ?
+_ECX DD ?
+_EAX DD ?
+_DS DW ?
+_ES DW ?
+_FS DW ?
+_GS DW ?
+_EFLAGS DD ?
+_EIP DD ?
+_CS DW ?
+_SS DW ?
+IA32_REGS ENDS
+
+ .const
+
+;
+; These are global constant to convey information to C code.
+;
+m16Size DW InternalAsmThunk16 - m16Start
+mThunk16Attr DW _ThunkAttr - m16Start
+m16Gdt DW _NullSegDesc - m16Start
+m16GdtrBase DW _16GdtrBase - m16Start
+mTransition DW _EntryPoint - m16Start
+
+ .code
+
+m16Start LABEL BYTE
+
+SavedGdt LABEL FWORD
+ DW ?
+ DD ?
+;------------------------------------------------------------------------------
+; _BackFromUserCode() takes control in real mode after 'retf' has been executed
+; by user code. It will be shadowed to somewhere in memory below 1MB.
+;------------------------------------------------------------------------------
+_BackFromUserCode PROC
+ push ss
+ push cs
+ DB 66h
+ call @Base ; push eip
+@Base:
+ pushf ; pushfd actually
+ cli ; disable interrupts
+ push gs
+ push fs
+ push es
+ push ds
+ pushaw ; pushad actually
+ DB 66h, 0bah ; mov edx, imm32
+_ThunkAttr DD ?
+ test dl, THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15
+ jz @1
+ mov eax, 15cd2401h ; mov ax, 2401h & int 15h
+ cli ; disable interrupts
+ jnc @2
+@1:
+ test dl, THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL
+ jz @2
+ in al, 92h
+ or al, 2
+ out 92h, al ; deactivate A20M#
+@2:
+ xor ax, ax ; xor eax, eax
+ mov eax, ss
+ DB 67h
+ lea bp, [esp + sizeof (IA32_REGS)]
+ mov word ptr (IA32_REGS ptr [esi - sizeof (IA32_REGS)])._ESP, bp
+ mov ebx, (IA32_REGS ptr [esi - sizeof (IA32_REGS)])._EIP
+ shl ax, 4 ; shl eax, 4
+ add bp, ax ; add ebp, eax
+ DB 66h, 0b8h ; mov eax, imm32
+SavedCr4 DD ?
+ mov cr4, eax
+ DB 66h
+ lgdt fword ptr cs:[edi + (SavedGdt - @Base)]
+ DB 66h, 0b8h ; mov eax, imm32
+SavedCr0 DD ?
+ mov cr0, eax
+ DB 0b8h ; mov ax, imm16
+SavedSs DW ?
+ mov ss, eax
+ DB 66h, 0bch ; mov esp, imm32
+SavedEsp DD ?
+ DB 66h
+ retf ; return to protected mode
+_BackFromUserCode ENDP
+
+_EntryPoint DD _ToUserCode - m16Start
+ DW 8h
+_16Idtr FWORD (1 SHL 10) - 1
+_16Gdtr LABEL FWORD
+ DW GdtEnd - _NullSegDesc - 1
+_16GdtrBase DD _NullSegDesc
+
+;------------------------------------------------------------------------------
+; _ToUserCode() takes control in real mode before passing control to user code.
+; It will be shadowed to somewhere in memory below 1MB.
+;------------------------------------------------------------------------------
+_ToUserCode PROC
+ mov edx, ss
+ mov ss, ecx ; set new segment selectors
+ mov ds, ecx
+ mov es, ecx
+ mov fs, ecx
+ mov gs, ecx
+ mov cr0, eax
+ mov cr4, ebp ; real mode starts at next instruction
+ mov ss, esi ; set up 16-bit stack segment
+ xchg sp, bx ; set up 16-bit stack pointer
+ DB 66h
+ call @Base ; push eip
+@Base:
+ pop bp ; ebp <- address of @Base
+ DB 67h ; address size override
+ push [esp + sizeof (IA32_REGS) + 2]
+ lea eax, [esi + (@RealMode - @Base)]
+ push eax
+ retf
+@RealMode:
+ mov cs:[esi + (SavedSs - @Base)], edx
+ mov cs:[esi + (SavedEsp - @Base)], bx
+ DB 66h
+ lidt fword ptr cs:[esi + (_16Idtr - @Base)]
+ popaw ; popad actually
+ pop ds
+ pop es
+ pop fs
+ pop gs
+ popf ; popfd
+ DB 66h
+ retf ; transfer control to user code
+_ToUserCode ENDP
+
+_NullSegDesc DQ 0
+_16CsDesc LABEL QWORD
+ DW -1
+ DW 0
+ DB 0
+ DB 9bh
+ DB 8fh ; 16-bit segment, 4GB limit
+ DB 0
+_16DsDesc LABEL QWORD
+ DW -1
+ DW 0
+ DB 0
+ DB 93h
+ DB 8fh ; 16-bit segment, 4GB limit
+ DB 0
+GdtEnd LABEL QWORD
+
+;------------------------------------------------------------------------------
+; IA32_REGISTER_SET *
+; EFIAPI
+; InternalAsmThunk16 (
+; IN IA32_REGISTER_SET *RegisterSet,
+; IN OUT VOID *Transition
+; );
+;------------------------------------------------------------------------------
+InternalAsmThunk16 PROC USES ebp ebx esi edi ds es fs gs
+ mov esi, [esp + 36] ; esi <- RegSet
+ movzx edx, (IA32_REGS ptr [esi])._SS
+ mov edi, (IA32_REGS ptr [esi])._ESP
+ add edi, - (sizeof (IA32_REGS) + 4) ; reserve stack space
+ mov ebx, edi ; ebx <- stack offset
+ imul eax, edx, 16 ; eax <- edx * 16
+ push sizeof (IA32_REGS) / 4
+ add edi, eax ; edi <- linear address of 16-bit stack
+ pop ecx
+ rep movsd ; copy RegSet
+ mov eax, [esp + 40] ; eax <- address of transition code
+ mov esi, edx ; esi <- 16-bit stack segment
+ lea edx, [eax + (SavedCr0 - m16Start)]
+ mov ecx, eax
+ and ecx, 0fh
+ shl eax, 12
+ lea ecx, [ecx + (_BackFromUserCode - m16Start)]
+ mov ax, cx
+ stosd ; [edi] <- return address of user code
+ sgdt fword ptr [edx + (SavedGdt - SavedCr0)]
+ sidt fword ptr [esp + 36] ; save IDT stack in argument space
+ mov eax, cr0
+ mov [edx], eax ; save CR0 in SavedCr0
+ and eax, 7ffffffeh ; clear PE, PG bits
+ mov ebp, cr4
+ mov [edx + (SavedCr4 - SavedCr0)], ebp
+ and ebp, 300h ; clear all but PCE and OSFXSR bits
+ push 10h
+ pop ecx ; ecx <- selector for data segments
+ lgdt fword ptr [edx + (_16Gdtr - SavedCr0)]
+ pushfd
+ call fword ptr [edx + (_EntryPoint - SavedCr0)]
+ popfd
+ lidt fword ptr [esp + 36] ; restore protected mode IDTR
+ lea eax, [ebp - sizeof (IA32_REGS)]
+ ret
+InternalAsmThunk16 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Wbinvd.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Wbinvd.asm
new file mode 100644
index 0000000..629c66b
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/Wbinvd.asm
@@ -0,0 +1,38 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; Wbinvd.Asm
+;
+; Abstract:
+;
+; AsmWbinvd function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .486p
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; VOID
+; EFIAPI
+; AsmWbinvd (
+; VOID
+; );
+;------------------------------------------------------------------------------
+AsmWbinvd PROC
+ wbinvd
+ ret
+AsmWbinvd ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteCr0.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteCr0.asm
new file mode 100644
index 0000000..01b05ff
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteCr0.asm
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; WriteCr0.Asm
+;
+; Abstract:
+;
+; AsmWriteCr0 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .386p
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; UINTN
+; EFIAPI
+; AsmWriteCr0 (
+; UINTN Cr0
+; );
+;------------------------------------------------------------------------------
+AsmWriteCr0 PROC
+ mov eax, [esp + 4]
+ mov cr0, eax
+ ret
+AsmWriteCr0 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteCr2.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteCr2.asm
new file mode 100644
index 0000000..5506636
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteCr2.asm
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; WriteCr2.Asm
+;
+; Abstract:
+;
+; AsmWriteCr2 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .386p
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; UINTN
+; EFIAPI
+; AsmWriteCr2 (
+; UINTN Cr2
+; );
+;------------------------------------------------------------------------------
+AsmWriteCr2 PROC
+ mov eax, [esp + 4]
+ mov cr2, eax
+ ret
+AsmWriteCr2 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteCr3.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteCr3.asm
new file mode 100644
index 0000000..01faffe
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteCr3.asm
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; WriteCr3.Asm
+;
+; Abstract:
+;
+; AsmWriteCr3 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .386p
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; UINTN
+; EFIAPI
+; AsmWriteCr3 (
+; UINTN Cr3
+; );
+;------------------------------------------------------------------------------
+AsmWriteCr3 PROC
+ mov eax, [esp + 4]
+ mov cr3, eax
+ ret
+AsmWriteCr3 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteCr4.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteCr4.asm
new file mode 100644
index 0000000..8469cf5
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteCr4.asm
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; WriteCr4.Asm
+;
+; Abstract:
+;
+; AsmWriteCr4 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .586p
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; UINTN
+; EFIAPI
+; AsmWriteCr4 (
+; UINTN Cr4
+; );
+;------------------------------------------------------------------------------
+AsmWriteCr4 PROC
+ mov eax, [esp + 4]
+ mov cr4, eax
+ ret
+AsmWriteCr4 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr0.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr0.asm
new file mode 100644
index 0000000..0b2dce9
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr0.asm
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; WriteDr0.Asm
+;
+; Abstract:
+;
+; AsmWriteDr0 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .586p
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; UINTN
+; EFIAPI
+; AsmWriteDr0 (
+; IN UINTN Value
+; );
+;------------------------------------------------------------------------------
+AsmWriteDr0 PROC
+ mov eax, [esp + 4]
+ mov dr0, eax
+ ret
+AsmWriteDr0 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr1.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr1.asm
new file mode 100644
index 0000000..3f27325
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr1.asm
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; WriteDr1.Asm
+;
+; Abstract:
+;
+; AsmWriteDr1 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .586p
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; UINTN
+; EFIAPI
+; AsmWriteDr1 (
+; IN UINTN Value
+; );
+;------------------------------------------------------------------------------
+AsmWriteDr1 PROC
+ mov eax, [esp + 4]
+ mov dr1, eax
+ ret
+AsmWriteDr1 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr2.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr2.asm
new file mode 100644
index 0000000..afff84b
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr2.asm
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; WriteDr2.Asm
+;
+; Abstract:
+;
+; AsmWriteDr2 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .586p
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; UINTN
+; EFIAPI
+; AsmWriteDr2 (
+; IN UINTN Value
+; );
+;------------------------------------------------------------------------------
+AsmWriteDr2 PROC
+ mov eax, [esp + 4]
+ mov dr2, eax
+ ret
+AsmWriteDr2 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr3.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr3.asm
new file mode 100644
index 0000000..3cdddce
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr3.asm
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; WriteDr3.Asm
+;
+; Abstract:
+;
+; AsmWriteDr3 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .586p
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; UINTN
+; EFIAPI
+; AsmWriteDr3 (
+; IN UINTN Value
+; );
+;------------------------------------------------------------------------------
+AsmWriteDr3 PROC
+ mov eax, [esp + 4]
+ mov dr3, eax
+ ret
+AsmWriteDr3 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr4.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr4.asm
new file mode 100644
index 0000000..4b3cc9d
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr4.asm
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; WriteDr4.Asm
+;
+; Abstract:
+;
+; AsmWriteDr4 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .586p
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; UINTN
+; EFIAPI
+; AsmWriteDr4 (
+; IN UINTN Value
+; );
+;------------------------------------------------------------------------------
+AsmWriteDr4 PROC
+ mov eax, [esp + 4]
+ DB 0fh, 23h, 0e0h
+ ret
+AsmWriteDr4 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr5.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr5.asm
new file mode 100644
index 0000000..d03d1f8
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr5.asm
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; WriteDr5.Asm
+;
+; Abstract:
+;
+; AsmWriteDr5 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .586p
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; UINTN
+; EFIAPI
+; AsmWriteDr5 (
+; IN UINTN Value
+; );
+;------------------------------------------------------------------------------
+AsmWriteDr5 PROC
+ mov eax, [esp + 4]
+ DB 0fh, 23h, 0e8h
+ ret
+AsmWriteDr5 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr6.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr6.asm
new file mode 100644
index 0000000..70fe09b
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr6.asm
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; WriteDr6.Asm
+;
+; Abstract:
+;
+; AsmWriteDr6 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .586p
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; UINTN
+; EFIAPI
+; AsmWriteDr6 (
+; IN UINTN Value
+; );
+;------------------------------------------------------------------------------
+AsmWriteDr6 PROC
+ mov eax, [esp + 4]
+ mov dr6, eax
+ ret
+AsmWriteDr6 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr7.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr7.asm
new file mode 100644
index 0000000..4fa5717
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteDr7.asm
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; WriteDr7.Asm
+;
+; Abstract:
+;
+; AsmWriteDr7 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .586p
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; UINTN
+; EFIAPI
+; AsmWriteDr7 (
+; IN UINTN Value
+; );
+;------------------------------------------------------------------------------
+AsmWriteDr7 PROC
+ mov eax, [esp + 4]
+ mov dr7, eax
+ ret
+AsmWriteDr7 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteGdtr.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteGdtr.asm
new file mode 100644
index 0000000..655c528
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteGdtr.asm
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; WriteGdtr.Asm
+;
+; Abstract:
+;
+; AsmWriteGdtr function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .386p
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; VOID
+; EFIAPI
+; InternalX86WriteGdtr (
+; IN CONST IA32_DESCRIPTOR *Idtr
+; );
+;------------------------------------------------------------------------------
+InternalX86WriteGdtr PROC
+ mov eax, [esp + 4]
+ lgdt fword ptr [eax]
+ ret
+InternalX86WriteGdtr ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteIdtr.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteIdtr.asm
new file mode 100644
index 0000000..043771b
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteIdtr.asm
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; WriteIdtr.Asm
+;
+; Abstract:
+;
+; AsmWriteIdtr function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .386p
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; VOID
+; EFIAPI
+; InternalX86WriteIdtr (
+; IN CONST IA32_DESCRIPTOR *Idtr
+; );
+;------------------------------------------------------------------------------
+InternalX86WriteIdtr PROC
+ mov eax, [esp + 4]
+ lidt fword ptr [eax]
+ ret
+InternalX86WriteIdtr ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteLdtr.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteLdtr.asm
new file mode 100644
index 0000000..a33b1bf
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteLdtr.asm
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; WriteLdtr.Asm
+;
+; Abstract:
+;
+; AsmWriteLdtr function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .386p
+ .model flat
+ .code
+
+;------------------------------------------------------------------------------
+; VOID
+; EFIAPI
+; AsmWriteLdtr (
+; IN UINT16 Ldtr
+; );
+;------------------------------------------------------------------------------
+_AsmWriteLdtr PROC
+ mov eax, [esp + 4]
+ lldt ax
+ ret
+_AsmWriteLdtr ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm0.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm0.asm
new file mode 100644
index 0000000..e8468e8
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm0.asm
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; WriteMm0.Asm
+;
+; Abstract:
+;
+; AsmWriteMm0 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .586
+ .model flat,C
+ .mmx
+ .code
+
+;------------------------------------------------------------------------------
+; VOID
+; EFIAPI
+; AsmWriteMm0 (
+; IN UINT64 Value
+; );
+;------------------------------------------------------------------------------
+AsmWriteMm0 PROC
+ movq mm0, [esp + 4]
+ ret
+AsmWriteMm0 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm1.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm1.asm
new file mode 100644
index 0000000..e04219b
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm1.asm
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; WriteMm1.Asm
+;
+; Abstract:
+;
+; AsmWriteMm1 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .586
+ .model flat,C
+ .mmx
+ .code
+
+;------------------------------------------------------------------------------
+; VOID
+; EFIAPI
+; AsmWriteMm1 (
+; IN UINT64 Value
+; );
+;------------------------------------------------------------------------------
+AsmWriteMm1 PROC
+ movq mm1, [esp + 4]
+ ret
+AsmWriteMm1 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm2.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm2.asm
new file mode 100644
index 0000000..a63c3d1
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm2.asm
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; WriteMm2.Asm
+;
+; Abstract:
+;
+; AsmWriteMm2 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .586
+ .model flat,C
+ .mmx
+ .code
+
+;------------------------------------------------------------------------------
+; VOID
+; EFIAPI
+; AsmWriteMm2 (
+; IN UINT64 Value
+; );
+;------------------------------------------------------------------------------
+AsmWriteMm2 PROC
+ movq mm2, [esp + 4]
+ ret
+AsmWriteMm2 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm3.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm3.asm
new file mode 100644
index 0000000..c3ceae3
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm3.asm
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; WriteMm3.Asm
+;
+; Abstract:
+;
+; AsmWriteMm3 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .586
+ .model flat,C
+ .mmx
+ .code
+
+;------------------------------------------------------------------------------
+; VOID
+; EFIAPI
+; AsmWriteMm3 (
+; IN UINT64 Value
+; );
+;------------------------------------------------------------------------------
+AsmWriteMm3 PROC
+ movq mm3, [esp + 4]
+ ret
+AsmWriteMm3 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm4.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm4.asm
new file mode 100644
index 0000000..458384e
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm4.asm
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; WriteMm4.Asm
+;
+; Abstract:
+;
+; AsmWriteMm4 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .586
+ .model flat,C
+ .mmx
+ .code
+
+;------------------------------------------------------------------------------
+; VOID
+; EFIAPI
+; AsmWriteMm4 (
+; IN UINT64 Value
+; );
+;------------------------------------------------------------------------------
+AsmWriteMm4 PROC
+ movq mm4, [esp + 4]
+ ret
+AsmWriteMm4 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm5.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm5.asm
new file mode 100644
index 0000000..d69b33e
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm5.asm
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; WriteMm5.Asm
+;
+; Abstract:
+;
+; AsmWriteMm5 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .586
+ .model flat,C
+ .mmx
+ .code
+
+;------------------------------------------------------------------------------
+; VOID
+; EFIAPI
+; AsmWriteMm5 (
+; IN UINT64 Value
+; );
+;------------------------------------------------------------------------------
+AsmWriteMm5 PROC
+ movq mm5, [esp + 4]
+ ret
+AsmWriteMm5 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm6.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm6.asm
new file mode 100644
index 0000000..9e8732e
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm6.asm
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; WriteMm6.Asm
+;
+; Abstract:
+;
+; AsmWriteMm6 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .586
+ .model flat,C
+ .mmx
+ .code
+
+;------------------------------------------------------------------------------
+; VOID
+; EFIAPI
+; AsmWriteMm6 (
+; IN UINT64 Value
+; );
+;------------------------------------------------------------------------------
+AsmWriteMm6 PROC
+ movq mm6, [esp + 4]
+ ret
+AsmWriteMm6 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm7.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm7.asm
new file mode 100644
index 0000000..127d6e6
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMm7.asm
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; WriteMm7.Asm
+;
+; Abstract:
+;
+; AsmWriteMm7 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .586
+ .model flat,C
+ .mmx
+ .code
+
+;------------------------------------------------------------------------------
+; VOID
+; EFIAPI
+; AsmWriteMm7 (
+; IN UINT64 Value
+; );
+;------------------------------------------------------------------------------
+AsmWriteMm7 PROC
+ movq mm7, [esp + 4]
+ ret
+AsmWriteMm7 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMsr64.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMsr64.asm
new file mode 100644
index 0000000..0df165c
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Ia32/WriteMsr64.asm
@@ -0,0 +1,42 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; WriteMsr64.Asm
+;
+; Abstract:
+;
+; AsmWriteMsr64 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .586p
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; UINT64
+; EFIAPI
+; AsmWriteMsr64 (
+; IN UINT32 Index,
+; IN UINT64 Value
+; );
+;------------------------------------------------------------------------------
+AsmWriteMsr64 PROC
+ mov edx, [esp + 12]
+ mov eax, [esp + 8]
+ mov ecx, [esp + 4]
+ wrmsr
+ ret
+AsmWriteMsr64 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LRotU32.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LRotU32.c
new file mode 100644
index 0000000..9d69d2f
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LRotU32.c
@@ -0,0 +1,50 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ LRotU32.c
+
+Abstract:
+
+ Math worker functions.
+
+--*/
+
+#include "BaseLibInternal.h"
+
+/**
+ Rotates a 32-bit integer left between 0 and 31 bits, filling the low bits
+ with the high bits that were rotated.
+
+ This function rotates the 32-bit value Operand to the left by Count bits. The
+ low Count bits are fill with the high Count bits of Operand. The rotated
+ value is returned.
+
+ If Count is greater than 31, then ASSERT().
+
+ @param Operand The 32-bit operand to rotate left.
+ @param Count The number of bits to rotate left.
+
+ @return Operand <<< Count
+
+**/
+UINT32
+EFIAPI
+LRotU32 (
+ IN UINT32 Operand,
+ IN UINTN Count
+ )
+{
+ ASSERT (Count < sizeof (Operand) * 8);
+ return (Operand << Count) | (Operand >> (32 - Count));
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LRotU64.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LRotU64.c
new file mode 100644
index 0000000..ebc8e91
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LRotU64.c
@@ -0,0 +1,50 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ LRotU64.c
+
+Abstract:
+
+ Math worker functions.
+
+--*/
+
+#include "BaseLibInternal.h"
+
+/**
+ Rotates a 64-bit integer left between 0 and 63 bits, filling the low bits
+ with the high bits that were rotated.
+
+ This function rotates the 64-bit value Operand to the left by Count bits. The
+ low Count bits are fill with the high Count bits of Operand. The rotated
+ value is returned.
+
+ If Count is greater than 63, then ASSERT().
+
+ @param Operand The 64-bit operand to rotate left.
+ @param Count The number of bits to rotate left.
+
+ @return Operand <<< Count
+
+**/
+UINT64
+EFIAPI
+LRotU64 (
+ IN UINT64 Operand,
+ IN UINTN Count
+ )
+{
+ ASSERT (Count < sizeof (Operand) * 8);
+ return InternalMathLRotU64 (Operand, Count);
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LShiftU64.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LShiftU64.c
new file mode 100644
index 0000000..c079f53
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LShiftU64.c
@@ -0,0 +1,49 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ LShiftU64.c
+
+Abstract:
+
+ Math worker functions.
+
+--*/
+
+#include "BaseLibInternal.h"
+
+/**
+ Shifts a 64-bit integer left between 0 and 63 bits. The low bits are filled
+ with zeros. The shifted value is returned.
+
+ This function shifts the 64-bit value Operand to the left by Count bits. The
+ low Count bits are set to zero. The shifted value is returned.
+
+ If Count is greater than 63, then ASSERT().
+
+ @param Operand The 64-bit operand to shift left.
+ @param Count The number of bits to shift left.
+
+ @return Operand << Count
+
+**/
+UINT64
+EFIAPI
+GlueLShiftU64 (
+ IN UINT64 Operand,
+ IN UINTN Count
+ )
+{
+ ASSERT (Count < sizeof (Operand) * 8);
+ return InternalMathLShiftU64 (Operand, Count);
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LinkedList.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LinkedList.c
new file mode 100644
index 0000000..cb84470
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LinkedList.c
@@ -0,0 +1,473 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ LinkedList.c
+
+Abstract:
+
+ Linked List Library Functions.
+
+--*/
+
+#include "BaseLibInternal.h"
+#include "Pcd\EdkIIGluePcdBaseLib.h"
+
+
+/**
+ Worker function that locates the Node in the List
+
+ By searching the List, finds the location of the Node in List. At the same time,
+ verifies the validity of this list.
+
+ If List is NULL, then ASSERT().
+ If List->ForwardLink is NULL, then ASSERT().
+ If List->backLink is NULL, then ASSERT().
+ If Node is NULL, then ASSERT();
+ If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number
+ of nodes in ListHead, including the ListHead node, is greater than or
+ equal to PcdMaximumLinkedListLength, then ASSERT().
+
+ @param List A pointer to a node in a linked list.
+ @param Node A pointer to one nod.
+
+ @retval TRUE Node is in List
+ @retval FALSE Node isn't in List, or List is invalid
+
+**/
+BOOLEAN
+IsNodeInList (
+ IN CONST LIST_ENTRY *List,
+ IN CONST LIST_ENTRY *Node
+ )
+{
+ UINTN Count;
+ CONST LIST_ENTRY *Ptr;
+ BOOLEAN Found;
+
+ //
+ // Test the validity of List and Node
+ //
+ ASSERT (List != NULL);
+ ASSERT (List->ForwardLink != NULL);
+ ASSERT (List->BackLink != NULL);
+ ASSERT (Node != NULL);
+
+ Count = PcdGet32 (PcdMaximumLinkedListLength);
+
+ Ptr = List;
+ do {
+ Ptr = Ptr->ForwardLink;
+ Count--;
+ } while ((Ptr != List) && (Ptr != Node) && (Count > 0));
+ Found = (BOOLEAN)(Ptr == Node);
+
+ if (PcdGet32 (PcdMaximumLinkedListLength) > 0) {
+ while ((Count > 0) && (Ptr != List)) {
+ Ptr = Ptr->ForwardLink;
+ Count--;
+ }
+ ASSERT (Count > 0);
+ }
+
+ return Found;
+}
+
+/**
+ Initializes the head node of a doubly linked list, and returns the pointer to
+ the head node of the doubly linked list.
+
+ Initializes the forward and backward links of a new linked list. After
+ initializing a linked list with this function, the other linked list
+ functions may be used to add and remove nodes from the linked list. It is up
+ to the caller of this function to allocate the memory for ListHead.
+
+ If ListHead is NULL, then ASSERT().
+
+ @param ListHead A pointer to the head node of a new doubly linked list.
+
+ @return ListHead
+
+**/
+LIST_ENTRY *
+EFIAPI
+GlueInitializeListHead (
+ IN OUT LIST_ENTRY *List
+ )
+
+{
+ ASSERT (List != NULL);
+
+ List->ForwardLink = List;
+ List->BackLink = List;
+ return List;
+}
+
+/**
+ Adds a node to the beginning of a doubly linked list, and returns the pointer
+ to the head node of the doubly linked list.
+
+ Adds the node Entry at the beginning of the doubly linked list denoted by
+ ListHead, and returns ListHead.
+
+ If ListHead is NULL, then ASSERT().
+ If Entry is NULL, then ASSERT().
+ If ListHead was not initialized with InitializeListHead(), then ASSERT().
+ If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number
+ of nodes in ListHead, including the ListHead node, is greater than or
+ equal to PcdMaximumLinkedListLength, then ASSERT().
+
+ @param ListHead A pointer to the head node of a doubly linked list.
+ @param Entry A pointer to a node that is to be inserted at the beginning
+ of a doubly linked list.
+
+ @return ListHead
+
+**/
+LIST_ENTRY *
+EFIAPI
+GlueInsertHeadList (
+ IN OUT LIST_ENTRY *List,
+ IN OUT LIST_ENTRY *Entry
+ )
+{
+ //
+ // ASSERT List not too long and Entry is not one of the nodes of List
+ //
+ ASSERT (!IsNodeInList (List, Entry));
+
+ Entry->ForwardLink = List->ForwardLink;
+ Entry->BackLink = List;
+ Entry->ForwardLink->BackLink = Entry;
+ List->ForwardLink = Entry;
+ return List;
+}
+
+/**
+ Adds a node to the end of a doubly linked list, and returns the pointer to
+ the head node of the doubly linked list.
+
+ Adds the node Entry to the end of the doubly linked list denoted by ListHead,
+ and returns ListHead.
+
+ If ListHead is NULL, then ASSERT().
+ If Entry is NULL, then ASSERT().
+ If ListHead was not initialized with InitializeListHead(), then ASSERT().
+ If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number
+ of nodes in ListHead, including the ListHead node, is greater than or
+ equal to PcdMaximumLinkedListLength, then ASSERT().
+
+ @param ListHead A pointer to the head node of a doubly linked list.
+ @param Entry A pointer to a node that is to be added at the end of the
+ doubly linked list.
+
+ @return ListHead
+
+**/
+LIST_ENTRY *
+EFIAPI
+GlueInsertTailList (
+ IN OUT LIST_ENTRY *List,
+ IN OUT LIST_ENTRY *Entry
+ )
+{
+ //
+ // ASSERT List not too long and Entry is not one of the nodes of List
+ //
+ ASSERT (!IsNodeInList (List, Entry));
+
+ Entry->ForwardLink = List;
+ Entry->BackLink = List->BackLink;
+ Entry->BackLink->ForwardLink = Entry;
+ List->BackLink = Entry;
+ return List;
+}
+
+/**
+ Retrieves the first node of a doubly linked list.
+
+ Returns the first node of a doubly linked list. List must have been
+ initialized with InitializeListHead(). If List is empty, then NULL is
+ returned.
+
+ If List is NULL, then ASSERT().
+ If List was not initialized with InitializeListHead(), then ASSERT().
+ If PcdMaximumLinkedListLenth is not zero, and the number of nodes
+ in List, including the List node, is greater than or equal to
+ PcdMaximumLinkedListLength, then ASSERT().
+
+ @param List A pointer to the head node of a doubly linked list.
+
+ @return The first node of a doubly linked list.
+ @retval NULL The list is empty.
+
+**/
+LIST_ENTRY *
+EFIAPI
+GlueGetFirstNode (
+ IN CONST LIST_ENTRY *List
+ )
+{
+ //
+ // ASSERT List not too long
+ //
+ ASSERT (IsNodeInList (List, List));
+
+ return List->ForwardLink;
+}
+
+/**
+ Retrieves the next node of a doubly linked list.
+
+ Returns the node of a doubly linked list that follows Node. List must have
+ been initialized with InitializeListHead(). If List is empty, then List is
+ returned.
+
+ If List is NULL, then ASSERT().
+ If Node is NULL, then ASSERT().
+ If List was not initialized with InitializeListHead(), then ASSERT().
+ If PcdMaximumLinkedListLenth is not zero, and List contains more than
+ PcdMaximumLinkedListLenth nodes, then ASSERT().
+ If Node is not a node in List, then ASSERT().
+
+ @param List A pointer to the head node of a doubly linked list.
+ @param Node A pointer to a node in the doubly linked list.
+
+ @return Pointer to the next node if one exists. Otherwise a null value which
+ is actually List is returned.
+
+**/
+LIST_ENTRY *
+EFIAPI
+GlueGetNextNode (
+ IN CONST LIST_ENTRY *List,
+ IN CONST LIST_ENTRY *Node
+ )
+{
+ //
+ // ASSERT List not too long and Node is one of the nodes of List
+ //
+ ASSERT (IsNodeInList (List, Node));
+
+ return Node->ForwardLink;
+}
+
+/**
+ Checks to see if a doubly linked list is empty or not.
+
+ Checks to see if the doubly linked list is empty. If the linked list contains
+ zero nodes, this function returns TRUE. Otherwise, it returns FALSE.
+
+ If ListHead is NULL, then ASSERT().
+ If ListHead was not initialized with InitializeListHead(), then ASSERT().
+ If PcdMaximumLinkedListLenth is not zero, and the number of nodes
+ in List, including the List node, is greater than or equal to
+ PcdMaximumLinkedListLength, then ASSERT().
+
+ @param ListHead A pointer to the head node of a doubly linked list.
+
+ @retval TRUE The linked list is empty.
+ @retval FALSE The linked list is not empty.
+
+**/
+BOOLEAN
+EFIAPI
+GlueIsListEmpty (
+ IN CONST LIST_ENTRY *List
+ )
+{
+ //
+ // ASSERT List not too long
+ //
+ ASSERT (IsNodeInList (List, List));
+
+ return (BOOLEAN)(List->ForwardLink == List);
+}
+
+/**
+ Determines if a node in a doubly linked list is null.
+
+ Returns FALSE if Node is one of the nodes in the doubly linked list specified
+ by List. Otherwise, TRUE is returned. List must have been initialized with
+ InitializeListHead().
+
+ If List is NULL, then ASSERT().
+ If Node is NULL, then ASSERT().
+ If List was not initialized with InitializeListHead(), then ASSERT().
+ If PcdMaximumLinkedListLenth is not zero, and the number of nodes
+ in List, including the List node, is greater than or equal to
+ PcdMaximumLinkedListLength, then ASSERT().
+ If Node is not a node in List and Node is not equal to List, then ASSERT().
+
+ @param List A pointer to the head node of a doubly linked list.
+ @param Node A pointer to a node in the doubly linked list.
+
+ @retval TRUE Node is one of the nodes in the doubly linked list.
+ @retval FALSE Node is not one of the nodes in the doubly linked list.
+
+**/
+BOOLEAN
+EFIAPI
+GlueIsNull (
+ IN CONST LIST_ENTRY *List,
+ IN CONST LIST_ENTRY *Node
+ )
+{
+ //
+ // ASSERT List not too long and Node is one of the nodes of List
+ //
+ ASSERT (IsNodeInList (List, Node));
+
+ return (BOOLEAN)(Node == List);
+}
+
+/**
+ Determines if a node the last node in a doubly linked list.
+
+ Returns TRUE if Node is the last node in the doubly linked list specified by
+ List. Otherwise, FALSE is returned. List must have been initialized with
+ InitializeListHead().
+
+ If List is NULL, then ASSERT().
+ If Node is NULL, then ASSERT().
+ If List was not initialized with InitializeListHead(), then ASSERT().
+ If PcdMaximumLinkedListLenth is not zero, and the number of nodes
+ in List, including the List node, is greater than or equal to
+ PcdMaximumLinkedListLength, then ASSERT().
+ If Node is not a node in List, then ASSERT().
+
+ @param List A pointer to the head node of a doubly linked list.
+ @param Node A pointer to a node in the doubly linked list.
+
+ @retval TRUE Node is the last node in the linked list.
+ @retval FALSE Node is not the last node in the linked list.
+
+**/
+BOOLEAN
+EFIAPI
+GlueIsNodeAtEnd (
+ IN CONST LIST_ENTRY *List,
+ IN CONST LIST_ENTRY *Node
+ )
+{
+ //
+ // ASSERT List not too long and Node is one of the nodes of List
+ //
+ ASSERT (IsNodeInList (List, Node));
+
+ return (BOOLEAN)(!IsNull (List, Node) && List->BackLink == Node);
+}
+
+/**
+ Swaps the location of two nodes in a doubly linked list, and returns the
+ first node after the swap.
+
+ If FirstEntry is identical to SecondEntry, then SecondEntry is returned.
+ Otherwise, the location of the FirstEntry node is swapped with the location
+ of the SecondEntry node in a doubly linked list. SecondEntry must be in the
+ same double linked list as FirstEntry and that double linked list must have
+ been initialized with InitializeListHead(). SecondEntry is returned after the
+ nodes are swapped.
+
+ If FirstEntry is NULL, then ASSERT().
+ If SecondEntry is NULL, then ASSERT().
+ If SecondEntry and FirstEntry are not in the same linked list, then ASSERT().
+ If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
+ linked list containing the FirstEntry and SecondEntry nodes, including
+ the FirstEntry and SecondEntry nodes, is greater than or equal to
+ PcdMaximumLinkedListLength, then ASSERT().
+
+ @param FirstEntry A pointer to a node in a linked list.
+ @param SecondEntry A pointer to another node in the same linked list.
+
+**/
+LIST_ENTRY *
+EFIAPI
+GlueSwapListEntries (
+ IN OUT LIST_ENTRY *FirstEntry,
+ IN OUT LIST_ENTRY *SecondEntry
+ )
+{
+ LIST_ENTRY *Ptr;
+
+ if (FirstEntry == SecondEntry) {
+ return SecondEntry;
+ }
+
+ //
+ // ASSERT Entry1 and Entry2 are in the same linked list
+ //
+ ASSERT (IsNodeInList (FirstEntry, SecondEntry));
+
+ //
+ // Ptr is the node pointed to by FirstEntry->ForwardLink
+ //
+ Ptr = RemoveEntryList (FirstEntry);
+
+ //
+ // If FirstEntry immediately follows SecondEntry, FirstEntry willl be placed
+ // immediately in front of SecondEntry
+ //
+ if (Ptr->BackLink == SecondEntry) {
+ return InsertTailList (SecondEntry, FirstEntry);
+ }
+
+ //
+ // Ptr == SecondEntry means SecondEntry immediately follows FirstEntry,
+ // then there are no further steps necessary
+ //
+ if (Ptr == InsertHeadList (SecondEntry, FirstEntry)) {
+ return Ptr;
+ }
+
+ //
+ // Move SecondEntry to the front of Ptr
+ //
+ RemoveEntryList (SecondEntry);
+ InsertTailList (Ptr, SecondEntry);
+ return SecondEntry;
+}
+
+/**
+ Removes a node from a doubly linked list, and returns the node that follows
+ the removed node.
+
+ Removes the node Entry from a doubly linked list. It is up to the caller of
+ this function to release the memory used by this node if that is required. On
+ exit, the node following Entry in the doubly linked list is returned. If
+ Entry is the only node in the linked list, then the head node of the linked
+ list is returned.
+
+ If Entry is NULL, then ASSERT().
+ If Entry is the head node of an empty list, then ASSERT().
+ If PcdMaximumLinkedListLength is not zero, and the number of nodes in the
+ linked list containing Entry, including the Entry node, is greater than
+ or equal to PcdMaximumLinkedListLength, then ASSERT().
+
+ @param Entry A pointer to a node in a linked list
+
+ @return Entry
+
+**/
+LIST_ENTRY *
+EFIAPI
+GlueRemoveEntryList (
+ IN CONST LIST_ENTRY *Entry
+ )
+{
+ ASSERT (!IsListEmpty (Entry));
+
+ Entry->ForwardLink->BackLink = Entry->BackLink;
+ Entry->BackLink->ForwardLink = Entry->ForwardLink;
+ return Entry->ForwardLink;
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LongJump.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LongJump.c
new file mode 100644
index 0000000..baa2d47
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LongJump.c
@@ -0,0 +1,85 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ LongJump.c
+
+Abstract:
+
+ Long Jump functions
+
+--*/
+
+#include "BaseLibInternal.h"
+
+/**
+ Worker function that checks ASSERT condition for JumpBuffer
+
+ Checks ASSERT condition for JumpBuffer.
+
+ If JumpBuffer is NULL, then ASSERT().
+ For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
+
+ @param JumpBuffer A pointer to CPU context buffer.
+
+**/
+VOID
+InternalAssertJumpBuffer (
+ IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer
+ );
+
+/**
+ Restores the CPU context that was saved with SetJump().
+
+ Restores the CPU context from the buffer specified by JumpBuffer.
+ This function never returns to the caller.
+ Instead is resumes execution based on the state of JumpBuffer.
+
+ @param JumpBuffer A pointer to CPU context buffer.
+ @param Value The value to return when the SetJump() context is restored.
+
+**/
+VOID
+EFIAPI
+InternalLongJump (
+ IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer,
+ IN UINTN Value
+ );
+
+/**
+ Restores the CPU context that was saved with SetJump().
+
+ Restores the CPU context from the buffer specified by JumpBuffer.
+ This function never returns to the caller.
+ Instead is resumes execution based on the state of JumpBuffer.
+
+ If JumpBuffer is NULL, then ASSERT().
+ For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
+ If Value is 0, then ASSERT().
+
+ @param JumpBuffer A pointer to CPU context buffer.
+ @param Value The value to return when the SetJump() context is restored.
+
+**/
+VOID
+EFIAPI
+LongJump (
+ IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer,
+ IN UINTN Value
+ )
+{
+ InternalAssertJumpBuffer (JumpBuffer);
+ ASSERT (Value != 0);
+
+ InternalLongJump (JumpBuffer, Value);
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LowBitSet32.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LowBitSet32.c
new file mode 100644
index 0000000..99ebe42
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LowBitSet32.c
@@ -0,0 +1,52 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ LowBitSet32.c
+
+Abstract:
+
+ Math worker functions.
+
+--*/
+
+#include "BaseLibInternal.h"
+
+/**
+ Returns the bit position of the lowest bit set in a 32-bit value.
+
+ This function computes the bit position of the lowest bit set in the 32-bit
+ value specified by Operand. If Operand is zero, then -1 is returned.
+ Otherwise, a value between 0 and 31 is returned.
+
+ @param Operand The 32-bit operand to evaluate.
+
+ @return Position of the lowest bit set in Operand if found.
+ @retval -1 Operand is zero.
+
+**/
+INTN
+EFIAPI
+LowBitSet32 (
+ IN UINT32 Operand
+ )
+{
+ INTN BitIndex;
+
+ if (Operand == 0) {
+ return -1;
+ }
+
+ for (BitIndex = 0; (Operand & 1) == 0; BitIndex++, Operand >>= 1);
+ return BitIndex;
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LowBitSet64.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LowBitSet64.c
new file mode 100644
index 0000000..10bd132
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/LowBitSet64.c
@@ -0,0 +1,54 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ LowBitSet64.c
+
+Abstract:
+
+ Math worker functions.
+
+--*/
+
+#include "BaseLibInternal.h"
+
+/**
+ Returns the bit position of the lowest bit set in a 64-bit value.
+
+ This function computes the bit position of the lowest bit set in the 64-bit
+ value specified by Operand. If Operand is zero, then -1 is returned.
+ Otherwise, a value between 0 and 63 is returned.
+
+ @param Operand The 64-bit operand to evaluate.
+
+ @return Position of the lowest bit set in Operand if found.
+ @retval -1 Operand is zero.
+
+**/
+INTN
+EFIAPI
+LowBitSet64 (
+ IN UINT64 Operand
+ )
+{
+ INTN BitIndex;
+
+ if (Operand == 0) {
+ return -1;
+ }
+
+ for (BitIndex = 0;
+ (Operand & 1) == 0;
+ BitIndex++, Operand = RShiftU64 (Operand, 1));
+ return BitIndex;
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Math64.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Math64.c
new file mode 100644
index 0000000..48f06dd
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Math64.c
@@ -0,0 +1,371 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ Match64.c
+
+Abstract:
+
+ Leaf math worker functions that require 64-bit arithmetic support from the
+ compiler.
+
+--*/
+
+#include "BaseLibInternal.h"
+
+/**
+ Shifts a 64-bit integer left between 0 and 63 bits. The low bits
+ are filled with zeros. The shifted value is returned.
+
+ This function shifts the 64-bit value Operand to the left by Count bits. The
+ low Count bits are set to zero. The shifted value is returned.
+
+ @param Operand The 64-bit operand to shift left.
+ @param Count The number of bits to shift left.
+
+ @return Operand << Count
+
+**/
+UINT64
+EFIAPI
+InternalMathLShiftU64 (
+ IN UINT64 Operand,
+ IN UINTN Count
+ )
+{
+ return Operand << Count;
+}
+
+/**
+ Shifts a 64-bit integer right between 0 and 63 bits. This high bits
+ are filled with zeros. The shifted value is returned.
+
+ This function shifts the 64-bit value Operand to the right by Count bits. The
+ high Count bits are set to zero. The shifted value is returned.
+
+ @param Operand The 64-bit operand to shift right.
+ @param Count The number of bits to shift right.
+
+ @return Operand >> Count
+
+**/
+UINT64
+EFIAPI
+InternalMathRShiftU64 (
+ IN UINT64 Operand,
+ IN UINTN Count
+ )
+{
+ return Operand >> Count;
+}
+
+/**
+ Shifts a 64-bit integer right between 0 and 63 bits. The high bits
+ are filled with original integer's bit 63. The shifted value is returned.
+
+ This function shifts the 64-bit value Operand to the right by Count bits. The
+ high Count bits are set to bit 63 of Operand. The shifted value is returned.
+
+ If Count is greater than 63, then ASSERT().
+
+ @param Operand The 64-bit operand to shift right.
+ @param Count The number of bits to shift right.
+
+ @return Operand arithmetically shifted right by Count
+
+**/
+UINT64
+EFIAPI
+InternalMathARShiftU64 (
+ IN UINT64 Operand,
+ IN UINTN Count
+ )
+{
+ //
+ // Test if this compiler supports arithmetic shift
+ //
+ if ((((-1) << (sizeof (-1) * 8 - 1)) >> (sizeof (-1) * 8 - 1)) == -1) {
+ //
+ // Arithmetic shift is supported
+ //
+ return (UINT64)((INT64)Operand >> Count);
+ }
+
+ //
+ // Arithmetic is not supported
+ //
+ return (Operand >> Count) |
+ ((INTN)Operand < 0 ? ~((UINTN)-1 >> Count) : 0);
+}
+
+
+/**
+ Rotates a 64-bit integer left between 0 and 63 bits, filling
+ the low bits with the high bits that were rotated.
+
+ This function rotates the 64-bit value Operand to the left by Count bits. The
+ low Count bits are fill with the high Count bits of Operand. The rotated
+ value is returned.
+
+ @param Operand The 64-bit operand to rotate left.
+ @param Count The number of bits to rotate left.
+
+ @return Operand <<< Count
+
+**/
+UINT64
+EFIAPI
+InternalMathLRotU64 (
+ IN UINT64 Operand,
+ IN UINTN Count
+ )
+{
+ return (Operand << Count) | (Operand >> (64 - Count));
+}
+
+/**
+ Rotates a 64-bit integer right between 0 and 63 bits, filling
+ the high bits with the high low bits that were rotated.
+
+ This function rotates the 64-bit value Operand to the right by Count bits.
+ The high Count bits are fill with the low Count bits of Operand. The rotated
+ value is returned.
+
+ @param Operand The 64-bit operand to rotate right.
+ @param Count The number of bits to rotate right.
+
+ @return Operand >>> Count
+
+**/
+UINT64
+EFIAPI
+InternalMathRRotU64 (
+ IN UINT64 Operand,
+ IN UINTN Count
+ )
+{
+ return (Operand >> Count) | (Operand << (64 - Count));
+}
+
+/**
+ Switches the endianess of a 64-bit integer.
+
+ This function swaps the bytes in a 64-bit unsigned value to switch the value
+ from little endian to big endian or vice versa. The byte swapped value is
+ returned.
+
+ @param Operand A 64-bit unsigned value.
+
+ @return The byte swaped Operand.
+
+**/
+UINT64
+EFIAPI
+InternalMathSwapBytes64 (
+ IN UINT64 Operand
+ )
+{
+ return (UINT64)(
+ ((UINT64)SwapBytes32 ((UINT32)Operand) << 32) |
+ ((UINT64)SwapBytes32 ((UINT32)(Operand >> 32)))
+ );
+}
+
+/**
+ Multiples a 64-bit unsigned integer by a 32-bit unsigned integer
+ and generates a 64-bit unsigned result.
+
+ This function multiples the 64-bit unsigned value Multiplicand by the 32-bit
+ unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
+ bit unsigned result is returned.
+
+ @param Multiplicand A 64-bit unsigned value.
+ @param Multiplier A 32-bit unsigned value.
+
+ @return Multiplicand * Multiplier
+
+**/
+UINT64
+EFIAPI
+InternalMathMultU64x32 (
+ IN UINT64 Multiplicand,
+ IN UINT32 Multiplier
+ )
+{
+ return Multiplicand * Multiplier;
+}
+
+
+/**
+ Multiples a 64-bit unsigned integer by a 64-bit unsigned integer
+ and generates a 64-bit unsigned result.
+
+ This function multiples the 64-bit unsigned value Multiplicand by the 64-bit
+ unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
+ bit unsigned result is returned.
+
+ @param Multiplicand A 64-bit unsigned value.
+ @param Multiplier A 64-bit unsigned value.
+
+ @return Multiplicand * Multiplier
+
+**/
+UINT64
+EFIAPI
+InternalMathMultU64x64 (
+ IN UINT64 Multiplicand,
+ IN UINT64 Multiplier
+ )
+{
+ return Multiplicand * Multiplier;
+}
+
+/**
+ Divides a 64-bit unsigned integer by a 32-bit unsigned integer and
+ generates a 64-bit unsigned result.
+
+ This function divides the 64-bit unsigned value Dividend by the 32-bit
+ unsigned value Divisor and generates a 64-bit unsigned quotient. This
+ function returns the 64-bit unsigned quotient.
+
+ @param Dividend A 64-bit unsigned value.
+ @param Divisor A 32-bit unsigned value.
+
+ @return Dividend / Divisor
+
+**/
+UINT64
+EFIAPI
+InternalMathDivU64x32 (
+ IN UINT64 Dividend,
+ IN UINT32 Divisor
+ )
+{
+ return Dividend / Divisor;
+}
+
+/**
+ Divides a 64-bit unsigned integer by a 32-bit unsigned integer
+ and generates a 32-bit unsigned remainder.
+
+ This function divides the 64-bit unsigned value Dividend by the 32-bit
+ unsigned value Divisor and generates a 32-bit remainder. This function
+ returns the 32-bit unsigned remainder.
+
+ @param Dividend A 64-bit unsigned value.
+ @param Divisor A 32-bit unsigned value.
+
+ @return Dividend % Divisor
+
+**/
+UINT32
+EFIAPI
+InternalMathModU64x32 (
+ IN UINT64 Dividend,
+ IN UINT32 Divisor
+ )
+{
+ return (UINT32)(Dividend % Divisor);
+}
+
+/**
+ Divides a 64-bit unsigned integer by a 32-bit unsigned integer and
+ generates a 64-bit unsigned result and an optional 32-bit unsigned remainder.
+
+ This function divides the 64-bit unsigned value Dividend by the 32-bit
+ unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
+ is not NULL, then the 32-bit unsigned remainder is returned in Remainder.
+ This function returns the 64-bit unsigned quotient.
+
+ @param Dividend A 64-bit unsigned value.
+ @param Divisor A 32-bit unsigned value.
+ @param Remainder A pointer to a 32-bit unsigned value. This parameter is
+ optional and may be NULL.
+
+ @return Dividend / Divisor
+
+**/
+UINT64
+EFIAPI
+InternalMathDivRemU64x32 (
+ IN UINT64 Dividend,
+ IN UINT32 Divisor,
+ OUT UINT32 *Remainder OPTIONAL
+ )
+{
+ if (Remainder != NULL) {
+ *Remainder = (UINT32)(Dividend % Divisor);
+ }
+ return Dividend / Divisor;
+}
+
+/**
+ Divides a 64-bit unsigned integer by a 64-bit unsigned integer and
+ generates a 64-bit unsigned result and an optional 64-bit unsigned remainder.
+
+ This function divides the 64-bit unsigned value Dividend by the 64-bit
+ unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
+ is not NULL, then the 64-bit unsigned remainder is returned in Remainder.
+ This function returns the 64-bit unsigned quotient.
+
+ @param Dividend A 64-bit unsigned value.
+ @param Divisor A 64-bit unsigned value.
+ @param Remainder A pointer to a 64-bit unsigned value. This parameter is
+ optional and may be NULL.
+
+ @return Dividend / Divisor
+
+**/
+UINT64
+EFIAPI
+InternalMathDivRemU64x64 (
+ IN UINT64 Dividend,
+ IN UINT64 Divisor,
+ OUT UINT64 *Remainder OPTIONAL
+ )
+{
+ if (Remainder != NULL) {
+ *Remainder = Dividend % Divisor;
+ }
+ return Dividend / Divisor;
+}
+
+/**
+ Divides a 64-bit signed integer by a 64-bit signed integer and
+ generates a 64-bit signed result and a optional 64-bit signed remainder.
+
+ This function divides the 64-bit unsigned value Dividend by the 64-bit
+ unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
+ is not NULL, then the 64-bit unsigned remainder is returned in Remainder.
+ This function returns the 64-bit unsigned quotient.
+
+ @param Dividend A 64-bit signed value.
+ @param Divisor A 64-bit signed value.
+ @param Remainder A pointer to a 64-bit signed value. This parameter is
+ optional and may be NULL.
+
+ @return Dividend / Divisor
+
+**/
+INT64
+InternalMathDivRemS64x64 (
+ IN INT64 Dividend,
+ IN INT64 Divisor,
+ OUT INT64 *Remainder OPTIONAL
+ )
+{
+ if (Remainder != NULL) {
+ *Remainder = Dividend % Divisor;
+ }
+ return Dividend / Divisor;
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/ModU64x32.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/ModU64x32.c
new file mode 100644
index 0000000..350a704
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/ModU64x32.c
@@ -0,0 +1,50 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ ModU64x32.c
+
+Abstract:
+
+ Math worker functions.
+
+--*/
+
+#include "BaseLibInternal.h"
+
+/**
+ Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates
+ a 32-bit unsigned remainder.
+
+ This function divides the 64-bit unsigned value Dividend by the 32-bit
+ unsigned value Divisor and generates a 32-bit remainder. This function
+ returns the 32-bit unsigned remainder.
+
+ If Divisor is 0, then ASSERT().
+
+ @param Dividend A 64-bit unsigned value.
+ @param Divisor A 32-bit unsigned value.
+
+ @return Dividend % Divisor
+
+**/
+UINT32
+EFIAPI
+ModU64x32 (
+ IN UINT64 Dividend,
+ IN UINT32 Divisor
+ )
+{
+ ASSERT (Divisor != 0);
+ return InternalMathModU64x32 (Dividend, Divisor);
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/MultS64x64.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/MultS64x64.c
new file mode 100644
index 0000000..52c7adb
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/MultS64x64.c
@@ -0,0 +1,49 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ MultS64x64.c
+
+Abstract:
+
+ Math worker functions.
+
+--*/
+
+#include "BaseLibInternal.h"
+
+/**
+ Multiples a 64-bit signed integer by a 64-bit signed integer and generates a
+ 64-bit signed result.
+
+ This function multiples the 64-bit signed value Multiplicand by the 64-bit
+ signed value Multiplier and generates a 64-bit signed result. This 64-bit
+ signed result is returned.
+
+ If the result overflows, then ASSERT().
+
+ @param Multiplicand A 64-bit signed value.
+ @param Multiplier A 64-bit signed value.
+
+ @return Multiplicand * Multiplier
+
+**/
+INT64
+EFIAPI
+MultS64x64 (
+ IN INT64 Multiplicand,
+ IN INT64 Multiplier
+ )
+{
+ return (INT64)MultU64x64 (Multiplicand, Multiplier);
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/MultU64x32.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/MultU64x32.c
new file mode 100644
index 0000000..be271b8
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/MultU64x32.c
@@ -0,0 +1,51 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ MultU64x32.c
+
+Abstract:
+
+ Math worker functions.
+
+--*/
+
+#include "BaseLibInternal.h"
+
+/**
+ Multiples a 64-bit unsigned integer by a 32-bit unsigned integer and
+ generates a 64-bit unsigned result.
+
+ This function multiples the 64-bit unsigned value Multiplicand by the 32-bit
+ unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
+ bit unsigned result is returned.
+
+ @param Multiplicand A 64-bit unsigned value.
+ @param Multiplier A 32-bit unsigned value.
+
+ @return Multiplicand * Multiplier
+
+**/
+UINT64
+EFIAPI
+GlueMultU64x32 (
+ IN UINT64 Multiplicand,
+ IN UINT32 Multiplier
+ )
+{
+ UINT64 Result;
+
+ Result = InternalMathMultU64x32 (Multiplicand, Multiplier);
+
+ return Result;
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/MultU64x64.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/MultU64x64.c
new file mode 100644
index 0000000..a0e5b39
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/MultU64x64.c
@@ -0,0 +1,51 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ MultU64x64.c
+
+Abstract:
+
+ Math worker functions.
+
+--*/
+
+#include "BaseLibInternal.h"
+
+/**
+ Multiples a 64-bit unsigned integer by a 64-bit unsigned integer and
+ generates a 64-bit unsigned result.
+
+ This function multiples the 64-bit unsigned value Multiplicand by the 64-bit
+ unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
+ bit unsigned result is returned.
+
+ @param Multiplicand A 64-bit unsigned value.
+ @param Multiplier A 64-bit unsigned value.
+
+ @return Multiplicand * Multiplier
+
+**/
+UINT64
+EFIAPI
+MultU64x64 (
+ IN UINT64 Multiplicand,
+ IN UINT64 Multiplier
+ )
+{
+ UINT64 Result;
+
+ Result = InternalMathMultU64x64 (Multiplicand, Multiplier);
+
+ return Result;
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/RRotU32.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/RRotU32.c
new file mode 100644
index 0000000..e07d2b0
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/RRotU32.c
@@ -0,0 +1,50 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ RRotU32.c
+
+Abstract:
+
+ Math worker functions.
+
+--*/
+
+#include "BaseLibInternal.h"
+
+/**
+ Rotates a 32-bit integer right between 0 and 31 bits, filling the high bits
+ with the low bits that were rotated.
+
+ This function rotates the 32-bit value Operand to the right by Count bits.
+ The high Count bits are fill with the low Count bits of Operand. The rotated
+ value is returned.
+
+ If Count is greater than 31, then ASSERT().
+
+ @param Operand The 32-bit operand to rotate right.
+ @param Count The number of bits to rotate right.
+
+ @return Operand >>> Count
+
+**/
+UINT32
+EFIAPI
+RRotU32 (
+ IN UINT32 Operand,
+ IN UINTN Count
+ )
+{
+ ASSERT (Count < sizeof (Operand) * 8);
+ return (Operand >> Count) | (Operand << (32 - Count));
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/RRotU64.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/RRotU64.c
new file mode 100644
index 0000000..f862278
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/RRotU64.c
@@ -0,0 +1,50 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ RRotU64.c
+
+Abstract:
+
+ Math worker functions.
+
+--*/
+
+#include "BaseLibInternal.h"
+
+/**
+ Rotates a 64-bit integer right between 0 and 63 bits, filling the high bits
+ with the high low bits that were rotated.
+
+ This function rotates the 64-bit value Operand to the right by Count bits.
+ The high Count bits are fill with the low Count bits of Operand. The rotated
+ value is returned.
+
+ If Count is greater than 63, then ASSERT().
+
+ @param Operand The 64-bit operand to rotate right.
+ @param Count The number of bits to rotate right.
+
+ @return Operand >>> Count
+
+**/
+UINT64
+EFIAPI
+RRotU64 (
+ IN UINT64 Operand,
+ IN UINTN Count
+ )
+{
+ ASSERT (Count < sizeof (Operand) * 8);
+ return InternalMathRRotU64 (Operand, Count);
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/RShiftU64.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/RShiftU64.c
new file mode 100644
index 0000000..954394d
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/RShiftU64.c
@@ -0,0 +1,49 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ RShiftU64.c
+
+Abstract:
+
+ Math worker functions.
+
+--*/
+
+#include "BaseLibInternal.h"
+
+/**
+ Shifts a 64-bit integer right between 0 and 63 bits. This high bits are
+ filled with zeros. The shifted value is returned.
+
+ This function shifts the 64-bit value Operand to the right by Count bits. The
+ high Count bits are set to zero. The shifted value is returned.
+
+ If Count is greater than 63, then ASSERT().
+
+ @param Operand The 64-bit operand to shift right.
+ @param Count The number of bits to shift right.
+
+ @return Operand >> Count
+
+**/
+UINT64
+EFIAPI
+GlueRShiftU64 (
+ IN UINT64 Operand,
+ IN UINTN Count
+ )
+{
+ ASSERT (Count < sizeof (Operand) * 8);
+ return InternalMathRShiftU64 (Operand, Count);
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SetJump.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SetJump.c
new file mode 100644
index 0000000..6d4eb66
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SetJump.c
@@ -0,0 +1,43 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ SetJump.c
+
+Abstract:
+
+ Internal ASSERT () functions for SetJump.
+
+--*/
+
+#include "BaseLibInternal.h"
+
+/**
+ Worker function that checks ASSERT condition for JumpBuffer
+
+ Checks ASSERT condition for JumpBuffer.
+
+ If JumpBuffer is NULL, then ASSERT().
+ For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
+
+ @param JumpBuffer A pointer to CPU context buffer.
+
+**/
+VOID
+EFIAPI
+InternalAssertJumpBuffer (
+ IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer
+ )
+{
+ ASSERT (JumpBuffer != NULL);
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/String.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/String.c
new file mode 100644
index 0000000..a0dee7e
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/String.c
@@ -0,0 +1,974 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ String.c
+
+Abstract:
+
+ Unicode string primatives.
+
+--*/
+
+#include "BaseLibInternal.h"
+#include "Pcd\EdkIIGluePcdBaseLib.h"
+
+
+/**
+ Copies one Null-terminated Unicode string to another Null-terminated Unicode
+ string and returns the new Unicode string.
+
+ This function copies the contents of the Unicode string Source to the Unicode
+ string Destination, and returns Destination. If Source and Destination
+ overlap, then the results are undefined.
+
+ If Destination is NULL, then ASSERT().
+ If Source is NULL, then ASSERT().
+ If Source and Destination overlap, then ASSERT().
+ If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
+ PcdMaximumUnicodeStringLength Unicode characters not including the
+ Null-terminator, then ASSERT().
+
+ @param Destination Pointer to a Null-terminated Unicode string.
+ @param Source Pointer to a Null-terminated Unicode string.
+
+ @return Destiantion
+
+**/
+CHAR16 *
+EFIAPI
+GlueStrCpy (
+ OUT CHAR16 *Destination,
+ IN CONST CHAR16 *Source
+ )
+{
+ CHAR16 *ReturnValue;
+
+ //
+ // Destination cannot be NULL
+ //
+ ASSERT (Destination != NULL);
+
+ //
+ // Destination and source cannot overlap
+ //
+ ASSERT ((UINTN)(Destination - Source) > StrLen (Source));
+ ASSERT ((UINTN)(Source - Destination) > StrLen (Source));
+
+ ReturnValue = Destination;
+ while (*Source) {
+ *(Destination++) = *(Source++);
+ }
+ *Destination = 0;
+ return ReturnValue;
+}
+
+/**
+ Copies one Null-terminated Unicode string with a maximum length to another
+ Null-terminated Unicode string with a maximum length and returns the new
+ Unicode string.
+
+ This function copies the contents of the Unicode string Source to the Unicode
+ string Destination, and returns Destination. At most, Length Unicode
+ characters are copied from Source to Destination. If Length is 0, then
+ Destination is returned unmodified. If Length is greater that the number of
+ Unicode characters in Source, then Destination is padded with Null Unicode
+ characters. If Source and Destination overlap, then the results are
+ undefined.
+
+ If Destination is NULL, then ASSERT().
+ If Source is NULL, then ASSERT().
+ If Source and Destination overlap, then ASSERT().
+ If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
+ PcdMaximumUnicodeStringLength Unicode characters not including the
+ Null-terminator, then ASSERT().
+
+ @param Destination Pointer to a Null-terminated Unicode string.
+ @param Source Pointer to a Null-terminated Unicode string.
+ @param Length Maximum number of Unicode characters to copy.
+
+ @return Destination
+
+**/
+CHAR16 *
+EFIAPI
+GlueStrnCpy (
+ OUT CHAR16 *Destination,
+ IN CONST CHAR16 *Source,
+ IN UINTN Length
+ )
+{
+ CHAR16 *ReturnValue;
+
+ if (Length == 0) {
+ return Destination;
+ }
+
+ //
+ // Destination cannot be NULL if Length is not zero
+ //
+ ASSERT (Destination != NULL);
+
+ //
+ // Destination and source cannot overlap
+ // Q: Does Source have to be NULL-terminated?
+ //
+ ASSERT ((UINTN)(Destination - Source) > StrLen (Source));
+ ASSERT ((UINTN)(Source - Destination) >= Length);
+
+ ReturnValue = Destination;
+
+ while ((*Source != L'\0') && (Length > 0)) {
+ *(Destination++) = *(Source++);
+ Length--;
+ }
+
+ ZeroMem (Destination, Length * sizeof (*Destination));
+ return ReturnValue;
+}
+
+/**
+ Returns the length of a Null-terminated Unicode string.
+
+ This function returns the number of Unicode characters in the Null-terminated
+ Unicode string specified by String.
+
+ If String is NULL, then ASSERT().
+ If PcdMaximumUnicodeStringLength is not zero, and String contains more than
+ PcdMaximumUnicodeStringLength Unicode characters not including the
+ Null-terminator, then ASSERT().
+
+ @param String Pointer to a Null-terminated Unicode string.
+
+ @return The length of String.
+
+**/
+UINTN
+EFIAPI
+GlueStrLen (
+ IN CONST CHAR16 *String
+ )
+{
+ UINTN Length;
+
+ ASSERT (String != NULL);
+
+ for (Length = 0; *String != L'\0'; String++, Length++) {
+ //
+ // If PcdMaximumUnicodeStringLength is not zero,
+ // length should not more than PcdMaximumUnicodeStringLength
+ //
+ if (PcdGet32 (PcdMaximumUnicodeStringLength) != 0) {
+ ASSERT (Length < PcdGet32 (PcdMaximumUnicodeStringLength));
+ }
+ }
+ return Length;
+}
+
+/**
+ Returns the size of a Null-terminated Unicode string in bytes, including the
+ Null terminator.
+
+ This function returns the size, in bytes, of the Null-terminated Unicode
+ string specified by String.
+
+ If String is NULL, then ASSERT().
+ If PcdMaximumUnicodeStringLength is not zero, and String contains more than
+ PcdMaximumUnicodeStringLength Unicode characters not including the
+ Null-terminator, then ASSERT().
+
+ @param String Pointer to a Null-terminated Unicode string.
+
+ @return The size of String.
+
+**/
+UINTN
+EFIAPI
+GlueStrSize (
+ IN CONST CHAR16 *String
+ )
+{
+ return (StrLen (String) + 1) * sizeof (*String);
+}
+
+/**
+ Compares two Null-terminated Unicode strings, and returns the difference
+ between the first mismatched Unicode characters.
+
+ This function compares the Null-terminated Unicode string FirstString to the
+ Null-terminated Unicode string SecondString. If FirstString is identical to
+ SecondString, then 0 is returned. Otherwise, the value returned is the first
+ mismatched Unicode character in SecondString subtracted from the first
+ mismatched Unicode character in FirstString.
+
+ If FirstString is NULL, then ASSERT().
+ If SecondString is NULL, then ASSERT().
+ If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more
+ than PcdMaximumUnicodeStringLength Unicode characters not including the
+ Null-terminator, then ASSERT().
+ If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more
+ than PcdMaximumUnicodeStringLength Unicode characters not including the
+ Null-terminator, then ASSERT().
+
+ @param FirstString Pointer to a Null-terminated Unicode string.
+ @param SecondString Pointer to a Null-terminated Unicode string.
+
+ @retval 0 FirstString is identical to SecondString.
+ @retval !=0 FirstString is not identical to SecondString.
+
+**/
+INTN
+EFIAPI
+GlueStrCmp (
+ IN CONST CHAR16 *FirstString,
+ IN CONST CHAR16 *SecondString
+ )
+{
+ //
+ // ASSERT both strings are less long than PcdMaximumUnicodeStringLength
+ //
+ ASSERT (StrSize (FirstString) != 0);
+ ASSERT (StrSize (SecondString) != 0);
+
+ while ((*FirstString != L'\0') && (*FirstString == *SecondString)) {
+ FirstString++;
+ SecondString++;
+ }
+ return *FirstString - *SecondString;
+}
+
+/**
+ Compares two Null-terminated Unicode strings with maximum lengths, and
+ returns the difference between the first mismatched Unicode characters.
+
+ This function compares the Null-terminated Unicode string FirstString to the
+ Null-terminated Unicode string SecondString. At most, Length Unicode
+ characters will be compared. If Length is 0, then 0 is returned. If
+ FirstString is identical to SecondString, then 0 is returned. Otherwise, the
+ value returned is the first mismatched Unicode character in SecondString
+ subtracted from the first mismatched Unicode character in FirstString.
+
+ If FirstString is NULL, then ASSERT().
+ If SecondString is NULL, then ASSERT().
+ If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more
+ than PcdMaximumUnicodeStringLength Unicode characters not including the
+ Null-terminator, then ASSERT().
+ If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more
+ than PcdMaximumUnicodeStringLength Unicode characters not including the
+ Null-terminator, then ASSERT().
+
+ @param FirstString Pointer to a Null-terminated Unicode string.
+ @param SecondString Pointer to a Null-terminated Unicode string.
+ @param Length Maximum number of Unicode characters to compare.
+
+ @retval 0 FirstString is identical to SecondString.
+ @retval !=0 FirstString is not identical to SecondString.
+
+**/
+INTN
+EFIAPI
+GlueStrnCmp (
+ IN CONST CHAR16 *FirstString,
+ IN CONST CHAR16 *SecondString,
+ IN UINTN Length
+ )
+{
+ if (Length == 0) {
+ return 0;
+ }
+
+ //
+ // ASSERT both strings are less long than PcdMaximumUnicodeStringLength.
+ // Length tests are performed inside StrLen().
+ //
+ ASSERT (StrSize (FirstString) != 0);
+ ASSERT (StrSize (SecondString) != 0);
+
+ while ((*FirstString != L'\0') &&
+ (*FirstString == *SecondString) &&
+ (Length > 1)) {
+ FirstString++;
+ SecondString++;
+ Length--;
+ }
+
+ return *FirstString - *SecondString;
+}
+
+/**
+ Concatenates one Null-terminated Unicode string to another Null-terminated
+ Unicode string, and returns the concatenated Unicode string.
+
+ This function concatenates two Null-terminated Unicode strings. The contents
+ of Null-terminated Unicode string Source are concatenated to the end of
+ Null-terminated Unicode string Destination. The Null-terminated concatenated
+ Unicode String is returned. If Source and Destination overlap, then the
+ results are undefined.
+
+ If Destination is NULL, then ASSERT().
+ If Source is NULL, then ASSERT().
+ If Source and Destination overlap, then ASSERT().
+ If PcdMaximumUnicodeStringLength is not zero, and Destination contains more
+ than PcdMaximumUnicodeStringLength Unicode characters not including the
+ Null-terminator, then ASSERT().
+ If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
+ PcdMaximumUnicodeStringLength Unicode characters not including the
+ Null-terminator, then ASSERT().
+ If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination
+ and Source results in a Unicode string with more than
+ PcdMaximumUnicodeStringLength Unicode characters not including the
+ Null-terminator, then ASSERT().
+
+ @param Destination Pointer to a Null-terminated Unicode string.
+ @param Source Pointer to a Null-terminated Unicode string.
+
+ @return Destination
+
+**/
+CHAR16 *
+EFIAPI
+GlueStrCat (
+ IN OUT CHAR16 *Destination,
+ IN CONST CHAR16 *Source
+ )
+{
+ StrCpy (Destination + StrLen (Destination), Source);
+
+ //
+ // Size of the resulting string should never be zero.
+ // PcdMaximumUnicodeStringLength is tested inside StrLen().
+ //
+ ASSERT (StrSize (Destination) != 0);
+ return Destination;
+}
+
+/**
+ Concatenates one Null-terminated Unicode string with a maximum length to the
+ end of another Null-terminated Unicode string, and returns the concatenated
+ Unicode string.
+
+ This function concatenates two Null-terminated Unicode strings. The contents
+ of Null-terminated Unicode string Source are concatenated to the end of
+ Null-terminated Unicode string Destination, and Destination is returned. At
+ most, Length Unicode characters are concatenated from Source to the end of
+ Destination, and Destination is always Null-terminated. If Length is 0, then
+ Destination is returned unmodified. If Source and Destination overlap, then
+ the results are undefined.
+
+ If Destination is NULL, then ASSERT().
+ If Source is NULL, then ASSERT().
+ If Source and Destination overlap, then ASSERT().
+ If PcdMaximumUnicodeStringLength is not zero, and Destination contains more
+ than PcdMaximumUnicodeStringLength Unicode characters not including the
+ Null-terminator, then ASSERT().
+ If PcdMaximumUnicodeStringLength is not zero, and Source contains more than
+ PcdMaximumUnicodeStringLength Unicode characters not including the
+ Null-terminator, then ASSERT().
+ If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination
+ and Source results in a Unicode string with more than
+ PcdMaximumUnicodeStringLength Unicode characters not including the
+ Null-terminator, then ASSERT().
+
+ @param Destination Pointer to a Null-terminated Unicode string.
+ @param Source Pointer to a Null-terminated Unicode string.
+ @param Length Maximum number of Unicode characters to concatenate from
+ Source.
+
+ @return Destination
+
+**/
+CHAR16 *
+EFIAPI
+GlueStrnCat (
+ IN OUT CHAR16 *Destination,
+ IN CONST CHAR16 *Source,
+ IN UINTN Length
+ )
+{
+ StrnCpy (Destination + StrLen (Destination), Source, Length);
+
+ //
+ // Size of the resulting string should never be zero.
+ // PcdMaximumUnicodeStringLength is tested inside StrLen().
+ //
+ ASSERT (StrSize (Destination) != 0);
+ return Destination;
+}
+
+//;;## ...AMI_OVERRIDE... Support Unicode Str To Ascii Str start.
+/**
+ Convert a Null-terminated Unicode string to a Null-terminated
+ ASCII string and returns the ASCII string.
+
+ This function converts the content of the Unicode string Source
+ to the ASCII string Destination by copying the lower 8 bits of
+ each Unicode character. It returns Destination. The function terminates
+ the ASCII string Destination by appending a Null-terminator character
+ at the end. The caller is responsible to make sure Destination points
+ to a buffer with size equal or greater than (StrLen (Source) + 1) in bytes.
+
+ If Destination is NULL, then ASSERT().
+ If Source is NULL, then ASSERT().
+ If Source is not aligned on a 16-bit boundary, then ASSERT().
+ If Source and Destination overlap, then ASSERT().
+
+ If any Unicode characters in Source contain non-zero value in
+ the upper 8 bits, then ASSERT().
+
+ If PcdMaximumUnicodeStringLength is not zero, and Source contains
+ more than PcdMaximumUnicodeStringLength Unicode characters not including
+ the Null-terminator, then ASSERT().
+
+ If PcdMaximumAsciiStringLength is not zero, and Source contains more
+ than PcdMaximumAsciiStringLength Unicode characters not including the
+ Null-terminator, then ASSERT().
+
+ @param Source Pointer to a Null-terminated Unicode string.
+ @param Destination Pointer to a Null-terminated ASCII string.
+
+ @reture Destination
+
+**/
+CHAR8 *
+EFIAPI
+UnicodeStrToAsciiStr (
+ IN CONST CHAR16 *Source,
+ OUT CHAR8 *Destination
+ )
+{
+ ASSERT (Destination != NULL);
+ ASSERT (Source != NULL);
+ ASSERT (((UINTN) Source & 0x01) == 0);
+
+ //
+ // Source and Destination should not overlap
+ //
+ ASSERT ((UINTN) ((CHAR16 *) Destination - Source) > StrLen (Source));
+ ASSERT ((UINTN) ((CHAR8 *) Source - Destination) > StrLen (Source));
+
+ //
+ // If PcdMaximumUnicodeStringLength is not zero,
+ // length of Source should not more than PcdMaximumUnicodeStringLength
+ //
+ if (PcdGet32 (PcdMaximumUnicodeStringLength) != 0) {
+ ASSERT (StrLen (Source) < PcdGet32 (PcdMaximumUnicodeStringLength));
+ }
+
+ while (*Source != '\0') {
+ //
+ // If any Unicode characters in Source contain
+ // non-zero value in the upper 8 bits, then ASSERT().
+ //
+ ASSERT (*Source < 0x100);
+ *(Destination++) = (CHAR8) *(Source++);
+ }
+
+ *Destination = '\0';
+
+ return Destination;
+}
+//;;## ...AMI_OVERRIDE... Support Unicode Str To Ascii Str end.
+
+/**
+ Copies one Null-terminated ASCII string to another Null-terminated ASCII
+ string and returns the new ASCII string.
+
+ This function copies the contents of the ASCII string Source to the ASCII
+ string Destination, and returns Destination. If Source and Destination
+ overlap, then the results are undefined.
+
+ If Destination is NULL, then ASSERT().
+ If Source is NULL, then ASSERT().
+ If Source and Destination overlap, then ASSERT().
+ If PcdMaximumAsciiStringLength is not zero and Source contains more than
+ PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
+ then ASSERT().
+
+ @param Destination Pointer to a Null-terminated ASCII string.
+ @param Source Pointer to a Null-terminated ASCII string.
+
+ @return Destination
+
+**/
+CHAR8 *
+EFIAPI
+AsciiStrCpy (
+ OUT CHAR8 *Destination,
+ IN CONST CHAR8 *Source
+ )
+{
+ CHAR8 *ReturnValue;
+
+ //
+ // Destination cannot be NULL
+ //
+ ASSERT (Destination != NULL);
+
+ //
+ // Destination and source cannot overlap
+ //
+ ASSERT ((UINTN)(Destination - Source) > AsciiStrLen (Source));
+ ASSERT ((UINTN)(Source - Destination) > AsciiStrLen (Source));
+
+ ReturnValue = Destination;
+ while (*Source) {
+ *(Destination++) = *(Source++);
+ }
+ *Destination = 0;
+ return ReturnValue;
+}
+
+/**
+ Copies one Null-terminated ASCII string with a maximum length to another
+ Null-terminated ASCII string with a maximum length and returns the new ASCII
+ string.
+
+ This function copies the contents of the ASCII string Source to the ASCII
+ string Destination, and returns Destination. At most, Length ASCII characters
+ are copied from Source to Destination. If Length is 0, then Destination is
+ returned unmodified. If Length is greater that the number of ASCII characters
+ in Source, then Destination is padded with Null ASCII characters. If Source
+ and Destination overlap, then the results are undefined.
+
+ If Destination is NULL, then ASSERT().
+ If Source is NULL, then ASSERT().
+ If Source and Destination overlap, then ASSERT().
+ If PcdMaximumAsciiStringLength is not zero, and Source contains more than
+ PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
+ then ASSERT().
+
+ @param Destination Pointer to a Null-terminated ASCII string.
+ @param Source Pointer to a Null-terminated ASCII string.
+ @param Length Maximum number of ASCII characters to copy.
+
+ @return Destination
+
+**/
+CHAR8 *
+EFIAPI
+AsciiStrnCpy (
+ OUT CHAR8 *Destination,
+ IN CONST CHAR8 *Source,
+ IN UINTN Length
+ )
+{
+ CHAR8 *ReturnValue;
+
+ if (Length == 0) {
+ return Destination;
+ }
+
+ //
+ // Destination cannot be NULL
+ //
+ ASSERT (Destination != NULL);
+
+ //
+ // Destination and source cannot overlap
+ //
+ ASSERT ((UINTN)(Destination - Source) > AsciiStrLen (Source));
+ ASSERT ((UINTN)(Source - Destination) >= Length);
+
+ ReturnValue = Destination;
+
+ while (*Source && Length > 0) {
+ *(Destination++) = *(Source++);
+ Length--;
+ }
+
+ ZeroMem (Destination, Length * sizeof (*Destination));
+ return ReturnValue;
+}
+
+/**
+ Returns the length of a Null-terminated ASCII string.
+
+ This function returns the number of ASCII characters in the Null-terminated
+ ASCII string specified by String.
+
+ If String is NULL, then ASSERT().
+ If PcdMaximumAsciiStringLength is not zero and String contains more than
+ PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
+ then ASSERT().
+
+ @param String Pointer to a Null-terminated ASCII string.
+
+ @return The length of String.
+
+**/
+UINTN
+EFIAPI
+AsciiStrLen (
+ IN CONST CHAR8 *String
+ )
+{
+ UINTN Length;
+
+ ASSERT (String != NULL);
+
+ for (Length = 0; *String != '\0'; String++, Length++) {
+ //
+ // If PcdMaximumUnicodeStringLength is not zero,
+ // length should not more than PcdMaximumUnicodeStringLength
+ //
+ if (PcdGet32 (PcdMaximumAsciiStringLength) != 0) {
+ ASSERT (Length < PcdGet32 (PcdMaximumAsciiStringLength));
+ }
+ }
+ return Length;
+}
+
+/**
+ Returns the size of a Null-terminated ASCII string in bytes, including the
+ Null terminator.
+
+ This function returns the size, in bytes, of the Null-terminated ASCII string
+ specified by String.
+
+ If String is NULL, then ASSERT().
+ If PcdMaximumAsciiStringLength is not zero and String contains more than
+ PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
+ then ASSERT().
+
+ @param String Pointer to a Null-terminated ASCII string.
+
+ @return The size of String.
+
+**/
+UINTN
+EFIAPI
+AsciiStrSize (
+ IN CONST CHAR8 *String
+ )
+{
+ return (AsciiStrLen (String) + 1) * sizeof (*String);
+}
+
+/**
+ Compares two Null-terminated ASCII strings, and returns the difference
+ between the first mismatched ASCII characters.
+
+ This function compares the Null-terminated ASCII string FirstString to the
+ Null-terminated ASCII string SecondString. If FirstString is identical to
+ SecondString, then 0 is returned. Otherwise, the value returned is the first
+ mismatched ASCII character in SecondString subtracted from the first
+ mismatched ASCII character in FirstString.
+
+ If FirstString is NULL, then ASSERT().
+ If SecondString is NULL, then ASSERT().
+ If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
+ PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
+ then ASSERT().
+ If PcdMaximumAsciiStringLength is not zero and SecondString contains more
+ than PcdMaximumAsciiStringLength ASCII characters not including the
+ Null-terminator, then ASSERT().
+
+ @param FirstString Pointer to a Null-terminated ASCII string.
+ @param SecondString Pointer to a Null-terminated ASCII string.
+
+ @retval 0 FirstString is identical to SecondString.
+ @retval !=0 FirstString is not identical to SecondString.
+
+**/
+INTN
+EFIAPI
+AsciiStrCmp (
+ IN CONST CHAR8 *FirstString,
+ IN CONST CHAR8 *SecondString
+ )
+{
+ //
+ // ASSERT both strings are less long than PcdMaximumAsciiStringLength
+ //
+ ASSERT (AsciiStrSize (FirstString));
+ ASSERT (AsciiStrSize (SecondString));
+
+ while ((*FirstString != '\0') && (*FirstString == *SecondString)) {
+ FirstString++;
+ SecondString++;
+ }
+
+ return *FirstString - *SecondString;
+}
+
+/**
+ Converts a lowercase Ascii character to upper one
+
+ If Chr is lowercase Ascii character, then converts it to upper one.
+
+ If Value >= 0xA0, then ASSERT().
+ If (Value & 0x0F) >= 0x0A, then ASSERT().
+
+ @param chr one Ascii character
+
+ @return The uppercase value of Ascii character
+
+**/
+STATIC
+CHAR8
+AsciiToUpper (
+ IN CHAR8 Chr
+ )
+{
+ return (Chr >= 'a' && Chr <= 'z') ? Chr - ('a' - 'A') : Chr;
+}
+
+/**
+ Performs a case insensitive comparison of two Null-terminated ASCII strings,
+ and returns the difference between the first mismatched ASCII characters.
+
+ This function performs a case insensitive comparison of the Null-terminated
+ ASCII string FirstString to the Null-terminated ASCII string SecondString. If
+ FirstString is identical to SecondString, then 0 is returned. Otherwise, the
+ value returned is the first mismatched lower case ASCII character in
+ SecondString subtracted from the first mismatched lower case ASCII character
+ in FirstString.
+
+ If FirstString is NULL, then ASSERT().
+ If SecondString is NULL, then ASSERT().
+ If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
+ PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
+ then ASSERT().
+ If PcdMaximumAsciiStringLength is not zero and SecondString contains more
+ than PcdMaximumAsciiStringLength ASCII characters not including the
+ Null-terminator, then ASSERT().
+
+ @param FirstString Pointer to a Null-terminated ASCII string.
+ @param SecondString Pointer to a Null-terminated ASCII string.
+
+ @retval 0 FirstString is identical to SecondString using case insensitive
+ comparisons.
+ @retval !=0 FirstString is not identical to SecondString using case
+ insensitive comparisons.
+
+**/
+INTN
+EFIAPI
+AsciiStriCmp (
+ IN CONST CHAR8 *FirstString,
+ IN CONST CHAR8 *SecondString
+ )
+{
+ //
+ // ASSERT both strings are less long than PcdMaximumAsciiStringLength
+ //
+ ASSERT (AsciiStrSize (FirstString));
+ ASSERT (AsciiStrSize (SecondString));
+
+ while ((*FirstString != '\0') &&
+ (AsciiToUpper (*FirstString) == AsciiToUpper (*SecondString))) {
+ FirstString++;
+ SecondString++;
+ }
+
+ return AsciiToUpper (*FirstString) - AsciiToUpper (*SecondString);
+}
+
+/**
+ Compares two Null-terminated ASCII strings with maximum lengths, and returns
+ the difference between the first mismatched ASCII characters.
+
+ This function compares the Null-terminated ASCII string FirstString to the
+ Null-terminated ASCII string SecondString. At most, Length ASCII characters
+ will be compared. If Length is 0, then 0 is returned. If FirstString is
+ identical to SecondString, then 0 is returned. Otherwise, the value returned
+ is the first mismatched ASCII character in SecondString subtracted from the
+ first mismatched ASCII character in FirstString.
+
+ If FirstString is NULL, then ASSERT().
+ If SecondString is NULL, then ASSERT().
+ If PcdMaximumAsciiStringLength is not zero and FirstString contains more than
+ PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
+ then ASSERT().
+ If PcdMaximumAsciiStringLength is not zero and SecondString contains more than
+ PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
+ then ASSERT().
+
+ @param FirstString Pointer to a Null-terminated ASCII string.
+ @param SecondString Pointer to a Null-terminated ASCII string.
+
+ @retval 0 FirstString is identical to SecondString.
+ @retval !=0 FirstString is not identical to SecondString.
+
+**/
+INTN
+EFIAPI
+AsciiStrnCmp (
+ IN CONST CHAR8 *FirstString,
+ IN CONST CHAR8 *SecondString,
+ IN UINTN Length
+ )
+{
+ if (Length == 0) {
+ return 0;
+ }
+
+ //
+ // ASSERT both strings are less long than PcdMaximumAsciiStringLength
+ //
+ ASSERT (AsciiStrSize (FirstString));
+ ASSERT (AsciiStrSize (SecondString));
+
+ while ((*FirstString != '\0') &&
+ (*FirstString == *SecondString) &&
+ (Length > 1)) {
+ FirstString++;
+ SecondString++;
+ Length--;
+ }
+ return *FirstString - *SecondString;
+}
+
+/**
+ Concatenates one Null-terminated ASCII string to another Null-terminated
+ ASCII string, and returns the concatenated ASCII string.
+
+ This function concatenates two Null-terminated ASCII strings. The contents of
+ Null-terminated ASCII string Source are concatenated to the end of Null-
+ terminated ASCII string Destination. The Null-terminated concatenated ASCII
+ String is returned.
+
+ If Destination is NULL, then ASSERT().
+ If Source is NULL, then ASSERT().
+ If PcdMaximumAsciiStringLength is not zero and Destination contains more than
+ PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
+ then ASSERT().
+ If PcdMaximumAsciiStringLength is not zero and Source contains more than
+ PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
+ then ASSERT().
+ If PcdMaximumAsciiStringLength is not zero and concatenating Destination and
+ Source results in a ASCII string with more than PcdMaximumAsciiStringLength
+ ASCII characters, then ASSERT().
+
+ @param Destination Pointer to a Null-terminated ASCII string.
+ @param Source Pointer to a Null-terminated ASCII string.
+
+ @return Destination
+
+**/
+CHAR8 *
+EFIAPI
+AsciiStrCat (
+ IN OUT CHAR8 *Destination,
+ IN CONST CHAR8 *Source
+ )
+{
+ AsciiStrCpy (Destination + AsciiStrLen (Destination), Source);
+
+ //
+ // Size of the resulting string should never be zero.
+ // PcdMaximumUnicodeStringLength is tested inside StrLen().
+ //
+ ASSERT (AsciiStrSize (Destination) != 0);
+ return Destination;
+}
+
+/**
+ Concatenates one Null-terminated ASCII string with a maximum length to the
+ end of another Null-terminated ASCII string, and returns the concatenated
+ ASCII string.
+
+ This function concatenates two Null-terminated ASCII strings. The contents
+ of Null-terminated ASCII string Source are concatenated to the end of Null-
+ terminated ASCII string Destination, and Destination is returned. At most,
+ Length ASCII characters are concatenated from Source to the end of
+ Destination, and Destination is always Null-terminated. If Length is 0, then
+ Destination is returned unmodified. If Source and Destination overlap, then
+ the results are undefined.
+
+ If Destination is NULL, then ASSERT().
+ If Source is NULL, then ASSERT().
+ If Source and Destination overlap, then ASSERT().
+ If PcdMaximumAsciiStringLength is not zero, and Destination contains more than
+ PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
+ then ASSERT().
+ If PcdMaximumAsciiStringLength is not zero, and Source contains more than
+ PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,
+ then ASSERT().
+ If PcdMaximumAsciiStringLength is not zero, and concatenating Destination and
+ Source results in a ASCII string with more than PcdMaximumAsciiStringLength
+ ASCII characters not including the Null-terminator, then ASSERT().
+
+ @param Destination Pointer to a Null-terminated ASCII string.
+ @param Source Pointer to a Null-terminated ASCII string.
+ @param Length Maximum number of ASCII characters to concatenate from
+ Source.
+
+ @return Destination
+
+**/
+CHAR8 *
+EFIAPI
+AsciiStrnCat (
+ IN OUT CHAR8 *Destination,
+ IN CONST CHAR8 *Source,
+ IN UINTN Length
+ )
+{
+ AsciiStrnCpy (Destination + AsciiStrLen (Destination), Source, Length);
+
+ //
+ // Size of the resulting string should never be zero.
+ // PcdMaximumUnicodeStringLength is tested inside StrLen().
+ //
+ ASSERT (AsciiStrSize (Destination) != 0);
+ return Destination;
+}
+
+/**
+ Converts an 8-bit value to an 8-bit BCD value.
+
+ Converts the 8-bit value specified by Value to BCD. The BCD value is
+ returned.
+
+ If Value >= 100, then ASSERT().
+
+ @param Value The 8-bit value to convert to BCD. Range 0..99.
+
+ @return The BCD value
+
+**/
+UINT8
+EFIAPI
+DecimalToBcd8 (
+ IN UINT8 Value
+ )
+{
+ ASSERT (Value < 100);
+ return ((Value / 10) << 4) | (Value % 10);
+}
+
+/**
+ Converts an 8-bit BCD value to an 8-bit value.
+
+ Converts the 8-bit BCD value specified by Value to an 8-bit value. The 8-bit
+ value is returned.
+
+ If Value >= 0xA0, then ASSERT().
+ If (Value & 0x0F) >= 0x0A, then ASSERT().
+
+ @param Value The 8-bit BCD value to convert to an 8-bit value.
+
+ @return The 8-bit value is returned.
+
+**/
+UINT8
+EFIAPI
+BcdToDecimal8 (
+ IN UINT8 Value
+ )
+{
+ ASSERT (Value < 0xa0);
+ ASSERT ((Value & 0xf) < 0xa);
+ return (Value >> 4) * 10 + (Value & 0xf);
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SwapBytes16.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SwapBytes16.c
new file mode 100644
index 0000000..07392ed
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SwapBytes16.c
@@ -0,0 +1,44 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ SwapBytes16.c
+
+Abstract:
+
+ Math worker functions.
+
+--*/
+
+#include "BaseLibInternal.h"
+
+/**
+ Switches the endianess of a 16-bit integer.
+
+ This function swaps the bytes in a 16-bit unsigned value to switch the value
+ from little endian to big endian or vice versa. The byte swapped value is
+ returned.
+
+ @param Operand A 16-bit unsigned value.
+
+ @return The byte swaped Operand.
+
+**/
+UINT16
+EFIAPI
+SwapBytes16 (
+ IN UINT16 Operand
+ )
+{
+ return (Operand << 8) | (Operand >> 8);
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SwapBytes32.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SwapBytes32.c
new file mode 100644
index 0000000..1b5b129
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SwapBytes32.c
@@ -0,0 +1,47 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ SwapBytes32.c
+
+Abstract:
+
+ Math worker functions.
+
+--*/
+
+#include "BaseLibInternal.h"
+
+/**
+ Switches the endianess of a 32-bit integer.
+
+ This function swaps the bytes in a 32-bit unsigned value to switch the value
+ from little endian to big endian or vice versa. The byte swapped value is
+ returned.
+
+ @param Operand A 32-bit unsigned value.
+
+ @return The byte swaped Operand.
+
+**/
+UINT32
+EFIAPI
+SwapBytes32 (
+ IN UINT32 Operand
+ )
+{
+ return (UINT32)(
+ ((UINT32)SwapBytes16 ((UINT16)Operand) << 16) |
+ ((UINT32)SwapBytes16 ((UINT16)(Operand >> 16)))
+ );
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SwapBytes64.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SwapBytes64.c
new file mode 100644
index 0000000..5f6891c
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SwapBytes64.c
@@ -0,0 +1,44 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ SwapBytes64.c
+
+Abstract:
+
+ Math worker functions.
+
+--*/
+
+#include "BaseLibInternal.h"
+
+/**
+ Switches the endianess of a 64-bit integer.
+
+ This function swaps the bytes in a 64-bit unsigned value to switch the value
+ from little endian to big endian or vice versa. The byte swapped value is
+ returned.
+
+ @param Operand A 64-bit unsigned value.
+
+ @return The byte swaped Operand.
+
+**/
+UINT64
+EFIAPI
+SwapBytes64 (
+ IN UINT64 Operand
+ )
+{
+ return InternalMathSwapBytes64 (Operand);
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SwitchStack.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SwitchStack.c
new file mode 100644
index 0000000..34f8dce
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/SwitchStack.c
@@ -0,0 +1,58 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ SwitchStack.c
+
+Abstract:
+
+ Switch Stack functions.
+
+--*/
+
+#include "BaseLibInternal.h"
+
+/**
+ Transfers control to a function starting with a new stack.
+
+ Transfers control to the function specified by EntryPoint using the new stack
+ specified by NewStack and passing in the parameters specified by Context1 and
+ Context2. Context1 and Context2 are optional and may be NULL. The function
+ EntryPoint must never return.
+
+ If EntryPoint is NULL, then ASSERT().
+ If NewStack is NULL, then ASSERT().
+ For IPF CPUs, if NewStack is not aligned on a 16-byte boundary, then ASSERT().
+
+ @param EntryPoint A pointer to function to call with the new stack.
+ @param Context1 A pointer to the context to pass into the EntryPoint
+ function.
+ @param Context2 A pointer to the context to pass into the EntryPoint
+ function.
+ @param NewStack A pointer to the new stack to use for the EntryPoint
+ function.
+
+**/
+VOID
+EFIAPI
+SwitchStack (
+ IN SWITCH_STACK_ENTRY_POINT EntryPoint,
+ IN VOID *Context1,
+ IN VOID *Context2,
+ IN VOID *NewStack
+ )
+{
+ ASSERT (EntryPoint != NULL && NewStack != NULL);
+
+ InternalSwitchStack (EntryPoint, Context1, Context2, NewStack);
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Synchronization.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Synchronization.c
new file mode 100644
index 0000000..8056f6e
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Synchronization.c
@@ -0,0 +1,438 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ Synchronization.c
+
+Abstract:
+
+ Implementation of synchronization functions.
+
+--*/
+
+#include "BaseLibInternal.h"
+#include "Pcd\EdkIIGluePcdBaseLib.h"
+
+#define SPIN_LOCK_RELEASED ((UINTN)1)
+#define SPIN_LOCK_ACQUIRED ((UINTN)2)
+
+/**
+ Performs an atomic increment of an 32-bit unsigned integer.
+
+ Performs an atomic increment of the 32-bit unsigned integer specified by
+ Value and returns the incremented value. The increment operation must be
+ performed using MP safe mechanisms. The state of the return value is not
+ guaranteed to be MP safe.
+
+ @param Value A pointer to the 32-bit value to increment.
+
+ @return The incremented value.
+
+**/
+UINT32
+EFIAPI
+InternalSyncIncrement (
+ IN volatile UINT32 *Value
+ );
+
+/**
+ Performs an atomic decrement of an 32-bit unsigned integer.
+
+ Performs an atomic decrement of the 32-bit unsigned integer specified by
+ Value and returns the decrement value. The decrement operation must be
+ performed using MP safe mechanisms. The state of the return value is not
+ guaranteed to be MP safe.
+
+ @param Value A pointer to the 32-bit value to decrement.
+
+ @return The decrement value.
+
+**/
+UINT32
+EFIAPI
+InternalSyncDecrement (
+ IN volatile UINT32 *Value
+ );
+
+/**
+ Performs an atomic compare exchange operation on a 32-bit unsigned integer.
+
+ Performs an atomic compare exchange operation on the 32-bit unsigned integer
+ specified by Value. If Value is equal to CompareValue, then Value is set to
+ ExchangeValue and CompareValue is returned. If Value is not equal to CompareValue,
+ then Value is returned. The compare exchange operation must be performed using
+ MP safe mechanisms.
+
+ @param Value A pointer to the 32-bit value for the compare exchange
+ operation.
+ @param CompareValue 32-bit value used in compare operation.
+ @param ExchangeValue 32-bit value used in exchange operation.
+
+ @return The original *Value before exchange.
+
+**/
+UINT32
+EFIAPI
+InternalSyncCompareExchange32 (
+ IN volatile UINT32 *Value,
+ IN UINT32 CompareValue,
+ IN UINT32 ExchangeValue
+ );
+
+/**
+ Performs an atomic compare exchange operation on a 64-bit unsigned integer.
+
+ Performs an atomic compare exchange operation on the 64-bit unsigned integer specified
+ by Value. If Value is equal to CompareValue, then Value is set to ExchangeValue and
+ CompareValue is returned. If Value is not equal to CompareValue, then Value is returned.
+ The compare exchange operation must be performed using MP safe mechanisms.
+
+ @param Value A pointer to the 64-bit value for the compare exchange
+ operation.
+ @param CompareValue 64-bit value used in compare operation.
+ @param ExchangeValue 64-bit value used in exchange operation.
+
+ @return The original *Value before exchange.
+
+**/
+UINT64
+EFIAPI
+InternalSyncCompareExchange64 (
+ IN volatile UINT64 *Value,
+ IN UINT64 CompareValue,
+ IN UINT64 ExchangeValue
+ );
+
+/**
+ Retrieves the architecture specific spin lock alignment requirements for
+ optimal spin lock performance.
+
+ This function retrieves the spin lock alignment requirements for optimal
+ performance on a given CPU architecture. The spin lock alignment must be a
+ power of two and is returned by this function. If there are no alignment
+ requirements, then 1 must be returned. The spin lock synchronization
+ functions must function correctly if the spin lock size and alignment values
+ returned by this function are not used at all. These values are hints to the
+ consumers of the spin lock synchronization functions to obtain optimal spin
+ lock performance.
+
+ @return The architecture specific spin lock alignment.
+
+**/
+UINTN
+EFIAPI
+GetSpinLockProperties (
+ VOID
+ )
+{
+ // @bug May use a PCD entry to determine this alignment.
+ return 32;
+}
+
+/**
+ Initializes a spin lock to the released state and returns the spin lock.
+
+ This function initializes the spin lock specified by SpinLock to the released
+ state, and returns SpinLock. Optimal performance can be achieved by calling
+ GetSpinLockProperties() to determine the size and alignment requirements for
+ SpinLock.
+
+ If SpinLock is NULL, then ASSERT().
+
+ @param SpinLock A pointer to the spin lock to initialize to the released
+ state.
+
+ @return SpinLock
+
+**/
+SPIN_LOCK *
+EFIAPI
+InitializeSpinLock (
+ OUT SPIN_LOCK *SpinLock
+ )
+{
+ ASSERT (SpinLock != NULL);
+ *SpinLock = SPIN_LOCK_RELEASED;
+ return SpinLock;
+}
+
+/**
+ Waits until a spin lock can be placed in the acquired state.
+
+ This function checks the state of the spin lock specified by SpinLock. If
+ SpinLock is in the released state, then this function places SpinLock in the
+ acquired state and returns SpinLock. Otherwise, this function waits
+ indefinitely for the spin lock to be released, and then places it in the
+ acquired state and returns SpinLock. All state transitions of SpinLock must
+ be performed using MP safe mechanisms.
+
+ If SpinLock is NULL, then ASSERT().
+ If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().
+ If PcdSpinLockTimeout is not zero, and SpinLock is can not be acquired in
+ PcdSpinLockTimeout microseconds, then ASSERT().
+
+ @param SpinLock A pointer to the spin lock to place in the acquired state.
+
+ @return SpinLock
+
+**/
+SPIN_LOCK *
+EFIAPI
+AcquireSpinLock (
+ IN OUT SPIN_LOCK *SpinLock
+ )
+{
+ UINT64 Tick;
+ UINT64 Start, End;
+ UINT64 Timeout;
+
+ Tick = 0;
+ Start = 0;
+ End = 0;
+ if (PcdGet32 (PcdSpinLockTimeout) > 0) {
+ Tick = GetPerformanceCounter ();
+ Timeout = DivU64x32 (
+ MultU64x32 (
+ GetPerformanceCounterProperties (&Start, &End),
+ PcdGet32 (PcdSpinLockTimeout)
+ ),
+ 1000000
+ );
+ if (Start < End) {
+ Tick += Timeout;
+ } else {
+ Tick -= Timeout;
+ }
+ }
+
+ while (!AcquireSpinLockOrFail (SpinLock)) {
+ CpuPause ();
+ ASSERT ((Start < End) ^ (Tick <= GetPerformanceCounter ()));
+ }
+ return SpinLock;
+}
+
+/**
+ Attempts to place a spin lock in the acquired state.
+
+ This function checks the state of the spin lock specified by SpinLock. If
+ SpinLock is in the released state, then this function places SpinLock in the
+ acquired state and returns TRUE. Otherwise, FALSE is returned. All state
+ transitions of SpinLock must be performed using MP safe mechanisms.
+
+ If SpinLock is NULL, then ASSERT().
+ If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().
+
+ @param SpinLock A pointer to the spin lock to place in the acquired state.
+
+ @retval TRUE SpinLock was placed in the acquired state.
+ @retval FALSE SpinLock could not be acquired.
+
+**/
+BOOLEAN
+EFIAPI
+AcquireSpinLockOrFail (
+ IN OUT SPIN_LOCK *SpinLock
+ )
+{
+ ASSERT (SpinLock != NULL);
+ ASSERT (*SpinLock == SPIN_LOCK_ACQUIRED || *SpinLock == SPIN_LOCK_RELEASED);
+ return (BOOLEAN)(
+ InterlockedCompareExchangePointer (
+ (VOID**)SpinLock,
+ (VOID*)SPIN_LOCK_RELEASED,
+ (VOID*)SPIN_LOCK_ACQUIRED
+ ) == (VOID*)SPIN_LOCK_RELEASED
+ );
+}
+
+/**
+ Releases a spin lock.
+
+ This function places the spin lock specified by SpinLock in the release state
+ and returns SpinLock.
+
+ If SpinLock is NULL, then ASSERT().
+ If SpinLock was not initialized with InitializeSpinLock(), then ASSERT().
+
+ @param SpinLock A pointer to the spin lock to release.
+
+ @return SpinLock
+
+**/
+SPIN_LOCK *
+EFIAPI
+ReleaseSpinLock (
+ IN OUT SPIN_LOCK *SpinLock
+ )
+{
+ ASSERT (SpinLock != NULL);
+ ASSERT (*SpinLock == SPIN_LOCK_ACQUIRED || *SpinLock == SPIN_LOCK_RELEASED);
+ *SpinLock = SPIN_LOCK_RELEASED;
+ return SpinLock;
+}
+
+/**
+ Performs an atomic increment of an 32-bit unsigned integer.
+
+ Performs an atomic increment of the 32-bit unsigned integer specified by
+ Value and returns the incremented value. The increment operation must be
+ performed using MP safe mechanisms. The state of the return value is not
+ guaranteed to be MP safe.
+
+ If Value is NULL, then ASSERT().
+
+ @param Value A pointer to the 32-bit value to increment.
+
+ @return The incremented value.
+
+**/
+UINT32
+EFIAPI
+InterlockedIncrement (
+ IN UINT32 *Value
+ )
+{
+ ASSERT (Value != NULL);
+ return InternalSyncIncrement (Value);
+}
+
+/**
+ Performs an atomic decrement of an 32-bit unsigned integer.
+
+ Performs an atomic decrement of the 32-bit unsigned integer specified by
+ Value and returns the decremented value. The decrement operation must be
+ performed using MP safe mechanisms. The state of the return value is not
+ guaranteed to be MP safe.
+
+ If Value is NULL, then ASSERT().
+
+ @param Value A pointer to the 32-bit value to decrement.
+
+ @return The decremented value.
+
+**/
+UINT32
+EFIAPI
+InterlockedDecrement (
+ IN UINT32 *Value
+ )
+{
+ ASSERT (Value != NULL);
+ return InternalSyncDecrement (Value);
+}
+
+/**
+ Performs an atomic compare exchange operation on a 32-bit unsigned integer.
+
+ Performs an atomic compare exchange operation on the 32-bit unsigned integer
+ specified by Value. If Value is equal to CompareValue, then Value is set to
+ ExchangeValue and CompareValue is returned. If Value is not equal to CompareValue,
+ then Value is returned. The compare exchange operation must be performed using
+ MP safe mechanisms.
+
+ If Value is NULL, then ASSERT().
+
+ @param Value A pointer to the 32-bit value for the compare exchange
+ operation.
+ @param CompareValue 32-bit value used in compare operation.
+ @param ExchangeValue 32-bit value used in exchange operation.
+
+ @return The original *Value before exchange.
+
+**/
+UINT32
+EFIAPI
+InterlockedCompareExchange32 (
+ IN OUT VOLATILE UINT32 *Value,
+ IN UINT32 CompareValue,
+ IN UINT32 ExchangeValue
+ )
+{
+ ASSERT (Value != NULL);
+ return InternalSyncCompareExchange32 (Value, CompareValue, ExchangeValue);
+}
+
+/**
+ Performs an atomic compare exchange operation on a 64-bit unsigned integer.
+
+ Performs an atomic compare exchange operation on the 64-bit unsigned integer specified
+ by Value. If Value is equal to CompareValue, then Value is set to ExchangeValue and
+ CompareValue is returned. If Value is not equal to CompareValue, then Value is returned.
+ The compare exchange operation must be performed using MP safe mechanisms.
+
+ If Value is NULL, then ASSERT().
+
+ @param Value A pointer to the 64-bit value for the compare exchange
+ operation.
+ @param CompareValue 64-bit value used in compare operation.
+ @param ExchangeValue 64-bit value used in exchange operation.
+
+ @return The original *Value before exchange.
+
+**/
+UINT64
+EFIAPI
+InterlockedCompareExchange64 (
+ IN OUT VOLATILE UINT64 *Value,
+ IN UINT64 CompareValue,
+ IN UINT64 ExchangeValue
+ )
+{
+ ASSERT (Value != NULL);
+ return InternalSyncCompareExchange64 (Value, CompareValue, ExchangeValue);
+}
+
+/**
+ Performs an atomic compare exchange operation on a pointer value.
+
+ Performs an atomic compare exchange operation on the pointer value specified
+ by Value. If Value is equal to CompareValue, then Value is set to
+ ExchangeValue and CompareValue is returned. If Value is not equal to
+ CompareValue, then Value is returned. The compare exchange operation must be
+ performed using MP safe mechanisms.
+
+ If Value is NULL, then ASSERT().
+
+ @param Value A pointer to the pointer value for the compare exchange
+ operation.
+ @param CompareValue Pointer value used in compare operation.
+ @param ExchangeValue Pointer value used in exchange operation.
+
+**/
+VOID *
+EFIAPI
+InterlockedCompareExchangePointer (
+ IN OUT VOLATILE VOID **Value,
+ IN VOID *CompareValue,
+ IN VOID *ExchangeValue
+ )
+{
+ switch (sizeof (*Value)) {
+ case sizeof (UINT32):
+ return (VOID*)(UINTN)InterlockedCompareExchange32 (
+ (UINT32*)Value,
+ (UINT32)(UINTN)CompareValue,
+ (UINT32)(UINTN)ExchangeValue
+ );
+ case sizeof (UINT64):
+ return (VOID*)(UINTN)InterlockedCompareExchange64 (
+ (UINT64*)Value,
+ (UINT64)(UINTN)CompareValue,
+ (UINT64)(UINTN)ExchangeValue
+ );
+ default:
+ ASSERT (FALSE);
+ return NULL;
+ }
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Unaligned.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Unaligned.c
new file mode 100644
index 0000000..42e7b69
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/Unaligned.c
@@ -0,0 +1,228 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ Unaligned.c
+
+Abstract:
+
+ Unaligned access functions of BaseLib.
+
+--*/
+
+#include "BaseLibInternal.h"
+
+/**
+ Reads a 16-bit value from memory that may be unaligned.
+
+ This function returns the 16-bit value pointed to by Buffer. The function
+ guarantees that the read operation does not produce an alignment fault.
+
+ If the Buffer is NULL, then ASSERT().
+
+ @param Buffer Pointer to a 16-bit value that may be unaligned.
+
+ @return *Uint16
+
+**/
+UINT16
+EFIAPI
+ReadUnaligned16 (
+ IN CONST UINT16 *Buffer
+ )
+{
+ ASSERT (Buffer != NULL);
+
+ return *Buffer;
+}
+
+/**
+ Writes a 16-bit value to memory that may be unaligned.
+
+ This function writes the 16-bit value specified by Value to Buffer. Value is
+ returned. The function guarantees that the write operation does not produce
+ an alignment fault.
+
+ If the Buffer is NULL, then ASSERT().
+
+ @param Buffer Pointer to a 16-bit value that may be unaligned.
+ @param Value 16-bit value to write to Buffer.
+
+ @return Value
+
+**/
+UINT16
+EFIAPI
+WriteUnaligned16 (
+ OUT UINT16 *Buffer,
+ IN UINT16 Value
+ )
+{
+ ASSERT (Buffer != NULL);
+
+ return *Buffer = Value;
+}
+
+/**
+ Reads a 24-bit value from memory that may be unaligned.
+
+ This function returns the 24-bit value pointed to by Buffer. The function
+ guarantees that the read operation does not produce an alignment fault.
+
+ If the Buffer is NULL, then ASSERT().
+
+ @param Buffer Pointer to a 24-bit value that may be unaligned.
+
+ @return The value read.
+
+**/
+UINT32
+EFIAPI
+ReadUnaligned24 (
+ IN CONST UINT32 *Buffer
+ )
+{
+ ASSERT (Buffer != NULL);
+
+ return *Buffer & 0xffffff;
+}
+
+/**
+ Writes a 24-bit value to memory that may be unaligned.
+
+ This function writes the 24-bit value specified by Value to Buffer. Value is
+ returned. The function guarantees that the write operation does not produce
+ an alignment fault.
+
+ If the Buffer is NULL, then ASSERT().
+
+ @param Buffer Pointer to a 24-bit value that may be unaligned.
+ @param Value 24-bit value to write to Buffer.
+
+ @return The value written.
+
+**/
+UINT32
+EFIAPI
+WriteUnaligned24 (
+ OUT UINT32 *Buffer,
+ IN UINT32 Value
+ )
+{
+ ASSERT (Buffer != NULL);
+
+ *Buffer = BitFieldWrite32 (*Buffer, 0, 23, Value);
+ return Value;
+}
+
+/**
+ Reads a 32-bit value from memory that may be unaligned.
+
+ This function returns the 32-bit value pointed to by Buffer. The function
+ guarantees that the read operation does not produce an alignment fault.
+
+ If the Buffer is NULL, then ASSERT().
+
+ @param Buffer Pointer to a 32-bit value that may be unaligned.
+
+ @return *Uint32
+
+**/
+UINT32
+EFIAPI
+ReadUnaligned32 (
+ IN CONST UINT32 *Buffer
+ )
+{
+ ASSERT (Buffer != NULL);
+
+ return *Buffer;
+}
+
+/**
+ Writes a 32-bit value to memory that may be unaligned.
+
+ This function writes the 32-bit value specified by Value to Buffer. Value is
+ returned. The function guarantees that the write operation does not produce
+ an alignment fault.
+
+ If the Buffer is NULL, then ASSERT().
+
+ @param Buffer Pointer to a 32-bit value that may be unaligned.
+ @param Value 32-bit value to write to Buffer.
+
+ @return Value
+
+**/
+UINT32
+EFIAPI
+WriteUnaligned32 (
+ OUT UINT32 *Buffer,
+ IN UINT32 Value
+ )
+{
+ ASSERT (Buffer != NULL);
+
+ return *Buffer = Value;
+}
+
+/**
+ Reads a 64-bit value from memory that may be unaligned.
+
+ This function returns the 64-bit value pointed to by Buffer. The function
+ guarantees that the read operation does not produce an alignment fault.
+
+ If the Buffer is NULL, then ASSERT().
+
+ @param Buffer Pointer to a 64-bit value that may be unaligned.
+
+ @return *Uint64
+
+**/
+UINT64
+EFIAPI
+ReadUnaligned64 (
+ IN CONST UINT64 *Buffer
+ )
+{
+ ASSERT (Buffer != NULL);
+
+ return *Buffer;
+}
+
+/**
+ Writes a 64-bit value to memory that may be unaligned.
+
+ This function writes the 64-bit value specified by Value to Buffer. Value is
+ returned. The function guarantees that the write operation does not produce
+ an alignment fault.
+
+ If the Buffer is NULL, then ASSERT().
+
+ @param Buffer Pointer to a 64-bit value that may be unaligned.
+ @param Value 64-bit value to write to Buffer.
+
+ @return Value
+
+**/
+UINT64
+EFIAPI
+WriteUnaligned64 (
+ OUT UINT64 *Buffer,
+ IN UINT64 Value
+ )
+{
+ ASSERT (Buffer != NULL);
+
+ return *Buffer = Value;
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuBreakpoint.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuBreakpoint.asm
new file mode 100644
index 0000000..cd517d3
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuBreakpoint.asm
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; CpuBreakpoint.Asm
+;
+; Abstract:
+;
+; CpuBreakpoint function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; VOID
+; EFIAPI
+; CpuBreakpoint (
+; VOID
+; );
+;------------------------------------------------------------------------------
+CpuBreakpoint PROC
+ int 3
+ ret
+CpuBreakpoint ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuFlushTlb.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuFlushTlb.asm
new file mode 100644
index 0000000..617c6ad
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuFlushTlb.asm
@@ -0,0 +1,37 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; CpuFlushTlb.Asm
+;
+; Abstract:
+;
+; CpuFlushTlb function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; VOID
+; EFIAPI
+; CpuFlushTlb (
+; VOID
+; );
+;------------------------------------------------------------------------------
+CpuFlushTlb PROC
+ mov rax, cr3
+ mov cr3, rax
+ ret
+CpuFlushTlb ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuId.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuId.asm
new file mode 100644
index 0000000..e46802c
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuId.asm
@@ -0,0 +1,60 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; CpuId.Asm
+;
+; Abstract:
+;
+; AsmCpuid function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; VOID
+; EFIAPI
+; AsmCpuid (
+; IN UINT32 RegisterInEax,
+; OUT UINT32 *RegisterOutEax OPTIONAL,
+; OUT UINT32 *RegisterOutEbx OPTIONAL,
+; OUT UINT32 *RegisterOutEcx OPTIONAL,
+; OUT UINT32 *RegisterOutEdx OPTIONAL
+; )
+;------------------------------------------------------------------------------
+AsmCpuid PROC USES rbx
+ mov eax, ecx
+ push rax ; save Index on stack
+ push rdx
+ cpuid
+ test r9, r9
+ jz @F
+ mov [r9], ecx
+@@:
+ pop rcx
+ jrcxz @F
+ mov [rcx], eax
+@@:
+ mov rcx, r8
+ jrcxz @F
+ mov [rcx], ebx
+@@:
+ mov rcx, [rsp + 38h]
+ jrcxz @F
+ mov [rcx], edx
+@@:
+ pop rax ; restore Index to rax as return value
+ ret
+AsmCpuid ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuIdEx.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuIdEx.asm
new file mode 100644
index 0000000..c6fce10
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuIdEx.asm
@@ -0,0 +1,62 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; CpuIdEx.Asm
+;
+; Abstract:
+;
+; AsmCpuidEx function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; UINT32
+; EFIAPI
+; AsmCpuidEx (
+; IN UINT32 RegisterInEax,
+; IN UINT32 RegisterInEcx,
+; OUT UINT32 *RegisterOutEax OPTIONAL,
+; OUT UINT32 *RegisterOutEbx OPTIONAL,
+; OUT UINT32 *RegisterOutEcx OPTIONAL,
+; OUT UINT32 *RegisterOutEdx OPTIONAL
+; )
+;------------------------------------------------------------------------------
+AsmCpuidEx PROC USES rbx
+ mov eax, ecx
+ mov ecx, edx
+ push rax ; save Index on stack
+ cpuid
+ mov r10, [rsp + 38h]
+ test r10, r10
+ jz @F
+ mov [r10], ecx
+@@:
+ mov rcx, r8
+ jrcxz @F
+ mov [rcx], eax
+@@:
+ mov rcx, r9
+ jrcxz @F
+ mov [rcx], ebx
+@@:
+ mov rcx, [rsp + 40h]
+ jrcxz @F
+ mov [rcx], edx
+@@:
+ pop rax ; restore Index to rax as return value
+ ret
+AsmCpuidEx ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuPause.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuPause.asm
new file mode 100644
index 0000000..680d8ed
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuPause.asm
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; CpuPause.Asm
+;
+; Abstract:
+;
+; CpuPause function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; VOID
+; EFIAPI
+; CpuPause (
+; VOID
+; );
+;------------------------------------------------------------------------------
+CpuPause PROC
+ pause
+ ret
+CpuPause ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuSleep.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuSleep.asm
new file mode 100644
index 0000000..44457f1
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/CpuSleep.asm
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; CpuSleep.Asm
+;
+; Abstract:
+;
+; CpuSleep function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; VOID
+; EFIAPI
+; CpuSleep (
+; VOID
+; );
+;------------------------------------------------------------------------------
+CpuSleep PROC
+ hlt
+ ret
+CpuSleep ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/DisableInterrupts.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/DisableInterrupts.asm
new file mode 100644
index 0000000..90b0c8e
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/DisableInterrupts.asm
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; DisableInterrupts.Asm
+;
+; Abstract:
+;
+; DisableInterrupts function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; VOID
+; EFIAPI
+; DisableInterrupts (
+; VOID
+; );
+;------------------------------------------------------------------------------
+DisableInterrupts PROC
+ cli
+ ret
+DisableInterrupts ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/DisablePaging64.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/DisablePaging64.asm
new file mode 100644
index 0000000..3d86cc5
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/DisablePaging64.asm
@@ -0,0 +1,64 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; DisablePaging64.Asm
+;
+; Abstract:
+;
+; AsmDisablePaging64 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; VOID
+; EFIAPI
+; InternalX86DisablePaging64 (
+; IN UINT16 Cs,
+; IN UINT32 EntryPoint,
+; IN UINT32 Context1, OPTIONAL
+; IN UINT32 Context2, OPTIONAL
+; IN UINT32 NewStack
+; );
+;------------------------------------------------------------------------------
+InternalX86DisablePaging64 PROC
+ cli
+ shl rcx, 32
+ lea eax, @F
+ mov ecx, eax
+ push rcx
+ mov ebx, edx
+ mov esi, r8d
+ mov edi, r9d
+ mov eax, [rsp + 28h]
+ retf
+@@:
+ mov esp, eax ; set up new stack
+ mov rax, cr0
+ btr eax, 31
+ mov cr0, rax ; disable paging
+ mov ecx, 0c0000080h
+ rdmsr
+ and ah, NOT 1 ; clear LME
+ wrmsr
+ mov rax, cr4
+ and al, NOT (1 SHL 5) ; clear PAE
+ mov cr4, rax
+ push rdi
+ push rsi
+ call rbx
+ jmp $
+InternalX86DisablePaging64 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/EnableDisableInterrupts.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/EnableDisableInterrupts.asm
new file mode 100644
index 0000000..3cd7f79
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/EnableDisableInterrupts.asm
@@ -0,0 +1,37 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; EnableDisableInterrupts.Asm
+;
+; Abstract:
+;
+; EnableDisableInterrupts function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; VOID
+; EFIAPI
+; EnableDisableInterrupts (
+; VOID
+; );
+;------------------------------------------------------------------------------
+EnableDisableInterrupts PROC
+ sti
+ cli
+ ret
+EnableDisableInterrupts ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/EnableInterrupts.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/EnableInterrupts.asm
new file mode 100644
index 0000000..a772947
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/EnableInterrupts.asm
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; EnableInterrupts.Asm
+;
+; Abstract:
+;
+; EnableInterrupts function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; VOID
+; EFIAPI
+; EnableInterrupts (
+; VOID
+; );
+;------------------------------------------------------------------------------
+EnableInterrupts PROC
+ sti
+ ret
+EnableInterrupts ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/EnablePaging64.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/EnablePaging64.asm
new file mode 100644
index 0000000..97e90c9
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/EnablePaging64.asm
@@ -0,0 +1,62 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; EnablePaging64.Asm
+;
+; Abstract:
+;
+; AsmEnablePaging64 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; VOID
+; EFIAPI
+; InternalX86EnablePaging64 (
+; IN UINT16 Cs,
+; IN UINT64 EntryPoint,
+; IN UINT64 Context1, OPTIONAL
+; IN UINT64 Context2, OPTIONAL
+; IN UINT64 NewStack
+; );
+;------------------------------------------------------------------------------
+InternalX86EnablePaging64 PROC
+ cli
+ pop rax
+ call @Base
+@Base:
+ add dword ptr [rsp], @F - @Base ; offset for far retf, seg is the 1st arg
+ mov rax, cr4 ; mov eax, cr4
+ or al, (1 SHL 5)
+ mov cr4, rax ; enable PAE
+ mov ecx, 0c0000080h
+ rdmsr
+ or ah, 1 ; set LME
+ wrmsr
+ mov rax, cr0 ; mov eax, cr0
+ bts eax, 31
+ mov cr0, rax ; enable paging
+ retf
+@@: ; long mode starts here
+ mov rbx, [esp]
+ mov rcx, [esp + 8]
+ mov rdx, [esp + 10h]
+ mov rsp, [esp + 18h]
+ add rsp, -20h
+ call rbx
+ jmp $ ; halt processor if EntryPoint() returned
+InternalX86EnablePaging64 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/FlushCacheLine.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/FlushCacheLine.asm
new file mode 100644
index 0000000..5f0a1be
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/FlushCacheLine.asm
@@ -0,0 +1,37 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; FlushCacheLine.Asm
+;
+; Abstract:
+;
+; AsmFlushCacheLine function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; VOID *
+; EFIAPI
+; AsmFlushCacheLine (
+; IN VOID *LinearAddress
+; );
+;------------------------------------------------------------------------------
+AsmFlushCacheLine PROC
+ clflush [rcx]
+ mov rax, rcx
+ ret
+AsmFlushCacheLine ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/FxRestore.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/FxRestore.asm
new file mode 100644
index 0000000..b47184c
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/FxRestore.asm
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; FxRestore.Asm
+;
+; Abstract:
+;
+; AsmFxRestore function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; VOID
+; EFIAPI
+; InternalX86FxRestore (
+; IN CONST IA32_FX_BUFFER *Buffer
+; );
+;------------------------------------------------------------------------------
+InternalX86FxRestore PROC
+ fxrstor [rcx]
+ ret
+InternalX86FxRestore ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/FxSave.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/FxSave.asm
new file mode 100644
index 0000000..e8fcd61
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/FxSave.asm
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; FxSave.Asm
+;
+; Abstract:
+;
+; AsmFxSave function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; VOID
+; EFIAPI
+; InternalX86FxSave (
+; OUT IA32_FX_BUFFER *Buffer
+; );
+;------------------------------------------------------------------------------
+InternalX86FxSave PROC
+ fxsave [rcx]
+ ret
+InternalX86FxSave ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/InterlockedCompareExchange32.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/InterlockedCompareExchange32.asm
new file mode 100644
index 0000000..9450532
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/InterlockedCompareExchange32.asm
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; InterlockedCompareExchange32.Asm
+;
+; Abstract:
+;
+; InterlockedCompareExchange32 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; UINT32
+; EFIAPI
+; InterlockedCompareExchange32 (
+; IN UINT32 *Value,
+; IN UINT32 CompareValue,
+; IN UINT32 ExchangeValue
+; );
+;------------------------------------------------------------------------------
+InternalSyncCompareExchange32 PROC
+ mov eax, edx
+ lock cmpxchg [rcx], r8d
+ ret
+InternalSyncCompareExchange32 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/InterlockedCompareExchange64.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/InterlockedCompareExchange64.asm
new file mode 100644
index 0000000..4391e41
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/InterlockedCompareExchange64.asm
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; InterlockedCompareExchange64.Asm
+;
+; Abstract:
+;
+; InterlockedCompareExchange64 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; UINT64
+; EFIAPI
+; InterlockedCompareExchange64 (
+; IN UINT64 *Value,
+; IN UINT64 CompareValue,
+; IN UINT64 ExchangeValue
+; );
+;------------------------------------------------------------------------------
+InternalSyncCompareExchange64 PROC
+ mov rax, rdx
+ lock cmpxchg [rcx], r8
+ ret
+InternalSyncCompareExchange64 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/InterlockedDecrement.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/InterlockedDecrement.asm
new file mode 100644
index 0000000..ffa1e58
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/InterlockedDecrement.asm
@@ -0,0 +1,37 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; InterlockedDecrement.Asm
+;
+; Abstract:
+;
+; InterlockedDecrement function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; UINT32
+; EFIAPI
+; InterlockedDecrement (
+; IN UINT32 *Value
+; );
+;------------------------------------------------------------------------------
+InternalSyncDecrement PROC
+ lock dec dword ptr [rcx]
+ mov eax, [rcx]
+ ret
+InternalSyncDecrement ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/InterlockedIncrement.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/InterlockedIncrement.asm
new file mode 100644
index 0000000..8e49d8b
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/InterlockedIncrement.asm
@@ -0,0 +1,37 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; InterlockedIncrement.Asm
+;
+; Abstract:
+;
+; InterlockedIncrement function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; UINT32
+; EFIAPI
+; InterlockedIncrement (
+; IN UINT32 *Value
+; );
+;------------------------------------------------------------------------------
+InternalSyncIncrement PROC
+ lock inc dword ptr [rcx]
+ mov eax, [rcx]
+ ret
+InternalSyncIncrement ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Invd.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Invd.asm
new file mode 100644
index 0000000..87775c7
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Invd.asm
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; Invd.Asm
+;
+; Abstract:
+;
+; AsmInvd function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; VOID
+; EFIAPI
+; AsmInvd (
+; VOID
+; );
+;------------------------------------------------------------------------------
+AsmInvd PROC
+ invd
+ ret
+AsmInvd ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/LongJump.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/LongJump.asm
new file mode 100644
index 0000000..e669aee
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/LongJump.asm
@@ -0,0 +1,44 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; LongJump.Asm
+;
+; Abstract:
+;
+; Implementation of _LongJump() on x64.
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; VOID
+; EFIAPI
+; InternalLongJump (
+; IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer,
+; IN UINTN Value
+; );
+;------------------------------------------------------------------------------
+InternalLongJump PROC
+ mov rbx, [rcx]
+ mov rsp, [rcx + 8]
+ mov rbp, [rcx + 10h]
+ mov rdi, [rcx + 18h]
+ mov rsi, [rcx + 20h]
+ mov r12, [rcx + 28h]
+ mov r13, [rcx + 30h]
+ mov r14, [rcx + 38h]
+ mov r15, [rcx + 40h]
+ mov rax, rdx
+ jmp qword ptr [rcx + 48h]
+InternalLongJump ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Monitor.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Monitor.asm
new file mode 100644
index 0000000..88f7dbe
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Monitor.asm
@@ -0,0 +1,41 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; Monitor.Asm
+;
+; Abstract:
+;
+; AsmMonitor function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; UINT64
+; EFIAPI
+; AsmMonitor (
+; IN UINTN Eax,
+; IN UINTN Ecx,
+; IN UINTN Edx
+; );
+;------------------------------------------------------------------------------
+AsmMonitor PROC
+ mov eax, ecx
+ mov ecx, edx
+ mov edx, r8d
+ DB 0fh, 1, 0c8h
+ ret
+AsmMonitor ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Mwait.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Mwait.asm
new file mode 100644
index 0000000..ec66cf6
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Mwait.asm
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; Mwait.Asm
+;
+; Abstract:
+;
+; AsmMwait function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; UINT64
+; EFIAPI
+; AsmMwait (
+; IN UINTN Eax,
+; IN UINTN Ecx
+; );
+;------------------------------------------------------------------------------
+AsmMwait PROC
+ mov eax, ecx
+ mov ecx, edx
+ DB 0fh, 1, 0c9h
+ ret
+AsmMwait ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Non-existing.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Non-existing.c
new file mode 100644
index 0000000..b5c0acd
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Non-existing.c
@@ -0,0 +1,116 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ Non-existing.c
+
+Abstract:
+
+ Non-existing BaseLib functions on x64
+
+--*/
+
+#include "..\BaseLibInternal.h"
+
+/**
+ Enables the 32-bit paging mode on the CPU.
+
+ Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
+ must be properly initialized prior to calling this service. This function
+ assumes the current execution mode is 32-bit protected mode. This function is
+ only available on IA-32. After the 32-bit paging mode is enabled, control is
+ transferred to the function specified by EntryPoint using the new stack
+ specified by NewStack and passing in the parameters specified by Context1 and
+ Context2. Context1 and Context2 are optional and may be NULL. The function
+ EntryPoint must never return.
+
+ There are a number of constraints that must be followed before calling this
+ function:
+ 1) Interrupts must be disabled.
+ 2) The caller must be in 32-bit protected mode with flat descriptors. This
+ means all descriptors must have a base of 0 and a limit of 4GB.
+ 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat
+ descriptors.
+ 4) CR3 must point to valid page tables that will be used once the transition
+ is complete, and those page tables must guarantee that the pages for this
+ function and the stack are identity mapped.
+
+ @param EntryPoint A pointer to function to call with the new stack after
+ paging is enabled.
+ @param Context1 A pointer to the context to pass into the EntryPoint
+ function as the first parameter after paging is enabled.
+ @param Context2 A pointer to the context to pass into the EntryPoint
+ function as the second parameter after paging is enabled.
+ @param NewStack A pointer to the new stack to use for the EntryPoint
+ function after paging is enabled.
+
+**/
+VOID
+EFIAPI
+InternalX86EnablePaging32 (
+ IN SWITCH_STACK_ENTRY_POINT EntryPoint,
+ IN VOID *Context1, OPTIONAL
+ IN VOID *Context2, OPTIONAL
+ IN VOID *NewStack
+ )
+{
+ //
+ // This function cannot work on X64 platform
+ //
+ ASSERT (FALSE);
+}
+
+/**
+ Disables the 32-bit paging mode on the CPU.
+
+ Disables the 32-bit paging mode on the CPU and returns to 32-bit protected
+ mode. This function assumes the current execution mode is 32-paged protected
+ mode. This function is only available on IA-32. After the 32-bit paging mode
+ is disabled, control is transferred to the function specified by EntryPoint
+ using the new stack specified by NewStack and passing in the parameters
+ specified by Context1 and Context2. Context1 and Context2 are optional and
+ may be NULL. The function EntryPoint must never return.
+
+ There are a number of constraints that must be followed before calling this
+ function:
+ 1) Interrupts must be disabled.
+ 2) The caller must be in 32-bit paged mode.
+ 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode.
+ 4) CR3 must point to valid page tables that guarantee that the pages for
+ this function and the stack are identity mapped.
+
+ @param EntryPoint A pointer to function to call with the new stack after
+ paging is disabled.
+ @param Context1 A pointer to the context to pass into the EntryPoint
+ function as the first parameter after paging is disabled.
+ @param Context2 A pointer to the context to pass into the EntryPoint
+ function as the second parameter after paging is
+ disabled.
+ @param NewStack A pointer to the new stack to use for the EntryPoint
+ function after paging is disabled.
+
+**/
+VOID
+EFIAPI
+InternalX86DisablePaging32 (
+ IN SWITCH_STACK_ENTRY_POINT EntryPoint,
+ IN VOID *Context1, OPTIONAL
+ IN VOID *Context2, OPTIONAL
+ IN VOID *NewStack
+ )
+{
+ //
+ // This function cannot work on X64 platform
+ //
+ ASSERT (FALSE);
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadCr0.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadCr0.asm
new file mode 100644
index 0000000..b25df23
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadCr0.asm
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ReadCr0.Asm
+;
+; Abstract:
+;
+; AsmReadCr0 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; UINTN
+; EFIAPI
+; AsmReadCr0 (
+; VOID
+; );
+;------------------------------------------------------------------------------
+AsmReadCr0 PROC
+ mov rax, cr0
+ ret
+AsmReadCr0 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadCr2.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadCr2.asm
new file mode 100644
index 0000000..3416ec6
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadCr2.asm
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ReadCr2.Asm
+;
+; Abstract:
+;
+; AsmReadCr2 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; UINTN
+; EFIAPI
+; AsmReadCr2 (
+; VOID
+; );
+;------------------------------------------------------------------------------
+AsmReadCr2 PROC
+ mov rax, cr2
+ ret
+AsmReadCr2 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadCr3.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadCr3.asm
new file mode 100644
index 0000000..c4130d9
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadCr3.asm
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ReadCr3.Asm
+;
+; Abstract:
+;
+; AsmReadCr3 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; UINTN
+; EFIAPI
+; AsmReadCr3 (
+; VOID
+; );
+;------------------------------------------------------------------------------
+AsmReadCr3 PROC
+ mov rax, cr3
+ ret
+AsmReadCr3 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadCr4.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadCr4.asm
new file mode 100644
index 0000000..a964adb
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadCr4.asm
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ReadCr4.Asm
+;
+; Abstract:
+;
+; AsmReadCr4 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; UINTN
+; EFIAPI
+; AsmReadCr4 (
+; VOID
+; );
+;------------------------------------------------------------------------------
+AsmReadCr4 PROC
+ mov rax, cr4
+ ret
+AsmReadCr4 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadCs.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadCs.asm
new file mode 100644
index 0000000..507209c
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadCs.asm
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ReadCs.Asm
+;
+; Abstract:
+;
+; AsmReadCs function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; UINT16
+; EFIAPI
+; AsmReadCs (
+; VOID
+; );
+;------------------------------------------------------------------------------
+AsmReadCs PROC
+ mov eax, cs
+ ret
+AsmReadCs ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr0.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr0.asm
new file mode 100644
index 0000000..a9748fe
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr0.asm
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ReadDr0.Asm
+;
+; Abstract:
+;
+; AsmReadDr0 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; UINTN
+; EFIAPI
+; AsmReadDr0 (
+; VOID
+; );
+;------------------------------------------------------------------------------
+AsmReadDr0 PROC
+ mov rax, dr0
+ ret
+AsmReadDr0 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr1.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr1.asm
new file mode 100644
index 0000000..a3927b4
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr1.asm
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ReadDr1.Asm
+;
+; Abstract:
+;
+; AsmReadDr1 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; UINTN
+; EFIAPI
+; AsmReadDr1 (
+; VOID
+; );
+;------------------------------------------------------------------------------
+AsmReadDr1 PROC
+ mov rax, dr1
+ ret
+AsmReadDr1 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr2.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr2.asm
new file mode 100644
index 0000000..c71a00d
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr2.asm
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ReadDr2.Asm
+;
+; Abstract:
+;
+; AsmReadDr2 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; UINTN
+; EFIAPI
+; AsmReadDr2 (
+; VOID
+; );
+;------------------------------------------------------------------------------
+AsmReadDr2 PROC
+ mov rax, dr2
+ ret
+AsmReadDr2 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr3.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr3.asm
new file mode 100644
index 0000000..8e5a835
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr3.asm
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ReadDr3.Asm
+;
+; Abstract:
+;
+; AsmReadDr3 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; UINTN
+; EFIAPI
+; AsmReadDr3 (
+; VOID
+; );
+;------------------------------------------------------------------------------
+AsmReadDr3 PROC
+ mov rax, dr3
+ ret
+AsmReadDr3 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr4.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr4.asm
new file mode 100644
index 0000000..da2d793
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr4.asm
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ReadDr4.Asm
+;
+; Abstract:
+;
+; AsmReadDr4 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; UINTN
+; EFIAPI
+; AsmReadDr4 (
+; VOID
+; );
+;------------------------------------------------------------------------------
+AsmReadDr4 PROC
+ DB 0fh, 21h, 0e0h
+ ret
+AsmReadDr4 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr5.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr5.asm
new file mode 100644
index 0000000..2c5cdbc
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr5.asm
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ReadDr5.Asm
+;
+; Abstract:
+;
+; AsmReadDr5 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; UINTN
+; EFIAPI
+; AsmReadDr5 (
+; VOID
+; );
+;------------------------------------------------------------------------------
+AsmReadDr5 PROC
+ DB 0fh, 21h, 0e8h
+ ret
+AsmReadDr5 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr6.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr6.asm
new file mode 100644
index 0000000..5a6cdd3
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr6.asm
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ReadDr6.Asm
+;
+; Abstract:
+;
+; AsmReadDr6 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; UINTN
+; EFIAPI
+; AsmReadDr6 (
+; VOID
+; );
+;------------------------------------------------------------------------------
+AsmReadDr6 PROC
+ mov rax, dr6
+ ret
+AsmReadDr6 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr7.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr7.asm
new file mode 100644
index 0000000..a96a2a4
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDr7.asm
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ReadDr7.Asm
+;
+; Abstract:
+;
+; AsmReadDr7 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; UINTN
+; EFIAPI
+; AsmReadDr7 (
+; VOID
+; );
+;------------------------------------------------------------------------------
+AsmReadDr7 PROC
+ mov rax, dr7
+ ret
+AsmReadDr7 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDs.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDs.asm
new file mode 100644
index 0000000..fe36b76
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadDs.asm
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ReadDs.Asm
+;
+; Abstract:
+;
+; AsmReadDs function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; UINT16
+; EFIAPI
+; AsmReadDs (
+; VOID
+; );
+;------------------------------------------------------------------------------
+AsmReadDs PROC
+ mov eax, ds
+ ret
+AsmReadDs ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadEflags.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadEflags.asm
new file mode 100644
index 0000000..9a399e7
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadEflags.asm
@@ -0,0 +1,37 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ReadEflags.Asm
+;
+; Abstract:
+;
+; AsmReadEflags function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; UINTN
+; EFIAPI
+; AsmReadEflags (
+; VOID
+; );
+;------------------------------------------------------------------------------
+AsmReadEflags PROC
+ pushfq
+ pop rax
+ ret
+AsmReadEflags ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadEs.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadEs.asm
new file mode 100644
index 0000000..4ba0c12
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadEs.asm
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ReadEs.Asm
+;
+; Abstract:
+;
+; AsmReadEs function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; UINT16
+; EFIAPI
+; AsmReadEs (
+; VOID
+; );
+;------------------------------------------------------------------------------
+AsmReadEs PROC
+ mov eax, es
+ ret
+AsmReadEs ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadFs.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadFs.asm
new file mode 100644
index 0000000..7d0d5af
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadFs.asm
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ReadFs.Asm
+;
+; Abstract:
+;
+; AsmReadFs function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; UINT16
+; EFIAPI
+; AsmReadFs (
+; VOID
+; );
+;------------------------------------------------------------------------------
+AsmReadFs PROC
+ mov eax, fs
+ ret
+AsmReadFs ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadGdtr.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadGdtr.asm
new file mode 100644
index 0000000..6c319fd
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadGdtr.asm
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ReadGdtr.Asm
+;
+; Abstract:
+;
+; AsmReadGdtr function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; VOID
+; EFIAPI
+; InternalX86ReadGdtr (
+; OUT IA32_DESCRIPTOR *Gdtr
+; );
+;------------------------------------------------------------------------------
+InternalX86ReadGdtr PROC
+ sgdt fword ptr [rcx]
+ ret
+InternalX86ReadGdtr ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadGs.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadGs.asm
new file mode 100644
index 0000000..321410d
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadGs.asm
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ReadGs.Asm
+;
+; Abstract:
+;
+; AsmReadGs function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; UINT16
+; EFIAPI
+; AsmReadGs (
+; VOID
+; );
+;------------------------------------------------------------------------------
+AsmReadGs PROC
+ mov eax, gs
+ ret
+AsmReadGs ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadIdtr.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadIdtr.asm
new file mode 100644
index 0000000..325c97b
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadIdtr.asm
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ReadIdtr.Asm
+;
+; Abstract:
+;
+; AsmReadIdtr function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; VOID
+; EFIAPI
+; InternalX86ReadIdtr (
+; OUT IA32_DESCRIPTOR *Idtr
+; );
+;------------------------------------------------------------------------------
+InternalX86ReadIdtr PROC
+ sidt fword ptr [rcx]
+ ret
+InternalX86ReadIdtr ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadLdtr.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadLdtr.asm
new file mode 100644
index 0000000..8268e5c
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadLdtr.asm
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ReadLdtr.Asm
+;
+; Abstract:
+;
+; AsmReadLdtr function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; UINT16
+; EFIAPI
+; AsmReadLdtr (
+; VOID
+; );
+;------------------------------------------------------------------------------
+AsmReadLdtr PROC
+ sldt eax
+ ret
+AsmReadLdtr ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm0.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm0.asm
new file mode 100644
index 0000000..31090d5
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm0.asm
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ReadMm0.Asm
+;
+; Abstract:
+;
+; AsmReadMm0 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; UINT64
+; EFIAPI
+; AsmReadMm0 (
+; VOID
+; );
+;------------------------------------------------------------------------------
+AsmReadMm0 PROC
+ DB 48h, 0fh, 7eh, 0c0h
+ ret
+AsmReadMm0 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm1.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm1.asm
new file mode 100644
index 0000000..d2a4f5f
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm1.asm
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ReadMm1.Asm
+;
+; Abstract:
+;
+; AsmReadMm1 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; UINT64
+; EFIAPI
+; AsmReadMm1 (
+; VOID
+; );
+;------------------------------------------------------------------------------
+AsmReadMm1 PROC
+ DB 48h, 0fh, 7eh, 0c8h
+ ret
+AsmReadMm1 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm2.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm2.asm
new file mode 100644
index 0000000..c6ac1d6
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm2.asm
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ReadMm2.Asm
+;
+; Abstract:
+;
+; AsmReadMm2 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; UINT64
+; EFIAPI
+; AsmReadMm2 (
+; VOID
+; );
+;------------------------------------------------------------------------------
+AsmReadMm2 PROC
+ DB 48h, 0fh, 7eh, 0d0h
+ ret
+AsmReadMm2 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm3.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm3.asm
new file mode 100644
index 0000000..2a3cd6e
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm3.asm
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ReadMm3.Asm
+;
+; Abstract:
+;
+; AsmReadMm3 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; UINT64
+; EFIAPI
+; AsmReadMm3 (
+; VOID
+; );
+;------------------------------------------------------------------------------
+AsmReadMm3 PROC
+ DB 48h, 0fh, 7eh, 0d8h
+ ret
+AsmReadMm3 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm4.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm4.asm
new file mode 100644
index 0000000..1b03ad1
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm4.asm
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ReadMm4.Asm
+;
+; Abstract:
+;
+; AsmReadMm4 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; UINT64
+; EFIAPI
+; AsmReadMm4 (
+; VOID
+; );
+;------------------------------------------------------------------------------
+AsmReadMm4 PROC
+ DB 48h, 0fh, 7eh, 0e0h
+ ret
+AsmReadMm4 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm5.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm5.asm
new file mode 100644
index 0000000..c7f9ecf
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm5.asm
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ReadMm5.Asm
+;
+; Abstract:
+;
+; AsmReadMm5 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; UINT64
+; EFIAPI
+; AsmReadMm5 (
+; VOID
+; );
+;------------------------------------------------------------------------------
+AsmReadMm5 PROC
+ DB 48h, 0fh, 7eh, 0e8h
+ ret
+AsmReadMm5 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm6.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm6.asm
new file mode 100644
index 0000000..19eaf0d
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm6.asm
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ReadMm6.Asm
+;
+; Abstract:
+;
+; AsmReadMm6 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; UINT64
+; EFIAPI
+; AsmReadMm6 (
+; VOID
+; );
+;------------------------------------------------------------------------------
+AsmReadMm6 PROC
+ DB 48h, 0fh, 7eh, 0f0h
+ ret
+AsmReadMm6 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm7.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm7.asm
new file mode 100644
index 0000000..595b829
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMm7.asm
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ReadMm7.Asm
+;
+; Abstract:
+;
+; AsmReadMm7 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; UINT64
+; EFIAPI
+; AsmReadMm7 (
+; VOID
+; );
+;------------------------------------------------------------------------------
+AsmReadMm7 PROC
+ DB 48h, 0fh, 7eh, 0f8h
+ ret
+AsmReadMm7 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMsr64.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMsr64.asm
new file mode 100644
index 0000000..328c12e
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadMsr64.asm
@@ -0,0 +1,38 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ReadMsr64.Asm
+;
+; Abstract:
+;
+; AsmReadMsr64 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; UINT64
+; EFIAPI
+; AsmReadMsr64 (
+; IN UINT32 Index
+; );
+;------------------------------------------------------------------------------
+AsmReadMsr64 PROC
+ rdmsr ; edx & eax are zero extended
+ shl rdx, 20h
+ or rax, rdx
+ ret
+AsmReadMsr64 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadPmc.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadPmc.asm
new file mode 100644
index 0000000..3e958dc
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadPmc.asm
@@ -0,0 +1,38 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ReadPmc.Asm
+;
+; Abstract:
+;
+; AsmReadPmc function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; UINT64
+; EFIAPI
+; AsmReadPmc (
+; IN UINT32 PmcIndex
+; );
+;------------------------------------------------------------------------------
+AsmReadPmc PROC
+ rdpmc
+ shl rdx, 20h
+ or rax, rdx
+ ret
+AsmReadPmc ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadSs.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadSs.asm
new file mode 100644
index 0000000..02d950d
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadSs.asm
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ReadSs.Asm
+;
+; Abstract:
+;
+; AsmReadSs function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; UINT16
+; EFIAPI
+; AsmReadSs (
+; VOID
+; );
+;------------------------------------------------------------------------------
+AsmReadSs PROC
+ mov eax, ss
+ ret
+AsmReadSs ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadTr.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadTr.asm
new file mode 100644
index 0000000..ad17008
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadTr.asm
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ReadTr.Asm
+;
+; Abstract:
+;
+; AsmReadTr function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; UINT16
+; EFIAPI
+; AsmReadTr (
+; VOID
+; );
+;------------------------------------------------------------------------------
+AsmReadTr PROC
+ str eax
+ ret
+AsmReadTr ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadTsc.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadTsc.asm
new file mode 100644
index 0000000..67329a9
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/ReadTsc.asm
@@ -0,0 +1,38 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ReadTsc.Asm
+;
+; Abstract:
+;
+; AsmReadTsc function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; UINT64
+; EFIAPI
+; AsmReadTsc (
+; VOID
+; );
+;------------------------------------------------------------------------------
+AsmReadTsc PROC
+ rdtsc
+ shl rdx, 20h
+ or rax, rdx
+ ret
+AsmReadTsc ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/SetJump.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/SetJump.asm
new file mode 100644
index 0000000..78d238a
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/SetJump.asm
@@ -0,0 +1,52 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; SetJump.Asm
+;
+; Abstract:
+;
+; Implementation of SetJump() on x64.
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+EXTERNDEF InternalAssertJumpBuffer:PROC
+
+;------------------------------------------------------------------------------
+; UINTN
+; EFIAPI
+; SetJump (
+; OUT BASE_LIBRARY_JUMP_BUFFER *JumpBuffer
+; );
+;------------------------------------------------------------------------------
+SetJump PROC
+ push rcx
+ add rsp, -20h
+ call InternalAssertJumpBuffer
+ add rsp, 20h
+ pop rcx
+ pop rdx
+ mov [rcx], rbx
+ mov [rcx + 8], rsp
+ mov [rcx + 10h], rbp
+ mov [rcx + 18h], rdi
+ mov [rcx + 20h], rsi
+ mov [rcx + 28h], r12
+ mov [rcx + 30h], r13
+ mov [rcx + 38h], r14
+ mov [rcx + 40h], r15
+ mov [rcx + 48h], rdx
+ xor rax, rax
+ jmp rdx
+SetJump ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/SwitchStack.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/SwitchStack.asm
new file mode 100644
index 0000000..dcfafe3
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/SwitchStack.asm
@@ -0,0 +1,45 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; SwitchStack.Asm
+;
+; Abstract:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; Routine Description:
+;
+; Routine for switching stacks with 1 parameter
+;
+; Arguments:
+;
+; (rcx) EntryPoint - Entry point with new stack.
+; (rdx) Context - Parameter for entry point.
+; (r8) Context2 - Parameter2 for entry point.
+; (r9) NewStack - Pointer to new stack.
+;
+; Returns:
+;
+; None
+;
+;------------------------------------------------------------------------------
+InternalSwitchStack PROC
+ mov rax, rcx
+ mov rcx, rdx
+ mov rdx, r8
+ lea rsp, [r9 - 20h]
+ call rax
+InternalSwitchStack ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Thunk16.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Thunk16.asm
new file mode 100644
index 0000000..243c053
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Thunk16.asm
@@ -0,0 +1,251 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; Thunk.asm
+;
+; Abstract:
+;
+; Real mode thunk
+;
+;------------------------------------------------------------------------------
+
+EXTERNDEF m16Start:BYTE
+EXTERNDEF m16Size:WORD
+EXTERNDEF mThunk16Attr:WORD
+EXTERNDEF m16Gdt:WORD
+EXTERNDEF m16GdtrBase:WORD
+EXTERNDEF mTransition:WORD
+
+THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 EQU 2
+THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL EQU 4
+
+IA32_REGS STRUC 4t
+_EDI DD ?
+_ESI DD ?
+_EBP DD ?
+_ESP DD ?
+_EBX DD ?
+_EDX DD ?
+_ECX DD ?
+_EAX DD ?
+_DS DW ?
+_ES DW ?
+_FS DW ?
+_GS DW ?
+_EFLAGS DQ ?
+_EIP DD ?
+_CS DW ?
+_SS DW ?
+IA32_REGS ENDS
+
+ .const
+
+m16Size DW InternalAsmThunk16 - m16Start
+mThunk16Attr DW _ThunkAttr - m16Start
+m16Gdt DW _NullSegDesc - m16Start
+m16GdtrBase DW _16GdtrBase - m16Start
+mTransition DW _EntryPoint - m16Start
+
+ .code
+
+m16Start LABEL BYTE
+
+SavedGdt LABEL FWORD
+ DW ?
+ DQ ?
+
+;------------------------------------------------------------------------------
+; _BackFromUserCode() takes control in real mode after 'retf' has been executed
+; by user code. It will be shadowed to somewhere in memory below 1MB.
+;------------------------------------------------------------------------------
+_BackFromUserCode PROC
+ DB 16h ; push ss
+ DB 0eh ; push cs
+ DB 66h
+ call @Base ; push eip
+@Base:
+ DB 66h
+ push 0 ; reserved high order 32 bits of EFlags
+ pushf ; pushfd actually
+ cli ; disable interrupts
+ push gs
+ push fs
+ DB 6 ; push es
+ DB 1eh ; push ds
+ DB 66h, 60h ; pushad
+ DB 66h, 0bah ; mov edx, imm32
+_ThunkAttr DD ?
+ test dl, THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15
+ jz @1
+ mov eax, 15cd2401h ; mov ax, 2401h & int 15h
+ cli ; disable interrupts
+ jnc @2
+@1:
+ test dl, THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL
+ jz @2
+ in al, 92h
+ or al, 2
+ out 92h, al ; deactivate A20M#
+@2:
+ xor ax, ax ; xor eax, eax
+ mov eax, ss
+ lea bp, [esp + sizeof (IA32_REGS)]
+ mov word ptr (IA32_REGS ptr [rsi - sizeof (IA32_REGS)])._ESP, bp
+ mov ebx, (IA32_REGS ptr [rsi - sizeof (IA32_REGS)])._EIP
+ shl ax, 4 ; shl eax, 4
+ add bp, ax ; add ebp, eax
+ DB 66h, 0b8h ; mov eax, imm32
+SavedCr4 DD ?
+ mov cr4, rax
+ DB 66h, 2eh
+ lgdt fword ptr [rdi + (SavedGdt - @Base)]
+ DB 66h
+ mov ecx, 0c0000080h
+ rdmsr
+ or ah, 1
+ wrmsr
+ DB 66h, 0b8h ; mov eax, imm32
+SavedCr0 DD ?
+ mov cr0, rax
+ DB 0b8h ; mov ax, imm16
+SavedSs DW ?
+ mov ss, eax
+ DB 66h, 0bch ; mov esp, imm32
+SavedEsp DD ?
+ DB 66h
+ retf ; return to protected mode
+_BackFromUserCode ENDP
+
+_EntryPoint DD _ToUserCode - m16Start
+ DW 8h
+_16Gdtr LABEL FWORD
+ DW GdtEnd - _NullSegDesc - 1
+_16GdtrBase DQ _NullSegDesc
+_16Idtr FWORD (1 SHL 10) - 1
+
+;------------------------------------------------------------------------------
+; _ToUserCode() takes control in real mode before passing control to user code.
+; It will be shadowed to somewhere in memory below 1MB.
+;------------------------------------------------------------------------------
+_ToUserCode PROC
+ mov edi, ss
+ mov ss, edx ; set new segment selectors
+ mov ds, edx
+ mov es, edx
+ mov fs, edx
+ mov gs, edx
+ DB 66h
+ mov ecx, 0c0000080h
+ mov cr0, rax ; real mode starts at next instruction
+ rdmsr
+ and ah, NOT 1
+ wrmsr
+ mov cr4, rbp
+ mov ss, esi ; set up 16-bit stack segment
+ xchg sp, bx ; set up 16-bit stack pointer
+ DB 66h
+ call @Base ; push eip
+@Base:
+ pop bp ; ebp <- address of @Base
+ push [esp + sizeof (IA32_REGS) + 2]
+ lea eax, [rsi + (@RealMode - @Base)]
+ push rax
+ retf
+@RealMode:
+ DB 2eh ; cs:
+ mov [rsi + (SavedSs - @Base)], edi
+ DB 2eh ; cs:
+ mov [rsi + (SavedEsp - @Base)], bx
+ DB 66h, 2eh ; CS and operand size override
+ lidt fword ptr [rsi + (_16Idtr - @Base)]
+ DB 66h, 61h ; popad
+ DB 1fh ; pop ds
+ DB 07h ; pop es
+ pop fs
+ pop gs
+ popf ; popfd
+ lea sp, [esp + 4] ; skip high order 32 bits of EFlags
+ DB 66h
+ retf ; transfer control to user code
+_ToUserCode ENDP
+
+_NullSegDesc DQ 0
+_16CsDesc LABEL QWORD
+ DW -1
+ DW 0
+ DB 0
+ DB 9bh
+ DB 8fh ; 16-bit segment, 4GB limit
+ DB 0
+_16DsDesc LABEL QWORD
+ DW -1
+ DW 0
+ DB 0
+ DB 93h
+ DB 8fh ; 16-bit segment, 4GB limit
+ DB 0
+GdtEnd LABEL QWORD
+
+;------------------------------------------------------------------------------
+; IA32_REGISTER_SET *
+; EFIAPI
+; InternalAsmThunk16 (
+; IN IA32_REGISTER_SET *RegisterSet,
+; IN OUT VOID *Transition
+; );
+;------------------------------------------------------------------------------
+InternalAsmThunk16 PROC USES rbp rbx rsi rdi
+ mov r10d, ds
+ mov r11d, es
+ push fs
+ push gs
+ mov rsi, rcx
+ movzx r8d, (IA32_REGS ptr [rsi])._SS
+ mov edi, (IA32_REGS ptr [rsi])._ESP
+ lea rdi, [edi - (sizeof (IA32_REGS) + 4)]
+ imul eax, r8d, 16 ; eax <- r8d(stack segment) * 16
+ mov ebx, edi ; ebx <- stack for 16-bit code
+ push sizeof (IA32_REGS) / 4
+ add edi, eax ; edi <- linear address of 16-bit stack
+ pop rcx
+ rep movsd ; copy RegSet
+ lea ecx, [rdx + (SavedCr4 - m16Start)]
+ mov eax, edx ; eax <- transition code address
+ and edx, 0fh
+ shl eax, 12
+ lea edx, [rdx + (_BackFromUserCode - m16Start)]
+ mov ax, dx
+ stosd ; [edi] <- return address of user code
+ sgdt fword ptr [rcx + (SavedGdt - SavedCr4)]
+ sidt fword ptr [rsp + 38h] ; save IDT stack in argument space
+ mov rax, cr0
+ mov [rcx + (SavedCr0 - SavedCr4)], eax
+ and eax, 7ffffffeh ; clear PE, PG bits
+ mov rbp, cr4
+ mov [rcx], ebp ; save CR4 in SavedCr4
+ and ebp, 300h ; clear all but PCE and OSFXSR bits
+ mov esi, r8d ; esi <- 16-bit stack segment
+ push 10h
+ pop rdx ; rdx <- selector for data segments
+ lgdt fword ptr [rcx + (_16Gdtr - SavedCr4)]
+ pushfq
+ call fword ptr [rcx + (_EntryPoint - SavedCr4)]
+ popfq
+ lidt fword ptr [rsp + 38h] ; restore protected mode IDTR
+ lea eax, [rbp - sizeof (IA32_REGS)]
+ pop gs
+ pop fs
+ mov es, r11d
+ mov ds, r10d
+ ret
+InternalAsmThunk16 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Wbinvd.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Wbinvd.asm
new file mode 100644
index 0000000..0349ec7
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/Wbinvd.asm
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; Wbinvd.Asm
+;
+; Abstract:
+;
+; AsmWbinvd function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; VOID
+; EFIAPI
+; AsmWbinvd (
+; VOID
+; );
+;------------------------------------------------------------------------------
+AsmWbinvd PROC
+ wbinvd
+ ret
+AsmWbinvd ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteCr0.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteCr0.asm
new file mode 100644
index 0000000..b321dd2
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteCr0.asm
@@ -0,0 +1,37 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; WriteCr0.Asm
+;
+; Abstract:
+;
+; AsmWriteCr0 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; UINTN
+; EFIAPI
+; AsmWriteCr0 (
+; UINTN Cr0
+; );
+;------------------------------------------------------------------------------
+AsmWriteCr0 PROC
+ mov cr0, rcx
+ mov rax, rcx
+ ret
+AsmWriteCr0 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteCr2.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteCr2.asm
new file mode 100644
index 0000000..7a44b69
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteCr2.asm
@@ -0,0 +1,37 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; WriteCr2.Asm
+;
+; Abstract:
+;
+; AsmWriteCr2 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; UINTN
+; EFIAPI
+; AsmWriteCr2 (
+; UINTN Cr2
+; );
+;------------------------------------------------------------------------------
+AsmWriteCr2 PROC
+ mov cr2, rcx
+ mov rax, rcx
+ ret
+AsmWriteCr2 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteCr3.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteCr3.asm
new file mode 100644
index 0000000..867eb3e
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteCr3.asm
@@ -0,0 +1,37 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; WriteCr3.Asm
+;
+; Abstract:
+;
+; AsmWriteCr3 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; UINTN
+; EFIAPI
+; AsmWriteCr3 (
+; UINTN Cr3
+; );
+;------------------------------------------------------------------------------
+AsmWriteCr3 PROC
+ mov cr3, rcx
+ mov rax, rcx
+ ret
+AsmWriteCr3 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteCr4.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteCr4.asm
new file mode 100644
index 0000000..765d8d1
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteCr4.asm
@@ -0,0 +1,37 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; WriteCr4.Asm
+;
+; Abstract:
+;
+; AsmWriteCr4 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; UINTN
+; EFIAPI
+; AsmWriteCr4 (
+; UINTN Cr4
+; );
+;------------------------------------------------------------------------------
+AsmWriteCr4 PROC
+ mov cr4, rcx
+ mov rax, rcx
+ ret
+AsmWriteCr4 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr0.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr0.asm
new file mode 100644
index 0000000..4762337
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr0.asm
@@ -0,0 +1,37 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; WriteDr0.Asm
+;
+; Abstract:
+;
+; AsmWriteDr0 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; UINTN
+; EFIAPI
+; AsmWriteDr0 (
+; IN UINTN Value
+; );
+;------------------------------------------------------------------------------
+AsmWriteDr0 PROC
+ mov dr0, rcx
+ mov rax, rcx
+ ret
+AsmWriteDr0 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr1.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr1.asm
new file mode 100644
index 0000000..11c5b7f
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr1.asm
@@ -0,0 +1,37 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; WriteDr1.Asm
+;
+; Abstract:
+;
+; AsmWriteDr1 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; UINTN
+; EFIAPI
+; AsmWriteDr1 (
+; IN UINTN Value
+; );
+;------------------------------------------------------------------------------
+AsmWriteDr1 PROC
+ mov dr1, rcx
+ mov rax, rcx
+ ret
+AsmWriteDr1 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr2.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr2.asm
new file mode 100644
index 0000000..42ecea9
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr2.asm
@@ -0,0 +1,37 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; WriteDr2.Asm
+;
+; Abstract:
+;
+; AsmWriteDr2 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; UINTN
+; EFIAPI
+; AsmWriteDr2 (
+; IN UINTN Value
+; );
+;------------------------------------------------------------------------------
+AsmWriteDr2 PROC
+ mov dr2, rcx
+ mov rax, rcx
+ ret
+AsmWriteDr2 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr3.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr3.asm
new file mode 100644
index 0000000..c0bbead
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr3.asm
@@ -0,0 +1,37 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; WriteDr3.Asm
+;
+; Abstract:
+;
+; AsmWriteDr3 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; UINTN
+; EFIAPI
+; AsmWriteDr3 (
+; IN UINTN Value
+; );
+;------------------------------------------------------------------------------
+AsmWriteDr3 PROC
+ mov dr3, rcx
+ mov rax, rcx
+ ret
+AsmWriteDr3 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr4.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr4.asm
new file mode 100644
index 0000000..adb4d2f
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr4.asm
@@ -0,0 +1,37 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; WriteDr4.Asm
+;
+; Abstract:
+;
+; AsmWriteDr4 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; UINTN
+; EFIAPI
+; AsmWriteDr4 (
+; IN UINTN Value
+; );
+;------------------------------------------------------------------------------
+AsmWriteDr4 PROC
+ DB 0fh, 23h, 0e1h
+ mov rax, rcx
+ ret
+AsmWriteDr4 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr5.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr5.asm
new file mode 100644
index 0000000..dc15442
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr5.asm
@@ -0,0 +1,37 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; WriteDr5.Asm
+;
+; Abstract:
+;
+; AsmWriteDr5 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; UINTN
+; EFIAPI
+; AsmWriteDr6 (
+; IN UINTN Value
+; );
+;------------------------------------------------------------------------------
+AsmWriteDr5 PROC
+ DB 0fh, 23h, 0e9h
+ mov rax, rcx
+ ret
+AsmWriteDr5 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr6.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr6.asm
new file mode 100644
index 0000000..7c94162
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr6.asm
@@ -0,0 +1,37 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; WriteDr6.Asm
+;
+; Abstract:
+;
+; AsmWriteDr6 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; UINTN
+; EFIAPI
+; AsmWriteDr6 (
+; IN UINTN Value
+; );
+;------------------------------------------------------------------------------
+AsmWriteDr6 PROC
+ mov dr6, rcx
+ mov rax, rcx
+ ret
+AsmWriteDr6 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr7.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr7.asm
new file mode 100644
index 0000000..bf7a43f
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteDr7.asm
@@ -0,0 +1,37 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; WriteDr7.Asm
+;
+; Abstract:
+;
+; AsmWriteDr7 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; UINTN
+; EFIAPI
+; AsmWriteDr7 (
+; IN UINTN Value
+; );
+;------------------------------------------------------------------------------
+AsmWriteDr7 PROC
+ mov dr7, rcx
+ mov rax, rcx
+ ret
+AsmWriteDr7 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteGdtr.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteGdtr.asm
new file mode 100644
index 0000000..b288963
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteGdtr.asm
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; WriteGdtr.Asm
+;
+; Abstract:
+;
+; AsmWriteGdtr function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; VOID
+; EFIAPI
+; InternalX86WriteGdtr (
+; IN CONST IA32_DESCRIPTOR *Idtr
+; );
+;------------------------------------------------------------------------------
+InternalX86WriteGdtr PROC
+ lgdt fword ptr [rcx]
+ ret
+InternalX86WriteGdtr ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteIdtr.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteIdtr.asm
new file mode 100644
index 0000000..d2d9660
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteIdtr.asm
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; WriteIdtr.Asm
+;
+; Abstract:
+;
+; AsmWriteIdtr function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; VOID
+; EFIAPI
+; InternalX86WriteIdtr (
+; IN CONST IA32_DESCRIPTOR *Idtr
+; );
+;------------------------------------------------------------------------------
+InternalX86WriteIdtr PROC
+ lidt fword ptr [rcx]
+ ret
+InternalX86WriteIdtr ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteLdtr.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteLdtr.asm
new file mode 100644
index 0000000..a026776
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteLdtr.asm
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; WriteLdtr.Asm
+;
+; Abstract:
+;
+; AsmWriteLdtr function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; VOID
+; EFIAPI
+; AsmWriteLdtr (
+; IN UINT16 Ldtr
+; );
+;------------------------------------------------------------------------------
+AsmWriteLdtr PROC
+ lldt cx
+ ret
+AsmWriteLdtr ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm0.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm0.asm
new file mode 100644
index 0000000..c6adfbf
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm0.asm
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; WriteMm0.Asm
+;
+; Abstract:
+;
+; AsmWriteMm0 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; VOID
+; EFIAPI
+; AsmWriteMm0 (
+; IN UINT64 Value
+; );
+;------------------------------------------------------------------------------
+AsmWriteMm0 PROC
+ DB 48h, 0fh, 6eh, 0c1h
+ ret
+AsmWriteMm0 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm1.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm1.asm
new file mode 100644
index 0000000..b941ade
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm1.asm
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; WriteMm1.Asm
+;
+; Abstract:
+;
+; AsmWriteMm1 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; VOID
+; EFIAPI
+; AsmWriteMm1 (
+; IN UINT64 Value
+; );
+;------------------------------------------------------------------------------
+AsmWriteMm1 PROC
+ DB 48h, 0fh, 6eh, 0c9h
+ ret
+AsmWriteMm1 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm2.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm2.asm
new file mode 100644
index 0000000..218c625
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm2.asm
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; WriteMm2.Asm
+;
+; Abstract:
+;
+; AsmWriteMm2 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; VOID
+; EFIAPI
+; AsmWriteMm2 (
+; IN UINT64 Value
+; );
+;------------------------------------------------------------------------------
+AsmWriteMm2 PROC
+ DB 48h, 0fh, 6eh, 0d1h
+ ret
+AsmWriteMm2 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm3.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm3.asm
new file mode 100644
index 0000000..c374b9a
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm3.asm
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; WriteMm3.Asm
+;
+; Abstract:
+;
+; AsmWriteMm3 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; VOID
+; EFIAPI
+; AsmWriteMm3 (
+; IN UINT64 Value
+; );
+;------------------------------------------------------------------------------
+AsmWriteMm3 PROC
+ DB 48h, 0fh, 6eh, 0d9h
+ ret
+AsmWriteMm3 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm4.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm4.asm
new file mode 100644
index 0000000..a69193e
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm4.asm
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; WriteMm4.Asm
+;
+; Abstract:
+;
+; AsmWriteMm4 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; VOID
+; EFIAPI
+; AsmWriteMm4 (
+; IN UINT64 Value
+; );
+;------------------------------------------------------------------------------
+AsmWriteMm4 PROC
+ DB 48h, 0fh, 6eh, 0e1h
+ ret
+AsmWriteMm4 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm5.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm5.asm
new file mode 100644
index 0000000..6e50afc
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm5.asm
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; WriteMm5.Asm
+;
+; Abstract:
+;
+; AsmWriteMm5 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; VOID
+; EFIAPI
+; AsmWriteMm5 (
+; IN UINT64 Value
+; );
+;------------------------------------------------------------------------------
+AsmWriteMm5 PROC
+ DB 48h, 0fh, 6eh, 0e9h
+ ret
+AsmWriteMm5 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm6.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm6.asm
new file mode 100644
index 0000000..aed61e4
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm6.asm
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; WriteMm6.Asm
+;
+; Abstract:
+;
+; AsmWriteMm6 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; VOID
+; EFIAPI
+; AsmWriteMm6 (
+; IN UINT64 Value
+; );
+;------------------------------------------------------------------------------
+AsmWriteMm6 PROC
+ DB 48h, 0fh, 6eh, 0f1h
+ ret
+AsmWriteMm6 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm7.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm7.asm
new file mode 100644
index 0000000..ec42248
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMm7.asm
@@ -0,0 +1,36 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; WriteMm7.Asm
+;
+; Abstract:
+;
+; AsmWriteMm7 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; VOID
+; EFIAPI
+; AsmWriteMm7 (
+; IN UINT64 Value
+; );
+;------------------------------------------------------------------------------
+AsmWriteMm7 PROC
+ DB 48h, 0fh, 6eh, 0f9h
+ ret
+AsmWriteMm7 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMsr64.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMsr64.asm
new file mode 100644
index 0000000..a37caf5
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/WriteMsr64.asm
@@ -0,0 +1,39 @@
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; WriteMsr64.Asm
+;
+; Abstract:
+;
+; AsmWriteMsr64 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; UINT64
+; EFIAPI
+; AsmWriteMsr64 (
+; IN UINT32 Index,
+; IN UINT64 Value
+; );
+;------------------------------------------------------------------------------
+AsmWriteMsr64 PROC
+ mov rax, rdx
+ shr rdx, 20h
+ wrmsr
+ ret
+AsmWriteMsr64 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86DisablePaging32.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86DisablePaging32.c
new file mode 100644
index 0000000..db4b66d
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86DisablePaging32.c
@@ -0,0 +1,71 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ x86DisablePaging32.c
+
+Abstract:
+
+ IA-32/x64 specific functions.
+
+--*/
+
+#include "BaseLibInternal.h"
+
+/**
+ Disables the 32-bit paging mode on the CPU.
+
+ Disables the 32-bit paging mode on the CPU and returns to 32-bit protected
+ mode. This function assumes the current execution mode is 32-paged protected
+ mode. This function is only available on IA-32. After the 32-bit paging mode
+ is disabled, control is transferred to the function specified by EntryPoint
+ using the new stack specified by NewStack and passing in the parameters
+ specified by Context1 and Context2. Context1 and Context2 are optional and
+ may be NULL. The function EntryPoint must never return.
+
+ If the current execution mode is not 32-bit paged mode, then ASSERT().
+ If EntryPoint is NULL, then ASSERT().
+ If NewStack is NULL, then ASSERT().
+
+ There are a number of constraints that must be followed before calling this
+ function:
+ 1) Interrupts must be disabled.
+ 2) The caller must be in 32-bit paged mode.
+ 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode.
+ 4) CR3 must point to valid page tables that guarantee that the pages for
+ this function and the stack are identity mapped.
+
+ @param EntryPoint A pointer to function to call with the new stack after
+ paging is disabled.
+ @param Context1 A pointer to the context to pass into the EntryPoint
+ function as the first parameter after paging is disabled.
+ @param Context2 A pointer to the context to pass into the EntryPoint
+ function as the second parameter after paging is
+ disabled.
+ @param NewStack A pointer to the new stack to use for the EntryPoint
+ function after paging is disabled.
+
+**/
+VOID
+EFIAPI
+AsmDisablePaging32 (
+ IN SWITCH_STACK_ENTRY_POINT EntryPoint,
+ IN VOID *Context1, OPTIONAL
+ IN VOID *Context2, OPTIONAL
+ IN VOID *NewStack
+ )
+{
+ ASSERT (EntryPoint != NULL);
+ ASSERT (NewStack != NULL);
+ InternalX86DisablePaging32 (EntryPoint, Context1, Context2, NewStack);
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86DisablePaging64.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86DisablePaging64.c
new file mode 100644
index 0000000..d4bf650
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86DisablePaging64.c
@@ -0,0 +1,68 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ x86DisablePaging64.c
+
+Abstract:
+
+ IA-32/x64 specific functions.
+
+--*/
+
+#include "BaseLibInternal.h"
+
+/**
+ Disables the 64-bit paging mode on the CPU.
+
+ Disables the 64-bit paging mode on the CPU and returns to 32-bit protected
+ mode. This function assumes the current execution mode is 64-paging mode.
+ This function is only available on X64. After the 64-bit paging mode is
+ disabled, control is transferred to the function specified by EntryPoint
+ using the new stack specified by NewStack and passing in the parameters
+ specified by Context1 and Context2. Context1 and Context2 are optional and
+ may be 0. The function EntryPoint must never return.
+
+ If the current execution mode is not 64-bit paged mode, then ASSERT().
+ If EntryPoint is 0, then ASSERT().
+ If NewStack is 0, then ASSERT().
+
+ @param Cs The 16-bit selector to load in the CS before EntryPoint
+ is called. The descriptor in the GDT that this selector
+ references must be setup for 32-bit protected mode.
+ @param EntryPoint The 64-bit virtual address of the function to call with
+ the new stack after paging is disabled.
+ @param Context1 The 64-bit virtual address of the context to pass into
+ the EntryPoint function as the first parameter after
+ paging is disabled.
+ @param Context2 The 64-bit virtual address of the context to pass into
+ the EntryPoint function as the second parameter after
+ paging is disabled.
+ @param NewStack The 64-bit virtual address of the new stack to use for
+ the EntryPoint function after paging is disabled.
+
+**/
+VOID
+EFIAPI
+AsmDisablePaging64 (
+ IN UINT16 Cs,
+ IN UINT32 EntryPoint,
+ IN UINT32 Context1, OPTIONAL
+ IN UINT32 Context2, OPTIONAL
+ IN UINT32 NewStack
+ )
+{
+ ASSERT (EntryPoint != 0);
+ ASSERT (NewStack != 0);
+ InternalX86DisablePaging64 (Cs, EntryPoint, Context1, Context2, NewStack);
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86EnablePaging32.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86EnablePaging32.c
new file mode 100644
index 0000000..44b0ee4
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86EnablePaging32.c
@@ -0,0 +1,74 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ x86EnablePaging32.c
+
+Abstract:
+
+ IA-32/x64 specific functions.
+
+--*/
+
+#include "BaseLibInternal.h"
+
+/**
+ Enables the 32-bit paging mode on the CPU.
+
+ Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
+ must be properly initialized prior to calling this service. This function
+ assumes the current execution mode is 32-bit protected mode. This function is
+ only available on IA-32. After the 32-bit paging mode is enabled, control is
+ transferred to the function specified by EntryPoint using the new stack
+ specified by NewStack and passing in the parameters specified by Context1 and
+ Context2. Context1 and Context2 are optional and may be NULL. The function
+ EntryPoint must never return.
+
+ If the current execution mode is not 32-bit protected mode, then ASSERT().
+ If EntryPoint is NULL, then ASSERT().
+ If NewStack is NULL, then ASSERT().
+
+ There are a number of constraints that must be followed before calling this
+ function:
+ 1) Interrupts must be disabled.
+ 2) The caller must be in 32-bit protected mode with flat descriptors. This
+ means all descriptors must have a base of 0 and a limit of 4GB.
+ 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat
+ descriptors.
+ 4) CR3 must point to valid page tables that will be used once the transition
+ is complete, and those page tables must guarantee that the pages for this
+ function and the stack are identity mapped.
+
+ @param EntryPoint A pointer to function to call with the new stack after
+ paging is enabled.
+ @param Context1 A pointer to the context to pass into the EntryPoint
+ function as the first parameter after paging is enabled.
+ @param Context2 A pointer to the context to pass into the EntryPoint
+ function as the second parameter after paging is enabled.
+ @param NewStack A pointer to the new stack to use for the EntryPoint
+ function after paging is enabled.
+
+**/
+VOID
+EFIAPI
+AsmEnablePaging32 (
+ IN SWITCH_STACK_ENTRY_POINT EntryPoint,
+ IN VOID *Context1, OPTIONAL
+ IN VOID *Context2, OPTIONAL
+ IN VOID *NewStack
+ )
+{
+ ASSERT (EntryPoint != NULL);
+ ASSERT (NewStack != NULL);
+ InternalX86EnablePaging32 (EntryPoint, Context1, Context2, NewStack);
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86EnablePaging64.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86EnablePaging64.c
new file mode 100644
index 0000000..c9388db
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86EnablePaging64.c
@@ -0,0 +1,70 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ x86EnablePaging64.c
+
+Abstract:
+
+ IA-32/x64 specific functions.
+
+--*/
+
+#include "BaseLibInternal.h"
+
+/**
+ Enables the 64-bit paging mode on the CPU.
+
+ Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
+ must be properly initialized prior to calling this service. This function
+ assumes the current execution mode is 32-bit protected mode with flat
+ descriptors. This function is only available on IA-32. After the 64-bit
+ paging mode is enabled, control is transferred to the function specified by
+ EntryPoint using the new stack specified by NewStack and passing in the
+ parameters specified by Context1 and Context2. Context1 and Context2 are
+ optional and may be 0. The function EntryPoint must never return.
+
+ If the current execution mode is not 32-bit protected mode with flat
+ descriptors, then ASSERT().
+ If EntryPoint is 0, then ASSERT().
+ If NewStack is 0, then ASSERT().
+
+ @param Cs The 16-bit selector to load in the CS before EntryPoint
+ is called. The descriptor in the GDT that this selector
+ references must be setup for long mode.
+ @param EntryPoint The 64-bit virtual address of the function to call with
+ the new stack after paging is enabled.
+ @param Context1 The 64-bit virtual address of the context to pass into
+ the EntryPoint function as the first parameter after
+ paging is enabled.
+ @param Context2 The 64-bit virtual address of the context to pass into
+ the EntryPoint function as the second parameter after
+ paging is enabled.
+ @param NewStack The 64-bit virtual address of the new stack to use for
+ the EntryPoint function after paging is enabled.
+
+**/
+VOID
+EFIAPI
+AsmEnablePaging64 (
+ IN UINT16 Cs,
+ IN UINT64 EntryPoint,
+ IN UINT64 Context1, OPTIONAL
+ IN UINT64 Context2, OPTIONAL
+ IN UINT64 NewStack
+ )
+{
+ ASSERT (EntryPoint != 0);
+ ASSERT (NewStack != 0);
+ InternalX86EnablePaging64 (Cs, EntryPoint, Context1, Context2, NewStack);
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86FxRestore.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86FxRestore.c
new file mode 100644
index 0000000..3a9cd16
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86FxRestore.c
@@ -0,0 +1,54 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ x86FxRestore.c
+
+Abstract:
+
+ IA-32/x64 specific functions.
+
+--*/
+
+#include "BaseLibInternal.h"
+
+/**
+ Restores the current floating point/SSE/SSE2 context from a buffer.
+
+ Restores the current floating point/SSE/SSE2 state from the buffer specified
+ by Buffer. Buffer must be aligned on a 16-byte boundary. This function is
+ only available on IA-32 and X64.
+
+ If Buffer is NULL, then ASSERT().
+ If Buffer is not aligned on a 16-byte boundary, then ASSERT().
+ If Buffer was not saved with AsmFxSave(), then ASSERT().
+
+ @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context.
+
+**/
+VOID
+EFIAPI
+AsmFxRestore (
+ IN CONST IA32_FX_BUFFER *Buffer
+ )
+{
+ ASSERT (Buffer != NULL);
+ ASSERT (((UINTN)Buffer & 0xf) == 0);
+
+ //
+ // Check the flag recorded by AsmFxSave()
+ //
+ ASSERT (*(UINT32 *) (&Buffer[sizeof (IA32_FX_BUFFER) - 4]) == 0xAA5555AA);
+
+ InternalX86FxRestore (Buffer);
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86FxSave.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86FxSave.c
new file mode 100644
index 0000000..4622ede
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86FxSave.c
@@ -0,0 +1,53 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ x86FxSave.c
+
+Abstract:
+
+ IA-32/x64 specific functions.
+
+--*/
+
+#include "BaseLibInternal.h"
+
+/**
+ Save the current floating point/SSE/SSE2 context to a buffer.
+
+ Saves the current floating point/SSE/SSE2 state to the buffer specified by
+ Buffer. Buffer must be aligned on a 16-byte boundary. This function is only
+ available on IA-32 and X64.
+
+ If Buffer is NULL, then ASSERT().
+ If Buffer is not aligned on a 16-byte boundary, then ASSERT().
+
+ @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context.
+
+**/
+VOID
+EFIAPI
+AsmFxSave (
+ OUT IA32_FX_BUFFER *Buffer
+ )
+{
+ ASSERT (Buffer != NULL);
+ ASSERT (((UINTN)Buffer & 0xf) == 0);
+
+ InternalX86FxSave (Buffer);
+
+ //
+ // Mark one flag at end of Buffer, it will be check by AsmFxRestor()
+ //
+ *(UINT32 *) (&Buffer[sizeof (IA32_FX_BUFFER) - 4]) = 0xAA5555AA;
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86GetInterruptState.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86GetInterruptState.c
new file mode 100644
index 0000000..328c9a9
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86GetInterruptState.c
@@ -0,0 +1,47 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ x86GetInterruptState.c
+
+Abstract:
+
+ IA-32/x64 specific functions.
+
+--*/
+
+#include "BaseLibInternal.h"
+
+/**
+ Retrieves the current CPU interrupt state.
+
+ Retrieves the current CPU interrupt state. Returns TRUE is interrupts are
+ currently enabled. Otherwise returns FALSE.
+
+ @retval TRUE CPU interrupts are enabled.
+ @retval FALSE CPU interrupts are disabled.
+
+**/
+BOOLEAN
+EFIAPI
+GlueGetInterruptState (
+ VOID
+ )
+{
+ IA32_EFLAGS32 EFlags;
+
+ EFlags.UintN = AsmReadEflags ();
+ return (BOOLEAN)(EFlags.Bits.IF == 1);
+}
+
+
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86MemoryFence.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86MemoryFence.c
new file mode 100644
index 0000000..1112f41
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86MemoryFence.c
@@ -0,0 +1,39 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ x86MemoryFence.c
+
+Abstract:
+
+ IA-32/x64 specific functions.
+
+--*/
+
+#include "BaseLibInternal.h"
+
+/**
+ Used to serialize load and store operations.
+
+ All loads and stores that proceed calls to this function are guaranteed to be
+ globally visible when this function returns.
+
+**/
+VOID
+EFIAPI
+MemoryFence (
+ VOID
+ )
+{
+ return;
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86Msr.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86Msr.c
new file mode 100644
index 0000000..e22489b
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86Msr.c
@@ -0,0 +1,657 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ x86Msr.c
+
+Abstract:
+
+ IA-32/x64 specific functions.
+
+--*/
+
+#include "BaseLibInternal.h"
+
+/**
+ Returns the lower 32-bits of a Machine Specific Register(MSR).
+
+ Reads and returns the lower 32-bits of the MSR specified by Index.
+ No parameter checking is performed on Index, and some Index values may cause
+ CPU exceptions. The caller must either guarantee that Index is valid, or the
+ caller must set up exception handlers to catch the exceptions. This function
+ is only available on IA-32 and X64.
+
+ @param Index The 32-bit MSR index to read.
+
+ @return The lower 32 bits of the MSR identified by Index.
+
+**/
+UINT32
+EFIAPI
+AsmReadMsr32 (
+ IN UINT32 Index
+ )
+{
+ return (UINT32)AsmReadMsr64 (Index);
+}
+
+/**
+ Zero-extend a 32-bit value and writes it to a Machine Specific Register(MSR).
+
+ Writes the 32-bit value specified by Value to the MSR specified by Index. The
+ upper 32-bits of the MSR write are set to zero. The 32-bit value written to
+ the MSR is returned. No parameter checking is performed on Index or Value,
+ and some of these may cause CPU exceptions. The caller must either guarantee
+ that Index and Value are valid, or the caller must establish proper exception
+ handlers. This function is only available on IA-32 and X64.
+
+ @param Index The 32-bit MSR index to write.
+ @param Value The 32-bit value to write to the MSR.
+
+ @return Value
+
+**/
+UINT32
+EFIAPI
+AsmWriteMsr32 (
+ IN UINT32 Index,
+ IN UINT32 Value
+ )
+{
+ return (UINT32)AsmWriteMsr64 (Index, Value);
+}
+
+/**
+ Reads a 64-bit MSR, performs a bitwise inclusive OR on the lower 32-bits, and
+ writes the result back to the 64-bit MSR.
+
+ Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR
+ between the lower 32-bits of the read result and the value specified by
+ OrData, and writes the result to the 64-bit MSR specified by Index. The lower
+ 32-bits of the value written to the MSR is returned. No parameter checking is
+ performed on Index or OrData, and some of these may cause CPU exceptions. The
+ caller must either guarantee that Index and OrData are valid, or the caller
+ must establish proper exception handlers. This function is only available on
+ IA-32 and X64.
+
+ @param Index The 32-bit MSR index to write.
+ @param OrData The value to OR with the read value from the MSR.
+
+ @return The lower 32-bit value written to the MSR.
+
+**/
+UINT32
+EFIAPI
+AsmMsrOr32 (
+ IN UINT32 Index,
+ IN UINT32 OrData
+ )
+{
+ return (UINT32)AsmMsrOr64 (Index, OrData);
+}
+
+/**
+ Reads a 64-bit MSR, performs a bitwise AND on the lower 32-bits, and writes
+ the result back to the 64-bit MSR.
+
+ Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
+ lower 32-bits of the read result and the value specified by AndData, and
+ writes the result to the 64-bit MSR specified by Index. The lower 32-bits of
+ the value written to the MSR is returned. No parameter checking is performed
+ on Index or AndData, and some of these may cause CPU exceptions. The caller
+ must either guarantee that Index and AndData are valid, or the caller must
+ establish proper exception handlers. This function is only available on IA-32
+ and X64.
+
+ @param Index The 32-bit MSR index to write.
+ @param AndData The value to AND with the read value from the MSR.
+
+ @return The lower 32-bit value written to the MSR.
+
+**/
+UINT32
+EFIAPI
+AsmMsrAnd32 (
+ IN UINT32 Index,
+ IN UINT32 AndData
+ )
+{
+ return (UINT32)AsmMsrAnd64 (Index, AndData);
+}
+
+/**
+ Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise inclusive OR
+ on the lower 32-bits, and writes the result back to the 64-bit MSR.
+
+ Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
+ lower 32-bits of the read result and the value specified by AndData
+ preserving the upper 32-bits, performs a bitwise inclusive OR between the
+ result of the AND operation and the value specified by OrData, and writes the
+ result to the 64-bit MSR specified by Address. The lower 32-bits of the value
+ written to the MSR is returned. No parameter checking is performed on Index,
+ AndData, or OrData, and some of these may cause CPU exceptions. The caller
+ must either guarantee that Index, AndData, and OrData are valid, or the
+ caller must establish proper exception handlers. This function is only
+ available on IA-32 and X64.
+
+ @param Index The 32-bit MSR index to write.
+ @param AndData The value to AND with the read value from the MSR.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The lower 32-bit value written to the MSR.
+
+**/
+UINT32
+EFIAPI
+AsmMsrAndThenOr32 (
+ IN UINT32 Index,
+ IN UINT32 AndData,
+ IN UINT32 OrData
+ )
+{
+ return (UINT32)AsmMsrAndThenOr64 (Index, AndData, OrData);
+}
+
+/**
+ Reads a bit field of an MSR.
+
+ Reads the bit field in the lower 32-bits of a 64-bit MSR. The bit field is
+ specified by the StartBit and the EndBit. The value of the bit field is
+ returned. The caller must either guarantee that Index is valid, or the caller
+ must set up exception handlers to catch the exceptions. This function is only
+ available on IA-32 and X64.
+
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Index The 32-bit MSR index to read.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+
+ @return The bit field read from the MSR.
+
+**/
+UINT32
+EFIAPI
+AsmMsrBitFieldRead32 (
+ IN UINT32 Index,
+ IN UINTN StartBit,
+ IN UINTN EndBit
+ )
+{
+ return BitFieldRead32 (AsmReadMsr32 (Index), StartBit, EndBit);
+}
+
+/**
+ Writes a bit field to an MSR.
+
+ Writes Value to a bit field in the lower 32-bits of a 64-bit MSR. The bit
+ field is specified by the StartBit and the EndBit. All other bits in the
+ destination MSR are preserved. The lower 32-bits of the MSR written is
+ returned. Extra left bits in Value are stripped. The caller must either
+ guarantee that Index and the data written is valid, or the caller must set up
+ exception handlers to catch the exceptions. This function is only available
+ on IA-32 and X64.
+
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Index The 32-bit MSR index to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+ @param Value New value of the bit field.
+
+ @return The lower 32-bit of the value written to the MSR.
+
+**/
+UINT32
+EFIAPI
+AsmMsrBitFieldWrite32 (
+ IN UINT32 Index,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT32 Value
+ )
+{
+ ASSERT (EndBit < sizeof (Value) * 8);
+ ASSERT (StartBit <= EndBit);
+ return (UINT32)AsmMsrBitFieldWrite64 (Index, StartBit, EndBit, Value);
+}
+
+/**
+ Reads a bit field in a 64-bit MSR, performs a bitwise OR, and writes the
+ result back to the bit field in the 64-bit MSR.
+
+ Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR
+ between the read result and the value specified by OrData, and writes the
+ result to the 64-bit MSR specified by Index. The lower 32-bits of the value
+ written to the MSR are returned. Extra left bits in OrData are stripped. The
+ caller must either guarantee that Index and the data written is valid, or
+ the caller must set up exception handlers to catch the exceptions. This
+ function is only available on IA-32 and X64.
+
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Index The 32-bit MSR index to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+ @param OrData The value to OR with the read value from the MSR.
+
+ @return The lower 32-bit of the value written to the MSR.
+
+**/
+UINT32
+EFIAPI
+AsmMsrBitFieldOr32 (
+ IN UINT32 Index,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT32 OrData
+ )
+{
+ ASSERT (EndBit < sizeof (OrData) * 8);
+ ASSERT (StartBit <= EndBit);
+ return (UINT32)AsmMsrBitFieldOr64 (Index, StartBit, EndBit, OrData);
+}
+
+/**
+ Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
+ result back to the bit field in the 64-bit MSR.
+
+ Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
+ read result and the value specified by AndData, and writes the result to the
+ 64-bit MSR specified by Index. The lower 32-bits of the value written to the
+ MSR are returned. Extra left bits in AndData are stripped. The caller must
+ either guarantee that Index and the data written is valid, or the caller must
+ set up exception handlers to catch the exceptions. This function is only
+ available on IA-32 and X64.
+
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Index The 32-bit MSR index to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+ @param AndData The value to AND with the read value from the MSR.
+
+ @return The lower 32-bit of the value written to the MSR.
+
+**/
+UINT32
+EFIAPI
+AsmMsrBitFieldAnd32 (
+ IN UINT32 Index,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT32 AndData
+ )
+{
+ ASSERT (EndBit < sizeof (AndData) * 8);
+ ASSERT (StartBit <= EndBit);
+ return (UINT32)AsmMsrBitFieldAnd64 (Index, StartBit, EndBit, AndData);
+}
+
+/**
+ Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
+ bitwise inclusive OR, and writes the result back to the bit field in the
+ 64-bit MSR.
+
+ Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by a
+ bitwise inclusive OR between the read result and the value specified by
+ AndData, and writes the result to the 64-bit MSR specified by Index. The
+ lower 32-bits of the value written to the MSR are returned. Extra left bits
+ in both AndData and OrData are stripped. The caller must either guarantee
+ that Index and the data written is valid, or the caller must set up exception
+ handlers to catch the exceptions. This function is only available on IA-32
+ and X64.
+
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Index The 32-bit MSR index to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+ @param AndData The value to AND with the read value from the MSR.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The lower 32-bit of the value written to the MSR.
+
+**/
+UINT32
+EFIAPI
+AsmMsrBitFieldAndThenOr32 (
+ IN UINT32 Index,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT32 AndData,
+ IN UINT32 OrData
+ )
+{
+ ASSERT (EndBit < sizeof (AndData) * 8);
+ ASSERT (StartBit <= EndBit);
+ return (UINT32)AsmMsrBitFieldAndThenOr64 (
+ Index,
+ StartBit,
+ EndBit,
+ AndData,
+ OrData
+ );
+}
+
+/**
+ Reads a 64-bit MSR, performs a bitwise inclusive OR, and writes the result
+ back to the 64-bit MSR.
+
+ Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR
+ between the read result and the value specified by OrData, and writes the
+ result to the 64-bit MSR specified by Index. The value written to the MSR is
+ returned. No parameter checking is performed on Index or OrData, and some of
+ these may cause CPU exceptions. The caller must either guarantee that Index
+ and OrData are valid, or the caller must establish proper exception handlers.
+ This function is only available on IA-32 and X64.
+
+ @param Index The 32-bit MSR index to write.
+ @param OrData The value to OR with the read value from the MSR.
+
+ @return The value written back to the MSR.
+
+**/
+UINT64
+EFIAPI
+AsmMsrOr64 (
+ IN UINT32 Index,
+ IN UINT64 OrData
+ )
+{
+ return AsmWriteMsr64 (Index, AsmReadMsr64 (Index) | OrData);
+}
+
+/**
+ Reads a 64-bit MSR, performs a bitwise AND, and writes the result back to the
+ 64-bit MSR.
+
+ Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
+ read result and the value specified by OrData, and writes the result to the
+ 64-bit MSR specified by Index. The value written to the MSR is returned. No
+ parameter checking is performed on Index or OrData, and some of these may
+ cause CPU exceptions. The caller must either guarantee that Index and OrData
+ are valid, or the caller must establish proper exception handlers. This
+ function is only available on IA-32 and X64.
+
+ @param Index The 32-bit MSR index to write.
+ @param AndData The value to AND with the read value from the MSR.
+
+ @return The value written back to the MSR.
+
+**/
+UINT64
+EFIAPI
+AsmMsrAnd64 (
+ IN UINT32 Index,
+ IN UINT64 AndData
+ )
+{
+ return AsmWriteMsr64 (Index, AsmReadMsr64 (Index) & AndData);
+}
+
+/**
+ Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise inclusive
+ OR, and writes the result back to the 64-bit MSR.
+
+ Reads the 64-bit MSR specified by Index, performs a bitwise AND between read
+ result and the value specified by AndData, performs a bitwise inclusive OR
+ between the result of the AND operation and the value specified by OrData,
+ and writes the result to the 64-bit MSR specified by Index. The value written
+ to the MSR is returned. No parameter checking is performed on Index, AndData,
+ or OrData, and some of these may cause CPU exceptions. The caller must either
+ guarantee that Index, AndData, and OrData are valid, or the caller must
+ establish proper exception handlers. This function is only available on IA-32
+ and X64.
+
+ @param Index The 32-bit MSR index to write.
+ @param AndData The value to AND with the read value from the MSR.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the MSR.
+
+**/
+UINT64
+EFIAPI
+AsmMsrAndThenOr64 (
+ IN UINT32 Index,
+ IN UINT64 AndData,
+ IN UINT64 OrData
+ )
+{
+ return AsmWriteMsr64 (Index, (AsmReadMsr64 (Index) & AndData) | OrData);
+}
+
+/**
+ Reads a bit field of an MSR.
+
+ Reads the bit field in the 64-bit MSR. The bit field is specified by the
+ StartBit and the EndBit. The value of the bit field is returned. The caller
+ must either guarantee that Index is valid, or the caller must set up
+ exception handlers to catch the exceptions. This function is only available
+ on IA-32 and X64.
+
+ If StartBit is greater than 63, then ASSERT().
+ If EndBit is greater than 63, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Index The 32-bit MSR index to read.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..63.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..63.
+
+ @return The value written back to the MSR.
+
+**/
+UINT64
+EFIAPI
+AsmMsrBitFieldRead64 (
+ IN UINT32 Index,
+ IN UINTN StartBit,
+ IN UINTN EndBit
+ )
+{
+ return BitFieldRead64 (AsmReadMsr64 (Index), StartBit, EndBit);
+}
+
+/**
+ Writes a bit field to an MSR.
+
+ Writes Value to a bit field in a 64-bit MSR. The bit field is specified by
+ the StartBit and the EndBit. All other bits in the destination MSR are
+ preserved. The MSR written is returned. Extra left bits in Value are
+ stripped. The caller must either guarantee that Index and the data written is
+ valid, or the caller must set up exception handlers to catch the exceptions.
+ This function is only available on IA-32 and X64.
+
+ If StartBit is greater than 63, then ASSERT().
+ If EndBit is greater than 63, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Index The 32-bit MSR index to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..63.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..63.
+ @param Value New value of the bit field.
+
+ @return The value written back to the MSR.
+
+**/
+UINT64
+EFIAPI
+AsmMsrBitFieldWrite64 (
+ IN UINT32 Index,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT64 Value
+ )
+{
+ return AsmWriteMsr64 (
+ Index,
+ BitFieldWrite64 (AsmReadMsr64 (Index), StartBit, EndBit, Value)
+ );
+}
+
+/**
+ Reads a bit field in a 64-bit MSR, performs a bitwise inclusive OR, and
+ writes the result back to the bit field in the 64-bit MSR.
+
+ Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR
+ between the read result and the value specified by OrData, and writes the
+ result to the 64-bit MSR specified by Index. The value written to the MSR is
+ returned. Extra left bits in OrData are stripped. The caller must either
+ guarantee that Index and the data written is valid, or the caller must set up
+ exception handlers to catch the exceptions. This function is only available
+ on IA-32 and X64.
+
+ If StartBit is greater than 63, then ASSERT().
+ If EndBit is greater than 63, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Index The 32-bit MSR index to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..63.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..63.
+ @param OrData The value to OR with the read value from the bit field.
+
+ @return The value written back to the MSR.
+
+**/
+UINT64
+EFIAPI
+AsmMsrBitFieldOr64 (
+ IN UINT32 Index,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT64 OrData
+ )
+{
+ return AsmWriteMsr64 (
+ Index,
+ BitFieldOr64 (AsmReadMsr64 (Index), StartBit, EndBit, OrData)
+ );
+}
+
+/**
+ Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
+ result back to the bit field in the 64-bit MSR.
+
+ Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
+ read result and the value specified by AndData, and writes the result to the
+ 64-bit MSR specified by Index. The value written to the MSR is returned.
+ Extra left bits in AndData are stripped. The caller must either guarantee
+ that Index and the data written is valid, or the caller must set up exception
+ handlers to catch the exceptions. This function is only available on IA-32
+ and X64.
+
+ If StartBit is greater than 63, then ASSERT().
+ If EndBit is greater than 63, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Index The 32-bit MSR index to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..63.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..63.
+ @param AndData The value to AND with the read value from the bit field.
+
+ @return The value written back to the MSR.
+
+**/
+UINT64
+EFIAPI
+AsmMsrBitFieldAnd64 (
+ IN UINT32 Index,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT64 AndData
+ )
+{
+ return AsmWriteMsr64 (
+ Index,
+ BitFieldAnd64 (AsmReadMsr64 (Index), StartBit, EndBit, AndData)
+ );
+}
+
+/**
+ Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
+ bitwise inclusive OR, and writes the result back to the bit field in the
+ 64-bit MSR.
+
+ Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by
+ a bitwise inclusive OR between the read result and the value specified by
+ AndData, and writes the result to the 64-bit MSR specified by Index. The
+ value written to the MSR is returned. Extra left bits in both AndData and
+ OrData are stripped. The caller must either guarantee that Index and the data
+ written is valid, or the caller must set up exception handlers to catch the
+ exceptions. This function is only available on IA-32 and X64.
+
+ If StartBit is greater than 63, then ASSERT().
+ If EndBit is greater than 63, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Index The 32-bit MSR index to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..63.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..63.
+ @param AndData The value to AND with the read value from the bit field.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the MSR.
+
+**/
+UINT64
+EFIAPI
+AsmMsrBitFieldAndThenOr64 (
+ IN UINT32 Index,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT64 AndData,
+ IN UINT64 OrData
+ )
+{
+ return AsmWriteMsr64 (
+ Index,
+ BitFieldAndThenOr64 (
+ AsmReadMsr64 (Index),
+ StartBit,
+ EndBit,
+ AndData,
+ OrData
+ )
+ );
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86ReadGdtr.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86ReadGdtr.c
new file mode 100644
index 0000000..dbb367e
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86ReadGdtr.c
@@ -0,0 +1,44 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ x86ReadGdtr.c
+
+Abstract:
+
+ IA-32/x64 specific functions.
+
+--*/
+
+#include "BaseLibInternal.h"
+
+/**
+ Reads the current Global Descriptor Table Register(GDTR) descriptor.
+
+ Reads and returns the current GDTR descriptor and returns it in Gdtr. This
+ function is only available on IA-32 and X64.
+
+ If Gdtr is NULL, then ASSERT().
+
+ @param Gdtr Pointer to a GDTR descriptor.
+
+**/
+VOID
+EFIAPI
+AsmReadGdtr (
+ OUT IA32_DESCRIPTOR *Gdtr
+ )
+{
+ ASSERT (Gdtr != NULL);
+ InternalX86ReadGdtr (Gdtr);
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86ReadIdtr.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86ReadIdtr.c
new file mode 100644
index 0000000..873535a
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86ReadIdtr.c
@@ -0,0 +1,44 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ x86ReadIdtr.c
+
+Abstract:
+
+ IA-32/x64 specific functions.
+
+--*/
+
+#include "BaseLibInternal.h"
+
+/**
+ Reads the current Interrupt Descriptor Table Register(GDTR) descriptor.
+
+ Reads and returns the current IDTR descriptor and returns it in Idtr. This
+ function is only available on IA-32 and X64.
+
+ If Idtr is NULL, then ASSERT().
+
+ @param Idtr Pointer to a IDTR descriptor.
+
+**/
+VOID
+EFIAPI
+AsmReadIdtr (
+ OUT IA32_DESCRIPTOR *Idtr
+ )
+{
+ ASSERT (Idtr != NULL);
+ InternalX86ReadIdtr (Idtr);
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86Thunk.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86Thunk.c
new file mode 100644
index 0000000..0176e90
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86Thunk.c
@@ -0,0 +1,250 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ x86Thunk.c
+
+Abstract:
+
+ Real Mode Thunk Functions for IA32 and X64.
+
+--*/
+
+#include "BaseLibInternal.h"
+//
+// Byte packed structure for a segment descriptor in a GDT/LDT
+//
+typedef union {
+ struct {
+ UINT32 LimitLow:16;
+ UINT32 BaseLow:16;
+ UINT32 BaseMid:8;
+ UINT32 Type:4;
+ UINT32 S:1;
+ UINT32 DPL:2;
+ UINT32 P:1;
+ UINT32 LimitHigh:4;
+ UINT32 AVL:1;
+ UINT32 L:1;
+ UINT32 DB:1;
+ UINT32 G:1;
+ UINT32 BaseHigh:8;
+ } Bits;
+ UINT64 Uint64;
+} IA32_SEGMENT_DESCRIPTOR;
+
+extern CONST UINT8 m16Start;
+extern CONST UINT16 m16Size;
+extern CONST UINT16 mThunk16Attr;
+extern CONST UINT16 m16Gdt;
+extern CONST UINT16 m16GdtrBase;
+extern CONST UINT16 mTransition;
+
+/**
+ Invokes 16-bit code in big real mode and returns the updated register set.
+
+ This function transfers control to the 16-bit code specified by CS:EIP using
+ the stack specified by SS:ESP in RegisterSet. The updated registers are saved
+ on the real mode stack and the starting address of the save area is returned.
+
+ @param RegisterSet Values of registers before invocation of 16-bit code.
+ @param Transition Pointer to the transition code under 1MB.
+
+ @return The pointer to a IA32_REGISTER_SET structure containing the updated
+ register values.
+
+**/
+IA32_REGISTER_SET *
+EFIAPI
+InternalAsmThunk16 (
+ IN IA32_REGISTER_SET *RegisterSet,
+ IN OUT VOID *Transition
+ );
+
+/**
+ Retrieves the properties for 16-bit thunk functions.
+
+ Computes the size of the buffer and stack below 1MB required to use the
+ AsmPrepareThunk16(), AsmThunk16() and AsmPrepareAndThunk16() functions. This
+ buffer size is returned in RealModeBufferSize, and the stack size is returned
+ in ExtraStackSize. If parameters are passed to the 16-bit real mode code,
+ then the actual minimum stack size is ExtraStackSize plus the maximum number
+ of bytes that need to be passed to the 16-bit real mode code.
+
+ If RealModeBufferSize is NULL, then ASSERT().
+ If ExtraStackSize is NULL, then ASSERT().
+
+ @param RealModeBufferSize A pointer to the size of the buffer below 1MB
+ required to use the 16-bit thunk functions.
+ @param ExtraStackSize A pointer to the extra size of stack below 1MB
+ that the 16-bit thunk functions require for
+ temporary storage in the transition to and from
+ 16-bit real mode.
+
+**/
+VOID
+EFIAPI
+AsmGetThunk16Properties (
+ OUT UINT32 *RealModeBufferSize,
+ OUT UINT32 *ExtraStackSize
+ )
+{
+ ASSERT (RealModeBufferSize != NULL);
+ ASSERT (ExtraStackSize != NULL);
+
+ *RealModeBufferSize = m16Size;
+
+ //
+ // Extra 4 bytes for return address, and another 4 bytes for mode transition
+ //
+ *ExtraStackSize = sizeof (IA32_DWORD_REGS) + 8;
+}
+
+/**
+ Prepares all structures a code required to use AsmThunk16().
+
+ Prepares all structures and code required to use AsmThunk16().
+
+ If ThunkContext is NULL, then ASSERT().
+
+ @param ThunkContext A pointer to the context structure that describes the
+ 16-bit real mode code to call.
+
+**/
+VOID
+EFIAPI
+AsmPrepareThunk16 (
+ OUT THUNK_CONTEXT *ThunkContext
+ )
+{
+ IA32_SEGMENT_DESCRIPTOR *RealModeGdt;
+
+ ASSERT (ThunkContext != NULL);
+ ASSERT ((UINTN)ThunkContext->RealModeBuffer < 0x100000);
+ ASSERT (ThunkContext->RealModeBufferSize >= m16Size);
+ ASSERT ((UINTN)ThunkContext->RealModeBuffer + m16Size <= 0x100000);
+
+ CopyMem (ThunkContext->RealModeBuffer, &m16Start, m16Size);
+
+ //
+ // Point RealModeGdt to the GDT to be used in transition
+ //
+ // RealModeGdt[0]: Reserved as NULL descriptor
+ // RealModeGdt[1]: Code Segment
+ // RealModeGdt[2]: Data Segment
+ // RealModeGdt[3]: Call Gate
+ //
+ RealModeGdt = (IA32_SEGMENT_DESCRIPTOR*)(
+ (UINTN)ThunkContext->RealModeBuffer + m16Gdt);
+
+ //
+ // Update Code & Data Segment Descriptor
+ //
+ RealModeGdt[1].Bits.BaseLow =
+ (UINT32)(UINTN)ThunkContext->RealModeBuffer & ~0xf;
+ RealModeGdt[1].Bits.BaseMid =
+ (UINT32)(UINTN)ThunkContext->RealModeBuffer >> 16;
+
+ //
+ // Update transition code entry point offset
+ //
+ *(UINT32*)((UINTN)ThunkContext->RealModeBuffer + mTransition) +=
+ (UINT32)(UINTN)ThunkContext->RealModeBuffer & 0xf;
+
+ //
+ // Update Segment Limits for both Code and Data Segment Descriptors
+ //
+ if ((ThunkContext->ThunkAttributes & THUNK_ATTRIBUTE_BIG_REAL_MODE) == 0) {
+ //
+ // Set segment limits to 64KB
+ //
+ RealModeGdt[1].Bits.LimitHigh = 0;
+ RealModeGdt[1].Bits.G = 0;
+ RealModeGdt[2].Bits.LimitHigh = 0;
+ RealModeGdt[2].Bits.G = 0;
+ }
+
+ //
+ // Update GDTBASE for this thunk context
+ //
+ *(VOID**)((UINTN)ThunkContext->RealModeBuffer + m16GdtrBase) = RealModeGdt;
+
+ //
+ // Update Thunk Attributes
+ //
+ *(UINT32*)((UINTN)ThunkContext->RealModeBuffer + mThunk16Attr) =
+ ThunkContext->ThunkAttributes;
+}
+
+/**
+ Transfers control to a 16-bit real mode entry point and returns the results.
+
+ Transfers control to a 16-bit real mode entry point and returns the results.
+ AsmPrepareThunk16() must be called with ThunkContext before this function is
+ used. This function must be called with interrupts disabled.
+
+ If ThunkContext is NULL, then ASSERT().
+ If AsmPrepareThunk16() was not previously called with ThunkContext, then ASSERT().
+
+ @param ThunkContext A pointer to the context structure that describes the
+ 16-bit real mode code to call.
+
+**/
+VOID
+EFIAPI
+AsmThunk16 (
+ IN OUT THUNK_CONTEXT *ThunkContext
+ )
+{
+ IA32_REGISTER_SET *UpdatedRegs;
+
+ ASSERT (ThunkContext != NULL);
+ ASSERT ((UINTN)ThunkContext->RealModeBuffer < 0x100000);
+ ASSERT (ThunkContext->RealModeBufferSize >= m16Size);
+ ASSERT ((UINTN)ThunkContext->RealModeBuffer + m16Size <= 0x100000);
+
+ UpdatedRegs = InternalAsmThunk16 (
+ ThunkContext->RealModeState,
+ ThunkContext->RealModeBuffer
+ );
+
+ CopyMem (ThunkContext->RealModeState, UpdatedRegs, sizeof (*UpdatedRegs));
+}
+
+/**
+ Prepares all structures and code for a 16-bit real mode thunk, transfers
+ control to a 16-bit real mode entry point, and returns the results.
+
+ Prepares all structures and code for a 16-bit real mode thunk, transfers
+ control to a 16-bit real mode entry point, and returns the results. If the
+ caller only need to perform a single 16-bit real mode thunk, then this
+ service should be used. If the caller intends to make more than one 16-bit
+ real mode thunk, then it is more efficient if AsmPrepareThunk16() is called
+ once and AsmThunk16() can be called for each 16-bit real mode thunk. This
+ function must be called with interrupts disabled.
+
+ If ThunkContext is NULL, then ASSERT().
+
+ @param ThunkContext A pointer to the context structure that describes the
+ 16-bit real mode code to call.
+
+**/
+VOID
+EFIAPI
+AsmPrepareAndThunk16 (
+ IN OUT THUNK_CONTEXT *ThunkContext
+ )
+{
+ AsmPrepareThunk16 (ThunkContext);
+ AsmThunk16 (ThunkContext);
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86WriteGdtr.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86WriteGdtr.c
new file mode 100644
index 0000000..8e7c189
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86WriteGdtr.c
@@ -0,0 +1,44 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ x86WriteGdtr.c
+
+Abstract:
+
+ IA-32/x64 specific functions.
+
+--*/
+
+#include "BaseLibInternal.h"
+
+/**
+ Writes the current Global Descriptor Table Register (GDTR) descriptor.
+
+ Writes and the current GDTR descriptor specified by Gdtr. This function is
+ only available on IA-32 and X64.
+
+ If Gdtr is NULL, then ASSERT().
+
+ @param Gdtr Pointer to a GDTR descriptor.
+
+**/
+VOID
+EFIAPI
+AsmWriteGdtr (
+ IN CONST IA32_DESCRIPTOR *Gdtr
+ )
+{
+ ASSERT (Gdtr != NULL);
+ InternalX86WriteGdtr (Gdtr);
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86WriteIdtr.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86WriteIdtr.c
new file mode 100644
index 0000000..e82c0e3
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86WriteIdtr.c
@@ -0,0 +1,44 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ x86WriteIdtr.c
+
+Abstract:
+
+ IA-32/x64 specific functions.
+
+--*/
+
+#include "BaseLibInternal.h"
+
+/**
+ Writes the current Interrupt Descriptor Table Register(GDTR) descriptor.
+
+ Writes the current IDTR descriptor and returns it in Idtr. This function is
+ only available on IA-32 and X64.
+
+ If Idtr is NULL, then ASSERT().
+
+ @param Idtr Pointer to a IDTR descriptor.
+
+**/
+VOID
+EFIAPI
+AsmWriteIdtr (
+ IN CONST IA32_DESCRIPTOR *Idtr
+ )
+{
+ ASSERT (Idtr != NULL);
+ InternalX86WriteIdtr (Idtr);
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/BaseMemoryLib.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/BaseMemoryLib.inf
new file mode 100644
index 0000000..ac186c3
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/BaseMemoryLib.inf
@@ -0,0 +1,119 @@
+#/*++
+#
+# Copyright (c) 2004 - 2006, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# BaseMemoryLib.inf
+#
+# Abstract:
+#
+# Component description file for BaseMemoryLib. This instance is not the
+# BaseMemoryLib in EdkII but almost BaseMemoryLibRepStr.
+# Use REP string instructions for Ia32 and X64 for high performance and small size
+# Use C implementation for IPF and EBC
+#
+#--*/
+
+[defines]
+BASE_NAME = EdkIIGlueBaseMemoryLib
+COMPONENT_TYPE = LIBRARY
+
+[sources.common]
+ MemLibGuid.c
+ CopyMemWrapper.c
+ SetMemWrapper.c
+ SetMem16Wrapper.c
+ SetMem32Wrapper.c
+ SetMem64Wrapper.c
+ CompareMemWrapper.c
+ ZeroMemWrapper.c
+ ScanMem8Wrapper.c
+ ScanMem16Wrapper.c
+ ScanMem32Wrapper.c
+ ScanMem64Wrapper.c
+
+[sources.ia32]
+ Ia32/CopyMem.asm
+ Ia32/SetMem.asm
+ Ia32/SetMem16.asm
+ Ia32/SetMem32.asm
+ Ia32/SetMem64.asm
+ Ia32/ZeroMem.asm
+ Ia32/CompareMem.asm
+ Ia32/ScanMem8.asm
+ Ia32/ScanMem16.asm
+ Ia32/ScanMem32.asm
+ Ia32/ScanMem64.asm
+
+[sources.x64]
+ X64/CopyMem.asm
+ X64/SetMem.asm
+ X64/SetMem16.asm
+ X64/SetMem32.asm
+ X64/SetMem64.asm
+ X64/ZeroMem.asm
+ X64/CompareMem.asm
+ X64/ScanMem8.asm
+ X64/ScanMem16.asm
+ X64/ScanMem32.asm
+ X64/ScanMem64.asm
+
+[sources.ipf]
+ Ipf/CopyMem.c
+ Ipf/MemLibGeneric.c
+ Ipf/SetMem.c
+
+[sources.ebc]
+ Ebc/CopyMem.c
+ Ebc/MemLibGeneric.c
+ Ebc/SetMem.c
+
+[includes.common]
+ .
+ ..\..\Include
+ ..\..\include\Library
+ $(EDK_SOURCE)\Foundation
+ $(EDK_SOURCE)\Foundation\Framework
+ $(EDK_SOURCE)\Foundation\Efi
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+ $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include
+
+[libraries.common]
+ EdkIIGlueBaseLib
+
+[libraries.ia32]
+
+
+[libraries.x64]
+
+
+[nmake.common]
+ C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION
+ LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006 /IGNORE:4221
+
+[nmake.ia32]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32
+
+[nmake.x64]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64
+
+[nmake.ipf]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF
+
+[nmake.ebc]
+ EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION
+ EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS) /IGNORE:4006 /IGNORE:4221
+ EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/BaseMemoryLibInternal.h b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/BaseMemoryLibInternal.h
new file mode 100644
index 0000000..5a2df01
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/BaseMemoryLibInternal.h
@@ -0,0 +1,227 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ BaseMemoryLibInternals.h
+
+Abstract:
+
+ Header file for Base Memory Library.
+
+--*/
+
+#ifndef __BASEMEMORY_LIB_INTERNALS_H__
+#define __BASEMEMORY_LIB_INTERNALS_H__
+
+#include "EdkIIGlueBase.h"
+/**
+ Copy Length bytes from Source to Destination.
+
+ @param Destination Target of copy
+ @param Source Place to copy from
+ @param Length Number of bytes to copy
+
+ @return Destination
+
+**/
+VOID *
+EFIAPI
+InternalMemCopyMem (
+ OUT VOID *DestinationBuffer,
+ IN CONST VOID *SourceBuffer,
+ IN UINTN Length
+ );
+
+/**
+ Set Buffer to Value for Size bytes.
+
+ @param Buffer Memory to set.
+ @param Size Number of bytes to set
+ @param Value Value of the set operation.
+
+ @return Buffer
+
+**/
+VOID *
+EFIAPI
+InternalMemSetMem (
+ OUT VOID *Buffer,
+ IN UINTN Length,
+ IN UINT8 Value
+ );
+
+/**
+ Fills a target buffer with a 16-bit value, and returns the target buffer.
+
+ @param Buffer Pointer to the target buffer to fill.
+ @param Length Number of bytes in Buffer to fill.
+ @param Value Value with which to fill Length bytes of Buffer.
+
+ @return Buffer
+
+**/
+VOID *
+EFIAPI
+InternalMemSetMem16 (
+ OUT VOID *Buffer,
+ IN UINTN Length,
+ IN UINT16 Value
+ );
+
+/**
+ Fills a target buffer with a 32-bit value, and returns the target buffer.
+
+ @param Buffer Pointer to the target buffer to fill.
+ @param Length Number of bytes in Buffer to fill.
+ @param Value Value with which to fill Length bytes of Buffer.
+
+ @return Buffer
+
+**/
+VOID *
+EFIAPI
+InternalMemSetMem32 (
+ OUT VOID *Buffer,
+ IN UINTN Length,
+ IN UINT32 Value
+ );
+
+/**
+ Fills a target buffer with a 64-bit value, and returns the target buffer.
+
+ @param Buffer Pointer to the target buffer to fill.
+ @param Length Number of bytes in Buffer to fill.
+ @param Value Value with which to fill Length bytes of Buffer.
+
+ @return Buffer
+
+**/
+VOID *
+EFIAPI
+InternalMemSetMem64 (
+ OUT VOID *Buffer,
+ IN UINTN Length,
+ IN UINT64 Value
+ );
+
+/**
+ Set Buffer to 0 for Size bytes.
+
+ @param Buffer Memory to set.
+ @param Size Number of bytes to set
+
+ @return Buffer
+
+**/
+VOID *
+EFIAPI
+InternalMemZeroMem (
+ OUT VOID *Buffer,
+ IN UINTN Length
+ );
+
+/**
+ Compares two memory buffers of a given length.
+
+ @param DestinationBuffer First memory buffer
+ @param SourceBuffer Second memory buffer
+ @param Length Length of DestinationBuffer and SourceBuffer memory
+ regions to compare. Must be non-zero.
+
+ @retval 0 if MemOne == MemTwo
+
+**/
+INTN
+EFIAPI
+InternalMemCompareMem (
+ IN CONST VOID *DestinationBuffer,
+ IN CONST VOID *SourceBuffer,
+ IN UINTN Length
+ );
+
+/**
+ Scans a target buffer for an 8-bit value, and returns a pointer to the
+ matching 8-bit value in the target buffer.
+
+ @param Buffer Pointer to the target buffer to scan.
+ @param Length Number of bytes in Buffer to scan. Must be non-zero.
+ @param Value Value to search for in the target buffer.
+
+ @return Pointer to the first occurrence or NULL if not found.
+
+**/
+CONST VOID *
+EFIAPI
+InternalMemScanMem8 (
+ IN CONST VOID *Buffer,
+ IN UINTN Length,
+ IN UINT8 Value
+ );
+
+/**
+ Scans a target buffer for a 16-bit value, and returns a pointer to the
+ matching 16-bit value in the target buffer.
+
+ @param Buffer Pointer to the target buffer to scan.
+ @param Length Number of bytes in Buffer to scan. Must be non-zero.
+ @param Value Value to search for in the target buffer.
+
+ @return Pointer to the first occurrence or NULL if not found.
+
+**/
+CONST VOID *
+EFIAPI
+InternalMemScanMem16 (
+ IN CONST VOID *Buffer,
+ IN UINTN Length,
+ IN UINT16 Value
+ );
+
+/**
+ Scans a target buffer for a 32-bit value, and returns a pointer to the
+ matching 32-bit value in the target buffer.
+
+ @param Buffer Pointer to the target buffer to scan.
+ @param Length Number of bytes in Buffer to scan. Must be non-zero.
+ @param Value Value to search for in the target buffer.
+
+ @return Pointer to the first occurrence or NULL if not found.
+
+**/
+CONST VOID *
+EFIAPI
+InternalMemScanMem32 (
+ IN CONST VOID *Buffer,
+ IN UINTN Length,
+ IN UINT32 Value
+ );
+
+/**
+ Scans a target buffer for a 64-bit value, and returns a pointer to the
+ matching 64-bit value in the target buffer.
+
+ @param Buffer Pointer to the target buffer to scan.
+ @param Length Number of bytes in Buffer to scan. Must be non-zero.
+ @param Value Value to search for in the target buffer.
+
+ @return Pointer to the first occurrence or NULL if not found.
+
+**/
+CONST VOID *
+EFIAPI
+InternalMemScanMem64 (
+ IN CONST VOID *Buffer,
+ IN UINTN Length,
+ IN UINT64 Value
+ );
+
+#endif
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/CompareMemWrapper.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/CompareMemWrapper.c
new file mode 100644
index 0000000..a1a27cf
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/CompareMemWrapper.c
@@ -0,0 +1,63 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ CompareMemWrapper.c
+
+Abstract:
+
+ CompareMem() implementation.
+
+--*/
+
+#include "BaseMemoryLibInternal.h"
+
+/**
+ Compares the contents of two buffers.
+
+ This function compares Length bytes of SourceBuffer to Length bytes of DestinationBuffer.
+ If all Length bytes of the two buffers are identical, then 0 is returned. Otherwise, the
+ value returned is the first mismatched byte in SourceBuffer subtracted from the first
+ mismatched byte in DestinationBuffer.
+ If Length > 0 and DestinationBuffer is NULL and Length > 0, then ASSERT().
+ If Length > 0 and SourceBuffer is NULL and Length > 0, then ASSERT().
+ If Length is greater than (MAX_ADDRESS - DestinationBuffer + 1), then ASSERT().
+ If Length is greater than (MAX_ADDRESS - SourceBuffer + 1), then ASSERT().
+
+
+ @param DestinationBuffer Pointer to the destination buffer to compare.
+ @param SourceBuffer Pointer to the source buffer to compare.
+ @param Length Number of bytes to compare.
+
+ @return 0 All Length bytes of the two buffers are identical.
+ @retval Non-zero The first mismatched byte in SourceBuffer subtracted from the first
+ mismatched byte in DestinationBuffer.
+
+**/
+INTN
+EFIAPI
+GlueCompareMem (
+ IN CONST VOID *DestinationBuffer,
+ IN CONST VOID *SourceBuffer,
+ IN UINTN Length
+ )
+{
+ if (Length == 0 || DestinationBuffer == SourceBuffer) {
+ return 0;
+ }
+ ASSERT (DestinationBuffer != NULL);
+ ASSERT (SourceBuffer != NULL);
+ ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)DestinationBuffer));
+ ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)SourceBuffer));
+
+ return InternalMemCompareMem (DestinationBuffer, SourceBuffer, Length);
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/CopyMem.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/CopyMem.c
new file mode 100644
index 0000000..17ea273
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/CopyMem.c
@@ -0,0 +1,65 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ CopyMem.c
+
+Abstract:
+
+ Internal CopyMem
+
+--*/
+
+#include "BaseMemoryLibInternal.h"
+
+/**
+ Copy Length bytes from Source to Destination.
+
+ @param Destination Target of copy
+ @param Source Place to copy from
+ @param Length Number of bytes to copy
+
+ @return Destination
+
+**/
+VOID *
+EFIAPI
+InternalMemCopyMem (
+ OUT VOID *Destination,
+ IN CONST VOID *Source,
+ IN UINTN Length
+ )
+{
+ //
+ // Declare the local variables that actually move the data elements as
+ // volatile to prevent the optimizer from replacing this function with
+ // the intrinsic memcpy()
+ //
+ volatile UINT8 *Destination8;
+ CONST UINT8 *Source8;
+
+ if (Source > Destination) {
+ Destination8 = (UINT8*)Destination;
+ Source8 = (CONST UINT8*)Source;
+ while (Length-- != 0) {
+ *(Destination8++) = *(Source8++);
+ }
+ } else if (Source < Destination) {
+ Destination8 = (UINT8*)Destination + Length;
+ Source8 = (CONST UINT8*)Source + Length;
+ while (Length-- != 0) {
+ *(--Destination8) = *(--Source8);
+ }
+ }
+ return Destination;
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/CopyMemWrapper.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/CopyMemWrapper.c
new file mode 100644
index 0000000..b9d8101
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/CopyMemWrapper.c
@@ -0,0 +1,58 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ CopyMemWrapper.c
+
+Abstract:
+
+ CopyMem() implementation.
+
+--*/
+
+#include "BaseMemoryLibInternal.h"
+
+/**
+ Copies a source buffer to a destination buffer, and returns the destination buffer.
+
+ This function copies Length bytes from SourceBuffer to DestinationBuffer, and returns
+ DestinationBuffer. The implementation must be reentrant, and it must handle the case
+ where SourceBuffer overlaps DestinationBuffer.
+ If Length is greater than (MAX_ADDRESS - DestinationBuffer + 1), then ASSERT().
+ If Length is greater than (MAX_ADDRESS - SourceBuffer + 1), then ASSERT().
+
+ @param DestinationBuffer Pointer to the destination buffer of the memory copy.
+ @param SourceBuffer Pointer to the source buffer of the memory copy.
+ @param Length Number of bytes to copy from SourceBuffer to DestinationBuffer.
+
+ @return DestinationBuffer.
+
+**/
+VOID *
+EFIAPI
+GlueCopyMem (
+ OUT VOID *DestinationBuffer,
+ IN CONST VOID *SourceBuffer,
+ IN UINTN Length
+ )
+{
+ if (Length == 0) {
+ return DestinationBuffer;
+ }
+ ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)DestinationBuffer));
+ ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)SourceBuffer));
+
+ if (DestinationBuffer == SourceBuffer) {
+ return DestinationBuffer;
+ }
+ return InternalMemCopyMem (DestinationBuffer, SourceBuffer, Length);
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ebc/CopyMem.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ebc/CopyMem.c
new file mode 100644
index 0000000..17ea273
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ebc/CopyMem.c
@@ -0,0 +1,65 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ CopyMem.c
+
+Abstract:
+
+ Internal CopyMem
+
+--*/
+
+#include "BaseMemoryLibInternal.h"
+
+/**
+ Copy Length bytes from Source to Destination.
+
+ @param Destination Target of copy
+ @param Source Place to copy from
+ @param Length Number of bytes to copy
+
+ @return Destination
+
+**/
+VOID *
+EFIAPI
+InternalMemCopyMem (
+ OUT VOID *Destination,
+ IN CONST VOID *Source,
+ IN UINTN Length
+ )
+{
+ //
+ // Declare the local variables that actually move the data elements as
+ // volatile to prevent the optimizer from replacing this function with
+ // the intrinsic memcpy()
+ //
+ volatile UINT8 *Destination8;
+ CONST UINT8 *Source8;
+
+ if (Source > Destination) {
+ Destination8 = (UINT8*)Destination;
+ Source8 = (CONST UINT8*)Source;
+ while (Length-- != 0) {
+ *(Destination8++) = *(Source8++);
+ }
+ } else if (Source < Destination) {
+ Destination8 = (UINT8*)Destination + Length;
+ Source8 = (CONST UINT8*)Source + Length;
+ while (Length-- != 0) {
+ *(--Destination8) = *(--Source8);
+ }
+ }
+ return Destination;
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ebc/MemLibGeneric.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ebc/MemLibGeneric.c
new file mode 100644
index 0000000..284a492
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ebc/MemLibGeneric.c
@@ -0,0 +1,261 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ MemLibGeneric.c
+
+Abstract:
+
+ Architecture Independent Base Memory Library Implementation.
+
+--*/
+
+#include "BaseMemoryLibInternal.h"
+
+/**
+ Fills a target buffer with a 16-bit value, and returns the target buffer.
+
+ @param Buffer Pointer to the target buffer to fill.
+ @param Length Number of bytes in Buffer to fill.
+ @param Value Value with which to fill Length bytes of Buffer.
+
+ @return Buffer
+
+**/
+VOID *
+EFIAPI
+InternalMemSetMem16 (
+ OUT VOID *Buffer,
+ IN UINTN Length,
+ IN UINT16 Value
+ )
+{
+ do {
+ ((UINT16*)Buffer)[--Length] = Value;
+ } while (Length != 0);
+ return Buffer;
+}
+
+/**
+ Fills a target buffer with a 32-bit value, and returns the target buffer.
+
+ @param Buffer Pointer to the target buffer to fill.
+ @param Length Number of bytes in Buffer to fill.
+ @param Value Value with which to fill Length bytes of Buffer.
+
+ @return Buffer
+
+**/
+VOID *
+EFIAPI
+InternalMemSetMem32 (
+ OUT VOID *Buffer,
+ IN UINTN Length,
+ IN UINT32 Value
+ )
+{
+ do {
+ ((UINT32*)Buffer)[--Length] = Value;
+ } while (Length != 0);
+ return Buffer;
+}
+
+/**
+ Fills a target buffer with a 64-bit value, and returns the target buffer.
+
+ @param Buffer Pointer to the target buffer to fill.
+ @param Length Number of bytes in Buffer to fill.
+ @param Value Value with which to fill Length bytes of Buffer.
+
+ @return Buffer
+
+**/
+VOID *
+EFIAPI
+InternalMemSetMem64 (
+ OUT VOID *Buffer,
+ IN UINTN Length,
+ IN UINT64 Value
+ )
+{
+ do {
+ ((UINT64*)Buffer)[--Length] = Value;
+ } while (Length != 0);
+ return Buffer;
+}
+
+/**
+ Set Buffer to 0 for Size bytes.
+
+ @param Buffer Memory to set.
+ @param Size Number of bytes to set
+
+ @return Buffer
+
+**/
+VOID *
+EFIAPI
+InternalMemZeroMem (
+ OUT VOID *Buffer,
+ IN UINTN Length
+ )
+{
+ return InternalMemSetMem (Buffer, Length, 0);
+}
+
+/**
+ Compares two memory buffers of a given length.
+
+ @param DestinationBuffer First memory buffer
+ @param SourceBuffer Second memory buffer
+ @param Length Length of DestinationBuffer and SourceBuffer memory
+ regions to compare. Must be non-zero.
+
+ @retval 0 if MemOne == MemTwo
+
+**/
+INTN
+EFIAPI
+InternalMemCompareMem (
+ IN CONST VOID *DestinationBuffer,
+ IN CONST VOID *SourceBuffer,
+ IN UINTN Length
+ )
+{
+ while ((--Length != 0) &&
+ (*(INT8*)DestinationBuffer == *(INT8*)SourceBuffer)) {
+ DestinationBuffer = (INT8*)DestinationBuffer + 1;
+ SourceBuffer = (INT8*)SourceBuffer + 1;
+ }
+ return (INTN)*(UINT8*)DestinationBuffer - (INTN)*(UINT8*)SourceBuffer;
+}
+
+/**
+ Scans a target buffer for an 8-bit value, and returns a pointer to the
+ matching 8-bit value in the target buffer.
+
+ @param Buffer Pointer to the target buffer to scan.
+ @param Length Number of bytes in Buffer to scan. Must be non-zero.
+ @param Value Value to search for in the target buffer.
+
+ @return Pointer to the first occurrence or NULL if not found.
+
+**/
+CONST VOID *
+EFIAPI
+InternalMemScanMem8 (
+ IN CONST VOID *Buffer,
+ IN UINTN Length,
+ IN UINT8 Value
+ )
+{
+ CONST UINT8 *Pointer;
+
+ Pointer = (CONST UINT8*)Buffer;
+ do {
+ if (*(Pointer++) == Value) {
+ return Pointer;
+ }
+ } while (--Length != 0);
+ return NULL;
+}
+
+/**
+ Scans a target buffer for a 16-bit value, and returns a pointer to the
+ matching 16-bit value in the target buffer.
+
+ @param Buffer Pointer to the target buffer to scan.
+ @param Length Number of bytes in Buffer to scan. Must be non-zero.
+ @param Value Value to search for in the target buffer.
+
+ @return Pointer to the first occurrence or NULL if not found.
+
+**/
+CONST VOID *
+EFIAPI
+InternalMemScanMem16 (
+ IN CONST VOID *Buffer,
+ IN UINTN Length,
+ IN UINT16 Value
+ )
+{
+ CONST UINT16 *Pointer;
+
+ Pointer = (CONST UINT16*)Buffer;
+ do {
+ if (*(Pointer++) == Value) {
+ return Pointer;
+ }
+ } while (--Length != 0);
+ return NULL;
+}
+
+/**
+ Scans a target buffer for a 32-bit value, and returns a pointer to the
+ matching 32-bit value in the target buffer.
+
+ @param Buffer Pointer to the target buffer to scan.
+ @param Length Number of bytes in Buffer to scan. Must be non-zero.
+ @param Value Value to search for in the target buffer.
+
+ @return Pointer to the first occurrence or NULL if not found.
+
+**/
+CONST VOID *
+EFIAPI
+InternalMemScanMem32 (
+ IN CONST VOID *Buffer,
+ IN UINTN Length,
+ IN UINT32 Value
+ )
+{
+ CONST UINT32 *Pointer;
+
+ Pointer = (CONST UINT32*)Buffer;
+ do {
+ if (*(Pointer++) == Value) {
+ return Pointer;
+ }
+ } while (--Length != 0);
+ return NULL;
+}
+
+/**
+ Scans a target buffer for a 64-bit value, and returns a pointer to the
+ matching 64-bit value in the target buffer.
+
+ @param Buffer Pointer to the target buffer to scan.
+ @param Length Number of bytes in Buffer to scan. Must be non-zero.
+ @param Value Value to search for in the target buffer.
+
+ @return Pointer to the first occurrence or NULL if not found.
+
+**/
+CONST VOID *
+EFIAPI
+InternalMemScanMem64 (
+ IN CONST VOID *Buffer,
+ IN UINTN Length,
+ IN UINT64 Value
+ )
+{
+ CONST UINT64 *Pointer;
+
+ Pointer = (CONST UINT64*)Buffer;
+ do {
+ if (*(Pointer++) == Value) {
+ return Pointer;
+ }
+ } while (--Length != 0);
+ return NULL;
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ebc/SetMem.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ebc/SetMem.c
new file mode 100644
index 0000000..9c94c91
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ebc/SetMem.c
@@ -0,0 +1,55 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ SetMem.c
+
+Abstract:
+
+ Internal SetMem
+
+--*/
+
+#include "BaseMemoryLibInternal.h"
+
+/**
+ Set Buffer to Value for Size bytes.
+
+ @param Buffer Memory to set.
+ @param Size Number of bytes to set
+ @param Value Value of the set operation.
+
+ @return Buffer
+
+**/
+VOID *
+EFIAPI
+InternalMemSetMem (
+ IN VOID *Buffer,
+ IN UINTN Size,
+ IN UINT8 Value
+ )
+{
+ //
+ // Declare the local variables that actually move the data elements as
+ // volatile to prevent the optimizer from replacing this function with
+ // the intrinsic memset()
+ //
+ volatile UINT8 *Pointer;
+
+ Pointer = (UINT8*)Buffer;
+ while (Size-- != 0) {
+ *(Pointer++) = Value;
+ }
+ return Buffer;
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/EdkIIGlueBaseMemoryLib.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/EdkIIGlueBaseMemoryLib.cif
new file mode 100644
index 0000000..a290dfe
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/EdkIIGlueBaseMemoryLib.cif
@@ -0,0 +1,57 @@
+<component>
+ name = "EdkIIGlueBaseMemoryLib"
+ category = ModulePart
+ LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\BaseMemoryLib"
+ RefName = "EdkIIGlueBaseMemoryLib"
+[files]
+"EdkIIGlueBaseMemoryLib.sdl"
+"EdkIIGlueBaseMemoryLib.mak"
+"BaseMemoryLib.inf"
+"BaseMemoryLibInternal.h"
+"MemLibGuid.c"
+"MemLibGeneric.c"
+"CopyMem.c"
+"CopyMemWrapper.c"
+"SetMem.c"
+"SetMemWrapper.c"
+"SetMem16Wrapper.c"
+"SetMem32Wrapper.c"
+"SetMem64Wrapper.c"
+"CompareMemWrapper.c"
+"ZeroMemWrapper.c"
+"ScanMem8Wrapper.c"
+"ScanMem16Wrapper.c"
+"ScanMem32Wrapper.c"
+"ScanMem64Wrapper.c"
+"Ia32\SetMem16.asm"
+"Ia32\SetMem32.asm"
+"Ia32\SetMem64.asm"
+"Ia32\ZeroMem.asm"
+"Ia32\CompareMem.asm"
+"Ia32\CopyMem.asm"
+"Ia32\ScanMem8.asm"
+"Ia32\ScanMem16.asm"
+"Ia32\ScanMem32.asm"
+"Ia32\ScanMem64.asm"
+"Ia32\SetMem.asm"
+"X64\SetMem16.asm"
+"X64\SetMem32.asm"
+"X64\SetMem64.asm"
+"X64\ZeroMem.asm"
+"X64\CompareMem.asm"
+"X64\CopyMem.asm"
+"X64\ScanMem8.asm"
+"X64\ScanMem16.asm"
+"X64\ScanMem32.asm"
+"X64\ScanMem64.asm"
+"X64\SetMem.asm"
+"Ipf\CopyMem.c"
+"Ipf\MemLibGeneric.c"
+"Ipf\SetMem.c"
+"Ebc\CopyMem.c"
+"Ebc\MemLibGeneric.c"
+"Ebc\SetMem.c"
+[parts]
+"EdkIIGlueBaseMemoryLibIA32"
+"EdkIIGlueBaseMemoryLibX64"
+<endComponent>
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/EdkIIGlueBaseMemoryLib.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/EdkIIGlueBaseMemoryLib.mak
new file mode 100644
index 0000000..f8bd54d
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/EdkIIGlueBaseMemoryLib.mak
@@ -0,0 +1,142 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueBaseMemoryLib/EdkIIGlueBaseMemoryLib.mak 1 1/20/12 3:51a Jeffch $
+#
+# $Revision: 1 $
+#
+# $Date: 1/20/12 3:51a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueBaseMemoryLib/EdkIIGlueBaseMemoryLib.mak $
+#
+# 1 1/20/12 3:51a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 1/20/12 3:30a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 9/27/11 6:14a Wesleychen
+# Intel EDK initially releases.
+#
+# 1 9/18/09 1:51a Iminglin
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: EdkIIGlueBaseMemoryLib.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+
+EdkIIGlueBaseMemoryLib_OBJECTS=\
+$$(BUILD_DIR)\$(EdkIIGlueBaseMemoryLib_DIR)\ScanMem32Wrapper.obj \
+$$(BUILD_DIR)\$(EdkIIGlueBaseMemoryLib_DIR)\ScanMem64Wrapper.obj \
+$$(BUILD_DIR)\$(EdkIIGlueBaseMemoryLib_DIR)\SetMem16Wrapper.obj \
+$$(BUILD_DIR)\$(EdkIIGlueBaseMemoryLib_DIR)\SetMem32Wrapper.obj \
+$$(BUILD_DIR)\$(EdkIIGlueBaseMemoryLib_DIR)\SetMem64Wrapper.obj \
+$$(BUILD_DIR)\$(EdkIIGlueBaseMemoryLib_DIR)\SetMemWrapper.obj \
+$$(BUILD_DIR)\$(EdkIIGlueBaseMemoryLib_DIR)\ZeroMemWrapper.obj \
+$$(BUILD_DIR)\$(EdkIIGlueBaseMemoryLib_DIR)\CompareMemWrapper.obj \
+$$(BUILD_DIR)\$(EdkIIGlueBaseMemoryLib_DIR)\CopyMemWrapper.obj \
+$$(BUILD_DIR)\$(EdkIIGlueBaseMemoryLib_DIR)\MemLibGuid.obj \
+$$(BUILD_DIR)\$(EdkIIGlueBaseMemoryLib_DIR)\ScanMem8Wrapper.obj \
+$$(BUILD_DIR)\$(EdkIIGlueBaseMemoryLib_DIR)\ScanMem16Wrapper.obj
+
+EdkIIGlueBaseMemoryLib_IA32_OBJECTS=\
+$$(BUILD_DIR)\$(EdkIIGlueBaseMemoryLib_DIR)\Ia32\ScanMem8.obj \
+$$(BUILD_DIR)\$(EdkIIGlueBaseMemoryLib_DIR)\Ia32\ScanMem16.obj \
+$$(BUILD_DIR)\$(EdkIIGlueBaseMemoryLib_DIR)\Ia32\ScanMem32.obj \
+$$(BUILD_DIR)\$(EdkIIGlueBaseMemoryLib_DIR)\Ia32\ScanMem64.obj \
+$$(BUILD_DIR)\$(EdkIIGlueBaseMemoryLib_DIR)\Ia32\SetMem.obj \
+$$(BUILD_DIR)\$(EdkIIGlueBaseMemoryLib_DIR)\Ia32\SetMem16.obj \
+$$(BUILD_DIR)\$(EdkIIGlueBaseMemoryLib_DIR)\Ia32\SetMem32.obj \
+$$(BUILD_DIR)\$(EdkIIGlueBaseMemoryLib_DIR)\Ia32\SetMem64.obj \
+$$(BUILD_DIR)\$(EdkIIGlueBaseMemoryLib_DIR)\Ia32\ZeroMem.obj \
+$$(BUILD_DIR)\$(EdkIIGlueBaseMemoryLib_DIR)\Ia32\CompareMem.obj \
+$$(BUILD_DIR)\$(EdkIIGlueBaseMemoryLib_DIR)\Ia32\CopyMem.obj
+
+!IF "$(PROCESSOR)"=="IA32"
+EdkIIGlueBaseMemoryLib_OBJECTS =$(EdkIIGlueBaseMemoryLib_OBJECTS) $(EdkIIGlueBaseMemoryLib_IA32_OBJECTS)
+!ELSEIF "$(PROCESSOR)"=="x64"
+EdkIIGlueBaseMemoryLib_PEI_OBJECTS =$(EdkIIGlueBaseMemoryLib_OBJECTS) $(EdkIIGlueBaseMemoryLib_IA32_OBJECTS)
+EdkIIGlueBaseMemoryLib_DXE_OBJECTS =$(EdkIIGlueBaseMemoryLib_OBJECTS)\
+$$(BUILD_DIR)\$(EdkIIGlueBaseMemoryLib_DIR)\X64\CompareMem.obj\
+$$(BUILD_DIR)\$(EdkIIGlueBaseMemoryLib_DIR)\X64\CopyMem.obj\
+$$(BUILD_DIR)\$(EdkIIGlueBaseMemoryLib_DIR)\X64\ScanMem16.obj\
+$$(BUILD_DIR)\$(EdkIIGlueBaseMemoryLib_DIR)\X64\ScanMem32.obj\
+$$(BUILD_DIR)\$(EdkIIGlueBaseMemoryLib_DIR)\X64\ScanMem64.obj\
+$$(BUILD_DIR)\$(EdkIIGlueBaseMemoryLib_DIR)\X64\ScanMem8.obj\
+$$(BUILD_DIR)\$(EdkIIGlueBaseMemoryLib_DIR)\X64\SetMem.obj\
+$$(BUILD_DIR)\$(EdkIIGlueBaseMemoryLib_DIR)\X64\SetMem16.obj\
+$$(BUILD_DIR)\$(EdkIIGlueBaseMemoryLib_DIR)\X64\SetMem32.obj\
+$$(BUILD_DIR)\$(EdkIIGlueBaseMemoryLib_DIR)\X64\SetMem64.obj\
+$$(BUILD_DIR)\$(EdkIIGlueBaseMemoryLib_DIR)\X64\ZeroMem.obj
+!ENDIF
+
+!IF "$(PROCESSOR)"=="IA32"
+EdkIIGlueBaseMemoryLib_PORCESSOR_CIF=$(EdkIIGlueBaseMemoryLib_DIR)\Ia32\EdkIIGlueBaseMemoryLibIa32.cif
+!ELSEIF "$(PROCESSOR)"=="x64"
+EdkIIGlueBaseMemoryLib_PORCESSOR_PEI_CIF=$(EdkIIGlueBaseMemoryLib_DIR)\Ia32\EdkIIGlueBaseMemoryLibIa32.cif
+EdkIIGlueBaseMemoryLib_PORCESSOR_DXE_CIF=$(EdkIIGlueBaseMemoryLib_DIR)\X64\EdkIIGlueBaseMemoryLibX64.cif
+!ENDIF
+
+$(EdkIIGlueBaseMemoryLib_LIB) : EdkIIGlueBaseMemoryLib
+
+EdkIIGlueBaseMemoryLib : $(BUILD_DIR)\EdkIIGlueBaseMemoryLib.mak EdkIIGlueBaseMemoryLibBin
+
+!IF "$(PROCESSOR)"=="x64"
+$(BUILD_DIR)\EdkIIGlueBaseMemoryLib.mak : $(EdkIIGlueBaseMemoryLib_DIR)\$(@B).cif $(EdkIIGlueBaseMemoryLib_DIR)\$(@B).mak $(BUILD_RULES) $(EdkIIGlueBaseMemoryLib_PORCESSOR_PEI_CIF) $(EdkIIGlueBaseMemoryLib_PORCESSOR_DXE_CIF)
+ $(CIF2MAK) $(EdkIIGlueBaseMemoryLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS) $(EdkIIGlueBaseMemoryLib_PORCESSOR_PEI_CIF) $(EdkIIGlueBaseMemoryLib_PORCESSOR_DXE_CIF)
+!ELSE
+$(BUILD_DIR)\EdkIIGlueBaseMemoryLib.mak : $(EdkIIGlueBaseMemoryLib_DIR)\$(@B).cif $(EdkIIGlueBaseMemoryLib_DIR)\$(@B).mak $(BUILD_RULES) $(EdkIIGlueBaseMemoryLib_PORCESSOR_CIF)
+ $(CIF2MAK) $(EdkIIGlueBaseMemoryLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS) $(EdkIIGlueBaseMemoryLib_PORCESSOR_CIF)
+!ENDIF
+
+EdkIIGlueBaseMemoryLibBin : $(EdkIIGlueBaseLib_LIB)
+!IF "$(x64_BUILD)"=="1"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGlueBaseMemoryLib.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBaseMemoryLib_LIB)"\
+ "OBJECTS=$(EdkIIGlueBaseMemoryLib_DXE_OBJECTS)"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\IA32\
+ /f $(BUILD_DIR)\EdkIIGlueBaseMemoryLib.mak all\
+ TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBaseMemoryLib_LIB)"\
+ "OBJECTS=$(EdkIIGlueBaseMemoryLib_PEI_OBJECTS)"
+!ELSE
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGlueBaseMemoryLib.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBaseMemoryLib_LIB)"\
+ "OBJECTS=$(EdkIIGlueBaseMemoryLib_OBJECTS)"
+!ENDIF
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/EdkIIGlueBaseMemoryLib.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/EdkIIGlueBaseMemoryLib.sdl
new file mode 100644
index 0000000..f4ea6ce
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/EdkIIGlueBaseMemoryLib.sdl
@@ -0,0 +1,26 @@
+TOKEN
+ Name = "EdkIIGlueBaseMemoryLib_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable EdkIIGlueBaseMemoryLib support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "EdkIIGlueBaseMemoryLib_LIB"
+ Value = "$$(LIB_BUILD_DIR)\EdkIIGlueBaseMemoryLib.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "EdkIIGlueBaseMemoryLib_DIR"
+End
+
+MODULE
+ Help = "Includes EdkIIGlueBaseMemoryLib.mak to Project"
+ File = "EdkIIGlueBaseMemoryLib.mak"
+End
+
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/CompareMem.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/CompareMem.asm
new file mode 100644
index 0000000..d811ca9
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/CompareMem.asm
@@ -0,0 +1,54 @@
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2006, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; CompareMem.Asm
+;
+; Abstract:
+;
+; CompareMem function
+;
+; Notes:
+;
+; The following BaseMemoryLib instances share the same version of this file:
+;
+; BaseMemoryLibRepStr
+; BaseMemoryLibMmx
+; BaseMemoryLibSse2
+;
+;------------------------------------------------------------------------------
+
+ .686
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; INTN
+; EFIAPI
+; InternalMemCompareMem (
+; IN CONST VOID *DestinationBuffer,
+; IN CONST VOID *SourceBuffer,
+; IN UINTN Length
+; );
+;------------------------------------------------------------------------------
+InternalMemCompareMem PROC USES esi edi
+ mov esi, [esp + 12]
+ mov edi, [esp + 16]
+ mov ecx, [esp + 20]
+ repe cmpsb
+ movzx eax, byte ptr [esi - 1]
+ movzx edx, byte ptr [edi - 1]
+ sub eax, edx
+ ret
+InternalMemCompareMem ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/CopyMem.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/CopyMem.asm
new file mode 100644
index 0000000..6f818f0
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/CopyMem.asm
@@ -0,0 +1,63 @@
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2006, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; CopyMem.Asm
+;
+; Abstract:
+;
+; CopyMem function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .386
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; VOID *
+; InternalMemCopyMem (
+; IN VOID *Destination,
+; IN VOID *Source,
+; IN UINTN Count
+; )
+;------------------------------------------------------------------------------
+InternalMemCopyMem PROC USES esi edi
+ mov esi, [esp + 16] ; esi <- Source
+ mov edi, [esp + 12] ; edi <- Destination
+ mov edx, [esp + 20] ; edx <- Count
+ lea eax, [esi + edx - 1] ; eax <- End of Source
+ cmp esi, edi
+ jae @F
+ cmp eax, edi
+ jae @CopyBackward ; Copy backward if overlapped
+@@:
+ mov ecx, edx
+ and edx, 3
+ shr ecx, 2
+ rep movsd ; Copy as many Dwords as possible
+ jmp @CopyBytes
+@CopyBackward:
+ mov esi, eax ; esi <- End of Source
+ lea edi, [edi + edx - 1] ; edi <- End of Destination
+ std
+@CopyBytes:
+ mov ecx, edx
+ rep movsb ; Copy bytes backward
+ cld
+ mov eax, [esp + 12] ; eax <- Destination as return value
+ ret
+InternalMemCopyMem ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/EdkIIGlueBaseMemoryLibIA32.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/EdkIIGlueBaseMemoryLibIA32.cif
new file mode 100644
index 0000000..84776e8
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/EdkIIGlueBaseMemoryLibIA32.cif
@@ -0,0 +1,18 @@
+<component>
+ name = "EdkIIGlueBaseMemoryLibIa32"
+ category = ModulePart
+ LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\BaseMemoryLib\Ia32"
+ RefName = "EdkIIGlueBaseMemoryLibIa32"
+[files]
+"CompareMem.asm"
+"CopyMem.asm"
+"ScanMem16.asm"
+"ScanMem32.asm"
+"ScanMem64.asm"
+"ScanMem8.asm"
+"SetMem.asm"
+"SetMem16.asm"
+"SetMem32.asm"
+"SetMem64.asm"
+"ZeroMem.asm"
+<endComponent>
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/ScanMem16.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/ScanMem16.asm
new file mode 100644
index 0000000..8143e03
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/ScanMem16.asm
@@ -0,0 +1,53 @@
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2006, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ScanMem16.Asm
+;
+; Abstract:
+;
+; ScanMem16 function
+;
+; Notes:
+;
+; The following BaseMemoryLib instances share the same version of this file:
+;
+; BaseMemoryLibRepStr
+; BaseMemoryLibMmx
+; BaseMemoryLibSse2
+;
+;------------------------------------------------------------------------------
+
+ .686
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; CONST VOID *
+; EFIAPI
+; InternalMemScanMem16 (
+; IN CONST VOID *Buffer,
+; IN UINTN Length,
+; IN UINT16 Value
+; );
+;------------------------------------------------------------------------------
+InternalMemScanMem16 PROC USES edi
+ mov ecx, [esp + 12]
+ mov edi, [esp + 8]
+ mov eax, [esp + 16]
+ repne scasw
+ lea eax, [edi - 2]
+ cmovnz eax, ecx
+ ret
+InternalMemScanMem16 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/ScanMem32.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/ScanMem32.asm
new file mode 100644
index 0000000..1d22040
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/ScanMem32.asm
@@ -0,0 +1,53 @@
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2006, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ScanMem32.Asm
+;
+; Abstract:
+;
+; ScanMem32 function
+;
+; Notes:
+;
+; The following BaseMemoryLib instances share the same version of this file:
+;
+; BaseMemoryLibRepStr
+; BaseMemoryLibMmx
+; BaseMemoryLibSse2
+;
+;------------------------------------------------------------------------------
+
+ .686
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; CONST VOID *
+; EFIAPI
+; InternalMemScanMem32 (
+; IN CONST VOID *Buffer,
+; IN UINTN Length,
+; IN UINT32 Value
+; );
+;------------------------------------------------------------------------------
+InternalMemScanMem32 PROC USES edi
+ mov ecx, [esp + 12]
+ mov edi, [esp + 8]
+ mov eax, [esp + 16]
+ repne scasd
+ lea eax, [edi - 4]
+ cmovnz eax, ecx
+ ret
+InternalMemScanMem32 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/ScanMem64.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/ScanMem64.asm
new file mode 100644
index 0000000..ae4e6ce
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/ScanMem64.asm
@@ -0,0 +1,62 @@
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2006, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ScanMem64.Asm
+;
+; Abstract:
+;
+; ScanMem64 function
+;
+; Notes:
+;
+; The following BaseMemoryLib instances share the same version of this file:
+;
+; BaseMemoryLibRepStr
+; BaseMemoryLibMmx
+; BaseMemoryLibSse2
+;
+;------------------------------------------------------------------------------
+
+ .686
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; CONST VOID *
+; EFIAPI
+; InternalMemScanMem64 (
+; IN CONST VOID *Buffer,
+; IN UINTN Length,
+; IN UINT64 Value
+; );
+;------------------------------------------------------------------------------
+InternalMemScanMem64 PROC USES edi
+ mov ecx, [esp + 12]
+ mov eax, [esp + 16]
+ mov edx, [esp + 20]
+ mov edi, [esp + 8]
+@@:
+ cmp eax, [edi]
+ lea edi, [edi + 8]
+ loopne @B
+ jne @F
+ cmp edx, [edi - 4]
+ jecxz @F
+ jne @B
+@@:
+ lea eax, [edi - 8]
+ cmovne eax, ecx
+ ret
+InternalMemScanMem64 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/ScanMem8.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/ScanMem8.asm
new file mode 100644
index 0000000..8420b74
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/ScanMem8.asm
@@ -0,0 +1,53 @@
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2006, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ScanMem8.Asm
+;
+; Abstract:
+;
+; ScanMem8 function
+;
+; Notes:
+;
+; The following BaseMemoryLib instances share the same version of this file:
+;
+; BaseMemoryLibRepStr
+; BaseMemoryLibMmx
+; BaseMemoryLibSse2
+;
+;------------------------------------------------------------------------------
+
+ .686
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; CONST VOID *
+; EFIAPI
+; InternalMemScanMem8 (
+; IN CONST VOID *Buffer,
+; IN UINTN Length,
+; IN UINT8 Value
+; );
+;------------------------------------------------------------------------------
+InternalMemScanMem8 PROC USES edi
+ mov ecx, [esp + 12]
+ mov edi, [esp + 8]
+ mov al, [esp + 16]
+ repne scasb
+ lea eax, [edi - 1]
+ cmovnz eax, ecx
+ ret
+InternalMemScanMem8 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/SetMem.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/SetMem.asm
new file mode 100644
index 0000000..fc26b94
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/SetMem.asm
@@ -0,0 +1,45 @@
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2006, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; SetMem.Asm
+;
+; Abstract:
+;
+; SetMem function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .386
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; VOID *
+; InternalMemSetMem (
+; IN VOID *Buffer,
+; IN UINTN Count,
+; IN UINT8 Value
+; )
+;------------------------------------------------------------------------------
+InternalMemSetMem PROC USES edi
+ mov eax, [esp + 16]
+ mov edi, [esp + 8]
+ mov ecx, [esp + 12]
+ rep stosb
+ mov eax, [esp + 8]
+ ret
+InternalMemSetMem ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/SetMem16.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/SetMem16.asm
new file mode 100644
index 0000000..fd52154
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/SetMem16.asm
@@ -0,0 +1,45 @@
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2006, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; SetMem16.Asm
+;
+; Abstract:
+;
+; SetMem16 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .386
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; VOID *
+; InternalMemSetMem16 (
+; IN VOID *Buffer,
+; IN UINTN Count,
+; IN UINT16 Value
+; )
+;------------------------------------------------------------------------------
+InternalMemSetMem16 PROC USES edi
+ mov eax, [esp + 16]
+ mov edi, [esp + 8]
+ mov ecx, [esp + 12]
+ rep stosw
+ mov eax, [esp + 8]
+ ret
+InternalMemSetMem16 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/SetMem32.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/SetMem32.asm
new file mode 100644
index 0000000..2c58ef3
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/SetMem32.asm
@@ -0,0 +1,45 @@
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2006, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; SetMem32.Asm
+;
+; Abstract:
+;
+; SetMem32 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .386
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; VOID *
+; InternalMemSetMem32 (
+; IN VOID *Buffer,
+; IN UINTN Count,
+; IN UINT32 Value
+; )
+;------------------------------------------------------------------------------
+InternalMemSetMem32 PROC USES edi
+ mov eax, [esp + 16]
+ mov edi, [esp + 8]
+ mov ecx, [esp + 12]
+ rep stosd
+ mov eax, [esp + 8]
+ ret
+InternalMemSetMem32 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/SetMem64.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/SetMem64.asm
new file mode 100644
index 0000000..f379810
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/SetMem64.asm
@@ -0,0 +1,49 @@
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2006, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; SetMem64.Asm
+;
+; Abstract:
+;
+; SetMem64 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .386
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; VOID *
+; InternalMemSetMem64 (
+; IN VOID *Buffer,
+; IN UINTN Count,
+; IN UINT64 Value
+; )
+;------------------------------------------------------------------------------
+InternalMemSetMem64 PROC USES edi
+ mov ecx, [esp + 12]
+ mov eax, [esp + 16]
+ mov edx, [esp + 20]
+ mov edi, [esp + 8]
+@@:
+ mov [edi + ecx*8 - 8], eax
+ mov [edi + ecx*8 - 4], edx
+ loop @B
+ mov eax, edi
+ ret
+InternalMemSetMem64 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/ZeroMem.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/ZeroMem.asm
new file mode 100644
index 0000000..8419ead
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ia32/ZeroMem.asm
@@ -0,0 +1,50 @@
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2006, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ZeroMem.Asm
+;
+; Abstract:
+;
+; ZeroMem function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .386
+ .model flat,C
+ .code
+
+;------------------------------------------------------------------------------
+; VOID *
+; InternalMemZeroMem (
+; IN VOID *Buffer,
+; IN UINTN Count
+; );
+;------------------------------------------------------------------------------
+InternalMemZeroMem PROC USES edi
+ xor eax, eax
+ mov edi, [esp + 8]
+ mov ecx, [esp + 12]
+ mov edx, ecx
+ shr ecx, 2
+ and edx, 3
+ push edi
+ rep stosd
+ mov ecx, edx
+ rep stosb
+ pop eax
+ ret
+InternalMemZeroMem ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ipf/CopyMem.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ipf/CopyMem.c
new file mode 100644
index 0000000..17ea273
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ipf/CopyMem.c
@@ -0,0 +1,65 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ CopyMem.c
+
+Abstract:
+
+ Internal CopyMem
+
+--*/
+
+#include "BaseMemoryLibInternal.h"
+
+/**
+ Copy Length bytes from Source to Destination.
+
+ @param Destination Target of copy
+ @param Source Place to copy from
+ @param Length Number of bytes to copy
+
+ @return Destination
+
+**/
+VOID *
+EFIAPI
+InternalMemCopyMem (
+ OUT VOID *Destination,
+ IN CONST VOID *Source,
+ IN UINTN Length
+ )
+{
+ //
+ // Declare the local variables that actually move the data elements as
+ // volatile to prevent the optimizer from replacing this function with
+ // the intrinsic memcpy()
+ //
+ volatile UINT8 *Destination8;
+ CONST UINT8 *Source8;
+
+ if (Source > Destination) {
+ Destination8 = (UINT8*)Destination;
+ Source8 = (CONST UINT8*)Source;
+ while (Length-- != 0) {
+ *(Destination8++) = *(Source8++);
+ }
+ } else if (Source < Destination) {
+ Destination8 = (UINT8*)Destination + Length;
+ Source8 = (CONST UINT8*)Source + Length;
+ while (Length-- != 0) {
+ *(--Destination8) = *(--Source8);
+ }
+ }
+ return Destination;
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ipf/MemLibGeneric.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ipf/MemLibGeneric.c
new file mode 100644
index 0000000..284a492
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ipf/MemLibGeneric.c
@@ -0,0 +1,261 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ MemLibGeneric.c
+
+Abstract:
+
+ Architecture Independent Base Memory Library Implementation.
+
+--*/
+
+#include "BaseMemoryLibInternal.h"
+
+/**
+ Fills a target buffer with a 16-bit value, and returns the target buffer.
+
+ @param Buffer Pointer to the target buffer to fill.
+ @param Length Number of bytes in Buffer to fill.
+ @param Value Value with which to fill Length bytes of Buffer.
+
+ @return Buffer
+
+**/
+VOID *
+EFIAPI
+InternalMemSetMem16 (
+ OUT VOID *Buffer,
+ IN UINTN Length,
+ IN UINT16 Value
+ )
+{
+ do {
+ ((UINT16*)Buffer)[--Length] = Value;
+ } while (Length != 0);
+ return Buffer;
+}
+
+/**
+ Fills a target buffer with a 32-bit value, and returns the target buffer.
+
+ @param Buffer Pointer to the target buffer to fill.
+ @param Length Number of bytes in Buffer to fill.
+ @param Value Value with which to fill Length bytes of Buffer.
+
+ @return Buffer
+
+**/
+VOID *
+EFIAPI
+InternalMemSetMem32 (
+ OUT VOID *Buffer,
+ IN UINTN Length,
+ IN UINT32 Value
+ )
+{
+ do {
+ ((UINT32*)Buffer)[--Length] = Value;
+ } while (Length != 0);
+ return Buffer;
+}
+
+/**
+ Fills a target buffer with a 64-bit value, and returns the target buffer.
+
+ @param Buffer Pointer to the target buffer to fill.
+ @param Length Number of bytes in Buffer to fill.
+ @param Value Value with which to fill Length bytes of Buffer.
+
+ @return Buffer
+
+**/
+VOID *
+EFIAPI
+InternalMemSetMem64 (
+ OUT VOID *Buffer,
+ IN UINTN Length,
+ IN UINT64 Value
+ )
+{
+ do {
+ ((UINT64*)Buffer)[--Length] = Value;
+ } while (Length != 0);
+ return Buffer;
+}
+
+/**
+ Set Buffer to 0 for Size bytes.
+
+ @param Buffer Memory to set.
+ @param Size Number of bytes to set
+
+ @return Buffer
+
+**/
+VOID *
+EFIAPI
+InternalMemZeroMem (
+ OUT VOID *Buffer,
+ IN UINTN Length
+ )
+{
+ return InternalMemSetMem (Buffer, Length, 0);
+}
+
+/**
+ Compares two memory buffers of a given length.
+
+ @param DestinationBuffer First memory buffer
+ @param SourceBuffer Second memory buffer
+ @param Length Length of DestinationBuffer and SourceBuffer memory
+ regions to compare. Must be non-zero.
+
+ @retval 0 if MemOne == MemTwo
+
+**/
+INTN
+EFIAPI
+InternalMemCompareMem (
+ IN CONST VOID *DestinationBuffer,
+ IN CONST VOID *SourceBuffer,
+ IN UINTN Length
+ )
+{
+ while ((--Length != 0) &&
+ (*(INT8*)DestinationBuffer == *(INT8*)SourceBuffer)) {
+ DestinationBuffer = (INT8*)DestinationBuffer + 1;
+ SourceBuffer = (INT8*)SourceBuffer + 1;
+ }
+ return (INTN)*(UINT8*)DestinationBuffer - (INTN)*(UINT8*)SourceBuffer;
+}
+
+/**
+ Scans a target buffer for an 8-bit value, and returns a pointer to the
+ matching 8-bit value in the target buffer.
+
+ @param Buffer Pointer to the target buffer to scan.
+ @param Length Number of bytes in Buffer to scan. Must be non-zero.
+ @param Value Value to search for in the target buffer.
+
+ @return Pointer to the first occurrence or NULL if not found.
+
+**/
+CONST VOID *
+EFIAPI
+InternalMemScanMem8 (
+ IN CONST VOID *Buffer,
+ IN UINTN Length,
+ IN UINT8 Value
+ )
+{
+ CONST UINT8 *Pointer;
+
+ Pointer = (CONST UINT8*)Buffer;
+ do {
+ if (*(Pointer++) == Value) {
+ return Pointer;
+ }
+ } while (--Length != 0);
+ return NULL;
+}
+
+/**
+ Scans a target buffer for a 16-bit value, and returns a pointer to the
+ matching 16-bit value in the target buffer.
+
+ @param Buffer Pointer to the target buffer to scan.
+ @param Length Number of bytes in Buffer to scan. Must be non-zero.
+ @param Value Value to search for in the target buffer.
+
+ @return Pointer to the first occurrence or NULL if not found.
+
+**/
+CONST VOID *
+EFIAPI
+InternalMemScanMem16 (
+ IN CONST VOID *Buffer,
+ IN UINTN Length,
+ IN UINT16 Value
+ )
+{
+ CONST UINT16 *Pointer;
+
+ Pointer = (CONST UINT16*)Buffer;
+ do {
+ if (*(Pointer++) == Value) {
+ return Pointer;
+ }
+ } while (--Length != 0);
+ return NULL;
+}
+
+/**
+ Scans a target buffer for a 32-bit value, and returns a pointer to the
+ matching 32-bit value in the target buffer.
+
+ @param Buffer Pointer to the target buffer to scan.
+ @param Length Number of bytes in Buffer to scan. Must be non-zero.
+ @param Value Value to search for in the target buffer.
+
+ @return Pointer to the first occurrence or NULL if not found.
+
+**/
+CONST VOID *
+EFIAPI
+InternalMemScanMem32 (
+ IN CONST VOID *Buffer,
+ IN UINTN Length,
+ IN UINT32 Value
+ )
+{
+ CONST UINT32 *Pointer;
+
+ Pointer = (CONST UINT32*)Buffer;
+ do {
+ if (*(Pointer++) == Value) {
+ return Pointer;
+ }
+ } while (--Length != 0);
+ return NULL;
+}
+
+/**
+ Scans a target buffer for a 64-bit value, and returns a pointer to the
+ matching 64-bit value in the target buffer.
+
+ @param Buffer Pointer to the target buffer to scan.
+ @param Length Number of bytes in Buffer to scan. Must be non-zero.
+ @param Value Value to search for in the target buffer.
+
+ @return Pointer to the first occurrence or NULL if not found.
+
+**/
+CONST VOID *
+EFIAPI
+InternalMemScanMem64 (
+ IN CONST VOID *Buffer,
+ IN UINTN Length,
+ IN UINT64 Value
+ )
+{
+ CONST UINT64 *Pointer;
+
+ Pointer = (CONST UINT64*)Buffer;
+ do {
+ if (*(Pointer++) == Value) {
+ return Pointer;
+ }
+ } while (--Length != 0);
+ return NULL;
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ipf/SetMem.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ipf/SetMem.c
new file mode 100644
index 0000000..9c94c91
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/Ipf/SetMem.c
@@ -0,0 +1,55 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ SetMem.c
+
+Abstract:
+
+ Internal SetMem
+
+--*/
+
+#include "BaseMemoryLibInternal.h"
+
+/**
+ Set Buffer to Value for Size bytes.
+
+ @param Buffer Memory to set.
+ @param Size Number of bytes to set
+ @param Value Value of the set operation.
+
+ @return Buffer
+
+**/
+VOID *
+EFIAPI
+InternalMemSetMem (
+ IN VOID *Buffer,
+ IN UINTN Size,
+ IN UINT8 Value
+ )
+{
+ //
+ // Declare the local variables that actually move the data elements as
+ // volatile to prevent the optimizer from replacing this function with
+ // the intrinsic memset()
+ //
+ volatile UINT8 *Pointer;
+
+ Pointer = (UINT8*)Buffer;
+ while (Size-- != 0) {
+ *(Pointer++) = Value;
+ }
+ return Buffer;
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/MemLibGeneric.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/MemLibGeneric.c
new file mode 100644
index 0000000..284a492
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/MemLibGeneric.c
@@ -0,0 +1,261 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ MemLibGeneric.c
+
+Abstract:
+
+ Architecture Independent Base Memory Library Implementation.
+
+--*/
+
+#include "BaseMemoryLibInternal.h"
+
+/**
+ Fills a target buffer with a 16-bit value, and returns the target buffer.
+
+ @param Buffer Pointer to the target buffer to fill.
+ @param Length Number of bytes in Buffer to fill.
+ @param Value Value with which to fill Length bytes of Buffer.
+
+ @return Buffer
+
+**/
+VOID *
+EFIAPI
+InternalMemSetMem16 (
+ OUT VOID *Buffer,
+ IN UINTN Length,
+ IN UINT16 Value
+ )
+{
+ do {
+ ((UINT16*)Buffer)[--Length] = Value;
+ } while (Length != 0);
+ return Buffer;
+}
+
+/**
+ Fills a target buffer with a 32-bit value, and returns the target buffer.
+
+ @param Buffer Pointer to the target buffer to fill.
+ @param Length Number of bytes in Buffer to fill.
+ @param Value Value with which to fill Length bytes of Buffer.
+
+ @return Buffer
+
+**/
+VOID *
+EFIAPI
+InternalMemSetMem32 (
+ OUT VOID *Buffer,
+ IN UINTN Length,
+ IN UINT32 Value
+ )
+{
+ do {
+ ((UINT32*)Buffer)[--Length] = Value;
+ } while (Length != 0);
+ return Buffer;
+}
+
+/**
+ Fills a target buffer with a 64-bit value, and returns the target buffer.
+
+ @param Buffer Pointer to the target buffer to fill.
+ @param Length Number of bytes in Buffer to fill.
+ @param Value Value with which to fill Length bytes of Buffer.
+
+ @return Buffer
+
+**/
+VOID *
+EFIAPI
+InternalMemSetMem64 (
+ OUT VOID *Buffer,
+ IN UINTN Length,
+ IN UINT64 Value
+ )
+{
+ do {
+ ((UINT64*)Buffer)[--Length] = Value;
+ } while (Length != 0);
+ return Buffer;
+}
+
+/**
+ Set Buffer to 0 for Size bytes.
+
+ @param Buffer Memory to set.
+ @param Size Number of bytes to set
+
+ @return Buffer
+
+**/
+VOID *
+EFIAPI
+InternalMemZeroMem (
+ OUT VOID *Buffer,
+ IN UINTN Length
+ )
+{
+ return InternalMemSetMem (Buffer, Length, 0);
+}
+
+/**
+ Compares two memory buffers of a given length.
+
+ @param DestinationBuffer First memory buffer
+ @param SourceBuffer Second memory buffer
+ @param Length Length of DestinationBuffer and SourceBuffer memory
+ regions to compare. Must be non-zero.
+
+ @retval 0 if MemOne == MemTwo
+
+**/
+INTN
+EFIAPI
+InternalMemCompareMem (
+ IN CONST VOID *DestinationBuffer,
+ IN CONST VOID *SourceBuffer,
+ IN UINTN Length
+ )
+{
+ while ((--Length != 0) &&
+ (*(INT8*)DestinationBuffer == *(INT8*)SourceBuffer)) {
+ DestinationBuffer = (INT8*)DestinationBuffer + 1;
+ SourceBuffer = (INT8*)SourceBuffer + 1;
+ }
+ return (INTN)*(UINT8*)DestinationBuffer - (INTN)*(UINT8*)SourceBuffer;
+}
+
+/**
+ Scans a target buffer for an 8-bit value, and returns a pointer to the
+ matching 8-bit value in the target buffer.
+
+ @param Buffer Pointer to the target buffer to scan.
+ @param Length Number of bytes in Buffer to scan. Must be non-zero.
+ @param Value Value to search for in the target buffer.
+
+ @return Pointer to the first occurrence or NULL if not found.
+
+**/
+CONST VOID *
+EFIAPI
+InternalMemScanMem8 (
+ IN CONST VOID *Buffer,
+ IN UINTN Length,
+ IN UINT8 Value
+ )
+{
+ CONST UINT8 *Pointer;
+
+ Pointer = (CONST UINT8*)Buffer;
+ do {
+ if (*(Pointer++) == Value) {
+ return Pointer;
+ }
+ } while (--Length != 0);
+ return NULL;
+}
+
+/**
+ Scans a target buffer for a 16-bit value, and returns a pointer to the
+ matching 16-bit value in the target buffer.
+
+ @param Buffer Pointer to the target buffer to scan.
+ @param Length Number of bytes in Buffer to scan. Must be non-zero.
+ @param Value Value to search for in the target buffer.
+
+ @return Pointer to the first occurrence or NULL if not found.
+
+**/
+CONST VOID *
+EFIAPI
+InternalMemScanMem16 (
+ IN CONST VOID *Buffer,
+ IN UINTN Length,
+ IN UINT16 Value
+ )
+{
+ CONST UINT16 *Pointer;
+
+ Pointer = (CONST UINT16*)Buffer;
+ do {
+ if (*(Pointer++) == Value) {
+ return Pointer;
+ }
+ } while (--Length != 0);
+ return NULL;
+}
+
+/**
+ Scans a target buffer for a 32-bit value, and returns a pointer to the
+ matching 32-bit value in the target buffer.
+
+ @param Buffer Pointer to the target buffer to scan.
+ @param Length Number of bytes in Buffer to scan. Must be non-zero.
+ @param Value Value to search for in the target buffer.
+
+ @return Pointer to the first occurrence or NULL if not found.
+
+**/
+CONST VOID *
+EFIAPI
+InternalMemScanMem32 (
+ IN CONST VOID *Buffer,
+ IN UINTN Length,
+ IN UINT32 Value
+ )
+{
+ CONST UINT32 *Pointer;
+
+ Pointer = (CONST UINT32*)Buffer;
+ do {
+ if (*(Pointer++) == Value) {
+ return Pointer;
+ }
+ } while (--Length != 0);
+ return NULL;
+}
+
+/**
+ Scans a target buffer for a 64-bit value, and returns a pointer to the
+ matching 64-bit value in the target buffer.
+
+ @param Buffer Pointer to the target buffer to scan.
+ @param Length Number of bytes in Buffer to scan. Must be non-zero.
+ @param Value Value to search for in the target buffer.
+
+ @return Pointer to the first occurrence or NULL if not found.
+
+**/
+CONST VOID *
+EFIAPI
+InternalMemScanMem64 (
+ IN CONST VOID *Buffer,
+ IN UINTN Length,
+ IN UINT64 Value
+ )
+{
+ CONST UINT64 *Pointer;
+
+ Pointer = (CONST UINT64*)Buffer;
+ do {
+ if (*(Pointer++) == Value) {
+ return Pointer;
+ }
+ } while (--Length != 0);
+ return NULL;
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/MemLibGuid.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/MemLibGuid.c
new file mode 100644
index 0000000..7f752d4
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/MemLibGuid.c
@@ -0,0 +1,130 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ MemLibGuid.c
+
+Abstract:
+
+ Implementation of GUID functions.
+
+--*/
+
+#include "BaseMemoryLibInternal.h"
+
+/**
+ Copies a source GUID to a destination GUID.
+
+ This function copies the contents of the 128-bit GUID specified by SourceGuid to
+ DestinationGuid, and returns DestinationGuid.
+ If DestinationGuid is NULL, then ASSERT().
+ If SourceGuid is NULL, then ASSERT().
+
+ @param DestinationGuid Pointer to the destination GUID.
+ @param SourceGuid Pointer to the source GUID.
+
+ @return DestinationGuid.
+
+**/
+GUID *
+EFIAPI
+CopyGuid (
+ OUT GUID *DestinationGuid,
+ IN CONST GUID *SourceGuid
+ )
+{
+ WriteUnaligned64 (
+ (UINT64*)DestinationGuid,
+ ReadUnaligned64 ((CONST UINT64*)SourceGuid)
+ );
+ WriteUnaligned64 (
+ (UINT64*)DestinationGuid + 1,
+ ReadUnaligned64 ((CONST UINT64*)SourceGuid + 1)
+ );
+ return DestinationGuid;
+}
+
+/**
+ Compares two GUIDs.
+
+ This function compares Guid1 to Guid2. If the GUIDs are identical then TRUE is returned.
+ If there are any bit differences in the two GUIDs, then FALSE is returned.
+ If Guid1 is NULL, then ASSERT().
+ If Guid2 is NULL, then ASSERT().
+
+ @param Guid1 A pointer to a 128 bit GUID.
+ @param Guid2 A pointer to a 128 bit GUID.
+
+ @retval TRUE Guid1 and Guid2 are identical.
+ @retval FALSE Guid1 and Guid2 are not identical.
+
+**/
+BOOLEAN
+EFIAPI
+GlueCompareGuid (
+ IN CONST GUID *Guid1,
+ IN CONST GUID *Guid2
+ )
+{
+ return (BOOLEAN)(
+ ReadUnaligned64 ((CONST UINT64*)Guid1)
+ == ReadUnaligned64 ((CONST UINT64*)Guid2) &&
+ ReadUnaligned64 ((CONST UINT64*)Guid1 + 1)
+ == ReadUnaligned64 ((CONST UINT64*)Guid2 + 1)
+ );
+}
+
+/**
+ Scans a target buffer for a GUID, and returns a pointer to the matching GUID
+ in the target buffer.
+
+ This function searches target the buffer specified by Buffer and Length from
+ the lowest address to the highest address at 128-bit increments for the 128-bit
+ GUID value that matches Guid. If a match is found, then a pointer to the matching
+ GUID in the target buffer is returned. If no match is found, then NULL is returned.
+ If Length is 0, then NULL is returned.
+ If Length > 0 and Buffer is NULL, then ASSERT().
+ If Buffer is not aligned on a 32-bit boundary, then ASSERT().
+ If Length is not aligned on a 128-bit boundary, then ASSERT().
+ If Length is greater than (MAX_ADDRESS ?Buffer + 1), then ASSERT().
+
+ @param Buffer Pointer to the target buffer to scan.
+ @param Length Number of bytes in Buffer to scan.
+ @param Guid Value to search for in the target buffer.
+
+ @return A pointer to the matching Guid in the target buffer or NULL otherwise.
+
+**/
+VOID *
+EFIAPI
+ScanGuid (
+ IN CONST VOID *Buffer,
+ IN UINTN Length,
+ IN CONST GUID *Guid
+ )
+{
+ CONST GUID *GuidPtr;
+
+ ASSERT (((UINTN)Buffer & (sizeof (Guid->Data1) - 1)) == 0);
+ ASSERT (Length <= (MAX_ADDRESS - (UINTN)Buffer + 1));
+ ASSERT ((Length & (sizeof (*GuidPtr) - 1)) == 0);
+
+ GuidPtr = (GUID*)Buffer;
+ Buffer = GuidPtr + Length / sizeof (*GuidPtr);
+ while (GuidPtr < (CONST GUID*)Buffer) {
+ if (CompareGuid (GuidPtr, Guid)) {
+ return (VOID*)GuidPtr;
+ }
+ GuidPtr++;
+ }
+ return NULL;
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ScanMem16Wrapper.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ScanMem16Wrapper.c
new file mode 100644
index 0000000..9a93479
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ScanMem16Wrapper.c
@@ -0,0 +1,63 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ ScanMem16Wrapper.c
+
+Abstract:
+
+ ScanMem16() implementation.
+
+--*/
+
+#include "BaseMemoryLibInternal.h"
+
+/**
+ Scans a target buffer for a 16-bit value, and returns a pointer to the matching 16-bit value
+ in the target buffer.
+
+ This function searches target the buffer specified by Buffer and Length from the lowest
+ address to the highest address for a 16-bit value that matches Value. If a match is found,
+ then a pointer to the matching byte in the target buffer is returned. If no match is found,
+ then NULL is returned. If Length is 0, then NULL is returned.
+ If Length > 0 and Buffer is NULL, then ASSERT().
+ If Buffer is not aligned on a 16-bit boundary, then ASSERT().
+ If Length is not aligned on a 16-bit boundary, then ASSERT().
+ If Length is greater than (MAX_ADDRESS ?Buffer + 1), then ASSERT().
+
+ @param Buffer Pointer to the target buffer to scan.
+ @param Length Number of bytes in Buffer to scan.
+ @param Value Value to search for in the target buffer.
+
+ @return A pointer to the matching byte in the target buffer or NULL otherwise.
+
+**/
+VOID *
+EFIAPI
+ScanMem16 (
+ IN CONST VOID *Buffer,
+ IN UINTN Length,
+ IN UINT16 Value
+ )
+{
+ if (Length == 0) {
+ return NULL;
+ }
+
+ ASSERT (Buffer != NULL);
+ ASSERT (((UINTN)Buffer & (sizeof (Value) - 1)) == 0);
+ ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer));
+ ASSERT ((Length & (sizeof (Value) - 1)) == 0);
+
+ return (VOID*)InternalMemScanMem16 (Buffer, Length / sizeof (Value), Value);
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ScanMem32Wrapper.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ScanMem32Wrapper.c
new file mode 100644
index 0000000..42e7dd0
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ScanMem32Wrapper.c
@@ -0,0 +1,63 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ ScanMem32Wrapper.c
+
+Abstract:
+
+ ScanMem32() implementation.
+
+--*/
+
+#include "BaseMemoryLibInternal.h"
+
+/**
+ Scans a target buffer for a 32-bit value, and returns a pointer to the matching 32-bit value
+ in the target buffer.
+
+ This function searches target the buffer specified by Buffer and Length from the lowest
+ address to the highest address for a 32-bit value that matches Value. If a match is found,
+ then a pointer to the matching byte in the target buffer is returned. If no match is found,
+ then NULL is returned. If Length is 0, then NULL is returned.
+ If Length > 0 and Buffer is NULL, then ASSERT().
+ If Buffer is not aligned on a 32-bit boundary, then ASSERT().
+ If Length is not aligned on a 32-bit boundary, then ASSERT().
+ If Length is greater than (MAX_ADDRESS ?Buffer + 1), then ASSERT().
+
+ @param Buffer Pointer to the target buffer to scan.
+ @param Length Number of bytes in Buffer to scan.
+ @param Value Value to search for in the target buffer.
+
+ @return A pointer to the matching byte in the target buffer or NULL otherwise.
+
+**/
+VOID *
+EFIAPI
+ScanMem32 (
+ IN CONST VOID *Buffer,
+ IN UINTN Length,
+ IN UINT32 Value
+ )
+{
+ if (Length == 0) {
+ return NULL;
+ }
+
+ ASSERT (Buffer != NULL);
+ ASSERT (((UINTN)Buffer & (sizeof (Value) - 1)) == 0);
+ ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer));
+ ASSERT ((Length & (sizeof (Value) - 1)) == 0);
+
+ return (VOID*)InternalMemScanMem32 (Buffer, Length / sizeof (Value), Value);
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ScanMem64Wrapper.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ScanMem64Wrapper.c
new file mode 100644
index 0000000..c7b39f5
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ScanMem64Wrapper.c
@@ -0,0 +1,62 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ ScanMem64Wrapper.c
+
+Abstract:
+
+ ScanMem64() implementation.
+
+--*/
+
+#include "BaseMemoryLibInternal.h"
+
+/**
+ Scans a target buffer for a 64-bit value, and returns a pointer to the matching 64-bit value
+ in the target buffer.
+
+ This function searches target the buffer specified by Buffer and Length from the lowest
+ address to the highest address for a 64-bit value that matches Value. If a match is found,
+ then a pointer to the matching byte in the target buffer is returned. If no match is found,
+ then NULL is returned. If Length is 0, then NULL is returned.
+ If Length > 0 and Buffer is NULL, then ASSERT().
+ If Buffer is not aligned on a 64-bit boundary, then ASSERT().
+ If Length is not aligned on a 64-bit boundary, then ASSERT().
+ If Length is greater than (MAX_ADDRESS ?Buffer + 1), then ASSERT().
+
+ @param Buffer Pointer to the target buffer to scan.
+ @param Length Number of bytes in Buffer to scan.
+ @param Value Value to search for in the target buffer.
+
+ @return A pointer to the matching byte in the target buffer or NULL otherwise.
+
+**/
+VOID *
+EFIAPI
+ScanMem64 (
+ IN CONST VOID *Buffer,
+ IN UINTN Length,
+ IN UINT64 Value
+ )
+{
+ if (Length == 0) {
+ return NULL;
+ }
+
+ ASSERT (Buffer != NULL);
+ ASSERT (((UINTN)Buffer & (sizeof (Value) - 1)) == 0);
+ ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer));
+ ASSERT ((Length & (sizeof (Value) - 1)) == 0);
+
+ return (VOID*)InternalMemScanMem64 (Buffer, Length / sizeof (Value), Value);
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ScanMem8Wrapper.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ScanMem8Wrapper.c
new file mode 100644
index 0000000..084526b
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ScanMem8Wrapper.c
@@ -0,0 +1,57 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ ScanMem8Wrapper.c
+
+Abstract:
+
+ ScanMem8() implementation.
+
+--*/
+
+#include "BaseMemoryLibInternal.h"
+
+/**
+ Scans a target buffer for an 8-bit value, and returns a pointer to the matching 8-bit value
+ in the target buffer.
+
+ This function searches target the buffer specified by Buffer and Length from the lowest
+ address to the highest address for an 8-bit value that matches Value. If a match is found,
+ then a pointer to the matching byte in the target buffer is returned. If no match is found,
+ then NULL is returned. If Length is 0, then NULL is returned.
+ If Length > 0 and Buffer is NULL, then ASSERT().
+ If Length is greater than (MAX_ADDRESS ?Buffer + 1), then ASSERT().
+
+ @param Buffer Pointer to the target buffer to scan.
+ @param Length Number of bytes in Buffer to scan.
+ @param Value Value to search for in the target buffer.
+
+ @return A pointer to the matching byte in the target buffer or NULL otherwise.
+
+**/
+VOID *
+EFIAPI
+ScanMem8 (
+ IN CONST VOID *Buffer,
+ IN UINTN Length,
+ IN UINT8 Value
+ )
+{
+ if (Length == 0) {
+ return NULL;
+ }
+ ASSERT (Buffer != NULL);
+ ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer));
+
+ return (VOID*)InternalMemScanMem8 (Buffer, Length, Value);
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMem.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMem.c
new file mode 100644
index 0000000..9c94c91
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMem.c
@@ -0,0 +1,55 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ SetMem.c
+
+Abstract:
+
+ Internal SetMem
+
+--*/
+
+#include "BaseMemoryLibInternal.h"
+
+/**
+ Set Buffer to Value for Size bytes.
+
+ @param Buffer Memory to set.
+ @param Size Number of bytes to set
+ @param Value Value of the set operation.
+
+ @return Buffer
+
+**/
+VOID *
+EFIAPI
+InternalMemSetMem (
+ IN VOID *Buffer,
+ IN UINTN Size,
+ IN UINT8 Value
+ )
+{
+ //
+ // Declare the local variables that actually move the data elements as
+ // volatile to prevent the optimizer from replacing this function with
+ // the intrinsic memset()
+ //
+ volatile UINT8 *Pointer;
+
+ Pointer = (UINT8*)Buffer;
+ while (Size-- != 0) {
+ *(Pointer++) = Value;
+ }
+ return Buffer;
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMem16Wrapper.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMem16Wrapper.c
new file mode 100644
index 0000000..729d439
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMem16Wrapper.c
@@ -0,0 +1,61 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ SetMem16Wrapper.c
+
+Abstract:
+
+ SetMem16() implementation.
+
+--*/
+
+#include "BaseMemoryLibInternal.h"
+
+/**
+ Fills a target buffer with a 16-bit value, and returns the target buffer.
+
+ This function fills Length bytes of Buffer with the 16-bit value specified by
+ Value, and returns Buffer. Value is repeated every 16-bits in for Length
+ bytes of Buffer.
+
+ If Length > 0 and Buffer is NULL, then ASSERT().
+ If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
+ If Buffer is not aligned on a 16-bit boundary, then ASSERT().
+ If Length is not aligned on a 16-bit boundary, then ASSERT().
+
+ @param Buffer Pointer to the target buffer to fill.
+ @param Length Number of bytes in Buffer to fill.
+ @param Value Value with which to fill Length bytes of Buffer.
+
+ @return Buffer.
+
+**/
+VOID *
+EFIAPI
+SetMem16 (
+ OUT VOID *Buffer,
+ IN UINTN Length,
+ IN UINT16 Value
+ )
+{
+ if (Length == 0) {
+ return Buffer;
+ }
+
+ ASSERT (Buffer != NULL);
+ ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer));
+ ASSERT ((((UINTN)Buffer) & (sizeof (Value) - 1)) == 0);
+ ASSERT ((Length & (sizeof (Value) - 1)) == 0);
+
+ return InternalMemSetMem16 (Buffer, Length / sizeof (Value), Value);
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMem32Wrapper.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMem32Wrapper.c
new file mode 100644
index 0000000..517bb59
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMem32Wrapper.c
@@ -0,0 +1,61 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ SetMem32Wrapper.c
+
+Abstract:
+
+ SetMem32() implementation.
+
+--*/
+
+#include "BaseMemoryLibInternal.h"
+
+/**
+ Fills a target buffer with a 32-bit value, and returns the target buffer.
+
+ This function fills Length bytes of Buffer with the 32-bit value specified by
+ Value, and returns Buffer. Value is repeated every 32-bits in for Length
+ bytes of Buffer.
+
+ If Length > 0 and Buffer is NULL, then ASSERT().
+ If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
+ If Buffer is not aligned on a 32-bit boundary, then ASSERT().
+ If Length is not aligned on a 32-bit boundary, then ASSERT().
+
+ @param Buffer Pointer to the target buffer to fill.
+ @param Length Number of bytes in Buffer to fill.
+ @param Value Value with which to fill Length bytes of Buffer.
+
+ @return Buffer.
+
+**/
+VOID *
+EFIAPI
+SetMem32 (
+ OUT VOID *Buffer,
+ IN UINTN Length,
+ IN UINT32 Value
+ )
+{
+ if (Length == 0) {
+ return Buffer;
+ }
+
+ ASSERT (Buffer != NULL);
+ ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer));
+ ASSERT ((((UINTN)Buffer) & (sizeof (Value) - 1)) == 0);
+ ASSERT ((Length & (sizeof (Value) - 1)) == 0);
+
+ return InternalMemSetMem32 (Buffer, Length / sizeof (Value), Value);
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMem64Wrapper.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMem64Wrapper.c
new file mode 100644
index 0000000..2e265f5
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMem64Wrapper.c
@@ -0,0 +1,62 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ SetMem64Wrapper.c
+
+Abstract:
+
+ SetMem64() implementation.
+
+--*/
+
+#include "BaseMemoryLibInternal.h"
+
+/**
+ Fills a target buffer with a 64-bit value, and returns the target buffer.
+
+ This function fills Length bytes of Buffer with the 64-bit value specified by
+ Value, and returns Buffer. Value is repeated every 64-bits in for Length
+ bytes of Buffer.
+
+ If Length > 0 and Buffer is NULL, then ASSERT().
+ If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().
+ If Buffer is not aligned on a 64-bit boundary, then ASSERT().
+ If Length is not aligned on a 64-bit boundary, then ASSERT().
+
+ @param Buffer Pointer to the target buffer to fill.
+ @param Length Number of bytes in Buffer to fill.
+ @param Value Value with which to fill Length bytes of Buffer.
+
+ @return Buffer.
+
+**/
+VOID *
+EFIAPI
+SetMem64 (
+ OUT VOID *Buffer,
+ IN UINTN Length,
+ IN UINT64 Value
+ )
+{
+ if (Length == 0) {
+ return Buffer;
+ }
+
+ ASSERT (Buffer != NULL);
+ ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer));
+ ASSERT ((((UINTN)Buffer) & (sizeof (Value) - 1)) == 0);
+ ASSERT ((Length & (sizeof (Value) - 1)) == 0);
+
+ return InternalMemSetMem64 (Buffer, Length / sizeof (Value), Value);
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMemWrapper.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMemWrapper.c
new file mode 100644
index 0000000..f55c84c
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/SetMemWrapper.c
@@ -0,0 +1,52 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ SetMemWrapper.c
+
+Abstract:
+
+ SetMem() implementation.
+
+--*/
+
+#include "BaseMemoryLibInternal.h"
+
+/**
+ Fills a target buffer with a byte value, and returns the target buffer.
+
+ This function fills Length bytes of Buffer with Value, and returns Buffer.
+ If Length is greater than (MAX_ADDRESS ?Buffer + 1), then ASSERT().
+
+ @param Buffer Memory to set.
+ @param Length Number of bytes to set.
+ @param Value Value of the set operation.
+
+ @return Buffer.
+
+**/
+VOID *
+EFIAPI
+GlueSetMem (
+ OUT VOID *Buffer,
+ IN UINTN Length,
+ IN UINT8 Value
+ )
+{
+ if (Length == 0) {
+ return Buffer;
+ }
+
+ ASSERT ((Length - 1) <= (MAX_ADDRESS - (UINTN)Buffer));
+
+ return InternalMemSetMem (Buffer, Length, Value);
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/CompareMem.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/CompareMem.asm
new file mode 100644
index 0000000..d8e84e8
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/CompareMem.asm
@@ -0,0 +1,52 @@
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2006, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; CompareMem.Asm
+;
+; Abstract:
+;
+; CompareMem function
+;
+; Notes:
+;
+; The following BaseMemoryLib instances share the same version of this file:
+;
+; BaseMemoryLibRepStr
+; BaseMemoryLibMmx
+; BaseMemoryLibSse2
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; INTN
+; EFIAPI
+; InternalMemCompareMem (
+; IN CONST VOID *DestinationBuffer,
+; IN CONST VOID *SourceBuffer,
+; IN UINTN Length
+; );
+;------------------------------------------------------------------------------
+InternalMemCompareMem PROC USES rsi rdi
+ mov rsi, rcx
+ mov rdi, rdx
+ mov rcx, r8
+ repe cmpsb
+ movzx rax, byte ptr [rsi - 1]
+ movzx rdx, byte ptr [rdi - 1]
+ sub rax, rdx
+ ret
+InternalMemCompareMem ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/CopyMem.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/CopyMem.asm
new file mode 100644
index 0000000..0297975
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/CopyMem.asm
@@ -0,0 +1,61 @@
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2006, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; CopyMem.Asm
+;
+; Abstract:
+;
+; CopyMem function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; VOID *
+; EFIAPI
+; InternalMemCopyMem (
+; IN VOID *Destination,
+; IN VOID *Source,
+; IN UINTN Count
+; )
+;------------------------------------------------------------------------------
+InternalMemCopyMem PROC USES rsi rdi
+ mov rsi, rdx ; rsi <- Source
+ mov rdi, rcx ; rdi <- Destination
+ lea r9, [rsi + r8 - 1] ; r9 <- End of Source
+ cmp rsi, rdi
+ mov rax, rdi ; rax <- Destination as return value
+ jae @F
+ cmp r9, rdi
+ jae @CopyBackward ; Copy backward if overlapped
+@@:
+ mov rcx, r8
+ and r8, 7
+ shr rcx, 3
+ rep movsq ; Copy as many Qwords as possible
+ jmp @CopyBytes
+@CopyBackward:
+ mov rsi, r9 ; rsi <- End of Source
+ lea rdi, [rdi + r8 - 1] ; esi <- End of Destination
+ std ; set direction flag
+@CopyBytes:
+ mov rcx, r8
+ rep movsb ; Copy bytes backward
+ cld
+ ret
+InternalMemCopyMem ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/EdkIIGlueBaseMemoryLibX64.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/EdkIIGlueBaseMemoryLibX64.cif
new file mode 100644
index 0000000..676b818
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/EdkIIGlueBaseMemoryLibX64.cif
@@ -0,0 +1,18 @@
+<component>
+ name = "EdkIIGlueBaseMemoryLibX64"
+ category = ModulePart
+ LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\BaseMemoryLib\X64"
+ RefName = "EdkIIGlueBaseMemoryLibX64"
+[files]
+"CompareMem.asm"
+"CopyMem.asm"
+"ScanMem16.asm"
+"ScanMem32.asm"
+"ScanMem64.asm"
+"ScanMem8.asm"
+"SetMem.asm"
+"SetMem16.asm"
+"SetMem32.asm"
+"SetMem64.asm"
+"ZeroMem.asm"
+<endComponent>
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/ScanMem16.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/ScanMem16.asm
new file mode 100644
index 0000000..9d4bcab
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/ScanMem16.asm
@@ -0,0 +1,51 @@
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2006, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ScanMem16.Asm
+;
+; Abstract:
+;
+; ScanMem16 function
+;
+; Notes:
+;
+; The following BaseMemoryLib instances share the same version of this file:
+;
+; BaseMemoryLibRepStr
+; BaseMemoryLibMmx
+; BaseMemoryLibSse2
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; CONST VOID *
+; EFIAPI
+; InternalMemScanMem16 (
+; IN CONST VOID *Buffer,
+; IN UINTN Length,
+; IN UINT16 Value
+; );
+;------------------------------------------------------------------------------
+InternalMemScanMem16 PROC USES rdi
+ mov rdi, rcx
+ mov rax, r8
+ mov rcx, rdx
+ repne scasw
+ lea rax, [rdi - 2]
+ cmovnz rax, rcx
+ ret
+InternalMemScanMem16 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/ScanMem32.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/ScanMem32.asm
new file mode 100644
index 0000000..a59c5b4
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/ScanMem32.asm
@@ -0,0 +1,51 @@
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2006, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ScanMem32.Asm
+;
+; Abstract:
+;
+; ScanMem32 function
+;
+; Notes:
+;
+; The following BaseMemoryLib instances share the same version of this file:
+;
+; BaseMemoryLibRepStr
+; BaseMemoryLibMmx
+; BaseMemoryLibSse2
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; CONST VOID *
+; EFIAPI
+; InternalMemScanMem32 (
+; IN CONST VOID *Buffer,
+; IN UINTN Length,
+; IN UINT32 Value
+; );
+;------------------------------------------------------------------------------
+InternalMemScanMem32 PROC USES rdi
+ mov rdi, rcx
+ mov rax, r8
+ mov rcx, rdx
+ repne scasd
+ lea rax, [rdi - 4]
+ cmovnz rax, rcx
+ ret
+InternalMemScanMem32 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/ScanMem64.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/ScanMem64.asm
new file mode 100644
index 0000000..87c8dfb
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/ScanMem64.asm
@@ -0,0 +1,51 @@
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2006, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ScanMem64.Asm
+;
+; Abstract:
+;
+; ScanMem64 function
+;
+; Notes:
+;
+; The following BaseMemoryLib instances share the same version of this file:
+;
+; BaseMemoryLibRepStr
+; BaseMemoryLibMmx
+; BaseMemoryLibSse2
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; CONST VOID *
+; EFIAPI
+; InternalMemScanMem64 (
+; IN CONST VOID *Buffer,
+; IN UINTN Length,
+; IN UINT64 Value
+; );
+;------------------------------------------------------------------------------
+InternalMemScanMem64 PROC USES rdi
+ mov rdi, rcx
+ mov rax, r8
+ mov rcx, rdx
+ repne scasq
+ lea rax, [rdi - 8]
+ cmovnz rax, rcx
+ ret
+InternalMemScanMem64 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/ScanMem8.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/ScanMem8.asm
new file mode 100644
index 0000000..dff52e5
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/ScanMem8.asm
@@ -0,0 +1,51 @@
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2006, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ScanMem8.Asm
+;
+; Abstract:
+;
+; ScanMem8 function
+;
+; Notes:
+;
+; The following BaseMemoryLib instances share the same version of this file:
+;
+; BaseMemoryLibRepStr
+; BaseMemoryLibMmx
+; BaseMemoryLibSse2
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; CONST VOID *
+; EFIAPI
+; InternalMemScanMem8 (
+; IN CONST VOID *Buffer,
+; IN UINTN Length,
+; IN UINT8 Value
+; );
+;------------------------------------------------------------------------------
+InternalMemScanMem8 PROC USES rdi
+ mov rdi, rcx
+ mov rcx, rdx
+ mov rax, r8
+ repne scasb
+ lea rax, [rdi - 1]
+ cmovnz rax, rcx ; set rax to 0 if not found
+ ret
+InternalMemScanMem8 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/SetMem.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/SetMem.asm
new file mode 100644
index 0000000..39791f3
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/SetMem.asm
@@ -0,0 +1,44 @@
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2006, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; SetMem.Asm
+;
+; Abstract:
+;
+; SetMem function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; VOID *
+; EFIAPI
+; InternalMemSetMem (
+; IN VOID *Buffer,
+; IN UINTN Count,
+; IN UINT8 Value
+; )
+;------------------------------------------------------------------------------
+InternalMemSetMem PROC USES rdi
+ mov rax, r8
+ mov rdi, rcx
+ xchg rcx, rdx
+ rep stosb
+ mov rax, rdx
+ ret
+InternalMemSetMem ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/SetMem16.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/SetMem16.asm
new file mode 100644
index 0000000..9dc9525
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/SetMem16.asm
@@ -0,0 +1,44 @@
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2006, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; SetMem16.Asm
+;
+; Abstract:
+;
+; SetMem16 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; VOID *
+; EFIAPI
+; InternalMemSetMem16 (
+; IN VOID *Buffer,
+; IN UINTN Count,
+; IN UINT16 Value
+; )
+;------------------------------------------------------------------------------
+InternalMemSetMem16 PROC USES rdi
+ mov rdi, rcx
+ mov rax, r8
+ xchg rcx, rdx
+ rep stosw
+ mov rax, rdx
+ ret
+InternalMemSetMem16 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/SetMem32.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/SetMem32.asm
new file mode 100644
index 0000000..416577b
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/SetMem32.asm
@@ -0,0 +1,44 @@
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2006, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; SetMem32.Asm
+;
+; Abstract:
+;
+; SetMem32 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; VOID *
+; EFIAPI
+; InternalMemSetMem32 (
+; IN VOID *Buffer,
+; IN UINTN Count,
+; IN UINT32 Value
+; );
+;------------------------------------------------------------------------------
+InternalMemSetMem32 PROC USES rdi
+ mov rdi, rcx
+ mov rax, r8
+ xchg rcx, rdx
+ rep stosd
+ mov rax, rdx
+ ret
+InternalMemSetMem32 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/SetMem64.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/SetMem64.asm
new file mode 100644
index 0000000..4cece3d
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/SetMem64.asm
@@ -0,0 +1,43 @@
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2006, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; SetMem64.Asm
+;
+; Abstract:
+;
+; SetMem64 function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; VOID *
+; InternalMemSetMem64 (
+; IN VOID *Buffer,
+; IN UINTN Count,
+; IN UINT64 Value
+; )
+;------------------------------------------------------------------------------
+InternalMemSetMem64 PROC USES rdi
+ mov rdi, rcx
+ mov rax, r8
+ xchg rcx, rdx
+ rep stosq
+ mov rax, rdx
+ ret
+InternalMemSetMem64 ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/ZeroMem.asm b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/ZeroMem.asm
new file mode 100644
index 0000000..1b1b809
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/X64/ZeroMem.asm
@@ -0,0 +1,47 @@
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2006, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ZeroMem.Asm
+;
+; Abstract:
+;
+; ZeroMem function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; VOID *
+; InternalMemZeroMem (
+; IN VOID *Buffer,
+; IN UINTN Count
+; );
+;------------------------------------------------------------------------------
+InternalMemZeroMem PROC USES rdi
+ push rcx
+ xor rax, rax
+ mov rdi, rcx
+ mov rcx, rdx
+ shr rcx, 3
+ and rdx, 7
+ rep stosq
+ mov ecx, edx
+ rep stosb
+ pop rax
+ ret
+InternalMemZeroMem ENDP
+
+ END
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ZeroMemWrapper.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ZeroMemWrapper.c
new file mode 100644
index 0000000..5d7c1e0
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseMemoryLib/ZeroMemWrapper.c
@@ -0,0 +1,47 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ ZeroMemWrapper.c
+
+Abstract:
+
+ ZeroMem() implementation.
+
+--*/
+
+#include "BaseMemoryLibInternal.h"
+
+/**
+ Fills a target buffer with zeros, and returns the target buffer.
+
+ This function fills Length bytes of Buffer with zeros, and returns Buffer.
+ If Length > 0 and Buffer is NULL, then ASSERT().
+ If Length is greater than (MAX_ADDRESS ?Buffer + 1), then ASSERT().
+
+ @param Buffer Pointer to the target buffer to fill with zeros.
+ @param Length Number of bytes in Buffer to fill with zeros.
+
+ @return Buffer.
+
+**/
+VOID *
+EFIAPI
+GlueZeroMem (
+ OUT VOID *Buffer,
+ IN UINTN Length
+ )
+{
+ ASSERT (!(Buffer == NULL && Length > 0));
+ ASSERT (Length <= (MAX_ADDRESS - (UINTN)Buffer + 1));
+ return InternalMemZeroMem (Buffer, Length);
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciCf8Lib/BasePciCf8Lib.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciCf8Lib/BasePciCf8Lib.inf
new file mode 100644
index 0000000..737e75d
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciCf8Lib/BasePciCf8Lib.inf
@@ -0,0 +1,79 @@
+#/*++
+#
+# Copyright (c) 2004 - 2006, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# BasePciCf8Lib.inf
+#
+# Abstract:
+#
+# Component description file for BasePciCf8Lib.
+#
+#--*/
+
+[defines]
+BASE_NAME = EdkIIGlueBasePciCf8Lib
+COMPONENT_TYPE = LIBRARY
+
+[sources.common]
+ PciLib.c
+
+[sources.ia32]
+
+
+[sources.x64]
+
+
+[sources.ipf]
+
+
+[sources.ebc]
+
+
+[includes.common]
+ .
+ ..\..\Include
+ ..\..\include\Library
+ $(EDK_SOURCE)\Foundation
+ $(EDK_SOURCE)\Foundation\Framework
+ $(EDK_SOURCE)\Foundation\Efi
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+ $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include
+
+[libraries.common]
+ EdkIIGlueBaseIoLibIntrinsic
+
+[libraries.ia32]
+
+
+[libraries.x64]
+
+
+[nmake.common]
+ C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION
+ LIB_STD_FLAGS = /NOLOGO /IGNORE:4006
+
+[nmake.ia32]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32
+
+[nmake.x64]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64
+
+[nmake.ipf]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF
+
+[nmake.ebc]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciCf8Lib/EdkIIGlueBasePciCf8Lib.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciCf8Lib/EdkIIGlueBasePciCf8Lib.cif
new file mode 100644
index 0000000..f3b575a
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciCf8Lib/EdkIIGlueBasePciCf8Lib.cif
@@ -0,0 +1,11 @@
+<component>
+ name = "EdkIIGlueBasePciCf8Lib"
+ category = ModulePart
+ LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\BasePciCf8Lib"
+ RefName = "EdkIIGlueBasePciCf8Lib"
+[files]
+"EdkIIGlueBasePciCf8Lib.sdl"
+"EdkIIGlueBasePciCf8Lib.mak"
+"BasePciCf8Lib.inf"
+"PciLib.c"
+<endComponent>
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciCf8Lib/EdkIIGlueBasePciCf8Lib.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciCf8Lib/EdkIIGlueBasePciCf8Lib.mak
new file mode 100644
index 0000000..e0d1e10
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciCf8Lib/EdkIIGlueBasePciCf8Lib.mak
@@ -0,0 +1,85 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueBasePciCf8Lib/EdkIIGlueBasePciCf8Lib.mak 1 1/20/12 3:53a Jeffch $
+#
+# $Revision: 1 $
+#
+# $Date: 1/20/12 3:53a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueBasePciCf8Lib/EdkIIGlueBasePciCf8Lib.mak $
+#
+# 1 1/20/12 3:53a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 9/27/11 6:15a Wesleychen
+# Intel EDK initially releases.
+#
+# 1 9/18/09 1:51a Iminglin
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: EdkIIGlueBasePciCf8Lib.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+
+
+$(EdkIIGlueBasePciCf8Lib_LIB) : EdkIIGlueBasePciCf8Lib
+
+EdkIIGlueBasePciCf8Lib : $(BUILD_DIR)\EdkIIGlueBasePciCf8Lib.mak EdkIIGlueBasePciCf8LibBin
+
+$(BUILD_DIR)\EdkIIGlueBasePciCf8Lib.mak : $(EdkIIGlueBasePciCf8Lib_DIR)\$(@B).cif $(EdkIIGlueBasePciCf8Lib_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(EdkIIGlueBasePciCf8Lib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+EdkIIGlueBasePciCf8Lib_LIB_LINKS=\
+!IF "$(PROCESSOR)"=="IA32" || "$(PROCESSOR)"=="x64"
+$(EdkIIGlueBaseIoLibIntrinsic_LIB)
+!ENDIF
+
+EdkIIGlueBasePciCf8LibBin : $(EdkIIGlueBasePciCf8Lib_LIB_LINKS)
+!IF "$(x64_BUILD)"=="1"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGlueBasePciCf8Lib.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBasePciCf8Lib_LIB)"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\IA32\
+ /f $(BUILD_DIR)\EdkIIGlueBasePciCf8Lib.mak all\
+ TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBasePciCf8Lib_LIB)"
+!ELSE
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGlueBasePciCf8Lib.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBasePciCf8Lib_LIB)"
+!ENDIF
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciCf8Lib/EdkIIGlueBasePciCf8Lib.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciCf8Lib/EdkIIGlueBasePciCf8Lib.sdl
new file mode 100644
index 0000000..00c7a6f
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciCf8Lib/EdkIIGlueBasePciCf8Lib.sdl
@@ -0,0 +1,26 @@
+TOKEN
+ Name = "EdkIIGlueBasePciCf8Lib_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable EdkIIGlueBasePciCf8Lib support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "EdkIIGlueBasePciCf8Lib_LIB"
+ Value = "$$(LIB_BUILD_DIR)\EdkIIGlueBasePciCf8Lib.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "EdkIIGlueBasePciCf8Lib_DIR"
+End
+
+MODULE
+ Help = "Includes EdkIIGlueBasePciCf8Lib.mak to Project"
+ File = "EdkIIGlueBasePciCf8Lib.mak"
+End
+
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciCf8Lib/PciLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciCf8Lib/PciLib.c
new file mode 100644
index 0000000..ee09942
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciCf8Lib/PciLib.c
@@ -0,0 +1,1468 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PciLib.c
+
+Abstract:
+
+ PCI Library.
+
+--*/
+
+#include "EdkIIGlueBase.h"
+
+//
+// Declare I/O Ports used to perform PCI Confguration Cycles
+//
+#define PCI_CONFIGURATION_ADDRESS_PORT 0xCF8
+#define PCI_CONFIGURATION_DATA_PORT 0xCFC
+
+//
+// Declare macro to convert PCI Library formatted address to CF8 formatted address
+//
+// PCI Library formatted address CF8 Formatted Address
+// ============================= ======================
+// Bits 00..11 Register Bits 00..07 Register
+// Bits 12..14 Function Bits 08..10 Function
+// Bits 15..19 Device Bits 11..15 Device
+// Bits 20..27 Bus Bits 16..23 Bus
+// Bits 28..31 Reserved(MBZ) Bits 24..30 Reserved(MBZ)
+// Bits 31..31 Must be 1
+//
+
+/**
+ Assert the validity of a PCI address. A valid PCI address should contain 1's
+ only in the low 28 bits.
+
+ @param A The address to validate.
+ @param M Additional bits to assert to be zero.
+
+**/
+#define ASSERT_INVALID_PCI_ADDRESS(A,M) \
+ ASSERT (((A) & (~0xffff0ff | (M))) == 0)
+
+/**
+ Convert a PCI Express address to PCI CF8 address.
+
+ @param A The address to convert.
+
+ @retval The coverted address.
+
+**/
+#define PCI_TO_CF8_ADDRESS(A) \
+ ((UINT32) ((((A) >> 4) & 0x00ffff00) | ((A) & 0xfc) | 0x80000000))
+
+/**
+ Reads an 8-bit PCI configuration register.
+
+ Reads and returns the 8-bit PCI configuration register specified by Address.
+ This function must guarantee that all PCI read and write operations are
+ serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If the register specified by Address >= 0x100, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+
+ @return The read value from the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciCf8Read8 (
+ IN UINTN Address
+ )
+{
+ ASSERT_INVALID_PCI_ADDRESS (Address, 0);
+ IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address));
+ return IoRead8 (PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 3));
+}
+
+/**
+ Writes an 8-bit PCI configuration register.
+
+ Writes the 8-bit PCI configuration register specified by Address with the
+ value specified by Value. Value is returned. This function must guarantee
+ that all PCI read and write operations are serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If the register specified by Address >= 0x100, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param Value The value to write.
+
+ @return The value written to the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciCf8Write8 (
+ IN UINTN Address,
+ IN UINT8 Value
+ )
+{
+ ASSERT_INVALID_PCI_ADDRESS (Address, 0);
+ IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address));
+ return IoWrite8 (
+ PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 3),
+ Value
+ );
+}
+
+/**
+ Performs a bitwise inclusive OR of an 8-bit PCI configuration register with
+ an 8-bit value.
+
+ Reads the 8-bit PCI configuration register specified by Address, performs a
+ bitwise inclusive OR between the read result and the value specified by
+ OrData, and writes the result to the 8-bit PCI configuration register
+ specified by Address. The value written to the PCI configuration register is
+ returned. This function must guarantee that all PCI read and write operations
+ are serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If the register specified by Address >= 0x100, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param OrData The value to OR with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciCf8Or8 (
+ IN UINTN Address,
+ IN UINT8 OrData
+ )
+{
+ ASSERT_INVALID_PCI_ADDRESS (Address, 0);
+ IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address));
+ return IoOr8 (
+ PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 3),
+ OrData
+ );
+}
+
+/**
+ Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit
+ value.
+
+ Reads the 8-bit PCI configuration register specified by Address, performs a
+ bitwise AND between the read result and the value specified by AndData, and
+ writes the result to the 8-bit PCI configuration register specified by
+ Address. The value written to the PCI configuration register is returned.
+ This function must guarantee that all PCI read and write operations are
+ serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If the register specified by Address >= 0x100, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param AndData The value to AND with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciCf8And8 (
+ IN UINTN Address,
+ IN UINT8 AndData
+ )
+{
+ ASSERT_INVALID_PCI_ADDRESS (Address, 0);
+ IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address));
+ return IoAnd8 (
+ PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 3),
+ AndData
+ );
+}
+
+/**
+ Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit
+ value, followed a bitwise inclusive OR with another 8-bit value.
+
+ Reads the 8-bit PCI configuration register specified by Address, performs a
+ bitwise AND between the read result and the value specified by AndData,
+ performs a bitwise inclusive OR between the result of the AND operation and
+ the value specified by OrData, and writes the result to the 8-bit PCI
+ configuration register specified by Address. The value written to the PCI
+ configuration register is returned. This function must guarantee that all PCI
+ read and write operations are serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If the register specified by Address >= 0x100, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param AndData The value to AND with the PCI configuration register.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciCf8AndThenOr8 (
+ IN UINTN Address,
+ IN UINT8 AndData,
+ IN UINT8 OrData
+ )
+{
+ ASSERT_INVALID_PCI_ADDRESS (Address, 0);
+ IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address));
+ return IoAndThenOr8 (
+ PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 3),
+ AndData,
+ OrData
+ );
+}
+
+/**
+ Reads a bit field of a PCI configuration register.
+
+ Reads the bit field in an 8-bit PCI configuration register. The bit field is
+ specified by the StartBit and the EndBit. The value of the bit field is
+ returned.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If the register specified by Address >= 0x100, then ASSERT().
+ If StartBit is greater than 7, then ASSERT().
+ If EndBit is greater than 7, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to read.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..7.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..7.
+
+ @return The value of the bit field read from the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciCf8BitFieldRead8 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit
+ )
+{
+ ASSERT_INVALID_PCI_ADDRESS (Address, 0);
+ IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address));
+ return IoBitFieldRead8 (
+ PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 3),
+ StartBit,
+ EndBit
+ );
+}
+
+/**
+ Writes a bit field to a PCI configuration register.
+
+ Writes Value to the bit field of the PCI configuration register. The bit
+ field is specified by the StartBit and the EndBit. All other bits in the
+ destination PCI configuration register are preserved. The new value of the
+ 8-bit register is returned.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If the register specified by Address >= 0x100, then ASSERT().
+ If StartBit is greater than 7, then ASSERT().
+ If EndBit is greater than 7, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..7.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..7.
+ @param Value New value of the bit field.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciCf8BitFieldWrite8 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT8 Value
+ )
+{
+ ASSERT_INVALID_PCI_ADDRESS (Address, 0);
+ IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address));
+ return IoBitFieldWrite8 (
+ PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 3),
+ StartBit,
+ EndBit,
+ Value
+ );
+}
+
+/**
+ Reads a bit field in an 8-bit PCI configuration, performs a bitwise OR, and
+ writes the result back to the bit field in the 8-bit port.
+
+ Reads the 8-bit PCI configuration register specified by Address, performs a
+ bitwise inclusive OR between the read result and the value specified by
+ OrData, and writes the result to the 8-bit PCI configuration register
+ specified by Address. The value written to the PCI configuration register is
+ returned. This function must guarantee that all PCI read and write operations
+ are serialized. Extra left bits in OrData are stripped.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If the register specified by Address >= 0x100, then ASSERT().
+ If StartBit is greater than 7, then ASSERT().
+ If EndBit is greater than 7, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..7.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..7.
+ @param OrData The value to OR with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciCf8BitFieldOr8 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT8 OrData
+ )
+{
+ ASSERT_INVALID_PCI_ADDRESS (Address, 0);
+ IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address));
+ return IoBitFieldOr8 (
+ PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 3),
+ StartBit,
+ EndBit,
+ OrData
+ );
+}
+
+/**
+ Reads a bit field in an 8-bit PCI configuration register, performs a bitwise
+ AND, and writes the result back to the bit field in the 8-bit register.
+
+ Reads the 8-bit PCI configuration register specified by Address, performs a
+ bitwise AND between the read result and the value specified by AndData, and
+ writes the result to the 8-bit PCI configuration register specified by
+ Address. The value written to the PCI configuration register is returned.
+ This function must guarantee that all PCI read and write operations are
+ serialized. Extra left bits in AndData are stripped.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If the register specified by Address >= 0x100, then ASSERT().
+ If StartBit is greater than 7, then ASSERT().
+ If EndBit is greater than 7, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..7.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..7.
+ @param AndData The value to AND with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciCf8BitFieldAnd8 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT8 AndData
+ )
+{
+ ASSERT_INVALID_PCI_ADDRESS (Address, 0);
+ IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address));
+ return IoBitFieldAnd8 (
+ PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 3),
+ StartBit,
+ EndBit,
+ AndData
+ );
+}
+
+/**
+ Reads a bit field in an 8-bit port, performs a bitwise AND followed by a
+ bitwise inclusive OR, and writes the result back to the bit field in the
+ 8-bit port.
+
+ Reads the 8-bit PCI configuration register specified by Address, performs a
+ bitwise AND followed by a bitwise inclusive OR between the read result and
+ the value specified by AndData, and writes the result to the 8-bit PCI
+ configuration register specified by Address. The value written to the PCI
+ configuration register is returned. This function must guarantee that all PCI
+ read and write operations are serialized. Extra left bits in both AndData and
+ OrData are stripped.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If the register specified by Address >= 0x100, then ASSERT().
+ If StartBit is greater than 7, then ASSERT().
+ If EndBit is greater than 7, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..7.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..7.
+ @param AndData The value to AND with the PCI configuration register.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciCf8BitFieldAndThenOr8(
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT8 AndData,
+ IN UINT8 OrData
+ )
+{
+ ASSERT_INVALID_PCI_ADDRESS (Address, 0);
+ IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address));
+ return IoBitFieldAndThenOr8 (
+ PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 3),
+ StartBit,
+ EndBit,
+ AndData,
+ OrData
+ );
+}
+
+/**
+ Reads a 16-bit PCI configuration register.
+
+ Reads and returns the 16-bit PCI configuration register specified by Address.
+ This function must guarantee that all PCI read and write operations are
+ serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 16-bit boundary, then ASSERT().
+ If the register specified by Address >= 0x100, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+
+ @return The read value from the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciCf8Read16 (
+ IN UINTN Address
+ )
+{
+ ASSERT_INVALID_PCI_ADDRESS (Address, 1);
+ IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address));
+ return IoRead16 (PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 2));
+}
+
+/**
+ Writes a 16-bit PCI configuration register.
+
+ Writes the 16-bit PCI configuration register specified by Address with the
+ value specified by Value. Value is returned. This function must guarantee
+ that all PCI read and write operations are serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 16-bit boundary, then ASSERT().
+ If the register specified by Address >= 0x100, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param Value The value to write.
+
+ @return The value written to the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciCf8Write16 (
+ IN UINTN Address,
+ IN UINT16 Value
+ )
+{
+ ASSERT_INVALID_PCI_ADDRESS (Address, 1);
+ IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address));
+ return IoWrite16 (
+ PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 2),
+ Value
+ );
+}
+
+/**
+ Performs a bitwise inclusive OR of a 16-bit PCI configuration register with
+ a 16-bit value.
+
+ Reads the 16-bit PCI configuration register specified by Address, performs a
+ bitwise inclusive OR between the read result and the value specified by
+ OrData, and writes the result to the 16-bit PCI configuration register
+ specified by Address. The value written to the PCI configuration register is
+ returned. This function must guarantee that all PCI read and write operations
+ are serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 16-bit boundary, then ASSERT().
+ If the register specified by Address >= 0x100, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param OrData The value to OR with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciCf8Or16 (
+ IN UINTN Address,
+ IN UINT16 OrData
+ )
+{
+ ASSERT_INVALID_PCI_ADDRESS (Address, 1);
+ IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address));
+ return IoOr16 (
+ PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 2),
+ OrData
+ );
+}
+
+/**
+ Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit
+ value.
+
+ Reads the 16-bit PCI configuration register specified by Address, performs a
+ bitwise AND between the read result and the value specified by AndData, and
+ writes the result to the 16-bit PCI configuration register specified by
+ Address. The value written to the PCI configuration register is returned.
+ This function must guarantee that all PCI read and write operations are
+ serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 16-bit boundary, then ASSERT().
+ If the register specified by Address >= 0x100, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param AndData The value to AND with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciCf8And16 (
+ IN UINTN Address,
+ IN UINT16 AndData
+ )
+{
+ ASSERT_INVALID_PCI_ADDRESS (Address, 1);
+ IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address));
+ return IoAnd16 (
+ PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 2),
+ AndData
+ );
+}
+
+/**
+ Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit
+ value, followed a bitwise inclusive OR with another 16-bit value.
+
+ Reads the 16-bit PCI configuration register specified by Address, performs a
+ bitwise AND between the read result and the value specified by AndData,
+ performs a bitwise inclusive OR between the result of the AND operation and
+ the value specified by OrData, and writes the result to the 16-bit PCI
+ configuration register specified by Address. The value written to the PCI
+ configuration register is returned. This function must guarantee that all PCI
+ read and write operations are serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 16-bit boundary, then ASSERT().
+ If the register specified by Address >= 0x100, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param AndData The value to AND with the PCI configuration register.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciCf8AndThenOr16 (
+ IN UINTN Address,
+ IN UINT16 AndData,
+ IN UINT16 OrData
+ )
+{
+ ASSERT_INVALID_PCI_ADDRESS (Address, 1);
+ IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address));
+ return IoAndThenOr16 (
+ PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 2),
+ AndData,
+ OrData
+ );
+}
+
+/**
+ Reads a bit field of a PCI configuration register.
+
+ Reads the bit field in a 16-bit PCI configuration register. The bit field is
+ specified by the StartBit and the EndBit. The value of the bit field is
+ returned.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 16-bit boundary, then ASSERT().
+ If the register specified by Address >= 0x100, then ASSERT().
+ If StartBit is greater than 15, then ASSERT().
+ If EndBit is greater than 15, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to read.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..15.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..15.
+
+ @return The value of the bit field read from the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciCf8BitFieldRead16 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit
+ )
+{
+ ASSERT_INVALID_PCI_ADDRESS (Address, 1);
+ IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address));
+ return IoBitFieldRead16 (
+ PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 2),
+ StartBit,
+ EndBit
+ );
+}
+
+/**
+ Writes a bit field to a PCI configuration register.
+
+ Writes Value to the bit field of the PCI configuration register. The bit
+ field is specified by the StartBit and the EndBit. All other bits in the
+ destination PCI configuration register are preserved. The new value of the
+ 16-bit register is returned.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 16-bit boundary, then ASSERT().
+ If the register specified by Address >= 0x100, then ASSERT().
+ If StartBit is greater than 15, then ASSERT().
+ If EndBit is greater than 15, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..15.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..15.
+ @param Value New value of the bit field.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciCf8BitFieldWrite16 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT16 Value
+ )
+{
+ ASSERT_INVALID_PCI_ADDRESS (Address, 1);
+ IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address));
+ return IoBitFieldWrite16 (
+ PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 2),
+ StartBit,
+ EndBit,
+ Value
+ );
+}
+
+/**
+ Reads a bit field in a 16-bit PCI configuration, performs a bitwise OR, and
+ writes the result back to the bit field in the 16-bit port.
+
+ Reads the 16-bit PCI configuration register specified by Address, performs a
+ bitwise inclusive OR between the read result and the value specified by
+ OrData, and writes the result to the 16-bit PCI configuration register
+ specified by Address. The value written to the PCI configuration register is
+ returned. This function must guarantee that all PCI read and write operations
+ are serialized. Extra left bits in OrData are stripped.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 16-bit boundary, then ASSERT().
+ If the register specified by Address >= 0x100, then ASSERT().
+ If StartBit is greater than 15, then ASSERT().
+ If EndBit is greater than 15, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..15.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..15.
+ @param OrData The value to OR with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciCf8BitFieldOr16 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT16 OrData
+ )
+{
+ ASSERT_INVALID_PCI_ADDRESS (Address, 1);
+ IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address));
+ return IoBitFieldOr16 (
+ PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 2),
+ StartBit,
+ EndBit,
+ OrData
+ );
+}
+
+/**
+ Reads a bit field in a 16-bit PCI configuration register, performs a bitwise
+ AND, and writes the result back to the bit field in the 16-bit register.
+
+ Reads the 16-bit PCI configuration register specified by Address, performs a
+ bitwise AND between the read result and the value specified by AndData, and
+ writes the result to the 16-bit PCI configuration register specified by
+ Address. The value written to the PCI configuration register is returned.
+ This function must guarantee that all PCI read and write operations are
+ serialized. Extra left bits in AndData are stripped.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 16-bit boundary, then ASSERT().
+ If the register specified by Address >= 0x100, then ASSERT().
+ If StartBit is greater than 15, then ASSERT().
+ If EndBit is greater than 15, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..15.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..15.
+ @param AndData The value to AND with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciCf8BitFieldAnd16 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT16 AndData
+ )
+{
+ ASSERT_INVALID_PCI_ADDRESS (Address, 1);
+ IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address));
+ return IoBitFieldAnd16 (
+ PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 2),
+ StartBit,
+ EndBit,
+ AndData
+ );
+}
+
+/**
+ Reads a bit field in a 16-bit port, performs a bitwise AND followed by a
+ bitwise inclusive OR, and writes the result back to the bit field in the
+ 16-bit port.
+
+ Reads the 16-bit PCI configuration register specified by Address, performs a
+ bitwise AND followed by a bitwise inclusive OR between the read result and
+ the value specified by AndData, and writes the result to the 16-bit PCI
+ configuration register specified by Address. The value written to the PCI
+ configuration register is returned. This function must guarantee that all PCI
+ read and write operations are serialized. Extra left bits in both AndData and
+ OrData are stripped.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 16-bit boundary, then ASSERT().
+ If the register specified by Address >= 0x100, then ASSERT().
+ If StartBit is greater than 15, then ASSERT().
+ If EndBit is greater than 15, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..15.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..15.
+ @param AndData The value to AND with the PCI configuration register.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciCf8BitFieldAndThenOr16(
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT16 AndData,
+ IN UINT16 OrData
+ )
+{
+ ASSERT_INVALID_PCI_ADDRESS (Address, 1);
+ IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address));
+ return IoBitFieldAndThenOr16 (
+ PCI_CONFIGURATION_DATA_PORT + (UINT16)(Address & 2),
+ StartBit,
+ EndBit,
+ AndData,
+ OrData
+ );
+}
+
+/**
+ Reads a 32-bit PCI configuration register.
+
+ Reads and returns the 32-bit PCI configuration register specified by Address.
+ This function must guarantee that all PCI read and write operations are
+ serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 32-bit boundary, then ASSERT().
+ If the register specified by Address >= 0x100, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+
+ @return The read value from the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciCf8Read32 (
+ IN UINTN Address
+ )
+{
+ ASSERT_INVALID_PCI_ADDRESS (Address, 3);
+ IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address));
+ return IoRead32 (PCI_CONFIGURATION_DATA_PORT);
+}
+
+/**
+ Writes a 32-bit PCI configuration register.
+
+ Writes the 32-bit PCI configuration register specified by Address with the
+ value specified by Value. Value is returned. This function must guarantee
+ that all PCI read and write operations are serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 32-bit boundary, then ASSERT().
+ If the register specified by Address >= 0x100, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param Value The value to write.
+
+ @return The value written to the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciCf8Write32 (
+ IN UINTN Address,
+ IN UINT32 Value
+ )
+{
+ ASSERT_INVALID_PCI_ADDRESS (Address, 3);
+ IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address));
+ return IoWrite32 (
+ PCI_CONFIGURATION_DATA_PORT,
+ Value
+ );
+}
+
+/**
+ Performs a bitwise inclusive OR of a 32-bit PCI configuration register with
+ a 32-bit value.
+
+ Reads the 32-bit PCI configuration register specified by Address, performs a
+ bitwise inclusive OR between the read result and the value specified by
+ OrData, and writes the result to the 32-bit PCI configuration register
+ specified by Address. The value written to the PCI configuration register is
+ returned. This function must guarantee that all PCI read and write operations
+ are serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 32-bit boundary, then ASSERT().
+ If the register specified by Address >= 0x100, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param OrData The value to OR with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciCf8Or32 (
+ IN UINTN Address,
+ IN UINT32 OrData
+ )
+{
+ ASSERT_INVALID_PCI_ADDRESS (Address, 3);
+ IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address));
+ return IoOr32 (
+ PCI_CONFIGURATION_DATA_PORT,
+ OrData
+ );
+}
+
+/**
+ Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit
+ value.
+
+ Reads the 32-bit PCI configuration register specified by Address, performs a
+ bitwise AND between the read result and the value specified by AndData, and
+ writes the result to the 32-bit PCI configuration register specified by
+ Address. The value written to the PCI configuration register is returned.
+ This function must guarantee that all PCI read and write operations are
+ serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 32-bit boundary, then ASSERT().
+ If the register specified by Address >= 0x100, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param AndData The value to AND with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciCf8And32 (
+ IN UINTN Address,
+ IN UINT32 AndData
+ )
+{
+ ASSERT_INVALID_PCI_ADDRESS (Address, 3);
+ IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address));
+ return IoAnd32 (
+ PCI_CONFIGURATION_DATA_PORT,
+ AndData
+ );
+}
+
+/**
+ Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit
+ value, followed a bitwise inclusive OR with another 32-bit value.
+
+ Reads the 32-bit PCI configuration register specified by Address, performs a
+ bitwise AND between the read result and the value specified by AndData,
+ performs a bitwise inclusive OR between the result of the AND operation and
+ the value specified by OrData, and writes the result to the 32-bit PCI
+ configuration register specified by Address. The value written to the PCI
+ configuration register is returned. This function must guarantee that all PCI
+ read and write operations are serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 32-bit boundary, then ASSERT().
+ If the register specified by Address >= 0x100, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param AndData The value to AND with the PCI configuration register.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciCf8AndThenOr32 (
+ IN UINTN Address,
+ IN UINT32 AndData,
+ IN UINT32 OrData
+ )
+{
+ ASSERT_INVALID_PCI_ADDRESS (Address, 3);
+ IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address));
+ return IoAndThenOr32 (
+ PCI_CONFIGURATION_DATA_PORT,
+ AndData,
+ OrData
+ );
+}
+
+/**
+ Reads a bit field of a PCI configuration register.
+
+ Reads the bit field in a 32-bit PCI configuration register. The bit field is
+ specified by the StartBit and the EndBit. The value of the bit field is
+ returned.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 32-bit boundary, then ASSERT().
+ If the register specified by Address >= 0x100, then ASSERT().
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to read.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+
+ @return The value of the bit field read from the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciCf8BitFieldRead32 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit
+ )
+{
+ ASSERT_INVALID_PCI_ADDRESS (Address, 3);
+ IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address));
+ return IoBitFieldRead32 (
+ PCI_CONFIGURATION_DATA_PORT,
+ StartBit,
+ EndBit
+ );
+}
+
+/**
+ Writes a bit field to a PCI configuration register.
+
+ Writes Value to the bit field of the PCI configuration register. The bit
+ field is specified by the StartBit and the EndBit. All other bits in the
+ destination PCI configuration register are preserved. The new value of the
+ 32-bit register is returned.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 32-bit boundary, then ASSERT().
+ If the register specified by Address >= 0x100, then ASSERT().
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+ @param Value New value of the bit field.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciCf8BitFieldWrite32 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT32 Value
+ )
+{
+ ASSERT_INVALID_PCI_ADDRESS (Address, 3);
+ IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address));
+ return IoBitFieldWrite32 (
+ PCI_CONFIGURATION_DATA_PORT,
+ StartBit,
+ EndBit,
+ Value
+ );
+}
+
+/**
+ Reads a bit field in a 32-bit PCI configuration, performs a bitwise OR, and
+ writes the result back to the bit field in the 32-bit port.
+
+ Reads the 32-bit PCI configuration register specified by Address, performs a
+ bitwise inclusive OR between the read result and the value specified by
+ OrData, and writes the result to the 32-bit PCI configuration register
+ specified by Address. The value written to the PCI configuration register is
+ returned. This function must guarantee that all PCI read and write operations
+ are serialized. Extra left bits in OrData are stripped.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 32-bit boundary, then ASSERT().
+ If the register specified by Address >= 0x100, then ASSERT().
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+ @param OrData The value to OR with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciCf8BitFieldOr32 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT32 OrData
+ )
+{
+ ASSERT_INVALID_PCI_ADDRESS (Address, 3);
+ IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address));
+ return IoBitFieldOr32 (
+ PCI_CONFIGURATION_DATA_PORT,
+ StartBit,
+ EndBit,
+ OrData
+ );
+}
+
+/**
+ Reads a bit field in a 32-bit PCI configuration register, performs a bitwise
+ AND, and writes the result back to the bit field in the 32-bit register.
+
+ Reads the 32-bit PCI configuration register specified by Address, performs a
+ bitwise AND between the read result and the value specified by AndData, and
+ writes the result to the 32-bit PCI configuration register specified by
+ Address. The value written to the PCI configuration register is returned.
+ This function must guarantee that all PCI read and write operations are
+ serialized. Extra left bits in AndData are stripped.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 32-bit boundary, then ASSERT().
+ If the register specified by Address >= 0x100, then ASSERT().
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+ @param AndData The value to AND with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciCf8BitFieldAnd32 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT32 AndData
+ )
+{
+ ASSERT_INVALID_PCI_ADDRESS (Address, 3);
+ IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address));
+ return IoBitFieldAnd32 (
+ PCI_CONFIGURATION_DATA_PORT,
+ StartBit,
+ EndBit,
+ AndData
+ );
+}
+
+/**
+ Reads a bit field in a 32-bit port, performs a bitwise AND followed by a
+ bitwise inclusive OR, and writes the result back to the bit field in the
+ 32-bit port.
+
+ Reads the 32-bit PCI configuration register specified by Address, performs a
+ bitwise AND followed by a bitwise inclusive OR between the read result and
+ the value specified by AndData, and writes the result to the 32-bit PCI
+ configuration register specified by Address. The value written to the PCI
+ configuration register is returned. This function must guarantee that all PCI
+ read and write operations are serialized. Extra left bits in both AndData and
+ OrData are stripped.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 32-bit boundary, then ASSERT().
+ If the register specified by Address >= 0x100, then ASSERT().
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+ @param AndData The value to AND with the PCI configuration register.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciCf8BitFieldAndThenOr32(
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT32 AndData,
+ IN UINT32 OrData
+ )
+{
+ ASSERT_INVALID_PCI_ADDRESS (Address, 3);
+ IoWrite32 (PCI_CONFIGURATION_ADDRESS_PORT, PCI_TO_CF8_ADDRESS (Address));
+ return IoBitFieldAndThenOr32 (
+ PCI_CONFIGURATION_DATA_PORT,
+ StartBit,
+ EndBit,
+ AndData,
+ OrData
+ );
+}
+
+/**
+ Reads a range of PCI configuration registers into a caller supplied buffer.
+
+ Reads the range of PCI configuration registers specified by StartAddress and
+ Size into the buffer specified by Buffer. This function only allows the PCI
+ configuration registers from a single PCI function to be read. Size is
+ returned. When possible 32-bit PCI configuration read cycles are used to read
+ from StartAdress to StartAddress + Size. Due to alignment restrictions, 8-bit
+ and 16-bit PCI configuration read cycles may be used at the beginning and the
+ end of the range.
+
+ If StartAddress > 0x0FFFFFFF, then ASSERT().
+ If the register specified by StartAddress >= 0x100, then ASSERT().
+ If ((StartAddress & 0xFFF) + Size) > 0x100, then ASSERT().
+ If Size > 0 and Buffer is NULL, then ASSERT().
+
+ @param StartAddress Starting address that encodes the PCI Bus, Device,
+ Function and Register.
+ @param Size Size in bytes of the transfer.
+ @param Buffer Pointer to a buffer receiving the data read.
+
+ @return Size
+
+**/
+UINTN
+EFIAPI
+PciCf8ReadBuffer (
+ IN UINTN StartAddress,
+ IN UINTN Size,
+ OUT VOID *Buffer
+ )
+{
+ UINTN ReturnValue;
+
+ ASSERT_INVALID_PCI_ADDRESS (StartAddress, 0);
+ ASSERT (((StartAddress & 0xFFF) + Size) <= 0x100);
+
+ if (Size == 0) {
+ return Size;
+ }
+
+ ASSERT (Buffer != NULL);
+
+ //
+ // Save Size for return
+ //
+ ReturnValue = Size;
+
+ if ((StartAddress & 1) != 0) {
+ //
+ // Read a byte if StartAddress is byte aligned
+ //
+ *(volatile UINT8 *)Buffer = PciCf8Read8 (StartAddress);
+ StartAddress += sizeof (UINT8);
+ Size -= sizeof (UINT8);
+ Buffer = (UINT8*)Buffer + 1;
+ }
+
+ if (Size >= sizeof (UINT16) && (StartAddress & 2) != 0) {
+ //
+ // Read a word if StartAddress is word aligned
+ //
+ *(volatile UINT16 *)Buffer = PciCf8Read16 (StartAddress);
+ StartAddress += sizeof (UINT16);
+ Size -= sizeof (UINT16);
+ Buffer = (UINT16*)Buffer + 1;
+ }
+
+ while (Size >= sizeof (UINT32)) {
+ //
+ // Read as many double words as possible
+ //
+ *(volatile UINT32 *)Buffer = PciCf8Read32 (StartAddress);
+ StartAddress += sizeof (UINT32);
+ Size -= sizeof (UINT32);
+ Buffer = (UINT32*)Buffer + 1;
+ }
+
+ if (Size >= sizeof (UINT16)) {
+ //
+ // Read the last remaining word if exist
+ //
+ *(volatile UINT16 *)Buffer = PciCf8Read16 (StartAddress);
+ StartAddress += sizeof (UINT16);
+ Size -= sizeof (UINT16);
+ Buffer = (UINT16*)Buffer + 1;
+ }
+
+ if (Size >= sizeof (UINT8)) {
+ //
+ // Read the last remaining byte if exist
+ //
+ *(volatile UINT8 *)Buffer = PciCf8Read8 (StartAddress);
+ }
+
+ return ReturnValue;
+}
+
+/**
+ Copies the data in a caller supplied buffer to a specified range of PCI
+ configuration space.
+
+ Writes the range of PCI configuration registers specified by StartAddress and
+ Size from the buffer specified by Buffer. This function only allows the PCI
+ configuration registers from a single PCI function to be written. Size is
+ returned. When possible 32-bit PCI configuration write cycles are used to
+ write from StartAdress to StartAddress + Size. Due to alignment restrictions,
+ 8-bit and 16-bit PCI configuration write cycles may be used at the beginning
+ and the end of the range.
+
+ If StartAddress > 0x0FFFFFFF, then ASSERT().
+ If the register specified by StartAddress >= 0x100, then ASSERT().
+ If ((StartAddress & 0xFFF) + Size) > 0x100, then ASSERT().
+ If Size > 0 and Buffer is NULL, then ASSERT().
+
+ @param StartAddress Starting address that encodes the PCI Bus, Device,
+ Function and Register.
+ @param Size Size in bytes of the transfer.
+ @param Buffer Pointer to a buffer containing the data to write.
+
+ @return Size
+
+**/
+UINTN
+EFIAPI
+PciCf8WriteBuffer (
+ IN UINTN StartAddress,
+ IN UINTN Size,
+ IN VOID *Buffer
+ )
+{
+ UINTN ReturnValue;
+
+ ASSERT_INVALID_PCI_ADDRESS (StartAddress, 0);
+ ASSERT (((StartAddress & 0xFFF) + Size) <= 0x100);
+
+ if (Size == 0) {
+ return 0;
+ }
+
+ ASSERT (Buffer != NULL);
+
+ //
+ // Save Size for return
+ //
+ ReturnValue = Size;
+
+ if ((StartAddress & 1) != 0) {
+ //
+ // Write a byte if StartAddress is byte aligned
+ //
+ PciCf8Write8 (StartAddress, *(UINT8*)Buffer);
+ StartAddress += sizeof (UINT8);
+ Size -= sizeof (UINT8);
+ Buffer = (UINT8*)Buffer + 1;
+ }
+
+ if (Size >= sizeof (UINT16) && (StartAddress & 2) != 0) {
+ //
+ // Write a word if StartAddress is word aligned
+ //
+ PciCf8Write16 (StartAddress, *(UINT16*)Buffer);
+ StartAddress += sizeof (UINT16);
+ Size -= sizeof (UINT16);
+ Buffer = (UINT16*)Buffer + 1;
+ }
+
+ while (Size >= sizeof (UINT32)) {
+ //
+ // Write as many double words as possible
+ //
+ PciCf8Write32 (StartAddress, *(UINT32*)Buffer);
+ StartAddress += sizeof (UINT32);
+ Size -= sizeof (UINT32);
+ Buffer = (UINT32*)Buffer + 1;
+ }
+
+ if (Size >= sizeof (UINT16)) {
+ //
+ // Write the last remaining word if exist
+ //
+ PciCf8Write16 (StartAddress, *(UINT16*)Buffer);
+ StartAddress += sizeof (UINT16);
+ Size -= sizeof (UINT16);
+ Buffer = (UINT16*)Buffer + 1;
+ }
+
+ if (Size >= sizeof (UINT8)) {
+ //
+ // Write the last remaining byte if exist
+ //
+ PciCf8Write8 (StartAddress, *(UINT8*)Buffer);
+ }
+
+ return ReturnValue;
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciExpressLib/BasePciExpressLib.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciExpressLib/BasePciExpressLib.inf
new file mode 100644
index 0000000..e179ebe
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciExpressLib/BasePciExpressLib.inf
@@ -0,0 +1,79 @@
+#/*++
+#
+# Copyright (c) 2004 - 2006, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# BasePciExpressLib.inf
+#
+# Abstract:
+#
+# Component description file for BasePciExpressLib.
+#
+#--*/
+
+[defines]
+BASE_NAME = EdkIIGlueBasePciExpressLib
+COMPONENT_TYPE = LIBRARY
+
+[sources.common]
+ PciLib.c
+
+[sources.ia32]
+
+
+[sources.x64]
+
+
+[sources.ipf]
+
+
+[sources.ebc]
+
+
+[includes.common]
+ .
+ ..\..\Include
+ ..\..\Include\Library
+ $(EDK_SOURCE)\Foundation
+ $(EDK_SOURCE)\Foundation\Framework
+ $(EDK_SOURCE)\Foundation\Efi
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+ $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include
+
+[libraries.common]
+ EdkIIGlueBaseIoLibIntrinsic
+
+[libraries.ia32]
+
+
+[libraries.x64]
+
+
+[nmake.common]
+ C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION
+ LIB_STD_FLAGS = /NOLOGO /IGNORE:4006
+
+[nmake.ia32]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32
+
+[nmake.x64]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64
+
+[nmake.ipf]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF
+
+[nmake.ebc]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciExpressLib/EdkIIGlueBasePciExpressLib.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciExpressLib/EdkIIGlueBasePciExpressLib.cif
new file mode 100644
index 0000000..73476ae
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciExpressLib/EdkIIGlueBasePciExpressLib.cif
@@ -0,0 +1,11 @@
+<component>
+ name = "EdkIIGlueBasePciExpressLib"
+ category = ModulePart
+ LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\BasePciExpressLib"
+ RefName = "EdkIIGlueBasePciExpressLib"
+[files]
+"EdkIIGlueBasePciExpressLib.sdl"
+"EdkIIGlueBasePciExpressLib.mak"
+"BasePciExpressLib.inf"
+"PciLib.c"
+<endComponent>
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciExpressLib/EdkIIGlueBasePciExpressLib.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciExpressLib/EdkIIGlueBasePciExpressLib.mak
new file mode 100644
index 0000000..abe41a4
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciExpressLib/EdkIIGlueBasePciExpressLib.mak
@@ -0,0 +1,85 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueBasePciExpressLib/EdkIIGlueBasePciExpressLib.mak 1 1/20/12 3:53a Jeffch $
+#
+# $Revision: 1 $
+#
+# $Date: 1/20/12 3:53a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueBasePciExpressLib/EdkIIGlueBasePciExpressLib.mak $
+#
+# 1 1/20/12 3:53a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 9/27/11 6:15a Wesleychen
+# Intel EDK initially releases.
+#
+# 1 9/18/09 1:52a Iminglin
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: EdkIIGlueBasePciExpressLib.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+
+
+$(EdkIIGlueBasePciExpressLib_LIB) : EdkIIGlueBasePciExpressLib
+
+EdkIIGlueBasePciExpressLib : $(BUILD_DIR)\EdkIIGlueBasePciExpressLib.mak EdkIIGlueBasePciExpressLibBin
+
+$(BUILD_DIR)\EdkIIGlueBasePciExpressLib.mak : $(EdkIIGlueBasePciExpressLib_DIR)\$(@B).cif $(EdkIIGlueBasePciExpressLib_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(EdkIIGlueBasePciExpressLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+EdkIIGlueBasePciExpressLib_LIB_LINKS=\
+!IF "$(PROCESSOR)"=="IA32" || "$(PROCESSOR)"=="x64"
+$(EdkIIGlueBaseIoLibIntrinsic_LIB)
+!ENDIF
+
+EdkIIGlueBasePciExpressLibBin : $(EdkIIGlueBasePciExpressLib_LIB_LINKS)
+!IF "$(x64_BUILD)"=="1"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGlueBasePciExpressLib.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBasePciExpressLib_LIB)"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\IA32\
+ /f $(BUILD_DIR)\EdkIIGlueBasePciExpressLib.mak all\
+ TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBasePciExpressLib_LIB)"
+!ELSE
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGlueBasePciExpressLib.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBasePciExpressLib_LIB)"
+!ENDIF
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciExpressLib/EdkIIGlueBasePciExpressLib.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciExpressLib/EdkIIGlueBasePciExpressLib.sdl
new file mode 100644
index 0000000..fe523de
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciExpressLib/EdkIIGlueBasePciExpressLib.sdl
@@ -0,0 +1,26 @@
+TOKEN
+ Name = "EdkIIGlueBasePciExpressLib_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable EdkIIGlueBasePciExpressLib support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "EdkIIGlueBasePciExpressLib_LIB"
+ Value = "$$(LIB_BUILD_DIR)\EdkIIGlueBasePciExpressLib.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "EdkIIGlueBasePciExpressLib_DIR"
+End
+
+MODULE
+ Help = "Includes EdkIIGlueBasePciExpressLib.mak to Project"
+ File = "EdkIIGlueBasePciExpressLib.mak"
+End
+
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciExpressLib/PciLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciExpressLib/PciLib.c
new file mode 100644
index 0000000..ba78a78
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciExpressLib/PciLib.c
@@ -0,0 +1,1377 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PciLib.c
+
+Abstract:
+
+ PCI Library.
+
+ Functions in this library instance make use of MMIO functions in IoLib to
+ access memory mapped PCI configuration space.
+
+ All assertions for I/O operations are handled in MMIO functions in the IoLib
+ Library.
+
+--*/
+
+#include "EdkIIGlueBase.h"
+#include "Pcd\EdkIIGluePcdPciExpressLib.h"
+
+/**
+ Assert the validity of a PCI address. A valid PCI address should contain 1's
+ only in the low 28 bits.
+
+ @param A The address to validate.
+
+**/
+//
+// Uncommenting this will improve verification of PCI address validity, but will make the debug size significantly larger.
+//
+#define ASSERT_INVALID_PCI_ADDRESS(A)
+// #define ASSERT_INVALID_PCI_ADDRESS(A) \
+// ASSERT (((A) & ~0xfffffff) == 0)
+
+
+/**
+ Gets the base address of PCI Express.
+
+ This internal functions retrieves PCI Express Base Address via a PCD entry
+ PcdPciExpressBaseAddress.
+
+ @return The base address of PCI Express.
+
+**/
+volatile VOID*
+GetPciExpressBaseAddress (
+ VOID
+ )
+{
+ return (VOID*)(UINTN) PcdGet64 (PcdPciExpressBaseAddress);
+}
+
+/**
+ Reads an 8-bit PCI configuration register.
+
+ Reads and returns the 8-bit PCI configuration register specified by Address.
+ This function must guarantee that all PCI read and write operations are
+ serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+
+ @return The read value from the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciExpressRead8 (
+ IN UINTN Address
+ )
+{
+ ASSERT_INVALID_PCI_ADDRESS (Address);
+ return MmioRead8 ((UINTN) GetPciExpressBaseAddress () + Address);
+}
+
+/**
+ Writes an 8-bit PCI configuration register.
+
+ Writes the 8-bit PCI configuration register specified by Address with the
+ value specified by Value. Value is returned. This function must guarantee
+ that all PCI read and write operations are serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param Value The value to write.
+
+ @return The value written to the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciExpressWrite8 (
+ IN UINTN Address,
+ IN UINT8 Value
+ )
+{
+ ASSERT_INVALID_PCI_ADDRESS (Address);
+ return MmioWrite8 ((UINTN) GetPciExpressBaseAddress () + Address, Value);
+}
+
+/**
+ Performs a bitwise inclusive OR of an 8-bit PCI configuration register with
+ an 8-bit value.
+
+ Reads the 8-bit PCI configuration register specified by Address, performs a
+ bitwise inclusive OR between the read result and the value specified by
+ OrData, and writes the result to the 8-bit PCI configuration register
+ specified by Address. The value written to the PCI configuration register is
+ returned. This function must guarantee that all PCI read and write operations
+ are serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param OrData The value to OR with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciExpressOr8 (
+ IN UINTN Address,
+ IN UINT8 OrData
+ )
+{
+ ASSERT_INVALID_PCI_ADDRESS (Address);
+ return MmioOr8 ((UINTN) GetPciExpressBaseAddress () + Address, OrData);
+}
+
+/**
+ Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit
+ value.
+
+ Reads the 8-bit PCI configuration register specified by Address, performs a
+ bitwise AND between the read result and the value specified by AndData, and
+ writes the result to the 8-bit PCI configuration register specified by
+ Address. The value written to the PCI configuration register is returned.
+ This function must guarantee that all PCI read and write operations are
+ serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param AndData The value to AND with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciExpressAnd8 (
+ IN UINTN Address,
+ IN UINT8 AndData
+ )
+{
+ ASSERT_INVALID_PCI_ADDRESS (Address);
+ return MmioAnd8 ((UINTN) GetPciExpressBaseAddress () + Address, AndData);
+}
+
+/**
+ Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit
+ value, followed a bitwise inclusive OR with another 8-bit value.
+
+ Reads the 8-bit PCI configuration register specified by Address, performs a
+ bitwise AND between the read result and the value specified by AndData,
+ performs a bitwise inclusive OR between the result of the AND operation and
+ the value specified by OrData, and writes the result to the 8-bit PCI
+ configuration register specified by Address. The value written to the PCI
+ configuration register is returned. This function must guarantee that all PCI
+ read and write operations are serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param AndData The value to AND with the PCI configuration register.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciExpressAndThenOr8 (
+ IN UINTN Address,
+ IN UINT8 AndData,
+ IN UINT8 OrData
+ )
+{
+ ASSERT_INVALID_PCI_ADDRESS (Address);
+ return MmioAndThenOr8 (
+ (UINTN) GetPciExpressBaseAddress () + Address,
+ AndData,
+ OrData
+ );
+}
+
+/**
+ Reads a bit field of a PCI configuration register.
+
+ Reads the bit field in an 8-bit PCI configuration register. The bit field is
+ specified by the StartBit and the EndBit. The value of the bit field is
+ returned.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If StartBit is greater than 7, then ASSERT().
+ If EndBit is greater than 7, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to read.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..7.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..7.
+
+ @return The value of the bit field read from the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciExpressBitFieldRead8 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit
+ )
+{
+ ASSERT_INVALID_PCI_ADDRESS (Address);
+ return MmioBitFieldRead8 (
+ (UINTN) GetPciExpressBaseAddress () + Address,
+ StartBit,
+ EndBit
+ );
+}
+
+/**
+ Writes a bit field to a PCI configuration register.
+
+ Writes Value to the bit field of the PCI configuration register. The bit
+ field is specified by the StartBit and the EndBit. All other bits in the
+ destination PCI configuration register are preserved. The new value of the
+ 8-bit register is returned.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If StartBit is greater than 7, then ASSERT().
+ If EndBit is greater than 7, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..7.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..7.
+ @param Value New value of the bit field.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciExpressBitFieldWrite8 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT8 Value
+ )
+{
+ ASSERT_INVALID_PCI_ADDRESS (Address);
+ return MmioBitFieldWrite8 (
+ (UINTN) GetPciExpressBaseAddress () + Address,
+ StartBit,
+ EndBit,
+ Value
+ );
+}
+
+/**
+ Reads a bit field in an 8-bit PCI configuration, performs a bitwise OR, and
+ writes the result back to the bit field in the 8-bit port.
+
+ Reads the 8-bit PCI configuration register specified by Address, performs a
+ bitwise inclusive OR between the read result and the value specified by
+ OrData, and writes the result to the 8-bit PCI configuration register
+ specified by Address. The value written to the PCI configuration register is
+ returned. This function must guarantee that all PCI read and write operations
+ are serialized. Extra left bits in OrData are stripped.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If StartBit is greater than 7, then ASSERT().
+ If EndBit is greater than 7, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..7.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..7.
+ @param OrData The value to OR with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciExpressBitFieldOr8 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT8 OrData
+ )
+{
+ ASSERT_INVALID_PCI_ADDRESS (Address);
+ return MmioBitFieldOr8 (
+ (UINTN) GetPciExpressBaseAddress () + Address,
+ StartBit,
+ EndBit,
+ OrData
+ );
+}
+
+/**
+ Reads a bit field in an 8-bit PCI configuration register, performs a bitwise
+ AND, and writes the result back to the bit field in the 8-bit register.
+
+ Reads the 8-bit PCI configuration register specified by Address, performs a
+ bitwise AND between the read result and the value specified by AndData, and
+ writes the result to the 8-bit PCI configuration register specified by
+ Address. The value written to the PCI configuration register is returned.
+ This function must guarantee that all PCI read and write operations are
+ serialized. Extra left bits in AndData are stripped.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If StartBit is greater than 7, then ASSERT().
+ If EndBit is greater than 7, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..7.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..7.
+ @param AndData The value to AND with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciExpressBitFieldAnd8 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT8 AndData
+ )
+{
+ ASSERT_INVALID_PCI_ADDRESS (Address);
+ return MmioBitFieldAnd8 (
+ (UINTN) GetPciExpressBaseAddress () + Address,
+ StartBit,
+ EndBit,
+ AndData
+ );
+}
+
+/**
+ Reads a bit field in an 8-bit port, performs a bitwise AND followed by a
+ bitwise inclusive OR, and writes the result back to the bit field in the
+ 8-bit port.
+
+ Reads the 8-bit PCI configuration register specified by Address, performs a
+ bitwise AND followed by a bitwise inclusive OR between the read result and
+ the value specified by AndData, and writes the result to the 8-bit PCI
+ configuration register specified by Address. The value written to the PCI
+ configuration register is returned. This function must guarantee that all PCI
+ read and write operations are serialized. Extra left bits in both AndData and
+ OrData are stripped.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If StartBit is greater than 7, then ASSERT().
+ If EndBit is greater than 7, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..7.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..7.
+ @param AndData The value to AND with the PCI configuration register.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciExpressBitFieldAndThenOr8 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT8 AndData,
+ IN UINT8 OrData
+ )
+{
+ ASSERT_INVALID_PCI_ADDRESS (Address);
+ return MmioBitFieldAndThenOr8 (
+ (UINTN) GetPciExpressBaseAddress () + Address,
+ StartBit,
+ EndBit,
+ AndData,
+ OrData
+ );
+}
+
+/**
+ Reads a 16-bit PCI configuration register.
+
+ Reads and returns the 16-bit PCI configuration register specified by Address.
+ This function must guarantee that all PCI read and write operations are
+ serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 16-bit boundary, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+
+ @return The read value from the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciExpressRead16 (
+ IN UINTN Address
+ )
+{
+ ASSERT_INVALID_PCI_ADDRESS (Address);
+ return MmioRead16 ((UINTN) GetPciExpressBaseAddress () + Address);
+}
+
+/**
+ Writes a 16-bit PCI configuration register.
+
+ Writes the 16-bit PCI configuration register specified by Address with the
+ value specified by Value. Value is returned. This function must guarantee
+ that all PCI read and write operations are serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 16-bit boundary, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param Value The value to write.
+
+ @return The value written to the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciExpressWrite16 (
+ IN UINTN Address,
+ IN UINT16 Value
+ )
+{
+ ASSERT_INVALID_PCI_ADDRESS (Address);
+ return MmioWrite16 ((UINTN) GetPciExpressBaseAddress () + Address, Value);
+}
+
+/**
+ Performs a bitwise inclusive OR of a 16-bit PCI configuration register with
+ a 16-bit value.
+
+ Reads the 16-bit PCI configuration register specified by Address, performs a
+ bitwise inclusive OR between the read result and the value specified by
+ OrData, and writes the result to the 16-bit PCI configuration register
+ specified by Address. The value written to the PCI configuration register is
+ returned. This function must guarantee that all PCI read and write operations
+ are serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 16-bit boundary, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param OrData The value to OR with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciExpressOr16 (
+ IN UINTN Address,
+ IN UINT16 OrData
+ )
+{
+ ASSERT_INVALID_PCI_ADDRESS (Address);
+ return MmioOr16 ((UINTN) GetPciExpressBaseAddress () + Address, OrData);
+}
+
+/**
+ Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit
+ value.
+
+ Reads the 16-bit PCI configuration register specified by Address, performs a
+ bitwise AND between the read result and the value specified by AndData, and
+ writes the result to the 16-bit PCI configuration register specified by
+ Address. The value written to the PCI configuration register is returned.
+ This function must guarantee that all PCI read and write operations are
+ serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 16-bit boundary, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param AndData The value to AND with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciExpressAnd16 (
+ IN UINTN Address,
+ IN UINT16 AndData
+ )
+{
+ ASSERT_INVALID_PCI_ADDRESS (Address);
+ return MmioAnd16 ((UINTN) GetPciExpressBaseAddress () + Address, AndData);
+}
+
+/**
+ Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit
+ value, followed a bitwise inclusive OR with another 16-bit value.
+
+ Reads the 16-bit PCI configuration register specified by Address, performs a
+ bitwise AND between the read result and the value specified by AndData,
+ performs a bitwise inclusive OR between the result of the AND operation and
+ the value specified by OrData, and writes the result to the 16-bit PCI
+ configuration register specified by Address. The value written to the PCI
+ configuration register is returned. This function must guarantee that all PCI
+ read and write operations are serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 16-bit boundary, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param AndData The value to AND with the PCI configuration register.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciExpressAndThenOr16 (
+ IN UINTN Address,
+ IN UINT16 AndData,
+ IN UINT16 OrData
+ )
+{
+ ASSERT_INVALID_PCI_ADDRESS (Address);
+ return MmioAndThenOr16 (
+ (UINTN) GetPciExpressBaseAddress () + Address,
+ AndData,
+ OrData
+ );
+}
+
+/**
+ Reads a bit field of a PCI configuration register.
+
+ Reads the bit field in a 16-bit PCI configuration register. The bit field is
+ specified by the StartBit and the EndBit. The value of the bit field is
+ returned.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 16-bit boundary, then ASSERT().
+ If StartBit is greater than 15, then ASSERT().
+ If EndBit is greater than 15, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to read.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..15.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..15.
+
+ @return The value of the bit field read from the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciExpressBitFieldRead16 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit
+ )
+{
+ ASSERT_INVALID_PCI_ADDRESS (Address);
+ return MmioBitFieldRead16 (
+ (UINTN) GetPciExpressBaseAddress () + Address,
+ StartBit,
+ EndBit
+ );
+}
+
+/**
+ Writes a bit field to a PCI configuration register.
+
+ Writes Value to the bit field of the PCI configuration register. The bit
+ field is specified by the StartBit and the EndBit. All other bits in the
+ destination PCI configuration register are preserved. The new value of the
+ 16-bit register is returned.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 16-bit boundary, then ASSERT().
+ If StartBit is greater than 15, then ASSERT().
+ If EndBit is greater than 15, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..15.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..15.
+ @param Value New value of the bit field.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciExpressBitFieldWrite16 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT16 Value
+ )
+{
+ ASSERT_INVALID_PCI_ADDRESS (Address);
+ return MmioBitFieldWrite16 (
+ (UINTN) GetPciExpressBaseAddress () + Address,
+ StartBit,
+ EndBit,
+ Value
+ );
+}
+
+/**
+ Reads a bit field in a 16-bit PCI configuration, performs a bitwise OR, and
+ writes the result back to the bit field in the 16-bit port.
+
+ Reads the 16-bit PCI configuration register specified by Address, performs a
+ bitwise inclusive OR between the read result and the value specified by
+ OrData, and writes the result to the 16-bit PCI configuration register
+ specified by Address. The value written to the PCI configuration register is
+ returned. This function must guarantee that all PCI read and write operations
+ are serialized. Extra left bits in OrData are stripped.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 16-bit boundary, then ASSERT().
+ If StartBit is greater than 15, then ASSERT().
+ If EndBit is greater than 15, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..15.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..15.
+ @param OrData The value to OR with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciExpressBitFieldOr16 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT16 OrData
+ )
+{
+ ASSERT_INVALID_PCI_ADDRESS (Address);
+ return MmioBitFieldOr16 (
+ (UINTN) GetPciExpressBaseAddress () + Address,
+ StartBit,
+ EndBit,
+ OrData
+ );
+}
+
+/**
+ Reads a bit field in a 16-bit PCI configuration register, performs a bitwise
+ AND, and writes the result back to the bit field in the 16-bit register.
+
+ Reads the 16-bit PCI configuration register specified by Address, performs a
+ bitwise AND between the read result and the value specified by AndData, and
+ writes the result to the 16-bit PCI configuration register specified by
+ Address. The value written to the PCI configuration register is returned.
+ This function must guarantee that all PCI read and write operations are
+ serialized. Extra left bits in AndData are stripped.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 16-bit boundary, then ASSERT().
+ If StartBit is greater than 15, then ASSERT().
+ If EndBit is greater than 15, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..15.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..15.
+ @param AndData The value to AND with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciExpressBitFieldAnd16 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT16 AndData
+ )
+{
+ ASSERT_INVALID_PCI_ADDRESS (Address);
+ return MmioBitFieldAnd16 (
+ (UINTN) GetPciExpressBaseAddress () + Address,
+ StartBit,
+ EndBit,
+ AndData
+ );
+}
+
+/**
+ Reads a bit field in a 16-bit port, performs a bitwise AND followed by a
+ bitwise inclusive OR, and writes the result back to the bit field in the
+ 16-bit port.
+
+ Reads the 16-bit PCI configuration register specified by Address, performs a
+ bitwise AND followed by a bitwise inclusive OR between the read result and
+ the value specified by AndData, and writes the result to the 16-bit PCI
+ configuration register specified by Address. The value written to the PCI
+ configuration register is returned. This function must guarantee that all PCI
+ read and write operations are serialized. Extra left bits in both AndData and
+ OrData are stripped.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 16-bit boundary, then ASSERT().
+ If StartBit is greater than 15, then ASSERT().
+ If EndBit is greater than 15, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..15.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..15.
+ @param AndData The value to AND with the PCI configuration register.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciExpressBitFieldAndThenOr16 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT16 AndData,
+ IN UINT16 OrData
+ )
+{
+ ASSERT_INVALID_PCI_ADDRESS (Address);
+ return MmioBitFieldAndThenOr16 (
+ (UINTN) GetPciExpressBaseAddress () + Address,
+ StartBit,
+ EndBit,
+ AndData,
+ OrData
+ );
+}
+
+/**
+ Reads a 32-bit PCI configuration register.
+
+ Reads and returns the 32-bit PCI configuration register specified by Address.
+ This function must guarantee that all PCI read and write operations are
+ serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 32-bit boundary, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+
+ @return The read value from the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciExpressRead32 (
+ IN UINTN Address
+ )
+{
+ ASSERT_INVALID_PCI_ADDRESS (Address);
+ return MmioRead32 ((UINTN) GetPciExpressBaseAddress () + Address);
+}
+
+/**
+ Writes a 32-bit PCI configuration register.
+
+ Writes the 32-bit PCI configuration register specified by Address with the
+ value specified by Value. Value is returned. This function must guarantee
+ that all PCI read and write operations are serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 32-bit boundary, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param Value The value to write.
+
+ @return The value written to the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciExpressWrite32 (
+ IN UINTN Address,
+ IN UINT32 Value
+ )
+{
+ ASSERT_INVALID_PCI_ADDRESS (Address);
+ return MmioWrite32 ((UINTN) GetPciExpressBaseAddress () + Address, Value);
+}
+
+/**
+ Performs a bitwise inclusive OR of a 32-bit PCI configuration register with
+ a 32-bit value.
+
+ Reads the 32-bit PCI configuration register specified by Address, performs a
+ bitwise inclusive OR between the read result and the value specified by
+ OrData, and writes the result to the 32-bit PCI configuration register
+ specified by Address. The value written to the PCI configuration register is
+ returned. This function must guarantee that all PCI read and write operations
+ are serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 32-bit boundary, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param OrData The value to OR with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciExpressOr32 (
+ IN UINTN Address,
+ IN UINT32 OrData
+ )
+{
+ ASSERT_INVALID_PCI_ADDRESS (Address);
+ return MmioOr32 ((UINTN) GetPciExpressBaseAddress () + Address, OrData);
+}
+
+/**
+ Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit
+ value.
+
+ Reads the 32-bit PCI configuration register specified by Address, performs a
+ bitwise AND between the read result and the value specified by AndData, and
+ writes the result to the 32-bit PCI configuration register specified by
+ Address. The value written to the PCI configuration register is returned.
+ This function must guarantee that all PCI read and write operations are
+ serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 32-bit boundary, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param AndData The value to AND with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciExpressAnd32 (
+ IN UINTN Address,
+ IN UINT32 AndData
+ )
+{
+ ASSERT_INVALID_PCI_ADDRESS (Address);
+ return MmioAnd32 ((UINTN) GetPciExpressBaseAddress () + Address, AndData);
+}
+
+/**
+ Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit
+ value, followed a bitwise inclusive OR with another 32-bit value.
+
+ Reads the 32-bit PCI configuration register specified by Address, performs a
+ bitwise AND between the read result and the value specified by AndData,
+ performs a bitwise inclusive OR between the result of the AND operation and
+ the value specified by OrData, and writes the result to the 32-bit PCI
+ configuration register specified by Address. The value written to the PCI
+ configuration register is returned. This function must guarantee that all PCI
+ read and write operations are serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 32-bit boundary, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param AndData The value to AND with the PCI configuration register.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciExpressAndThenOr32 (
+ IN UINTN Address,
+ IN UINT32 AndData,
+ IN UINT32 OrData
+ )
+{
+ ASSERT_INVALID_PCI_ADDRESS (Address);
+ return MmioAndThenOr32 (
+ (UINTN) GetPciExpressBaseAddress () + Address,
+ AndData,
+ OrData
+ );
+}
+
+/**
+ Reads a bit field of a PCI configuration register.
+
+ Reads the bit field in a 32-bit PCI configuration register. The bit field is
+ specified by the StartBit and the EndBit. The value of the bit field is
+ returned.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 32-bit boundary, then ASSERT().
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to read.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+
+ @return The value of the bit field read from the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciExpressBitFieldRead32 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit
+ )
+{
+ ASSERT_INVALID_PCI_ADDRESS (Address);
+ return MmioBitFieldRead32 (
+ (UINTN) GetPciExpressBaseAddress () + Address,
+ StartBit,
+ EndBit
+ );
+}
+
+/**
+ Writes a bit field to a PCI configuration register.
+
+ Writes Value to the bit field of the PCI configuration register. The bit
+ field is specified by the StartBit and the EndBit. All other bits in the
+ destination PCI configuration register are preserved. The new value of the
+ 32-bit register is returned.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 32-bit boundary, then ASSERT().
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+ @param Value New value of the bit field.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciExpressBitFieldWrite32 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT32 Value
+ )
+{
+ ASSERT_INVALID_PCI_ADDRESS (Address);
+ return MmioBitFieldWrite32 (
+ (UINTN) GetPciExpressBaseAddress () + Address,
+ StartBit,
+ EndBit,
+ Value
+ );
+}
+
+/**
+ Reads a bit field in a 32-bit PCI configuration, performs a bitwise OR, and
+ writes the result back to the bit field in the 32-bit port.
+
+ Reads the 32-bit PCI configuration register specified by Address, performs a
+ bitwise inclusive OR between the read result and the value specified by
+ OrData, and writes the result to the 32-bit PCI configuration register
+ specified by Address. The value written to the PCI configuration register is
+ returned. This function must guarantee that all PCI read and write operations
+ are serialized. Extra left bits in OrData are stripped.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 32-bit boundary, then ASSERT().
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+ @param OrData The value to OR with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciExpressBitFieldOr32 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT32 OrData
+ )
+{
+ ASSERT_INVALID_PCI_ADDRESS (Address);
+ return MmioBitFieldOr32 (
+ (UINTN) GetPciExpressBaseAddress () + Address,
+ StartBit,
+ EndBit,
+ OrData
+ );
+}
+
+/**
+ Reads a bit field in a 32-bit PCI configuration register, performs a bitwise
+ AND, and writes the result back to the bit field in the 32-bit register.
+
+ Reads the 32-bit PCI configuration register specified by Address, performs a
+ bitwise AND between the read result and the value specified by AndData, and
+ writes the result to the 32-bit PCI configuration register specified by
+ Address. The value written to the PCI configuration register is returned.
+ This function must guarantee that all PCI read and write operations are
+ serialized. Extra left bits in AndData are stripped.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 32-bit boundary, then ASSERT().
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+ @param AndData The value to AND with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciExpressBitFieldAnd32 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT32 AndData
+ )
+{
+ ASSERT_INVALID_PCI_ADDRESS (Address);
+ return MmioBitFieldAnd32 (
+ (UINTN) GetPciExpressBaseAddress () + Address,
+ StartBit,
+ EndBit,
+ AndData
+ );
+}
+
+/**
+ Reads a bit field in a 32-bit port, performs a bitwise AND followed by a
+ bitwise inclusive OR, and writes the result back to the bit field in the
+ 32-bit port.
+
+ Reads the 32-bit PCI configuration register specified by Address, performs a
+ bitwise AND followed by a bitwise inclusive OR between the read result and
+ the value specified by AndData, and writes the result to the 32-bit PCI
+ configuration register specified by Address. The value written to the PCI
+ configuration register is returned. This function must guarantee that all PCI
+ read and write operations are serialized. Extra left bits in both AndData and
+ OrData are stripped.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If Address is not aligned on a 32-bit boundary, then ASSERT().
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+ @param AndData The value to AND with the PCI configuration register.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciExpressBitFieldAndThenOr32 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT32 AndData,
+ IN UINT32 OrData
+ )
+{
+ ASSERT_INVALID_PCI_ADDRESS (Address);
+ return MmioBitFieldAndThenOr32 (
+ (UINTN) GetPciExpressBaseAddress () + Address,
+ StartBit,
+ EndBit,
+ AndData,
+ OrData
+ );
+}
+
+/**
+ Reads a range of PCI configuration registers into a caller supplied buffer.
+
+ Reads the range of PCI configuration registers specified by StartAddress and
+ Size into the buffer specified by Buffer. This function only allows the PCI
+ configuration registers from a single PCI function to be read. Size is
+ returned. When possible 32-bit PCI configuration read cycles are used to read
+ from StartAdress to StartAddress + Size. Due to alignment restrictions, 8-bit
+ and 16-bit PCI configuration read cycles may be used at the beginning and the
+ end of the range.
+
+ If StartAddress > 0x0FFFFFFF, then ASSERT().
+ If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT().
+ If Size > 0 and Buffer is NULL, then ASSERT().
+
+ @param StartAddress Starting address that encodes the PCI Bus, Device,
+ Function and Register.
+ @param Size Size in bytes of the transfer.
+ @param Buffer Pointer to a buffer receiving the data read.
+
+ @return Size
+
+**/
+UINTN
+EFIAPI
+PciExpressReadBuffer (
+ IN UINTN StartAddress,
+ IN UINTN Size,
+ OUT VOID *Buffer
+ )
+{
+ UINTN ReturnValue;
+
+ ASSERT_INVALID_PCI_ADDRESS (StartAddress);
+ ASSERT (((StartAddress & 0xFFF) + Size) <= 0x1000);
+
+ if (Size == 0) {
+ return Size;
+ }
+
+ ASSERT (Buffer != NULL);
+
+ //
+ // Save Size for return
+ //
+ ReturnValue = Size;
+
+ if ((StartAddress & 1) != 0) {
+ //
+ // Read a byte if StartAddress is byte aligned
+ //
+ *(volatile UINT8 *)Buffer = PciExpressRead8 (StartAddress);
+ StartAddress += sizeof (UINT8);
+ Size -= sizeof (UINT8);
+ Buffer = (UINT8*)Buffer + 1;
+ }
+
+ if (Size >= sizeof (UINT16) && (StartAddress & 2) != 0) {
+ //
+ // Read a word if StartAddress is word aligned
+ //
+ *(volatile UINT16 *)Buffer = PciExpressRead16 (StartAddress);
+ StartAddress += sizeof (UINT16);
+ Size -= sizeof (UINT16);
+ Buffer = (UINT16*)Buffer + 1;
+ }
+
+ while (Size >= sizeof (UINT32)) {
+ //
+ // Read as many double words as possible
+ //
+ *(volatile UINT32 *)Buffer = PciExpressRead32 (StartAddress);
+ StartAddress += sizeof (UINT32);
+ Size -= sizeof (UINT32);
+ Buffer = (UINT32*)Buffer + 1;
+ }
+
+ if (Size >= sizeof (UINT16)) {
+ //
+ // Read the last remaining word if exist
+ //
+ *(volatile UINT16 *)Buffer = PciExpressRead16 (StartAddress);
+ StartAddress += sizeof (UINT16);
+ Size -= sizeof (UINT16);
+ Buffer = (UINT16*)Buffer + 1;
+ }
+
+ if (Size >= sizeof (UINT8)) {
+ //
+ // Read the last remaining byte if exist
+ //
+ *(volatile UINT8 *)Buffer = PciExpressRead8 (StartAddress);
+ }
+
+ return ReturnValue;
+}
+
+/**
+ Copies the data in a caller supplied buffer to a specified range of PCI
+ configuration space.
+
+ Writes the range of PCI configuration registers specified by StartAddress and
+ Size from the buffer specified by Buffer. This function only allows the PCI
+ configuration registers from a single PCI function to be written. Size is
+ returned. When possible 32-bit PCI configuration write cycles are used to
+ write from StartAdress to StartAddress + Size. Due to alignment restrictions,
+ 8-bit and 16-bit PCI configuration write cycles may be used at the beginning
+ and the end of the range.
+
+ If StartAddress > 0x0FFFFFFF, then ASSERT().
+ If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT().
+ If Size > 0 and Buffer is NULL, then ASSERT().
+
+ @param StartAddress Starting address that encodes the PCI Bus, Device,
+ Function and Register.
+ @param Size Size in bytes of the transfer.
+ @param Buffer Pointer to a buffer containing the data to write.
+
+ @return Size
+
+**/
+UINTN
+EFIAPI
+PciExpressWriteBuffer (
+ IN UINTN StartAddress,
+ IN UINTN Size,
+ IN VOID *Buffer
+ )
+{
+ UINTN ReturnValue;
+
+ ASSERT_INVALID_PCI_ADDRESS (StartAddress);
+ ASSERT (((StartAddress & 0xFFF) + Size) <= 0x1000);
+
+ if (Size == 0) {
+ return 0;
+ }
+
+ ASSERT (Buffer != NULL);
+
+ //
+ // Save Size for return
+ //
+ ReturnValue = Size;
+
+ if ((StartAddress & 1) != 0) {
+ //
+ // Write a byte if StartAddress is byte aligned
+ //
+ PciExpressWrite8 (StartAddress, *(UINT8*)Buffer);
+ StartAddress += sizeof (UINT8);
+ Size -= sizeof (UINT8);
+ Buffer = (UINT8*)Buffer + 1;
+ }
+
+ if (Size >= sizeof (UINT16) && (StartAddress & 2) != 0) {
+ //
+ // Write a word if StartAddress is word aligned
+ //
+ PciExpressWrite16 (StartAddress, *(UINT16*)Buffer);
+ StartAddress += sizeof (UINT16);
+ Size -= sizeof (UINT16);
+ Buffer = (UINT16*)Buffer + 1;
+ }
+
+ while (Size >= sizeof (UINT32)) {
+ //
+ // Write as many double words as possible
+ //
+ PciExpressWrite32 (StartAddress, *(UINT32*)Buffer);
+ StartAddress += sizeof (UINT32);
+ Size -= sizeof (UINT32);
+ Buffer = (UINT32*)Buffer + 1;
+ }
+
+ if (Size >= sizeof (UINT16)) {
+ //
+ // Write the last remaining word if exist
+ //
+ PciExpressWrite16 (StartAddress, *(UINT16*)Buffer);
+ StartAddress += sizeof (UINT16);
+ Size -= sizeof (UINT16);
+ Buffer = (UINT16*)Buffer + 1;
+ }
+
+ if (Size >= sizeof (UINT8)) {
+ //
+ // Write the last remaining byte if exist
+ //
+ PciExpressWrite8 (StartAddress, *(UINT8*)Buffer);
+ }
+
+ return ReturnValue;
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibCf8/BasePciLibCf8.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibCf8/BasePciLibCf8.inf
new file mode 100644
index 0000000..a543f41
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibCf8/BasePciLibCf8.inf
@@ -0,0 +1,79 @@
+#/*++
+#
+# Copyright (c) 2004 - 2006, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# BasePciLibCf8.inf
+#
+# Abstract:
+#
+# Component description file for BasePciLibCf8.
+#
+#--*/
+
+[defines]
+BASE_NAME = EdkIIGlueBasePciLibCf8
+COMPONENT_TYPE = LIBRARY
+
+[sources.common]
+ PciLib.c
+
+[sources.ia32]
+
+
+[sources.x64]
+
+
+[sources.ipf]
+
+
+[sources.ebc]
+
+
+[includes.common]
+ .
+ ..\..\Include
+ ..\..\include\Library
+ $(EDK_SOURCE)\Foundation
+ $(EDK_SOURCE)\Foundation\Framework
+ $(EDK_SOURCE)\Foundation\Efi
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+ $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include
+
+[libraries.common]
+ EdkIIGlueBasePciCf8Lib
+
+[libraries.ia32]
+
+
+[libraries.x64]
+
+
+[nmake.common]
+ C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION
+ LIB_STD_FLAGS = /NOLOGO /IGNORE:4006
+
+[nmake.ia32]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32
+
+[nmake.x64]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64
+
+[nmake.ipf]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF
+
+[nmake.ebc]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibCf8/EdkIIGlueBasePciLibCf8.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibCf8/EdkIIGlueBasePciLibCf8.cif
new file mode 100644
index 0000000..db1ff75
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibCf8/EdkIIGlueBasePciLibCf8.cif
@@ -0,0 +1,11 @@
+<component>
+ name = "EdkIIGlueBasePciLibCf8"
+ category = ModulePart
+ LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\BasePciLibCf8"
+ RefName = "EdkIIGlueBasePciLibCf8"
+[files]
+"EdkIIGlueBasePciLibCf8.sdl"
+"EdkIIGlueBasePciLibCf8.mak"
+"BasePciLibCf8.inf"
+"PciLib.c"
+<endComponent>
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibCf8/EdkIIGlueBasePciLibCf8.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibCf8/EdkIIGlueBasePciLibCf8.mak
new file mode 100644
index 0000000..8aa5b37
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibCf8/EdkIIGlueBasePciLibCf8.mak
@@ -0,0 +1,80 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueBasePciLibCf8/EdkIIGlueBasePciLibCf8.mak 1 1/20/12 3:53a Jeffch $
+#
+# $Revision: 1 $
+#
+# $Date: 1/20/12 3:53a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueBasePciLibCf8/EdkIIGlueBasePciLibCf8.mak $
+#
+# 1 1/20/12 3:53a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 9/27/11 6:15a Wesleychen
+# Intel EDK initially releases.
+#
+# 1 9/18/09 1:52a Iminglin
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: EdkIIGlueBasePciLibCf8.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+
+
+$(EdkIIGlueBasePciLibCf8_LIB) : EdkIIGlueBasePciLibCf8
+
+EdkIIGlueBasePciLibCf8 : $(BUILD_DIR)\EdkIIGlueBasePciLibCf8.mak EdkIIGlueBasePciLibCf8Bin
+
+$(BUILD_DIR)\EdkIIGlueBasePciLibCf8.mak : $(EdkIIGlueBasePciLibCf8_DIR)\$(@B).cif $(EdkIIGlueBasePciLibCf8_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(EdkIIGlueBasePciLibCf8_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+EdkIIGlueBasePciLibCf8Bin : $(EdkIIGlueBasePciCf8Lib_LIB)
+!IF "$(x64_BUILD)"=="1"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGlueBasePciLibCf8.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBasePciLibCf8_LIB)"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\IA32\
+ /f $(BUILD_DIR)\EdkIIGlueBasePciLibCf8.mak all\
+ TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBasePciLibCf8_LIB)"
+!ELSE
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGlueBasePciLibCf8.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBasePciLibCf8_LIB)"
+!ENDIF
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibCf8/EdkIIGlueBasePciLibCf8.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibCf8/EdkIIGlueBasePciLibCf8.sdl
new file mode 100644
index 0000000..8f85282
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibCf8/EdkIIGlueBasePciLibCf8.sdl
@@ -0,0 +1,26 @@
+TOKEN
+ Name = "EdkIIGlueBasePciLibCf8_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable EdkIIGlueBasePciLibCf8 support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "EdkIIGlueBasePciLibCf8_LIB"
+ Value = "$$(LIB_BUILD_DIR)\EdkIIGlueBasePciLibCf8.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "EdkIIGlueBasePciLibCf8_DIR"
+End
+
+MODULE
+ Help = "Includes EdkIIGlueBasePciLibCf8.mak to Project"
+ File = "EdkIIGlueBasePciLibCf8.mak"
+End
+
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibCf8/PciLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibCf8/PciLib.c
new file mode 100644
index 0000000..7f85431
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibCf8/PciLib.c
@@ -0,0 +1,1076 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ PciLib.c
+
+Abstract:
+
+ PCI Library using Port CF8/CFC access.
+
+--*/
+
+#include "EdkIIGlueBase.h"
+
+/**
+ Reads an 8-bit PCI configuration register.
+
+ Reads and returns the 8-bit PCI configuration register specified by Address.
+ This function must guarantee that all PCI read and write operations are
+ serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+
+ @return The read value from the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciRead8 (
+ IN UINTN Address
+ )
+{
+ return PciCf8Read8 (Address);
+}
+
+/**
+ Writes an 8-bit PCI configuration register.
+
+ Writes the 8-bit PCI configuration register specified by Address with the
+ value specified by Value. Value is returned. This function must guarantee
+ that all PCI read and write operations are serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param Value The value to write.
+
+ @return The value written to the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciWrite8 (
+ IN UINTN Address,
+ IN UINT8 Data
+ )
+{
+ return PciCf8Write8 (Address, Data);
+}
+
+/**
+ Performs a bitwise inclusive OR of an 8-bit PCI configuration register with
+ an 8-bit value.
+
+ Reads the 8-bit PCI configuration register specified by Address, performs a
+ bitwise inclusive OR between the read result and the value specified by
+ OrData, and writes the result to the 8-bit PCI configuration register
+ specified by Address. The value written to the PCI configuration register is
+ returned. This function must guarantee that all PCI read and write operations
+ are serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param OrData The value to OR with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciOr8 (
+ IN UINTN Address,
+ IN UINT8 OrData
+ )
+{
+ return PciCf8Or8 (Address, OrData);
+}
+
+/**
+ Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit
+ value.
+
+ Reads the 8-bit PCI configuration register specified by Address, performs a
+ bitwise AND between the read result and the value specified by AndData, and
+ writes the result to the 8-bit PCI configuration register specified by
+ Address. The value written to the PCI configuration register is returned.
+ This function must guarantee that all PCI read and write operations are
+ serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param AndData The value to AND with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciAnd8 (
+ IN UINTN Address,
+ IN UINT8 AndData
+ )
+{
+ return PciCf8And8 (Address, AndData);
+}
+
+/**
+ Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit
+ value, followed a bitwise inclusive OR with another 8-bit value.
+
+ Reads the 8-bit PCI configuration register specified by Address, performs a
+ bitwise AND between the read result and the value specified by AndData,
+ performs a bitwise inclusive OR between the result of the AND operation and
+ the value specified by OrData, and writes the result to the 8-bit PCI
+ configuration register specified by Address. The value written to the PCI
+ configuration register is returned. This function must guarantee that all PCI
+ read and write operations are serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param AndData The value to AND with the PCI configuration register.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciAndThenOr8 (
+ IN UINTN Address,
+ IN UINT8 AndData,
+ IN UINT8 OrData
+ )
+{
+ return PciCf8AndThenOr8 (Address, AndData, OrData);
+}
+
+/**
+ Reads a bit field of a PCI configuration register.
+
+ Reads the bit field in an 8-bit PCI configuration register. The bit field is
+ specified by the StartBit and the EndBit. The value of the bit field is
+ returned.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If StartBit is greater than 7, then ASSERT().
+ If EndBit is greater than 7, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to read.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..7.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..7.
+
+ @return The value of the bit field read from the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciBitFieldRead8 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit
+ )
+{
+ return PciCf8BitFieldRead8 (Address, StartBit, EndBit);
+}
+
+/**
+ Writes a bit field to a PCI configuration register.
+
+ Writes Value to the bit field of the PCI configuration register. The bit
+ field is specified by the StartBit and the EndBit. All other bits in the
+ destination PCI configuration register are preserved. The new value of the
+ 8-bit register is returned.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If StartBit is greater than 7, then ASSERT().
+ If EndBit is greater than 7, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..7.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..7.
+ @param Value New value of the bit field.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciBitFieldWrite8 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT8 Value
+ )
+{
+ return PciCf8BitFieldWrite8 (Address, StartBit, EndBit, Value);
+}
+
+/**
+ Reads a bit field in an 8-bit PCI configuration, performs a bitwise OR, and
+ writes the result back to the bit field in the 8-bit port.
+
+ Reads the 8-bit PCI configuration register specified by Address, performs a
+ bitwise inclusive OR between the read result and the value specified by
+ OrData, and writes the result to the 8-bit PCI configuration register
+ specified by Address. The value written to the PCI configuration register is
+ returned. This function must guarantee that all PCI read and write operations
+ are serialized. Extra left bits in OrData are stripped.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If StartBit is greater than 7, then ASSERT().
+ If EndBit is greater than 7, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..7.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..7.
+ @param OrData The value to OR with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciBitFieldOr8 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT8 OrData
+ )
+{
+ return PciCf8BitFieldOr8 (Address, StartBit, EndBit, OrData);
+}
+
+/**
+ Reads a bit field in an 8-bit PCI configuration register, performs a bitwise
+ AND, and writes the result back to the bit field in the 8-bit register.
+
+ Reads the 8-bit PCI configuration register specified by Address, performs a
+ bitwise AND between the read result and the value specified by AndData, and
+ writes the result to the 8-bit PCI configuration register specified by
+ Address. The value written to the PCI configuration register is returned.
+ This function must guarantee that all PCI read and write operations are
+ serialized. Extra left bits in AndData are stripped.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If StartBit is greater than 7, then ASSERT().
+ If EndBit is greater than 7, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..7.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..7.
+ @param AndData The value to AND with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciBitFieldAnd8 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT8 AndData
+ )
+{
+ return PciCf8BitFieldAnd8 (Address, StartBit, EndBit, AndData);
+}
+
+/**
+ Reads a bit field in an 8-bit port, performs a bitwise AND followed by a
+ bitwise inclusive OR, and writes the result back to the bit field in the
+ 8-bit port.
+
+ Reads the 8-bit PCI configuration register specified by Address, performs a
+ bitwise AND followed by a bitwise inclusive OR between the read result and
+ the value specified by AndData, and writes the result to the 8-bit PCI
+ configuration register specified by Address. The value written to the PCI
+ configuration register is returned. This function must guarantee that all PCI
+ read and write operations are serialized. Extra left bits in both AndData and
+ OrData are stripped.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If StartBit is greater than 7, then ASSERT().
+ If EndBit is greater than 7, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..7.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..7.
+ @param AndData The value to AND with the PCI configuration register.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciBitFieldAndThenOr8 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT8 AndData,
+ IN UINT8 OrData
+ )
+{
+ return PciCf8BitFieldAndThenOr8 (Address, StartBit, EndBit, AndData, OrData);
+}
+
+/**
+ Reads a 16-bit PCI configuration register.
+
+ Reads and returns the 16-bit PCI configuration register specified by Address.
+ This function must guarantee that all PCI read and write operations are
+ serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+
+ @return The read value from the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciRead16 (
+ IN UINTN Address
+ )
+{
+ return PciCf8Read16 (Address);
+}
+
+/**
+ Writes a 16-bit PCI configuration register.
+
+ Writes the 16-bit PCI configuration register specified by Address with the
+ value specified by Value. Value is returned. This function must guarantee
+ that all PCI read and write operations are serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param Value The value to write.
+
+ @return The value written to the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciWrite16 (
+ IN UINTN Address,
+ IN UINT16 Data
+ )
+{
+ return PciCf8Write16 (Address, Data);
+}
+
+/**
+ Performs a bitwise inclusive OR of a 16-bit PCI configuration register with
+ a 16-bit value.
+
+ Reads the 16-bit PCI configuration register specified by Address, performs a
+ bitwise inclusive OR between the read result and the value specified by
+ OrData, and writes the result to the 16-bit PCI configuration register
+ specified by Address. The value written to the PCI configuration register is
+ returned. This function must guarantee that all PCI read and write operations
+ are serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param OrData The value to OR with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciOr16 (
+ IN UINTN Address,
+ IN UINT16 OrData
+ )
+{
+ return PciCf8Or16 (Address, OrData);
+}
+
+/**
+ Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit
+ value.
+
+ Reads the 16-bit PCI configuration register specified by Address, performs a
+ bitwise AND between the read result and the value specified by AndData, and
+ writes the result to the 16-bit PCI configuration register specified by
+ Address. The value written to the PCI configuration register is returned.
+ This function must guarantee that all PCI read and write operations are
+ serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param AndData The value to AND with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciAnd16 (
+ IN UINTN Address,
+ IN UINT16 AndData
+ )
+{
+ return PciCf8And16 (Address, AndData);
+}
+
+/**
+ Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit
+ value, followed a bitwise inclusive OR with another 16-bit value.
+
+ Reads the 16-bit PCI configuration register specified by Address, performs a
+ bitwise AND between the read result and the value specified by AndData,
+ performs a bitwise inclusive OR between the result of the AND operation and
+ the value specified by OrData, and writes the result to the 16-bit PCI
+ configuration register specified by Address. The value written to the PCI
+ configuration register is returned. This function must guarantee that all PCI
+ read and write operations are serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param AndData The value to AND with the PCI configuration register.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciAndThenOr16 (
+ IN UINTN Address,
+ IN UINT16 AndData,
+ IN UINT16 OrData
+ )
+{
+ return PciCf8AndThenOr16 (Address, AndData, OrData);
+}
+
+/**
+ Reads a bit field of a PCI configuration register.
+
+ Reads the bit field in a 16-bit PCI configuration register. The bit field is
+ specified by the StartBit and the EndBit. The value of the bit field is
+ returned.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If StartBit is greater than 15, then ASSERT().
+ If EndBit is greater than 15, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to read.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..15.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..15.
+
+ @return The value of the bit field read from the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciBitFieldRead16 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit
+ )
+{
+ return PciCf8BitFieldRead16 (Address, StartBit, EndBit);
+}
+
+/**
+ Writes a bit field to a PCI configuration register.
+
+ Writes Value to the bit field of the PCI configuration register. The bit
+ field is specified by the StartBit and the EndBit. All other bits in the
+ destination PCI configuration register are preserved. The new value of the
+ 16-bit register is returned.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If StartBit is greater than 15, then ASSERT().
+ If EndBit is greater than 15, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..15.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..15.
+ @param Value New value of the bit field.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciBitFieldWrite16 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT16 Value
+ )
+{
+ return PciCf8BitFieldWrite16 (Address, StartBit, EndBit, Value);
+}
+
+/**
+ Reads a bit field in a 16-bit PCI configuration, performs a bitwise OR, and
+ writes the result back to the bit field in the 16-bit port.
+
+ Reads the 16-bit PCI configuration register specified by Address, performs a
+ bitwise inclusive OR between the read result and the value specified by
+ OrData, and writes the result to the 16-bit PCI configuration register
+ specified by Address. The value written to the PCI configuration register is
+ returned. This function must guarantee that all PCI read and write operations
+ are serialized. Extra left bits in OrData are stripped.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If StartBit is greater than 15, then ASSERT().
+ If EndBit is greater than 15, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..15.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..15.
+ @param OrData The value to OR with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciBitFieldOr16 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT16 OrData
+ )
+{
+ return PciCf8BitFieldOr16 (Address, StartBit, EndBit, OrData);
+}
+
+/**
+ Reads a bit field in a 16-bit PCI configuration register, performs a bitwise
+ AND, and writes the result back to the bit field in the 16-bit register.
+
+ Reads the 16-bit PCI configuration register specified by Address, performs a
+ bitwise AND between the read result and the value specified by AndData, and
+ writes the result to the 16-bit PCI configuration register specified by
+ Address. The value written to the PCI configuration register is returned.
+ This function must guarantee that all PCI read and write operations are
+ serialized. Extra left bits in AndData are stripped.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If StartBit is greater than 15, then ASSERT().
+ If EndBit is greater than 15, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..15.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..15.
+ @param AndData The value to AND with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciBitFieldAnd16 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT16 AndData
+ )
+{
+ return PciCf8BitFieldAnd16 (Address, StartBit, EndBit, AndData);
+}
+
+/**
+ Reads a bit field in a 16-bit port, performs a bitwise AND followed by a
+ bitwise inclusive OR, and writes the result back to the bit field in the
+ 16-bit port.
+
+ Reads the 16-bit PCI configuration register specified by Address, performs a
+ bitwise AND followed by a bitwise inclusive OR between the read result and
+ the value specified by AndData, and writes the result to the 16-bit PCI
+ configuration register specified by Address. The value written to the PCI
+ configuration register is returned. This function must guarantee that all PCI
+ read and write operations are serialized. Extra left bits in both AndData and
+ OrData are stripped.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If StartBit is greater than 15, then ASSERT().
+ If EndBit is greater than 15, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..15.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..15.
+ @param AndData The value to AND with the PCI configuration register.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciBitFieldAndThenOr16 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT16 AndData,
+ IN UINT16 OrData
+ )
+{
+ return PciCf8BitFieldAndThenOr16 (Address, StartBit, EndBit, AndData, OrData);
+}
+
+/**
+ Reads a 32-bit PCI configuration register.
+
+ Reads and returns the 32-bit PCI configuration register specified by Address.
+ This function must guarantee that all PCI read and write operations are
+ serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+
+ @return The read value from the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciRead32 (
+ IN UINTN Address
+ )
+{
+ return PciCf8Read32 (Address);
+}
+
+/**
+ Writes a 32-bit PCI configuration register.
+
+ Writes the 32-bit PCI configuration register specified by Address with the
+ value specified by Value. Value is returned. This function must guarantee
+ that all PCI read and write operations are serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param Value The value to write.
+
+ @return The value written to the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciWrite32 (
+ IN UINTN Address,
+ IN UINT32 Data
+ )
+{
+ return PciCf8Write32 (Address, Data);
+}
+
+/**
+ Performs a bitwise inclusive OR of a 32-bit PCI configuration register with
+ a 32-bit value.
+
+ Reads the 32-bit PCI configuration register specified by Address, performs a
+ bitwise inclusive OR between the read result and the value specified by
+ OrData, and writes the result to the 32-bit PCI configuration register
+ specified by Address. The value written to the PCI configuration register is
+ returned. This function must guarantee that all PCI read and write operations
+ are serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param OrData The value to OR with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciOr32 (
+ IN UINTN Address,
+ IN UINT32 OrData
+ )
+{
+ return PciCf8Or32 (Address, OrData);
+}
+
+/**
+ Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit
+ value.
+
+ Reads the 32-bit PCI configuration register specified by Address, performs a
+ bitwise AND between the read result and the value specified by AndData, and
+ writes the result to the 32-bit PCI configuration register specified by
+ Address. The value written to the PCI configuration register is returned.
+ This function must guarantee that all PCI read and write operations are
+ serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param AndData The value to AND with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciAnd32 (
+ IN UINTN Address,
+ IN UINT32 AndData
+ )
+{
+ return PciCf8And32 (Address, AndData);
+}
+
+/**
+ Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit
+ value, followed a bitwise inclusive OR with another 32-bit value.
+
+ Reads the 32-bit PCI configuration register specified by Address, performs a
+ bitwise AND between the read result and the value specified by AndData,
+ performs a bitwise inclusive OR between the result of the AND operation and
+ the value specified by OrData, and writes the result to the 32-bit PCI
+ configuration register specified by Address. The value written to the PCI
+ configuration register is returned. This function must guarantee that all PCI
+ read and write operations are serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param AndData The value to AND with the PCI configuration register.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciAndThenOr32 (
+ IN UINTN Address,
+ IN UINT32 AndData,
+ IN UINT32 OrData
+ )
+{
+ return PciCf8AndThenOr32 (Address, AndData, OrData);
+}
+
+/**
+ Reads a bit field of a PCI configuration register.
+
+ Reads the bit field in a 32-bit PCI configuration register. The bit field is
+ specified by the StartBit and the EndBit. The value of the bit field is
+ returned.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to read.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+
+ @return The value of the bit field read from the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciBitFieldRead32 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit
+ )
+{
+ return PciCf8BitFieldRead32 (Address, StartBit, EndBit);
+}
+
+/**
+ Writes a bit field to a PCI configuration register.
+
+ Writes Value to the bit field of the PCI configuration register. The bit
+ field is specified by the StartBit and the EndBit. All other bits in the
+ destination PCI configuration register are preserved. The new value of the
+ 32-bit register is returned.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+ @param Value New value of the bit field.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciBitFieldWrite32 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT32 Value
+ )
+{
+ return PciCf8BitFieldWrite32 (Address, StartBit, EndBit, Value);
+}
+
+/**
+ Reads a bit field in a 32-bit PCI configuration, performs a bitwise OR, and
+ writes the result back to the bit field in the 32-bit port.
+
+ Reads the 32-bit PCI configuration register specified by Address, performs a
+ bitwise inclusive OR between the read result and the value specified by
+ OrData, and writes the result to the 32-bit PCI configuration register
+ specified by Address. The value written to the PCI configuration register is
+ returned. This function must guarantee that all PCI read and write operations
+ are serialized. Extra left bits in OrData are stripped.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+ @param OrData The value to OR with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciBitFieldOr32 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT32 OrData
+ )
+{
+ return PciCf8BitFieldOr32 (Address, StartBit, EndBit, OrData);
+}
+
+/**
+ Reads a bit field in a 32-bit PCI configuration register, performs a bitwise
+ AND, and writes the result back to the bit field in the 32-bit register.
+
+ Reads the 32-bit PCI configuration register specified by Address, performs a
+ bitwise AND between the read result and the value specified by AndData, and
+ writes the result to the 32-bit PCI configuration register specified by
+ Address. The value written to the PCI configuration register is returned.
+ This function must guarantee that all PCI read and write operations are
+ serialized. Extra left bits in AndData are stripped.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+ @param AndData The value to AND with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciBitFieldAnd32 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT32 AndData
+ )
+{
+ return PciCf8BitFieldAnd32 (Address, StartBit, EndBit, AndData);
+}
+
+/**
+ Reads a bit field in a 32-bit port, performs a bitwise AND followed by a
+ bitwise inclusive OR, and writes the result back to the bit field in the
+ 32-bit port.
+
+ Reads the 32-bit PCI configuration register specified by Address, performs a
+ bitwise AND followed by a bitwise inclusive OR between the read result and
+ the value specified by AndData, and writes the result to the 32-bit PCI
+ configuration register specified by Address. The value written to the PCI
+ configuration register is returned. This function must guarantee that all PCI
+ read and write operations are serialized. Extra left bits in both AndData and
+ OrData are stripped.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+ @param AndData The value to AND with the PCI configuration register.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciBitFieldAndThenOr32 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT32 AndData,
+ IN UINT32 OrData
+ )
+{
+ return PciCf8BitFieldAndThenOr32 (Address, StartBit, EndBit, AndData, OrData);
+}
+
+/**
+ Reads a range of PCI configuration registers into a caller supplied buffer.
+
+ Reads the range of PCI configuration registers specified by StartAddress and
+ Size into the buffer specified by Buffer. This function only allows the PCI
+ configuration registers from a single PCI function to be read. Size is
+ returned. When possible 32-bit PCI configuration read cycles are used to read
+ from StartAdress to StartAddress + Size. Due to alignment restrictions, 8-bit
+ and 16-bit PCI configuration read cycles may be used at the beginning and the
+ end of the range.
+
+ If StartAddress > 0x0FFFFFFF, then ASSERT().
+ If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT().
+ If Size > 0 and Buffer is NULL, then ASSERT().
+
+ @param StartAddress Starting address that encodes the PCI Bus, Device,
+ Function and Register.
+ @param Size Size in bytes of the transfer.
+ @param Buffer Pointer to a buffer receiving the data read.
+
+ @return Size
+
+**/
+UINTN
+EFIAPI
+PciReadBuffer (
+ IN UINTN StartAddress,
+ IN UINTN Size,
+ OUT VOID *Buffer
+ )
+{
+ return PciCf8ReadBuffer (StartAddress, Size, Buffer);
+}
+
+/**
+ Copies the data in a caller supplied buffer to a specified range of PCI
+ configuration space.
+
+ Writes the range of PCI configuration registers specified by StartAddress and
+ Size from the buffer specified by Buffer. This function only allows the PCI
+ configuration registers from a single PCI function to be written. Size is
+ returned. When possible 32-bit PCI configuration write cycles are used to
+ write from StartAdress to StartAddress + Size. Due to alignment restrictions,
+ 8-bit and 16-bit PCI configuration write cycles may be used at the beginning
+ and the end of the range.
+
+ If StartAddress > 0x0FFFFFFF, then ASSERT().
+ If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT().
+ If Size > 0 and Buffer is NULL, then ASSERT().
+
+ @param StartAddress Starting address that encodes the PCI Bus, Device,
+ Function and Register.
+ @param Size Size in bytes of the transfer.
+ @param Buffer Pointer to a buffer containing the data to write.
+
+ @return Size
+
+**/
+UINTN
+EFIAPI
+PciWriteBuffer (
+ IN UINTN StartAddress,
+ IN UINTN Size,
+ IN VOID *Buffer
+ )
+{
+ return PciCf8WriteBuffer (StartAddress, Size, Buffer);
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibPciExpress/BasePciLibPciExpress.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibPciExpress/BasePciLibPciExpress.inf
new file mode 100644
index 0000000..0d2ad19
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibPciExpress/BasePciLibPciExpress.inf
@@ -0,0 +1,79 @@
+#/*++
+#
+# Copyright (c) 2004 - 2006, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# BasePciLibPciExpress.inf
+#
+# Abstract:
+#
+# Component description file for BasePciLibPciExpress.
+#
+#--*/
+
+[defines]
+BASE_NAME = EdkIIGlueBasePciLibPciExpress
+COMPONENT_TYPE = LIBRARY
+
+[sources.common]
+ PciLib.c
+
+[sources.ia32]
+
+
+[sources.x64]
+
+
+[sources.ipf]
+
+
+[sources.ebc]
+
+
+[includes.common]
+ .
+ ..\..\Include
+ ..\..\include\Library
+ $(EDK_SOURCE)\Foundation
+ $(EDK_SOURCE)\Foundation\Framework
+ $(EDK_SOURCE)\Foundation\Efi
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+ $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include
+
+[libraries.common]
+ EdkIIGlueBasePciExpressLib
+
+[libraries.ia32]
+
+
+[libraries.x64]
+
+
+[nmake.common]
+ C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION
+ LIB_STD_FLAGS = /NOLOGO /IGNORE:4006
+
+[nmake.ia32]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32
+
+[nmake.x64]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64
+
+[nmake.ipf]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF
+
+[nmake.ebc]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibPciExpress/EdkIIGlueBasePciLibPciExpress.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibPciExpress/EdkIIGlueBasePciLibPciExpress.cif
new file mode 100644
index 0000000..6913cab
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibPciExpress/EdkIIGlueBasePciLibPciExpress.cif
@@ -0,0 +1,11 @@
+<component>
+ name = "EdkIIGlueBasePciLibPciExpress"
+ category = ModulePart
+ LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\BasePciLibPciExpress"
+ RefName = "EdkIIGlueBasePciLibPciExpress"
+[files]
+"EdkIIGlueBasePciLibPciExpress.sdl"
+"EdkIIGlueBasePciLibPciExpress.mak"
+"BasePciLibPciExpress.inf"
+"PciLib.c"
+<endComponent>
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibPciExpress/EdkIIGlueBasePciLibPciExpress.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibPciExpress/EdkIIGlueBasePciLibPciExpress.mak
new file mode 100644
index 0000000..4591e24
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibPciExpress/EdkIIGlueBasePciLibPciExpress.mak
@@ -0,0 +1,80 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueBasePciLibPciExpress/EdkIIGlueBasePciLibPciExpress.mak 1 1/20/12 3:53a Jeffch $
+#
+# $Revision: 1 $
+#
+# $Date: 1/20/12 3:53a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueBasePciLibPciExpress/EdkIIGlueBasePciLibPciExpress.mak $
+#
+# 1 1/20/12 3:53a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 9/27/11 6:15a Wesleychen
+# Intel EDK initially releases.
+#
+# 1 9/18/09 1:52a Iminglin
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: EdkIIGlueBasePciLibPciExpress.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+
+
+$(EdkIIGlueBasePciLibPciExpress_LIB) : EdkIIGlueBasePciLibPciExpress
+
+EdkIIGlueBasePciLibPciExpress : $(BUILD_DIR)\EdkIIGlueBasePciLibPciExpress.mak EdkIIGlueBasePciLibPciExpressBin
+
+$(BUILD_DIR)\EdkIIGlueBasePciLibPciExpress.mak : $(EdkIIGlueBasePciLibPciExpress_DIR)\$(@B).cif $(EdkIIGlueBasePciLibPciExpress_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(EdkIIGlueBasePciLibPciExpress_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+EdkIIGlueBasePciLibPciExpressBin : $(EdkIIGlueBasePciExpressLib_LIB)
+!IF "$(x64_BUILD)"=="1"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGlueBasePciLibPciExpress.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBasePciLibPciExpress_LIB)"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\IA32\
+ /f $(BUILD_DIR)\EdkIIGlueBasePciLibPciExpress.mak all\
+ TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBasePciLibPciExpress_LIB)"
+!ELSE
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGlueBasePciLibPciExpress.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBasePciLibPciExpress_LIB)"
+!ENDIF
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#********************************************************************** \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibPciExpress/EdkIIGlueBasePciLibPciExpress.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibPciExpress/EdkIIGlueBasePciLibPciExpress.sdl
new file mode 100644
index 0000000..ff7527a
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibPciExpress/EdkIIGlueBasePciLibPciExpress.sdl
@@ -0,0 +1,26 @@
+TOKEN
+ Name = "EdkIIGlueBasePciLibPciExpress_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable EdkIIGlueBasePciLibPciExpress support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "EdkIIGlueBasePciLibPciExpress_LIB"
+ Value = "$$(LIB_BUILD_DIR)\EdkIIGlueBasePciLibPciExpress.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "EdkIIGlueBasePciLibPciExpress_DIR"
+End
+
+MODULE
+ Help = "Includes EdkIIGlueBasePciLibPciExpress.mak to Project"
+ File = "EdkIIGlueBasePciLibPciExpress.mak"
+End
+
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibPciExpress/PciLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibPciExpress/PciLib.c
new file mode 100644
index 0000000..4d97a37
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePciLibPciExpress/PciLib.c
@@ -0,0 +1,1076 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ PciLib.c
+
+Abstract:
+
+ PCI Library using PC Express access.
+
+--*/
+
+#include "EdkIIGlueBase.h"
+
+/**
+ Reads an 8-bit PCI configuration register.
+
+ Reads and returns the 8-bit PCI configuration register specified by Address.
+ This function must guarantee that all PCI read and write operations are
+ serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+
+ @return The read value from the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciRead8 (
+ IN UINTN Address
+ )
+{
+ return PciExpressRead8 (Address);
+}
+
+/**
+ Writes an 8-bit PCI configuration register.
+
+ Writes the 8-bit PCI configuration register specified by Address with the
+ value specified by Value. Value is returned. This function must guarantee
+ that all PCI read and write operations are serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param Value The value to write.
+
+ @return The value written to the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciWrite8 (
+ IN UINTN Address,
+ IN UINT8 Data
+ )
+{
+ return PciExpressWrite8 (Address, Data);
+}
+
+/**
+ Performs a bitwise inclusive OR of an 8-bit PCI configuration register with
+ an 8-bit value.
+
+ Reads the 8-bit PCI configuration register specified by Address, performs a
+ bitwise inclusive OR between the read result and the value specified by
+ OrData, and writes the result to the 8-bit PCI configuration register
+ specified by Address. The value written to the PCI configuration register is
+ returned. This function must guarantee that all PCI read and write operations
+ are serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param OrData The value to OR with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciOr8 (
+ IN UINTN Address,
+ IN UINT8 OrData
+ )
+{
+ return PciExpressOr8 (Address, OrData);
+}
+
+/**
+ Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit
+ value.
+
+ Reads the 8-bit PCI configuration register specified by Address, performs a
+ bitwise AND between the read result and the value specified by AndData, and
+ writes the result to the 8-bit PCI configuration register specified by
+ Address. The value written to the PCI configuration register is returned.
+ This function must guarantee that all PCI read and write operations are
+ serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param AndData The value to AND with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciAnd8 (
+ IN UINTN Address,
+ IN UINT8 AndData
+ )
+{
+ return PciExpressAnd8 (Address, AndData);
+}
+
+/**
+ Performs a bitwise AND of an 8-bit PCI configuration register with an 8-bit
+ value, followed a bitwise inclusive OR with another 8-bit value.
+
+ Reads the 8-bit PCI configuration register specified by Address, performs a
+ bitwise AND between the read result and the value specified by AndData,
+ performs a bitwise inclusive OR between the result of the AND operation and
+ the value specified by OrData, and writes the result to the 8-bit PCI
+ configuration register specified by Address. The value written to the PCI
+ configuration register is returned. This function must guarantee that all PCI
+ read and write operations are serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param AndData The value to AND with the PCI configuration register.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciAndThenOr8 (
+ IN UINTN Address,
+ IN UINT8 AndData,
+ IN UINT8 OrData
+ )
+{
+ return PciExpressAndThenOr8 (Address, AndData, OrData);
+}
+
+/**
+ Reads a bit field of a PCI configuration register.
+
+ Reads the bit field in an 8-bit PCI configuration register. The bit field is
+ specified by the StartBit and the EndBit. The value of the bit field is
+ returned.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If StartBit is greater than 7, then ASSERT().
+ If EndBit is greater than 7, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to read.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..7.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..7.
+
+ @return The value of the bit field read from the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciBitFieldRead8 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit
+ )
+{
+ return PciExpressBitFieldRead8 (Address, StartBit, EndBit);
+}
+
+/**
+ Writes a bit field to a PCI configuration register.
+
+ Writes Value to the bit field of the PCI configuration register. The bit
+ field is specified by the StartBit and the EndBit. All other bits in the
+ destination PCI configuration register are preserved. The new value of the
+ 8-bit register is returned.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If StartBit is greater than 7, then ASSERT().
+ If EndBit is greater than 7, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..7.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..7.
+ @param Value New value of the bit field.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciBitFieldWrite8 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT8 Value
+ )
+{
+ return PciExpressBitFieldWrite8 (Address, StartBit, EndBit, Value);
+}
+
+/**
+ Reads a bit field in an 8-bit PCI configuration, performs a bitwise OR, and
+ writes the result back to the bit field in the 8-bit port.
+
+ Reads the 8-bit PCI configuration register specified by Address, performs a
+ bitwise inclusive OR between the read result and the value specified by
+ OrData, and writes the result to the 8-bit PCI configuration register
+ specified by Address. The value written to the PCI configuration register is
+ returned. This function must guarantee that all PCI read and write operations
+ are serialized. Extra left bits in OrData are stripped.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If StartBit is greater than 7, then ASSERT().
+ If EndBit is greater than 7, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..7.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..7.
+ @param OrData The value to OR with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciBitFieldOr8 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT8 OrData
+ )
+{
+ return PciExpressBitFieldOr8 (Address, StartBit, EndBit, OrData);
+}
+
+/**
+ Reads a bit field in an 8-bit PCI configuration register, performs a bitwise
+ AND, and writes the result back to the bit field in the 8-bit register.
+
+ Reads the 8-bit PCI configuration register specified by Address, performs a
+ bitwise AND between the read result and the value specified by AndData, and
+ writes the result to the 8-bit PCI configuration register specified by
+ Address. The value written to the PCI configuration register is returned.
+ This function must guarantee that all PCI read and write operations are
+ serialized. Extra left bits in AndData are stripped.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If StartBit is greater than 7, then ASSERT().
+ If EndBit is greater than 7, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..7.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..7.
+ @param AndData The value to AND with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciBitFieldAnd8 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT8 AndData
+ )
+{
+ return PciExpressBitFieldAnd8 (Address, StartBit, EndBit, AndData);
+}
+
+/**
+ Reads a bit field in an 8-bit port, performs a bitwise AND followed by a
+ bitwise inclusive OR, and writes the result back to the bit field in the
+ 8-bit port.
+
+ Reads the 8-bit PCI configuration register specified by Address, performs a
+ bitwise AND followed by a bitwise inclusive OR between the read result and
+ the value specified by AndData, and writes the result to the 8-bit PCI
+ configuration register specified by Address. The value written to the PCI
+ configuration register is returned. This function must guarantee that all PCI
+ read and write operations are serialized. Extra left bits in both AndData and
+ OrData are stripped.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If StartBit is greater than 7, then ASSERT().
+ If EndBit is greater than 7, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..7.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..7.
+ @param AndData The value to AND with the PCI configuration register.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT8
+EFIAPI
+PciBitFieldAndThenOr8 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT8 AndData,
+ IN UINT8 OrData
+ )
+{
+ return PciExpressBitFieldAndThenOr8 (Address, StartBit, EndBit, AndData, OrData);
+}
+
+/**
+ Reads a 16-bit PCI configuration register.
+
+ Reads and returns the 16-bit PCI configuration register specified by Address.
+ This function must guarantee that all PCI read and write operations are
+ serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+
+ @return The read value from the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciRead16 (
+ IN UINTN Address
+ )
+{
+ return PciExpressRead16 (Address);
+}
+
+/**
+ Writes a 16-bit PCI configuration register.
+
+ Writes the 16-bit PCI configuration register specified by Address with the
+ value specified by Value. Value is returned. This function must guarantee
+ that all PCI read and write operations are serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param Value The value to write.
+
+ @return The value written to the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciWrite16 (
+ IN UINTN Address,
+ IN UINT16 Data
+ )
+{
+ return PciExpressWrite16 (Address, Data);
+}
+
+/**
+ Performs a bitwise inclusive OR of a 16-bit PCI configuration register with
+ a 16-bit value.
+
+ Reads the 16-bit PCI configuration register specified by Address, performs a
+ bitwise inclusive OR between the read result and the value specified by
+ OrData, and writes the result to the 16-bit PCI configuration register
+ specified by Address. The value written to the PCI configuration register is
+ returned. This function must guarantee that all PCI read and write operations
+ are serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param OrData The value to OR with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciOr16 (
+ IN UINTN Address,
+ IN UINT16 OrData
+ )
+{
+ return PciExpressOr16 (Address, OrData);
+}
+
+/**
+ Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit
+ value.
+
+ Reads the 16-bit PCI configuration register specified by Address, performs a
+ bitwise AND between the read result and the value specified by AndData, and
+ writes the result to the 16-bit PCI configuration register specified by
+ Address. The value written to the PCI configuration register is returned.
+ This function must guarantee that all PCI read and write operations are
+ serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param AndData The value to AND with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciAnd16 (
+ IN UINTN Address,
+ IN UINT16 AndData
+ )
+{
+ return PciExpressAnd16 (Address, AndData);
+}
+
+/**
+ Performs a bitwise AND of a 16-bit PCI configuration register with a 16-bit
+ value, followed a bitwise inclusive OR with another 16-bit value.
+
+ Reads the 16-bit PCI configuration register specified by Address, performs a
+ bitwise AND between the read result and the value specified by AndData,
+ performs a bitwise inclusive OR between the result of the AND operation and
+ the value specified by OrData, and writes the result to the 16-bit PCI
+ configuration register specified by Address. The value written to the PCI
+ configuration register is returned. This function must guarantee that all PCI
+ read and write operations are serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param AndData The value to AND with the PCI configuration register.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciAndThenOr16 (
+ IN UINTN Address,
+ IN UINT16 AndData,
+ IN UINT16 OrData
+ )
+{
+ return PciExpressAndThenOr16 (Address, AndData, OrData);
+}
+
+/**
+ Reads a bit field of a PCI configuration register.
+
+ Reads the bit field in a 16-bit PCI configuration register. The bit field is
+ specified by the StartBit and the EndBit. The value of the bit field is
+ returned.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If StartBit is greater than 15, then ASSERT().
+ If EndBit is greater than 15, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to read.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..15.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..15.
+
+ @return The value of the bit field read from the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciBitFieldRead16 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit
+ )
+{
+ return PciExpressBitFieldRead16 (Address, StartBit, EndBit);
+}
+
+/**
+ Writes a bit field to a PCI configuration register.
+
+ Writes Value to the bit field of the PCI configuration register. The bit
+ field is specified by the StartBit and the EndBit. All other bits in the
+ destination PCI configuration register are preserved. The new value of the
+ 16-bit register is returned.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If StartBit is greater than 15, then ASSERT().
+ If EndBit is greater than 15, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..15.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..15.
+ @param Value New value of the bit field.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciBitFieldWrite16 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT16 Value
+ )
+{
+ return PciExpressBitFieldWrite16 (Address, StartBit, EndBit, Value);
+}
+
+/**
+ Reads a bit field in a 16-bit PCI configuration, performs a bitwise OR, and
+ writes the result back to the bit field in the 16-bit port.
+
+ Reads the 16-bit PCI configuration register specified by Address, performs a
+ bitwise inclusive OR between the read result and the value specified by
+ OrData, and writes the result to the 16-bit PCI configuration register
+ specified by Address. The value written to the PCI configuration register is
+ returned. This function must guarantee that all PCI read and write operations
+ are serialized. Extra left bits in OrData are stripped.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If StartBit is greater than 15, then ASSERT().
+ If EndBit is greater than 15, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..15.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..15.
+ @param OrData The value to OR with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciBitFieldOr16 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT16 OrData
+ )
+{
+ return PciExpressBitFieldOr16 (Address, StartBit, EndBit, OrData);
+}
+
+/**
+ Reads a bit field in a 16-bit PCI configuration register, performs a bitwise
+ AND, and writes the result back to the bit field in the 16-bit register.
+
+ Reads the 16-bit PCI configuration register specified by Address, performs a
+ bitwise AND between the read result and the value specified by AndData, and
+ writes the result to the 16-bit PCI configuration register specified by
+ Address. The value written to the PCI configuration register is returned.
+ This function must guarantee that all PCI read and write operations are
+ serialized. Extra left bits in AndData are stripped.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If StartBit is greater than 15, then ASSERT().
+ If EndBit is greater than 15, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..15.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..15.
+ @param AndData The value to AND with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciBitFieldAnd16 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT16 AndData
+ )
+{
+ return PciExpressBitFieldAnd16 (Address, StartBit, EndBit, AndData);
+}
+
+/**
+ Reads a bit field in a 16-bit port, performs a bitwise AND followed by a
+ bitwise inclusive OR, and writes the result back to the bit field in the
+ 16-bit port.
+
+ Reads the 16-bit PCI configuration register specified by Address, performs a
+ bitwise AND followed by a bitwise inclusive OR between the read result and
+ the value specified by AndData, and writes the result to the 16-bit PCI
+ configuration register specified by Address. The value written to the PCI
+ configuration register is returned. This function must guarantee that all PCI
+ read and write operations are serialized. Extra left bits in both AndData and
+ OrData are stripped.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If StartBit is greater than 15, then ASSERT().
+ If EndBit is greater than 15, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..15.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..15.
+ @param AndData The value to AND with the PCI configuration register.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT16
+EFIAPI
+PciBitFieldAndThenOr16 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT16 AndData,
+ IN UINT16 OrData
+ )
+{
+ return PciExpressBitFieldAndThenOr16 (Address, StartBit, EndBit, AndData, OrData);
+}
+
+/**
+ Reads a 32-bit PCI configuration register.
+
+ Reads and returns the 32-bit PCI configuration register specified by Address.
+ This function must guarantee that all PCI read and write operations are
+ serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+
+ @return The read value from the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciRead32 (
+ IN UINTN Address
+ )
+{
+ return PciExpressRead32 (Address);
+}
+
+/**
+ Writes a 32-bit PCI configuration register.
+
+ Writes the 32-bit PCI configuration register specified by Address with the
+ value specified by Value. Value is returned. This function must guarantee
+ that all PCI read and write operations are serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param Value The value to write.
+
+ @return The value written to the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciWrite32 (
+ IN UINTN Address,
+ IN UINT32 Data
+ )
+{
+ return PciExpressWrite32 (Address, Data);
+}
+
+/**
+ Performs a bitwise inclusive OR of a 32-bit PCI configuration register with
+ a 32-bit value.
+
+ Reads the 32-bit PCI configuration register specified by Address, performs a
+ bitwise inclusive OR between the read result and the value specified by
+ OrData, and writes the result to the 32-bit PCI configuration register
+ specified by Address. The value written to the PCI configuration register is
+ returned. This function must guarantee that all PCI read and write operations
+ are serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param OrData The value to OR with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciOr32 (
+ IN UINTN Address,
+ IN UINT32 OrData
+ )
+{
+ return PciExpressOr32 (Address, OrData);
+}
+
+/**
+ Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit
+ value.
+
+ Reads the 32-bit PCI configuration register specified by Address, performs a
+ bitwise AND between the read result and the value specified by AndData, and
+ writes the result to the 32-bit PCI configuration register specified by
+ Address. The value written to the PCI configuration register is returned.
+ This function must guarantee that all PCI read and write operations are
+ serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param AndData The value to AND with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciAnd32 (
+ IN UINTN Address,
+ IN UINT32 AndData
+ )
+{
+ return PciExpressAnd32 (Address, AndData);
+}
+
+/**
+ Performs a bitwise AND of a 32-bit PCI configuration register with a 32-bit
+ value, followed a bitwise inclusive OR with another 32-bit value.
+
+ Reads the 32-bit PCI configuration register specified by Address, performs a
+ bitwise AND between the read result and the value specified by AndData,
+ performs a bitwise inclusive OR between the result of the AND operation and
+ the value specified by OrData, and writes the result to the 32-bit PCI
+ configuration register specified by Address. The value written to the PCI
+ configuration register is returned. This function must guarantee that all PCI
+ read and write operations are serialized.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+
+ @param Address Address that encodes the PCI Bus, Device, Function and
+ Register.
+ @param AndData The value to AND with the PCI configuration register.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciAndThenOr32 (
+ IN UINTN Address,
+ IN UINT32 AndData,
+ IN UINT32 OrData
+ )
+{
+ return PciExpressAndThenOr32 (Address, AndData, OrData);
+}
+
+/**
+ Reads a bit field of a PCI configuration register.
+
+ Reads the bit field in a 32-bit PCI configuration register. The bit field is
+ specified by the StartBit and the EndBit. The value of the bit field is
+ returned.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to read.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+
+ @return The value of the bit field read from the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciBitFieldRead32 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit
+ )
+{
+ return PciExpressBitFieldRead32 (Address, StartBit, EndBit);
+}
+
+/**
+ Writes a bit field to a PCI configuration register.
+
+ Writes Value to the bit field of the PCI configuration register. The bit
+ field is specified by the StartBit and the EndBit. All other bits in the
+ destination PCI configuration register are preserved. The new value of the
+ 32-bit register is returned.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+ @param Value New value of the bit field.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciBitFieldWrite32 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT32 Value
+ )
+{
+ return PciExpressBitFieldWrite32 (Address, StartBit, EndBit, Value);
+}
+
+/**
+ Reads a bit field in a 32-bit PCI configuration, performs a bitwise OR, and
+ writes the result back to the bit field in the 32-bit port.
+
+ Reads the 32-bit PCI configuration register specified by Address, performs a
+ bitwise inclusive OR between the read result and the value specified by
+ OrData, and writes the result to the 32-bit PCI configuration register
+ specified by Address. The value written to the PCI configuration register is
+ returned. This function must guarantee that all PCI read and write operations
+ are serialized. Extra left bits in OrData are stripped.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+ @param OrData The value to OR with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciBitFieldOr32 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT32 OrData
+ )
+{
+ return PciExpressBitFieldOr32 (Address, StartBit, EndBit, OrData);
+}
+
+/**
+ Reads a bit field in a 32-bit PCI configuration register, performs a bitwise
+ AND, and writes the result back to the bit field in the 32-bit register.
+
+ Reads the 32-bit PCI configuration register specified by Address, performs a
+ bitwise AND between the read result and the value specified by AndData, and
+ writes the result to the 32-bit PCI configuration register specified by
+ Address. The value written to the PCI configuration register is returned.
+ This function must guarantee that all PCI read and write operations are
+ serialized. Extra left bits in AndData are stripped.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+ @param AndData The value to AND with the PCI configuration register.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciBitFieldAnd32 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT32 AndData
+ )
+{
+ return PciExpressBitFieldAnd32 (Address, StartBit, EndBit, AndData);
+}
+
+/**
+ Reads a bit field in a 32-bit port, performs a bitwise AND followed by a
+ bitwise inclusive OR, and writes the result back to the bit field in the
+ 32-bit port.
+
+ Reads the 32-bit PCI configuration register specified by Address, performs a
+ bitwise AND followed by a bitwise inclusive OR between the read result and
+ the value specified by AndData, and writes the result to the 32-bit PCI
+ configuration register specified by Address. The value written to the PCI
+ configuration register is returned. This function must guarantee that all PCI
+ read and write operations are serialized. Extra left bits in both AndData and
+ OrData are stripped.
+
+ If Address > 0x0FFFFFFF, then ASSERT().
+ If StartBit is greater than 31, then ASSERT().
+ If EndBit is greater than 31, then ASSERT().
+ If EndBit is less than StartBit, then ASSERT().
+
+ @param Address PCI configuration register to write.
+ @param StartBit The ordinal of the least significant bit in the bit field.
+ Range 0..31.
+ @param EndBit The ordinal of the most significant bit in the bit field.
+ Range 0..31.
+ @param AndData The value to AND with the PCI configuration register.
+ @param OrData The value to OR with the result of the AND operation.
+
+ @return The value written back to the PCI configuration register.
+
+**/
+UINT32
+EFIAPI
+PciBitFieldAndThenOr32 (
+ IN UINTN Address,
+ IN UINTN StartBit,
+ IN UINTN EndBit,
+ IN UINT32 AndData,
+ IN UINT32 OrData
+ )
+{
+ return PciExpressBitFieldAndThenOr32 (Address, StartBit, EndBit, AndData, OrData);
+}
+
+/**
+ Reads a range of PCI configuration registers into a caller supplied buffer.
+
+ Reads the range of PCI configuration registers specified by StartAddress and
+ Size into the buffer specified by Buffer. This function only allows the PCI
+ configuration registers from a single PCI function to be read. Size is
+ returned. When possible 32-bit PCI configuration read cycles are used to read
+ from StartAdress to StartAddress + Size. Due to alignment restrictions, 8-bit
+ and 16-bit PCI configuration read cycles may be used at the beginning and the
+ end of the range.
+
+ If StartAddress > 0x0FFFFFFF, then ASSERT().
+ If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT().
+ If Size > 0 and Buffer is NULL, then ASSERT().
+
+ @param StartAddress Starting address that encodes the PCI Bus, Device,
+ Function and Register.
+ @param Size Size in bytes of the transfer.
+ @param Buffer Pointer to a buffer receiving the data read.
+
+ @return Size
+
+**/
+UINTN
+EFIAPI
+PciReadBuffer (
+ IN UINTN StartAddress,
+ IN UINTN Size,
+ OUT VOID *Buffer
+ )
+{
+ return PciExpressReadBuffer (StartAddress, Size, Buffer);
+}
+
+/**
+ Copies the data in a caller supplied buffer to a specified range of PCI
+ configuration space.
+
+ Writes the range of PCI configuration registers specified by StartAddress and
+ Size from the buffer specified by Buffer. This function only allows the PCI
+ configuration registers from a single PCI function to be written. Size is
+ returned. When possible 32-bit PCI configuration write cycles are used to
+ write from StartAdress to StartAddress + Size. Due to alignment restrictions,
+ 8-bit and 16-bit PCI configuration write cycles may be used at the beginning
+ and the end of the range.
+
+ If StartAddress > 0x0FFFFFFF, then ASSERT().
+ If ((StartAddress & 0xFFF) + Size) > 0x1000, then ASSERT().
+ If Size > 0 and Buffer is NULL, then ASSERT().
+
+ @param StartAddress Starting address that encodes the PCI Bus, Device,
+ Function and Register.
+ @param Size Size in bytes of the transfer.
+ @param Buffer Pointer to a buffer containing the data to write.
+
+ @return Size
+
+**/
+UINTN
+EFIAPI
+PciWriteBuffer (
+ IN UINTN StartAddress,
+ IN UINTN Size,
+ IN VOID *Buffer
+ )
+{
+ return PciExpressWriteBuffer (StartAddress, Size, Buffer);
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf
new file mode 100644
index 0000000..9ef8d0a
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffGetEntryPointLib/BasePeCoffGetEntryPointLib.inf
@@ -0,0 +1,82 @@
+#/*++
+#
+# Copyright (c) 2004 - 2006, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# BasePeCoffGetEntryPointLib.inf
+#
+# Abstract:
+#
+# Component description file for BasePeCoffGetEntryPointLib.
+#
+#--*/
+
+[defines]
+BASE_NAME = EdkIIGlueBasePeCoffGetEntryPointLib
+COMPONENT_TYPE = LIBRARY
+
+[sources.common]
+ PeCoffGetEntryPoint.c
+
+[sources.ia32]
+
+
+[sources.x64]
+
+
+[sources.ipf]
+
+
+[sources.ebc]
+
+
+[includes.common]
+ .
+ ..\..\Include
+ ..\..\include\Library
+ $(EDK_SOURCE)\Foundation
+ $(EDK_SOURCE)\Foundation\Framework
+ $(EDK_SOURCE)\Foundation\Efi
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+ $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include
+
+ $(EDK_SOURCE)\Foundation\Efi\Include
+
+
+[libraries.common]
+
+
+[libraries.ia32]
+
+
+[libraries.x64]
+
+
+[nmake.common]
+ C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION
+ LIB_STD_FLAGS = /NOLOGO /IGNORE:4006
+
+[nmake.ia32]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32
+
+[nmake.x64]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64
+
+[nmake.ipf]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF
+
+[nmake.ebc]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffGetEntryPointLib/EdkIIGlueBasePeCoffGetEntryPointLib.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffGetEntryPointLib/EdkIIGlueBasePeCoffGetEntryPointLib.cif
new file mode 100644
index 0000000..c21dfa7
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffGetEntryPointLib/EdkIIGlueBasePeCoffGetEntryPointLib.cif
@@ -0,0 +1,11 @@
+<component>
+ name = "EdkIIGlueBasePeCoffGetEntryPointLib"
+ category = ModulePart
+ LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\BasePeCoffGetEntryPointLib"
+ RefName = "EdkIIGlueBasePeCoffGetEntryPointLib"
+[files]
+"EdkIIGlueBasePeCoffGetEntryPointLib.sdl"
+"EdkIIGlueBasePeCoffGetEntryPointLib.mak"
+"BasePeCoffGetEntryPointLib.inf"
+"PeCoffGetEntryPoint.c"
+<endComponent>
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffGetEntryPointLib/EdkIIGlueBasePeCoffGetEntryPointLib.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffGetEntryPointLib/EdkIIGlueBasePeCoffGetEntryPointLib.mak
new file mode 100644
index 0000000..871cf28
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffGetEntryPointLib/EdkIIGlueBasePeCoffGetEntryPointLib.mak
@@ -0,0 +1,80 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueBasePeCoffGetEntryPointLib/EdkIIGlueBasePeCoffGetEntryPointLib.mak 1 1/20/12 3:53a Jeffch $
+#
+# $Revision: 1 $
+#
+# $Date: 1/20/12 3:53a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueBasePeCoffGetEntryPointLib/EdkIIGlueBasePeCoffGetEntryPointLib.mak $
+#
+# 1 1/20/12 3:53a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 9/27/11 6:16a Wesleychen
+# Intel EDK initially releases.
+#
+# 1 9/18/09 1:52a Iminglin
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: EdkIIGlueBasePeCoffGetEntryPointLib.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+
+
+$(EdkIIGlueBasePeCoffGetEntryPointLib_LIB) : EdkIIGlueBasePeCoffGetEntryPointLib
+
+EdkIIGlueBasePeCoffGetEntryPointLib : $(BUILD_DIR)\EdkIIGlueBasePeCoffGetEntryPointLib.mak EdkIIGlueBasePeCoffGetEntryPointLibBin
+
+$(BUILD_DIR)\EdkIIGlueBasePeCoffGetEntryPointLib.mak : $(EdkIIGlueBasePeCoffGetEntryPointLib_DIR)\$(@B).cif $(EdkIIGlueBasePeCoffGetEntryPointLib_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(EdkIIGlueBasePeCoffGetEntryPointLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+EdkIIGlueBasePeCoffGetEntryPointLibBin :
+!IF "$(x64_BUILD)"=="1"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGlueBasePeCoffGetEntryPointLib.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBasePeCoffGetEntryPointLib_LIB)"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\IA32\
+ /f $(BUILD_DIR)\EdkIIGlueBasePeCoffGetEntryPointLib.mak all\
+ TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBasePeCoffGetEntryPointLib_LIB)"
+!ELSE
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGlueBasePeCoffGetEntryPointLib.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBasePeCoffGetEntryPointLib_LIB)"
+!ENDIF
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#********************************************************************** \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffGetEntryPointLib/EdkIIGlueBasePeCoffGetEntryPointLib.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffGetEntryPointLib/EdkIIGlueBasePeCoffGetEntryPointLib.sdl
new file mode 100644
index 0000000..27c457a
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffGetEntryPointLib/EdkIIGlueBasePeCoffGetEntryPointLib.sdl
@@ -0,0 +1,26 @@
+TOKEN
+ Name = "EdkIIGlueBasePeCoffGetEntryPointLib_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable EdkIIGlueBasePeCoffGetEntryPointLib support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "EdkIIGlueBasePeCoffGetEntryPointLib_LIB"
+ Value = "$$(LIB_BUILD_DIR)\EdkIIGlueBasePeCoffGetEntryPointLib.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "EdkIIGlueBasePeCoffGetEntryPointLib_DIR"
+End
+
+MODULE
+ Help = "Includes EdkIIGlueBasePeCoffGetEntryPointLib.mak to Project"
+ File = "EdkIIGlueBasePeCoffGetEntryPointLib.mak"
+End
+
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffGetEntryPointLib/PeCoffGetEntryPoint.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffGetEntryPointLib/PeCoffGetEntryPoint.c
new file mode 100644
index 0000000..208d662
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffGetEntryPointLib/PeCoffGetEntryPoint.c
@@ -0,0 +1,222 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ PeCoffGetEntryPoint.c
+
+Abstract:
+
+ Pe/Coff loader
+
+--*/
+
+#include "EdkIIGlueBase.h"
+
+/**
+ Retrieves and returns a pointer to the entry point to a PE/COFF image that has been loaded
+ into system memory with the PE/COFF Loader Library functions.
+
+ Retrieves the entry point to the PE/COFF image specified by Pe32Data and returns this entry
+ point in EntryPoint. If the entry point could not be retrieved from the PE/COFF image, then
+ return RETURN_INVALID_PARAMETER. Otherwise return RETURN_SUCCESS.
+ If Pe32Data is NULL, then ASSERT().
+ If EntryPoint is NULL, then ASSERT().
+
+ @param Pe32Data Pointer to the PE/COFF image that is loaded in system memory.
+ @param EntryPoint Pointer to entry point to the PE/COFF image to return.
+
+ @retval RETURN_SUCCESS EntryPoint was returned.
+ @retval RETURN_INVALID_PARAMETER The entry point could not be found in the PE/COFF image.
+
+**/
+RETURN_STATUS
+EFIAPI
+PeCoffLoaderGetEntryPoint (
+ IN VOID *Pe32Data,
+ OUT VOID **EntryPoint
+ )
+{
+ EFI_IMAGE_DOS_HEADER *DosHeader;
+ EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Header;
+
+ ASSERT (Pe32Data != NULL);
+ ASSERT (EntryPoint != NULL);
+
+ DosHeader = (EFI_IMAGE_DOS_HEADER *)Pe32Data;
+ if (DosHeader->e_magic == EFI_IMAGE_DOS_SIGNATURE) {
+ //
+ // DOS image header is present, so read the PE header after the DOS image header.
+ //
+ Header.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINTN) Pe32Data + (UINTN) ((DosHeader->e_lfanew) & 0x0ffff));
+ } else {
+ //
+ // DOS image header is not present, so PE header is at the image base.
+ //
+ Header.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)Pe32Data;
+ }
+
+ //
+ // Calculate the entry point relative to the start of the image.
+ // AddressOfEntryPoint is common for PE32 & PE32+
+ //
+ *EntryPoint = (VOID *)((UINTN)Pe32Data + (UINTN)(Header.Pe32->OptionalHeader.AddressOfEntryPoint & 0x0ffffffff));
+ return RETURN_SUCCESS;
+}
+
+
+/**
+ Returns the machine type of a PE/COFF image.
+
+ Returns the machine type from the PE/COFF image specified by Pe32Data.
+ If Pe32Data is NULL, then ASSERT().
+
+ @param Pe32Data Pointer to the PE/COFF image that is loaded in system
+ memory.
+
+ @return Machine type or zero if not a valid iamge.
+
+**/
+UINT16
+EFIAPI
+PeCoffLoaderGetMachineType (
+ IN VOID *Pe32Data
+ )
+{
+ EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr;
+ EFI_IMAGE_DOS_HEADER *DosHdr;
+
+ DosHdr = (EFI_IMAGE_DOS_HEADER *)Pe32Data;
+ if (DosHdr->e_magic == EFI_IMAGE_DOS_SIGNATURE) {
+ Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINTN)Pe32Data + DosHdr->e_lfanew);
+ } else {
+ Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINTN)Pe32Data);
+ }
+
+ if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE) {
+ return Hdr.Pe32->FileHeader.Machine;
+ }
+
+ return 0x0000;
+}
+
+/**
+ Returns a pointer to the PDB file name for a PE/COFF image that has been
+ loaded into system memory with the PE/COFF Loader Library functions.
+
+ Returns the PDB file name for the PE/COFF image specified by Pe32Data. If
+ the PE/COFF image specified by Pe32Data is not a valid, then NULL is
+ returned. If the PE/COFF image specified by Pe32Data does not contain a
+ debug directory entry, then NULL is returned. If the debug directory entry
+ in the PE/COFF image specified by Pe32Data does not contain a PDB file name,
+ then NULL is returned.
+ If Pe32Data is NULL, then ASSERT().
+
+ @param Pe32Data Pointer to the PE/COFF image that is loaded in system
+ memory.
+
+ @return The PDB file name for the PE/COFF image specified by Pe32Data or NULL
+ if it cannot be retrieved.
+
+**/
+VOID *
+EFIAPI
+PeCoffLoaderGetPdbPointer (
+ IN VOID *Pe32Data
+ )
+{
+ EFI_IMAGE_DOS_HEADER *DosHeader;
+ EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr;
+ EFI_IMAGE_DATA_DIRECTORY *DirectoryEntry;
+ EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *DebugEntry;
+ UINTN DirCount;
+ VOID *CodeViewEntryPointer;
+ INTN TEImageAdjust;
+ UINT32 NumberOfRvaAndSizes;
+
+ ASSERT (Pe32Data != NULL);
+
+ TEImageAdjust = 0;
+ DirectoryEntry = NULL;
+ DebugEntry = NULL;
+ NumberOfRvaAndSizes = 0;
+
+ DosHeader = (EFI_IMAGE_DOS_HEADER *)Pe32Data;
+ if (DosHeader->e_magic == EFI_IMAGE_DOS_SIGNATURE) {
+ //
+ // DOS image header is present, so read the PE header after the DOS image header.
+ //
+ Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINTN) Pe32Data + (UINTN) ((DosHeader->e_lfanew) & 0x0ffff));
+ } else {
+ //
+ // DOS image header is not present, so PE header is at the image base.
+ //
+ Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)Pe32Data;
+ }
+
+ if (Hdr.Te->Signature == EFI_TE_IMAGE_HEADER_SIGNATURE) {
+ if (Hdr.Te->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress != 0) {
+ DirectoryEntry = &Hdr.Te->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG];
+ TEImageAdjust = sizeof (EFI_TE_IMAGE_HEADER) - Hdr.Te->StrippedSize;
+ DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *)((UINTN) Hdr.Te +
+ Hdr.Te->DataDirectory[EFI_TE_IMAGE_DIRECTORY_ENTRY_DEBUG].VirtualAddress +
+ TEImageAdjust);
+ }
+ } else if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE) {
+ if (Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
+ //
+ // Use PE32 offset get Debug Directory Entry
+ //
+ NumberOfRvaAndSizes = Hdr.Pe32->OptionalHeader.NumberOfRvaAndSizes;
+ DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]);
+ DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *) ((UINTN) Pe32Data + DirectoryEntry->VirtualAddress);
+ } else if (Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC) {
+ //
+ // Use PE32+ offset get Debug Directory Entry
+ //
+ NumberOfRvaAndSizes = Hdr.Pe32Plus->OptionalHeader.NumberOfRvaAndSizes;
+ DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32Plus->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]);
+ DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *) ((UINTN) Pe32Data + DirectoryEntry->VirtualAddress);
+ }
+
+ if (NumberOfRvaAndSizes <= EFI_IMAGE_DIRECTORY_ENTRY_DEBUG) {
+ DirectoryEntry = NULL;
+ DebugEntry = NULL;
+ }
+ } else {
+ return NULL;
+ }
+
+ if (DebugEntry == NULL || DirectoryEntry == NULL) {
+ return NULL;
+ }
+
+ for (DirCount = 0; DirCount < DirectoryEntry->Size; DirCount++, DebugEntry++) {
+ if (DebugEntry->Type == EFI_IMAGE_DEBUG_TYPE_CODEVIEW) {
+ if (DebugEntry->SizeOfData > 0) {
+ CodeViewEntryPointer = (VOID *) ((UINTN) DebugEntry->RVA + ((UINTN)Pe32Data) + (UINTN)TEImageAdjust);
+ switch (* (UINT32 *) CodeViewEntryPointer) {
+ case CODEVIEW_SIGNATURE_NB10:
+ return (VOID *) ((CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY));
+ case CODEVIEW_SIGNATURE_RSDS:
+ return (VOID *) ((CHAR8 *)CodeViewEntryPointer + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY));
+ default:
+ break;
+ }
+ }
+ }
+ }
+
+ return NULL;
+}
+
+
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/BasePeCoff.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/BasePeCoff.c
new file mode 100644
index 0000000..3b8264a
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/BasePeCoff.c
@@ -0,0 +1,1357 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ EdkIIGlueDxeDriverEntryPoint.c
+
+Abstract:
+
+ Pe/Coff loader
+
+--*/
+
+#include "BasePeCoffLibInternals.h"
+
+/**
+ Retrieves the magic value from the PE/COFF header.
+
+ @param Hdr The buffer in which to return the PE32, PE32+, or TE header.
+
+ @return EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC - Image is PE32
+ @return EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC - Image is PE32+
+
+**/
+UINT16
+PeCoffLoaderGetPeHeaderMagicValue (
+ IN EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr
+ )
+{
+ //
+ // NOTE: Some versions of Linux ELILO for Itanium have an incorrect magic value
+ // in the PE/COFF Header. If the MachineType is Itanium(IA64) and the
+ // Magic value in the OptionalHeader is EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC
+ // then override the returned value to EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC
+ //
+ if (Hdr.Pe32->FileHeader.Machine == EFI_IMAGE_MACHINE_IA64 && Hdr.Pe32->OptionalHeader.Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
+ return EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC;
+ }
+ //
+ // Return the magic value from the PC/COFF Optional Header
+ //
+ return Hdr.Pe32->OptionalHeader.Magic;
+}
+
+
+/**
+ Retrieves the PE or TE Header from a PE/COFF or TE image.
+
+ @param ImageContext The context of the image being loaded.
+ @param Hdr The buffer in which to return the PE32, PE32+, or TE header.
+
+ @retval RETURN_SUCCESS The PE or TE Header is read.
+ @retval Other The error status from reading the PE/COFF or TE image using the ImageRead function.
+
+**/
+RETURN_STATUS
+GluePeCoffLoaderGetPeHeader (
+ IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext,
+ OUT EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr
+ )
+{
+ RETURN_STATUS Status;
+ EFI_IMAGE_DOS_HEADER DosHdr;
+ UINTN Size;
+ UINT16 Magic;
+
+ //
+ // Read the DOS image header to check for it's existance
+ //
+ Size = sizeof (EFI_IMAGE_DOS_HEADER);
+ Status = ImageContext->ImageRead (
+ ImageContext->Handle,
+ 0,
+ &Size,
+ &DosHdr
+ );
+ if (RETURN_ERROR (Status)) {
+ ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ;
+ return Status;
+ }
+
+ ImageContext->PeCoffHeaderOffset = 0;
+ if (DosHdr.e_magic == EFI_IMAGE_DOS_SIGNATURE) {
+ //
+ // DOS image header is present, so read the PE header after the DOS image
+ // header
+ //
+ ImageContext->PeCoffHeaderOffset = DosHdr.e_lfanew;
+ }
+
+ //
+ // Read the PE/COFF Header. For PE32 (32-bit) this will read in too much
+ // data, but that should not hurt anythine. Hdr.Pe32->OptionalHeader.Magic
+ // determins if this is a PE32 or PE32+ image. The magic is in the same
+ // location in both images.
+ //
+ Size = sizeof (EFI_IMAGE_OPTIONAL_HEADER_UNION);
+ Status = ImageContext->ImageRead (
+ ImageContext->Handle,
+ ImageContext->PeCoffHeaderOffset,
+ &Size,
+ Hdr.Pe32
+ );
+ if (RETURN_ERROR (Status)) {
+ ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ;
+ return Status;
+ }
+
+ //
+ // Use Signature to figure out if we understand the image format
+ //
+ if (Hdr.Te->Signature == EFI_TE_IMAGE_HEADER_SIGNATURE) {
+ ImageContext->IsTeImage = TRUE;
+ ImageContext->Machine = Hdr.Te->Machine;
+ ImageContext->ImageType = (UINT16)(Hdr.Te->Subsystem);
+ ImageContext->ImageSize = 0;
+ ImageContext->SectionAlignment = 4096;
+ ImageContext->SizeOfHeaders = sizeof (EFI_TE_IMAGE_HEADER) + (UINTN)Hdr.Te->BaseOfCode - (UINTN)Hdr.Te->StrippedSize;
+
+ } else if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE) {
+ ImageContext->IsTeImage = FALSE;
+ ImageContext->Machine = Hdr.Pe32->FileHeader.Machine;
+
+ Magic = PeCoffLoaderGetPeHeaderMagicValue (Hdr);
+
+ if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
+ //
+ // Use PE32 offset
+ //
+ ImageContext->ImageType = Hdr.Pe32->OptionalHeader.Subsystem;
+ ImageContext->ImageSize = (UINT64)Hdr.Pe32->OptionalHeader.SizeOfImage;
+ ImageContext->SectionAlignment = Hdr.Pe32->OptionalHeader.SectionAlignment;
+ ImageContext->SizeOfHeaders = Hdr.Pe32->OptionalHeader.SizeOfHeaders;
+
+ } else if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC) {
+ //
+ // Use PE32+ offset
+ //
+ ImageContext->ImageType = Hdr.Pe32Plus->OptionalHeader.Subsystem;
+ ImageContext->ImageSize = (UINT64) Hdr.Pe32Plus->OptionalHeader.SizeOfImage;
+ ImageContext->SectionAlignment = Hdr.Pe32Plus->OptionalHeader.SectionAlignment;
+ ImageContext->SizeOfHeaders = Hdr.Pe32Plus->OptionalHeader.SizeOfHeaders;
+ } else {
+ ImageContext->ImageError = IMAGE_ERROR_INVALID_MACHINE_TYPE;
+ return RETURN_UNSUPPORTED;
+ }
+ } else {
+ ImageContext->ImageError = IMAGE_ERROR_INVALID_MACHINE_TYPE;
+ return RETURN_UNSUPPORTED;
+ }
+
+ if (!PeCoffLoaderImageFormatSupported (ImageContext->Machine)) {
+ //
+ // If the PE/COFF loader does not support the image type return
+ // unsupported. This library can suport lots of types of images
+ // this does not mean the user of this library can call the entry
+ // point of the image.
+ //
+ return RETURN_UNSUPPORTED;
+ }
+
+ return RETURN_SUCCESS;
+}
+
+
+/**
+ Retrieves information about a PE/COFF image.
+
+ Computes the PeCoffHeaderOffset, ImageAddress, ImageSize, DestinationAddress, CodeView,
+ PdbPointer, RelocationsStripped, SectionAlignment, SizeOfHeaders, and DebugDirectoryEntryRva
+ fields of the ImageContext structure. If ImageContext is NULL, then return RETURN_INVALID_PARAMETER.
+ If the PE/COFF image accessed through the ImageRead service in the ImageContext structure is not
+ a supported PE/COFF image type, then return RETURN_UNSUPPORTED. If any errors occur while
+ computing the fields of ImageContext, then the error status is returned in the ImageError field of
+ ImageContext.
+
+ @param ImageContext Pointer to the image context structure that describes the PE/COFF
+ image that needs to be examined by this function.
+
+ @retval RETURN_SUCCESS The information on the PE/COFF image was collected.
+ @retval RETURN_INVALID_PARAMETER ImageContext is NULL.
+ @retval RETURN_UNSUPPORTED The PE/COFF image is not supported.
+
+**/
+RETURN_STATUS
+EFIAPI
+GluePeCoffLoaderGetImageInfo (
+ IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
+ )
+{
+ RETURN_STATUS Status;
+ EFI_IMAGE_OPTIONAL_HEADER_UNION HdrData;
+ EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr;
+ EFI_IMAGE_DATA_DIRECTORY *DebugDirectoryEntry;
+ UINTN Size;
+ UINTN Index;
+ UINTN DebugDirectoryEntryRva;
+ UINTN DebugDirectoryEntryFileOffset;
+ UINTN SectionHeaderOffset;
+ EFI_IMAGE_SECTION_HEADER SectionHeader;
+ EFI_IMAGE_DEBUG_DIRECTORY_ENTRY DebugEntry;
+ UINT32 NumberOfRvaAndSizes;
+ UINT16 Magic;
+
+ if (NULL == ImageContext) {
+ return RETURN_INVALID_PARAMETER;
+ }
+ //
+ // Assume success
+ //
+ ImageContext->ImageError = IMAGE_ERROR_SUCCESS;
+
+ Hdr.Union = &HdrData;
+ Status = PeCoffLoaderGetPeHeader (ImageContext, Hdr);
+ if (RETURN_ERROR (Status)) {
+ return Status;
+ }
+
+ Magic = PeCoffLoaderGetPeHeaderMagicValue (Hdr);
+
+ //
+ // Retrieve the base address of the image
+ //
+ if (!(ImageContext->IsTeImage)) {
+ if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
+ //
+ // Use PE32 offset
+ //
+ ImageContext->ImageAddress = Hdr.Pe32->OptionalHeader.ImageBase;
+ } else {
+ //
+ // Use PE32+ offset
+ //
+ ImageContext->ImageAddress = Hdr.Pe32Plus->OptionalHeader.ImageBase;
+ }
+ } else {
+ ImageContext->ImageAddress = (PHYSICAL_ADDRESS)(Hdr.Te->ImageBase + Hdr.Te->StrippedSize - sizeof (EFI_TE_IMAGE_HEADER));
+ }
+
+ //
+ // Initialize the alternate destination address to 0 indicating that it
+ // should not be used.
+ //
+ ImageContext->DestinationAddress = 0;
+
+ //
+ // Initialize the codeview pointer.
+ //
+ ImageContext->CodeView = NULL;
+ ImageContext->PdbPointer = NULL;
+
+ //
+ // Three cases with regards to relocations:
+ // - Image has base relocs, RELOCS_STRIPPED==0 => image is relocatable
+ // - Image has no base relocs, RELOCS_STRIPPED==1 => Image is not relocatable
+ // - Image has no base relocs, RELOCS_STRIPPED==0 => Image is relocatable but
+ // has no base relocs to apply
+ // Obviously having base relocations with RELOCS_STRIPPED==1 is invalid.
+ //
+ // Look at the file header to determine if relocations have been stripped, and
+ // save this info in the image context for later use.
+ //
+ if ((!(ImageContext->IsTeImage)) && ((Hdr.Pe32->FileHeader.Characteristics & EFI_IMAGE_FILE_RELOCS_STRIPPED) != 0)) {
+ ImageContext->RelocationsStripped = TRUE;
+ } else {
+ ImageContext->RelocationsStripped = FALSE;
+ }
+
+ if (!(ImageContext->IsTeImage)) {
+ if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
+ //
+ // Use PE32 offset
+ //
+ NumberOfRvaAndSizes = Hdr.Pe32->OptionalHeader.NumberOfRvaAndSizes;
+ DebugDirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]);
+ } else {
+ //
+ // Use PE32+ offset
+ //
+ NumberOfRvaAndSizes = Hdr.Pe32Plus->OptionalHeader.NumberOfRvaAndSizes;
+ DebugDirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32Plus->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]);
+ }
+
+ if (NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_DEBUG) {
+
+ DebugDirectoryEntryRva = DebugDirectoryEntry->VirtualAddress;
+
+ //
+ // Determine the file offset of the debug directory... This means we walk
+ // the sections to find which section contains the RVA of the debug
+ // directory
+ //
+ DebugDirectoryEntryFileOffset = 0;
+
+ SectionHeaderOffset = (UINTN)(
+ ImageContext->PeCoffHeaderOffset +
+ sizeof (UINT32) +
+ sizeof (EFI_IMAGE_FILE_HEADER) +
+ Hdr.Pe32->FileHeader.SizeOfOptionalHeader
+ );
+
+ for (Index = 0; Index < Hdr.Pe32->FileHeader.NumberOfSections; Index++) {
+ //
+ // Read section header from file
+ //
+ Size = sizeof (EFI_IMAGE_SECTION_HEADER);
+ Status = ImageContext->ImageRead (
+ ImageContext->Handle,
+ SectionHeaderOffset,
+ &Size,
+ &SectionHeader
+ );
+ if (RETURN_ERROR (Status)) {
+ ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ;
+ return Status;
+ }
+
+ if (DebugDirectoryEntryRva >= SectionHeader.VirtualAddress &&
+ DebugDirectoryEntryRva < SectionHeader.VirtualAddress + SectionHeader.Misc.VirtualSize) {
+
+ DebugDirectoryEntryFileOffset = DebugDirectoryEntryRva - SectionHeader.VirtualAddress + SectionHeader.PointerToRawData;
+ break;
+ }
+
+ SectionHeaderOffset += sizeof (EFI_IMAGE_SECTION_HEADER);
+ }
+
+ if (DebugDirectoryEntryFileOffset != 0) {
+ for (Index = 0; Index < DebugDirectoryEntry->Size; Index += sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY)) {
+ //
+ // Read next debug directory entry
+ //
+ Size = sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY);
+ Status = ImageContext->ImageRead (
+ ImageContext->Handle,
+ DebugDirectoryEntryFileOffset,
+ &Size,
+ &DebugEntry
+ );
+ if (RETURN_ERROR (Status)) {
+ ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ;
+ return Status;
+ }
+ if (DebugEntry.Type == EFI_IMAGE_DEBUG_TYPE_CODEVIEW) {
+ ImageContext->DebugDirectoryEntryRva = (UINT32) (DebugDirectoryEntryRva + Index);
+ if (DebugEntry.RVA == 0 && DebugEntry.FileOffset != 0) {
+ ImageContext->ImageSize += DebugEntry.SizeOfData;
+ }
+
+ return RETURN_SUCCESS;
+ }
+ }
+ }
+ }
+ } else {
+
+ DebugDirectoryEntry = &Hdr.Te->DataDirectory[1];
+ DebugDirectoryEntryRva = DebugDirectoryEntry->VirtualAddress;
+ SectionHeaderOffset = (UINTN)(sizeof (EFI_TE_IMAGE_HEADER));
+
+ DebugDirectoryEntryFileOffset = 0;
+
+ for (Index = 0; Index < Hdr.Te->NumberOfSections;) {
+ //
+ // Read section header from file
+ //
+ Size = sizeof (EFI_IMAGE_SECTION_HEADER);
+ Status = ImageContext->ImageRead (
+ ImageContext->Handle,
+ SectionHeaderOffset,
+ &Size,
+ &SectionHeader
+ );
+ if (RETURN_ERROR (Status)) {
+ ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ;
+ return Status;
+ }
+
+ if (DebugDirectoryEntryRva >= SectionHeader.VirtualAddress &&
+ DebugDirectoryEntryRva < SectionHeader.VirtualAddress + SectionHeader.Misc.VirtualSize) {
+ DebugDirectoryEntryFileOffset = DebugDirectoryEntryRva -
+ SectionHeader.VirtualAddress +
+ SectionHeader.PointerToRawData +
+ sizeof (EFI_TE_IMAGE_HEADER) -
+ Hdr.Te->StrippedSize;
+
+ //
+ // File offset of the debug directory was found, if this is not the last
+ // section, then skip to the last section for calculating the image size.
+ //
+ if (Index < (UINTN) Hdr.Te->NumberOfSections - 1) {
+ SectionHeaderOffset += (Hdr.Te->NumberOfSections - 1 - Index) * sizeof (EFI_IMAGE_SECTION_HEADER);
+ Index = Hdr.Te->NumberOfSections - 1;
+ continue;
+ }
+ }
+
+ //
+ // In Te image header there is not a field to describe the ImageSize.
+ // Actually, the ImageSize equals the RVA plus the VirtualSize of
+ // the last section mapped into memory (Must be rounded up to
+ // a mulitple of Section Alignment). Per the PE/COFF specification, the
+ // section headers in the Section Table must appear in order of the RVA
+ // values for the corresponding sections. So the ImageSize can be determined
+ // by the RVA and the VirtualSize of the last section header in the
+ // Section Table.
+ //
+ if ((++Index) == (UINTN)Hdr.Te->NumberOfSections) {
+ ImageContext->ImageSize = (SectionHeader.VirtualAddress + SectionHeader.Misc.VirtualSize +
+ ImageContext->SectionAlignment - 1) & ~(ImageContext->SectionAlignment - 1);
+ }
+
+ SectionHeaderOffset += sizeof (EFI_IMAGE_SECTION_HEADER);
+ }
+
+ if (DebugDirectoryEntryFileOffset != 0) {
+ for (Index = 0; Index < DebugDirectoryEntry->Size; Index += sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY)) {
+ //
+ // Read next debug directory entry
+ //
+ Size = sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY);
+ Status = ImageContext->ImageRead (
+ ImageContext->Handle,
+ DebugDirectoryEntryFileOffset,
+ &Size,
+ &DebugEntry
+ );
+ if (RETURN_ERROR (Status)) {
+ ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ;
+ return Status;
+ }
+
+ if (DebugEntry.Type == EFI_IMAGE_DEBUG_TYPE_CODEVIEW) {
+ ImageContext->DebugDirectoryEntryRva = (UINT32) (DebugDirectoryEntryRva + Index);
+ return RETURN_SUCCESS;
+ }
+ }
+ }
+ }
+
+ return RETURN_SUCCESS;
+}
+
+
+/**
+ Converts an image address to the loaded address.
+
+ @param ImageContext The context of the image being loaded.
+ @param Address The address to be converted to the loaded address.
+
+ @return The converted address or NULL if the address can not be converted.
+
+**/
+VOID *
+GluePeCoffLoaderImageAddress (
+ IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext,
+ IN UINTN Address
+ )
+{
+ //
+ // @bug Check to make sure ImageSize is correct for the relocated image.
+ // it may only work for the file we start with and not the relocated image
+ //
+ if (Address >= ImageContext->ImageSize) {
+ ImageContext->ImageError = IMAGE_ERROR_INVALID_IMAGE_ADDRESS;
+ return NULL;
+ }
+
+ return (CHAR8 *)((UINTN) ImageContext->ImageAddress + Address);
+}
+
+/**
+ Applies relocation fixups to a PE/COFF image that was loaded with PeCoffLoaderLoadImage().
+
+ If the DestinationAddress field of ImageContext is 0, then use the ImageAddress field of
+ ImageContext as the relocation base address. Otherwise, use the DestinationAddress field
+ of ImageContext as the relocation base address. The caller must allocate the relocation
+ fixup log buffer and fill in the FixupData field of ImageContext prior to calling this function.
+ If ImageContext is NULL, then ASSERT().
+
+ @param ImageContext Pointer to the image context structure that describes the PE/COFF
+ image that is being relocated.
+
+ @retval RETURN_SUCCESS The PE/COFF image was relocated.
+ Extended status information is in the ImageError field of ImageContext.
+ @retval RETURN_LOAD_ERROR The image in not a valid PE/COFF image.
+ Extended status information is in the ImageError field of ImageContext.
+ @retval RETURN_UNSUPPORTED A relocation record type is not supported.
+ Extended status information is in the ImageError field of ImageContext.
+
+**/
+RETURN_STATUS
+EFIAPI
+GluePeCoffLoaderRelocateImage (
+ IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
+ )
+{
+ RETURN_STATUS Status;
+ EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr;
+ EFI_IMAGE_DATA_DIRECTORY *RelocDir;
+ UINT64 Adjust;
+ EFI_IMAGE_BASE_RELOCATION *RelocBase;
+ EFI_IMAGE_BASE_RELOCATION *RelocBaseEnd;
+ UINT16 *Reloc;
+ UINT16 *RelocEnd;
+ CHAR8 *Fixup;
+ CHAR8 *FixupBase;
+ UINT16 *F16;
+ UINT32 *F32;
+ UINT64 *F64;
+ CHAR8 *FixupData;
+ PHYSICAL_ADDRESS BaseAddress;
+ UINT32 NumberOfRvaAndSizes;
+ UINT16 Magic;
+
+ ASSERT (ImageContext != NULL);
+
+ //
+ // Assume success
+ //
+ ImageContext->ImageError = IMAGE_ERROR_SUCCESS;
+
+ //
+ // If there are no relocation entries, then we are done
+ //
+ if (ImageContext->RelocationsStripped) {
+ return RETURN_SUCCESS;
+ }
+
+ //
+ // If the destination address is not 0, use that rather than the
+ // image address as the relocation target.
+ //
+ if (ImageContext->DestinationAddress != 0) {
+ BaseAddress = ImageContext->DestinationAddress;
+ } else if (!(ImageContext->IsTeImage)) {
+ BaseAddress = ImageContext->ImageAddress;
+ } else {
+ Hdr.Te = (EFI_TE_IMAGE_HEADER *)(UINTN)(ImageContext->ImageAddress);
+ BaseAddress = ImageContext->ImageAddress + sizeof (EFI_TE_IMAGE_HEADER) - Hdr.Te->StrippedSize;
+ }
+
+ if (!(ImageContext->IsTeImage)) {
+ Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINTN)ImageContext->ImageAddress + ImageContext->PeCoffHeaderOffset);
+
+ Magic = PeCoffLoaderGetPeHeaderMagicValue (Hdr);
+
+ if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
+ //
+ // Use PE32 offset
+ //
+ Adjust = (UINT64)BaseAddress - Hdr.Pe32->OptionalHeader.ImageBase;
+ Hdr.Pe32->OptionalHeader.ImageBase = (UINT32)BaseAddress;
+
+ NumberOfRvaAndSizes = Hdr.Pe32->OptionalHeader.NumberOfRvaAndSizes;
+ RelocDir = &Hdr.Pe32->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC];
+ } else {
+ //
+ // Use PE32+ offset
+ //
+ Adjust = (UINT64) BaseAddress - Hdr.Pe32Plus->OptionalHeader.ImageBase;
+ Hdr.Pe32Plus->OptionalHeader.ImageBase = (UINT64)BaseAddress;
+
+ NumberOfRvaAndSizes = Hdr.Pe32Plus->OptionalHeader.NumberOfRvaAndSizes;
+ RelocDir = &Hdr.Pe32Plus->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC];
+ }
+
+ //
+ // Find the relocation block
+ // Per the PE/COFF spec, you can't assume that a given data directory
+ // is present in the image. You have to check the NumberOfRvaAndSizes in
+ // the optional header to verify a desired directory entry is there.
+ //
+
+ if (NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC && RelocDir->Size > 0) {
+ RelocBase = PeCoffLoaderImageAddress (ImageContext, RelocDir->VirtualAddress);
+ RelocBaseEnd = PeCoffLoaderImageAddress (
+ ImageContext,
+ RelocDir->VirtualAddress + RelocDir->Size - 1
+ );
+ if ((RelocBase == NULL) || (RelocBaseEnd == NULL)) {
+ //
+ // If the base start or end address resolved to 0, then fail.
+ //
+ return RETURN_LOAD_ERROR;
+ }
+ } else {
+ //
+ // Set base and end to bypass processing below.
+ //
+ RelocBase = RelocBaseEnd = 0;
+ }
+ } else {
+ Hdr.Te = (EFI_TE_IMAGE_HEADER *)(UINTN)(ImageContext->ImageAddress);
+ Adjust = (UINT64) (BaseAddress - Hdr.Te->ImageBase);
+ Hdr.Te->ImageBase = (UINT64) (BaseAddress);
+
+ //
+ // Find the relocation block
+ //
+ RelocDir = &Hdr.Te->DataDirectory[0];
+ if (RelocDir->Size > 0) {
+ RelocBase = (EFI_IMAGE_BASE_RELOCATION *)(UINTN)(
+ ImageContext->ImageAddress +
+ RelocDir->VirtualAddress +
+ sizeof(EFI_TE_IMAGE_HEADER) -
+ Hdr.Te->StrippedSize
+ );
+ RelocBaseEnd = (EFI_IMAGE_BASE_RELOCATION *) ((UINTN) RelocBase + (UINTN) RelocDir->Size - 1);
+ } else {
+ //
+ // Set base and end to bypass processing below.
+ //
+ RelocBase = RelocBaseEnd = 0;
+ }
+ }
+
+ //
+ // Run the relocation information and apply the fixups
+ //
+ FixupData = ImageContext->FixupData;
+ while (RelocBase < RelocBaseEnd) {
+
+ Reloc = (UINT16 *) ((CHAR8 *) RelocBase + sizeof (EFI_IMAGE_BASE_RELOCATION));
+ RelocEnd = (UINT16 *) ((CHAR8 *) RelocBase + RelocBase->SizeOfBlock);
+ if (!(ImageContext->IsTeImage)) {
+ FixupBase = PeCoffLoaderImageAddress (ImageContext, RelocBase->VirtualAddress);
+
+ if (FixupBase == NULL) {
+ //
+ // If the FixupBase address resolved to 0, then fail.
+ //
+ return RETURN_LOAD_ERROR;
+ }
+
+ } else {
+ FixupBase = (CHAR8 *)(UINTN)(ImageContext->ImageAddress +
+ RelocBase->VirtualAddress +
+ sizeof(EFI_TE_IMAGE_HEADER) -
+ Hdr.Te->StrippedSize
+ );
+ }
+
+ if ((CHAR8 *) RelocEnd < (CHAR8 *) ((UINTN) ImageContext->ImageAddress) ||
+ (CHAR8 *) RelocEnd > (CHAR8 *)((UINTN)ImageContext->ImageAddress +
+ (UINTN)ImageContext->ImageSize)) {
+ ImageContext->ImageError = IMAGE_ERROR_FAILED_RELOCATION;
+ return RETURN_LOAD_ERROR;
+ }
+
+ //
+ // Run this relocation record
+ //
+ while (Reloc < RelocEnd) {
+
+ Fixup = FixupBase + (*Reloc & 0xFFF);
+ switch ((*Reloc) >> 12) {
+ case EFI_IMAGE_REL_BASED_ABSOLUTE:
+ break;
+
+ case EFI_IMAGE_REL_BASED_HIGH:
+ F16 = (UINT16 *) Fixup;
+ *F16 = (UINT16) (*F16 + ((UINT16) ((UINT32) Adjust >> 16)));
+ if (FixupData != NULL) {
+ *(UINT16 *) FixupData = *F16;
+ FixupData = FixupData + sizeof (UINT16);
+ }
+ break;
+
+ case EFI_IMAGE_REL_BASED_LOW:
+ F16 = (UINT16 *) Fixup;
+ *F16 = (UINT16) (*F16 + (UINT16) Adjust);
+ if (FixupData != NULL) {
+ *(UINT16 *) FixupData = *F16;
+ FixupData = FixupData + sizeof (UINT16);
+ }
+ break;
+
+ case EFI_IMAGE_REL_BASED_HIGHLOW:
+ F32 = (UINT32 *) Fixup;
+ *F32 = *F32 + (UINT32) Adjust;
+ if (FixupData != NULL) {
+ FixupData = ALIGN_POINTER (FixupData, sizeof (UINT32));
+ *(UINT32 *)FixupData = *F32;
+ FixupData = FixupData + sizeof (UINT32);
+ }
+ break;
+
+ case EFI_IMAGE_REL_BASED_DIR64:
+ F64 = (UINT64 *) Fixup;
+ *F64 = *F64 + (UINT64) Adjust;
+ if (FixupData != NULL) {
+ FixupData = ALIGN_POINTER (FixupData, sizeof(UINT64));
+ *(UINT64 *)(FixupData) = *F64;
+ FixupData = FixupData + sizeof(UINT64);
+ }
+ break;
+
+ default:
+ //
+ // The common code does not handle some of the stranger IPF relocations
+ // PeCoffLoaderRelocateImageEx () addes support for these complex fixups
+ // on IPF and is a No-Op on other archtiectures.
+ //
+ Status = PeCoffLoaderRelocateImageEx (Reloc, Fixup, &FixupData, Adjust);
+ if (RETURN_ERROR (Status)) {
+ ImageContext->ImageError = IMAGE_ERROR_FAILED_RELOCATION;
+ return Status;
+ }
+ }
+
+ //
+ // Next relocation record
+ //
+ Reloc += 1;
+ }
+
+ //
+ // Next reloc block
+ //
+ RelocBase = (EFI_IMAGE_BASE_RELOCATION *) RelocEnd;
+ }
+
+ return RETURN_SUCCESS;
+}
+
+/**
+ Loads a PE/COFF image into memory.
+
+ Loads the PE/COFF image accessed through the ImageRead service of ImageContext into the buffer
+ specified by the ImageAddress and ImageSize fields of ImageContext. The caller must allocate
+ the load buffer and fill in the ImageAddress and ImageSize fields prior to calling this function.
+ The EntryPoint, FixupDataSize, CodeView, and PdbPointer fields of ImageContext are computed.
+ If ImageContext is NULL, then ASSERT().
+
+ @param ImageContext Pointer to the image context structure that describes the PE/COFF
+ image that is being loaded.
+
+ @retval RETURN_SUCCESS The PE/COFF image was loaded into the buffer specified by
+ the ImageAddress and ImageSize fields of ImageContext.
+ Extended status information is in the ImageError field of ImageContext.
+ @retval RETURN_BUFFER_TOO_SMALL The caller did not provide a large enough buffer.
+ Extended status information is in the ImageError field of ImageContext.
+ @retval RETURN_LOAD_ERROR The PE/COFF image is an EFI Runtime image with no relocations.
+ Extended status information is in the ImageError field of ImageContext.
+ @retval RETURN_INVALID_PARAMETER The image address is invalid.
+ Extended status information is in the ImageError field of ImageContext.
+
+**/
+RETURN_STATUS
+EFIAPI
+GluePeCoffLoaderLoadImage (
+ IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
+ )
+{
+ RETURN_STATUS Status;
+ EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr;
+ PE_COFF_LOADER_IMAGE_CONTEXT CheckContext;
+ EFI_IMAGE_SECTION_HEADER *FirstSection;
+ EFI_IMAGE_SECTION_HEADER *Section;
+ UINTN NumberOfSections;
+ UINTN Index;
+ CHAR8 *Base;
+ CHAR8 *End;
+ CHAR8 *MaxEnd;
+ EFI_IMAGE_DATA_DIRECTORY *DirectoryEntry;
+ EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *DebugEntry;
+ UINTN Size;
+ UINT32 TempDebugEntryRva;
+ UINT32 NumberOfRvaAndSizes;
+ UINT16 Magic;
+
+ ASSERT (ImageContext != NULL);
+
+ //
+ // Assume success
+ //
+ ImageContext->ImageError = IMAGE_ERROR_SUCCESS;
+
+ //
+ // Copy the provided context info into our local version, get what we
+ // can from the original image, and then use that to make sure everything
+ // is legit.
+ //
+ CopyMem (&CheckContext, ImageContext, sizeof (PE_COFF_LOADER_IMAGE_CONTEXT));
+
+ Status = PeCoffLoaderGetImageInfo (&CheckContext);
+ if (RETURN_ERROR (Status)) {
+ return Status;
+ }
+
+ //
+ // Make sure there is enough allocated space for the image being loaded
+ //
+ if (ImageContext->ImageSize < CheckContext.ImageSize) {
+ ImageContext->ImageError = IMAGE_ERROR_INVALID_IMAGE_SIZE;
+ return RETURN_BUFFER_TOO_SMALL;
+ }
+ if (ImageContext->ImageAddress == 0) {
+ //
+ // Image cannot be loaded into 0 address.
+ //
+ ImageContext->ImageError = IMAGE_ERROR_INVALID_IMAGE_ADDRESS;
+ return RETURN_INVALID_PARAMETER;
+ }
+ //
+ // If there's no relocations, then make sure it's not a runtime driver,
+ // and that it's being loaded at the linked address.
+ //
+ if (CheckContext.RelocationsStripped) {
+ //
+ // If the image does not contain relocations and it is a runtime driver
+ // then return an error.
+ //
+ if (CheckContext.ImageType == EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER) {
+ ImageContext->ImageError = IMAGE_ERROR_INVALID_SUBSYSTEM;
+ return RETURN_LOAD_ERROR;
+ }
+ //
+ // If the image does not contain relocations, and the requested load address
+ // is not the linked address, then return an error.
+ //
+ if (CheckContext.ImageAddress != ImageContext->ImageAddress) {
+ ImageContext->ImageError = IMAGE_ERROR_INVALID_IMAGE_ADDRESS;
+ return RETURN_INVALID_PARAMETER;
+ }
+ }
+ //
+ // Make sure the allocated space has the proper section alignment
+ //
+ if (!(ImageContext->IsTeImage)) {
+ if ((ImageContext->ImageAddress & (CheckContext.SectionAlignment - 1)) != 0) {
+ ImageContext->ImageError = IMAGE_ERROR_INVALID_SECTION_ALIGNMENT;
+ return RETURN_INVALID_PARAMETER;
+ }
+ }
+ //
+ // Read the entire PE/COFF or TE header into memory
+ //
+ if (!(ImageContext->IsTeImage)) {
+ Status = ImageContext->ImageRead (
+ ImageContext->Handle,
+ 0,
+ &ImageContext->SizeOfHeaders,
+ (VOID *) (UINTN) ImageContext->ImageAddress
+ );
+
+ Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINTN)ImageContext->ImageAddress + ImageContext->PeCoffHeaderOffset);
+
+ FirstSection = (EFI_IMAGE_SECTION_HEADER *) (
+ (UINTN)ImageContext->ImageAddress +
+ ImageContext->PeCoffHeaderOffset +
+ sizeof(UINT32) +
+ sizeof(EFI_IMAGE_FILE_HEADER) +
+ Hdr.Pe32->FileHeader.SizeOfOptionalHeader
+ );
+ NumberOfSections = (UINTN) (Hdr.Pe32->FileHeader.NumberOfSections);
+ } else {
+ Status = ImageContext->ImageRead (
+ ImageContext->Handle,
+ 0,
+ &ImageContext->SizeOfHeaders,
+ (void *)(UINTN)ImageContext->ImageAddress
+ );
+
+ Hdr.Te = (EFI_TE_IMAGE_HEADER *)(UINTN)(ImageContext->ImageAddress);
+
+ FirstSection = (EFI_IMAGE_SECTION_HEADER *) (
+ (UINTN)ImageContext->ImageAddress +
+ sizeof(EFI_TE_IMAGE_HEADER)
+ );
+ NumberOfSections = (UINTN) (Hdr.Te->NumberOfSections);
+
+ }
+
+ if (RETURN_ERROR (Status)) {
+ ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ;
+ return RETURN_LOAD_ERROR;
+ }
+
+ //
+ // Load each section of the image
+ //
+ Section = FirstSection;
+ for (Index = 0, MaxEnd = NULL; Index < NumberOfSections; Index++) {
+
+ //
+ // Compute sections address
+ //
+ Base = PeCoffLoaderImageAddress (ImageContext, Section->VirtualAddress);
+ End = PeCoffLoaderImageAddress (
+ ImageContext,
+ Section->VirtualAddress + Section->Misc.VirtualSize - 1
+ );
+ if (ImageContext->IsTeImage) {
+ Base = (CHAR8 *)((UINTN) Base + sizeof (EFI_TE_IMAGE_HEADER) - (UINTN)Hdr.Te->StrippedSize);
+ End = (CHAR8 *)((UINTN) End + sizeof (EFI_TE_IMAGE_HEADER) - (UINTN)Hdr.Te->StrippedSize);
+ }
+
+ if (End > MaxEnd) {
+ MaxEnd = End;
+ }
+ //
+ // If the base start or end address resolved to 0, then fail.
+ //
+ if ((Base == NULL) || (End == NULL)) {
+ ImageContext->ImageError = IMAGE_ERROR_SECTION_NOT_LOADED;
+ return RETURN_LOAD_ERROR;
+ }
+
+ //
+ // Read the section
+ //
+ Size = (UINTN) Section->Misc.VirtualSize;
+ if ((Size == 0) || (Size > Section->SizeOfRawData)) {
+ Size = (UINTN) Section->SizeOfRawData;
+ }
+
+ if (Section->SizeOfRawData) {
+ if (!(ImageContext->IsTeImage)) {
+ Status = ImageContext->ImageRead (
+ ImageContext->Handle,
+ Section->PointerToRawData,
+ &Size,
+ Base
+ );
+ } else {
+ Status = ImageContext->ImageRead (
+ ImageContext->Handle,
+ Section->PointerToRawData + sizeof (EFI_TE_IMAGE_HEADER) - (UINTN)Hdr.Te->StrippedSize,
+ &Size,
+ Base
+ );
+ }
+
+ if (RETURN_ERROR (Status)) {
+ ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ;
+ return Status;
+ }
+ }
+
+ //
+ // If raw size is less then virt size, zero fill the remaining
+ //
+
+ if (Size < Section->Misc.VirtualSize) {
+ ZeroMem (Base + Size, Section->Misc.VirtualSize - Size);
+ }
+
+ //
+ // Next Section
+ //
+ Section += 1;
+ }
+
+ //
+ // Get image's entry point
+ //
+ Magic = PeCoffLoaderGetPeHeaderMagicValue (Hdr);
+ if (!(ImageContext->IsTeImage)) {
+ //
+ // Sizes of AddressOfEntryPoint are different so we need to do this safely
+ //
+ if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
+ //
+ // Use PE32 offset
+ //
+ ImageContext->EntryPoint = (PHYSICAL_ADDRESS)(UINTN)PeCoffLoaderImageAddress (
+ ImageContext,
+ (UINTN)Hdr.Pe32->OptionalHeader.AddressOfEntryPoint
+ );
+ } else {
+ //
+ // Use PE32+ offset
+ //
+ ImageContext->EntryPoint = (PHYSICAL_ADDRESS)(UINTN)PeCoffLoaderImageAddress (
+ ImageContext,
+ (UINTN)Hdr.Pe32Plus->OptionalHeader.AddressOfEntryPoint
+ );
+ }
+ } else {
+ ImageContext->EntryPoint = (PHYSICAL_ADDRESS) (
+ (UINTN)ImageContext->ImageAddress +
+ (UINTN)Hdr.Te->AddressOfEntryPoint +
+ (UINTN)sizeof(EFI_TE_IMAGE_HEADER) -
+ (UINTN)Hdr.Te->StrippedSize
+ );
+ }
+
+ //
+ // Determine the size of the fixup data
+ //
+ // Per the PE/COFF spec, you can't assume that a given data directory
+ // is present in the image. You have to check the NumberOfRvaAndSizes in
+ // the optional header to verify a desired directory entry is there.
+ //
+ if (!(ImageContext->IsTeImage)) {
+ if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
+ //
+ // Use PE32 offset
+ //
+ NumberOfRvaAndSizes = Hdr.Pe32->OptionalHeader.NumberOfRvaAndSizes;
+ DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&Hdr.Pe32->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC];
+ } else {
+ //
+ // Use PE32+ offset
+ //
+ NumberOfRvaAndSizes = Hdr.Pe32Plus->OptionalHeader.NumberOfRvaAndSizes;
+ DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&Hdr.Pe32Plus->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC];
+ }
+
+ if (NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC) {
+ ImageContext->FixupDataSize = DirectoryEntry->Size / sizeof (UINT16) * sizeof (UINTN);
+ } else {
+ ImageContext->FixupDataSize = 0;
+ }
+ } else {
+ DirectoryEntry = &Hdr.Te->DataDirectory[0];
+ ImageContext->FixupDataSize = DirectoryEntry->Size / sizeof (UINT16) * sizeof (UINTN);
+ }
+ //
+ // Consumer must allocate a buffer for the relocation fixup log.
+ // Only used for runtime drivers.
+ //
+ ImageContext->FixupData = NULL;
+
+ //
+ // Load the Codeview info if present
+ //
+ if (ImageContext->DebugDirectoryEntryRva != 0) {
+ if (!(ImageContext->IsTeImage)) {
+ DebugEntry = PeCoffLoaderImageAddress (
+ ImageContext,
+ ImageContext->DebugDirectoryEntryRva
+ );
+ } else {
+ DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *)(UINTN)(
+ ImageContext->ImageAddress +
+ ImageContext->DebugDirectoryEntryRva +
+ sizeof(EFI_TE_IMAGE_HEADER) -
+ Hdr.Te->StrippedSize
+ );
+ }
+
+ if (DebugEntry != NULL) {
+ TempDebugEntryRva = DebugEntry->RVA;
+ if (DebugEntry->RVA == 0 && DebugEntry->FileOffset != 0) {
+ Section--;
+ if ((UINTN)Section->SizeOfRawData < Section->Misc.VirtualSize) {
+ TempDebugEntryRva = Section->VirtualAddress + Section->Misc.VirtualSize;
+ } else {
+ TempDebugEntryRva = Section->VirtualAddress + Section->SizeOfRawData;
+ }
+ }
+
+ if (TempDebugEntryRva != 0) {
+ if (!(ImageContext->IsTeImage)) {
+ ImageContext->CodeView = PeCoffLoaderImageAddress (ImageContext, TempDebugEntryRva);
+ } else {
+ ImageContext->CodeView = (VOID *)(
+ (UINTN)ImageContext->ImageAddress +
+ (UINTN)TempDebugEntryRva +
+ (UINTN)sizeof (EFI_TE_IMAGE_HEADER) -
+ (UINTN) Hdr.Te->StrippedSize
+ );
+ }
+
+ if (ImageContext->CodeView == NULL) {
+ ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ;
+ return RETURN_LOAD_ERROR;
+ }
+
+ if (DebugEntry->RVA == 0) {
+ Size = DebugEntry->SizeOfData;
+ if (!(ImageContext->IsTeImage)) {
+ Status = ImageContext->ImageRead (
+ ImageContext->Handle,
+ DebugEntry->FileOffset,
+ &Size,
+ ImageContext->CodeView
+ );
+ } else {
+ Status = ImageContext->ImageRead (
+ ImageContext->Handle,
+ DebugEntry->FileOffset + sizeof (EFI_TE_IMAGE_HEADER) - Hdr.Te->StrippedSize,
+ &Size,
+ ImageContext->CodeView
+ );
+ //
+ // Should we apply fix up to this field according to the size difference between PE and TE?
+ // Because now we maintain TE header fields unfixed, this field will also remain as they are
+ // in original PE image.
+ //
+ }
+
+ if (RETURN_ERROR (Status)) {
+ ImageContext->ImageError = IMAGE_ERROR_IMAGE_READ;
+ return RETURN_LOAD_ERROR;
+ }
+
+ DebugEntry->RVA = TempDebugEntryRva;
+ }
+
+ switch (*(UINT32 *) ImageContext->CodeView) {
+ case CODEVIEW_SIGNATURE_NB10:
+ ImageContext->PdbPointer = (CHAR8 *)ImageContext->CodeView + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY);
+ break;
+
+ case CODEVIEW_SIGNATURE_RSDS:
+ ImageContext->PdbPointer = (CHAR8 *)ImageContext->CodeView + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY);
+ break;
+
+ default:
+ break;
+ }
+ }
+ }
+ }
+
+ return Status;
+}
+
+
+/**
+ Reapply fixups on a fixed up PE32/PE32+ image to allow virutal calling at EFI
+ runtime.
+
+ PE_COFF_LOADER_IMAGE_CONTEXT.FixupData stores information needed to reapply
+ the fixups with a virtual mapping.
+
+
+ @param ImageBase Base address of relocated image
+ @param VirtImageBase Virtual mapping for ImageBase
+ @param ImageSize Size of the image to relocate
+ @param RelocationData Location to place results of read
+
+**/
+VOID
+EFIAPI
+PeCoffLoaderRelocateImageForRuntime (
+ IN PHYSICAL_ADDRESS ImageBase,
+ IN PHYSICAL_ADDRESS VirtImageBase,
+ IN UINTN ImageSize,
+ IN VOID *RelocationData
+ )
+{
+ CHAR8 *OldBase;
+ CHAR8 *NewBase;
+ EFI_IMAGE_DOS_HEADER *DosHdr;
+ EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr;
+ UINT32 NumberOfRvaAndSizes;
+ EFI_IMAGE_DATA_DIRECTORY *DataDirectory;
+ EFI_IMAGE_DATA_DIRECTORY *RelocDir;
+ EFI_IMAGE_BASE_RELOCATION *RelocBase;
+ EFI_IMAGE_BASE_RELOCATION *RelocBaseEnd;
+ UINT16 *Reloc;
+ UINT16 *RelocEnd;
+ CHAR8 *Fixup;
+ CHAR8 *FixupBase;
+ UINT16 *F16;
+ UINT32 *F32;
+ UINT64 *F64;
+ CHAR8 *FixupData;
+ UINTN Adjust;
+ RETURN_STATUS Status;
+ UINT16 Magic;
+
+ OldBase = (CHAR8 *)((UINTN)ImageBase);
+ NewBase = (CHAR8 *)((UINTN)VirtImageBase);
+ Adjust = (UINTN) NewBase - (UINTN) OldBase;
+
+ //
+ // Find the image's relocate dir info
+ //
+ DosHdr = (EFI_IMAGE_DOS_HEADER *)OldBase;
+ if (DosHdr->e_magic == EFI_IMAGE_DOS_SIGNATURE) {
+ //
+ // Valid DOS header so get address of PE header
+ //
+ Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)(((CHAR8 *)DosHdr) + DosHdr->e_lfanew);
+ } else {
+ //
+ // No Dos header so assume image starts with PE header.
+ //
+ Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)OldBase;
+ }
+
+ if (Hdr.Pe32->Signature != EFI_IMAGE_NT_SIGNATURE) {
+ //
+ // Not a valid PE image so Exit
+ //
+ return ;
+ }
+
+ Magic = PeCoffLoaderGetPeHeaderMagicValue (Hdr);
+
+ if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
+ //
+ // Use PE32 offset
+ //
+ NumberOfRvaAndSizes = Hdr.Pe32->OptionalHeader.NumberOfRvaAndSizes;
+ DataDirectory = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32->OptionalHeader.DataDirectory[0]);
+ } else {
+ //
+ // Use PE32+ offset
+ //
+ NumberOfRvaAndSizes = Hdr.Pe32Plus->OptionalHeader.NumberOfRvaAndSizes;
+ DataDirectory = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32Plus->OptionalHeader.DataDirectory[0]);
+ }
+
+ //
+ // Find the relocation block
+ //
+ // Per the PE/COFF spec, you can't assume that a given data directory
+ // is present in the image. You have to check the NumberOfRvaAndSizes in
+ // the optional header to verify a desired directory entry is there.
+ //
+ if (NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC) {
+ RelocDir = DataDirectory + EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC;
+ RelocBase = (EFI_IMAGE_BASE_RELOCATION *)(UINTN)(ImageBase + RelocDir->VirtualAddress);
+ RelocBaseEnd = (EFI_IMAGE_BASE_RELOCATION *)(UINTN)(ImageBase + RelocDir->VirtualAddress + RelocDir->Size);
+ } else {
+ //
+ // Cannot find relocations, cannot continue
+ //
+ ASSERT (FALSE);
+ return ;
+ }
+
+ ASSERT (RelocBase != NULL && RelocBaseEnd != NULL);
+
+ //
+ // Run the whole relocation block. And re-fixup data that has not been
+ // modified. The FixupData is used to see if the image has been modified
+ // since it was relocated. This is so data sections that have been updated
+ // by code will not be fixed up, since that would set them back to
+ // defaults.
+ //
+ FixupData = RelocationData;
+ while (RelocBase < RelocBaseEnd) {
+
+ Reloc = (UINT16 *) ((UINT8 *) RelocBase + sizeof (EFI_IMAGE_BASE_RELOCATION));
+ RelocEnd = (UINT16 *) ((UINT8 *) RelocBase + RelocBase->SizeOfBlock);
+ FixupBase = (CHAR8 *) ((UINTN)ImageBase) + RelocBase->VirtualAddress;
+
+ //
+ // Run this relocation record
+ //
+ while (Reloc < RelocEnd) {
+
+ Fixup = FixupBase + (*Reloc & 0xFFF);
+ switch ((*Reloc) >> 12) {
+
+ case EFI_IMAGE_REL_BASED_ABSOLUTE:
+ break;
+
+ case EFI_IMAGE_REL_BASED_HIGH:
+ F16 = (UINT16 *) Fixup;
+ if (*(UINT16 *) FixupData == *F16) {
+ *F16 = (UINT16) (*F16 + ((UINT16) ((UINT32) Adjust >> 16)));
+ }
+
+ FixupData = FixupData + sizeof (UINT16);
+ break;
+
+ case EFI_IMAGE_REL_BASED_LOW:
+ F16 = (UINT16 *) Fixup;
+ if (*(UINT16 *) FixupData == *F16) {
+ *F16 = (UINT16) (*F16 + ((UINT16) Adjust & 0xffff));
+ }
+
+ FixupData = FixupData + sizeof (UINT16);
+ break;
+
+ case EFI_IMAGE_REL_BASED_HIGHLOW:
+ F32 = (UINT32 *) Fixup;
+ FixupData = ALIGN_POINTER (FixupData, sizeof (UINT32));
+ if (*(UINT32 *) FixupData == *F32) {
+ *F32 = *F32 + (UINT32) Adjust;
+ }
+
+ FixupData = FixupData + sizeof (UINT32);
+ break;
+
+ case EFI_IMAGE_REL_BASED_DIR64:
+ F64 = (UINT64 *)Fixup;
+ FixupData = ALIGN_POINTER (FixupData, sizeof (UINT64));
+ if (*(UINT64 *) FixupData == *F64) {
+ *F64 = *F64 + (UINT64)Adjust;
+ }
+
+ FixupData = FixupData + sizeof (UINT64);
+ break;
+
+ case EFI_IMAGE_REL_BASED_HIGHADJ:
+ //
+ // Not implemented, but not used in EFI 1.0
+ //
+ ASSERT (FALSE);
+ break;
+
+ default:
+ //
+ // Only Itanium requires ConvertPeImage_Ex
+ //
+ Status = PeHotRelocateImageEx (Reloc, Fixup, &FixupData, Adjust);
+ if (RETURN_ERROR (Status)) {
+ return ;
+ }
+ }
+ //
+ // Next relocation record
+ //
+ Reloc += 1;
+ }
+ //
+ // next reloc block
+ //
+ RelocBase = (EFI_IMAGE_BASE_RELOCATION *) RelocEnd;
+ }
+}
+
+
+/**
+ ImageRead function that operates on a memory buffer whos base is passed into
+ FileHandle.
+
+ @param FileHandle Ponter to baes of the input stream
+ @param FileOffset Offset to the start of the buffer
+ @param ReadSize Number of bytes to copy into the buffer
+ @param Buffer Location to place results of read
+
+ @retval RETURN_SUCCESS Data is read from FileOffset from the Handle into
+ the buffer.
+**/
+RETURN_STATUS
+EFIAPI
+PeCoffLoaderImageReadFromMemory (
+ IN VOID *FileHandle,
+ IN UINTN FileOffset,
+ IN OUT UINTN *ReadSize,
+ OUT VOID *Buffer
+ )
+{
+ CopyMem (Buffer, ((UINT8 *)FileHandle) + FileOffset, *ReadSize);
+ return RETURN_SUCCESS;
+}
+
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/BasePeCoffLib.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/BasePeCoffLib.inf
new file mode 100644
index 0000000..cca4a8c
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/BasePeCoffLib.inf
@@ -0,0 +1,81 @@
+#/*++
+#
+# Copyright (c) 2004 - 2006, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# BasePeCoffLib.inf
+#
+# Abstract:
+#
+# Component description file for BasePeCoffLib.
+#
+#--*/
+
+[defines]
+BASE_NAME = EdkIIGlueBasePeCoffLib
+COMPONENT_TYPE = LIBRARY
+
+[sources.common]
+ BasePeCoff.c
+
+[sources.ia32]
+ Ia32\PeCoffLoaderEx.c
+
+[sources.x64]
+ X64\PeCoffLoaderEx.c
+
+[sources.ipf]
+
+
+[sources.ebc]
+
+
+[includes.common]
+ .
+ ..\..\Include
+ ..\..\include\Library
+ $(EDK_SOURCE)\Foundation
+ $(EDK_SOURCE)\Foundation\Framework
+ $(EDK_SOURCE)\Foundation\Efi
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+ $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include
+ $(EDK_SOURCE)\Foundation\Guid\PeiPeCoffLoader
+
+
+[libraries.common]
+ EdkIIGlueBaseMemoryLib
+
+[libraries.ia32]
+
+
+[libraries.x64]
+
+
+[nmake.common]
+ C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION
+ LIB_STD_FLAGS = /NOLOGO /IGNORE:4006
+
+[nmake.ia32]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32
+
+[nmake.x64]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64
+
+[nmake.ipf]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF
+
+[nmake.ebc]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/BasePeCoffLibInternals.h b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/BasePeCoffLibInternals.h
new file mode 100644
index 0000000..5c7d18c
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/BasePeCoffLibInternals.h
@@ -0,0 +1,131 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ BasePeCoffLibInternals.h
+
+Abstract:
+
+ Header file for Base PeCoff Library
+
+--*/
+
+#ifndef __BASE_PECOFF_LIB_INTERNALS__
+#define __BASE_PECOFF_LIB_INTERNALS__
+
+#include "EdkIIGlueBase.h"
+
+/**
+ Performs an Itanium-based specific relocation fixup and is a no-op on other
+ instruction sets.
+
+ @param Reloc Pointer to the relocation record.
+ @param Fixup Pointer to the address to fix up.
+ @param FixupData Pointer to a buffer to log the fixups.
+ @param Adjust The offset to adjust the fixup.
+
+ @return Status code.
+
+**/
+RETURN_STATUS
+GluePeCoffLoaderRelocateImageEx (
+ IN UINT16 *Reloc,
+ IN OUT CHAR8 *Fixup,
+ IN OUT CHAR8 **FixupData,
+ IN UINT64 Adjust
+ );
+
+
+/**
+ Performs an Itanium-based specific re-relocation fixup and is a no-op on other
+ instruction sets. This is used to re-relocated the image into the EFI virtual
+ space for runtime calls.
+
+ @param Reloc Pointer to the relocation record.
+ @param Fixup Pointer to the address to fix up.
+ @param FixupData Pointer to a buffer to log the fixups.
+ @param Adjust The offset to adjust the fixup.
+
+ @return Status code.
+
+**/
+RETURN_STATUS
+GluePeHotRelocateImageEx (
+ IN UINT16 *Reloc,
+ IN OUT CHAR8 *Fixup,
+ IN OUT CHAR8 **FixupData,
+ IN UINT64 Adjust
+ );
+
+
+/**
+ Returns TRUE if the machine type of PE/COFF image is supported. Supported
+ does not mean the image can be executed it means the PE/COFF loader supports
+ loading and relocating of the image type. It's up to the caller to support
+ the entry point.
+
+ @param Machine Machine type from the PE Header.
+
+ @return TRUE if this PE/COFF loader can load the image
+
+**/
+BOOLEAN
+PeCoffLoaderImageFormatSupported (
+ IN UINT16 Machine
+ );
+
+/**
+ Retrieves the magic value from the PE/COFF header.
+
+ @param Hdr The buffer in which to return the PE32, PE32+, or TE header.
+
+ @return EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC - Image is PE32
+ @return EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC - Image is PE32+
+
+**/
+UINT16
+PeCoffLoaderGetPeHeaderMagicValue (
+ IN EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr
+ );
+
+/**
+ Retrieves the PE or TE Header from a PE/COFF or TE image.
+
+ @param ImageContext The context of the image being loaded.
+ @param Hdr The buffer in which to return the PE32, PE32+, or TE header.
+
+ @retval RETURN_SUCCESS The PE or TE Header is read.
+ @retval Other The error status from reading the PE/COFF or TE image using the ImageRead function.
+
+**/
+RETURN_STATUS
+PeCoffLoaderGetPeHeader (
+ IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext,
+ OUT EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr
+ );
+
+/**
+ Converts an image address to the loaded address.
+
+ @param ImageContext The context of the image being loaded.
+ @param Address The address to be converted to the loaded address.
+
+ @return The converted address or NULL if the address can not be converted.
+
+**/
+VOID *
+PeCoffLoaderImageAddress (
+ IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext,
+ IN UINTN Address
+ );
+
+#endif
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/EdkIIGlueBasePeCoffLib.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/EdkIIGlueBasePeCoffLib.cif
new file mode 100644
index 0000000..7803f70
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/EdkIIGlueBasePeCoffLib.cif
@@ -0,0 +1,14 @@
+<component>
+ name = "EdkIIGlueBasePeCoffLib"
+ category = ModulePart
+ LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\BasePeCoffLib"
+ RefName = "EdkIIGlueBasePeCoffLib"
+[files]
+"EdkIIGlueBasePeCoffLib.sdl"
+"EdkIIGlueBasePeCoffLib.mak"
+"BasePeCoffLib.inf"
+"BasePeCoff.c"
+"BasePeCoffLibInternals.h"
+"Ia32\PeCoffLoaderEx.c"
+"X64\PeCoffLoaderEx.c"
+<endComponent>
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/EdkIIGlueBasePeCoffLib.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/EdkIIGlueBasePeCoffLib.mak
new file mode 100644
index 0000000..9888fe0
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/EdkIIGlueBasePeCoffLib.mak
@@ -0,0 +1,100 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueBasePeCoffLib/EdkIIGlueBasePeCoffLib.mak 1 1/20/12 3:54a Jeffch $
+#
+# $Revision: 1 $
+#
+# $Date: 1/20/12 3:54a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueBasePeCoffLib/EdkIIGlueBasePeCoffLib.mak $
+#
+# 1 1/20/12 3:54a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 9/27/11 6:16a Wesleychen
+# Intel EDK initially releases.
+#
+# 1 9/18/09 1:52a Iminglin
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: EdkIIGlueBasePeCoffLib.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+
+
+EdkIIGlueBasePeCoffLib_OBJECTS=\
+$$(BUILD_DIR)\$(EdkIIGlueBasePeCoffLib_DIR)\BasePeCoff.obj
+
+EdkIIGlueBasePeCoffLib_IA32_OBJECTS=\
+$$(BUILD_DIR)\$(EdkIIGlueBasePeCoffLib_DIR)\Ia32\PeCoffLoaderEx.obj
+
+!IF "$(PROCESSOR)"=="IA32"
+EdkIIGlueBasePeCoffLib_OBJECTS =$(EdkIIGlueBasePeCoffLib_OBJECTS) $(EdkIIGlueBasePeCoffLib_IA32_OBJECTS)
+!ELSEIF "$(PROCESSOR)"=="x64"
+EdkIIGlueBasePeCoffLib_PEI_OBJECTS =$(EdkIIGlueBasePeCoffLib_OBJECTS) $(EdkIIGlueBasePeCoffLib_IA32_OBJECTS)
+EdkIIGlueBasePeCoffLib_DXE_OBJECTS =$(EdkIIGlueBasePeCoffLib_OBJECTS)\
+$$(BUILD_DIR)\$(EdkIIGlueBasePeCoffLib_DIR)\X64\PeCoffLoaderEx.obj
+!ENDIF
+
+$(EdkIIGlueBasePeCoffLib_LIB) : EdkIIGlueBasePeCoffLib
+
+EdkIIGlueBasePeCoffLib : $(BUILD_DIR)\EdkIIGlueBasePeCoffLib.mak EdkIIGlueBasePeCoffLibBin
+
+$(BUILD_DIR)\EdkIIGlueBasePeCoffLib.mak : $(EdkIIGlueBasePeCoffLib_DIR)\$(@B).cif $(EdkIIGlueBasePeCoffLib_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(EdkIIGlueBasePeCoffLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+EdkIIGlueBasePeCoffLibBin : $(EdkIIGlueBaseMemoryLib_LIB)
+!IF "$(x64_BUILD)"=="1"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGlueBasePeCoffLib.mak all\
+ "MY_INCLUDES=/I$(EdkIIGlueBasePeCoffLib_DIR)"\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBasePeCoffLib_LIB)"\
+ "OBJECTS=$(EdkIIGlueBasePeCoffLib_DXE_OBJECTS)"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\IA32\
+ /f $(BUILD_DIR)\EdkIIGlueBasePeCoffLib.mak all\
+ "MY_INCLUDES=/I$(EdkIIGlueBasePeCoffLib_DIR)"\
+ TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBasePeCoffLib_LIB)"\
+ "OBJECTS=$(EdkIIGlueBasePeCoffLib_PEI_OBJECTS)"
+!ELSE
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGlueBasePeCoffLib.mak all\
+ "MY_INCLUDES=/I$(EdkIIGlueBasePeCoffLib_DIR)"\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBasePeCoffLib_LIB)"\
+ "OBJECTS=$(EdkIIGlueBasePeCoffLib_OBJECTS)"
+!ENDIF
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/EdkIIGlueBasePeCoffLib.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/EdkIIGlueBasePeCoffLib.sdl
new file mode 100644
index 0000000..13901f4
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/EdkIIGlueBasePeCoffLib.sdl
@@ -0,0 +1,26 @@
+TOKEN
+ Name = "EdkIIGlueBasePeCoffLib_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable EdkIIGlueBasePeCoffLib support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "EdkIIGlueBasePeCoffLib_LIB"
+ Value = "$$(LIB_BUILD_DIR)\EdkIIGlueBasePeCoffLib.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "EdkIIGlueBasePeCoffLib_DIR"
+End
+
+MODULE
+ Help = "Includes EdkIIGlueBasePeCoffLib.mak to Project"
+ File = "EdkIIGlueBasePeCoffLib.mak"
+End
+
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/Ia32/PeCoffLoaderEx.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/Ia32/PeCoffLoaderEx.c
new file mode 100644
index 0000000..245d9e9
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/Ia32/PeCoffLoaderEx.c
@@ -0,0 +1,98 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ PeCoffLoaderEx.c
+
+Abstract:
+
+ IA-32 Specific relocation fixups.
+
+--*/
+
+#include "EdkIIGlueBase.h"
+
+/**
+ Performs an IA-32 specific relocation fixup.
+
+ @param Reloc Pointer to the relocation record.
+ @param Fixup Pointer to the address to fix up.
+ @param FixupData Pointer to a buffer to log the fixups.
+ @param Adjust The offset to adjust the fixup.
+
+ @retval EFI_UNSUPPORTED Unsupported now.
+
+**/
+RETURN_STATUS
+GluePeCoffLoaderRelocateImageEx (
+ IN UINT16 *Reloc,
+ IN OUT CHAR8 *Fixup,
+ IN OUT CHAR8 **FixupData,
+ IN UINT64 Adjust
+ )
+{
+ return RETURN_UNSUPPORTED;
+}
+
+/**
+ Returns TRUE if the machine type of PE/COFF image is supported. Supported
+ does not mean the image can be executed it means the PE/COFF loader supports
+ loading and relocating of the image type. It's up to the caller to support
+ the entry point.
+
+ This function implies the basic PE/COFF loader/relocator supports IA32, EBC,
+ & X64 images. Calling the entry point in a correct mannor is up to the
+ consumer of this library.
+
+ @param Machine Machine type from the PE Header.
+
+ @return TRUE if this PE/COFF loader can load the image
+
+**/
+BOOLEAN
+PeCoffLoaderImageFormatSupported (
+ IN UINT16 Machine
+ )
+{
+ if ((Machine == EFI_IMAGE_MACHINE_IA32) || (Machine == EFI_IMAGE_MACHINE_X64) ||
+ (Machine == EFI_IMAGE_MACHINE_EBC)) {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+/**
+ Performs an Itanium-based specific re-relocation fixup and is a no-op on other
+ instruction sets. This is used to re-relocated the image into the EFI virtual
+ space for runtime calls.
+
+ @param Reloc Pointer to the relocation record.
+ @param Fixup Pointer to the address to fix up.
+ @param FixupData Pointer to a buffer to log the fixups.
+ @param Adjust The offset to adjust the fixup.
+
+ @return Status code.
+
+**/
+RETURN_STATUS
+GluePeHotRelocateImageEx (
+ IN UINT16 *Reloc,
+ IN OUT CHAR8 *Fixup,
+ IN OUT CHAR8 **FixupData,
+ IN UINT64 Adjust
+ )
+{
+ return RETURN_UNSUPPORTED;
+}
+
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/X64/PeCoffLoaderEx.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/X64/PeCoffLoaderEx.c
new file mode 100644
index 0000000..6a17a51
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePeCoffLib/X64/PeCoffLoaderEx.c
@@ -0,0 +1,97 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ PeCoffLoaderEx.c
+
+Abstract:
+
+ x64 Specific relocation fixups.
+
+--*/
+
+#include "EdkIIGlueBase.h"
+
+
+/**
+ Performs an x64 specific relocation fixup.
+
+ @param Reloc Pointer to the relocation record
+ @param Fixup Pointer to the address to fix up
+ @param FixupData Pointer to a buffer to log the fixups
+ @param Adjust The offset to adjust the fixup
+
+**/
+RETURN_STATUS
+GluePeCoffLoaderRelocateImageEx (
+ IN UINT16 *Reloc,
+ IN OUT CHAR8 *Fixup,
+ IN OUT CHAR8 **FixupData,
+ IN UINT64 Adjust
+ )
+{
+ return RETURN_UNSUPPORTED;
+}
+
+/**
+ Returns TRUE if the machine type of PE/COFF image is supported. Supported
+ does not mean the image can be executed it means the PE/COFF loader supports
+ loading and relocating of the image type. It's up to the caller to support
+ the entry point.
+
+ This function implies the basic PE/COFF loader/relocator supports IA32, EBC,
+ & X64 images. Calling the entry point in a correct mannor is up to the
+ consumer of this library.
+
+ @param Machine Machine type from the PE Header.
+
+ @return TRUE if this PE/COFF loader can load the image
+
+**/
+BOOLEAN
+PeCoffLoaderImageFormatSupported (
+ IN UINT16 Machine
+ )
+{
+ if ((Machine == EFI_IMAGE_MACHINE_IA32) || (Machine == EFI_IMAGE_MACHINE_X64) ||
+ (Machine == EFI_IMAGE_MACHINE_EBC)) {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+
+/**
+ Performs an Itanium-based specific re-relocation fixup and is a no-op on other
+ instruction sets. This is used to re-relocated the image into the EFI virtual
+ space for runtime calls.
+
+ @param Reloc Pointer to the relocation record.
+ @param Fixup Pointer to the address to fix up.
+ @param FixupData Pointer to a buffer to log the fixups.
+ @param Adjust The offset to adjust the fixup.
+
+ @return Status code.
+
+**/
+RETURN_STATUS
+GluePeHotRelocateImageEx (
+ IN UINT16 *Reloc,
+ IN OUT CHAR8 *Fixup,
+ IN OUT CHAR8 **FixupData,
+ IN UINT64 Adjust
+ )
+{
+ return RETURN_UNSUPPORTED;
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibDebug/BasePostCodeLibDebug.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibDebug/BasePostCodeLibDebug.inf
new file mode 100644
index 0000000..7e5a618
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibDebug/BasePostCodeLibDebug.inf
@@ -0,0 +1,79 @@
+#/*++
+#
+# Copyright (c) 2004 - 2006, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# BasePostCodeLibDebug.inf
+#
+# Abstract:
+#
+# Component description file for BasePostCodeLibDebug
+#
+#--*/
+
+[defines]
+BASE_NAME = EdkIIGlueBasePostCodeLibDebug
+COMPONENT_TYPE = LIBRARY
+
+[sources.common]
+ PostCode.c
+
+[sources.ia32]
+
+[sources.x64]
+
+[sources.ipf]
+
+
+[sources.ebc]
+
+
+[includes.common]
+ .
+ ..\..\Include
+ ..\..\include\Library
+ $(EDK_SOURCE)\Foundation
+ $(EDK_SOURCE)\Foundation\Framework
+ $(EDK_SOURCE)\Foundation\Efi
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+ $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include
+ $(EDK_SOURCE)\Foundation\Guid\PeiPeCoffLoader
+
+
+[libraries.common]
+# A DebugLib instance
+
+[libraries.ia32]
+
+
+[libraries.x64]
+
+
+[nmake.common]
+ C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION
+ LIB_STD_FLAGS = /NOLOGO /IGNORE:4006
+
+[nmake.ia32]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32
+
+[nmake.x64]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64
+
+[nmake.ipf]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF
+
+[nmake.ebc]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibDebug/EdkIIGlueBasePostCodeLibDebug.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibDebug/EdkIIGlueBasePostCodeLibDebug.cif
new file mode 100644
index 0000000..3022ef5
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibDebug/EdkIIGlueBasePostCodeLibDebug.cif
@@ -0,0 +1,11 @@
+<component>
+ name = "EdkIIGlueBasePostCodeLibDebug"
+ category = ModulePart
+ LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\BasePostCodeLibDebug"
+ RefName = "EdkIIGlueBasePostCodeLibDebug"
+[files]
+"EdkIIGlueBasePostCodeLibDebug.sdl"
+"EdkIIGlueBasePostCodeLibDebug.mak"
+"BasePostCodeLibDebug.inf"
+"PostCode.c"
+<endComponent>
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibDebug/EdkIIGlueBasePostCodeLibDebug.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibDebug/EdkIIGlueBasePostCodeLibDebug.mak
new file mode 100644
index 0000000..305b8e1
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibDebug/EdkIIGlueBasePostCodeLibDebug.mak
@@ -0,0 +1,80 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueBasePostCodeLibDebug/EdkIIGlueBasePostCodeLibDebug.mak 1 1/20/12 3:54a Jeffch $
+#
+# $Revision: 1 $
+#
+# $Date: 1/20/12 3:54a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueBasePostCodeLibDebug/EdkIIGlueBasePostCodeLibDebug.mak $
+#
+# 1 1/20/12 3:54a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 9/27/11 6:16a Wesleychen
+# Intel EDK initially releases.
+#
+# 1 9/18/09 1:53a Iminglin
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: EdkIIGlueBasePostCodeLibDebug.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+
+
+$(EdkIIGlueBasePostCodeLibDebug_LIB) : EdkIIGlueBasePostCodeLibDebug
+
+EdkIIGlueBasePostCodeLibDebug : $(BUILD_DIR)\EdkIIGlueBasePostCodeLibDebug.mak EdkIIGlueBasePostCodeLibDebugBin
+
+$(BUILD_DIR)\EdkIIGlueBasePostCodeLibDebug.mak : $(EdkIIGlueBasePostCodeLibDebug_DIR)\$(@B).cif $(EdkIIGlueBasePostCodeLibDebug_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(EdkIIGlueBasePostCodeLibDebug_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+EdkIIGlueBasePostCodeLibDebugBin :
+!IF "$(x64_BUILD)"=="1"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGlueBasePostCodeLibDebug.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBasePostCodeLibDebug_LIB)"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\IA32\
+ /f $(BUILD_DIR)\EdkIIGlueBasePostCodeLibDebug.mak all\
+ TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBasePostCodeLibDebug_LIB)"
+!ELSE
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGlueBasePostCodeLibDebug.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBasePostCodeLibDebug_LIB)"
+!ENDIF
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#********************************************************************** \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibDebug/EdkIIGlueBasePostCodeLibDebug.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibDebug/EdkIIGlueBasePostCodeLibDebug.sdl
new file mode 100644
index 0000000..82ebae4
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibDebug/EdkIIGlueBasePostCodeLibDebug.sdl
@@ -0,0 +1,26 @@
+TOKEN
+ Name = "EdkIIGlueBasePostCodeLibDebug_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable EdkIIGlueBasePostCodeLibDebug support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "EdkIIGlueBasePostCodeLibDebug_LIB"
+ Value = "$$(LIB_BUILD_DIR)\EdkIIGlueBasePostCodeLibDebug.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "EdkIIGlueBasePostCodeLibDebug_DIR"
+End
+
+MODULE
+ Help = "Includes EdkIIGlueBasePostCodeLibDebug.mak to Project"
+ File = "EdkIIGlueBasePostCodeLibDebug.mak"
+End
+
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibDebug/PostCode.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibDebug/PostCode.c
new file mode 100644
index 0000000..a8c5a78
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibDebug/PostCode.c
@@ -0,0 +1,132 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ PostCode.c
+
+Abstract:
+
+ Post Code functions
+
+--*/
+
+#include "EdkIIGlueBase.h"
+#include "Pcd\EdkIIGluePcdPostCodeLib.h"
+
+/**
+ Sends an 32-bit value to a POST card.
+
+ Sends the 32-bit value specified by Value to a POST card, and returns Value.
+ Some implementations of this library function may perform I/O operations
+ directly to a POST card device. Other implementations may send Value to
+ ReportStatusCode(), and the status code reporting mechanism will eventually
+ display the 32-bit value on the status reporting device.
+
+ PostCode() must actively prevent recursion. If PostCode() is called while
+ processing another any other Report Status Code Library function, then
+ PostCode() must return Value immediately.
+
+ @param Value The 32-bit value to write to the POST card.
+
+ @return Value
+
+**/
+UINT32
+EFIAPI
+GluePostCode (
+ IN UINT32 Value
+ )
+{
+ DEBUG((EFI_D_INFO, "POST %08x\n", Value));
+ return Value;
+}
+
+
+/**
+ Sends an 32-bit value to a POST and associated ASCII string.
+
+ Sends the 32-bit value specified by Value to a POST card, and returns Value.
+ If Description is not NULL, then the ASCII string specified by Description is
+ also passed to the handler that displays the POST card value. Some
+ implementations of this library function may perform I/O operations directly
+ to a POST card device. Other implementations may send Value to ReportStatusCode(),
+ and the status code reporting mechanism will eventually display the 32-bit
+ value on the status reporting device.
+
+ PostCodeWithDescription()must actively prevent recursion. If
+ PostCodeWithDescription() is called while processing another any other Report
+ Status Code Library function, then PostCodeWithDescription() must return Value
+ immediately.
+
+ @param Value The 32-bit value to write to the POST card.
+ @param Description Pointer to an ASCII string that is a description of the
+ POST code value. This is an optional parameter that may
+ be NULL.
+
+ @return Value
+
+**/
+UINT32
+EFIAPI
+GluePostCodeWithDescription (
+ IN UINT32 Value,
+ IN CONST CHAR8 *Description OPTIONAL
+ )
+{
+ DEBUG((EFI_D_INFO, "POST %08x - %s\n", Value, Description));
+ return Value;
+}
+
+
+/**
+ Returns TRUE if POST Codes are enabled.
+
+ This function returns TRUE if the POST_CODE_PROPERTY_POST_CODE_ENABLED
+ bit of PcdPostCodePropertyMask is set. Otherwise FALSE is returned.
+
+ @retval TRUE The POST_CODE_PROPERTY_POST_CODE_ENABLED bit of
+ PcdPostCodeProperyMask is set.
+ @retval FALSE The POST_CODE_PROPERTY_POST_CODE_ENABLED bit of
+ PcdPostCodeProperyMask is clear.
+
+**/
+BOOLEAN
+EFIAPI
+GluePostCodeEnabled (
+ VOID
+ )
+{
+ return ((PcdGet8(PcdPostCodePropertyMask) & POST_CODE_PROPERTY_POST_CODE_ENABLED) != 0);
+}
+
+
+/**
+ Returns TRUE if POST code descriptions are enabled.
+
+ This function returns TRUE if the POST_CODE_PROPERTY_POST_CODE_ENABLED
+ bit of PcdPostCodePropertyMask is set. Otherwise FALSE is returned.
+
+ @retval TRUE The POST_CODE_PROPERTY_POST_CODE_ENABLED bit of
+ PcdPostCodeProperyMask is set.
+ @retval FALSE The POST_CODE_PROPERTY_POST_CODE_ENABLED bit of
+ PcdPostCodeProperyMask is clear.
+
+**/
+BOOLEAN
+EFIAPI
+GluePostCodeDescriptionEnabled (
+ VOID
+ )
+{
+ return ((PcdGet8(PcdPostCodePropertyMask) & POST_CODE_PROPERTY_POST_CODE_ENABLED) != 0);
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibPort80/BasePostCodeLibPort80.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibPort80/BasePostCodeLibPort80.inf
new file mode 100644
index 0000000..921483e
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibPort80/BasePostCodeLibPort80.inf
@@ -0,0 +1,79 @@
+#/*++
+#
+# Copyright (c) 2004 - 2006, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# BasePostCodeLibPort80.inf
+#
+# Abstract:
+#
+# Component description file for BasePostCodeLibPort80
+#
+#--*/
+
+[defines]
+BASE_NAME = EdkIIGlueBasePostCodeLibPort80
+COMPONENT_TYPE = LIBRARY
+
+[sources.common]
+ PostCode.c
+
+[sources.ia32]
+
+[sources.x64]
+
+[sources.ipf]
+
+
+[sources.ebc]
+
+
+[includes.common]
+ .
+ ..\..\Include
+ ..\..\include\Library
+ $(EDK_SOURCE)\Foundation
+ $(EDK_SOURCE)\Foundation\Framework
+ $(EDK_SOURCE)\Foundation\Efi
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+ $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include
+ $(EDK_SOURCE)\Foundation\Guid\PeiPeCoffLoader
+
+
+[libraries.common]
+ EdkIIGlueBaseIoLibIntrinsic
+
+[libraries.ia32]
+
+
+[libraries.x64]
+
+
+[nmake.common]
+ C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION
+ LIB_STD_FLAGS = /NOLOGO /IGNORE:4006
+
+[nmake.ia32]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32
+
+[nmake.x64]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64
+
+[nmake.ipf]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF
+
+[nmake.ebc]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibPort80/EdkIIGlueBasePostCodeLibPort80.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibPort80/EdkIIGlueBasePostCodeLibPort80.cif
new file mode 100644
index 0000000..341bf9d
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibPort80/EdkIIGlueBasePostCodeLibPort80.cif
@@ -0,0 +1,11 @@
+<component>
+ name = "EdkIIGlueBasePostCodeLibPort80"
+ category = ModulePart
+ LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\BasePostCodeLibPort80"
+ RefName = "EdkIIGlueBasePostCodeLibPort80"
+[files]
+"EdkIIGlueBasePostCodeLibPort80.sdl"
+"EdkIIGlueBasePostCodeLibPort80.mak"
+"BasePostCodeLibPort80.inf"
+"PostCode.c"
+<endComponent>
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibPort80/EdkIIGlueBasePostCodeLibPort80.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibPort80/EdkIIGlueBasePostCodeLibPort80.mak
new file mode 100644
index 0000000..7689553
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibPort80/EdkIIGlueBasePostCodeLibPort80.mak
@@ -0,0 +1,87 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueBasePostCodeLibPort80/EdkIIGlueBasePostCodeLibPort80.mak 1 1/20/12 3:54a Jeffch $
+#
+# $Revision: 1 $
+#
+# $Date: 1/20/12 3:54a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueBasePostCodeLibPort80/EdkIIGlueBasePostCodeLibPort80.mak $
+#
+# 1 1/20/12 3:54a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 9/27/11 6:16a Wesleychen
+# Intel EDK initially releases.
+#
+# 1 9/18/09 1:53a Iminglin
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: EdkIIGlueBasePostCodeLibPort80.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+
+
+$(EdkIIGlueBasePostCodeLibPort80_LIB) : EdkIIGlueBasePostCodeLibPort80
+
+EdkIIGlueBasePostCodeLibPort80 : $(BUILD_DIR)\EdkIIGlueBasePostCodeLibPort80.mak EdkIIGlueBasePostCodeLibPort80Bin
+
+$(BUILD_DIR)\EdkIIGlueBasePostCodeLibPort80.mak : $(EdkIIGlueBasePostCodeLibPort80_DIR)\$(@B).cif $(EdkIIGlueBasePostCodeLibPort80_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(EdkIIGlueBasePostCodeLibPort80_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+EdkIIGlueBasePostCodeLibPort80_LIB_LINKS=\
+!IF "$(PROCESSOR)"=="IA32" || "$(PROCESSOR)"=="x64"
+$(EdkIIGlueBaseIoLibIntrinsic_LIB)
+!ELSEIF "$(PROCESSOR)"=="EBC"
+$(EdkIIGlueDxeIoLibCpuIo_LIB)
+!ENDIF
+
+EdkIIGlueBasePostCodeLibPort80Bin : $(EdkIIGlueBasePostCodeLibPort80_LIB_LINKS)
+!IF "$(x64_BUILD)"=="1"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGlueBasePostCodeLibPort80.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBasePostCodeLibPort80_LIB)"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\IA32\
+ /f $(BUILD_DIR)\EdkIIGlueBasePostCodeLibPort80.mak all\
+ TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBasePostCodeLibPort80_LIB)"
+!ELSE
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGlueBasePostCodeLibPort80.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBasePostCodeLibPort80_LIB)"
+!ENDIF
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#********************************************************************** \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibPort80/EdkIIGlueBasePostCodeLibPort80.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibPort80/EdkIIGlueBasePostCodeLibPort80.sdl
new file mode 100644
index 0000000..27db987
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibPort80/EdkIIGlueBasePostCodeLibPort80.sdl
@@ -0,0 +1,26 @@
+TOKEN
+ Name = "EdkIIGlueBasePostCodeLibPort80_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable EdkIIGlueBasePostCodeLibPort80 support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "EdkIIGlueBasePostCodeLibPort80_LIB"
+ Value = "$$(LIB_BUILD_DIR)\EdkIIGlueBasePostCodeLibPort80.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "EdkIIGlueBasePostCodeLibPort80_DIR"
+End
+
+MODULE
+ Help = "Includes EdkIIGlueBasePostCodeLibPort80.mak to Project"
+ File = "EdkIIGlueBasePostCodeLibPort80.mak"
+End
+
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibPort80/PostCode.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibPort80/PostCode.c
new file mode 100644
index 0000000..e2aec10
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePostCodeLibPort80/PostCode.c
@@ -0,0 +1,132 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PostCode.c
+
+Abstract:
+
+ Post Code functions
+
+--*/
+
+#include "EdkIIGlueBase.h"
+#include "Pcd\EdkIIGluePcdPostCodeLib.h"
+
+/**
+ Sends an 32-bit value to a POST card.
+
+ Sends the 32-bit value specified by Value to a POST card, and returns Value.
+ Some implementations of this library function may perform I/O operations
+ directly to a POST card device. Other implementations may send Value to
+ ReportStatusCode(), and the status code reporting mechanism will eventually
+ display the 32-bit value on the status reporting device.
+
+ PostCode() must actively prevent recursion. If PostCode() is called while
+ processing another any other Report Status Code Library function, then
+ PostCode() must return Value immediately.
+
+ @param Value The 32-bit value to write to the POST card.
+
+ @return Value
+
+**/
+UINT32
+EFIAPI
+GluePostCode (
+ IN UINT32 Value
+ )
+{
+ IoWrite8 (0x80, (UINT8)(Value));
+ return Value;
+}
+
+
+/**
+ Sends an 32-bit value to a POST and associated ASCII string.
+
+ Sends the 32-bit value specified by Value to a POST card, and returns Value.
+ If Description is not NULL, then the ASCII string specified by Description is
+ also passed to the handler that displays the POST card value. Some
+ implementations of this library function may perform I/O operations directly
+ to a POST card device. Other implementations may send Value to ReportStatusCode(),
+ and the status code reporting mechanism will eventually display the 32-bit
+ value on the status reporting device.
+
+ PostCodeWithDescription()must actively prevent recursion. If
+ PostCodeWithDescription() is called while processing another any other Report
+ Status Code Library function, then PostCodeWithDescription() must return Value
+ immediately.
+
+ @param Value The 32-bit value to write to the POST card.
+ @param Description Pointer to an ASCII string that is a description of the
+ POST code value. This is an optional parameter that may
+ be NULL.
+
+ @return Value
+
+**/
+UINT32
+EFIAPI
+GluePostCodeWithDescription (
+ IN UINT32 Value,
+ IN CONST CHAR8 *Description OPTIONAL
+ )
+{
+ IoWrite8 (0x80, (UINT8)(Value));
+ return Value;
+}
+
+
+/**
+ Returns TRUE if POST Codes are enabled.
+
+ This function returns TRUE if the POST_CODE_PROPERTY_POST_CODE_ENABLED
+ bit of PcdPostCodePropertyMask is set. Otherwise FALSE is returned.
+
+ @retval TRUE The POST_CODE_PROPERTY_POST_CODE_ENABLED bit of
+ PcdPostCodeProperyMask is set.
+ @retval FALSE The POST_CODE_PROPERTY_POST_CODE_ENABLED bit of
+ PcdPostCodeProperyMask is clear.
+
+**/
+BOOLEAN
+EFIAPI
+GluePostCodeEnabled (
+ VOID
+ )
+{
+ return ((PcdGet8(PcdPostCodePropertyMask) & POST_CODE_PROPERTY_POST_CODE_ENABLED) != 0);
+}
+
+
+/**
+ Returns TRUE if POST code descriptions are enabled.
+
+ This function returns TRUE if the
+ POST_CODE_PROPERTY_POST_CODE_ENABLED bit of
+ PcdPostCodePropertyMask is set. Otherwise FALSE is returned.
+
+ @retval TRUE The POST_CODE_PROPERTY_POST_CODE_ENABLED
+ bit of PcdPostCodeProperyMask is set.
+ @retval FALSE The POST_CODE_PROPERTY_POST_CODE_ENABLED
+ bit of PcdPostCodeProperyMask is clear.
+
+**/
+BOOLEAN
+EFIAPI
+GluePostCodeDescriptionEnabled (
+ VOID
+ )
+{
+ return ((PcdGet8(PcdPostCodePropertyMask) & POST_CODE_PROPERTY_POST_CODE_ENABLED) != 0);
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/BasePrintLib.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/BasePrintLib.inf
new file mode 100644
index 0000000..fb2cf50
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/BasePrintLib.inf
@@ -0,0 +1,80 @@
+#/*++
+#
+# Copyright (c) 2004 - 2006, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# BasePrintLib.inf
+#
+# Abstract:
+#
+# Component description file for BasePrintLib.
+#
+#--*/
+
+[defines]
+BASE_NAME = EdkIIGlueBasePrintLib
+COMPONENT_TYPE = LIBRARY
+
+[sources.common]
+ PrintLib.c
+ PrintLibInternal.c
+
+[sources.ia32]
+
+[sources.x64]
+
+[sources.ipf]
+
+
+[sources.ebc]
+
+
+[includes.common]
+ .
+ ..\..\Include
+ ..\..\include\Library
+ $(EDK_SOURCE)\Foundation
+ $(EDK_SOURCE)\Foundation\Framework
+ $(EDK_SOURCE)\Foundation\Efi
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+ $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include
+ $(EDK_SOURCE)\Foundation\Guid\PeiPeCoffLoader
+
+
+[libraries.common]
+ EdkIIGlueBaseLib
+
+[libraries.ia32]
+
+
+[libraries.x64]
+
+
+[nmake.common]
+ C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION
+ LIB_STD_FLAGS = /NOLOGO /IGNORE:4006
+
+[nmake.ia32]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32
+
+[nmake.x64]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64
+
+[nmake.ipf]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF
+
+[nmake.ebc]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/EdkIIGlueBasePrintLib.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/EdkIIGlueBasePrintLib.cif
new file mode 100644
index 0000000..64dfc7c
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/EdkIIGlueBasePrintLib.cif
@@ -0,0 +1,13 @@
+<component>
+ name = "EdkIIGlueBasePrintLib"
+ category = ModulePart
+ LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\BasePrintLib"
+ RefName = "EdkIIGlueBasePrintLib"
+[files]
+"EdkIIGlueBasePrintLib.sdl"
+"EdkIIGlueBasePrintLib.mak"
+"BasePrintLib.inf"
+"PrintLib.c"
+"PrintLibInternal.c"
+"PrintLibInternal.h"
+<endComponent>
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/EdkIIGlueBasePrintLib.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/EdkIIGlueBasePrintLib.mak
new file mode 100644
index 0000000..d974948
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/EdkIIGlueBasePrintLib.mak
@@ -0,0 +1,80 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueBasePrintLib/EdkIIGlueBasePrintLib.mak 1 1/20/12 3:54a Jeffch $
+#
+# $Revision: 1 $
+#
+# $Date: 1/20/12 3:54a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueBasePrintLib/EdkIIGlueBasePrintLib.mak $
+#
+# 1 1/20/12 3:54a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 9/27/11 6:16a Wesleychen
+# Intel EDK initially releases.
+#
+# 1 9/18/09 1:53a Iminglin
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: EdkIIGlueBasePrintLib.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+
+
+$(EdkIIGlueBasePrintLib_LIB) : EdkIIGlueBasePrintLib
+
+EdkIIGlueBasePrintLib : $(BUILD_DIR)\EdkIIGlueBasePrintLib.mak EdkIIGlueBasePrintLibBin
+
+$(BUILD_DIR)\EdkIIGlueBasePrintLib.mak : $(EdkIIGlueBasePrintLib_DIR)\$(@B).cif $(EdkIIGlueBasePrintLib_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(EdkIIGlueBasePrintLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+EdkIIGlueBasePrintLibBin : $(EdkIIGlueBaseLib_LIB)
+!IF "$(x64_BUILD)"=="1"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGlueBasePrintLib.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBasePrintLib_LIB)"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\IA32\
+ /f $(BUILD_DIR)\EdkIIGlueBasePrintLib.mak all\
+ TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBasePrintLib_LIB)"
+!ELSE
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGlueBasePrintLib.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBasePrintLib_LIB)"
+!ENDIF
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#********************************************************************** \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/EdkIIGlueBasePrintLib.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/EdkIIGlueBasePrintLib.sdl
new file mode 100644
index 0000000..2df6627
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/EdkIIGlueBasePrintLib.sdl
@@ -0,0 +1,26 @@
+TOKEN
+ Name = "EdkIIGlueBasePrintLib_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable EdkIIGlueBasePrintLib support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "EdkIIGlueBasePrintLib_LIB"
+ Value = "$$(LIB_BUILD_DIR)\EdkIIGlueBasePrintLib.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "EdkIIGlueBasePrintLib_DIR"
+End
+
+MODULE
+ Help = "Includes EdkIIGlueBasePrintLib.mak to Project"
+ File = "EdkIIGlueBasePrintLib.mak"
+End
+
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/PrintLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/PrintLib.c
new file mode 100644
index 0000000..9446e02
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/PrintLib.c
@@ -0,0 +1,1061 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ PrintLib.c
+
+Abstract:
+
+ Print Library.
+
+--*/
+
+#include "PrintLibInternal.h"
+
+#define WARNING_STATUS_NUMBER 4
+#define ERROR_STATUS_NUMBER 24
+
+STATIC CONST CHAR8 *StatusString [] = {
+ "Success", // RETURN_SUCCESS = 0
+ "Warning Unknown Glyph", // RETURN_WARN_UNKNOWN_GLYPH = 1
+ "Warning Delete Failure", // RETURN_WARN_DELETE_FAILURE = 2
+ "Warning Write Failure", // RETURN_WARN_WRITE_FAILURE = 3
+ "Warning Buffer Too Small", // RETURN_WARN_BUFFER_TOO_SMALL = 4
+ "Load Error", // RETURN_LOAD_ERROR = 1 | MAX_BIT
+ "Invalid Parameter", // RETURN_INVALID_PARAMETER = 2 | MAX_BIT
+ "Unsupported", // RETURN_UNSUPPORTED = 3 | MAX_BIT
+ "Bad Buffer Size", // RETURN_BAD_BUFFER_SIZE = 4 | MAX_BIT
+ "Buffer Too Small", // RETURN_BUFFER_TOO_SMALL, = 5 | MAX_BIT
+ "Not Ready", // RETURN_NOT_READY = 6 | MAX_BIT
+ "Device Error", // RETURN_DEVICE_ERROR = 7 | MAX_BIT
+ "Write Protected", // RETURN_WRITE_PROTECTED = 8 | MAX_BIT
+ "Out of Resources", // RETURN_OUT_OF_RESOURCES = 9 | MAX_BIT
+ "Volume Corrupt", // RETURN_VOLUME_CORRUPTED = 10 | MAX_BIT
+ "Volume Full", // RETURN_VOLUME_FULL = 11 | MAX_BIT
+ "No Media", // RETURN_NO_MEDIA = 12 | MAX_BIT
+ "Media changed", // RETURN_MEDIA_CHANGED = 13 | MAX_BIT
+ "Not Found", // RETURN_NOT_FOUND = 14 | MAX_BIT
+ "Access Denied", // RETURN_ACCESS_DENIED = 15 | MAX_BIT
+ "No Response", // RETURN_NO_RESPONSE = 16 | MAX_BIT
+ "No mapping", // RETURN_NO_MAPPING = 17 | MAX_BIT
+ "Time out", // RETURN_TIMEOUT = 18 | MAX_BIT
+ "Not started", // RETURN_NOT_STARTED = 19 | MAX_BIT
+ "Already started", // RETURN_ALREADY_STARTED = 20 | MAX_BIT
+ "Aborted", // RETURN_ABORTED = 21 | MAX_BIT
+ "ICMP Error", // RETURN_ICMP_ERROR = 22 | MAX_BIT
+ "TFTP Error", // RETURN_TFTP_ERROR = 23 | MAX_BIT
+ "Protocol Error" // RETURN_PROTOCOL_ERROR = 24 | MAX_BIT
+};
+
+/**
+ Worker function that produces a Null-terminated string in an output buffer
+ based on a Null-terminated format string and a VA_LIST argument list.
+
+ VSPrint function to process format and place the results in Buffer. Since a
+ VA_LIST is used this rountine allows the nesting of Vararg routines. Thus
+ this is the main print working routine.
+
+ @param Buffer Character buffer to print the results of the parsing
+ of Format into.
+ @param BufferSize Maximum number of characters to put into buffer.
+ @param Flags Intial flags value.
+ Can only have FORMAT_UNICODE and OUTPUT_UNICODE set.
+ @param Format Null-terminated format string.
+ @param Marker Vararg list consumed by processing Format.
+
+ @return Number of characters printed not including the Null-terminator.
+
+**/
+UINTN
+BasePrintLibVSPrint (
+ OUT CHAR8 *Buffer,
+ IN UINTN BufferSize,
+ IN UINTN Flags,
+ IN CONST CHAR8 *Format,
+ IN VA_LIST Marker
+ )
+{
+ CHAR8 *OriginalBuffer;
+ CHAR8 *EndBuffer;
+ CHAR8 ValueBuffer[MAXIMUM_VALUE_CHARACTERS];
+ UINTN BytesPerOutputCharacter;
+ UINTN BytesPerFormatCharacter;
+ UINTN FormatMask;
+ UINTN FormatCharacter;
+ UINTN Width;
+ UINTN Precision;
+ INT64 Value;
+ CONST CHAR8 *ArgumentString;
+ UINTN Character;
+ GUID *TmpGuid;
+ TIME *TmpTime;
+ UINTN Count;
+ UINTN ArgumentMask;
+ INTN BytesPerArgumentCharacter;
+ UINTN ArgumentCharacter;
+ BOOLEAN Done;
+ UINTN Index;
+ CHAR8 Prefix;
+ BOOLEAN ZeroPad;
+ BOOLEAN Comma;
+ UINTN Digits;
+ UINTN Radix;
+ RETURN_STATUS Status;
+
+ if (BufferSize == 0) {
+ return 0;
+ }
+ ASSERT (Buffer != NULL);
+
+ if ((Flags & OUTPUT_UNICODE) != 0) {
+ BytesPerOutputCharacter = 2;
+ } else {
+ BytesPerOutputCharacter = 1;
+ }
+
+ //
+ // Reserve space for the Null terminator.
+ //
+ BufferSize--;
+ OriginalBuffer = Buffer;
+ //
+ // Set the tag for the end of the input Buffer.
+ //
+ EndBuffer = Buffer + BufferSize * BytesPerOutputCharacter;
+
+ if ((Flags & FORMAT_UNICODE) != 0) {
+ //
+ // Make sure format string cannot contain more than PcdMaximumUnicodeStringLength
+ // Unicode characters if PcdMaximumUnicodeStringLength is not zero.
+ //
+ ASSERT (StrSize ((CHAR16 *) Format) != 0);
+ BytesPerFormatCharacter = 2;
+ FormatMask = 0xffff;
+ } else {
+ //
+ // Make sure format string cannot contain more than PcdMaximumAsciiStringLength
+ // Ascii characters if PcdMaximumAsciiStringLength is not zero.
+ //
+ ASSERT (AsciiStrSize (Format) != 0);
+ BytesPerFormatCharacter = 1;
+ FormatMask = 0xff;
+ }
+
+
+
+ //
+ // Get the first character from the format string
+ //
+ FormatCharacter = (*Format | (*(Format + 1) << 8)) & FormatMask;
+
+ //
+ // Loop until the end of the format string is reached or the output buffer is full
+ //
+ while (FormatCharacter != 0 && Buffer < EndBuffer) {
+ //
+ // Clear all the flag bits except those that may have been passed in
+ //
+ Flags &= (OUTPUT_UNICODE | FORMAT_UNICODE);
+
+ //
+ // Set the default width to zero, and the default precision to 1
+ //
+ Width = 0;
+ Precision = 1;
+ Prefix = 0;
+ Comma = FALSE;
+ ZeroPad = FALSE;
+ Count = 0;
+ Digits = 0;
+
+ switch (FormatCharacter) {
+ case '%':
+ //
+ // Parse Flags and Width
+ //
+ for (Done = FALSE; !Done; ) {
+ Format += BytesPerFormatCharacter;
+ FormatCharacter = (*Format | (*(Format + 1) << 8)) & FormatMask;
+ switch (FormatCharacter) {
+ case '.':
+ Flags |= PRECISION;
+ break;
+ case '-':
+ Flags |= LEFT_JUSTIFY;
+ break;
+ case '+':
+ Flags |= PREFIX_SIGN;
+ break;
+ case ' ':
+ Flags |= PREFIX_BLANK;
+ break;
+ case ',':
+ Flags |= COMMA_TYPE;
+ break;
+ case 'L':
+ case 'l':
+ Flags |= LONG_TYPE;
+ break;
+ case '*':
+ if ((Flags & PRECISION) == 0) {
+ Flags |= PAD_TO_WIDTH;
+ Width = VA_ARG (Marker, UINTN);
+ } else {
+ Precision = VA_ARG (Marker, UINTN);
+ }
+ break;
+ case '0':
+ if ((Flags & PRECISION) == 0) {
+ Flags |= PREFIX_ZERO;
+ }
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ for (Count = 0; ((FormatCharacter >= '0') && (FormatCharacter <= '9')); ){
+ Count = (Count * 10) + FormatCharacter - '0';
+ Format += BytesPerFormatCharacter;
+ FormatCharacter = (*Format | (*(Format + 1) << 8)) & FormatMask;
+ }
+ Format -= BytesPerFormatCharacter;
+ if ((Flags & PRECISION) == 0) {
+ Flags |= PAD_TO_WIDTH;
+ Width = Count;
+ } else {
+ Precision = Count;
+ }
+ break;
+
+ case '\0':
+ //
+ // Make no output if Format string terminates unexpectedly when
+ // looking up for flag, width, precision and type.
+ //
+ Format -= BytesPerFormatCharacter;
+ Precision = 0;
+ //
+ // break skipped on purpose.
+ //
+ default:
+ Done = TRUE;
+ break;
+ }
+ }
+
+ //
+ // Handle each argument type
+ //
+ switch (FormatCharacter) {
+ case 'p':
+ //
+ // Flag space, +, 0, L & l are invalid for type p.
+ //
+ Flags &= ~(PREFIX_BLANK | PREFIX_SIGN | PREFIX_ZERO | LONG_TYPE);
+ if (sizeof (VOID *) > 4) {
+ Flags |= LONG_TYPE;
+ }
+ case 'X':
+ Flags |= PREFIX_ZERO;
+ //
+ // break skipped on purpose
+ //
+ case 'x':
+ Flags |= RADIX_HEX;
+ //
+ // break skipped on purpose
+ //
+ case 'd':
+ if ((Flags & LONG_TYPE) == 0) {
+ Value = (VA_ARG (Marker, int));
+ } else {
+ Value = VA_ARG (Marker, INT64);
+ }
+ if ((Flags & PREFIX_BLANK) != 0) {
+ Prefix = ' ';
+ }
+ if ((Flags & PREFIX_SIGN) != 0) {
+ Prefix = '+';
+ }
+ if ((Flags & COMMA_TYPE) != 0) {
+ Comma = TRUE;
+ }
+ if ((Flags & RADIX_HEX) == 0) {
+ Radix = 10;
+ if (Comma) {
+ Flags &= (~PREFIX_ZERO);
+ Precision = 1;
+ }
+ if (Value < 0) {
+ Flags |= PREFIX_SIGN;
+ Prefix = '-';
+ Value = -Value;
+ }
+ } else {
+ Radix = 16;
+ Comma = FALSE;
+ if ((Flags & LONG_TYPE) == 0 && Value < 0) {
+ Value = (unsigned int)Value;
+ }
+ }
+ //
+ // Convert Value to a reversed string
+ //
+ Count = BasePrintLibValueToString (ValueBuffer, Value, Radix);
+ if (Value == 0 && Precision == 0) {
+ Count = 0;
+ }
+ ArgumentString = (CHAR8 *)ValueBuffer + Count;
+
+ Digits = Count % 3;
+ if (Digits != 0) {
+ Digits = 3 - Digits;
+ }
+ if (Comma && Count != 0) {
+ Count += ((Count - 1) / 3);
+ }
+ if (Prefix != 0) {
+ Count++;
+ Precision++;
+ }
+ Flags |= ARGUMENT_REVERSED;
+ ZeroPad = TRUE;
+ if ((Flags & PREFIX_ZERO) != 0) {
+ if ((Flags & LEFT_JUSTIFY) == 0) {
+ if ((Flags & PAD_TO_WIDTH) != 0) {
+ if ((Flags & PRECISION) == 0) {
+ Precision = Width;
+ }
+ }
+ }
+ }
+ break;
+
+ case 's':
+ case 'S':
+ Flags |= ARGUMENT_UNICODE;
+ //
+ // break skipped on purpose
+ //
+ case 'a':
+ ArgumentString = (CHAR8 *)VA_ARG (Marker, CHAR8 *);
+ if (ArgumentString == NULL) {
+ Flags &= (~ARGUMENT_UNICODE);
+ ArgumentString = "<null string>";
+ }
+ break;
+
+ case 'c':
+ Character = VA_ARG (Marker, UINTN) & 0xffff;
+ ArgumentString = (CHAR8 *)&Character;
+ Flags |= ARGUMENT_UNICODE;
+ break;
+
+ case 'g':
+ TmpGuid = VA_ARG (Marker, GUID *);
+ if (TmpGuid == NULL) {
+ ArgumentString = "<null guid>";
+ } else {
+ BasePrintLibSPrint (
+ ValueBuffer,
+ MAXIMUM_VALUE_CHARACTERS,
+ 0,
+ "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
+ TmpGuid->Data1,
+ TmpGuid->Data2,
+ TmpGuid->Data3,
+ TmpGuid->Data4[0],
+ TmpGuid->Data4[1],
+ TmpGuid->Data4[2],
+ TmpGuid->Data4[3],
+ TmpGuid->Data4[4],
+ TmpGuid->Data4[5],
+ TmpGuid->Data4[6],
+ TmpGuid->Data4[7]
+ );
+ ArgumentString = ValueBuffer;
+ }
+ break;
+
+ case 't':
+ TmpTime = VA_ARG (Marker, TIME *);
+ if (TmpTime == NULL) {
+ ArgumentString = "<null time>";
+ } else {
+ BasePrintLibSPrint (
+ ValueBuffer,
+ MAXIMUM_VALUE_CHARACTERS,
+ 0,
+ "%02d/%02d/%04d %02d:%02d",
+ TmpTime->Month,
+ TmpTime->Day,
+ TmpTime->Year,
+ TmpTime->Hour,
+ TmpTime->Minute
+ );
+ ArgumentString = ValueBuffer;
+ }
+ break;
+
+ case 'r':
+ Status = VA_ARG (Marker, RETURN_STATUS);
+ ArgumentString = ValueBuffer;
+ if (RETURN_ERROR (Status)) {
+ //
+ // Clear error bit
+ //
+ Index = Status & ~MAX_BIT;
+ if (Index > 0 && Index <= ERROR_STATUS_NUMBER) {
+ ArgumentString = StatusString [Index + WARNING_STATUS_NUMBER];
+ }
+ } else {
+ Index = Status;
+ if (Index <= WARNING_STATUS_NUMBER) {
+ ArgumentString = StatusString [Index];
+ }
+ }
+ if (ArgumentString == ValueBuffer) {
+ BasePrintLibSPrint ((CHAR8 *) ValueBuffer, MAXIMUM_VALUE_CHARACTERS, 0, "%08X", Status);
+ }
+ break;
+
+ case '\n':
+ ArgumentString = "\n\r";
+ break;
+
+ case '%':
+ default:
+ //
+ // if the type is '%' or unknown, then print it to the screen
+ //
+ ArgumentString = (CHAR8 *)&FormatCharacter;
+ Flags |= ARGUMENT_UNICODE;
+ break;
+ }
+ break;
+
+ case '\n':
+ ArgumentString = "\n\r";
+ break;
+
+ default:
+ ArgumentString = (CHAR8 *)&FormatCharacter;
+ Flags |= ARGUMENT_UNICODE;
+ break;
+ }
+
+ //
+ // Retrieve the ArgumentString attriubutes
+ //
+ if ((Flags & ARGUMENT_UNICODE) != 0) {
+ ArgumentMask = 0xffff;
+ BytesPerArgumentCharacter = 2;
+ } else {
+ ArgumentMask = 0xff;
+ BytesPerArgumentCharacter = 1;
+ }
+ if ((Flags & ARGUMENT_REVERSED) != 0) {
+ BytesPerArgumentCharacter = -BytesPerArgumentCharacter;
+ } else {
+ //
+ // Compute the number of characters in ArgumentString and store it in Count
+ // ArgumentString is either null-terminated, or it contains Precision characters
+ //
+ for (Count = 0; Count < Precision || ((Flags & PRECISION) == 0); Count++) {
+ ArgumentCharacter = ((ArgumentString[Count * BytesPerArgumentCharacter] & 0xff) | ((ArgumentString[Count * BytesPerArgumentCharacter + 1]) << 8)) & ArgumentMask;
+ if (ArgumentCharacter == 0) {
+ break;
+ }
+ }
+ }
+
+ if (Precision < Count) {
+ Precision = Count;
+ }
+
+ //
+ // Pad before the string
+ //
+ if ((Flags & (PAD_TO_WIDTH | LEFT_JUSTIFY)) == (PAD_TO_WIDTH)) {
+ Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, Width - Precision, ' ', BytesPerOutputCharacter);
+ }
+
+ if (ZeroPad) {
+ if (Prefix != 0) {
+ Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, 1, Prefix, BytesPerOutputCharacter);
+ }
+ Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, Precision - Count, '0', BytesPerOutputCharacter);
+ } else {
+ Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, Precision - Count, ' ', BytesPerOutputCharacter);
+ if (Prefix != 0) {
+ Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, 1, Prefix, BytesPerOutputCharacter);
+ }
+ }
+
+ //
+ // Output the Prefix character if it is present
+ //
+ Index = 0;
+ if (Prefix != 0) {
+ Index++;
+ }
+
+ //
+ // Copy the string into the output buffer performing the required type conversions
+ //
+ while (Index < Count) {
+ ArgumentCharacter = ((*ArgumentString & 0xff) | (*(ArgumentString + 1) << 8)) & ArgumentMask;
+
+ Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, 1, ArgumentCharacter, BytesPerOutputCharacter);
+ ArgumentString += BytesPerArgumentCharacter;
+ Index++;
+ if (Comma) {
+ Digits++;
+ if (Digits == 3) {
+ Digits = 0;
+ Index++;
+ if (Index < Count) {
+ Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, 1, ',', BytesPerOutputCharacter);
+ }
+ }
+ }
+ }
+
+ //
+ // Pad after the string
+ //
+ if ((Flags & (PAD_TO_WIDTH | LEFT_JUSTIFY)) == (PAD_TO_WIDTH | LEFT_JUSTIFY)) {
+ Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, Width - Precision, ' ', BytesPerOutputCharacter);
+ }
+
+ //
+ // Get the next character from the format string
+ //
+ Format += BytesPerFormatCharacter;
+
+ //
+ // Get the next character from the format string
+ //
+ FormatCharacter = (*Format | (*(Format + 1) << 8)) & FormatMask;
+ }
+
+ //
+ // Null terminate the Unicode or ASCII string
+ //
+ BasePrintLibFillBuffer (Buffer, EndBuffer + BytesPerOutputCharacter, 1, 0, BytesPerOutputCharacter);
+ //
+ // Make sure output buffer cannot contain more than PcdMaximumUnicodeStringLength
+ // Unicode characters if PcdMaximumUnicodeStringLength is not zero.
+ //
+ ASSERT ((((Flags & OUTPUT_UNICODE) == 0)) || (StrSize ((CHAR16 *) OriginalBuffer) != 0));
+ //
+ // Make sure output buffer cannot contain more than PcdMaximumAsciiStringLength
+ // ASCII characters if PcdMaximumAsciiStringLength is not zero.
+ //
+ ASSERT ((((Flags & OUTPUT_UNICODE) != 0)) || (AsciiStrSize (OriginalBuffer) != 0));
+
+ return ((Buffer - OriginalBuffer) / BytesPerOutputCharacter);
+}
+
+/**
+ Worker function that produces a Null-terminated string in an output buffer
+ based on a Null-terminated format string and variable argument list.
+
+ VSPrint function to process format and place the results in Buffer. Since a
+ VA_LIST is used this rountine allows the nesting of Vararg routines. Thus
+ this is the main print working routine.
+
+ @param Buffer Character buffer to print the results of the parsing
+ of Format into.
+ @param BufferSize Maximum number of characters to put into buffer.
+ Zero means no limit.
+ @param Flags Intial flags value.
+ Can only have FORMAT_UNICODE and OUTPUT_UNICODE set
+ @param FormatString Null-terminated format string.
+
+ @return Number of characters printed not including the Null-terminator.
+
+**/
+UINTN
+BasePrintLibSPrint (
+ OUT CHAR8 *StartOfBuffer,
+ IN UINTN BufferSize,
+ IN UINTN Flags,
+ IN CONST CHAR8 *FormatString,
+ ...
+ )
+{
+ VA_LIST Marker;
+
+ VA_START (Marker, FormatString);
+ return BasePrintLibVSPrint (StartOfBuffer, BufferSize, Flags, FormatString, Marker);
+}
+
+/**
+ Produces a Null-terminated Unicode string in an output buffer based on
+ a Null-terminated Unicode format string and a VA_LIST argument list
+
+ Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer
+ and BufferSize.
+ The Unicode string is produced by parsing the format string specified by FormatString.
+ Arguments are pulled from the variable argument list specified by Marker based on the
+ contents of the format string.
+ The number of Unicode characters in the produced output buffer is returned not including
+ the Null-terminator.
+ If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.
+
+ If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().
+ If BufferSize > 1 and FormatString is NULL, then ASSERT().
+ If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
+ PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
+ ASSERT().
+ If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string
+ contains more than PcdMaximumUnicodeStringLength Unicode characters not including the
+ Null-terminator, then ASSERT().
+
+ @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
+ Unicode string.
+ @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
+ @param FormatString Null-terminated Unicode format string.
+ @param Marker VA_LIST marker for the variable argument list.
+
+ @return The number of Unicode characters in the produced output buffer not including the
+ Null-terminator.
+
+**/
+UINTN
+EFIAPI
+UnicodeVSPrint (
+ OUT CHAR16 *StartOfBuffer,
+ IN UINTN BufferSize,
+ IN CONST CHAR16 *FormatString,
+ IN VA_LIST Marker
+ )
+{
+ return BasePrintLibVSPrint ((CHAR8 *)StartOfBuffer, BufferSize >> 1, FORMAT_UNICODE | OUTPUT_UNICODE, (CHAR8 *)FormatString, Marker);
+}
+
+/**
+ Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated
+ Unicode format string and variable argument list.
+
+ Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer
+ and BufferSize.
+ The Unicode string is produced by parsing the format string specified by FormatString.
+ Arguments are pulled from the variable argument list based on the contents of the format string.
+ The number of Unicode characters in the produced output buffer is returned not including
+ the Null-terminator.
+ If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.
+
+ If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().
+ If BufferSize > 1 and FormatString is NULL, then ASSERT().
+ If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
+ PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
+ ASSERT().
+ If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string
+ contains more than PcdMaximumUnicodeStringLength Unicode characters not including the
+ Null-terminator, then ASSERT().
+
+ @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
+ Unicode string.
+ @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
+ @param FormatString Null-terminated Unicode format string.
+
+ @return The number of Unicode characters in the produced output buffer not including the
+ Null-terminator.
+
+**/
+UINTN
+EFIAPI
+UnicodeSPrint (
+ OUT CHAR16 *StartOfBuffer,
+ IN UINTN BufferSize,
+ IN CONST CHAR16 *FormatString,
+ ...
+ )
+{
+ VA_LIST Marker;
+
+ VA_START (Marker, FormatString);
+ return UnicodeVSPrint (StartOfBuffer, BufferSize, FormatString, Marker);
+}
+
+/**
+ Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated
+ ASCII format string and a VA_LIST argument list
+
+ Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer
+ and BufferSize.
+ The Unicode string is produced by parsing the format string specified by FormatString.
+ Arguments are pulled from the variable argument list specified by Marker based on the
+ contents of the format string.
+ The number of Unicode characters in the produced output buffer is returned not including
+ the Null-terminator.
+ If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.
+
+ If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().
+ If BufferSize > 1 and FormatString is NULL, then ASSERT().
+ If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
+ PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then
+ ASSERT().
+ If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string
+ contains more than PcdMaximumUnicodeStringLength Unicode characters not including the
+ Null-terminator, then ASSERT().
+
+ @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
+ Unicode string.
+ @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
+ @param FormatString Null-terminated Unicode format string.
+ @param Marker VA_LIST marker for the variable argument list.
+
+ @return The number of Unicode characters in the produced output buffer not including the
+ Null-terminator.
+
+**/
+UINTN
+EFIAPI
+UnicodeVSPrintAsciiFormat (
+ OUT CHAR16 *StartOfBuffer,
+ IN UINTN BufferSize,
+ IN CONST CHAR8 *FormatString,
+ IN VA_LIST Marker
+ )
+{
+ return BasePrintLibVSPrint ((CHAR8 *)StartOfBuffer, BufferSize >> 1, OUTPUT_UNICODE,FormatString, Marker);
+}
+
+/**
+ Produces a Null-terminated Unicode string in an output buffer based on a Null-terminated
+ ASCII format string and variable argument list.
+
+ Produces a Null-terminated Unicode string in the output buffer specified by StartOfBuffer
+ and BufferSize.
+ The Unicode string is produced by parsing the format string specified by FormatString.
+ Arguments are pulled from the variable argument list based on the contents of the
+ format string.
+ The number of Unicode characters in the produced output buffer is returned not including
+ the Null-terminator.
+ If BufferSize is 0 or 1, then no output buffer is produced and 0 is returned.
+
+ If BufferSize > 1 and StartOfBuffer is NULL, then ASSERT().
+ If BufferSize > 1 and FormatString is NULL, then ASSERT().
+ If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
+ PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then
+ ASSERT().
+ If PcdMaximumUnicodeStringLength is not zero, and produced Null-terminated Unicode string
+ contains more than PcdMaximumUnicodeStringLength Unicode characters not including the
+ Null-terminator, then ASSERT().
+
+ @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
+ Unicode string.
+ @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
+ @param FormatString Null-terminated Unicode format string.
+
+ @return The number of Unicode characters in the produced output buffer not including the
+ Null-terminator.
+
+**/
+UINTN
+EFIAPI
+UnicodeSPrintAsciiFormat (
+ OUT CHAR16 *StartOfBuffer,
+ IN UINTN BufferSize,
+ IN CONST CHAR8 *FormatString,
+ ...
+ )
+{
+ VA_LIST Marker;
+
+ VA_START (Marker, FormatString);
+ return UnicodeVSPrintAsciiFormat (StartOfBuffer, BufferSize, FormatString, Marker);
+}
+
+/**
+ Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
+ ASCII format string and a VA_LIST argument list.
+
+ Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
+ and BufferSize.
+ The ASCII string is produced by parsing the format string specified by FormatString.
+ Arguments are pulled from the variable argument list specified by Marker based on
+ the contents of the format string.
+ The number of ASCII characters in the produced output buffer is returned not including
+ the Null-terminator.
+ If BufferSize is 0, then no output buffer is produced and 0 is returned.
+
+ If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().
+ If BufferSize > 0 and FormatString is NULL, then ASSERT().
+ If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
+ PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then
+ ASSERT().
+ If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string
+ contains more than PcdMaximumAsciiStringLength ASCII characters not including the
+ Null-terminator, then ASSERT().
+
+ @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
+ ASCII string.
+ @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
+ @param FormatString Null-terminated Unicode format string.
+ @param Marker VA_LIST marker for the variable argument list.
+
+ @return The number of ASCII characters in the produced output buffer not including the
+ Null-terminator.
+
+**/
+UINTN
+EFIAPI
+AsciiVSPrint (
+ OUT CHAR8 *StartOfBuffer,
+ IN UINTN BufferSize,
+ IN CONST CHAR8 *FormatString,
+ IN VA_LIST Marker
+ )
+{
+ return BasePrintLibVSPrint (StartOfBuffer, BufferSize, 0, FormatString, Marker);
+}
+
+/**
+ Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
+ ASCII format string and variable argument list.
+
+ Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
+ and BufferSize.
+ The ASCII string is produced by parsing the format string specified by FormatString.
+ Arguments are pulled from the variable argument list based on the contents of the
+ format string.
+ The number of ASCII characters in the produced output buffer is returned not including
+ the Null-terminator.
+ If BufferSize is 0, then no output buffer is produced and 0 is returned.
+
+ If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().
+ If BufferSize > 0 and FormatString is NULL, then ASSERT().
+ If PcdMaximumAsciiStringLength is not zero, and FormatString contains more than
+ PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator, then
+ ASSERT().
+ If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string
+ contains more than PcdMaximumAsciiStringLength ASCII characters not including the
+ Null-terminator, then ASSERT().
+
+ @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
+ ASCII string.
+ @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
+ @param FormatString Null-terminated Unicode format string.
+
+ @return The number of ASCII characters in the produced output buffer not including the
+ Null-terminator.
+
+**/
+UINTN
+EFIAPI
+AsciiSPrint (
+ OUT CHAR8 *StartOfBuffer,
+ IN UINTN BufferSize,
+ IN CONST CHAR8 *FormatString,
+ ...
+ )
+{
+ VA_LIST Marker;
+
+ VA_START (Marker, FormatString);
+ return AsciiVSPrint (StartOfBuffer, BufferSize, FormatString, Marker);
+}
+
+/**
+ Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
+ ASCII format string and a VA_LIST argument list.
+
+ Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
+ and BufferSize.
+ The ASCII string is produced by parsing the format string specified by FormatString.
+ Arguments are pulled from the variable argument list specified by Marker based on
+ the contents of the format string.
+ The number of ASCII characters in the produced output buffer is returned not including
+ the Null-terminator.
+ If BufferSize is 0, then no output buffer is produced and 0 is returned.
+
+ If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().
+ If BufferSize > 0 and FormatString is NULL, then ASSERT().
+ If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
+ PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
+ ASSERT().
+ If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string
+ contains more than PcdMaximumAsciiStringLength ASCII characters not including the
+ Null-terminator, then ASSERT().
+
+ @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
+ ASCII string.
+ @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
+ @param FormatString Null-terminated Unicode format string.
+ @param Marker VA_LIST marker for the variable argument list.
+
+ @return The number of ASCII characters in the produced output buffer not including the
+ Null-terminator.
+
+**/
+UINTN
+EFIAPI
+AsciiVSPrintUnicodeFormat (
+ OUT CHAR8 *StartOfBuffer,
+ IN UINTN BufferSize,
+ IN CONST CHAR16 *FormatString,
+ IN VA_LIST Marker
+ )
+{
+ return BasePrintLibVSPrint (StartOfBuffer, BufferSize, FORMAT_UNICODE, (CHAR8 *)FormatString, Marker);
+}
+
+/**
+ Produces a Null-terminated ASCII string in an output buffer based on a Null-terminated
+ ASCII format string and variable argument list.
+
+ Produces a Null-terminated ASCII string in the output buffer specified by StartOfBuffer
+ and BufferSize.
+ The ASCII string is produced by parsing the format string specified by FormatString.
+ Arguments are pulled from the variable argument list based on the contents of the
+ format string.
+ The number of ASCII characters in the produced output buffer is returned not including
+ the Null-terminator.
+ If BufferSize is 0, then no output buffer is produced and 0 is returned.
+
+ If BufferSize > 0 and StartOfBuffer is NULL, then ASSERT().
+ If BufferSize > 0 and FormatString is NULL, then ASSERT().
+ If PcdMaximumUnicodeStringLength is not zero, and FormatString contains more than
+ PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator, then
+ ASSERT().
+ If PcdMaximumAsciiStringLength is not zero, and produced Null-terminated ASCII string
+ contains more than PcdMaximumAsciiStringLength ASCII characters not including the
+ Null-terminator, then ASSERT().
+
+ @param StartOfBuffer A pointer to the output buffer for the produced Null-terminated
+ ASCII string.
+ @param BufferSize The size, in bytes, of the output buffer specified by StartOfBuffer.
+ @param FormatString Null-terminated Unicode format string.
+
+ @return The number of ASCII characters in the produced output buffer not including the
+ Null-terminator.
+
+**/
+UINTN
+EFIAPI
+AsciiSPrintUnicodeFormat (
+ OUT CHAR8 *StartOfBuffer,
+ IN UINTN BufferSize,
+ IN CONST CHAR16 *FormatString,
+ ...
+ )
+{
+ VA_LIST Marker;
+
+ VA_START (Marker, FormatString);
+ return AsciiVSPrintUnicodeFormat (StartOfBuffer, BufferSize, FormatString, Marker);
+}
+
+/**
+ Converts a decimal value to a Null-terminated Unicode string.
+
+ Converts the decimal number specified by Value to a Null-terminated Unicode
+ string specified by Buffer containing at most Width characters.
+ If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.
+ The number of Unicode characters in Buffer is returned not including the Null-terminator.
+ If the conversion contains more than Width characters, then only the first
+ Width characters are returned, and the total number of characters
+ required to perform the conversion is returned.
+ Additional conversion parameters are specified in Flags.
+ The Flags bit LEFT_JUSTIFY is always ignored.
+ All conversions are left justified in Buffer.
+ If Width is 0, PREFIX_ZERO is ignored in Flags.
+ If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas
+ are inserted every 3rd digit starting from the right.
+ If Value is < 0, then the fist character in Buffer is a '-'.
+ If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored,
+ then Buffer is padded with '0' characters so the combination of the optional '-'
+ sign character, '0' characters, digit characters for Value, and the Null-terminator
+ add up to Width characters.
+
+ If Buffer is NULL, then ASSERT().
+ If unsupported bits are set in Flags, then ASSERT().
+ If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()
+
+ @param Buffer Pointer to the output buffer for the produced Null-terminated
+ Unicode string.
+ @param Flags The bitmask of flags that specify left justification, zero pad, and commas.
+ @param Value The 64-bit signed value to convert to a string.
+ @param Width The maximum number of Unicode characters to place in Buffer, not including
+ the Null-terminator.
+
+ @return The number of Unicode characters in Buffer not including the Null-terminator.
+
+**/
+UINTN
+EFIAPI
+UnicodeValueToString (
+ IN OUT CHAR16 *Buffer,
+ IN UINTN Flags,
+ IN INT64 Value,
+ IN UINTN Width
+ )
+{
+ return BasePrintLibConvertValueToString ((CHAR8 *)Buffer, Flags, Value, Width, 2);
+}
+
+/**
+ Converts a decimal value to a Null-terminated ASCII string.
+
+ Converts the decimal number specified by Value to a Null-terminated ASCII string
+ specified by Buffer containing at most Width characters.
+ If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.
+ The number of ASCII characters in Buffer is returned not including the Null-terminator.
+ If the conversion contains more than Width characters, then only the first Width
+ characters are returned, and the total number of characters required to perform
+ the conversion is returned.
+ Additional conversion parameters are specified in Flags.
+ The Flags bit LEFT_JUSTIFY is always ignored.
+ All conversions are left justified in Buffer.
+ If Width is 0, PREFIX_ZERO is ignored in Flags.
+ If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas
+ are inserted every 3rd digit starting from the right.
+ If Value is < 0, then the fist character in Buffer is a '-'.
+ If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored, then Buffer
+ is padded with '0' characters so the combination of the optional '-'
+ sign character, '0' characters, digit characters for Value, and the
+ Null-terminator add up to Width characters.
+
+ If Buffer is NULL, then ASSERT().
+ If unsupported bits are set in Flags, then ASSERT().
+ If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()
+
+ @param Buffer Pointer to the output buffer for the produced Null-terminated
+ ASCII string.
+ @param Flags The bitmask of flags that specify left justification, zero pad, and commas.
+ @param Value The 64-bit signed value to convert to a string.
+ @param Width The maximum number of ASCII characters to place in Buffer, not including
+ the Null-terminator.
+
+ @return The number of ASCII characters in Buffer not including the Null-terminator.
+
+**/
+UINTN
+EFIAPI
+AsciiValueToString (
+ IN OUT CHAR8 *Buffer,
+ IN UINTN Flags,
+ IN INT64 Value,
+ IN UINTN Width
+ )
+{
+ return BasePrintLibConvertValueToString ((CHAR8 *)Buffer, Flags, Value, Width, 1);
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/PrintLibInternal.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/PrintLibInternal.c
new file mode 100644
index 0000000..83f75a5
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/PrintLibInternal.c
@@ -0,0 +1,215 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ PrintLibInternal.c
+
+Abstract:
+
+ Print Library worker functions.
+
+--*/
+
+#include "PrintLibInternal.h"
+
+GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 mHexStr[] = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
+
+
+/**
+ Internal function that places the character into the Buffer.
+
+ Internal function that places ASCII or Unicode character into the Buffer.
+
+ @param Buffer Buffer to place the Unicode or ASCII string.
+ @param EndBuffer The end of the input Buffer. No characters will be
+ placed after that.
+ @param Length Count of character to be placed into Buffer.
+ @param Character Character to be placed into Buffer.
+ @param Increment Character increment in Buffer.
+
+ @return Number of characters printed.
+
+**/
+CHAR8 *
+BasePrintLibFillBuffer (
+ CHAR8 *Buffer,
+ CHAR8 *EndBuffer,
+ INTN Length,
+ UINTN Character,
+ INTN Increment
+ )
+{
+ INTN Index;
+
+ for (Index = 0; Index < Length && Buffer < EndBuffer; Index++) {
+ *Buffer = (CHAR8) Character;
+ *(Buffer + 1) = (CHAR8) (Character >> 8);
+ Buffer += Increment;
+ }
+ return Buffer;
+}
+
+/**
+ Internal function that convert a decimal number to a string in Buffer.
+
+ Print worker function that convert a decimal number to a string in Buffer.
+
+ @param Buffer Location to place the Unicode or ASCII string of Value.
+ @param Value Value to convert to a Decimal or Hexidecimal string in Buffer.
+ @param Radix Radix of the value
+
+ @return Number of characters printed.
+
+**/
+UINTN
+EFIAPI
+BasePrintLibValueToString (
+ IN OUT CHAR8 *Buffer,
+ IN INT64 Value,
+ IN UINTN Radix
+ )
+{
+ UINTN Digits;
+ UINT32 Remainder;
+
+ //
+ // Loop to convert one digit at a time in reverse order
+ //
+ *(Buffer++) = 0;
+ Digits = 0;
+ do {
+ Value = (INT64)DivU64x32Remainder ((UINT64)Value, (UINT32)Radix, &Remainder);
+ *(Buffer++) = mHexStr[Remainder];
+ Digits++;
+ } while (Value != 0);
+ return Digits;
+}
+
+/**
+ Internal function that converts a decimal value to a Null-terminated string.
+
+ Converts the decimal number specified by Value to a Null-terminated
+ string specified by Buffer containing at most Width characters.
+ If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.
+ The number of characters in Buffer is returned not including the Null-terminator.
+ If the conversion contains more than Width characters, then only the first
+ Width characters are returned, and the total number of characters
+ required to perform the conversion is returned.
+ Additional conversion parameters are specified in Flags.
+ The Flags bit LEFT_JUSTIFY is always ignored.
+ All conversions are left justified in Buffer.
+ If Width is 0, PREFIX_ZERO is ignored in Flags.
+ If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas
+ are inserted every 3rd digit starting from the right.
+ If HEX_RADIX is set in Flags, then the output buffer will be formatted in hexadecimal format.
+ If Value is < 0 and HEX_RADIX is not set in Flags, then the fist character in Buffer is a '-'.
+ If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored,
+ then Buffer is padded with '0' characters so the combination of the optional '-'
+ sign character, '0' characters, digit characters for Value, and the Null-terminator
+ add up to Width characters.
+ If both COMMA_TYPE and HEX_RADIX are set in Flags, then ASSERT().
+
+ If Buffer is NULL, then ASSERT().
+ If unsupported bits are set in Flags, then ASSERT().
+ If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()
+
+ @param Buffer Pointer to the output buffer for the produced Null-terminated
+ string.
+ @param Flags The bitmask of flags that specify left justification, zero pad,
+ and commas.
+ @param Value The 64-bit signed value to convert to a string.
+ @param Width The maximum number of characters to place in Buffer, not including
+ the Null-terminator.
+ @param Increment Character increment in Buffer.
+
+ @return The number of characters in Buffer not including the Null-terminator.
+
+**/
+UINTN
+BasePrintLibConvertValueToString (
+ IN OUT CHAR8 *Buffer,
+ IN UINTN Flags,
+ IN INT64 Value,
+ IN UINTN Width,
+ IN UINTN Increment
+ )
+{
+ CHAR8 *OriginalBuffer;
+ CHAR8 *EndBuffer;
+ CHAR8 ValueBuffer[MAXIMUM_VALUE_CHARACTERS];
+ UINTN Count;
+ UINTN Digits;
+ UINTN Index;
+ UINTN Radix;
+
+ ASSERT (Buffer != NULL);
+ ASSERT (Width < MAXIMUM_VALUE_CHARACTERS);
+ //
+ // Make sure Flags can only contain supported bits.
+ //
+ ASSERT ((Flags & ~(LEFT_JUSTIFY | COMMA_TYPE | PREFIX_ZERO | RADIX_HEX)) == 0);
+
+ //
+ // If both COMMA_TYPE and HEX_RADIX are set, then ASSERT ()
+ //
+ ASSERT (((Flags & COMMA_TYPE) != 0 && (Flags & RADIX_HEX) != 0) == FALSE);
+
+ OriginalBuffer = Buffer;
+
+ if (Width == 0 || (Flags & COMMA_TYPE) != 0) {
+ Flags &= (~PREFIX_ZERO);
+ }
+
+ if (Width == 0) {
+ Width = MAXIMUM_VALUE_CHARACTERS - 1;
+ }
+ //
+ // Set the tag for the end of the input Buffer.
+ //
+ EndBuffer = Buffer + Width * Increment;
+
+ if ((Value < 0) && ((Flags & RADIX_HEX) == 0)) {
+ Value = -Value;
+ Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, 1, '-', Increment);
+ Width--;
+ }
+
+ Radix = ((Flags & RADIX_HEX) == 0)? 10 : 16;
+ Count = BasePrintLibValueToString (ValueBuffer, Value, Radix);
+
+ if ((Flags & PREFIX_ZERO) != 0) {
+ Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, Width - Count, '0', Increment);
+ }
+
+ Digits = Count % 3;
+ if (Digits != 0) {
+ Digits = 3 - Digits;
+ }
+ for (Index = 0; Index < Count; Index++) {
+ Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, 1, ValueBuffer[Count - Index], Increment);
+ if ((Flags & COMMA_TYPE) != 0) {
+ Digits++;
+ if (Digits == 3) {
+ Digits = 0;
+ if ((Index + 1) < Count) {
+ Buffer = BasePrintLibFillBuffer (Buffer, EndBuffer, 1, ',', Increment);
+ }
+ }
+ }
+ }
+
+ BasePrintLibFillBuffer (Buffer, EndBuffer + Increment, 1, 0, Increment);
+
+ return ((Buffer - OriginalBuffer) / Increment);
+}
+
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/PrintLibInternal.h b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/PrintLibInternal.h
new file mode 100644
index 0000000..db621f2
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BasePrintLib/PrintLibInternal.h
@@ -0,0 +1,181 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ PrintLibInternal.h
+
+Abstract:
+
+ Print Library.
+
+--*/
+
+#ifndef __PRINT_LIB_INTERNAL_H__
+#define __PRINT_LIB_INTERNAL_H__
+
+#include "EdkIIGlueBase.h"
+
+//
+// Print primitives
+//
+//#define LEFT_JUSTIFY 0x01
+#define PREFIX_SIGN 0x02
+#define PREFIX_BLANK 0x04
+//#define COMMA_TYPE 0x08
+#define LONG_TYPE 0x10
+//#define PREFIX_ZERO 0x20
+#define OUTPUT_UNICODE 0x40
+#define RADIX_HEX 0x80
+#define FORMAT_UNICODE 0x100
+#define PAD_TO_WIDTH 0x200
+#define ARGUMENT_UNICODE 0x400
+#define PRECISION 0x800
+#define ARGUMENT_REVERSED 0x1000
+
+//
+// Record date and time information
+//
+typedef struct {
+ UINT16 Year;
+ UINT8 Month;
+ UINT8 Day;
+ UINT8 Hour;
+ UINT8 Minute;
+ UINT8 Second;
+ UINT8 Pad1;
+ UINT32 Nanosecond;
+ INT16 TimeZone;
+ UINT8 Daylight;
+ UINT8 Pad2;
+} TIME;
+
+/**
+ Worker function that produces a Null-terminated string in an output buffer
+ based on a Null-terminated format string and variable argument list.
+
+ VSPrint function to process format and place the results in Buffer. Since a
+ VA_LIST is used this rountine allows the nesting of Vararg routines. Thus
+ this is the main print working routine
+
+ @param Buffer Character buffer to print the results of the parsing
+ of Format into.
+ @param BufferSize Maximum number of characters to put into buffer.
+ Zero means no limit.
+ @param Flags Intial flags value.
+ Can only have FORMAT_UNICODE and OUTPUT_UNICODE set
+ @param FormatString Null-terminated format string.
+
+ @return Number of characters printed.
+
+**/
+UINTN
+BasePrintLibSPrint (
+ OUT CHAR8 *Buffer,
+ IN UINTN BufferSize,
+ IN UINTN Flags,
+ IN CONST CHAR8 *FormatString,
+ ...
+ );
+
+/**
+ Internal function that places the character into the Buffer.
+
+ Internal function that places ASCII or Unicode character into the Buffer.
+
+ @param Buffer Buffer to place the Unicode or ASCII string.
+ @param EndBuffer The end of the input Buffer. No characters will be
+ placed after that.
+ @param Length Count of character to be placed into Buffer.
+ @param Character Character to be placed into Buffer.
+ @param Increment Character increment in Buffer.
+
+ @return Number of characters printed.
+
+**/
+CHAR8 *
+BasePrintLibFillBuffer (
+ CHAR8 *Buffer,
+ CHAR8 *EndBuffer,
+ INTN Length,
+ UINTN Character,
+ INTN Increment
+ );
+
+/**
+ Internal function that convert a decimal number to a string in Buffer.
+
+ Print worker function that convert a decimal number to a string in Buffer.
+
+ @param Buffer Location to place the Unicode or ASCII string of Value.
+ @param Value Value to convert to a Decimal or Hexidecimal string in Buffer.
+ @param Radix Radix of the value
+
+ @return Number of characters printed.
+
+**/
+UINTN
+EFIAPI
+BasePrintLibValueToString (
+ IN OUT CHAR8 *Buffer,
+ IN INT64 Value,
+ IN UINTN Radix
+ );
+
+/**
+ Internal function that converts a decimal value to a Null-terminated string.
+
+ Converts the decimal number specified by Value to a Null-terminated
+ string specified by Buffer containing at most Width characters.
+ If Width is 0 then a width of MAXIMUM_VALUE_CHARACTERS is assumed.
+ The total number of characters placed in Buffer is returned.
+ If the conversion contains more than Width characters, then only the first
+ Width characters are returned, and the total number of characters
+ required to perform the conversion is returned.
+ Additional conversion parameters are specified in Flags.
+ The Flags bit LEFT_JUSTIFY is always ignored.
+ All conversions are left justified in Buffer.
+ If Width is 0, PREFIX_ZERO is ignored in Flags.
+ If COMMA_TYPE is set in Flags, then PREFIX_ZERO is ignored in Flags, and commas
+ are inserted every 3rd digit starting from the right.
+ If Value is < 0, then the fist character in Buffer is a '-'.
+ If PREFIX_ZERO is set in Flags and PREFIX_ZERO is not being ignored,
+ then Buffer is padded with '0' characters so the combination of the optional '-'
+ sign character, '0' characters, digit characters for Value, and the Null-terminator
+ add up to Width characters.
+
+ If Buffer is NULL, then ASSERT().
+ If unsupported bits are set in Flags, then ASSERT().
+ If Width >= MAXIMUM_VALUE_CHARACTERS, then ASSERT()
+
+ @param Buffer Pointer to the output buffer for the produced Null-terminated
+ string.
+ @param Flags The bitmask of flags that specify left justification, zero pad,
+ and commas.
+ @param Value The 64-bit signed value to convert to a string.
+ @param Width The maximum number of characters to place in Buffer, not including
+ the Null-terminator.
+ @param Increment Character increment in Buffer.
+
+ @return Total number of characters required to perform the conversion.
+
+**/
+UINTN
+BasePrintLibConvertValueToString (
+ IN OUT CHAR8 *Buffer,
+ IN UINTN Flags,
+ IN INT64 Value,
+ IN UINTN Width,
+ IN UINTN Increment
+ );
+
+#endif
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibLocalApic/BaseTimerLibLocalApic.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibLocalApic/BaseTimerLibLocalApic.inf
new file mode 100644
index 0000000..e41daab
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibLocalApic/BaseTimerLibLocalApic.inf
@@ -0,0 +1,79 @@
+#/*++
+#
+# Copyright (c) 2004 - 2006, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# BaseTimerLibLocalApic.inf
+#
+# Abstract:
+#
+# Component description file for BaseTimerLibLocalApic.
+#
+#--*/
+
+[defines]
+BASE_NAME = EdkIIGlueBaseTimerLibLocalApic
+COMPONENT_TYPE = LIBRARY
+
+[sources.common]
+
+[sources.ia32]
+ x86TimerLib.c
+
+[sources.x64]
+ x86TimerLib.c
+
+
+[sources.ipf]
+
+[sources.ebc]
+
+
+[includes.common]
+ .
+ ..\..\Include
+ ..\..\include\Library
+ $(EDK_SOURCE)\Foundation
+ $(EDK_SOURCE)\Foundation\Framework
+ $(EDK_SOURCE)\Foundation\Efi
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+ $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include
+
+[libraries.common]
+ EdkIIGlueBaseLib
+ EdkIIGlueBaseIoLibIntrinsic
+
+[libraries.ia32]
+
+
+[libraries.x64]
+
+
+[nmake.common]
+ C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION
+ LIB_STD_FLAGS = /NOLOGO /IGNORE:4006
+
+[nmake.ia32]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32
+
+[nmake.x64]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64
+
+[nmake.ipf]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF
+
+[nmake.ebc]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibLocalApic/EdkIIGlueBaseTimerLibLocalApic.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibLocalApic/EdkIIGlueBaseTimerLibLocalApic.cif
new file mode 100644
index 0000000..89bdee3
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibLocalApic/EdkIIGlueBaseTimerLibLocalApic.cif
@@ -0,0 +1,11 @@
+<component>
+ name = "EdkIIGlueBaseTimerLibLocalApic"
+ category = ModulePart
+ LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\BaseTimerLibLocalApic"
+ RefName = "EdkIIGlueBaseTimerLibLocalApic"
+[files]
+"EdkIIGlueBaseTimerLibLocalApic.sdl"
+"EdkIIGlueBaseTimerLibLocalApic.mak"
+"BaseTimerLibLocalApic.inf"
+"x86TimerLib.c"
+<endComponent>
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibLocalApic/EdkIIGlueBaseTimerLibLocalApic.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibLocalApic/EdkIIGlueBaseTimerLibLocalApic.mak
new file mode 100644
index 0000000..a4798db
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibLocalApic/EdkIIGlueBaseTimerLibLocalApic.mak
@@ -0,0 +1,87 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueBaseTimerLibLocalApic/EdkIIGlueBaseTimerLibLocalApic.mak 1 1/20/12 3:54a Jeffch $
+#
+# $Revision: 1 $
+#
+# $Date: 1/20/12 3:54a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueBaseTimerLibLocalApic/EdkIIGlueBaseTimerLibLocalApic.mak $
+#
+# 1 1/20/12 3:54a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 9/27/11 6:16a Wesleychen
+# Intel EDK initially releases.
+#
+# 1 9/18/09 1:53a Iminglin
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: EdkIIGlueBaseTimerLibLocalApic.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#***************************************************************s*******
+
+
+$(EdkIIGlueBaseTimerLibLocalApic_LIB) : EdkIIGlueBaseTimerLibLocalApic
+
+$(EdkIIGlueBaseTimerLibLocalApic_LIB) : EdkIIGlueBaseTimerLibLocalApic
+
+EdkIIGlueBaseTimerLibLocalApic : $(BUILD_DIR)\EdkIIGlueBaseTimerLibLocalApic.mak EdkIIGlueBaseTimerLibLocalApicBin
+
+$(BUILD_DIR)\EdkIIGlueBaseTimerLibLocalApic.mak : $(EdkIIGlueBaseTimerLibLocalApic_DIR)\$(@B).cif $(EdkIIGlueBaseTimerLibLocalApic_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(EdkIIGlueBaseTimerLibLocalApic_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+EdkIIGlueBaseTimerLibLocalApic_LIB_LINKS=$(EdkIIGlueBaseLib_LIB)\
+!IF "$(PROCESSOR)"=="IA32" || "$(PROCESSOR)"=="x64"
+$(EdkIIGlueBaseIoLibIntrinsic_LIB)
+!ENDIF
+
+EdkIIGlueBaseTimerLibLocalApicBin : $(EdkIIGlueBaseTimerLibLocalApic_LIB_LINKS)
+!IF "$(x64_BUILD)"=="1"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGlueBaseTimerLibLocalApic.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBaseTimerLibLocalApic_LIB)"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\IA32\
+ /f $(BUILD_DIR)\EdkIIGlueBaseTimerLibLocalApic.mak all\
+ TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBaseTimerLibLocalApic_LIB)"
+!ELSE
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGlueBaseTimerLibLocalApic.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBaseTimerLibLocalApic_LIB)"
+!ENDIF
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibLocalApic/EdkIIGlueBaseTimerLibLocalApic.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibLocalApic/EdkIIGlueBaseTimerLibLocalApic.sdl
new file mode 100644
index 0000000..b132527
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibLocalApic/EdkIIGlueBaseTimerLibLocalApic.sdl
@@ -0,0 +1,26 @@
+TOKEN
+ Name = "EdkIIGlueBaseTimerLibLocalApic_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable EdkIIGlueBaseTimerLibLocalApic support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "EdkIIGlueBaseTimerLibLocalApic_LIB"
+ Value = "$$(LIB_BUILD_DIR)\EdkIIGlueBaseTimerLibLocalApic.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "EdkIIGlueBaseTimerLibLocalApic_DIR"
+End
+
+MODULE
+ Help = "Includes EdkIIGlueBaseTimerLibLocalApic.mak to Project"
+ File = "EdkIIGlueBaseTimerLibLocalApic.mak"
+End
+
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibLocalApic/x86TimerLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibLocalApic/x86TimerLib.c
new file mode 100644
index 0000000..a19e16d
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibLocalApic/x86TimerLib.c
@@ -0,0 +1,293 @@
+/*++
+
+Copyright (c) 2004 - 2011, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ x86TimerLib.c
+
+Abstract:
+
+ Timer Library functions built upon local APIC on IA32/x64.
+
+ @bug Should use PCD to retrieve all the constants including index of
+ the IA32_APIC_BASE MSR, the offsets of InitialCount, CorrentCount
+ and DivideConfiguration.
+
+--*/
+
+#include "EdkIIGlueBase.h"
+
+//
+// The following 2 arrays are used in calculating the frequency of local APIC
+// timer. Refer to IA-32 developers' manual for more details.
+//
+
+GLOBAL_REMOVE_IF_UNREFERENCED
+CONST UINT32 mTimerLibLocalApicFrequencies[] = {
+ 100000000,
+ 133000000,
+ 200000000,
+ 166000000
+};
+
+GLOBAL_REMOVE_IF_UNREFERENCED
+CONST UINT8 mTimerLibLocalApicDivisor[] = {
+ 0x02, 0x04, 0x08, 0x10,
+ 0x02, 0x04, 0x08, 0x10,
+ 0x20, 0x40, 0x80, 0x01,
+ 0x20, 0x40, 0x80, 0x01
+};
+
+/**
+ Internal function to retrieve the base address of local APIC.
+
+ Internal function to retrieve the base address of local APIC.
+
+ @return The base address of local APIC
+
+**/
+STATIC
+UINTN
+InternalX86GetApicBase (
+ VOID
+ )
+{
+ return (UINTN)AsmMsrBitFieldRead64 (27, 12, 35) << 12;
+}
+
+/**
+ Internal function to return the frequency of the local APIC timer.
+
+ Internal function to return the frequency of the local APIC timer.
+
+ @param ApicBase The base address of memory mapped registers of local APIC.
+
+ @return The frequency of the timer in Hz.
+
+**/
+STATIC
+UINT32
+InternalX86GetTimerFrequency (
+ IN UINTN ApicBase
+ )
+{
+ return
+ mTimerLibLocalApicFrequencies[AsmMsrBitFieldRead32 (44, 16, 18)] /
+ mTimerLibLocalApicDivisor[MmioBitFieldRead32 (ApicBase + 0x3e0, 0, 3)];
+}
+
+/**
+ Internal function to read the current tick counter of local APIC.
+
+ Internal function to read the current tick counter of local APIC.
+
+ @param ApicBase The base address of memory mapped registers of local APIC.
+
+ @return The tick counter read.
+
+**/
+STATIC
+INT32
+InternalX86GetTimerTick (
+ IN UINTN ApicBase
+ )
+{
+ return MmioRead32 (ApicBase + 0x390);
+}
+
+/**
+ Stalls the CPU for at least the given number of ticks.
+
+ Stalls the CPU for at least the given number of ticks. It's invoked by
+ MicroSecondDelay() and NanoSecondDelay().
+
+ @param ApicBase The base address of memory mapped registers of local APIC.
+ @param Delay A period of time to delay in ticks.
+
+**/
+STATIC
+VOID
+InternalX86Delay (
+ IN UINTN ApicBase,
+ IN UINT32 Delay
+ )
+{
+ INT32 Ticks;
+
+ //
+ // The target timer count is calculated here
+ //
+ Ticks = InternalX86GetTimerTick (ApicBase) - Delay;
+
+ //
+ // Wait until time out
+ // Delay > 2^31 could not be handled by this function
+ // Timer wrap-arounds are handled correctly by this function
+ //
+ while (InternalX86GetTimerTick (ApicBase) - Ticks >= 0);
+}
+
+/**
+ Stalls the CPU for at least the given number of microseconds.
+
+ Stalls the CPU for the number of microseconds specified by MicroSeconds.
+
+ @param MicroSeconds The minimum number of microseconds to delay.
+
+ @return MicroSeconds
+
+**/
+UINTN
+EFIAPI
+MicroSecondDelay (
+ IN UINTN MicroSeconds
+ )
+{
+ UINTN ApicBase;
+
+ ApicBase = InternalX86GetApicBase ();
+ InternalX86Delay (
+ ApicBase,
+ (UINT32)DivU64x32 (
+ MultU64x64 (
+ InternalX86GetTimerFrequency (ApicBase),
+ MicroSeconds
+ ),
+ 1000000u
+ )
+ );
+ return MicroSeconds;
+}
+
+/**
+ Stalls the CPU for at least the given number of nanoseconds.
+
+ Stalls the CPU for the number of nanoseconds specified by NanoSeconds.
+
+ @param NanoSeconds The minimum number of nanoseconds to delay.
+
+ @return NanoSeconds
+
+**/
+UINTN
+EFIAPI
+NanoSecondDelay (
+ IN UINTN NanoSeconds
+ )
+{
+ UINTN ApicBase;
+
+ ApicBase = InternalX86GetApicBase ();
+ InternalX86Delay (
+ ApicBase,
+ (UINT32)DivU64x32 (
+ MultU64x64 (
+ InternalX86GetTimerFrequency (ApicBase),
+ NanoSeconds
+ ),
+ 1000000000u
+ )
+ );
+ return NanoSeconds;
+}
+
+/**
+ Retrieves the current value of a 64-bit free running performance counter.
+
+ Retrieves the current value of a 64-bit free running performance counter. The
+ counter can either count up by 1 or count down by 1. If the physical
+ performance counter counts by a larger increment, then the counter values
+ must be translated. The properties of the counter can be retrieved from
+ GetPerformanceCounterProperties().
+
+ @return The current value of the free running performance counter.
+
+**/
+UINT64
+EFIAPI
+GetPerformanceCounter (
+ VOID
+ )
+{
+ return (UINT32)InternalX86GetTimerTick (InternalX86GetApicBase ());
+}
+
+/**
+ Retrieves the 64-bit frequency in Hz and the range of performance counter
+ values.
+
+ If StartValue is not NULL, then the value that the performance counter starts
+ with immediately after is it rolls over is returned in StartValue. If
+ EndValue is not NULL, then the value that the performance counter end with
+ immediately before it rolls over is returned in EndValue. The 64-bit
+ frequency of the performance counter in Hz is always returned. If StartValue
+ is less than EndValue, then the performance counter counts up. If StartValue
+ is greater than EndValue, then the performance counter counts down. For
+ example, a 64-bit free running counter that counts up would have a StartValue
+ of 0 and an EndValue of 0xFFFFFFFFFFFFFFFF. A 24-bit free running counter
+ that counts down would have a StartValue of 0xFFFFFF and an EndValue of 0.
+
+ @param StartValue The value the performance counter starts with when it
+ rolls over.
+ @param EndValue The value that the performance counter ends with before
+ it rolls over.
+
+ @return The frequency in Hz.
+
+**/
+UINT64
+EFIAPI
+GetPerformanceCounterProperties (
+ IN UINT64 *StartValue,
+ IN UINT64 *EndValue
+ )
+{
+ UINTN ApicBase;
+
+ ApicBase = InternalX86GetApicBase ();
+
+ if (StartValue != NULL) {
+ *StartValue = MmioRead32 (ApicBase + 0x380);
+ }
+
+ if (EndValue != NULL) {
+ *EndValue = 0;
+ }
+
+ return InternalX86GetTimerFrequency (ApicBase);
+}
+
+/**
+ Retrieves current APIC ID.
+
+ @return UINT32 value of APIC ID
+
+**/
+UINT32
+GetApicId (
+ VOID
+ )
+{
+ UINT32 ApicId;
+ BOOLEAN x2ApicEnabled;
+ UINT64 LocalApicBase;
+
+ x2ApicEnabled = (BOOLEAN) (((AsmReadMsr64 (PcdGet16(XAPICBaseMsr))) & (0x0C00)) == 0x0C00);
+ if (x2ApicEnabled) {
+ ApicId = (UINT32) AsmReadMsr64 (PcdGet32(ExtXAPICLogicalAPICIdMsr));
+ } else {
+ LocalApicBase = ((UINT32) AsmReadMsr64 (PcdGet16(XAPICBaseMsr))) & 0xFFFFF000;
+ ApicId = (UINT8) (*(volatile UINT32 *) (UINTN) (LocalApicBase + 0x20) >> 24);
+ }
+
+ return ApicId;
+} \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibTsc/BaseTimerLibTsc.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibTsc/BaseTimerLibTsc.inf
new file mode 100644
index 0000000..4979885
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibTsc/BaseTimerLibTsc.inf
@@ -0,0 +1,78 @@
+#/*++
+#
+# Copyright (c) 2011, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# EdkIIGlueBaseTimerLibTsc.inf
+#
+# Abstract:
+#
+# Component description file for BaseTimerLibTsc.
+#
+#--*/
+
+[defines]
+BASE_NAME = EdkIIGlueBaseTimerLibTsc
+COMPONENT_TYPE = LIBRARY
+
+[sources.common]
+ TimerLibTsc.c
+
+[sources.ia32]
+
+[sources.x64]
+
+[sources.ipf]
+
+
+[sources.ebc]
+
+
+[includes.common]
+ .
+ ..\..\Include
+ ..\..\include\Library
+ $(EDK_SOURCE)\Foundation
+ $(EDK_SOURCE)\Foundation\Framework
+ $(EDK_SOURCE)\Foundation\Efi
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+ $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include
+ $(EDK_SOURCE)\Foundation\Guid\PeiPeCoffLoader
+
+
+[libraries.common]
+
+[libraries.ia32]
+
+
+[libraries.x64]
+
+
+[nmake.common]
+ C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION
+ LIB_STD_FLAGS = /NOLOGO /IGNORE:4006
+
+[nmake.ia32]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32
+
+[nmake.x64]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64
+
+[nmake.ipf]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF
+
+[nmake.ebc]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibTsc/EdkIIGlueBaseTimerLibTsc.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibTsc/EdkIIGlueBaseTimerLibTsc.cif
new file mode 100644
index 0000000..d65f67f
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibTsc/EdkIIGlueBaseTimerLibTsc.cif
@@ -0,0 +1,11 @@
+<component>
+ name = "EdkIIGlueBaseTimerLibTsc"
+ category = ModulePart
+ LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\BaseTimerLibTsc"
+ RefName = "EdkIIGlueBaseTimerLibTsc"
+[files]
+"EdkIIGlueBaseTimerLibTsc.sdl"
+"EdkIIGlueBaseTimerLibTsc.mak"
+"BaseTimerLibTsc.inf"
+"TimerLibTsc.c"
+<endComponent>
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibTsc/EdkIIGlueBaseTimerLibTsc.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibTsc/EdkIIGlueBaseTimerLibTsc.mak
new file mode 100644
index 0000000..81102d1
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibTsc/EdkIIGlueBaseTimerLibTsc.mak
@@ -0,0 +1,78 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2011, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueBaseTimerLibTsc/EdkIIGlueBaseTimerLibTsc.mak 1 1/20/12 3:59a Jeffch $
+#
+# $Revision: 1 $
+#
+# $Date: 1/20/12 3:59a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueBaseTimerLibTsc/EdkIIGlueBaseTimerLibTsc.mak $
+#
+# 1 1/20/12 3:59a Jeffch
+#
+# 1 9/27/11 6:21a Wesleychen
+# Intel EDK initially releases.
+#
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: EdkIIGlueBaseTimerLibTsc.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+
+
+$(EdkIIGlueBaseTimerLibTsc_LIB) : EdkIIGlueBaseTimerLibTsc
+
+EdkIIGlueBaseTimerLibTsc : $(BUILD_DIR)\EdkIIGlueBaseTimerLibTsc.mak EdkIIGlueBaseTimerLibTscBin
+
+$(BUILD_DIR)\EdkIIGlueBaseTimerLibTsc.mak : $(EdkIIGlueBaseTimerLibTsc_DIR)\$(@B).cif $(EdkIIGlueBaseTimerLibTsc_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(EdkIIGlueBaseTimerLibTsc_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+EdkIIGlueBaseTimerLibTscBin : $(EFIPROTOCOLLIB) $(EDKGUIDLIB) $(ARCHPROTOCOLLIB)
+!IF "$(x64_BUILD)"=="1"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGlueBaseTimerLibTsc.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBaseTimerLibTsc_LIB)"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\IA32\
+ /f $(BUILD_DIR)\EdkIIGlueBaseTimerLibTsc.mak all\
+ TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBaseTimerLibTsc_LIB)"
+!ELSE
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGlueBaseTimerLibTsc.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBaseTimerLibTsc_LIB)"
+!ENDIF
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2011, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#********************************************************************** \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibTsc/EdkIIGlueBaseTimerLibTsc.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibTsc/EdkIIGlueBaseTimerLibTsc.sdl
new file mode 100644
index 0000000..6a8b42d
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibTsc/EdkIIGlueBaseTimerLibTsc.sdl
@@ -0,0 +1,26 @@
+TOKEN
+ Name = "EdkIIGlueBaseTimerLibTsc_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable EdkIIGlueBaseTimerLibTsc support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "EdkIIGlueBaseTimerLibTsc_LIB"
+ Value = "$$(LIB_BUILD_DIR)\EdkIIGlueBaseTimerLibTsc.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "EdkIIGlueBaseTimerLibTsc_DIR"
+End
+
+MODULE
+ Help = "Includes EdkIIGlueBaseTimerLibTsc.mak to Project"
+ File = "EdkIIGlueBaseTimerLibTsc.mak"
+End
+
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibTsc/TimerLibTsc.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibTsc/TimerLibTsc.c
new file mode 100644
index 0000000..7860d8d
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseTimerLibTsc/TimerLibTsc.c
@@ -0,0 +1,46 @@
+/*++
+
+Copyright (c) 2011, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ TimerLibTsc.c
+
+Abstract:
+
+ Timer Library based on TSC timer.
+
+--*/
+
+#include "EdkIIGlueBase.h"
+
+/**
+ Converts TSC value into nano second value.
+
+ @param Timestamp TSC ticker
+
+ @return UINT64 value in naosecond unit converted from TSC
+
+**/
+UINT64
+EFIAPI
+GetTimeInNanoSec (
+ UINT64 Timestamp
+ )
+{
+ UINT64 pi;
+ UINT8 Ratio;
+
+ pi = AsmReadMsr64 (PcdGet16(PlatformInfoMsr));
+ Ratio = (UINT8) (((UINT32) (UINTN) RShiftU64 (pi, 8)) & 0xff);
+
+ return (UINT64) DivU64x32 (MultU64x32 (Timestamp, 10), (UINT32) (Ratio));
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c
new file mode 100644
index 0000000..72a64b5
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.c
@@ -0,0 +1,892 @@
+/*++
+
+Copyright (c) 2004 - 2011, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ BaseUefiDecompressLib.c
+
+Abstract:
+
+ UEFI Decompress Library.
+
+--*/
+
+#include "EdkIIGlueBase.h"
+
+//
+// Decompression algorithm begins here
+//
+#define BITBUFSIZ 32
+#define MAXMATCH 256
+#define THRESHOLD 3
+#define CODE_BIT 16
+#define BAD_TABLE - 1
+
+//
+// C: Char&Len Set; P: Position Set; T: exTra Set
+//
+#define NC (0xff + MAXMATCH + 2 - THRESHOLD)
+#define CBIT 9
+#define MAXPBIT 5
+#define TBIT 5
+#define MAXNP ((1U << MAXPBIT) - 1)
+#define NT (CODE_BIT + 3)
+#if NT > MAXNP
+#define NPT NT
+#else
+#define NPT MAXNP
+#endif
+
+typedef struct {
+ UINT8 *mSrcBase; ///< Starting address of compressed data
+ UINT8 *mDstBase; ///< Starting address of decompressed data
+ UINT32 mOutBuf;
+ UINT32 mInBuf;
+
+ UINT16 mBitCount;
+ UINT32 mBitBuf;
+ UINT32 mSubBitBuf;
+ UINT16 mBlockSize;
+ UINT32 mCompSize;
+ UINT32 mOrigSize;
+
+ UINT16 mBadTableFlag;
+
+ UINT16 mLeft[2 * NC - 1];
+ UINT16 mRight[2 * NC - 1];
+ UINT8 mCLen[NC];
+ UINT8 mPTLen[NPT];
+ UINT16 mCTable[4096];
+ UINT16 mPTTable[256];
+
+ ///
+ /// The length of the field 'Position Set Code Length Array Size' in Block Header.
+ /// For EFI 1.1 de/compression algorithm, mPBit = 4
+ /// For Tiano de/compression algorithm, mPBit = 5
+ ///
+ UINT8 mPBit;
+} SCRATCH_DATA;
+
+/**
+ Read NumOfBit of bits from source into mBitBuf
+
+ Shift mBitBuf NumOfBits left. Read in NumOfBits of bits from source.
+
+ @param Sd The global scratch data
+ @param NumOfBits The number of bits to shift and read.
+
+**/
+VOID
+GlueFillBuf (
+ IN SCRATCH_DATA *Sd,
+ IN UINT16 NumOfBits
+ )
+{
+ //
+ // Left shift NumOfBits of bits in advance
+ //
+ Sd->mBitBuf = (UINT32) (Sd->mBitBuf << NumOfBits);
+
+ //
+ // Copy data needed in bytes into mSbuBitBuf
+ //
+ while (NumOfBits > Sd->mBitCount) {
+
+ Sd->mBitBuf |= (UINT32) (Sd->mSubBitBuf << (NumOfBits = (UINT16) (NumOfBits - Sd->mBitCount)));
+
+ if (Sd->mCompSize > 0) {
+ //
+ // Get 1 byte into SubBitBuf
+ //
+ Sd->mCompSize--;
+ Sd->mSubBitBuf = Sd->mSrcBase[Sd->mInBuf++];
+ Sd->mBitCount = 8;
+
+ } else {
+ //
+ // No more bits from the source, just pad zero bit.
+ //
+ Sd->mSubBitBuf = 0;
+ Sd->mBitCount = 8;
+
+ }
+ }
+
+ //
+ // Caculate additional bit count read to update mBitCount
+ //
+ Sd->mBitCount = (UINT16) (Sd->mBitCount - NumOfBits);
+
+ //
+ // Copy NumOfBits of bits from mSubBitBuf into mBitBuf
+ //
+ Sd->mBitBuf |= Sd->mSubBitBuf >> Sd->mBitCount;
+}
+
+/**
+ Get NumOfBits of bits out from mBitBuf
+
+ Get NumOfBits of bits out from mBitBuf. Fill mBitBuf with subsequent
+ NumOfBits of bits from source. Returns NumOfBits of bits that are
+ popped out.
+
+ @param Sd The global scratch data.
+ @param NumOfBits The number of bits to pop and read.
+
+ @return The bits that are popped out.
+
+**/
+UINT32
+GlueGetBits (
+ IN SCRATCH_DATA *Sd,
+ IN UINT16 NumOfBits
+ )
+{
+ UINT32 OutBits;
+
+ //
+ // Pop NumOfBits of Bits from Left
+ //
+ OutBits = (UINT32) (Sd->mBitBuf >> (BITBUFSIZ - NumOfBits));
+
+ //
+ // Fill up mBitBuf from source
+ //
+ FillBuf (Sd, NumOfBits);
+
+ return OutBits;
+}
+
+/**
+ Creates Huffman Code mapping table according to code length array.
+
+ Creates Huffman Code mapping table for Extra Set, Char&Len Set
+ and Position Set according to code length array.
+
+ @param Sd The global scratch data
+ @param NumOfChar Number of symbols in the symbol set
+ @param BitLen Code length array
+ @param TableBits The width of the mapping table
+ @param Table The table
+
+ @retval 0 OK.
+ @retval BAD_TABLE The table is corrupted.
+
+**/
+UINT16
+GlueMakeTable (
+ IN SCRATCH_DATA *Sd,
+ IN UINT16 NumOfChar,
+ IN UINT8 *BitLen,
+ IN UINT16 TableBits,
+ OUT UINT16 *Table
+ )
+{
+ UINT16 Count[17];
+ UINT16 Weight[17];
+ UINT16 Start[18];
+ UINT16 *Pointer;
+ UINT16 Index3;
+ volatile UINT16 Index;
+ UINT16 Len;
+ UINT16 Char;
+ UINT16 JuBits;
+ UINT16 Avail;
+ UINT16 NextCode;
+ UINT16 Mask;
+
+ //
+ // TableBits should not be greater than 16.
+ //
+ if (TableBits >= (sizeof (Count)/sizeof (UINT16))) {
+ return (UINT16) BAD_TABLE;
+ }
+
+ //
+ // Initializing Start
+ //
+ for (Index = 0; Index <= 17; Index++) {
+ Start[Index] = 0;
+ }
+
+ //
+ // Initialize Count array starting from Index 0, as there is a possibility of Count array being uninitialized.
+ //
+ for (Index = 0; Index <= 16; Index++) {
+ Count[Index] = 0;
+ }
+
+ for (Index = 0; Index < NumOfChar; Index++) {
+ //
+ // Count array index should not be greater than or equal to its size.
+ //
+ if (BitLen[Index] < (sizeof (Count)/sizeof (UINT16))) {
+ Count[BitLen[Index]]++;
+ } else {
+ return (UINT16) BAD_TABLE;
+ }
+ }
+
+ Start[1] = 0;
+
+ for (Index = 1; Index <= 16; Index++) {
+ Start[Index + 1] = (UINT16) (Start[Index] + (Count[Index] << (16 - Index)));
+ }
+
+ if (Start[17] != 0) {
+ /*(1U << 16)*/
+ return (UINT16) BAD_TABLE;
+ }
+
+ JuBits = (UINT16) (16 - TableBits);
+
+ for (Index = 1; Index <= TableBits; Index++) {
+ Start[Index] >>= JuBits;
+ Weight[Index] = (UINT16) (1U << (TableBits - Index));
+ }
+
+ while (Index <= 16) {
+ Weight[Index] = (UINT16) (1U << (16 - Index));
+ Index++;
+ }
+
+ Index = (UINT16) (Start[TableBits + 1] >> JuBits);
+
+ if (Index != 0) {
+ Index3 = (UINT16) (1U << TableBits);
+ while (Index != Index3) {
+ Table[Index++] = 0;
+ }
+ }
+
+ Avail = NumOfChar;
+ Mask = (UINT16) (1U << (15 - TableBits));
+
+ for (Char = 0; Char < NumOfChar; Char++) {
+
+ Len = BitLen[Char];
+ if (Len == 0) {
+ continue;
+ }
+
+ NextCode = (UINT16) (Start[Len] + Weight[Len]);
+
+ if (Len <= TableBits) {
+
+ for (Index = Start[Len]; Index < NextCode; Index++) {
+ Table[Index] = Char;
+ }
+
+ } else {
+
+ Index3 = Start[Len];
+ Pointer = &Table[Index3 >> JuBits];
+ Index = (UINT16) (Len - TableBits);
+
+ while (Index != 0) {
+ //
+ // Avail should be lesser than size of mRight and mLeft to prevent buffer overflow.
+ //
+ if ((*Pointer == 0) && (Avail < sizeof (Sd->mRight)/sizeof (UINT16)) && (Avail < sizeof (Sd->mLeft)/sizeof (UINT16))) {
+ Sd->mRight[Avail] = Sd->mLeft[Avail] = 0;
+ *Pointer = Avail++;
+ }
+
+ //
+ // *Pointer should be lesser than size of mRight and mLeft to prevent buffer overflow.
+ //
+ if ((Index3 & Mask) && (*Pointer < (sizeof (Sd->mRight)/sizeof (UINT16)))) {
+ Pointer = &Sd->mRight[*Pointer];
+ } else if (*Pointer < (sizeof (Sd->mLeft)/sizeof (UINT16))) {
+ Pointer = &Sd->mLeft[*Pointer];
+ }
+
+ Index3 <<= 1;
+ Index--;
+ }
+
+ *Pointer = Char;
+
+ }
+
+ Start[Len] = NextCode;
+ }
+ //
+ // Succeeds
+ //
+ return 0;
+}
+
+/**
+ Decodes a position value.
+
+ Get a position value according to Position Huffman Table.
+
+ @param Sd the global scratch data
+
+ @return The position value decoded.
+
+**/
+UINT32
+GlueDecodeP (
+ IN SCRATCH_DATA *Sd
+ )
+{
+ UINT16 Val;
+ UINT32 Mask;
+ UINT32 Pos;
+
+ Val = Sd->mPTTable[Sd->mBitBuf >> (BITBUFSIZ - 8)];
+
+ if (Val >= MAXNP) {
+ Mask = 1U << (BITBUFSIZ - 1 - 8);
+
+ do {
+
+ if (Sd->mBitBuf & Mask) {
+ Val = Sd->mRight[Val];
+ } else {
+ Val = Sd->mLeft[Val];
+ }
+
+ Mask >>= 1;
+ } while (Val >= MAXNP);
+ }
+ //
+ // Advance what we have read
+ //
+ FillBuf (Sd, Sd->mPTLen[Val]);
+
+ Pos = Val;
+ if (Val > 1) {
+ Pos = (UINT32) ((1U << (Val - 1)) + GetBits (Sd, (UINT16) (Val - 1)));
+ }
+
+ return Pos;
+}
+
+/**
+ Reads code lengths for the Extra Set or the Position Set.
+
+ Read in the Extra Set or Pointion Set Length Arrary, then
+ generate the Huffman code mapping for them.
+
+ @param Sd The global scratch data.
+ @param nn Number of symbols.
+ @param nbit Number of bits needed to represent nn.
+ @param Special The special symbol that needs to be taken care of.
+
+ @retval 0 OK.
+ @retval BAD_TABLE Table is corrupted.
+
+**/
+UINT16
+GlueReadPTLen (
+ IN SCRATCH_DATA *Sd,
+ IN UINT16 nn,
+ IN UINT16 nbit,
+ IN UINT16 Special
+ )
+{
+ UINT16 Number;
+ UINT16 CharC;
+ volatile UINT16 Index;
+ UINT32 Mask;
+
+ //
+ // Read Extra Set Code Length Array size
+ //
+ Number = (UINT16) GetBits (Sd, nbit);
+
+ if ((Number > sizeof (Sd->mPTLen)) || (nn > sizeof (Sd->mPTLen))) {
+ //
+ // Fail if Number or nn is greater than size of mPTLen
+ //
+ return (UINT16) BAD_TABLE;
+ }
+
+ if (Number == 0) {
+ //
+ // This represents only Huffman code used
+ //
+ CharC = (UINT16) GetBits (Sd, nbit);
+
+ for (Index = 0; Index < 256; Index++) {
+ Sd->mPTTable[Index] = CharC;
+ }
+
+ for (Index = 0; Index < nn; Index++) {
+ Sd->mPTLen[Index] = 0;
+ }
+
+ return 0;
+ }
+
+ Index = 0;
+
+ while (Index < Number) {
+
+ CharC = (UINT16) (Sd->mBitBuf >> (BITBUFSIZ - 3));
+
+ //
+ // If a code length is less than 7, then it is encoded as a 3-bit
+ // value. Or it is encoded as a series of "1"s followed by a
+ // terminating "0". The number of "1"s = Code length - 4.
+ //
+ if (CharC == 7) {
+ Mask = 1U << (BITBUFSIZ - 1 - 3);
+ while (Mask & Sd->mBitBuf) {
+ Mask >>= 1;
+ CharC += 1;
+ }
+ }
+
+ FillBuf (Sd, (UINT16) ((CharC < 7) ? 3 : CharC - 3));
+
+ Sd->mPTLen[Index++] = (UINT8) CharC;
+
+ //
+ // For Code&Len Set,
+ // After the third length of the code length concatenation,
+ // a 2-bit value is used to indicated the number of consecutive
+ // zero lengths after the third length.
+ //
+ if (Index == Special) {
+ CharC = (UINT16) GetBits (Sd, 2);
+ while ((INT16) (--CharC) >= 0) {
+ if (Index >= sizeof (Sd->mPTLen)) {
+ //
+ // Fail if Index is greater than or equal to mPTLen
+ //
+ return (UINT16) BAD_TABLE;
+ }
+ Sd->mPTLen[Index++] = 0;
+ }
+ }
+ }
+
+ while (Index < nn) {
+ Sd->mPTLen[Index++] = 0;
+ }
+
+ return MakeTable (Sd, nn, Sd->mPTLen, 8, Sd->mPTTable);
+}
+
+/**
+ Reads code lengths for Char&Len Set.
+
+ Read in and decode the Char&Len Set Code Length Array, then
+ generate the Huffman Code mapping table for the Char&Len Set.
+
+ @param Sd the global scratch data
+
+**/
+VOID
+GlueReadCLen (
+ SCRATCH_DATA *Sd
+ )
+{
+ UINT16 Number;
+ UINT16 CharC;
+ volatile UINT16 Index;
+ UINT32 Mask;
+
+ Number = (UINT16) GetBits (Sd, CBIT);
+
+ if (Number == 0) {
+ //
+ // This represents only Huffman code used
+ //
+ CharC = (UINT16) GetBits (Sd, CBIT);
+
+ for (Index = 0; Index < NC; Index++) {
+ Sd->mCLen[Index] = 0;
+ }
+
+ for (Index = 0; Index < 4096; Index++) {
+ Sd->mCTable[Index] = CharC;
+ }
+
+ return ;
+ }
+
+ Index = 0;
+ while (Index < Number) {
+ CharC = Sd->mPTTable[Sd->mBitBuf >> (BITBUFSIZ - 8)];
+ if (CharC >= NT) {
+ Mask = 1U << (BITBUFSIZ - 1 - 8);
+
+ do {
+
+ if (Mask & Sd->mBitBuf) {
+ CharC = Sd->mRight[CharC];
+ } else {
+ CharC = Sd->mLeft[CharC];
+ }
+
+ Mask >>= 1;
+
+ } while (CharC >= NT);
+ }
+ //
+ // Advance what we have read
+ //
+ FillBuf (Sd, Sd->mPTLen[CharC]);
+
+ if (CharC <= 2) {
+
+ if (CharC == 0) {
+ CharC = 1;
+ } else if (CharC == 1) {
+ CharC = (UINT16) (GetBits (Sd, 4) + 3);
+ } else if (CharC == 2) {
+ CharC = (UINT16) (GetBits (Sd, CBIT) + 20);
+ }
+
+ while ((INT16) (--CharC) >= 0) {
+ Sd->mCLen[Index++] = 0;
+ }
+
+ } else {
+
+ Sd->mCLen[Index++] = (UINT8) (CharC - 2);
+
+ }
+ }
+
+ while (Index < NC) {
+ Sd->mCLen[Index++] = 0;
+ }
+
+ MakeTable (Sd, NC, Sd->mCLen, 12, Sd->mCTable);
+
+ return ;
+}
+
+/**
+ Decode a character/length value.
+
+ Read one value from mBitBuf, Get one code from mBitBuf. If it is at block boundary, generates
+ Huffman code mapping table for Extra Set, Code&Len Set and
+ Position Set.
+
+ @param Sd The global scratch data.
+
+ @return The value decoded.
+
+**/
+UINT16
+GlueDecodeC (
+ SCRATCH_DATA *Sd
+ )
+{
+ UINT16 Index2;
+ UINT32 Mask;
+
+ if (Sd->mBlockSize == 0) {
+ //
+ // Starting a new block
+ // Read BlockSize from block header
+ //
+ Sd->mBlockSize = (UINT16) GetBits (Sd, 16);
+
+ //
+ // Read in the Extra Set Code Length Arrary,
+ // Generate the Huffman code mapping table for Extra Set.
+ //
+ Sd->mBadTableFlag = ReadPTLen (Sd, NT, TBIT, 3);
+ if (Sd->mBadTableFlag != 0) {
+ return 0;
+ }
+
+ //
+ // Read in and decode the Char&Len Set Code Length Arrary,
+ // Generate the Huffman code mapping table for Char&Len Set.
+ //
+ ReadCLen (Sd);
+
+ //
+ // Read in the Position Set Code Length Arrary,
+ // Generate the Huffman code mapping table for the Position Set.
+ //
+ Sd->mBadTableFlag = ReadPTLen (Sd, MAXNP, Sd->mPBit, (UINT16) (-1));
+ if (Sd->mBadTableFlag != 0) {
+ return 0;
+ }
+ }
+
+ //
+ // Get one code according to Code&Set Huffman Table
+ //
+ Sd->mBlockSize--;
+ Index2 = Sd->mCTable[Sd->mBitBuf >> (BITBUFSIZ - 12)];
+
+ if (Index2 >= NC) {
+ Mask = 1U << (BITBUFSIZ - 1 - 12);
+
+ do {
+ if (Sd->mBitBuf & Mask) {
+ Index2 = Sd->mRight[Index2];
+ } else {
+ Index2 = Sd->mLeft[Index2];
+ }
+
+ Mask >>= 1;
+ } while (Index2 >= NC);
+ }
+ //
+ // Advance what we have read
+ //
+ FillBuf (Sd, Sd->mCLen[Index2]);
+
+ return Index2;
+}
+
+/**
+ Decode the source data and put the resulting data into the destination buffer.
+
+ Decode the source data and put the resulting data into the destination buffer.
+
+ @param Sd The global scratch data
+
+**/
+VOID
+GlueDecode (
+ SCRATCH_DATA *Sd
+ )
+{
+ UINT16 BytesRemain;
+ UINT32 DataIdx;
+ UINT16 CharC;
+
+ BytesRemain = (UINT16) (-1);
+
+ DataIdx = 0;
+
+ for (;;) {
+ //
+ // Get one code from mBitBuf
+ //
+ CharC = DecodeC (Sd);
+ if (Sd->mBadTableFlag != 0) {
+ return ;
+ }
+
+ if (CharC < 256) {
+ //
+ // Process an Original character
+ //
+ if (Sd->mOutBuf >= Sd->mOrigSize) {
+ return ;
+ } else {
+ //
+ // Write orignal character into mDstBase
+ //
+ Sd->mDstBase[Sd->mOutBuf++] = (UINT8) CharC;
+ }
+
+ } else {
+ //
+ // Process a Pointer
+ //
+ CharC = (UINT16) (CharC - (UINT8_MAX + 1 - THRESHOLD));
+
+ //
+ // Get string length
+ //
+ BytesRemain = CharC;
+
+ //
+ // Locate string position
+ //
+ DataIdx = Sd->mOutBuf - DecodeP (Sd) - 1;
+
+ //
+ // Write BytesRemain of bytes into mDstBase
+ //
+ BytesRemain--;
+ while ((INT16) (BytesRemain) >= 0) {
+ Sd->mDstBase[Sd->mOutBuf++] = Sd->mDstBase[DataIdx++];
+ if (Sd->mOutBuf >= Sd->mOrigSize) {
+ return ;
+ }
+
+ BytesRemain--;
+ }
+ }
+ }
+
+ return ;
+}
+
+/**
+ Retrieves the size of the uncompressed buffer and the size of the scratch buffer.
+
+ Retrieves the size of the uncompressed buffer and the temporary scratch buffer
+ required to decompress the buffer specified by Source and SourceSize.
+ If the size of the uncompressed buffer or the size of the scratch buffer cannot
+ be determined from the compressed data specified by Source and SourceData,
+ then RETURN_INVALID_PARAMETER is returned. Otherwise, the size of the uncompressed
+ buffer is returned in DestinationSize, the size of the scratch buffer is returned
+ in ScratchSize, and RETURN_SUCCESS is returned.
+ This function does not have scratch buffer available to perform a thorough
+ checking of the validity of the source data. It just retrieves the "Original Size"
+ field from the beginning bytes of the source data and output it as DestinationSize.
+ And ScratchSize is specific to the decompression implementation.
+
+ If Source is NULL, then ASSERT().
+ If DestinationSize is NULL, then ASSERT().
+ If ScratchSize is NULL, then ASSERT().
+
+ @param Source The source buffer containing the compressed data.
+ @param SourceSize The size, in bytes, of the source buffer.
+ @param DestinationSize A pointer to the size, in bytes, of the uncompressed buffer
+ that will be generated when the compressed buffer specified
+ by Source and SourceSize is decompressed..
+ @param ScratchSize A pointer to the size, in bytes, of the scratch buffer that
+ is required to decompress the compressed buffer specified
+ by Source and SourceSize.
+
+ @retval RETURN_SUCCESS The size of destination buffer and the size of scratch
+ buffer are successull retrieved.
+ @retval RETURN_INVALID_PARAMETER The source data is corrupted
+
+**/
+RETURN_STATUS
+EFIAPI
+UefiDecompressGetInfo (
+ IN CONST VOID *Source,
+ IN UINT32 SourceSize,
+ OUT UINT32 *DestinationSize,
+ OUT UINT32 *ScratchSize
+ )
+{
+ UINT32 CompressedSize;
+
+ ASSERT (Source != NULL);
+ ASSERT (DestinationSize != NULL);
+ ASSERT (ScratchSize != NULL);
+
+ *ScratchSize = sizeof (SCRATCH_DATA);
+
+ if (SourceSize < 8) {
+ return RETURN_INVALID_PARAMETER;
+ }
+
+ CopyMem (&CompressedSize, Source, sizeof (UINT32));
+ CopyMem (DestinationSize, (VOID *)((UINT8 *)Source + 4), sizeof (UINT32));
+
+ if (SourceSize < (CompressedSize + 8)) {
+ return RETURN_INVALID_PARAMETER;
+ }
+
+ return RETURN_SUCCESS;
+}
+
+/**
+ Decompresses a compressed source buffer.
+
+ This function is designed so that the decompression algorithm can be implemented
+ without using any memory services. As a result, this function is not allowed to
+ call any memory allocation services in its implementation. It is the caller¡¯s r
+ esponsibility to allocate and free the Destination and Scratch buffers.
+ If the compressed source data specified by Source is sucessfully decompressed
+ into Destination, then RETURN_SUCCESS is returned. If the compressed source data
+ specified by Source is not in a valid compressed data format,
+ then RETURN_INVALID_PARAMETER is returned.
+
+ If Source is NULL, then ASSERT().
+ If Destination is NULL, then ASSERT().
+ If the required scratch buffer size > 0 and Scratch is NULL, then ASSERT().
+
+ @param Source The source buffer containing the compressed data.
+ @param Destination The destination buffer to store the decompressed data
+ @param Scratch A temporary scratch buffer that is used to perform the decompression.
+ This is an optional parameter that may be NULL if the
+ required scratch buffer size is 0.
+
+ @retval RETURN_SUCCESS Decompression is successfull
+ @retval RETURN_INVALID_PARAMETER The source data is corrupted
+
+**/
+RETURN_STATUS
+EFIAPI
+UefiDecompress (
+ IN CONST VOID *Source,
+ IN OUT VOID *Destination,
+ IN OUT VOID *Scratch
+ )
+{
+ volatile UINT32 Index;
+ UINT32 CompSize;
+ UINT32 OrigSize;
+ SCRATCH_DATA *Sd;
+ CONST UINT8 *Src;
+ UINT8 *Dst;
+
+ ASSERT (Source != NULL);
+ ASSERT (Destination != NULL);
+ ASSERT (Scratch != NULL);
+
+ Src = Source;
+ Dst = Destination;
+
+ Sd = (SCRATCH_DATA *) Scratch;
+
+ CompSize = Src[0] + (Src[1] << 8) + (Src[2] << 16) + (Src[3] << 24);
+ OrigSize = Src[4] + (Src[5] << 8) + (Src[6] << 16) + (Src[7] << 24);
+
+ //
+ // If compressed file size is 0, return
+ //
+ if (OrigSize == 0) {
+ return RETURN_SUCCESS;
+ }
+
+ Src = Src + 8;
+
+ for (Index = 0; Index < sizeof (SCRATCH_DATA); Index++) {
+ ((UINT8 *) Sd)[Index] = 0;
+ }
+ //
+ // The length of the field 'Position Set Code Length Array Size' in Block Header.
+ // For EFI 1.1 de/compression algorithm(Version 1), mPBit = 4
+ // For Tiano de/compression algorithm(Version 2), mPBit = 5
+ //
+ Sd->mPBit = 4;
+ Sd->mSrcBase = (UINT8 *)Src;
+ Sd->mDstBase = Dst;
+ //
+ // CompSize and OrigSize are caculated in bytes
+ //
+ Sd->mCompSize = CompSize;
+ Sd->mOrigSize = OrigSize;
+
+ //
+ // Fill the first BITBUFSIZ bits
+ //
+ FillBuf (Sd, BITBUFSIZ);
+
+ //
+ // Decompress it
+ //
+ Decode (Sd);
+
+ if (Sd->mBadTableFlag != 0) {
+ //
+ // Something wrong with the source
+ //
+ return RETURN_INVALID_PARAMETER;
+ }
+
+ return RETURN_SUCCESS;
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf
new file mode 100644
index 0000000..7d2db1f
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf
@@ -0,0 +1,76 @@
+#/*++
+#
+# Copyright (c) 2004 - 2006, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# BaseUefiDecompressLib.inf
+#
+# Abstract:
+#
+# Component description file for BaseUefiDecompressLib.
+#
+#--*/
+
+[defines]
+BASE_NAME = EdkIIGlueBaseUefiDecompressLib
+COMPONENT_TYPE = LIBRARY
+
+[sources.common]
+ BaseUefiDecompressLib.c
+
+[sources.ia32]
+
+[sources.x64]
+
+[sources.ipf]
+
+[sources.ebc]
+
+
+[includes.common]
+ .
+ ..\..\Include
+ ..\..\include\Library
+ $(EDK_SOURCE)\Foundation
+ $(EDK_SOURCE)\Foundation\Framework
+ $(EDK_SOURCE)\Foundation\Efi
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+ $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include
+
+[libraries.common]
+ EdkIIGlueBaseMemoryLib
+
+[libraries.ia32]
+
+
+[libraries.x64]
+
+
+[nmake.common]
+ C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION
+ LIB_STD_FLAGS = /NOLOGO /IGNORE:4006
+
+[nmake.ia32]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32
+
+[nmake.x64]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64
+
+[nmake.ipf]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF
+
+[nmake.ebc]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/EdkIIGlueBaseUefiDecompressLib.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/EdkIIGlueBaseUefiDecompressLib.cif
new file mode 100644
index 0000000..184d5b6
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/EdkIIGlueBaseUefiDecompressLib.cif
@@ -0,0 +1,11 @@
+<component>
+ name = "EdkIIGlueBaseUefiDecompressLib"
+ category = ModulePart
+ LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\BaseUefiDecompressLib"
+ RefName = "EdkIIGlueBaseUefiDecompressLib"
+[files]
+"EdkIIGlueBaseUefiDecompressLib.sdl"
+"EdkIIGlueBaseUefiDecompressLib.mak"
+"BaseUefiDecompressLib.inf"
+"BaseUefiDecompressLib.c"
+<endComponent>
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/EdkIIGlueBaseUefiDecompressLib.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/EdkIIGlueBaseUefiDecompressLib.mak
new file mode 100644
index 0000000..636fc18
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/EdkIIGlueBaseUefiDecompressLib.mak
@@ -0,0 +1,80 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueBaseUefiDecompressLib/EdkIIGlueBaseUefiDecompressLib.mak 1 1/20/12 3:54a Jeffch $
+#
+# $Revision: 1 $
+#
+# $Date: 1/20/12 3:54a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueBaseUefiDecompressLib/EdkIIGlueBaseUefiDecompressLib.mak $
+#
+# 1 1/20/12 3:54a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 9/27/11 6:17a Wesleychen
+# Intel EDK initially releases.
+#
+# 1 9/18/09 1:53a Iminglin
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: EdkIIGlueBaseUefiDecompressLib.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+
+
+$(EdkIIGlueBaseUefiDecompressLib_LIB) : EdkIIGlueBaseUefiDecompressLib
+
+EdkIIGlueBaseUefiDecompressLib : $(BUILD_DIR)\EdkIIGlueBaseUefiDecompressLib.mak EdkIIGlueBaseUefiDecompressLibBin
+
+$(BUILD_DIR)\EdkIIGlueBaseUefiDecompressLib.mak : $(EdkIIGlueBaseUefiDecompressLib_DIR)\$(@B).cif $(EdkIIGlueBaseUefiDecompressLib_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(EdkIIGlueBaseUefiDecompressLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+EdkIIGlueBaseUefiDecompressLibBin : $(EdkIIGlueBaseMemoryLib_LIB)
+!IF "$(x64_BUILD)"=="1"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGlueBaseUefiDecompressLib.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBaseUefiDecompressLib_LIB)"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\IA32\
+ /f $(BUILD_DIR)\EdkIIGlueBaseUefiDecompressLib.mak all\
+ TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBaseUefiDecompressLib_LIB)"
+!ELSE
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGlueBaseUefiDecompressLib.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueBaseUefiDecompressLib_LIB)"
+!ENDIF
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#********************************************************************** \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/EdkIIGlueBaseUefiDecompressLib.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/EdkIIGlueBaseUefiDecompressLib.sdl
new file mode 100644
index 0000000..b6bf41c
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/BaseUefiDecompressLib/EdkIIGlueBaseUefiDecompressLib.sdl
@@ -0,0 +1,26 @@
+TOKEN
+ Name = "EdkIIGlueBaseUefiDecompressLib_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable EdkIIGlueBaseUefiDecompressLib support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "EdkIIGlueBaseUefiDecompressLib_LIB"
+ Value = "$$(LIB_BUILD_DIR)\EdkIIGlueBaseUefiDecompressLib.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "EdkIIGlueBaseUefiDecompressLib_DIR"
+End
+
+MODULE
+ Help = "Includes EdkIIGlueBaseUefiDecompressLib.mak to Project"
+ File = "EdkIIGlueBaseUefiDecompressLib.mak"
+End
+
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeDebugLibReportStatusCode/DebugLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeDebugLibReportStatusCode/DebugLib.c
new file mode 100644
index 0000000..bba3b5e
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeDebugLibReportStatusCode/DebugLib.c
@@ -0,0 +1,322 @@
+/*++
+
+Copyright (c) 2004 - 2011, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ DebugLib.c
+
+Abstract:
+
+ Debug Library that fowards all messages to ReportStatusCode()
+
+--*/
+
+#include "EdkIIGlueDxe.h"
+#include "Pcd\EdkIIGluePcdDebugLib.h"
+
+/**
+
+ Gets the error level.
+
+ If DebugMaskInterface is not NULL, return the error level from DebugMaskInterface.
+
+ If DebugMaskInterface is NULL, return the default define DebugPrintErrorLevel error level.
+
+ @retval Debug Message Error Level
+
+**/
+UINTN
+EFIAPI
+EdkIIGlueGetDebugPrintErrorLevel (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ UINTN ImageDebugMask;
+
+ if (gDebugMaskInterface != NULL) {
+ Status = gDebugMaskInterface->GetDebugMask (gDebugMaskInterface, &ImageDebugMask);
+ if (!(EFI_ERROR(Status))) {
+ return ImageDebugMask;
+ }
+ }
+ return EDKII_GLUE_DebugPrintErrorLevel;
+}
+
+/**
+
+ Prints a debug message to the debug output device if the specified error level is enabled.
+
+ If any bit in ErrorLevel is also set in PcdDebugPrintErrorLevel, then print
+ the message specified by Format and the associated variable argument list to
+ the debug output device.
+
+ If Format is NULL, then ASSERT().
+
+ @param ErrorLevel The error level of the debug message.
+ @param Format Format string for the debug message to print.
+
+**/
+VOID
+EFIAPI
+DebugPrint (
+ IN UINTN ErrorLevel,
+ IN CONST CHAR8 *Format,
+ ...
+ )
+{
+ UINT64 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE / sizeof (UINT64)];
+ EFI_DEBUG_INFO *DebugInfo;
+ UINTN TotalSize;
+ UINTN Index;
+ VA_LIST Marker;
+ UINT64 *ArgumentPointer;
+
+ //
+ // If Format is NULL, then ASSERT().
+ //
+ ASSERT (Format != NULL);
+
+ //
+ // Check driver Debug Level value and global debug level
+ //
+ if ((ErrorLevel & PcdGet32(PcdDebugPrintErrorLevel)) == 0) {
+ return;
+ }
+
+ TotalSize = sizeof (EFI_DEBUG_INFO) + 12 * sizeof (UINT64) + AsciiStrLen (Format) + 1;
+ if (TotalSize > EFI_STATUS_CODE_DATA_MAX_SIZE) {
+ return;
+ }
+
+ //
+ // Then EFI_DEBUG_INFO
+ //
+ DebugInfo = (EFI_DEBUG_INFO *)Buffer;
+ DebugInfo->ErrorLevel = (UINT32)ErrorLevel;
+
+ //
+ // 256 byte mini Var Arg stack. That is followed by the format string.
+ //
+ VA_START (Marker, Format);
+ for (Index = 0, ArgumentPointer = (UINT64 *)(DebugInfo + 1); Index < 12; Index++, ArgumentPointer++) {
+ *ArgumentPointer = VA_ARG (Marker, UINT64);
+ }
+ VA_END (Marker);
+ AsciiStrCpy ((CHAR8 *)ArgumentPointer, Format);
+
+ REPORT_STATUS_CODE_EX (
+ EFI_DEBUG_CODE,
+ (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_DC_UNSPECIFIED),
+ 0,
+ NULL,
+ &gEfiStatusCodeDataTypeDebugGuid,
+ DebugInfo,
+ TotalSize
+ );
+}
+
+
+/**
+
+ Prints an assert message containing a filename, line number, and description.
+ This may be followed by a breakpoint or a dead loop.
+
+ Print a message of the form "ASSERT <FileName>(<LineNumber>): <Description>\n"
+ to the debug output device. If DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED bit of
+ PcdDebugProperyMask is set then CpuBreakpoint() is called. Otherwise, if
+ DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED bit of PcdDebugProperyMask is set then
+ CpuDeadLoop() is called. If neither of these bits are set, then this function
+ returns immediately after the message is printed to the debug output device.
+ DebugAssert() must actively prevent recusrsion. If DebugAssert() is called while
+ processing another DebugAssert(), then DebugAssert() must return immediately.
+
+ If FileName is NULL, then a <FileName> string of "(NULL) Filename" is printed.
+
+ If Description is NULL, then a <Description> string of "(NULL) Description" is printed.
+
+ @param FileName Pointer to the name of the source file that generated the assert condition.
+ @param LineNumber The line number in the source file that generated the assert condition
+ @param Description Pointer to the description of the assert condition.
+
+**/
+VOID
+EFIAPI
+DebugAssert (
+ IN CONST CHAR8 *FileName,
+ IN UINTN LineNumber,
+ IN CONST CHAR8 *Description
+ )
+{
+ UINT64 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE / sizeof(UINT64)];
+ EFI_DEBUG_ASSERT_DATA *AssertData;
+ UINTN TotalSize;
+ CHAR8 *Temp;
+
+ //
+ // Make sure it will all fit in the passed in buffer
+ //
+ TotalSize = sizeof (EFI_DEBUG_ASSERT_DATA) + AsciiStrLen (FileName) + 1 + AsciiStrLen (Description) + 1;
+ if (TotalSize <= EFI_STATUS_CODE_DATA_MAX_SIZE) {
+ //
+ // Fill in EFI_DEBUG_ASSERT_DATA
+ //
+ AssertData = (EFI_DEBUG_ASSERT_DATA *)Buffer;
+ AssertData->LineNumber = (UINT32)LineNumber;
+
+ //
+ // Copy Ascii FileName including NULL.
+ //
+ Temp = AsciiStrCpy ((CHAR8 *)(AssertData + 1), FileName);
+
+ //
+ // Copy Ascii Description
+ //
+ AsciiStrCpy (Temp + AsciiStrLen (FileName) + 1, Description);
+
+ REPORT_STATUS_CODE_WITH_EXTENDED_DATA (
+ (EFI_ERROR_CODE | EFI_ERROR_UNRECOVERED),
+ (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_EC_ILLEGAL_SOFTWARE_STATE),
+ AssertData,
+ TotalSize
+ );
+ }
+
+ //
+ // Generate a Breakpoint, DeadLoop, or NOP based on PCD settings
+ //
+ if ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED) != 0) {
+ CpuBreakpoint ();
+ } else if ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED) != 0) {
+ CpuDeadLoop ();
+ }
+}
+
+
+/**
+
+ Fills a target buffer with PcdDebugClearMemoryValue, and returns the target buffer.
+
+ This function fills Length bytes of Buffer with the value specified by
+ PcdDebugClearMemoryValue, and returns Buffer.
+
+ If Buffer is NULL, then ASSERT().
+
+ If Length is greater than (MAX_ADDRESS ?Buffer + 1), then ASSERT().
+
+ @param Buffer Pointer to the target buffer to fill with PcdDebugClearMemoryValue.
+ @param Length Number of bytes in Buffer to fill with zeros PcdDebugClearMemoryValue.
+
+ @return Buffer
+
+**/
+VOID *
+EFIAPI
+DebugClearMemory (
+ OUT VOID *Buffer,
+ IN UINTN Length
+ )
+{
+ //
+ // If Buffer is NULL, then ASSERT().
+ //
+ ASSERT (Buffer != NULL);
+
+ //
+ // SetMem() checks for the the ASSERT() condition on Length and returns Buffer
+ //
+ return SetMem (Buffer, Length, PcdGet8(PcdDebugClearMemoryValue));
+}
+
+
+/**
+
+ Returns TRUE if ASSERT() macros are enabled.
+
+ This function returns TRUE if the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of
+ PcdDebugProperyMask is set. Otherwise FALSE is returned.
+
+ @retval TRUE The DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is set.
+ @retval FALSE The DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is clear.
+
+**/
+BOOLEAN
+EFIAPI
+DebugAssertEnabled (
+ VOID
+ )
+{
+ return (BOOLEAN) ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED) != 0);
+}
+
+
+/**
+
+ Returns TRUE if DEBUG()macros are enabled.
+
+ This function returns TRUE if the DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of
+ PcdDebugProperyMask is set. Otherwise FALSE is returned.
+
+ @retval TRUE The DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of PcdDebugProperyMask is set.
+ @retval FALSE The DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of PcdDebugProperyMask is clear.
+
+**/
+BOOLEAN
+EFIAPI
+DebugPrintEnabled (
+ VOID
+ )
+{
+ return (BOOLEAN) ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_PRINT_ENABLED) != 0);
+}
+
+
+/**
+
+ Returns TRUE if DEBUG_CODE()macros are enabled.
+
+ This function returns TRUE if the DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of
+ PcdDebugProperyMask is set. Otherwise FALSE is returned.
+
+ @retval TRUE The DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is set.
+ @retval FALSE The DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is clear.
+
+**/
+BOOLEAN
+EFIAPI
+DebugCodeEnabled (
+ VOID
+ )
+{
+ return (BOOLEAN) ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_CODE_ENABLED) != 0);
+}
+
+
+/**
+
+ Returns TRUE if DEBUG_CLEAR_MEMORY()macro is enabled.
+
+ This function returns TRUE if the DEBUG_PROPERTY_DEBUG_CLEAR_MEMORY_ENABLED bit of
+ PcdDebugProperyMask is set. Otherwise FALSE is returned.
+
+ @retval TRUE The DEBUG_PROPERTY_DEBUG_CLEAR_MEMORY_ENABLED bit of PcdDebugProperyMask is set.
+ @retval FALSE The DEBUG_PROPERTY_DEBUG_CLEAR_MEMORY_ENABLED bit of PcdDebugProperyMask is clear.
+
+**/
+BOOLEAN
+EFIAPI
+DebugClearMemoryEnabled (
+ VOID
+ )
+{
+ return (BOOLEAN) ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED) != 0);
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeDebugLibReportStatusCode/DxeDebugLibReportStatusCode.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeDebugLibReportStatusCode/DxeDebugLibReportStatusCode.inf
new file mode 100644
index 0000000..6c6741f
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeDebugLibReportStatusCode/DxeDebugLibReportStatusCode.inf
@@ -0,0 +1,88 @@
+#/*++
+#
+# Copyright (c) 2004 - 2006, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# DxeDebugLibReportStatusCode.inf
+#
+# Abstract:
+#
+# Component description file for DxeDebugLibReportStatusCode.
+#
+#--*/
+
+[defines]
+BASE_NAME = EdkIIGlueDxeDebugLibReportStatusCode
+COMPONENT_TYPE = LIBRARY
+
+[sources.common]
+ DebugLib.c
+
+[sources.ia32]
+
+[sources.x64]
+
+[sources.ipf]
+
+[sources.ebc]
+
+
+[includes.common]
+ .
+ ..\..\Include
+ ..\..\include\Library
+ $(EDK_SOURCE)\Foundation
+ $(EDK_SOURCE)\Foundation\Framework
+ $(EDK_SOURCE)\Foundation\Framework\Protocol\Hii
+ $(EDK_SOURCE)\Foundation\Efi
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+ $(EDK_SOURCE)\Foundation\Library\Dxe\EfiIfrSupportLib
+ $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include
+
+[libraries.common]
+ EdkIIGlueBaseLib
+ EdkIIGlueBaseMemoryLib
+#
+# R8.x
+#
+ EdkFrameworkGuidLib
+ EfiProtocolLib
+#
+#
+# An user must specify a PEI or DXE ReportStatusCodeLib instance in module's .inf
+#
+
+[libraries.ia32]
+
+
+[libraries.x64]
+
+
+[nmake.common]
+ C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION
+ LIB_STD_FLAGS = /NOLOGO /IGNORE:4006
+
+[nmake.ia32]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32
+
+[nmake.x64]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64
+
+[nmake.ipf]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF
+
+[nmake.ebc]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeDebugLibReportStatusCode/EdkIIGlueDxeDebugLibReportStatusCode.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeDebugLibReportStatusCode/EdkIIGlueDxeDebugLibReportStatusCode.cif
new file mode 100644
index 0000000..aef686f
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeDebugLibReportStatusCode/EdkIIGlueDxeDebugLibReportStatusCode.cif
@@ -0,0 +1,11 @@
+<component>
+ name = "EdkIIGlueDxeDebugLibReportStatusCode"
+ category = ModulePart
+ LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\DxeDebugLibReportStatusCode"
+ RefName = "EdkIIGlueDxeDebugLibReportStatusCode"
+[files]
+"EdkIIGlueDxeDebugLibReportStatusCode.sdl"
+"EdkIIGlueDxeDebugLibReportStatusCode.mak"
+"DxeDebugLibReportStatusCode.inf"
+"DebugLib.c"
+<endComponent>
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeDebugLibReportStatusCode/EdkIIGlueDxeDebugLibReportStatusCode.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeDebugLibReportStatusCode/EdkIIGlueDxeDebugLibReportStatusCode.mak
new file mode 100644
index 0000000..e58f4bd
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeDebugLibReportStatusCode/EdkIIGlueDxeDebugLibReportStatusCode.mak
@@ -0,0 +1,80 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueDxeDebugLibReportStatusCode/EdkIIGlueDxeDebugLibReportStatusCode.mak 1 1/20/12 3:55a Jeffch $
+#
+# $Revision: 1 $
+#
+# $Date: 1/20/12 3:55a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueDxeDebugLibReportStatusCode/EdkIIGlueDxeDebugLibReportStatusCode.mak $
+#
+# 1 1/20/12 3:55a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 9/27/11 6:18a Wesleychen
+# Intel EDK initially releases.
+#
+# 1 9/18/09 1:56a Iminglin
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: EdkIIGlueDxeDebugLibReportStatusCode.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+
+
+$(EdkIIGlueDxeDebugLibReportStatusCode_LIB) : EdkIIGlueDxeDebugLibReportStatusCode
+
+EdkIIGlueDxeDebugLibReportStatusCode : $(BUILD_DIR)\EdkIIGlueDxeDebugLibReportStatusCode.mak EdkIIGlueDxeDebugLibReportStatusCodeBin
+
+$(BUILD_DIR)\EdkIIGlueDxeDebugLibReportStatusCode.mak : $(EdkIIGlueDxeDebugLibReportStatusCode_DIR)\$(@B).cif $(EdkIIGlueDxeDebugLibReportStatusCode_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(EdkIIGlueDxeDebugLibReportStatusCode_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+EdkIIGlueDxeDebugLibReportStatusCodeBin : $(EdkIIGlueBaseLib_LIB) $(EdkIIGlueBaseMemoryLib_LIB) $(EDKFRAMEWORKGUIDLIB) $(EFIPROTOCOLLIB)
+!IF "$(x64_BUILD)"=="1"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGlueDxeDebugLibReportStatusCode.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueDxeDebugLibReportStatusCode_LIB)"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\IA32\
+ /f $(BUILD_DIR)\EdkIIGlueDxeDebugLibReportStatusCode.mak all\
+ TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueDxeDebugLibReportStatusCode_LIB)"
+!ELSE
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGlueDxeDebugLibReportStatusCode.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueDxeDebugLibReportStatusCode_LIB)"
+!ENDIF
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeDebugLibReportStatusCode/EdkIIGlueDxeDebugLibReportStatusCode.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeDebugLibReportStatusCode/EdkIIGlueDxeDebugLibReportStatusCode.sdl
new file mode 100644
index 0000000..312d08b
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeDebugLibReportStatusCode/EdkIIGlueDxeDebugLibReportStatusCode.sdl
@@ -0,0 +1,26 @@
+TOKEN
+ Name = "EdkIIGlueDxeDebugLibReportStatusCode_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable EdkIIGlueDxeDebugLibReportStatusCode support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "EdkIIGlueDxeDebugLibReportStatusCode_LIB"
+ Value = "$$(LIB_BUILD_DIR)\EdkIIGlueDxeDebugLibReportStatusCode.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "EdkIIGlueDxeDebugLibReportStatusCode_DIR"
+End
+
+MODULE
+ Help = "Includes EdkIIGlueDxeDebugLibReportStatusCode.mak to Project"
+ File = "EdkIIGlueDxeDebugLibReportStatusCode.mak"
+End
+
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeFirmwarePerformanceLib/EdkIIGlueDxeFirmwarePerformanceLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeFirmwarePerformanceLib/EdkIIGlueDxeFirmwarePerformanceLib.c
new file mode 100644
index 0000000..f38eee7
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeFirmwarePerformanceLib/EdkIIGlueDxeFirmwarePerformanceLib.c
@@ -0,0 +1,638 @@
+/*++
+
+Copyright (c) 2011 - 2012, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ EdkIIGlueDxeFirmwarePerformanceLib.c
+
+Abstract:
+
+ DXE Library for FPDT performance logging.
+
+--*/
+
+#include "Tiano.h"
+#include "EdkIIGlueDxe.h"
+#include "EfiImage.h"
+
+#include EFI_PROTOCOL_DEFINITION (FirmwarePerformance)
+#include EFI_GUID_DEFINITION (PeiPerformanceHob)
+#include EFI_PROTOCOL_DEFINITION (LoadedImage)
+#include EFI_GUID_DEFINITION (Hob)
+
+static UINT32 *mPerformancePointer;
+static UINT32 mPerformanceLength;
+UINT16 BdsAttemptNumber = 0;
+
+FIRMWARE_PERFORMANCE_PROTOCOL *FirmwarePerformance;
+EFI_GUID gNullGuid = EFI_NULL_GUID;
+
+STATIC
+VOID
+GetShortPdbFileName (
+ IN CHAR8 *PdbFileName,
+ OUT CHAR8 *GaugeString
+ )
+/*++
+
+Routine Description:
+
+ Shotens PDB path name
+
+Arguments:
+
+ PdbFileName - PdbFileName to be shorten
+
+Returns:
+
+ Pointer to Shortened PdbFileName
+
+--*/
+{
+ UINTN Index;
+ UINTN Index1;
+ UINTN StartIndex;
+ UINTN EndIndex;
+
+ if (PdbFileName == NULL) {
+ AsciiStrCpy (GaugeString, " ");
+ } else {
+ StartIndex = 0;
+ for (EndIndex = 0; PdbFileName[EndIndex] != 0; EndIndex++)
+ ;
+
+ for (Index = 0; PdbFileName[Index] != 0; Index++) {
+ if (PdbFileName[Index] == '\\') {
+ StartIndex = Index + 1;
+ }
+
+ if (PdbFileName[Index] == '.') {
+ EndIndex = Index;
+ }
+ }
+
+ Index1 = 0;
+ for (Index = StartIndex; Index < EndIndex; Index++) {
+ GaugeString[Index1] = PdbFileName[Index];
+ Index1++;
+ if (Index1 == STRING_EVENT_RECORD_NAME_LENGTH - 1) {
+ break;
+ }
+ }
+
+ GaugeString[Index1] = 0;
+ }
+
+ return ;
+}
+
+STATIC
+VOID
+GetNameFromHandle (
+ IN EFI_HANDLE Handle,
+ OUT CHAR8 *GaugeString
+ )
+/*++
+
+Routine Description:
+
+ retrieves PDB path name from Handle
+
+Arguments:
+
+ Handle - Handle of image
+ GaugeString - returns pointer to PDB Filename
+
+Returns:
+
+ None
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_LOADED_IMAGE_PROTOCOL *Image;
+ CHAR8 *PdbFileName;
+ EFI_DRIVER_BINDING_PROTOCOL *DriverBinding;
+
+ AsciiStrCpy (GaugeString, " ");
+
+ //
+ // Get handle name from image protocol
+ //
+ Status = gBS->HandleProtocol (
+ Handle,
+ &gEfiLoadedImageProtocolGuid,
+ (VOID**)&Image
+ );
+
+ if (EFI_ERROR (Status)) {
+ Status = gBS->OpenProtocol (
+ Handle,
+ &gEfiDriverBindingProtocolGuid,
+ (VOID **) &DriverBinding,
+ NULL,
+ NULL,
+ EFI_OPEN_PROTOCOL_GET_PROTOCOL
+ );
+ if (EFI_ERROR (Status)) {
+ return ;
+ }
+ //
+ // Get handle name from image protocol
+ //
+ Status = gBS->HandleProtocol (
+ DriverBinding->ImageHandle,
+ &gEfiLoadedImageProtocolGuid,
+ (VOID **) &Image
+ );
+ }
+
+ PdbFileName = PeCoffLoaderGetPdbPointer (Image->ImageBase);
+
+ if (PdbFileName != NULL) {
+ GetShortPdbFileName (PdbFileName, GaugeString);
+ }
+
+ return ;
+}
+
+EFI_STATUS
+LocatePerformanceProtocol (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ locates Performance protocol interface
+
+Arguments:
+
+ None
+
+Returns:
+
+ EFI_SUCCESS - Located protocol successfully
+ EFI_NOT_FOUND - Fail to locate protocol
+
+--*/
+{
+ EFI_STATUS Status;
+
+ FirmwarePerformance = NULL;
+ Status = gBS->LocateProtocol (&gFirmwarePerformanceProtocolGuid, NULL, (VOID **) &FirmwarePerformance);
+
+ return Status;
+}
+
+EFI_STATUS
+EFIAPI
+InsertMeasurement (
+ IN FIRMWARE_PERFORMANCE_PROTOCOL *This,
+ IN EFI_HANDLE Handle,
+ IN UINT16 RecordType,
+ IN UINT64 Timestamp,
+ IN UINT16 Identifier OPTIONAL
+ )
+/*++
+
+Routine Description:
+
+ Logs performance data according to record type into pre-allocated buffer
+
+Arguments:
+
+ This - Calling context
+ Handle - Handle of gauge data
+ RecordType - Type of FPDT record
+ Timestamp - Timestamp of TSC timer when even happend.
+ Identifier - Identifier of event records and other types of records
+
+Returns:
+
+ EFI_SUCCESS - Successfully create and initialized a guage data node.
+ EFI_OUT_OF_RESOURCES - No enough resource to create a guage data node.
+ EFI_ABORTED - Type of record is not defined
+
+--*/
+{
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ HARDWARE_BOOT_REC *HardwareBootRec;
+ STRING_EVENT_REC *StringEvent;
+ GUID_EVENT_REC *GuidEvent;
+ BDS_ATTEMPT_REC *BdsAttemptRec;
+ EFI_GUID *GuidName;
+
+ UINT8 PdbFileName[STRING_EVENT_RECORD_NAME_LENGTH] = { 0 };
+ UINT8 NullFileName[STRING_EVENT_RECORD_NAME_LENGTH] = { 0 };
+ DevicePath = NULL;
+
+ //
+ // Check if pre-allocated buffer is full
+ //
+ if (mPerformanceLength + sizeof (STRING_EVENT_REC) > FIRMWARE_MAX_BUFFER) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ switch (RecordType) {
+ case HARDWARE_BOOT_TYPE:
+ //
+ // Hardware Boot Record Table
+ //
+ HardwareBootRec = (HARDWARE_BOOT_REC*) ((UINT8*)mPerformancePointer + mPerformanceLength);
+
+ HardwareBootRec->RecType = RecordType;
+ HardwareBootRec->RecLength = sizeof (HARDWARE_BOOT_REC);
+ HardwareBootRec->Revision = RECORD_REVISION_1;
+ HardwareBootRec->HardwareBoot = GetTimeInNanoSec (Timestamp);
+
+ mPerformanceLength += sizeof (HARDWARE_BOOT_REC);
+ break;
+
+ case GUID_EVENT_REC_TYPE:
+ case STRING_EVENT_REC_TYPE:
+ //
+ // Determine Pdb FileName associated with module logging performance
+ //
+ if (Handle != NULL) {
+ GetNameFromHandle (Handle, PdbFileName);
+ }
+
+ GuidName = GetGuidFromHandle (Handle);
+ if (CompareMem (PdbFileName,NullFileName, STRING_EVENT_RECORD_NAME_LENGTH)){
+ //
+ // String Event Record
+ //
+ StringEvent = (STRING_EVENT_REC*) ((UINT8*)mPerformancePointer + mPerformanceLength);
+ StringEvent->RecType = STRING_EVENT_REC_TYPE;
+ StringEvent->RecLength = sizeof (STRING_EVENT_REC);
+ StringEvent->Revision = RECORD_REVISION_1;
+ StringEvent->ProgressID = Identifier;
+ StringEvent->ApicID = GetApicId ();
+ StringEvent->Timestamp = GetTimeInNanoSec (Timestamp);
+ if (GuidName != NULL) {
+ (gBS->CopyMem) (&(StringEvent->Guid), GuidName, sizeof (EFI_GUID));
+ }
+
+ (gBS->CopyMem) (StringEvent->NameString, PdbFileName, STRING_EVENT_RECORD_NAME_LENGTH);
+
+ mPerformanceLength += sizeof (STRING_EVENT_REC);
+
+ } else {
+ //
+ // GUID Event Record
+ //
+ GuidEvent = (GUID_EVENT_REC*) ((UINT8*)mPerformancePointer + mPerformanceLength);
+ GuidEvent->RecType = GUID_EVENT_REC_TYPE;
+ GuidEvent->RecLength = sizeof (GUID_EVENT_REC);
+ GuidEvent->Revision = RECORD_REVISION_1;
+ GuidEvent->ProgressID = Identifier;
+ GuidEvent->ApicID = GetApicId ();
+ GuidEvent->Timestamp = GetTimeInNanoSec (Timestamp);
+ if (GuidName != NULL) {
+ (gBS->CopyMem) (&(GuidEvent->Guid), GuidName, sizeof (EFI_GUID));
+ }
+
+ mPerformanceLength += sizeof (GUID_EVENT_REC);
+ }
+ break;
+
+ case BDS_ATTEMPT_EVENT_REC_TYPE:
+ //
+ // BDS Boot Attempt Record
+ //
+ DevicePath = DevicePathFromHandle (Handle);
+
+ BdsAttemptRec = (BDS_ATTEMPT_REC*) ((UINT8*)mPerformancePointer + mPerformanceLength);
+ BdsAttemptRec->RecType = BDS_ATTEMPT_EVENT_REC_TYPE;
+ BdsAttemptRec->RecLength = sizeof (BDS_ATTEMPT_REC);
+ BdsAttemptRec->Revision = RECORD_REVISION_1;
+ BdsAttemptRec->ApicID = GetApicId ();
+ BdsAttemptRec->BdsAttemptNo = BdsAttemptNumber + 1;
+ BdsAttemptRec->Timestamp = GetTimeInNanoSec (Timestamp);
+ ASPrint ((CHAR8*)(&BdsAttemptRec->UEFIBootVar), sizeof(BdsAttemptRec->UEFIBootVar)+1, "BOOT%04x", Identifier);
+ BdsAttemptRec->DevicePathString = '0';
+ mPerformanceLength += sizeof (BDS_ATTEMPT_REC);
+ break;
+
+ default:
+ //
+ // Record is undefined, return EFI_ABORTED
+ //
+ return EFI_ABORTED;
+ break;
+ }
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+GetPerfBufferAddr (
+ IN FIRMWARE_PERFORMANCE_PROTOCOL *This,
+ OUT UINT32 *PerformanceBuffer
+ )
+/*++
+
+Routine Description:
+
+ Retrieves pointer to performance buffer
+
+Arguments:
+
+ This - Calling context
+ PerformanceBuffer - returns pointer to pre-allocated memory buffer
+
+Returns:
+
+ EFI_SUCCESS - Located protocol successfully
+ EFI_NOT_FOUND - Fail to locate protocol or invalide returned pointer
+
+--*/
+{
+ EFI_STATUS Status;
+
+ *PerformanceBuffer = 0;
+
+ Status = LocatePerformanceProtocol ();
+ if (EFI_ERROR (Status)) {
+ return EFI_NOT_FOUND;
+ }
+
+ if (mPerformancePointer == NULL) {
+ return EFI_NOT_FOUND;
+ }
+
+ *PerformanceBuffer = (UINT32) ((UINTN) mPerformancePointer);
+
+ return Status;
+}
+
+UINT32
+GetPerfBufferLength (
+ IN FIRMWARE_PERFORMANCE_PROTOCOL *This
+ )
+/*++
+
+Routine Description:
+
+ Retrieves length of performance buffer
+
+Arguments:
+
+ This - Calling context
+
+Returns:
+
+ mPerformanceLength - length of pre-allocated memory buffer
+
+--*/
+{
+ EFI_STATUS Status;
+
+ Status = LocatePerformanceProtocol ();
+ if (EFI_ERROR (Status)) {
+ return 0;
+ }
+
+ return mPerformanceLength;
+}
+
+EFI_STATUS
+StartMeasure (
+ IN VOID *Handle,
+ IN UINT16 *Token,
+ IN UINT16 *Module,
+ IN UINT64 TimeStamp
+ )
+/*++
+
+Routine Description:
+
+ Start measurement according to token field and insert into pre-allocated buffer
+
+Arguments:
+
+ Handle - Handle to measure
+ Token - Token to measure
+ Module - Module to measure
+ Timestamp - Ticker as start tick
+
+Returns:
+
+ EFI_SUCCESS - Located protocol successfully, and buffer is updated with new record
+ EFI_NOT_FOUND - Failure in update
+
+--*/
+{
+ EFI_STATUS Status;
+ UINT16 RecordType;
+ UINT16 Identifier;
+
+ Status = LocatePerformanceProtocol ();
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ if (!StrCmp (Token, START_IMAGE_TOK)) {
+ RecordType = STRING_EVENT_REC_TYPE;
+ Identifier = MODULE_START_ID;
+ } else if (!StrCmp (Token, LOAD_IMAGE_TOK)) {
+ RecordType = STRING_EVENT_REC_TYPE;
+ Identifier = MODULE_LOADIMAGE_START_ID;
+ } else if (!StrCmp (Token, DRIVERBINDING_START_TOK)) {
+ RecordType = STRING_EVENT_REC_TYPE;
+ Identifier = MODULE_DRIVERBINDING_START_ID;
+ } else if (!StrCmp (Token, DXE_TOK)) {
+ RecordType = STRING_EVENT_REC_TYPE;
+ Identifier = DXE_START_ID;
+ } else if (!StrCmp (Token, DXE_CORE_DISP_INIT_TOK)) {
+ RecordType = STRING_EVENT_REC_TYPE;
+ Identifier = DXE_CORE_DISP_START_ID;
+ } else if (!StrCmp (Token, COREDISPATCHER_TOK)) {
+ RecordType = STRING_EVENT_REC_TYPE;
+ Identifier = COREDISPATCHER_START_ID;
+ } else {
+ RecordType = PERFORMANCE_RECORD_TYPE_MAX;
+ Identifier = 0;
+ }
+
+ Status = FirmwarePerformance->InsertMeasurement (FirmwarePerformance, Handle, RecordType, TimeStamp, Identifier);
+
+ return Status;
+}
+
+EFI_STATUS
+EndMeasure (
+ IN VOID *Handle,
+ IN UINT16 *Token,
+ IN UINT16 *Module,
+ IN UINT64 TimeStamp
+ )
+/*++
+
+Routine Description:
+
+ End measurement according to token field and insert into pre-allocated buffer
+
+Arguments:
+
+ Handle - Handle to stop
+ Token - Token to stop
+ Module - Module to stop
+ Timestamp - Ticker as end tick
+
+Returns:
+
+ EFI_SUCCESS - Located protocol successfully, and buffer is updated with new record
+ EFI_NOT_FOUND - Failure in update
+
+--*/
+{
+ EFI_STATUS Status;
+ UINT16 RecordType;
+ UINT16 Identifier;
+
+ Status = LocatePerformanceProtocol ();
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ if (!StrCmp (Token, START_IMAGE_TOK)) {
+ RecordType = STRING_EVENT_REC_TYPE;
+ Identifier = MODULE_END_ID;
+ } else if (!StrCmp (Token, LOAD_IMAGE_TOK)) {
+ RecordType = STRING_EVENT_REC_TYPE;
+ Identifier = MODULE_LOADIMAGE_END_ID;
+ } else if (!StrCmp (Token, DRIVERBINDING_START_TOK)) {
+ RecordType = STRING_EVENT_REC_TYPE;
+ Identifier = MODULE_DRIVERBINDING_END_ID;
+ } else if (!StrCmp (Token, DXE_TOK)) {
+ RecordType = STRING_EVENT_REC_TYPE;
+ Identifier = DXE_END_ID;
+ } else if (!StrCmp (Token, DXE_CORE_DISP_INIT_TOK)) {
+ RecordType = STRING_EVENT_REC_TYPE;
+ Identifier = DXE_CORE_DISP_END_ID;
+ } else if (!StrCmp (Token, COREDISPATCHER_TOK)) {
+ RecordType = STRING_EVENT_REC_TYPE;
+ Identifier = COREDISPATCHER_END_ID;
+ } else {
+ RecordType = PERFORMANCE_RECORD_TYPE_MAX;
+ Identifier = 0;
+ }
+
+ Status = FirmwarePerformance->InsertMeasurement (FirmwarePerformance, Handle, RecordType, TimeStamp, Identifier);
+
+ return Status;
+}
+
+EFI_STATUS
+StartMeasureEx (
+ IN VOID *Handle,
+ IN UINT16 *Token,
+ IN UINT16 *Module,
+ IN UINT64 TimeStamp,
+ IN UINT16 Identifier
+ )
+/*++
+
+Routine Description:
+
+ Start extended measurement according to token field and insert into pre-allocated buffer
+
+Arguments:
+
+ Handle - Handle to stop
+ Token - Token to stop
+ Module - Module to stop
+ Timestamp - Ticker as end tick
+ Identifier - Identifier for a given record
+Returns:
+
+ EFI_SUCCESS - Located protocol successfully, and buffer is updated with new record
+ EFI_NOT_FOUND - Failure in update
+
+--*/
+{
+ EFI_STATUS Status;
+ UINT16 RecordType;
+
+ Status = LocatePerformanceProtocol ();
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ if (!StrCmp (Token, HARDWARE_BOOT_TOK)) {
+ RecordType = HARDWARE_BOOT_TYPE;
+ } else if (!StrCmp (Token, EVENT_REC_TOK)) {
+ RecordType = STRING_EVENT_REC_TYPE;
+ } else if (!StrCmp (Token, BDS_ATTEMPT_TOK)) {
+ RecordType = BDS_ATTEMPT_EVENT_REC_TYPE;
+ } else {
+ RecordType = PERFORMANCE_RECORD_TYPE_MAX;
+ }
+
+ Status = FirmwarePerformance->InsertMeasurement (FirmwarePerformance, Handle, RecordType, TimeStamp, Identifier);
+
+ return Status;
+}
+
+EFI_STATUS
+EndMeasureEx (
+ IN VOID *Handle,
+ IN UINT16 *Token,
+ IN UINT16 *Module,
+ IN UINT64 TimeStamp,
+ IN UINT16 Identifier
+ )
+/*++
+
+Routine Description:
+
+ End extended measurement according to token field and insert into pre-allocated buffer
+
+Arguments:
+
+ Handle - Handle to stop
+ Token - Token to stop
+ Module - Module to stop
+ Timestamp - Ticker as end tick
+ Identifier - Identifier for a given record
+
+Returns:
+
+ EFI_SUCCESS - Located protocol successfully, and buffer is updated with new record
+ EFI_NOT_FOUND - Failure in update
+
+--*/
+{
+ EFI_STATUS Status;
+ UINT16 RecordType;
+
+ Status = LocatePerformanceProtocol ();
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ if (!StrCmp (Token, HARDWARE_BOOT_TOK)) {
+ RecordType = HARDWARE_BOOT_TYPE;
+ } else if (!StrCmp (Token, EVENT_REC_TOK)) {
+ RecordType = STRING_EVENT_REC_TYPE;
+ } else if (!StrCmp (Token, BDS_ATTEMPT_TOK)) {
+ RecordType = BDS_ATTEMPT_EVENT_REC_TYPE;
+ } else {
+ RecordType = PERFORMANCE_RECORD_TYPE_MAX;
+ }
+
+ Status = FirmwarePerformance->InsertMeasurement (FirmwarePerformance, Handle, RecordType, TimeStamp, Identifier);
+
+ return Status;
+} \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeFirmwarePerformanceLib/EdkIIGlueDxeFirmwarePerformanceLib.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeFirmwarePerformanceLib/EdkIIGlueDxeFirmwarePerformanceLib.cif
new file mode 100644
index 0000000..fbdf2e3
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeFirmwarePerformanceLib/EdkIIGlueDxeFirmwarePerformanceLib.cif
@@ -0,0 +1,11 @@
+<component>
+ name = "EdkIIGlueDxeFirmwarePerformanceLib"
+ category = ModulePart
+ LocalRoot = "EDK\Foundation\Library\EdkIIGlueLib\Library\DxeFirmwarePerformanceLib\"
+ RefName = "EdkIIGlueDxeFirmwarePerformanceLib"
+[files]
+"EdkIIGlueDxeFirmwarePerformanceLib.sdl"
+"EdkIIGlueDxeFirmwarePerformanceLib.mak"
+"EdkIIGlueDxeFirmwarePerformanceLib.inf"
+"EdkIIGlueDxeFirmwarePerformanceLib.c"
+<endComponent> \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeFirmwarePerformanceLib/EdkIIGlueDxeFirmwarePerformanceLib.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeFirmwarePerformanceLib/EdkIIGlueDxeFirmwarePerformanceLib.inf
new file mode 100644
index 0000000..c0e5e2e
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeFirmwarePerformanceLib/EdkIIGlueDxeFirmwarePerformanceLib.inf
@@ -0,0 +1,81 @@
+#/*++
+#
+# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
+# This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# EdkIIGlueDxeFirmwarePerformanceLib.inf
+#
+# Abstract:
+#
+# Component description file for DxePerformanceLib
+#
+#--*/
+
+[defines]
+BASE_NAME = EdkIIGlueDxeFirmwarePerformanceLib
+COMPONENT_TYPE = LIBRARY
+
+[sources.common]
+ EdkIIGluedxeFirmwarePerformanceLib.c
+
+[sources.ia32]
+
+
+[sources.x64]
+
+
+[sources.ipf]
+
+
+[sources.ebc]
+
+
+[includes.common]
+ .
+ ..\..\Include
+ ..\..\include\Library
+ $(EDK_SOURCE)\Foundation
+ $(EDK_SOURCE)\Foundation\Framework
+ $(EDK_SOURCE)\Foundation\Efi
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+ $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+
+[libraries.common]
+ EdkIIGlueUefiDevicePathLib
+ EdkIIGlueUefiLib
+ EdkIIGlueBaseTimerLibLocalApic
+ EdkIIGlueBasePeCoffGetEntryPointLib
+ EdkIIGlueBaseTimerLibTsc
+
+[libraries.ia32]
+
+[libraries.x64]
+
+[nmake.common]
+ C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION
+ LIB_STD_FLAGS = /NOLOGO /IGNORE:4006 /IGNORE:4221
+
+[nmake.ia32]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32
+
+[nmake.x64]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64
+
+[nmake.ipf]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF
+
+[nmake.ebc]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeFirmwarePerformanceLib/EdkIIGlueDxeFirmwarePerformanceLib.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeFirmwarePerformanceLib/EdkIIGlueDxeFirmwarePerformanceLib.mak
new file mode 100644
index 0000000..d8d96d0
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeFirmwarePerformanceLib/EdkIIGlueDxeFirmwarePerformanceLib.mak
@@ -0,0 +1,68 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2011, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueDxeFirmwarePerformanceLib/EdkIIGlueDxeFirmwarePerformanceLib.mak 1 1/20/12 3:59a Jeffch $
+#
+# $Revision: 1 $
+#
+# $Date: 1/20/12 3:59a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueDxeFirmwarePerformanceLib/EdkIIGlueDxeFirmwarePerformanceLib.mak $
+#
+# 1 1/20/12 3:59a Jeffch
+#
+# 1 11/17/11 9:32p Wesleychen
+# Add firmware performance support from Intel EDK117 Client Framework
+# PatchV7 package.
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: EdkIIGlueDxeFirmwarePerformanceLib.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+$(EdkIIGlueDxeFirmwarePerformanceLib_LIB) : EdkIIGlueDxeFirmwarePerformanceLib
+
+EdkIIGlueDxeFirmwarePerformanceLib : $(BUILD_DIR)\EdkIIGlueDxeFirmwarePerformanceLib.mak EdkIIGlueDxeFirmwarePerformanceLibBin
+
+$(BUILD_DIR)\EdkIIGlueDxeFirmwarePerformanceLib.mak : $(EdkIIGlueDxeFirmwarePerformanceLib_DIR)\$(@B).cif $(EdkIIGlueDxeFirmwarePerformanceLib_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(EdkIIGlueDxeFirmwarePerformanceLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+EdkIIGlueDxeFirmwarePerformanceLibBin : $(CPUIA32LIB)
+
+EdkIIGlueDxeFirmwarePerformanceLibBin : $(EdkIIGlueUefiDevicePathLib_LIB) $(EdkIIGlueBasePeCoffGetEntryPointLib_LIB) $(EdkIIGlueBaseTimerLibLocalApic_LIB) $(EdkIIGlueUefiLib_LIB) $(EdkIIGlueBaseTimerLibTsc_LIB) $(EDKGUIDLIB) $(ARCHPROTOCOLLIB)
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGlueDxeFirmwarePerformanceLib.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueDxeFirmwarePerformanceLib_LIB)"
+
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2011, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeFirmwarePerformanceLib/EdkIIGlueDxeFirmwarePerformanceLib.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeFirmwarePerformanceLib/EdkIIGlueDxeFirmwarePerformanceLib.sdl
new file mode 100644
index 0000000..1e50421
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeFirmwarePerformanceLib/EdkIIGlueDxeFirmwarePerformanceLib.sdl
@@ -0,0 +1,24 @@
+TOKEN
+ Name = EdkIIGlueDxeFirmwarePerformanceLib_SUPPORT
+ Value = 1
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "EdkIIGlueDxeFirmwarePerformanceLib_LIB"
+ Value = "$$(LIB_BUILD_DIR)\EdkIIGlueDxeFirmwarePerformanceLib.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "EdkIIGlueDxeFirmwarePerformanceLib_DIR"
+End
+
+MODULE
+ Help = "Includes EdkIIGlueDxeFirmwarePerformanceLib.mak to Project"
+ File = "EdkIIGlueDxeFirmwarePerformanceLib.mak"
+End \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeHobLib/DxeHobLib.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeHobLib/DxeHobLib.inf
new file mode 100644
index 0000000..590e2f1
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeHobLib/DxeHobLib.inf
@@ -0,0 +1,82 @@
+#/*++
+#
+# Copyright (c) 2004 - 2006, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# DxeHobLib.inf
+#
+# Abstract:
+#
+# Component description file for DxeHobLib.
+#
+#--*/
+
+[defines]
+BASE_NAME = EdkIIGlueDxeHobLib
+COMPONENT_TYPE = LIBRARY
+
+[sources.common]
+ HobLib.c
+
+[sources.ia32]
+
+[sources.x64]
+
+[sources.ipf]
+
+[sources.ebc]
+
+
+[includes.common]
+ .
+ ..\..\Include
+ ..\..\include\Library
+ $(EDK_SOURCE)\Foundation
+ $(EDK_SOURCE)\Foundation\Framework
+ $(EDK_SOURCE)\Foundation\Efi
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+ $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include
+
+[libraries.common]
+ EdkIIGlueBaseMemoryLib
+ EdkIIGlueUefiLib
+#
+# R8.x Library, GUID needed: gEfiHobListGuid
+#
+ EdkFrameworkGuidLib
+
+
+[libraries.ia32]
+
+
+[libraries.x64]
+
+
+[nmake.common]
+ C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION
+ LIB_STD_FLAGS = /NOLOGO /IGNORE:4006
+
+[nmake.ia32]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32
+
+[nmake.x64]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64
+
+[nmake.ipf]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF
+
+[nmake.ebc]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeHobLib/EdkIIGlueDxeHobLib.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeHobLib/EdkIIGlueDxeHobLib.cif
new file mode 100644
index 0000000..a5444f6
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeHobLib/EdkIIGlueDxeHobLib.cif
@@ -0,0 +1,11 @@
+<component>
+ name = "EdkIIGlueDxeHobLib"
+ category = ModulePart
+ LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\DxeHobLib"
+ RefName = "EdkIIGlueDxeHobLib"
+[files]
+"EdkIIGlueDxeHobLib.sdl"
+"EdkIIGlueDxeHobLib.mak"
+"DxeHobLib.inf"
+"HobLib.c"
+<endComponent>
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeHobLib/EdkIIGlueDxeHobLib.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeHobLib/EdkIIGlueDxeHobLib.mak
new file mode 100644
index 0000000..19e9823
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeHobLib/EdkIIGlueDxeHobLib.mak
@@ -0,0 +1,80 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueDxeHobLib/EdkIIGlueDxeHobLib.mak 1 1/20/12 3:55a Jeffch $
+#
+# $Revision: 1 $
+#
+# $Date: 1/20/12 3:55a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueDxeHobLib/EdkIIGlueDxeHobLib.mak $
+#
+# 1 1/20/12 3:55a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 9/27/11 6:17a Wesleychen
+# Intel EDK initially releases.
+#
+# 1 9/18/09 1:54a Iminglin
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: EdkIIGlueDxeHobLib.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+
+
+$(EdkIIGlueDxeHobLib_LIB) : EdkIIGlueDxeHobLib
+
+EdkIIGlueDxeHobLib : $(BUILD_DIR)\EdkIIGlueDxeHobLib.mak EdkIIGlueDxeHobLibBin
+
+$(BUILD_DIR)\EdkIIGlueDxeHobLib.mak : $(EdkIIGlueDxeHobLib_DIR)\$(@B).cif $(EdkIIGlueDxeHobLib_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(EdkIIGlueDxeHobLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+EdkIIGlueDxeHobLibBin : $(EdkIIGlueBaseMemoryLib_LIB) $(EdkIIGlueUefiLib_LIB) $(EDKFRAMEWORKGUIDLIB)
+!IF "$(x64_BUILD)"=="1"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGlueDxeHobLib.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueDxeHobLib_LIB)"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\IA32\
+ /f $(BUILD_DIR)\EdkIIGlueDxeHobLib.mak all\
+ TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueDxeHobLib_LIB)"
+!ELSE
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGlueDxeHobLib.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueDxeHobLib_LIB)"
+!ENDIF
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeHobLib/EdkIIGlueDxeHobLib.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeHobLib/EdkIIGlueDxeHobLib.sdl
new file mode 100644
index 0000000..a581d6f
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeHobLib/EdkIIGlueDxeHobLib.sdl
@@ -0,0 +1,26 @@
+TOKEN
+ Name = "EdkIIGlueDxeHobLib_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable EdkIIGlueDxeHobLib support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "EdkIIGlueDxeHobLib_LIB"
+ Value = "$$(LIB_BUILD_DIR)\EdkIIGlueDxeHobLib.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "EdkIIGlueDxeHobLib_DIR"
+End
+
+MODULE
+ Help = "Includes EdkIIGlueDxeHobLib.mak to Project"
+ File = "EdkIIGlueDxeHobLib.mak"
+End
+
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeHobLib/HobLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeHobLib/HobLib.c
new file mode 100644
index 0000000..8cc17a8
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeHobLib/HobLib.c
@@ -0,0 +1,501 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ HobLib.c
+
+Abstract:
+
+ HOB Library.
+
+--*/
+
+#include "EdkIIGlueDxe.h"
+
+
+STATIC VOID *mHobList = NULL;
+
+/**
+ The constructor function caches the pointer to HOB list.
+
+ The constructor function gets the start address of HOB list from system configuration table.
+ It will ASSERT() if that operation fails and it will always return EFI_SUCCESS.
+
+ @param ImageHandle The firmware allocated handle for the EFI image.
+ @param SystemTable A pointer to the EFI System Table.
+
+ @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
+
+**/
+EFI_STATUS
+EFIAPI
+HobLibConstructor (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ EFI_STATUS Status;
+
+ Status = EfiGetSystemConfigurationTable (&gEfiHobListGuid, &mHobList);
+ ASSERT_EFI_ERROR (Status);
+ ASSERT (mHobList != NULL);
+ return Status;
+}
+
+/**
+ Returns the pointer to the HOB list.
+
+ This function returns the pointer to first HOB in the list.
+
+ @return The pointer to the HOB list.
+
+**/
+VOID *
+EFIAPI
+GetHobList (
+ VOID
+ )
+{
+ return mHobList;
+}
+
+/**
+ Returns the next instance of a HOB type from the starting HOB.
+
+ This function searches the first instance of a HOB type from the starting HOB pointer.
+ If there does not exist such HOB type from the starting HOB pointer, it will return NULL.
+ In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer
+ unconditionally: it returns HobStart back if HobStart itself meets the requirement;
+ caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart.
+ If HobStart is NULL, then ASSERT().
+
+ @param Type The HOB type to return.
+ @param HobStart The starting HOB pointer to search from.
+
+ @return The next instance of a HOB type from the starting HOB.
+
+**/
+VOID *
+EFIAPI
+GetNextHob (
+ IN UINT16 Type,
+ IN CONST VOID *HobStart
+ )
+{
+ EFI_PEI_HOB_POINTERS Hob;
+
+ ASSERT (HobStart != NULL);
+
+ Hob.Raw = (UINT8 *) HobStart;
+ //
+ // Parse the HOB list until end of list or matching type is found.
+ //
+ while (!END_OF_HOB_LIST (Hob)) {
+ if (Hob.Header->HobType == Type) {
+ return Hob.Raw;
+ }
+ Hob.Raw = GET_NEXT_HOB (Hob);
+ }
+ return NULL;
+}
+
+/**
+ Returns the first instance of a HOB type among the whole HOB list.
+
+ This function searches the first instance of a HOB type among the whole HOB list.
+ If there does not exist such HOB type in the HOB list, it will return NULL.
+
+ @param Type The HOB type to return.
+
+ @return The next instance of a HOB type from the starting HOB.
+
+**/
+VOID *
+EFIAPI
+GetFirstHob (
+ IN UINT16 Type
+ )
+{
+ VOID *HobList;
+
+ HobList = GetHobList ();
+ return GetNextHob (Type, HobList);
+}
+
+/**
+ This function searches the first instance of a HOB from the starting HOB pointer.
+ Such HOB should satisfy two conditions:
+ its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid.
+ If there does not exist such HOB from the starting HOB pointer, it will return NULL.
+ Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE ()
+ to extract the data section and its size info respectively.
+ In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer
+ unconditionally: it returns HobStart back if HobStart itself meets the requirement;
+ caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart.
+ If Guid is NULL, then ASSERT().
+ If HobStart is NULL, then ASSERT().
+
+ @param Guid The GUID to match with in the HOB list.
+ @param HobStart A pointer to a Guid.
+
+ @return The next instance of the matched GUID HOB from the starting HOB.
+
+**/
+VOID *
+EFIAPI
+GlueGetNextGuidHob (
+ IN CONST EFI_GUID *Guid,
+ IN CONST VOID *HobStart
+ )
+{
+ EFI_PEI_HOB_POINTERS GuidHob;
+
+ GuidHob.Raw = (UINT8 *) HobStart;
+ while ((GuidHob.Raw = GetNextHob (EFI_HOB_TYPE_GUID_EXTENSION, GuidHob.Raw)) != NULL) {
+ if (CompareGuid (Guid, &GuidHob.Guid->Name)) {
+ break;
+ }
+ GuidHob.Raw = GET_NEXT_HOB (GuidHob);
+ }
+ return GuidHob.Raw;
+}
+
+/**
+ This function searches the first instance of a HOB among the whole HOB list.
+ Such HOB should satisfy two conditions:
+ its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid.
+ If there does not exist such HOB from the starting HOB pointer, it will return NULL.
+ Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE ()
+ to extract the data section and its size info respectively.
+ If Guid is NULL, then ASSERT().
+
+ @param Guid The GUID to match with in the HOB list.
+
+ @return The first instance of the matched GUID HOB among the whole HOB list.
+
+**/
+VOID *
+EFIAPI
+GlueGetFirstGuidHob (
+ IN CONST EFI_GUID *Guid
+ )
+{
+ VOID *HobList;
+
+ HobList = GetHobList ();
+ return GetNextGuidHob (Guid, HobList);
+}
+
+/**
+ Get the Boot Mode from the HOB list.
+
+ This function returns the system boot mode information from the
+ PHIT HOB in HOB list.
+
+ @param VOID
+
+ @return The Boot Mode.
+
+**/
+EFI_BOOT_MODE
+EFIAPI
+GetBootModeHob (
+ VOID
+ )
+{
+ EFI_HOB_HANDOFF_INFO_TABLE *HandOffHob;
+
+ HandOffHob = (EFI_HOB_HANDOFF_INFO_TABLE *) GetHobList ();
+
+ return HandOffHob->BootMode;
+}
+
+/**
+ Builds a HOB for a loaded PE32 module.
+
+ This function builds a HOB for a loaded PE32 module.
+ It can only be invoked during PEI phase;
+ for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
+ If ModuleName is NULL, then ASSERT().
+ If there is no additional space for HOB creation, then ASSERT().
+
+ @param ModuleName The GUID File Name of the module.
+ @param MemoryAllocationModule The 64 bit physical address of the module.
+ @param ModuleLength The length of the module in bytes.
+ @param EntryPoint The 64 bit physical address of the module's entry point.
+
+**/
+VOID
+EFIAPI
+GlueBuildModuleHob (
+ IN CONST EFI_GUID *ModuleName,
+ IN EFI_PHYSICAL_ADDRESS MemoryAllocationModule,
+ IN UINT64 ModuleLength,
+ IN EFI_PHYSICAL_ADDRESS EntryPoint
+ )
+{
+ //
+ // PEI HOB is read only for DXE phase
+ //
+ ASSERT (FALSE);
+}
+
+/**
+ Builds a HOB that describes a chunk of system memory.
+
+ This function builds a HOB that describes a chunk of system memory.
+ It can only be invoked during PEI phase;
+ for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
+ If there is no additional space for HOB creation, then ASSERT().
+
+ @param ResourceType The type of resource described by this HOB.
+ @param ResourceAttribute The resource attributes of the memory described by this HOB.
+ @param PhysicalStart The 64 bit physical address of memory described by this HOB.
+ @param NumberOfBytes The length of the memory described by this HOB in bytes.
+
+**/
+VOID
+EFIAPI
+BuildResourceDescriptorHob (
+ IN EFI_RESOURCE_TYPE ResourceType,
+ IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute,
+ IN EFI_PHYSICAL_ADDRESS PhysicalStart,
+ IN UINT64 NumberOfBytes
+ )
+{
+ //
+ // PEI HOB is read only for DXE phase
+ //
+ ASSERT (FALSE);
+}
+
+/**
+ Builds a GUID HOB with a certain data length.
+
+ This function builds a customized HOB tagged with a GUID for identification
+ and returns the start address of GUID HOB data so that caller can fill the customized data.
+ The HOB Header and Name field is already stripped.
+ It can only be invoked during PEI phase;
+ for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
+ If Guid is NULL, then ASSERT().
+ If there is no additional space for HOB creation, then ASSERT().
+ If DataLength >= (0x10000 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().
+
+ @param Guid The GUID to tag the customized HOB.
+ @param DataLength The size of the data payload for the GUID HOB.
+
+ @return The start address of GUID HOB data.
+
+**/
+VOID *
+EFIAPI
+BuildGuidHob (
+ IN CONST EFI_GUID *Guid,
+ IN UINTN DataLength
+ )
+{
+ //
+ // PEI HOB is read only for DXE phase
+ //
+ ASSERT (FALSE);
+ return NULL;
+}
+
+/**
+ Copies a data buffer to a newly-built HOB.
+
+ This function builds a customized HOB tagged with a GUID for identification,
+ copies the input data to the HOB data field and returns the start address of the GUID HOB data.
+ The HOB Header and Name field is already stripped.
+ It can only be invoked during PEI phase;
+ for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
+ If Guid is NULL, then ASSERT().
+ If Data is NULL and DataLength > 0, then ASSERT().
+ If there is no additional space for HOB creation, then ASSERT().
+ If DataLength >= (0x10000 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().
+
+ @param Guid The GUID to tag the customized HOB.
+ @param Data The data to be copied into the data field of the GUID HOB.
+ @param DataLength The size of the data payload for the GUID HOB.
+
+ @return The start address of GUID HOB data.
+
+**/
+VOID *
+EFIAPI
+BuildGuidDataHob (
+ IN CONST EFI_GUID *Guid,
+ IN VOID *Data,
+ IN UINTN DataLength
+ )
+{
+ //
+ // PEI HOB is read only for DXE phase
+ //
+ ASSERT (FALSE);
+ return NULL;
+}
+
+/**
+ Builds a Firmware Volume HOB.
+
+ This function builds a Firmware Volume HOB.
+ It can only be invoked during PEI phase;
+ for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
+ If there is no additional space for HOB creation, then ASSERT().
+
+ @param BaseAddress The base address of the Firmware Volume.
+ @param Length The size of the Firmware Volume in bytes.
+
+**/
+VOID
+EFIAPI
+BuildFvHob (
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length
+ )
+{
+ //
+ // PEI HOB is read only for DXE phase
+ //
+ ASSERT (FALSE);
+}
+
+/**
+ Builds a Capsule Volume HOB.
+
+ This function builds a Capsule Volume HOB.
+ It can only be invoked during PEI phase;
+ for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
+ If there is no additional space for HOB creation, then ASSERT().
+
+ @param BaseAddress The base address of the Capsule Volume.
+ @param Length The size of the Capsule Volume in bytes.
+
+**/
+VOID
+EFIAPI
+BuildCvHob (
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length
+ )
+{
+ //
+ // PEI HOB is read only for DXE phase
+ //
+ ASSERT (FALSE);
+}
+
+/**
+ Builds a HOB for the CPU.
+
+ This function builds a HOB for the CPU.
+ It can only be invoked during PEI phase;
+ for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
+ If there is no additional space for HOB creation, then ASSERT().
+
+ @param SizeOfMemorySpace The maximum physical memory addressability of the processor.
+ @param SizeOfIoSpace The maximum physical I/O addressability of the processor.
+
+**/
+VOID
+EFIAPI
+BuildCpuHob (
+ IN UINT8 SizeOfMemorySpace,
+ IN UINT8 SizeOfIoSpace
+ )
+{
+ //
+ // PEI HOB is read only for DXE phase
+ //
+ ASSERT (FALSE);
+}
+
+/**
+ Builds a HOB for the Stack.
+
+ This function builds a HOB for the stack.
+ It can only be invoked during PEI phase;
+ for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
+ If there is no additional space for HOB creation, then ASSERT().
+
+ @param BaseAddress The 64 bit physical address of the Stack.
+ @param Length The length of the stack in bytes.
+
+**/
+VOID
+EFIAPI
+BuildStackHob (
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length
+ )
+{
+ //
+ // PEI HOB is read only for DXE phase
+ //
+ ASSERT (FALSE);
+}
+
+/**
+ Builds a HOB for the BSP store.
+
+ This function builds a HOB for BSP store.
+ It can only be invoked during PEI phase;
+ for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
+ If there is no additional space for HOB creation, then ASSERT().
+
+ @param BaseAddress The 64 bit physical address of the BSP.
+ @param Length The length of the BSP store in bytes.
+ @param MemoryType Type of memory allocated by this HOB.
+
+**/
+VOID
+EFIAPI
+BuildBspStoreHob (
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length,
+ IN EFI_MEMORY_TYPE MemoryType
+ )
+{
+ //
+ // PEI HOB is read only for DXE phase
+ //
+ ASSERT (FALSE);
+}
+
+/**
+ Builds a HOB for the memory allocation.
+
+ This function builds a HOB for the memory allocation.
+ It can only be invoked during PEI phase;
+ for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
+ If there is no additional space for HOB creation, then ASSERT().
+
+ @param BaseAddress The 64 bit physical address of the memory.
+ @param Length The length of the memory allocation in bytes.
+ @param MemoryType Type of memory allocated by this HOB.
+
+**/
+VOID
+EFIAPI
+GlueBuildMemoryAllocationHob (
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length,
+ IN EFI_MEMORY_TYPE MemoryType
+ )
+{
+ //
+ // PEI HOB is read only for DXE phase
+ //
+ ASSERT (FALSE);
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeMemoryAllocationLib/DxeMemoryAllocationLib.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeMemoryAllocationLib/DxeMemoryAllocationLib.inf
new file mode 100644
index 0000000..68ebf65
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeMemoryAllocationLib/DxeMemoryAllocationLib.inf
@@ -0,0 +1,79 @@
+#/*++
+#
+# Copyright (c) 2004 - 2006, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# DxeMemoryAllocationLib.inf
+#
+# Abstract:
+#
+# Component description file for DxeMemoryAllocationLib.
+#
+#--*/
+
+[defines]
+BASE_NAME = EdkIIGlueDxeMemoryAllocationLib
+COMPONENT_TYPE = LIBRARY
+
+[sources.common]
+ MemoryAllocationLib.c
+
+[sources.ia32]
+
+[sources.x64]
+
+[sources.ipf]
+
+[sources.ebc]
+
+
+[includes.common]
+ .
+ ..\..\Include
+ ..\..\include\Library
+ $(EDK_SOURCE)\Foundation
+ $(EDK_SOURCE)\Foundation\Framework
+ $(EDK_SOURCE)\Foundation\Efi
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+ $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include
+
+[libraries.common]
+ EdkIIGlueBaseMemoryLib
+ EdkIIGlueUefiBootServicesTableLib
+ EfiProtocolLib
+
+
+[libraries.ia32]
+
+
+[libraries.x64]
+
+
+[nmake.common]
+ C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION
+ LIB_STD_FLAGS = /NOLOGO /IGNORE:4006
+
+[nmake.ia32]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32
+
+[nmake.x64]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64
+
+[nmake.ipf]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF
+
+[nmake.ebc]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeMemoryAllocationLib/EdkIIGlueDxeMemoryAllocationLib.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeMemoryAllocationLib/EdkIIGlueDxeMemoryAllocationLib.cif
new file mode 100644
index 0000000..f08f575
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeMemoryAllocationLib/EdkIIGlueDxeMemoryAllocationLib.cif
@@ -0,0 +1,11 @@
+<component>
+ name = "EdkIIGlueDxeMemoryAllocationLib"
+ category = ModulePart
+ LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\DxeMemoryAllocationLib"
+ RefName = "EdkIIGlueDxeMemoryAllocationLib"
+[files]
+"EdkIIGlueDxeMemoryAllocationLib.sdl"
+"EdkIIGlueDxeMemoryAllocationLib.mak"
+"DxeMemoryAllocationLib.inf"
+"MemoryAllocationLib.c"
+<endComponent>
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeMemoryAllocationLib/EdkIIGlueDxeMemoryAllocationLib.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeMemoryAllocationLib/EdkIIGlueDxeMemoryAllocationLib.mak
new file mode 100644
index 0000000..f88e68f
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeMemoryAllocationLib/EdkIIGlueDxeMemoryAllocationLib.mak
@@ -0,0 +1,80 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueDxeMemoryAllocationLib/EdkIIGlueDxeMemoryAllocationLib.mak 1 1/20/12 3:55a Jeffch $
+#
+# $Revision: 1 $
+#
+# $Date: 1/20/12 3:55a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueDxeMemoryAllocationLib/EdkIIGlueDxeMemoryAllocationLib.mak $
+#
+# 1 1/20/12 3:55a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 9/27/11 6:17a Wesleychen
+# Intel EDK initially releases.
+#
+# 1 9/18/09 1:54a Iminglin
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: EdkIIGlueDxeMemoryAllocationLib.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+
+
+$(EdkIIGlueDxeMemoryAllocationLib_LIB) : EdkIIGlueDxeMemoryAllocationLib
+
+EdkIIGlueDxeMemoryAllocationLib : $(BUILD_DIR)\EdkIIGlueDxeMemoryAllocationLib.mak EdkIIGlueDxeMemoryAllocationLibBin
+
+$(BUILD_DIR)\EdkIIGlueDxeMemoryAllocationLib.mak : $(EdkIIGlueDxeMemoryAllocationLib_DIR)\$(@B).cif $(EdkIIGlueDxeMemoryAllocationLib_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(EdkIIGlueDxeMemoryAllocationLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+EdkIIGlueDxeMemoryAllocationLibBin : $(EdkIIGlueBaseMemoryLib_LIB) $(EdkIIGlueUefiBootServicesTableLib_LIB) $(EFIPROTOCOLLIB)
+!IF "$(x64_BUILD)"=="1"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGlueDxeMemoryAllocationLib.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueDxeMemoryAllocationLib_LIB)"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\IA32\
+ /f $(BUILD_DIR)\EdkIIGlueDxeMemoryAllocationLib.mak all\
+ TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueDxeMemoryAllocationLib_LIB)"
+!ELSE
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGlueDxeMemoryAllocationLib.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueDxeMemoryAllocationLib_LIB)"
+!ENDIF
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeMemoryAllocationLib/EdkIIGlueDxeMemoryAllocationLib.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeMemoryAllocationLib/EdkIIGlueDxeMemoryAllocationLib.sdl
new file mode 100644
index 0000000..191f45e
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeMemoryAllocationLib/EdkIIGlueDxeMemoryAllocationLib.sdl
@@ -0,0 +1,26 @@
+TOKEN
+ Name = "EdkIIGlueDxeMemoryAllocationLib_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable EdkIIGlueDxeMemoryAllocationLib support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "EdkIIGlueDxeMemoryAllocationLib_LIB"
+ Value = "$$(LIB_BUILD_DIR)\EdkIIGlueDxeMemoryAllocationLib.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "EdkIIGlueDxeMemoryAllocationLib_DIR"
+End
+
+MODULE
+ Help = "Includes EdkIIGlueDxeMemoryAllocationLib.mak to Project"
+ File = "EdkIIGlueDxeMemoryAllocationLib.mak"
+End
+
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeMemoryAllocationLib/MemoryAllocationLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeMemoryAllocationLib/MemoryAllocationLib.c
new file mode 100644
index 0000000..21a781c
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeMemoryAllocationLib/MemoryAllocationLib.c
@@ -0,0 +1,1079 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ MemoryAllocationLib.c
+
+Abstract:
+
+ Support routines for memory allocation routines for use with drivers.
+
+--*/
+
+#include "EdkIIGlueDxe.h"
+
+
+/**
+ Allocates one or more 4KB pages of a certain memory type.
+
+ Allocates the number of 4KB pages of a certain memory type and returns a pointer to the allocated
+ buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL is returned.
+ If there is not enough memory remaining to satisfy the request, then NULL is returned.
+
+ @param MemoryType The type of memory to allocate.
+ @param Pages The number of 4 KB pages to allocate.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+InternalAllocatePages (
+ IN EFI_MEMORY_TYPE MemoryType,
+ IN UINTN Pages
+ )
+{
+ EFI_STATUS Status;
+ EFI_PHYSICAL_ADDRESS Memory;
+
+ if (Pages == 0) {
+ return NULL;
+ }
+
+ Status = (gBS->AllocatePages) (AllocateAnyPages, MemoryType, Pages, &Memory);
+ if (EFI_ERROR (Status)) {
+ Memory = 0;
+ }
+ return (VOID *) (UINTN) Memory;
+}
+
+/**
+ Allocates one or more 4KB pages of type EfiBootServicesData.
+
+ Allocates the number of 4KB pages of type EfiBootServicesData and returns a pointer to the
+ allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL
+ is returned. If there is not enough memory remaining to satisfy the request, then NULL is
+ returned.
+
+ @param Pages The number of 4 KB pages to allocate.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+GlueAllocatePages (
+ IN UINTN Pages
+ )
+{
+ return InternalAllocatePages (EfiBootServicesData, Pages);
+}
+
+/**
+ Allocates one or more 4KB pages of type EfiRuntimeServicesData.
+
+ Allocates the number of 4KB pages of type EfiRuntimeServicesData and returns a pointer to the
+ allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL
+ is returned. If there is not enough memory remaining to satisfy the request, then NULL is
+ returned.
+
+ @param Pages The number of 4 KB pages to allocate.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateRuntimePages (
+ IN UINTN Pages
+ )
+{
+ return InternalAllocatePages (EfiRuntimeServicesData, Pages);
+}
+
+/**
+ Allocates one or more 4KB pages of type EfiReservedMemoryType.
+
+ Allocates the number of 4KB pages of type EfiReservedMemoryType and returns a pointer to the
+ allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL
+ is returned. If there is not enough memory remaining to satisfy the request, then NULL is
+ returned.
+
+ @param Pages The number of 4 KB pages to allocate.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateReservedPages (
+ IN UINTN Pages
+ )
+{
+ return InternalAllocatePages (EfiReservedMemoryType, Pages);
+}
+
+/**
+ Frees one or more 4KB pages that were previously allocated with one of the page allocation
+ functions in the Memory Allocation Library.
+
+ Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer. Buffer
+ must have been allocated on a previous call to the page allocation services of the Memory
+ Allocation Library.
+ If Buffer was not allocated with a page allocation function in the Memory Allocation Library,
+ then ASSERT().
+ If Pages is zero, then ASSERT().
+
+ @param Buffer Pointer to the buffer of pages to free.
+ @param Pages The number of 4 KB pages to free.
+
+**/
+VOID
+EFIAPI
+GlueFreePages (
+ IN VOID *Buffer,
+ IN UINTN Pages
+ )
+{
+ EFI_STATUS Status;
+
+ ASSERT (Pages != 0);
+ Status = (gBS->FreePages) ((EFI_PHYSICAL_ADDRESS) (UINTN) Buffer, Pages);
+ ASSERT_EFI_ERROR (Status);
+}
+
+/**
+ Allocates one or more 4KB pages of a certain memory type at a specified alignment.
+
+ Allocates the number of 4KB pages specified by Pages of a certain memory type with an alignment
+ specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is returned.
+ If there is not enough memory at the specified alignment remaining to satisfy the request, then
+ NULL is returned.
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().
+
+ @param MemoryType The type of memory to allocate.
+ @param Pages The number of 4 KB pages to allocate.
+ @param Alignment The requested alignment of the allocation. Must be a power of two.
+ If Alignment is zero, then byte alignment is used.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+InternalAllocateAlignedPages (
+ IN EFI_MEMORY_TYPE MemoryType,
+ IN UINTN Pages,
+ IN UINTN Alignment
+ )
+{
+ EFI_STATUS Status;
+ EFI_PHYSICAL_ADDRESS Memory;
+ UINTN AlignedMemory;
+ UINTN AlignmentMask;
+ UINTN UnalignedPages;
+ UINTN RealPages;
+
+ //
+ // Alignment must be a power of two or zero.
+ //
+ ASSERT ((Alignment & (Alignment - 1)) == 0);
+
+ if (Pages == 0) {
+ return NULL;
+ }
+ if (Alignment > EFI_PAGE_SIZE) {
+ //
+ // Caculate the total number of pages since alignment is larger than page size.
+ //
+ AlignmentMask = Alignment - 1;
+ RealPages = Pages + EFI_SIZE_TO_PAGES (Alignment);
+ //
+ // Make sure that Pages plus EFI_SIZE_TO_PAGES (Alignment) does not overflow.
+ //
+ ASSERT (RealPages > Pages);
+
+ Status = (gBS->AllocatePages) (AllocateAnyPages, MemoryType, RealPages, &Memory);
+ if (EFI_ERROR (Status)) {
+ return NULL;
+ }
+ AlignedMemory = ((UINTN) Memory + AlignmentMask) & ~AlignmentMask;
+ UnalignedPages = EFI_SIZE_TO_PAGES ((UINTN) Memory - AlignedMemory);
+ if (UnalignedPages > 0) {
+ //
+ // Free first unaligned page(s).
+ //
+ Status = (gBS->FreePages) (Memory, UnalignedPages);
+ ASSERT_EFI_ERROR (Status);
+ }
+ Memory = (EFI_PHYSICAL_ADDRESS) (AlignedMemory + EFI_PAGES_TO_SIZE (Pages));
+ UnalignedPages = RealPages - Pages - UnalignedPages;
+ if (UnalignedPages > 0) {
+ //
+ // Free last unaligned page(s).
+ //
+ Status = (gBS->FreePages) (Memory, UnalignedPages);
+ ASSERT_EFI_ERROR (Status);
+ }
+ } else {
+ //
+ // Do not over-allocate pages in this case.
+ //
+ Status = (gBS->AllocatePages) (AllocateAnyPages, MemoryType, Pages, &Memory);
+ if (EFI_ERROR (Status)) {
+ return NULL;
+ }
+ AlignedMemory = (UINTN) Memory;
+ }
+ return (VOID *) AlignedMemory;
+}
+
+/**
+ Allocates one or more 4KB pages of type EfiBootServicesData at a specified alignment.
+
+ Allocates the number of 4KB pages specified by Pages of type EfiBootServicesData with an
+ alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is
+ returned. If there is not enough memory at the specified alignment remaining to satisfy the
+ request, then NULL is returned.
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().
+
+ @param Pages The number of 4 KB pages to allocate.
+ @param Alignment The requested alignment of the allocation. Must be a power of two.
+ If Alignment is zero, then byte alignment is used.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateAlignedPages (
+ IN UINTN Pages,
+ IN UINTN Alignment
+ )
+{
+ return InternalAllocateAlignedPages (EfiBootServicesData, Pages, Alignment);
+}
+
+/**
+ Allocates one or more 4KB pages of type EfiRuntimeServicesData at a specified alignment.
+
+ Allocates the number of 4KB pages specified by Pages of type EfiRuntimeServicesData with an
+ alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is
+ returned. If there is not enough memory at the specified alignment remaining to satisfy the
+ request, then NULL is returned.
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().
+
+ @param Pages The number of 4 KB pages to allocate.
+ @param Alignment The requested alignment of the allocation. Must be a power of two.
+ If Alignment is zero, then byte alignment is used.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateAlignedRuntimePages (
+ IN UINTN Pages,
+ IN UINTN Alignment
+ )
+{
+ return InternalAllocateAlignedPages (EfiRuntimeServicesData, Pages, Alignment);
+}
+
+/**
+ Allocates one or more 4KB pages of type EfiReservedMemoryType at a specified alignment.
+
+ Allocates the number of 4KB pages specified by Pages of type EfiReservedMemoryType with an
+ alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is
+ returned. If there is not enough memory at the specified alignment remaining to satisfy the
+ request, then NULL is returned.
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().
+
+ @param Pages The number of 4 KB pages to allocate.
+ @param Alignment The requested alignment of the allocation. Must be a power of two.
+ If Alignment is zero, then byte alignment is used.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateAlignedReservedPages (
+ IN UINTN Pages,
+ IN UINTN Alignment
+ )
+{
+ return InternalAllocateAlignedPages (EfiReservedMemoryType, Pages, Alignment);
+}
+
+/**
+ Frees one or more 4KB pages that were previously allocated with one of the aligned page
+ allocation functions in the Memory Allocation Library.
+
+ Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer. Buffer
+ must have been allocated on a previous call to the aligned page allocation services of the Memory
+ Allocation Library.
+ If Buffer was not allocated with an aligned page allocation function in the Memory Allocation
+ Library, then ASSERT().
+ If Pages is zero, then ASSERT().
+
+ @param Buffer Pointer to the buffer of pages to free.
+ @param Pages The number of 4 KB pages to free.
+
+**/
+VOID
+EFIAPI
+FreeAlignedPages (
+ IN VOID *Buffer,
+ IN UINTN Pages
+ )
+{
+ EFI_STATUS Status;
+
+ ASSERT (Pages != 0);
+ Status = (gBS->FreePages) ((EFI_PHYSICAL_ADDRESS) (UINTN) Buffer, Pages);
+ ASSERT_EFI_ERROR (Status);
+}
+
+/**
+ Allocates a buffer of a certain pool type.
+
+ Allocates the number bytes specified by AllocationSize of a certain pool type and returns a
+ pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is
+ returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.
+
+ @param MemoryType The type of memory to allocate.
+ @param AllocationSize The number of bytes to allocate.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+InternalAllocatePool (
+ IN EFI_MEMORY_TYPE MemoryType,
+ IN UINTN AllocationSize
+ )
+{
+ EFI_STATUS Status;
+ VOID *Memory;
+
+ Status = (gBS->AllocatePool) (MemoryType, AllocationSize, &Memory);
+ if (EFI_ERROR (Status)) {
+ Memory = NULL;
+ }
+ return Memory;
+}
+
+/**
+ Allocates a buffer of type EfiBootServicesData.
+
+ Allocates the number bytes specified by AllocationSize of type EfiBootServicesData and returns a
+ pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is
+ returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.
+
+ @param AllocationSize The number of bytes to allocate.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+GlueAllocatePool (
+ IN UINTN AllocationSize
+ )
+{
+ return InternalAllocatePool (EfiBootServicesData, AllocationSize);
+}
+
+/**
+ Allocates a buffer of type EfiRuntimeServicesData.
+
+ Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData and returns
+ a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is
+ returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.
+
+ @param AllocationSize The number of bytes to allocate.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateRuntimePool (
+ IN UINTN AllocationSize
+ )
+{
+ return InternalAllocatePool (EfiRuntimeServicesData, AllocationSize);
+}
+
+/**
+ Allocates a buffer of type EfieservedMemoryType.
+
+ Allocates the number bytes specified by AllocationSize of type EfieservedMemoryType and returns
+ a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is
+ returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.
+
+ @param AllocationSize The number of bytes to allocate.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateReservedPool (
+ IN UINTN AllocationSize
+ )
+{
+ return InternalAllocatePool (EfiReservedMemoryType, AllocationSize);
+}
+
+/**
+ Allocates and zeros a buffer of a certian pool type.
+
+ Allocates the number bytes specified by AllocationSize of a certian pool type, clears the buffer
+ with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a valid
+ buffer of 0 size is returned. If there is not enough memory remaining to satisfy the request,
+ then NULL is returned.
+
+ @param PoolType The type of memory to allocate.
+ @param AllocationSize The number of bytes to allocate and zero.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+InternalAllocateZeroPool (
+ IN EFI_MEMORY_TYPE PoolType,
+ IN UINTN AllocationSize
+ )
+{
+ VOID *Memory;
+
+ Memory = InternalAllocatePool (PoolType, AllocationSize);
+ if (Memory != NULL) {
+ Memory = ZeroMem (Memory, AllocationSize);
+ }
+ return Memory;
+}
+
+/**
+ Allocates and zeros a buffer of type EfiBootServicesData.
+
+ Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, clears the
+ buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a
+ valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the
+ request, then NULL is returned.
+
+ @param AllocationSize The number of bytes to allocate and zero.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+GlueAllocateZeroPool (
+ IN UINTN AllocationSize
+ )
+{
+ return InternalAllocateZeroPool (EfiBootServicesData, AllocationSize);
+}
+
+/**
+ Allocates and zeros a buffer of type EfiRuntimeServicesData.
+
+ Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, clears the
+ buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a
+ valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the
+ request, then NULL is returned.
+
+ @param AllocationSize The number of bytes to allocate and zero.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateRuntimeZeroPool (
+ IN UINTN AllocationSize
+ )
+{
+ return InternalAllocateZeroPool (EfiRuntimeServicesData, AllocationSize);
+}
+
+/**
+ Allocates and zeros a buffer of type EfiReservedMemoryType.
+
+ Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, clears the
+ buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a
+ valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the
+ request, then NULL is returned.
+
+ @param AllocationSize The number of bytes to allocate and zero.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateReservedZeroPool (
+ IN UINTN AllocationSize
+ )
+{
+ return InternalAllocateZeroPool (EfiReservedMemoryType, AllocationSize);
+}
+
+/**
+ Copies a buffer to an allocated buffer of a certian pool type.
+
+ Allocates the number bytes specified by AllocationSize of a certian pool type, copies
+ AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
+ allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
+ is not enough memory remaining to satisfy the request, then NULL is returned.
+ If Buffer is NULL, then ASSERT().
+ If AllocationSize is greater than (MAX_ADDRESS ?Buffer + 1), then ASSERT().
+
+ @param PoolType The type of pool to allocate.
+ @param AllocationSize The number of bytes to allocate and zero.
+ @param Buffer The buffer to copy to the allocated buffer.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+InternalAllocateCopyPool (
+ IN EFI_MEMORY_TYPE PoolType,
+ IN UINTN AllocationSize,
+ IN CONST VOID *Buffer
+ )
+{
+ VOID *Memory;
+
+ ASSERT (Buffer != NULL);
+ ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN) Buffer + 1));
+
+ Memory = InternalAllocatePool (PoolType, AllocationSize);
+ if (Memory != NULL) {
+ Memory = CopyMem (Memory, Buffer, AllocationSize);
+ }
+ return Memory;
+}
+
+/**
+ Copies a buffer to an allocated buffer of type EfiBootServicesData.
+
+ Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, copies
+ AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
+ allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
+ is not enough memory remaining to satisfy the request, then NULL is returned.
+ If Buffer is NULL, then ASSERT().
+ If AllocationSize is greater than (MAX_ADDRESS ?Buffer + 1), then ASSERT().
+
+ @param AllocationSize The number of bytes to allocate and zero.
+ @param Buffer The buffer to copy to the allocated buffer.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+GlueAllocateCopyPool (
+ IN UINTN AllocationSize,
+ IN CONST VOID *Buffer
+ )
+{
+ return InternalAllocateCopyPool (EfiBootServicesData, AllocationSize, Buffer);
+}
+
+/**
+ Copies a buffer to an allocated buffer of type EfiRuntimeServicesData.
+
+ Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, copies
+ AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
+ allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
+ is not enough memory remaining to satisfy the request, then NULL is returned.
+ If Buffer is NULL, then ASSERT().
+ If AllocationSize is greater than (MAX_ADDRESS ?Buffer + 1), then ASSERT().
+
+ @param AllocationSize The number of bytes to allocate and zero.
+ @param Buffer The buffer to copy to the allocated buffer.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateRuntimeCopyPool (
+ IN UINTN AllocationSize,
+ IN CONST VOID *Buffer
+ )
+{
+ return InternalAllocateCopyPool (EfiRuntimeServicesData, AllocationSize, Buffer);
+}
+
+/**
+ Copies a buffer to an allocated buffer of type EfiReservedMemoryType.
+
+ Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, copies
+ AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
+ allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
+ is not enough memory remaining to satisfy the request, then NULL is returned.
+ If Buffer is NULL, then ASSERT().
+ If AllocationSize is greater than (MAX_ADDRESS ?Buffer + 1), then ASSERT().
+
+ @param AllocationSize The number of bytes to allocate and zero.
+ @param Buffer The buffer to copy to the allocated buffer.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateReservedCopyPool (
+ IN UINTN AllocationSize,
+ IN CONST VOID *Buffer
+ )
+{
+ return InternalAllocateCopyPool (EfiReservedMemoryType, AllocationSize, Buffer);
+}
+
+/**
+ Frees a buffer that was previously allocated with one of the pool allocation functions in the
+ Memory Allocation Library.
+
+ Frees the buffer specified by Buffer. Buffer must have been allocated on a previous call to the
+ pool allocation services of the Memory Allocation Library.
+ If Buffer was not allocated with a pool allocation function in the Memory Allocation Library,
+ then ASSERT().
+
+ @param Buffer Pointer to the buffer to free.
+
+**/
+VOID
+EFIAPI
+GlueFreePool (
+ IN VOID *Buffer
+ )
+{
+ EFI_STATUS Status;
+
+ Status = (gBS->FreePool) (Buffer);
+ ASSERT_EFI_ERROR (Status);
+}
+
+/**
+ Allocates a buffer of a certain pool type at a specified alignment.
+
+ Allocates the number bytes specified by AllocationSize of a certain pool type with an alignment
+ specified by Alignment. The allocated buffer is returned. If AllocationSize is 0, then a valid
+ buffer of 0 size is returned. If there is not enough memory at the specified alignment remaining
+ to satisfy the request, then NULL is returned.
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().
+
+ @param PoolType The type of pool to allocate.
+ @param AllocationSize The number of bytes to allocate.
+ @param Alignment The requested alignment of the allocation. Must be a power of two. If Alignment is zero, then byte alignment is used.
+ If Alignment is zero, then byte alignment is used.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+InternalAllocateAlignedPool (
+ IN EFI_MEMORY_TYPE PoolType,
+ IN UINTN AllocationSize,
+ IN UINTN Alignment
+ )
+{
+ VOID *RawAddress;
+ UINTN AlignedAddress;
+ UINTN AlignmentMask;
+ UINTN OverAllocationSize;
+ UINTN RealAllocationSize;
+ VOID **FreePointer;
+
+ //
+ // Alignment must be a power of two or zero.
+ //
+ ASSERT ((Alignment & (Alignment - 1)) == 0);
+
+ if (Alignment == 0) {
+ AlignmentMask = Alignment;
+ } else {
+ AlignmentMask = Alignment - 1;
+ }
+ //
+ // Calculate the extra memory size, over-allocate memory pool and get the aligned memory address.
+ //
+ OverAllocationSize = sizeof (RawAddress) + AlignmentMask;
+ RealAllocationSize = AllocationSize + OverAllocationSize;
+ //
+ // Make sure that AllocationSize plus OverAllocationSize does not overflow.
+ //
+ ASSERT (RealAllocationSize > AllocationSize);
+
+ RawAddress = InternalAllocatePool (PoolType, RealAllocationSize);
+ if (RawAddress == NULL) {
+ return NULL;
+ }
+ AlignedAddress = ((UINTN) RawAddress + OverAllocationSize) & ~AlignmentMask;
+ //
+ // Save the original memory address just before the aligned address.
+ //
+ FreePointer = (VOID **)(AlignedAddress - sizeof (RawAddress));
+ *FreePointer = RawAddress;
+
+ return (VOID *) AlignedAddress;
+}
+
+/**
+ Allocates a buffer of type EfiBootServicesData at a specified alignment.
+
+ Allocates the number bytes specified by AllocationSize of type EfiBootServicesData with an
+ alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0,
+ then a valid buffer of 0 size is returned. If there is not enough memory at the specified
+ alignment remaining to satisfy the request, then NULL is returned.
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().
+
+ @param AllocationSize The number of bytes to allocate.
+ @param Alignment The requested alignment of the allocation. Must be a power of two.
+ If Alignment is zero, then byte alignment is used.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateAlignedPool (
+ IN UINTN AllocationSize,
+ IN UINTN Alignment
+ )
+{
+ return InternalAllocateAlignedPool (EfiBootServicesData, AllocationSize, Alignment);
+}
+
+/**
+ Allocates a buffer of type EfiRuntimeServicesData at a specified alignment.
+
+ Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData with an
+ alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0,
+ then a valid buffer of 0 size is returned. If there is not enough memory at the specified
+ alignment remaining to satisfy the request, then NULL is returned.
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().
+
+ @param AllocationSize The number of bytes to allocate.
+ @param Alignment The requested alignment of the allocation. Must be a power of two.
+ If Alignment is zero, then byte alignment is used.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateAlignedRuntimePool (
+ IN UINTN AllocationSize,
+ IN UINTN Alignment
+ )
+{
+ return InternalAllocateAlignedPool (EfiRuntimeServicesData, AllocationSize, Alignment);
+}
+
+/**
+ Allocates a buffer of type EfieservedMemoryType at a specified alignment.
+
+ Allocates the number bytes specified by AllocationSize of type EfieservedMemoryType with an
+ alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0,
+ then a valid buffer of 0 size is returned. If there is not enough memory at the specified
+ alignment remaining to satisfy the request, then NULL is returned.
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().
+
+ @param AllocationSize The number of bytes to allocate.
+ @param Alignment The requested alignment of the allocation. Must be a power of two.
+ If Alignment is zero, then byte alignment is used.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateAlignedReservedPool (
+ IN UINTN AllocationSize,
+ IN UINTN Alignment
+ )
+{
+ return InternalAllocateAlignedPool (EfiReservedMemoryType, AllocationSize, Alignment);
+}
+
+/**
+ Allocates and zeros a buffer of a certain pool type at a specified alignment.
+
+ Allocates the number bytes specified by AllocationSize of a certain pool type with an alignment
+ specified by Alignment, clears the buffer with zeros, and returns a pointer to the allocated
+ buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there is not
+ enough memory at the specified alignment remaining to satisfy the request, then NULL is returned.
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().
+
+ @param PoolType The type of pool to allocate.
+ @param AllocationSize The number of bytes to allocate.
+ @param Alignment The requested alignment of the allocation. Must be a power of two.
+ If Alignment is zero, then byte alignment is used.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+InternalAllocateAlignedZeroPool (
+ IN EFI_MEMORY_TYPE PoolType,
+ IN UINTN AllocationSize,
+ IN UINTN Alignment
+ )
+{
+ VOID *Memory;
+ Memory = InternalAllocateAlignedPool (PoolType, AllocationSize, Alignment);
+ if (Memory != NULL) {
+ Memory = ZeroMem (Memory, AllocationSize);
+ }
+ return Memory;
+}
+
+/**
+ Allocates and zeros a buffer of type EfiBootServicesData at a specified alignment.
+
+ Allocates the number bytes specified by AllocationSize of type EfiBootServicesData with an
+ alignment specified by Alignment, clears the buffer with zeros, and returns a pointer to the
+ allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
+ is not enough memory at the specified alignment remaining to satisfy the request, then NULL is
+ returned.
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().
+
+ @param AllocationSize The number of bytes to allocate.
+ @param Alignment The requested alignment of the allocation. Must be a power of two.
+ If Alignment is zero, then byte alignment is used.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateAlignedZeroPool (
+ IN UINTN AllocationSize,
+ IN UINTN Alignment
+ )
+{
+ return InternalAllocateAlignedZeroPool (EfiBootServicesData, AllocationSize, Alignment);
+}
+
+/**
+ Allocates and zeros a buffer of type EfiRuntimeServicesData at a specified alignment.
+
+ Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData with an
+ alignment specified by Alignment, clears the buffer with zeros, and returns a pointer to the
+ allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
+ is not enough memory at the specified alignment remaining to satisfy the request, then NULL is
+ returned.
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().
+
+ @param AllocationSize The number of bytes to allocate.
+ @param Alignment The requested alignment of the allocation. Must be a power of two.
+ If Alignment is zero, then byte alignment is used.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateAlignedRuntimeZeroPool (
+ IN UINTN AllocationSize,
+ IN UINTN Alignment
+ )
+{
+ return InternalAllocateAlignedZeroPool (EfiRuntimeServicesData, AllocationSize, Alignment);
+}
+
+/**
+ Allocates and zeros a buffer of type EfieservedMemoryType at a specified alignment.
+
+ Allocates the number bytes specified by AllocationSize of type EfieservedMemoryType with an
+ alignment specified by Alignment, clears the buffer with zeros, and returns a pointer to the
+ allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
+ is not enough memory at the specified alignment remaining to satisfy the request, then NULL is
+ returned.
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().
+
+ @param AllocationSize The number of bytes to allocate.
+ @param Alignment The requested alignment of the allocation. Must be a power of two.
+ If Alignment is zero, then byte alignment is used.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateAlignedReservedZeroPool (
+ IN UINTN AllocationSize,
+ IN UINTN Alignment
+ )
+{
+ return InternalAllocateAlignedZeroPool (EfiReservedMemoryType, AllocationSize, Alignment);
+}
+
+/**
+ Copies a buffer to an allocated buffer of a certain pool type at a specified alignment.
+
+ Allocates the number bytes specified by AllocationSize of a certain pool type with an alignment
+ specified by Alignment. The allocated buffer is returned. If AllocationSize is 0, then a valid
+ buffer of 0 size is returned. If there is not enough memory at the specified alignment remaining
+ to satisfy the request, then NULL is returned.
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().
+
+ @param PoolType The type of pool to allocate.
+ @param AllocationSize The number of bytes to allocate.
+ @param Buffer The buffer to copy to the allocated buffer.
+ @param Alignment The requested alignment of the allocation. Must be a power of two.
+ If Alignment is zero, then byte alignment is used.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+InternalAllocateAlignedCopyPool (
+ IN EFI_MEMORY_TYPE PoolType,
+ IN UINTN AllocationSize,
+ IN CONST VOID *Buffer,
+ IN UINTN Alignment
+ )
+{
+ VOID *Memory;
+
+ ASSERT (Buffer != NULL);
+ ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN) Buffer + 1));
+
+ Memory = InternalAllocateAlignedPool (PoolType, AllocationSize, Alignment);
+ if (Memory != NULL) {
+ Memory = CopyMem (Memory, Buffer, AllocationSize);
+ }
+ return Memory;
+}
+
+/**
+ Copies a buffer to an allocated buffer of type EfiBootServicesData at a specified alignment.
+
+ Allocates the number bytes specified by AllocationSize of type EfiBootServicesData type with an
+ alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0,
+ then a valid buffer of 0 size is returned. If there is not enough memory at the specified
+ alignment remaining to satisfy the request, then NULL is returned.
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().
+
+ @param AllocationSize The number of bytes to allocate.
+ @param Buffer The buffer to copy to the allocated buffer.
+ @param Alignment The requested alignment of the allocation. Must be a power of two.
+ If Alignment is zero, then byte alignment is used.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateAlignedCopyPool (
+ IN UINTN AllocationSize,
+ IN CONST VOID *Buffer,
+ IN UINTN Alignment
+ )
+{
+ return InternalAllocateAlignedCopyPool (EfiBootServicesData, AllocationSize, Buffer, Alignment);
+}
+
+/**
+ Copies a buffer to an allocated buffer of type EfiRuntimeServicesData at a specified alignment.
+
+ Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData type with an
+ alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0,
+ then a valid buffer of 0 size is returned. If there is not enough memory at the specified
+ alignment remaining to satisfy the request, then NULL is returned.
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().
+
+ @param AllocationSize The number of bytes to allocate.
+ @param Buffer The buffer to copy to the allocated buffer.
+ @param Alignment The requested alignment of the allocation. Must be a power of two.
+ If Alignment is zero, then byte alignment is used.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateAlignedRuntimeCopyPool (
+ IN UINTN AllocationSize,
+ IN CONST VOID *Buffer,
+ IN UINTN Alignment
+ )
+{
+ return InternalAllocateAlignedCopyPool (EfiRuntimeServicesData, AllocationSize, Buffer, Alignment);
+}
+
+/**
+ Copies a buffer to an allocated buffer of type EfiReservedMemoryType at a specified alignment.
+
+ Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType type with an
+ alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0,
+ then a valid buffer of 0 size is returned. If there is not enough memory at the specified
+ alignment remaining to satisfy the request, then NULL is returned.
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().
+
+ @param AllocationSize The number of bytes to allocate.
+ @param Buffer The buffer to copy to the allocated buffer.
+ @param Alignment The requested alignment of the allocation. Must be a power of two.
+ If Alignment is zero, then byte alignment is used.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateAlignedReservedCopyPool (
+ IN UINTN AllocationSize,
+ IN CONST VOID *Buffer,
+ IN UINTN Alignment
+ )
+{
+ return InternalAllocateAlignedCopyPool (EfiReservedMemoryType, AllocationSize, Buffer, Alignment);
+}
+
+/**
+ Frees a buffer that was previously allocated with one of the aligned pool allocation functions
+ in the Memory Allocation Library.
+
+ Frees the buffer specified by Buffer. Buffer must have been allocated on a previous call to the
+ aligned pool allocation services of the Memory Allocation Library.
+ If Buffer was not allocated with an aligned pool allocation function in the Memory Allocation
+ Library, then ASSERT().
+
+ @param Buffer Pointer to the buffer to free.
+
+**/
+VOID
+EFIAPI
+FreeAlignedPool (
+ IN VOID *Buffer
+ )
+{
+ VOID *RawAddress;
+ VOID **FreePointer;
+ EFI_STATUS Status;
+
+ //
+ // Get the pre-saved original address in the over-allocate pool.
+ //
+ FreePointer = (VOID **)((UINTN) Buffer - sizeof (RawAddress));
+ RawAddress = *FreePointer;
+
+ Status = (gBS->FreePool) (RawAddress);
+ ASSERT_EFI_ERROR (Status);
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
new file mode 100644
index 0000000..a2eed0a
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeReportStatusCodeLib/DxeReportStatusCodeLib.inf
@@ -0,0 +1,92 @@
+#/*++
+#
+# Copyright (c) 2004 - 2006, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# DxeReportStatusCodeLib.inf
+#
+# Abstract:
+#
+# Component description file for DxeReportStatusCodeLib.
+#
+#--*/
+
+[defines]
+BASE_NAME = EdkIIGlueDxeReportStatusCodeLib
+COMPONENT_TYPE = LIBRARY
+
+[sources.common]
+ ReportStatusCodeLib.c
+
+[sources.ia32]
+
+[sources.x64]
+
+[sources.ipf]
+
+[sources.ebc]
+
+
+[includes.common]
+ .
+ ..\..\Include
+ ..\..\include\Library
+ $(EDK_SOURCE)\Foundation
+ $(EDK_SOURCE)\Foundation\Framework
+ $(EDK_SOURCE)\Foundation\Efi
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+ $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include
+ $(EDK_SOURCE)\Foundation\Framework\Guid\DataHubRecords
+ $(EDK_SOURCE)\Foundation\Framework\Guid\StatusCodeDataTypeId
+ $(EDK_SOURCE)\Foundation\Core\Dxe\ArchProtocol\StatusCode
+
+[libraries.common]
+ EdkIIGlueBaseLib
+ EdkIIGlueBaseIoLibIntrinsic
+ EdkIIGlueBaseMemoryLib
+ EdkIIGlueUefiBootServicesTableLib
+#
+# when EFI_SPECIFICATION_VERSION < 0x00020000, gRT is used
+#
+ EdkIIGlueUefiRuntimeServicesTableLib
+# R8.x lib
+ EfiProtocolLib
+# Possibly, gEfiCallerIdGuid might be used.
+ EdkGuidLib
+ ArchProtocolLib
+
+
+[libraries.ia32]
+
+
+[libraries.x64]
+
+
+[nmake.common]
+ C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION
+ LIB_STD_FLAGS = /NOLOGO /IGNORE:4006
+
+[nmake.ia32]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32
+
+[nmake.x64]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64
+
+[nmake.ipf]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF
+
+[nmake.ebc]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeReportStatusCodeLib/EdkIIGlueDxeReportStatusCodeLib.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeReportStatusCodeLib/EdkIIGlueDxeReportStatusCodeLib.cif
new file mode 100644
index 0000000..af45c64
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeReportStatusCodeLib/EdkIIGlueDxeReportStatusCodeLib.cif
@@ -0,0 +1,11 @@
+<component>
+ name = "EdkIIGlueDxeReportStatusCodeLib"
+ category = ModulePart
+ LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\DxeReportStatusCodeLib"
+ RefName = "EdkIIGlueDxeReportStatusCodeLib"
+[files]
+"EdkIIGlueDxeReportStatusCodeLib.sdl"
+"EdkIIGlueDxeReportStatusCodeLib.mak"
+"DxeReportStatusCodeLib.inf"
+"ReportStatusCodeLib.c"
+<endComponent>
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeReportStatusCodeLib/EdkIIGlueDxeReportStatusCodeLib.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeReportStatusCodeLib/EdkIIGlueDxeReportStatusCodeLib.mak
new file mode 100644
index 0000000..e2056f8
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeReportStatusCodeLib/EdkIIGlueDxeReportStatusCodeLib.mak
@@ -0,0 +1,91 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueDxeReportStatusCodeLib/EdkIIGlueDxeReportStatusCodeLib.mak 1 1/20/12 3:55a Jeffch $
+#
+# $Revision: 1 $
+#
+# $Date: 1/20/12 3:55a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueDxeReportStatusCodeLib/EdkIIGlueDxeReportStatusCodeLib.mak $
+#
+# 1 1/20/12 3:55a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 9/27/11 6:17a Wesleychen
+# Intel EDK initially releases.
+#
+# 1 9/18/09 1:55a Iminglin
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: EdkIIGlueDxeReportStatusCodeLib.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+
+
+$(EdkIIGlueDxeReportStatusCodeLib_LIB) : EdkIIGlueDxeReportStatusCodeLib
+
+EdkIIGlueDxeReportStatusCodeLib : $(BUILD_DIR)\EdkIIGlueDxeReportStatusCodeLib.mak EdkIIGlueDxeReportStatusCodeLibBin
+
+$(BUILD_DIR)\EdkIIGlueDxeReportStatusCodeLib.mak : $(EdkIIGlueDxeReportStatusCodeLib_DIR)\$(@B).cif $(EdkIIGlueDxeReportStatusCodeLib_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(EdkIIGlueDxeReportStatusCodeLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+EdkIIGlueDxeReportStatusCodeLib_LIB_LINKS=$(EdkIIGlueBaseLib_LIB)\
+$(EdkIIGlueBaseMemoryLib_LIB)\
+$(EdkIIGlueUefiBootServicesTableLib_LIB)\
+$(EdkIIGlueUefiRuntimeServicesTableLib_LIB)\
+$(EFIPROTOCOLLIB)\
+$(EDKGUIDLIB)\
+$(ARCHPROTOCOLLIB)\
+!IF "$(PROCESSOR)"=="IA32" || "$(PROCESSOR)"=="x64"
+$(EdkIIGlueBaseIoLibIntrinsic_LIB)
+!ENDIF
+
+EdkIIGlueDxeReportStatusCodeLibBin : $(EdkIIGlueDxeReportStatusCodeLib_LIB_LINKS)
+!IF "$(x64_BUILD)"=="1"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGlueDxeReportStatusCodeLib.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueDxeReportStatusCodeLib_LIB)"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\IA32\
+ /f $(BUILD_DIR)\EdkIIGlueDxeReportStatusCodeLib.mak all\
+ TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueDxeReportStatusCodeLib_LIB)"
+!ELSE
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGlueDxeReportStatusCodeLib.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueDxeReportStatusCodeLib_LIB)"
+!ENDIF
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeReportStatusCodeLib/EdkIIGlueDxeReportStatusCodeLib.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeReportStatusCodeLib/EdkIIGlueDxeReportStatusCodeLib.sdl
new file mode 100644
index 0000000..cd4a486
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeReportStatusCodeLib/EdkIIGlueDxeReportStatusCodeLib.sdl
@@ -0,0 +1,26 @@
+TOKEN
+ Name = "EdkIIGlueDxeReportStatusCodeLib_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable EdkIIGlueDxeReportStatusCodeLib support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "EdkIIGlueDxeReportStatusCodeLib_LIB"
+ Value = "$$(LIB_BUILD_DIR)\EdkIIGlueDxeReportStatusCodeLib.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "EdkIIGlueDxeReportStatusCodeLib_DIR"
+End
+
+MODULE
+ Help = "Includes EdkIIGlueDxeReportStatusCodeLib.mak to Project"
+ File = "EdkIIGlueDxeReportStatusCodeLib.mak"
+End
+
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c
new file mode 100644
index 0000000..a69d14d
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeReportStatusCodeLib/ReportStatusCodeLib.c
@@ -0,0 +1,605 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ ReportStatusCodeLib.c
+
+Abstract:
+
+ Report Status Code Library for DXE Phase.
+
+--*/
+
+#include "EdkIIGlueDxe.h"
+#include "Pcd\EdkIIGluePcdReportStatusCodeLib.h"
+
+
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+//
+// Global pointer to the Status Code Protocol
+//
+static EFI_STATUS_CODE_PROTOCOL *gStatusCode = NULL;
+
+#endif
+
+/**
+ Internal worker function that reports a status code through the Status Code Protocol
+
+ This function checks to see if a Status Code Protocol is present in the handle
+ database. If a Status Code Protocol is not present, then EFI_UNSUPPORTED is
+ returned. If a Status Code Protocol is present, then it is cached in gStatusCode,
+ and the ReportStatusCode() service of the Status Code Protocol is called passing in
+ Type, Value, Instance, CallerId, and Data. The result of this call is returned.
+
+ @param Type Status code type.
+ @param Value Status code value.
+ @param Instance Status code instance number.
+ @param CallerId Pointer to a GUID that identifies the caller of this
+ function. This is an optional parameter that may be
+ NULL.
+ @param Data Pointer to the extended data buffer. This is an
+ optional parameter that may be NULL.
+
+ @retval EFI_SUCCESS The status code was reported.
+ @retval EFI_OUT_OF_RESOURCES There were not enough resources to report the status code.
+ @retval EFI_UNSUPPORTED Status Code Protocol is not available.
+
+**/
+EFI_STATUS
+InternalReportStatusCode (
+ IN EFI_STATUS_CODE_TYPE Type,
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN UINT32 Instance,
+ IN CONST EFI_GUID *CallerId OPTIONAL,
+ IN EFI_STATUS_CODE_DATA *Data OPTIONAL
+ )
+{
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+
+ EFI_STATUS Status;
+
+ //
+ // If gStatusCode is NULL, then see if a Status Code Protocol instance is present
+ // in the handle database.
+ //
+ if (gStatusCode == NULL) {
+ Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID **)&gStatusCode);
+ if (EFI_ERROR (Status) || gStatusCode == NULL) {
+ return EFI_UNSUPPORTED;
+ }
+ }
+
+ //
+ // A Status Code Protocol is present in the handle database, so pass in all the
+ // parameters to the ReportStatusCode() service of the Status Code Protocol
+ //
+ return (gStatusCode->ReportStatusCode) (Type, Value, Instance, (EFI_GUID *)CallerId, Data);
+
+#else
+
+ return (gRT->ReportStatusCode) (Type, Value, Instance, (EFI_GUID *)CallerId, Data);
+
+#endif
+
+}
+
+
+/**
+ Computes and returns the size, in bytes, of a device path.
+
+ @param DevicePath A pointer to a device path.
+
+ @return The size, in bytes, of DevicePath.
+
+**/
+UINTN
+InternalReportStatusCodeDevicePathSize (
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ )
+{
+ CONST EFI_DEVICE_PATH_PROTOCOL *Start;
+
+ //
+ // Search for the end of the device path structure
+ //
+ Start = DevicePath;
+ while (!EfiIsDevicePathEnd (DevicePath)) {
+ DevicePath = EfiNextDevicePathNode (DevicePath);
+ }
+
+ //
+ // Subtract the start node from the end node and add in the size of the end node
+ //
+ return ((UINTN) DevicePath - (UINTN) Start) + DevicePathNodeLength (DevicePath);
+}
+
+
+/**
+ Converts a status code to an 8-bit POST code value.
+
+ Converts the status code specified by CodeType and Value to an 8-bit POST code
+ and returns the 8-bit POST code in PostCode. If CodeType is an
+ EFI_PROGRESS_CODE or CodeType is an EFI_ERROR_CODE, then bits 0..4 of PostCode
+ are set to bits 16..20 of Value, and bits 5..7 of PostCode are set to bits
+ 24..26 of Value., and TRUE is returned. Otherwise, FALSE is returned.
+
+ If PostCode is NULL, then ASSERT().
+
+ @param CodeType The type of status code being converted.
+ @param Value The status code value being converted.
+ @param PostCode A pointer to the 8-bit POST code value to return.
+
+ @retval TRUE The status code specified by CodeType and Value was converted
+ to an 8-bit POST code and returned in PostCode.
+ @retval FALSE The status code specified by CodeType and Value could not be
+ converted to an 8-bit POST code value.
+
+**/
+BOOLEAN
+EFIAPI
+GlueCodeTypeToPostCode (
+ IN EFI_STATUS_CODE_TYPE CodeType,
+ IN EFI_STATUS_CODE_VALUE Value,
+ OUT UINT8 *PostCode
+ )
+{
+ //
+ // If PostCode is NULL, then ASSERT()
+ //
+ ASSERT (PostCode != NULL);
+
+ //
+ // Convert Value to an 8 bit post code
+ //
+ if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ||
+ ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ) {
+ *PostCode = (UINT8) (((Value & EFI_STATUS_CODE_CLASS_MASK) >> 24) << 5);
+ *PostCode |= (UINT8) (((Value & EFI_STATUS_CODE_SUBCLASS_MASK) >> 16) & 0x1f);
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
+/**
+ Extracts ASSERT() information from a status code structure.
+
+ Converts the status code specified by CodeType, Value, and Data to the ASSERT()
+ arguments specified by Filename, Description, and LineNumber. If CodeType is
+ an EFI_ERROR_CODE, and CodeType has a severity of EFI_ERROR_UNRECOVERED, and
+ Value has an operation mask of EFI_SW_EC_ILLEGAL_SOFTWARE_STATE, extract
+ Filename, Description, and LineNumber from the optional data area of the
+ status code buffer specified by Data. The optional data area of Data contains
+ a Null-terminated ASCII string for the FileName, followed by a Null-terminated
+ ASCII string for the Description, followed by a 32-bit LineNumber. If the
+ ASSERT() information could be extracted from Data, then return TRUE.
+ Otherwise, FALSE is returned.
+
+ If Data is NULL, then ASSERT().
+ If Filename is NULL, then ASSERT().
+ If Description is NULL, then ASSERT().
+ If LineNumber is NULL, then ASSERT().
+
+ @param CodeType The type of status code being converted.
+ @param Value The status code value being converted.
+ @param Data Pointer to status code data buffer.
+ @param Filename Pointer to the source file name that generated the ASSERT().
+ @param Description Pointer to the description of the ASSERT().
+ @param LineNumber Pointer to source line number that generated the ASSERT().
+
+ @retval TRUE The status code specified by CodeType, Value, and Data was
+ converted ASSERT() arguments specified by Filename, Description,
+ and LineNumber.
+ @retval FALSE The status code specified by CodeType, Value, and Data could
+ not be converted to ASSERT() arguments.
+
+**/
+BOOLEAN
+EFIAPI
+GlueReportStatusCodeExtractAssertInfo (
+ IN EFI_STATUS_CODE_TYPE CodeType,
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN CONST EFI_STATUS_CODE_DATA *Data,
+ OUT CHAR8 **Filename,
+ OUT CHAR8 **Description,
+ OUT UINT32 *LineNumber
+ )
+{
+ EFI_DEBUG_ASSERT_DATA *AssertData;
+
+ ASSERT (Data != NULL);
+ ASSERT (Filename != NULL);
+ ASSERT (Description != NULL);
+ ASSERT (LineNumber != NULL);
+
+ if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) &&
+ ((CodeType & EFI_STATUS_CODE_SEVERITY_MASK) == EFI_ERROR_UNRECOVERED) &&
+ ((Value & EFI_STATUS_CODE_OPERATION_MASK) == EFI_SW_EC_ILLEGAL_SOFTWARE_STATE)) {
+ AssertData = (EFI_DEBUG_ASSERT_DATA *)(Data + 1);
+ *Filename = (CHAR8 *)(AssertData + 1);
+ *Description = *Filename + AsciiStrLen (*Filename) + 1;
+ *LineNumber = AssertData->LineNumber;
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
+/**
+ Extracts DEBUG() information from a status code structure.
+
+ Converts the status code specified by Data to the DEBUG() arguments specified
+ by ErrorLevel, Marker, and Format. If type GUID in Data is
+ EFI_STATUS_CODE_DATA_TYPE_DEBUG_GUID, then extract ErrorLevel, Marker, and
+ Format from the optional data area of the status code buffer specified by Data.
+ The optional data area of Data contains a 32-bit ErrorLevel followed by Marker
+ which is 12 UINTN parameters, followed by a Null-terminated ASCII string for
+ the Format. If the DEBUG() information could be extracted from Data, then
+ return TRUE. Otherwise, FALSE is returned.
+
+ If Data is NULL, then ASSERT().
+ If ErrorLevel is NULL, then ASSERT().
+ If Marker is NULL, then ASSERT().
+ If Format is NULL, then ASSERT().
+
+ @param Data Pointer to status code data buffer.
+ @param ErrorLevel Pointer to error level mask for a debug message.
+ @param Marker Pointer to the variable argument list associated with Format.
+ @param Format Pointer to a Null-terminated ASCII format string of a
+ debug message.
+
+ @retval TRUE The status code specified by Data was converted DEBUG() arguments
+ specified by ErrorLevel, Marker, and Format.
+ @retval FALSE The status code specified by Data could not be converted to
+ DEBUG() arguments.
+
+**/
+BOOLEAN
+EFIAPI
+GlueReportStatusCodeExtractDebugInfo (
+ IN CONST EFI_STATUS_CODE_DATA *Data,
+ OUT UINT32 *ErrorLevel,
+ OUT VA_LIST *Marker,
+ OUT CHAR8 **Format
+ )
+{
+ EFI_DEBUG_INFO *DebugInfo;
+
+ ASSERT (Data != NULL);
+ ASSERT (ErrorLevel != NULL);
+ ASSERT (Marker != NULL);
+ ASSERT (Format != NULL);
+
+ //
+ // If the GUID type is not EFI_STATUS_CODE_DATA_TYPE_DEBUG_GUID then return FALSE
+ //
+ if (!CompareGuid (&Data->Type, &gEfiStatusCodeDataTypeDebugGuid)) {
+ return FALSE;
+ }
+
+ //
+ // Retrieve the debug information from the status code record
+ //
+ DebugInfo = (EFI_DEBUG_INFO *)(Data + 1);
+
+ *ErrorLevel = DebugInfo->ErrorLevel;
+
+ //
+ // The first 12 * UINTN bytes of the string are really an
+ // argument stack to support varargs on the Format string.
+ //
+ *Marker = (VA_LIST) (DebugInfo + 1);
+ *Format = (CHAR8 *)(((UINT64 *)*Marker) + 12);
+
+ return TRUE;
+}
+
+
+/**
+ Reports a status code.
+
+ Reports the status code specified by the parameters Type and Value. Status
+ code also require an instance, caller ID, and extended data. This function
+ passed in a zero instance, NULL extended data, and a caller ID of
+ gEfiCallerIdGuid, which is the GUID for the module.
+
+ ReportStatusCode()must actively prevent recusrsion. If ReportStatusCode()
+ is called while processing another any other Report Status Code Library function,
+ then ReportStatusCode() must return immediately.
+
+ @param Type Status code type.
+ @param Value Status code value.
+
+ @retval EFI_SUCCESS The status code was reported.
+ @retval EFI_DEVICE_ERROR There status code could not be reported due to a
+ device error.
+ @retval EFI_UNSUPPORTED Report status code is not supported
+
+**/
+EFI_STATUS
+EFIAPI
+GlueReportStatusCode (
+ IN EFI_STATUS_CODE_TYPE Type,
+ IN EFI_STATUS_CODE_VALUE Value
+ )
+{
+ return InternalReportStatusCode (Type, Value, 0, &gEfiCallerIdGuid, NULL);
+}
+
+
+/**
+ Reports a status code with a Device Path Protocol as the extended data.
+
+ Allocates and fills in the extended data section of a status code with the
+ Device Path Protocol specified by DevicePath. This function is responsible
+ for allocating a buffer large enough for the standard header and the device
+ path. The standard header is filled in with a GUID of
+ gEfiStatusCodeSpecificDataGuid. The status code is reported with a zero
+ instance and a caller ID of gEfiCallerIdGuid.
+
+ ReportStatusCodeWithDevicePath()must actively prevent recursion. If
+ ReportStatusCodeWithDevicePath() is called while processing another any other
+ Report Status Code Library function, then ReportStatusCodeWithDevicePath()
+ must return EFI_DEVICE_ERROR immediately.
+
+ If DevicePath is NULL, then ASSERT().
+
+ @param Type Status code type.
+ @param Value Status code value.
+ @param DevicePath Pointer to the Device Path Protocol to be reported.
+
+ @retval EFI_SUCCESS The status code was reported with the extended
+ data specified by DevicePath.
+ @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the
+ extended data section.
+ @retval EFI_UNSUPPORTED Report status code is not supported
+
+**/
+EFI_STATUS
+EFIAPI
+GlueReportStatusCodeWithDevicePath (
+ IN EFI_STATUS_CODE_TYPE Type,
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ )
+{
+ ASSERT (DevicePath != NULL);
+ return ReportStatusCodeWithExtendedData (
+ Type,
+ Value,
+ (VOID *)DevicePath,
+ InternalReportStatusCodeDevicePathSize (DevicePath)
+ );
+}
+
+
+/**
+ Reports a status code with an extended data buffer.
+
+ Allocates and fills in the extended data section of a status code with the
+ extended data specified by ExtendedData and ExtendedDataSize. ExtendedData
+ is assumed to be one of the data structures specified in Related Definitions.
+ These data structure do not have the standard header, so this function is
+ responsible for allocating a buffer large enough for the standard header and
+ the extended data passed into this function. The standard header is filled
+ in with a GUID of gEfiStatusCodeSpecificDataGuid. The status code is reported
+ with a zero instance and a caller ID of gEfiCallerIdGuid.
+
+ ReportStatusCodeWithExtendedData()must actively prevent recursion. If
+ ReportStatusCodeWithExtendedData() is called while processing another any other
+ Report Status Code Library function, then ReportStatusCodeWithExtendedData()
+ must return EFI_DEVICE_ERROR immediately.
+
+ If ExtendedData is NULL, then ASSERT().
+ If ExtendedDataSize is 0, then ASSERT().
+
+ @param Type Status code type.
+ @param Value Status code value.
+ @param ExtendedData Pointer to the extended data buffer to be reported.
+ @param ExtendedDataSize The size, in bytes, of the extended data buffer to
+ be reported.
+
+ @retval EFI_SUCCESS The status code was reported with the extended
+ data specified by ExtendedData and ExtendedDataSize.
+ @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the
+ extended data section.
+ @retval EFI_UNSUPPORTED Report status code is not supported
+
+**/
+EFI_STATUS
+EFIAPI
+GlueReportStatusCodeWithExtendedData (
+ IN EFI_STATUS_CODE_TYPE Type,
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN CONST VOID *ExtendedData,
+ IN UINTN ExtendedDataSize
+ )
+{
+ ASSERT (ExtendedData != NULL);
+ ASSERT (ExtendedDataSize != 0);
+ return ReportStatusCodeEx (
+ Type,
+ Value,
+ 0,
+ NULL,
+ NULL,
+ ExtendedData,
+ ExtendedDataSize
+ );
+}
+
+
+/**
+ Reports a status code with full parameters.
+
+ The function reports a status code. If ExtendedData is NULL and ExtendedDataSize
+ is 0, then an extended data buffer is not reported. If ExtendedData is not
+ NULL and ExtendedDataSize is not 0, then an extended data buffer is allocated.
+ ExtendedData is assumed not have the standard status code header, so this function
+ is responsible for allocating a buffer large enough for the standard header and
+ the extended data passed into this function. The standard header is filled in
+ with a GUID specified by ExtendedDataGuid. If ExtendedDataGuid is NULL, then a
+ GUID of gEfiStatusCodeSpecificDatauid is used. The status code is reported with
+ an instance specified by Instance and a caller ID specified by CallerId. If
+ CallerId is NULL, then a caller ID of gEfiCallerIdGuid is used.
+
+ ReportStatusCodeEx()must actively prevent recursion. If ReportStatusCodeEx()
+ is called while processing another any other Report Status Code Library function,
+ then ReportStatusCodeEx() must return EFI_DEVICE_ERROR immediately.
+
+ If ExtendedData is NULL and ExtendedDataSize is not zero, then ASSERT().
+ If ExtendedData is not NULL and ExtendedDataSize is zero, then ASSERT().
+
+ @param Type Status code type.
+ @param Value Status code value.
+ @param Instance Status code instance number.
+ @param CallerId Pointer to a GUID that identifies the caller of this
+ function. If this parameter is NULL, then a caller
+ ID of gEfiCallerIdGuid is used.
+ @param ExtendedDataGuid Pointer to the GUID for the extended data buffer.
+ If this parameter is NULL, then a the status code
+ standard header is filled in with
+ gEfiStatusCodeSpecificDataGuid.
+ @param ExtendedData Pointer to the extended data buffer. This is an
+ optional parameter that may be NULL.
+ @param ExtendedDataSize The size, in bytes, of the extended data buffer.
+
+ @retval EFI_SUCCESS The status code was reported.
+ @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate
+ the extended data section if it was specified.
+ @retval EFI_UNSUPPORTED Report status code is not supported
+
+**/
+EFI_STATUS
+EFIAPI
+GlueReportStatusCodeEx (
+ IN EFI_STATUS_CODE_TYPE Type,
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN UINT32 Instance,
+ IN CONST EFI_GUID *CallerId OPTIONAL,
+ IN CONST EFI_GUID *ExtendedDataGuid OPTIONAL,
+ IN CONST VOID *ExtendedData OPTIONAL,
+ IN UINTN ExtendedDataSize
+ )
+{
+ EFI_STATUS Status;
+ EFI_STATUS_CODE_DATA *StatusCodeData;
+
+ ASSERT (!((ExtendedData == NULL) && (ExtendedDataSize != 0)));
+ ASSERT (!((ExtendedData != NULL) && (ExtendedDataSize == 0)));
+
+ //
+ // Allocate space for the Status Code Header and its buffer
+ //
+ StatusCodeData = NULL;
+ (gBS->AllocatePool) (EfiBootServicesData, sizeof (EFI_STATUS_CODE_DATA) + ExtendedDataSize, (VOID **)&StatusCodeData);
+ if (StatusCodeData == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ //
+ // Fill in the extended data header
+ //
+ StatusCodeData->HeaderSize = sizeof (EFI_STATUS_CODE_DATA);
+ StatusCodeData->Size = (UINT16)ExtendedDataSize;
+ if (ExtendedDataGuid == NULL) {
+ ExtendedDataGuid = &gEfiStatusCodeSpecificDataGuid;
+ }
+ CopyGuid (&StatusCodeData->Type, ExtendedDataGuid);
+
+ //
+ // Fill in the extended data buffer
+ //
+ CopyMem (StatusCodeData + 1, ExtendedData, ExtendedDataSize);
+
+ //
+ // Report the status code
+ //
+ if (CallerId == NULL) {
+ CallerId = &gEfiCallerIdGuid;
+ }
+ Status = InternalReportStatusCode (Type, Value, Instance, CallerId, StatusCodeData);
+
+ //
+ // Free the allocated buffer
+ //
+ (gBS->FreePool) (StatusCodeData);
+
+ return Status;
+}
+
+
+/**
+ Returns TRUE if status codes of type EFI_PROGRESS_CODE are enabled
+
+ This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED
+ bit of PcdReportStatusCodeProperyMask is set. Otherwise FALSE is returned.
+
+ @retval TRUE The REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED bit of
+ PcdReportStatusCodeProperyMask is set.
+ @retval FALSE The REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED bit of
+ PcdReportStatusCodeProperyMask is clear.
+
+**/
+BOOLEAN
+EFIAPI
+GlueReportProgressCodeEnabled (
+ VOID
+ )
+{
+ return ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED) != 0);
+}
+
+
+/**
+ Returns TRUE if status codes of type EFI_ERROR_CODE are enabled
+
+ This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED
+ bit of PcdReportStatusCodeProperyMask is set. Otherwise FALSE is returned.
+
+ @retval TRUE The REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED bit of
+ PcdReportStatusCodeProperyMask is set.
+ @retval FALSE The REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED bit of
+ PcdReportStatusCodeProperyMask is clear.
+
+**/
+BOOLEAN
+EFIAPI
+GlueReportErrorCodeEnabled (
+ VOID
+ )
+{
+ return ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED) != 0);
+}
+
+
+/**
+ Returns TRUE if status codes of type EFI_DEBUG_CODE are enabled
+
+ This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED
+ bit of PcdReportStatusCodeProperyMask is set. Otherwise FALSE is returned.
+
+ @retval TRUE The REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED bit of
+ PcdReportStatusCodeProperyMask is set.
+ @retval FALSE The REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED bit of
+ PcdReportStatusCodeProperyMask is clear.
+
+**/
+BOOLEAN
+EFIAPI
+GlueReportDebugCodeEnabled (
+ VOID
+ )
+{
+ return ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED) != 0);
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeServicesTableLib/DxeServicesTableLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeServicesTableLib/DxeServicesTableLib.c
new file mode 100644
index 0000000..99bdb3c
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeServicesTableLib/DxeServicesTableLib.c
@@ -0,0 +1,60 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ DxeServicesTableLib.c
+
+Abstract:
+
+ Dxe Services Table Lib
+
+--*/
+
+#include "EdkIIGlueDxe.h"
+
+//
+// Cache copy of the DXE Services Table
+//
+EFI_DXE_SERVICES *gDS = NULL;
+
+/**
+ The constructor function caches the pointer of DXE Services Table.
+
+ The constructor function caches the pointer of DXE Services Table.
+ It will ASSERT() if that operation fails.
+ It will ASSERT() if the pointer of DXE Services Table is NULL.
+ It will always return EFI_SUCCESS.
+
+ @param ImageHandle The firmware allocated handle for the EFI image.
+ @param SystemTable A pointer to the EFI System Table.
+
+ @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
+
+**/
+EFI_STATUS
+DxeServicesTableLibConstructor (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ EFI_STATUS Status;
+
+ //
+ // Cache copy of the DXE Services Table
+ //
+ Status = EfiGetSystemConfigurationTable (&gEfiDxeServicesTableGuid, (VOID **) &gDS);
+ ASSERT_EFI_ERROR (Status);
+ ASSERT (gDS != NULL);
+
+ return Status;
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeServicesTableLib/DxeServicesTableLib.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeServicesTableLib/DxeServicesTableLib.inf
new file mode 100644
index 0000000..08c4f04
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeServicesTableLib/DxeServicesTableLib.inf
@@ -0,0 +1,77 @@
+#/*++
+#
+# Copyright (c) 2004 - 2006, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# DxeServicesTableLib.inf
+#
+# Abstract:
+#
+# Component description file for DxeServicesTableLib.
+#
+#--*/
+
+[defines]
+BASE_NAME = EdkIIGlueDxeServicesTableLib
+COMPONENT_TYPE = LIBRARY
+
+[sources.common]
+ DxeServicesTableLib.c
+
+[sources.ia32]
+
+[sources.x64]
+
+[sources.ipf]
+
+[sources.ebc]
+
+
+[includes.common]
+ .
+ ..\..\Include
+ ..\..\include\Library
+ $(EDK_SOURCE)\Foundation
+ $(EDK_SOURCE)\Foundation\Framework
+ $(EDK_SOURCE)\Foundation\Efi
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+ $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include
+ $(EDK_SOURCE)\Foundation\Framework\Guid\DataHubRecords
+ $(EDK_SOURCE)\Foundation\Framework\Guid\StatusCodeDataTypeId
+
+[libraries.common]
+ EdkIIGlueUefiLib
+ EfiProtocolLib
+
+[libraries.ia32]
+
+[libraries.x64]
+
+[nmake.common]
+ C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION
+ LIB_STD_FLAGS = /NOLOGO /IGNORE:4006
+
+[nmake.ia32]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32
+
+[nmake.x64]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64
+
+[nmake.ipf]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF
+
+[nmake.ebc]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeServicesTableLib/EdkIIGlueDxeServicesTableLib.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeServicesTableLib/EdkIIGlueDxeServicesTableLib.cif
new file mode 100644
index 0000000..e7794f7
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeServicesTableLib/EdkIIGlueDxeServicesTableLib.cif
@@ -0,0 +1,11 @@
+<component>
+ name = "EdkIIGlueDxeServicesTableLib"
+ category = ModulePart
+ LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\DxeServicesTableLib"
+ RefName = "EdkIIGlueDxeServicesTableLib"
+[files]
+"EdkIIGlueDxeServicesTableLib.sdl"
+"EdkIIGlueDxeServicesTableLib.mak"
+"DxeServicesTableLib.inf"
+"DxeServicesTableLib.c"
+<endComponent>
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeServicesTableLib/EdkIIGlueDxeServicesTableLib.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeServicesTableLib/EdkIIGlueDxeServicesTableLib.mak
new file mode 100644
index 0000000..7d62e5d
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeServicesTableLib/EdkIIGlueDxeServicesTableLib.mak
@@ -0,0 +1,80 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueDxeServicesTableLib/EdkIIGlueDxeServicesTableLib.mak 1 1/20/12 3:55a Jeffch $
+#
+# $Revision: 1 $
+#
+# $Date: 1/20/12 3:55a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueDxeServicesTableLib/EdkIIGlueDxeServicesTableLib.mak $
+#
+# 1 1/20/12 3:55a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 9/27/11 6:17a Wesleychen
+# Intel EDK initially releases.
+#
+# 1 9/18/09 1:55a Iminglin
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: EdkIIGlueDxeServicesTableLib.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+
+
+$(EdkIIGlueDxeServicesTableLib_LIB) : EdkIIGlueDxeServicesTableLib
+
+EdkIIGlueDxeServicesTableLib : $(BUILD_DIR)\EdkIIGlueDxeServicesTableLib.mak EdkIIGlueDxeServicesTableLibBin
+
+$(BUILD_DIR)\EdkIIGlueDxeServicesTableLib.mak : $(EdkIIGlueDxeServicesTableLib_DIR)\$(@B).cif $(EdkIIGlueDxeServicesTableLib_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(EdkIIGlueDxeServicesTableLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+EdkIIGlueDxeServicesTableLibBin : $(EdkIIGlueUefiLib_LIB) $(EFIPROTOCOLLIB)
+!IF "$(x64_BUILD)"=="1"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGlueDxeServicesTableLib.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueDxeServicesTableLib_LIB)"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\IA32\
+ /f $(BUILD_DIR)\EdkIIGlueDxeServicesTableLib.mak all\
+ TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueDxeServicesTableLib_LIB)"
+!ELSE
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGlueDxeServicesTableLib.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueDxeServicesTableLib_LIB)"
+!ENDIF
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#********************************************************************** \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeServicesTableLib/EdkIIGlueDxeServicesTableLib.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeServicesTableLib/EdkIIGlueDxeServicesTableLib.sdl
new file mode 100644
index 0000000..095f01a
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeServicesTableLib/EdkIIGlueDxeServicesTableLib.sdl
@@ -0,0 +1,26 @@
+TOKEN
+ Name = "EdkIIGlueDxeServicesTableLib_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable EdkIIGlueDxeServicesTableLib support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "EdkIIGlueDxeServicesTableLib_LIB"
+ Value = "$$(LIB_BUILD_DIR)\EdkIIGlueDxeServicesTableLib.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "EdkIIGlueDxeServicesTableLib_DIR"
+End
+
+MODULE
+ Help = "Includes EdkIIGlueDxeServicesTableLib.mak to Project"
+ File = "EdkIIGlueDxeServicesTableLib.mak"
+End
+
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/DxeSmbusLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/DxeSmbusLib.c
new file mode 100644
index 0000000..8d5e10f
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/DxeSmbusLib.c
@@ -0,0 +1,107 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ DxeSmbusLib.c
+
+Abstract:
+
+ Dxe Smbus Lib internal functions
+
+--*/
+
+#include "DxeSmbusLibInternal.h"
+
+//
+// Globle varible to cache pointer to Smbus protocol.
+//
+STATIC EFI_SMBUS_HC_PROTOCOL *mSmbus = NULL;
+
+/**
+ The constructor function caches the pointer to Smbus protocol.
+
+ The constructor function locates Smbus protocol from protocol database.
+ It will ASSERT() if that operation fails and it will always return EFI_SUCCESS.
+
+ @param ImageHandle The firmware allocated handle for the EFI image.
+ @param SystemTable A pointer to the EFI System Table.
+
+ @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
+
+**/
+EFI_STATUS
+EFIAPI
+SmbusLibConstructor (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ EFI_STATUS Status;
+
+ Status = gBS->LocateProtocol (&gEfiSmbusProtocolGuid, NULL, (VOID**) &mSmbus);
+ ASSERT_EFI_ERROR (Status);
+ ASSERT (mSmbus != NULL);
+
+ return Status;
+}
+
+/**
+ Executes an SMBus operation to an SMBus controller.
+
+ This function provides a standard way to execute Smbus script
+ as defined in the SmBus Specification. The data can either be of
+ the Length byte, word, or a block of data.
+
+ @param SmbusOperation Signifies which particular SMBus hardware protocol instance that it will use to
+ execute the SMBus transactions.
+ @param SmBusAddress Address that encodes the SMBUS Slave Address,
+ SMBUS Command, SMBUS Data Length, and PEC.
+ @param Length Signifies the number of bytes that this operation will do. The maximum number of
+ bytes can be revision specific and operation specific.
+ @param Buffer Contains the value of data to execute to the SMBus slave device. Not all operations
+ require this argument. The length of this buffer is identified by Length.
+ @param Status Return status for the executed command.
+ This is an optional parameter and may be NULL.
+
+ @return The actual number of bytes that are executed for this operation..
+
+**/
+UINTN
+InternalSmBusExec (
+ IN EFI_SMBUS_OPERATION SmbusOperation,
+ IN UINTN SmBusAddress,
+ IN UINTN Length,
+ IN OUT VOID *Buffer,
+ OUT RETURN_STATUS *Status OPTIONAL
+ )
+{
+ RETURN_STATUS ReturnStatus;
+ EFI_SMBUS_DEVICE_ADDRESS SmbusDeviceAddress;
+
+ SmbusDeviceAddress.SmbusDeviceAddress = SMBUS_LIB_SLAVE_ADDRESS (SmBusAddress);
+
+ ReturnStatus = mSmbus->Execute (
+ mSmbus,
+ SmbusDeviceAddress,
+ SMBUS_LIB_COMMAND (SmBusAddress),
+ SmbusOperation,
+ SMBUS_LIB_PEC (SmBusAddress),
+ &Length,
+ Buffer
+ );
+ if (Status != NULL) {
+ *Status = ReturnStatus;
+ }
+
+ return Length;
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/DxeSmbusLib.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/DxeSmbusLib.inf
new file mode 100644
index 0000000..518d63d
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/DxeSmbusLib.inf
@@ -0,0 +1,80 @@
+#/*++
+#
+# Copyright (c) 2004 - 2006, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# DxeSmbusLib.inf
+#
+# Abstract:
+#
+# Component description file for DxeSmbusLib.
+#
+#--*/
+
+[defines]
+BASE_NAME = EdkIIGlueDxeSmbusLib
+COMPONENT_TYPE = LIBRARY
+
+[sources.common]
+ DxeSmbusLib.c
+ SmbusLib.c
+
+[sources.ia32]
+
+[sources.x64]
+
+[sources.ipf]
+
+[sources.ebc]
+
+
+[includes.common]
+ .
+ ..\..\Include
+ ..\..\include\Library
+ $(EDK_SOURCE)\Foundation
+ $(EDK_SOURCE)\Foundation\Framework
+ $(EDK_SOURCE)\Foundation\Efi
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+ $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include
+ $(EDK_SOURCE)\Foundation\Framework\Guid\DataHubRecords
+ $(EDK_SOURCE)\Foundation\Framework\Guid\StatusCodeDataTypeId
+
+[libraries.common]
+ EdkIIGlueBaseMemoryLib
+ EdkIIGlueUefiBootServicesTableLib
+ EfiProtocolLib
+ EdkFrameworkProtocolLib
+
+[libraries.ia32]
+
+[libraries.x64]
+
+[nmake.common]
+ C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION
+ LIB_STD_FLAGS = /NOLOGO /IGNORE:4006
+
+[nmake.ia32]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32
+
+[nmake.x64]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64
+
+[nmake.ipf]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF
+
+[nmake.ebc]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/DxeSmbusLibInternal.h b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/DxeSmbusLibInternal.h
new file mode 100644
index 0000000..c704b07
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/DxeSmbusLibInternal.h
@@ -0,0 +1,67 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ DxeSmbusLibInternal.h
+
+Abstract:
+
+ Declarations of internal functions in DxeSmbusLib.
+
+--*/
+
+#ifndef __DXE_SMBUS_LIB_INTERNAL_H__
+#define __DXE_SMBUS_LIB_INTERNAL_H__
+
+#include "EdkIIGlueDxe.h"
+
+#define SMBUS_LIB_SLAVE_ADDRESS(SmBusAddress) (((SmBusAddress) >> 1) & 0x7f)
+#define SMBUS_LIB_COMMAND(SmBusAddress) (((SmBusAddress) >> 8) & 0xff)
+#define SMBUS_LIB_LENGTH(SmBusAddress) (((SmBusAddress) >> 16) & 0x3f)
+#define SMBUS_LIB_PEC(SmBusAddress) ((BOOLEAN) (((SmBusAddress) & SMBUS_LIB_PEC_BIT) != 0))
+#define SMBUS_LIB_RESEARVED(SmBusAddress) ((SmBusAddress) & ~(((1 << 22) - 2) | SMBUS_LIB_PEC_BIT))
+
+//
+// Declaration for internal functions
+//
+/**
+ Executes an SMBus operation to an SMBus controller.
+
+ This function provides a standard way to execute Smbus script
+ as defined in the SmBus Specification. The data can either be of
+ the Length byte, word, or a block of data.
+
+ @param SmbusOperation Signifies which particular SMBus hardware protocol instance that it will use to
+ execute the SMBus transactions.
+ @param SmBusAddress Address that encodes the SMBUS Slave Address,
+ SMBUS Command, SMBUS Data Length, and PEC.
+ @param Length Signifies the number of bytes that this operation will do. The maximum number of
+ bytes can be revision specific and operation specific.
+ @param Buffer Contains the value of data to execute to the SMBus slave device. Not all operations
+ require this argument. The length of this buffer is identified by Length.
+ @param Status Return status for the executed command.
+ This is an optional parameter and may be NULL.
+
+ @return The actual number of bytes that are executed for this operation.
+
+**/
+UINTN
+InternalSmBusExec (
+ IN EFI_SMBUS_OPERATION SmbusOperation,
+ IN UINTN SmBusAddress,
+ IN UINTN Length,
+ IN OUT VOID *Buffer,
+ OUT RETURN_STATUS *Status OPTIONAL
+ );
+
+#endif
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/EdkIIGlueDxeSmbusLib.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/EdkIIGlueDxeSmbusLib.cif
new file mode 100644
index 0000000..595b2b0
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/EdkIIGlueDxeSmbusLib.cif
@@ -0,0 +1,13 @@
+<component>
+ name = "EdkIIGlueDxeSmbusLib"
+ category = ModulePart
+ LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\DxeSmbusLib"
+ RefName = "EdkIIGlueDxeSmbusLib"
+[files]
+"EdkIIGlueDxeSmbusLib.sdl"
+"EdkIIGlueDxeSmbusLib.mak"
+"DxeSmbusLib.inf"
+"DxeSmbusLib.c"
+"SmbusLib.c"
+"DxeSmbusLibInternal.h"
+<endComponent>
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/EdkIIGlueDxeSmbusLib.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/EdkIIGlueDxeSmbusLib.mak
new file mode 100644
index 0000000..9212712
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/EdkIIGlueDxeSmbusLib.mak
@@ -0,0 +1,80 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueDxeSmbusLib/EdkIIGlueDxeSmbusLib.mak 1 1/20/12 3:55a Jeffch $
+#
+# $Revision: 1 $
+#
+# $Date: 1/20/12 3:55a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueDxeSmbusLib/EdkIIGlueDxeSmbusLib.mak $
+#
+# 1 1/20/12 3:55a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 9/27/11 6:17a Wesleychen
+# Intel EDK initially releases.
+#
+# 1 9/18/09 1:55a Iminglin
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: EdkIIGlueDxeSmbusLib.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+
+
+$(EdkIIGlueDxeSmbusLib_LIB) : EdkIIGlueDxeSmbusLib
+
+EdkIIGlueDxeSmbusLib : $(BUILD_DIR)\EdkIIGlueDxeSmbusLib.mak EdkIIGlueDxeSmbusLibBin
+
+$(BUILD_DIR)\EdkIIGlueDxeSmbusLib.mak : $(EdkIIGlueDxeSmbusLib_DIR)\$(@B).cif $(EdkIIGlueDxeSmbusLib_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(EdkIIGlueDxeSmbusLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+EdkIIGlueDxeSmbusLibBin : $(EdkIIGlueBaseMemoryLib_LIB) $(EdkIIGlueUefiBootServicesTableLib_LIB) $(EFIPROTOCOLLIB) $(EDKFRAMEWORKPROTOCOLLIB)
+!IF "$(x64_BUILD)"=="1"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGlueDxeSmbusLib.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueDxeSmbusLib_LIB)"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\IA32\
+ /f $(BUILD_DIR)\EdkIIGlueDxeSmbusLib.mak all\
+ TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueDxeSmbusLib_LIB)"
+!ELSE
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGlueDxeSmbusLib.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueDxeSmbusLib_LIB)"
+!ENDIF
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#********************************************************************** \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/EdkIIGlueDxeSmbusLib.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/EdkIIGlueDxeSmbusLib.sdl
new file mode 100644
index 0000000..1a6173a
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/EdkIIGlueDxeSmbusLib.sdl
@@ -0,0 +1,26 @@
+TOKEN
+ Name = "EdkIIGlueDxeSmbusLib_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable EdkIIGlueDxeSmbusLib support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "EdkIIGlueDxeSmbusLib_LIB"
+ Value = "$$(LIB_BUILD_DIR)\EdkIIGlueDxeSmbusLib.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "EdkIIGlueDxeSmbusLib_DIR"
+End
+
+MODULE
+ Help = "Includes EdkIIGlueDxeSmbusLib.mak to Project"
+ File = "EdkIIGlueDxeSmbusLib.mak"
+End
+
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/SmbusLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/SmbusLib.c
new file mode 100644
index 0000000..00fdf32
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/DxeSmbusLib/SmbusLib.c
@@ -0,0 +1,475 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ DxeSmbus.c
+
+Abstract:
+
+ Dxe Smbus Lib Interfaces
+
+--*/
+
+#include "DxeSmbusLibInternal.h"
+
+/**
+ Executes an SMBUS quick read command.
+
+ Executes an SMBUS quick read command on the SMBUS device specified by SmBusAddress.
+ Only the SMBUS slave address field of SmBusAddress is required.
+ If Status is not NULL, then the status of the executed command is returned in Status.
+ If PEC is set in SmBusAddress, then ASSERT().
+ If Command in SmBusAddress is not zero, then ASSERT().
+ If Length in SmBusAddress is not zero, then ASSERT().
+ If any reserved bits of SmBusAddress are set, then ASSERT().
+
+ @param SmBusAddress Address that encodes the SMBUS Slave Address,
+ SMBUS Command, SMBUS Data Length, and PEC.
+ @param Status Return status for the executed command.
+ This is an optional parameter and may be NULL.
+
+**/
+VOID
+EFIAPI
+SmBusQuickRead (
+ IN UINTN SmBusAddress,
+ OUT RETURN_STATUS *Status OPTIONAL
+ )
+{
+ ASSERT (!SMBUS_LIB_PEC (SmBusAddress));
+ ASSERT (SMBUS_LIB_COMMAND (SmBusAddress) == 0);
+ ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0);
+ ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);
+
+ InternalSmBusExec (EfiSmbusQuickRead, SmBusAddress, 0, NULL, Status);
+}
+
+/**
+ Executes an SMBUS quick write command.
+
+ Executes an SMBUS quick write command on the SMBUS device specified by SmBusAddress.
+ Only the SMBUS slave address field of SmBusAddress is required.
+ If Status is not NULL, then the status of the executed command is returned in Status.
+ If PEC is set in SmBusAddress, then ASSERT().
+ If Command in SmBusAddress is not zero, then ASSERT().
+ If Length in SmBusAddress is not zero, then ASSERT().
+ If any reserved bits of SmBusAddress are set, then ASSERT().
+
+ @param SmBusAddress Address that encodes the SMBUS Slave Address,
+ SMBUS Command, SMBUS Data Length, and PEC.
+ @param Status Return status for the executed command.
+ This is an optional parameter and may be NULL.
+
+**/
+VOID
+EFIAPI
+SmBusQuickWrite (
+ IN UINTN SmBusAddress,
+ OUT RETURN_STATUS *Status OPTIONAL
+ )
+{
+ ASSERT (!SMBUS_LIB_PEC (SmBusAddress));
+ ASSERT (SMBUS_LIB_COMMAND (SmBusAddress) == 0);
+ ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0);
+ ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);
+
+ InternalSmBusExec (EfiSmbusQuickWrite, SmBusAddress, 0, NULL, Status);
+}
+
+/**
+ Executes an SMBUS receive byte command.
+
+ Executes an SMBUS receive byte command on the SMBUS device specified by SmBusAddress.
+ Only the SMBUS slave address field of SmBusAddress is required.
+ The byte received from the SMBUS is returned.
+ If Status is not NULL, then the status of the executed command is returned in Status.
+ If Command in SmBusAddress is not zero, then ASSERT().
+ If Length in SmBusAddress is not zero, then ASSERT().
+ If any reserved bits of SmBusAddress are set, then ASSERT().
+
+ @param SmBusAddress Address that encodes the SMBUS Slave Address,
+ SMBUS Command, SMBUS Data Length, and PEC.
+ @param Status Return status for the executed command.
+ This is an optional parameter and may be NULL.
+
+ @return The byte received from the SMBUS.
+
+**/
+UINT8
+EFIAPI
+SmBusReceiveByte (
+ IN UINTN SmBusAddress,
+ OUT RETURN_STATUS *Status OPTIONAL
+ )
+{
+ UINT8 Byte;
+
+ ASSERT (SMBUS_LIB_COMMAND (SmBusAddress) == 0);
+ ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0);
+ ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);
+
+ InternalSmBusExec (EfiSmbusReceiveByte, SmBusAddress, 1, &Byte, Status);
+
+ return Byte;
+}
+
+/**
+ Executes an SMBUS send byte command.
+
+ Executes an SMBUS send byte command on the SMBUS device specified by SmBusAddress.
+ The byte specified by Value is sent.
+ Only the SMBUS slave address field of SmBusAddress is required. Value is returned.
+ If Status is not NULL, then the status of the executed command is returned in Status.
+ If Command in SmBusAddress is not zero, then ASSERT().
+ If Length in SmBusAddress is not zero, then ASSERT().
+ If any reserved bits of SmBusAddress are set, then ASSERT().
+
+ @param SmBusAddress Address that encodes the SMBUS Slave Address,
+ SMBUS Command, SMBUS Data Length, and PEC.
+ @param Value The 8-bit value to send.
+ @param Status Return status for the executed command.
+ This is an optional parameter and may be NULL.
+
+ @return The parameter of Value.
+
+**/
+UINT8
+EFIAPI
+SmBusSendByte (
+ IN UINTN SmBusAddress,
+ IN UINT8 Value,
+ OUT RETURN_STATUS *Status OPTIONAL
+ )
+{
+ UINT8 Byte;
+
+ ASSERT (SMBUS_LIB_COMMAND (SmBusAddress) == 0);
+ ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0);
+ ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);
+
+ Byte = Value;
+ InternalSmBusExec (EfiSmbusSendByte, SmBusAddress, 1, &Byte, Status);
+
+ return Value;
+}
+
+/**
+ Executes an SMBUS read data byte command.
+
+ Executes an SMBUS read data byte command on the SMBUS device specified by SmBusAddress.
+ Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.
+ The 8-bit value read from the SMBUS is returned.
+ If Status is not NULL, then the status of the executed command is returned in Status.
+ If Length in SmBusAddress is not zero, then ASSERT().
+ If any reserved bits of SmBusAddress are set, then ASSERT().
+
+ @param SmBusAddress Address that encodes the SMBUS Slave Address,
+ SMBUS Command, SMBUS Data Length, and PEC.
+ @param Status Return status for the executed command.
+ This is an optional parameter and may be NULL.
+
+ @return The byte read from the SMBUS.
+
+**/
+UINT8
+EFIAPI
+SmBusReadDataByte (
+ IN UINTN SmBusAddress,
+ OUT RETURN_STATUS *Status OPTIONAL
+ )
+{
+ UINT8 Byte;
+
+ ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0);
+ ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);
+
+ InternalSmBusExec (EfiSmbusReadByte, SmBusAddress, 1, &Byte, Status);
+
+ return Byte;
+}
+
+/**
+ Executes an SMBUS write data byte command.
+
+ Executes an SMBUS write data byte command on the SMBUS device specified by SmBusAddress.
+ The 8-bit value specified by Value is written.
+ Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.
+ Value is returned.
+ If Status is not NULL, then the status of the executed command is returned in Status.
+ If Length in SmBusAddress is not zero, then ASSERT().
+ If any reserved bits of SmBusAddress are set, then ASSERT().
+
+ @param SmBusAddress Address that encodes the SMBUS Slave Address,
+ SMBUS Command, SMBUS Data Length, and PEC.
+ @param Value The 8-bit value to write.
+ @param Status Return status for the executed command.
+ This is an optional parameter and may be NULL.
+
+ @return The parameter of Value.
+
+**/
+UINT8
+EFIAPI
+SmBusWriteDataByte (
+ IN UINTN SmBusAddress,
+ IN UINT8 Value,
+ OUT RETURN_STATUS *Status OPTIONAL
+ )
+{
+ UINT8 Byte;
+
+ ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0);
+ ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);
+
+ Byte = Value;
+ InternalSmBusExec (EfiSmbusWriteByte, SmBusAddress, 1, &Byte, Status);
+
+ return Value;
+}
+
+/**
+ Executes an SMBUS read data word command.
+
+ Executes an SMBUS read data word command on the SMBUS device specified by SmBusAddress.
+ Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.
+ The 16-bit value read from the SMBUS is returned.
+ If Status is not NULL, then the status of the executed command is returned in Status.
+ If Length in SmBusAddress is not zero, then ASSERT().
+ If any reserved bits of SmBusAddress are set, then ASSERT().
+
+ @param SmBusAddress Address that encodes the SMBUS Slave Address,
+ SMBUS Command, SMBUS Data Length, and PEC.
+ @param Status Return status for the executed command.
+ This is an optional parameter and may be NULL.
+
+ @return The byte read from the SMBUS.
+
+**/
+UINT16
+EFIAPI
+SmBusReadDataWord (
+ IN UINTN SmBusAddress,
+ OUT RETURN_STATUS *Status OPTIONAL
+ )
+{
+ UINT16 Word;
+
+ ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0);
+ ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);
+
+ InternalSmBusExec (EfiSmbusReadWord, SmBusAddress, 2, &Word, Status);
+
+ return Word;
+}
+
+/**
+ Executes an SMBUS write data word command.
+
+ Executes an SMBUS write data word command on the SMBUS device specified by SmBusAddress.
+ The 16-bit value specified by Value is written.
+ Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.
+ Value is returned.
+ If Status is not NULL, then the status of the executed command is returned in Status.
+ If Length in SmBusAddress is not zero, then ASSERT().
+ If any reserved bits of SmBusAddress are set, then ASSERT().
+
+ @param SmBusAddress Address that encodes the SMBUS Slave Address,
+ SMBUS Command, SMBUS Data Length, and PEC.
+ @param Value The 16-bit value to write.
+ @param Status Return status for the executed command.
+ This is an optional parameter and may be NULL.
+
+ @return The parameter of Value.
+
+**/
+UINT16
+EFIAPI
+SmBusWriteDataWord (
+ IN UINTN SmBusAddress,
+ IN UINT16 Value,
+ OUT RETURN_STATUS *Status OPTIONAL
+ )
+{
+ UINT16 Word;
+
+ ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0);
+ ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);
+
+ Word = Value;
+ InternalSmBusExec (EfiSmbusWriteWord, SmBusAddress, 2, &Word, Status);
+
+ return Value;
+}
+
+/**
+ Executes an SMBUS process call command.
+
+ Executes an SMBUS process call command on the SMBUS device specified by SmBusAddress.
+ The 16-bit value specified by Value is written.
+ Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.
+ The 16-bit value returned by the process call command is returned.
+ If Status is not NULL, then the status of the executed command is returned in Status.
+ If Length in SmBusAddress is not zero, then ASSERT().
+ If any reserved bits of SmBusAddress are set, then ASSERT().
+
+ @param SmBusAddress Address that encodes the SMBUS Slave Address,
+ SMBUS Command, SMBUS Data Length, and PEC.
+ @param Value The 16-bit value to write.
+ @param Status Return status for the executed command.
+ This is an optional parameter and may be NULL.
+
+ @return The 16-bit value returned by the process call command.
+
+**/
+UINT16
+EFIAPI
+SmBusProcessCall (
+ IN UINTN SmBusAddress,
+ IN UINT16 Value,
+ OUT RETURN_STATUS *Status OPTIONAL
+ )
+{
+ ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0);
+ ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);
+
+ InternalSmBusExec (EfiSmbusProcessCall, SmBusAddress, 2, &Value, Status);
+
+ return Value;
+}
+
+/**
+ Executes an SMBUS read block command.
+
+ Executes an SMBUS read block command on the SMBUS device specified by SmBusAddress.
+ Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.
+ Bytes are read from the SMBUS and stored in Buffer.
+ The number of bytes read is returned, and will never return a value larger than 32-bytes.
+ If Status is not NULL, then the status of the executed command is returned in Status.
+ It is the caller's responsibility to make sure Buffer is large enough for the total number of bytes read.
+ SMBUS supports a maximum transfer size of 32 bytes, so Buffer does not need to be any larger than 32 bytes.
+ If Length in SmBusAddress is not zero, then ASSERT().
+ If Buffer is NULL, then ASSERT().
+ If any reserved bits of SmBusAddress are set, then ASSERT().
+
+ @param SmBusAddress Address that encodes the SMBUS Slave Address,
+ SMBUS Command, SMBUS Data Length, and PEC.
+ @param Buffer Pointer to the buffer to store the bytes read from the SMBUS.
+ @param Status Return status for the executed command.
+ This is an optional parameter and may be NULL.
+
+ @return The number of bytes read.
+
+**/
+UINTN
+EFIAPI
+SmBusReadBlock (
+ IN UINTN SmBusAddress,
+ OUT VOID *Buffer,
+ OUT RETURN_STATUS *Status OPTIONAL
+ )
+{
+ ASSERT (Buffer != NULL);
+ ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0);
+ ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);
+
+ return InternalSmBusExec (EfiSmbusReadBlock, SmBusAddress, 0x20, Buffer, Status);
+}
+
+/**
+ Executes an SMBUS write block command.
+
+ Executes an SMBUS write block command on the SMBUS device specified by SmBusAddress.
+ The SMBUS slave address, SMBUS command, and SMBUS length fields of SmBusAddress are required.
+ Bytes are written to the SMBUS from Buffer.
+ The number of bytes written is returned, and will never return a value larger than 32-bytes.
+ If Status is not NULL, then the status of the executed command is returned in Status.
+ If Length in SmBusAddress is zero or greater than 32, then ASSERT().
+ If Buffer is NULL, then ASSERT().
+ If any reserved bits of SmBusAddress are set, then ASSERT().
+
+ @param SmBusAddress Address that encodes the SMBUS Slave Address,
+ SMBUS Command, SMBUS Data Length, and PEC.
+ @param Buffer Pointer to the buffer to store the bytes read from the SMBUS.
+ @param Status Return status for the executed command.
+ This is an optional parameter and may be NULL.
+
+ @return The number of bytes written.
+
+**/
+UINTN
+EFIAPI
+SmBusWriteBlock (
+ IN UINTN SmBusAddress,
+ OUT VOID *Buffer,
+ OUT RETURN_STATUS *Status OPTIONAL
+ )
+{
+ UINTN Length;
+
+ ASSERT (Buffer != NULL);
+ ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) >= 1);
+ ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) <= 32);
+ ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);
+
+ Length = SMBUS_LIB_LENGTH (SmBusAddress);
+ return InternalSmBusExec (EfiSmbusWriteBlock, SmBusAddress, Length, Buffer, Status);
+}
+
+/**
+ Executes an SMBUS block process call command.
+
+ Executes an SMBUS block process call command on the SMBUS device specified by SmBusAddress.
+ The SMBUS slave address, SMBUS command, and SMBUS length fields of SmBusAddress are required.
+ Bytes are written to the SMBUS from WriteBuffer. Bytes are then read from the SMBUS into ReadBuffer.
+ If Status is not NULL, then the status of the executed command is returned in Status.
+ It is the caller's responsibility to make sure ReadBuffer is large enough for the total number of bytes read.
+ SMBUS supports a maximum transfer size of 32 bytes, so Buffer does not need to be any larger than 32 bytes.
+ If Length in SmBusAddress is zero or greater than 32, then ASSERT().
+ If WriteBuffer is NULL, then ASSERT().
+ If ReadBuffer is NULL, then ASSERT().
+ If any reserved bits of SmBusAddress are set, then ASSERT().
+
+ @param SmBusAddress Address that encodes the SMBUS Slave Address,
+ SMBUS Command, SMBUS Data Length, and PEC.
+ @param WriteBuffer Pointer to the buffer of bytes to write to the SMBUS.
+ @param ReadBuffer Pointer to the buffer of bytes to read from the SMBUS.
+ @param Status Return status for the executed command.
+ This is an optional parameter and may be NULL.
+
+ @return The number of bytes written.
+
+**/
+UINTN
+EFIAPI
+SmBusBlockProcessCall (
+ IN UINTN SmBusAddress,
+ IN VOID *WriteBuffer,
+ OUT VOID *ReadBuffer,
+ OUT RETURN_STATUS *Status OPTIONAL
+ )
+{
+ UINTN Length;
+
+ ASSERT (WriteBuffer != NULL);
+ ASSERT (ReadBuffer != NULL);
+ ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) >= 1);
+ ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) <= 32);
+ ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);
+
+ Length = SMBUS_LIB_LENGTH (SmBusAddress);
+ //
+ // Assuming that ReadBuffer is large enough to save another memory copy.
+ //
+ ReadBuffer = CopyMem (ReadBuffer, WriteBuffer, Length);
+ return InternalSmBusExec (EfiSmbusBWBRProcessCall, SmBusAddress, Length, ReadBuffer, Status);
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Common/RuntimeLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Common/RuntimeLib.c
new file mode 100644
index 0000000..e0b434b
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Common/RuntimeLib.c
@@ -0,0 +1,261 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ RuntimeLib.c
+
+Abstract:
+
+ Runtime lib
+
+--*/
+
+#include "..\RuntimeLibInternal.h"
+
+//
+// Driver Lib Module Globals
+//
+STATIC EFI_EVENT mRuntimeNotifyEvent;
+STATIC EFI_EVENT mEfiVirtualNotifyEvent;
+STATIC BOOLEAN mEfiGoneVirtual = FALSE;
+STATIC BOOLEAN mEfiAtRuntime = FALSE;
+
+EFI_RUNTIME_SERVICES *mRT = NULL;
+
+VOID
+EFIAPI
+RuntimeDriverExitBootServices (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+/*++
+
+Routine Description:
+
+ Set AtRuntime flag as TRUE after ExitBootServices
+
+Arguments:
+
+ Event - The Event that is being processed
+
+ Context - Event Context
+
+Returns:
+
+ None
+
+--*/
+{
+ EFI_EVENT_NOTIFY ChildNotifyEventHandler;
+ UINTN Index;
+
+ for (Index = 0;
+ _gDriverExitBootServicesEvent[Index] != NULL;
+ Index++) {
+ ChildNotifyEventHandler = _gDriverExitBootServicesEvent[Index];
+ ChildNotifyEventHandler (Event, NULL);
+ }
+
+ mEfiAtRuntime = TRUE;
+}
+
+STATIC
+VOID
+EFIAPI
+RuntimeLibVirtualNotifyEvent (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+/*++
+
+Routine Description:
+
+ Fixup internal data so that EFI can be call in virtual mode.
+ Call the passed in Child Notify event and convert any pointers in
+ lib to virtual mode.
+
+Arguments:
+
+ Event - The Event that is being processed
+
+ Context - Event Context
+
+Returns:
+
+ None
+
+--*/
+{
+ UINTN Index;
+ EFI_EVENT_NOTIFY ChildNotifyEventHandler;
+
+ for (Index = 0;
+ _gDriverSetVirtualAddressMapEvent[Index] != NULL;
+ Index++) {
+ ChildNotifyEventHandler = _gDriverSetVirtualAddressMapEvent[Index];
+ ChildNotifyEventHandler (Event, NULL);
+ }
+
+ //
+ // Update global for Runtime Services Table and IO
+ //
+ EfiConvertInternalPointer ((VOID **) &mRT);
+
+ //
+ // Clear out BootService globals
+ //
+ gBS = NULL;
+ gST = NULL;
+ mEfiGoneVirtual = TRUE;
+}
+
+EFI_STATUS
+EFIAPI
+RuntimeDriverLibConstruct (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+/*++
+
+Routine Description:
+
+ Intialize runtime Driver Lib if it has not yet been initialized.
+
+Arguments:
+
+ ImageHandle - The firmware allocated handle for the EFI image.
+
+ SystemTable - A pointer to the EFI System Table.
+
+ GoVirtualChildEvent - Caller can register a virtual notification event.
+
+Returns:
+
+ EFI_STATUS always returns EFI_SUCCESS except EFI_ALREADY_STARTED if already started.
+
+--*/
+{
+ EFI_STATUS Status;
+
+ mRT = SystemTable->RuntimeServices;
+
+ //
+ // Register our ExitBootServices () notify function
+ //
+ Status = gBS->CreateEvent (
+ EFI_EVENT_SIGNAL_EXIT_BOOT_SERVICES,
+ EFI_TPL_NOTIFY,
+ RuntimeDriverExitBootServices,
+ NULL,
+ &mRuntimeNotifyEvent
+ );
+
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // Register SetVirtualAddressMap () notify function
+ //
+ Status = gBS->CreateEvent (
+ EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE,
+ EFI_TPL_NOTIFY,
+ RuntimeLibVirtualNotifyEvent,
+ NULL,
+ &mEfiVirtualNotifyEvent
+ );
+
+ ASSERT_EFI_ERROR (Status);
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+RuntimeDriverLibDeconstruct (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ This routine will free some resources which have been allocated in
+ EfiInitializeRuntimeDriverLib(). If a runtime driver exits with an error,
+ it must call this routine to free the allocated resource before the exiting.
+
+Arguments:
+
+ None
+
+Returns:
+
+ EFI_SUCCESS - Shotdown the Runtime Driver Lib successfully
+ EFI_UNSUPPORTED - Runtime Driver lib was not initialized at all
+
+--*/
+{
+ EFI_STATUS Status;
+
+ //
+ // Close our ExitBootServices () notify function
+ //
+ Status = gBS->CloseEvent (mRuntimeNotifyEvent);
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // Close SetVirtualAddressMap () notify function
+ //
+ Status = gBS->CloseEvent (mEfiVirtualNotifyEvent);
+ ASSERT_EFI_ERROR (Status);
+
+ return EFI_SUCCESS;
+}
+
+BOOLEAN
+EfiAtRuntime (
+ VOID
+ )
+/*++
+
+Routine Description:
+ Return TRUE if ExitBootServices () has been called
+
+Arguments:
+ NONE
+
+Returns:
+ TRUE - If ExitBootServices () has been called
+
+--*/
+{
+ return mEfiAtRuntime;
+}
+
+BOOLEAN
+EfiGoneVirtual (
+ VOID
+ )
+/*++
+
+Routine Description:
+ Return TRUE if SetVirtualAddressMap () has been called
+
+Arguments:
+ NONE
+
+Returns:
+ TRUE - If SetVirtualAddressMap () has been called
+
+--*/
+{
+ return mEfiGoneVirtual;
+}
+
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Common/RuntimeService.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Common/RuntimeService.c
new file mode 100644
index 0000000..83b718c
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/Common/RuntimeService.c
@@ -0,0 +1,481 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ RuntimeService.c
+
+Abstract:
+
+ Runtime Lib
+
+--*/
+
+#include "..\RuntimeLibInternal.h"
+
+VOID
+EfiResetSystem (
+ IN EFI_RESET_TYPE ResetType,
+ IN EFI_STATUS ResetStatus,
+ IN UINTN DataSize,
+ IN CHAR16 *ResetData
+ )
+/*++
+
+Routine Description:
+
+ Resets the entire platform.
+
+Arguments:
+
+ ResetType - The type of reset to perform.
+ ResetStatus - The status code for the reset.
+ DataSize - The size, in bytes, of ResetData.
+ ResetData - A data buffer that includes a Null-terminated Unicode string, optionally
+ followed by additional binary data.
+
+Returns:
+
+ None
+
+--*/
+{
+ mRT->ResetSystem (ResetType, ResetStatus, DataSize, ResetData);
+}
+
+//
+// The following functions hide the mRT local global from the call to
+// runtime service in the EFI system table.
+//
+EFI_STATUS
+EfiGetTime (
+ OUT EFI_TIME *Time,
+ OUT EFI_TIME_CAPABILITIES *Capabilities
+ )
+/*++
+
+Routine Description:
+
+ Returns the current time and date information, and the time-keeping
+ capabilities of the hardware platform.
+
+Arguments:
+
+ Time - A pointer to storage to receive a snapshot of the current time.
+ Capabilities - An optional pointer to a buffer to receive the real time clock device¡¯s
+ capabilities.
+
+Returns:
+
+ Status code
+
+--*/
+{
+ return mRT->GetTime (Time, Capabilities);
+}
+
+EFI_STATUS
+EfiSetTime (
+ IN EFI_TIME *Time
+ )
+/*++
+
+Routine Description:
+
+ Sets the current local time and date information.
+
+Arguments:
+
+ Time - A pointer to the current time.
+
+Returns:
+
+ Status code
+
+--*/
+{
+ return mRT->SetTime (Time);
+}
+
+EFI_STATUS
+EfiGetWakeupTime (
+ OUT BOOLEAN *Enabled,
+ OUT BOOLEAN *Pending,
+ OUT EFI_TIME *Time
+ )
+/*++
+
+Routine Description:
+
+ Returns the current wakeup alarm clock setting.
+
+Arguments:
+
+ Enabled - Indicates if the alarm is currently enabled or disabled.
+ Pending - Indicates if the alarm signal is pending and requires acknowledgement.
+ Time - The current alarm setting.
+
+Returns:
+
+ Status code
+
+--*/
+{
+ return mRT->GetWakeupTime (Enabled, Pending, Time);
+}
+
+EFI_STATUS
+EfiSetWakeupTime (
+ IN BOOLEAN Enable,
+ IN EFI_TIME *Time
+ )
+/*++
+
+Routine Description:
+
+ Sets the system wakeup alarm clock time.
+
+Arguments:
+
+ Enable - Enable or disable the wakeup alarm.
+ Time - If Enable is TRUE, the time to set the wakeup alarm for.
+ If Enable is FALSE, then this parameter is optional, and may be NULL.
+
+Returns:
+
+ Status code
+
+--*/
+{
+ return mRT->SetWakeupTime (Enable, Time);
+}
+
+
+
+
+EFI_STATUS
+EfiGetVariable (
+ IN CHAR16 *VariableName,
+ IN EFI_GUID * VendorGuid,
+ OUT UINT32 *Attributes OPTIONAL,
+ IN OUT UINTN *DataSize,
+ OUT VOID *Data
+ )
+/*++
+
+Routine Description:
+
+ Returns the value of a variable.
+
+Arguments:
+
+ VariableName - A Null-terminated Unicode string that is the name of the
+ vendor¡¯s variable.
+ VendorGuid - A unique identifier for the vendor.
+ Attributes - If not NULL, a pointer to the memory location to return the
+ attributes bitmask for the variable.
+ DataSize - On input, the size in bytes of the return Data buffer.
+ On output the size of data returned in Data.
+ Data - The buffer to return the contents of the variable.
+
+Returns:
+
+ Status code
+
+--*/
+{
+ return mRT->GetVariable (VariableName, VendorGuid, Attributes, DataSize, Data);
+}
+
+EFI_STATUS
+EfiGetNextVariableName (
+ IN OUT UINTN *VariableNameSize,
+ IN OUT CHAR16 *VariableName,
+ IN OUT EFI_GUID *VendorGuid
+ )
+/*++
+
+Routine Description:
+
+ Enumerates the current variable names.
+
+Arguments:
+
+ VariableNameSize - The size of the VariableName buffer.
+ VariableName - On input, supplies the last VariableName that was returned
+ by GetNextVariableName().
+ On output, returns the Nullterminated Unicode string of the
+ current variable.
+ VendorGuid - On input, supplies the last VendorGuid that was returned by
+ GetNextVariableName().
+ On output, returns the VendorGuid of the current variable.
+
+Returns:
+
+ Status code
+
+--*/
+{
+ return mRT->GetNextVariableName (VariableNameSize, VariableName, VendorGuid);
+}
+
+EFI_STATUS
+EfiSetVariable (
+ IN CHAR16 *VariableName,
+ IN EFI_GUID *VendorGuid,
+ IN UINT32 Attributes,
+ IN UINTN DataSize,
+ IN VOID *Data
+ )
+/*++
+
+Routine Description:
+
+ Sets the value of a variable.
+
+Arguments:
+
+ VariableName - A Null-terminated Unicode string that is the name of the
+ vendor¡¯s variable.
+ VendorGuid - A unique identifier for the vendor.
+ Attributes - Attributes bitmask to set for the variable.
+ DataSize - The size in bytes of the Data buffer.
+ Data - The contents for the variable.
+
+Returns:
+
+ Status code
+
+--*/
+{
+ return mRT->SetVariable (VariableName, VendorGuid, Attributes, DataSize, Data);
+}
+
+EFI_STATUS
+EfiGetNextHighMonotonicCount (
+ OUT UINT32 *HighCount
+ )
+/*++
+
+Routine Description:
+
+ Returns the next high 32 bits of the platform¡¯s monotonic counter.
+
+Arguments:
+
+ HighCount - Pointer to returned value.
+
+Returns:
+
+ Status code
+
+--*/
+{
+ return mRT->GetNextHighMonotonicCount (HighCount);
+}
+
+EFI_STATUS
+EfiConvertPointer (
+ IN UINTN DebugDisposition,
+ IN OUT VOID *Address
+ )
+/*++
+
+Routine Description:
+
+ Determines the new virtual address that is to be used on subsequent memory accesses.
+
+Arguments:
+
+ DebugDisposition - Supplies type information for the pointer being converted.
+ Address - A pointer to a pointer that is to be fixed to be the value needed
+ for the new virtual address mappings being applied.
+
+Returns:
+
+ Status code
+
+--*/
+{
+ return mRT->ConvertPointer (DebugDisposition, Address);
+}
+
+EFI_STATUS
+EfiConvertInternalPointer (
+ IN OUT VOID *Address
+ )
+/*++
+
+Routine Description:
+
+ Call EfiConvertPointer() to convert internal pointer.
+
+Arguments:
+
+ Address - A pointer to a pointer that is to be fixed to be the value needed
+ for the new virtual address mappings being applied.
+
+Returns:
+
+ Status code
+
+--*/
+{
+ return EfiConvertPointer (0x0, Address);
+}
+
+EFI_STATUS
+EfiConvertList (
+ IN UINTN DebugDisposition,
+ IN OUT LIST_ENTRY *ListHead
+ )
+/*++
+
+Routine Description:
+
+ Conver the standard Lib double linked list to a virtual mapping.
+
+Arguments:
+
+ DebugDisposition - Argument to EfiConvertPointer (EFI 1.0 API)
+
+ ListHead - Head of linked list to convert
+
+Returns:
+
+ EFI_SUCCESS
+
+--*/
+{
+ LIST_ENTRY *Link;
+ LIST_ENTRY *NextLink;
+
+ //
+ // Convert all the ForwardLink & BackLink pointers in the list
+ //
+ Link = ListHead;
+ do {
+ NextLink = Link->ForwardLink;
+
+ EfiConvertPointer (
+ Link->ForwardLink == ListHead ? DebugDisposition : 0,
+ (VOID **) &Link->ForwardLink
+ );
+
+ EfiConvertPointer (
+ Link->BackLink == ListHead ? DebugDisposition : 0,
+ (VOID **) &Link->BackLink
+ );
+
+ Link = NextLink;
+ } while (Link != ListHead);
+ return EFI_SUCCESS;
+}
+
+
+/**
+ Change the runtime addressing mode of EFI firmware from physical to virtual.
+
+ @param MemoryMapSize The size in bytes of VirtualMap.
+ @param DescriptorSize The size in bytes of an entry in the VirtualMap.
+ @param DescriptorVersion The version of the structure entries in VirtualMap.
+ @param VirtualMap An array of memory descriptors which contain new virtual
+ address mapping information for all runtime ranges. Type
+ EFI_MEMORY_DESCRIPTOR is defined in the
+ GetMemoryMap() function description.
+
+ @retval EFI_SUCCESS The virtual address map has been applied.
+ @retval EFI_UNSUPPORTED EFI firmware is not at runtime, or the EFI firmware is already in
+ virtual address mapped mode.
+ @retval EFI_INVALID_PARAMETER DescriptorSize or DescriptorVersion is
+ invalid.
+ @retval EFI_NO_MAPPING A virtual address was not supplied for a range in the memory
+ map that requires a mapping.
+ @retval EFI_NOT_FOUND A virtual address was supplied for an address that is not found
+ in the memory map.
+**/
+EFI_STATUS
+EFIAPI
+EfiSetVirtualAddressMap (
+ IN UINTN MemoryMapSize,
+ IN UINTN DescriptorSize,
+ IN UINT32 DescriptorVersion,
+ IN CONST EFI_MEMORY_DESCRIPTOR *VirtualMap
+ )
+{
+ return mRT->SetVirtualAddressMap (
+ MemoryMapSize,
+ DescriptorSize,
+ DescriptorVersion,
+ (EFI_MEMORY_DESCRIPTOR *) VirtualMap
+ );
+}
+
+
+EFI_STATUS
+EfiUpdateCapsule (
+ IN UEFI_CAPSULE_HEADER **CapsuleHeaderArray,
+ IN UINTN CapsuleCount,
+ IN EFI_PHYSICAL_ADDRESS ScatterGatherList OPTIONAL
+ )
+{
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+ return mRT->UpdateCapsule (
+ CapsuleHeaderArray,
+ CapsuleCount,
+ ScatterGatherList
+ );
+#else
+ return EFI_UNSUPPORTED;
+#endif
+}
+
+EFI_STATUS
+EfiQueryCapsuleCapabilities (
+ IN UEFI_CAPSULE_HEADER **CapsuleHeaderArray,
+ IN UINTN CapsuleCount,
+ OUT UINT64 *MaximumCapsuleSize,
+ OUT EFI_RESET_TYPE *ResetType
+ )
+{
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+ return mRT->QueryCapsuleCapabilities (
+ CapsuleHeaderArray,
+ CapsuleCount,
+ MaximumCapsuleSize,
+ ResetType
+ );
+#else
+ return EFI_UNSUPPORTED;
+#endif
+}
+
+
+EFI_STATUS
+EfiQueryVariableInfo (
+ IN UINT32 Attributes,
+ OUT UINT64 *MaximumVariableStorageSize,
+ OUT UINT64 *RemainingVariableStorageSize,
+ OUT UINT64 *MaximumVariableSize
+ )
+{
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+ return mRT->QueryVariableInfo (
+ Attributes,
+ MaximumVariableStorageSize,
+ RemainingVariableStorageSize,
+ MaximumVariableSize
+ );
+#else
+ return EFI_UNSUPPORTED;
+#endif
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/EdkDxeRuntimeDriverLib.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/EdkDxeRuntimeDriverLib.inf
new file mode 100644
index 0000000..170d1ae
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/EdkDxeRuntimeDriverLib.inf
@@ -0,0 +1,83 @@
+#/*++
+#
+# Copyright (c) 2004 - 2006, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# EdkDxeRuntimeDriverLib.inf
+#
+# Abstract:
+#
+# Component description file for EdkDxeRuntimeDriverLib.
+#
+#--*/
+
+[defines]
+BASE_NAME = EdkIIGlueEdkDxeRuntimeDriverLib
+COMPONENT_TYPE = LIBRARY
+
+[sources.common]
+ Common\RuntimeLib.c
+ Common\RuntimeService.c
+
+[sources.ia32]
+
+[sources.x64]
+
+[sources.ipf]
+
+[sources.ebc]
+
+
+[includes.common]
+ .
+ ..\..\Include
+ ..\..\include\Library
+ $(EDK_SOURCE)\Foundation
+ $(EDK_SOURCE)\Foundation\Framework
+ $(EDK_SOURCE)\Foundation\Efi
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+ $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include
+ $(EDK_SOURCE)\Foundation\Framework\Guid\DataHubRecords
+ $(EDK_SOURCE)\Foundation\Framework\Guid\StatusCodeDataTypeId
+
+[libraries.common]
+ EdkIIGlueUefiLib
+ EdkIIGlueBaseLib
+ EdkIIGlueUefiBootServicesTableLib
+#
+# R8.x Library
+#
+ EfiProtocolLib
+
+[libraries.ia32]
+
+[libraries.x64]
+
+[nmake.common]
+ C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION
+ LIB_STD_FLAGS = /NOLOGO /IGNORE:4006
+
+[nmake.ia32]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32
+
+[nmake.x64]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64
+
+[nmake.ipf]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF
+
+[nmake.ebc]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/EdkIIGlueEdkDxeRuntimeDriverLib.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/EdkIIGlueEdkDxeRuntimeDriverLib.cif
new file mode 100644
index 0000000..ed2fd0e
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/EdkIIGlueEdkDxeRuntimeDriverLib.cif
@@ -0,0 +1,13 @@
+<component>
+ name = "EdkIIGlueEdkDxeRuntimeDriverLib"
+ category = ModulePart
+ LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\EdkDxeRuntimeDriverLib"
+ RefName = "EdkIIGlueEdkDxeRuntimeDriverLib"
+[files]
+"EdkIIGlueEdkDxeRuntimeDriverLib.sdl"
+"EdkIIGlueEdkDxeRuntimeDriverLib.mak"
+"EdkDxeRuntimeDriverLib.inf"
+"Common\RuntimeLib.c"
+"Common\RuntimeService.c"
+"RuntimeLibInternal.h"
+<endComponent>
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/EdkIIGlueEdkDxeRuntimeDriverLib.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/EdkIIGlueEdkDxeRuntimeDriverLib.mak
new file mode 100644
index 0000000..1811347
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/EdkIIGlueEdkDxeRuntimeDriverLib.mak
@@ -0,0 +1,103 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueEdkDxeRuntimeDriverLib/EdkIIGlueEdkDxeRuntimeDriverLib.mak 1 1/20/12 3:56a Jeffch $
+#
+# $Revision: 1 $
+#
+# $Date: 1/20/12 3:56a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueEdkDxeRuntimeDriverLib/EdkIIGlueEdkDxeRuntimeDriverLib.mak $
+#
+# 1 1/20/12 3:56a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 9/27/11 6:18a Wesleychen
+# Intel EDK initially releases.
+#
+# 1 9/18/09 1:55a Iminglin
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: EdkIIGlueEdkDxeRuntimeDriverLib.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+
+
+EdkIIGlueEdkDxeRuntimeDriverLib_OBJECTS=
+
+!IF "$(PROCESSOR)"=="IA32" || "$(PROCESSOR)"=="x64" || "$(PROCESSOR)"=="EBC"
+EdkIIGlueEdkDxeRuntimeDriverLib_OBJECTS=$(EdkIIGlueEdkDxeRuntimeDriverLib_OBJECTS)\
+$$(BUILD_DIR)\$(EdkIIGlueEdkDxeRuntimeDriverLib_DIR)\Common\RuntimeLib.obj\
+$$(BUILD_DIR)\$(EdkIIGlueEdkDxeRuntimeDriverLib_DIR)\Common\RuntimeService.obj
+!ELSEIF "$(PROCESSOR)"=="IPF"
+EdkIIGlueEdkDxeRuntimeDriverLib_OBJECTS=$(EdkIIGlueEdkDxeRuntimeDriverLib_OBJECTS)\
+$$(BUILD_DIR)\$(EdkIIGlueEdkDxeRuntimeDriverLib_DIR)\Ipf\RuntimeLib.obj\
+$$(BUILD_DIR)\$(EdkIIGlueEdkDxeRuntimeDriverLib_DIR)\Ipf\RuntimeService.obj
+!ENDIF
+
+$(EdkIIGlueEdkDxeRuntimeDriverLib_LIB) : EdkIIGlueEdkDxeRuntimeDriverLib
+
+EdkIIGlueEdkDxeRuntimeDriverLib : $(BUILD_DIR)\EdkIIGlueEdkDxeRuntimeDriverLib.mak EdkIIGlueEdkDxeRuntimeDriverLibBin
+
+$(BUILD_DIR)\EdkIIGlueEdkDxeRuntimeDriverLib.mak : $(EdkIIGlueEdkDxeRuntimeDriverLib_DIR)\$(@B).cif $(EdkIIGlueEdkDxeRuntimeDriverLib_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(EdkIIGlueEdkDxeRuntimeDriverLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+EdkIIGlueEdkDxeRuntimeDriverLib_LIB_LINKS=$(EdkIIGlueUefiLib_LIB)\
+$(EdkIIGlueBaseLib_LIB)\
+$(EdkIIGlueUefiBootServicesTableLib_LIB)\
+$(EFIPROTOCOLLIB)\
+!IF "$(PROCESSOR)"=="IPF"
+$(EdkIIGlueEdkDxeSalLib_LIB)
+!ENDIF
+
+EdkIIGlueEdkDxeRuntimeDriverLibBin : $(EdkIIGlueEdkDxeRuntimeDriverLib_LIB_LINKS)
+!IF "$(x64_BUILD)"=="1"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGlueEdkDxeRuntimeDriverLib.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueEdkDxeRuntimeDriverLib_LIB)"\
+ "OBJECTS=$(EdkIIGlueEdkDxeRuntimeDriverLib_OBJECTS)"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\IA32\
+ /f $(BUILD_DIR)\EdkIIGlueEdkDxeRuntimeDriverLib.mak all\
+ TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueEdkDxeRuntimeDriverLib_LIB)"\
+ "OBJECTS=$(EdkIIGlueEdkDxeRuntimeDriverLib_OBJECTS)"
+!ELSE
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGlueEdkDxeRuntimeDriverLib.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueEdkDxeRuntimeDriverLib_LIB)"\
+ "OBJECTS=$(EdkIIGlueEdkDxeRuntimeDriverLib_OBJECTS)"
+!ENDIF
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/EdkIIGlueEdkDxeRuntimeDriverLib.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/EdkIIGlueEdkDxeRuntimeDriverLib.sdl
new file mode 100644
index 0000000..c42a416
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/EdkIIGlueEdkDxeRuntimeDriverLib.sdl
@@ -0,0 +1,26 @@
+TOKEN
+ Name = "EdkIIGlueEdkDxeRuntimeDriverLib_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable EdkIIGlueEdkDxeRuntimeDriverLib support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "EdkIIGlueEdkDxeRuntimeDriverLib_LIB"
+ Value = "$$(LIB_BUILD_DIR)\EdkIIGlueEdkDxeRuntimeDriverLib.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "EdkIIGlueEdkDxeRuntimeDriverLib_DIR"
+End
+
+MODULE
+ Help = "Includes EdkIIGlueEdkDxeRuntimeDriverLib.mak to Project"
+ File = "EdkIIGlueEdkDxeRuntimeDriverLib.mak"
+End
+
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/RuntimeLibInternal.h b/EDK/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/RuntimeLibInternal.h
new file mode 100644
index 0000000..3f37861
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/EdkDxeRuntimeDriverLib/RuntimeLibInternal.h
@@ -0,0 +1,35 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ RuntimeLibInternal.h
+
+Abstract:
+
+ Runtime Lib internal header file
+
+--*/
+
+#ifndef __RUNTIMELIBINTERNAL_H__
+#define __RUNTIMELIBINTERNAL_H__
+
+#include "EdkIIGlueDxe.h"
+
+EFI_STATUS
+EfiConvertInternalPointer (
+ IN OUT VOID *Address
+ );
+
+extern EFI_RUNTIME_SERVICES *mRT;
+
+#endif //__RUNTIMELIBINTERNAL_H__
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/HiiLib/EdkIIGlueHiiLib.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/HiiLib/EdkIIGlueHiiLib.cif
new file mode 100644
index 0000000..0eef635
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/HiiLib/EdkIIGlueHiiLib.cif
@@ -0,0 +1,11 @@
+<component>
+ name = "EdkIIGlueHiiLib"
+ category = ModulePart
+ LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\HiiLib"
+ RefName = "EdkIIGlueHiiLib"
+[files]
+"EdkIIGlueHiiLib.sdl"
+"EdkIIGlueHiiLib.mak"
+"HiiLib.inf"
+"HiiLib.c"
+<endComponent>
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/HiiLib/EdkIIGlueHiiLib.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/HiiLib/EdkIIGlueHiiLib.mak
new file mode 100644
index 0000000..a69c5c4
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/HiiLib/EdkIIGlueHiiLib.mak
@@ -0,0 +1,80 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueHiiLib/EdkIIGlueHiiLib.mak 1 1/20/12 3:56a Jeffch $
+#
+# $Revision: 1 $
+#
+# $Date: 1/20/12 3:56a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueHiiLib/EdkIIGlueHiiLib.mak $
+#
+# 1 1/20/12 3:56a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 9/27/11 6:18a Wesleychen
+# Intel EDK initially releases.
+#
+# 1 9/18/09 1:56a Iminglin
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: EdkIIGlueHiiLib.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+
+
+$(EdkIIGlueHiiLib_LIB) : EdkIIGlueHiiLib
+
+EdkIIGlueHiiLib : $(BUILD_DIR)\EdkIIGlueHiiLib.mak EdkIIGlueHiiLibBin
+
+$(BUILD_DIR)\EdkIIGlueHiiLib.mak : $(EdkIIGlueHiiLib_DIR)\$(@B).cif $(EdkIIGlueHiiLib_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(EdkIIGlueHiiLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+EdkIIGlueHiiLibBin : $(EdkIIGlueDxeMemoryAllocationLib_LIB) $(EFIPROTOCOLLIB)
+!IF "$(x64_BUILD)"=="1"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGlueHiiLib.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueHiiLib_LIB)"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\IA32\
+ /f $(BUILD_DIR)\EdkIIGlueHiiLib.mak all\
+ TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueHiiLib_LIB)"
+!ELSE
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGlueHiiLib.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueHiiLib_LIB)"
+!ENDIF
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#********************************************************************** \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/HiiLib/EdkIIGlueHiiLib.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/HiiLib/EdkIIGlueHiiLib.sdl
new file mode 100644
index 0000000..31c6c1d
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/HiiLib/EdkIIGlueHiiLib.sdl
@@ -0,0 +1,26 @@
+TOKEN
+ Name = "EdkIIGlueHiiLib_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable EdkIIGlueHiiLib support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "EdkIIGlueHiiLib_LIB"
+ Value = "$$(LIB_BUILD_DIR)\EdkIIGlueHiiLib.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "EdkIIGlueHiiLib_DIR"
+End
+
+MODULE
+ Help = "Includes EdkIIGlueHiiLib.mak to Project"
+ File = "EdkIIGlueHiiLib.mak"
+End
+
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/HiiLib/HiiLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/HiiLib/HiiLib.c
new file mode 100644
index 0000000..3424d91
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/HiiLib/HiiLib.c
@@ -0,0 +1,75 @@
+/*++
+
+Copyright (c) 2004 - 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ HiiLib.c
+
+Abstract:
+
+ HII Library implementation that uses DXE protocols and services.
+
+--*/
+
+#include "EdkIIGlueDxe.h"
+
+#if (EFI_SPECIFICATION_VERSION < 0x0002000A)
+/**
+ This function allocates pool for an EFI_HII_PACKAGES structure
+ with enough space for the variable argument list of package pointers.
+ The allocated structure is initialized using NumberOfPackages, Guid,
+ and the variable length argument list of package pointers.
+
+ @param NumberOfPackages The number of HII packages to prepare.
+ @param Guid Package GUID.
+
+ @return The allocated and initialized packages.
+
+**/
+EFI_HII_PACKAGES *
+EFIAPI
+GluePreparePackages (
+ IN UINTN NumberOfPackages,
+ IN CONST EFI_GUID *Guid OPTIONAL,
+ ...
+ )
+{
+ VA_LIST Args;
+ EFI_HII_PACKAGES *HiiPackages;
+ VOID **Package;
+ UINTN Index;
+
+ ASSERT (NumberOfPackages > 0);
+
+ HiiPackages = AllocateZeroPool (sizeof (EFI_HII_PACKAGES) + NumberOfPackages * sizeof (VOID *));
+ ASSERT (HiiPackages != NULL);
+ if (HiiPackages == NULL) {
+ return HiiPackages;
+ }
+
+ HiiPackages->GuidId = (EFI_GUID *) Guid;
+ HiiPackages->NumberOfPackages = NumberOfPackages;
+ Package = (VOID **) (((UINT8 *) HiiPackages) + sizeof (EFI_HII_PACKAGES));
+
+ VA_START (Args, Guid);
+
+ for (Index = 0; Index < NumberOfPackages; Index++) {
+ *Package = VA_ARG (Args, VOID *);
+ Package++;
+ }
+
+ VA_END (Args);
+
+ return HiiPackages;
+
+}
+#endif
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/HiiLib/HiiLib.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/HiiLib/HiiLib.inf
new file mode 100644
index 0000000..8e57c64
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/HiiLib/HiiLib.inf
@@ -0,0 +1,77 @@
+#/*++
+#
+# Copyright (c) 2004 - 2006, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# HiiLib.inf
+#
+# Abstract:
+#
+# Component description file for HiiLib.
+#
+#--*/
+
+[defines]
+BASE_NAME = EdkIIGlueHiiLib
+COMPONENT_TYPE = LIBRARY
+
+[sources.common]
+ HiiLib.c
+
+[sources.ia32]
+
+[sources.x64]
+
+[sources.ipf]
+
+[sources.ebc]
+
+
+[includes.common]
+ .
+ ..\..\Include
+ ..\..\include\Library
+ $(EDK_SOURCE)\Foundation
+ $(EDK_SOURCE)\Foundation\Framework
+ $(EDK_SOURCE)\Foundation\Framework\Protocol\Hii
+ $(EDK_SOURCE)\Foundation\Efi
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+ $(EDK_SOURCE)\Foundation\Library\Dxe\EfiIfrSupportLib
+ $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include
+
+[libraries.common]
+ EdkIIGlueDxeMemoryAllocationLib
+ EfiProtocolLib
+
+[libraries.ia32]
+
+[libraries.x64]
+
+[nmake.common]
+ C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION
+ LIB_STD_FLAGS = /NOLOGO /IGNORE:4006
+
+[nmake.ia32]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32
+
+[nmake.x64]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64
+
+[nmake.ipf]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF
+
+[nmake.ebc]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDebugLibReportStatusCode/DebugLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDebugLibReportStatusCode/DebugLib.c
new file mode 100644
index 0000000..ac846dc
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDebugLibReportStatusCode/DebugLib.c
@@ -0,0 +1,336 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ DebugLib.c
+
+Abstract:
+
+ Debug Library that fowards all messages to ReportStatusCode()
+
+--*/
+
+#include "EdkIIGluePeim.h"
+#include EFI_PPI_CONSUMER (DebugMask)
+#include "Pcd\EdkIIGluePcdDebugLib.h"
+
+/**
+
+ Gets the error level.
+
+ If DebugMaskInterface is not NULL, return the error level from DebugMaskInterface.
+
+ If DebugMaskInterface is NULL, return the default define DebugPrintErrorLevel error level.
+
+ @retval Debug Message Error Level
+
+**/
+UINTN
+EFIAPI
+EdkIIGlueGetDebugPrintErrorLevel (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ EFI_DEBUG_MASK_PPI *DebugMaskPpi;
+ EFI_PEI_SERVICES **PeiServices;
+
+ PeiServices = GetPeiServicesTablePointer ();
+ //
+ // Locate the Debug Mask PPI.
+ //
+ Status = (*PeiServices)->LocatePpi (
+ PeiServices,
+ &gEfiDebugMaskPpiGuid,
+ 0,
+ NULL,
+ &DebugMaskPpi
+ );
+
+ //
+ // Check driver debug mask value and global mask
+ //
+ if (!EFI_ERROR (Status)) {
+ return DebugMaskPpi->ImageDebugMask;
+ }
+ return EDKII_GLUE_DebugPrintErrorLevel;
+}
+
+/**
+
+ Prints a debug message to the debug output device if the specified error level is enabled.
+
+ If any bit in ErrorLevel is also set in PcdDebugPrintErrorLevel, then print
+ the message specified by Format and the associated variable argument list to
+ the debug output device.
+
+ If Format is NULL, then ASSERT().
+
+ @param ErrorLevel The error level of the debug message.
+ @param Format Format string for the debug message to print.
+
+**/
+VOID
+EFIAPI
+DebugPrint (
+ IN UINTN ErrorLevel,
+ IN CONST CHAR8 *Format,
+ ...
+ )
+{
+ UINT64 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE / sizeof (UINT64)];
+ EFI_DEBUG_INFO *DebugInfo;
+ UINTN TotalSize;
+ UINTN Index;
+ VA_LIST Marker;
+ UINT64 *ArgumentPointer;
+
+ //
+ // If Format is NULL, then ASSERT().
+ //
+ ASSERT (Format != NULL);
+
+ //
+ // Check driver Debug Level value and global debug level
+ //
+ if ((ErrorLevel & PcdGet32(PcdDebugPrintErrorLevel)) == 0) {
+ return;
+ }
+
+ TotalSize = sizeof (EFI_DEBUG_INFO) + 12 * sizeof (UINT64) + AsciiStrLen (Format) + 1;
+ if (TotalSize > EFI_STATUS_CODE_DATA_MAX_SIZE) {
+ return;
+ }
+
+ //
+ // Then EFI_DEBUG_INFO
+ //
+ DebugInfo = (EFI_DEBUG_INFO *)Buffer;
+ DebugInfo->ErrorLevel = (UINT32)ErrorLevel;
+
+ //
+ // 256 byte mini Var Arg stack. That is followed by the format string.
+ //
+ VA_START (Marker, Format);
+ for (Index = 0, ArgumentPointer = (UINT64 *)(DebugInfo + 1); Index < 12; Index++, ArgumentPointer++) {
+ *ArgumentPointer = VA_ARG (Marker, UINT64);
+ }
+ VA_END (Marker);
+ AsciiStrCpy ((CHAR8 *)ArgumentPointer, Format);
+
+ REPORT_STATUS_CODE_EX (
+ EFI_DEBUG_CODE,
+ (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_DC_UNSPECIFIED),
+ 0,
+ NULL,
+ &gEfiStatusCodeDataTypeDebugGuid,
+ DebugInfo,
+ TotalSize
+ );
+}
+
+
+/**
+
+ Prints an assert message containing a filename, line number, and description.
+ This may be followed by a breakpoint or a dead loop.
+
+ Print a message of the form "ASSERT <FileName>(<LineNumber>): <Description>\n"
+ to the debug output device. If DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED bit of
+ PcdDebugProperyMask is set then CpuBreakpoint() is called. Otherwise, if
+ DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED bit of PcdDebugProperyMask is set then
+ CpuDeadLoop() is called. If neither of these bits are set, then this function
+ returns immediately after the message is printed to the debug output device.
+ DebugAssert() must actively prevent recusrsion. If DebugAssert() is called while
+ processing another DebugAssert(), then DebugAssert() must return immediately.
+
+ If FileName is NULL, then a <FileName> string of "(NULL) Filename" is printed.
+
+ If Description is NULL, then a <Description> string of "(NULL) Description" is printed.
+
+ @param FileName Pointer to the name of the source file that generated the assert condition.
+ @param LineNumber The line number in the source file that generated the assert condition
+ @param Description Pointer to the description of the assert condition.
+
+**/
+VOID
+EFIAPI
+DebugAssert (
+ IN CONST CHAR8 *FileName,
+ IN UINTN LineNumber,
+ IN CONST CHAR8 *Description
+ )
+{
+ UINT64 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE / sizeof(UINT64)];
+ EFI_DEBUG_ASSERT_DATA *AssertData;
+ UINTN TotalSize;
+ CHAR8 *Temp;
+
+ //
+ // Make sure it will all fit in the passed in buffer
+ //
+ TotalSize = sizeof (EFI_DEBUG_ASSERT_DATA) + AsciiStrLen (FileName) + 1 + AsciiStrLen (Description) + 1;
+ if (TotalSize <= EFI_STATUS_CODE_DATA_MAX_SIZE) {
+ //
+ // Fill in EFI_DEBUG_ASSERT_DATA
+ //
+ AssertData = (EFI_DEBUG_ASSERT_DATA *)Buffer;
+ AssertData->LineNumber = (UINT32)LineNumber;
+
+ //
+ // Copy Ascii FileName including NULL.
+ //
+ Temp = AsciiStrCpy ((CHAR8 *)(AssertData + 1), FileName);
+
+ //
+ // Copy Ascii Description
+ //
+ AsciiStrCpy (Temp + AsciiStrLen (FileName) + 1, Description);
+
+ REPORT_STATUS_CODE_WITH_EXTENDED_DATA (
+ (EFI_ERROR_CODE | EFI_ERROR_UNRECOVERED),
+ (EFI_SOFTWARE_DXE_BS_DRIVER | EFI_SW_EC_ILLEGAL_SOFTWARE_STATE),
+ AssertData,
+ TotalSize
+ );
+ }
+
+ //
+ // Generate a Breakpoint, DeadLoop, or NOP based on PCD settings
+ //
+ if ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_ASSERT_BREAKPOINT_ENABLED) != 0) {
+ CpuBreakpoint ();
+ } else if ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_ASSERT_DEADLOOP_ENABLED) != 0) {
+ CpuDeadLoop ();
+ }
+}
+
+
+/**
+
+ Fills a target buffer with PcdDebugClearMemoryValue, and returns the target buffer.
+
+ This function fills Length bytes of Buffer with the value specified by
+ PcdDebugClearMemoryValue, and returns Buffer.
+
+ If Buffer is NULL, then ASSERT().
+
+ If Length is greater than (MAX_ADDRESS ?Buffer + 1), then ASSERT().
+
+ @param Buffer Pointer to the target buffer to fill with PcdDebugClearMemoryValue.
+ @param Length Number of bytes in Buffer to fill with zeros PcdDebugClearMemoryValue.
+
+ @return Buffer
+
+**/
+VOID *
+EFIAPI
+DebugClearMemory (
+ OUT VOID *Buffer,
+ IN UINTN Length
+ )
+{
+ //
+ // If Buffer is NULL, then ASSERT().
+ //
+ ASSERT (Buffer != NULL);
+
+ //
+ // SetMem() checks for the the ASSERT() condition on Length and returns Buffer
+ //
+ return SetMem (Buffer, Length, PcdGet8(PcdDebugClearMemoryValue));
+}
+
+
+/**
+
+ Returns TRUE if ASSERT() macros are enabled.
+
+ This function returns TRUE if the DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of
+ PcdDebugProperyMask is set. Otherwise FALSE is returned.
+
+ @retval TRUE The DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is set.
+ @retval FALSE The DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED bit of PcdDebugProperyMask is clear.
+
+**/
+BOOLEAN
+EFIAPI
+DebugAssertEnabled (
+ VOID
+ )
+{
+ return ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_ASSERT_ENABLED) != 0);
+}
+
+
+/**
+
+ Returns TRUE if DEBUG()macros are enabled.
+
+ This function returns TRUE if the DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of
+ PcdDebugProperyMask is set. Otherwise FALSE is returned.
+
+ @retval TRUE The DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of PcdDebugProperyMask is set.
+ @retval FALSE The DEBUG_PROPERTY_DEBUG_PRINT_ENABLED bit of PcdDebugProperyMask is clear.
+
+**/
+BOOLEAN
+EFIAPI
+DebugPrintEnabled (
+ VOID
+ )
+{
+ return ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_PRINT_ENABLED) != 0);
+}
+
+
+/**
+
+ Returns TRUE if DEBUG_CODE()macros are enabled.
+
+ This function returns TRUE if the DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of
+ PcdDebugProperyMask is set. Otherwise FALSE is returned.
+
+ @retval TRUE The DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is set.
+ @retval FALSE The DEBUG_PROPERTY_DEBUG_CODE_ENABLED bit of PcdDebugProperyMask is clear.
+
+**/
+BOOLEAN
+EFIAPI
+DebugCodeEnabled (
+ VOID
+ )
+{
+ return ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_DEBUG_CODE_ENABLED) != 0);
+}
+
+
+/**
+
+ Returns TRUE if DEBUG_CLEAR_MEMORY()macro is enabled.
+
+ This function returns TRUE if the DEBUG_PROPERTY_DEBUG_CLEAR_MEMORY_ENABLED bit of
+ PcdDebugProperyMask is set. Otherwise FALSE is returned.
+
+ @retval TRUE The DEBUG_PROPERTY_DEBUG_CLEAR_MEMORY_ENABLED bit of PcdDebugProperyMask is set.
+ @retval FALSE The DEBUG_PROPERTY_DEBUG_CLEAR_MEMORY_ENABLED bit of PcdDebugProperyMask is clear.
+
+**/
+BOOLEAN
+EFIAPI
+DebugClearMemoryEnabled (
+ VOID
+ )
+{
+ return ((PcdGet8(PcdDebugPropertyMask) & DEBUG_PROPERTY_CLEAR_MEMORY_ENABLED) != 0);
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDebugLibReportStatusCode/EdkIIGluePeiDebugLibReportStatusCode.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDebugLibReportStatusCode/EdkIIGluePeiDebugLibReportStatusCode.cif
new file mode 100644
index 0000000..1022964
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDebugLibReportStatusCode/EdkIIGluePeiDebugLibReportStatusCode.cif
@@ -0,0 +1,11 @@
+<component>
+ name = "EdkIIGluePeiDebugLibReportStatusCode"
+ category = ModulePart
+ LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\PeiDebugLibReportStatusCode"
+ RefName = "EdkIIGluePeiDebugLibReportStatusCode"
+[files]
+"EdkIIGluePeiDebugLibReportStatusCode.sdl"
+"EdkIIGluePeiDebugLibReportStatusCode.mak"
+"PeiDebugLibReportStatusCode.inf"
+"DebugLib.c"
+<endComponent>
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDebugLibReportStatusCode/EdkIIGluePeiDebugLibReportStatusCode.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDebugLibReportStatusCode/EdkIIGluePeiDebugLibReportStatusCode.mak
new file mode 100644
index 0000000..1eeb2cb
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDebugLibReportStatusCode/EdkIIGluePeiDebugLibReportStatusCode.mak
@@ -0,0 +1,80 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGluePeiDebugLibReportStatusCode/EdkIIGluePeiDebugLibReportStatusCode.mak 1 1/20/12 3:56a Jeffch $
+#
+# $Revision: 1 $
+#
+# $Date: 1/20/12 3:56a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGluePeiDebugLibReportStatusCode/EdkIIGluePeiDebugLibReportStatusCode.mak $
+#
+# 1 1/20/12 3:56a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 9/27/11 6:18a Wesleychen
+# Intel EDK initially releases.
+#
+# 1 9/18/09 1:56a Iminglin
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: EdkIIGluePeiDebugLibReportStatusCode.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+
+
+$(EdkIIGluePeiDebugLibReportStatusCode_LIB) : EdkIIGluePeiDebugLibReportStatusCode
+
+EdkIIGluePeiDebugLibReportStatusCode : $(BUILD_DIR)\EdkIIGluePeiDebugLibReportStatusCode.mak EdkIIGluePeiDebugLibReportStatusCodeBin
+
+$(BUILD_DIR)\EdkIIGluePeiDebugLibReportStatusCode.mak : $(EdkIIGluePeiDebugLibReportStatusCode_DIR)\$(@B).cif $(EdkIIGluePeiDebugLibReportStatusCode_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(EdkIIGluePeiDebugLibReportStatusCode_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+EdkIIGluePeiDebugLibReportStatusCodeBin : $(EdkIIGlueBaseLib_LIB) $(EdkIIGlueBaseMemoryLib_LIB) $(EDKFRAMEWORKGUIDLIB) $(EFIPROTOCOLLIB) $(EDKPPILIB)
+!IF "$(x64_BUILD)"=="1"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGluePeiDebugLibReportStatusCode.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGluePeiDebugLibReportStatusCode_LIB)"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\IA32\
+ /f $(BUILD_DIR)\EdkIIGluePeiDebugLibReportStatusCode.mak all\
+ TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGluePeiDebugLibReportStatusCode_LIB)"
+!ELSE
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGluePeiDebugLibReportStatusCode.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGluePeiDebugLibReportStatusCode_LIB)"
+!ENDIF
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDebugLibReportStatusCode/EdkIIGluePeiDebugLibReportStatusCode.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDebugLibReportStatusCode/EdkIIGluePeiDebugLibReportStatusCode.sdl
new file mode 100644
index 0000000..fe8a1e9
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDebugLibReportStatusCode/EdkIIGluePeiDebugLibReportStatusCode.sdl
@@ -0,0 +1,26 @@
+TOKEN
+ Name = "EdkIIGluePeiDebugLibReportStatusCode_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable EdkIIGluePeiDebugLibReportStatusCode support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "EdkIIGluePeiDebugLibReportStatusCode_LIB"
+ Value = "$$(LIB_BUILD_DIR)\EdkIIGluePeiDebugLibReportStatusCode.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "EdkIIGluePeiDebugLibReportStatusCode_DIR"
+End
+
+MODULE
+ Help = "Includes EdkIIGluePeiDebugLibReportStatusCode.mak to Project"
+ File = "EdkIIGluePeiDebugLibReportStatusCode.mak"
+End
+
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDebugLibReportStatusCode/PeiDebugLibReportStatusCode.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDebugLibReportStatusCode/PeiDebugLibReportStatusCode.inf
new file mode 100644
index 0000000..8ec6663
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDebugLibReportStatusCode/PeiDebugLibReportStatusCode.inf
@@ -0,0 +1,90 @@
+#/*++
+#
+# Copyright (c) 2004 - 2006, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# PeiDebugLibReportStatusCode.inf
+#
+# Abstract:
+#
+# Component description file for PeiDebugLibReportStatusCode.
+#
+#--*/
+
+[defines]
+BASE_NAME = EdkIIGluePeiDebugLibReportStatusCode
+COMPONENT_TYPE = LIBRARY
+
+[sources.common]
+ DebugLib.c
+
+[sources.ia32]
+
+[sources.x64]
+
+[sources.ipf]
+
+[sources.ebc]
+
+
+[includes.common]
+ .
+ ..\..\Include
+ ..\..\include\Library
+ $(EDK_SOURCE)\Foundation
+ $(EDK_SOURCE)\Foundation\Framework
+ $(EDK_SOURCE)\Foundation\Framework\Protocol\Hii
+ $(EDK_SOURCE)\Foundation\Efi
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+ $(EDK_SOURCE)\Foundation\Library\Dxe\EfiIfrSupportLib
+ $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include
+ $(EDK_SOURCE)\Foundation\Include\Pei
+
+[libraries.common]
+ EdkIIGlueBaseLib
+ EdkIIGlueBaseMemoryLib
+#
+# R8.x
+#
+ EdkFrameworkGuidLib
+ EfiProtocolLib
+ EdkPpiLib
+#
+#
+# An user must specify a PEI or DXE ReportStatusCodeLib instance in module's .inf
+#
+
+[libraries.ia32]
+
+
+[libraries.x64]
+
+
+[nmake.common]
+ C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION
+ LIB_STD_FLAGS = /NOLOGO /IGNORE:4006
+
+[nmake.ia32]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32
+
+[nmake.x64]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64
+
+[nmake.ipf]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF
+
+[nmake.ebc]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDxePostCodeLibReportStatusCode/EdkIIGluePeiDxePostCodeLibReportStatusCode.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDxePostCodeLibReportStatusCode/EdkIIGluePeiDxePostCodeLibReportStatusCode.cif
new file mode 100644
index 0000000..ada48e4
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDxePostCodeLibReportStatusCode/EdkIIGluePeiDxePostCodeLibReportStatusCode.cif
@@ -0,0 +1,11 @@
+<component>
+ name = "EdkIIGluePeiDxePostCodeLibReportStatusCode"
+ category = ModulePart
+ LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\PeiDxePostCodeLibReportStatusCode"
+ RefName = "EdkIIGluePeiDxePostCodeLibReportStatusCode"
+[files]
+"EdkIIGluePeiDxePostCodeLibReportStatusCode.sdl"
+"EdkIIGluePeiDxePostCodeLibReportStatusCode.mak"
+"PeiDxePostCodeLibReportStatusCode.inf"
+"PostCode.c"
+<endComponent>
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDxePostCodeLibReportStatusCode/EdkIIGluePeiDxePostCodeLibReportStatusCode.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDxePostCodeLibReportStatusCode/EdkIIGluePeiDxePostCodeLibReportStatusCode.mak
new file mode 100644
index 0000000..92a03b3
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDxePostCodeLibReportStatusCode/EdkIIGluePeiDxePostCodeLibReportStatusCode.mak
@@ -0,0 +1,80 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGluePeiDxePostCodeLibReportStatusCode/EdkIIGluePeiDxePostCodeLibReportStatusCode.mak 1 1/20/12 3:56a Jeffch $
+#
+# $Revision: 1 $
+#
+# $Date: 1/20/12 3:56a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGluePeiDxePostCodeLibReportStatusCode/EdkIIGluePeiDxePostCodeLibReportStatusCode.mak $
+#
+# 1 1/20/12 3:56a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 9/27/11 6:18a Wesleychen
+# Intel EDK initially releases.
+#
+# 1 9/18/09 1:56a Iminglin
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: EdkIIGluePeiDxePostCodeLibReportStatusCode.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+
+
+$(EdkIIGluePeiDxePostCodeLibReportStatusCode_LIB) : EdkIIGluePeiDxePostCodeLibReportStatusCode
+
+EdkIIGluePeiDxePostCodeLibReportStatusCode : $(BUILD_DIR)\EdkIIGluePeiDxePostCodeLibReportStatusCode.mak EdkIIGluePeiDxePostCodeLibReportStatusCodeBin
+
+$(BUILD_DIR)\EdkIIGluePeiDxePostCodeLibReportStatusCode.mak : $(EdkIIGluePeiDxePostCodeLibReportStatusCode_DIR)\$(@B).cif $(EdkIIGluePeiDxePostCodeLibReportStatusCode_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(EdkIIGluePeiDxePostCodeLibReportStatusCode_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+EdkIIGluePeiDxePostCodeLibReportStatusCodeBin :
+!IF "$(x64_BUILD)"=="1"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGluePeiDxePostCodeLibReportStatusCode.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGluePeiDxePostCodeLibReportStatusCode_LIB)"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\IA32\
+ /f $(BUILD_DIR)\EdkIIGluePeiDxePostCodeLibReportStatusCode.mak all\
+ TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGluePeiDxePostCodeLibReportStatusCode_LIB)"
+!ELSE
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGluePeiDxePostCodeLibReportStatusCode.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGluePeiDxePostCodeLibReportStatusCode_LIB)"
+!ENDIF
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDxePostCodeLibReportStatusCode/EdkIIGluePeiDxePostCodeLibReportStatusCode.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDxePostCodeLibReportStatusCode/EdkIIGluePeiDxePostCodeLibReportStatusCode.sdl
new file mode 100644
index 0000000..386b4b6
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDxePostCodeLibReportStatusCode/EdkIIGluePeiDxePostCodeLibReportStatusCode.sdl
@@ -0,0 +1,26 @@
+TOKEN
+ Name = "EdkIIGluePeiDxePostCodeLibReportStatusCode_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable EdkIIGluePeiDxePostCodeLibReportStatusCode support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "EdkIIGluePeiDxePostCodeLibReportStatusCode_LIB"
+ Value = "$$(LIB_BUILD_DIR)\EdkIIGluePeiDxePostCodeLibReportStatusCode.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "EdkIIGluePeiDxePostCodeLibReportStatusCode_DIR"
+End
+
+MODULE
+ Help = "Includes EdkIIGluePeiDxePostCodeLibReportStatusCode.mak to Project"
+ File = "EdkIIGluePeiDxePostCodeLibReportStatusCode.mak"
+End
+
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDxePostCodeLibReportStatusCode/PeiDxePostCodeLibReportStatusCode.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDxePostCodeLibReportStatusCode/PeiDxePostCodeLibReportStatusCode.inf
new file mode 100644
index 0000000..8916894
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDxePostCodeLibReportStatusCode/PeiDxePostCodeLibReportStatusCode.inf
@@ -0,0 +1,81 @@
+#/*++
+#
+# Copyright (c) 2004 - 2006, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# PeiDxePostCodeLibReportStatusCode.inf
+#
+# Abstract:
+#
+# Component description file for PeiDxePostCodeLibReportStatusCode.
+#
+#--*/
+
+[defines]
+BASE_NAME = EdkIIGluePeiDxePostCodeLibReportStatusCode
+COMPONENT_TYPE = LIBRARY
+
+[sources.common]
+ PostCode.c
+
+[sources.ia32]
+
+[sources.x64]
+
+[sources.ipf]
+
+[sources.ebc]
+
+
+[includes.common]
+ .
+ ..\..\Include
+ ..\..\include\Library
+ $(EDK_SOURCE)\Foundation
+ $(EDK_SOURCE)\Foundation\Framework
+ $(EDK_SOURCE)\Foundation\Framework\Protocol\Hii
+ $(EDK_SOURCE)\Foundation\Efi
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+ $(EDK_SOURCE)\Foundation\Library\Dxe\EfiIfrSupportLib
+ $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include
+
+[libraries.common]
+#
+# An user must specify a PEI or DXE ReportStatusCodeLib instance in module's .inf
+#
+ EfiProtocolLib
+
+[libraries.ia32]
+
+
+[libraries.x64]
+
+
+[nmake.common]
+ C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION
+ LIB_STD_FLAGS = /NOLOGO /IGNORE:4006
+
+[nmake.ia32]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32
+
+[nmake.x64]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64
+
+[nmake.ipf]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF
+
+[nmake.ebc]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDxePostCodeLibReportStatusCode/PostCode.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDxePostCodeLibReportStatusCode/PostCode.c
new file mode 100644
index 0000000..6fcb711
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiDxePostCodeLibReportStatusCode/PostCode.c
@@ -0,0 +1,161 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ PostCode.c
+
+Abstract:
+
+ Post Code Lib
+
+--*/
+
+#include "EdkIIGlueDxe.h"
+#include "Pcd\EdkIIGluePcdPostCodeLib.h"
+
+/**
+ Converts POST code value to status code value.
+
+ This macro converts the post code to status code value. Bits 0..4 of PostCode
+ are mapped to bits 16..20 of status code value, and bits 5..7 of PostCode are mapped to bits
+ 24..26 of status code value.
+
+ @param PostCode POST code value.
+
+ @return The converted status code value.
+
+**/
+#define POST_CODE_TO_STATUS_CODE_VALUE(PostCode) \
+ ((EFI_STATUS_CODE_VALUE) (((PostCode & 0x1f) << 16) | ((PostCode & 0x3) << 19)))
+
+/**
+ Sends an 32-bit value to a POST card.
+
+ Sends the 32-bit value specified by Value to a POST card, and returns Value.
+ Some implementations of this library function may perform I/O operations
+ directly to a POST card device. Other implementations may send Value to
+ ReportStatusCode(), and the status code reporting mechanism will eventually
+ display the 32-bit value on the status reporting device.
+
+ PostCode() must actively prevent recursion. If PostCode() is called while
+ processing another any other Report Status Code Library function, then
+ PostCode() must return Value immediately.
+
+ @param Value The 32-bit value to write to the POST card.
+
+ @return Value
+
+**/
+UINT32
+EFIAPI
+GluePostCode (
+ IN UINT32 Value
+ )
+{
+ REPORT_STATUS_CODE (EFI_PROGRESS_CODE, POST_CODE_TO_STATUS_CODE_VALUE (Value));
+ return Value;
+}
+
+
+/**
+ Sends an 32-bit value to a POST and associated ASCII string.
+
+ Sends the 32-bit value specified by Value to a POST card, and returns Value.
+ If Description is not NULL, then the ASCII string specified by Description is
+ also passed to the handler that displays the POST card value. Some
+ implementations of this library function may perform I/O operations directly
+ to a POST card device. Other implementations may send Value to ReportStatusCode(),
+ and the status code reporting mechanism will eventually display the 32-bit
+ value on the status reporting device.
+
+ PostCodeWithDescription()must actively prevent recursion. If
+ PostCodeWithDescription() is called while processing another any other Report
+ Status Code Library function, then PostCodeWithDescription() must return Value
+ immediately.
+
+ @param Value The 32-bit value to write to the POST card.
+ @param Description Pointer to an ASCII string that is a description of the
+ POST code value. This is an optional parameter that may
+ be NULL.
+
+ @return Value
+
+**/
+UINT32
+EFIAPI
+GluePostCodeWithDescription (
+ IN UINT32 Value,
+ IN CONST CHAR8 *Description OPTIONAL
+ )
+{
+ if (Description == NULL) {
+ REPORT_STATUS_CODE (
+ EFI_PROGRESS_CODE,
+ POST_CODE_TO_STATUS_CODE_VALUE (Value)
+ );
+ } else {
+ REPORT_STATUS_CODE_WITH_EXTENDED_DATA (
+ EFI_PROGRESS_CODE,
+ POST_CODE_TO_STATUS_CODE_VALUE (Value),
+ Description,
+ AsciiStrSize (Description)
+ );
+ }
+
+ return Value;
+}
+
+
+/**
+ Returns TRUE if POST Codes are enabled.
+
+ This function returns TRUE if the POST_CODE_PROPERTY_POST_CODE_ENABLED
+ bit of PcdPostCodePropertyMask is set. Otherwise FALSE is returned.
+
+ @retval TRUE The POST_CODE_PROPERTY_POST_CODE_ENABLED bit of
+ PcdPostCodeProperyMask is set.
+ @retval FALSE The POST_CODE_PROPERTY_POST_CODE_ENABLED bit of
+ PcdPostCodeProperyMask is clear.
+
+**/
+BOOLEAN
+EFIAPI
+GluePostCodeEnabled (
+ VOID
+ )
+{
+ return ((PcdGet8(PcdPostCodePropertyMask) & POST_CODE_PROPERTY_POST_CODE_ENABLED) != 0);
+}
+
+
+/**
+ Returns TRUE if POST code descriptions are enabled.
+
+ This function returns TRUE if the
+ POST_CODE_PROPERTY_POST_CODE_ENABLED bit of
+ PcdPostCodePropertyMask is set. Otherwise FALSE is returned.
+
+ @retval TRUE The POST_CODE_PROPERTY_POST_CODE_ENABLED
+ bit of PcdPostCodeProperyMask is set.
+ @retval FALSE The POST_CODE_PROPERTY_POST_CODE_ENABLED
+ bit of PcdPostCodeProperyMask is clear.
+
+**/
+BOOLEAN
+EFIAPI
+GluePostCodeDescriptionEnabled (
+ VOID
+ )
+{
+ return ((PcdGet8(PcdPostCodePropertyMask) & POST_CODE_PROPERTY_POST_CODE_ENABLED) != 0);
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiFirmwarePerformanceLib/EdkIIGluePeiFirmwarePerformanceLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiFirmwarePerformanceLib/EdkIIGluePeiFirmwarePerformanceLib.c
new file mode 100644
index 0000000..5990272
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiFirmwarePerformanceLib/EdkIIGluePeiFirmwarePerformanceLib.c
@@ -0,0 +1,452 @@
+/*++
+
+Copyright (c) 2011 - 2012, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EdkIIGluePeiFirmwarePerformanceLib.c
+
+Abstract:
+
+ PEI Library for FPDT performance logging.
+
+--*/
+
+#include "EdkIIGluePeim.h"
+#include EFI_GUID_DEFINITION (PeiPerformanceHob)
+
+//
+// MAX perfomance HOB Entries
+//
+#define MAX_FIRMWARE_PERFORMANCE_ENTRIES 80
+
+EFI_STATUS
+PeiPerfMeasureEx (
+ IN VOID *FileHeader,
+ IN UINT16 *Token,
+ IN BOOLEAN EntryExit,
+ IN UINT64 TimeStamp,
+ IN UINT16 Identifier
+ )
+/*++
+
+Routine Description:
+
+ Log an extended timestamp value into pre-allocated hob.
+
+Arguments:
+
+ FileHeader - Pointer to the file header
+
+ Token - Pointer to Token Name
+
+ EntryExit - Indicates start or stop measurement
+
+ Timestamp - The TSC value
+
+ Identifier - Identifier of the record
+
+Returns:
+
+ EFI_BUFFER_TOO_SMALL - Allocate buffer is not enough to hold new records
+
+ EFI_SUCCESS - Successfully updated the record in hob
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_PEI_PPI_DESCRIPTOR *PerfHobDescriptor;
+ PEI_FIRMWARE_PERFORMANCE_HOB *FirmwarePerformanceHob;
+ PEI_GUID_EVENT_REC *PeiGuidRec;
+ EFI_PEI_SERVICES **PeiServices;
+ UINTN BufferSize;
+ EFI_PEI_HOB_POINTERS Hob;
+
+ PeiServices = GetPeiServicesTablePointer ();
+ //
+ // Locate the Pei Performance Log Hob.
+ //
+ Status = (*PeiServices)->LocatePpi (
+ PeiServices,
+ &gPeiFirmwarePerformanceGuid,
+ 0,
+ &PerfHobDescriptor,
+ NULL
+ );
+ if (EFI_ERROR (Status)) {
+ BufferSize = (UINT16) (sizeof (PEI_FIRMWARE_PERFORMANCE_HOB) +
+ ((MAX_FIRMWARE_PERFORMANCE_ENTRIES-1) * sizeof (PEI_GUID_EVENT_REC)) +
+ sizeof(EFI_PEI_PPI_DESCRIPTOR)
+ );
+
+ Hob.Raw = BuildGuidHob (
+ &gPeiFirmwarePerformanceGuid,
+ BufferSize
+ );
+
+ if (Hob.Raw == NULL) {
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ FirmwarePerformanceHob = (VOID *) (Hob.Raw);
+ FirmwarePerformanceHob->NumberOfEntries = 0;
+ FirmwarePerformanceHob->Reserved = 0;
+
+ PerfHobDescriptor = (EFI_PEI_PPI_DESCRIPTOR *)((UINT8 *)(FirmwarePerformanceHob+1) +
+ (sizeof (PEI_GUID_EVENT_REC) *
+ (MAX_FIRMWARE_PERFORMANCE_ENTRIES-1))
+ );
+ PerfHobDescriptor->Flags = (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST);
+ PerfHobDescriptor->Guid = &gPeiFirmwarePerformanceGuid;
+ PerfHobDescriptor->Ppi = NULL;
+
+ (*PeiServices)->InstallPpi (PeiServices, PerfHobDescriptor);
+ ASSERT_EFI_ERROR (Status);
+ }
+
+ FirmwarePerformanceHob = (PEI_FIRMWARE_PERFORMANCE_HOB *)(((UINT8 *)(PerfHobDescriptor)) -
+ ((sizeof (PEI_GUID_EVENT_REC) *
+ (MAX_FIRMWARE_PERFORMANCE_ENTRIES-1))
+ + sizeof (PEI_FIRMWARE_PERFORMANCE_HOB)
+ )
+ );
+
+ //
+ // return if pre-allocated performance hob has filled up
+ //
+ if (FirmwarePerformanceHob->NumberOfEntries >= MAX_FIRMWARE_PERFORMANCE_ENTRIES) {
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ PeiGuidRec = &(FirmwarePerformanceHob->GuidEventRecord[FirmwarePerformanceHob->NumberOfEntries]);
+ ((*PeiServices)->SetMem) (PeiGuidRec, sizeof (PEI_GUID_EVENT_REC), 0);
+
+ //
+ // If not NULL pointer, copy the file name
+ //
+ if (FileHeader != NULL) {
+ PeiGuidRec->Guid = ((EFI_FFS_FILE_HEADER *)FileHeader)->Name;
+ }
+ //
+ // Record the time stamp nanosec value.
+ //
+ PeiGuidRec->Timestamp = GetTimeInNanoSec (TimeStamp);
+
+ //
+ // Copy the progress ID
+ //
+ PeiGuidRec->ProgressID = Identifier;
+
+ //
+ // Record the APIC Id
+ //
+ PeiGuidRec->ApicID = GetApicId ();
+
+ //
+ // Increment the number of valid log entries.
+ //
+ FirmwarePerformanceHob->NumberOfEntries++;
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+PeiPerfMeasure (
+ IN VOID *FileHeader,
+ IN UINT16 *Token,
+ IN BOOLEAN EntryExit,
+ IN UINT64 TimeStamp
+ )
+/*++
+
+Routine Description:
+
+ Log a timestamp value into pre-allocated buffer.
+ Creates performance hob if not already installed
+
+Arguments:
+
+ FileHeader - Pointer to the file header
+
+ Token - Pointer to Token Name
+
+ EntryExit - Indicates start or stop measurement
+
+ TimeStamp - The start time or the stop time
+
+Returns:
+
+ EFI_BUFFER_TOO_SMALL - Allocate buffer is not enough to hold new records
+
+ EFI_UNSUPPORTED - Unable to recognize used token
+
+ EFI_SUCCESS - Successfully updated the record in hob
+
+--*/
+{
+ EFI_STATUS Status;
+ PEI_FIRMWARE_PERFORMANCE_HOB *FirmwarePerformanceHob;
+ EFI_PEI_PPI_DESCRIPTOR *PerfHobDescriptor;
+ PEI_GUID_EVENT_REC *PeiGuidRec;
+ EFI_PEI_SERVICES **PeiServices;
+ UINTN BufferSize;
+ EFI_PEI_HOB_POINTERS Hob;
+
+ PeiServices = GetPeiServicesTablePointer ();
+ //
+ // Locate the Pei Performance Log Hob.
+ //
+ Status = (*PeiServices)->LocatePpi (
+ PeiServices,
+ &gPeiFirmwarePerformanceGuid,
+ 0,
+ &PerfHobDescriptor,
+ NULL
+ );
+
+ if (EFI_ERROR (Status)) {
+
+ BufferSize = (UINT16) (sizeof (PEI_FIRMWARE_PERFORMANCE_HOB) +
+ ((MAX_FIRMWARE_PERFORMANCE_ENTRIES-1) * sizeof (PEI_GUID_EVENT_REC)) +
+ sizeof(EFI_PEI_PPI_DESCRIPTOR)
+ );
+
+ Hob.Raw = BuildGuidHob (
+ &gPeiFirmwarePerformanceGuid,
+ BufferSize
+ );
+
+ if (Hob.Raw == NULL) {
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ FirmwarePerformanceHob = (VOID *) (Hob.Raw);
+ FirmwarePerformanceHob->NumberOfEntries = 0;
+ FirmwarePerformanceHob->Reserved = 0;
+
+ PerfHobDescriptor = (EFI_PEI_PPI_DESCRIPTOR *)((UINT8 *)(FirmwarePerformanceHob+1) +
+ (sizeof (PEI_GUID_EVENT_REC) *
+ (MAX_FIRMWARE_PERFORMANCE_ENTRIES-1))
+ );
+ PerfHobDescriptor->Flags = (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST);
+ PerfHobDescriptor->Guid = &gPeiFirmwarePerformanceGuid;
+ PerfHobDescriptor->Ppi = NULL;
+
+ (*PeiServices)->InstallPpi (PeiServices, PerfHobDescriptor);
+ ASSERT_EFI_ERROR (Status);
+ }
+
+ FirmwarePerformanceHob = (PEI_FIRMWARE_PERFORMANCE_HOB *)(((UINT8 *)(PerfHobDescriptor)) -
+ ((sizeof (PEI_GUID_EVENT_REC) *
+ (MAX_FIRMWARE_PERFORMANCE_ENTRIES-1))
+ + sizeof (PEI_FIRMWARE_PERFORMANCE_HOB))
+ );
+
+ if (FirmwarePerformanceHob->NumberOfEntries >= MAX_FIRMWARE_PERFORMANCE_ENTRIES) {
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ PeiGuidRec = &(FirmwarePerformanceHob->GuidEventRecord[FirmwarePerformanceHob->NumberOfEntries]);
+ ((*PeiServices)->SetMem) (PeiGuidRec, sizeof (PEI_GUID_EVENT_REC), 0);
+
+ //
+ // If not NULL pointer, copy the file name
+ //
+ if (FileHeader != NULL) {
+ PeiGuidRec->Guid = ((EFI_FFS_FILE_HEADER *)FileHeader)->Name;
+ }
+ //
+ // Record the time stamp nanosec value.
+ //
+ PeiGuidRec->Timestamp = GetTimeInNanoSec (TimeStamp);
+
+ //
+ // Record the Progress Id
+ // Tokens are used by PEI core to log various phases of PEI
+ //
+ if (!StrCmp (Token, L"PEIM")) {
+ if (!EntryExit) {
+ PeiGuidRec->ProgressID = PEIM_START_ID;
+ } else {
+ PeiGuidRec->ProgressID = PEIM_END_ID;
+ }
+ } else if (!StrCmp (Token, L"PreMem")) {
+ if (!EntryExit) {
+ PeiGuidRec->ProgressID = PREMEM_START_ID;
+ } else {
+ PeiGuidRec->ProgressID = PREMEM_END_ID;
+ }
+ } else if (!StrCmp (Token, L"DisMem")) {
+ if (!EntryExit) {
+ PeiGuidRec->ProgressID = DISMEM_START_ID;
+ } else {
+ PeiGuidRec->ProgressID = DISMEM_END_ID;
+ }
+ } else if (!StrCmp (Token, L"PostMem")) {
+ if (!EntryExit) {
+ PeiGuidRec->ProgressID = POSTMEM_START_ID;
+ } else {
+ PeiGuidRec->ProgressID = POSTMEM_END_ID;
+ }
+ } else {
+ return EFI_UNSUPPORTED;
+ }
+ //
+ // Record the APIC Id
+ //
+ PeiGuidRec->ApicID = GetApicId ();
+
+ //
+ // Increment the number of valid log entries.
+ //
+ FirmwarePerformanceHob->NumberOfEntries++;
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+StartMeasure (
+ IN VOID *Handle,
+ IN UINT16 *Token,
+ IN UINT16 *Module,
+ IN UINT64 TimeStamp
+ )
+/*++
+
+Routine Description:
+
+ Start measurement according to token field and insert into pre-allocated buffer
+
+Arguments:
+
+ Handle - Handle to measure
+ Token - Token to measure
+ Module - Module to measure
+ Timestamp - Ticker as start tick
+
+Returns:
+
+ EFI_SUCCESS - Located hob successfully, and buffer is updated with new record
+ EFI_UNSUPPORTED - Failure in update
+ EFI_BUFFER_TOO_SMALL - Allocate buffer is not enough to hold new records
+
+--*/
+{
+ EFI_STATUS Status;
+
+ Status = PeiPerfMeasure (Handle, Token, FALSE, TimeStamp);
+ return Status;
+}
+
+EFI_STATUS
+EndMeasure (
+ IN VOID *Handle,
+ IN UINT16 *Token,
+ IN UINT16 *Module,
+ IN UINT64 TimeStamp
+ )
+/*++
+
+Routine Description:
+
+ End measurement according to token field and insert into pre-allocated buffer
+
+Arguments:
+
+ Handle - Handle to stop
+ Token - Token to stop
+ Module - Module to stop
+ Timestamp - Ticker as end tick
+
+Returns:
+
+ EFI_SUCCESS - Located hob successfully, and buffer is updated with new record
+ EFI_UNSUPPORTED - Failure in update
+ EFI_BUFFER_TOO_SMALL - Allocate buffer is not enough to hold new records
+
+--*/
+{
+ EFI_STATUS Status;
+
+ Status = PeiPerfMeasure (Handle, Token, TRUE, TimeStamp);
+ return Status;
+}
+
+EFI_STATUS
+StartMeasureEx (
+ IN VOID *Handle,
+ IN UINT16 *Token,
+ IN UINT16 *Module,
+ IN UINT64 TimeStamp,
+ IN UINT16 Identifier
+ )
+/*++
+
+Routine Description:
+
+ Start extended measurement according to token field and insert into pre-allocated buffer
+
+Arguments:
+
+ Handle - Handle to stop
+ Token - Token to stop
+ Module - Module to stop
+ Timestamp - Ticker as end tick
+ Identifier - Identifier for a given record
+
+Returns:
+
+ EFI_SUCCESS - Located hob successfully, and buffer is updated with new record
+ EFI_UNSUPPORTED - Failure in update
+ EFI_BUFFER_TOO_SMALL - Allocate buffer is not enough to hold new records
+
+--*/
+{
+ EFI_STATUS Status;
+
+ Status = PeiPerfMeasureEx (Handle, Token, FALSE, TimeStamp, Identifier);
+ return Status;
+}
+
+EFI_STATUS
+EndMeasureEx (
+ IN VOID *Handle,
+ IN UINT16 *Token,
+ IN UINT16 *Module,
+ IN UINT64 TimeStamp,
+ IN UINT16 Identifier
+ )
+/*++
+
+Routine Description:
+
+ End extended measurement according to token field and insert into pre-allocated buffer
+
+Arguments:
+
+ Handle - Handle to stop
+ Token - Token to stop
+ Module - Module to stop
+ Timestamp - Ticker as end tick
+ Identifier - Identifier for a given record
+
+Returns:
+
+ EFI_SUCCESS - Located hob successfully, and buffer is updated with new record
+ EFI_UNSUPPORTED - Failure in update
+ EFI_BUFFER_TOO_SMALL - Allocate buffer is not enough to hold new records
+
+--*/
+{
+ EFI_STATUS Status;
+
+ Status = PeiPerfMeasureEx (Handle, Token, TRUE, TimeStamp, Identifier);
+ return Status;
+} \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiFirmwarePerformanceLib/EdkIIGluePeiFirmwarePerformanceLib.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiFirmwarePerformanceLib/EdkIIGluePeiFirmwarePerformanceLib.cif
new file mode 100644
index 0000000..ccfaff0
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiFirmwarePerformanceLib/EdkIIGluePeiFirmwarePerformanceLib.cif
@@ -0,0 +1,11 @@
+<component>
+ name = "EdkIIGluePeiFirmwarePerformanceLib"
+ category = ModulePart
+ LocalRoot = "EDK\Foundation\Library\EdkIIGlueLib\Library\PeiFirmwarePerformanceLib\"
+ RefName = "EdkIIGluePeiFirmwarePerformanceLib"
+[files]
+"EdkIIGluePeiFirmwarePerformanceLib.sdl"
+"EdkIIGluePeiFirmwarePerformanceLib.mak"
+"EdkIIGluePeiFirmwarePerformanceLib.inf"
+"EdkIIGluePeiFirmwarePerformanceLib.c"
+<endComponent> \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiFirmwarePerformanceLib/EdkIIGluePeiFirmwarePerformanceLib.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiFirmwarePerformanceLib/EdkIIGluePeiFirmwarePerformanceLib.inf
new file mode 100644
index 0000000..d692147
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiFirmwarePerformanceLib/EdkIIGluePeiFirmwarePerformanceLib.inf
@@ -0,0 +1,77 @@
+#/*++
+#
+# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
+# This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# EdkIIGluePeiFirmwarePerformanceLib.inf
+#
+# Abstract:
+#
+# Component description file for PeiFirmwarePerformanceLib
+#
+#--*/
+
+[defines]
+BASE_NAME = EdkIIGluePeiFirmwarePerformanceLib
+COMPONENT_TYPE = LIBRARY
+
+[sources.common]
+ EdkIIGluePeiFirmwarePerformanceLib.c
+
+[sources.ia32]
+
+
+[sources.x64]
+
+
+[sources.ipf]
+
+
+[sources.ebc]
+
+
+[includes.common]
+ .
+ ..\..\Include
+ ..\..\include\Library
+ $(EDK_SOURCE)\Foundation
+ $(EDK_SOURCE)\Foundation\Include\Pei
+ $(EDK_SOURCE)\Foundation\Framework
+ $(EDK_SOURCE)\Foundation\Efi
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+
+[libraries.common]
+ EdkIIGlueBaseTimerLibLocalApic
+ EdkIIGlueBaseTimerLibTsc
+ EdkIIGluePeiHobLib
+
+[libraries.ia32]
+
+[libraries.x64]
+
+[nmake.common]
+ C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION
+ LIB_STD_FLAGS = /NOLOGO /IGNORE:4006 /IGNORE:4221
+
+[nmake.ia32]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32
+
+[nmake.x64]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64
+
+[nmake.ipf]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF
+
+[nmake.ebc]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiFirmwarePerformanceLib/EdkIIGluePeiFirmwarePerformanceLib.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiFirmwarePerformanceLib/EdkIIGluePeiFirmwarePerformanceLib.mak
new file mode 100644
index 0000000..99a1d78
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiFirmwarePerformanceLib/EdkIIGluePeiFirmwarePerformanceLib.mak
@@ -0,0 +1,74 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2011, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGluePeiFirmwarePerformanceLib/EdkIIGluePeiFirmwarePerformanceLib.mak 1 1/20/12 3:58a Jeffch $
+#
+# $Revision: 1 $
+#
+# $Date: 1/20/12 3:58a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGluePeiFirmwarePerformanceLib/EdkIIGluePeiFirmwarePerformanceLib.mak $
+#
+# 1 1/20/12 3:58a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 11/17/11 9:31p Wesleychen
+# EdkIIGluePeiFirmwarePerformanceLib
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: EdkIIGluePeiFirmwarePerformanceLib.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+$(EdkIIGluePeiFirmwarePerformanceLib_LIB) : EdkIIGluePeiFirmwarePerformanceLib
+
+EdkIIGluePeiFirmwarePerformanceLib : $(BUILD_DIR)\EdkIIGluePeiFirmwarePerformanceLib.mak EdkIIGluePeiFirmwarePerformanceLibBin
+
+$(BUILD_DIR)\EdkIIGluePeiFirmwarePerformanceLib.mak : $(EdkIIGluePeiFirmwarePerformanceLib_DIR)\$(@B).cif $(EdkIIGluePeiFirmwarePerformanceLib_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(EdkIIGluePeiFirmwarePerformanceLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+EdkIIGluePeiFirmwarePerformanceLibBin : $(CPUIA32LIB)
+
+EdkIIGluePeiFirmwarePerformanceLibBin : $(EdkIIGlueBaseTimerLibLocalApic_LIB) $(EdkIIGlueBaseTimerLibTsc_LIB) $(EdkIIGluePeiHobLib_LIB) $(EDKGUIDLIB) $(ARCHPROTOCOLLIB)
+!IF "$(x64_BUILD)"=="1"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\IA32\
+ /f $(BUILD_DIR)\EdkIIGluePeiFirmwarePerformanceLib.mak all\
+ TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGluePeiFirmwarePerformanceLib_LIB)"
+!ELSE
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGluePeiFirmwarePerformanceLib.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGluePeiFirmwarePerformanceLib_LIB)"
+!ENDIF
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2011, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiFirmwarePerformanceLib/EdkIIGluePeiFirmwarePerformanceLib.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiFirmwarePerformanceLib/EdkIIGluePeiFirmwarePerformanceLib.sdl
new file mode 100644
index 0000000..1ba2d0b
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiFirmwarePerformanceLib/EdkIIGluePeiFirmwarePerformanceLib.sdl
@@ -0,0 +1,24 @@
+TOKEN
+ Name = EdkIIGluePeiFirmwarePerformanceLib_SUPPORT
+ Value = 1
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "EdkIIGluePeiFirmwarePerformanceLib_LIB"
+ Value = "$$(LIB_BUILD_DIR)\EdkIIGluePeiFirmwarePerformanceLib.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "EdkIIGluePeiFirmwarePerformanceLib_DIR"
+End
+
+MODULE
+ Help = "Includes EdkIIGluePeiFirmwarePerformanceLib.mak to Project"
+ File = "EdkIIGluePeiFirmwarePerformanceLib.mak"
+End \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiHobLib/EdkIIGluePeiHobLib.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiHobLib/EdkIIGluePeiHobLib.cif
new file mode 100644
index 0000000..38bd79c
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiHobLib/EdkIIGluePeiHobLib.cif
@@ -0,0 +1,11 @@
+<component>
+ name = "EdkIIGluePeiHobLib"
+ category = ModulePart
+ LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\PeiHobLib"
+ RefName = "EdkIIGluePeiHobLib"
+[files]
+"EdkIIGluePeiHobLib.sdl"
+"EdkIIGluePeiHobLib.mak"
+"PeiHobLib.inf"
+"HobLib.c"
+<endComponent>
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiHobLib/EdkIIGluePeiHobLib.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiHobLib/EdkIIGluePeiHobLib.mak
new file mode 100644
index 0000000..9b3f50b
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiHobLib/EdkIIGluePeiHobLib.mak
@@ -0,0 +1,80 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGluePeiHobLib/EdkIIGluePeiHobLib.mak 1 1/20/12 3:56a Jeffch $
+#
+# $Revision: 1 $
+#
+# $Date: 1/20/12 3:56a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGluePeiHobLib/EdkIIGluePeiHobLib.mak $
+#
+# 1 1/20/12 3:56a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 9/27/11 6:18a Wesleychen
+# Intel EDK initially releases.
+#
+# 1 9/18/09 1:56a Iminglin
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: EdkIIGluePeiHobLib.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+
+
+$(EdkIIGluePeiHobLib_LIB) : EdkIIGluePeiHobLib
+
+EdkIIGluePeiHobLib : $(BUILD_DIR)\EdkIIGluePeiHobLib.mak EdkIIGluePeiHobLibBin
+
+$(BUILD_DIR)\EdkIIGluePeiHobLib.mak : $(EdkIIGluePeiHobLib_DIR)\$(@B).cif $(EdkIIGluePeiHobLib_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(EdkIIGluePeiHobLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+EdkIIGluePeiHobLibBin : $(EdkIIGlueBaseMemoryLib_LIB) $(EdkIIGluePeiServicesLib_LIB)
+!IF "$(x64_BUILD)"=="1"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGluePeiHobLib.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGluePeiHobLib_LIB)"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\IA32\
+ /f $(BUILD_DIR)\EdkIIGluePeiHobLib.mak all\
+ TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGluePeiHobLib_LIB)"
+!ELSE
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGluePeiHobLib.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGluePeiHobLib_LIB)"
+!ENDIF
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiHobLib/EdkIIGluePeiHobLib.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiHobLib/EdkIIGluePeiHobLib.sdl
new file mode 100644
index 0000000..50a1dfd
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiHobLib/EdkIIGluePeiHobLib.sdl
@@ -0,0 +1,26 @@
+TOKEN
+ Name = "EdkIIGluePeiHobLib_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable EdkIIGluePeiHobLib support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "EdkIIGluePeiHobLib_LIB"
+ Value = "$$(LIB_BUILD_DIR)\EdkIIGluePeiHobLib.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "EdkIIGluePeiHobLib_DIR"
+End
+
+MODULE
+ Help = "Includes EdkIIGluePeiHobLib.mak to Project"
+ File = "EdkIIGluePeiHobLib.mak"
+End
+
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiHobLib/HobLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiHobLib/HobLib.c
new file mode 100644
index 0000000..cff5f91
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiHobLib/HobLib.c
@@ -0,0 +1,573 @@
+/*++
+
+Copyright (c) 2004 - 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ HobLib.c
+
+Abstract:
+
+ HOB Library.
+
+--*/
+
+#include "EdkIIGluePeim.h"
+
+/**
+ Returns the pointer to the HOB list.
+
+ This function returns the pointer to first HOB in the list.
+
+ @return The pointer to the HOB list.
+
+**/
+VOID *
+EFIAPI
+GetHobList (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ VOID *HobList;
+
+ Status = PeiServicesGetHobList (&HobList);
+ ASSERT_EFI_ERROR (Status);
+ ASSERT (HobList != NULL);
+
+ return HobList;
+}
+
+/**
+ Returns the next instance of a HOB type from the starting HOB.
+
+ This function searches the first instance of a HOB type from the starting HOB pointer.
+ If there does not exist such HOB type from the starting HOB pointer, it will return NULL.
+ In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer
+ unconditionally: it returns HobStart back if HobStart itself meets the requirement;
+ caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart.
+ If HobStart is NULL, then ASSERT().
+
+ @param Type The HOB type to return.
+ @param HobStart The starting HOB pointer to search from.
+
+ @return The next instance of a HOB type from the starting HOB.
+
+**/
+VOID *
+EFIAPI
+GetNextHob (
+ IN UINT16 Type,
+ IN CONST VOID *HobStart
+ )
+{
+ EFI_PEI_HOB_POINTERS Hob;
+
+ ASSERT (HobStart != NULL);
+
+ Hob.Raw = (UINT8 *) HobStart;
+ //
+ // Parse the HOB list until end of list or matching type is found.
+ //
+ while (!END_OF_HOB_LIST (Hob)) {
+ if (Hob.Header->HobType == Type) {
+ return Hob.Raw;
+ }
+ Hob.Raw = GET_NEXT_HOB (Hob);
+ }
+ return NULL;
+}
+
+/**
+ Returns the first instance of a HOB type among the whole HOB list.
+
+ This function searches the first instance of a HOB type among the whole HOB list.
+ If there does not exist such HOB type in the HOB list, it will return NULL.
+
+ @param Type The HOB type to return.
+
+ @return The next instance of a HOB type from the starting HOB.
+
+**/
+VOID *
+EFIAPI
+GetFirstHob (
+ IN UINT16 Type
+ )
+{
+ VOID *HobList;
+
+ HobList = GetHobList ();
+ return GetNextHob (Type, HobList);
+}
+
+/**
+ This function searches the first instance of a HOB from the starting HOB pointer.
+ Such HOB should satisfy two conditions:
+ its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid.
+ If there does not exist such HOB from the starting HOB pointer, it will return NULL.
+ Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE ()
+ to extract the data section and its size info respectively.
+ In contrast with macro GET_NEXT_HOB(), this function does not skip the starting HOB pointer
+ unconditionally: it returns HobStart back if HobStart itself meets the requirement;
+ caller is required to use GET_NEXT_HOB() if it wishes to skip current HobStart.
+ If Guid is NULL, then ASSERT().
+ If HobStart is NULL, then ASSERT().
+
+ @param Guid The GUID to match with in the HOB list.
+ @param HobStart A pointer to a Guid.
+
+ @return The next instance of the matched GUID HOB from the starting HOB.
+
+**/
+VOID *
+EFIAPI
+GlueGetNextGuidHob (
+ IN CONST EFI_GUID *Guid,
+ IN CONST VOID *HobStart
+ )
+{
+ EFI_PEI_HOB_POINTERS GuidHob;
+
+ GuidHob.Raw = (UINT8 *) HobStart;
+ while ((GuidHob.Raw = GetNextHob (EFI_HOB_TYPE_GUID_EXTENSION, GuidHob.Raw)) != NULL) {
+ if (CompareGuid (Guid, &GuidHob.Guid->Name)) {
+ break;
+ }
+ GuidHob.Raw = GET_NEXT_HOB (GuidHob);
+ }
+ return GuidHob.Raw;
+}
+
+/**
+ This function searches the first instance of a HOB among the whole HOB list.
+ Such HOB should satisfy two conditions:
+ its HOB type is EFI_HOB_TYPE_GUID_EXTENSION and its GUID Name equals to the input Guid.
+ If there does not exist such HOB from the starting HOB pointer, it will return NULL.
+ Caller is required to apply GET_GUID_HOB_DATA () and GET_GUID_HOB_DATA_SIZE ()
+ to extract the data section and its size info respectively.
+ If Guid is NULL, then ASSERT().
+
+ @param Guid The GUID to match with in the HOB list.
+
+ @return The first instance of the matched GUID HOB among the whole HOB list.
+
+**/
+VOID *
+EFIAPI
+GlueGetFirstGuidHob (
+ IN CONST EFI_GUID *Guid
+ )
+{
+ VOID *HobList;
+
+ HobList = GetHobList ();
+ return GetNextGuidHob (Guid, HobList);
+}
+
+/**
+ Get the Boot Mode from the HOB list.
+
+ This function returns the system boot mode information from the
+ PHIT HOB in HOB list.
+
+ @param VOID
+
+ @return The Boot Mode.
+
+**/
+EFI_BOOT_MODE
+EFIAPI
+GetBootModeHob (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ EFI_BOOT_MODE BootMode;
+
+ Status = PeiServicesGetBootMode (&BootMode);
+ ASSERT_EFI_ERROR (Status);
+
+ return BootMode;
+}
+
+/**
+ Adds a new HOB to the HOB List.
+
+ This internal function enables PEIMs to create various types of HOBs.
+
+ @param Type Type of the new HOB.
+ @param Length Length of the new HOB to allocate.
+
+ @return The address of new HOB.
+
+**/
+STATIC
+VOID *
+InternalPeiCreateHob (
+ IN UINT16 Type,
+ IN UINT16 Length
+ )
+{
+ EFI_STATUS Status;
+ VOID *Hob;
+
+ Status = PeiServicesCreateHob (Type, Length, &Hob);
+ //
+ // Assume the process of HOB building is always successful.
+ //
+ ASSERT_EFI_ERROR (Status);
+ return Hob;
+}
+
+/**
+ Builds a HOB for a loaded PE32 module.
+
+ This function builds a HOB for a loaded PE32 module.
+ It can only be invoked during PEI phase;
+ for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
+ If ModuleName is NULL, then ASSERT().
+ If there is no additional space for HOB creation, then ASSERT().
+
+ @param ModuleName The GUID File Name of the module.
+ @param MemoryAllocationModule The 64 bit physical address of the module.
+ @param ModuleLength The length of the module in bytes.
+ @param EntryPoint The 64 bit physical address of the module's entry point.
+
+**/
+VOID
+EFIAPI
+GlueBuildModuleHob (
+ IN CONST EFI_GUID *ModuleName,
+ IN EFI_PHYSICAL_ADDRESS MemoryAllocationModule,
+ IN UINT64 ModuleLength,
+ IN EFI_PHYSICAL_ADDRESS EntryPoint
+ )
+{
+ EFI_HOB_MEMORY_ALLOCATION_MODULE *Hob;
+
+ Hob = InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION_MODULE));
+
+ CopyGuid (&(Hob->MemoryAllocationHeader.Name), &gEfiHobMemoryAllocModuleGuid);
+ Hob->MemoryAllocationHeader.MemoryBaseAddress = MemoryAllocationModule;
+ Hob->MemoryAllocationHeader.MemoryLength = ModuleLength;
+ Hob->MemoryAllocationHeader.MemoryType = EfiBootServicesCode;
+
+ //
+ // Zero the reserved space to match HOB spec
+ //
+ ZeroMem (Hob->MemoryAllocationHeader.Reserved, sizeof (Hob->MemoryAllocationHeader.Reserved));
+
+ CopyGuid (&Hob->ModuleName, ModuleName);
+ Hob->EntryPoint = EntryPoint;
+}
+
+/**
+ Builds a HOB that describes a chunk of system memory.
+
+ This function builds a HOB that describes a chunk of system memory.
+ It can only be invoked during PEI phase;
+ for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
+ If there is no additional space for HOB creation, then ASSERT().
+
+ @param ResourceType The type of resource described by this HOB.
+ @param ResourceAttribute The resource attributes of the memory described by this HOB.
+ @param PhysicalStart The 64 bit physical address of memory described by this HOB.
+ @param NumberOfBytes The length of the memory described by this HOB in bytes.
+
+**/
+VOID
+EFIAPI
+BuildResourceDescriptorHob (
+ IN EFI_RESOURCE_TYPE ResourceType,
+ IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute,
+ IN EFI_PHYSICAL_ADDRESS PhysicalStart,
+ IN UINT64 NumberOfBytes
+ )
+{
+ EFI_HOB_RESOURCE_DESCRIPTOR *Hob;
+
+ Hob = InternalPeiCreateHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, sizeof (EFI_HOB_RESOURCE_DESCRIPTOR));
+
+ Hob->ResourceType = ResourceType;
+ Hob->ResourceAttribute = ResourceAttribute;
+ Hob->PhysicalStart = PhysicalStart;
+ Hob->ResourceLength = NumberOfBytes;
+}
+
+/**
+ Builds a GUID HOB with a certain data length.
+
+ This function builds a customized HOB tagged with a GUID for identification
+ and returns the start address of GUID HOB data so that caller can fill the customized data.
+ The HOB Header and Name field is already stripped.
+ It can only be invoked during PEI phase;
+ for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
+ If Guid is NULL, then ASSERT().
+ If there is no additional space for HOB creation, then ASSERT().
+ If DataLength >= (0x10000 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().
+
+ @param Guid The GUID to tag the customized HOB.
+ @param DataLength The size of the data payload for the GUID HOB.
+
+ @return The start address of GUID HOB data.
+
+**/
+VOID *
+EFIAPI
+BuildGuidHob (
+ IN CONST EFI_GUID *Guid,
+ IN UINTN DataLength
+ )
+{
+ EFI_HOB_GUID_TYPE *Hob;
+
+ //
+ // Make sure that data length is not too long.
+ //
+ ASSERT (DataLength <= (0xffff - sizeof (EFI_HOB_GUID_TYPE)));
+
+ Hob = InternalPeiCreateHob (EFI_HOB_TYPE_GUID_EXTENSION, (UINT16) (sizeof (EFI_HOB_GUID_TYPE) + DataLength));
+ CopyGuid (&Hob->Name, Guid);
+ return Hob + 1;
+}
+
+/**
+ Copies a data buffer to a newly-built HOB.
+
+ This function builds a customized HOB tagged with a GUID for identification,
+ copies the input data to the HOB data field and returns the start address of the GUID HOB data.
+ The HOB Header and Name field is already stripped.
+ It can only be invoked during PEI phase;
+ for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
+ If Guid is NULL, then ASSERT().
+ If Data is NULL and DataLength > 0, then ASSERT().
+ If there is no additional space for HOB creation, then ASSERT().
+ If DataLength >= (0x10000 - sizeof (EFI_HOB_GUID_TYPE)), then ASSERT().
+
+ @param Guid The GUID to tag the customized HOB.
+ @param Data The data to be copied into the data field of the GUID HOB.
+ @param DataLength The size of the data payload for the GUID HOB.
+
+ @return The start address of GUID HOB data.
+
+**/
+VOID *
+EFIAPI
+BuildGuidDataHob (
+ IN CONST EFI_GUID *Guid,
+ IN VOID *Data,
+ IN UINTN DataLength
+ )
+{
+ VOID *HobData;
+
+ ASSERT (Data != NULL || DataLength == 0);
+
+ HobData = BuildGuidHob (Guid, DataLength);
+
+ return CopyMem (HobData, Data, DataLength);
+}
+
+/**
+ Builds a Firmware Volume HOB.
+
+ This function builds a Firmware Volume HOB.
+ It can only be invoked during PEI phase;
+ for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
+ If there is no additional space for HOB creation, then ASSERT().
+
+ @param BaseAddress The base address of the Firmware Volume.
+ @param Length The size of the Firmware Volume in bytes.
+
+**/
+VOID
+EFIAPI
+BuildFvHob (
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length
+ )
+{
+ EFI_HOB_FIRMWARE_VOLUME *Hob;
+
+ //
+ // Check FV Signature
+ //
+ ASSERT (((EFI_FIRMWARE_VOLUME_HEADER*)((UINTN)BaseAddress))->Signature == EFI_FVH_SIGNATURE);
+ Hob = InternalPeiCreateHob (EFI_HOB_TYPE_FV, sizeof (EFI_HOB_FIRMWARE_VOLUME));
+
+ Hob->BaseAddress = BaseAddress;
+ Hob->Length = Length;
+}
+
+/**
+ Builds a Capsule Volume HOB.
+
+ This function builds a Capsule Volume HOB.
+ It can only be invoked during PEI phase;
+ for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
+ If there is no additional space for HOB creation, then ASSERT().
+
+ @param BaseAddress The base address of the Capsule Volume.
+ @param Length The size of the Capsule Volume in bytes.
+
+**/
+VOID
+EFIAPI
+BuildCvHob (
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length
+ )
+{
+ EFI_HOB_CAPSULE_VOLUME *Hob;
+
+ Hob = InternalPeiCreateHob (EFI_HOB_TYPE_CV, sizeof (EFI_HOB_CAPSULE_VOLUME));
+
+ Hob->BaseAddress = BaseAddress;
+ Hob->Length = Length;
+}
+
+/**
+ Builds a HOB for the CPU.
+
+ This function builds a HOB for the CPU.
+ It can only be invoked during PEI phase;
+ for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
+ If there is no additional space for HOB creation, then ASSERT().
+
+ @param SizeOfMemorySpace The maximum physical memory addressability of the processor.
+ @param SizeOfIoSpace The maximum physical I/O addressability of the processor.
+
+**/
+VOID
+EFIAPI
+BuildCpuHob (
+ IN UINT8 SizeOfMemorySpace,
+ IN UINT8 SizeOfIoSpace
+ )
+{
+ EFI_HOB_CPU *Hob;
+
+ Hob = InternalPeiCreateHob (EFI_HOB_TYPE_CPU, sizeof (EFI_HOB_CPU));
+
+ Hob->SizeOfMemorySpace = SizeOfMemorySpace;
+ Hob->SizeOfIoSpace = SizeOfIoSpace;
+
+ //
+ // Zero the reserved space to match HOB spec
+ //
+ ZeroMem (Hob->Reserved, sizeof (Hob->Reserved));
+}
+
+/**
+ Builds a HOB for the Stack.
+
+ This function builds a HOB for the stack.
+ It can only be invoked during PEI phase;
+ for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
+ If there is no additional space for HOB creation, then ASSERT().
+
+ @param BaseAddress The 64 bit physical address of the Stack.
+ @param Length The length of the stack in bytes.
+
+**/
+VOID
+EFIAPI
+BuildStackHob (
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length
+ )
+{
+ EFI_HOB_MEMORY_ALLOCATION_STACK *Hob;
+
+ Hob = InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION_STACK));
+
+ CopyGuid (&(Hob->AllocDescriptor.Name), &gEfiHobMemoryAllocStackGuid);
+ Hob->AllocDescriptor.MemoryBaseAddress = BaseAddress;
+ Hob->AllocDescriptor.MemoryLength = Length;
+ Hob->AllocDescriptor.MemoryType = EfiBootServicesData;
+
+ //
+ // Zero the reserved space to match HOB spec
+ //
+ ZeroMem (Hob->AllocDescriptor.Reserved, sizeof (Hob->AllocDescriptor.Reserved));
+}
+
+/**
+ Builds a HOB for the BSP store.
+
+ This function builds a HOB for BSP store.
+ It can only be invoked during PEI phase;
+ for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
+ If there is no additional space for HOB creation, then ASSERT().
+
+ @param BaseAddress The 64 bit physical address of the BSP.
+ @param Length The length of the BSP store in bytes.
+ @param MemoryType Type of memory allocated by this HOB.
+
+**/
+VOID
+EFIAPI
+BuildBspStoreHob (
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length,
+ IN EFI_MEMORY_TYPE MemoryType
+ )
+{
+ EFI_HOB_MEMORY_ALLOCATION_BSP_STORE *Hob;
+
+ Hob = InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION_BSP_STORE));
+
+ CopyGuid (&(Hob->AllocDescriptor.Name), &gEfiHobMemoryAllocBspStoreGuid);
+ Hob->AllocDescriptor.MemoryBaseAddress = BaseAddress;
+ Hob->AllocDescriptor.MemoryLength = Length;
+ Hob->AllocDescriptor.MemoryType = MemoryType;
+
+ //
+ // Zero the reserved space to match HOB spec
+ //
+ ZeroMem (Hob->AllocDescriptor.Reserved, sizeof (Hob->AllocDescriptor.Reserved));
+}
+
+/**
+ Builds a HOB for the memory allocation.
+
+ This function builds a HOB for the memory allocation.
+ It can only be invoked during PEI phase;
+ for DXE phase, it will ASSERT() since PEI HOB is read-only for DXE phase.
+ If there is no additional space for HOB creation, then ASSERT().
+
+ @param BaseAddress The 64 bit physical address of the memory.
+ @param Length The length of the memory allocation in bytes.
+ @param MemoryType Type of memory allocated by this HOB.
+
+**/
+VOID
+EFIAPI
+GlueBuildMemoryAllocationHob (
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length,
+ IN EFI_MEMORY_TYPE MemoryType
+ )
+{
+ EFI_HOB_MEMORY_ALLOCATION *Hob;
+
+ Hob = InternalPeiCreateHob (EFI_HOB_TYPE_MEMORY_ALLOCATION, sizeof (EFI_HOB_MEMORY_ALLOCATION));
+
+ ZeroMem (&(Hob->AllocDescriptor.Name), sizeof (EFI_GUID));
+ Hob->AllocDescriptor.MemoryBaseAddress = BaseAddress;
+ Hob->AllocDescriptor.MemoryLength = Length;
+ Hob->AllocDescriptor.MemoryType = MemoryType;
+ //
+ // Zero the reserved space to match HOB spec
+ //
+ ZeroMem (Hob->AllocDescriptor.Reserved, sizeof (Hob->AllocDescriptor.Reserved));
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiHobLib/PeiHobLib.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiHobLib/PeiHobLib.inf
new file mode 100644
index 0000000..27cfdc0
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiHobLib/PeiHobLib.inf
@@ -0,0 +1,81 @@
+#/*++
+#
+# Copyright (c) 2004 - 2006, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# PeiHobLib.inf
+#
+# Abstract:
+#
+# Component description file for PeiHobLib.
+#
+#--*/
+
+[defines]
+BASE_NAME = EdkIIGluePeiHobLib
+COMPONENT_TYPE = LIBRARY
+
+[sources.common]
+ HobLib.c
+
+[sources.ia32]
+
+[sources.x64]
+
+[sources.ipf]
+
+[sources.ebc]
+
+
+[includes.common]
+ .
+ ..\..\Include
+ ..\..\include\Library
+ $(EDK_SOURCE)\Foundation
+ $(EDK_SOURCE)\Foundation\Library\Pei\Include
+ $(EDK_SOURCE)\Foundation\Framework
+ $(EDK_SOURCE)\Foundation\Include\Pei
+ $(EDK_SOURCE)\Foundation\Efi
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Include\Pei
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+ $(EDK_SOURCE)\Foundation\Library\Pei\Include
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+ $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include
+
+[libraries.common]
+ EdkIIGlueBaseMemoryLib
+ EdkIIGluePeiServicesLib
+
+[libraries.ia32]
+
+
+[libraries.x64]
+
+
+[nmake.common]
+ C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION
+ LIB_STD_FLAGS = /NOLOGO /IGNORE:4006
+
+[nmake.ia32]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32
+
+[nmake.x64]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64
+
+[nmake.ipf]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF
+
+[nmake.ebc]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiMemoryAllocationLib/EdkIIGluePeiMemoryAllocationLib.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiMemoryAllocationLib/EdkIIGluePeiMemoryAllocationLib.cif
new file mode 100644
index 0000000..cb5fddf
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiMemoryAllocationLib/EdkIIGluePeiMemoryAllocationLib.cif
@@ -0,0 +1,11 @@
+<component>
+ name = "EdkIIGluePeiMemoryAllocationLib"
+ category = ModulePart
+ LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\PeiMemoryAllocationLib"
+ RefName = "EdkIIGluePeiMemoryAllocationLib"
+[files]
+"EdkIIGluePeiMemoryAllocationLib.sdl"
+"EdkIIGluePeiMemoryAllocationLib.mak"
+"PeiMemoryAllocationLib.inf"
+"MemoryAllocationLib.c"
+<endComponent>
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiMemoryAllocationLib/EdkIIGluePeiMemoryAllocationLib.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiMemoryAllocationLib/EdkIIGluePeiMemoryAllocationLib.mak
new file mode 100644
index 0000000..9d15d3a
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiMemoryAllocationLib/EdkIIGluePeiMemoryAllocationLib.mak
@@ -0,0 +1,80 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGluePeiMemoryAllocationLib/EdkIIGluePeiMemoryAllocationLib.mak 1 1/20/12 3:56a Jeffch $
+#
+# $Revision: 1 $
+#
+# $Date: 1/20/12 3:56a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGluePeiMemoryAllocationLib/EdkIIGluePeiMemoryAllocationLib.mak $
+#
+# 1 1/20/12 3:56a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 9/27/11 6:19a Wesleychen
+# Intel EDK initially releases.
+#
+# 1 9/18/09 1:57a Iminglin
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: EdkIIGluePeiMemoryAllocationLib.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+
+
+$(EdkIIGluePeiMemoryAllocationLib_LIB) : EdkIIGluePeiMemoryAllocationLib
+
+EdkIIGluePeiMemoryAllocationLib : $(BUILD_DIR)\EdkIIGluePeiMemoryAllocationLib.mak EdkIIGluePeiMemoryAllocationLibBin
+
+$(BUILD_DIR)\EdkIIGluePeiMemoryAllocationLib.mak : $(EdkIIGluePeiMemoryAllocationLib_DIR)\$(@B).cif $(EdkIIGluePeiMemoryAllocationLib_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(EdkIIGluePeiMemoryAllocationLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+EdkIIGluePeiMemoryAllocationLibBin : $(EdkIIGlueBaseMemoryLib_LIB) $(EdkIIGluePeiServicesTablePointerLibMm7_LIB)
+!IF "$(x64_BUILD)"=="1"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGluePeiMemoryAllocationLib.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGluePeiMemoryAllocationLib_LIB)"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\IA32\
+ /f $(BUILD_DIR)\EdkIIGluePeiMemoryAllocationLib.mak all\
+ TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGluePeiMemoryAllocationLib_LIB)"
+!ELSE
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGluePeiMemoryAllocationLib.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGluePeiMemoryAllocationLib_LIB)"
+!ENDIF
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#********************************************************************** \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiMemoryAllocationLib/EdkIIGluePeiMemoryAllocationLib.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiMemoryAllocationLib/EdkIIGluePeiMemoryAllocationLib.sdl
new file mode 100644
index 0000000..d382d83
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiMemoryAllocationLib/EdkIIGluePeiMemoryAllocationLib.sdl
@@ -0,0 +1,26 @@
+TOKEN
+ Name = "EdkIIGluePeiMemoryAllocationLib_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable EdkIIGluePeiMemoryAllocationLib support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "EdkIIGluePeiMemoryAllocationLib_LIB"
+ Value = "$$(LIB_BUILD_DIR)\EdkIIGluePeiMemoryAllocationLib.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "EdkIIGluePeiMemoryAllocationLib_DIR"
+End
+
+MODULE
+ Help = "Includes EdkIIGluePeiMemoryAllocationLib.mak to Project"
+ File = "EdkIIGluePeiMemoryAllocationLib.mak"
+End
+
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiMemoryAllocationLib/MemoryAllocationLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiMemoryAllocationLib/MemoryAllocationLib.c
new file mode 100644
index 0000000..50ff6ff
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiMemoryAllocationLib/MemoryAllocationLib.c
@@ -0,0 +1,1080 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ MemoryAllocationLib.c
+
+Abstract:
+
+ Support routines for memory allocation routines for use with drivers.
+
+--*/
+
+#include "EdkIIGluePeim.h"
+
+/**
+ Allocates one or more 4KB pages of a certain memory type.
+
+ Allocates the number of 4KB pages of a certain memory type and returns a pointer to the allocated
+ buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL is returned.
+ If there is not enough memory remaining to satisfy the request, then NULL is returned.
+
+ @param MemoryType The type of memory to allocate.
+ @param Pages The number of 4 KB pages to allocate.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+InternalAllocatePages (
+ IN EFI_MEMORY_TYPE MemoryType,
+ IN UINTN Pages
+ )
+{
+ EFI_STATUS Status;
+ EFI_PHYSICAL_ADDRESS Memory;
+ EFI_PEI_SERVICES **PeiServices;
+
+ if (Pages == 0) {
+ return NULL;
+ }
+
+ PeiServices = GetPeiServicesTablePointer ();
+ Status = ((*PeiServices)->AllocatePages) (PeiServices, MemoryType, Pages, &Memory);
+ if (EFI_ERROR (Status)) {
+ Memory = 0;
+ }
+ return (VOID *) (UINTN) Memory;
+}
+
+/**
+ Allocates one or more 4KB pages of type EfiBootServicesData.
+
+ Allocates the number of 4KB pages of type EfiBootServicesData and returns a pointer to the
+ allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL
+ is returned. If there is not enough memory remaining to satisfy the request, then NULL is
+ returned.
+
+ @param Pages The number of 4 KB pages to allocate.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+GlueAllocatePages (
+ IN UINTN Pages
+ )
+{
+ return InternalAllocatePages (EfiBootServicesData, Pages);
+}
+
+/**
+ Allocates one or more 4KB pages of type EfiRuntimeServicesData.
+
+ Allocates the number of 4KB pages of type EfiRuntimeServicesData and returns a pointer to the
+ allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL
+ is returned. If there is not enough memory remaining to satisfy the request, then NULL is
+ returned.
+
+ @param Pages The number of 4 KB pages to allocate.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateRuntimePages (
+ IN UINTN Pages
+ )
+{
+ return InternalAllocatePages (EfiRuntimeServicesData, Pages);
+}
+
+/**
+ Allocates one or more 4KB pages of type EfiReservedMemoryType.
+
+ Allocates the number of 4KB pages of type EfiReservedMemoryType and returns a pointer to the
+ allocated buffer. The buffer returned is aligned on a 4KB boundary. If Pages is 0, then NULL
+ is returned. If there is not enough memory remaining to satisfy the request, then NULL is
+ returned.
+
+ @param Pages The number of 4 KB pages to allocate.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateReservedPages (
+ IN UINTN Pages
+ )
+{
+ return InternalAllocatePages (EfiReservedMemoryType, Pages);
+}
+
+/**
+ Frees one or more 4KB pages that were previously allocated with one of the page allocation
+ functions in the Memory Allocation Library.
+
+ Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer. Buffer
+ must have been allocated on a previous call to the page allocation services of the Memory
+ Allocation Library.
+ If Buffer was not allocated with a page allocation function in the Memory Allocation Library,
+ then ASSERT().
+ If Pages is zero, then ASSERT().
+
+ @param Buffer Pointer to the buffer of pages to free.
+ @param Pages The number of 4 KB pages to free.
+
+**/
+VOID
+EFIAPI
+GlueFreePages (
+ IN VOID *Buffer,
+ IN UINTN Pages
+ )
+{
+ //
+ // PEI phase does not support to free pages, so leave it as NOP.
+ //
+}
+
+/**
+ Allocates one or more 4KB pages of a certain memory type at a specified alignment.
+
+ Allocates the number of 4KB pages specified by Pages of a certain memory type with an alignment
+ specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is returned.
+ If there is not enough memory at the specified alignment remaining to satisfy the request, then
+ NULL is returned.
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().
+
+ @param MemoryType The type of memory to allocate.
+ @param Pages The number of 4 KB pages to allocate.
+ @param Alignment The requested alignment of the allocation. Must be a power of two.
+ If Alignment is zero, then byte alignment is used.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+InternalAllocateAlignedPages (
+ IN EFI_MEMORY_TYPE MemoryType,
+ IN UINTN Pages,
+ IN UINTN Alignment
+ )
+{
+ VOID *Memory;
+ UINTN AlignmentMask;
+
+ //
+ // Alignment must be a power of two or zero.
+ //
+ ASSERT ((Alignment & (Alignment - 1)) == 0);
+
+ if (Pages == 0) {
+ return NULL;
+ }
+ //
+ // Make sure that Pages plus EFI_SIZE_TO_PAGES (Alignment) does not overflow.
+ //
+ ASSERT (Pages <= (MAX_ADDRESS - EFI_SIZE_TO_PAGES (Alignment)));
+ //
+ // We would rather waste some memory to save PEI code size.
+ //
+ Memory = InternalAllocatePages (MemoryType, Pages + EFI_SIZE_TO_PAGES (Alignment));
+ if (Alignment == 0) {
+ AlignmentMask = Alignment;
+ } else {
+ AlignmentMask = Alignment - 1;
+ }
+ return (VOID *) (UINTN) (((UINTN) Memory + AlignmentMask) & ~AlignmentMask);
+}
+
+/**
+ Allocates one or more 4KB pages of type EfiBootServicesData at a specified alignment.
+
+ Allocates the number of 4KB pages specified by Pages of type EfiBootServicesData with an
+ alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is
+ returned. If there is not enough memory at the specified alignment remaining to satisfy the
+ request, then NULL is returned.
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().
+
+ @param Pages The number of 4 KB pages to allocate.
+ @param Alignment The requested alignment of the allocation. Must be a power of two.
+ If Alignment is zero, then byte alignment is used.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateAlignedPages (
+ IN UINTN Pages,
+ IN UINTN Alignment
+ )
+{
+ return InternalAllocateAlignedPages (EfiBootServicesData, Pages, Alignment);
+}
+
+/**
+ Allocates one or more 4KB pages of type EfiRuntimeServicesData at a specified alignment.
+
+ Allocates the number of 4KB pages specified by Pages of type EfiRuntimeServicesData with an
+ alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is
+ returned. If there is not enough memory at the specified alignment remaining to satisfy the
+ request, then NULL is returned.
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().
+
+ @param Pages The number of 4 KB pages to allocate.
+ @param Alignment The requested alignment of the allocation. Must be a power of two.
+ If Alignment is zero, then byte alignment is used.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateAlignedRuntimePages (
+ IN UINTN Pages,
+ IN UINTN Alignment
+ )
+{
+ return InternalAllocateAlignedPages (EfiRuntimeServicesData, Pages, Alignment);
+}
+
+/**
+ Allocates one or more 4KB pages of type EfiReservedMemoryType at a specified alignment.
+
+ Allocates the number of 4KB pages specified by Pages of type EfiReservedMemoryType with an
+ alignment specified by Alignment. The allocated buffer is returned. If Pages is 0, then NULL is
+ returned. If there is not enough memory at the specified alignment remaining to satisfy the
+ request, then NULL is returned.
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().
+
+ @param Pages The number of 4 KB pages to allocate.
+ @param Alignment The requested alignment of the allocation. Must be a power of two.
+ If Alignment is zero, then byte alignment is used.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateAlignedReservedPages (
+ IN UINTN Pages,
+ IN UINTN Alignment
+ )
+{
+ return InternalAllocateAlignedPages (EfiReservedMemoryType, Pages, Alignment);
+}
+
+/**
+ Frees one or more 4KB pages that were previously allocated with one of the aligned page
+ allocation functions in the Memory Allocation Library.
+
+ Frees the number of 4KB pages specified by Pages from the buffer specified by Buffer. Buffer
+ must have been allocated on a previous call to the aligned page allocation services of the Memory
+ Allocation Library.
+ If Buffer was not allocated with an aligned page allocation function in the Memory Allocation
+ Library, then ASSERT().
+ If Pages is zero, then ASSERT().
+
+ @param Buffer Pointer to the buffer of pages to free.
+ @param Pages The number of 4 KB pages to free.
+
+**/
+VOID
+EFIAPI
+FreeAlignedPages (
+ IN VOID *Buffer,
+ IN UINTN Pages
+ )
+{
+ //
+ // PEI phase does not support to free pages, so leave it as NOP.
+ //
+}
+
+/**
+ Allocates a buffer of a certain pool type.
+
+ Allocates the number bytes specified by AllocationSize of a certain pool type and returns a
+ pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is
+ returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.
+
+ @param MemoryType The type of memory to allocate.
+ @param AllocationSize The number of bytes to allocate.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+InternalAllocatePool (
+ IN EFI_MEMORY_TYPE MemoryType,
+ IN UINTN AllocationSize
+ )
+{
+ //
+ // If we need lots of small runtime/reserved memory type from PEI in the future,
+ // we can consider providing a more complex algorithm that allocates runtime pages and
+ // provide pool allocations from those pages.
+ //
+ return InternalAllocatePages (MemoryType, EFI_SIZE_TO_PAGES (AllocationSize));
+}
+
+/**
+ Allocates a buffer of type EfiBootServicesData.
+
+ Allocates the number bytes specified by AllocationSize of type EfiBootServicesData and returns a
+ pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is
+ returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.
+
+ @param AllocationSize The number of bytes to allocate.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+GlueAllocatePool (
+ IN UINTN AllocationSize
+ )
+{
+ EFI_STATUS Status;
+ EFI_PEI_SERVICES **PeiServices;
+ VOID *Buffer;
+
+ PeiServices = GetPeiServicesTablePointer ();
+
+ Status = ((*PeiServices)->AllocatePool) (PeiServices, AllocationSize, &Buffer);
+ if (EFI_ERROR (Status)) {
+ Buffer = NULL;
+ }
+ return Buffer;
+}
+
+/**
+ Allocates a buffer of type EfiRuntimeServicesData.
+
+ Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData and returns
+ a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is
+ returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.
+
+ @param AllocationSize The number of bytes to allocate.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateRuntimePool (
+ IN UINTN AllocationSize
+ )
+{
+ return InternalAllocatePool (EfiRuntimeServicesData, AllocationSize);
+}
+
+/**
+ Allocates a buffer of type EfieservedMemoryType.
+
+ Allocates the number bytes specified by AllocationSize of type EfieservedMemoryType and returns
+ a pointer to the allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is
+ returned. If there is not enough memory remaining to satisfy the request, then NULL is returned.
+
+ @param AllocationSize The number of bytes to allocate.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateReservedPool (
+ IN UINTN AllocationSize
+ )
+{
+ return InternalAllocatePool (EfiReservedMemoryType, AllocationSize);
+}
+
+/**
+ Allocates and zeros a buffer of a certian pool type.
+
+ Allocates the number bytes specified by AllocationSize of a certian pool type, clears the buffer
+ with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a valid
+ buffer of 0 size is returned. If there is not enough memory remaining to satisfy the request,
+ then NULL is returned.
+
+ @param PoolType The type of memory to allocate.
+ @param AllocationSize The number of bytes to allocate and zero.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+InternalAllocateZeroPool (
+ IN EFI_MEMORY_TYPE PoolType,
+ IN UINTN AllocationSize
+ )
+{
+ VOID *Memory;
+
+ Memory = InternalAllocatePool (PoolType, AllocationSize);
+ if (Memory != NULL) {
+ Memory = ZeroMem (Memory, AllocationSize);
+ }
+ return Memory;
+}
+
+/**
+ Allocates and zeros a buffer of type EfiBootServicesData.
+
+ Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, clears the
+ buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a
+ valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the
+ request, then NULL is returned.
+
+ @param AllocationSize The number of bytes to allocate and zero.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+GlueAllocateZeroPool (
+ IN UINTN AllocationSize
+ )
+{
+ VOID *Memory;
+
+ Memory = AllocatePool (AllocationSize);
+ if (Memory != NULL) {
+ Memory = ZeroMem (Memory, AllocationSize);
+ }
+ return Memory;
+}
+
+/**
+ Allocates and zeros a buffer of type EfiRuntimeServicesData.
+
+ Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, clears the
+ buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a
+ valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the
+ request, then NULL is returned.
+
+ @param AllocationSize The number of bytes to allocate and zero.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateRuntimeZeroPool (
+ IN UINTN AllocationSize
+ )
+{
+ return InternalAllocateZeroPool (EfiRuntimeServicesData, AllocationSize);
+}
+
+/**
+ Allocates and zeros a buffer of type EfiReservedMemoryType.
+
+ Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, clears the
+ buffer with zeros, and returns a pointer to the allocated buffer. If AllocationSize is 0, then a
+ valid buffer of 0 size is returned. If there is not enough memory remaining to satisfy the
+ request, then NULL is returned.
+
+ @param AllocationSize The number of bytes to allocate and zero.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateReservedZeroPool (
+ IN UINTN AllocationSize
+ )
+{
+ return InternalAllocateZeroPool (EfiReservedMemoryType, AllocationSize);
+}
+
+/**
+ Copies a buffer to an allocated buffer of a certian pool type.
+
+ Allocates the number bytes specified by AllocationSize of a certian pool type, copies
+ AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
+ allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
+ is not enough memory remaining to satisfy the request, then NULL is returned.
+ If Buffer is NULL, then ASSERT().
+ If AllocationSize is greater than (MAX_ADDRESS ?Buffer + 1), then ASSERT().
+
+ @param PoolType The type of pool to allocate.
+ @param AllocationSize The number of bytes to allocate and zero.
+ @param Buffer The buffer to copy to the allocated buffer.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+InternalAllocateCopyPool (
+ IN EFI_MEMORY_TYPE PoolType,
+ IN UINTN AllocationSize,
+ IN CONST VOID *Buffer
+ )
+{
+ VOID *Memory;
+
+ ASSERT (Buffer != NULL);
+ ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN) Buffer + 1));
+
+ Memory = InternalAllocatePool (PoolType, AllocationSize);
+ if (Memory != NULL) {
+ Memory = CopyMem (Memory, Buffer, AllocationSize);
+ }
+ return Memory;
+}
+
+/**
+ Copies a buffer to an allocated buffer of type EfiBootServicesData.
+
+ Allocates the number bytes specified by AllocationSize of type EfiBootServicesData, copies
+ AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
+ allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
+ is not enough memory remaining to satisfy the request, then NULL is returned.
+ If Buffer is NULL, then ASSERT().
+ If AllocationSize is greater than (MAX_ADDRESS ?Buffer + 1), then ASSERT().
+
+ @param AllocationSize The number of bytes to allocate and zero.
+ @param Buffer The buffer to copy to the allocated buffer.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+GlueAllocateCopyPool (
+ IN UINTN AllocationSize,
+ IN CONST VOID *Buffer
+ )
+{
+ VOID *Memory;
+
+ ASSERT (Buffer != NULL);
+ ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN) Buffer + 1));
+
+ Memory = AllocatePool (AllocationSize);
+ if (Memory != NULL) {
+ Memory = CopyMem (Memory, Buffer, AllocationSize);
+ }
+ return Memory;
+}
+
+/**
+ Copies a buffer to an allocated buffer of type EfiRuntimeServicesData.
+
+ Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData, copies
+ AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
+ allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
+ is not enough memory remaining to satisfy the request, then NULL is returned.
+ If Buffer is NULL, then ASSERT().
+ If AllocationSize is greater than (MAX_ADDRESS ?Buffer + 1), then ASSERT().
+
+ @param AllocationSize The number of bytes to allocate and zero.
+ @param Buffer The buffer to copy to the allocated buffer.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateRuntimeCopyPool (
+ IN UINTN AllocationSize,
+ IN CONST VOID *Buffer
+ )
+{
+ return InternalAllocateCopyPool (EfiRuntimeServicesData, AllocationSize, Buffer);
+}
+
+/**
+ Copies a buffer to an allocated buffer of type EfiReservedMemoryType.
+
+ Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType, copies
+ AllocationSize bytes from Buffer to the newly allocated buffer, and returns a pointer to the
+ allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
+ is not enough memory remaining to satisfy the request, then NULL is returned.
+ If Buffer is NULL, then ASSERT().
+ If AllocationSize is greater than (MAX_ADDRESS ?Buffer + 1), then ASSERT().
+
+ @param AllocationSize The number of bytes to allocate and zero.
+ @param Buffer The buffer to copy to the allocated buffer.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateReservedCopyPool (
+ IN UINTN AllocationSize,
+ IN CONST VOID *Buffer
+ )
+{
+ return InternalAllocateCopyPool (EfiReservedMemoryType, AllocationSize, Buffer);
+}
+
+/**
+ Frees a buffer that was previously allocated with one of the pool allocation functions in the
+ Memory Allocation Library.
+
+ Frees the buffer specified by Buffer. Buffer must have been allocated on a previous call to the
+ pool allocation services of the Memory Allocation Library.
+ If Buffer was not allocated with a pool allocation function in the Memory Allocation Library,
+ then ASSERT().
+
+ @param Buffer Pointer to the buffer to free.
+
+**/
+VOID
+EFIAPI
+GlueFreePool (
+ IN VOID *Buffer
+ )
+{
+ //
+ // PEI phase does not support to free pool, so leave it as NOP.
+ //
+}
+
+/**
+ Allocates a buffer of a certain pool type at a specified alignment.
+
+ Allocates the number bytes specified by AllocationSize of a certain pool type with an alignment
+ specified by Alignment. The allocated buffer is returned. If AllocationSize is 0, then a valid
+ buffer of 0 size is returned. If there is not enough memory at the specified alignment remaining
+ to satisfy the request, then NULL is returned.
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().
+
+ @param PoolType The type of pool to allocate.
+ @param AllocationSize The number of bytes to allocate.
+ @param Alignment The requested alignment of the allocation. Must be a power of two. If Alignment is zero, then byte alignment is used.
+ If Alignment is zero, then byte alignment is used.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+InternalAllocateAlignedPool (
+ IN EFI_MEMORY_TYPE PoolType,
+ IN UINTN AllocationSize,
+ IN UINTN Alignment
+ )
+{
+ VOID *RawAddress;
+ UINTN AlignedAddress;
+ UINTN AlignmentMask;
+
+ //
+ // Alignment must be a power of two or zero.
+ //
+ ASSERT ((Alignment & (Alignment - 1)) == 0);
+
+ if (Alignment == 0) {
+ AlignmentMask = Alignment;
+ } else {
+ AlignmentMask = Alignment - 1;
+ }
+ //
+ // Make sure that AllocationSize plus AlignmentMask does not overflow.
+ //
+ ASSERT (AllocationSize <= (MAX_ADDRESS - AlignmentMask));
+
+ RawAddress = InternalAllocatePool (PoolType, AllocationSize + AlignmentMask);
+
+ AlignedAddress = ((UINTN) RawAddress + AlignmentMask) & ~AlignmentMask;
+
+ return (VOID *) AlignedAddress;
+}
+
+/**
+ Allocates a buffer of type EfiBootServicesData at a specified alignment.
+
+ Allocates the number bytes specified by AllocationSize of type EfiBootServicesData with an
+ alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0,
+ then a valid buffer of 0 size is returned. If there is not enough memory at the specified
+ alignment remaining to satisfy the request, then NULL is returned.
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().
+
+ @param AllocationSize The number of bytes to allocate.
+ @param Alignment The requested alignment of the allocation. Must be a power of two.
+ If Alignment is zero, then byte alignment is used.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateAlignedPool (
+ IN UINTN AllocationSize,
+ IN UINTN Alignment
+ )
+{
+ VOID *RawAddress;
+ UINTN AlignedAddress;
+ UINTN AlignmentMask;
+
+ //
+ // Alignment must be a power of two or zero.
+ //
+ ASSERT ((Alignment & (Alignment - 1)) == 0);
+
+ if (Alignment == 0) {
+ AlignmentMask = Alignment;
+ } else {
+ AlignmentMask = Alignment - 1;
+ }
+
+ //
+ // Make sure that AllocationSize plus AlignmentMask does not overflow.
+ //
+ ASSERT (AllocationSize <= (MAX_ADDRESS - AlignmentMask));
+
+ RawAddress = AllocatePool (AllocationSize + AlignmentMask);
+
+ AlignedAddress = ((UINTN) RawAddress + AlignmentMask) & ~AlignmentMask;
+
+ return (VOID *) AlignedAddress;
+}
+
+/**
+ Allocates a buffer of type EfiRuntimeServicesData at a specified alignment.
+
+ Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData with an
+ alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0,
+ then a valid buffer of 0 size is returned. If there is not enough memory at the specified
+ alignment remaining to satisfy the request, then NULL is returned.
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().
+
+ @param AllocationSize The number of bytes to allocate.
+ @param Alignment The requested alignment of the allocation. Must be a power of two.
+ If Alignment is zero, then byte alignment is used.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateAlignedRuntimePool (
+ IN UINTN AllocationSize,
+ IN UINTN Alignment
+ )
+{
+ return InternalAllocateAlignedPool (EfiRuntimeServicesData, AllocationSize, Alignment);
+}
+
+/**
+ Allocates a buffer of type EfieservedMemoryType at a specified alignment.
+
+ Allocates the number bytes specified by AllocationSize of type EfieservedMemoryType with an
+ alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0,
+ then a valid buffer of 0 size is returned. If there is not enough memory at the specified
+ alignment remaining to satisfy the request, then NULL is returned.
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().
+
+ @param AllocationSize The number of bytes to allocate.
+ @param Alignment The requested alignment of the allocation. Must be a power of two.
+ If Alignment is zero, then byte alignment is used.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateAlignedReservedPool (
+ IN UINTN AllocationSize,
+ IN UINTN Alignment
+ )
+{
+ return InternalAllocateAlignedPool (EfiReservedMemoryType, AllocationSize, Alignment);
+}
+
+/**
+ Allocates and zeros a buffer of a certain pool type at a specified alignment.
+
+ Allocates the number bytes specified by AllocationSize of a certain pool type with an alignment
+ specified by Alignment, clears the buffer with zeros, and returns a pointer to the allocated
+ buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there is not
+ enough memory at the specified alignment remaining to satisfy the request, then NULL is returned.
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().
+
+ @param PoolType The type of pool to allocate.
+ @param AllocationSize The number of bytes to allocate.
+ @param Alignment The requested alignment of the allocation. Must be a power of two.
+ If Alignment is zero, then byte alignment is used.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+InternalAllocateAlignedZeroPool (
+ IN EFI_MEMORY_TYPE PoolType,
+ IN UINTN AllocationSize,
+ IN UINTN Alignment
+ )
+{
+ VOID *Memory;
+
+ Memory = InternalAllocateAlignedPool (PoolType, AllocationSize, Alignment);
+ if (Memory != NULL) {
+ Memory = ZeroMem (Memory, AllocationSize);
+ }
+ return Memory;
+}
+
+/**
+ Allocates and zeros a buffer of type EfiBootServicesData at a specified alignment.
+
+ Allocates the number bytes specified by AllocationSize of type EfiBootServicesData with an
+ alignment specified by Alignment, clears the buffer with zeros, and returns a pointer to the
+ allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
+ is not enough memory at the specified alignment remaining to satisfy the request, then NULL is
+ returned.
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().
+
+ @param AllocationSize The number of bytes to allocate.
+ @param Alignment The requested alignment of the allocation. Must be a power of two.
+ If Alignment is zero, then byte alignment is used.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateAlignedZeroPool (
+ IN UINTN AllocationSize,
+ IN UINTN Alignment
+ )
+{
+ VOID *Memory;
+
+ Memory = AllocateAlignedPool (AllocationSize, Alignment);
+ if (Memory != NULL) {
+ Memory = ZeroMem (Memory, AllocationSize);
+ }
+ return Memory;
+}
+
+/**
+ Allocates and zeros a buffer of type EfiRuntimeServicesData at a specified alignment.
+
+ Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData with an
+ alignment specified by Alignment, clears the buffer with zeros, and returns a pointer to the
+ allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
+ is not enough memory at the specified alignment remaining to satisfy the request, then NULL is
+ returned.
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().
+
+ @param AllocationSize The number of bytes to allocate.
+ @param Alignment The requested alignment of the allocation. Must be a power of two.
+ If Alignment is zero, then byte alignment is used.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateAlignedRuntimeZeroPool (
+ IN UINTN AllocationSize,
+ IN UINTN Alignment
+ )
+{
+ return InternalAllocateAlignedZeroPool (EfiRuntimeServicesData, AllocationSize, Alignment);
+}
+
+/**
+ Allocates and zeros a buffer of type EfieservedMemoryType at a specified alignment.
+
+ Allocates the number bytes specified by AllocationSize of type EfieservedMemoryType with an
+ alignment specified by Alignment, clears the buffer with zeros, and returns a pointer to the
+ allocated buffer. If AllocationSize is 0, then a valid buffer of 0 size is returned. If there
+ is not enough memory at the specified alignment remaining to satisfy the request, then NULL is
+ returned.
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().
+
+ @param AllocationSize The number of bytes to allocate.
+ @param Alignment The requested alignment of the allocation. Must be a power of two.
+ If Alignment is zero, then byte alignment is used.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateAlignedReservedZeroPool (
+ IN UINTN AllocationSize,
+ IN UINTN Alignment
+ )
+{
+ return InternalAllocateAlignedZeroPool (EfiReservedMemoryType, AllocationSize, Alignment);
+}
+
+/**
+ Copies a buffer to an allocated buffer of a certain pool type at a specified alignment.
+
+ Allocates the number bytes specified by AllocationSize of a certain pool type with an alignment
+ specified by Alignment. The allocated buffer is returned. If AllocationSize is 0, then a valid
+ buffer of 0 size is returned. If there is not enough memory at the specified alignment remaining
+ to satisfy the request, then NULL is returned.
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().
+
+ @param PoolType The type of pool to allocate.
+ @param AllocationSize The number of bytes to allocate.
+ @param Buffer The buffer to copy to the allocated buffer.
+ @param Alignment The requested alignment of the allocation. Must be a power of two.
+ If Alignment is zero, then byte alignment is used.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+InternalAllocateAlignedCopyPool (
+ IN EFI_MEMORY_TYPE PoolType,
+ IN UINTN AllocationSize,
+ IN CONST VOID *Buffer,
+ IN UINTN Alignment
+ )
+{
+ VOID *Memory;
+
+ ASSERT (Buffer != NULL);
+ ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN) Buffer + 1));
+
+ Memory = InternalAllocateAlignedPool (PoolType, AllocationSize, Alignment);
+ if (Memory != NULL) {
+ Memory = CopyMem (Memory, Buffer, AllocationSize);
+ }
+ return Memory;
+}
+
+/**
+ Copies a buffer to an allocated buffer of type EfiBootServicesData at a specified alignment.
+
+ Allocates the number bytes specified by AllocationSize of type EfiBootServicesData type with an
+ alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0,
+ then a valid buffer of 0 size is returned. If there is not enough memory at the specified
+ alignment remaining to satisfy the request, then NULL is returned.
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().
+
+ @param AllocationSize The number of bytes to allocate.
+ @param Buffer The buffer to copy to the allocated buffer.
+ @param Alignment The requested alignment of the allocation. Must be a power of two.
+ If Alignment is zero, then byte alignment is used.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateAlignedCopyPool (
+ IN UINTN AllocationSize,
+ IN CONST VOID *Buffer,
+ IN UINTN Alignment
+ )
+{
+ VOID *Memory;
+
+ ASSERT (Buffer != NULL);
+ ASSERT (AllocationSize <= (MAX_ADDRESS - (UINTN) Buffer + 1));
+
+ Memory = AllocateAlignedPool (AllocationSize, Alignment);
+ if (Memory != NULL) {
+ Memory = CopyMem (Memory, Buffer, AllocationSize);
+ }
+ return Memory;
+}
+
+/**
+ Copies a buffer to an allocated buffer of type EfiRuntimeServicesData at a specified alignment.
+
+ Allocates the number bytes specified by AllocationSize of type EfiRuntimeServicesData type with an
+ alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0,
+ then a valid buffer of 0 size is returned. If there is not enough memory at the specified
+ alignment remaining to satisfy the request, then NULL is returned.
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().
+
+ @param AllocationSize The number of bytes to allocate.
+ @param Buffer The buffer to copy to the allocated buffer.
+ @param Alignment The requested alignment of the allocation. Must be a power of two.
+ If Alignment is zero, then byte alignment is used.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateAlignedRuntimeCopyPool (
+ IN UINTN AllocationSize,
+ IN CONST VOID *Buffer,
+ IN UINTN Alignment
+ )
+{
+ return InternalAllocateAlignedCopyPool (EfiRuntimeServicesData, AllocationSize, Buffer, Alignment);
+}
+
+/**
+ Copies a buffer to an allocated buffer of type EfiReservedMemoryType at a specified alignment.
+
+ Allocates the number bytes specified by AllocationSize of type EfiReservedMemoryType type with an
+ alignment specified by Alignment. The allocated buffer is returned. If AllocationSize is 0,
+ then a valid buffer of 0 size is returned. If there is not enough memory at the specified
+ alignment remaining to satisfy the request, then NULL is returned.
+ If Alignment is not a power of two and Alignment is not zero, then ASSERT().
+
+ @param AllocationSize The number of bytes to allocate.
+ @param Buffer The buffer to copy to the allocated buffer.
+ @param Alignment The requested alignment of the allocation. Must be a power of two.
+ If Alignment is zero, then byte alignment is used.
+
+ @return A pointer to the allocated buffer or NULL if allocation fails.
+
+**/
+VOID *
+EFIAPI
+AllocateAlignedReservedCopyPool (
+ IN UINTN AllocationSize,
+ IN CONST VOID *Buffer,
+ IN UINTN Alignment
+ )
+{
+ return InternalAllocateAlignedCopyPool (EfiReservedMemoryType, AllocationSize, Buffer, Alignment);
+}
+
+/**
+ Frees a buffer that was previously allocated with one of the aligned pool allocation functions
+ in the Memory Allocation Library.
+
+ Frees the buffer specified by Buffer. Buffer must have been allocated on a previous call to the
+ aligned pool allocation services of the Memory Allocation Library.
+ If Buffer was not allocated with an aligned pool allocation function in the Memory Allocation
+ Library, then ASSERT().
+
+ @param Buffer Pointer to the buffer to free.
+
+**/
+VOID
+EFIAPI
+FreeAlignedPool (
+ IN VOID *Buffer
+ )
+{
+ //
+ // PEI phase does not support to free pool, so leave it as NOP.
+ //
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf
new file mode 100644
index 0000000..f576bc5
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiMemoryAllocationLib/PeiMemoryAllocationLib.inf
@@ -0,0 +1,85 @@
+#/*++
+#
+# Copyright (c) 2004 - 2006, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# PeiMemoryAllocationLib.inf
+#
+# Abstract:
+#
+# Component description file for PeiMemoryAllocationLib.
+#
+#--*/
+
+[defines]
+BASE_NAME = EdkIIGluePeiMemoryAllocationLib
+COMPONENT_TYPE = LIBRARY
+
+[sources.common]
+ MemoryAllocationLib.c
+
+[sources.ia32]
+
+
+[sources.x64]
+
+
+[sources.ipf]
+
+
+[sources.ebc]
+
+
+[includes.common]
+ .
+ ..\..\Include
+ ..\..\include\Library
+ $(EDK_SOURCE)\Foundation
+ $(EDK_SOURCE)\Foundation\Include\Pei
+ $(EDK_SOURCE)\Foundation\Framework
+ $(EDK_SOURCE)\Foundation\Efi
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+ $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include
+
+[libraries.common]
+ EdkIIGlueBaseMemoryLib
+ EdkIIGluePeiServicesTablePointerLibMm7
+#
+# If necessary, EdkIIGluePeiSerivcesTablePointerLib can be used to
+# replaced EdkIIGluePeiServicesTablePointerLibMm7
+#
+
+[libraries.ia32]
+
+
+[libraries.x64]
+
+
+[nmake.common]
+ C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION
+ LIB_STD_FLAGS = /NOLOGO /IGNORE:4006
+
+[nmake.ia32]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32
+
+[nmake.x64]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64
+
+[nmake.ipf]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF
+
+[nmake.ebc]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiReportStatusCodeLib/EdkIIGluePeiReportStatusCodeLib.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiReportStatusCodeLib/EdkIIGluePeiReportStatusCodeLib.cif
new file mode 100644
index 0000000..a3b9273
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiReportStatusCodeLib/EdkIIGluePeiReportStatusCodeLib.cif
@@ -0,0 +1,11 @@
+<component>
+ name = "EdkIIGluePeiReportStatusCodeLib"
+ category = ModulePart
+ LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\PeiReportStatusCodeLib"
+ RefName = "EdkIIGluePeiReportStatusCodeLib"
+[files]
+"EdkIIGluePeiReportStatusCodeLib.sdl"
+"EdkIIGluePeiReportStatusCodeLib.mak"
+"PeiReportStatusCodeLib.inf"
+"ReportStatusCodeLib.c"
+<endComponent>
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiReportStatusCodeLib/EdkIIGluePeiReportStatusCodeLib.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiReportStatusCodeLib/EdkIIGluePeiReportStatusCodeLib.mak
new file mode 100644
index 0000000..f6f35d6
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiReportStatusCodeLib/EdkIIGluePeiReportStatusCodeLib.mak
@@ -0,0 +1,89 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGluePeiReportStatusCodeLib/EdkIIGluePeiReportStatusCodeLib.mak 1 1/20/12 3:57a Jeffch $
+#
+# $Revision: 1 $
+#
+# $Date: 1/20/12 3:57a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGluePeiReportStatusCodeLib/EdkIIGluePeiReportStatusCodeLib.mak $
+#
+# 1 1/20/12 3:57a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 9/27/11 6:19a Wesleychen
+# Intel EDK initially releases.
+#
+# 1 9/18/09 1:57a Iminglin
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: EdkIIGluePeiReportStatusCodeLib.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+
+
+$(EdkIIGluePeiReportStatusCodeLib_LIB) : EdkIIGluePeiReportStatusCodeLib
+
+EdkIIGluePeiReportStatusCodeLib : $(BUILD_DIR)\EdkIIGluePeiReportStatusCodeLib.mak EdkIIGluePeiReportStatusCodeLibBin
+
+$(BUILD_DIR)\EdkIIGluePeiReportStatusCodeLib.mak : $(EdkIIGluePeiReportStatusCodeLib_DIR)\$(@B).cif $(EdkIIGluePeiReportStatusCodeLib_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(EdkIIGluePeiReportStatusCodeLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+EdkIIGluePeiReportStatusCodeLib_LIB_LINKS=$(EdkIIGlueBaseLib_LIB)\
+$(EdkIIGlueBaseMemoryLib_LIB)\
+$(EdkIIGlueBaseIoLibIntrinsic_LIB)\
+$(EDKFRAMEWORKGUIDLIB)\
+$(EDKGUIDLIB)\
+!IF "$(PROCESSOR)"=="IA32" || "$(PROCESSOR)"=="x64"
+$(EdkIIGluePeiServicesTablePointerLibMm7_LIB)
+!ENDIF
+
+EdkIIGluePeiReportStatusCodeLibBin : $(EdkIIGluePeiReportStatusCodeLib_LIB_LINKS)
+!IF "$(x64_BUILD)"=="1"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGluePeiReportStatusCodeLib.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGluePeiReportStatusCodeLib_LIB)"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\IA32\
+ /f $(BUILD_DIR)\EdkIIGluePeiReportStatusCodeLib.mak all\
+ TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGluePeiReportStatusCodeLib_LIB)"
+!ELSE
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGluePeiReportStatusCodeLib.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGluePeiReportStatusCodeLib_LIB)"
+!ENDIF
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiReportStatusCodeLib/EdkIIGluePeiReportStatusCodeLib.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiReportStatusCodeLib/EdkIIGluePeiReportStatusCodeLib.sdl
new file mode 100644
index 0000000..b6aae58
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiReportStatusCodeLib/EdkIIGluePeiReportStatusCodeLib.sdl
@@ -0,0 +1,26 @@
+TOKEN
+ Name = "EdkIIGluePeiReportStatusCodeLib_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable EdkIIGluePeiReportStatusCodeLib support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "EdkIIGluePeiReportStatusCodeLib_LIB"
+ Value = "$$(LIB_BUILD_DIR)\EdkIIGluePeiReportStatusCodeLib.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "EdkIIGluePeiReportStatusCodeLib_DIR"
+End
+
+MODULE
+ Help = "Includes EdkIIGluePeiReportStatusCodeLib.mak to Project"
+ File = "EdkIIGluePeiReportStatusCodeLib.mak"
+End
+
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiReportStatusCodeLib/PeiReportStatusCodeLib.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiReportStatusCodeLib/PeiReportStatusCodeLib.inf
new file mode 100644
index 0000000..0e3f804
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiReportStatusCodeLib/PeiReportStatusCodeLib.inf
@@ -0,0 +1,92 @@
+#/*++
+#
+# Copyright (c) 2004 - 2006, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# PeiReportStatusCodeLib.inf
+#
+# Abstract:
+#
+# Component description file for PeiReportStatusCodeLib.
+#
+#--*/
+
+[defines]
+BASE_NAME = EdkIIGluePeiReportStatusCodeLib
+COMPONENT_TYPE = LIBRARY
+
+[sources.common]
+ ReportStatusCodeLib.c
+
+[sources.ia32]
+
+
+[sources.x64]
+
+
+[sources.ipf]
+
+
+[sources.ebc]
+
+
+[includes.common]
+ .
+ ..\..\Include
+ ..\..\include\Library
+ $(EDK_SOURCE)\Foundation
+ $(EDK_SOURCE)\Foundation\Include\Pei
+ $(EDK_SOURCE)\Foundation\Framework
+ $(EDK_SOURCE)\Foundation\Efi
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+ $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include
+ $(EDK_SOURCE)\Foundation\Framework\Guid\DataHubRecords
+ $(EDK_SOURCE)\Foundation\Framework\Guid\StatusCodeDataTypeId
+
+[libraries.common]
+ EdkIIGlueBaseLib
+ EdkIIGlueBaseMemoryLib
+ EdkIIGlueBaseIoLibIntrinsic
+ EdkIIGluePeiServicesTablePointerLibMm7
+#
+# If necessary, EdkIIGluePeiServicesTablePointerLib can be used
+# to replace EdkIIGluePeiServicesTablePointerLibMm7
+#
+ EdkFrameworkGuidLib
+# Possibly, gEfiCallerIdGuid might be used.
+ EdkGuidLib
+
+[libraries.ia32]
+
+
+[libraries.x64]
+
+
+[nmake.common]
+ C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION
+ LIB_STD_FLAGS = /NOLOGO /IGNORE:4006
+
+[nmake.ia32]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32
+
+[nmake.x64]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64
+
+[nmake.ipf]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF
+
+[nmake.ebc]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiReportStatusCodeLib/ReportStatusCodeLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiReportStatusCodeLib/ReportStatusCodeLib.c
new file mode 100644
index 0000000..d4292f5
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiReportStatusCodeLib/ReportStatusCodeLib.c
@@ -0,0 +1,527 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ ReportStatusCodeLib.c
+
+Abstract:
+
+ Report Status Code Lib
+
+--*/
+
+#include "EdkIIGluePeim.h"
+#include "Pcd\EdkIIGluePcdReportStatusCodeLib.h"
+
+//
+// Define the maximum extended data size that is supported in the PEI phase
+//
+#define MAX_EXTENDED_DATA_SIZE 0x200
+
+/**
+ Internal worker function that reports a status code through the Status Code Protocol
+
+ This function checks to see if a Status Code Protocol is present in the handle
+ database. If a Status Code Protocol is not present, then EFI_UNSUPPORTED is
+ returned. If a Status Code Protocol is present, then it is cached in gStatusCode,
+ and the ReportStatusCode() service of the Status Code Protocol is called passing in
+ Type, Value, Instance, CallerId, and Data. The result of this call is returned.
+
+ @param Type Status code type.
+ @param Value Status code value.
+ @param Instance Status code instance number.
+ @param CallerId Pointer to a GUID that identifies the caller of this
+ function. This is an optional parameter that may be
+ NULL.
+ @param Data Pointer to the extended data buffer. This is an
+ optional parameter that may be NULL.
+
+ @retval EFI_SUCCESS The status code was reported.
+ @retval EFI_OUT_OF_RESOURCES There were not enough resources to report the status code.
+ @retval EFI_UNSUPPORTED Status Code Protocol is not available.
+
+**/
+EFI_STATUS
+InternalReportStatusCode (
+ IN EFI_STATUS_CODE_TYPE Type,
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN UINT32 Instance,
+ IN CONST EFI_GUID *CallerId OPTIONAL,
+ IN EFI_STATUS_CODE_DATA *Data OPTIONAL
+ )
+{
+ EFI_PEI_SERVICES **PeiServices;
+
+ PeiServices = GetPeiServicesTablePointer ();
+ return (*PeiServices)->PeiReportStatusCode (
+ PeiServices,
+ Type,
+ Value,
+ Instance,
+ (EFI_GUID *)CallerId,
+ Data
+ );
+}
+
+
+/**
+ Converts a status code to an 8-bit POST code value.
+
+ Converts the status code specified by CodeType and Value to an 8-bit POST code
+ and returns the 8-bit POST code in PostCode. If CodeType is an
+ EFI_PROGRESS_CODE or CodeType is an EFI_ERROR_CODE, then bits 0..4 of PostCode
+ are set to bits 16..20 of Value, and bits 5..7 of PostCode are set to bits
+ 24..26 of Value., and TRUE is returned. Otherwise, FALSE is returned.
+
+ If PostCode is NULL, then ASSERT().
+
+ @param CodeType The type of status code being converted.
+ @param Value The status code value being converted.
+ @param PostCode A pointer to the 8-bit POST code value to return.
+
+ @retval TRUE The status code specified by CodeType and Value was converted
+ to an 8-bit POST code and returned in PostCode.
+ @retval FALSE The status code specified by CodeType and Value could not be
+ converted to an 8-bit POST code value.
+
+**/
+BOOLEAN
+EFIAPI
+GlueCodeTypeToPostCode (
+ IN EFI_STATUS_CODE_TYPE CodeType,
+ IN EFI_STATUS_CODE_VALUE Value,
+ OUT UINT8 *PostCode
+ )
+{
+ //
+ // If PostCode is NULL, then ASSERT()
+ //
+ ASSERT (PostCode != NULL);
+
+ //
+ // Convert Value to an 8 bit post code
+ //
+ if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ||
+ ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ) {
+ *PostCode = (UINT8) (((Value & EFI_STATUS_CODE_CLASS_MASK) >> 24) << 5);
+ *PostCode |= (UINT8) (((Value & EFI_STATUS_CODE_SUBCLASS_MASK) >> 16) & 0x1f);
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
+/**
+ Extracts ASSERT() information from a status code structure.
+
+ Converts the status code specified by CodeType, Value, and Data to the ASSERT()
+ arguments specified by Filename, Description, and LineNumber. If CodeType is
+ an EFI_ERROR_CODE, and CodeType has a severity of EFI_ERROR_UNRECOVERED, and
+ Value has an operation mask of EFI_SW_EC_ILLEGAL_SOFTWARE_STATE, extract
+ Filename, Description, and LineNumber from the optional data area of the
+ status code buffer specified by Data. The optional data area of Data contains
+ a Null-terminated ASCII string for the FileName, followed by a Null-terminated
+ ASCII string for the Description, followed by a 32-bit LineNumber. If the
+ ASSERT() information could be extracted from Data, then return TRUE.
+ Otherwise, FALSE is returned.
+
+ If Data is NULL, then ASSERT().
+ If Filename is NULL, then ASSERT().
+ If Description is NULL, then ASSERT().
+ If LineNumber is NULL, then ASSERT().
+
+ @param CodeType The type of status code being converted.
+ @param Value The status code value being converted.
+ @param Data Pointer to status code data buffer.
+ @param Filename Pointer to the source file name that generated the ASSERT().
+ @param Description Pointer to the description of the ASSERT().
+ @param LineNumber Pointer to source line number that generated the ASSERT().
+
+ @retval TRUE The status code specified by CodeType, Value, and Data was
+ converted ASSERT() arguments specified by Filename, Description,
+ and LineNumber.
+ @retval FALSE The status code specified by CodeType, Value, and Data could
+ not be converted to ASSERT() arguments.
+
+**/
+BOOLEAN
+EFIAPI
+GlueReportStatusCodeExtractAssertInfo (
+ IN EFI_STATUS_CODE_TYPE CodeType,
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN CONST EFI_STATUS_CODE_DATA *Data,
+ OUT CHAR8 **Filename,
+ OUT CHAR8 **Description,
+ OUT UINT32 *LineNumber
+ )
+{
+ EFI_DEBUG_ASSERT_DATA *AssertData;
+
+ ASSERT (Data != NULL);
+ ASSERT (Filename != NULL);
+ ASSERT (Description != NULL);
+ ASSERT (LineNumber != NULL);
+
+ if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) &&
+ ((CodeType & EFI_STATUS_CODE_SEVERITY_MASK) == EFI_ERROR_UNRECOVERED) &&
+ ((Value & EFI_STATUS_CODE_OPERATION_MASK) == EFI_SW_EC_ILLEGAL_SOFTWARE_STATE)) {
+ AssertData = (EFI_DEBUG_ASSERT_DATA *)(Data + 1);
+ *Filename = (CHAR8 *)(AssertData + 1);
+ *Description = *Filename + AsciiStrLen (*Filename) + 1;
+ *LineNumber = AssertData->LineNumber;
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
+/**
+ Extracts DEBUG() information from a status code structure.
+
+ Converts the status code specified by Data to the DEBUG() arguments specified
+ by ErrorLevel, Marker, and Format. If type GUID in Data is
+ EFI_STATUS_CODE_DATA_TYPE_DEBUG_GUID, then extract ErrorLevel, Marker, and
+ Format from the optional data area of the status code buffer specified by Data.
+ The optional data area of Data contains a 32-bit ErrorLevel followed by Marker
+ which is 12 UINTN parameters, followed by a Null-terminated ASCII string for
+ the Format. If the DEBUG() information could be extracted from Data, then
+ return TRUE. Otherwise, FALSE is returned.
+
+ If Data is NULL, then ASSERT().
+ If ErrorLevel is NULL, then ASSERT().
+ If Marker is NULL, then ASSERT().
+ If Format is NULL, then ASSERT().
+
+ @param Data Pointer to status code data buffer.
+ @param ErrorLevel Pointer to error level mask for a debug message.
+ @param Marker Pointer to the variable argument list associated with Format.
+ @param Format Pointer to a Null-terminated ASCII format string of a
+ debug message.
+
+ @retval TRUE The status code specified by Data was converted DEBUG() arguments
+ specified by ErrorLevel, Marker, and Format.
+ @retval FALSE The status code specified by Data could not be converted to
+ DEBUG() arguments.
+
+**/
+BOOLEAN
+EFIAPI
+GlueReportStatusCodeExtractDebugInfo (
+ IN CONST EFI_STATUS_CODE_DATA *Data,
+ OUT UINT32 *ErrorLevel,
+ OUT VA_LIST *Marker,
+ OUT CHAR8 **Format
+ )
+{
+ EFI_DEBUG_INFO *DebugInfo;
+
+ ASSERT (Data != NULL);
+ ASSERT (ErrorLevel != NULL);
+ ASSERT (Marker != NULL);
+ ASSERT (Format != NULL);
+
+ //
+ // If the GUID type is not EFI_STATUS_CODE_DATA_TYPE_DEBUG_GUID then return FALSE
+ //
+ if (!CompareGuid (&Data->Type, &gEfiStatusCodeDataTypeDebugGuid)) {
+ return FALSE;
+ }
+
+ //
+ // Retrieve the debug information from the status code record
+ //
+ DebugInfo = (EFI_DEBUG_INFO *)(Data + 1);
+
+ *ErrorLevel = DebugInfo->ErrorLevel;
+
+ //
+ // The first 12 * UINTN bytes of the string are really an
+ // argument stack to support varargs on the Format string.
+ //
+ *Marker = (VA_LIST) (DebugInfo + 1);
+ *Format = (CHAR8 *)(((UINT64 *)*Marker) + 12);
+
+ return TRUE;
+}
+
+
+/**
+ Reports a status code.
+
+ Reports the status code specified by the parameters Type and Value. Status
+ code also require an instance, caller ID, and extended data. This function
+ passed in a zero instance, NULL extended data, and a caller ID of
+ gEfiCallerIdGuid, which is the GUID for the module.
+
+ ReportStatusCode()must actively prevent recusrsion. If ReportStatusCode()
+ is called while processing another any other Report Status Code Library function,
+ then ReportStatusCode() must return immediately.
+
+ @param Type Status code type.
+ @param Value Status code value.
+
+ @retval EFI_SUCCESS The status code was reported.
+ @retval EFI_DEVICE_ERROR There status code could not be reported due to a
+ device error.
+ @retval EFI_UNSUPPORTED Report status code is not supported
+
+**/
+EFI_STATUS
+EFIAPI
+GlueReportStatusCode (
+ IN EFI_STATUS_CODE_TYPE Type,
+ IN EFI_STATUS_CODE_VALUE Value
+ )
+{
+ return InternalReportStatusCode (Type, Value, 0, &gEfiCallerIdGuid, NULL);
+}
+
+
+/**
+ Reports a status code with a Device Path Protocol as the extended data.
+
+ Allocates and fills in the extended data section of a status code with the
+ Device Path Protocol specified by DevicePath. This function is responsible
+ for allocating a buffer large enough for the standard header and the device
+ path. The standard header is filled in with a GUID of
+ gEfiStatusCodeSpecificDataGuid. The status code is reported with a zero
+ instance and a caller ID of gEfiCallerIdGuid.
+
+ ReportStatusCodeWithDevicePath()must actively prevent recursion. If
+ ReportStatusCodeWithDevicePath() is called while processing another any other
+ Report Status Code Library function, then ReportStatusCodeWithDevicePath()
+ must return EFI_DEVICE_ERROR immediately.
+
+ If DevicePath is NULL, then ASSERT().
+
+ @param Type Status code type.
+ @param Value Status code value.
+ @param DevicePath Pointer to the Device Path Protocol to be reported.
+
+ @retval EFI_SUCCESS The status code was reported with the extended
+ data specified by DevicePath.
+ @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the
+ extended data section.
+ @retval EFI_UNSUPPORTED Report status code is not supported
+
+**/
+EFI_STATUS
+EFIAPI
+GlueReportStatusCodeWithDevicePath (
+ IN EFI_STATUS_CODE_TYPE Type,
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ )
+{
+ ASSERT (DevicePath != NULL);
+ return EFI_UNSUPPORTED;
+}
+
+
+/**
+ Reports a status code with an extended data buffer.
+
+ Allocates and fills in the extended data section of a status code with the
+ extended data specified by ExtendedData and ExtendedDataSize. ExtendedData
+ is assumed to be one of the data structures specified in Related Definitions.
+ These data structure do not have the standard header, so this function is
+ responsible for allocating a buffer large enough for the standard header and
+ the extended data passed into this function. The standard header is filled
+ in with a GUID of gEfiStatusCodeSpecificDataGuid. The status code is reported
+ with a zero instance and a caller ID of gEfiCallerIdGuid.
+
+ ReportStatusCodeWithExtendedData()must actively prevent recursion. If
+ ReportStatusCodeWithExtendedData() is called while processing another any other
+ Report Status Code Library function, then ReportStatusCodeWithExtendedData()
+ must return EFI_DEVICE_ERROR immediately.
+
+ If ExtendedData is NULL, then ASSERT().
+ If ExtendedDataSize is 0, then ASSERT().
+
+ @param Type Status code type.
+ @param Value Status code value.
+ @param ExtendedData Pointer to the extended data buffer to be reported.
+ @param ExtendedDataSize The size, in bytes, of the extended data buffer to
+ be reported.
+
+ @retval EFI_SUCCESS The status code was reported with the extended
+ data specified by ExtendedData and ExtendedDataSize.
+ @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the
+ extended data section.
+ @retval EFI_UNSUPPORTED Report status code is not supported
+
+**/
+EFI_STATUS
+EFIAPI
+GlueReportStatusCodeWithExtendedData (
+ IN EFI_STATUS_CODE_TYPE Type,
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN CONST VOID *ExtendedData,
+ IN UINTN ExtendedDataSize
+ )
+{
+ ASSERT (ExtendedData != NULL);
+ ASSERT (ExtendedDataSize != 0);
+ return ReportStatusCodeEx (
+ Type,
+ Value,
+ 0,
+ NULL,
+ NULL,
+ ExtendedData,
+ ExtendedDataSize
+ );
+}
+
+
+/**
+ Reports a status code with full parameters.
+
+ The function reports a status code. If ExtendedData is NULL and ExtendedDataSize
+ is 0, then an extended data buffer is not reported. If ExtendedData is not
+ NULL and ExtendedDataSize is not 0, then an extended data buffer is allocated.
+ ExtendedData is assumed not have the standard status code header, so this function
+ is responsible for allocating a buffer large enough for the standard header and
+ the extended data passed into this function. The standard header is filled in
+ with a GUID specified by ExtendedDataGuid. If ExtendedDataGuid is NULL, then a
+ GUID of gEfiStatusCodeSpecificDatauid is used. The status code is reported with
+ an instance specified by Instance and a caller ID specified by CallerId. If
+ CallerId is NULL, then a caller ID of gEfiCallerIdGuid is used.
+
+ ReportStatusCodeEx()must actively prevent recursion. If ReportStatusCodeEx()
+ is called while processing another any other Report Status Code Library function,
+ then ReportStatusCodeEx() must return EFI_DEVICE_ERROR immediately.
+
+ If ExtendedData is NULL and ExtendedDataSize is not zero, then ASSERT().
+ If ExtendedData is not NULL and ExtendedDataSize is zero, then ASSERT().
+
+ @param Type Status code type.
+ @param Value Status code value.
+ @param Instance Status code instance number.
+ @param CallerId Pointer to a GUID that identifies the caller of this
+ function. If this parameter is NULL, then a caller
+ ID of gEfiCallerIdGuid is used.
+ @param ExtendedDataGuid Pointer to the GUID for the extended data buffer.
+ If this parameter is NULL, then a the status code
+ standard header is filled in with
+ gEfiStatusCodeSpecificDataGuid.
+ @param ExtendedData Pointer to the extended data buffer. This is an
+ optional parameter that may be NULL.
+ @param ExtendedDataSize The size, in bytes, of the extended data buffer.
+
+ @retval EFI_SUCCESS The status code was reported.
+ @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate
+ the extended data section if it was specified.
+ @retval EFI_UNSUPPORTED Report status code is not supported
+
+**/
+EFI_STATUS
+EFIAPI
+GlueReportStatusCodeEx (
+ IN EFI_STATUS_CODE_TYPE Type,
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN UINT32 Instance,
+ IN CONST EFI_GUID *CallerId OPTIONAL,
+ IN CONST EFI_GUID *ExtendedDataGuid OPTIONAL,
+ IN CONST VOID *ExtendedData OPTIONAL,
+ IN UINTN ExtendedDataSize
+ )
+{
+ EFI_STATUS_CODE_DATA *StatusCodeData;
+ UINT64 Buffer[MAX_EXTENDED_DATA_SIZE / sizeof (UINT64)];
+
+ ASSERT (!((ExtendedData == NULL) && (ExtendedDataSize != 0)));
+ ASSERT (!((ExtendedData != NULL) && (ExtendedDataSize == 0)));
+
+ if (ExtendedDataSize > (MAX_EXTENDED_DATA_SIZE - sizeof (EFI_STATUS_CODE_DATA))) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ StatusCodeData = (EFI_STATUS_CODE_DATA *)Buffer;
+ StatusCodeData->HeaderSize = sizeof (EFI_STATUS_CODE_DATA);
+ StatusCodeData->Size = (UINT16)ExtendedDataSize;
+ if (ExtendedDataGuid == NULL) {
+ ExtendedDataGuid = &gEfiStatusCodeSpecificDataGuid;
+ }
+ CopyGuid (&StatusCodeData->Type, ExtendedDataGuid);
+ CopyMem (StatusCodeData + 1, ExtendedData, ExtendedDataSize);
+ if (CallerId == NULL) {
+ CallerId = &gEfiCallerIdGuid;
+ }
+ return InternalReportStatusCode (Type, Value, Instance, CallerId, StatusCodeData);
+}
+
+
+/**
+ Returns TRUE if status codes of type EFI_PROGRESS_CODE are enabled
+
+ This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED
+ bit of PcdReportStatusCodeProperyMask is set. Otherwise FALSE is returned.
+
+ @retval TRUE The REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED bit of
+ PcdReportStatusCodeProperyMask is set.
+ @retval FALSE The REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED bit of
+ PcdReportStatusCodeProperyMask is clear.
+
+**/
+BOOLEAN
+EFIAPI
+GlueReportProgressCodeEnabled (
+ VOID
+ )
+{
+ return ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED) != 0);
+}
+
+
+/**
+ Returns TRUE if status codes of type EFI_ERROR_CODE are enabled
+
+ This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED
+ bit of PcdReportStatusCodeProperyMask is set. Otherwise FALSE is returned.
+
+ @retval TRUE The REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED bit of
+ PcdReportStatusCodeProperyMask is set.
+ @retval FALSE The REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED bit of
+ PcdReportStatusCodeProperyMask is clear.
+
+**/
+BOOLEAN
+EFIAPI
+GlueReportErrorCodeEnabled (
+ VOID
+ )
+{
+ return ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED) != 0);
+}
+
+
+/**
+ Returns TRUE if status codes of type EFI_DEBUG_CODE are enabled
+
+ This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED
+ bit of PcdReportStatusCodeProperyMask is set. Otherwise FALSE is returned.
+
+ @retval TRUE The REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED bit of
+ PcdReportStatusCodeProperyMask is set.
+ @retval FALSE The REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED bit of
+ PcdReportStatusCodeProperyMask is clear.
+
+**/
+BOOLEAN
+EFIAPI
+GlueReportDebugCodeEnabled (
+ VOID
+ )
+{
+ return ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED) != 0);
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiResourcePublicationLib/EdkIIGluePeiResourcePublicationLib.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiResourcePublicationLib/EdkIIGluePeiResourcePublicationLib.cif
new file mode 100644
index 0000000..505f666
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiResourcePublicationLib/EdkIIGluePeiResourcePublicationLib.cif
@@ -0,0 +1,11 @@
+<component>
+ name = "EdkIIGluePeiResourcePublicationLib"
+ category = ModulePart
+ LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\PeiResourcePublicationLib"
+ RefName = "EdkIIGluePeiResourcePublicationLib"
+[files]
+"EdkIIGluePeiResourcePublicationLib.sdl"
+"EdkIIGluePeiResourcePublicationLib.mak"
+"PeiResourcePublicationLib.inf"
+"PeiResourcePublicationLib.c"
+<endComponent>
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiResourcePublicationLib/EdkIIGluePeiResourcePublicationLib.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiResourcePublicationLib/EdkIIGluePeiResourcePublicationLib.mak
new file mode 100644
index 0000000..37632da
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiResourcePublicationLib/EdkIIGluePeiResourcePublicationLib.mak
@@ -0,0 +1,80 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGluePeiResourcePublicationLib/EdkIIGluePeiResourcePublicationLib.mak 1 1/20/12 3:57a Jeffch $
+#
+# $Revision: 1 $
+#
+# $Date: 1/20/12 3:57a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGluePeiResourcePublicationLib/EdkIIGluePeiResourcePublicationLib.mak $
+#
+# 1 1/20/12 3:57a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 9/27/11 6:19a Wesleychen
+# Intel EDK initially releases.
+#
+# 1 9/18/09 1:57a Iminglin
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: EdkIIGluePeiResourcePublicationLib.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+
+
+$(EdkIIGluePeiResourcePublicationLib_LIB) : EdkIIGluePeiResourcePublicationLib
+
+EdkIIGluePeiResourcePublicationLib : $(BUILD_DIR)\EdkIIGluePeiResourcePublicationLib.mak EdkIIGluePeiResourcePublicationLibBin
+
+$(BUILD_DIR)\EdkIIGluePeiResourcePublicationLib.mak : $(EdkIIGluePeiResourcePublicationLib_DIR)\$(@B).cif $(EdkIIGluePeiResourcePublicationLib_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(EdkIIGluePeiResourcePublicationLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+EdkIIGluePeiResourcePublicationLibBin : $(EdkIIGluePeiServicesLib_LIB)
+!IF "$(x64_BUILD)"=="1"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGluePeiResourcePublicationLib.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGluePeiResourcePublicationLib_LIB)"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\IA32\
+ /f $(BUILD_DIR)\EdkIIGluePeiResourcePublicationLib.mak all\
+ TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGluePeiResourcePublicationLib_LIB)"
+!ELSE
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGluePeiResourcePublicationLib.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGluePeiResourcePublicationLib_LIB)"
+!ENDIF
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#********************************************************************** \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiResourcePublicationLib/EdkIIGluePeiResourcePublicationLib.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiResourcePublicationLib/EdkIIGluePeiResourcePublicationLib.sdl
new file mode 100644
index 0000000..4ccd6f1
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiResourcePublicationLib/EdkIIGluePeiResourcePublicationLib.sdl
@@ -0,0 +1,26 @@
+TOKEN
+ Name = "EdkIIGluePeiResourcePublicationLib_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable EdkIIGluePeiResourcePublicationLib support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "EdkIIGluePeiResourcePublicationLib_LIB"
+ Value = "$$(LIB_BUILD_DIR)\EdkIIGluePeiResourcePublicationLib.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "EdkIIGluePeiResourcePublicationLib_DIR"
+End
+
+MODULE
+ Help = "Includes EdkIIGluePeiResourcePublicationLib.mak to Project"
+ File = "EdkIIGluePeiResourcePublicationLib.mak"
+End
+
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiResourcePublicationLib/PeiResourcePublicationLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiResourcePublicationLib/PeiResourcePublicationLib.c
new file mode 100644
index 0000000..726493d
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiResourcePublicationLib/PeiResourcePublicationLib.c
@@ -0,0 +1,57 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ PeiResourcePublicationLib.c
+
+Abstract:
+
+ Resource Publication Library that uses PEI Core Services to publish system memory.
+
+--*/
+
+#include "EdkIIGluePeim.h"
+
+/**
+
+ Declares the presence of permanent system memory in the platform.
+
+ Declares that the system memory buffer specified by MemoryBegin and MemoryLength
+ as permanent memory that may be used for general purpose use by software.
+ The amount of memory available to software may be less than MemoryLength
+ if published memory has alignment restrictions.
+
+ @param MemoryBegin The start address of the memory being declared.
+ @param MemoryLength The number of bytes of memory being declared.
+
+ @retval RETURN_SUCCESS The memory buffer was published.
+ @retval RETURN_OUT_OF_RESOURCES There are not enough resources to publish the memory buffer
+
+**/
+RETURN_STATUS
+EFIAPI
+PublishSystemMemory (
+ IN PHYSICAL_ADDRESS MemoryBegin,
+ IN UINT64 MemoryLength
+ )
+{
+ EFI_STATUS Status;
+
+ ASSERT (MemoryLength > 0);
+ ASSERT (MemoryLength <= (MAX_ADDRESS - MemoryBegin + 1));
+
+ Status = PeiServicesInstallPeiMemory (MemoryBegin, MemoryLength);
+
+ return (RETURN_STATUS) Status;
+}
+
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiResourcePublicationLib/PeiResourcePublicationLib.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiResourcePublicationLib/PeiResourcePublicationLib.inf
new file mode 100644
index 0000000..a568773
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiResourcePublicationLib/PeiResourcePublicationLib.inf
@@ -0,0 +1,79 @@
+#/*++
+#
+# Copyright (c) 2004 - 2006, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# PeiResourcePublication.inf
+#
+# Abstract:
+#
+# Component description file for PeiResourcePublication.
+#
+#--*/
+
+[defines]
+BASE_NAME = EdkIIGluePeiResourcePublicationLib
+COMPONENT_TYPE = LIBRARY
+
+[sources.common]
+ PeiResourcePublicationLib.c
+
+[sources.ia32]
+
+[sources.x64]
+
+[sources.ipf]
+
+[sources.ebc]
+
+
+[includes.common]
+ .
+ ..\..\Include
+ ..\..\include\Library
+ $(EDK_SOURCE)\Foundation
+ $(EDK_SOURCE)\Foundation\Framework
+ $(EDK_SOURCE)\Foundation\Include\Pei
+ $(EDK_SOURCE)\Foundation\Efi
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Include\Pei
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+ $(EDK_SOURCE)\Foundation\Library\Pei\Include
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+ $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include
+
+[libraries.common]
+ EdkIIGluePeiServicesLib
+
+[libraries.ia32]
+
+
+[libraries.x64]
+
+
+[nmake.common]
+ C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION
+ LIB_STD_FLAGS = /NOLOGO /IGNORE:4006
+
+[nmake.ia32]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32
+
+[nmake.x64]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64
+
+[nmake.ipf]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF
+
+[nmake.ebc]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesLib/EdkIIGluePeiServicesLib.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesLib/EdkIIGluePeiServicesLib.cif
new file mode 100644
index 0000000..cf46ede
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesLib/EdkIIGluePeiServicesLib.cif
@@ -0,0 +1,11 @@
+<component>
+ name = "EdkIIGluePeiServicesLib"
+ category = ModulePart
+ LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\PeiServicesLib"
+ RefName = "EdkIIGluePeiServicesLib"
+[files]
+"EdkIIGluePeiServicesLib.sdl"
+"EdkIIGluePeiServicesLib.mak"
+"PeiServicesLib.inf"
+"PeiServicesLib.c"
+<endComponent>
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesLib/EdkIIGluePeiServicesLib.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesLib/EdkIIGluePeiServicesLib.mak
new file mode 100644
index 0000000..c5cbc56
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesLib/EdkIIGluePeiServicesLib.mak
@@ -0,0 +1,88 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGluePeiServicesLib/EdkIIGluePeiServicesLib.mak 2 2/24/12 5:01a Jeffch $
+#
+# $Revision: 2 $
+#
+# $Date: 2/24/12 5:01a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGluePeiServicesLib/EdkIIGluePeiServicesLib.mak $
+#
+# 2 2/24/12 5:01a Jeffch
+#
+# 1 1/20/12 3:57a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 9/27/11 6:19a Wesleychen
+# Intel EDK initially releases.
+#
+# 1 9/18/09 1:57a Iminglin
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: EdkIIGluePeiServicesLib.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+
+
+$(EdkIIGluePeiServicesLib_LIB) : EdkIIGluePeiServicesLib
+
+EdkIIGluePeiServicesLib : $(BUILD_DIR)\EdkIIGluePeiServicesLib.mak EdkIIGluePeiServicesLibBin
+
+$(BUILD_DIR)\EdkIIGluePeiServicesLib.mak : $(EdkIIGluePeiServicesLib_DIR)\$(@B).cif $(EdkIIGluePeiServicesLib_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(EdkIIGluePeiServicesLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+EdkIIGluePeiServicesLib_LIB_LINKS=\
+$(EDKFRAMEWORKPPILIB)\
+!IF "$(PROCESSOR)"=="IA32" || "$(PROCESSOR)"=="x64"
+$(EdkIIGluePeiServicesTablePointerLibMm7_LIB)
+!ENDIF
+
+EdkIIGluePeiServicesLibBin : $(EdkIIGluePeiServicesLib_LIB_LINKS)
+!IF "$(x64_BUILD)"=="1"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGluePeiServicesLib.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGluePeiServicesLib_LIB)"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\IA32\
+ /f $(BUILD_DIR)\EdkIIGluePeiServicesLib.mak all\
+ TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGluePeiServicesLib_LIB)"
+!ELSE
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGluePeiServicesLib.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGluePeiServicesLib_LIB)"
+!ENDIF
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesLib/EdkIIGluePeiServicesLib.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesLib/EdkIIGluePeiServicesLib.sdl
new file mode 100644
index 0000000..7f71919
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesLib/EdkIIGluePeiServicesLib.sdl
@@ -0,0 +1,26 @@
+TOKEN
+ Name = "EdkIIGluePeiServicesLib_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable EdkIIGluePeiServicesLib support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "EdkIIGluePeiServicesLib_LIB"
+ Value = "$$(LIB_BUILD_DIR)\EdkIIGluePeiServicesLib.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "EdkIIGluePeiServicesLib_DIR"
+End
+
+MODULE
+ Help = "Includes EdkIIGluePeiServicesLib.mak to Project"
+ File = "EdkIIGluePeiServicesLib.mak"
+End
+
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesLib/PeiServicesLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesLib/PeiServicesLib.c
new file mode 100644
index 0000000..b5df45e
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesLib/PeiServicesLib.c
@@ -0,0 +1,470 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ PeiServicesLib.c
+
+Abstract:
+
+ PEI Services Lib
+
+--*/
+
+#include "EdkIIGluePeim.h"
+
+/**
+ This service enables a given PEIM to register an interface into the PEI Foundation.
+
+ @param PpiList A pointer to the list of interfaces that the caller shall install.
+
+ @retval EFI_SUCCESS The interface was successfully installed.
+ @retval EFI_INVALID_PARAMETER The PpiList pointer is NULL.
+ @retval EFI_INVALID_PARAMETER Any of the PEI PPI descriptors in the list do not have the
+ EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field.
+ @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database.
+
+**/
+EFI_STATUS
+EFIAPI
+PeiServicesInstallPpi (
+ IN EFI_PEI_PPI_DESCRIPTOR *PpiList
+ )
+{
+ EFI_PEI_SERVICES **PeiServices;
+
+ PeiServices = GetPeiServicesTablePointer ();
+ return (*PeiServices)->InstallPpi (PeiServices, PpiList);
+}
+
+/**
+ This service enables PEIMs to replace an entry in the PPI database with an alternate entry.
+
+ @param OldPpi Pointer to the old PEI PPI Descriptors.
+ @param NewPpi Pointer to the new PEI PPI Descriptors.
+
+ @retval EFI_SUCCESS The interface was successfully installed.
+ @retval EFI_INVALID_PARAMETER The OldPpi or NewPpi is NULL.
+ @retval EFI_INVALID_PARAMETER Any of the PEI PPI descriptors in the list do not have the
+ EFI_PEI_PPI_DESCRIPTOR_PPI bit set in the Flags field.
+ @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database.
+ @retval EFI_NOT_FOUND The PPI for which the reinstallation was requested has not been
+ installed.
+
+**/
+EFI_STATUS
+EFIAPI
+PeiServicesReInstallPpi (
+ IN EFI_PEI_PPI_DESCRIPTOR *OldPpi,
+ IN EFI_PEI_PPI_DESCRIPTOR *NewPpi
+ )
+{
+ EFI_PEI_SERVICES **PeiServices;
+
+ PeiServices = GetPeiServicesTablePointer ();
+ return (*PeiServices)->ReInstallPpi (PeiServices, OldPpi, NewPpi);
+}
+
+/**
+ This service enables PEIMs to discover a given instance of an interface.
+
+ @param Guid A pointer to the GUID whose corresponding interface needs to be
+ found.
+ @param Instance The N-th instance of the interface that is required.
+ @param PpiDescriptor A pointer to instance of the EFI_PEI_PPI_DESCRIPTOR.
+ @param Ppi A pointer to the instance of the interface.
+
+ @retval EFI_SUCCESS The interface was successfully returned.
+ @retval EFI_NOT_FOUND The PPI descriptor is not found in the database.
+
+**/
+EFI_STATUS
+EFIAPI
+PeiServicesLocatePpi (
+ IN EFI_GUID *Guid,
+ IN UINTN Instance,
+ IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor,
+ IN OUT VOID **Ppi
+ )
+{
+ EFI_PEI_SERVICES **PeiServices;
+
+ PeiServices = GetPeiServicesTablePointer ();
+ return (*PeiServices)->LocatePpi (PeiServices, Guid, Instance, PpiDescriptor, Ppi);
+}
+
+/**
+ This service enables PEIMs to register a given service to be invoked when another service is
+ installed or reinstalled.
+
+ @param NotifyList A pointer to the list of notification interfaces that the caller
+ shall install.
+
+ @retval EFI_SUCCESS The interface was successfully installed.
+ @retval EFI_INVALID_PARAMETER The NotifyList pointer is NULL.
+ @retval EFI_INVALID_PARAMETER Any of the PEI notify descriptors in the list do not have the
+ EFI_PEI_PPI_DESCRIPTOR_NOTIFY_TYPES bit set in the Flags field.
+ @retval EFI_OUT_OF_RESOURCES There is no additional space in the PPI database.
+
+**/
+EFI_STATUS
+EFIAPI
+PeiServicesNotifyPpi (
+ IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyList
+ )
+{
+ EFI_PEI_SERVICES **PeiServices;
+
+ PeiServices = GetPeiServicesTablePointer ();
+ return (*PeiServices)->NotifyPpi (PeiServices, NotifyList);
+}
+
+/**
+ This service enables PEIMs to ascertain the present value of the boot mode.
+
+ @param BootMode A pointer to contain the value of the boot mode.
+
+ @retval EFI_SUCCESS The boot mode was returned successfully.
+ @retval EFI_INVALID_PARAMETER BootMode is NULL.
+
+**/
+EFI_STATUS
+EFIAPI
+PeiServicesGetBootMode (
+ IN OUT EFI_BOOT_MODE *BootMode
+ )
+{
+ EFI_PEI_SERVICES **PeiServices;
+
+ PeiServices = GetPeiServicesTablePointer ();
+ return (*PeiServices)->GetBootMode (PeiServices, BootMode);
+}
+
+/**
+ This service enables PEIMs to update the boot mode variable.
+
+ @param BootMode The value of the boot mode to set.
+
+ @retval EFI_SUCCESS The value was successfully updated
+
+**/
+EFI_STATUS
+EFIAPI
+PeiServicesSetBootMode (
+ IN EFI_BOOT_MODE BootMode
+ )
+{
+ EFI_PEI_SERVICES **PeiServices;
+
+ PeiServices = GetPeiServicesTablePointer ();
+ return (*PeiServices)->SetBootMode (PeiServices, BootMode);
+}
+
+/**
+ This service enables a PEIM to ascertain the address of the list of HOBs in memory.
+
+ @param HobList A pointer to the list of HOBs that the PEI Foundation will initialize.
+
+ @retval EFI_SUCCESS The list was successfully returned.
+ @retval EFI_NOT_AVAILABLE_YET The HOB list is not yet published.
+
+**/
+EFI_STATUS
+EFIAPI
+PeiServicesGetHobList (
+ IN OUT VOID **HobList
+ )
+{
+ EFI_PEI_SERVICES **PeiServices;
+
+ PeiServices = GetPeiServicesTablePointer ();
+ return (*PeiServices)->GetHobList (PeiServices, HobList);
+}
+
+/**
+ This service enables PEIMs to create various types of HOBs.
+
+ @param Type The type of HOB to be installed.
+ @param Length The length of the HOB to be added.
+ @param Hob The address of a pointer that will contain the HOB header.
+
+ @retval EFI_SUCCESS The HOB was successfully created.
+ @retval EFI_OUT_OF_RESOURCES There is no additional space for HOB creation.
+
+**/
+EFI_STATUS
+EFIAPI
+PeiServicesCreateHob (
+ IN UINT16 Type,
+ IN UINT16 Length,
+ IN OUT VOID **Hob
+ )
+{
+ EFI_PEI_SERVICES **PeiServices;
+
+ PeiServices = GetPeiServicesTablePointer ();
+ return (*PeiServices)->CreateHob (PeiServices, Type, Length, Hob);
+}
+
+//;;## ...AMI_OVERRIDE... Support PI1.x
+#if (PI_SPECIFICATION_VERSION < 0x00010000)
+/**
+ This service enables PEIMs to discover additional firmware volumes.
+
+ @param Instance This instance of the firmware volume to find. The value 0 is the
+ Boot Firmware Volume (BFV).
+ @param FwVolHeader Pointer to the firmware volume header of the volume to return.
+
+ @retval EFI_SUCCESS The volume was found.
+ @retval EFI_NOT_FOUND The volume was not found.
+ @retval EFI_INVALID_PARAMETER FwVolHeader is NULL.
+
+**/
+EFI_STATUS
+EFIAPI
+PeiServicesFfsFindNextVolume (
+ IN UINTN Instance,
+ IN OUT EFI_FIRMWARE_VOLUME_HEADER **FwVolHeader
+ )
+{
+ EFI_PEI_SERVICES **PeiServices;
+
+ PeiServices = GetPeiServicesTablePointer ();
+ return (*PeiServices)->FfsFindNextVolume (PeiServices, Instance, FwVolHeader);
+}
+
+/**
+ This service enables PEIMs to discover additional firmware files.
+
+ @param SearchType A filter to find files only of this type.
+ @param FwVolHeader Pointer to the firmware volume header of the volume to search.
+ This parameter must point to a valid FFS volume.
+ @param FileHeader Pointer to the current file from which to begin searching.
+
+ @retval EFI_SUCCESS The file was found.
+ @retval EFI_NOT_FOUND The file was not found.
+ @retval EFI_NOT_FOUND The header checksum was not zero.
+
+**/
+EFI_STATUS
+EFIAPI
+PeiServicesFfsFindNextFile (
+ IN EFI_FV_FILETYPE SearchType,
+ IN EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader,
+ IN OUT EFI_FFS_FILE_HEADER **FileHeader
+ )
+{
+ EFI_PEI_SERVICES **PeiServices;
+
+ PeiServices = GetPeiServicesTablePointer ();
+ return (*PeiServices)->FfsFindNextFile (PeiServices, SearchType, FwVolHeader, FileHeader);
+}
+
+/**
+ This service enables PEIMs to discover sections of a given type within a valid FFS file.
+
+ @param SearchType The value of the section type to find.
+ @param FfsFileHeader A pointer to the file header that contains the set of sections to
+ be searched.
+ @param SectionData A pointer to the discovered section, if successful.
+
+ @retval EFI_SUCCESS The section was found.
+ @retval EFI_NOT_FOUND The section was not found.
+
+**/
+EFI_STATUS
+EFIAPI
+PeiServicesFfsFindSectionData (
+ IN EFI_SECTION_TYPE SectionType,
+ IN EFI_FFS_FILE_HEADER *FfsFileHeader,
+ IN OUT VOID **SectionData
+ )
+{
+ EFI_PEI_SERVICES **PeiServices;
+
+ PeiServices = GetPeiServicesTablePointer ();
+ return (*PeiServices)->FfsFindSectionData (PeiServices, SectionType, FfsFileHeader, SectionData);
+}
+#endif
+
+/**
+ This service enables PEIMs to register the permanent memory configuration
+ that has been initialized with the PEI Foundation.
+
+ @param MemoryBegin The value of a region of installed memory.
+ @param MemoryLength The corresponding length of a region of installed memory.
+
+ @retval EFI_SUCCESS The region was successfully installed in a HOB.
+ @retval EFI_INVALID_PARAMETER MemoryBegin and MemoryLength are illegal for this system.
+ @retval EFI_OUT_OF_RESOURCES There is no additional space for HOB creation.
+
+**/
+EFI_STATUS
+EFIAPI
+PeiServicesInstallPeiMemory (
+ IN EFI_PHYSICAL_ADDRESS MemoryBegin,
+ IN UINT64 MemoryLength
+ )
+{
+ EFI_PEI_SERVICES **PeiServices;
+
+ PeiServices = GetPeiServicesTablePointer ();
+ return (*PeiServices)->InstallPeiMemory (PeiServices, MemoryBegin, MemoryLength);
+}
+
+/**
+ This service enables PEIMs to allocate memory after the permanent memory has been installed by a
+ PEIM.
+
+ @param MemoryType Type of memory to allocate.
+ @param Pages Number of pages to allocate.
+ @param Memory Pointer of memory allocated.
+
+ @retval EFI_SUCCESS The memory range was successfully allocated.
+ @retval EFI_INVALID_PARAMETER Type is not equal to AllocateAnyPages.
+ @retval EFI_NOT_AVAILABLE_YET Called with permanent memory not available.
+ @retval EFI_OUT_OF_RESOURCES The pages could not be allocated.
+
+**/
+EFI_STATUS
+EFIAPI
+PeiServicesAllocatePages (
+ IN EFI_MEMORY_TYPE MemoryType,
+ IN UINTN Pages,
+ IN OUT EFI_PHYSICAL_ADDRESS *Memory
+ )
+{
+ EFI_PEI_SERVICES **PeiServices;
+
+ PeiServices = GetPeiServicesTablePointer ();
+ return ((*PeiServices)->AllocatePages) (PeiServices, MemoryType, Pages, Memory);
+}
+
+/**
+ This service allocates memory from the Hand-Off Block (HOB) heap.
+
+ @param Size The number of bytes to allocate from the pool.
+ @param Buffer If the call succeeds, a pointer to a pointer to the allocate
+ buffer; undefined otherwise.
+
+ @retval EFI_SUCCESS The allocation was successful
+ @retval EFI_OUT_OF_RESOURCES There is not enough heap to allocate the requested size.
+
+**/
+EFI_STATUS
+EFIAPI
+PeiServicesAllocatePool (
+ IN UINTN Size,
+ OUT VOID **Buffer
+ )
+{
+ EFI_PEI_SERVICES **PeiServices;
+
+ PeiServices = GetPeiServicesTablePointer ();
+ return ((*PeiServices)->AllocatePool) (PeiServices, Size, Buffer);
+}
+
+/**
+ This service resets the entire platform, including all processors and devices, and reboots the
+ system.
+
+ @retval EFI_NOT_AVAILABLE_YET The service has not been installed yet.
+
+**/
+EFI_STATUS
+EFIAPI
+PeiServicesResetSystem (
+ VOID
+ )
+{
+ EFI_PEI_SERVICES **PeiServices;
+
+ PeiServices = GetPeiServicesTablePointer ();
+ return (*PeiServices)->PeiResetSystem (PeiServices);
+}
+/**
+ PCI read-modify-write operations.
+
+ PIWG's PI specification replaces Inte's EFI Specification 1.10.
+ EFI_PEI_PCI_CFG_PPI defined in Inte's EFI Specification 1.10 is replaced by
+ EFI_PEI_PCI_CFG2_PPI in PI 1.0. "Modify" function in these two PPI are not
+ compatibile with each other.
+
+ For Framework code that make the following call:
+ PciCfg->Modify (
+ PeiServices,
+ PciCfg,
+ Width,
+ Address,
+ SetBits,
+ ClearBits
+ );
+ it will be updated to the following code which call this library API:
+ PeiLibPciCfgModify (
+ PeiServices,
+ PciCfg,
+ Width,
+ Address,
+ SetBits,
+ ClearBits
+ );
+
+ @param PeiServices An indirect pointer to the PEI Services Table
+ published by the PEI Foundation.
+ @param PciCfg A pointer to the this pointer of EFI_PEI_PCI_CFG_PPI.
+ This parameter is unused as a place holder to make
+ the parameter list identical to PEI_PCI_CFG_PPI_RW.
+ @param Width The width of the access. Enumerated in bytes. Type
+ EFI_PEI_PCI_CFG_PPI_WIDTH is defined in Read().
+ @param Address The physical address of the access.
+ @param SetBits Points to value to bitwise-OR with the read configuration value.
+ The size of the value is determined by Width.
+ @param ClearBits Points to the value to negate and bitwise-AND with the read configuration value.
+ The size of the value is determined by Width.
+
+ @retval EFI_SUCCESS The function completed successfully.
+ @retval EFI_DEVICE_ERROR There was a problem with the transaction.
+**/
+EFI_STATUS
+EFIAPI
+PeiLibPciCfgModify (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_PCI_CFG_PPI *PciCfg,
+ IN PEI_PCI_CFG_PPI_WIDTH Width,
+ IN UINT64 Address,
+ IN UINTN SetBits,
+ IN UINTN ClearBits
+ )
+{
+ EFI_STATUS Status;
+ EFI_PEI_PCI_CFG2_PPI *PciCfg2;
+
+ Status = (*PeiServices)->LocatePpi (
+ PeiServices,
+ &gPeiPciCfg2PpiGuid,
+ 0,
+ NULL,
+ (VOID **) &PciCfg2
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ Status = PciCfg2->Modify (
+ (CONST EFI_PEI_SERVICES **) PeiServices,
+ PciCfg2,
+ (EFI_PEI_PCI_CFG_PPI_WIDTH) Width,
+ Address,
+ &SetBits,
+ &ClearBits
+ );
+
+ return Status;
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesLib/PeiServicesLib.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesLib/PeiServicesLib.inf
new file mode 100644
index 0000000..c3ecc08
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesLib/PeiServicesLib.inf
@@ -0,0 +1,82 @@
+#/*++
+#
+# Copyright (c) 2004 - 2006, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# PeiServicesLib.inf
+#
+# Abstract:
+#
+# Component description file for PeiServicesLib
+#
+#--*/
+
+[defines]
+BASE_NAME = EdkIIGluePeiServicesLib
+COMPONENT_TYPE = LIBRARY
+
+[sources.common]
+ PeiServicesLib.c
+
+[sources.ia32]
+
+[sources.x64]
+
+[sources.ipf]
+
+[sources.ebc]
+
+
+[includes.common]
+ .
+ ..\..\Include
+ ..\..\include\Library
+ $(EDK_SOURCE)\Foundation
+ $(EDK_SOURCE)\Foundation\Framework
+ $(EDK_SOURCE)\Foundation\Efi
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Include\Pei
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+ $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include
+
+[libraries.common]
+ EdkIIGluePeiServicesTablePointerLibMm7
+#
+# If necessary, EdkIIGluePeiServicesTablePointerLib can be
+# used to replace EdkIIGluePeiServicesTablePointerLibMm7
+#
+ EdkFrameworkPpiLib
+
+[libraries.ia32]
+
+
+[libraries.x64]
+
+
+[nmake.common]
+ C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION
+ LIB_STD_FLAGS = /NOLOGO /IGNORE:4006
+
+[nmake.ia32]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32
+
+[nmake.x64]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64
+
+[nmake.ipf]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF
+
+[nmake.ebc]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLib/EdkIIGluePeiServicesTablePointerLib.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLib/EdkIIGluePeiServicesTablePointerLib.cif
new file mode 100644
index 0000000..525bd3a
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLib/EdkIIGluePeiServicesTablePointerLib.cif
@@ -0,0 +1,11 @@
+<component>
+ name = "EdkIIGluePeiServicesTablePointerLib"
+ category = ModulePart
+ LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\PeiServicesTablePointerLib"
+ RefName = "EdkIIGluePeiServicesTablePointerLib"
+[files]
+"EdkIIGluePeiServicesTablePointerLib.sdl"
+"EdkIIGluePeiServicesTablePointerLib.mak"
+"PeiServicesTablePointerLib.inf"
+"PeiServicesTablePointer.c"
+<endComponent>
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLib/EdkIIGluePeiServicesTablePointerLib.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLib/EdkIIGluePeiServicesTablePointerLib.mak
new file mode 100644
index 0000000..5454fa6
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLib/EdkIIGluePeiServicesTablePointerLib.mak
@@ -0,0 +1,80 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGluePeiServicesTablePointerLib/EdkIIGluePeiServicesTablePointerLib.mak 1 1/20/12 3:57a Jeffch $
+#
+# $Revision: 1 $
+#
+# $Date: 1/20/12 3:57a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGluePeiServicesTablePointerLib/EdkIIGluePeiServicesTablePointerLib.mak $
+#
+# 1 1/20/12 3:57a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 9/27/11 6:19a Wesleychen
+# Intel EDK initially releases.
+#
+# 1 9/18/09 1:58a Iminglin
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: EdkIIGluePeiServicesTablePointerLib.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+
+
+$(EdkIIGluePeiServicesTablePointerLib_LIB) : EdkIIGluePeiServicesTablePointerLib
+
+EdkIIGluePeiServicesTablePointerLib : $(BUILD_DIR)\EdkIIGluePeiServicesTablePointerLib.mak EdkIIGluePeiServicesTablePointerLibBin
+
+$(BUILD_DIR)\EdkIIGluePeiServicesTablePointerLib.mak : $(EdkIIGluePeiServicesTablePointerLib_DIR)\$(@B).cif $(EdkIIGluePeiServicesTablePointerLib_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(EdkIIGluePeiServicesTablePointerLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+EdkIIGluePeiServicesTablePointerLibBin :
+!IF "$(x64_BUILD)"=="1"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGluePeiServicesTablePointerLib.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGluePeiServicesTablePointerLib_LIB)"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\IA32\
+ /f $(BUILD_DIR)\EdkIIGluePeiServicesTablePointerLib.mak all\
+ TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGluePeiServicesTablePointerLib_LIB)"
+!ELSE
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGluePeiServicesTablePointerLib.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGluePeiServicesTablePointerLib_LIB)"
+!ENDIF
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLib/EdkIIGluePeiServicesTablePointerLib.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLib/EdkIIGluePeiServicesTablePointerLib.sdl
new file mode 100644
index 0000000..1a9ad48
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLib/EdkIIGluePeiServicesTablePointerLib.sdl
@@ -0,0 +1,26 @@
+TOKEN
+ Name = "EdkIIGluePeiServicesTablePointerLib_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable EdkIIGluePeiServicesTablePointerLib support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "EdkIIGluePeiServicesTablePointerLib_LIB"
+ Value = "$$(LIB_BUILD_DIR)\EdkIIGluePeiServicesTablePointerLib.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "EdkIIGluePeiServicesTablePointerLib_DIR"
+End
+
+MODULE
+ Help = "Includes EdkIIGluePeiServicesTablePointerLib.mak to Project"
+ File = "EdkIIGluePeiServicesTablePointerLib.mak"
+End
+
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLib/PeiServicesTablePointer.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLib/PeiServicesTablePointer.c
new file mode 100644
index 0000000..7e632d3
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLib/PeiServicesTablePointer.c
@@ -0,0 +1,66 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ PeiServicesTablePointer.c
+
+Abstract:
+
+ PEI Services Table Pointer Library.
+
+--*/
+
+#include "EdkIIGluePeim.h"
+
+static EFI_PEI_SERVICES **gPeiServices;
+
+/**
+ The function returns the pointer to PEI services.
+
+ The function returns the pointer to PEI services.
+ It will ASSERT() if the pointer to PEI services is NULL.
+
+ @retval The pointer to PeiServices.
+
+**/
+EFI_PEI_SERVICES **
+GetPeiServicesTablePointer (
+ VOID
+ )
+{
+ ASSERT (gPeiServices != NULL);
+ return gPeiServices;
+}
+
+
+/**
+ The constructor function caches the pointer to PEI services.
+
+ The constructor function caches the pointer to PEI services.
+ It will always return EFI_SUCCESS.
+
+ @param FfsHeader Pointer to FFS header the loaded driver.
+ @param PeiServices Pointer to the PEI services.
+
+ @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
+
+**/
+EFI_STATUS
+PeiServicesTablePointerLibConstructor (
+ IN EFI_FFS_FILE_HEADER *FfsHeader,
+ IN EFI_PEI_SERVICES **PeiServices
+ )
+{
+ gPeiServices = PeiServices;
+ return EFI_SUCCESS;
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
new file mode 100644
index 0000000..8eb2e6d
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLib/PeiServicesTablePointerLib.inf
@@ -0,0 +1,77 @@
+#/*++
+#
+# Copyright (c) 2004 - 2006, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# PeiServiceTablePointerLib.inf
+#
+# Abstract:
+#
+# Component description file for PeiServicesTablePointerLib.
+#
+#--*/
+
+[defines]
+BASE_NAME = EdkIIGluePeiServicesTablePointerLib
+COMPONENT_TYPE = LIBRARY
+
+[sources.common]
+ PeiServicesTablePointer.c
+
+[sources.ia32]
+
+[sources.x64]
+
+[sources.ipf]
+
+[sources.ebc]
+
+
+[includes.common]
+ .
+ ..\..\Include
+ ..\..\include\Library
+ $(EDK_SOURCE)\Foundation
+ $(EDK_SOURCE)\Foundation\Framework
+ $(EDK_SOURCE)\Foundation\Include\Pei
+ $(EDK_SOURCE)\Foundation\Efi
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+ $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include
+
+[libraries.common]
+
+
+[libraries.ia32]
+
+
+[libraries.x64]
+
+
+[nmake.common]
+ C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION
+ LIB_STD_FLAGS = /NOLOGO /IGNORE:4006
+
+[nmake.ia32]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32
+
+[nmake.x64]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64
+
+[nmake.ipf]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF
+
+[nmake.ebc]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibMm7/EdkIIGluePeiServicesTablePointerLibMm7.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibMm7/EdkIIGluePeiServicesTablePointerLibMm7.cif
new file mode 100644
index 0000000..e363243
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibMm7/EdkIIGluePeiServicesTablePointerLibMm7.cif
@@ -0,0 +1,11 @@
+<component>
+ name = "EdkIIGluePeiServicesTablePointerLibMm7"
+ category = ModulePart
+ LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\PeiServicesTablePointerLibMm7"
+ RefName = "EdkIIGluePeiServicesTablePointerLibMm7"
+[files]
+"EdkIIGluePeiServicesTablePointerLibMm7.sdl"
+"EdkIIGluePeiServicesTablePointerLibMm7.mak"
+"PeiServicesTablePointerLibMm7.inf"
+"PeiServicesTablePointer.c"
+<endComponent>
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibMm7/EdkIIGluePeiServicesTablePointerLibMm7.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibMm7/EdkIIGluePeiServicesTablePointerLibMm7.mak
new file mode 100644
index 0000000..6bec27d
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibMm7/EdkIIGluePeiServicesTablePointerLibMm7.mak
@@ -0,0 +1,80 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGluePeiServicesTablePointerLibMm7/EdkIIGluePeiServicesTablePointerLibMm7.mak 1 1/20/12 3:57a Jeffch $
+#
+# $Revision: 1 $
+#
+# $Date: 1/20/12 3:57a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGluePeiServicesTablePointerLibMm7/EdkIIGluePeiServicesTablePointerLibMm7.mak $
+#
+# 1 1/20/12 3:57a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 9/27/11 6:19a Wesleychen
+# Intel EDK initially releases.
+#
+# 1 9/18/09 1:58a Iminglin
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: EdkIIGluePeiServicesTablePointerLibMm7.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+
+
+$(EdkIIGluePeiServicesTablePointerLibMm7_LIB) : EdkIIGluePeiServicesTablePointerLibMm7
+
+EdkIIGluePeiServicesTablePointerLibMm7 : $(BUILD_DIR)\EdkIIGluePeiServicesTablePointerLibMm7.mak EdkIIGluePeiServicesTablePointerLibMm7Bin
+
+$(BUILD_DIR)\EdkIIGluePeiServicesTablePointerLibMm7.mak : $(EdkIIGluePeiServicesTablePointerLibMm7_DIR)\$(@B).cif $(EdkIIGluePeiServicesTablePointerLibMm7_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(EdkIIGluePeiServicesTablePointerLibMm7_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+EdkIIGluePeiServicesTablePointerLibMm7Bin : $(EdkIIGlueBaseLib_LIB)
+!IF "$(x64_BUILD)"=="1"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGluePeiServicesTablePointerLibMm7.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGluePeiServicesTablePointerLibMm7_LIB)"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\IA32\
+ /f $(BUILD_DIR)\EdkIIGluePeiServicesTablePointerLibMm7.mak all\
+ TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGluePeiServicesTablePointerLibMm7_LIB)"
+!ELSE
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGluePeiServicesTablePointerLibMm7.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGluePeiServicesTablePointerLibMm7_LIB)"
+!ENDIF
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#********************************************************************** \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibMm7/EdkIIGluePeiServicesTablePointerLibMm7.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibMm7/EdkIIGluePeiServicesTablePointerLibMm7.sdl
new file mode 100644
index 0000000..c8b62d5
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibMm7/EdkIIGluePeiServicesTablePointerLibMm7.sdl
@@ -0,0 +1,26 @@
+TOKEN
+ Name = "EdkIIGluePeiServicesTablePointerLibMm7_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable EdkIIGluePeiServicesTablePointerLibMm7 support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "EdkIIGluePeiServicesTablePointerLibMm7_LIB"
+ Value = "$$(LIB_BUILD_DIR)\EdkIIGluePeiServicesTablePointerLibMm7.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "EdkIIGluePeiServicesTablePointerLibMm7_DIR"
+End
+
+MODULE
+ Help = "Includes EdkIIGluePeiServicesTablePointerLibMm7.mak to Project"
+ File = "EdkIIGluePeiServicesTablePointerLibMm7.mak"
+End
+
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibMm7/PeiServicesTablePointer.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibMm7/PeiServicesTablePointer.c
new file mode 100644
index 0000000..c6f4cf3
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibMm7/PeiServicesTablePointer.c
@@ -0,0 +1,84 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ PeiServicesTablePointer.c
+
+Abstract:
+
+ PEI Services Table Pointer Library.
+
+--*/
+
+#include "EdkIIGluePeim.h"
+
+/**
+ The function returns the pointer to PeiServices.
+
+ The function returns the pointer to PeiServices.
+ It will ASSERT() if the pointer to PeiServices is NULL.
+
+ @retval The pointer to PeiServices.
+
+**/
+EFI_PEI_SERVICES **
+EFIAPI
+GetPeiServicesTablePointer (
+ VOID
+ )
+{
+ EFI_PEI_SERVICES **PeiServices;
+#if (PI_SPECIFICATION_VERSION >= 0x00010000) //;;## ...AMI_OVERRIDE... Support PI1.x
+ IA32_DESCRIPTOR Idtr;
+#endif
+
+#if (PI_SPECIFICATION_VERSION < 0x00010000) //;;## ...AMI_OVERRIDE... Support PI1.x
+ PeiServices = (EFI_PEI_SERVICES **)(UINTN)AsmReadMm7 ();
+#else
+ AsmReadIdtr (&Idtr);
+ PeiServices = (EFI_PEI_SERVICES **)(UINTN)(*(UINTN*)(Idtr.Base - sizeof (UINTN)));
+#endif
+
+ if ((*PeiServices)->Hdr.Signature == PEI_SERVICES_SIGNATURE) {
+ return PeiServices;
+ } else {
+ PeiServices = (EFI_PEI_SERVICES **)(UINTN)AsmReadMm7 ();
+ ASSERT (PeiServices != NULL);
+ return PeiServices;
+ }
+}
+
+/**
+ The constructor function caches the pointer to PEI services.
+
+ The constructor function caches the pointer to PEI services.
+ It will always return EFI_SUCCESS.
+
+ @param FfsHeader Pointer to FFS header the loaded driver.
+ @param PeiServices Pointer to the PEI services.
+
+ @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
+
+**/
+EFI_STATUS
+EFIAPI
+PeiServicesTablePointerLibConstructor (
+ IN EFI_FFS_FILE_HEADER *FfsHeader,
+ IN EFI_PEI_SERVICES **PeiServices
+ )
+{
+#if (PI_SPECIFICATION_VERSION < 0x00010000)
+ AsmWriteMm7 ((UINT64)(UINTN)PeiServices);
+#endif
+ return EFI_SUCCESS;
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibMm7/PeiServicesTablePointerLibMm7.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibMm7/PeiServicesTablePointerLibMm7.inf
new file mode 100644
index 0000000..9e66213
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiServicesTablePointerLibMm7/PeiServicesTablePointerLibMm7.inf
@@ -0,0 +1,77 @@
+#/*++
+#
+# Copyright (c) 2004 - 2006, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# PeiServiceTablePointerLibMm7.inf
+#
+# Abstract:
+#
+# Component description file for PeiServicesTablePointerLibMm7.
+#
+#--*/
+
+[defines]
+BASE_NAME = EdkIIGluePeiServicesTablePointerLibMm7
+COMPONENT_TYPE = LIBRARY
+
+[sources.common]
+ PeiServicesTablePointer.c
+
+[sources.ia32]
+
+[sources.x64]
+
+[sources.ipf]
+
+[sources.ebc]
+
+
+[includes.common]
+ .
+ ..\..\Include
+ ..\..\include\Library
+ $(EDK_SOURCE)\Foundation
+ $(EDK_SOURCE)\Foundation\Framework
+ $(EDK_SOURCE)\Foundation\Include\Pei
+ $(EDK_SOURCE)\Foundation\Efi
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+ $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include
+
+[libraries.common]
+ EdkIIGlueBaseLib
+
+[libraries.ia32]
+
+
+[libraries.x64]
+
+
+[nmake.common]
+ C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION
+ LIB_STD_FLAGS = /NOLOGO /IGNORE:4006
+
+[nmake.ia32]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32
+
+[nmake.x64]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64
+
+[nmake.ipf]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF
+
+[nmake.ebc]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/EdkIIGluePeiSmbusLib.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/EdkIIGluePeiSmbusLib.cif
new file mode 100644
index 0000000..89f6664
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/EdkIIGluePeiSmbusLib.cif
@@ -0,0 +1,13 @@
+<component>
+ name = "EdkIIGluePeiSmbusLib"
+ category = ModulePart
+ LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\PeiSmbusLib"
+ RefName = "EdkIIGluePeiSmbusLib"
+[files]
+"EdkIIGluePeiSmbusLib.sdl"
+"EdkIIGluePeiSmbusLib.mak"
+"PeiSmbusLib.inf"
+"PeiSmbusLib.c"
+"SmbusLib.c"
+"PeiSmbusLibInternal.h"
+<endComponent>
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/EdkIIGluePeiSmbusLib.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/EdkIIGluePeiSmbusLib.mak
new file mode 100644
index 0000000..8a62183
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/EdkIIGluePeiSmbusLib.mak
@@ -0,0 +1,80 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGluePeiSmbusLib/EdkIIGluePeiSmbusLib.mak 1 1/20/12 3:57a Jeffch $
+#
+# $Revision: 1 $
+#
+# $Date: 1/20/12 3:57a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGluePeiSmbusLib/EdkIIGluePeiSmbusLib.mak $
+#
+# 1 1/20/12 3:57a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 9/27/11 6:19a Wesleychen
+# Intel EDK initially releases.
+#
+# 1 9/18/09 1:58a Iminglin
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: EdkIIGluePeiSmbusLib.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+
+
+$(EdkIIGluePeiSmbusLib_LIB) : EdkIIGluePeiSmbusLib
+
+EdkIIGluePeiSmbusLib : $(BUILD_DIR)\EdkIIGluePeiSmbusLib.mak EdkIIGluePeiSmbusLibBin
+
+$(BUILD_DIR)\EdkIIGluePeiSmbusLib.mak : $(EdkIIGluePeiSmbusLib_DIR)\$(@B).cif $(EdkIIGluePeiSmbusLib_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(EdkIIGluePeiSmbusLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+EdkIIGluePeiSmbusLibBin : $(EdkIIGlueBaseMemoryLib_LIB) $(EdkIIGluePeiServicesTablePointerLibMm7_LIB)
+!IF "$(x64_BUILD)"=="1"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGluePeiSmbusLib.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGluePeiSmbusLib_LIB)"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\IA32\
+ /f $(BUILD_DIR)\EdkIIGluePeiSmbusLib.mak all\
+ TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGluePeiSmbusLib_LIB)"
+!ELSE
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGluePeiSmbusLib.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGluePeiSmbusLib_LIB)"
+!ENDIF
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#********************************************************************** \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/EdkIIGluePeiSmbusLib.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/EdkIIGluePeiSmbusLib.sdl
new file mode 100644
index 0000000..14029a3
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/EdkIIGluePeiSmbusLib.sdl
@@ -0,0 +1,26 @@
+TOKEN
+ Name = "EdkIIGluePeiSmbusLib_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable EdkIIGluePeiSmbusLib support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "EdkIIGluePeiSmbusLib_LIB"
+ Value = "$$(LIB_BUILD_DIR)\EdkIIGluePeiSmbusLib.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "EdkIIGluePeiSmbusLib_DIR"
+End
+
+MODULE
+ Help = "Includes EdkIIGluePeiSmbusLib.mak to Project"
+ File = "EdkIIGluePeiSmbusLib.mak"
+End
+
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/PeiSmbusLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/PeiSmbusLib.c
new file mode 100644
index 0000000..4598af4
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/PeiSmbusLib.c
@@ -0,0 +1,104 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ PeiSmbusLib.c
+
+Abstract:
+
+ PEI Smbus Lib internal functions
+
+--*/
+
+#include "PeiSmbusLibInternal.h"
+
+/**
+ Gets Smbus PPIs.
+
+ This internal function retrieves Smbus PPI from PPI database.
+
+ @param PeiServices An indirect pointer to the EFI_PEI_SERVICES published by the PEI Foundation.
+
+ @return The pointer to Smbus PPI.
+
+**/
+EFI_PEI_SMBUS_PPI *
+InternalGetSmbusPpi (
+ EFI_PEI_SERVICES **PeiServices
+ )
+{
+ EFI_STATUS Status;
+ EFI_PEI_SMBUS_PPI *SmbusPpi;
+
+ Status = (*PeiServices)->LocatePpi (PeiServices, &gEfiPeiSmbusPpiGuid, 0, NULL, (VOID **) &SmbusPpi);
+ ASSERT_EFI_ERROR (Status);
+ ASSERT (SmbusPpi != NULL);
+
+ return SmbusPpi;
+}
+
+/**
+ Executes an SMBus operation to an SMBus controller.
+
+ This function provides a standard way to execute Smbus script
+ as defined in the SmBus Specification. The data can either be of
+ the Length byte, word, or a block of data.
+
+ @param SmbusOperation Signifies which particular SMBus hardware protocol instance that it will use to
+ execute the SMBus transactions.
+ @param SmBusAddress Address that encodes the SMBUS Slave Address,
+ SMBUS Command, SMBUS Data Length, and PEC.
+ @param Length Signifies the number of bytes that this operation will do. The maximum number of
+ bytes can be revision specific and operation specific.
+ @param Buffer Contains the value of data to execute to the SMBus slave device. Not all operations
+ require this argument. The length of this buffer is identified by Length.
+ @param Status Return status for the executed command.
+ This is an optional parameter and may be NULL.
+
+ @return The actual number of bytes that are executed for this operation..
+
+**/
+UINTN
+InternalSmBusExec (
+ IN EFI_SMBUS_OPERATION SmbusOperation,
+ IN UINTN SmBusAddress,
+ IN UINTN Length,
+ IN OUT VOID *Buffer,
+ OUT RETURN_STATUS *Status OPTIONAL
+ )
+{
+ EFI_PEI_SMBUS_PPI *SmbusPpi;
+ EFI_PEI_SERVICES **PeiServices;
+ RETURN_STATUS ReturnStatus;
+ EFI_SMBUS_DEVICE_ADDRESS SmbusDeviceAddress;
+
+ PeiServices = GetPeiServicesTablePointer ();
+ SmbusPpi = InternalGetSmbusPpi (PeiServices);
+ SmbusDeviceAddress.SmbusDeviceAddress = SMBUS_LIB_SLAVE_ADDRESS (SmBusAddress);
+
+ ReturnStatus = SmbusPpi->Execute (
+ PeiServices,
+ SmbusPpi,
+ SmbusDeviceAddress,
+ SMBUS_LIB_COMMAND (SmBusAddress),
+ SmbusOperation,
+ SMBUS_LIB_PEC (SmBusAddress),
+ &Length,
+ Buffer
+ );
+ if (Status != NULL) {
+ *Status = ReturnStatus;
+ }
+
+ return Length;
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/PeiSmbusLib.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/PeiSmbusLib.inf
new file mode 100644
index 0000000..0b98e3c
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/PeiSmbusLib.inf
@@ -0,0 +1,84 @@
+#/*++
+#
+# Copyright (c) 2004 - 2006, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# PeiSmbusLib.inf
+#
+# Abstract:
+#
+# Component description file for PeiSmbusLib.
+#
+#--*/
+
+[defines]
+BASE_NAME = EdkIIGluePeiSmbusLib
+COMPONENT_TYPE = LIBRARY
+
+[sources.common]
+ PeiSmbusLib.c
+ SmbusLib.c
+
+[sources.ia32]
+
+[sources.x64]
+
+[sources.ipf]
+
+[sources.ebc]
+
+
+[includes.common]
+ .
+ ..\..\Include
+ ..\..\include\Library
+ $(EDK_SOURCE)\Foundation
+ $(EDK_SOURCE)\Foundation\Framework
+ $(EDK_SOURCE)\Foundation\Efi
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+ $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include
+ $(EDK_SOURCE)\Foundation\Framework\Guid\DataHubRecords
+ $(EDK_SOURCE)\Foundation\Framework\Guid\StatusCodeDataTypeId
+ $(EDK_SOURCE)\Foundation\Include\Pei
+
+[libraries.common]
+ EdkIIGlueBaseMemoryLib
+ EdkIIGluePeiServicesTablePointerLibMm7
+#
+# If necessary, EdkIIGluePeiServicesTablePointerLib can be
+# used to replace EdkIIGluePeiServicesTablePointerLibMm7
+#
+
+
+[libraries.ia32]
+
+[libraries.x64]
+
+[nmake.common]
+ C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION
+ LIB_STD_FLAGS = /NOLOGO /IGNORE:4006
+
+[nmake.ia32]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32
+
+[nmake.x64]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64
+
+[nmake.ipf]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF
+
+[nmake.ebc]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/PeiSmbusLibInternal.h b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/PeiSmbusLibInternal.h
new file mode 100644
index 0000000..2826a4e
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/PeiSmbusLibInternal.h
@@ -0,0 +1,68 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ PeiSmbusLibInternal.h
+
+Abstract:
+
+ Declarations of internal functions in PeiSmbusLib.
+
+--*/
+
+#ifndef __PEI_SMBUS_LIB_INTERNAL_H__
+#define __PEI_SMBUS_LIB_INTERNAL_H__
+
+#include "EdkIIGluePeim.h"
+
+
+#define SMBUS_LIB_SLAVE_ADDRESS(SmBusAddress) (((SmBusAddress) >> 1) & 0x7f)
+#define SMBUS_LIB_COMMAND(SmBusAddress) (((SmBusAddress) >> 8) & 0xff)
+#define SMBUS_LIB_LENGTH(SmBusAddress) (((SmBusAddress) >> 16) & 0x3f)
+#define SMBUS_LIB_PEC(SmBusAddress) ((BOOLEAN) (((SmBusAddress) & SMBUS_LIB_PEC_BIT) != 0))
+#define SMBUS_LIB_RESEARVED(SmBusAddress) ((SmBusAddress) & ~(((1 << 22) - 2) | SMBUS_LIB_PEC_BIT))
+
+//
+// Declaration for internal functions
+//
+/**
+ Executes an SMBus operation to an SMBus controller.
+
+ This function provides a standard way to execute Smbus script
+ as defined in the SmBus Specification. The data can either be of
+ the Length byte, word, or a block of data.
+
+ @param SmbusOperation Signifies which particular SMBus hardware protocol instance that it will use to
+ execute the SMBus transactions.
+ @param SmBusAddress Address that encodes the SMBUS Slave Address,
+ SMBUS Command, SMBUS Data Length, and PEC.
+ @param Length Signifies the number of bytes that this operation will do. The maximum number of
+ bytes can be revision specific and operation specific.
+ @param Buffer Contains the value of data to execute to the SMBus slave device. Not all operations
+ require this argument. The length of this buffer is identified by Length.
+ @param Status Return status for the executed command.
+ This is an optional parameter and may be NULL.
+
+ @return The actual number of bytes that are executed for this operation.
+
+**/
+UINTN
+InternalSmBusExec (
+ IN EFI_SMBUS_OPERATION SmbusOperation,
+ IN UINTN SmBusAddress,
+ IN UINTN Length,
+ IN OUT VOID *Buffer,
+ OUT RETURN_STATUS *Status OPTIONAL
+ );
+
+#endif
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/SmbusLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/SmbusLib.c
new file mode 100644
index 0000000..bd32d53
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/PeiSmbusLib/SmbusLib.c
@@ -0,0 +1,475 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ PeiSmbus.c
+
+Abstract:
+
+ Pei Smbus Lib Interfaces
+
+--*/
+
+#include "PeiSmbusLibInternal.h"
+
+/**
+ Executes an SMBUS quick read command.
+
+ Executes an SMBUS quick read command on the SMBUS device specified by SmBusAddress.
+ Only the SMBUS slave address field of SmBusAddress is required.
+ If Status is not NULL, then the status of the executed command is returned in Status.
+ If PEC is set in SmBusAddress, then ASSERT().
+ If Command in SmBusAddress is not zero, then ASSERT().
+ If Length in SmBusAddress is not zero, then ASSERT().
+ If any reserved bits of SmBusAddress are set, then ASSERT().
+
+ @param SmBusAddress Address that encodes the SMBUS Slave Address,
+ SMBUS Command, SMBUS Data Length, and PEC.
+ @param Status Return status for the executed command.
+ This is an optional parameter and may be NULL.
+
+**/
+VOID
+EFIAPI
+SmBusQuickRead (
+ IN UINTN SmBusAddress,
+ OUT RETURN_STATUS *Status OPTIONAL
+ )
+{
+ ASSERT (!SMBUS_LIB_PEC (SmBusAddress));
+ ASSERT (SMBUS_LIB_COMMAND (SmBusAddress) == 0);
+ ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0);
+ ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);
+
+ InternalSmBusExec (EfiSmbusQuickRead, SmBusAddress, 0, NULL, Status);
+}
+
+/**
+ Executes an SMBUS quick write command.
+
+ Executes an SMBUS quick write command on the SMBUS device specified by SmBusAddress.
+ Only the SMBUS slave address field of SmBusAddress is required.
+ If Status is not NULL, then the status of the executed command is returned in Status.
+ If PEC is set in SmBusAddress, then ASSERT().
+ If Command in SmBusAddress is not zero, then ASSERT().
+ If Length in SmBusAddress is not zero, then ASSERT().
+ If any reserved bits of SmBusAddress are set, then ASSERT().
+
+ @param SmBusAddress Address that encodes the SMBUS Slave Address,
+ SMBUS Command, SMBUS Data Length, and PEC.
+ @param Status Return status for the executed command.
+ This is an optional parameter and may be NULL.
+
+**/
+VOID
+EFIAPI
+SmBusQuickWrite (
+ IN UINTN SmBusAddress,
+ OUT RETURN_STATUS *Status OPTIONAL
+ )
+{
+ ASSERT (!SMBUS_LIB_PEC (SmBusAddress));
+ ASSERT (SMBUS_LIB_COMMAND (SmBusAddress) == 0);
+ ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0);
+ ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);
+
+ InternalSmBusExec (EfiSmbusQuickWrite, SmBusAddress, 0, NULL, Status);
+}
+
+/**
+ Executes an SMBUS receive byte command.
+
+ Executes an SMBUS receive byte command on the SMBUS device specified by SmBusAddress.
+ Only the SMBUS slave address field of SmBusAddress is required.
+ The byte received from the SMBUS is returned.
+ If Status is not NULL, then the status of the executed command is returned in Status.
+ If Command in SmBusAddress is not zero, then ASSERT().
+ If Length in SmBusAddress is not zero, then ASSERT().
+ If any reserved bits of SmBusAddress are set, then ASSERT().
+
+ @param SmBusAddress Address that encodes the SMBUS Slave Address,
+ SMBUS Command, SMBUS Data Length, and PEC.
+ @param Status Return status for the executed command.
+ This is an optional parameter and may be NULL.
+
+ @return The byte received from the SMBUS.
+
+**/
+UINT8
+EFIAPI
+SmBusReceiveByte (
+ IN UINTN SmBusAddress,
+ OUT RETURN_STATUS *Status OPTIONAL
+ )
+{
+ UINT8 Byte;
+
+ ASSERT (SMBUS_LIB_COMMAND (SmBusAddress) == 0);
+ ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0);
+ ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);
+
+ InternalSmBusExec (EfiSmbusReceiveByte, SmBusAddress, 1, &Byte, Status);
+
+ return Byte;
+}
+
+/**
+ Executes an SMBUS send byte command.
+
+ Executes an SMBUS send byte command on the SMBUS device specified by SmBusAddress.
+ The byte specified by Value is sent.
+ Only the SMBUS slave address field of SmBusAddress is required. Value is returned.
+ If Status is not NULL, then the status of the executed command is returned in Status.
+ If Command in SmBusAddress is not zero, then ASSERT().
+ If Length in SmBusAddress is not zero, then ASSERT().
+ If any reserved bits of SmBusAddress are set, then ASSERT().
+
+ @param SmBusAddress Address that encodes the SMBUS Slave Address,
+ SMBUS Command, SMBUS Data Length, and PEC.
+ @param Value The 8-bit value to send.
+ @param Status Return status for the executed command.
+ This is an optional parameter and may be NULL.
+
+ @return The parameter of Value.
+
+**/
+UINT8
+EFIAPI
+SmBusSendByte (
+ IN UINTN SmBusAddress,
+ IN UINT8 Value,
+ OUT RETURN_STATUS *Status OPTIONAL
+ )
+{
+ UINT8 Byte;
+
+ ASSERT (SMBUS_LIB_COMMAND (SmBusAddress) == 0);
+ ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0);
+ ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);
+
+ Byte = Value;
+ InternalSmBusExec (EfiSmbusSendByte, SmBusAddress, 1, &Byte, Status);
+
+ return Value;
+}
+
+/**
+ Executes an SMBUS read data byte command.
+
+ Executes an SMBUS read data byte command on the SMBUS device specified by SmBusAddress.
+ Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.
+ The 8-bit value read from the SMBUS is returned.
+ If Status is not NULL, then the status of the executed command is returned in Status.
+ If Length in SmBusAddress is not zero, then ASSERT().
+ If any reserved bits of SmBusAddress are set, then ASSERT().
+
+ @param SmBusAddress Address that encodes the SMBUS Slave Address,
+ SMBUS Command, SMBUS Data Length, and PEC.
+ @param Status Return status for the executed command.
+ This is an optional parameter and may be NULL.
+
+ @return The byte read from the SMBUS.
+
+**/
+UINT8
+EFIAPI
+SmBusReadDataByte (
+ IN UINTN SmBusAddress,
+ OUT RETURN_STATUS *Status OPTIONAL
+ )
+{
+ UINT8 Byte;
+
+ ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0);
+ ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);
+
+ InternalSmBusExec (EfiSmbusReadByte, SmBusAddress, 1, &Byte, Status);
+
+ return Byte;
+}
+
+/**
+ Executes an SMBUS write data byte command.
+
+ Executes an SMBUS write data byte command on the SMBUS device specified by SmBusAddress.
+ The 8-bit value specified by Value is written.
+ Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.
+ Value is returned.
+ If Status is not NULL, then the status of the executed command is returned in Status.
+ If Length in SmBusAddress is not zero, then ASSERT().
+ If any reserved bits of SmBusAddress are set, then ASSERT().
+
+ @param SmBusAddress Address that encodes the SMBUS Slave Address,
+ SMBUS Command, SMBUS Data Length, and PEC.
+ @param Value The 8-bit value to write.
+ @param Status Return status for the executed command.
+ This is an optional parameter and may be NULL.
+
+ @return The parameter of Value.
+
+**/
+UINT8
+EFIAPI
+SmBusWriteDataByte (
+ IN UINTN SmBusAddress,
+ IN UINT8 Value,
+ OUT RETURN_STATUS *Status OPTIONAL
+ )
+{
+ UINT8 Byte;
+
+ ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0);
+ ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);
+
+ Byte = Value;
+ InternalSmBusExec (EfiSmbusWriteByte, SmBusAddress, 1, &Byte, Status);
+
+ return Value;
+}
+
+/**
+ Executes an SMBUS read data word command.
+
+ Executes an SMBUS read data word command on the SMBUS device specified by SmBusAddress.
+ Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.
+ The 16-bit value read from the SMBUS is returned.
+ If Status is not NULL, then the status of the executed command is returned in Status.
+ If Length in SmBusAddress is not zero, then ASSERT().
+ If any reserved bits of SmBusAddress are set, then ASSERT().
+
+ @param SmBusAddress Address that encodes the SMBUS Slave Address,
+ SMBUS Command, SMBUS Data Length, and PEC.
+ @param Status Return status for the executed command.
+ This is an optional parameter and may be NULL.
+
+ @return The byte read from the SMBUS.
+
+**/
+UINT16
+EFIAPI
+SmBusReadDataWord (
+ IN UINTN SmBusAddress,
+ OUT RETURN_STATUS *Status OPTIONAL
+ )
+{
+ UINT16 Word;
+
+ ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0);
+ ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);
+
+ InternalSmBusExec (EfiSmbusReadWord, SmBusAddress, 2, &Word, Status);
+
+ return Word;
+}
+
+/**
+ Executes an SMBUS write data word command.
+
+ Executes an SMBUS write data word command on the SMBUS device specified by SmBusAddress.
+ The 16-bit value specified by Value is written.
+ Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.
+ Value is returned.
+ If Status is not NULL, then the status of the executed command is returned in Status.
+ If Length in SmBusAddress is not zero, then ASSERT().
+ If any reserved bits of SmBusAddress are set, then ASSERT().
+
+ @param SmBusAddress Address that encodes the SMBUS Slave Address,
+ SMBUS Command, SMBUS Data Length, and PEC.
+ @param Value The 16-bit value to write.
+ @param Status Return status for the executed command.
+ This is an optional parameter and may be NULL.
+
+ @return The parameter of Value.
+
+**/
+UINT16
+EFIAPI
+SmBusWriteDataWord (
+ IN UINTN SmBusAddress,
+ IN UINT16 Value,
+ OUT RETURN_STATUS *Status OPTIONAL
+ )
+{
+ UINT16 Word;
+
+ ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0);
+ ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);
+
+ Word = Value;
+ InternalSmBusExec (EfiSmbusWriteWord, SmBusAddress, 2, &Word, Status);
+
+ return Value;
+}
+
+/**
+ Executes an SMBUS process call command.
+
+ Executes an SMBUS process call command on the SMBUS device specified by SmBusAddress.
+ The 16-bit value specified by Value is written.
+ Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.
+ The 16-bit value returned by the process call command is returned.
+ If Status is not NULL, then the status of the executed command is returned in Status.
+ If Length in SmBusAddress is not zero, then ASSERT().
+ If any reserved bits of SmBusAddress are set, then ASSERT().
+
+ @param SmBusAddress Address that encodes the SMBUS Slave Address,
+ SMBUS Command, SMBUS Data Length, and PEC.
+ @param Value The 16-bit value to write.
+ @param Status Return status for the executed command.
+ This is an optional parameter and may be NULL.
+
+ @return The 16-bit value returned by the process call command.
+
+**/
+UINT16
+EFIAPI
+SmBusProcessCall (
+ IN UINTN SmBusAddress,
+ IN UINT16 Value,
+ OUT RETURN_STATUS *Status OPTIONAL
+ )
+{
+ ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0);
+ ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);
+
+ InternalSmBusExec (EfiSmbusProcessCall, SmBusAddress, 2, &Value, Status);
+
+ return Value;
+}
+
+/**
+ Executes an SMBUS read block command.
+
+ Executes an SMBUS read block command on the SMBUS device specified by SmBusAddress.
+ Only the SMBUS slave address and SMBUS command fields of SmBusAddress are required.
+ Bytes are read from the SMBUS and stored in Buffer.
+ The number of bytes read is returned, and will never return a value larger than 32-bytes.
+ If Status is not NULL, then the status of the executed command is returned in Status.
+ It is the caller's responsibility to make sure Buffer is large enough for the total number of bytes read.
+ SMBUS supports a maximum transfer size of 32 bytes, so Buffer does not need to be any larger than 32 bytes.
+ If Length in SmBusAddress is not zero, then ASSERT().
+ If Buffer is NULL, then ASSERT().
+ If any reserved bits of SmBusAddress are set, then ASSERT().
+
+ @param SmBusAddress Address that encodes the SMBUS Slave Address,
+ SMBUS Command, SMBUS Data Length, and PEC.
+ @param Buffer Pointer to the buffer to store the bytes read from the SMBUS.
+ @param Status Return status for the executed command.
+ This is an optional parameter and may be NULL.
+
+ @return The number of bytes read.
+
+**/
+UINTN
+EFIAPI
+SmBusReadBlock (
+ IN UINTN SmBusAddress,
+ OUT VOID *Buffer,
+ OUT RETURN_STATUS *Status OPTIONAL
+ )
+{
+ ASSERT (Buffer != NULL);
+ ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) == 0);
+ ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);
+
+ return InternalSmBusExec (EfiSmbusReadBlock, SmBusAddress, 0x20, Buffer, Status);
+}
+
+/**
+ Executes an SMBUS write block command.
+
+ Executes an SMBUS write block command on the SMBUS device specified by SmBusAddress.
+ The SMBUS slave address, SMBUS command, and SMBUS length fields of SmBusAddress are required.
+ Bytes are written to the SMBUS from Buffer.
+ The number of bytes written is returned, and will never return a value larger than 32-bytes.
+ If Status is not NULL, then the status of the executed command is returned in Status.
+ If Length in SmBusAddress is zero or greater than 32, then ASSERT().
+ If Buffer is NULL, then ASSERT().
+ If any reserved bits of SmBusAddress are set, then ASSERT().
+
+ @param SmBusAddress Address that encodes the SMBUS Slave Address,
+ SMBUS Command, SMBUS Data Length, and PEC.
+ @param Buffer Pointer to the buffer to store the bytes read from the SMBUS.
+ @param Status Return status for the executed command.
+ This is an optional parameter and may be NULL.
+
+ @return The number of bytes written.
+
+**/
+UINTN
+EFIAPI
+SmBusWriteBlock (
+ IN UINTN SmBusAddress,
+ OUT VOID *Buffer,
+ OUT RETURN_STATUS *Status OPTIONAL
+ )
+{
+ UINTN Length;
+
+ ASSERT (Buffer != NULL);
+ ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) >= 1);
+ ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) <= 32);
+ ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);
+
+ Length = SMBUS_LIB_LENGTH (SmBusAddress);
+ return InternalSmBusExec (EfiSmbusWriteBlock, SmBusAddress, Length, Buffer, Status);
+}
+
+/**
+ Executes an SMBUS block process call command.
+
+ Executes an SMBUS block process call command on the SMBUS device specified by SmBusAddress.
+ The SMBUS slave address, SMBUS command, and SMBUS length fields of SmBusAddress are required.
+ Bytes are written to the SMBUS from WriteBuffer. Bytes are then read from the SMBUS into ReadBuffer.
+ If Status is not NULL, then the status of the executed command is returned in Status.
+ It is the caller's responsibility to make sure ReadBuffer is large enough for the total number of bytes read.
+ SMBUS supports a maximum transfer size of 32 bytes, so Buffer does not need to be any larger than 32 bytes.
+ If Length in SmBusAddress is zero or greater than 32, then ASSERT().
+ If WriteBuffer is NULL, then ASSERT().
+ If ReadBuffer is NULL, then ASSERT().
+ If any reserved bits of SmBusAddress are set, then ASSERT().
+
+ @param SmBusAddress Address that encodes the SMBUS Slave Address,
+ SMBUS Command, SMBUS Data Length, and PEC.
+ @param WriteBuffer Pointer to the buffer of bytes to write to the SMBUS.
+ @param ReadBuffer Pointer to the buffer of bytes to read from the SMBUS.
+ @param Status Return status for the executed command.
+ This is an optional parameter and may be NULL.
+
+ @return The number of bytes written.
+
+**/
+UINTN
+EFIAPI
+SmBusBlockProcessCall (
+ IN UINTN SmBusAddress,
+ IN VOID *WriteBuffer,
+ OUT VOID *ReadBuffer,
+ OUT RETURN_STATUS *Status OPTIONAL
+ )
+{
+ UINTN Length;
+
+ ASSERT (WriteBuffer != NULL);
+ ASSERT (ReadBuffer != NULL);
+ ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) >= 1);
+ ASSERT (SMBUS_LIB_LENGTH (SmBusAddress) <= 32);
+ ASSERT (SMBUS_LIB_RESEARVED (SmBusAddress) == 0);
+
+ Length = SMBUS_LIB_LENGTH (SmBusAddress);
+ //
+ // Assuming that ReadBuffer is large enough to save another memory copy.
+ //
+ ReadBuffer = CopyMem (ReadBuffer, WriteBuffer, Length);
+ return InternalSmBusExec (EfiSmbusBWBRProcessCall, SmBusAddress, Length, ReadBuffer, Status);
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmFirmwarePerformanceLib/EdkIIGlueSmmFirmwarePerformanceLib.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmFirmwarePerformanceLib/EdkIIGlueSmmFirmwarePerformanceLib.cif
new file mode 100644
index 0000000..ef6464a
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmFirmwarePerformanceLib/EdkIIGlueSmmFirmwarePerformanceLib.cif
@@ -0,0 +1,11 @@
+<component>
+ name = "EdkIIGlueSmmFirmwarePerformanceLib"
+ category = ModulePart
+ LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\SmmFirmwarePerformanceLib"
+ RefName = "EdkIIGlueSmmFirmwarePerformanceLib"
+[files]
+"EdkIIGlueSmmFirmwarePerformanceLib.sdl"
+"EdkIIGlueSmmFirmwarePerformanceLib.mak"
+"EdkIIGlueSmmFirmwarePerformanceLib.inf"
+"EdkIIGlueSmmPerformanceLib.c"
+<endComponent>
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmFirmwarePerformanceLib/EdkIIGlueSmmFirmwarePerformanceLib.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmFirmwarePerformanceLib/EdkIIGlueSmmFirmwarePerformanceLib.inf
new file mode 100644
index 0000000..8568f7f
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmFirmwarePerformanceLib/EdkIIGlueSmmFirmwarePerformanceLib.inf
@@ -0,0 +1,81 @@
+#/*++
+#
+# Copyright (c) 2011 - 2012, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# EdkIIGlueSmmFirmwarePerformanceLib.inf
+#
+# Abstract:
+#
+# Component description file for SmmFirmwarePerformanceLib
+#
+#--*/
+
+[defines]
+BASE_NAME = EdkIIGlueSmmFirmwarePerformanceLib
+COMPONENT_TYPE = LIBRARY
+
+[sources.common]
+ EdkIIGlueSmmPerformanceLib.c
+
+[sources.ia32]
+
+[sources.x64]
+
+[sources.ipf]
+
+[sources.ebc]
+
+
+[includes.common]
+ .
+ ..\..\Include
+ ..\..\include\Library
+ $(EDK_SOURCE)\Foundation
+ $(EDK_SOURCE)\Foundation\Framework
+ $(EDK_SOURCE)\Foundation\Efi
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+ $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include
+
+[libraries.common]
+ EdkIIGlueBaseTimerLibLocalApic
+ EdkIIGlueUefiLib
+ EdkIIGlueBaseTimerLibTsc
+
+[libraries.ia32]
+
+[libraries.x64]
+
+[libraries.ebc]
+
+
+[nmake.common]
+ C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION
+ LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006 /IGNORE:4221
+
+[nmake.ia32]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32
+
+[nmake.x64]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64
+
+[nmake.ipf]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF
+
+[nmake.ebc]
+ EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION
+ EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS) /IGNORE:4006 /IGNORE:4221
+ EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmFirmwarePerformanceLib/EdkIIGlueSmmFirmwarePerformanceLib.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmFirmwarePerformanceLib/EdkIIGlueSmmFirmwarePerformanceLib.mak
new file mode 100644
index 0000000..b53d2ee
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmFirmwarePerformanceLib/EdkIIGlueSmmFirmwarePerformanceLib.mak
@@ -0,0 +1,79 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2011, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueSmmFirmwarePerformanceLib/EdkIIGlueSmmFirmwarePerformanceLib.mak 1 1/20/12 3:59a Jeffch $
+#
+# $Revision: 1 $
+#
+# $Date: 1/20/12 3:59a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueSmmFirmwarePerformanceLib/EdkIIGlueSmmFirmwarePerformanceLib.mak $
+#
+# 1 1/20/12 3:59a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 9/27/11 6:22a Wesleychen
+# Intel EDK initially releases.
+#
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: EdkIIGlueSmmFirmwarePerformanceLib.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+
+
+$(EdkIIGlueSmmFirmwarePerformanceLib_LIB) : EdkIIGlueSmmFirmwarePerformanceLib
+
+EdkIIGlueSmmFirmwarePerformanceLib : $(BUILD_DIR)\EdkIIGlueSmmFirmwarePerformanceLib.mak EdkIIGlueSmmFirmwarePerformanceLibBin
+
+$(BUILD_DIR)\EdkIIGlueSmmFirmwarePerformanceLib.mak : $(EdkIIGlueSmmFirmwarePerformanceLib_DIR)\$(@B).cif $(EdkIIGlueSmmFirmwarePerformanceLib_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(EdkIIGlueSmmFirmwarePerformanceLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+EdkIIGlueSmmFirmwarePerformanceLibBin : $(EdkIIGlueBaseTimerLibLocalApic_LIB) $(EdkIIGlueUefiLib_LIB) $(EdkIIGlueBaseTimerLibTsc_LIB) $(EDKGUIDLIB) $(ARCHPROTOCOLLIB)
+!IF "$(x64_BUILD)"=="1"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGlueSmmFirmwarePerformanceLib.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueSmmFirmwarePerformanceLib_LIB)"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\IA32\
+ /f $(BUILD_DIR)\EdkIIGlueSmmFirmwarePerformanceLib.mak all\
+ TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueSmmFirmwarePerformanceLib_LIB)"
+!ELSE
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGlueSmmFirmwarePerformanceLib.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueSmmFirmwarePerformanceLib_LIB)"
+!ENDIF
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2011, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#********************************************************************** \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmFirmwarePerformanceLib/EdkIIGlueSmmFirmwarePerformanceLib.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmFirmwarePerformanceLib/EdkIIGlueSmmFirmwarePerformanceLib.sdl
new file mode 100644
index 0000000..dd89ca3
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmFirmwarePerformanceLib/EdkIIGlueSmmFirmwarePerformanceLib.sdl
@@ -0,0 +1,25 @@
+TOKEN
+ Name = "EdkIIGlueSmmFirmwarePerformanceLib_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable EdkIIGlueSmmFirmwarePerformanceLib support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "EdkIIGlueSmmFirmwarePerformanceLib_LIB"
+ Value = "$$(LIB_BUILD_DIR)\EdkIIGlueSmmFirmwarePerformanceLib.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "EdkIIGlueSmmFirmwarePerformanceLib_DIR"
+End
+
+MODULE
+ Help = "Includes EdkIIGlueSmmFirmwarePerformanceLib.mak to Project"
+ File = "EdkIIGlueSmmFirmwarePerformanceLib.mak"
+End \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmFirmwarePerformanceLib/EdkIIGlueSmmPerformanceLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmFirmwarePerformanceLib/EdkIIGlueSmmPerformanceLib.c
new file mode 100644
index 0000000..880a502
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmFirmwarePerformanceLib/EdkIIGlueSmmPerformanceLib.c
@@ -0,0 +1,261 @@
+/*++
+
+Copyright (c) 2011 - 2012, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ EdkIIGlueSmmPerformanceLib.c
+
+Abstract:
+
+ SMM Library for FPDT performance logging.
+
+--*/
+
+#include "EdkIIGlueDxe.h"
+#include EFI_PROTOCOL_DEFINITION (Fpdt)
+#include EFI_PROTOCOL_DEFINITION (FirmwarePerformance)
+
+UINT64 *mStartTicker;
+UINT32 mFunctionNumber;
+
+RUNTIME_MODULE_PERF_RECORD *mRuntimeModulePerfRecord = NULL;
+RUNTIME_FUNCTION_PERF_RECORD *mRuntimeFunctionPerfRecord = NULL;
+
+EFI_GUID gFpdtPerformanceProtocolGuid = FPDT_PERFORMANCE_PROTOCOL_GUID;
+EFI_GUID gEfiEventReadyToBootGuid = EFI_EVENT_GROUP_READY_TO_BOOT;
+
+EFI_STATUS
+StartMeasureEx (
+ IN EFI_HANDLE Handle,
+ IN UINT16 *Token,
+ IN UINT16 *Host,
+ IN UINT64 Timestamp,
+ IN UINT16 Identifier
+ )
+/*++
+
+Routine Description:
+
+ Start measurement according to token field. Inserts data into pre-allocatede memory buffer
+ Updates FPDT table using protocol API
+
+Arguments:
+
+ Handle - Handle to measure
+ Token - Token to measure
+ Host - Host to measure
+ Timestamp - Ticker as start tick
+ Identifier - Identifier for a record
+
+Returns:
+
+ EFI_SUCCESS - Located protocol successfully, and buffer is updated with new record
+ EFI_BUFFER_TOO_SMALL - Allocated memory is not enough to store new function
+ EFI_NOT_FOUND - Failure in update
+
+--*/
+{
+ EFI_STATUS Status;
+ UINT32 Index;
+ UINT32 RmptTableLength;
+
+ FPDT_PERFORMANCE_PROTOCOL *FpdtProtocol;
+ VOID *TableAddress;
+ EFI_GUID *GuidName;
+ RUNTIME_PERF_TABLE_HEADER *RuntimePerfTableHeader;
+
+ RmptTableLength = 0;
+
+ if (!StrCmp(Token, SMM_MODULE_TOK)) {
+ //
+ // Create RMPT table. The input Identifier specifies the max number of functions in this module.
+ //
+ mFunctionNumber = Identifier;
+ RmptTableLength = sizeof (RUNTIME_PERF_TABLE_HEADER) +
+ sizeof (RUNTIME_MODULE_PERF_RECORD) +
+ (sizeof(RUNTIME_FUNCTION_PERF_RECORD) * mFunctionNumber);
+
+ //
+ // Allocate reseved memory for RMPT table
+ //
+ Status = (gBS->AllocatePool) (EfiReservedMemoryType, RmptTableLength, &TableAddress);
+ ZeroMem (TableAddress, RmptTableLength);
+
+ Status = (gBS->AllocatePool) (EfiReservedMemoryType, sizeof (UINT64) * mFunctionNumber, &mStartTicker);
+ ZeroMem (mStartTicker, (sizeof (UINT64) * mFunctionNumber));
+
+ RuntimePerfTableHeader = (RUNTIME_PERF_TABLE_HEADER *) TableAddress;
+ mRuntimeModulePerfRecord = (RUNTIME_MODULE_PERF_RECORD *) ((UINT8 *) TableAddress + sizeof (RUNTIME_PERF_TABLE_HEADER));
+ mRuntimeFunctionPerfRecord = (RUNTIME_FUNCTION_PERF_RECORD *) ((UINT8 *) mRuntimeModulePerfRecord + sizeof (RUNTIME_MODULE_PERF_RECORD));
+
+ //
+ // Fill RMPT table header
+ //
+ RuntimePerfTableHeader->Signature = RMPT_SIG;
+ RuntimePerfTableHeader->Length = RmptTableLength;
+
+ GuidName = GetGuidFromHandle (Handle);
+ if (GuidName != NULL) {
+ (gBS->CopyMem) (&(RuntimePerfTableHeader->Guid), GuidName, sizeof (EFI_GUID));
+ }
+ //
+ // Fill mRuntimeModulePerfRecord.
+ //
+ mRuntimeModulePerfRecord->RuntimeRecType = RUNTIME_MODULE_REC_TYPE;
+ mRuntimeModulePerfRecord->Revision = RECORD_REVISION_1;
+ mRuntimeModulePerfRecord->Reclength = sizeof (RUNTIME_MODULE_PERF_RECORD);
+
+ //
+ // Call FPDT performance protocol to add RMPT table pointer record into FPDT table.
+ //
+ Status = (gBS->LocateProtocol) (
+ &gFpdtPerformanceProtocolGuid,
+ NULL,
+ &FpdtProtocol
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ if (!EFI_ERROR(Status)) {
+ Status = FpdtProtocol->UpdateRecord (
+ FpdtProtocol,
+ Handle,
+ RUNTIME_MODULE_TABLE_PTR_TYPE,
+ (UINT64) TableAddress,
+ 0
+ );
+ ASSERT_EFI_ERROR (Status);
+ }
+ }
+
+ if (!StrCmp (Token, SMM_FUNCTION_TOK)) {
+ //
+ // Add function record into RMPT table.
+ // The input Identifier is the function ID.
+ //
+ //
+ // Add function record into Record buffer.
+ //
+ for (Index = 0; Index < mFunctionNumber; Index++) {
+ if (mRuntimeFunctionPerfRecord[Index].RuntimeRecType == 0) {
+ //
+ // Fucntion ID is not found in Record buffer.
+ //
+ break;
+ }
+
+ if (mRuntimeFunctionPerfRecord[Index].FunctionId == Identifier) {
+ //
+ // This function ID is found in Record buffer.
+ //
+ break;
+ }
+ }
+
+ if (Index == mFunctionNumber) {
+ //
+ // Function record buffer is not enough to store new function.
+ //
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ if (mRuntimeFunctionPerfRecord[Index].RuntimeRecType == 0) {
+ //
+ // New function ID is found. Need to add it into FunctionRecord buffer.
+ //
+ mRuntimeFunctionPerfRecord[Index].RuntimeRecType = RUNTIME_FUNCTION_REC_TYPE;
+ mRuntimeFunctionPerfRecord[Index].Revision = RECORD_REVISION_1;
+ mRuntimeFunctionPerfRecord[Index].Reclength = sizeof (RUNTIME_FUNCTION_PERF_RECORD);
+ mRuntimeFunctionPerfRecord[Index].FunctionId = Identifier;
+ }
+ //
+ // Record start tick.
+ //
+ mStartTicker[Index] = GetTimeInNanoSec (Timestamp);
+ }
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EndMeasureEx (
+ IN EFI_HANDLE Handle,
+ IN UINT16 *Token,
+ IN UINT16 *Host,
+ IN UINT64 Timestamp,
+ IN UINT16 Identifier
+ )
+/*++
+
+Routine Description:
+
+ End measurement according to token field. Inserts data into pre-allocatede memory buffer
+
+Arguments:
+
+ Handle - Handle to measure
+ Token - Token to measure
+ Host - Host to measure
+ Timestamp - Ticker as start tick
+ Identifier - Identifier for a record
+
+Returns:
+
+ EFI_SUCCESS - Located protocol successfully, and buffer is updated with new record
+ EFI_BUFFER_TOO_SMALL - Allocated memory is not enough to store new function
+ EFI_NOT_FOUND - Fucntion ID is not found in Record buffer.
+
+--*/
+{
+ UINT32 Index;
+
+ if (!StrCmp (Token, SMM_FUNCTION_TOK)) {
+ //
+ // Update function record into RMPT table.
+ // The input Identifier is the function ID.
+ //
+ //
+ // Update function record into Record buffer.
+ //
+ for (Index = 0; Index < mFunctionNumber; Index++) {
+ if (mRuntimeFunctionPerfRecord[Index].RuntimeRecType == 0) {
+ //
+ // Fucntion ID is not found in Record buffer.
+ //
+ return EFI_NOT_FOUND;
+ }
+
+ if (mRuntimeFunctionPerfRecord[Index].FunctionId == Identifier) {
+ //
+ // This function ID has been added.
+ //
+ break;
+ }
+ }
+
+ if (Index == mFunctionNumber) {
+ //
+ // Fucntion ID is not found in Record buffer.
+ //
+ return EFI_NOT_FOUND;
+ }
+
+ mRuntimeFunctionPerfRecord[Index].FunctionCallCount++;
+ mRuntimeFunctionPerfRecord[Index].FunctionResidency += (GetTimeInNanoSec (Timestamp)) - mStartTicker[Index];
+ //
+ // Update Module Record.
+ //
+ mRuntimeModulePerfRecord->ModuleCallCount++;
+ mRuntimeModulePerfRecord->ModuleResidency += (GetTimeInNanoSec (Timestamp)) - mStartTicker[Index];
+ }
+
+ return EFI_SUCCESS;
+} \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmRuntimeDxeReportStatusCodeLib/EdkIIGlueSmmRuntimeDxeReportStatusCodeLib.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmRuntimeDxeReportStatusCodeLib/EdkIIGlueSmmRuntimeDxeReportStatusCodeLib.cif
new file mode 100644
index 0000000..8de103f
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmRuntimeDxeReportStatusCodeLib/EdkIIGlueSmmRuntimeDxeReportStatusCodeLib.cif
@@ -0,0 +1,13 @@
+<component>
+ name = "EdkIIGlueSmmRuntimeDxeReportStatusCodeLib"
+ category = ModulePart
+ LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\SmmRuntimeDxeReportStatusCodeLib"
+ RefName = "EdkIIGlueSmmRuntimeDxeReportStatusCodeLib"
+[files]
+"EdkIIGlueSmmRuntimeDxeReportStatusCodeLib.sdl"
+"EdkIIGlueSmmRuntimeDxeReportStatusCodeLib.mak"
+"SmmRuntimeDxeReportStatusCodeLib.inf"
+"ReportStatusCodeLib.c"
+"SmmRuntimeDxeSupport.c"
+"ReportStatusCodeLibInternal.h"
+<endComponent>
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmRuntimeDxeReportStatusCodeLib/EdkIIGlueSmmRuntimeDxeReportStatusCodeLib.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmRuntimeDxeReportStatusCodeLib/EdkIIGlueSmmRuntimeDxeReportStatusCodeLib.mak
new file mode 100644
index 0000000..6792693
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmRuntimeDxeReportStatusCodeLib/EdkIIGlueSmmRuntimeDxeReportStatusCodeLib.mak
@@ -0,0 +1,88 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueSmmRuntimeDxeReportStatusCodeLib/EdkIIGlueSmmRuntimeDxeReportStatusCodeLib.mak 1 1/20/12 3:58a Jeffch $
+#
+# $Revision: 1 $
+#
+# $Date: 1/20/12 3:58a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueSmmRuntimeDxeReportStatusCodeLib/EdkIIGlueSmmRuntimeDxeReportStatusCodeLib.mak $
+#
+# 1 1/20/12 3:58a Jeffch
+#
+# 1 9/27/11 6:20a Wesleychen
+# Intel EDK initially releases.
+#
+# 2 1/23/11 10:01p Iminglin
+# EIP52651
+# EdkIIGlueSMMRuntimeDxeReportStatusCodeLib includes
+# $(EdkIIGlueUefiBootServicesTableLib_LIB) which will be a problem if
+# there are any DEBUG messages in SMM code after booting to OS. Instead
+# of this library EdkIIGlueUefiRuntimeServicesTableLib_LIB is used.
+#
+# 1 9/18/09 1:58a Iminglin
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: EdkIIGlueSmmRuntimeDxeReportStatusCodeLib.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+#all : EdkIIGlueSmmRuntimeDxeReportStatusCodeLib
+
+$(EdkIIGlueSmmRuntimeDxeReportStatusCodeLib_LIB) : EdkIIGlueSmmRuntimeDxeReportStatusCodeLib
+
+EdkIIGlueSmmRuntimeDxeReportStatusCodeLib : $(BUILD_DIR)\EdkIIGlueSmmRuntimeDxeReportStatusCodeLib.mak EdkIIGlueSmmRuntimeDxeReportStatusCodeLibBin
+
+$(BUILD_DIR)\EdkIIGlueSmmRuntimeDxeReportStatusCodeLib.mak : $(EdkIIGlueSmmRuntimeDxeReportStatusCodeLib_DIR)\$(@B).cif $(EdkIIGlueSmmRuntimeDxeReportStatusCodeLib_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(EdkIIGlueSmmRuntimeDxeReportStatusCodeLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+
+#EdkIIGlueSmmRuntimeDxeReportStatusCodeLibBin : $(EdkIIGlueBaseLib_LIB) $(EdkIIGlueBaseMemoryLib_LIB) $(EdkIIGlueUefiBootServicesTableLib_LIB) $(EdkIIGlueUefiRuntimeServicesTableLib_LIB) $(EFIPROTOCOLLIB) $(EDKGUIDLIB) $(ARCHPROTOCOLLIB)
+EdkIIGlueSmmRuntimeDxeReportStatusCodeLibBin : $(EdkIIGlueUefiRuntimeServicesTableLib_LIB) $(EDKGUIDLIB) $(ARCHPROTOCOLLIB) $(EdkIIGlueBaseIoLibIntrinsic_LIB) $(EFIGUIDLIB)
+!IF "$(x64_BUILD)"=="1"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGlueSmmRuntimeDxeReportStatusCodeLib.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueSmmRuntimeDxeReportStatusCodeLib_LIB)"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\IA32\
+ /f $(BUILD_DIR)\EdkIIGlueSmmRuntimeDxeReportStatusCodeLib.mak all\
+ TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueSmmRuntimeDxeReportStatusCodeLib_LIB)"
+!ELSE
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGlueSmmRuntimeDxeReportStatusCodeLib.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueSmmRuntimeDxeReportStatusCodeLib_LIB)"
+!ENDIF
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#********************************************************************** \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmRuntimeDxeReportStatusCodeLib/EdkIIGlueSmmRuntimeDxeReportStatusCodeLib.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmRuntimeDxeReportStatusCodeLib/EdkIIGlueSmmRuntimeDxeReportStatusCodeLib.sdl
new file mode 100644
index 0000000..8464ca1
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmRuntimeDxeReportStatusCodeLib/EdkIIGlueSmmRuntimeDxeReportStatusCodeLib.sdl
@@ -0,0 +1,26 @@
+TOKEN
+ Name = "EdkIIGlueSmmRuntimeDxeReportStatusCodeLib_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable EdkIIGlueSmmRuntimeDxeReportStatusCodeLib support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "EdkIIGlueSmmRuntimeDxeReportStatusCodeLib_LIB"
+ Value = "$$(LIB_BUILD_DIR)\EdkIIGlueSmmRuntimeDxeReportStatusCodeLib.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "EdkIIGlueSmmRuntimeDxeReportStatusCodeLib_DIR"
+End
+
+MODULE
+ Help = "Includes EdkIIGlueSmmRuntimeDxeReportStatusCodeLib.mak to Project"
+ File = "EdkIIGlueSmmRuntimeDxeReportStatusCodeLib.mak"
+End
+
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmRuntimeDxeReportStatusCodeLib/ReportStatusCodeLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmRuntimeDxeReportStatusCodeLib/ReportStatusCodeLib.c
new file mode 100644
index 0000000..6bc5277
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmRuntimeDxeReportStatusCodeLib/ReportStatusCodeLib.c
@@ -0,0 +1,557 @@
+/*++
+
+Copyright (c) 2004 - 2009, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ ReportStatusCodeLib.c
+
+Abstract:
+
+ Report Status Code Library for SMM Runtime driver.
+
+--*/
+
+#include "ReportStatusCodeLibInternal.h"
+
+
+EFI_REPORT_STATUS_CODE mReportStatusCode = NULL;
+
+/**
+ Internal worker function that reports a status code through the Status Code Protocol
+
+ This function checks to see if a Status Code Protocol is present in the handle
+ database. If a Status Code Protocol is not present, then EFI_UNSUPPORTED is
+ returned. If a Status Code Protocol is present, then it is cached in gStatusCode,
+ and the ReportStatusCode() service of the Status Code Protocol is called passing in
+ Type, Value, Instance, CallerId, and Data. The result of this call is returned.
+
+ @param Type Status code type.
+ @param Value Status code value.
+ @param Instance Status code instance number.
+ @param CallerId Pointer to a GUID that identifies the caller of this
+ function. This is an optional parameter that may be
+ NULL.
+ @param Data Pointer to the extended data buffer. This is an
+ optional parameter that may be NULL.
+
+ @retval EFI_SUCCESS The status code was reported.
+ @retval EFI_OUT_OF_RESOURCES There were not enough resources to report the status code.
+ @retval EFI_UNSUPPORTED Status Code Protocol is not available.
+
+**/
+EFI_STATUS
+InternalReportStatusCode (
+ IN EFI_STATUS_CODE_TYPE Type,
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN UINT32 Instance,
+ IN CONST EFI_GUID *CallerId OPTIONAL,
+ IN EFI_STATUS_CODE_DATA *Data OPTIONAL
+ )
+{
+ //
+ // If gStatusCode is NULL, then see if a Status Code Protocol instance is present
+ // in the handle database.
+ //
+ if (mReportStatusCode == NULL) {
+ mReportStatusCode = InternalGetReportStatusCode ();
+ if (mReportStatusCode == NULL) {
+ return EFI_UNSUPPORTED;
+ }
+ }
+
+ //
+ // A Status Code Protocol is present in the handle database, so pass in all the
+ // parameters to the ReportStatusCode() service of the Status Code Protocol
+ //
+ return (*mReportStatusCode) (Type, Value, Instance, (EFI_GUID *)CallerId, Data);
+}
+
+
+/**
+ Computes and returns the size, in bytes, of a device path.
+
+ @param DevicePath A pointer to a device path.
+
+ @return The size, in bytes, of DevicePath.
+
+**/
+UINTN
+InternalReportStatusCodeDevicePathSize (
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ )
+{
+ CONST EFI_DEVICE_PATH_PROTOCOL *Start;
+
+ //
+ // Search for the end of the device path structure
+ //
+ Start = DevicePath;
+ while (!IsDevicePathEnd (DevicePath)) {
+ DevicePath = NextDevicePathNode (DevicePath);
+ }
+
+ //
+ // Subtract the start node from the end node and add in the size of the end node
+ //
+ return ((UINTN) DevicePath - (UINTN) Start) + DevicePathNodeLength (DevicePath);
+}
+
+
+/**
+ Converts a status code to an 8-bit POST code value.
+
+ Converts the status code specified by CodeType and Value to an 8-bit POST code
+ and returns the 8-bit POST code in PostCode. If CodeType is an
+ EFI_PROGRESS_CODE or CodeType is an EFI_ERROR_CODE, then bits 0..4 of PostCode
+ are set to bits 16..20 of Value, and bits 5..7 of PostCode are set to bits
+ 24..26 of Value., and TRUE is returned. Otherwise, FALSE is returned.
+
+ If PostCode is NULL, then ASSERT().
+
+ @param CodeType The type of status code being converted.
+ @param Value The status code value being converted.
+ @param PostCode A pointer to the 8-bit POST code value to return.
+
+ @retval TRUE The status code specified by CodeType and Value was converted
+ to an 8-bit POST code and returned in PostCode.
+ @retval FALSE The status code specified by CodeType and Value could not be
+ converted to an 8-bit POST code value.
+
+**/
+BOOLEAN
+EFIAPI
+GlueCodeTypeToPostCode (
+ IN EFI_STATUS_CODE_TYPE CodeType,
+ IN EFI_STATUS_CODE_VALUE Value,
+ OUT UINT8 *PostCode
+ )
+{
+ //
+ // If PostCode is NULL, then ASSERT()
+ //
+ ASSERT (PostCode != NULL);
+
+ //
+ // Convert Value to an 8 bit post code
+ //
+ if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ||
+ ((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) ) {
+ *PostCode = (UINT8) ((((Value & EFI_STATUS_CODE_CLASS_MASK) >> 24) << 5) |
+ (((Value & EFI_STATUS_CODE_SUBCLASS_MASK) >> 16) & 0x1f));
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
+/**
+ Extracts ASSERT() information from a status code structure.
+
+ Converts the status code specified by CodeType, Value, and Data to the ASSERT()
+ arguments specified by Filename, Description, and LineNumber. If CodeType is
+ an EFI_ERROR_CODE, and CodeType has a severity of EFI_ERROR_UNRECOVERED, and
+ Value has an operation mask of EFI_SW_EC_ILLEGAL_SOFTWARE_STATE, extract
+ Filename, Description, and LineNumber from the optional data area of the
+ status code buffer specified by Data. The optional data area of Data contains
+ a Null-terminated ASCII string for the FileName, followed by a Null-terminated
+ ASCII string for the Description, followed by a 32-bit LineNumber. If the
+ ASSERT() information could be extracted from Data, then return TRUE.
+ Otherwise, FALSE is returned.
+
+ If Data is NULL, then ASSERT().
+ If Filename is NULL, then ASSERT().
+ If Description is NULL, then ASSERT().
+ If LineNumber is NULL, then ASSERT().
+
+ @param CodeType The type of status code being converted.
+ @param Value The status code value being converted.
+ @param Data Pointer to status code data buffer.
+ @param Filename Pointer to the source file name that generated the ASSERT().
+ @param Description Pointer to the description of the ASSERT().
+ @param LineNumber Pointer to source line number that generated the ASSERT().
+
+ @retval TRUE The status code specified by CodeType, Value, and Data was
+ converted ASSERT() arguments specified by Filename, Description,
+ and LineNumber.
+ @retval FALSE The status code specified by CodeType, Value, and Data could
+ not be converted to ASSERT() arguments.
+
+**/
+BOOLEAN
+EFIAPI
+GlueReportStatusCodeExtractAssertInfo (
+ IN EFI_STATUS_CODE_TYPE CodeType,
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN CONST EFI_STATUS_CODE_DATA *Data,
+ OUT CHAR8 **Filename,
+ OUT CHAR8 **Description,
+ OUT UINT32 *LineNumber
+ )
+{
+ EFI_DEBUG_ASSERT_DATA *AssertData;
+
+ ASSERT (Data != NULL);
+ ASSERT (Filename != NULL);
+ ASSERT (Description != NULL);
+ ASSERT (LineNumber != NULL);
+
+ if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) &&
+ ((CodeType & EFI_STATUS_CODE_SEVERITY_MASK) == EFI_ERROR_UNRECOVERED) &&
+ ((Value & EFI_STATUS_CODE_OPERATION_MASK) == EFI_SW_EC_ILLEGAL_SOFTWARE_STATE)) {
+ AssertData = (EFI_DEBUG_ASSERT_DATA *)(Data + 1);
+ *Filename = (CHAR8 *)(AssertData + 1);
+ *Description = *Filename + AsciiStrLen (*Filename) + 1;
+ *LineNumber = AssertData->LineNumber;
+ return TRUE;
+ }
+ return FALSE;
+}
+
+
+/**
+ Extracts DEBUG() information from a status code structure.
+
+ Converts the status code specified by Data to the DEBUG() arguments specified
+ by ErrorLevel, Marker, and Format. If type GUID in Data is
+ EFI_STATUS_CODE_DATA_TYPE_DEBUG_GUID, then extract ErrorLevel, Marker, and
+ Format from the optional data area of the status code buffer specified by Data.
+ The optional data area of Data contains a 32-bit ErrorLevel followed by Marker
+ which is 12 UINTN parameters, followed by a Null-terminated ASCII string for
+ the Format. If the DEBUG() information could be extracted from Data, then
+ return TRUE. Otherwise, FALSE is returned.
+
+ If Data is NULL, then ASSERT().
+ If ErrorLevel is NULL, then ASSERT().
+ If Marker is NULL, then ASSERT().
+ If Format is NULL, then ASSERT().
+
+ @param Data Pointer to status code data buffer.
+ @param ErrorLevel Pointer to error level mask for a debug message.
+ @param Marker Pointer to the variable argument list associated with Format.
+ @param Format Pointer to a Null-terminated ASCII format string of a
+ debug message.
+
+ @retval TRUE The status code specified by Data was converted DEBUG() arguments
+ specified by ErrorLevel, Marker, and Format.
+ @retval FALSE The status code specified by Data could not be converted to
+ DEBUG() arguments.
+
+**/
+BOOLEAN
+EFIAPI
+GlueReportStatusCodeExtractDebugInfo (
+ IN CONST EFI_STATUS_CODE_DATA *Data,
+ OUT UINT32 *ErrorLevel,
+ OUT VA_LIST *Marker,
+ OUT CHAR8 **Format
+ )
+{
+ EFI_DEBUG_INFO *DebugInfo;
+
+ ASSERT (Data != NULL);
+ ASSERT (ErrorLevel != NULL);
+ ASSERT (Marker != NULL);
+ ASSERT (Format != NULL);
+
+ //
+ // If the GUID type is not EFI_STATUS_CODE_DATA_TYPE_DEBUG_GUID then return FALSE
+ //
+ if (!CompareGuid (&Data->Type, &gEfiStatusCodeDataTypeDebugGuid)) {
+ return FALSE;
+ }
+
+ //
+ // Retrieve the debug information from the status code record
+ //
+ DebugInfo = (EFI_DEBUG_INFO *)(Data + 1);
+
+ *ErrorLevel = DebugInfo->ErrorLevel;
+
+ //
+ // The first 12 * UINTN bytes of the string are really an
+ // argument stack to support varargs on the Format string.
+ //
+ *Marker = (VA_LIST) (DebugInfo + 1);
+ *Format = (CHAR8 *)(((UINT64 *)*Marker) + 12);
+
+ return TRUE;
+}
+
+
+/**
+ Reports a status code.
+
+ Reports the status code specified by the parameters Type and Value. Status
+ code also require an instance, caller ID, and extended data. This function
+ passed in a zero instance, NULL extended data, and a caller ID of
+ gEfiCallerIdGuid, which is the GUID for the module.
+
+ ReportStatusCode()must actively prevent recusrsion. If ReportStatusCode()
+ is called while processing another any other Report Status Code Library function,
+ then ReportStatusCode() must return immediately.
+
+ @param Type Status code type.
+ @param Value Status code value.
+
+ @retval EFI_SUCCESS The status code was reported.
+ @retval EFI_DEVICE_ERROR There status code could not be reported due to a
+ device error.
+ @retval EFI_UNSUPPORTED Report status code is not supported
+
+**/
+EFI_STATUS
+EFIAPI
+GlueReportStatusCode (
+ IN EFI_STATUS_CODE_TYPE Type,
+ IN EFI_STATUS_CODE_VALUE Value
+ )
+{
+ return InternalReportStatusCode (Type, Value, 0, &gEfiCallerIdGuid, NULL);
+}
+
+
+/**
+ Reports a status code with a Device Path Protocol as the extended data.
+
+ Allocates and fills in the extended data section of a status code with the
+ Device Path Protocol specified by DevicePath. This function is responsible
+ for allocating a buffer large enough for the standard header and the device
+ path. The standard header is filled in with a GUID of
+ gEfiStatusCodeSpecificDataGuid. The status code is reported with a zero
+ instance and a caller ID of gEfiCallerIdGuid.
+
+ ReportStatusCodeWithDevicePath()must actively prevent recursion. If
+ ReportStatusCodeWithDevicePath() is called while processing another any other
+ Report Status Code Library function, then ReportStatusCodeWithDevicePath()
+ must return EFI_DEVICE_ERROR immediately.
+
+ If DevicePath is NULL, then ASSERT().
+
+ @param Type Status code type.
+ @param Value Status code value.
+ @param DevicePath Pointer to the Device Path Protocol to be reported.
+
+ @retval EFI_SUCCESS The status code was reported with the extended
+ data specified by DevicePath.
+ @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the
+ extended data section.
+ @retval EFI_UNSUPPORTED Report status code is not supported
+
+**/
+EFI_STATUS
+EFIAPI
+GlueReportStatusCodeWithDevicePath (
+ IN EFI_STATUS_CODE_TYPE Type,
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ )
+{
+ ASSERT (DevicePath != NULL);
+ return ReportStatusCodeWithExtendedData (
+ Type,
+ Value,
+ (VOID *)DevicePath,
+ InternalReportStatusCodeDevicePathSize (DevicePath)
+ );
+}
+
+
+/**
+ Reports a status code with an extended data buffer.
+
+ Allocates and fills in the extended data section of a status code with the
+ extended data specified by ExtendedData and ExtendedDataSize. ExtendedData
+ is assumed to be one of the data structures specified in Related Definitions.
+ These data structure do not have the standard header, so this function is
+ responsible for allocating a buffer large enough for the standard header and
+ the extended data passed into this function. The standard header is filled
+ in with a GUID of gEfiStatusCodeSpecificDataGuid. The status code is reported
+ with a zero instance and a caller ID of gEfiCallerIdGuid.
+
+ ReportStatusCodeWithExtendedData()must actively prevent recursion. If
+ ReportStatusCodeWithExtendedData() is called while processing another any other
+ Report Status Code Library function, then ReportStatusCodeWithExtendedData()
+ must return EFI_DEVICE_ERROR immediately.
+
+ If ExtendedData is NULL, then ASSERT().
+ If ExtendedDataSize is 0, then ASSERT().
+
+ @param Type Status code type.
+ @param Value Status code value.
+ @param ExtendedData Pointer to the extended data buffer to be reported.
+ @param ExtendedDataSize The size, in bytes, of the extended data buffer to
+ be reported.
+
+ @retval EFI_SUCCESS The status code was reported with the extended
+ data specified by ExtendedData and ExtendedDataSize.
+ @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate the
+ extended data section.
+ @retval EFI_UNSUPPORTED Report status code is not supported
+
+**/
+EFI_STATUS
+EFIAPI
+GlueReportStatusCodeWithExtendedData (
+ IN EFI_STATUS_CODE_TYPE Type,
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN CONST VOID *ExtendedData,
+ IN UINTN ExtendedDataSize
+ )
+{
+ ASSERT (ExtendedData != NULL);
+ ASSERT (ExtendedDataSize != 0);
+ return ReportStatusCodeEx (
+ Type,
+ Value,
+ 0,
+ NULL,
+ NULL,
+ ExtendedData,
+ ExtendedDataSize
+ );
+}
+
+
+/**
+ Reports a status code with full parameters.
+
+ The function reports a status code. If ExtendedData is NULL and ExtendedDataSize
+ is 0, then an extended data buffer is not reported. If ExtendedData is not
+ NULL and ExtendedDataSize is not 0, then an extended data buffer is allocated.
+ ExtendedData is assumed not have the standard status code header, so this function
+ is responsible for allocating a buffer large enough for the standard header and
+ the extended data passed into this function. The standard header is filled in
+ with a GUID specified by ExtendedDataGuid. If ExtendedDataGuid is NULL, then a
+ GUID of gEfiStatusCodeSpecificDatauid is used. The status code is reported with
+ an instance specified by Instance and a caller ID specified by CallerId. If
+ CallerId is NULL, then a caller ID of gEfiCallerIdGuid is used.
+
+ ReportStatusCodeEx()must actively prevent recursion. If
+ ReportStatusCodeEx() is called while processing another any
+ other Report Status Code Library function, then
+ ReportStatusCodeEx() must return EFI_DEVICE_ERROR immediately.
+
+ If ExtendedData is NULL and ExtendedDataSize is not zero, then ASSERT().
+ If ExtendedData is not NULL and ExtendedDataSize is zero, then ASSERT().
+
+ @param Type Status code type.
+ @param Value Status code value.
+ @param Instance Status code instance number.
+ @param CallerId Pointer to a GUID that identifies the caller of this
+ function. If this parameter is NULL, then a caller
+ ID of gEfiCallerIdGuid is used.
+ @param ExtendedDataGuid Pointer to the GUID for the extended data buffer.
+ If this parameter is NULL, then a the status code
+ standard header is filled in with
+ gEfiStatusCodeSpecificDataGuid.
+ @param ExtendedData Pointer to the extended data buffer. This is an
+ optional parameter that may be NULL.
+ @param ExtendedDataSize The size, in bytes, of the extended data buffer.
+
+ @retval EFI_SUCCESS The status code was reported.
+ @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate
+ the extended data section if it was specified.
+ @retval EFI_UNSUPPORTED Report status code is not supported
+
+**/
+EFI_STATUS
+EFIAPI
+GlueReportStatusCodeEx (
+ IN EFI_STATUS_CODE_TYPE Type,
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN UINT32 Instance,
+ IN CONST EFI_GUID *CallerId OPTIONAL,
+ IN CONST EFI_GUID *ExtendedDataGuid OPTIONAL,
+ IN CONST VOID *ExtendedData OPTIONAL,
+ IN UINTN ExtendedDataSize
+ )
+{
+ EFI_STATUS Status;
+
+ Status = InternalReportStatusCodeEx (
+ Type,
+ Value,
+ Instance,
+ CallerId,
+ ExtendedDataGuid,
+ ExtendedData,
+ ExtendedDataSize
+ );
+
+ return Status;
+}
+
+
+/**
+ Returns TRUE if status codes of type EFI_PROGRESS_CODE are enabled
+
+ This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED
+ bit of PcdReportStatusCodeProperyMask is set. Otherwise FALSE is returned.
+
+ @retval TRUE The REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED bit of
+ PcdReportStatusCodeProperyMask is set.
+ @retval FALSE The REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED bit of
+ PcdReportStatusCodeProperyMask is clear.
+
+**/
+BOOLEAN
+EFIAPI
+GlueReportProgressCodeEnabled (
+ VOID
+ )
+{
+ return (BOOLEAN) ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_PROGRESS_CODE_ENABLED) != 0);
+}
+
+
+/**
+ Returns TRUE if status codes of type EFI_ERROR_CODE are enabled
+
+ This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED
+ bit of PcdReportStatusCodeProperyMask is set. Otherwise FALSE is returned.
+
+ @retval TRUE The REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED bit of
+ PcdReportStatusCodeProperyMask is set.
+ @retval FALSE The REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED bit of
+ PcdReportStatusCodeProperyMask is clear.
+
+**/
+BOOLEAN
+EFIAPI
+GlueReportErrorCodeEnabled (
+ VOID
+ )
+{
+ return (BOOLEAN) ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_ERROR_CODE_ENABLED) != 0);
+}
+
+
+/**
+ Returns TRUE if status codes of type EFI_DEBUG_CODE are enabled
+
+ This function returns TRUE if the REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED
+ bit of PcdReportStatusCodeProperyMask is set. Otherwise FALSE is returned.
+
+ @retval TRUE The REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED bit of
+ PcdReportStatusCodeProperyMask is set.
+ @retval FALSE The REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED bit of
+ PcdReportStatusCodeProperyMask is clear.
+
+**/
+BOOLEAN
+EFIAPI
+GlueReportDebugCodeEnabled (
+ VOID
+ )
+{
+ return (BOOLEAN) ((PcdGet8(PcdReportStatusCodePropertyMask) & REPORT_STATUS_CODE_PROPERTY_DEBUG_CODE_ENABLED) != 0);
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmRuntimeDxeReportStatusCodeLib/ReportStatusCodeLibInternal.h b/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmRuntimeDxeReportStatusCodeLib/ReportStatusCodeLibInternal.h
new file mode 100644
index 0000000..2bc0e03
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmRuntimeDxeReportStatusCodeLib/ReportStatusCodeLibInternal.h
@@ -0,0 +1,128 @@
+/*++
+
+Copyright (c) 2004 - 2009, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ ReportStatusCodeLibInternal.h
+
+Abstract:
+
+ Internal Header file of Report Status Code Library for RUNTIME
+ DXE Phase.
+
+--*/
+
+#ifndef __REPORT_STATUS_CODE_LIB_INTERNAL__H
+#define __REPORT_STATUS_CODE_LIB_INTERNAL__H
+
+#include "EdkIIGlueDxe.h"
+
+/**
+ Locatet he report status code service.
+
+ @return EFI_REPORT_STATUS_CODE function point to
+ ReportStatusCode.
+**/
+EFI_REPORT_STATUS_CODE
+InternalGetReportStatusCode (
+ VOID
+ );
+
+/**
+ Internal worker function that reports a status code through the Status Code Protocol
+
+ This function checks to see if a Status Code Protocol is present in the handle
+ database. If a Status Code Protocol is not present, then EFI_UNSUPPORTED is
+ returned. If a Status Code Protocol is present, then it is cached in gStatusCode,
+ and the ReportStatusCode() service of the Status Code Protocol is called passing in
+ Type, Value, Instance, CallerId, and Data. The result of this call is returned.
+
+ @param Type Status code type.
+ @param Value Status code value.
+ @param Instance Status code instance number.
+ @param CallerId Pointer to a GUID that identifies the caller of this
+ function. This is an optional parameter that may be
+ NULL.
+ @param Data Pointer to the extended data buffer. This is an
+ optional parameter that may be NULL.
+
+ @retval EFI_SUCCESS The status code was reported.
+ @retval EFI_OUT_OF_RESOURCES There were not enough resources to report the status code.
+ @retval EFI_UNSUPPORTED Status Code Protocol is not available.
+
+**/
+EFI_STATUS
+InternalReportStatusCode (
+ IN EFI_STATUS_CODE_TYPE Type,
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN UINT32 Instance,
+ IN CONST EFI_GUID *CallerId OPTIONAL,
+ IN EFI_STATUS_CODE_DATA *Data OPTIONAL
+ );
+
+/**
+ Reports a status code with full parameters.
+
+ The function reports a status code. If ExtendedData is NULL and ExtendedDataSize
+ is 0, then an extended data buffer is not reported. If ExtendedData is not
+ NULL and ExtendedDataSize is not 0, then an extended data buffer is allocated.
+ ExtendedData is assumed not have the standard status code header, so this function
+ is responsible for allocating a buffer large enough for the standard header and
+ the extended data passed into this function. The standard header is filled in
+ with a GUID specified by ExtendedDataGuid. If ExtendedDataGuid is NULL, then a
+ GUID of gEfiStatusCodeSpecificDatauid is used. The status code is reported with
+ an instance specified by Instance and a caller ID specified by CallerId. If
+ CallerId is NULL, then a caller ID of gEfiCallerIdGuid is used.
+
+ ReportStatusCodeEx()must actively prevent recursion. If ReportStatusCodeEx()
+ is called while processing another any other Report Status Code Library function,
+ then ReportStatusCodeEx() must return EFI_DEVICE_ERROR immediately.
+
+ If ExtendedData is NULL and ExtendedDataSize is not zero, then ASSERT().
+ If ExtendedData is not NULL and ExtendedDataSize is zero, then ASSERT().
+
+ @param Type Status code type.
+ @param Value Status code value.
+ @param Instance Status code instance number.
+ @param CallerId Pointer to a GUID that identifies the caller of this
+ function. If this parameter is NULL, then a caller
+ ID of gEfiCallerIdGuid is used.
+ @param ExtendedDataGuid Pointer to the GUID for the extended data buffer.
+ If this parameter is NULL, then a the status code
+ standard header is filled in with
+ gEfiStatusCodeSpecificDataGuid.
+ @param ExtendedData Pointer to the extended data buffer. This is an
+ optional parameter that may be NULL.
+ @param ExtendedDataSize The size, in bytes, of the extended data buffer.
+
+ @retval EFI_SUCCESS The status code was reported.
+ @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate
+ the extended data section if it was specified.
+ @retval EFI_UNSUPPORTED Report status code is not supported
+
+**/
+EFI_STATUS
+EFIAPI
+InternalReportStatusCodeEx (
+ IN EFI_STATUS_CODE_TYPE Type,
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN UINT32 Instance,
+ IN CONST EFI_GUID *CallerId OPTIONAL,
+ IN CONST EFI_GUID *ExtendedDataGuid OPTIONAL,
+ IN CONST VOID *ExtendedData OPTIONAL,
+ IN UINTN ExtendedDataSize
+ );
+
+extern EFI_REPORT_STATUS_CODE mReportStatusCode;
+
+#endif // __REPORT_STATUS_CODE_LIB_INTERNAL__H
+
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmRuntimeDxeReportStatusCodeLib/SmmRuntimeDxeReportStatusCodeLib.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmRuntimeDxeReportStatusCodeLib/SmmRuntimeDxeReportStatusCodeLib.inf
new file mode 100644
index 0000000..c89be29
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmRuntimeDxeReportStatusCodeLib/SmmRuntimeDxeReportStatusCodeLib.inf
@@ -0,0 +1,96 @@
+#/*++
+#
+# Copyright (c) 2004 - 2011, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# SmmRuntimeDxeReportStatusCodeLib.inf
+#
+# Abstract:
+#
+# Component description file for SmmRuntimeDxeReportStatusCodeLib
+#
+#--*/
+
+[defines]
+BASE_NAME = EdkIIGlueSmmRuntimeDxeReportStatusCodeLib
+COMPONENT_TYPE = LIBRARY
+
+[sources.common]
+ ReportStatusCodeLib.c
+ SmmRuntimeDxeSupport.c
+ ReportStatusCodeLibInternal.h
+
+[sources.ia32]
+
+[sources.x64]
+
+[sources.ipf]
+
+[sources.ebc]
+
+
+[includes.common]
+ .
+ ..\..\Include
+ ..\..\include\Library
+ $(EDK_SOURCE)\Foundation
+ $(EDK_SOURCE)\Foundation\Framework
+ $(EDK_SOURCE)\Foundation\Efi
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+ $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include
+ $(EDK_SOURCE)\Foundation\Framework\Guid\DataHubRecords
+ $(EDK_SOURCE)\Foundation\Framework\Guid\StatusCodeDataTypeId
+ $(EDK_SOURCE)\Foundation\Core\Dxe\ArchProtocol\StatusCode
+
+[libraries.common]
+ EdkIIGlueBaseLib
+ EdkIIGlueBaseMemoryLib
+ EdkIIGlueUefiBootServicesTableLib
+#
+# when EFI_SPECIFICATION_VERSION < 0x00020000, gRT is used
+#
+ EdkIIGlueUefiRuntimeServicesTableLib
+# R8.x lib
+ EfiProtocolLib
+# Possibly, gEfiCallerIdGuid might be used.
+ EdkGuidLib
+ ArchProtocolLib
+ EfiGuidLib
+
+[libraries.ia32]
+
+[libraries.x64]
+
+[libraries.ebc]
+
+
+[nmake.common]
+ C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION
+ LIB_STD_FLAGS = $(LIB_STD_FLAGS) /IGNORE:4006 /IGNORE:4221
+
+[nmake.ia32]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32
+
+[nmake.x64]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64
+
+[nmake.ipf]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF
+
+[nmake.ebc]
+ EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION
+ EBC_LIB_STD_FLAGS = $(EBC_LIB_STD_FLAGS) /IGNORE:4006 /IGNORE:4221
+ EBC_C_STD_FLAGS = $(EBC_C_STD_FLAGS) /D MDE_CPU_EBC
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmRuntimeDxeReportStatusCodeLib/SmmRuntimeDxeSupport.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmRuntimeDxeReportStatusCodeLib/SmmRuntimeDxeSupport.c
new file mode 100644
index 0000000..07b1487
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/SmmRuntimeDxeReportStatusCodeLib/SmmRuntimeDxeSupport.c
@@ -0,0 +1,698 @@
+/*++
+
+Copyright (c) 2004 - 2011, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ SmmRuntimeDxeSupport.c
+
+Abstract:
+
+ Report Status Code Library for DXE Phase.
+
+--*/
+
+#include "ReportStatusCodeLibInternal.h"
+#include EFI_PROTOCOL_DEFINITION (SmmStatusCode)
+#include EFI_GUID_DEFINITION (GlobalVariable)
+
+#define DEBUG_MASK_VARIABLE_NAME L"EFIDebug"
+
+EFI_EVENT mVirtualAddressChangeEvent;
+EFI_EVENT mExitBootServicesEvent;
+EFI_EVENT mSmmStatusCodeEvent = NULL;
+EFI_STATUS_CODE_DATA *mStatusCodeData;
+BOOLEAN mInSmm;
+EFI_SMM_BASE_PROTOCOL *mSmmBase;
+EFI_RUNTIME_SERVICES *mRTSmmRuntimeDxeReportStatusCodeLib;
+BOOLEAN mHaveExitedBootServices = FALSE;
+EFI_SMM_STATUS_CODE_PROTOCOL *mSmmStatusCode;
+UINTN mErrorLevel = EDKII_GLUE_DebugPrintErrorLevel;
+BOOLEAN mDebugMaskInitialized = FALSE;
+
+EFI_STATUS
+InstallSmmDebugMaskProtocol (
+ IN EFI_HANDLE ImageHandle
+ );
+
+EFI_STATUS
+InstallRuntimeDebugMaskProtocol (
+ IN EFI_HANDLE ImageHandle
+ );
+
+EFI_STATUS
+UnInstallRuntimeDebugMaskProtocol (
+ IN EFI_HANDLE ImageHandle
+ );
+
+EFI_STATUS
+UnInstallSmmDebugMaskProtocol (
+ IN EFI_HANDLE ImageHandle
+ );
+
+VOID
+InitializeDebugMask (
+ )
+/*++
+
+Routine Description:
+
+ Initialize the debug mask when the variable service is ready.
+
+--*/
+{
+ EFI_STATUS Status;
+ UINTN DebugMask;
+ UINTN DataSize;
+
+ DataSize = sizeof(UINTN);
+ Status = gRT->GetVariable(
+ DEBUG_MASK_VARIABLE_NAME,
+ &gEfiGlobalVariableGuid,
+ NULL,
+ &DataSize,
+ &DebugMask
+ );
+
+ if (Status != EFI_NOT_AVAILABLE_YET) {
+ //
+ // If EFI Variable Services are available, then set a flag so the EFI
+ // Variable will not be read again by this module.
+ //
+ mDebugMaskInitialized = TRUE;
+ if (!EFI_ERROR (Status)) {
+ //
+ // If the EFI Varible exists, then set this module's module's mask to
+ // the global level mask value.
+ //
+ mErrorLevel = DebugMask;
+ }
+ }
+}
+
+EFI_STATUS
+EFIAPI
+GetDebugMask (
+ IN EFI_DEBUG_MASK_PROTOCOL *This, // Calling context
+ IN OUT UINTN *CurrentDebugMask // Ptr to store current debug mask
+ )
+/*++
+
+Routine Description:
+ DebugMask protocol member function.
+ Gets the current debug mask for an image, on which this protocol has been installed.
+
+Arguments:
+
+ This - Indicates calling context
+ CurrentDebugMask - Ptr to store current debug mask
+
+Returns:
+ EFI_SUCCESS - Debug mask is retrieved successfully
+ EFI_INVALID_PARAMETER - CurrentDebugMask is NULL.
+ EFI_UNSUPPORTED - The handle on which this protocol is installed is not an image handle.
+
+--*/
+{
+ //
+ // Check Parameter
+ //
+ if (CurrentDebugMask == NULL){
+ return EFI_INVALID_PARAMETER;
+ }
+
+ *CurrentDebugMask = mErrorLevel;
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+SetDebugMask (
+ IN EFI_DEBUG_MASK_PROTOCOL *This, // Calling context
+ IN UINTN NewDebugMask // New Debug Mask value to set
+ )
+/*++
+
+Routine Description:
+ DebugMask protocol member function.
+ Updates the current debug mask for an image, on which this protocol has been installed.
+
+Arguments:
+
+ This - Calling context
+ NewDebugMask - New Debug Mask value to set
+
+Returns:
+ EFI_SUCCESS - Debug mask is updated with the new value successfully
+ EFI_UNSUPPORTED - The handle on which this protocol is installed is not an image handle.
+
+--*/
+{
+
+ if (!mDebugMaskInitialized) {
+ //
+ // If DebugMask is set, it is initialized. Don't need to init again.
+ //
+ mDebugMaskInitialized = TRUE;
+ }
+
+ mErrorLevel = NewDebugMask;
+ return EFI_SUCCESS;
+}
+
+//
+// Debug Mask Protocol instance
+//
+EFI_DEBUG_MASK_PROTOCOL mDebugMaskProtocol = {
+ EFI_DEBUG_MASK_REVISION,
+ GetDebugMask,
+ SetDebugMask
+};
+
+EFI_STATUS
+InstallSmmDebugMaskProtocol (
+ IN EFI_HANDLE ImageHandle
+ )
+/*++
+
+Routine Description:
+
+ Install Smm debug mask protocol on an image handle.
+
+Arguments:
+
+ ImageHandle - Image handle which debug mask protocol will install on
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Invalid image handle
+ EFI_OUT_OF_RESOURCES - No enough buffer could be allocated
+ EFI_SUCCESS - Debug mask protocol successfully installed
+
+--*/
+{
+ EFI_STATUS Status;
+
+ //
+ // Install Debug Mask Protocol in Image Handle
+ //
+ Status = gBS->InstallProtocolInterface (
+ &ImageHandle,
+ &gEfiSmmDebugMaskProtocolGuid,
+ EFI_NATIVE_INTERFACE,
+ &mDebugMaskProtocol
+ );
+ return Status;
+}
+
+EFI_STATUS
+UnInstallSmmDebugMaskProtocol (
+ IN EFI_HANDLE ImageHandle
+ )
+/*++
+
+Routine Description:
+
+ Uninstall Smm debug mask protocol on an image handle.
+
+Arguments:
+
+ ImageHandle - Image handle which debug mask protocol will uninstall on
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Invalid image handle
+ EFI_SUCCESS - Debug mask protocol successfully uninstalled
+
+--*/
+{
+ EFI_STATUS Status;
+
+ if (ImageHandle == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // Install Debug Mask Protocol in Image Handle
+ //
+ Status = gBS->UninstallProtocolInterface (
+ &ImageHandle,
+ &gEfiSmmDebugMaskProtocolGuid,
+ &mDebugMaskProtocol
+ );
+
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+InstallRuntimeDebugMaskProtocol (
+ IN EFI_HANDLE ImageHandle
+ )
+/*++
+
+Routine Description:
+
+ Install Runtime debug mask protocol on an image handle.
+
+Arguments:
+
+ ImageHandle - Image handle which debug mask protocol will install on
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Invalid image handle
+ EFI_OUT_OF_RESOURCES - No enough buffer could be allocated
+ EFI_SUCCESS - Debug mask protocol successfully installed
+
+--*/
+{
+ EFI_STATUS Status;
+
+ //
+ // Install Debug Mask Protocol in Image Handle
+ //
+ Status = gBS->InstallProtocolInterface (
+ &ImageHandle,
+ &gEfiRuntimeDebugMaskProtocolGuid,
+ EFI_NATIVE_INTERFACE,
+ &mDebugMaskProtocol
+ );
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+UnInstallRuntimeDebugMaskProtocol (
+ IN EFI_HANDLE ImageHandle
+ )
+/*++
+
+Routine Description:
+
+ Uninstall Runtime debug mask protocol on an image handle.
+
+Arguments:
+
+ ImageHandle - Image handle which debug mask protocol will uninstall on
+
+Returns:
+
+ EFI_INVALID_PARAMETER - Invalid image handle
+ EFI_SUCCESS - Debug mask protocol successfully uninstalled
+
+--*/
+{
+ EFI_STATUS Status;
+
+ if (ImageHandle == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // Remove Protocol from ImageHandle
+ //
+ Status = gBS->UninstallProtocolInterface (
+ ImageHandle,
+ &gEfiDebugMaskProtocolGuid,
+ &mDebugMaskProtocol
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ return EFI_SUCCESS;
+}
+
+VOID
+EFIAPI
+InitializeSmmStatusCode (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+/*++
+
+Routine Description:
+
+ Initialize the Smm Status code point
+
+Arguments:
+
+ Event The Event that is being processed
+ Context Event Context
+
+Returns:
+
+ None
+
+--*/
+{
+ EFI_STATUS Status;
+
+ Status = gBS->LocateProtocol (&gEfiSmmStatusCodeProtocolGuid, NULL, (VOID **) &mSmmStatusCode);
+ if (EFI_ERROR (Status)) {
+ mSmmStatusCode = NULL;
+ } else {
+ gBS->CloseEvent (mSmmStatusCodeEvent);
+ }
+}
+
+EFI_STATUS
+SmmStatusCodeReport (
+ IN EFI_STATUS_CODE_TYPE Type,
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN UINT32 Instance,
+ IN EFI_GUID *CallerId OPTIONAL,
+ IN EFI_STATUS_CODE_DATA *Data OPTIONAL
+ )
+{
+ if (mSmmStatusCode != NULL) {
+ (mSmmStatusCode->ReportStatusCode) (mSmmStatusCode, Type, Value, Instance, CallerId, Data);
+ }
+ return EFI_SUCCESS;
+}
+
+/**
+ Locate he report status code service.
+
+ @return EFI_REPORT_STATUS_CODE function point to
+ ReportStatusCode.
+**/
+EFI_REPORT_STATUS_CODE
+InternalGetReportStatusCode (
+ VOID
+ )
+{
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+ EFI_STATUS_CODE_PROTOCOL *StatusCodeProtocol;
+ EFI_STATUS Status;
+#endif
+
+ if (mInSmm) {
+ return (EFI_REPORT_STATUS_CODE) SmmStatusCodeReport;
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+ } else if (!mHaveExitedBootServices) {
+ //
+ // Check gBS just in case. ReportStatusCode is called before gBS is initialized.
+ //
+ if (gBS != NULL) {
+ Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID**)&StatusCodeProtocol);
+ if (!EFI_ERROR (Status) && StatusCodeProtocol != NULL) {
+ return StatusCodeProtocol->ReportStatusCode;
+ }
+ }
+ }
+#elif (TIANO_RELEASE_VERSION != 0)
+ } else if (mRTSmmRuntimeDxeReportStatusCodeLib != NULL) {
+ return mRTSmmRuntimeDxeReportStatusCodeLib->ReportStatusCode;
+ }
+#endif
+
+ return NULL;
+}
+
+
+/**
+ Fixup internal report status code protocol interface.
+
+ @param[in] Event The Event that is being processed
+ @param[in] Context Event Context
+**/
+VOID
+EFIAPI
+ReportStatusCodeLibVirtualAddressChange (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+ mRTSmmRuntimeDxeReportStatusCodeLib->ConvertPointer (0, (VOID **) &gDebugMaskInterface->GetDebugMask);
+ mRTSmmRuntimeDxeReportStatusCodeLib->ConvertPointer (0, (VOID **) &gDebugMaskInterface);
+ if (NULL != mReportStatusCode) {
+ mRTSmmRuntimeDxeReportStatusCodeLib->ConvertPointer (0, (VOID **) &mReportStatusCode);
+ }
+ mRTSmmRuntimeDxeReportStatusCodeLib->ConvertPointer (0, (VOID **) &mStatusCodeData);
+ mRTSmmRuntimeDxeReportStatusCodeLib->ConvertPointer (0, (VOID **) &mRTSmmRuntimeDxeReportStatusCodeLib);
+}
+
+/**
+ Update the In Runtime Indicator.
+
+ @param[in] Event The Event that is being processed
+ @param[in] Context Event Context
+**/
+VOID
+EFIAPI
+ReportStatusCodeLibExitBootServices (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+ if (!mDebugMaskInitialized) {
+ InitializeDebugMask ();
+ }
+
+ if (mReportStatusCode == NULL) {
+ mReportStatusCode = InternalGetReportStatusCode ();
+ }
+ mHaveExitedBootServices = TRUE;
+}
+
+/**
+ Intialize Report Status Code Lib.
+
+ @param[in] ImageHandle The firmware allocated handle for the EFI image.
+ @param[in] SystemTable A pointer to the EFI System Table.
+
+ @return EFI_STATUS always returns EFI_SUCCESS.
+**/
+EFI_STATUS
+EFIAPI
+ReportStatusCodeLibConstruct (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ EFI_STATUS Status;
+ VOID *SmmStatusCodeRegistration;
+
+ //
+ // SMM driver depends on the SMM BASE protocol.
+ // the SMM driver must be success to locate protocol.
+ //
+ Status = gBS->LocateProtocol (&gEfiSmmBaseProtocolGuid, NULL, (VOID **) &mSmmBase);
+ if (!EFI_ERROR (Status)) {
+ mSmmBase->InSmm (mSmmBase, &mInSmm);
+ if (mInSmm) {
+ Status = mSmmBase->SmmAllocatePool (
+ mSmmBase,
+ EfiRuntimeServicesData,
+ sizeof (EFI_STATUS_CODE_DATA) + EFI_STATUS_CODE_DATA_MAX_SIZE,
+ (VOID **) &mStatusCodeData
+ );
+ ASSERT_EFI_ERROR (Status);
+ Status = gBS->LocateProtocol (&gEfiSmmStatusCodeProtocolGuid, NULL, (VOID **) &mSmmStatusCode);
+ if (EFI_ERROR (Status)) {
+ mSmmStatusCode = NULL;
+ //
+ // Create the event
+ //
+ Status = gBS->CreateEvent (
+ EFI_EVENT_NOTIFY_SIGNAL,
+ TPL_CALLBACK,
+ InitializeSmmStatusCode,
+ NULL,
+ &mSmmStatusCodeEvent
+ );
+ ASSERT_EFI_ERROR (Status);
+ //
+ // Register for protocol notifactions on this event
+ // NOTE: Because this protocol will be installed in SMM, it is safety to
+ // register ProtocolNotify here. This event will be triggered in SMM later.
+ //
+ Status = gBS->RegisterProtocolNotify (
+ &gEfiSmmStatusCodeProtocolGuid,
+ mSmmStatusCodeEvent,
+ &SmmStatusCodeRegistration
+ );
+ ASSERT_EFI_ERROR (Status);
+ }
+ Status = InstallSmmDebugMaskProtocol (ImageHandle);
+ return EFI_SUCCESS;
+ }
+ }
+
+ Status = InstallRuntimeDebugMaskProtocol (ImageHandle);
+
+ //
+ // Library should not use the gRT directly, since it
+ // may be converted by other library instance.
+ //
+ mRTSmmRuntimeDxeReportStatusCodeLib = gRT;
+ mInSmm = FALSE;
+
+ (gBS->AllocatePool) (EfiRuntimeServicesData, sizeof (EFI_STATUS_CODE_DATA) + EFI_STATUS_CODE_DATA_MAX_SIZE, (VOID **)&mStatusCodeData);
+ ASSERT (NULL != mStatusCodeData);
+ //
+ // Cache the report status code service
+ //
+ mReportStatusCode = InternalGetReportStatusCode ();
+
+ //
+ // Register the call back of virtual address change
+ //
+ Status = gBS->CreateEvent (
+ EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE,
+ TPL_NOTIFY,
+ ReportStatusCodeLibVirtualAddressChange,
+ NULL,
+ &mVirtualAddressChangeEvent
+ );
+ ASSERT_EFI_ERROR (Status);
+
+
+ //
+ // Register the call back of exit boot services
+ //
+ Status = gBS->CreateEvent (
+ EFI_EVENT_SIGNAL_EXIT_BOOT_SERVICES,
+ TPL_NOTIFY,
+ ReportStatusCodeLibExitBootServices,
+ NULL,
+ &mExitBootServicesEvent
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ return Status;
+}
+
+/**
+ Desctructor of library will close events.
+
+ @param ImageHandle callder module's image handle
+ @param SystemTable pointer to EFI system table.
+ @return the status of close event.
+**/
+EFI_STATUS
+EFIAPI
+ReportStatusCodeLibDestruct (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ EFI_STATUS Status;
+
+ if (!mInSmm) {
+ //
+ // Close SetVirtualAddressMap () notify function
+ //
+ ASSERT (gBS != NULL);
+ Status = gBS->CloseEvent (mVirtualAddressChangeEvent);
+ ASSERT_EFI_ERROR (Status);
+ Status = gBS->CloseEvent (mExitBootServicesEvent);
+ ASSERT_EFI_ERROR (Status);
+
+ (gBS->FreePool) (mStatusCodeData);
+ UnInstallRuntimeDebugMaskProtocol (ImageHandle);
+ } else {
+ if (mSmmStatusCodeEvent != NULL) {
+ Status = gBS->CloseEvent (mSmmStatusCodeEvent);
+ ASSERT_EFI_ERROR (Status);
+ }
+ mSmmBase->SmmFreePool (mSmmBase, mStatusCodeData);
+ UnInstallSmmDebugMaskProtocol (ImageHandle);
+ }
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Reports a status code with full parameters.
+
+ The function reports a status code. If ExtendedData is NULL and ExtendedDataSize
+ is 0, then an extended data buffer is not reported. If ExtendedData is not
+ NULL and ExtendedDataSize is not 0, then an extended data buffer is allocated.
+ ExtendedData is assumed not have the standard status code header, so this function
+ is responsible for allocating a buffer large enough for the standard header and
+ the extended data passed into this function. The standard header is filled in
+ with a GUID specified by ExtendedDataGuid. If ExtendedDataGuid is NULL, then a
+ GUID of gEfiStatusCodeSpecificDatauid is used. The status code is reported with
+ an instance specified by Instance and a caller ID specified by CallerId. If
+ CallerId is NULL, then a caller ID of gEfiCallerIdGuid is used.
+
+ ReportStatusCodeEx()must actively prevent recursion. If ReportStatusCodeEx()
+ is called while processing another any other Report Status Code Library function,
+ then ReportStatusCodeEx() must return EFI_DEVICE_ERROR immediately.
+
+ If ExtendedData is NULL and ExtendedDataSize is not zero, then ASSERT().
+ If ExtendedData is not NULL and ExtendedDataSize is zero, then ASSERT().
+
+ @param Type Status code type.
+ @param Value Status code value.
+ @param Instance Status code instance number.
+ @param CallerId Pointer to a GUID that identifies the caller of this
+ function. If this parameter is NULL, then a caller
+ ID of gEfiCallerIdGuid is used.
+ @param ExtendedDataGuid Pointer to the GUID for the extended data buffer.
+ If this parameter is NULL, then a the status code
+ standard header is filled in with
+ gEfiStatusCodeSpecificDataGuid.
+ @param ExtendedData Pointer to the extended data buffer. This is an
+ optional parameter that may be NULL.
+ @param ExtendedDataSize The size, in bytes, of the extended data buffer.
+
+ @retval EFI_SUCCESS The status code was reported.
+ @retval EFI_OUT_OF_RESOURCES There were not enough resources to allocate
+ the extended data section if it was specified.
+ @retval EFI_UNSUPPORTED Report status code is not supported
+
+**/
+EFI_STATUS
+EFIAPI
+InternalReportStatusCodeEx (
+ IN EFI_STATUS_CODE_TYPE Type,
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN UINT32 Instance,
+ IN CONST EFI_GUID *CallerId OPTIONAL,
+ IN CONST EFI_GUID *ExtendedDataGuid OPTIONAL,
+ IN CONST VOID *ExtendedData OPTIONAL,
+ IN UINTN ExtendedDataSize
+ )
+{
+ ASSERT (!((ExtendedData == NULL) && (ExtendedDataSize != 0)));
+ ASSERT (!((ExtendedData != NULL) && (ExtendedDataSize == 0)));
+
+ if (ExtendedDataSize > EFI_STATUS_CODE_DATA_MAX_SIZE) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ //
+ // Fill in the extended data header
+ //
+ mStatusCodeData->HeaderSize = sizeof (EFI_STATUS_CODE_DATA);
+ mStatusCodeData->Size = (UINT16)ExtendedDataSize;
+ if (ExtendedDataGuid == NULL) {
+ ExtendedDataGuid = &gEfiStatusCodeSpecificDataGuid;
+ }
+ CopyGuid (&mStatusCodeData->Type, ExtendedDataGuid);
+
+ //
+ // Fill in the extended data buffer
+ //
+ CopyMem (mStatusCodeData + 1, ExtendedData, ExtendedDataSize);
+
+ //
+ // Report the status code
+ //
+ if (CallerId == NULL) {
+ CallerId = &gEfiCallerIdGuid;
+ }
+ return InternalReportStatusCode (Type, Value, Instance, CallerId, mStatusCodeData);
+} \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiBootServicesTableLib/EdkIIGlueUefiBootServicesTableLib.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiBootServicesTableLib/EdkIIGlueUefiBootServicesTableLib.cif
new file mode 100644
index 0000000..01bcb4d
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiBootServicesTableLib/EdkIIGlueUefiBootServicesTableLib.cif
@@ -0,0 +1,11 @@
+<component>
+ name = "EdkIIGlueUefiBootServicesTableLib"
+ category = ModulePart
+ LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\UefiBootServicesTableLib"
+ RefName = "EdkIIGlueUefiBootServicesTableLib"
+[files]
+"EdkIIGlueUefiBootServicesTableLib.sdl"
+"EdkIIGlueUefiBootServicesTableLib.mak"
+"UefiBootServicesTableLib.inf"
+"UefiBootServicesTableLib.c"
+<endComponent>
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiBootServicesTableLib/EdkIIGlueUefiBootServicesTableLib.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiBootServicesTableLib/EdkIIGlueUefiBootServicesTableLib.mak
new file mode 100644
index 0000000..df0ea5b
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiBootServicesTableLib/EdkIIGlueUefiBootServicesTableLib.mak
@@ -0,0 +1,80 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueUefiBootServicesTableLib/EdkIIGlueUefiBootServicesTableLib.mak 1 1/20/12 3:57a Jeffch $
+#
+# $Revision: 1 $
+#
+# $Date: 1/20/12 3:57a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueUefiBootServicesTableLib/EdkIIGlueUefiBootServicesTableLib.mak $
+#
+# 1 1/20/12 3:57a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 9/27/11 6:20a Wesleychen
+# Intel EDK initially releases.
+#
+# 1 9/18/09 1:59a Iminglin
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: EdkIIGlueUefiBootServicesTableLib.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+
+
+$(EdkIIGlueUefiBootServicesTableLib_LIB) : EdkIIGlueUefiBootServicesTableLib
+
+EdkIIGlueUefiBootServicesTableLib : $(BUILD_DIR)\EdkIIGlueUefiBootServicesTableLib.mak EdkIIGlueUefiBootServicesTableLibBin
+
+$(BUILD_DIR)\EdkIIGlueUefiBootServicesTableLib.mak : $(EdkIIGlueUefiBootServicesTableLib_DIR)\$(@B).cif $(EdkIIGlueUefiBootServicesTableLib_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(EdkIIGlueUefiBootServicesTableLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+EdkIIGlueUefiBootServicesTableLibBin :
+!IF "$(x64_BUILD)"=="1"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGlueUefiBootServicesTableLib.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueUefiBootServicesTableLib_LIB)"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\IA32\
+ /f $(BUILD_DIR)\EdkIIGlueUefiBootServicesTableLib.mak all\
+ TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueUefiBootServicesTableLib_LIB)"
+!ELSE
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGlueUefiBootServicesTableLib.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueUefiBootServicesTableLib_LIB)"
+!ENDIF
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#********************************************************************** \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiBootServicesTableLib/EdkIIGlueUefiBootServicesTableLib.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiBootServicesTableLib/EdkIIGlueUefiBootServicesTableLib.sdl
new file mode 100644
index 0000000..80d01ac
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiBootServicesTableLib/EdkIIGlueUefiBootServicesTableLib.sdl
@@ -0,0 +1,26 @@
+TOKEN
+ Name = "EdkIIGlueUefiBootServicesTableLib_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable EdkIIGlueUefiBootServicesTableLib support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "EdkIIGlueUefiBootServicesTableLib_LIB"
+ Value = "$$(LIB_BUILD_DIR)\EdkIIGlueUefiBootServicesTableLib.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "EdkIIGlueUefiBootServicesTableLib_DIR"
+End
+
+MODULE
+ Help = "Includes EdkIIGlueUefiBootServicesTableLib.mak to Project"
+ File = "EdkIIGlueUefiBootServicesTableLib.mak"
+End
+
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.c
new file mode 100644
index 0000000..dc4a82e
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.c
@@ -0,0 +1,67 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ UefiBootServicesTableLib.c
+
+Abstract:
+
+ UEFI Boot Services Table Library.
+
+--*/
+
+#include "EdkIIGlueUefi.h"
+
+EFI_HANDLE gImageHandle;
+EFI_SYSTEM_TABLE *gST;
+EFI_BOOT_SERVICES *gBS;
+
+/**
+ The constructor function caches the pointer of Boot Services Table.
+
+ The constructor function caches the pointer of Boot Services Table through System Table.
+ It will ASSERT() if the pointer of System Table is NULL.
+ It will ASSERT() if the pointer of Boot Services Table is NULL.
+ It will always return EFI_SUCCESS.
+
+ @param ImageHandle The firmware allocated handle for the EFI image.
+ @param SystemTable A pointer to the EFI System Table.
+
+ @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
+
+**/
+EFI_STATUS
+UefiBootServicesTableLibConstructor (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ //
+ // Cache the Image Handle
+ //
+ gImageHandle = ImageHandle;
+
+ //
+ // Cache pointer to the EFI System Table
+ //
+ gST = SystemTable;
+ ASSERT (gST != NULL);
+
+ //
+ // Cache pointer to the EFI Boot Services Table
+ //
+ gBS = SystemTable->BootServices;
+ ASSERT (gBS != NULL);
+
+ return EFI_SUCCESS;
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf
new file mode 100644
index 0000000..a554a54
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiBootServicesTableLib/UefiBootServicesTableLib.inf
@@ -0,0 +1,75 @@
+#/*++
+#
+# Copyright (c) 2004 - 2006, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# UefiBootServicesTableLib.inf
+#
+# Abstract:
+#
+# Component description file for UefiBootServicesTableLib.
+#
+#--*/
+
+[defines]
+BASE_NAME = EdkIIGlueUefiBootServicesTableLib
+COMPONENT_TYPE = LIBRARY
+
+[sources.common]
+ UefiBootServicesTableLib.c
+
+[sources.ia32]
+
+[sources.x64]
+
+[sources.ipf]
+
+[sources.ebc]
+
+
+[includes.common]
+ .
+ ..\..\Include
+ ..\..\include\Library
+ $(EDK_SOURCE)\Foundation
+ $(EDK_SOURCE)\Foundation\Framework
+ $(EDK_SOURCE)\Foundation\Efi
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+ $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include
+
+ $(EDK_SOURCE)\Foundation\Efi\Protocol\DevicePath
+
+[libraries.common]
+
+[libraries.ia32]
+
+[libraries.x64]
+
+[nmake.common]
+ C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION
+ LIB_STD_FLAGS = /NOLOGO /IGNORE:4006
+
+[nmake.ia32]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32
+
+[nmake.x64]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64
+
+[nmake.ipf]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF
+
+[nmake.ebc]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDevicePathLib/EdkIIGlueUefiDevicePathLib.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDevicePathLib/EdkIIGlueUefiDevicePathLib.cif
new file mode 100644
index 0000000..43c7a6b
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDevicePathLib/EdkIIGlueUefiDevicePathLib.cif
@@ -0,0 +1,11 @@
+<component>
+ name = "EdkIIGlueUefiDevicePathLib"
+ category = ModulePart
+ LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\UefiDevicePathLib"
+ RefName = "EdkIIGlueUefiDevicePathLib"
+[files]
+"EdkIIGlueUefiDevicePathLib.sdl"
+"EdkIIGlueUefiDevicePathLib.mak"
+"UefiDevicePathLib.inf"
+"UefiDevicePathLib.c"
+<endComponent>
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDevicePathLib/EdkIIGlueUefiDevicePathLib.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDevicePathLib/EdkIIGlueUefiDevicePathLib.mak
new file mode 100644
index 0000000..08b93d5
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDevicePathLib/EdkIIGlueUefiDevicePathLib.mak
@@ -0,0 +1,80 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueUefiDevicePathLib/EdkIIGlueUefiDevicePathLib.mak 1 1/20/12 3:58a Jeffch $
+#
+# $Revision: 1 $
+#
+# $Date: 1/20/12 3:58a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueUefiDevicePathLib/EdkIIGlueUefiDevicePathLib.mak $
+#
+# 1 1/20/12 3:58a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 9/27/11 6:20a Wesleychen
+# Intel EDK initially releases.
+#
+# 1 9/18/09 1:59a Iminglin
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: EdkIIGlueUefiDevicePathLib.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+
+
+$(EdkIIGlueUefiDevicePathLib_LIB) : EdkIIGlueUefiDevicePathLib
+
+EdkIIGlueUefiDevicePathLib : $(BUILD_DIR)\EdkIIGlueUefiDevicePathLib.mak EdkIIGlueUefiDevicePathLibBin
+
+$(BUILD_DIR)\EdkIIGlueUefiDevicePathLib.mak : $(EdkIIGlueUefiDevicePathLib_DIR)\$(@B).cif $(EdkIIGlueUefiDevicePathLib_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(EdkIIGlueUefiDevicePathLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+EdkIIGlueUefiDevicePathLibBin : $(EdkIIGlueBaseMemoryLib_LIB) $(EdkIIGlueUefiBootServicesTableLib_LIB) $(EdkIIGlueDxeMemoryAllocationLib_LIB)
+!IF "$(x64_BUILD)"=="1"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGlueUefiDevicePathLib.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueUefiDevicePathLib_LIB)"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\IA32\
+ /f $(BUILD_DIR)\EdkIIGlueUefiDevicePathLib.mak all\
+ TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueUefiDevicePathLib_LIB)"
+!ELSE
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGlueUefiDevicePathLib.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueUefiDevicePathLib_LIB)"
+!ENDIF
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#********************************************************************** \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDevicePathLib/EdkIIGlueUefiDevicePathLib.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDevicePathLib/EdkIIGlueUefiDevicePathLib.sdl
new file mode 100644
index 0000000..d8a3f85
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDevicePathLib/EdkIIGlueUefiDevicePathLib.sdl
@@ -0,0 +1,26 @@
+TOKEN
+ Name = "EdkIIGlueUefiDevicePathLib_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable EdkIIGlueUefiDevicePathLib support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "EdkIIGlueUefiDevicePathLib_LIB"
+ Value = "$$(LIB_BUILD_DIR)\EdkIIGlueUefiDevicePathLib.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "EdkIIGlueUefiDevicePathLib_DIR"
+End
+
+MODULE
+ Help = "Includes EdkIIGlueUefiDevicePathLib.mak to Project"
+ File = "EdkIIGlueUefiDevicePathLib.mak"
+End
+
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDevicePathLib/UefiDevicePathLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDevicePathLib/UefiDevicePathLib.c
new file mode 100644
index 0000000..a7f22bb
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDevicePathLib/UefiDevicePathLib.c
@@ -0,0 +1,533 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ UefiDevicePathLib.c
+
+Abstract:
+
+ Device Path services. The thing to remember is device paths are built out of
+ nodes. The device path is terminated by an end node that is length
+ sizeof(EFI_DEVICE_PATH_PROTOCOL). That would be why there is sizeof(EFI_DEVICE_PATH_PROTOCOL)
+ all over this file.
+
+ The only place where multi-instance device paths are supported is in
+ environment varibles. Multi-instance device paths should never be placed
+ on a Handle.
+
+--*/
+
+#include "EdkIIGlueUefi.h"
+#include "Library\EdkIIGlueMemoryAllocationLib.h"
+
+/**
+ Returns the size of a device path in bytes.
+
+ This function returns the size, in bytes, of the device path data structure specified by
+ DevicePath including the end of device path node. If DevicePath is NULL, then 0 is returned.
+
+ @param DevicePath A pointer to a device path data structure.
+
+ @return The size of a device path in bytes.
+
+**/
+UINTN
+EFIAPI
+GlueGetDevicePathSize (
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ )
+{
+ CONST EFI_DEVICE_PATH_PROTOCOL *Start;
+
+ if (DevicePath == NULL) {
+ return 0;
+ }
+
+ //
+ // Search for the end of the device path structure
+ //
+ Start = DevicePath;
+ while (!EfiIsDevicePathEnd (DevicePath)) {
+ DevicePath = EfiNextDevicePathNode (DevicePath);
+ }
+
+ //
+ // Compute the size and add back in the size of the end device path structure
+ //
+ return ((UINTN) DevicePath - (UINTN) Start) + sizeof (EFI_DEVICE_PATH_PROTOCOL);
+}
+
+/**
+ Creates a new device path by appending a second device path to a first device path.
+
+ This function allocates space for a new copy of the device path specified by DevicePath. If
+ DevicePath is NULL, then NULL is returned. If the memory is successfully allocated, then the
+ contents of DevicePath are copied to the newly allocated buffer, and a pointer to that buffer
+ is returned. Otherwise, NULL is returned.
+
+ @param DevicePath A pointer to a device path data structure.
+
+ @return A pointer to the duplicated device path.
+
+**/
+EFI_DEVICE_PATH_PROTOCOL *
+EFIAPI
+GlueDuplicateDevicePath (
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ )
+{
+ EFI_DEVICE_PATH_PROTOCOL *NewDevicePath;
+ UINTN Size;
+
+ //
+ // Compute the size
+ //
+ Size = GetDevicePathSize (DevicePath);
+ if (Size == 0) {
+ return NULL;
+ }
+
+ //
+ // Allocate space for duplicate device path
+ //
+ NewDevicePath = AllocateCopyPool (Size, DevicePath);
+
+ return NewDevicePath;
+}
+
+/**
+ Creates a new device path by appending a second device path to a first device path.
+
+ This function creates a new device path by appending a copy of SecondDevicePath to a copy of
+ FirstDevicePath in a newly allocated buffer. Only the end-of-device-path device node from
+ SecondDevicePath is retained. The newly created device path is returned.
+ If FirstDevicePath is NULL, then it is ignored, and a duplicate of SecondDevicePath is returned.
+ If SecondDevicePath is NULL, then it is ignored, and a duplicate of FirstDevicePath is returned.
+ If both FirstDevicePath and SecondDevicePath are NULL, then NULL is returned.
+ If there is not enough memory for the newly allocated buffer, then NULL is returned.
+ The memory for the new device path is allocated from EFI boot services memory. It is the
+ responsibility of the caller to free the memory allocated.
+
+ @param FirstDevicePath A pointer to a device path data structure.
+ @param SecondDevicePath A pointer to a device path data structure.
+
+ @return A pointer to the new device path.
+
+**/
+EFI_DEVICE_PATH_PROTOCOL *
+EFIAPI
+GlueAppendDevicePath (
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *FirstDevicePath, OPTIONAL
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *SecondDevicePath OPTIONAL
+ )
+{
+ UINTN Size;
+ UINTN Size1;
+ UINTN Size2;
+ EFI_DEVICE_PATH_PROTOCOL *NewDevicePath;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath2;
+
+ //
+ // If there's only 1 path, just duplicate it.
+ //
+ if (FirstDevicePath == NULL) {
+ return DuplicateDevicePath (SecondDevicePath);
+ }
+
+ if (SecondDevicePath == NULL) {
+ return DuplicateDevicePath (FirstDevicePath);
+ }
+
+ //
+ // Allocate space for the combined device path. It only has one end node of
+ // length EFI_DEVICE_PATH_PROTOCOL.
+ //
+ Size1 = GetDevicePathSize (FirstDevicePath);
+ Size2 = GetDevicePathSize (SecondDevicePath);
+ Size = Size1 + Size2 - sizeof (EFI_DEVICE_PATH_PROTOCOL);
+
+ NewDevicePath = AllocatePool (Size);
+
+ if (NewDevicePath != NULL) {
+ NewDevicePath = CopyMem (NewDevicePath, FirstDevicePath, Size1);
+ //
+ // Over write FirstDevicePath EndNode and do the copy
+ //
+ DevicePath2 = (EFI_DEVICE_PATH_PROTOCOL *) ((CHAR8 *) NewDevicePath +
+ (Size1 - sizeof (EFI_DEVICE_PATH_PROTOCOL)));
+ CopyMem (DevicePath2, SecondDevicePath, Size2);
+ }
+
+ return NewDevicePath;
+}
+
+/**
+ Creates a new path by appending the device node to the device path.
+
+ This function creates a new device path by appending a copy of the device node specified by
+ DevicePathNode to a copy of the device path specified by DevicePath in an allocated buffer.
+ The end-of-device-path device node is moved after the end of the appended device node.
+ If DevicePath is NULL, then NULL is returned.
+ If DevicePathNode is NULL, then NULL is returned.
+ If there is not enough memory to allocate space for the new device path, then NULL is returned.
+ The memory is allocated from EFI boot services memory. It is the responsibility of the caller to
+ free the memory allocated.
+
+ @param DevicePath A pointer to a device path data structure.
+ @param DevicePathNode A pointer to a single device path node.
+
+ @return A pointer to the new device path.
+
+**/
+EFI_DEVICE_PATH_PROTOCOL *
+EFIAPI
+GlueAppendDevicePathNode (
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, OPTIONAL
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathNode OPTIONAL
+ )
+{
+ EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
+ EFI_DEVICE_PATH_PROTOCOL *NextNode;
+ EFI_DEVICE_PATH_PROTOCOL *NewDevicePath;
+ UINTN NodeLength;
+
+ if (DevicePath == NULL || DevicePathNode == NULL) {
+ return NULL;
+ }
+ //
+ // Build a Node that has a terminator on it
+ //
+ NodeLength = DevicePathNodeLength (DevicePathNode);
+
+ TempDevicePath = AllocatePool (NodeLength + sizeof (EFI_DEVICE_PATH_PROTOCOL));
+ if (TempDevicePath == NULL) {
+ return NULL;
+ }
+ TempDevicePath = CopyMem (TempDevicePath, DevicePathNode, NodeLength);
+ //
+ // Add and end device path node to convert Node to device path
+ //
+ NextNode = NextDevicePathNode (TempDevicePath);
+ SetDevicePathEndNode (NextNode);
+ //
+ // Append device paths
+ //
+ NewDevicePath = AppendDevicePath (DevicePath, TempDevicePath);
+
+ FreePool (TempDevicePath);
+
+ return NewDevicePath;
+}
+
+/**
+ Creates a new device path by appending the specified device path instance to the specified device
+ path.
+
+ This function creates a new device path by appending a copy of the device path instance specified
+ by DevicePathInstance to a copy of the device path secified by DevicePath in a allocated buffer.
+ The end-of-device-path device node is moved after the end of the appended device path instance
+ and a new end-of-device-path-instance node is inserted between.
+ If DevicePath is NULL, then a copy if DevicePathInstance is returned.
+ If DevicePathInstance is NULL, then NULL is returned.
+ If there is not enough memory to allocate space for the new device path, then NULL is returned.
+ The memory is allocated from EFI boot services memory. It is the responsibility of the caller to
+ free the memory allocated.
+
+ @param DevicePath A pointer to a device path data structure.
+ @param DevicePathInstance A pointer to a device path instance.
+
+ @return A pointer to the new device path.
+
+**/
+EFI_DEVICE_PATH_PROTOCOL *
+EFIAPI
+GlueAppendDevicePathInstance (
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, OPTIONAL
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePathInstance OPTIONAL
+ )
+{
+ EFI_DEVICE_PATH_PROTOCOL *NewDevicePath;
+ EFI_DEVICE_PATH_PROTOCOL *TempDevicePath;
+ UINTN SrcSize;
+ UINTN InstanceSize;
+
+ if (DevicePath == NULL) {
+ return DuplicateDevicePath (DevicePathInstance);
+ }
+
+ if (DevicePathInstance == NULL) {
+ return NULL;
+ }
+
+ SrcSize = GetDevicePathSize (DevicePath);
+ InstanceSize = GetDevicePathSize (DevicePathInstance);
+
+ NewDevicePath = AllocatePool (SrcSize + InstanceSize);
+ if (NewDevicePath != NULL) {
+
+ TempDevicePath = CopyMem (NewDevicePath, DevicePath, SrcSize);;
+
+ while (!IsDevicePathEnd (TempDevicePath)) {
+ TempDevicePath = NextDevicePathNode (TempDevicePath);
+ }
+
+ TempDevicePath->SubType = END_INSTANCE_DEVICE_PATH_SUBTYPE;
+ TempDevicePath = NextDevicePathNode (TempDevicePath);
+ CopyMem (TempDevicePath, DevicePathInstance, InstanceSize);
+ }
+
+ return NewDevicePath;
+}
+
+/**
+ Creates a copy of the current device path instance and returns a pointer to the next device path
+ instance.
+
+ This function creates a copy of the current device path instance. It also updates DevicePath to
+ point to the next device path instance in the device path (or NULL if no more) and updates Size
+ to hold the size of the device path instance copy.
+ If DevicePath is NULL, then NULL is returned.
+ If there is not enough memory to allocate space for the new device path, then NULL is returned.
+ The memory is allocated from EFI boot services memory. It is the responsibility of the caller to
+ free the memory allocated.
+ If Size is NULL, then ASSERT().
+
+ @param DevicePath On input, this holds the pointer to the current device path
+ instance. On output, this holds the pointer to the next device
+ path instance or NULL if there are no more device path
+ instances in the device path pointer to a device path data
+ structure.
+ @param Size On output, this holds the size of the device path instance, in
+ bytes or zero, if DevicePath is NULL.
+
+ @return A pointer to the current device path instance.
+
+**/
+EFI_DEVICE_PATH_PROTOCOL *
+EFIAPI
+GlueGetNextDevicePathInstance (
+ IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath,
+ OUT UINTN *Size
+ )
+{
+ EFI_DEVICE_PATH_PROTOCOL *DevPath;
+ EFI_DEVICE_PATH_PROTOCOL *ReturnValue;
+ UINT8 Temp;
+
+ ASSERT (Size != NULL);
+
+ if (DevicePath == NULL || *DevicePath == NULL) {
+ *Size = 0;
+ return NULL;
+ }
+
+ //
+ // Find the end of the device path instance
+ //
+ DevPath = *DevicePath;
+ while (!IsDevicePathEndType (DevPath)) {
+ DevPath = NextDevicePathNode (DevPath);
+ }
+
+ //
+ // Compute the size of the device path instance
+ //
+ *Size = ((UINTN) DevPath - (UINTN) (*DevicePath)) + sizeof (EFI_DEVICE_PATH_PROTOCOL);
+
+ //
+ // Make a copy and return the device path instance
+ //
+ Temp = DevPath->SubType;
+ DevPath->SubType = END_ENTIRE_DEVICE_PATH_SUBTYPE;
+ ReturnValue = DuplicateDevicePath (*DevicePath);
+ DevPath->SubType = Temp;
+
+ //
+ // If DevPath is the end of an entire device path, then another instance
+ // does not follow, so *DevicePath is set to NULL.
+ //
+ if (DevicePathSubType (DevPath) == END_ENTIRE_DEVICE_PATH_SUBTYPE) {
+ *DevicePath = NULL;
+ } else {
+ *DevicePath = NextDevicePathNode (DevPath);
+ }
+
+ return ReturnValue;
+}
+
+/**
+ Creates a copy of the current device path instance and returns a pointer to the next device path
+ instance.
+
+ This function creates a new device node in a newly allocated buffer of size NodeLength and
+ initializes the device path node header with NodeType and NodeSubType. The new device path node
+ is returned.
+ If NodeLength is smaller than a device path header, then NULL is returned.
+ If there is not enough memory to allocate space for the new device path, then NULL is returned.
+ The memory is allocated from EFI boot services memory. It is the responsibility of the caller to
+ free the memory allocated.
+
+ @param NodeType The device node type for the new device node.
+ @param NodeSubType The device node sub-type for the new device node.
+ @param NodeLength The length of the new device node.
+
+ @return The new device path.
+
+**/
+EFI_DEVICE_PATH_PROTOCOL *
+EFIAPI
+CreateDeviceNode (
+ IN UINT8 NodeType,
+ IN UINT8 NodeSubType,
+ IN UINT16 NodeLength
+ )
+{
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+
+ if (NodeLength < sizeof (EFI_DEVICE_PATH_PROTOCOL)) {
+ //
+ // NodeLength is less than the size of the header.
+ //
+ return NULL;
+ }
+
+ DevicePath = AllocatePool (NodeLength);
+ if (DevicePath != NULL) {
+ DevicePath->Type = NodeType;
+ DevicePath->SubType = NodeSubType;
+ SetDevicePathNodeLength (DevicePath, NodeLength);
+ }
+
+ return DevicePath;
+}
+
+/**
+ Determines if a device path is single or multi-instance.
+
+ This function returns TRUE if the device path specified by DevicePath is multi-instance.
+ Otherwise, FALSE is returned. If DevicePath is NULL, then FALSE is returned.
+
+ @param DevicePath A pointer to a device path data structure.
+
+ @retval TRUE DevicePath is multi-instance.
+ @retval FALSE DevicePath is not multi-instance or DevicePath is NULL.
+
+**/
+BOOLEAN
+EFIAPI
+GlueIsDevicePathMultiInstance (
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ )
+{
+ CONST EFI_DEVICE_PATH_PROTOCOL *Node;
+
+ if (DevicePath == NULL) {
+ return FALSE;
+ }
+
+ Node = DevicePath;
+ while (!EfiIsDevicePathEnd (Node)) {
+ if (EfiIsDevicePathEndInstance (Node)) {
+ return TRUE;
+ }
+
+ Node = EfiNextDevicePathNode (Node);
+ }
+
+ return FALSE;
+}
+
+
+/**
+ Retrieves the device path protocol from a handle.
+
+ This function returns the device path protocol from the handle specified by Handle. If Handle is
+ NULL or Handle does not contain a device path protocol, then NULL is returned.
+
+ @param Handle The handle from which to retrieve the device path protocol.
+
+ @return The device path protocol from the handle specified by Handle.
+
+**/
+EFI_DEVICE_PATH_PROTOCOL *
+EFIAPI
+GlueDevicePathFromHandle (
+ IN EFI_HANDLE Handle
+ )
+{
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ EFI_STATUS Status;
+
+ Status = gBS->HandleProtocol (
+ Handle,
+ &gEfiDevicePathProtocolGuid,
+ (VOID *) &DevicePath
+ );
+ if (EFI_ERROR (Status)) {
+ DevicePath = NULL;
+ }
+ return DevicePath;
+}
+
+/**
+ Allocates a device path for a file and appends it to an existing device path.
+
+ If Device is a valid device handle that contains a device path protocol, then a device path for
+ the file specified by FileName is allocated and appended to the device path associated with the
+ handle Device. The allocated device path is returned. If Device is NULL or Device is a handle
+ that does not support the device path protocol, then a device path containing a single device
+ path node for the file specified by FileName is allocated and returned.
+ If FileName is NULL, then ASSERT().
+
+ @param Device A pointer to a device handle. This parameter is optional and
+ may be NULL.
+ @param FileName A pointer to a Null-terminated Unicode string.
+
+ @return The allocated device path.
+
+**/
+EFI_DEVICE_PATH_PROTOCOL *
+EFIAPI
+GlueFileDevicePath (
+ IN EFI_HANDLE Device, OPTIONAL
+ IN CONST CHAR16 *FileName
+ )
+{
+ UINTN Size;
+ FILEPATH_DEVICE_PATH *FilePath;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+ EFI_DEVICE_PATH_PROTOCOL *FileDevicePath;
+
+ DevicePath = NULL;
+
+ Size = StrSize (FileName);
+ FileDevicePath = AllocatePool (Size + SIZE_OF_FILEPATH_DEVICE_PATH + EFI_END_DEVICE_PATH_LENGTH);
+ if (FileDevicePath != NULL) {
+ FilePath = (FILEPATH_DEVICE_PATH *) FileDevicePath;
+ FilePath->Header.Type = MEDIA_DEVICE_PATH;
+ FilePath->Header.SubType = MEDIA_FILEPATH_DP;
+ CopyMem (&FilePath->PathName, FileName, Size);
+ SetDevicePathNodeLength (&FilePath->Header, Size + SIZE_OF_FILEPATH_DEVICE_PATH);
+ SetDevicePathEndNode (NextDevicePathNode (&FilePath->Header));
+
+ if (Device != NULL) {
+ DevicePath = DevicePathFromHandle (Device);
+ }
+
+ DevicePath = AppendDevicePath (DevicePath, FileDevicePath);
+ FreePool (FileDevicePath);
+ }
+
+ return DevicePath;
+}
+
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDevicePathLib/UefiDevicePathLib.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDevicePathLib/UefiDevicePathLib.inf
new file mode 100644
index 0000000..17af5bd
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDevicePathLib/UefiDevicePathLib.inf
@@ -0,0 +1,83 @@
+#/*++
+#
+# Copyright (c) 2004 - 2006, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# UefiDevicePathLib.inf
+#
+# Abstract:
+#
+# Component description file for UefiDevicePathLib.
+#
+#--*/
+
+[defines]
+BASE_NAME = EdkIIGlueUefiDevicePathLib
+COMPONENT_TYPE = LIBRARY
+
+[sources.common]
+ UefiDevicePathLib.c
+
+[sources.ia32]
+
+[sources.x64]
+
+[sources.ipf]
+
+[sources.ebc]
+
+
+[includes.common]
+ .
+ ..\..\Include
+ ..\..\include\Library
+ $(EDK_SOURCE)\Foundation
+ $(EDK_SOURCE)\Foundation\Framework
+ $(EDK_SOURCE)\Foundation\Efi
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+ $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include
+
+ $(EDK_SOURCE)\Foundation\Efi\Protocol\DevicePath
+
+[libraries.common]
+ EdkIIGlueBaseMemoryLib
+ EdkIIGlueUefiBootServicesTableLib
+#
+# MemoryAllocationLib instance
+#
+ EdkIIGlueDxeMemoryAllocationLib
+
+[libraries.ia32]
+
+
+[libraries.x64]
+
+
+[nmake.common]
+ C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION
+ LIB_STD_FLAGS = /NOLOGO /IGNORE:4006
+
+[nmake.ia32]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32
+
+[nmake.x64]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64
+
+[nmake.ipf]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF
+
+[nmake.ebc]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDriverModelLib/EdkIIGlueUefiDriverModelLib.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDriverModelLib/EdkIIGlueUefiDriverModelLib.cif
new file mode 100644
index 0000000..a5dc193
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDriverModelLib/EdkIIGlueUefiDriverModelLib.cif
@@ -0,0 +1,11 @@
+<component>
+ name = "EdkIIGlueUefiDriverModelLib"
+ category = ModulePart
+ LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\UefiDriverModelLib"
+ RefName = "EdkIIGlueUefiDriverModelLib"
+[files]
+"EdkIIGlueUefiDriverModelLib.sdl"
+"EdkIIGlueUefiDriverModelLib.mak"
+"UefiDriverModelLib.inf"
+"UefiDriverModelLib.c"
+<endComponent>
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDriverModelLib/EdkIIGlueUefiDriverModelLib.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDriverModelLib/EdkIIGlueUefiDriverModelLib.mak
new file mode 100644
index 0000000..70f8b12
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDriverModelLib/EdkIIGlueUefiDriverModelLib.mak
@@ -0,0 +1,80 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueUefiDriverModelLib/EdkIIGlueUefiDriverModelLib.mak 1 1/20/12 3:58a Jeffch $
+#
+# $Revision: 1 $
+#
+# $Date: 1/20/12 3:58a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueUefiDriverModelLib/EdkIIGlueUefiDriverModelLib.mak $
+#
+# 1 1/20/12 3:58a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 9/27/11 6:20a Wesleychen
+# Intel EDK initially releases.
+#
+# 1 9/18/09 1:59a Iminglin
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: EdkIIGlueUefiDriverModelLib.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+
+
+$(EdkIIGlueUefiDriverModelLib_LIB) : EdkIIGlueUefiDriverModelLib
+
+EdkIIGlueUefiDriverModelLib : $(BUILD_DIR)\EdkIIGlueUefiDriverModelLib.mak EdkIIGlueUefiDriverModelLibBin
+
+$(BUILD_DIR)\EdkIIGlueUefiDriverModelLib.mak : $(EdkIIGlueUefiDriverModelLib_DIR)\$(@B).cif $(EdkIIGlueUefiDriverModelLib_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(EdkIIGlueUefiDriverModelLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+EdkIIGlueUefiDriverModelLibBin : $(EdkIIGlueUefiBootServicesTableLib_LIB)
+!IF "$(x64_BUILD)"=="1"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGlueUefiDriverModelLib.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueUefiDriverModelLib_LIB)"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\IA32\
+ /f $(BUILD_DIR)\EdkIIGlueUefiDriverModelLib.mak all\
+ TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueUefiDriverModelLib_LIB)"
+!ELSE
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGlueUefiDriverModelLib.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueUefiDriverModelLib_LIB)"
+!ENDIF
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#********************************************************************** \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDriverModelLib/EdkIIGlueUefiDriverModelLib.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDriverModelLib/EdkIIGlueUefiDriverModelLib.sdl
new file mode 100644
index 0000000..bde01f2
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDriverModelLib/EdkIIGlueUefiDriverModelLib.sdl
@@ -0,0 +1,26 @@
+TOKEN
+ Name = "EdkIIGlueUefiDriverModelLib_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable EdkIIGlueUefiDriverModelLib support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "EdkIIGlueUefiDriverModelLib_LIB"
+ Value = "$$(LIB_BUILD_DIR)\EdkIIGlueUefiDriverModelLib.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "EdkIIGlueUefiDriverModelLib_DIR"
+End
+
+MODULE
+ Help = "Includes EdkIIGlueUefiDriverModelLib.mak to Project"
+ File = "EdkIIGlueUefiDriverModelLib.mak"
+End
+
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDriverModelLib/UefiDriverModelLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDriverModelLib/UefiDriverModelLib.c
new file mode 100644
index 0000000..8f1cbf5
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDriverModelLib/UefiDriverModelLib.c
@@ -0,0 +1,431 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ UefiDriverModelLib.c
+
+Abstract:
+
+ UEFI Driver Model Library.
+
+--*/
+
+#include "EdkIIGlueUefi.h"
+
+
+/**
+ The constructor function installs the standard EFI Driver Model Protocols.
+
+ @param[in] ImageHandle The firmware allocated handle for the EFI image.
+ @param[in] SystemTable A pointer to the EFI System Table.
+
+ @retval EFI_SUCCESS The constructor always return EFI_SUCCESS.
+
+**/
+EFI_STATUS
+EFIAPI
+UefiDriverModelLibConstructor (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ EFI_HANDLE DriverBindingHandle;
+ EFI_DRIVER_BINDING_PROTOCOL *DriverBinding;
+
+ //
+ // Install the first Driver Bindng Protocol onto ImageHandle
+ //
+ DriverBindingHandle = ImageHandle;
+
+ //
+ // See if onle one Driver Binding Protocol is advertised by the driver
+ // EdkIIGlueLib: _gDriverModelProtocolListEntries is always 1
+ //
+
+ //
+ // The Driver Binding Protocol must never be NULL
+ //
+ ASSERT(_gDriverModelProtocolList[0].DriverBinding != NULL);
+
+ //
+ // Check for all 8 possible combinations of the ComponentName, DriverConfiguration, and DriverDiagnostics Protocol
+ // These are all checks against const pointers, so the optimizing compiler will only select one of the
+ // calls to InstallMultipleProtocolInterfaces()
+ //
+ if ((_gEdkIIGlueDriverModelProtocolSelection == 1) || (_gEdkIIGlueDriverModelProtocolSelection == 3)) {
+ if (_gDriverModelProtocolList[0].DriverDiagnostics == NULL) {
+ if (_gDriverModelProtocolList[0].DriverConfiguration == NULL) {
+ if (_gDriverModelProtocolList[0].ComponentName == NULL) {
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
+ NULL
+ );
+ } else {
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
+ &gEfiComponentNameProtocolGuid, (EFI_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,
+ NULL
+ );
+ }
+ } else {
+ if (_gDriverModelProtocolList[0].ComponentName == NULL) {
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
+ &gEfiDriverConfigurationProtocolGuid, (EFI_DRIVER_CONFIGURATION_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration,
+ NULL
+ );
+ } else {
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
+ &gEfiComponentNameProtocolGuid, (EFI_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,
+ &gEfiDriverConfigurationProtocolGuid, (EFI_DRIVER_CONFIGURATION_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration,
+ NULL
+ );
+ }
+ }
+ } else {
+ if (_gDriverModelProtocolList[0].DriverConfiguration == NULL) {
+ if (_gDriverModelProtocolList[0].ComponentName == NULL) {
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
+ &gEfiDriverDiagnosticsProtocolGuid, (EFI_DRIVER_DIAGNOSTICS_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics,
+ NULL
+ );
+ } else {
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
+ &gEfiComponentNameProtocolGuid, (EFI_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,
+ &gEfiDriverDiagnosticsProtocolGuid, (EFI_DRIVER_DIAGNOSTICS_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics,
+ NULL
+ );
+ }
+ } else {
+ if (_gDriverModelProtocolList[0].ComponentName == NULL) {
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
+ &gEfiDriverConfigurationProtocolGuid, (EFI_DRIVER_CONFIGURATION_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration,
+ &gEfiDriverDiagnosticsProtocolGuid, (EFI_DRIVER_DIAGNOSTICS_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics,
+ NULL
+ );
+ } else {
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
+ &gEfiComponentNameProtocolGuid, (EFI_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,
+ &gEfiDriverConfigurationProtocolGuid, (EFI_DRIVER_CONFIGURATION_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration,
+ &gEfiDriverDiagnosticsProtocolGuid, (EFI_DRIVER_DIAGNOSTICS_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics,
+ NULL
+ );
+ }
+ }
+ }
+ } // selection == 1 or 3
+
+ if ((_gEdkIIGlueDriverModelProtocolSelection == 2) || (_gEdkIIGlueDriverModelProtocolSelection == 3)) {
+ if (_gDriverModelProtocolList[0].DriverDiagnostics2== NULL) {
+ if (_gDriverModelProtocolList[0].DriverConfiguration2== NULL) {
+ if (_gDriverModelProtocolList[0].ComponentName2== NULL) {
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
+ NULL
+ );
+ } else {
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
+ &gEfiComponentName2ProtocolGuid, (EFI_COMPONENT_NAME2_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName2,
+ NULL
+ );
+ }
+ } else {
+ if (_gDriverModelProtocolList[0].ComponentName2 == NULL) {
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
+ &gEfiDriverConfiguration2ProtocolGuid, (EFI_DRIVER_CONFIGURATION2_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration2,
+ NULL
+ );
+ } else {
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
+ &gEfiComponentName2ProtocolGuid, (EFI_COMPONENT_NAME2_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName2,
+ &gEfiDriverConfiguration2ProtocolGuid, (EFI_DRIVER_CONFIGURATION2_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration2,
+ NULL
+ );
+ }
+ }
+ } else {
+ if (_gDriverModelProtocolList[0].DriverConfiguration2 == NULL) {
+ if (_gDriverModelProtocolList[0].ComponentName2 == NULL) {
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
+ &gEfiDriverDiagnostics2ProtocolGuid, (EFI_DRIVER_DIAGNOSTICS2_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics2,
+ NULL
+ );
+ } else {
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
+ &gEfiComponentName2ProtocolGuid, (EFI_COMPONENT_NAME2_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName2,
+ &gEfiDriverDiagnostics2ProtocolGuid, (EFI_DRIVER_DIAGNOSTICS2_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics2,
+ NULL
+ );
+ }
+ } else {
+ if (_gDriverModelProtocolList[0].ComponentName2 == NULL) {
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
+ &gEfiDriverConfiguration2ProtocolGuid, (EFI_DRIVER_CONFIGURATION2_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration2,
+ &gEfiDriverDiagnostics2ProtocolGuid, (EFI_DRIVER_DIAGNOSTICS2_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics2,
+ NULL
+ );
+ } else {
+ Status = gBS->InstallMultipleProtocolInterfaces (
+ &DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
+ &gEfiComponentName2ProtocolGuid, (EFI_COMPONENT_NAME2_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName2,
+ &gEfiDriverConfiguration2ProtocolGuid, (EFI_DRIVER_CONFIGURATION2_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration2,
+ &gEfiDriverDiagnostics2ProtocolGuid, (EFI_DRIVER_DIAGNOSTICS2_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics2,
+ NULL
+ );
+ }
+ }
+ }
+ } // selection == 2 or 3
+
+ //
+ // ASSERT if the call to InstallMultipleProtocolInterfaces() failed
+ //
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // Update the ImageHandle and DriverBindingHandle fields of the Driver Binding Protocol
+ //
+ DriverBinding = (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding;
+ DriverBinding->ImageHandle = ImageHandle;
+ DriverBinding->DriverBindingHandle = DriverBindingHandle;
+
+
+ return EFI_SUCCESS;
+}
+
+/**
+ The destructor function uninstalls the standard EFI Driver Model Protocols.
+
+ @param[in] ImageHandle The firmware allocated handle for the EFI image.
+ @param[in] SystemTable A pointer to the EFI System Table.
+
+ @retval EFI_SUCCESS The destructor always return EFI_SUCCESS.
+
+**/
+EFI_STATUS
+EFIAPI
+UefiDriverModelLibDestructor (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ EFI_STATUS Status = EFI_UNSUPPORTED;
+ EFI_HANDLE DriverBindingHandle;
+
+ //
+ // See if onle one Driver Binding Protocol is advertised by the driver
+ // EdkIIGlueLib: _gDriverModelProtocolListEntries is always 1
+ //
+
+ //
+ // The Driver Binding Protocol must never be NULL
+ //
+ ASSERT(_gDriverModelProtocolList[0].DriverBinding != NULL);
+
+ //
+ // Retrieve the DriverBindingHandle from the Driver Binding Protocol
+ //
+ DriverBindingHandle = _gDriverModelProtocolList[0].DriverBinding->DriverBindingHandle;
+
+ //
+ // Check for all 8 possible combinations of the ComponentName, DriverConfiguration, and DriverDiagnostics Protocol
+ // These are all checks against const pointers, so the optimizing compiler will only select one of the
+ // calls to InstallMultipleProtocolInterfaces()
+ //
+ if ((_gEdkIIGlueDriverModelProtocolSelection == 1) || (_gEdkIIGlueDriverModelProtocolSelection == 3)) {
+ if (_gDriverModelProtocolList[0].DriverDiagnostics == NULL) {
+ if (_gDriverModelProtocolList[0].DriverConfiguration == NULL) {
+ if (_gDriverModelProtocolList[0].ComponentName == NULL) {
+ Status = gBS->UninstallMultipleProtocolInterfaces (
+ DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
+ NULL
+ );
+ } else {
+ Status = gBS->UninstallMultipleProtocolInterfaces (
+ &DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
+ &gEfiComponentNameProtocolGuid, (EFI_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,
+ NULL
+ );
+ }
+ } else {
+ if (_gDriverModelProtocolList[0].ComponentName == NULL) {
+ Status = gBS->UninstallMultipleProtocolInterfaces (
+ &DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
+ &gEfiDriverConfigurationProtocolGuid, (EFI_DRIVER_CONFIGURATION_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration,
+ NULL
+ );
+ } else {
+ Status = gBS->UninstallMultipleProtocolInterfaces (
+ &DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
+ &gEfiComponentNameProtocolGuid, (EFI_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,
+ &gEfiDriverConfigurationProtocolGuid, (EFI_DRIVER_CONFIGURATION_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration,
+ NULL
+ );
+ }
+ }
+ } else {
+ if (_gDriverModelProtocolList[0].DriverConfiguration == NULL) {
+ if (_gDriverModelProtocolList[0].ComponentName == NULL) {
+ Status = gBS->UninstallMultipleProtocolInterfaces (
+ &DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
+ &gEfiDriverDiagnosticsProtocolGuid, (EFI_DRIVER_DIAGNOSTICS_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics,
+ NULL
+ );
+ } else {
+ Status = gBS->UninstallMultipleProtocolInterfaces (
+ &DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
+ &gEfiComponentNameProtocolGuid, (EFI_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,
+ &gEfiDriverDiagnosticsProtocolGuid, (EFI_DRIVER_DIAGNOSTICS_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics,
+ NULL
+ );
+ }
+ } else {
+ if (_gDriverModelProtocolList[0].ComponentName == NULL) {
+ Status = gBS->UninstallMultipleProtocolInterfaces (
+ &DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
+ &gEfiDriverConfigurationProtocolGuid, (EFI_DRIVER_CONFIGURATION_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration,
+ &gEfiDriverDiagnosticsProtocolGuid, (EFI_DRIVER_DIAGNOSTICS_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics,
+ NULL
+ );
+ } else {
+ Status = gBS->UninstallMultipleProtocolInterfaces (
+ &DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
+ &gEfiComponentNameProtocolGuid, (EFI_COMPONENT_NAME_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName,
+ &gEfiDriverConfigurationProtocolGuid, (EFI_DRIVER_CONFIGURATION_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration,
+ &gEfiDriverDiagnosticsProtocolGuid, (EFI_DRIVER_DIAGNOSTICS_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics,
+ NULL
+ );
+ }
+ }
+ }
+ } // selection == 1 or 3
+
+ if ((_gEdkIIGlueDriverModelProtocolSelection == 2) || (_gEdkIIGlueDriverModelProtocolSelection == 3)) {
+ if (_gDriverModelProtocolList[0].DriverDiagnostics2 == NULL) {
+ if (_gDriverModelProtocolList[0].DriverConfiguration2 == NULL) {
+ if (_gDriverModelProtocolList[0].ComponentName2 == NULL) {
+ Status = gBS->UninstallMultipleProtocolInterfaces (
+ DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
+ NULL
+ );
+ } else {
+ Status = gBS->UninstallMultipleProtocolInterfaces (
+ &DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
+ &gEfiComponentName2ProtocolGuid, (EFI_COMPONENT_NAME2_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName2,
+ NULL
+ );
+ }
+ } else {
+ if (_gDriverModelProtocolList[0].ComponentName2 == NULL) {
+ Status = gBS->UninstallMultipleProtocolInterfaces (
+ &DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
+ &gEfiDriverConfiguration2ProtocolGuid, (EFI_DRIVER_CONFIGURATION2_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration2,
+ NULL
+ );
+ } else {
+ Status = gBS->UninstallMultipleProtocolInterfaces (
+ &DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
+ &gEfiComponentName2ProtocolGuid, (EFI_COMPONENT_NAME2_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName2,
+ &gEfiDriverConfiguration2ProtocolGuid, (EFI_DRIVER_CONFIGURATION2_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration2,
+ NULL
+ );
+ }
+ }
+ } else {
+ if (_gDriverModelProtocolList[0].DriverConfiguration2 == NULL) {
+ if (_gDriverModelProtocolList[0].ComponentName2 == NULL) {
+ Status = gBS->UninstallMultipleProtocolInterfaces (
+ &DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
+ &gEfiDriverDiagnostics2ProtocolGuid, (EFI_DRIVER_DIAGNOSTICS2_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics2,
+ NULL
+ );
+ } else {
+ Status = gBS->UninstallMultipleProtocolInterfaces (
+ &DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
+ &gEfiComponentName2ProtocolGuid, (EFI_COMPONENT_NAME2_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName2,
+ &gEfiDriverDiagnostics2ProtocolGuid, (EFI_DRIVER_DIAGNOSTICS2_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics2,
+ NULL
+ );
+ }
+ } else {
+ if (_gDriverModelProtocolList[0].ComponentName2 == NULL) {
+ Status = gBS->UninstallMultipleProtocolInterfaces (
+ &DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
+ &gEfiDriverConfiguration2ProtocolGuid, (EFI_DRIVER_CONFIGURATION2_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration2,
+ &gEfiDriverDiagnostics2ProtocolGuid, (EFI_DRIVER_DIAGNOSTICS2_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics2,
+ NULL
+ );
+ } else {
+ Status = gBS->UninstallMultipleProtocolInterfaces (
+ &DriverBindingHandle,
+ &gEfiDriverBindingProtocolGuid, (EFI_DRIVER_BINDING_PROTOCOL *)_gDriverModelProtocolList[0].DriverBinding,
+ &gEfiComponentName2ProtocolGuid, (EFI_COMPONENT_NAME2_PROTOCOL *)_gDriverModelProtocolList[0].ComponentName2,
+ &gEfiDriverConfiguration2ProtocolGuid, (EFI_DRIVER_CONFIGURATION2_PROTOCOL *)_gDriverModelProtocolList[0].DriverConfiguration2,
+ &gEfiDriverDiagnostics2ProtocolGuid, (EFI_DRIVER_DIAGNOSTICS2_PROTOCOL *)_gDriverModelProtocolList[0].DriverDiagnostics2,
+ NULL
+ );
+ }
+ }
+ }
+ } // selection == 2 or 3
+
+ //
+ // ASSERT if the call to UninstallMultipleProtocolInterfaces() failed
+ //
+ ASSERT_EFI_ERROR (Status);
+
+ return EFI_SUCCESS;
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDriverModelLib/UefiDriverModelLib.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDriverModelLib/UefiDriverModelLib.inf
new file mode 100644
index 0000000..9b335a8
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiDriverModelLib/UefiDriverModelLib.inf
@@ -0,0 +1,65 @@
+#/*++
+#
+# Copyright (c) 2006, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# UefiDriverModelLib.inf
+#
+# Abstract:
+#
+# Component description file for UefiDriverModelLib.inf
+#
+#--*/
+
+[defines]
+BASE_NAME = EdkIIGlueUefiDriverModelLib
+COMPONENT_TYPE = LIBRARY
+
+[sources.common]
+ UefiDriverModelLib.c
+
+[sources.ia32]
+
+[sources.ipf,sources.x64]
+
+[includes.common]
+ $(EDK_SOURCE)\Foundation\Framework
+ $(EDK_SOURCE)\Foundation
+ $(EDK_SOURCE)\Foundation\Efi
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)\Foundation\Library\EdkIIGlueLib\Include
+ $(EDK_SOURCE)\Foundation\Core
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+ $(EDK_SOURCE)\Foundation\Include\Pei
+ $(EDK_SOURCE)\Foundation\Library\Pei\Include
+
+[libraries.common]
+ EdkIIGlueUefiBootServicesTableLib
+
+[nmake.common]
+ C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION
+ LIB_STD_FLAGS = /NOLOGO /IGNORE:4006
+
+[nmake.ia32]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32
+
+[nmake.x64]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64
+
+[nmake.ipf]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF
+
+[nmake.ebc]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiLib/Console.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiLib/Console.c
new file mode 100644
index 0000000..a8a0635
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiLib/Console.c
@@ -0,0 +1,288 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ Console.c
+
+Abstract:
+
+ UEFI library functions.
+
+--*/
+
+#include "EdkIIGlueUefi.h"
+
+typedef struct {
+ CHAR16 WChar;
+ UINT32 Width;
+} UNICODE_WIDTH_ENTRY;
+
+UNICODE_WIDTH_ENTRY mUnicodeWidthTable[] = {
+ //
+ // General script area
+ //
+ {(CHAR16)0x1FFF, 1},
+ /*
+ * Merge the blocks and replace them with the above entry as they fall to
+ * the same category and they are all narrow glyph. This will reduce search
+ * time and table size. The merge will omit the reserved code.
+ *
+ * Remove the above item if below is un-commented.
+ *
+ {(CHAR16)0x007F, 1}, // C0 controls and basic Latin. 0x0000-0x007F
+ {(CHAR16)0x00FF, 1}, // C1 controls and Latin-1 support. 0x0080-0x00FF
+ {(CHAR16)0x017F, 1}, // Latin extended-A. 0x0100-0x017F
+ {(CHAR16)0x024F, 1}, // Latin extended-B. 0x0180-0x024F
+ {(CHAR16)0x02AF, 1}, // IPA extensions. 0x0250-0x02AF
+ {(CHAR16)0x02FF, 1}, // Spacing modifier letters. 0x02B0-0x02FF
+ {(CHAR16)0x036F, 1}, // Combining diacritical marks. 0x0300-0x036F
+ {(CHAR16)0x03FF, 1}, // Greek. 0x0370-0x03FF
+ {(CHAR16)0x04FF, 1}, // Cyrillic. 0x0400-0x04FF
+ {(CHAR16)0x052F, 0}, // Unassigned. As Armenian in ver3.0. 0x0500-0x052F
+ {(CHAR16)0x058F, 1}, // Armenian. 0x0530-0x058F
+ {(CHAR16)0x05FF, 1}, // Hebrew. 0x0590-0x05FF
+ {(CHAR16)0x06FF, 1}, // Arabic. 0x0600-0x06FF
+ {(CHAR16)0x08FF, 0}, // Unassigned. 0x0700-0x08FF
+ {(CHAR16)0x097F, 1}, // Devanagari. 0x0900-0x097F
+ {(CHAR16)0x09FF, 1}, // Bengali. 0x0980-0x09FF
+ {(CHAR16)0x0A7F, 1}, // Gurmukhi. 0x0A00-0x0A7F
+ {(CHAR16)0x0AFF, 1}, // Gujarati. 0x0A80-0x0AFF
+ {(CHAR16)0x0B7F, 1}, // Oriya. 0x0B00-0x0B7F
+ {(CHAR16)0x0BFF, 1}, // Tamil. (See page 7-92). 0x0B80-0x0BFF
+ {(CHAR16)0x0C7F, 1}, // Telugu. 0x0C00-0x0C7F
+ {(CHAR16)0x0CFF, 1}, // Kannada. (See page 7-100). 0x0C80-0x0CFF
+ {(CHAR16)0x0D7F, 1}, // Malayalam (See page 7-104). 0x0D00-0x0D7F
+ {(CHAR16)0x0DFF, 0}, // Unassigned. 0x0D80-0x0DFF
+ {(CHAR16)0x0E7F, 1}, // Thai. 0x0E00-0x0E7F
+ {(CHAR16)0x0EFF, 1}, // Lao. 0x0E80-0x0EFF
+ {(CHAR16)0x0FBF, 1}, // Tibetan. 0x0F00-0x0FBF
+ {(CHAR16)0x109F, 0}, // Unassigned. 0x0FC0-0x109F
+ {(CHAR16)0x10FF, 1}, // Georgian. 0x10A0-0x10FF
+ {(CHAR16)0x11FF, 1}, // Hangul Jamo. 0x1100-0x11FF
+ {(CHAR16)0x1DFF, 0}, // Unassigned. 0x1200-0x1DFF
+ {(CHAR16)0x1EFF, 1}, // Latin extended additional. 0x1E00-0x1EFF
+ {(CHAR16)0x1FFF, 1}, // Greek extended. 0x1F00-0x1FFF
+ *
+ */
+
+ //
+ // Symbol area
+ //
+ {(CHAR16)0x2FFF, 1},
+ /*
+ * Merge the blocks and replace them with the above entry as they fall to
+ * the same category and they are all narrow glyph. This will reduce search
+ * time and table size. The merge will omit the reserved code.
+ *
+ * Remove the above item if below is un-commented.
+ *
+ {(CHAR16)0x206F, 1}, // General punctuation. (See page7-154). 0x200-0x206F
+ {(CHAR16)0x209F, 1}, // Superscripts and subscripts. 0x2070-0x209F
+ {(CHAR16)0x20CF, 1}, // Currency symbols. 0x20A0-0x20CF
+ {(CHAR16)0x20FF, 1}, // Combining diacritical marks for symbols. 0x20D0-0x20FF
+ {(CHAR16)0x214F, 1}, // Letterlike sympbols. 0x2100-0x214F
+ {(CHAR16)0x218F, 1}, // Number forms. 0x2150-0x218F
+ {(CHAR16)0x21FF, 1}, // Arrows. 0x2190-0x21FF
+ {(CHAR16)0x22FF, 1}, // Mathematical operators. 0x2200-0x22FF
+ {(CHAR16)0x23FF, 1}, // Miscellaneous technical. 0x2300-0x23FF
+ {(CHAR16)0x243F, 1}, // Control pictures. 0x2400-0x243F
+ {(CHAR16)0x245F, 1}, // Optical character recognition. 0x2440-0x245F
+ {(CHAR16)0x24FF, 1}, // Enclosed alphanumerics. 0x2460-0x24FF
+ {(CHAR16)0x257F, 1}, // Box drawing. 0x2500-0x257F
+ {(CHAR16)0x259F, 1}, // Block elements. 0x2580-0x259F
+ {(CHAR16)0x25FF, 1}, // Geometric shapes. 0x25A0-0x25FF
+ {(CHAR16)0x26FF, 1}, // Miscellaneous symbols. 0x2600-0x26FF
+ {(CHAR16)0x27BF, 1}, // Dingbats. 0x2700-0x27BF
+ {(CHAR16)0x2FFF, 0}, // Reserved. 0x27C0-0x2FFF
+ *
+ */
+
+ //
+ // CJK phonetics and symbol area
+ //
+ {(CHAR16)0x33FF, 2},
+ /*
+ * Merge the blocks and replace them with the above entry as they fall to
+ * the same category and they are all wide glyph. This will reduce search
+ * time and table size. The merge will omit the reserved code.
+ *
+ * Remove the above item if below is un-commented.
+ *
+ {(CHAR16)0x303F, 2}, // CJK symbols and punctuation. 0x3000-0x303F
+ {(CHAR16)0x309F, 2}, // Hiragana. 0x3040-0x309F
+ {(CHAR16)0x30FF, 2}, // Katakana. 0x30A0-0x30FF
+ {(CHAR16)0x312F, 2}, // Bopomofo. 0x3100-0x312F
+ {(CHAR16)0x318F, 2}, // Hangul compatibility jamo. 0x3130-0x318F
+ {(CHAR16)0x319F, 2}, // Kanbun. 0x3190-0x319F
+ {(CHAR16)0x31FF, 0}, // Reserved. As Bopomofo extended in ver3.0. 0x31A0-0x31FF
+ {(CHAR16)0x32FF, 2}, // Enclosed CJK letters and months. 0x3200-0x32FF
+ {(CHAR16)0x33FF, 2}, // CJK compatibility. 0x3300-0x33FF
+ *
+ */
+
+ //
+ // CJK ideograph area
+ //
+ {(CHAR16)0x9FFF, 2},
+ /*
+ * Merge the blocks and replace them with the above entry as they fall to
+ * the same category and they are all wide glyph. This will reduce search
+ * time and table size. The merge will omit the reserved code.
+ *
+ * Remove the above item if below is un-commented.
+ *
+ {(CHAR16)0x4DFF, 0}, // Reserved. 0x3400-0x4DBF as CJK unified ideographs
+ // extension A in ver3.0. 0x3400-0x4DFF
+ {(CHAR16)0x9FFF, 2}, // CJK unified ideographs. 0x4E00-0x9FFF
+ *
+ */
+
+ //
+ // Reserved
+ //
+ {(CHAR16)0xABFF, 0}, // Reserved. 0xA000-0xA490 as Yi syllables. 0xA490-0xA4D0
+ // as Yi radicals in ver3.0. 0xA000-0xABFF
+ //
+ // Hangul syllables
+ //
+ {(CHAR16)0xD7FF, 2},
+ /*
+ * Merge the blocks and replace them with the above entry as they fall to
+ * the same category and they are all wide glyph. This will reduce search
+ * time and table size. The merge will omit the reserved code.
+ *
+ * Remove the above item if below is un-commented.
+ *
+ {(CHAR16)0xD7A3, 2}, // Hangul syllables. 0xAC00-0xD7A3
+ {(CHAR16)0xD7FF, 0}, // Reserved. 0xD7A3-0xD7FF
+ *
+ */
+
+ //
+ // Surrogates area
+ //
+ {(CHAR16)0xDFFF, 0}, // Surrogates, not used now. 0xD800-0xDFFF
+
+ //
+ // Private use area
+ //
+ {(CHAR16)0xF8FF, 0}, // Private use area. 0xE000-0xF8FF
+
+ //
+ // Compatibility area and specials
+ //
+ {(CHAR16)0xFAFF, 2}, // CJK compatibility ideographs. 0xF900-0xFAFF
+ {(CHAR16)0xFB4F, 1}, // Alphabetic presentation forms. 0xFB00-0xFB4F
+ {(CHAR16)0xFDFF, 1}, // Arabic presentation forms-A. 0xFB50-0xFDFF
+ {(CHAR16)0xFE1F, 0}, // Reserved. As variation selectors in ver3.0. 0xFE00-0xFE1F
+ {(CHAR16)0xFE2F, 1}, // Combining half marks. 0xFE20-0xFE2F
+ {(CHAR16)0xFE4F, 2}, // CJK compatibility forms. 0xFE30-0xFE4F
+ {(CHAR16)0xFE6F, 1}, // Small Form Variants. 0xFE50-0xFE6F
+ {(CHAR16)0xFEFF, 1}, // Arabic presentation forms-B. 0xFE70-0xFEFF
+ {(CHAR16)0xFFEF, 1}, // Half width and full width forms. 0xFF00-0xFFEF
+ {(CHAR16)0xFFFF, 0}, // Speicials. 0xFFF0-0xFFFF
+};
+
+/**
+ This function computes and returns the width of the Unicode character
+ specified by UnicodeChar.
+
+ @param UnicodeChar A Unicode character.
+
+ @retval 0 The width if UnicodeChar could not be determined.
+ @retval 1 UnicodeChar is a narrow glyph.
+ @retval 2 UnicodeChar is a wide glyph.
+
+**/
+UINTN
+EFIAPI
+GlueGetGlyphWidth (
+ IN CHAR16 UnicodeChar
+ )
+{
+ UINTN Index;
+ UINTN Low;
+ UINTN High;
+ UNICODE_WIDTH_ENTRY *Item;
+
+ Item = NULL;
+ Low = 0;
+ High = (sizeof (mUnicodeWidthTable)) / (sizeof (UNICODE_WIDTH_ENTRY)) - 1;
+ while (Low <= High) {
+ Index = (Low + High) >> 1;
+ Item = &(mUnicodeWidthTable[Index]);
+ if (Index == 0) {
+ if (UnicodeChar <= Item->WChar) {
+ break;
+ }
+
+ return 0;
+ }
+
+ if (UnicodeChar > Item->WChar) {
+ Low = Index + 1;
+ } else if (UnicodeChar <= mUnicodeWidthTable[Index - 1].WChar) {
+ High = Index - 1;
+ } else {
+ //
+ // Index - 1 < UnicodeChar <= Index. Found
+ //
+ break;
+ }
+ }
+
+ if (Low <= High) {
+ return Item->Width;
+ }
+
+ return 0;
+}
+
+/**
+ This function computes and returns the display length of
+ the Null-terminated Unicode string specified by String.
+ If String is NULL, then 0 is returned.
+ If any of the widths of the Unicode characters in String
+ can not be determined, then 0 is returned.
+
+ @param String A pointer to a Null-terminated Unicode string.
+
+ @return The display length of the Null-terminated Unicode string specified by String.
+
+**/
+UINTN
+EFIAPI
+UnicodeStringDisplayLength (
+ IN CONST CHAR16 *String
+ )
+{
+ UINTN Length;
+ UINTN Width;
+
+ if (String == NULL) {
+ return 0;
+ }
+
+ Length = 0;
+ while (*String != 0) {
+ Width = GetGlyphWidth (*String);
+ if (Width == 0) {
+ return 0;
+ }
+
+ Length += Width;
+ String++;
+ }
+
+ return Length;
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiLib/EdkIIGlueUefiLib.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiLib/EdkIIGlueUefiLib.cif
new file mode 100644
index 0000000..cc3905c
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiLib/EdkIIGlueUefiLib.cif
@@ -0,0 +1,13 @@
+<component>
+ name = "EdkIIGlueUefiLib"
+ category = ModulePart
+ LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\UefiLib"
+ RefName = "EdkIIGlueUefiLib"
+[files]
+"EdkIIGlueUefiLib.sdl"
+"EdkIIGlueUefiLib.mak"
+"UefiLib.inf"
+"UefiLib.c"
+"Console.c"
+"UefiNotTiano.c"
+<endComponent>
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiLib/EdkIIGlueUefiLib.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiLib/EdkIIGlueUefiLib.mak
new file mode 100644
index 0000000..0c9f282
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiLib/EdkIIGlueUefiLib.mak
@@ -0,0 +1,80 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueUefiLib/EdkIIGlueUefiLib.mak 1 1/20/12 3:58a Jeffch $
+#
+# $Revision: 1 $
+#
+# $Date: 1/20/12 3:58a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueUefiLib/EdkIIGlueUefiLib.mak $
+#
+# 1 1/20/12 3:58a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 9/27/11 6:20a Wesleychen
+# Intel EDK initially releases.
+#
+# 1 9/18/09 1:59a Iminglin
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: EdkIIGlueUefiLib.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+
+
+$(EdkIIGlueUefiLib_LIB) : EdkIIGlueUefiLib
+
+EdkIIGlueUefiLib : $(BUILD_DIR)\EdkIIGlueUefiLib.mak EdkIIGlueUefiLibBin
+
+$(BUILD_DIR)\EdkIIGlueUefiLib.mak : $(EdkIIGlueUefiLib_DIR)\$(@B).cif $(EdkIIGlueUefiLib_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(EdkIIGlueUefiLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+EdkIIGlueUefiLibBin : $(EdkIIGlueBaseLib_LIB) $(EdkIIGlueBaseMemoryLib_LIB) $(EdkIIGlueUefiBootServicesTableLib_LIB) $(EdkIIGlueDxeMemoryAllocationLib_LIB) $(EFIGUIDLIB)
+!IF "$(x64_BUILD)"=="1"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGlueUefiLib.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueUefiLib_LIB)"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\IA32\
+ /f $(BUILD_DIR)\EdkIIGlueUefiLib.mak all\
+ TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueUefiLib_LIB)"
+!ELSE
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGlueUefiLib.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueUefiLib_LIB)"
+!ENDIF
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiLib/EdkIIGlueUefiLib.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiLib/EdkIIGlueUefiLib.sdl
new file mode 100644
index 0000000..57d5e42
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiLib/EdkIIGlueUefiLib.sdl
@@ -0,0 +1,26 @@
+TOKEN
+ Name = "EdkIIGlueUefiLib_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable EdkIIGlueUefiLib support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "EdkIIGlueUefiLib_LIB"
+ Value = "$$(LIB_BUILD_DIR)\EdkIIGlueUefiLib.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "EdkIIGlueUefiLib_DIR"
+End
+
+MODULE
+ Help = "Includes EdkIIGlueUefiLib.mak to Project"
+ File = "EdkIIGlueUefiLib.mak"
+End
+
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiLib/UefiLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiLib/UefiLib.c
new file mode 100644
index 0000000..0174a82
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiLib/UefiLib.c
@@ -0,0 +1,948 @@
+/*++
+
+Copyright (c) 2004 - 2011, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+**/
+
+#include "EdkIIGlueUefi.h"
+#include "Library\EdkIIGlueMemoryAllocationLib.h"
+
+
+/**
+ This function searches the list of configuration tables stored in the EFI System
+ Table for a table with a GUID that matches TableGuid. If a match is found,
+ then a pointer to the configuration table is returned in Table, and EFI_SUCCESS
+ is returned. If a matching GUID is not found, then EFI_NOT_FOUND is returned.
+
+ @param TableGuid Pointer to table's GUID type..
+ @param Table Pointer to the table associated with TableGuid in the EFI System Table.
+
+ @retval EFI_SUCCESS A configuration table matching TableGuid was found.
+ @retval EFI_NOT_FOUND A configuration table matching TableGuid could not be found.
+
+**/
+EFI_STATUS
+EFIAPI
+EfiGetSystemConfigurationTable (
+ IN EFI_GUID *TableGuid,
+ OUT VOID **Table
+ )
+{
+ EFI_SYSTEM_TABLE *SystemTable;
+ UINTN Index;
+
+ ASSERT (TableGuid != NULL);
+ ASSERT (Table != NULL);
+
+ SystemTable = gST;
+ *Table = NULL;
+ for (Index = 0; Index < SystemTable->NumberOfTableEntries; Index++) {
+ if (CompareGuid (TableGuid, &(SystemTable->ConfigurationTable[Index].VendorGuid))) {
+ *Table = SystemTable->ConfigurationTable[Index].VendorTable;
+ return EFI_SUCCESS;
+ }
+ }
+
+ return EFI_NOT_FOUND;
+}
+
+/**
+ This function causes the notification function to be executed for every protocol
+ of type ProtocolGuid instance that exists in the system when this function is
+ invoked. In addition, every time a protocol of type ProtocolGuid instance is
+ installed or reinstalled, the notification function is also executed.
+
+ @param ProtocolGuid Supplies GUID of the protocol upon whose installation the event is fired.
+ @param NotifyTpl Supplies the task priority level of the event notifications.
+ @param NotifyFunction Supplies the function to notify when the event is signaled.
+ @param NotifyContext The context parameter to pass to NotifyFunction.
+ @param Registration A pointer to a memory location to receive the registration value.
+
+ @return The notification event that was created.
+
+**/
+EFI_EVENT
+EFIAPI
+EfiCreateProtocolNotifyEvent(
+ IN EFI_GUID *ProtocolGuid,
+ IN EFI_TPL NotifyTpl,
+ IN EFI_EVENT_NOTIFY NotifyFunction,
+ IN VOID *NotifyContext, OPTIONAL
+ OUT VOID **Registration
+ )
+{
+ EFI_STATUS Status;
+ EFI_EVENT Event;
+
+ //
+ // Create the event
+ //
+
+ Status = gBS->CreateEvent (
+ EFI_EVENT_NOTIFY_SIGNAL,
+ NotifyTpl,
+ NotifyFunction,
+ NotifyContext,
+ &Event
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // Register for protocol notifactions on this event
+ //
+
+ Status = gBS->RegisterProtocolNotify (
+ ProtocolGuid,
+ Event,
+ Registration
+ );
+
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // Kick the event so we will perform an initial pass of
+ // current installed drivers
+ //
+
+ gBS->SignalEvent (Event);
+ return Event;
+}
+
+/**
+ This function creates an event using NotifyTpl, NoifyFunction, and NotifyContext.
+ This event is signaled with EfiNamedEventSignal(). This provide the ability for
+ one or more listeners on the same event named by the GUID specified by Name.
+
+ @param Name Supplies GUID name of the event.
+ @param NotifyTpl Supplies the task priority level of the event notifications.
+ @param NotifyFunction Supplies the function to notify when the event is signaled.
+ @param NotifyContext The context parameter to pass to NotifyFunction.
+ @param Registration A pointer to a memory location to receive the registration value.
+
+ @retval EFI_SUCCESS A named event was created.
+ @retval EFI_OUT_OF_RESOURCES There are not enough resource to create the named event.
+
+**/
+EFI_STATUS
+EFIAPI
+EfiNamedEventListen (
+ IN CONST EFI_GUID *Name,
+ IN EFI_TPL NotifyTpl,
+ IN EFI_EVENT_NOTIFY NotifyFunction,
+ IN CONST VOID *NotifyContext, OPTIONAL
+ OUT VOID *Registration OPTIONAL
+ )
+{
+ EFI_STATUS Status;
+ EFI_EVENT Event;
+ VOID *RegistrationLocal;
+
+ //
+ // Create event
+ //
+ Status = gBS->CreateEvent (
+ EFI_EVENT_NOTIFY_SIGNAL,
+ NotifyTpl,
+ NotifyFunction,
+ (VOID *) NotifyContext,
+ &Event
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // The Registration is not optional to RegisterProtocolNotify().
+ // To make it optional to EfiNamedEventListen(), may need to substitute with a local.
+ //
+ if (Registration != NULL) {
+ RegistrationLocal = Registration;
+ } else {
+ RegistrationLocal = &RegistrationLocal;
+ }
+
+ //
+ // Register for an installation of protocol interface
+ //
+
+ Status = gBS->RegisterProtocolNotify (
+ (EFI_GUID *) Name,
+ Event,
+ RegistrationLocal
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ return EFI_SUCCESS;
+}
+
+/**
+ This function signals the named event specified by Name. The named event must
+ have been created with EfiNamedEventListen().
+
+ @param Name Supplies GUID name of the event.
+
+ @retval EFI_SUCCESS A named event was signaled.
+ @retval EFI_OUT_OF_RESOURCES There are not enough resource to signal the named event.
+
+**/
+EFI_STATUS
+EFIAPI
+EfiNamedEventSignal (
+ IN CONST EFI_GUID *Name
+ )
+{
+ EFI_STATUS Status;
+ EFI_HANDLE Handle;
+
+ Handle = NULL;
+ Status = gBS->InstallProtocolInterface (
+ &Handle,
+ (EFI_GUID *) Name,
+ EFI_NATIVE_INTERFACE,
+ NULL
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ Status = gBS->UninstallProtocolInterface (
+ Handle,
+ (EFI_GUID *) Name,
+ NULL
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Returns the current TPL.
+
+ This function returns the current TPL. There is no EFI service to directly
+ retrieve the current TPL. Instead, the RaiseTPL() function is used to raise
+ the TPL to TPL_HIGH_LEVEL. This will return the current TPL. The TPL level
+ can then immediately be restored back to the current TPL level with a call
+ to RestoreTPL().
+
+ @param VOID
+
+ @retvale EFI_TPL The current TPL.
+
+**/
+EFI_TPL
+EFIAPI
+EfiGetCurrentTpl (
+ VOID
+ )
+{
+ EFI_TPL Tpl;
+
+ Tpl = gBS->RaiseTPL (EFI_TPL_HIGH_LEVEL);
+ gBS->RestoreTPL (Tpl);
+
+ return Tpl;
+}
+
+
+/**
+ This function initializes a basic mutual exclusion lock to the released state
+ and returns the lock. Each lock provides mutual exclusion access at its task
+ priority level. Since there is no preemption or multiprocessor support in EFI,
+ acquiring the lock only consists of raising to the locks TPL.
+
+ @param Lock A pointer to the lock data structure to initialize.
+ @param Priority EFI TPL associated with the lock.
+
+ @return The lock.
+
+**/
+EFI_LOCK *
+EFIAPI
+GlueEfiInitializeLock (
+ IN OUT EFI_LOCK *Lock,
+ IN EFI_TPL Priority
+ )
+{
+ ASSERT (Lock != NULL);
+ ASSERT (Priority <= EFI_TPL_HIGH_LEVEL);
+
+ Lock->Tpl = Priority;
+ Lock->OwnerTpl = EFI_TPL_APPLICATION;
+ Lock->Lock = EfiLockReleased ;
+ return Lock;
+}
+
+/**
+ This function raises the system's current task priority level to the task
+ priority level of the mutual exclusion lock. Then, it places the lock in the
+ acquired state.
+
+ @param Priority The task priority level of the lock.
+
+**/
+VOID
+EFIAPI
+GlueEfiAcquireLock (
+ IN EFI_LOCK *Lock
+ )
+{
+ ASSERT (Lock != NULL);
+ ASSERT (Lock->Lock == EfiLockReleased);
+
+ Lock->OwnerTpl = gBS->RaiseTPL (Lock->Tpl);
+ Lock->Lock = EfiLockAcquired;
+}
+
+/**
+ This function raises the system's current task priority level to the task
+ priority level of the mutual exclusion lock. Then, it attempts to place the
+ lock in the acquired state.
+
+ @param Lock A pointer to the lock to acquire.
+
+ @retval EFI_SUCCESS The lock was acquired.
+ @retval EFI_ACCESS_DENIED The lock could not be acquired because it is already owned.
+
+**/
+EFI_STATUS
+EFIAPI
+GlueEfiAcquireLockOrFail (
+ IN EFI_LOCK *Lock
+ )
+{
+
+ ASSERT (Lock != NULL);
+ ASSERT (Lock->Lock != EfiLockUninitialized);
+
+ if (Lock->Lock == EfiLockAcquired) {
+ //
+ // Lock is already owned, so bail out
+ //
+ return EFI_ACCESS_DENIED;
+ }
+
+ Lock->OwnerTpl = gBS->RaiseTPL (Lock->Tpl);
+
+ Lock->Lock = EfiLockAcquired;
+
+ return EFI_SUCCESS;
+}
+
+/**
+ This function transitions a mutual exclusion lock from the acquired state to
+ the released state, and restores the system's task priority level to its
+ previous level.
+
+ @param Lock A pointer to the lock to release.
+
+**/
+VOID
+EFIAPI
+GlueEfiReleaseLock (
+ IN EFI_LOCK *Lock
+ )
+{
+ EFI_TPL Tpl;
+
+ ASSERT (Lock != NULL);
+ ASSERT (Lock->Lock == EfiLockAcquired);
+
+ Tpl = Lock->OwnerTpl;
+
+ Lock->Lock = EfiLockReleased;
+
+ gBS->RestoreTPL (Tpl);
+}
+
+/**
+ Tests whether a controller handle is being managed by a specific driver.
+
+ This function tests whether the driver specified by DriverBindingHandle is
+ currently managing the controller specified by ControllerHandle. This test
+ is performed by evaluating if the the protocol specified by ProtocolGuid is
+ present on ControllerHandle and is was opened by DriverBindingHandle with an
+ attribute of EFI_OPEN_PROTOCOL_BY_DRIVER.
+ If ProtocolGuid is NULL, then ASSERT().
+
+ @param ControllerHandle A handle for a controller to test.
+ @param DriverBindingHandle Specifies the driver binding handle for the
+ driver.
+ @param ProtocolGuid Specifies the protocol that the driver specified
+ by DriverBindingHandle opens in its Start()
+ function.
+
+ @retval EFI_SUCCESS ControllerHandle is managed by the driver
+ specifed by DriverBindingHandle.
+ @retval EFI_UNSUPPORTED ControllerHandle is not managed by the driver
+ specifed by DriverBindingHandle.
+
+**/
+EFI_STATUS
+EFIAPI
+EfiTestManagedDevice (
+ IN CONST EFI_HANDLE ControllerHandle,
+ IN CONST EFI_HANDLE DriverBindingHandle,
+ IN CONST EFI_GUID *ProtocolGuid
+ )
+{
+ EFI_STATUS Status;
+ VOID *ManagedInterface;
+
+ ASSERT (ProtocolGuid != NULL);
+
+ Status = gBS->OpenProtocol (
+ ControllerHandle,
+ (EFI_GUID *) ProtocolGuid,
+ &ManagedInterface,
+ DriverBindingHandle,
+ ControllerHandle,
+ EFI_OPEN_PROTOCOL_BY_DRIVER
+ );
+ if (!EFI_ERROR (Status)) {
+ gBS->CloseProtocol (
+ ControllerHandle,
+ (EFI_GUID *) ProtocolGuid,
+ DriverBindingHandle,
+ ControllerHandle
+ );
+ return EFI_UNSUPPORTED;
+ }
+
+ if (Status != EFI_ALREADY_STARTED) {
+ return EFI_UNSUPPORTED;
+ }
+
+ return EFI_SUCCESS;
+}
+
+/**
+ Tests whether a child handle is a child device of the controller.
+
+ This function tests whether ChildHandle is one of the children of
+ ControllerHandle. This test is performed by checking to see if the protocol
+ specified by ProtocolGuid is present on ControllerHandle and opened by
+ ChildHandle with an attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
+ If ProtocolGuid is NULL, then ASSERT().
+
+ @param ControllerHandle A handle for a (parent) controller to test.
+ @param ChildHandle A child handle to test.
+ @param ConsumsedGuid Supplies the protocol that the child controller
+ opens on its parent controller.
+
+ @retval EFI_SUCCESS ChildHandle is a child of the ControllerHandle.
+ @retval EFI_UNSUPPORTED ChildHandle is not a child of the
+ ControllerHandle.
+
+**/
+EFI_STATUS
+EFIAPI
+EfiTestChildHandle (
+ IN CONST EFI_HANDLE ControllerHandle,
+ IN CONST EFI_HANDLE ChildHandle,
+ IN CONST EFI_GUID *ProtocolGuid
+ )
+{
+ EFI_STATUS Status;
+ EFI_OPEN_PROTOCOL_INFORMATION_ENTRY *OpenInfoBuffer;
+ UINTN EntryCount;
+ UINTN Index;
+
+ ASSERT (ProtocolGuid != NULL);
+
+ //
+ // Retrieve the list of agents that are consuming the specific protocol
+ // on ControllerHandle.
+ //
+ Status = gBS->OpenProtocolInformation (
+ ControllerHandle,
+ (EFI_GUID *) ProtocolGuid,
+ &OpenInfoBuffer,
+ &EntryCount
+ );
+ if (EFI_ERROR (Status)) {
+ return EFI_UNSUPPORTED;
+ }
+
+ //
+ // Inspect if ChildHandle is one of the agents.
+ //
+ Status = EFI_UNSUPPORTED;
+ for (Index = 0; Index < EntryCount; Index++) {
+ if ((OpenInfoBuffer[Index].ControllerHandle == ChildHandle) &&
+ (OpenInfoBuffer[Index].Attributes & EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER) != 0) {
+ Status = EFI_SUCCESS;
+ break;
+ }
+ }
+
+ FreePool (OpenInfoBuffer);
+ return Status;
+}
+
+/**
+ Tests whether a language code has format of ISO639-2.
+
+ @param Languages The language code to be tested.
+
+ @retval TRUE Language code format is ISO 639-2.
+ @retval FALSE Language code format is not ISO639-2.
+
+**/
+STATIC
+BOOLEAN
+IsIso639LanguageCode (
+ IN CONST CHAR8 *Languages
+ )
+{
+ UINTN Index;
+
+ //
+ // Find out format of Languages
+ //
+ for (Index = 0; Languages[Index] != 0 && Languages[Index] != ';' && Languages[Index] != '-'; Index++);
+ if (Languages[Index] != 0) {
+ //
+ // RFC4646 language code
+ //
+ return FALSE;
+ }
+
+ //
+ // No ';' and '-', it's either ISO639-2 code (list) or single RFC4646 code
+ //
+ if (Index == 2) {
+ //
+ // Single RFC4646 language code without country code, e.g. "en"
+ //
+ return FALSE;
+ }
+
+ //
+ // Languages in format of ISO639-2
+ //
+ return TRUE;
+}
+
+/**
+ Compare the first language instance of two language codes, either could be a
+ single language code or a language code list. This function assume Language1
+ and Language2 has the same language code format, i.e. either ISO639-2 or RFC4646.
+
+ @param Language1 The first language code to be tested.
+ @param Language2 The second language code to be tested.
+
+ @retval TRUE Language code match.
+ @retval FALSE Language code mismatch.
+
+**/
+STATIC
+BOOLEAN
+CompareLanguageCode (
+ IN CONST CHAR8 *Language1,
+ IN CONST CHAR8 *Language2
+ )
+{
+ UINTN Index;
+
+ //
+ // Compare first two bytes of language tag
+ //
+ if ((Language1[0] != Language2[0]) || (Language1[1] != Language2[1])) {
+ return FALSE;
+ }
+
+ if (IsIso639LanguageCode (Language1)) {
+ //
+ // ISO639-2 language code, compare the third byte of language tag
+ //
+ return (Language1[2] == Language2[2]) ? TRUE : FALSE;
+ }
+
+ //
+ // RFC4646 language code
+ //
+ for (Index = 0; Language1[Index] != 0 && Language1[Index] != ';'; Index++);
+ if ((AsciiStrnCmp (Language1, Language2, Index) == 0) && (Language2[Index] == 0 || Language2[Index] == ';')) {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+/**
+ Step to next language code of a language code list.
+
+ @param Languages The language code list to traverse.
+
+ @return Pointer to next language code or NULL terminator if it's the last one.
+
+**/
+STATIC
+CONST
+CHAR8 *
+NextSupportedLanguage (
+ IN CONST CHAR8 *Languages
+ )
+{
+ UINTN Index;
+
+ if (IsIso639LanguageCode (Languages)) {
+ //
+ // ISO639-2 language code
+ //
+ return (Languages + 3);
+ }
+
+ //
+ // Search in RFC4646 language code list
+ //
+ for (Index = 0; Languages[Index] != 0 && Languages[Index] != ';'; Index++);
+ if (Languages[Index] == ';') {
+ Index++;
+ }
+ return (Languages + Index);
+}
+
+/**
+ This function looks up a Unicode string in UnicodeStringTable. If Language is
+ a member of SupportedLanguages and a Unicode string is found in UnicodeStringTable
+ that matches the language code specified by Language, then it is returned in
+ UnicodeString.
+
+ @param Language A pointer to the ISO 639-2 language code for the
+ Unicode string to look up and return.
+ @param SupportedLanguages A pointer to the set of ISO 639-2 language codes
+ that the Unicode string table supports. Language
+ must be a member of this set.
+ @param UnicodeStringTable A pointer to the table of Unicode strings.
+ @param UnicodeString A pointer to the Unicode string from UnicodeStringTable
+ that matches the language specified by Language.
+
+ @retval EFI_SUCCESS The Unicode string that matches the language
+ specified by Language was found
+ in the table of Unicoide strings UnicodeStringTable,
+ and it was returned in UnicodeString.
+ @retval EFI_INVALID_PARAMETER Language is NULL.
+ @retval EFI_INVALID_PARAMETER UnicodeString is NULL.
+ @retval EFI_UNSUPPORTED SupportedLanguages is NULL.
+ @retval EFI_UNSUPPORTED UnicodeStringTable is NULL.
+ @retval EFI_UNSUPPORTED The language specified by Language is not a
+ member of SupportedLanguages.
+ @retval EFI_UNSUPPORTED The language specified by Language is not
+ supported by UnicodeStringTable.
+
+**/
+EFI_STATUS
+EFIAPI
+LookupUnicodeString (
+ IN CONST CHAR8 *Language,
+ IN CONST CHAR8 *SupportedLanguages,
+ IN CONST EFI_UNICODE_STRING_TABLE *UnicodeStringTable,
+ OUT CHAR16 **UnicodeString
+ )
+{
+ //
+ // Make sure the parameters are valid
+ //
+ if (Language == NULL || UnicodeString == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // If there are no supported languages, or the Unicode String Table is empty, then the
+ // Unicode String specified by Language is not supported by this Unicode String Table
+ //
+ if (SupportedLanguages == NULL || UnicodeStringTable == NULL) {
+ return EFI_UNSUPPORTED;
+ }
+
+ //
+ // Make sure Language is in the set of Supported Languages
+ //
+ while (*SupportedLanguages != 0) {
+ if (CompareLanguageCode (Language, SupportedLanguages)) {
+
+ //
+ // Search the Unicode String Table for the matching Language specifier
+ //
+ while (UnicodeStringTable->Language != NULL) {
+ if (CompareLanguageCode (Language, UnicodeStringTable->Language)) {
+
+ //
+ // A matching string was found, so return it
+ //
+ *UnicodeString = UnicodeStringTable->UnicodeString;
+ return EFI_SUCCESS;
+ }
+
+ UnicodeStringTable++;
+ }
+
+ return EFI_UNSUPPORTED;
+ }
+
+ SupportedLanguages = NextSupportedLanguage (SupportedLanguages);
+ }
+
+ return EFI_UNSUPPORTED;
+}
+
+/**
+ This function adds a Unicode string to UnicodeStringTable.
+ If Language is a member of SupportedLanguages then UnicodeString is added to
+ UnicodeStringTable. New buffers are allocated for both Language and
+ UnicodeString. The contents of Language and UnicodeString are copied into
+ these new buffers. These buffers are automatically freed when
+ FreeUnicodeStringTable() is called.
+
+ @param Language A pointer to the ISO 639-2 language code for the Unicode
+ string to add.
+ @param SupportedLanguages A pointer to the set of ISO 639-2 language codes
+ that the Unicode string table supports.
+ Language must be a member of this set.
+ @param UnicodeStringTable A pointer to the table of Unicode strings.
+ @param UnicodeString A pointer to the Unicode string to add.
+
+ @retval EFI_SUCCESS The Unicode string that matches the language
+ specified by Language was found in the table of
+ Unicode strings UnicodeStringTable, and it was
+ returned in UnicodeString.
+ @retval EFI_INVALID_PARAMETER Language is NULL.
+ @retval EFI_INVALID_PARAMETER UnicodeString is NULL.
+ @retval EFI_INVALID_PARAMETER UnicodeString is an empty string.
+ @retval EFI_UNSUPPORTED SupportedLanguages is NULL.
+ @retval EFI_ALREADY_STARTED A Unicode string with language Language is
+ already present in UnicodeStringTable.
+ @retval EFI_OUT_OF_RESOURCES There is not enough memory to add another
+ Unicode string to UnicodeStringTable.
+ @retval EFI_UNSUPPORTED The language specified by Language is not a
+ member of SupportedLanguages.
+
+**/
+EFI_STATUS
+EFIAPI
+AddUnicodeString (
+ IN CONST CHAR8 *Language,
+ IN CONST CHAR8 *SupportedLanguages,
+ IN EFI_UNICODE_STRING_TABLE **UnicodeStringTable,
+ IN CONST CHAR16 *UnicodeString
+ )
+{
+ UINTN NumberOfEntries;
+ EFI_UNICODE_STRING_TABLE *OldUnicodeStringTable;
+ EFI_UNICODE_STRING_TABLE *NewUnicodeStringTable;
+ UINTN UnicodeStringLength;
+
+ //
+ // Make sure the parameter are valid
+ //
+ if (Language == NULL || UnicodeString == NULL || UnicodeStringTable == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // If there are no supported languages, then a Unicode String can not be added
+ //
+ if (SupportedLanguages == NULL) {
+ return EFI_UNSUPPORTED;
+ }
+
+ //
+ // If the Unicode String is empty, then a Unicode String can not be added
+ //
+ if (UnicodeString[0] == 0) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // Make sure Language is a member of SupportedLanguages
+ //
+ while (*SupportedLanguages != 0) {
+ if (CompareLanguageCode (Language, SupportedLanguages)) {
+
+ //
+ // Determine the size of the Unicode String Table by looking for a NULL Language entry
+ //
+ NumberOfEntries = 0;
+ if (*UnicodeStringTable != NULL) {
+ OldUnicodeStringTable = *UnicodeStringTable;
+ while (OldUnicodeStringTable->Language != NULL) {
+ if (CompareLanguageCode (Language, OldUnicodeStringTable->Language)) {
+ return EFI_ALREADY_STARTED;
+ }
+
+ OldUnicodeStringTable++;
+ NumberOfEntries++;
+ }
+ }
+
+ //
+ // Allocate space for a new Unicode String Table. It must hold the current number of
+ // entries, plus 1 entry for the new Unicode String, plus 1 entry for the end of table
+ // marker
+ //
+ NewUnicodeStringTable = AllocatePool ((NumberOfEntries + 2) * sizeof (EFI_UNICODE_STRING_TABLE));
+ if (NewUnicodeStringTable == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ //
+ // If the current Unicode String Table contains any entries, then copy them to the
+ // newly allocated Unicode String Table.
+ //
+ if (*UnicodeStringTable != NULL) {
+ CopyMem (
+ NewUnicodeStringTable,
+ *UnicodeStringTable,
+ NumberOfEntries * sizeof (EFI_UNICODE_STRING_TABLE)
+ );
+ }
+
+ //
+ // Allocate space for a copy of the Language specifier
+ //
+ NewUnicodeStringTable[NumberOfEntries].Language = AllocateCopyPool (AsciiStrSize (Language), Language);
+ if (NewUnicodeStringTable[NumberOfEntries].Language == NULL) {
+ (gBS->FreePool) (NewUnicodeStringTable);
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ //
+ // Compute the length of the Unicode String
+ //
+ for (UnicodeStringLength = 0; UnicodeString[UnicodeStringLength] != 0; UnicodeStringLength++)
+ ;
+
+ //
+ // Allocate space for a copy of the Unicode String
+ //
+ NewUnicodeStringTable[NumberOfEntries].UnicodeString = AllocateCopyPool (
+ (UnicodeStringLength + 1) * sizeof (CHAR16),
+ UnicodeString
+ );
+ if (NewUnicodeStringTable[NumberOfEntries].UnicodeString == NULL) {
+ (gBS->FreePool) (NewUnicodeStringTable[NumberOfEntries].Language);
+ (gBS->FreePool) (NewUnicodeStringTable);
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ //
+ // Mark the end of the Unicode String Table
+ //
+ NewUnicodeStringTable[NumberOfEntries + 1].Language = NULL;
+ NewUnicodeStringTable[NumberOfEntries + 1].UnicodeString = NULL;
+
+ //
+ // Free the old Unicode String Table
+ //
+ if (*UnicodeStringTable != NULL) {
+ (gBS->FreePool) (*UnicodeStringTable);
+ }
+
+ //
+ // Point UnicodeStringTable at the newly allocated Unicode String Table
+ //
+ *UnicodeStringTable = NewUnicodeStringTable;
+
+ return EFI_SUCCESS;
+ }
+
+ SupportedLanguages = NextSupportedLanguage (SupportedLanguages);
+ }
+
+ return EFI_UNSUPPORTED;
+}
+
+/**
+ This function frees the table of Unicode strings in UnicodeStringTable.
+ If UnicodeStringTable is NULL, then EFI_SUCCESS is returned.
+ Otherwise, each language code, and each Unicode string in the Unicode string
+ table are freed, and EFI_SUCCESS is returned.
+
+ @param UnicodeStringTable A pointer to the table of Unicode strings.
+
+ @retval EFI_SUCCESS The Unicode string table was freed.
+
+**/
+EFI_STATUS
+EFIAPI
+FreeUnicodeStringTable (
+ IN EFI_UNICODE_STRING_TABLE *UnicodeStringTable
+ )
+{
+ UINTN Index;
+
+ //
+ // If the Unicode String Table is NULL, then it is already freed
+ //
+ if (UnicodeStringTable == NULL) {
+ return EFI_SUCCESS;
+ }
+
+ //
+ // Loop through the Unicode String Table until we reach the end of table marker
+ //
+ for (Index = 0; UnicodeStringTable[Index].Language != NULL; Index++) {
+
+ //
+ // Free the Language string from the Unicode String Table
+ //
+ (gBS->FreePool) (UnicodeStringTable[Index].Language);
+
+ //
+ // Free the Unicode String from the Unicode String Table
+ //
+ if (UnicodeStringTable[Index].UnicodeString != NULL) {
+ (gBS->FreePool) (UnicodeStringTable[Index].UnicodeString);
+ }
+ }
+
+ //
+ // Free the Unicode String Table itself
+ //
+ (gBS->FreePool) (UnicodeStringTable);
+
+ return EFI_SUCCESS;
+}
+
+/**
+ This function retrievesGUID name from Image Handle
+
+ @param EFI_HANDLE Image Handle.
+
+ @retval EFI_GUID* pointer to EFI_GUID.
+
+**/
+EFI_GUID *
+GetGuidFromHandle (
+ EFI_HANDLE Handle
+ )
+{
+ EFI_STATUS Status;
+ EFI_LOADED_IMAGE_PROTOCOL *pImage;
+ MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFilePath;
+
+ if (Handle != NULL) {
+ Status = gBS->HandleProtocol (
+ Handle,
+ &gEfiLoadedImageProtocolGuid,
+ &pImage
+ );
+ if (!EFI_ERROR (Status)) {
+ if (pImage->FilePath->Type == MEDIA_DEVICE_PATH && pImage->FilePath->SubType == MEDIA_FV_FILEPATH_DP) {
+ //
+ // Determine GUID
+ //
+ FvFilePath = (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) pImage->FilePath;
+
+ return &FvFilePath->NameGuid;
+ }
+ }
+ }
+
+ return NULL;
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiLib/UefiLib.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiLib/UefiLib.inf
new file mode 100644
index 0000000..8ee38ac
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiLib/UefiLib.inf
@@ -0,0 +1,87 @@
+#/*++
+#
+# Copyright (c) 2004 - 2006, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# UefiLib.inf
+#
+# Abstract:
+#
+# Component description file for UefiLib.
+#
+#--*/
+
+[defines]
+BASE_NAME = EdkIIGlueUefiLib
+COMPONENT_TYPE = LIBRARY
+
+[sources.common]
+ UefiLib.c
+ Console.c
+ UefiNotTiano.c
+
+[sources.ia32]
+
+[sources.x64]
+
+[sources.ipf]
+
+[sources.ebc]
+
+
+[includes.common]
+ .
+ ..\..\Include
+ ..\..\include\Library
+ $(EDK_SOURCE)\Foundation
+ $(EDK_SOURCE)\Foundation\Framework
+ $(EDK_SOURCE)\Foundation\Efi
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+ $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include
+
+ $(EDK_SOURCE)\Foundation\Efi\Protocol\DevicePath
+
+[libraries.common]
+ EdkIIGlueBaseLib
+ EdkIIGlueBaseMemoryLib
+ EdkIIGlueUefiBootServicesTableLib
+#
+# MemoryAllocationLib instance
+#
+ EdkIIGlueDxeMemoryAllocationLib
+ EfiGuidLib
+
+[libraries.ia32]
+
+
+[libraries.x64]
+
+
+[nmake.common]
+ C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION
+ LIB_STD_FLAGS = /NOLOGO /IGNORE:4006
+
+[nmake.ia32]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32
+
+[nmake.x64]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64
+
+[nmake.ipf]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF
+
+[nmake.ebc]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiLib/UefiNotTiano.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiLib/UefiNotTiano.c
new file mode 100644
index 0000000..67438ed
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiLib/UefiNotTiano.c
@@ -0,0 +1,366 @@
+/*++
+
+Copyright (c) 2004 - 2009, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ UefiNotTiano.c
+
+Abstract:
+
+ Library functions that abstract areas of conflict between Tiano an UEFI 2.0.
+
+ Help Port Framework/Tinao code that has conflicts with UEFI 2.0 by hiding the
+ oldconflicts with library functions and supporting implementations of the old
+ (R8.5/EFI 1.10) and new (EdkII/UEFI 2.0) way.
+
+--*/
+
+#include "EdkIIGlueUefi.h"
+
+/**
+ An empty function to pass error checking of CreateEventEx ().
+
+ This empty function ensures that EFI_EVENT_NOTIFY_SIGNAL_ALL is error
+ checked correctly since it is now mapped into CreateEventEx() in UEFI 2.0.
+
+**/
+STATIC
+VOID
+EFIAPI
+InternalEmptyFuntion (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+ return;
+}
+
+/**
+ Create a Legacy Boot Event.
+
+ Tiano extended the CreateEvent Type enum to add a legacy boot event type.
+ This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was
+ added and now it's possible to not voilate the UEFI specification by
+ declaring a GUID for the legacy boot event class. This library supports
+ the EDK/EFI 1.10 form and EDK II/UEFI 2.0 form and allows common code to
+ work both ways.
+
+ @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
+
+ @retval EFI_SUCCESS Event was created.
+ @retval Other Event was not created.
+
+**/
+EFI_STATUS
+EFIAPI
+GlueEfiCreateEventLegacyBoot (
+ OUT EFI_EVENT *LegacyBootEvent
+ )
+{
+ return EfiCreateEventLegacyBootEx (
+ EFI_TPL_CALLBACK,
+ NULL,
+ NULL,
+ LegacyBootEvent
+ );
+}
+
+/**
+ Create an EFI event in the Legacy Boot Event Group and allows
+ the caller to specify a notification function.
+
+ This function abstracts the creation of the Legacy Boot Event.
+ The Framework moved from a proprietary to UEFI 2.0 based mechanism.
+ This library abstracts the caller from how this event is created to prevent
+ to code form having to change with the version of the specification supported.
+ If LegacyBootEvent is NULL, then ASSERT().
+
+ @param NotifyTpl The task priority level of the event.
+ @param NotifyFunction The notification function to call when the event is signaled.
+ @param NotifyContext The content to pass to NotifyFunction when the event is signaled.
+ @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
+
+ @retval EFI_SUCCESS Event was created.
+ @retval Other Event was not created.
+
+**/
+EFI_STATUS
+EFIAPI
+EfiCreateEventLegacyBootEx (
+ IN EFI_TPL NotifyTpl,
+ IN EFI_EVENT_NOTIFY NotifyFunction, OPTIONAL
+ IN VOID *NotifyContext, OPTIONAL
+ OUT EFI_EVENT *LegacyBootEvent
+ )
+{
+ EFI_STATUS Status;
+ UINT32 EventType;
+ EFI_EVENT_NOTIFY WorkerNotifyFunction;
+
+ ASSERT (LegacyBootEvent != NULL);
+
+#if (EFI_SPECIFICATION_VERSION < 0x00020000)
+
+ if (NotifyFunction == NULL) {
+ EventType = EFI_EVENT_SIGNAL_LEGACY_BOOT | EFI_EVENT_NOTIFY_SIGNAL_ALL;
+ } else {
+ EventType = EFI_EVENT_SIGNAL_LEGACY_BOOT;
+ }
+ WorkerNotifyFunction = NotifyFunction;
+
+ //
+ // prior to UEFI 2.0 use Tiano extension to EFI
+ //
+ Status = gBS->CreateEvent (
+ EventType,
+ NotifyTpl,
+ WorkerNotifyFunction,
+ NotifyContext,
+ LegacyBootEvent
+ );
+#else
+
+ EventType = EVENT_NOTIFY_SIGNAL;
+ if (NotifyFunction == NULL) {
+ //
+ // CreatEventEx will check NotifyFunction is NULL or not
+ //
+ WorkerNotifyFunction = InternalEmptyFuntion;
+ } else {
+ WorkerNotifyFunction = NotifyFunction;
+ }
+
+ //
+ // For UEFI 2.0 and the future use an Event Group
+ //
+ Status = gBS->CreateEventEx (
+ EventType,
+ NotifyTpl,
+ WorkerNotifyFunction,
+ NotifyContext,
+ &gEfiEventLegacyBootGuid,
+ LegacyBootEvent
+ );
+#endif
+
+ return Status;
+}
+
+/**
+ Create a Read to Boot Event.
+
+ Tiano extended the CreateEvent Type enum to add a ready to boot event type.
+ This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was
+ added and now it's possible to not voilate the UEFI specification and use
+ the ready to boot event class defined in UEFI 2.0. This library supports
+ the EDK/EFI 1.10 form and EDK II/UEFI 2.0 form and allows common code to
+ work both ways.
+
+ @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
+
+ @retval EFI_SUCCESS Event was created.
+ @retval Other Event was not created.
+
+**/
+EFI_STATUS
+EFIAPI
+GlueEfiCreateEventReadyToBoot (
+ OUT EFI_EVENT *ReadyToBootEvent
+ )
+{
+ return EfiCreateEventReadyToBootEx (
+ EFI_TPL_CALLBACK,
+ NULL,
+ NULL,
+ ReadyToBootEvent
+ );
+}
+
+/**
+ Create an EFI event in the Ready To Boot Event Group and allows
+ the caller to specify a notification function.
+
+ This function abstracts the creation of the Ready to Boot Event.
+ The Framework moved from a proprietary to UEFI 2.0 based mechanism.
+ This library abstracts the caller from how this event is created to prevent
+ to code form having to change with the version of the specification supported.
+ If ReadyToBootEvent is NULL, then ASSERT().
+
+ @param NotifyTpl The task priority level of the event.
+ @param NotifyFunction The notification function to call when the event is signaled.
+ @param NotifyContext The content to pass to NotifyFunction when the event is signaled.
+ @param LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex).
+
+ @retval EFI_SUCCESS Event was created.
+ @retval Other Event was not created.
+
+**/
+EFI_STATUS
+EFIAPI
+EfiCreateEventReadyToBootEx (
+ IN EFI_TPL NotifyTpl,
+ IN EFI_EVENT_NOTIFY NotifyFunction, OPTIONAL
+ IN VOID *NotifyContext, OPTIONAL
+ OUT EFI_EVENT *ReadyToBootEvent
+ )
+{
+ EFI_STATUS Status;
+ UINT32 EventType;
+ EFI_EVENT_NOTIFY WorkerNotifyFunction;
+
+ ASSERT (ReadyToBootEvent != NULL);
+
+#if (EFI_SPECIFICATION_VERSION < 0x00020000)
+
+ if (NotifyFunction == NULL) {
+ EventType = EFI_EVENT_SIGNAL_READY_TO_BOOT | EFI_EVENT_NOTIFY_SIGNAL_ALL;
+ } else {
+ EventType = EFI_EVENT_SIGNAL_READY_TO_BOOT;
+ }
+ WorkerNotifyFunction = NotifyFunction;
+
+ //
+ // prior to UEFI 2.0 use Tiano extension to EFI
+ //
+ Status = gBS->CreateEvent (
+ EventType,
+ NotifyTpl,
+ WorkerNotifyFunction,
+ NotifyContext,
+ ReadyToBootEvent
+ );
+#else
+
+ EventType = EVENT_NOTIFY_SIGNAL;
+
+ if (NotifyFunction == NULL) {
+ //
+ // CreatEventEx will check NotifyFunction is NULL or not
+ //
+ WorkerNotifyFunction = InternalEmptyFuntion;
+ } else {
+ WorkerNotifyFunction = NotifyFunction;
+ }
+
+ //
+ // For UEFI 2.0 and the future use an Event Group
+ //
+ Status = gBS->CreateEventEx (
+ EventType,
+ NotifyTpl,
+ WorkerNotifyFunction,
+ NotifyContext,
+ &gEfiEventReadyToBootGuid,
+ ReadyToBootEvent
+ );
+#endif
+
+ return Status;
+}
+
+
+/**
+ Signal a Ready to Boot Event.
+
+ Create a Ready to Boot Event. Signal it and close it. This causes other
+ events of the same event group to be signaled in other modules.
+
+**/
+VOID
+EFIAPI
+EfiSignalEventReadyToBoot (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ EFI_EVENT ReadyToBootEvent;
+
+ Status = EfiCreateEventReadyToBoot (&ReadyToBootEvent);
+ if (!EFI_ERROR (Status)) {
+ gBS->SignalEvent (ReadyToBootEvent);
+ gBS->CloseEvent (ReadyToBootEvent);
+ }
+}
+
+/**
+ Signal a Legacy Boot Event.
+
+ Create a legacy Boot Event. Signal it and close it. This causes other
+ events of the same event group to be signaled in other modules.
+
+**/
+VOID
+EFIAPI
+EfiSignalEventLegacyBoot (
+ VOID
+ )
+{
+ EFI_STATUS Status;
+ EFI_EVENT LegacyBootEvent;
+
+ Status = EfiCreateEventLegacyBoot (&LegacyBootEvent);
+ if (!EFI_ERROR (Status)) {
+ gBS->SignalEvent (LegacyBootEvent);
+ gBS->CloseEvent (LegacyBootEvent);
+ }
+}
+
+
+/**
+ Check to see if the Firmware Volume (FV) Media Device Path is valid
+
+ @param FvDevicePathNode Pointer to FV device path to check.
+
+ @retval NULL FvDevicePathNode is not valid.
+ @retval Other FvDevicePathNode is valid and pointer to NameGuid was returned.
+
+**/
+EFI_GUID *
+EFIAPI
+GlueEfiGetNameGuidFromFwVolDevicePathNode (
+ IN CONST MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode
+ )
+{
+ ASSERT (FvDevicePathNode != NULL);
+
+ if (DevicePathType (&FvDevicePathNode->Header) == MEDIA_DEVICE_PATH &&
+ DevicePathSubType (&FvDevicePathNode->Header) == MEDIA_FV_FILEPATH_DP) {
+ return (EFI_GUID *) &FvDevicePathNode->NameGuid;
+ }
+
+ return NULL;
+}
+
+
+/**
+ Initialize a Firmware Volume (FV) Media Device Path node.
+
+ @param FvDevicePathNode Pointer to a FV device path node to initialize
+ @param NameGuid FV file name to use in FvDevicePathNode
+
+**/
+VOID
+EFIAPI
+GlueEfiInitializeFwVolDevicepathNode (
+ IN OUT MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode,
+ IN CONST EFI_GUID *NameGuid
+ )
+{
+ ASSERT (FvDevicePathNode != NULL);
+ ASSERT (NameGuid != NULL);
+
+ FvDevicePathNode->Header.Type = MEDIA_DEVICE_PATH;
+ FvDevicePathNode->Header.SubType = MEDIA_FV_FILEPATH_DP;
+ SetDevicePathNodeLength (&FvDevicePathNode->Header, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH));
+
+ CopyGuid (&FvDevicePathNode->NameGuid, NameGuid);
+}
+
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiRuntimeServicesTableLib/EdkIIGlueUefiRuntimeServicesTableLib.cif b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiRuntimeServicesTableLib/EdkIIGlueUefiRuntimeServicesTableLib.cif
new file mode 100644
index 0000000..96af27f
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiRuntimeServicesTableLib/EdkIIGlueUefiRuntimeServicesTableLib.cif
@@ -0,0 +1,11 @@
+<component>
+ name = "EdkIIGlueUefiRuntimeServicesTableLib"
+ category = ModulePart
+ LocalRoot = "Edk\Foundation\Library\EdkIIGlueLib\Library\UefiRuntimeServicesTableLib"
+ RefName = "EdkIIGlueUefiRuntimeServicesTableLib"
+[files]
+"EdkIIGlueUefiRuntimeServicesTableLib.sdl"
+"EdkIIGlueUefiRuntimeServicesTableLib.mak"
+"UefiRuntimeServicesTableLib.inf"
+"UefiRuntimeServicesTableLib.c"
+<endComponent>
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiRuntimeServicesTableLib/EdkIIGlueUefiRuntimeServicesTableLib.mak b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiRuntimeServicesTableLib/EdkIIGlueUefiRuntimeServicesTableLib.mak
new file mode 100644
index 0000000..6f35ac8
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiRuntimeServicesTableLib/EdkIIGlueUefiRuntimeServicesTableLib.mak
@@ -0,0 +1,80 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueUefiRuntimeServicesTableLib/EdkIIGlueUefiRuntimeServicesTableLib.mak 1 1/20/12 3:58a Jeffch $
+#
+# $Revision: 1 $
+#
+# $Date: 1/20/12 3:58a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkIIGlue/EdkIIGlueUefiRuntimeServicesTableLib/EdkIIGlueUefiRuntimeServicesTableLib.mak $
+#
+# 1 1/20/12 3:58a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 9/27/11 6:20a Wesleychen
+# Intel EDK initially releases.
+#
+# 1 9/18/09 1:59a Iminglin
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: EdkIIGlueUefiRuntimeServicesTableLib.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+
+
+$(EdkIIGlueUefiRuntimeServicesTableLib_LIB) : EdkIIGlueUefiRuntimeServicesTableLib
+
+EdkIIGlueUefiRuntimeServicesTableLib : $(BUILD_DIR)\EdkIIGlueUefiRuntimeServicesTableLib.mak EdkIIGlueUefiRuntimeServicesTableLibBin
+
+$(BUILD_DIR)\EdkIIGlueUefiRuntimeServicesTableLib.mak : $(EdkIIGlueUefiRuntimeServicesTableLib_DIR)\$(@B).cif $(EdkIIGlueUefiRuntimeServicesTableLib_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(EdkIIGlueUefiRuntimeServicesTableLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+EdkIIGlueUefiRuntimeServicesTableLibBin :
+!IF "$(x64_BUILD)"=="1"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGlueUefiRuntimeServicesTableLib.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueUefiRuntimeServicesTableLib_LIB)"
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\IA32\
+ /f $(BUILD_DIR)\EdkIIGlueUefiRuntimeServicesTableLib.mak all\
+ TYPE=PEI_LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueUefiRuntimeServicesTableLib_LIB)"
+!ELSE
+ $(MAKE) /$(MAKEFLAGS) $(EDKIIGLUE_DEFAULTS)\
+ BUILD_DIR=$(BUILD_DIR)\
+ /f $(BUILD_DIR)\EdkIIGlueUefiRuntimeServicesTableLib.mak all\
+ TYPE=LIBRARY "PARAMETERS=LIBRARY_NAME=$$(EdkIIGlueUefiRuntimeServicesTableLib_LIB)"
+!ENDIF
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#********************************************************************** \ No newline at end of file
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiRuntimeServicesTableLib/EdkIIGlueUefiRuntimeServicesTableLib.sdl b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiRuntimeServicesTableLib/EdkIIGlueUefiRuntimeServicesTableLib.sdl
new file mode 100644
index 0000000..581b351
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiRuntimeServicesTableLib/EdkIIGlueUefiRuntimeServicesTableLib.sdl
@@ -0,0 +1,26 @@
+TOKEN
+ Name = "EdkIIGlueUefiRuntimeServicesTableLib_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable EdkIIGlueUefiRuntimeServicesTableLib support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "EdkIIGlueUefiRuntimeServicesTableLib_LIB"
+ Value = "$$(LIB_BUILD_DIR)\EdkIIGlueUefiRuntimeServicesTableLib.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "EdkIIGlueUefiRuntimeServicesTableLib_DIR"
+End
+
+MODULE
+ Help = "Includes EdkIIGlueUefiRuntimeServicesTableLib.mak to Project"
+ File = "EdkIIGlueUefiRuntimeServicesTableLib.mak"
+End
+
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.c b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.c
new file mode 100644
index 0000000..f6abed4
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.c
@@ -0,0 +1,52 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ UefiRuntimeServicesTableLib.c
+
+Abstract:
+
+ UEFI Runtime Services Table Library.
+
+--*/
+
+#include "EdkIIGlueUefi.h"
+
+EFI_RUNTIME_SERVICES *gRT = NULL;
+
+/**
+ The constructor function caches the pointer of Runtime Services Table.
+
+ The constructor function caches the pointer of Runtime Services Table.
+ It will ASSERT() if the pointer of Runtime Services Table is NULL.
+ It will always return EFI_SUCCESS.
+
+ @param ImageHandle The firmware allocated handle for the EFI image.
+ @param SystemTable A pointer to the EFI System Table.
+
+ @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.
+
+**/
+EFI_STATUS
+UefiRuntimeServicesTableLibConstructor (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+{
+ //
+ // Cache pointer to the EFI Runtime Services Table
+ //
+ gRT = SystemTable->RuntimeServices;
+ ASSERT (gRT != NULL);
+ return EFI_SUCCESS;
+}
diff --git a/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf
new file mode 100644
index 0000000..f7850bd
--- /dev/null
+++ b/EDK/Foundation/Library/EdkIIGlueLib/Library/UefiRuntimeServicesTableLib/UefiRuntimeServicesTableLib.inf
@@ -0,0 +1,76 @@
+#/*++
+#
+# Copyright (c) 2004 - 2006, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# UefiRuntimeServicesTableLib.inf
+#
+# Abstract:
+#
+# Component description file for UefiRuntimeServicesTableLib.
+#
+#--*/
+
+[defines]
+BASE_NAME = EdkIIGlueUefiRuntimeServicesTableLib
+COMPONENT_TYPE = LIBRARY
+
+[sources.common]
+ UefiRuntimeServicesTableLib.c
+
+[sources.ia32]
+
+[sources.x64]
+
+[sources.ipf]
+
+[sources.ebc]
+
+
+[includes.common]
+ .
+ ..\..\Include
+ ..\..\include\Library
+ $(EDK_SOURCE)\Foundation
+ $(EDK_SOURCE)\Foundation\Framework
+ $(EDK_SOURCE)\Foundation\Efi
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+ $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include
+ $(EDK_SOURCE)\Foundation\Efi\Protocol\DevicePath
+
+[libraries.common]
+
+[libraries.ia32]
+
+
+[libraries.x64]
+
+
+[nmake.common]
+ C_FLAGS = $(C_FLAGS) /D EDKII_GLUE_LIBRARY_IMPLEMENTATION
+ LIB_STD_FLAGS = /NOLOGO /IGNORE:4006
+
+[nmake.ia32]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IA32
+
+[nmake.x64]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_X64
+
+[nmake.ipf]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_IPF
+
+[nmake.ebc]
+ C_FLAGS = $(C_FLAGS) /D MDE_CPU_EBC \ No newline at end of file
diff --git a/EDK/Foundation/Library/EfiCommonLib/EfiCommonLib.cif b/EDK/Foundation/Library/EfiCommonLib/EfiCommonLib.cif
new file mode 100644
index 0000000..fbc1774
--- /dev/null
+++ b/EDK/Foundation/Library/EfiCommonLib/EfiCommonLib.cif
@@ -0,0 +1,36 @@
+<component>
+ name = "EfiCommonLib"
+ category = ModulePart
+ LocalRoot = "EDK\Foundation\Library\EfiCommonLib\"
+ RefName = "EfiCommonLib"
+[files]
+"EfiCommonLib.sdl"
+"EfiCommonLib.mak"
+"EfiCompareGuid.c"
+"EfiCompareMem.c"
+"linkedlist.c"
+"PostCode.c"
+"ReportStatusCode.c"
+"String.c"
+"ValueToString.c"
+"EfiCopyMem.c"
+"EfiSetMem.c"
+"EfiZeroMem.c"
+"Math.c"
+"Misc.c"
+"x64\EfiCopyMemRep4.asm"
+"Ia32\DivU64x32.asm"
+"Ia32\EfiCopyMem.asm"
+"Ia32\EfiCopyMemSSE2.asm"
+"Ia32\EfiSetMem.asm"
+"Ia32\EfiSetMemSSE2.asm"
+"Ia32\EfiZeroMem.asm"
+"Ia32\EfiZeroMemSSE2.asm"
+"Ia32\GetPowerOfTwo.asm"
+"Ia32\Log2.asm"
+"Ia32\LShiftU64.asm"
+"Ia32\MultU64x32.asm"
+"Ia32\Power10U64.asm"
+"Ia32\RShiftU64.asm"
+"EfiCommonLib.inf"
+<endComponent>
diff --git a/EDK/Foundation/Library/EfiCommonLib/EfiCommonLib.inf b/EDK/Foundation/Library/EfiCommonLib/EfiCommonLib.inf
new file mode 100644
index 0000000..1410b80
--- /dev/null
+++ b/EDK/Foundation/Library/EfiCommonLib/EfiCommonLib.inf
@@ -0,0 +1,85 @@
+#/*++
+#
+# Copyright (c) 2004 - 2006, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# EfiCommonLib.inf
+#
+# Abstract:
+#
+# Component description file for the EFI common library.
+#
+#--*/
+
+[defines]
+BASE_NAME = EfiCommonLib
+COMPONENT_TYPE = LIBRARY
+
+[sources.common]
+ EfiCompareGuid.c
+ EfiCompareMem.c
+ ReportStatusCode.c
+ PostCode.c
+ String.c
+ ValueToString.c
+ LinkedList.c
+
+[sources.ia32]
+ Ia32\EfiCopyMem.asm
+ Ia32\EfiSetMem.asm
+ Ia32\EfiZeroMem.asm
+ Ia32\LShiftU64.asm
+ Ia32\RShiftU64.asm
+ Ia32\MultU64x32.asm
+ Ia32\DivU64x32.asm
+ Ia32\Power10U64.asm
+ Ia32\Log2.asm
+ Ia32\GetPowerOfTwo.asm
+
+[sources.ipf]
+ EfiCopyMem.c
+ EfiSetMem.c
+ EfiZeroMem.c
+ Math.c
+
+[sources.ebc]
+ EfiCopyMem.c
+ EfiSetMem.c
+ EfiZeroMem.c
+ Math.c
+[sources.x64]
+ x64\EfiCopyMemRep4.asm
+ EfiSetMem.c
+ EfiZeroMem.c
+ Math.c
+
+[includes.common]
+ $(EDK_SOURCE)\Foundation
+ $(EDK_SOURCE)\Foundation\Framework
+ $(EDK_SOURCE)\Foundation\Efi
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+ $(EDK_SOURCE)\Foundation\Include\Pei
+ $(EDK_SOURCE)\Foundation\Library\Pei\Include
+ $(EDK_SOURCE)\Foundation\Core\Pei\Include
+ $(EDK_SOURCE)\Foundation\Framework\Ppi\CpuIo
+ $(EDK_SOURCE)\Foundation\Framework
+
+[libraries.common]
+ EdkFrameworkGuidLib
+
+[nmake.common]
+ C_STD_INCLUDE=
diff --git a/EDK/Foundation/Library/EfiCommonLib/EfiCommonLib.mak b/EDK/Foundation/Library/EfiCommonLib/EfiCommonLib.mak
new file mode 100644
index 0000000..e7ba070
--- /dev/null
+++ b/EDK/Foundation/Library/EfiCommonLib/EfiCommonLib.mak
@@ -0,0 +1,123 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EfiCommonLib/EfiCommonLib.mak 1 1/20/12 4:10a Jeffch $
+#
+# $Revision: 1 $
+#
+# $Date: 1/20/12 4:10a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EfiCommonLib/EfiCommonLib.mak $
+#
+# 1 1/20/12 4:10a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 9/27/11 6:31a Wesleychen
+# Intel EDK initially releases.
+#
+# 3 11/06/09 4:28a Iminglin
+# Edk-Dev-Snapshot-20090928
+#
+# 2 9/02/09 3:56a Iminglin
+# EIP24919
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: EfiCommonLib.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+$(EFICOMMONLIB) : EfiCommonLib
+
+EFI_COMMON_LIB_OBJECTS=\
+$$(BUILD_DIR)\$(EfiCommonLib_DIR)\EfiCompareGuid.obj\
+$$(BUILD_DIR)\$(EfiCommonLib_DIR)\EfiCompareMem.obj\
+$$(BUILD_DIR)\$(EfiCommonLib_DIR)\linkedlist.obj\
+$$(BUILD_DIR)\$(EfiCommonLib_DIR)\PostCode.obj\
+$$(BUILD_DIR)\$(EfiCommonLib_DIR)\ReportStatusCode.obj\
+$$(BUILD_DIR)\$(EfiCommonLib_DIR)\String.obj\
+$$(BUILD_DIR)\$(EfiCommonLib_DIR)\ValueToString.obj\
+$$(BUILD_DIR)\$(EfiCommonLib_DIR)\Misc.obj
+
+EFI_COMMON_LIB_IA32_OBJECTS=\
+$$(BUILD_DIR)\$(EfiCommonLib_DIR)\Ia32\EfiCopyMemSSE2.obj\
+$$(BUILD_DIR)\$(EfiCommonLib_DIR)\Ia32\EfiSetMemSSE2.obj\
+$$(BUILD_DIR)\$(EfiCommonLib_DIR)\Ia32\EfiZeroMemSSE2.obj\
+$$(BUILD_DIR)\$(EfiCommonLib_DIR)\Ia32\LShiftU64.obj\
+$$(BUILD_DIR)\$(EfiCommonLib_DIR)\Ia32\RShiftU64.obj\
+$$(BUILD_DIR)\$(EfiCommonLib_DIR)\Ia32\MultU64x32.obj\
+$$(BUILD_DIR)\$(EfiCommonLib_DIR)\Ia32\DivU64x32.obj\
+$$(BUILD_DIR)\$(EfiCommonLib_DIR)\Ia32\Power10U64.obj\
+$$(BUILD_DIR)\$(EfiCommonLib_DIR)\Ia32\Log2.obj\
+$$(BUILD_DIR)\$(EfiCommonLib_DIR)\Ia32\GetPowerOfTwo.obj
+
+!IF "$(PROCESSOR)"=="IA32"
+EFI_COMMON_LIB_OBJECTS=$(EFI_COMMON_LIB_OBJECTS) $(EFI_COMMON_LIB_IA32_OBJECTS)
+!ELSEIF "$(PROCESSOR)"=="x64"
+EFI_COMMON_LIB_PEI_OBJECTS=$(EFI_COMMON_LIB_OBJECTS) $(EFI_COMMON_LIB_IA32_OBJECTS)
+EFI_COMMON_LIB_DXE_OBJECTS=$(EFI_COMMON_LIB_OBJECTS)\
+$$(BUILD_DIR)\$(EfiCommonLib_DIR)\x64\EfiCopyMemRep4.obj\
+$$(BUILD_DIR)\$(EfiCommonLib_DIR)\EfiSetMem.obj\
+$$(BUILD_DIR)\$(EfiCommonLib_DIR)\EfiZeroMem.obj\
+$$(BUILD_DIR)\$(EfiCommonLib_DIR)\Math.obj
+!ELSEIF "$(PROCESSOR)"=="IPF" || "$(PROCESSOR)"=="EBC"
+EFI_COMMON_LIB_OBJECTS=$(EFI_COMMON_LIB_OBJECTS)\
+$$(BUILD_DIR)\$(EfiCommonLib_DIR)\EfiCopyMem.obj\
+$$(BUILD_DIR)\$(EfiCommonLib_DIR)\EfiSetMem.obj\
+$$(BUILD_DIR)\$(EfiCommonLib_DIR)\EfiZeroMem.obj\
+$$(BUILD_DIR)\$(EfiCommonLib_DIR)\Math.obj
+!ENDIF
+
+$(EFICOMMONLIB) : EfiCommonLib
+
+EfiCommonLib : $(BUILD_DIR)\EfiCommonLib.mak EfiCommonLibBin
+
+$(BUILD_DIR)\EfiCommonLib.mak : $(EfiCommonLib_DIR)\$(@B).cif $(EfiCommonLib_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(EfiCommonLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+EfiCommonLibBin : $(EDKFRAMEWORKGUIDLIB) $(COMPILERSTUB)
+!IF "$(PROCESSOR)"=="x64"
+ $(MAKE) /$(MAKEFLAGS) $(EDK_DEFAULTS)\
+ /f $(BUILD_DIR)\EfiCommonLib.mak all\
+ "MY_INCLUDES=/I$(EDK_SOURCE)\Foundation\Framework\Ppi\CpuIo" \
+ TYPE=LIBRARY "OBJECTS=$(EFI_COMMON_LIB_DXE_OBJECTS)"
+ $(MAKE) /$(MAKEFLAGS) $(EDK_DEFAULTS) BUILD_DIR=$(BUILD_DIR)\IA32\
+ /f $(BUILD_DIR)\EfiCommonLib.mak all\
+ "MY_INCLUDES=/I$(EDK_SOURCE)\Foundation\Framework\Ppi\CpuIo" \
+ TYPE=PEI_LIBRARY "OBJECTS=$(EFI_COMMON_LIB_PEI_OBJECTS)"
+!ELSE
+ $(MAKE) /$(MAKEFLAGS) $(EDK_DEFAULTS)\
+ /f $(BUILD_DIR)\EfiCommonLib.mak all\
+ "MY_INCLUDES=/I$(EDK_SOURCE)\Foundation\Framework\Ppi\CpuIo" \
+ TYPE=LIBRARY "OBJECTS=$(EFI_COMMON_LIB_OBJECTS)"
+!ENDIF
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#********************************************************************** \ No newline at end of file
diff --git a/EDK/Foundation/Library/EfiCommonLib/EfiCommonLib.sdl b/EDK/Foundation/Library/EfiCommonLib/EfiCommonLib.sdl
new file mode 100644
index 0000000..c6b970e
--- /dev/null
+++ b/EDK/Foundation/Library/EfiCommonLib/EfiCommonLib.sdl
@@ -0,0 +1,31 @@
+TOKEN
+ Name = "EfiCommonLib_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable EfiCommonLib support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "EFICOMMONLIB"
+ Value = "$$(LIB_BUILD_DIR)\EfiCommonLib.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "EfiCommonLib_DIR"
+End
+
+MODULE
+ Help = "Includes EfiCommonLib.mak to Project"
+ File = "EfiCommonLib.mak"
+End
+
+ELINK
+ Name = "/D SUPPORT_DEPRECATED_PCI_CFG_PPI"
+ Parent = "GLOBAL_DEFINES"
+ InvokeOrder = AfterParent
+End
diff --git a/EDK/Foundation/Library/EfiCommonLib/EfiCompareGuid.c b/EDK/Foundation/Library/EfiCommonLib/EfiCompareGuid.c
new file mode 100644
index 0000000..138aad6
--- /dev/null
+++ b/EDK/Foundation/Library/EfiCommonLib/EfiCompareGuid.c
@@ -0,0 +1,59 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiCompareGuid.c
+
+Abstract:
+
+ Driver library routine to compare two GUIDs.
+
+--*/
+
+#include "Tiano.h"
+#include "EfiDriverLib.h"
+
+BOOLEAN
+EfiCompareGuid (
+ IN EFI_GUID *Guid1,
+ IN EFI_GUID *Guid2
+ )
+/*++
+
+Routine Description:
+
+ Compares two GUIDs
+
+Arguments:
+
+ Guid1 - guid to compare
+
+ Guid2 - guid to compare
+
+Returns:
+ TRUE if Guid1 == Guid2
+ FALSE if Guid1 != Guid2
+
+--*/
+{
+ UINTN Index;
+
+ //
+ // compare byte by byte
+ //
+ for (Index = 0; Index < 16; ++Index) {
+ if (*(((UINT8*) Guid1) + Index) != *(((UINT8*) Guid2) + Index)) {
+ return FALSE;
+ }
+ }
+ return TRUE;
+}
diff --git a/EDK/Foundation/Library/EfiCommonLib/EfiCompareMem.c b/EDK/Foundation/Library/EfiCommonLib/EfiCompareMem.c
new file mode 100644
index 0000000..4a43026
--- /dev/null
+++ b/EDK/Foundation/Library/EfiCommonLib/EfiCompareMem.c
@@ -0,0 +1,76 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiCompareMem.c
+
+Abstract:
+
+ Generic compare-memory routine.
+
+--*/
+
+#include "Tiano.h"
+#include "EfiDriverLib.h"
+
+
+INTN
+EfiCompareMem (
+ IN VOID *MemOne,
+ IN VOID *MemTwo,
+ IN UINTN Length
+ )
+/*++
+
+Routine Description:
+
+ Compares two memory buffers of a given length.
+
+Arguments:
+
+ MemOne - First memory buffer
+
+ MemTwo - Second memory buffer
+
+ Len - Length of Mem1 and Mem2 memory regions to compare
+
+Returns:
+
+ = 0 if MemOne == MemTwo
+
+--*/
+{
+ INTN ReturnValue;
+
+ if (!(EFI_UINTN_ALIGNED (MemOne) || EFI_UINTN_ALIGNED (MemTwo) || EFI_UINTN_ALIGNED (Length))) {
+ //
+ // If Destination/Source/Length are aligned do UINTN conpare
+ //
+ for (; Length > 0; Length -= sizeof (INTN), MemOne = (VOID *)((UINTN)MemOne + sizeof (INTN)), MemTwo = (VOID *)((UINTN)MemTwo + sizeof (INTN))) {
+ if (*(INTN *)MemOne != *(INTN *)MemTwo) {
+ break;
+ }
+ }
+ }
+
+ //
+ // If Destination/Source/Length not aligned do byte compare
+ //
+ for (; Length > 0; Length--, MemOne = (VOID *)((UINTN)MemOne + 1), MemTwo = (VOID *)((UINTN)MemTwo + 1)) {
+ ReturnValue = (INTN)(*(INT8 *)MemOne - *(INT8 *)MemTwo);
+ if (ReturnValue != 0) {
+ return ReturnValue;
+ }
+ }
+
+ return 0;
+}
diff --git a/EDK/Foundation/Library/EfiCommonLib/EfiCopyMem.c b/EDK/Foundation/Library/EfiCommonLib/EfiCopyMem.c
new file mode 100644
index 0000000..6028b19
--- /dev/null
+++ b/EDK/Foundation/Library/EfiCommonLib/EfiCopyMem.c
@@ -0,0 +1,69 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiCopyMem.c
+
+Abstract:
+
+ Implementation of the EfiCopyMem routine. This function is broken
+ out into its own source file so that it can be excluded from a
+ build for a particular platform easily if an optimized version
+ is desired.
+
+--*/
+
+#include "Tiano.h"
+
+VOID
+EfiCommonLibCopyMem (
+ IN VOID *Destination,
+ IN VOID *Source,
+ IN UINTN Length
+ )
+/*++
+
+Routine Description:
+
+ Copy Length bytes from Source to Destination.
+
+Arguments:
+
+ Destination - Target of copy
+
+ Source - Place to copy from
+
+ Length - Number of bytes to copy
+
+Returns:
+
+ None
+
+--*/
+{
+ CHAR8 *Destination8;
+ CHAR8 *Source8;
+
+ if (Source < Destination) {
+ Destination8 = (CHAR8 *) Destination + Length - 1;
+ Source8 = (CHAR8 *) Source + Length - 1;
+ while (Length--) {
+ *(Destination8--) = *(Source8--);
+ }
+ } else {
+ Destination8 = (CHAR8 *) Destination;
+ Source8 = (CHAR8 *) Source;
+ while (Length--) {
+ *(Destination8++) = *(Source8++);
+ }
+ }
+}
diff --git a/EDK/Foundation/Library/EfiCommonLib/EfiSetMem.c b/EDK/Foundation/Library/EfiCommonLib/EfiSetMem.c
new file mode 100644
index 0000000..058ebeb
--- /dev/null
+++ b/EDK/Foundation/Library/EfiCommonLib/EfiSetMem.c
@@ -0,0 +1,65 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiSetMem.c
+
+Abstract:
+
+ Implementation of the EfiSetMem routine. This function is broken
+ out into its own source file so that it can be excluded from a
+ build for a particular platform easily if an optimized version
+ is desired.
+
+--*/
+
+#include "Tiano.h"
+#include "EfiCommonLib.h"
+
+
+VOID
+EfiCommonLibSetMem (
+ IN VOID *Buffer,
+ IN UINTN Size,
+ IN UINT8 Value
+ )
+/*++
+
+Routine Description:
+
+ Set Buffer to Value for Size bytes.
+
+Arguments:
+
+ Buffer - Memory to set.
+
+ Size - Number of bytes to set
+
+ Value - Value of the set operation.
+
+Returns:
+
+ None
+
+--*/
+{
+ INT8 *Ptr;
+
+ if (Value == 0) {
+ EfiCommonLibZeroMem (Buffer, Size);
+ } else {
+ Ptr = Buffer;
+ while (Size--) {
+ *(Ptr++) = Value;
+ }
+ }
+}
diff --git a/EDK/Foundation/Library/EfiCommonLib/EfiZeroMem.c b/EDK/Foundation/Library/EfiCommonLib/EfiZeroMem.c
new file mode 100644
index 0000000..d6e50db
--- /dev/null
+++ b/EDK/Foundation/Library/EfiCommonLib/EfiZeroMem.c
@@ -0,0 +1,57 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiZeroMem.c
+
+Abstract:
+
+ Implementation of the EfiSetMem routine. This function is broken
+ out into its own source file so that it can be excluded from a
+ build for a particular platform easily if an optimized version
+ is desired.
+
+--*/
+
+#include "Tiano.h"
+
+
+VOID
+EfiCommonLibZeroMem (
+ IN VOID *Buffer,
+ IN UINTN Size
+ )
+/*++
+
+Routine Description:
+
+ Set Buffer to 0 for Size bytes.
+
+Arguments:
+
+ Buffer - Memory to set.
+
+ Size - Number of bytes to set
+
+Returns:
+
+ None
+
+--*/
+{
+ INT8 *Ptr;
+
+ Ptr = Buffer;
+ while (Size--) {
+ *(Ptr++) = 0;
+ }
+}
diff --git a/EDK/Foundation/Library/EfiCommonLib/Ia32/DivU64x32.asm b/EDK/Foundation/Library/EfiCommonLib/Ia32/DivU64x32.asm
new file mode 100644
index 0000000..5fc399f
--- /dev/null
+++ b/EDK/Foundation/Library/EfiCommonLib/Ia32/DivU64x32.asm
@@ -0,0 +1,99 @@
+ TITLE DivU64x32.asm: 64-bit division function for IA-32
+
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; DivU64x32.asm
+;
+; Abstract:
+;
+; 64-bit division function for IA-32
+;
+;------------------------------------------------------------------------------
+
+ .686P
+ .XMM
+ .MODEL SMALL
+ .CODE
+
+DivU64x32 PROTO C Dividend: QWORD, Divisor: DWORD, Remainder: DWORD
+
+DivU64x32 PROC C Dividend: QWORD, Divisor: DWORD, Remainder: DWORD
+
+;------------------------------------------------------------------------------
+; UINT64
+; DivU64x32 (
+; IN UINT64 Dividend,
+; IN UINTN Divisor,
+; OUT UINTN *Remainder OPTIONAL
+; )
+;
+; Routine Description:
+;
+; This routine allows a 64 bit value to be divided with a 32 bit value returns
+; 64bit result and the Remainder.
+;
+; Arguments:
+;
+; Dividend - dividend
+; Divisor - divisor
+; Remainder - buffer for remainder
+;
+; Returns:
+;
+; Dividend / Divisor
+; Remainder = Dividend mod Divisor
+;
+; N.B. only works for 31bit divisors!!
+;------------------------------------------------------------------------------
+
+ push ecx
+ ;
+ ; let edx contain the intermediate result of remainder
+ ;
+ xor edx, edx
+ mov ecx, 64
+
+_DivU64x32_Wend:
+ shl dword ptr Dividend[0], 1
+ rcl dword ptr Dividend[4], 1
+ rcl edx, 1
+
+ ;
+ ; If intermediate result of remainder is larger than
+ ; or equal to divisor, then set the lowest bit of dividend,
+ ; and subtract divisor from intermediate remainder
+ ;
+ cmp edx, Divisor
+ jb _DivU64x32_Cont
+ bts dword ptr Dividend[0], 0
+ sub edx, Divisor
+
+_DivU64x32_Cont:
+ loop _DivU64x32_Wend
+
+ cmp Remainder, 0
+ je _DivU64x32_Done
+ mov eax, Remainder
+ mov dword ptr [eax], edx
+
+_DivU64x32_Done:
+ mov eax, dword ptr Dividend[0]
+ mov edx, dword ptr Dividend[4]
+ pop ecx
+ ret
+
+DivU64x32 ENDP
+
+
+END
diff --git a/EDK/Foundation/Library/EfiCommonLib/Ia32/EfiCopyMem.asm b/EDK/Foundation/Library/EfiCommonLib/Ia32/EfiCopyMem.asm
new file mode 100644
index 0000000..504c08a
--- /dev/null
+++ b/EDK/Foundation/Library/EfiCommonLib/Ia32/EfiCopyMem.asm
@@ -0,0 +1,183 @@
+ TITLE EfiCopyMem.asm: Optimized memory-copy routine
+
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; EfiCopyMem.asm
+;
+; Abstract:
+;
+; This is the code that supports IA32-optimized CopyMem service
+;
+;------------------------------------------------------------------------------
+
+; PROC:PRIVATE
+ .686P
+ .MMX
+ .MODEL SMALL
+ .CODE
+
+EfiCommonLibCopyMem PROTO C Destination:PTR DWORD, Source:PTR DWORD, Count:DWORD
+
+;------------------------------------------------------------------------------
+; VOID
+; EfiCommonLibCopyMem (
+; IN VOID *Destination,
+; IN VOID *Source,
+; IN UINTN Count
+; )
+;------------------------------------------------------------------------------
+
+EfiCommonLibCopyMem PROC C Destination:PTR DWORD, Source:PTR DWORD, Count:DWORD
+ LOCAL MmxSave:QWORD
+
+ ; Put source and destination pointers in esi/edi
+ push esi
+ push edi
+ mov ecx, Count
+ mov esi, Source
+ mov edi, Destination
+
+ ; First off, make sure we have no overlap. That is to say,
+ ; if (Source == Destination) => do nothing
+ ; if (Source + Count <= Destination) => regular copy
+ ; if (Destination + Count <= Source) => regular copy
+ ; otherwise, do a reverse copy
+ mov eax, esi
+ add eax, ecx ; Source + Count
+ cmp eax, edi
+ jbe _StartByteCopy
+
+ mov eax, edi
+ add eax, ecx ; Dest + Count
+ cmp eax, esi
+ jbe _StartByteCopy
+
+ cmp esi, edi
+ je _CopyMemDone
+ jb _CopyOverlapped ; too bad -- overlaps
+
+ ; Pick up misaligned start bytes to get destination pointer 4-byte aligned
+_StartByteCopy:
+ cmp ecx, 0
+ je _CopyMemDone ; Count == 0, all done
+ mov edx, edi
+ and dl, 3 ; check lower 2 bits of address
+ test dl, dl
+ je SHORT _CopyBlocks ; already aligned?
+
+ ; Copy a byte
+ mov al, BYTE PTR [esi] ; get byte from Source
+ mov BYTE PTR [edi], al ; write byte to Destination
+ dec ecx
+ inc edi
+ inc esi
+ jmp _StartByteCopy ; back to top of loop
+
+_CopyBlocks:
+ ; Compute how many 64-byte blocks we can clear
+ mov eax, ecx ; get Count in eax
+ shr eax, 6 ; convert to 64-byte count
+ shl eax, 6 ; convert back to bytes
+ sub ecx, eax ; subtract from the original count
+ shr eax, 6 ; and this is how many 64-byte blocks
+
+ ; If no 64-byte blocks, then skip
+ cmp eax, 0
+ je _CopyRemainingDWords
+
+ ; Save mm0
+ movq MmxSave, mm0
+
+copymmx:
+
+ movq mm0, QWORD PTR ds:[esi]
+ movq QWORD PTR ds:[edi], mm0
+ movq mm0, QWORD PTR ds:[esi+8]
+ movq QWORD PTR ds:[edi+8], mm0
+ movq mm0, QWORD PTR ds:[esi+16]
+ movq QWORD PTR ds:[edi+16], mm0
+ movq mm0, QWORD PTR ds:[esi+24]
+ movq QWORD PTR ds:[edi+24], mm0
+ movq mm0, QWORD PTR ds:[esi+32]
+ movq QWORD PTR ds:[edi+32], mm0
+ movq mm0, QWORD PTR ds:[esi+40]
+ movq QWORD PTR ds:[edi+40], mm0
+ movq mm0, QWORD PTR ds:[esi+48]
+ movq QWORD PTR ds:[edi+48], mm0
+ movq mm0, QWORD PTR ds:[esi+56]
+ movq QWORD PTR ds:[edi+56], mm0
+
+ add edi, 64
+ add esi, 64
+ dec eax
+ jnz copymmx
+
+; Restore mm0
+ movq mm0, MmxSave
+ emms ; Exit MMX Instruction
+
+ ; Copy as many DWORDS as possible
+_CopyRemainingDWords:
+ cmp ecx, 4
+ jb _CopyRemainingBytes
+
+ mov eax, DWORD PTR [esi] ; get data from Source
+ mov DWORD PTR [edi], eax ; write byte to Destination
+ sub ecx, 4 ; decrement Count
+ add esi, 4 ; advance Source pointer
+ add edi, 4 ; advance Destination pointer
+ jmp _CopyRemainingDWords ; back to top
+
+_CopyRemainingBytes:
+ cmp ecx, 0
+ je _CopyMemDone
+ mov al, BYTE PTR [esi] ; get byte from Source
+ mov BYTE PTR [edi], al ; write byte to Destination
+ dec ecx
+ inc esi
+ inc edi ; advance Destination pointer
+ jmp SHORT _CopyRemainingBytes ; back to top of loop
+
+ ;
+ ; We do this block if the source and destination buffers overlap. To
+ ; handle it, copy starting at the end of the source buffer and work
+ ; your way back. Since this is the atypical case, this code has not
+ ; been optimized, and thus simply copies bytes.
+ ;
+_CopyOverlapped:
+
+ ; Move the source and destination pointers to the end of the range
+ add esi, ecx ; Source + Count
+ dec esi
+ add edi, ecx ; Dest + Count
+ dec edi
+
+_CopyOverlappedLoop:
+ cmp ecx, 0
+ je _CopyMemDone
+ mov al, BYTE PTR [esi] ; get byte from Source
+ mov BYTE PTR [edi], al ; write byte to Destination
+ dec ecx
+ dec esi
+ dec edi
+ jmp _CopyOverlappedLoop ; back to top of loop
+
+_CopyMemDone:
+ pop edi
+ pop esi
+
+ ret
+
+EfiCommonLibCopyMem ENDP
+ END
diff --git a/EDK/Foundation/Library/EfiCommonLib/Ia32/EfiCopyMemSSE2.asm b/EDK/Foundation/Library/EfiCommonLib/Ia32/EfiCopyMemSSE2.asm
new file mode 100644
index 0000000..d5000d0
--- /dev/null
+++ b/EDK/Foundation/Library/EfiCommonLib/Ia32/EfiCopyMemSSE2.asm
@@ -0,0 +1,169 @@
+ TITLE EfiCopyMem.asm: Optimized memory-copy routine
+
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; EfiCopyMem.asm
+;
+; Abstract:
+;
+; This is the code that supports IA32-optimized CopyMem service
+;
+;------------------------------------------------------------------------------
+
+; PROC:PRIVATE
+ .686P
+ .XMM
+ .MODEL SMALL
+ .CODE
+
+EfiCommonLibCopyMem PROTO C Destination:PTR DWORD, Source:PTR DWORD, Count:DWORD
+
+;------------------------------------------------------------------------------
+; VOID
+; EfiCommonLibCopyMem (
+; IN VOID *Destination,
+; IN VOID *Source,
+; IN UINTN Count
+; )
+;------------------------------------------------------------------------------
+
+EfiCommonLibCopyMem PROC C Destination:PTR DWORD, Source:PTR DWORD, Count:DWORD
+
+ ; Put source and destination pointers in esi/edi
+ push esi
+ push edi
+ mov ecx, Count
+ mov esi, Source
+ mov edi, Destination
+
+ ; First off, make sure we have no overlap. That is to say,
+ ; if (Source == Destination) => do nothing
+ ; if (Source + Count <= Destination) => regular copy
+ ; if (Destination + Count <= Source) => regular copy
+ ; otherwise, do a reverse copy
+ mov eax, esi
+ add eax, ecx ; Source + Count
+ cmp eax, edi
+ jle _StartByteCopy
+
+ mov eax, edi
+ add eax, ecx ; Dest + Count
+ cmp eax, esi
+ jle _StartByteCopy
+
+ cmp esi, edi
+ je _CopyMemDone
+ jl _CopyOverlapped ; too bad -- overlaps
+
+ ; Pick up misaligned start bytes to get destination pointer 4-byte aligned
+_StartByteCopy:
+ cmp ecx, 0
+ je _CopyMemDone ; Count == 0, all done
+ mov edx, edi
+ and dl, 3 ; check lower 2 bits of address
+ test dl, dl
+ je SHORT _CopyBlocks ; already aligned?
+
+ ; Copy a byte
+ mov al, BYTE PTR [esi] ; get byte from Source
+ mov BYTE PTR [edi], al ; write byte to Destination
+ dec ecx
+ inc edi
+ inc esi
+ jmp _StartByteCopy ; back to top of loop
+
+_CopyBlocks:
+ ; Compute how many 64-byte blocks we can clear
+ mov eax, ecx ; get Count in eax
+ shr eax, 6 ; convert to 64-byte count
+ shl eax, 6 ; convert back to bytes
+ sub ecx, eax ; subtract from the original count
+ shr eax, 6 ; and this is how many 64-byte blocks
+
+ ; If no 64-byte blocks, then skip
+ cmp eax, 0
+ je _CopyRemainingDWords
+
+
+copyxmm:
+
+ movdqu xmm0, OWORD PTR ds:[esi]
+ movdqu OWORD PTR ds:[edi], xmm0
+ movdqu xmm1, OWORD PTR ds:[esi+16]
+ movdqu OWORD PTR ds:[edi+16], xmm1
+ movdqu xmm2, OWORD PTR ds:[esi+32]
+ movdqu OWORD PTR ds:[edi+32], xmm2
+ movdqu xmm3, OWORD PTR ds:[esi+48]
+ movdqu OWORD PTR ds:[edi+48], xmm3
+
+ add edi, 64
+ add esi, 64
+ dec eax
+ jnz copyxmm
+
+
+ ; Copy as many DWORDS as possible
+_CopyRemainingDWords:
+ cmp ecx, 4
+ jb _CopyRemainingBytes
+
+ mov eax, DWORD PTR [esi] ; get data from Source
+ mov DWORD PTR [edi], eax ; write byte to Destination
+ sub ecx, 4 ; decrement Count
+ add esi, 4 ; advance Source pointer
+ add edi, 4 ; advance Destination pointer
+ jmp _CopyRemainingDWords ; back to top
+
+_CopyRemainingBytes:
+ cmp ecx, 0
+ je _CopyMemDone
+ mov al, BYTE PTR [esi] ; get byte from Source
+ mov BYTE PTR [edi], al ; write byte to Destination
+ dec ecx
+ inc esi
+ inc edi ; advance Destination pointer
+ jmp SHORT _CopyRemainingBytes ; back to top of loop
+
+ ;
+ ; We do this block if the source and destination buffers overlap. To
+ ; handle it, copy starting at the end of the source buffer and work
+ ; your way back. Since this is the atypical case, this code has not
+ ; been optimized, and thus simply copies bytes.
+ ;
+_CopyOverlapped:
+
+ ; Move the source and destination pointers to the end of the range
+ add esi, ecx ; Source + Count
+ dec esi
+ add edi, ecx ; Dest + Count
+ dec edi
+
+_CopyOverlappedLoop:
+ cmp ecx, 0
+ je _CopyMemDone
+ mov al, BYTE PTR [esi] ; get byte from Source
+ mov BYTE PTR [edi], al ; write byte to Destination
+ dec ecx
+ dec esi
+ dec edi
+ jmp _CopyOverlappedLoop ; back to top of loop
+
+_CopyMemDone:
+ pop edi
+ pop esi
+
+ ret
+
+EfiCommonLibCopyMem ENDP
+ END
diff --git a/EDK/Foundation/Library/EfiCommonLib/Ia32/EfiSetMem.asm b/EDK/Foundation/Library/EfiCommonLib/Ia32/EfiSetMem.asm
new file mode 100644
index 0000000..3b08c37
--- /dev/null
+++ b/EDK/Foundation/Library/EfiCommonLib/Ia32/EfiSetMem.asm
@@ -0,0 +1,154 @@
+ TITLE EfiSetMem.asm: Optimized setmemory routine
+
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; EfiSetMem.asm
+;
+; Abstract:
+;
+; This is the code that supports IA32-optimized SetMem service
+;
+;------------------------------------------------------------------------------
+
+; PROC:PRIVATE
+ .686P
+ .MMX
+ .MODEL SMALL
+ .CODE
+
+EfiCommonLibSetMem PROTO C Buffer:PTR DWORD, Count:DWORD, Value:BYTE
+
+;------------------------------------------------------------------------------
+; Procedure: EfiCommonLibSetMem
+;
+; VOID
+; EfiCommonLibSetMem (
+; IN VOID *Buffer,
+; IN UINTN Count,
+; IN UINT8 Value
+; )
+;
+; Input: VOID *Buffer - Pointer to buffer to write
+; UINTN Count - Number of bytes to write
+; UINT8 Value - Value to write
+;
+; Output: None.
+;
+; Saves:
+;
+; Modifies:
+;
+; Description: This function is an optimized zero-memory function.
+;
+; Notes: This function tries to zero memory 8 bytes at a time. As a result,
+; it first picks up any misaligned bytes, then words, before getting
+; in the main loop that does the 8-byte clears.
+;
+;------------------------------------------------------------------------------
+EfiCommonLibSetMem PROC C Buffer:PTR DWORD, Count:DWORD, Value:BYTE
+ LOCAL QWordValue:QWORD
+ LOCAL MmxSave:QWORD
+
+
+ mov edx, Count
+ test edx, edx
+ je _SetMemDone
+
+ push edi
+ push ebx
+
+ mov eax, Buffer
+ mov bl, Value
+ mov edi, eax
+ mov bh, bl
+
+ cmp edx, 256
+ jb _SetRemindingByte
+
+ and al, 07h
+ test al, al
+ je _SetBlock
+
+ mov eax, edi
+ shr eax, 3
+ inc eax
+ shl eax, 3
+ sub eax, edi
+ cmp eax, edx
+ jnb _SetRemindingByte
+
+ sub edx, eax
+ mov ecx, eax
+
+ mov al, bl
+ rep stosb
+
+_SetBlock:
+ mov eax, edx
+ shr eax, 6
+ test eax, eax
+ je _SetRemindingByte
+
+ shl eax, 6
+ sub edx, eax
+ shr eax, 6
+
+ mov WORD PTR QWordValue[0], bx
+ mov WORD PTR QWordValue[2], bx
+ mov WORD PTR QWordValue[4], bx
+ mov WORD PTR QWordValue[6], bx
+
+
+ movq MmxSave, mm0
+ movq mm0, QWordValue
+
+@@:
+ movq QWORD PTR ds:[edi], mm0
+ movq QWORD PTR ds:[edi+8], mm0
+ movq QWORD PTR ds:[edi+16], mm0
+ movq QWORD PTR ds:[edi+24], mm0
+ movq QWORD PTR ds:[edi+32], mm0
+ movq QWORD PTR ds:[edi+40], mm0
+ movq QWORD PTR ds:[edi+48], mm0
+ movq QWORD PTR ds:[edi+56], mm0
+ add edi, 64
+ dec eax
+ jnz @B
+
+; Restore mm0
+ movq mm0, MmxSave
+ emms ; Exit MMX Instruction
+
+_SetRemindingByte:
+ mov ecx, edx
+
+ mov eax, ebx
+ shl eax, 16
+ mov ax, bx
+ shr ecx, 2
+ rep stosd
+
+ mov ecx, edx
+ and ecx, 3
+ rep stosb
+
+ pop ebx
+ pop edi
+
+_SetMemDone:
+ ret 0
+
+EfiCommonLibSetMem ENDP
+ END
+ \ No newline at end of file
diff --git a/EDK/Foundation/Library/EfiCommonLib/Ia32/EfiSetMemSSE2.asm b/EDK/Foundation/Library/EfiCommonLib/Ia32/EfiSetMemSSE2.asm
new file mode 100644
index 0000000..5d6652d
--- /dev/null
+++ b/EDK/Foundation/Library/EfiCommonLib/Ia32/EfiSetMemSSE2.asm
@@ -0,0 +1,158 @@
+ TITLE EfiSetMem.asm: Optimized setmemory routine
+
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; EfiCommonLibSetMem.asm
+;
+; Abstract:
+;
+; This is the code that supports IA32-optimized SetMem service
+;
+;------------------------------------------------------------------------------
+
+; PROC:PRIVATE
+ .686P
+ .MMX
+ .XMM
+ .MODEL SMALL
+ .CODE
+
+EfiCommonLibSetMem PROTO C Buffer:PTR DWORD, Count:DWORD, Value:BYTE
+
+;------------------------------------------------------------------------------
+; Procedure: EfiCommonLibSetMem
+;
+; VOID
+; EfiCommonLibSetMem (
+; IN VOID *Buffer,
+; IN UINTN Count,
+; IN UINT8 Value
+; )
+;
+; Input: VOID *Buffer - Pointer to buffer to write
+; UINTN Count - Number of bytes to write
+; UINT8 Value - Value to write
+;
+; Output: None.
+;
+; Saves:
+;
+; Modifies:
+;
+; Description: This function is an optimized zero-memory function.
+;
+; Notes: This function tries to zero memory 8 bytes at a time. As a result,
+; it first picks up any misaligned bytes, then words, before getting
+; in the main loop that does the 8-byte clears.
+;
+;------------------------------------------------------------------------------
+EfiCommonLibSetMem PROC C Buffer:PTR DWORD, Count:DWORD, Value:BYTE
+ LOCAL QWordValue:QWORD
+ LOCAL MmxSave:QWORD
+
+
+ mov edx, Count
+ test edx, edx
+ je _SetMemDone
+
+ push edi
+ push ebx
+
+ mov eax, Buffer
+ mov bl, Value
+ mov edi, eax
+ mov bh, bl
+
+ cmp edx, 256
+ jb _SetRemindingByte
+
+ and al, 0fh
+ test al, al
+ je _SetBlock
+
+ mov eax, edi
+ shr eax, 4
+ inc eax
+ shl eax, 4
+ sub eax, edi
+ cmp eax, edx
+ jnb _SetRemindingByte
+
+ sub edx, eax
+ mov ecx, eax
+
+ mov al, bl
+ rep stosb
+
+_SetBlock:
+ mov eax, edx
+ shr eax, 7
+ test eax, eax
+ je _SetRemindingByte
+
+ shl eax, 7
+ sub edx, eax
+ shr eax, 7
+
+ mov WORD PTR QWordValue[0], bx
+ mov WORD PTR QWordValue[2], bx
+ mov WORD PTR QWordValue[4], bx
+ mov WORD PTR QWordValue[6], bx
+
+
+ movq MmxSave, mm0
+ movq mm0, QWordValue
+
+ movq2dq xmm1, mm0
+ pshufd xmm1, xmm1, 0
+
+@@:
+ movdqa OWORD PTR ds:[edi], xmm1
+ movdqa OWORD PTR ds:[edi+16], xmm1
+ movdqa OWORD PTR ds:[edi+32], xmm1
+ movdqa OWORD PTR ds:[edi+48], xmm1
+ movdqa OWORD PTR ds:[edi+64], xmm1
+ movdqa OWORD PTR ds:[edi+80], xmm1
+ movdqa OWORD PTR ds:[edi+96], xmm1
+ movdqa OWORD PTR ds:[edi+112], xmm1
+ add edi, 128
+ dec eax
+ jnz @B
+
+; Restore mm0
+ movq mm0, MmxSave
+ emms ; Exit MMX Instruction
+
+_SetRemindingByte:
+ mov ecx, edx
+
+ mov eax, ebx
+ shl eax, 16
+ mov ax, bx
+ shr ecx, 2
+ rep stosd
+
+ mov ecx, edx
+ and ecx, 3
+ rep stosb
+
+ pop ebx
+ pop edi
+
+_SetMemDone:
+ ret 0
+
+EfiCommonLibSetMem ENDP
+ END
+ \ No newline at end of file
diff --git a/EDK/Foundation/Library/EfiCommonLib/Ia32/EfiZeroMem.asm b/EDK/Foundation/Library/EfiCommonLib/Ia32/EfiZeroMem.asm
new file mode 100644
index 0000000..7188e29
--- /dev/null
+++ b/EDK/Foundation/Library/EfiCommonLib/Ia32/EfiZeroMem.asm
@@ -0,0 +1,138 @@
+ TITLE EfiZeroMem.asm: Optimized memory-zero routine
+
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; EfiZeroMem.asm
+;
+; Abstract:
+;
+; This is the code that supports IA32-optimized ZeroMem service
+;
+;------------------------------------------------------------------------------
+
+; PROC:PRIVATE
+ .686P
+ .MMX
+ .MODEL SMALL
+ .CODE
+
+EfiCommonLibZeroMem PROTO C Buffer:PTR DWORD, Count:DWORD
+
+;------------------------------------------------------------------------------
+; Procedure: EfiCommonLibZeroMem
+;
+; VOID
+; EfiCommonLibZeroMem (
+; IN VOID *Buffer,
+; IN UINTN Count
+; )
+;
+; Input: VOID *Buffer - Pointer to buffer to clear
+; UINTN Count - Number of bytes to clear
+;
+; Output: None.
+;
+; Saves:
+;
+; Modifies:
+;
+; Description: This function is an optimized zero-memory function.
+;
+; Notes: This function tries to zero memory 8 bytes at a time. As a result,
+; it first picks up any misaligned bytes, then words, before getting
+; in the main loop that does the 8-byte clears.
+;
+;------------------------------------------------------------------------------
+EfiCommonLibZeroMem PROC C Buffer:PTR DWORD, Count:DWORD
+ LOCAL MmxSave:QWORD
+
+ ; Save edi, then put the buffer pointer into it.
+ push edi
+ mov ecx, Count
+ mov edi, Buffer
+
+ ; Pick up misaligned start bytes (get pointer 4-byte aligned)
+_StartByteZero:
+ mov eax, edi
+ and al, 3 ; check lower 2 bits of address
+ test al, al
+ je _ZeroBlocks ; already aligned?
+ cmp ecx, 0
+ je _ZeroMemDone
+
+ ; Clear the byte memory location
+ mov BYTE PTR [edi], 0
+ inc edi
+
+ ; Decrement our count
+ dec ecx
+ jmp _StartByteZero ; back to top of loop
+
+_ZeroBlocks:
+
+ ; Compute how many 64-byte blocks we can clear
+ mov edx, ecx
+ shr ecx, 6 ; convert to 64-byte count
+ shl ecx, 6 ; convert back to bytes
+ sub edx, ecx ; subtract from the original count
+ shr ecx, 6 ; and this is how many 64-byte blocks
+
+ ; If no 64-byte blocks, then skip
+ cmp ecx, 0
+ je _ZeroRemaining
+
+ ; Save mm0
+ movq MmxSave, mm0
+
+ pxor mm0, mm0 ; Clear mm0
+
+@@:
+ movq QWORD PTR ds:[edi], mm0
+ movq QWORD PTR ds:[edi+8], mm0
+ movq QWORD PTR ds:[edi+16], mm0
+ movq QWORD PTR ds:[edi+24], mm0
+ movq QWORD PTR ds:[edi+32], mm0
+ movq QWORD PTR ds:[edi+40], mm0
+ movq QWORD PTR ds:[edi+48], mm0
+ movq QWORD PTR ds:[edi+56], mm0
+
+ add edi, 64
+ dec ecx
+ jnz @B
+
+; Restore mm0
+ movq mm0, MmxSave
+ emms ; Exit MMX Instruction
+
+_ZeroRemaining:
+ ; Zero out as many DWORDS as possible
+ mov ecx, edx
+ shr ecx, 2
+ xor eax, eax
+
+ rep stosd
+
+ ; Zero out remaining as bytes
+ mov ecx, edx
+ and ecx, 03
+
+ rep stosb
+
+_ZeroMemDone:
+ pop edi
+
+ ret
+
+EfiCommonLibZeroMem ENDP
+ END
diff --git a/EDK/Foundation/Library/EfiCommonLib/Ia32/EfiZeroMemSSE2.asm b/EDK/Foundation/Library/EfiCommonLib/Ia32/EfiZeroMemSSE2.asm
new file mode 100644
index 0000000..a5efd4d
--- /dev/null
+++ b/EDK/Foundation/Library/EfiCommonLib/Ia32/EfiZeroMemSSE2.asm
@@ -0,0 +1,127 @@
+ TITLE EfiZeroMem.asm: Optimized memory-zero routine
+
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; EfiZeroMem.asm
+;
+; Abstract:
+;
+; This is the code that supports IA32-optimized ZeroMem service
+;
+;------------------------------------------------------------------------------
+
+; PROC:PRIVATE
+ .686P
+ .XMM
+ .MODEL SMALL
+ .CODE
+
+EfiCommonLibZeroMem PROTO C Buffer:PTR DWORD, Count:DWORD
+
+;------------------------------------------------------------------------------
+; Procedure: EfiCommonLibZeroMem
+;
+; VOID
+; EfiCommonLibZeroMem (
+; IN VOID *Buffer,
+; IN UINTN Count
+; )
+;
+; Input: VOID *Buffer - Pointer to buffer to clear
+; UINTN Count - Number of bytes to clear
+;
+; Output: None.
+;
+; Saves:
+;
+; Modifies:
+;
+; Description: This function is an optimized zero-memory function.
+;
+; Notes: This function tries to zero memory 8 bytes at a time. As a result,
+; it first picks up any misaligned bytes, then words, before getting
+; in the main loop that does the 8-byte clears.
+;
+;------------------------------------------------------------------------------
+EfiCommonLibZeroMem PROC C Buffer:PTR DWORD, Count:DWORD
+
+ ; Save edi, then put the buffer pointer into it.
+ push edi
+ mov ecx, Count
+ mov edi, Buffer
+
+ ; Pick up misaligned start bytes (get pointer 4-byte aligned)
+_StartByteZero:
+ mov eax, edi
+ and al, 3 ; check lower 2 bits of address
+ test al, al
+ je _ZeroBlocks ; already aligned?
+ cmp ecx, 0
+ je _ZeroMemDone
+
+ ; Clear the byte memory location
+ mov BYTE PTR [edi], 0
+ inc edi
+
+ ; Decrement our count
+ dec ecx
+ jmp _StartByteZero ; back to top of loop
+
+_ZeroBlocks:
+
+ ; Compute how many 64-byte blocks we can clear
+ mov edx, ecx
+ shr ecx, 6 ; convert to 64-byte count
+ shl ecx, 6 ; convert back to bytes
+ sub edx, ecx ; subtract from the original count
+ shr ecx, 6 ; and this is how many 64-byte blocks
+
+ ; If no 64-byte blocks, then skip
+ cmp ecx, 0
+ je _ZeroRemaining
+
+ xorps xmm1, xmm1
+
+@@:
+ movdqu OWORD PTR ds:[edi], xmm1
+ movdqu OWORD PTR ds:[edi+16], xmm1
+ movdqu OWORD PTR ds:[edi+32], xmm1
+ movdqu OWORD PTR ds:[edi+48], xmm1
+
+ add edi, 64
+ dec ecx
+ jnz @B
+
+
+_ZeroRemaining:
+ ; Zero out as many DWORDS as possible
+ mov ecx, edx
+ shr ecx, 2
+ xor eax, eax
+
+ rep stosd
+
+ ; Zero out remaining as bytes
+ mov ecx, edx
+ and ecx, 03
+
+ rep stosb
+
+_ZeroMemDone:
+ pop edi
+
+ ret
+
+EfiCommonLibZeroMem ENDP
+ END
diff --git a/EDK/Foundation/Library/EfiCommonLib/Ia32/GetPowerOfTwo.asm b/EDK/Foundation/Library/EfiCommonLib/Ia32/GetPowerOfTwo.asm
new file mode 100644
index 0000000..9f0d962
--- /dev/null
+++ b/EDK/Foundation/Library/EfiCommonLib/Ia32/GetPowerOfTwo.asm
@@ -0,0 +1,67 @@
+ TITLE GetPowerOfTwo.asm: Calculates the power of two value just below input
+
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2005 Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; GetPowerOfTwo.asm
+;
+; Abstract:
+;
+; Calculates the largest integer that is both
+; a power of two and less than Input
+;
+;------------------------------------------------------------------------------
+
+ .686P
+ .XMM
+ .MODEL SMALL
+ .CODE
+
+_GetPowerOfTwo PROC
+;------------------------------------------------------------------------------
+; UINT32
+; _GetPowerOfTwo (
+; IN UINT32 Input
+; )
+;
+; Routine Description:
+;
+; Calculates the largest integer that is both
+; a power of two and less than Input
+;
+; Arguments:
+;
+; Input - value to calculate power of two
+;
+; Returns:
+;
+; the largest integer that is both a power of
+; two and less than Input
+;------------------------------------------------------------------------------
+ xor eax, eax
+ mov edx, eax
+ mov ecx, [esp + 8]
+ jecxz @F
+ bsr ecx, ecx
+ bts edx, ecx
+ jmp @Exit
+@@:
+ mov ecx, [esp + 4]
+ jecxz @Exit
+ bsr ecx, ecx
+ bts eax, ecx
+@Exit:
+ ret
+_GetPowerOfTwo ENDP
+
+END
diff --git a/EDK/Foundation/Library/EfiCommonLib/Ia32/LShiftU64.asm b/EDK/Foundation/Library/EfiCommonLib/Ia32/LShiftU64.asm
new file mode 100644
index 0000000..de6d17e
--- /dev/null
+++ b/EDK/Foundation/Library/EfiCommonLib/Ia32/LShiftU64.asm
@@ -0,0 +1,86 @@
+ TITLE LShiftU64.asm: 64-bit left shift function for IA-32
+
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; LShiftU64.asm
+;
+; Abstract:
+;
+; 64-bit left shift function for IA-32
+;
+;------------------------------------------------------------------------------
+
+ .686P
+ .XMM
+ .MODEL SMALL
+ .CODE
+
+LShiftU64 PROTO C Operand: QWORD, Count: DWORD
+
+LShiftU64 PROC C Operand: QWORD, Count: DWORD
+
+;------------------------------------------------------------------------------
+; UINT64
+; LShiftU64 (
+; IN UINT64 Operand,
+; IN UINTN Count
+; )
+;
+; Routine Description:
+;
+; This routine allows a 64 bit value to be left shifted by 32 bits and
+; returns the shifted value.
+; Count is valid up 63. (Only Bits 0-5 is valid for Count)
+;
+; Arguments:
+;
+; Operand - Value to be shifted
+; Count - Number of times to shift left.
+;
+; Returns:
+;
+; Value shifted left identified by the Count.
+;------------------------------------------------------------------------------
+
+ push ecx
+
+ mov eax, dword ptr Operand[0]
+ mov edx, dword ptr Operand[4]
+
+ ;
+ ; CL is valid from 0 - 31. shld will move EDX:EAX by CL times but EAX is not touched
+ ; For CL of 32 - 63, it will be shifted 0 - 31 so we will move eax to edx later.
+ ;
+ mov ecx, Count
+ and ecx, 63
+ shld edx, eax, cl
+ shl eax, cl
+
+ ;
+ ; Since Count is 32 - 63, eax will have been shifted by 0 - 31
+ ; If shifted by 32 or more, set lower 32 bits to zero.
+ ;
+ cmp ecx, 32
+ jc short _LShiftU64_Done
+
+ mov edx, eax
+ xor eax, eax
+
+_LShiftU64_Done:
+ pop ecx
+ ret
+
+LShiftU64 ENDP
+
+END
diff --git a/EDK/Foundation/Library/EfiCommonLib/Ia32/Log2.asm b/EDK/Foundation/Library/EfiCommonLib/Ia32/Log2.asm
new file mode 100644
index 0000000..167086e
--- /dev/null
+++ b/EDK/Foundation/Library/EfiCommonLib/Ia32/Log2.asm
@@ -0,0 +1,87 @@
+ TITLE Log2.asm: 64-bit integer logarithm function for IA-32
+
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; Log2.asm
+;
+; Abstract:
+;
+; 64-bit integer logarithm function for IA-32
+;
+;------------------------------------------------------------------------------
+
+ .686P
+ .XMM
+ .MODEL SMALL
+ .CODE
+
+Log2 PROTO C Operand: QWORD
+
+Log2 PROC C Operand: QWORD
+
+;------------------------------------------------------------------------------
+; UINT8
+; Log2 (
+; IN UINT64 Operand
+; )
+;
+; Routine Description:
+;
+; Calculates and floors logarithms based on 2
+;
+; Arguments:
+;
+; Operand - value to calculate logarithm
+;
+; Returns:
+;
+; The largest integer that is less than or equal
+; to the logarithm of Operand based on 2
+;------------------------------------------------------------------------------
+
+ push ecx
+
+ mov ecx, 64
+
+ cmp dword ptr Operand[0], 0
+ jne _Log2_Wend
+ cmp dword ptr Operand[4], 0
+ jne _Log2_Wend
+ mov cl, 0FFH
+ jmp _Log2_Done
+
+_Log2_Wend:
+ dec ecx
+ cmp ecx, 32
+ jae _Log2_Higher
+ bt dword ptr Operand[0], ecx
+ jmp _Log2_Bit
+
+_Log2_Higher:
+ mov eax, ecx
+ sub eax, 32
+ bt dword ptr Operand[4], eax
+
+_Log2_Bit:
+ jc _Log2_Done
+ jmp _Log2_Wend
+
+_Log2_Done:
+ mov al, cl
+ pop ecx
+ ret
+
+Log2 ENDP
+
+END
diff --git a/EDK/Foundation/Library/EfiCommonLib/Ia32/MultU64x32.asm b/EDK/Foundation/Library/EfiCommonLib/Ia32/MultU64x32.asm
new file mode 100644
index 0000000..351020e
--- /dev/null
+++ b/EDK/Foundation/Library/EfiCommonLib/Ia32/MultU64x32.asm
@@ -0,0 +1,74 @@
+ TITLE MultU64x32.asm: 64-bit Multiplication function for IA-32
+
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; MultU64x32.asm
+;
+; Abstract:
+;
+; 64-bit Multiplication function for IA-32
+;
+;------------------------------------------------------------------------------
+
+ .686P
+ .XMM
+ .MODEL SMALL, C
+ .CODE
+
+MultU64x32 PROTO C Multiplicand: QWORD, Multiplier: DWORD
+
+MultU64x32 PROC C Multiplicand: QWORD, Multiplier: DWORD
+
+;------------------------------------------------------------------------------
+; UINT64
+; MultU64x32 (
+; IN UINT64 Multiplicand,
+; IN UINTN Multiplier
+; )
+;
+; Routine Description:
+;
+; This routine allows a 64 bit value to be multiplied with a 32 bit
+; value returns 64bit result.
+; No checking if the result is greater than 64bits
+;
+; Arguments:
+;
+; Multiplicand - multiplicand
+; Multiplier - multiplier
+;
+; Returns:
+;
+; Multiplicand * Multiplier
+;------------------------------------------------------------------------------
+
+ mov eax, dword ptr Multiplicand[0]
+ mul Multiplier
+ push eax
+ push edx
+ mov eax, dword ptr Multiplicand[4]
+ mul Multiplier
+ ;
+ ; The value in edx stored by second multiplication overflows
+ ; the output and should be discarded. So here we overwrite it
+ ; with the edx value of first multiplication.
+ ;
+ pop edx
+ add edx, eax
+ pop eax
+ ret
+
+MultU64x32 ENDP
+
+END
diff --git a/EDK/Foundation/Library/EfiCommonLib/Ia32/Power10U64.asm b/EDK/Foundation/Library/EfiCommonLib/Ia32/Power10U64.asm
new file mode 100644
index 0000000..0346e03
--- /dev/null
+++ b/EDK/Foundation/Library/EfiCommonLib/Ia32/Power10U64.asm
@@ -0,0 +1,72 @@
+ TITLE Power10U64.asm: calculates Operand * 10 ^ Power
+
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; Power10U64.asm
+;
+; Abstract:
+;
+; Calculates Operand * 10 ^ Power
+;
+;------------------------------------------------------------------------------
+
+ .686P
+ .XMM
+ .MODEL SMALL
+ .CODE
+
+Power10U64 PROTO C Operand: QWORD, Power: DWORD
+MultU64x32 PROTO C Multiplicand: QWORD, Multiplier: DWORD
+
+Power10U64 PROC C Operand: QWORD, Power: DWORD
+
+;------------------------------------------------------------------------------
+; UINT64
+; Power10U64 (
+; IN UINT64 Operand,
+; IN UINTN Power
+; )
+;
+; Routine Description:
+;
+; Raise 10 to the power of Power, and multiply the result with Operand
+;
+; Arguments:
+;
+; Operand - multiplicand
+; Power - power
+;
+; Returns:
+;
+; Operand * 10 ^ Power
+;------------------------------------------------------------------------------
+
+ push ecx
+
+ mov ecx, Power
+ jcxz _Power10U64_Done
+
+_Power10U64_Wend:
+ invoke MultU64x32, Operand, 10
+ mov dword ptr Operand[0], eax
+ mov dword ptr Operand[4], edx
+ loop _Power10U64_Wend
+
+_Power10U64_Done:
+ pop ecx
+ ret
+
+Power10U64 ENDP
+
+END
diff --git a/EDK/Foundation/Library/EfiCommonLib/Ia32/RShiftU64.asm b/EDK/Foundation/Library/EfiCommonLib/Ia32/RShiftU64.asm
new file mode 100644
index 0000000..de05d20
--- /dev/null
+++ b/EDK/Foundation/Library/EfiCommonLib/Ia32/RShiftU64.asm
@@ -0,0 +1,86 @@
+ TITLE RShiftU64.asm: 64-bit right shift function for IA-32
+
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; RShiftU64.asm
+;
+; Abstract:
+;
+; 64-bit right shift function for IA-32
+;
+;------------------------------------------------------------------------------
+
+ .686P
+ .XMM
+ .MODEL SMALL
+ .CODE
+
+RShiftU64 PROTO C Operand: QWORD, Count: DWORD
+
+RShiftU64 PROC C Operand: QWORD, Count: DWORD
+
+;------------------------------------------------------------------------------
+; UINT64
+; RShiftU64 (
+; IN UINT64 Operand,
+; IN UINTN Count
+; )
+;
+; Routine Description:
+;
+; This routine allows a 64 bit value to be right shifted by 32 bits and returns the
+; shifted value.
+; Count is valid up 63. (Only Bits 0-5 is valid for Count)
+;
+; Arguments:
+;
+; Operand - Value to be shifted
+; Count - Number of times to shift right.
+;
+; Returns:
+;
+; Value shifted right identified by the Count.
+;------------------------------------------------------------------------------
+
+ push ecx
+
+ mov eax, dword ptr Operand[0]
+ mov edx, dword ptr Operand[4]
+
+ ;
+ ; CL is valid from 0 - 31. shld will move EDX:EAX by CL times but EDX is not touched
+ ; For CL of 32 - 63, it will be shifted 0 - 31 so we will move edx to eax later.
+ ;
+ mov ecx, Count
+ and ecx, 63
+ shrd eax, edx, cl
+ shr edx, cl
+
+ cmp ecx, 32
+ jc short _RShiftU64_Done
+
+ ;
+ ; Since Count is 32 - 63, edx will have been shifted by 0 - 31
+ ; If shifted by 32 or more, set upper 32 bits to zero.
+ ;
+ mov eax, edx
+ xor edx, edx
+
+_RShiftU64_Done:
+ pop ecx
+ ret
+
+RShiftU64 ENDP
+
+END
diff --git a/EDK/Foundation/Library/EfiCommonLib/Math.c b/EDK/Foundation/Library/EfiCommonLib/Math.c
new file mode 100644
index 0000000..8767fa6
--- /dev/null
+++ b/EDK/Foundation/Library/EfiCommonLib/Math.c
@@ -0,0 +1,216 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Math.c
+
+Abstract:
+
+ Math worker functions.
+
+--*/
+
+#include "Tiano.h"
+
+UINT64
+LShiftU64 (
+ IN UINT64 Operand,
+ IN UINTN Count
+ )
+/*++
+
+Routine Description:
+
+ This routine allows a 64 bit value to be left shifted by 32 bits and
+ returns the shifted value.
+ Count is valid up 63. (Only Bits 0-5 is valid for Count)
+
+Arguments:
+
+ Operand - Value to be shifted
+ Count - Number of times to shift left.
+
+Returns:
+
+ Value shifted left identified by the Count.
+
+--*/
+{
+ return Operand << Count;
+}
+
+UINT64
+MultU64x32 (
+ IN UINT64 Multiplicand,
+ IN UINTN Multiplier
+ )
+/*++
+
+Routine Description:
+
+ This routine allows a 64 bit value to be multiplied with a 32 bit
+ value returns 64bit result.
+ No checking if the result is greater than 64bits
+
+Arguments:
+
+ Multiplicand - multiplicand
+ Multiplier - multiplier
+
+Returns:
+
+ Multiplicand * Multiplier
+
+--*/
+{
+ return Multiplicand * Multiplier;
+}
+
+UINT64
+RShiftU64 (
+ IN UINT64 Operand,
+ IN UINTN Count
+ )
+/*++
+
+Routine Description:
+
+ This routine allows a 64 bit value to be right shifted by 32 bits and returns the
+ shifted value.
+ Count is valid up 63. (Only Bits 0-5 is valid for Count)
+
+Arguments:
+
+ Operand - Value to be shifted
+ Count - Number of times to shift right.
+
+Returns:
+
+ Value shifted right identified by the Count.
+
+--*/
+{
+ return Operand >> Count;
+}
+
+UINT64
+DivU64x32 (
+ IN UINT64 Dividend,
+ IN UINTN Divisor,
+ OUT UINTN *Remainder OPTIONAL
+ )
+/*++
+
+Routine Description:
+
+ This routine allows a 64 bit value to be divided with a 32 bit value returns
+ 64bit result and the Remainder.
+
+Arguments:
+
+ Dividend - dividend
+ Divisor - divisor
+ Remainder - buffer for remainder
+
+Returns:
+
+ Dividend / Divisor
+ Remainder = Dividend mod Divisor
+
+--*/
+{
+ if (Remainder != NULL) {
+ *Remainder = Dividend % Divisor;
+ }
+
+ return Dividend / Divisor;
+}
+
+UINT8
+Log2 (
+ IN UINT64 Operand
+ )
+/*++
+
+Routine Description:
+
+ This function computes rounded down log2 of the Operand. This is an equivalent
+ of the position of the highest bit set in the Operand treated as a mask.
+ E.g., Log2 (0x0001) == 0, Log2 (0x0002) == 1, Log2 (0x0003) == 1, Log2 (0x0005) == 2
+ Log2 (0x4000) == 14, Log2 (0x8000) == 15, Log2 (0xC000) == 15, Log2 (0xFFFF) == 15, etc.
+
+Arguments:
+ Operand - value of which the Log2 is to be computed.
+
+Returns:
+ Rounded down log2 of the Operand or 0xFF if zero passed in.
+
+--*/
+{
+ UINT8 Bitpos;
+ Bitpos = 0;
+
+ if (Operand == 0) {
+ return (0xff);
+ }
+
+ while (Operand != 0) {
+ Operand >>= 1;
+ Bitpos++;
+ }
+ return (Bitpos - 1);
+
+}
+
+UINT64
+GetPowerOfTwo (
+ IN UINT64 Operand
+ )
+/*++
+
+Routine Description:
+
+ Calculates the largest integer that is both
+ a power of two and less than Input
+
+Arguments:
+
+ Operand - value to calculate power of two
+
+Returns:
+
+ the largest integer that is both a power of
+ two and less than Input
+
+--*/
+{
+ UINT8 Bitpos;
+ Bitpos = 0;
+
+ if (Operand == 0) {
+ return 0;
+ }
+
+ while (Operand != 0) {
+ Operand >>= 1;
+ Bitpos++;
+ }
+
+ Operand = 1;
+ Bitpos--;
+ while (Bitpos != 0) {
+ Operand <<= 1;
+ Bitpos--;
+ }
+
+ return Operand;
+}
diff --git a/EDK/Foundation/Library/EfiCommonLib/Misc.c b/EDK/Foundation/Library/EfiCommonLib/Misc.c
new file mode 100644
index 0000000..ef4fe58
--- /dev/null
+++ b/EDK/Foundation/Library/EfiCommonLib/Misc.c
@@ -0,0 +1,385 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ misc.c
+
+Abstract:
+
+--*/
+
+#include "Tiano.h"
+#include "pei.h"
+#include "cpuio.h"
+#include EFI_PPI_CONSUMER (PciCfg) //;;## ...AMI_OVERRIDE... Support PI1.x
+#include EFI_PPI_CONSUMER (PciCfg2) //;;## ...AMI_OVERRIDE... Support PI1.x
+#include EFI_PROTOCOL_CONSUMER (PciRootBridgeIo)
+
+//
+// Modular variable used by common libiary in PEI phase
+//
+EFI_GUID mPeiCpuIoPpiGuid = PEI_CPU_IO_PPI_GUID;
+#if (PI_SPECIFICATION_VERSION < 0x00010000) //;;## ...AMI_OVERRIDE... Support PI1.x
+EFI_GUID mPeiPciCfgPpiGuid = PEI_PCI_CFG_PPI_GUID;
+PEI_PCI_CFG_PPI *PciCfgPpi = NULL;
+#else
+EFI_GUID mPeiPciCfgPpiGuid = EFI_PEI_PCI_CFG2_PPI_GUID;
+EFI_PEI_PCI_CFG2_PPI *PciCfgPpi = NULL;
+#endif
+EFI_PEI_SERVICES **mPeiServices = NULL;
+PEI_CPU_IO_PPI *CpuIoPpi = NULL;
+
+//
+// Modular variable used by common libiary in DXE phase
+//
+EFI_SYSTEM_TABLE *mST = NULL;
+EFI_BOOT_SERVICES *mBS = NULL;
+EFI_RUNTIME_SERVICES *mRT = NULL;
+
+EFI_STATUS
+EfiInitializeCommonDriverLib (
+ IN EFI_HANDLE ImageHandle,
+ IN VOID *SystemTable
+ )
+/*++
+
+Routine Description:
+
+ Initialize lib function calling phase: PEI or DXE
+
+Arguments:
+
+ ImageHandle - The firmware allocated handle for the EFI image.
+
+ SystemTable - A pointer to the EFI System Table.
+
+Returns:
+
+ EFI_STATUS always returns EFI_SUCCESS
+
+--*/
+{
+ mPeiServices = NULL;
+ CpuIoPpi = NULL;
+ PciCfgPpi = NULL;
+
+ if (ImageHandle == NULL) {
+ //
+ // The function is called in PEI phase, use PEI interfaces
+ //
+ mPeiServices = (EFI_PEI_SERVICES **) SystemTable;
+
+ ASSERT (mPeiServices != NULL);
+
+ CpuIoPpi = (**mPeiServices).CpuIo;
+ PciCfgPpi = (**mPeiServices).PciCfg;
+
+ } else {
+ //
+ // ImageHandle is not NULL. The function is called in DXE phase
+ //
+ mST = SystemTable;
+ ASSERT (mST != NULL);
+
+ mBS = mST->BootServices;
+ mRT = mST->RuntimeServices;
+ ASSERT (mBS != NULL);
+ ASSERT (mRT != NULL);
+
+ //
+ // Should be at EFI_D_INFO, but lets us know things are running
+ //
+ DEBUG ((EFI_D_INFO, "EfiInitializeCommonDriverLib: Started in DXE\n"));
+ return EFI_SUCCESS;
+ }
+
+ return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+EfiCommonIoWrite (
+ IN UINT8 Width,
+ IN UINTN Address,
+ IN UINTN Count,
+ IN OUT VOID *Buffer
+ )
+/*++
+
+Routine Description:
+
+ Io write operation.
+
+Arguments:
+
+ Width - Width of write operation
+ Address - Start IO address to write
+ Count - Write count
+ Buffer - Buffer to write to the address
+
+Returns:
+
+ Status code
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *RootBridgeIo;
+
+ if (mPeiServices != NULL) {
+ //
+ // The function is called in PEI phase, use PEI interfaces
+ //
+ Status = CpuIoPpi->Io.Write (
+ mPeiServices,
+ CpuIoPpi,
+ Width,
+ Address,
+ Count,
+ Buffer
+ );
+ } else {
+ //
+ // The function is called in DXE phase
+ //
+ Status = mBS->LocateProtocol (
+ &gEfiPciRootBridgeIoProtocolGuid,
+ NULL,
+ (VOID **) &RootBridgeIo
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Status = RootBridgeIo->Io.Write (RootBridgeIo, Width, Address, Count, Buffer);
+ }
+
+ return Status;
+}
+
+
+EFI_STATUS
+EfiCommonIoRead (
+ IN UINT8 Width,
+ IN UINTN Address,
+ IN UINTN Count,
+ IN OUT VOID *Buffer
+ )
+/*++
+
+Routine Description:
+
+ Io read operation.
+
+Arguments:
+
+ Width - Width of read operation
+ Address - Start IO address to read
+ Count - Read count
+ Buffer - Buffer to store result
+
+Returns:
+
+ Status code
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *RootBridgeIo;
+
+ if (mPeiServices != NULL) {
+ //
+ // The function is called in PEI phase, use PEI interfaces
+ //
+ Status = CpuIoPpi->Io.Read (
+ mPeiServices,
+ CpuIoPpi,
+ Width,
+ Address,
+ Count,
+ Buffer
+ );
+ } else {
+ //
+ // The function is called in DXE phase
+ //
+ Status = mBS->LocateProtocol (
+ &gEfiPciRootBridgeIoProtocolGuid,
+ NULL,
+ (VOID **) &RootBridgeIo
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Status = RootBridgeIo->Io.Read (RootBridgeIo, Width, Address, Count, Buffer);
+ }
+
+ return Status;
+}
+
+
+EFI_STATUS
+EfiCommonPciWrite (
+ IN UINT8 Width,
+ IN UINT64 Address,
+ IN UINTN Count,
+ IN OUT VOID *Buffer
+ )
+/*++
+
+Routine Description:
+
+ Pci write operation
+
+Arguments:
+
+ Width - Width of PCI write
+ Address - PCI address to write
+ Count - Write count
+ Buffer - Buffer to write to the address
+
+Returns:
+
+ Status code
+
+--*/
+{
+ EFI_STATUS Status;
+ UINTN Index;
+ UINT8 *Buffer8;
+ EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *RootBridgeIo;
+
+ if (mPeiServices != NULL) {
+ //
+ // The function is called in PEI phase, use PEI interfaces
+ //
+ Buffer8 = Buffer;
+ for (Index = 0; Index < Count; Index++) {
+ Status = PciCfgPpi->Write (
+ mPeiServices,
+ PciCfgPpi,
+ Width,
+ Address,
+ Buffer8
+ );
+
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Buffer8 += Width;
+ }
+
+ } else {
+ //
+ // The function is called in DXE phase
+ //
+ Status = mBS->LocateProtocol (
+ &gEfiPciRootBridgeIoProtocolGuid,
+ NULL,
+ (VOID **) &RootBridgeIo
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Status = RootBridgeIo->Pci.Write (
+ RootBridgeIo,
+ Width,
+ Address,
+ Count,
+ Buffer
+ );
+ }
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EfiCommonPciRead (
+ IN UINT8 Width,
+ IN UINT64 Address,
+ IN UINTN Count,
+ IN OUT VOID *Buffer
+ )
+/*++
+
+Routine Description:
+
+ Pci read operation
+
+Arguments:
+
+ Width - Width of PCI read
+ Address - PCI address to read
+ Count - Read count
+ Buffer - Output buffer for the read
+
+Returns:
+
+ Status code
+
+--*/
+{
+ EFI_STATUS Status;
+ UINTN Index;
+ UINT8 *Buffer8;
+ EFI_PCI_ROOT_BRIDGE_IO_PROTOCOL *RootBridgeIo;
+
+ if (mPeiServices != NULL) {
+ //
+ // The function is called in PEI phase, use PEI interfaces
+ //
+ Buffer8 = Buffer;
+ for (Index = 0; Index < Count; Index++) {
+ Status = PciCfgPpi->Read (
+ mPeiServices,
+ PciCfgPpi,
+ Width,
+ Address,
+ Buffer8
+ );
+
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+//*** AMI PORTING BEGIN ***//
+// Buffer8 += Width;
+ Buffer8 += (UINTN)1 << Width;
+//*** AMI PORTING END ***//
+ }
+
+ } else {
+ //
+ // The function is called in DXE phase
+ //
+ Status = mBS->LocateProtocol (
+ &gEfiPciRootBridgeIoProtocolGuid,
+ NULL,
+ (VOID **) &RootBridgeIo
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Status = RootBridgeIo->Pci.Read (
+ RootBridgeIo,
+ Width,
+ Address,
+ Count,
+ Buffer
+ );
+ }
+
+ return EFI_SUCCESS;
+}
diff --git a/EDK/Foundation/Library/EfiCommonLib/PostCode.c b/EDK/Foundation/Library/EfiCommonLib/PostCode.c
new file mode 100644
index 0000000..bf9c544
--- /dev/null
+++ b/EDK/Foundation/Library/EfiCommonLib/PostCode.c
@@ -0,0 +1,62 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PostCode.c
+
+Abstract:
+
+ Worker functions for PostCode
+
+--*/
+
+#include "TianoCommon.h"
+#include "EfiCommonLib.h"
+
+BOOLEAN
+CodeTypeToPostCode (
+ IN EFI_STATUS_CODE_TYPE CodeType,
+ IN EFI_STATUS_CODE_VALUE Value,
+ OUT UINT8 *PostCode
+ )
+/*++
+
+Routine Description:
+
+ Convert code value to an 8 bit post code
+
+Arguments:
+
+ CodeType - Code type
+ Value - Code value
+ PostCode - Post code as output
+
+Returns:
+
+ TRUE - Successfully converted
+
+ FALSE - Convertion failed
+
+--*/
+{
+ //
+ // Convert Value to an 8 bit post code
+ //
+ if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_PROGRESS_CODE) ||
+ ((CodeType & EFI_STATUS_CODE_TYPE_MASK)== EFI_ERROR_CODE)) {
+ *PostCode = (UINT8) (((Value & EFI_STATUS_CODE_CLASS_MASK) >> 24) << 5);
+ *PostCode |= (UINT8) (((Value & EFI_STATUS_CODE_SUBCLASS_MASK) >> 16) & 0x1f);
+ return TRUE;
+ }
+
+ return FALSE;
+}
diff --git a/EDK/Foundation/Library/EfiCommonLib/ReportStatusCode.c b/EDK/Foundation/Library/EfiCommonLib/ReportStatusCode.c
new file mode 100644
index 0000000..8214d00
--- /dev/null
+++ b/EDK/Foundation/Library/EfiCommonLib/ReportStatusCode.c
@@ -0,0 +1,333 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ ReportStatusCode.c
+
+Abstract:
+
+ Worker functions for ReportStatusCode
+
+--*/
+
+#include "TianoCommon.h"
+#include "EfiCommonLib.h"
+#include EFI_GUID_DEFINITION (StatusCodeCallerId)
+#include EFI_GUID_DEFINITION (StatusCodeDataTypeId)
+
+
+VOID *
+EfiConstructStatusCodeData (
+ IN UINT16 DataSize,
+ IN EFI_GUID *TypeGuid,
+ IN OUT EFI_STATUS_CODE_DATA *Data
+ )
+/*++
+
+Routine Description:
+
+ Construct stanader header for optional data passed into ReportStatusCode
+
+Arguments:
+
+ DataSize - Size of optional data. Does not include EFI_STATUS_CODE_DATA header
+ TypeGuid - GUID to place in EFI_STATUS_CODE_DATA
+ Data - Buffer to use.
+
+Returns:
+
+ Return pointer to Data buffer pointing past the end of EFI_STATUS_CODE_DATA
+
+--*/
+{
+ Data->HeaderSize = sizeof (EFI_STATUS_CODE_DATA);
+ Data->Size = (UINT16)(DataSize - sizeof (EFI_STATUS_CODE_DATA));
+ EfiCommonLibCopyMem (&Data->Type, TypeGuid, sizeof (EFI_GUID));
+
+ return (VOID *)(Data + 1);
+}
+
+EFI_STATUS
+EfiDebugVPrintWorker (
+ IN UINTN ErrorLevel,
+ IN CHAR8 *Format,
+ IN VA_LIST Marker,
+ IN UINTN BufferSize,
+ IN OUT VOID *Buffer
+ )
+/*++
+
+Routine Description:
+
+ Worker function for DEBUG(). If Error Logging hub is loaded log ASSERT
+ information. If Error Logging hub is not loaded do nothing.
+
+ We use UINT64 buffers due to IPF alignment concerns.
+
+Arguments:
+
+ ErrorLevel - If error level is set do the debug print.
+
+ Format - String to use for the print, followed by Print arguments.
+
+ Marker - VarArgs
+
+ BufferSize - Size of Buffer.
+
+ Buffer - Caller allocated buffer, contains ReportStatusCode extended data
+
+Returns:
+
+ Status code
+
+ EFI_BUFFER_TOO_SMALL - Format too big to fit in buffer
+
+ EFI_SUCCESS - Successfully printed
+
+--*/
+{
+ UINTN Index;
+ UINTN FormatStrLen;
+ UINT64 *Ptr;
+ EFI_DEBUG_INFO *EfiDebug;
+
+
+ //
+ // Build the type specific EFI_STATUS_CODE_DATA in order
+ //
+
+ //
+ // Fill in EFI_STATUS_CODE_DATA to Buffer.
+ //
+ EfiDebug = (EFI_DEBUG_INFO *)EfiConstructStatusCodeData (
+ (UINT16)BufferSize,
+ &gEfiStatusCodeDataTypeDebugGuid,
+ Buffer
+ );
+
+ //
+ // Then EFI_DEBUG_INFO
+ //
+ EfiDebug->ErrorLevel = (UINT32)ErrorLevel;
+
+ //
+ // 256 byte mini Var Arg stack. That is followed by the format string.
+ //
+ for (Index = 0, Ptr = (UINT64 *)(EfiDebug + 1); Index < 12; Index++, Ptr++) {
+ *Ptr = VA_ARG (Marker, UINT64);
+ }
+
+ //
+ // Place Ascii Format string at the end
+ //
+ FormatStrLen = EfiAsciiStrLen (Format) + 1;
+ if (FormatStrLen > EFI_STATUS_CODE_DATA_MAX_SIZE) {
+ //
+ // Format too big to fit in our buffer, so do nothing.
+ //
+ return EFI_BUFFER_TOO_SMALL;
+ } else {
+ EfiCommonLibCopyMem (Ptr, Format, FormatStrLen);
+ }
+
+ return EFI_SUCCESS;
+}
+
+
+
+EFI_STATUS
+EfiDebugAssertWorker (
+ IN CHAR8 *Filename,
+ IN INTN LineNumber,
+ IN CHAR8 *Description,
+ IN UINTN BufferSize,
+ IN OUT VOID *Buffer
+ )
+/*++
+
+Routine Description:
+
+ Worker function for ASSERT (). If Error Logging hub is loaded log ASSERT
+ information. If Error Logging hub is not loaded DEADLOOP ().
+
+ We use UINT64 buffers due to IPF alignment concerns.
+
+Arguments:
+
+ Filename - File name of failing routine.
+
+ LineNumber - Line number of failing ASSERT().
+
+ Description - Description, usually the assertion,
+
+ BufferSize - Size of Buffer.
+
+ Buffer - Caller allocated buffer, contains ReportStatusCode extendecd data
+
+Returns:
+
+ Status code
+
+ EFI_BUFFER_TOO_SMALL - Buffer not large enough
+
+ EFI_SUCCESS - Function successfully done.
+
+--*/
+{
+ EFI_DEBUG_ASSERT_DATA *AssertData;
+ UINTN TotalSize;
+ CHAR8 *EndOfStr;
+
+ //
+ // Make sure it will all fit in the passed in buffer
+ //
+ TotalSize = sizeof (EFI_STATUS_CODE_DATA) + sizeof (EFI_DEBUG_ASSERT_DATA);
+ TotalSize += EfiAsciiStrLen (Filename) + EfiAsciiStrLen (Description);
+ if (TotalSize > BufferSize) {
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ //
+ // Fill in EFI_STATUS_CODE_DATA
+ //
+ AssertData = (EFI_DEBUG_ASSERT_DATA *)
+ EfiConstructStatusCodeData (
+ (UINT16)(TotalSize - sizeof (EFI_STATUS_CODE_DATA)),
+ &gEfiStatusCodeDataTypeAssertGuid,
+ Buffer
+ );
+
+ //
+ // Fill in EFI_DEBUG_ASSERT_DATA
+ //
+ AssertData->LineNumber = (UINT32)LineNumber;
+
+ //
+ // Copy Ascii FileName including NULL.
+ //
+ EndOfStr = EfiAsciiStrCpy ((CHAR8 *)(AssertData + 1), Filename);
+
+ //
+ // Copy Ascii Description
+ //
+ EfiAsciiStrCpy (EndOfStr, Description);
+ return EFI_SUCCESS;
+}
+
+
+
+BOOLEAN
+ReportStatusCodeExtractAssertInfo (
+ IN EFI_STATUS_CODE_TYPE CodeType,
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN EFI_STATUS_CODE_DATA *Data,
+ OUT CHAR8 **Filename,
+ OUT CHAR8 **Description,
+ OUT UINT32 *LineNumber
+ )
+/*++
+
+Routine Description:
+
+ Extract assert information from status code data.
+
+Arguments:
+
+ CodeType - Code type
+ Value - Code value
+ Data - Optional data associated with this status code.
+ Filename - Filename extracted from Data
+ Description - Description extracted from Data
+ LineNumber - Line number extracted from Data
+
+Returns:
+
+ TRUE - Successfully extracted
+
+ FALSE - Extraction failed
+
+--*/
+{
+ EFI_DEBUG_ASSERT_DATA *AssertData;
+
+ if (((CodeType & EFI_STATUS_CODE_TYPE_MASK) == EFI_ERROR_CODE) &&
+ ((CodeType & EFI_STATUS_CODE_SEVERITY_MASK) == EFI_ERROR_UNRECOVERED)) {
+ //
+ // Assume if we have an uncontained unrecoverable error that the data hub
+ // may not work. So we will print out data here. If we had an IPMI controller,
+ // or error log we could wack the hardware here.
+ //
+ if ((Value & EFI_STATUS_CODE_OPERATION_MASK) == EFI_SW_EC_ILLEGAL_SOFTWARE_STATE && (Data != NULL)) {
+ //
+ // ASSERT (Expresion) -
+ // ExtendedData == FileName
+ // Instance == Line Nuber
+ // NULL == String of Expresion
+ //
+ AssertData = (EFI_DEBUG_ASSERT_DATA *)(Data + 1);
+ *Filename = (CHAR8 *)(AssertData + 1);
+ *Description = *Filename + EfiAsciiStrLen (*Filename) + 1;
+ *LineNumber = AssertData->LineNumber;
+ return TRUE;
+ }
+ }
+ return FALSE;
+}
+
+
+BOOLEAN
+ReportStatusCodeExtractDebugInfo (
+ IN EFI_STATUS_CODE_DATA *Data,
+ OUT UINT32 *ErrorLevel,
+ OUT VA_LIST *Marker,
+ OUT CHAR8 **Format
+ )
+/*++
+
+Routine Description:
+
+ Extract debug information from status code data.
+
+Arguments:
+
+ Data - Optional data associated with status code.
+ ErrorLevel - Error level extracted from Data
+ Marker - VA_LIST extracted from Data
+ Format - Format string extracted from Data
+
+Returns:
+
+ TRUE - Successfully extracted
+
+ FALSE - Extraction failed
+
+--*/
+{
+ EFI_DEBUG_INFO *DebugInfo;
+
+ if ((Data == NULL) || (!EfiCompareGuid (&Data->Type, &gEfiStatusCodeDataTypeDebugGuid))) {
+ return FALSE;
+ }
+
+ DebugInfo = (EFI_DEBUG_INFO *)(Data + 1);
+
+ *ErrorLevel = DebugInfo->ErrorLevel;
+
+ //
+ // The first 12 * UINTN bytes of the string are really an
+ // arguement stack to support varargs on the Format string.
+ //
+ *Marker = (VA_LIST) (DebugInfo + 1);
+ *Format = (CHAR8 *)(((UINT64 *)*Marker) + 12);
+
+ return TRUE;
+}
diff --git a/EDK/Foundation/Library/EfiCommonLib/String.c b/EDK/Foundation/Library/EfiCommonLib/String.c
new file mode 100644
index 0000000..435bc66
--- /dev/null
+++ b/EDK/Foundation/Library/EfiCommonLib/String.c
@@ -0,0 +1,802 @@
+/*++
+
+Copyright (c) 2004 - 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ String.c
+
+Abstract:
+
+ Unicode string primatives
+
+--*/
+
+#include "Tiano.h"
+#include "EfiDriverLib.h"
+#include "EfiCommonLib.h"
+
+VOID
+EfiStrCpy (
+ IN CHAR16 *Destination,
+ IN CHAR16 *Source
+ )
+/*++
+
+Routine Description:
+ Copy the Unicode string Source to Destination.
+
+Arguments:
+ Destination - Location to copy string
+ Source - String to copy
+
+Returns:
+ NONE
+
+--*/
+{
+ while (*Source) {
+ *(Destination++) = *(Source++);
+ }
+ *Destination = 0;
+}
+
+VOID
+EfiStrnCpy (
+ OUT CHAR16 *Dst,
+ IN CHAR16 *Src,
+ IN UINTN Length
+ )
+/*++
+
+Routine Description:
+ Copy a string from source to destination
+
+Arguments:
+ Dst Destination string
+ Src Source string
+ Length Length of destination string
+
+Returns:
+
+--*/
+{
+ UINTN Index;
+ UINTN SrcLen;
+
+ SrcLen = EfiStrLen (Src);
+
+ Index = 0;
+ while (Index < Length && Index < SrcLen) {
+ Dst[Index] = Src[Index];
+ Index++;
+ }
+ for (Index = SrcLen; Index < Length; Index++) {
+ Dst[Index] = 0;
+ }
+}
+
+UINTN
+EfiStrLen (
+ IN CHAR16 *String
+ )
+/*++
+
+Routine Description:
+ Return the number of Unicode characters in String. This is not the same as
+ the length of the string in bytes.
+
+Arguments:
+ String - String to process
+
+Returns:
+ Number of Unicode characters in String
+
+--*/
+{
+ UINTN Length;
+
+ for (Length=0; *String; String++, Length++);
+ return Length;
+}
+
+
+UINTN
+EfiStrSize (
+ IN CHAR16 *String
+ )
+/*++
+
+Routine Description:
+ Return the number bytes in the Unicode String. This is not the same as
+ the length of the string in characters. The string size includes the NULL
+
+Arguments:
+ String - String to process
+
+Returns:
+ Number of bytes in String
+
+--*/
+{
+ return ((EfiStrLen (String) + 1) * sizeof (CHAR16));
+}
+
+
+INTN
+EfiStrCmp (
+ IN CHAR16 *String,
+ IN CHAR16 *String2
+ )
+/*++
+
+Routine Description:
+ Compare the Unicode string pointed by String to the string pointed by String2.
+
+Arguments:
+ String - String to process
+
+ String2 - The other string to process
+
+Returns:
+ Return a positive integer if String is lexicall greater than String2; Zero if
+ the two strings are identical; and a negative interger if String is lexically
+ less than String2.
+
+--*/
+{
+ while (*String) {
+ if (*String != *String2) {
+ break;
+ }
+
+ String += 1;
+ String2 += 1;
+ }
+
+ return *String - *String2;
+}
+
+INTN
+EfiStrnCmp (
+ IN CHAR16 *String,
+ IN CHAR16 *String2,
+ IN UINTN Length
+ )
+/*++
+
+Routine Description:
+ This function compares the Unicode string String to the Unicode
+ string String2 for len characters. If the first len characters
+ of String is identical to the first len characters of String2,
+ then 0 is returned. If substring of String sorts lexicographically
+ after String2, the function returns a number greater than 0. If
+ substring of String sorts lexicographically before String2, the
+ function returns a number less than 0.
+
+Arguments:
+ String - Compare to String2
+ String2 - Compare to String
+ Length - Number of Unicode characters to compare
+
+Returns:
+ 0 - The substring of String and String2 is identical.
+ > 0 - The substring of String sorts lexicographically after String2
+ < 0 - The substring of String sorts lexicographically before String2
+
+--*/
+{
+ while (*String && Length != 0) {
+ if (*String != *String2) {
+ break;
+ }
+ String += 1;
+ String2 += 1;
+ Length -= 1;
+ }
+ return Length > 0 ? *String - *String2 : 0;
+}
+
+VOID
+EfiStrCat (
+ IN CHAR16 *Destination,
+ IN CHAR16 *Source
+ )
+/*++
+
+Routine Description:
+ Concatinate Source on the end of Destination
+
+Arguments:
+ Destination - String to added to the end of.
+ Source - String to concatinate.
+
+Returns:
+ NONE
+
+--*/
+{
+ EfiStrCpy (Destination + EfiStrLen (Destination), Source);
+}
+
+VOID
+EfiStrnCat (
+ IN CHAR16 *Dest,
+ IN CHAR16 *Src,
+ IN UINTN Length
+ )
+/*++
+
+Routine Description:
+ Concatinate Source on the end of Destination
+
+Arguments:
+ Dst Destination string
+ Src Source string
+ Length Length of destination string
+
+Returns:
+
+--*/
+{
+ EfiStrnCpy (Dest + EfiStrLen (Dest), Src, Length);
+}
+
+UINTN
+EfiAsciiStrLen (
+ IN CHAR8 *String
+ )
+/*++
+
+Routine Description:
+ Return the number of Ascii characters in String. This is not the same as
+ the length of the string in bytes.
+
+Arguments:
+ String - String to process
+
+Returns:
+ Number of Ascii characters in String
+
+--*/
+{
+ UINTN Length;
+
+ for (Length=0; *String; String++, Length++);
+ return Length;
+}
+
+
+CHAR8 *
+EfiAsciiStrCpy (
+ IN CHAR8 *Destination,
+ IN CHAR8 *Source
+ )
+/*++
+
+Routine Description:
+ Copy the Ascii string Source to Destination.
+
+Arguments:
+ Destination - Location to copy string
+ Source - String to copy
+
+Returns:
+ Pointer just pass the end of Destination
+
+--*/
+{
+ while (*Source) {
+ *(Destination++) = *(Source++);
+ }
+ *Destination = 0;
+ return Destination + 1;
+}
+
+VOID
+EfiAsciiStrnCpy (
+ OUT CHAR8 *Dst,
+ IN CHAR8 *Src,
+ IN UINTN Length
+ )
+/*++
+
+Routine Description:
+ Copy the Ascii string from source to destination
+
+Arguments:
+ Dst Destination string
+ Src Source string
+ Length Length of destination string
+
+Returns:
+
+--*/
+{
+ UINTN Index;
+ UINTN SrcLen;
+
+ SrcLen = EfiAsciiStrLen (Src);
+
+ Index = 0;
+ while (Index < Length && Index < SrcLen) {
+ Dst[Index] = Src[Index];
+ Index++;
+ }
+ for (Index = SrcLen; Index < Length; Index++) {
+ Dst[Index] = 0;
+ }
+}
+
+UINTN
+EfiAsciiStrSize (
+ IN CHAR8 *String
+ )
+/*++
+
+Routine Description:
+ Return the number bytes in the Ascii String. This is not the same as
+ the length of the string in characters. The string size includes the NULL
+
+Arguments:
+ String - String to process
+
+Returns:
+ Number of bytes in String
+
+--*/
+{
+ return (EfiAsciiStrLen (String) + 1);
+}
+
+
+INTN
+EfiAsciiStrCmp (
+ IN CHAR8 *String,
+ IN CHAR8 *String2
+ )
+/*++
+
+Routine Description:
+ Compare the Ascii string pointed by String to the string pointed by String2.
+
+Arguments:
+ String - String to process
+
+ String2 - The other string to process
+
+Returns:
+ Return a positive integer if String is lexicall greater than String2; Zero if
+ the two strings are identical; and a negative interger if String is lexically
+ less than String2.
+--*/
+{
+ while (*String) {
+ if (*String != *String2) {
+ break;
+ }
+
+ String += 1;
+ String2 += 1;
+ }
+
+ return *String - *String2;
+}
+
+INTN
+EfiAsciiStrnCmp (
+ IN CHAR8 *String,
+ IN CHAR8 *String2,
+ IN UINTN Length
+ )
+{
+ if (Length == 0) {
+ return 0;
+ }
+
+ while ((*String != '\0') &&
+ (*String == *String2) &&
+ (Length > 1)) {
+ String++;
+ String2++;
+ Length--;
+ }
+ return *String - *String2;
+}
+
+VOID
+EfiAsciiStrCat (
+ IN CHAR8 *Destination,
+ IN CHAR8 *Source
+ )
+/*++
+
+Routine Description:
+ Concatinate Source on the end of Destination
+
+Arguments:
+ Destination - String to added to the end of.
+ Source - String to concatinate.
+
+Returns:
+ NONE
+
+--*/
+{
+ EfiAsciiStrCpy (Destination + EfiAsciiStrLen (Destination), Source);
+}
+
+VOID
+EfiAsciiStrnCat (
+ IN CHAR8 *Destination,
+ IN CHAR8 *Source,
+ IN UINTN Length
+ )
+/*++
+
+Routine Description:
+ Concatinate Source on the end of Destination
+
+Arguments:
+ Destination - String to added to the end of.
+ Source - String to concatinate.
+
+Returns:
+ NONE
+
+--*/
+{
+ EfiAsciiStrnCpy (Destination + EfiAsciiStrLen (Destination), Source, Length);
+}
+
+BOOLEAN
+IsHexDigit (
+ OUT UINT8 *Digit,
+ IN CHAR16 Char
+ )
+/*++
+
+ Routine Description:
+ Determines if a Unicode character is a hexadecimal digit.
+ The test is case insensitive.
+
+ Arguments:
+ Digit - Pointer to byte that receives the value of the hex character.
+ Char - Unicode character to test.
+
+ Returns:
+ TRUE - If the character is a hexadecimal digit.
+ FALSE - Otherwise.
+
+--*/
+{
+ if ((Char >= L'0') && (Char <= L'9')) {
+ *Digit = (UINT8) (Char - L'0');
+ return TRUE;
+ }
+
+ if ((Char >= L'A') && (Char <= L'F')) {
+ *Digit = (UINT8) (Char - L'A' + 0x0A);
+ return TRUE;
+ }
+
+ if ((Char >= L'a') && (Char <= L'f')) {
+ *Digit = (UINT8) (Char - L'a' + 0x0A);
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
+CHAR16
+NibbleToHexChar (
+ IN UINT8 Nibble
+ )
+/*++
+
+ Routine Description:
+ Converts the low nibble of a byte to hex unicode character.
+
+ Arguments:
+ Nibble - lower nibble of a byte.
+
+ Returns:
+ Hex unicode character.
+
+--*/
+{
+ Nibble &= 0x0F;
+ if (Nibble <= 0x9) {
+ return (CHAR16)(Nibble + L'0');
+ }
+
+ return (CHAR16)(Nibble - 0xA + L'A');
+}
+
+EFI_STATUS
+HexStringToBuf (
+ IN OUT UINT8 *Buf,
+ IN OUT UINTN *Len,
+ IN CHAR16 *Str,
+ OUT UINTN *ConvertedStrLen OPTIONAL
+ )
+/*++
+
+ Routine Description:
+ Converts Unicode string to binary buffer.
+ The conversion may be partial.
+ The first character in the string that is not hex digit stops the conversion.
+ At a minimum, any blob of data could be represented as a hex string.
+
+ Arguments:
+ Buf - Pointer to buffer that receives the data.
+ Len - Length in bytes of the buffer to hold converted data.
+ If routine return with EFI_SUCCESS, containing length of converted data.
+ If routine return with EFI_BUFFER_TOO_SMALL, containg length of buffer desired.
+ Str - String to be converted from.
+ ConvertedStrLen - Length of the Hex String consumed.
+
+ Returns:
+ EFI_SUCCESS: Routine Success.
+ EFI_BUFFER_TOO_SMALL: The buffer is too small to hold converted data.
+ EFI_
+
+--*/
+{
+ UINTN HexCnt;
+ UINTN Idx;
+ UINTN BufferLength;
+ UINT8 Digit;
+ UINT8 Byte;
+
+ //
+ // Find out how many hex characters the string has.
+ //
+ for (Idx = 0, HexCnt = 0; IsHexDigit (&Digit, Str[Idx]); Idx++, HexCnt++);
+
+ if (HexCnt == 0) {
+ *Len = 0;
+ return EFI_SUCCESS;
+ }
+ //
+ // Two Unicode characters make up 1 buffer byte. Round up.
+ //
+ BufferLength = (HexCnt + 1) / 2;
+
+ //
+ // Test if buffer is passed enough.
+ //
+ if (BufferLength > (*Len)) {
+ *Len = BufferLength;
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ *Len = BufferLength;
+
+ for (Idx = 0; Idx < HexCnt; Idx++) {
+
+ IsHexDigit (&Digit, Str[HexCnt - 1 - Idx]);
+
+ //
+ // For odd charaters, write the lower nibble for each buffer byte,
+ // and for even characters, the upper nibble.
+ //
+ if ((Idx & 1) == 0) {
+ Byte = Digit;
+ } else {
+ Byte = Buf[Idx / 2];
+ Byte &= 0x0F;
+ Byte |= Digit << 4;
+ }
+
+ Buf[Idx / 2] = Byte;
+ }
+
+ if (ConvertedStrLen != NULL) {
+ *ConvertedStrLen = HexCnt;
+ }
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+BufToHexString (
+ IN OUT CHAR16 *Str,
+ IN OUT UINTN *HexStringBufferLength,
+ IN UINT8 *Buf,
+ IN UINTN Len
+ )
+/*++
+
+ Routine Description:
+ Converts binary buffer to Unicode string.
+ At a minimum, any blob of data could be represented as a hex string.
+
+ Arguments:
+ Str - Pointer to the string.
+ HexStringBufferLength - Length in bytes of buffer to hold the hex string. Includes tailing '\0' character.
+ If routine return with EFI_SUCCESS, containing length of hex string buffer.
+ If routine return with EFI_BUFFER_TOO_SMALL, containg length of hex string buffer desired.
+ Buf - Buffer to be converted from.
+ Len - Length in bytes of the buffer to be converted.
+
+ Returns:
+ EFI_SUCCESS: Routine success.
+ EFI_BUFFER_TOO_SMALL: The hex string buffer is too small.
+
+--*/
+{
+ UINTN Idx;
+ UINT8 Byte;
+ UINTN StrLen;
+
+ //
+ // Make sure string is either passed or allocate enough.
+ // It takes 2 Unicode characters (4 bytes) to represent 1 byte of the binary buffer.
+ // Plus the Unicode termination character.
+ //
+ StrLen = Len * 2;
+ if (StrLen > ((*HexStringBufferLength) - 1)) {
+ *HexStringBufferLength = StrLen + 1;
+ return EFI_BUFFER_TOO_SMALL;
+ }
+
+ *HexStringBufferLength = StrLen + 1;
+ //
+ // Ends the string.
+ //
+ Str[StrLen] = L'\0';
+
+ for (Idx = 0; Idx < Len; Idx++) {
+
+ Byte = Buf[Idx];
+ Str[StrLen - 1 - Idx * 2] = NibbleToHexChar (Byte);
+ Str[StrLen - 2 - Idx * 2] = NibbleToHexChar ((UINT8)(Byte >> 4));
+ }
+
+ return EFI_SUCCESS;
+}
+
+VOID
+EfiStrTrim (
+ IN OUT CHAR16 *str,
+ IN CHAR16 CharC
+ )
+/*++
+
+Routine Description:
+
+ Removes (trims) specified leading and trailing characters from a string.
+
+Arguments:
+
+ str - Pointer to the null-terminated string to be trimmed. On return,
+ str will hold the trimmed string.
+ CharC - Character will be trimmed from str.
+
+Returns:
+
+--*/
+{
+ CHAR16 *p1;
+ CHAR16 *p2;
+
+ if (*str == 0) {
+ return;
+ }
+
+ //
+ // Trim off the leading and trailing characters c
+ //
+ for (p1 = str; *p1 && *p1 == CharC; p1++) {
+ ;
+ }
+
+ p2 = str;
+ if (p2 == p1) {
+ while (*p1) {
+ p2++;
+ p1++;
+ }
+ } else {
+ while (*p1) {
+ *p2 = *p1;
+ p1++;
+ p2++;
+ }
+ *p2 = 0;
+ }
+
+
+ for (p1 = str + EfiStrLen(str) - 1; p1 >= str && *p1 == CharC; p1--) {
+ ;
+ }
+ if (p1 != str + EfiStrLen(str) - 1) {
+ *(p1 + 1) = 0;
+ }
+}
+CHAR16*
+EfiStrStr (
+ IN CHAR16 *String,
+ IN CHAR16 *StrCharSet
+ )
+/*++
+
+Routine Description:
+
+ Find a substring.
+
+Arguments:
+
+ String - Null-terminated string to search.
+ StrCharSet - Null-terminated string to search for.
+
+Returns:
+ The address of the first occurrence of the matching substring if successful, or NULL otherwise.
+--*/
+{
+ CHAR16 *Src;
+ CHAR16 *Sub;
+
+ Src = String;
+ Sub = StrCharSet;
+
+ while ((*String != L'\0') && (*StrCharSet != L'\0')) {
+ if (*String++ != *StrCharSet++) {
+ String = ++Src;
+ StrCharSet = Sub;
+ }
+ }
+ if (*StrCharSet == L'\0') {
+ return Src;
+ } else {
+ return NULL;
+ }
+}
+
+CHAR8*
+EfiAsciiStrStr (
+ IN CHAR8 *String,
+ IN CHAR8 *StrCharSet
+ )
+/*++
+
+Routine Description:
+
+ Find a Ascii substring.
+
+Arguments:
+
+ String - Null-terminated Ascii string to search.
+ StrCharSet - Null-terminated Ascii string to search for.
+
+Returns:
+ The address of the first occurrence of the matching Ascii substring if successful, or NULL otherwise.
+--*/
+{
+ CHAR8 *Src;
+ CHAR8 *Sub;
+
+ Src = String;
+ Sub = StrCharSet;
+
+ while ((*String != '\0') && (*StrCharSet != '\0')) {
+ if (*String++ != *StrCharSet++) {
+ String = ++Src;
+ StrCharSet = Sub;
+ }
+ }
+ if (*StrCharSet == '\0') {
+ return Src;
+ } else {
+ return NULL;
+ }
+}
+
diff --git a/EDK/Foundation/Library/EfiCommonLib/ValueToString.c b/EDK/Foundation/Library/EfiCommonLib/ValueToString.c
new file mode 100644
index 0000000..f31b0de
--- /dev/null
+++ b/EDK/Foundation/Library/EfiCommonLib/ValueToString.c
@@ -0,0 +1,213 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ ValueToString.c
+
+Abstract:
+
+ Routines changing value to Hex or Dec string
+
+--*/
+
+#include "Tiano.h"
+#include "EfiDriverLib.h"
+
+static CHAR16 mHexStr[] = { L'0', L'1', L'2', L'3', L'4', L'5', L'6', L'7',
+ L'8', L'9', L'A', L'B', L'C', L'D', L'E', L'F' };
+
+UINTN
+EfiValueToHexStr (
+ IN OUT CHAR16 *Buffer,
+ IN UINT64 Value,
+ IN UINTN Flags,
+ IN UINTN Width
+ )
+/*++
+
+Routine Description:
+
+ VSPrint worker function that prints a Value as a hex number in Buffer
+
+Arguments:
+
+ Buffer - Location to place ascii hex string of Value.
+
+ Value - Hex value to convert to a string in Buffer.
+
+ Flags - Flags to use in printing Hex string, see file header for details.
+
+ Width - Width of hex value.
+
+Returns:
+
+ Number of characters printed.
+
+--*/
+{
+ CHAR16 TempBuffer[CHARACTER_NUMBER_FOR_VALUE];
+ CHAR16 *TempStr;
+ CHAR16 Prefix;
+ CHAR16 *BufferPtr;
+ UINTN Count;
+ UINTN Index;
+
+ TempStr = TempBuffer;
+ BufferPtr = Buffer;
+
+ //
+ // Count starts at one since we will null terminate. Each iteration of the
+ // loop picks off one nibble. Oh yea TempStr ends up backwards
+ //
+ Count = 0;
+
+ if (Width > CHARACTER_NUMBER_FOR_VALUE - 1) {
+ Width = CHARACTER_NUMBER_FOR_VALUE - 1;
+ }
+
+ do {
+ Index = ((UINTN)Value & 0xf);
+ *(TempStr++) = mHexStr[Index];
+ Value = RShiftU64 (Value, 4);
+ Count++;
+ } while (Value != 0);
+
+ if (Flags & PREFIX_ZERO) {
+ Prefix = '0';
+ } else {
+ Prefix = ' ';
+ }
+
+ Index = Count;
+ if (!(Flags & LEFT_JUSTIFY)) {
+ for (; Index < Width; Index++) {
+ *(TempStr++) = Prefix;
+ }
+ }
+
+ //
+ // Reverse temp string into Buffer.
+ //
+ if (Width > 0 && (UINTN) (TempStr - TempBuffer) > Width) {
+ TempStr = TempBuffer + Width;
+ }
+ Index = 0;
+ while (TempStr != TempBuffer) {
+ *(BufferPtr++) = *(--TempStr);
+ Index++;
+ }
+
+ *BufferPtr = 0;
+ return Index;
+}
+
+
+UINTN
+EfiValueToString (
+ IN OUT CHAR16 *Buffer,
+ IN INT64 Value,
+ IN UINTN Flags,
+ IN UINTN Width
+ )
+/*++
+
+Routine Description:
+
+ VSPrint worker function that prints a Value as a decimal number in Buffer
+
+Arguments:
+
+ Buffer - Location to place ascii decimal number string of Value.
+
+ Value - Decimal value to convert to a string in Buffer.
+
+ Flags - Flags to use in printing decimal string, see file header for details.
+
+ Width - Width of hex value.
+
+Returns:
+
+ Number of characters printed.
+
+--*/
+{
+ CHAR16 TempBuffer[CHARACTER_NUMBER_FOR_VALUE];
+ CHAR16 *TempStr;
+ CHAR16 *BufferPtr;
+ UINTN Count;
+ UINTN ValueCharNum;
+ UINTN Remainder;
+ CHAR16 Prefix;
+ UINTN Index;
+ BOOLEAN ValueIsNegative;
+
+ TempStr = TempBuffer;
+ BufferPtr = Buffer;
+ Count = 0;
+ ValueCharNum = 0;
+ ValueIsNegative = FALSE;
+
+ if (Width > CHARACTER_NUMBER_FOR_VALUE - 1) {
+ Width = CHARACTER_NUMBER_FOR_VALUE - 1;
+ }
+
+ if (Value < 0) {
+ Value = -Value;
+ ValueIsNegative = TRUE;
+ }
+
+ do {
+ Value = (INT64)DivU64x32 ((UINT64)Value, 10, &Remainder);
+ *(TempStr++) = (CHAR16)(Remainder + '0');
+ ValueCharNum++;
+ Count++;
+ if ((Flags & COMMA_TYPE) == COMMA_TYPE) {
+ if (ValueCharNum % 3 == 0 && Value != 0) {
+ *(TempStr++) = ',';
+ Count++;
+ }
+ }
+ } while (Value != 0);
+
+ if (ValueIsNegative) {
+ *(TempStr++) = '-';
+ Count++;
+ }
+
+ if ((Flags & PREFIX_ZERO) && !ValueIsNegative) {
+ Prefix = '0';
+ } else {
+ Prefix = ' ';
+ }
+
+ Index = Count;
+ if (!(Flags & LEFT_JUSTIFY)) {
+ for (; Index < Width; Index++) {
+ *(TempStr++) = Prefix;
+ }
+ }
+
+ //
+ // Reverse temp string into Buffer.
+ //
+ if (Width > 0 && (UINTN) (TempStr - TempBuffer) > Width) {
+ TempStr = TempBuffer + Width;
+ }
+ Index = 0;
+ while (TempStr != TempBuffer) {
+ *(BufferPtr++) = *(--TempStr);
+ Index++;
+ }
+
+ *BufferPtr = 0;
+ return Index;
+}
diff --git a/EDK/Foundation/Library/EfiCommonLib/linkedlist.c b/EDK/Foundation/Library/EfiCommonLib/linkedlist.c
new file mode 100644
index 0000000..fcec55f
--- /dev/null
+++ b/EDK/Foundation/Library/EfiCommonLib/linkedlist.c
@@ -0,0 +1,356 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ LinkedList.c
+
+Abstract:
+
+ Linked List Library Functions
+
+--*/
+
+#include "Tiano.h"
+#include "EfiDriverLib.h"
+
+
+VOID
+InitializeListHead (
+ EFI_LIST_ENTRY *List
+ )
+/*++
+
+Routine Description:
+
+ Initialize the head of the List. The caller must allocate the memory
+ for the EFI_LIST. This function must be called before the other linked
+ list macros can be used.
+
+Arguments:
+
+ List - Pointer to list head to initialize
+
+Returns:
+
+ None.
+
+--*/
+
+{
+ List->ForwardLink = List;
+ List->BackLink = List;
+}
+
+
+BOOLEAN
+IsListEmpty (
+ EFI_LIST_ENTRY *List
+ )
+/*++
+
+Routine Description:
+
+ Return TRUE is the list contains zero nodes. Otherzise return FALSE.
+ The list must have been initialized with InitializeListHead () before using
+ this function.
+
+Arguments:
+
+ List - Pointer to list head to test
+
+
+Returns:
+
+ Return TRUE is the list contains zero nodes. Otherzise return FALSE.
+
+--*/
+{
+ return (BOOLEAN)(List->ForwardLink == List);
+}
+
+
+VOID
+RemoveEntryList (
+ EFI_LIST_ENTRY *Entry
+ )
+/*++
+
+Routine Description:
+
+ Remove Node from the doubly linked list. It is the caller's responsibility
+ to free any memory used by the entry if needed. The list must have been
+ initialized with InitializeListHead () before using this function.
+
+Arguments:
+
+ Entry - Element to remove from the list.
+
+Returns:
+
+ None
+
+--*/
+{
+ EFI_LIST_ENTRY *_ForwardLink;
+ EFI_LIST_ENTRY *_BackLink;
+
+ _ForwardLink = Entry->ForwardLink;
+ _BackLink = Entry->BackLink;
+ _BackLink->ForwardLink = _ForwardLink;
+ _ForwardLink->BackLink = _BackLink;
+
+ DEBUG_CODE (
+ Entry->ForwardLink = (EFI_LIST_ENTRY *) EFI_BAD_POINTER;
+ Entry->BackLink = (EFI_LIST_ENTRY *) EFI_BAD_POINTER;
+ )
+}
+
+
+VOID
+InsertTailList (
+ EFI_LIST_ENTRY *ListHead,
+ EFI_LIST_ENTRY *Entry
+ )
+/*++
+
+Routine Description:
+
+ Insert a Node into the end of a doubly linked list. The list must have
+ been initialized with InitializeListHead () before using this function.
+
+Arguments:
+
+ ListHead - Head of doubly linked list
+
+ Entry - Element to insert at the end of the list.
+
+Returns:
+
+ None
+
+--*/
+{
+ EFI_LIST_ENTRY *_ListHead;
+ EFI_LIST_ENTRY *_BackLink;
+
+ _ListHead = ListHead;
+ _BackLink = _ListHead->BackLink;
+ Entry->ForwardLink = _ListHead;
+ Entry->BackLink = _BackLink;
+ _BackLink->ForwardLink = Entry;
+ _ListHead->BackLink = Entry;
+}
+
+
+
+VOID
+InsertHeadList (
+ EFI_LIST_ENTRY *ListHead,
+ EFI_LIST_ENTRY *Entry
+ )
+/*++
+
+Routine Description:
+
+ Insert a Node into the start of a doubly linked list. The list must have
+ been initialized with InitializeListHead () before using this function.
+
+Arguments:
+
+ ListHead - Head of doubly linked list
+
+ Entry - Element to insert to beginning of list
+
+Returns:
+
+ None
+
+--*/
+{
+ EFI_LIST_ENTRY *_ListHead;
+ EFI_LIST_ENTRY *_ForwardLink;
+
+ _ListHead = ListHead;
+ _ForwardLink = _ListHead->ForwardLink;
+ Entry->ForwardLink = _ForwardLink;
+ Entry->BackLink = _ListHead;
+ _ForwardLink->BackLink = Entry;
+ _ListHead->ForwardLink = Entry;
+}
+
+VOID
+SwapListEntries (
+ EFI_LIST_ENTRY *Entry1,
+ EFI_LIST_ENTRY *Entry2
+ )
+/*++
+
+Routine Description:
+
+ Swap the location of the two elements of a doubly linked list. Node2
+ is placed in front of Node1. The list must have been initialized with
+ InitializeListHead () before using this function.
+
+Arguments:
+
+ Entry1 - Element in the doubly linked list in front of Node2.
+
+ Entry2 - Element in the doubly linked list behind Node1.
+
+Returns:
+
+ None
+
+--*/
+{
+ EFI_LIST_ENTRY *Entry1ForwardLink;
+ EFI_LIST_ENTRY *Entry1BackLink;
+ EFI_LIST_ENTRY *Entry2ForwardLink;
+ EFI_LIST_ENTRY *Entry2BackLink;
+
+ Entry2ForwardLink = Entry2->ForwardLink;
+ Entry2BackLink = Entry2->BackLink;
+ Entry1ForwardLink = Entry1->ForwardLink;
+ Entry1BackLink = Entry1->BackLink;
+ Entry2BackLink->ForwardLink = Entry2ForwardLink;
+ Entry2ForwardLink->BackLink = Entry2BackLink;
+ Entry2->ForwardLink = Entry1;
+ Entry2->BackLink = Entry1BackLink;
+ Entry1BackLink->ForwardLink = Entry2;
+ Entry1->BackLink = Entry2;
+}
+
+
+EFI_LIST_ENTRY *
+GetFirstNode (
+ EFI_LIST_ENTRY *List
+ )
+/*++
+
+Routine Description:
+
+ Return the first node pointed to by the list head. The list must
+ have been initialized with InitializeListHead () before using this
+ function and must contain data.
+
+Arguments:
+
+ List - The head of the doubly linked list.
+
+Returns:
+
+ Pointer to the first node, if the list contains nodes. The list will
+ return a null value--that is, the value of List--when the list is empty.
+ See the description of IsNull for more information.
+
+
+--*/
+{
+ return List->ForwardLink;
+}
+
+
+EFI_LIST_ENTRY *
+GetNextNode (
+ EFI_LIST_ENTRY *List,
+ EFI_LIST_ENTRY *Node
+ )
+/*++
+
+Routine Description:
+
+ Returns the node following Node in the list. The list must
+ have been initialized with InitializeListHead () before using this
+ function and must contain data.
+
+Arguments:
+
+ List - The head of the list. MUST NOT be the literal value NULL.
+ Node - The node in the list. This value MUST NOT be the literal value NULL.
+ See the description of IsNull for more information.
+
+Returns:
+
+ Pointer to the next node, if one exists. Otherwise, returns a null value,
+ which is actually a pointer to List.
+ See the description of IsNull for more information.
+
+--*/
+{
+ if (Node == List) {
+ return List;
+ }
+ return Node->ForwardLink;
+}
+
+
+BOOLEAN
+IsNull (
+ EFI_LIST_ENTRY *List,
+ EFI_LIST_ENTRY *Node
+ )
+/*++
+
+Routine Description:
+
+ Determines whether the given node is null. Note that Node is null
+ when its value is equal to the value of List. It is an error for
+ Node to be the literal value NULL [(VOID*)0x0].
+
+Arguments:
+
+ List - The head of the list. MUST NOT be the literal value NULL.
+ Node - The node to test. MUST NOT be the literal value NULL. See
+ the description above.
+
+Returns:
+
+ Returns true if the node is null.
+
+--*/
+{
+ return (BOOLEAN)(Node == List);
+}
+
+
+BOOLEAN
+IsNodeAtEnd (
+ EFI_LIST_ENTRY *List,
+ EFI_LIST_ENTRY *Node
+ )
+/*++
+
+Routine Description:
+
+ Determines whether the given node is at the end of the list. Used
+ to walk the list. The list must have been initialized with
+ InitializeListHead () before using this function and must contain
+ data.
+
+Arguments:
+
+ List - The head of the list. MUST NOT be the literal value NULL.
+ Node - The node to test. MUST NOT be the literal value NULL.
+ See the description of IsNull for more information.
+
+Returns:
+
+ Returns true if the list is the tail.
+
+--*/
+{
+ if (IsNull (List, Node)) {
+ return FALSE;
+ }
+ return (BOOLEAN)(List->BackLink == Node);
+}
+
diff --git a/EDK/Foundation/Library/EfiCommonLib/x64/EfiCopyMemRep4.asm b/EDK/Foundation/Library/EfiCommonLib/x64/EfiCopyMemRep4.asm
new file mode 100644
index 0000000..62e377c
--- /dev/null
+++ b/EDK/Foundation/Library/EfiCommonLib/x64/EfiCopyMemRep4.asm
@@ -0,0 +1,65 @@
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2007, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; EfiCopyMemRep4.asm
+;
+; Abstract:
+;
+; CopyMem function
+;
+; Notes:
+;
+;------------------------------------------------------------------------------
+
+ .code
+
+;------------------------------------------------------------------------------
+; VOID
+; EfiCommonLibCopyMem (
+; OUT VOID *Destination,
+; IN VOID *Source,
+; IN UINTN Count
+; );
+;------------------------------------------------------------------------------
+EfiCommonLibCopyMem PROC USES rsi rdi
+ cmp rdx, rcx ; if Source == Destination, do nothing
+ je @CopyMemDone
+ cmp r8, 0 ; if Count == 0, do nothing
+ je @CopyMemDone
+ mov rsi, rdx ; rsi <- Source
+ mov rdi, rcx ; rdi <- Destination
+ lea r9, [rsi + r8 - 1] ; r9 <- End of Source
+ cmp rsi, rdi
+ jae @F
+ cmp r9, rdi
+ jae @CopyBackward ; Copy backward if overlapped
+@@:
+ mov rcx, r8
+ and r8, 3
+ shr rcx, 2
+ rep movsd ; Copy as many Dwords as possible
+ jmp @CopyBytes
+@CopyBackward:
+ mov rsi, r9 ; rsi <- End of Source
+ lea rdi, [rdi + r8 - 1] ; esi <- End of Destination
+ std ; set direction flag
+@CopyBytes:
+ mov rcx, r8
+ rep movsb ; Copy bytes backward
+ cld
+@CopyMemDone:
+ ret
+EfiCommonLibCopyMem ENDP
+
+ END
+
diff --git a/EDK/Foundation/Library/Pei/Hob/PeiHobLib.c b/EDK/Foundation/Library/Pei/Hob/PeiHobLib.c
new file mode 100644
index 0000000..15421df
--- /dev/null
+++ b/EDK/Foundation/Library/Pei/Hob/PeiHobLib.c
@@ -0,0 +1,721 @@
+
+/*++
+
+Copyright (c) 2004 - 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+MemoryAllocationModule Name:
+
+ Peihoblib.c
+
+Abstract:
+
+ PEI Library Functions
+
+--*/
+
+#include "Tiano.h"
+#include "PeiHob.h"
+#include "peihoblib.h"
+#include "peilib.h"
+#include EFI_GUID_DEFINITION(MemoryAllocationHob)
+
+
+EFI_PEI_HOB_POINTERS
+BuildHobEndOfHobList (
+ IN VOID *HobStart
+ )
+/*++
+
+Routine Description:
+
+ Builds an end of HOB list HOB
+
+Arguments:
+
+ HobStart - The HOB to build
+
+Returns:
+
+ A pointer to the next HOB
+
+--*/
+{
+ EFI_PEI_HOB_POINTERS Hob;
+
+ Hob.Raw = HobStart;
+
+ Hob.Header->HobType = EFI_HOB_TYPE_END_OF_HOB_LIST;
+ Hob.Header->HobLength = sizeof(EFI_HOB_GENERIC_HEADER);
+
+ Hob.Header++;
+ return Hob;
+}
+
+EFI_STATUS
+BuildHobHandoffInfoTable (
+ IN VOID *HobStart,
+ IN UINT16 Version,
+ IN EFI_BOOT_MODE BootMode,
+ IN EFI_PHYSICAL_ADDRESS EfiMemoryTop,
+ IN EFI_PHYSICAL_ADDRESS EfiMemoryBottom,
+ IN EFI_PHYSICAL_ADDRESS EfiFreeMemoryTop,
+ IN EFI_PHYSICAL_ADDRESS EfiFreeMemoryBottom
+ )
+/*++
+
+Routine Description:
+
+ Builds a HandoffInformationTable Information Table HOB
+
+Arguments:
+
+ HobStart - Start pointer of hob list
+ Version - The version number pertaining to the PHIT HOB definition.
+ BootMode - The system boot mode as determined during the HOB producer phase.
+ EfiMemoryTop - The highest address location of memory that is allocated for use by the HOB
+ producer phase.
+ EfiMemoryBottom - The lowest address location of memory that is allocated for use by the HOB
+ producer phase.
+ EfiFreeMemoryTop - The highest address location of free memory that is currently available for use
+ by the HOB producer phase.
+ EfiFreeMemoryBottom - The lowest address location of free memory that is available for
+ use by the HOB producer phase.
+
+Returns:
+
+ EFI_SUCCESS
+
+--*/
+{
+ EFI_PEI_HOB_POINTERS HandOffHob;
+ EFI_PEI_HOB_POINTERS Hob;
+ EFI_PEI_HOB_POINTERS HobEnd;
+
+
+ HandOffHob.Raw = HobStart;
+ Hob.Raw = HobStart;
+ Hob.Header->HobType = EFI_HOB_TYPE_HANDOFF;
+ Hob.Header->HobLength = sizeof(EFI_HOB_HANDOFF_INFO_TABLE);
+
+ Hob.HandoffInformationTable->Version = Version;
+ Hob.HandoffInformationTable->BootMode = BootMode;
+
+ Hob.HandoffInformationTable->EfiMemoryTop = EfiMemoryTop;
+ Hob.HandoffInformationTable->EfiMemoryBottom = EfiMemoryBottom;
+ Hob.HandoffInformationTable->EfiFreeMemoryTop = EfiFreeMemoryTop;
+ Hob.HandoffInformationTable->EfiFreeMemoryBottom = EfiFreeMemoryBottom;
+
+ HobEnd.Raw = (VOID*)(Hob.HandoffInformationTable + 1);
+ Hob.HandoffInformationTable->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS) (UINTN) HobEnd.Raw;
+ Hob = BuildHobEndOfHobList (HobEnd.Raw);
+ HandOffHob.HandoffInformationTable->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS) (UINTN) Hob.Raw;
+ return EFI_SUCCESS;
+}
+
+
+
+EFI_STATUS
+BuildHobModule (
+ IN VOID *HobStart,
+ IN EFI_GUID *ModuleName,
+ IN EFI_PHYSICAL_ADDRESS MemoryAllocationModule,
+ IN UINT64 ModuleLength,
+ IN EFI_PHYSICAL_ADDRESS EntryPoint
+ )
+/*++
+
+Routine Description:
+
+ Builds a HOB for a loaded PE32 module
+
+Arguments:
+
+ HobStart - Start pointer of hob list
+
+ ModuleName - The GUID File Name of the HON from the Firmware Volume
+
+ MemoryAllocationModule - The 64 bit physical address of the module
+
+ ModuleLength - The length of the module in bytes
+
+ EntryPoint - The 64 bit physical address of the entry point to the module
+
+Returns:
+
+ EFI_SUCCESS
+ EFI_NOT_AVAILABLE_YET
+
+--*/
+{
+ EFI_PEI_HOB_POINTERS Hob;
+ EFI_PEI_HOB_POINTERS HandOffHob;
+
+ HandOffHob.Raw = HobStart;
+ Hob.Raw = (VOID*)(UINTN)(HandOffHob.HandoffInformationTable->EfiEndOfHobList);
+
+ Hob.Header->HobType = EFI_HOB_TYPE_MEMORY_ALLOCATION;
+ Hob.Header->HobLength = sizeof(EFI_HOB_MEMORY_ALLOCATION_MODULE);
+
+ CopyMem(&(Hob.MemoryAllocationModule->ModuleName), ModuleName, sizeof(EFI_GUID));
+ CopyMem(&(Hob.MemoryAllocationModule->MemoryAllocationHeader.Name), &gEfiHobMemeryAllocModuleGuid, sizeof(EFI_GUID));
+ Hob.MemoryAllocationModule->MemoryAllocationHeader.MemoryBaseAddress = MemoryAllocationModule;
+ Hob.MemoryAllocationModule->MemoryAllocationHeader.MemoryLength = ModuleLength;
+ Hob.MemoryAllocationModule->MemoryAllocationHeader.MemoryType = EfiConventionalMemory;
+
+ Hob.MemoryAllocationModule->EntryPoint = EntryPoint;
+
+ Hob.MemoryAllocationModule++;
+ HandOffHob.HandoffInformationTable->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS) (UINTN) Hob.Raw;
+ Hob = BuildHobEndOfHobList(Hob.Raw);
+ HandOffHob.HandoffInformationTable->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS) (UINTN) Hob.Raw;
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+BuildHobResourceDescriptor (
+ IN VOID * HobStart,
+ IN EFI_RESOURCE_TYPE ResourceType,
+ IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute,
+ IN EFI_PHYSICAL_ADDRESS PhysicalStart,
+ IN UINT64 NumberOfBytes
+ )
+/*++
+
+Routine Description:
+
+ Builds a HOB that describes a chunck of system memory
+
+Arguments:
+
+ HobStart - Start pointer of hob list
+
+ ResourceType - The type of memory described by this HOB
+
+ ResourceAttribute - The memory attributes of the memory described by this HOB
+
+ PhysicalStart - The 64 bit physical address of memory described by this HOB
+
+ NumberOfBytes - The length of the memoty described by this HOB in bytes
+
+Returns:
+
+ EFI_SUCCESS
+ EFI_NOT_AVAILABLE_YET
+
+--*/
+{
+ EFI_PEI_HOB_POINTERS Hob;
+ EFI_PEI_HOB_POINTERS HandOffHob;
+
+ HandOffHob.Raw = HobStart;
+ Hob.Raw = (VOID *)(UINTN)(HandOffHob.HandoffInformationTable->EfiEndOfHobList);
+
+ Hob.Header->HobType = EFI_HOB_TYPE_RESOURCE_DESCRIPTOR;
+ Hob.Header->HobLength = sizeof(EFI_HOB_RESOURCE_DESCRIPTOR);
+
+ Hob.ResourceDescriptor->ResourceType = ResourceType;
+ Hob.ResourceDescriptor->ResourceAttribute = ResourceAttribute;
+ Hob.ResourceDescriptor->PhysicalStart = PhysicalStart;
+ Hob.ResourceDescriptor->ResourceLength = NumberOfBytes;
+
+ Hob.ResourceDescriptor++;
+ HandOffHob.HandoffInformationTable->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS) (UINTN) Hob.Raw;
+ Hob = BuildHobEndOfHobList(Hob.Raw);
+ HandOffHob.HandoffInformationTable->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS) (UINTN) Hob.Raw;
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+BuildHobGuidType (
+ IN VOID *HobStart,
+ IN EFI_GUID *Guid,
+ IN VOID *Buffer,
+ IN UINTN BufferSize
+ )
+/*++
+
+Routine Description:
+
+ Builds a custom HOB that is tagged with a GUID for identification
+
+Arguments:
+
+ HobStart - Start pointer of hob list
+
+ Guid - The GUID of the custome HOB type
+
+ Buffer - A pointer to the data for the custom HOB type
+
+ BufferSize - The size in byte of BufferSize
+
+Returns:
+
+ EFI_SUCCESS
+ EFI_NOT_AVAILABLE_YET
+
+--*/
+{
+ EFI_PEI_HOB_POINTERS Hob;
+ EFI_PEI_HOB_POINTERS HandOffHob;
+ UINTN Length;
+
+
+ HandOffHob.Raw = HobStart;
+ Hob.Raw = (VOID *)(UINTN)HandOffHob.HandoffInformationTable->EfiEndOfHobList;
+
+
+ Hob.Header->HobType = EFI_HOB_TYPE_GUID_EXTENSION;
+ Length = sizeof(EFI_HOB_GUID_TYPE) + BufferSize;
+ Hob.Header->HobLength = (UINT16)Length;
+ CopyMem(&Hob.Guid->Name, Guid, sizeof(EFI_GUID));
+ CopyMem(Hob.Raw + sizeof(EFI_HOB_GUID_TYPE), Buffer, BufferSize);
+ Hob.Raw += Length;
+
+ HandOffHob.HandoffInformationTable->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS) (UINTN) Hob.Raw;
+ Hob = BuildHobEndOfHobList(Hob.Raw);
+ HandOffHob.HandoffInformationTable->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS) (UINTN) Hob.Raw;
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+BuildHobFvDescriptor (
+ IN VOID *HobStart,
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length
+ )
+/*++
+
+Routine Description:
+
+ Builds a Firmware Volume HOB
+
+Arguments:
+
+ HobStart - Start pointer of hob list
+
+ BaseAddress - The base address of the Firmware Volume
+
+ Length - The size of the Firmware Volume in bytes
+
+Returns:
+
+ EFI_SUCCESS
+ EFI_NOT_AVAILABLE_YET
+
+--*/
+{
+ EFI_PEI_HOB_POINTERS Hob;
+ EFI_PEI_HOB_POINTERS HandOffHob;
+
+ HandOffHob.Raw = HobStart;
+ Hob.Raw = (VOID*)(UINTN)(HandOffHob.HandoffInformationTable->EfiEndOfHobList);
+
+ Hob.Header->HobType = EFI_HOB_TYPE_FV;
+ Hob.Header->HobLength = sizeof(EFI_HOB_FIRMWARE_VOLUME);
+
+ Hob.FirmwareVolume->BaseAddress = BaseAddress;
+ Hob.FirmwareVolume->Length = Length;
+
+ Hob.FirmwareVolume++;
+
+ HandOffHob.HandoffInformationTable->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS) (UINTN) Hob.Raw;
+ Hob = BuildHobEndOfHobList(Hob.Raw);
+ HandOffHob.HandoffInformationTable->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS) (UINTN) Hob.Raw;
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+BuildHobCpu (
+ IN VOID *HobStart,
+ IN UINT8 SizeOfMemorySpace,
+ IN UINT8 SizeOfIoSpace
+ )
+/*++
+
+Routine Description:
+
+ Builds a HOB for the CPU
+
+Arguments:
+
+ HobStart - Start pointer of hob list
+
+ SizeOfMemorySpace - Identifies the maximum
+ physical memory addressibility of the processor.
+
+ SizeOfIoSpace - Identifies the maximum physical I/O addressibility
+ of the processor.
+
+Returns:
+
+ EFI_SUCCESS
+ EFI_NOT_AVAILABLE_YET
+
+--*/
+{
+ EFI_PEI_HOB_POINTERS Hob;
+ EFI_PEI_HOB_POINTERS HandOffHob;
+
+ HandOffHob.Raw = HobStart;
+ Hob.Raw = (VOID*)(UINTN)HandOffHob.HandoffInformationTable->EfiEndOfHobList;
+
+ Hob.Header->HobType = EFI_HOB_TYPE_CPU;
+ Hob.Header->HobLength = sizeof(EFI_HOB_CPU);
+
+ Hob.Cpu->SizeOfMemorySpace = SizeOfMemorySpace;
+ Hob.Cpu->SizeOfIoSpace = SizeOfIoSpace;
+
+ Hob.Cpu++;
+ HandOffHob.HandoffInformationTable->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS) (UINTN) Hob.Raw;
+ Hob = BuildHobEndOfHobList(Hob.Raw);
+ HandOffHob.HandoffInformationTable->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS) (UINTN) Hob.Raw;
+ return EFI_SUCCESS;
+}
+
+
+
+EFI_STATUS
+BuildHobStack (
+ IN VOID *HobStart,
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length
+ )
+/*++
+
+Routine Description:
+
+ Builds a HOB for the Stack
+
+Arguments:
+
+ HobStart - Start pointer of hob list
+
+ BaseAddress - The 64 bit physical address of the Stack
+
+ Length - The length of the stack in bytes
+
+Returns:
+
+ EFI_SUCCESS
+ EFI_NOT_AVAILABLE_YET
+
+--*/
+{
+ EFI_PEI_HOB_POINTERS Hob;
+ EFI_PEI_HOB_POINTERS HandOffHob;
+
+ HandOffHob.Raw = HobStart;
+ Hob.Raw = (VOID*)(UINTN)HandOffHob.HandoffInformationTable->EfiEndOfHobList;
+
+ Hob.Header->HobType = EFI_HOB_TYPE_MEMORY_ALLOCATION;
+ Hob.Header->HobLength = sizeof(EFI_HOB_MEMORY_ALLOCATION_STACK);
+
+ CopyMem(&(Hob.MemoryAllocationStack->AllocDescriptor.Name), &gEfiHobMemeryAllocStackGuid, sizeof(EFI_GUID));
+ (Hob.MemoryAllocationStack->AllocDescriptor).MemoryBaseAddress = BaseAddress;
+ (Hob.MemoryAllocationStack->AllocDescriptor).MemoryLength = Length;
+ (Hob.MemoryAllocationStack->AllocDescriptor).MemoryType = EfiBootServicesData;
+
+ Hob.MemoryAllocationStack++;
+ HandOffHob.HandoffInformationTable->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS) (UINTN) Hob.Raw;
+ Hob = BuildHobEndOfHobList(Hob.Raw);
+ HandOffHob.HandoffInformationTable->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS) (UINTN) Hob.Raw;
+ return EFI_SUCCESS;
+}
+
+
+
+EFI_STATUS
+BuildHobBspStore (
+ IN VOID *HobStart,
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length,
+ IN EFI_MEMORY_TYPE MemoryType
+ )
+/*++
+
+Routine Description:
+
+ Builds a HOB for the bsp store
+
+Arguments:
+
+ HobStart - Start pointer of hob list
+
+ BaseAddress - The 64 bit physical address of bsp store
+
+ Length - The length of the bsp store in bytes
+
+ MemoryType - Memory type of the bsp store
+
+Returns:
+
+ EFI_SUCCESS
+ EFI_NOT_AVAILABLE_YET
+
+--*/
+{
+ EFI_PEI_HOB_POINTERS Hob;
+ EFI_PEI_HOB_POINTERS HandOffHob;
+
+ HandOffHob.Raw = HobStart;
+ Hob.Raw = (VOID *)(UINTN)HandOffHob.HandoffInformationTable->EfiEndOfHobList;
+ Hob.Header->HobType = EFI_HOB_TYPE_MEMORY_ALLOCATION;
+ Hob.Header->HobLength = sizeof(EFI_HOB_MEMORY_ALLOCATION_BSP_STORE);
+
+ (Hob.MemoryAllocationBspStore->AllocDescriptor).MemoryBaseAddress = BaseAddress;
+ (Hob.MemoryAllocationBspStore->AllocDescriptor).MemoryLength = Length;
+ (Hob.MemoryAllocationBspStore->AllocDescriptor).MemoryType = MemoryType;
+ CopyMem(&(Hob.MemoryAllocationBspStore->AllocDescriptor).Name, &gEfiHobMemeryAllocBspStoreGuid, sizeof(EFI_GUID));
+ Hob.MemoryAllocationBspStore++;
+
+ HandOffHob.HandoffInformationTable->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS) (UINTN) Hob.Raw;
+ Hob = BuildHobEndOfHobList(Hob.Raw);
+ HandOffHob.HandoffInformationTable->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS) (UINTN) Hob.Raw;
+ return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+BuildMemoryAllocationHob (
+ IN VOID *HobStart,
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length,
+ IN EFI_GUID *Name,
+ IN EFI_MEMORY_TYPE MemoryType
+ )
+/*++
+
+Routine Description:
+
+ Builds a HOB for memory allocation
+
+Arguments:
+
+ HobStart - Start pointer of hob list
+
+ BaseAddress - The base address of memory allocated by this HOB.
+
+ Length - The length in bytes of memory allocated by this HOB.
+
+ Name - A GUID that defines the memory allocation region¡¯s type and purpose,
+ as well as other fields within the memory allocation HOB.
+
+ MemoryType - Defines the type of memory allocated by this HOB.
+
+Returns:
+
+ EFI_SUCCESS
+ EFI_NOT_AVAILABLE_YET
+
+--*/
+{
+ EFI_PEI_HOB_POINTERS Hob;
+ EFI_PEI_HOB_POINTERS HandOffHob;
+
+
+ HandOffHob.Raw = HobStart;
+ Hob.Raw = (VOID*)(UINTN)HandOffHob.HandoffInformationTable->EfiEndOfHobList;
+
+ Hob.Header->HobType = EFI_HOB_TYPE_MEMORY_ALLOCATION;
+ Hob.Header->HobLength = sizeof(EFI_HOB_MEMORY_ALLOCATION);
+
+ if (Name != NULL) {
+ CopyMem(&(Hob.MemoryAllocation->AllocDescriptor.Name), &Name, sizeof(EFI_GUID));
+ } else {
+ ZeroMem(&Hob.MemoryAllocation->AllocDescriptor.Name, sizeof(EFI_GUID));
+ }
+
+ (Hob.MemoryAllocation->AllocDescriptor).MemoryBaseAddress = BaseAddress;
+ (Hob.MemoryAllocation->AllocDescriptor).MemoryLength = Length;
+ (Hob.MemoryAllocation->AllocDescriptor).MemoryType = MemoryType;
+
+ Hob.MemoryAllocation++;
+ HandOffHob.HandoffInformationTable->EfiEndOfHobList = (EFI_PHYSICAL_ADDRESS) (UINTN) Hob.Raw;
+ Hob = BuildHobEndOfHobList(Hob.Raw);
+ HandOffHob.HandoffInformationTable->EfiFreeMemoryBottom = (EFI_PHYSICAL_ADDRESS) (UINTN) Hob.Raw;
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+GetFirstGuidHob (
+ IN VOID **HobStart,
+ IN EFI_GUID *Guid,
+ OUT VOID **Buffer,
+ OUT UINTN *BufferSize OPTIONAL
+ )
+/*++
+
+Routine Description:
+
+ This function searches the first instance of a HOB among the whole HOB list.
+
+Arguments:
+
+ HobStart - A pointer to the start pointer of hob list.
+
+ Guid - A pointer to the GUID to match with in the HOB list.
+
+ Buffer - A pointer to the pointer to the data for the custom HOB type.
+
+ BufferSize - A Pointer to the size in byte of BufferSize.
+
+Returns:
+ EFI_SUCCESS
+ The first instance of the matched GUID HOB among the whole HOB list
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_PEI_HOB_POINTERS GuidHob;
+
+ GuidHob.Raw = *HobStart;
+
+ for (Status = EFI_NOT_FOUND; EFI_ERROR (Status); ) {
+
+ if (END_OF_HOB_LIST (GuidHob)) {
+ return EFI_NOT_FOUND;
+ }
+
+ if (GuidHob.Header->HobType == EFI_HOB_TYPE_GUID_EXTENSION) {
+ if ( ((INT32 *)Guid)[0] == ((INT32 *)&GuidHob.Guid->Name)[0] &&
+ ((INT32 *)Guid)[1] == ((INT32 *)&GuidHob.Guid->Name)[1] &&
+ ((INT32 *)Guid)[2] == ((INT32 *)&GuidHob.Guid->Name)[2] &&
+ ((INT32 *)Guid)[3] == ((INT32 *)&GuidHob.Guid->Name)[3] ) {
+ Status = EFI_SUCCESS;
+ *Buffer = (VOID *)((UINT8 *)(&GuidHob.Guid->Name) + sizeof (EFI_GUID));
+ if (BufferSize) {
+ *BufferSize = GuidHob.Header->HobLength - sizeof (EFI_HOB_GUID_TYPE);
+ }
+ }
+ }
+
+ GuidHob.Raw = GET_NEXT_HOB (GuidHob);
+ }
+
+ return Status;
+}
+
+VOID *
+GetHob (
+ IN UINT16 Type,
+ IN VOID *HobStart
+ )
+/*++
+
+Routine Description:
+
+ This function returns the first instance of a HOB type in a HOB list.
+
+Arguments:
+
+ Type The HOB type to return.
+ HobStart The first HOB in the HOB list.
+
+Returns:
+
+ HobStart There were no HOBs found with the requested type.
+ else Returns the first HOB with the matching type.
+
+--*/
+{
+ EFI_PEI_HOB_POINTERS Hob;
+
+ Hob.Raw = HobStart;
+ //
+ // Return input if not found
+ //
+ if (HobStart == NULL) {
+ return HobStart;
+ }
+
+ //
+ // Parse the HOB list, stop if end of list or matching type found.
+ //
+ while (!END_OF_HOB_LIST (Hob)) {
+
+ if (Hob.Header->HobType == Type) {
+ break;
+ }
+
+ Hob.Raw = GET_NEXT_HOB (Hob);
+ }
+
+ //
+ // Return input if not found
+ //
+ if (END_OF_HOB_LIST (Hob)) {
+ return HobStart;
+ }
+
+ return (VOID *) (Hob.Raw);
+}
+
+EFI_STATUS
+GetNextGuidHob (
+ IN OUT VOID **HobStart,
+ IN EFI_GUID * Guid,
+ OUT VOID **Buffer,
+ OUT UINTN *BufferSize OPTIONAL
+ )
+/*++
+
+Routine Description:
+ Get the next guid hob.
+
+Arguments:
+ HobStart A pointer to the start hob.
+ Guid A pointer to a guid.
+ Buffer A pointer to the buffer.
+ BufferSize Buffer size.
+
+Returns:
+ Status code.
+
+ EFI_NOT_FOUND - Next Guid hob not found
+
+ EFI_SUCCESS - Next Guid hob found and data for this Guid got
+
+ EFI_INVALID_PARAMETER - invalid parameter
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_PEI_HOB_POINTERS GuidHob;
+
+ if (Buffer == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ for (Status = EFI_NOT_FOUND; EFI_ERROR (Status);) {
+
+ GuidHob.Raw = *HobStart;
+ if (END_OF_HOB_LIST (GuidHob)) {
+ return EFI_NOT_FOUND;
+ }
+
+ GuidHob.Raw = GetHob (EFI_HOB_TYPE_GUID_EXTENSION, *HobStart);
+ if (GuidHob.Header->HobType == EFI_HOB_TYPE_GUID_EXTENSION) {
+ if ( ((INT32 *)Guid)[0] == ((INT32 *)&GuidHob.Guid->Name)[0] &&
+ ((INT32 *)Guid)[1] == ((INT32 *)&GuidHob.Guid->Name)[1] &&
+ ((INT32 *)Guid)[2] == ((INT32 *)&GuidHob.Guid->Name)[2] &&
+ ((INT32 *)Guid)[3] == ((INT32 *)&GuidHob.Guid->Name)[3] ) {
+ Status = EFI_SUCCESS;
+ *Buffer = (VOID *) ((UINT8 *) (&GuidHob.Guid->Name) + sizeof (EFI_GUID));
+ if (BufferSize != NULL) {
+ *BufferSize = GuidHob.Header->HobLength - sizeof (EFI_HOB_GUID_TYPE);
+ }
+ }
+ }
+
+ *HobStart = GET_NEXT_HOB (GuidHob);
+ }
+
+ return Status;
+}
diff --git a/EDK/Foundation/Library/Pei/Hob/PeiHobLib.cif b/EDK/Foundation/Library/Pei/Hob/PeiHobLib.cif
new file mode 100644
index 0000000..e43a597
--- /dev/null
+++ b/EDK/Foundation/Library/Pei/Hob/PeiHobLib.cif
@@ -0,0 +1,11 @@
+<component>
+ name = "PeiHobLib"
+ category = ModulePart
+ LocalRoot = "EDK\Foundation\Library\Pei\Hob\"
+ RefName = "PeiHobLib"
+[files]
+"PeiHobLib.sdl"
+"PeiHobLib.mak"
+"PeiHobLib.c"
+"PeiHobLib.inf"
+<endComponent>
diff --git a/EDK/Foundation/Library/Pei/Hob/PeiHobLib.inf b/EDK/Foundation/Library/Pei/Hob/PeiHobLib.inf
new file mode 100644
index 0000000..ba2e8b2
--- /dev/null
+++ b/EDK/Foundation/Library/Pei/Hob/PeiHobLib.inf
@@ -0,0 +1,51 @@
+#/*++
+#
+# Copyright (c) 2004, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# PeiHobLib.inf
+#
+# Abstract:
+#
+# Component description file for the PEI library.
+#
+#--*/
+
+[defines]
+BASE_NAME = PeiHobLib
+COMPONENT_TYPE = LIBRARY
+
+[sources.common]
+ PeiHobLib.c
+
+[sources.ia32]
+
+[sources.ipf]
+
+[libraries.common]
+
+[includes.common]
+ $(EDK_SOURCE)\Foundation
+ $(EDK_SOURCE)\Foundation\Efi
+ .
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)\Foundation\Include\Pei
+ $(EDK_SOURCE)\Foundation\Library\Pei\Include
+ $(EDK_SOURCE)\Foundation\Core\Pei\Include
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+ $(EDK_SOURCE)\Foundation\Framework
+
+[nmake.common]
+ C_STD_INCLUDE=
diff --git a/EDK/Foundation/Library/Pei/Hob/PeiHobLib.mak b/EDK/Foundation/Library/Pei/Hob/PeiHobLib.mak
new file mode 100644
index 0000000..4e07ccb
--- /dev/null
+++ b/EDK/Foundation/Library/Pei/Hob/PeiHobLib.mak
@@ -0,0 +1,69 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/PeiHobLib/PeiHobLib.mak 1 1/20/12 4:10a Jeffch $
+#
+# $Revision: 1 $
+#
+# $Date: 1/20/12 4:10a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/PeiHobLib/PeiHobLib.mak $
+#
+# 1 1/20/12 4:10a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 9/27/11 6:32a Wesleychen
+# Intel EDK initially releases.
+#
+# 2 9/02/09 3:57a Iminglin
+# EIP24919
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: PeiHobLib.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+$(PEIHOBLIB) : PeiHobLib
+
+$(BUILD_DIR)\PeiHobLib.lib : PeiHobLib
+
+PeiHobLib : $(BUILD_DIR)\PeiHobLib.mak PeiHobLibBin
+
+$(BUILD_DIR)\PeiHobLib.mak : $(PeiHobLib_DIR)\$(@B).cif $(PeiHobLib_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(PeiHobLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+PeiHobLibBin :
+ $(MAKE) /$(MAKEFLAGS) $(EDK_DEFAULTS)\
+ /f $(BUILD_DIR)\PeiHobLib.mak all\
+ TYPE=PEI_LIBRARY \
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#********************************************************************** \ No newline at end of file
diff --git a/EDK/Foundation/Library/Pei/Hob/PeiHobLib.sdl b/EDK/Foundation/Library/Pei/Hob/PeiHobLib.sdl
new file mode 100644
index 0000000..45fd030
--- /dev/null
+++ b/EDK/Foundation/Library/Pei/Hob/PeiHobLib.sdl
@@ -0,0 +1,26 @@
+TOKEN
+ Name = "PeiHobLib_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable PeiHobLib support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "PEIHOBLIB"
+ Value = "$(BUILD_DIR)\PeiHobLib.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "PeiHobLib_DIR"
+End
+
+MODULE
+ Help = "Includes PeiHobLib.mak to Project"
+ File = "PeiHobLib.mak"
+End
+
diff --git a/EDK/Foundation/Library/Pei/Include/PeiLib.h b/EDK/Foundation/Library/Pei/Include/PeiLib.h
new file mode 100644
index 0000000..3c24e24
--- /dev/null
+++ b/EDK/Foundation/Library/Pei/Include/PeiLib.h
@@ -0,0 +1,1455 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PeiLib.h
+
+Abstract:
+
+ PEI Library Functions
+
+--*/
+
+#ifndef _PEI_LIB_H_
+#define _PEI_LIB_H_
+
+#include "Tiano.h"
+#include "Pei.h"
+#include "peiHobLib.h"
+#include EFI_PROTOCOL_DEFINITION (Decompress)
+#include EFI_PROTOCOL_DEFINITION (TianoDecompress)
+#include EFI_GUID_DEFINITION (PeiPeCoffLoader)
+#include EFI_PPI_DEFINITION (FindFv)
+
+//;;## ...AMI_OVERRIDE... Support PI1.x start
+
+#if (PI_SPECIFICATION_VERSION >= 0x00010000)
+
+typedef struct {
+ UINT32 PeiServiceTable;
+} PEI_IDT_TABLE;
+
+
+VOID *
+EFIAPI
+ScanGuid (
+ IN VOID *Buffer,
+ IN UINTN Length,
+ IN EFI_GUID *Guid
+ )
+/*++
+
+Routine Description:
+
+ Scans a target buffer for a GUID, and returns a pointer to the matching GUID
+ in the target buffer.
+
+ This function searches target the buffer specified by Buffer and Length from
+ the lowest address to the highest address at 128-bit increments for the 128-bit
+ GUID value that matches Guid. If a match is found, then a pointer to the matching
+ GUID in the target buffer is returned. If no match is found, then NULL is returned.
+ If Length is 0, then NULL is returned.
+ If Length > 0 and Buffer is NULL, then ASSERT().
+ If Buffer is not aligned on a 32-bit boundary, then ASSERT().
+ If Length is not aligned on a 128-bit boundary, then ASSERT().
+ If Length is greater than (EFI_MAX_ADDRESS ?Buffer + 1), then ASSERT().
+
+Arguments:
+
+ Buffer - Pointer to the target buffer to scan.
+ Length - Number of bytes in Buffer to scan.
+ Guid - Value to search for in the target buffer.
+
+Returns:
+ A pointer to the matching Guid in the target buffer or NULL otherwise.
+
+--*/
+;
+
+VOID *
+EFIAPI
+InvalidateInstructionCacheRange (
+ IN VOID *Address,
+ IN UINTN Length
+ )
+/*++
+
+Routine Description:
+
+ Invalidates a range of instruction cache lines in the cache coherency domain
+ of the calling CPU.
+
+ Invalidates the instruction cache lines specified by Address and Length. If
+ Address is not aligned on a cache line boundary, then entire instruction
+ cache line containing Address is invalidated. If Address + Length is not
+ aligned on a cache line boundary, then the entire instruction cache line
+ containing Address + Length -1 is invalidated. This function may choose to
+ invalidate the entire instruction cache if that is more efficient than
+ invalidating the specified range. If Length is 0, the no instruction cache
+ lines are invalidated. Address is returned.
+
+ If Length is greater than (EFI_MAX_ADDRESS - Address + 1), then ASSERT().
+
+Arguments:
+
+ Address - The base address of the instruction cache lines to
+ invalidate. If the CPU is in a physical addressing mode, then
+ Address is a physical address. If the CPU is in a virtual
+ addressing mode, then Address is a virtual address.
+
+ Length - The number of bytes to invalidate from the instruction cache.
+
+ Returns:
+ Address
+
+**/
+;
+
+EFI_STATUS
+EFIAPI
+PeiLibFfsFindNextVolume (
+ IN UINTN Instance,
+ IN OUT EFI_PEI_FV_HANDLE *VolumeHandle
+ )
+/*++
+
+Routine Description:
+
+ The wrapper of Pei Core Service function FfsFindNextVolume.
+
+Arguments:
+
+ Instance - The Fv Volume Instance.
+ VolumeHandle - Pointer to the current Fv Volume to search.
+
+Returns:
+ EFI_STATUS
+
+--*/
+;
+
+EFI_STATUS
+EFIAPI
+PeiLibFfsFindNextFile (
+ IN EFI_FV_FILETYPE SearchType,
+ IN EFI_PEI_FV_HANDLE FvHandle,
+ IN OUT EFI_PEI_FILE_HANDLE *FileHandle
+ )
+/*++
+
+Routine Description:
+
+ The wrapper of Pei Core Service function FfsFindNextFile.
+
+Arguments:
+
+ SearchType - Filter to find only file of this type.
+ FvHandle - Pointer to the current FV to search.
+ FileHandle - Pointer to the file matching SearchType in FwVolHeader.
+ - NULL if file not found
+
+Returns:
+ EFI_STATUS
+
+--*/
+;
+
+EFI_STATUS
+EFIAPI
+PeiLibFfsFindFileByName (
+ IN EFI_GUID *FileName,
+ IN EFI_PEI_FV_HANDLE VolumeHandle,
+ OUT EFI_PEI_FILE_HANDLE *FileHandle
+ )
+/*++
+
+Routine Description:
+
+ The wrapper of Pei Core Service function FfsFindFileByName.
+
+Arguments:
+
+ FileName - File name to search.
+ VolumeHandle - The current FV to search.
+ FileHandle - Pointer to the file matching name in VolumeHandle.
+ - NULL if file not found
+
+Returns:
+ EFI_STATUS
+
+--*/
+;
+
+EFI_STATUS
+EFIAPI
+PeiLibFfsFindSectionData (
+ IN EFI_SECTION_TYPE SectionType,
+ IN EFI_FFS_FILE_HEADER *FfsFileHeader,
+ IN OUT VOID **SectionData
+ )
+/*++
+
+Routine Description:
+
+ The wrapper of Pei Core Service function FfsFindSectionData.
+
+Arguments:
+
+ SearchType - Filter to find only sections of this type.
+ FileHandle - Pointer to the current file to search.
+ SectionData - Pointer to the Section matching SectionType in FfsFileHeader.
+ - NULL if section not found
+
+Returns:
+ EFI_STATUS
+--*/
+;
+
+EFI_STATUS
+EFIAPI
+PeiLibFfsGetVolumeInfo (
+ IN EFI_PEI_FV_HANDLE VolumeHandle,
+ OUT EFI_FV_INFO *VolumeInfo
+ )
+/*++
+
+Routine Description:
+
+ The wrapper of Pei Core Service function FfsGetVolumeInfo.
+
+Arguments:
+
+ VolumeHandle - The handle to Fv Volume.
+ VolumeInfo - The pointer to volume information.
+
+Returns:
+ EFI_STATUS
+--*/
+;
+
+EFI_STATUS
+EFIAPI
+PeiServicesLocatePpi (
+ IN EFI_GUID *Guid,
+ IN UINTN Instance,
+ IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor,
+ IN OUT VOID **Ppi
+ )
+/*++
+
+Routine Description:
+
+ The wrapper of Pei Core Service function LocatePpi.
+
+Arguments:
+
+ Guid - Pointer to GUID of the PPI.
+ Instance - Instance Number to discover.
+ PpiDescriptor - Pointer to reference the found descriptor. If not NULL,
+ returns a pointer to the descriptor (includes flags, etc)
+ Ppi - Pointer to reference the found PPI
+
+Returns:
+
+ Status - EFI_SUCCESS if the PPI is in the database
+ EFI_NOT_FOUND if the PPI is not in the database
+--*/
+;
+
+VOID
+EFIAPI
+BuildFvHob (
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length
+ )
+/*++
+
+Routine Description:
+
+ Build FvHob.
+
+Arguments:
+
+ BaseAddress - Fv base address.
+ Length - Fv Length.
+
+Returns:
+ NONE.
+
+--*/
+;
+
+VOID
+EFIAPI
+BuildFvHob2 (
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length,
+ IN EFI_GUID *FvNameGuid,
+ IN EFI_GUID *FileNameGuid
+ )
+/*++
+
+Routine Description:
+
+ Build FvHob2.
+
+Arguments:
+
+ BaseAddress - Fv base address.
+ Length - Fv length.
+ FvNameGuid - Fv name.
+ FileNameGuid - File name which contians encapsulated Fv.
+
+Returns:
+ NONE.
+--*/
+;
+
+
+VOID
+EFIAPI
+BuildGuidDataHob (
+ IN EFI_GUID *Guid,
+ IN VOID *Data,
+ IN UINTN DataLength
+ )
+/*++
+
+Routine Description:
+
+ Build Guid data Hob.
+
+Arguments:
+
+ Guid - guid to build data hob.
+ Data - data to build data hob.
+ DataLength - the length of data.
+
+Returns:
+ NONE
+
+--*/
+;
+
+VOID *
+EFIAPI
+AllocatePages (
+ IN UINTN Pages
+ )
+/*++
+
+Routine Description:
+
+ Allocate Memory.
+
+Arguments:
+
+ Pages - Pages to allocate.
+
+Returns:
+ Address if successful to allocate memory.
+ NULL if fail to allocate memory.
+
+--*/
+;
+
+VOID
+SetPeiServicesTablePointer (
+ IN EFI_PEI_SERVICES **PeiServices
+ )
+/*++
+
+Routine Description:
+
+ Save PeiService pointer so that it can be retrieved anywhere.
+
+Arguments:
+
+ PeiServices - The direct pointer to PeiServiceTable.
+
+Returns:
+ NONE
+
+--*/
+;
+
+EFI_PEI_SERVICES **
+GetPeiServicesTablePointer (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Get PeiService pointer.
+
+Arguments:
+
+ NONE.
+
+Returns:
+ The direct pointer to PeiServiceTable.
+
+--*/
+;
+
+VOID
+MigrateIdtTable (
+ IN EFI_PEI_SERVICES **PeiServices
+ )
+/*++
+
+Routine Description:
+
+ Migrate IDT from CAR to real memory where preceded with 4 bytes for
+ storing PeiService pointer.
+
+Arguments:
+
+ PeiServices - The direct pointer to PeiServiceTable.
+
+Returns:
+
+ NONE.
+
+--*/
+;
+
+
+UINTN
+ReadIdtBase (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Read IDT Register BaseAddress.
+
+Arguments:
+
+ NONE
+
+Returns:
+ IDT Register BaseAddress.
+
+--*/
+;
+
+
+UINT16
+ReadIdtLimit (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Read IDT Register Limit.
+
+Arguments:
+
+ NONE
+
+Returns:
+ IDT Register Limit.
+
+--*/
+;
+
+
+VOID
+SetIdtBase (
+ UINT32 IdtBase,
+ UINT16 IdtLimit
+ )
+/*++
+
+Routine Description:
+
+ Set IDT Register BaseAddress.
+
+Arguments:
+
+ IdtBase - IDT.BaseAddress
+ IdtLimit - IDT.Limit
+
+Returns:
+ NONE
+--*/
+;
+
+VOID
+AsmWriteKr7 (
+ UINT64 Address
+ )
+/*++
+
+Routine Description:
+
+ Write 64 bit into Kernel Register7 on IPF.
+
+Arguments:
+
+ Address - Data to write into kr7.
+
+Returns:
+ NONE
+
+--*/
+;
+
+
+UINT64
+AsmReadKr7 (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Read 64 bit from Kernel Register7 on IPF.
+
+Arguments:
+
+ NONE
+
+Returns:
+ Data in kr7.
+
+--*/
+;
+
+#endif
+//;;## ...AMI_OVERRIDE... Support PI1.x end
+
+VOID
+PeiCopyMem (
+ IN VOID *Destination,
+ IN VOID *Source,
+ IN UINTN Length
+ )
+/*++
+
+Routine Description:
+
+ Copy Length bytes from Source to Destination.
+
+Arguments:
+
+ Destination - Target of copy
+
+ Source - Place to copy from
+
+ Length - Number of bytes to copy
+
+Returns:
+
+ None
+
+--*/
+;
+
+VOID
+ZeroMem (
+ IN VOID *Buffer,
+ IN UINTN Size
+ )
+/*++
+
+Routine Description:
+
+ Set Buffer to zero for Size bytes.
+
+Arguments:
+
+ Buffer - Memory to set.
+
+ Size - Number of bytes to set
+
+Returns:
+
+ None
+
+--*/
+;
+
+VOID
+CopyMem (
+ IN VOID *Destination,
+ IN VOID *Source,
+ IN UINTN Length
+ )
+/*++
+
+Routine Description:
+
+ Copy Length bytes from Source to Destination.
+
+Arguments:
+
+ Destination - Target of copy
+
+ Source - Place to copy from
+
+ Length - Number of bytes to copy
+
+Returns:
+
+ None
+
+--*/
+;
+
+BOOLEAN
+CompareGuid (
+ IN EFI_GUID *Guid1,
+ IN EFI_GUID *Guid2
+ )
+/*++
+
+Routine Description:
+
+ Compares two GUIDs
+
+Arguments:
+
+ Guid1 - guid to compare
+ Guid2 - guid to compare
+
+Returns:
+ = TRUE if Guid1 == Guid2
+ = FALSE if Guid1 != Guid2
+
+--*/
+;
+
+EFI_STATUS
+InstallEfiPeiPeCoffLoader (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PEI_PE_COFF_LOADER_PROTOCOL **This,
+ IN EFI_PEI_PPI_DESCRIPTOR *ThisPpi
+ )
+/*++
+
+Routine Description:
+
+ Install EFI Pei PE coff loader protocol.
+
+Arguments:
+
+ PeiServices - The PEI core services table.
+
+ This - Pointer to get Pei PE coff loader protocol as output
+
+ ThisPpi - Passed in as EFI_NT_LOAD_AS_DLL_PPI on NT_EMULATOR platform
+
+Returns:
+
+ EFI_SUCCESS
+
+--*/
+;
+
+EFI_STATUS
+InstallEfiPeiPeCoffLoader64 (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN OUT EFI_PEI_PE_COFF_LOADER_PROTOCOL **This,
+ IN EFI_PEI_PPI_DESCRIPTOR *ThisPpi
+ );
+
+
+
+EFI_STATUS
+InstallEfiDecompress (
+ EFI_DECOMPRESS_PROTOCOL **This
+ )
+/*++
+
+Routine Description:
+
+ Install EFI decompress protocol.
+
+Arguments:
+
+ This - Pointer to get decompress protocol as output
+
+Returns:
+
+ EFI_SUCCESS - EFI decompress protocol successfully installed.
+
+--*/
+;
+
+EFI_STATUS
+InstallTianoDecompress (
+ EFI_TIANO_DECOMPRESS_PROTOCOL **This
+ )
+/*++
+
+Routine Description:
+
+ Install Tiano decompress protocol.
+
+Arguments:
+
+ This - Pointer to get decompress protocol as output
+
+Returns:
+
+ EFI_SUCCESS - Tiano decompress protocol successfully installed.
+
+--*/
+;
+
+VOID
+PeiPerfMeasure (
+ EFI_PEI_SERVICES **PeiServices,
+ IN UINT16 *Token,
+ IN EFI_FFS_FILE_HEADER *FileHeader,
+ IN BOOLEAN EntryExit,
+ IN UINT64 Value
+ )
+/*++
+
+Routine Description:
+
+ Log a timestamp count.
+
+Arguments:
+
+ PeiServices - Pointer to the PEI Core Services table
+
+ Token - Pointer to Token Name
+
+ FileHeader - Pointer to the file header
+
+ EntryExit - Indicates start or stop measurement
+
+ Value - The start time or the stop time
+
+Returns:
+
+--*/
+;
+
+VOID
+PeiPerfMeasureEx (
+ EFI_PEI_SERVICES **PeiServices,
+ IN UINT16 *Token,
+ IN EFI_FFS_FILE_HEADER *FileHeader,
+ IN UINT16 Identifier,
+ IN BOOLEAN EntryExit,
+ IN UINT64 Value
+ )
+/*++
+
+Routine Description:
+
+ Log a timestamp count.
+
+Arguments:
+
+ PeiServices - Pointer to the PEI Core Services table
+
+ Token - Pointer to Token Name
+
+ FileHeader - Pointer to the file header
+
+ Identifier - Progress Identifier
+
+ EntryExit - Indicates start or stop measurement
+
+ Value - The start time or the stop time
+
+Returns:
+
+--*/
+;
+
+EFI_STATUS
+GetTimerValue (
+ OUT UINT64 *TimerValue
+ )
+/*++
+
+Routine Description:
+
+ Get timer value.
+
+Arguments:
+
+ TimerValue - Pointer to the returned timer value
+
+Returns:
+
+ EFI_SUCCESS - Successfully got timer value
+
+--*/
+;
+
+#ifdef FIRMWARE_PERFORMANCE
+#define PEI_PERF_START(Ps, Token, FileHeader, Value) PeiPerfMeasure (Ps, Token, FileHeader, FALSE, Value)
+#define PEI_PERF_END(Ps, Token, FileHeader, Value) PeiPerfMeasure (Ps, Token, FileHeader, TRUE, Value)
+#define PEI_PERF_START_EX(Ps, Token, FileHeader, Identifier, Value) PeiPerfMeasureEx (Ps, Token, FileHeader, Identifier, FALSE, Value)
+#define PEI_PERF_END_EX(Ps, Token, FileHeader, Identifier, Value) PeiPerfMeasureEx (Ps, Token, FileHeader, Identifier, TRUE, Value)
+#else
+#define PEI_PERF_START(Ps, Token, FileHeader, Value)
+#define PEI_PERF_END(Ps, Token, FileHeader, Value)
+#define PEI_PERF_START_EX(Ps, Token, FileHeader, Identifier, Value)
+#define PEI_PERF_END_EX(Ps, Token, FileHeader, Identifier, Value)
+#endif
+
+#ifdef EFI_NT_EMULATOR
+EFI_STATUS
+PeCoffLoaderWinNtLoadAsDll (
+ IN CHAR8 *PdbFileName,
+ IN VOID **ImageEntryPoint,
+ OUT VOID **ModHandle
+ )
+/*++
+
+Routine Description:
+
+ Loads the .DLL file is present when a PE/COFF file is loaded. This provides source level
+ debugging for drivers that have cooresponding .DLL files on the local system.
+
+Arguments:
+
+ PdbFileName - The name of the .PDB file. This was found from the PE/COFF
+ file's debug directory entry.
+
+ ImageEntryPoint - A pointer to the DLL entry point of the .DLL file was loaded.
+
+ ModHandle - Pointer to loaded library.
+
+Returns:
+
+ EFI_SUCCESS - The .DLL file was loaded, and the DLL entry point is returned in ImageEntryPoint
+
+ EFI_NOT_FOUND - The .DLL file could not be found
+
+ EFI_UNSUPPORTED - The .DLL file was loaded, but the entry point to the .DLL file could not
+ determined.
+
+--*/
+;
+
+#endif
+//
+// hob.c
+//
+EFI_STATUS
+PeiBuildHobModule (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_GUID *ModuleName,
+ IN EFI_PHYSICAL_ADDRESS Module,
+ IN UINT64 ModuleLength,
+ IN EFI_PHYSICAL_ADDRESS EntryPoint
+ )
+/*++
+
+Routine Description:
+
+ Builds a HOB for a loaded PE32 module
+
+Arguments:
+
+ PeiServices - The PEI core services table.
+ ModuleName - The GUID File Name of the module
+ Memory - The 64 bit physical address of the module
+ ModuleLength - The length of the module in bytes
+ EntryPoint - The 64 bit physical address of the entry point
+ to the module
+
+Returns:
+
+ EFI_SUCCESS - Hob is successfully built.
+ Others - Errors occur while creating new Hob
+
+--*/
+;
+
+EFI_STATUS
+PeiBuildHobResourceDescriptor (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_RESOURCE_TYPE ResourceType,
+ IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute,
+ IN EFI_PHYSICAL_ADDRESS PhysicalStart,
+ IN UINT64 NumberOfBytes
+ )
+/*++
+
+Routine Description:
+
+ Builds a HOB that describes a chunck of system memory
+
+Arguments:
+
+ PeiServices - The PEI core services table.
+
+ ResourceType - The type of resource described by this HOB
+
+ ResourceAttribute - The resource attributes of the memory described by this HOB
+
+ PhysicalStart - The 64 bit physical address of memory described by this HOB
+
+ NumberOfBytes - The length of the memoty described by this HOB in bytes
+
+Returns:
+
+ EFI_SUCCESS - Hob is successfully built.
+ Others - Errors occur while creating new Hob
+
+--*/
+;
+
+EFI_STATUS
+PeiBuildHobGuid (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_GUID *Guid,
+ IN UINTN DataLength,
+ IN OUT VOID **Hob
+ )
+/*++
+
+Routine Description:
+
+ Builds a custom HOB that is tagged with a GUID for identification
+
+Arguments:
+
+ PeiServices - The PEI core services table.
+
+ Guid - The GUID of the custome HOB type
+
+ DataLength - The size of the data payload for the GUIDed HOB
+
+ Hob - Pointer to the Hob
+
+Returns:
+
+ EFI_SUCCESS - Hob is successfully built.
+ Others - Errors occur while creating new Hob
+
+--*/
+;
+
+EFI_STATUS
+PeiBuildHobGuidData (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_GUID *Guid,
+ IN VOID *Data,
+ IN UINTN DataLength
+ )
+/*++
+
+Routine Description:
+
+ Builds a custom HOB that is tagged with a GUID for identification
+
+Arguments:
+
+ PeiServices - The PEI core services table.
+
+ Guid - The GUID of the custome HOB type
+
+ Data - The data to be copied into the GUIDed HOB data field.
+
+ DataLength - The data field length.
+
+Returns:
+
+ EFI_SUCCESS - Hob is successfully built.
+ Others - Errors occur while creating new Hob
+
+--*/
+;
+
+EFI_STATUS
+PeiBuildHobFv (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length
+ )
+/*++
+
+Routine Description:
+
+ Builds a Firmware Volume HOB
+
+Arguments:
+
+ PeiServices - The PEI core services table.
+
+ BaseAddress - The base address of the Firmware Volume
+
+ Length - The size of the Firmware Volume in bytes
+
+Returns:
+
+ EFI_SUCCESS - Hob is successfully built.
+ Others - Errors occur while creating new Hob
+
+--*/
+;
+
+EFI_STATUS
+PeiBuildHobCpu (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN UINT8 SizeOfMemorySpace,
+ IN UINT8 SizeOfIoSpace
+ )
+/*++
+
+Routine Description:
+
+ Builds a HOB for the CPU
+
+Arguments:
+
+ PeiServices - The PEI core services table.
+
+ SizeOfMemorySpace - Identifies the maximum
+ physical memory addressibility of the processor.
+
+ SizeOfIoSpace - Identifies the maximum physical I/O addressibility
+ of the processor.
+
+Returns:
+
+ EFI_SUCCESS - Hob is successfully built.
+ Others - Errors occur while creating new Hob
+
+--*/
+;
+
+EFI_STATUS
+PeiBuildHobStack (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length
+ )
+/*++
+
+Routine Description:
+
+ Builds a HOB for the Stack
+
+Arguments:
+
+ PeiServices - The PEI core services table.
+
+ BaseAddress - The 64 bit physical address of the Stack
+
+ Length - The length of the stack in bytes
+
+Returns:
+
+ EFI_SUCCESS - Hob is successfully built.
+ Others - Errors occur while creating new Hob
+
+--*/
+;
+
+EFI_STATUS
+PeiBuildHobBspStore (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length,
+ IN EFI_MEMORY_TYPE MemoryType
+ )
+/*++
+
+Routine Description:
+
+ Builds a HOB for the bsp store
+
+Arguments:
+
+ PeiServices - The PEI core services table.
+
+ BaseAddress - The 64 bit physical address of the bsp store
+
+ Length - The length of the bsp store in bytes
+
+ MemoryType - Memory type
+
+Returns:
+
+ EFI_SUCCESS - Hob is successfully built.
+ Others - Errors occur while creating new Hob
+
+--*/
+;
+
+EFI_STATUS
+PeiBuildHobMemoryAllocation (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length,
+ IN EFI_GUID *Name,
+ IN EFI_MEMORY_TYPE MemoryType
+ )
+/*++
+
+Routine Description:
+
+ Builds a HOB for the memory allocation
+
+Arguments:
+
+ PeiServices - The PEI core services table.
+
+ BaseAddress - The 64 bit physical address of the memory
+
+ Length - The length of the memory allocation in bytes
+
+ Name - Name for Hob
+
+ MemoryType - Memory type
+
+Returns:
+
+ EFI_SUCCESS - Hob is successfully built.
+ Others - Errors occur while creating new Hob
+
+--*/
+;
+
+//
+// print.c
+//
+UINTN
+AvSPrint (
+ OUT CHAR8 *StartOfBuffer,
+ IN UINTN StrSize,
+ IN CONST CHAR8 *Format,
+ IN VA_LIST Marker
+ )
+/*++
+
+Routine Description:
+
+ AvSPrint function to process format and place the results in Buffer. Since a
+ VA_LIST is used this rountine allows the nesting of Vararg routines. Thus
+ this is the main print working routine
+
+Arguments:
+
+ StartOfBuffer - Ascii buffer to print the results of the parsing of Format into.
+
+ StrSize - Maximum number of characters to put into buffer. Zero means
+ no limit.
+
+ FormatString - Ascii format string see file header for more details.
+
+ Marker - Vararg list consumed by processing Format.
+
+Returns:
+
+ Number of characters printed.
+
+--*/
+;
+
+UINTN
+ASPrint (
+ OUT CHAR8 *Buffer,
+ IN UINTN BufferSize,
+ IN CONST CHAR8 *Format,
+ ...
+ )
+/*++
+
+Routine Description:
+
+ ASPrint function to process format and place the results in Buffer.
+
+Arguments:
+
+ Buffer - Ascii buffer to print the results of the parsing of Format into.
+
+ BufferSize - Maximum number of characters to put into buffer. Zero means no
+ limit.
+
+ Format - Ascii format string see file header for more details.
+
+ ... - Vararg list consumed by processing Format.
+
+Returns:
+
+ Number of characters printed.
+
+--*/
+;
+
+//
+// math.c
+//
+UINT64
+MultU64x32 (
+ IN UINT64 Multiplicand,
+ IN UINTN Multiplier
+ )
+/*++
+
+Routine Description:
+
+ This routine allows a 64 bit value to be multiplied with a 32 bit
+ value returns 64bit result.
+ No checking if the result is greater than 64bits
+
+Arguments:
+
+ Multiplicand - multiplicand
+ Multiplier - multiplier
+
+Returns:
+
+ Multiplicand * Multiplier
+
+--*/
+;
+
+UINT64
+DivU64x32 (
+ IN UINT64 Dividend,
+ IN UINTN Divisor,
+ OUT UINTN *Remainder OPTIONAL
+ )
+/*++
+
+Routine Description:
+
+ This routine allows a 64 bit value to be divided with a 32 bit value returns
+ 64bit result and the Remainder.
+ N.B. only works for 31bit divisors!!
+
+Arguments:
+
+ Dividend - dividend
+ Divisor - divisor
+ Remainder - buffer for remainder
+
+Returns:
+
+ Dividend / Divisor
+ Remainder = Dividend mod Divisor
+
+--*/
+;
+
+UINT64
+RShiftU64 (
+ IN UINT64 Operand,
+ IN UINTN Count
+ )
+/*++
+
+Routine Description:
+
+ This routine allows a 64 bit value to be right shifted by 32 bits and returns the
+ shifted value.
+ Count is valid up 63. (Only Bits 0-5 is valid for Count)
+
+Arguments:
+
+ Operand - Value to be shifted
+ Count - Number of times to shift right.
+
+Returns:
+
+ Value shifted right identified by the Count.
+
+--*/
+;
+
+UINT64
+LShiftU64 (
+ IN UINT64 Operand,
+ IN UINTN Count
+ )
+/*++
+
+Routine Description:
+
+ This routine allows a 64 bit value to be left shifted by 32 bits and
+ returns the shifted value.
+ Count is valid up 63. (Only Bits 0-5 is valid for Count)
+
+Arguments:
+
+ Operand - Value to be shifted
+ Count - Number of times to shift left.
+
+Returns:
+
+ Value shifted left identified by the Count.
+
+--*/
+;
+
+VOID
+RegisterNativeCpuIo (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN VOID *CpuIo
+ )
+/*++
+
+Routine Description:
+
+ Register a native Cpu IO
+
+Arguments:
+
+ PeiServices - Calling context
+ CpuIo - CpuIo instance to register
+
+Returns:
+
+ None
+
+--*/
+;
+
+VOID
+GetNativeCpuIo (
+ IN EFI_PEI_SERVICES **PeiServices,
+ OUT VOID **CpuIo
+ )
+/*++
+
+Routine Description:
+
+ Get registered Cpu IO.
+
+Arguments:
+
+ PeiServices - Calling context
+ CpuIo - CpuIo instance registered before
+
+Returns:
+
+ None
+
+--*/
+;
+
+EFI_STATUS
+FindFv (
+ IN EFI_FIND_FV_PPI *This,
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN OUT UINT8 *FvNumber,
+ IN OUT EFI_FIRMWARE_VOLUME_HEADER **FVAddress
+ )
+/*++
+
+Routine Description:
+
+ Search Fv in Hob.
+
+Arguments:
+
+ This - Interface pointer that implement the Find Fv PPI
+
+ PeiServices - Pointer to the PEI Service Table
+
+ FvNumber - The index of the fireware volume to locate
+
+ FVAddress - The address of the volume to discover
+
+Returns:
+
+ EFI_SUCCESS - An addtional fv found
+ EFI_OUT_OF_RESOURCES - There are no fireware volume for given fvnumber
+ EFI_INVALID_PARAMETER - *FvAddress is NULL
+
+--*/
+;
+
+
+
+EFI_STATUS
+EFIAPI
+PeiLibPciCfgModify (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_PCI_CFG_PPI *PciCfg,
+ IN PEI_PCI_CFG_PPI_WIDTH Width,
+ IN UINT64 Address,
+ IN UINTN SetBits,
+ IN UINTN ClearBits
+ )
+/*++
+
+Routine Description:
+
+ PCI read-modify-write operations.
+
+ PIWG's PI specification replaces Inte's EFI Specification 1.10.
+ EFI_PEI_PCI_CFG_PPI defined in Inte's EFI Specification 1.10 is replaced by
+ EFI_PEI_PCI_CFG2_PPI in PI 1.0. "Modify" function in these two PPI are not
+ compatibile with each other.
+
+
+ For Framework code that make the following call:
+
+ PciCfg->Modify (
+ PeiServices,
+ PciCfg,
+ Width,
+ Address,
+ SetBits,
+ ClearBits
+ );
+ it will be updated to the following code which call this library API:
+ PeiLibPciCfgModify (
+ PeiServices,
+ PciCfg,
+ Width,
+ Address,
+ SetBits,
+ ClearBits
+ );
+
+ The
+
+Arguments:
+
+ PeiServices An indirect pointer to the PEI Services Table
+ published by the PEI Foundation.
+ PciCfg A pointer to the this pointer of EFI_PEI_PCI_CFG_PPI.
+ This parameter is unused as a place holder to make
+ the parameter list identical to PEI_PCI_CFG_PPI_RW.
+ Width The width of the access. Enumerated in bytes. Type
+ EFI_PEI_PCI_CFG_PPI_WIDTH is defined in Read().
+
+ Address The physical address of the access.
+
+ SetBits Points to value to bitwise-OR with the read configuration value.
+
+ The size of the value is determined by Width.
+
+ ClearBits Points to the value to negate and bitwise-AND with the read configuration value.
+ The size of the value is determined by Width.
+
+
+Returns:
+
+ EFI_SUCCESS The function completed successfully.
+
+ EFI_DEVICE_ERROR There was a problem with the transaction.
+
+--*/
+;
+
+#endif
diff --git a/EDK/Foundation/Library/Pei/Include/peihoblib.h b/EDK/Foundation/Library/Pei/Include/peihoblib.h
new file mode 100644
index 0000000..9a8b455
--- /dev/null
+++ b/EDK/Foundation/Library/Pei/Include/peihoblib.h
@@ -0,0 +1,346 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PeiHobLib.h
+
+Abstract:
+
+
+--*/
+
+#ifndef _EFI_PEI_HOB_LIB_H_
+#define _EFI_PEI_HOB_LIB_H_
+
+#include "PeiApi.h" // EFI_PEI_SERVICES definition
+#define EFI_STACK_SIZE 0x20000
+#define EFI_BSP_STORE_SIZE 0x4000
+
+EFI_STATUS
+BuildHobHandoffInfoTable (
+ IN VOID *HobStart,
+ IN UINT16 Version,
+ IN EFI_BOOT_MODE BootMode,
+ IN EFI_PHYSICAL_ADDRESS EfiMemoryTop,
+ IN EFI_PHYSICAL_ADDRESS EfiMemoryBottom,
+ IN EFI_PHYSICAL_ADDRESS EfiFreeMemoryTop,
+ IN EFI_PHYSICAL_ADDRESS EfiFreeMemoryBottom
+ )
+/*++
+
+Routine Description:
+
+ Builds a HandoffInformationTable Information Table HOB
+
+Arguments:
+
+ HobStart - Start pointer of hob list
+ Version - The version number pertaining to the PHIT HOB definition.
+ BootMode - The system boot mode as determined during the HOB producer phase.
+ EfiMemoryTop - The highest address location of memory that is allocated for use by the HOB
+ producer phase.
+ EfiMemoryBottom - The lowest address location of memory that is allocated for use by the HOB
+ producer phase.
+ EfiFreeMemoryTop - The highest address location of free memory that is currently available for use
+ by the HOB producer phase.
+ EfiFreeMemoryBottom - The lowest address location of free memory that is available for
+ use by the HOB producer phase.
+
+Returns:
+
+ EFI_SUCCESS
+
+--*/
+;
+
+EFI_STATUS
+BuildHobModule (
+ IN VOID *HobStart,
+ IN EFI_GUID *ModuleName,
+ IN EFI_PHYSICAL_ADDRESS Module,
+ IN UINT64 ModuleLength,
+ IN EFI_PHYSICAL_ADDRESS EntryPoint
+ )
+/*++
+
+Routine Description:
+
+ Builds a HOB for a loaded PE32 module
+
+Arguments:
+
+ HobStart - Start pointer of hob list
+
+ ModuleName - The GUID File Name of the HON from the Firmware Volume
+
+ Module - The 64 bit physical address of the module
+
+ ModuleLength - The length of the module in bytes
+
+ EntryPoint - The 64 bit physical address of the entry point to the module
+
+Returns:
+
+ EFI_SUCCESS
+ EFI_NOT_AVAILABLE_YET
+
+--*/
+;
+
+EFI_STATUS
+BuildHobResourceDescriptor (
+ IN VOID *HobStart,
+ IN EFI_RESOURCE_TYPE ResourceType,
+ IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute,
+ IN EFI_PHYSICAL_ADDRESS PhysicalStart,
+ IN UINT64 NumberOfBytes
+ )
+/*++
+
+Routine Description:
+
+ Builds a HOB that describes a chunck of system memory
+
+Arguments:
+
+ HobStart - Start pointer of hob list
+
+ ResourceType - The type of memory described by this HOB
+
+ ResourceAttribute - The memory attributes of the memory described by this HOB
+
+ PhysicalStart - The 64 bit physical address of memory described by this HOB
+
+ NumberOfBytes - The length of the memoty described by this HOB in bytes
+
+Returns:
+
+ EFI_SUCCESS
+ EFI_NOT_AVAILABLE_YET
+
+--*/
+;
+
+EFI_STATUS
+BuildHobGuidType (
+ IN VOID *HobStart,
+ IN EFI_GUID *Guid,
+ IN VOID *Buffer,
+ IN UINTN BufferSize
+ )
+/*++
+
+Routine Description:
+
+ Builds a custom HOB that is tagged with a GUID for identification
+
+Arguments:
+
+ HobStart - Start pointer of hob list
+
+ Guid - The GUID of the custome HOB type
+
+ Buffer - A pointer to the data for the custom HOB type
+
+ BufferSize - The size in byte of BufferSize
+
+Returns:
+
+ EFI_SUCCESS
+ EFI_NOT_AVAILABLE_YET
+
+--*/
+;
+
+EFI_STATUS
+BuildHobFvDescriptor (
+ IN VOID *HobStart,
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length
+ )
+/*++
+
+Routine Description:
+
+ Builds a Firmware Volume HOB
+
+Arguments:
+
+ HobStart - Start pointer of hob list
+
+ BaseAddress - The base address of the Firmware Volume
+
+ Length - The size of the Firmware Volume in bytes
+
+Returns:
+
+ EFI_SUCCESS
+ EFI_NOT_AVAILABLE_YET
+
+--*/
+;
+
+EFI_STATUS
+BuildHobCpu (
+ IN VOID *HobStart,
+ IN UINT8 SizeOfMemorySpace,
+ IN UINT8 SizeOfIoSpace
+ )
+/*++
+
+Routine Description:
+
+ Builds a HOB for the CPU
+
+Arguments:
+
+ HobStart - Start pointer of hob list
+
+ SizeOfMemorySpace - Identifies the maximum
+ physical memory addressibility of the processor.
+
+ SizeOfIoSpace - Identifies the maximum physical I/O addressibility
+ of the processor.
+
+Returns:
+
+ EFI_SUCCESS
+ EFI_NOT_AVAILABLE_YET
+
+--*/
+;
+
+EFI_STATUS
+BuildHobStack (
+ IN VOID *HobStart,
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length
+ )
+/*++
+
+Routine Description:
+
+ Builds a HOB for the Stack
+
+Arguments:
+
+ HobStart - Start pointer of hob list
+
+ BaseAddress - The 64 bit physical address of the Stack
+
+ Length - The length of the stack in bytes
+
+Returns:
+
+ EFI_SUCCESS
+ EFI_NOT_AVAILABLE_YET
+
+--*/
+;
+
+EFI_STATUS
+BuildHobBspStore (
+ IN VOID *HobStart,
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length,
+ IN EFI_MEMORY_TYPE MemoryType
+ )
+/*++
+
+Routine Description:
+
+ Builds a HOB for the bsp store
+
+Arguments:
+
+ HobStart - Start pointer of hob list
+
+ BaseAddress - The 64 bit physical address of bsp store
+
+ Length - The length of the bsp store in bytes
+
+ MemoryType - Memory type of the bsp store
+
+Returns:
+
+ EFI_SUCCESS
+ EFI_NOT_AVAILABLE_YET
+
+--*/
+;
+
+EFI_STATUS
+BuildMemoryAllocationHob (
+ IN VOID *HobStart,
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length,
+ IN EFI_GUID *Name,
+ IN EFI_MEMORY_TYPE MemoryType
+ )
+/*++
+
+Routine Description:
+
+ Builds a HOB for memory allocation
+
+Arguments:
+
+ HobStart - Start pointer of hob list
+
+ BaseAddress - The base address of memory allocated by this HOB.
+
+ Length - The length in bytes of memory allocated by this HOB.
+
+ Name - A GUID that defines the memory allocation region¡¯s type and purpose,
+ as well as other fields within the memory allocation HOB.
+
+ MemoryType - Defines the type of memory allocated by this HOB.
+
+Returns:
+
+ EFI_SUCCESS
+ EFI_NOT_AVAILABLE_YET
+
+--*/
+;
+
+EFI_STATUS
+GetNextGuidHob (
+ IN OUT VOID **HobStart,
+ IN EFI_GUID * Guid,
+ OUT VOID **Buffer,
+ OUT UINTN *BufferSize OPTIONAL
+ )
+/*++
+
+Routine Description:
+ Get the next guid hob.
+
+Arguments:
+ HobStart A pointer to the start hob.
+ Guid A pointer to a guid.
+ Buffer A pointer to the buffer.
+ BufferSize Buffer size.
+
+Returns:
+ Status code.
+
+ EFI_NOT_FOUND - Next Guid hob not found
+
+ EFI_SUCCESS - Next Guid hob found and data for this Guid got
+
+ EFI_INVALID_PARAMETER - invalid parameter
+
+--*/
+;
+
+#endif
diff --git a/EDK/Foundation/Library/Pei/PeiLib/Debug.c b/EDK/Foundation/Library/Pei/PeiLib/Debug.c
new file mode 100644
index 0000000..3f2fe67
--- /dev/null
+++ b/EDK/Foundation/Library/Pei/PeiLib/Debug.c
@@ -0,0 +1,158 @@
+/*++
+
+Copyright (c) 2004 - 2005, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Debug.c
+
+Abstract:
+
+ Support for Debug primatives.
+
+--*/
+
+#include "Tiano.h"
+#include "Pei.h"
+#include "EfiPrintLib.h"
+#include "EfiStatusCode.h"
+#include "EfiCommonLib.h"
+#include EFI_GUID_DEFINITION (StatusCodeCallerId)
+#include EFI_GUID_DEFINITION (StatusCodeDataTypeId)
+#include EFI_PPI_DEFINITION (DebugMask)
+
+UINTN gErrorLevel = EFI_DBUG_MASK | EFI_D_LOAD | EFI_D_INFO; //;;## ...AMI_OVERRIDE... Aptio not support gEfiDebugMaskPpiGuid.
+
+VOID
+PeiDebugAssert (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN CHAR8 *FileName,
+ IN INTN LineNumber,
+ IN CHAR8 *Description
+ )
+/*++
+
+Routine Description:
+
+ Worker function for ASSERT(). If Error Logging hub is loaded log ASSERT
+ information. If Error Logging hub is not loaded DEADLOOP ().
+
+Arguments:
+
+ PeiServices - The PEI core services table.
+
+ FileName - File name of failing routine.
+
+ LineNumber - Line number of failing ASSERT().
+
+ Description - Description, usually the assertion,
+
+Returns:
+
+ None
+
+--*/
+{
+ UINT64 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE];
+
+ EfiDebugAssertWorker (FileName, LineNumber, Description, sizeof (Buffer), Buffer);
+
+ //
+ // We choose NOT to use PEI_REPORT_STATUS_CODE here, because when debug is enable,
+ // we want get enough information if assert.
+ //
+ (**PeiServices).PeiReportStatusCode (
+ PeiServices,
+ (EFI_ERROR_CODE | EFI_ERROR_UNRECOVERED),
+ (EFI_SOFTWARE_PEI_MODULE | EFI_SW_EC_ILLEGAL_SOFTWARE_STATE),
+ 0,
+ &gEfiCallerIdGuid,
+ (EFI_STATUS_CODE_DATA *) Buffer
+ );
+
+ EFI_DEADLOOP ();
+}
+
+
+VOID
+PeiDebugPrint (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN UINTN ErrorLevel,
+ IN CHAR8 *Format,
+ ...
+ )
+/*++
+
+Routine Description:
+
+ Worker function for DEBUG(). If Error Logging hub is loaded log ASSERT
+ information. If Error Logging hub is not loaded do nothing.
+
+Arguments:
+
+ PeiServices - The PEI core services table.
+
+ ErrorLevel - If error level is set do the debug print.
+
+ Format - String to use for the print, followed by Print arguments.
+
+ ... - Print arguments
+
+Returns:
+
+ None
+
+--*/
+{
+ VA_LIST Marker;
+ UINT64 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE];
+ EFI_DEBUG_MASK_PPI *DebugMaskPpi;
+ EFI_STATUS Status;
+
+ //
+ // Locate the DebugMask Ppi.
+ //
+ Status = (*PeiServices)->LocatePpi (
+ PeiServices,
+ &gEfiDebugMaskPpiGuid,
+ 0,
+ NULL,
+ &DebugMaskPpi
+ );
+
+ //
+ // Check driver debug mask value and global mask
+ //
+ if (!EFI_ERROR (Status)) {
+ if (!(ErrorLevel & DebugMaskPpi->ImageDebugMask)) {
+ return ;
+ }
+ } else if (!(gErrorLevel & ErrorLevel)) {
+ return ;
+ }
+
+ VA_START (Marker, Format);
+ EfiDebugVPrintWorker (ErrorLevel, Format, Marker, sizeof (Buffer), Buffer);
+
+ //
+ // We choose NOT to use PEI_REPORT_STATUS_CODE here, because when debug is enable,
+ // we want get enough information if assert.
+ //
+ (**PeiServices).PeiReportStatusCode (
+ PeiServices,
+ EFI_DEBUG_CODE,
+ (EFI_SOFTWARE_PEI_MODULE | EFI_DC_UNSPECIFIED),
+ 0,
+ &gEfiCallerIdGuid,
+ (EFI_STATUS_CODE_DATA *) Buffer
+ );
+
+ return ;
+}
diff --git a/EDK/Foundation/Library/Pei/PeiLib/Decompress.c b/EDK/Foundation/Library/Pei/PeiLib/Decompress.c
new file mode 100644
index 0000000..2a8c80b
--- /dev/null
+++ b/EDK/Foundation/Library/Pei/PeiLib/Decompress.c
@@ -0,0 +1,1140 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Decompress.c
+
+Abstract:
+
+ Decompressor. Algorithm Ported from OPSD code (Decomp.asm)
+
+--*/
+
+#include "TianoCommon.h"
+#include EFI_PROTOCOL_DEFINITION (Decompress)
+#include EFI_PROTOCOL_DEFINITION (TianoDecompress)
+
+EFI_STATUS
+EFIAPI
+EfiGetInfo (
+ IN EFI_DECOMPRESS_PROTOCOL *This,
+ IN VOID *Source,
+ IN UINT32 SrcSize,
+ OUT UINT32 *DstSize,
+ OUT UINT32 *ScratchSize
+ );
+
+EFI_STATUS
+EFIAPI
+EfiDecompress (
+ IN EFI_DECOMPRESS_PROTOCOL *This,
+ IN VOID *Source,
+ IN UINT32 SrcSize,
+ IN OUT VOID *Destination,
+ IN UINT32 DstSize,
+ IN OUT VOID *Scratch,
+ IN UINT32 ScratchSize
+ );
+
+EFI_STATUS
+EFIAPI
+TianoGetInfo (
+ IN EFI_TIANO_DECOMPRESS_PROTOCOL *This,
+ IN VOID *Source,
+ IN UINT32 SrcSize,
+ OUT UINT32 *DstSize,
+ OUT UINT32 *ScratchSize
+ );
+
+EFI_STATUS
+EFIAPI
+TianoDecompress (
+ IN EFI_TIANO_DECOMPRESS_PROTOCOL *This,
+ IN VOID *Source,
+ IN UINT32 SrcSize,
+ IN OUT VOID *Destination,
+ IN UINT32 DstSize,
+ IN OUT VOID *Scratch,
+ IN UINT32 ScratchSize
+ );
+
+//
+// The protocol instance
+//
+
+EFI_DECOMPRESS_PROTOCOL mEfiDecompress = {
+ EfiGetInfo,
+ EfiDecompress
+};
+
+EFI_TIANO_DECOMPRESS_PROTOCOL mTianoDecompress = {
+ TianoGetInfo,
+ TianoDecompress
+};
+
+EFI_STATUS
+InstallEfiDecompress (
+ IN OUT EFI_DECOMPRESS_PROTOCOL **This
+ )
+/*++
+
+Routine Description:
+
+ Install EFI decompress protocol.
+
+Arguments:
+
+ This - Pointer to get decompress protocol as output
+
+Returns:
+
+ EFI_SUCCESS - EFI decompress protocol successfully installed.
+
+--*/
+{
+ *This = &mEfiDecompress;
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+InstallTianoDecompress (
+ EFI_TIANO_DECOMPRESS_PROTOCOL **This
+ )
+/*++
+
+Routine Description:
+
+ Install Tiano decompress protocol.
+
+Arguments:
+
+ This - Pointer to get decompress protocol as output
+
+Returns:
+
+ EFI_SUCCESS - Tiano decompress protocol successfully installed.
+
+--*/
+{
+ *This = &mTianoDecompress;
+ return EFI_SUCCESS;
+}
+//
+// Decompression algorithm begins here
+//
+#define BITBUFSIZ 32
+#define MAXMATCH 256
+#define THRESHOLD 3
+#define CODE_BIT 16
+#define UINT8_MAX 0xff
+#define BAD_TABLE - 1
+
+//
+// C: Char&Len Set; P: Position Set; T: exTra Set
+//
+#define NC (0xff + MAXMATCH + 2 - THRESHOLD)
+#define CBIT 9
+#define MAXPBIT 5
+#define TBIT 5
+#define MAXNP ((1U << MAXPBIT) - 1)
+#define NT (CODE_BIT + 3)
+#if NT > MAXNP
+#define NPT NT
+#else
+#define NPT MAXNP
+#endif
+
+typedef struct {
+ UINT8 *mSrcBase; // Starting address of compressed data
+ UINT8 *mDstBase; // Starting address of decompressed data
+ UINT32 mOutBuf;
+ UINT32 mInBuf;
+
+ UINT16 mBitCount;
+ UINT32 mBitBuf;
+ UINT32 mSubBitBuf;
+ UINT16 mBlockSize;
+ UINT32 mCompSize;
+ UINT32 mOrigSize;
+
+ UINT16 mBadTableFlag;
+
+ UINT16 mLeft[2 * NC - 1];
+ UINT16 mRight[2 * NC - 1];
+ UINT8 mCLen[NC];
+ UINT8 mPTLen[NPT];
+ UINT16 mCTable[4096];
+ UINT16 mPTTable[256];
+
+ //
+ // The length of the field 'Position Set Code Length Array Size' in Block Header.
+ // For EFI 1.1 de/compression algorithm, mPBit = 4
+ // For Tiano de/compression algorithm, mPBit = 5
+ //
+ UINT8 mPBit;
+} SCRATCH_DATA;
+
+STATIC
+VOID
+FillBuf (
+ IN SCRATCH_DATA *Sd,
+ IN UINT16 NumOfBits
+ )
+/*++
+
+Routine Description:
+
+ Shift mBitBuf NumOfBits left. Read in NumOfBits of bits from source.
+
+Arguments:
+
+ Sd - The global scratch data
+ NumOfBits - The number of bits to shift and read.
+
+Returns: (VOID)
+
+--*/
+{
+ Sd->mBitBuf = (UINT32) (Sd->mBitBuf << NumOfBits);
+
+ while (NumOfBits > Sd->mBitCount) {
+
+ Sd->mBitBuf |= (UINT32) (Sd->mSubBitBuf << (NumOfBits = (UINT16) (NumOfBits - Sd->mBitCount)));
+
+ if (Sd->mCompSize > 0) {
+ //
+ // Get 1 byte into SubBitBuf
+ //
+ Sd->mCompSize--;
+ Sd->mSubBitBuf = 0;
+ Sd->mSubBitBuf = Sd->mSrcBase[Sd->mInBuf++];
+ Sd->mBitCount = 8;
+
+ } else {
+ //
+ // No more bits from the source, just pad zero bit.
+ //
+ Sd->mSubBitBuf = 0;
+ Sd->mBitCount = 8;
+
+ }
+ }
+
+ Sd->mBitCount = (UINT16) (Sd->mBitCount - NumOfBits);
+ Sd->mBitBuf |= Sd->mSubBitBuf >> Sd->mBitCount;
+}
+
+STATIC
+UINT32
+GetBits (
+ IN SCRATCH_DATA *Sd,
+ IN UINT16 NumOfBits
+ )
+/*++
+
+Routine Description:
+
+ Get NumOfBits of bits out from mBitBuf. Fill mBitBuf with subsequent
+ NumOfBits of bits from source. Returns NumOfBits of bits that are
+ popped out.
+
+Arguments:
+
+ Sd - The global scratch data.
+ NumOfBits - The number of bits to pop and read.
+
+Returns:
+
+ The bits that are popped out.
+
+--*/
+{
+ UINT32 OutBits;
+
+ OutBits = (UINT32) (Sd->mBitBuf >> (BITBUFSIZ - NumOfBits));
+
+ FillBuf (Sd, NumOfBits);
+
+ return OutBits;
+}
+
+STATIC
+UINT16
+MakeTable (
+ IN SCRATCH_DATA *Sd,
+ IN UINT16 NumOfChar,
+ IN UINT8 *BitLen,
+ IN UINT16 TableBits,
+ OUT UINT16 *Table
+ )
+/*++
+
+Routine Description:
+
+ Creates Huffman Code mapping table according to code length array.
+
+Arguments:
+
+ Sd - The global scratch data
+ NumOfChar - Number of symbols in the symbol set
+ BitLen - Code length array
+ TableBits - The width of the mapping table
+ Table - The table
+
+Returns:
+
+ 0 - OK.
+ BAD_TABLE - The table is corrupted.
+
+--*/
+{
+ UINT16 Count[17];
+ UINT16 Weight[17];
+ UINT16 Start[18];
+ UINT16 *Pointer;
+ UINT16 Index3;
+ UINT16 Index;
+ UINT16 Len;
+ UINT16 Char;
+ UINT16 JuBits;
+ UINT16 Avail;
+ UINT16 NextCode;
+ UINT16 Mask;
+
+ //
+ // TableBits should not be greater than 16.
+ //
+ if (TableBits >= (sizeof (Count)/sizeof (UINT16))) {
+ return (UINT16) BAD_TABLE;
+ }
+
+ //
+ // Initialize Count array starting from Index 0, as there is a possibility of Count array being uninitialized.
+ //
+ for (Index = 0; Index <= 16; Index++) {
+ Count[Index] = 0;
+ }
+
+ for (Index = 0; Index < NumOfChar; Index++) {
+ //
+ // Count array index should not be greater than or equal to its size.
+ //
+ if (BitLen[Index] < (sizeof (Count)/sizeof (UINT16))) {
+ Count[BitLen[Index]]++;
+ } else {
+ return (UINT16) BAD_TABLE;
+ }
+ }
+
+ Start[1] = 0;
+
+ for (Index = 1; Index <= 16; Index++) {
+ Start[Index + 1] = (UINT16) (Start[Index] + (Count[Index] << (16 - Index)));
+ }
+
+ if (Start[17] != 0) {
+ /*(1U << 16)*/
+ return (UINT16) BAD_TABLE;
+ }
+
+ JuBits = (UINT16) (16 - TableBits);
+
+ for (Index = 1; Index <= TableBits; Index++) {
+ Start[Index] >>= JuBits;
+ Weight[Index] = (UINT16) (1U << (TableBits - Index));
+ }
+
+ while (Index <= 16) {
+ Weight[Index++] = (UINT16) (1U << (16 - Index));
+ }
+
+ Index = (UINT16) (Start[TableBits + 1] >> JuBits);
+
+ if (Index != 0) {
+ Index3 = (UINT16) (1U << TableBits);
+ while (Index != Index3) {
+ Table[Index++] = 0;
+ }
+ }
+
+ Avail = NumOfChar;
+ Mask = (UINT16) (1U << (15 - TableBits));
+
+ for (Char = 0; Char < NumOfChar; Char++) {
+
+ Len = BitLen[Char];
+ if (Len == 0) {
+ continue;
+ }
+
+ NextCode = (UINT16) (Start[Len] + Weight[Len]);
+
+ if (Len <= TableBits) {
+
+ for (Index = Start[Len]; Index < NextCode; Index++) {
+ Table[Index] = Char;
+ }
+
+ } else {
+
+ Index3 = Start[Len];
+ Pointer = &Table[Index3 >> JuBits];
+ Index = (UINT16) (Len - TableBits);
+
+ while (Index != 0) {
+ //
+ // Avail should be lesser than size of mRight and mLeft to prevent buffer overflow.
+ //
+ if ((*Pointer == 0) && (Avail < sizeof (Sd->mRight)/sizeof (UINT16)) && (Avail < sizeof (Sd->mLeft)/sizeof (UINT16))) {
+ Sd->mRight[Avail] = Sd->mLeft[Avail] = 0;
+ *Pointer = Avail++;
+ }
+
+ //
+ // *Pointer should be lesser than size of mRight and mLeft to prevent buffer overflow.
+ //
+ if ((Index3 & Mask) && (*Pointer < (sizeof (Sd->mRight)/sizeof (UINT16)))) {
+ Pointer = &Sd->mRight[*Pointer];
+ } else if (*Pointer < (sizeof (Sd->mLeft)/sizeof (UINT16))) {
+ Pointer = &Sd->mLeft[*Pointer];
+ }
+
+ Index3 <<= 1;
+ Index--;
+ }
+
+ *Pointer = Char;
+
+ }
+
+ Start[Len] = NextCode;
+ }
+ //
+ // Succeeds
+ //
+ return 0;
+}
+
+STATIC
+UINT32
+DecodeP (
+ IN SCRATCH_DATA *Sd
+ )
+/*++
+
+Routine Description:
+
+ Decodes a position value.
+
+Arguments:
+
+ Sd - the global scratch data
+
+Returns:
+
+ The position value decoded.
+
+--*/
+{
+ UINT16 Val;
+ UINT32 Mask;
+ UINT32 Pos;
+
+ Val = Sd->mPTTable[Sd->mBitBuf >> (BITBUFSIZ - 8)];
+
+ if (Val >= MAXNP) {
+ Mask = 1U << (BITBUFSIZ - 1 - 8);
+
+ do {
+
+ if (Sd->mBitBuf & Mask) {
+ Val = Sd->mRight[Val];
+ } else {
+ Val = Sd->mLeft[Val];
+ }
+
+ Mask >>= 1;
+ } while (Val >= MAXNP);
+ }
+ //
+ // Advance what we have read
+ //
+ FillBuf (Sd, Sd->mPTLen[Val]);
+
+ Pos = Val;
+ if (Val > 1) {
+ Pos = (UINT32) ((1U << (Val - 1)) + GetBits (Sd, (UINT16) (Val - 1)));
+ }
+
+ return Pos;
+}
+
+STATIC
+UINT16
+ReadPTLen (
+ IN SCRATCH_DATA *Sd,
+ IN UINT16 nn,
+ IN UINT16 nbit,
+ IN UINT16 Special
+ )
+/*++
+
+Routine Description:
+
+ Reads code lengths for the Extra Set or the Position Set
+
+Arguments:
+
+ Sd - The global scratch data
+ nn - Number of symbols
+ nbit - Number of bits needed to represent nn
+ Special - The special symbol that needs to be taken care of
+
+Returns:
+
+ 0 - OK.
+ BAD_TABLE - Table is corrupted.
+
+--*/
+{
+ UINT16 Number;
+ UINT16 CharC;
+ UINT16 Index;
+ UINT32 Mask;
+
+ Number = (UINT16) GetBits (Sd, nbit);
+
+ if ((Number > sizeof (Sd->mPTLen)) || (nn > sizeof (Sd->mPTLen))) {
+ //
+ // Fail if Number or nn is greater than size of mPTLen
+ //
+ return (UINT16) BAD_TABLE;
+ }
+
+ if (Number == 0) {
+ CharC = (UINT16) GetBits (Sd, nbit);
+
+ for (Index = 0; Index < 256; Index++) {
+ Sd->mPTTable[Index] = CharC;
+ }
+
+ for (Index = 0; Index < nn; Index++) {
+ Sd->mPTLen[Index] = 0;
+ }
+
+ return 0;
+ }
+
+ Index = 0;
+
+ while (Index < Number) {
+
+ CharC = (UINT16) (Sd->mBitBuf >> (BITBUFSIZ - 3));
+
+ if (CharC == 7) {
+ Mask = 1U << (BITBUFSIZ - 1 - 3);
+ while (Mask & Sd->mBitBuf) {
+ Mask >>= 1;
+ CharC += 1;
+ }
+ }
+
+ FillBuf (Sd, (UINT16) ((CharC < 7) ? 3 : CharC - 3));
+
+ Sd->mPTLen[Index++] = (UINT8) CharC;
+
+ if (Index == Special) {
+ CharC = (UINT16) GetBits (Sd, 2);
+ while ((INT16) (--CharC) >= 0) {
+ if (Index >= sizeof (Sd->mPTLen)) {
+ //
+ // Fail if Index is greater than or equal to mPTLen
+ //
+ return (UINT16) BAD_TABLE;
+ }
+ Sd->mPTLen[Index++] = 0;
+ }
+ }
+ }
+
+ while (Index < nn) {
+ Sd->mPTLen[Index++] = 0;
+ }
+
+ return MakeTable (Sd, nn, Sd->mPTLen, 8, Sd->mPTTable);
+}
+
+STATIC
+VOID
+ReadCLen (
+ SCRATCH_DATA *Sd
+ )
+/*++
+
+Routine Description:
+
+ Reads code lengths for Char&Len Set.
+
+Arguments:
+
+ Sd - the global scratch data
+
+Returns: (VOID)
+
+--*/
+{
+ UINT16 Number;
+ UINT16 CharC;
+ UINT16 Index;
+ UINT32 Mask;
+
+ Number = (UINT16) GetBits (Sd, CBIT);
+
+ if (Number == 0) {
+ CharC = (UINT16) GetBits (Sd, CBIT);
+
+ for (Index = 0; Index < NC; Index++) {
+ Sd->mCLen[Index] = 0;
+ }
+
+ for (Index = 0; Index < 4096; Index++) {
+ Sd->mCTable[Index] = CharC;
+ }
+
+ return ;
+ }
+
+ Index = 0;
+ while (Index < Number) {
+
+ CharC = Sd->mPTTable[Sd->mBitBuf >> (BITBUFSIZ - 8)];
+ if (CharC >= NT) {
+ Mask = 1U << (BITBUFSIZ - 1 - 8);
+
+ do {
+
+ if (Mask & Sd->mBitBuf) {
+ CharC = Sd->mRight[CharC];
+ } else {
+ CharC = Sd->mLeft[CharC];
+ }
+
+ Mask >>= 1;
+
+ } while (CharC >= NT);
+ }
+ //
+ // Advance what we have read
+ //
+ FillBuf (Sd, Sd->mPTLen[CharC]);
+
+ if (CharC <= 2) {
+
+ if (CharC == 0) {
+ CharC = 1;
+ } else if (CharC == 1) {
+ CharC = (UINT16) (GetBits (Sd, 4) + 3);
+ } else if (CharC == 2) {
+ CharC = (UINT16) (GetBits (Sd, CBIT) + 20);
+ }
+
+ while ((INT16) (--CharC) >= 0) {
+ Sd->mCLen[Index++] = 0;
+ }
+
+ } else {
+
+ Sd->mCLen[Index++] = (UINT8) (CharC - 2);
+
+ }
+ }
+
+ while (Index < NC) {
+ Sd->mCLen[Index++] = 0;
+ }
+
+ MakeTable (Sd, NC, Sd->mCLen, 12, Sd->mCTable);
+
+ return ;
+}
+
+STATIC
+UINT16
+DecodeC (
+ SCRATCH_DATA *Sd
+ )
+/*++
+
+Routine Description:
+
+ Decode a character/length value.
+
+Arguments:
+
+ Sd - The global scratch data.
+
+Returns:
+
+ The value decoded.
+
+--*/
+{
+ UINT16 Index2;
+ UINT32 Mask;
+
+ if (Sd->mBlockSize == 0) {
+ //
+ // Starting a new block
+ //
+ Sd->mBlockSize = (UINT16) GetBits (Sd, 16);
+ Sd->mBadTableFlag = ReadPTLen (Sd, NT, TBIT, 3);
+ if (Sd->mBadTableFlag != 0) {
+ return 0;
+ }
+
+ ReadCLen (Sd);
+
+ Sd->mBadTableFlag = ReadPTLen (Sd, MAXNP, Sd->mPBit, (UINT16) (-1));
+ if (Sd->mBadTableFlag != 0) {
+ return 0;
+ }
+ }
+
+ Sd->mBlockSize--;
+ Index2 = Sd->mCTable[Sd->mBitBuf >> (BITBUFSIZ - 12)];
+
+ if (Index2 >= NC) {
+ Mask = 1U << (BITBUFSIZ - 1 - 12);
+
+ do {
+ if (Sd->mBitBuf & Mask) {
+ Index2 = Sd->mRight[Index2];
+ } else {
+ Index2 = Sd->mLeft[Index2];
+ }
+
+ Mask >>= 1;
+ } while (Index2 >= NC);
+ }
+ //
+ // Advance what we have read
+ //
+ FillBuf (Sd, Sd->mCLen[Index2]);
+
+ return Index2;
+}
+
+STATIC
+VOID
+Decode (
+ SCRATCH_DATA *Sd
+ )
+/*++
+
+Routine Description:
+
+ Decode the source data and put the resulting data into the destination buffer.
+
+Arguments:
+
+ Sd - The global scratch data
+
+Returns: (VOID)
+
+ --*/
+{
+ UINT16 BytesRemain;
+ UINT32 DataIdx;
+ UINT16 CharC;
+
+ BytesRemain = (UINT16) (-1);
+
+ DataIdx = 0;
+
+ for (;;) {
+ CharC = DecodeC (Sd);
+ if (Sd->mBadTableFlag != 0) {
+ return ;
+ }
+
+ if (CharC < 256) {
+ //
+ // Process an Original character
+ //
+ if (Sd->mOutBuf >= Sd->mOrigSize) {
+ return ;
+ } else {
+ Sd->mDstBase[Sd->mOutBuf++] = (UINT8) CharC;
+ }
+
+ } else {
+ //
+ // Process a Pointer
+ //
+ CharC = (UINT16) (CharC - (UINT8_MAX + 1 - THRESHOLD));
+
+ BytesRemain = CharC;
+
+ DataIdx = Sd->mOutBuf - DecodeP (Sd) - 1;
+
+ BytesRemain--;
+ while ((INT16) (BytesRemain) >= 0) {
+ Sd->mDstBase[Sd->mOutBuf++] = Sd->mDstBase[DataIdx++];
+ if (Sd->mOutBuf >= Sd->mOrigSize) {
+ return ;
+ }
+
+ BytesRemain--;
+ }
+ }
+ }
+
+ return ;
+}
+
+EFI_STATUS
+GetInfo (
+ IN VOID *Source,
+ IN UINT32 SrcSize,
+ OUT UINT32 *DstSize,
+ OUT UINT32 *ScratchSize
+ )
+/*++
+
+Routine Description:
+
+ The internal implementation of *_DECOMPRESS_PROTOCOL.GetInfo().
+
+Arguments:
+
+ Source - The source buffer containing the compressed data.
+ SrcSize - The size of source buffer
+ DstSize - The size of destination buffer.
+ ScratchSize - The size of scratch buffer.
+
+Returns:
+
+ EFI_SUCCESS - The size of destination buffer and the size of scratch buffer are successull retrieved.
+ EFI_INVALID_PARAMETER - The source data is corrupted
+
+--*/
+{
+ UINT8 *Src;
+
+ *ScratchSize = sizeof (SCRATCH_DATA);
+
+ Src = Source;
+ if (SrcSize < 8) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ *DstSize = Src[4] + (Src[5] << 8) + (Src[6] << 16) + (Src[7] << 24);
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+Decompress (
+ IN VOID *Source,
+ IN UINT32 SrcSize,
+ IN OUT VOID *Destination,
+ IN UINT32 DstSize,
+ IN OUT VOID *Scratch,
+ IN UINT32 ScratchSize,
+ IN UINT8 Version
+ )
+/*++
+
+Routine Description:
+
+ The internal implementation of *_DECOMPRESS_PROTOCOL.Decompress().
+
+Arguments:
+
+ Source - The source buffer containing the compressed data.
+ SrcSize - The size of source buffer
+ Destination - The destination buffer to store the decompressed data
+ DstSize - The size of destination buffer.
+ Scratch - The buffer used internally by the decompress routine. This buffer is needed to store intermediate data.
+ ScratchSize - The size of scratch buffer.
+ Version - The version of de/compression algorithm.
+ Version 1 for EFI 1.1 de/compression algorithm.
+ Version 2 for Tiano de/compression algorithm.
+
+Returns:
+
+ EFI_SUCCESS - Decompression is successfull
+ EFI_INVALID_PARAMETER - The source data is corrupted
+
+--*/
+{
+ UINT32 Index;
+ UINT32 CompSize;
+ UINT32 OrigSize;
+ EFI_STATUS Status;
+ SCRATCH_DATA *Sd;
+ UINT8 *Src;
+ UINT8 *Dst;
+
+ Status = EFI_SUCCESS;
+ Src = Source;
+ Dst = Destination;
+
+ if (ScratchSize < sizeof (SCRATCH_DATA)) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Sd = (SCRATCH_DATA *) Scratch;
+
+ if (SrcSize < 8) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ CompSize = Src[0] + (Src[1] << 8) + (Src[2] << 16) + (Src[3] << 24);
+ OrigSize = Src[4] + (Src[5] << 8) + (Src[6] << 16) + (Src[7] << 24);
+
+ //
+ // If compressed file size is 0, return
+ //
+ if (OrigSize == 0) {
+ return Status;
+ }
+
+ if (SrcSize < CompSize + 8) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (DstSize != OrigSize) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Src = Src + 8;
+
+ for (Index = 0; Index < sizeof (SCRATCH_DATA); Index++) {
+ ((UINT8 *) Sd)[Index] = 0;
+ }
+ //
+ // The length of the field 'Position Set Code Length Array Size' in Block Header.
+ // For EFI 1.1 de/compression algorithm(Version 1), mPBit = 4
+ // For Tiano de/compression algorithm(Version 2), mPBit = 5
+ //
+ switch (Version) {
+ case 1:
+ Sd->mPBit = 4;
+ break;
+
+ case 2:
+ Sd->mPBit = 5;
+ break;
+
+ default:
+ //
+ // Currently, only have 2 versions
+ //
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Sd->mSrcBase = Src;
+ Sd->mDstBase = Dst;
+ Sd->mCompSize = CompSize;
+ Sd->mOrigSize = OrigSize;
+
+ //
+ // Fill the first BITBUFSIZ bits
+ //
+ FillBuf (Sd, BITBUFSIZ);
+
+ //
+ // Decompress it
+ //
+ Decode (Sd);
+
+ if (Sd->mBadTableFlag != 0) {
+ //
+ // Something wrong with the source
+ //
+ Status = EFI_INVALID_PARAMETER;
+ }
+
+ return Status;
+}
+
+EFI_STATUS
+EFIAPI
+EfiGetInfo (
+ IN EFI_DECOMPRESS_PROTOCOL *This,
+ IN VOID *Source,
+ IN UINT32 SrcSize,
+ OUT UINT32 *DstSize,
+ OUT UINT32 *ScratchSize
+ )
+/*++
+
+Routine Description:
+
+ The implementation of EFI_DECOMPRESS_PROTOCOL.GetInfo().
+
+Arguments:
+
+ This - The protocol instance pointer
+ Source - The source buffer containing the compressed data.
+ SrcSize - The size of source buffer
+ DstSize - The size of destination buffer.
+ ScratchSize - The size of scratch buffer.
+
+Returns:
+
+ EFI_SUCCESS - The size of destination buffer and the size of scratch buffer are successull retrieved.
+ EFI_INVALID_PARAMETER - The source data is corrupted
+
+--*/
+{
+ return GetInfo (
+ Source,
+ SrcSize,
+ DstSize,
+ ScratchSize
+ );
+}
+
+EFI_STATUS
+EFIAPI
+EfiDecompress (
+ IN EFI_DECOMPRESS_PROTOCOL *This,
+ IN VOID *Source,
+ IN UINT32 SrcSize,
+ IN OUT VOID *Destination,
+ IN UINT32 DstSize,
+ IN OUT VOID *Scratch,
+ IN UINT32 ScratchSize
+ )
+/*++
+
+Routine Description:
+
+ The implementation of EFI_DECOMPRESS_PROTOCOL.Decompress().
+
+Arguments:
+
+ This - The protocol instance pointer
+ Source - The source buffer containing the compressed data.
+ SrcSize - The size of source buffer
+ Destination - The destination buffer to store the decompressed data
+ DstSize - The size of destination buffer.
+ Scratch - The buffer used internally by the decompress routine. This buffer is needed to store intermediate data.
+ ScratchSize - The size of scratch buffer.
+
+Returns:
+
+ EFI_SUCCESS - Decompression is successfull
+ EFI_INVALID_PARAMETER - The source data is corrupted
+
+--*/
+{
+ //
+ // For EFI 1.1 de/compression algorithm, the version is 1.
+ //
+ return Decompress (
+ Source,
+ SrcSize,
+ Destination,
+ DstSize,
+ Scratch,
+ ScratchSize,
+ 1
+ );
+}
+
+EFI_STATUS
+EFIAPI
+TianoGetInfo (
+ IN EFI_TIANO_DECOMPRESS_PROTOCOL *This,
+ IN VOID *Source,
+ IN UINT32 SrcSize,
+ OUT UINT32 *DstSize,
+ OUT UINT32 *ScratchSize
+ )
+/*++
+
+Routine Description:
+
+ The implementation of EFI_TIANO_DECOMPRESS_PROTOCOL.GetInfo().
+
+Arguments:
+
+ This - The protocol instance pointer
+ Source - The source buffer containing the compressed data.
+ SrcSize - The size of source buffer
+ DstSize - The size of destination buffer.
+ ScratchSize - The size of scratch buffer.
+
+Returns:
+
+ EFI_SUCCESS - The size of destination buffer and the size of scratch buffer are successull retrieved.
+ EFI_INVALID_PARAMETER - The source data is corrupted
+
+--*/
+{
+ return GetInfo (
+ Source,
+ SrcSize,
+ DstSize,
+ ScratchSize
+ );
+}
+
+EFI_STATUS
+EFIAPI
+TianoDecompress (
+ IN EFI_TIANO_DECOMPRESS_PROTOCOL *This,
+ IN VOID *Source,
+ IN UINT32 SrcSize,
+ IN OUT VOID *Destination,
+ IN UINT32 DstSize,
+ IN OUT VOID *Scratch,
+ IN UINT32 ScratchSize
+ )
+/*++
+
+Routine Description:
+
+ The implementation of EFI_TIANO_DECOMPRESS_PROTOCOL.Decompress().
+
+Arguments:
+
+ This - The protocol instance pointer
+ Source - The source buffer containing the compressed data.
+ SrcSize - The size of source buffer
+ Destination - The destination buffer to store the decompressed data
+ DstSize - The size of destination buffer.
+ Scratch - The buffer used internally by the decompress routine. This buffer is needed to store intermediate data.
+ ScratchSize - The size of scratch buffer.
+
+Returns:
+
+ EFI_SUCCESS - Decompression is successfull
+ EFI_INVALID_PARAMETER - The source data is corrupted
+
+--*/
+{
+ //
+ // For Tiano de/compression algorithm, the version is 2.
+ //
+ return Decompress (
+ Source,
+ SrcSize,
+ Destination,
+ DstSize,
+ Scratch,
+ ScratchSize,
+ 2
+ );
+}
diff --git a/EDK/Foundation/Library/Pei/PeiLib/FindFv.c b/EDK/Foundation/Library/Pei/PeiLib/FindFv.c
new file mode 100644
index 0000000..c0149c2
--- /dev/null
+++ b/EDK/Foundation/Library/Pei/PeiLib/FindFv.c
@@ -0,0 +1,157 @@
+/*++
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ FindFv.c
+
+Abstract:
+
+ Library function to find fv by hob.
+
+--*/
+
+#include "Tiano.h"
+#include "Pei.h"
+#include "PeiLib.h"
+#include "PeiHobLib.h"
+
+static
+VOID *
+GetHob (
+ IN UINT16 Type,
+ IN VOID *HobStart
+ )
+/*++
+
+Routine Description:
+
+ This function returns the first instance of a HOB type in a HOB list.
+
+Arguments:
+
+ Type The HOB type to return.
+ HobStart The first HOB in the HOB list.
+
+Returns:
+
+ HobStart There were no HOBs found with the requested type.
+ else Returns the first HOB with the matching type.
+
+--*/
+{
+ EFI_PEI_HOB_POINTERS Hob;
+
+ Hob.Raw = HobStart;
+ //
+ // Return input if not found
+ //
+ if (HobStart == NULL) {
+ return HobStart;
+ }
+
+ //
+ // Parse the HOB list, stop if end of list or matching type found.
+ //
+ while (!END_OF_HOB_LIST (Hob)) {
+
+ if (Hob.Header->HobType == Type) {
+ break;
+ }
+
+ Hob.Raw = GET_NEXT_HOB (Hob);
+ }
+
+ //
+ // Return input if not found
+ //
+ if (END_OF_HOB_LIST (Hob)) {
+ return HobStart;
+ }
+
+ return (VOID *) (Hob.Raw);
+}
+
+EFI_STATUS
+FindFv (
+ IN EFI_FIND_FV_PPI *This,
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN OUT UINT8 *FvNumber,
+ IN OUT EFI_FIRMWARE_VOLUME_HEADER **FvAddress
+ )
+/*++
+
+Routine Description:
+
+ Search Fv in Hob.
+
+Arguments:
+
+ This - Interface pointer that implement the Find Fv PPI
+
+ PeiServices - Pointer to the PEI Service Table
+
+ FvNumber - The index of the fireware volume to locate
+
+ FVAddress - The address of the volume to discover
+
+Returns:
+
+ EFI_SUCCESS - An addtional fv found
+ EFI_OUT_OF_RESOURCES - There are no fireware volume for given fvnumber
+ EFI_INVALID_PARAMETER - *FvAddress is NULL
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_PEI_HOB_POINTERS HobStart;
+ EFI_PEI_HOB_POINTERS Hob;
+ EFI_HOB_FIRMWARE_VOLUME *FvHob;
+ UINT8 FvIndex;
+
+ if (*FvAddress == NULL){
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Hob.Raw = NULL;
+
+ //
+ // Get the Hob table pointer
+ //
+ Status = (*PeiServices)->GetHobList (
+ PeiServices,
+ &HobStart.Raw
+ );
+
+ if (EFI_ERROR (Status)) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ //
+ // Loop to search the wanted FirmwareVolume Hob
+ //
+ for (FvIndex = 0; FvIndex <= *FvNumber; FvIndex++) {
+ Hob.Raw = GetHob (EFI_HOB_TYPE_FV, HobStart.Raw);
+ if (Hob.Header->HobType != EFI_HOB_TYPE_FV) {
+ *FvNumber = 0;
+ return EFI_OUT_OF_RESOURCES;
+ }
+
+ HobStart.Raw = Hob.Raw + Hob.Header->HobLength;
+ }
+
+ FvHob = Hob.FirmwareVolume;
+
+ *FvAddress = (EFI_FIRMWARE_VOLUME_HEADER *) ((UINTN) FvHob->BaseAddress);
+ (*FvNumber)++;
+
+ return EFI_SUCCESS;
+}
diff --git a/EDK/Foundation/Library/Pei/PeiLib/Hob/Hob.c b/EDK/Foundation/Library/Pei/PeiLib/Hob/Hob.c
new file mode 100644
index 0000000..18f32cf
--- /dev/null
+++ b/EDK/Foundation/Library/Pei/PeiLib/Hob/Hob.c
@@ -0,0 +1,517 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ hob.c
+
+Abstract:
+
+ PEI Library Functions
+
+--*/
+
+#include "Tiano.h"
+#include "Pei.h"
+#include "peilib.h"
+#include EFI_GUID_DEFINITION (MemoryAllocationHob)
+
+
+EFI_STATUS
+PeiBuildHobModule (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_GUID *ModuleName,
+ IN EFI_PHYSICAL_ADDRESS MemoryAllocationModule,
+ IN UINT64 ModuleLength,
+ IN EFI_PHYSICAL_ADDRESS EntryPoint
+ )
+/*++
+
+Routine Description:
+
+ Builds a HOB for a loaded PE32 module
+
+Arguments:
+
+ PeiServices - The PEI core services table.
+ ModuleName - The GUID File Name of the module
+ MemoryAllocationModule - The 64 bit physical address of the module
+ ModuleLength - The length of the module in bytes
+ EntryPoint - The 64 bit physical address of the entry point
+ to the module
+
+Returns:
+
+ EFI_SUCCESS - Hob is successfully built.
+ Others - Errors occur while creating new Hob
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_HOB_MEMORY_ALLOCATION_MODULE *Hob;
+
+ Status = (*PeiServices)->CreateHob (
+ PeiServices,
+ EFI_HOB_TYPE_MEMORY_ALLOCATION,
+ sizeof (EFI_HOB_MEMORY_ALLOCATION_MODULE),
+ &Hob
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Hob->MemoryAllocationHeader.Name = gEfiHobMemeryAllocModuleGuid;
+ Hob->MemoryAllocationHeader.MemoryBaseAddress = MemoryAllocationModule;
+ Hob->MemoryAllocationHeader.MemoryLength = ModuleLength;
+ Hob->MemoryAllocationHeader.MemoryType = EfiBootServicesCode;
+ (*PeiServices)->SetMem (
+ Hob->MemoryAllocationHeader.Reserved,
+ sizeof (Hob->MemoryAllocationHeader.Reserved),
+ 0
+ );
+
+ Hob->ModuleName = *ModuleName;
+ Hob->EntryPoint = EntryPoint;
+
+ return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+PeiBuildHobResourceDescriptor (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_RESOURCE_TYPE ResourceType,
+ IN EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttribute,
+ IN EFI_PHYSICAL_ADDRESS PhysicalStart,
+ IN UINT64 NumberOfBytes
+ )
+/*++
+
+Routine Description:
+
+ Builds a HOB that describes a chunck of system memory
+
+Arguments:
+
+ PeiServices - The PEI core services table.
+
+ ResourceType - The type of resource described by this HOB
+
+ ResourceAttribute - The resource attributes of the memory described by this HOB
+
+ PhysicalStart - The 64 bit physical address of memory described by this HOB
+
+ NumberOfBytes - The length of the memoty described by this HOB in bytes
+
+Returns:
+
+ EFI_SUCCESS - Hob is successfully built.
+ Others - Errors occur while creating new Hob
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_HOB_RESOURCE_DESCRIPTOR *Hob;
+
+ Status = (*PeiServices)->CreateHob (
+ PeiServices,
+ EFI_HOB_TYPE_RESOURCE_DESCRIPTOR,
+ sizeof (EFI_HOB_RESOURCE_DESCRIPTOR),
+ &Hob
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Hob->ResourceType = ResourceType;
+ Hob->ResourceAttribute = ResourceAttribute;
+ Hob->PhysicalStart = PhysicalStart;
+ Hob->ResourceLength = NumberOfBytes;
+
+ return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+PeiBuildHobGuid (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_GUID *Guid,
+ IN UINTN DataLength,
+ OUT VOID **Hob
+ )
+/*++
+
+Routine Description:
+
+ Builds a custom HOB that is tagged with a GUID for identification
+
+Arguments:
+
+ PeiServices - The PEI core services table.
+ Guid - The GUID of the custome HOB type
+ DataLength - The size of the data payload for the GUIDed HOB
+ Hob - Pointer to pointer to the created Hob
+
+Returns:
+
+ EFI_SUCCESS - Hob is successfully built.
+ Others - Errors occur while creating new Hob
+
+--*/
+{
+ EFI_STATUS Status;
+
+ Status = (*PeiServices)->CreateHob (
+ PeiServices,
+ EFI_HOB_TYPE_GUID_EXTENSION,
+ (UINT16) (sizeof (EFI_HOB_GUID_TYPE) + DataLength),
+ Hob
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ ((EFI_HOB_GUID_TYPE *)(*Hob))->Name = *Guid;
+
+ return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+PeiBuildHobGuidData (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_GUID *Guid,
+ IN VOID *Data,
+ IN UINTN DataLength
+ )
+/*++
+
+Routine Description:
+
+ Builds a custom HOB that is tagged with a GUID for identification
+
+Arguments:
+
+ PeiServices - The PEI core services table.
+
+ Guid - The GUID of the custome HOB type
+
+ Data - The data to be copied into the GUIDed HOB data field.
+
+ DataLength - The data field length.
+
+Returns:
+
+ EFI_SUCCESS - Hob is successfully built.
+ Others - Errors occur while creating new Hob
+
+--*/
+{
+ EFI_STATUS Status;
+
+ EFI_HOB_GUID_TYPE *Hob;
+
+ Status = PeiBuildHobGuid (
+ PeiServices,
+ Guid,
+ DataLength,
+ &Hob
+ );
+
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Hob++;
+ (*PeiServices)->CopyMem (Hob, Data, DataLength);
+
+ return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+PeiBuildHobFv (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length
+ )
+/*++
+
+Routine Description:
+
+ Builds a Firmware Volume HOB
+
+Arguments:
+
+ PeiServices - The PEI core services table.
+
+ BaseAddress - The base address of the Firmware Volume
+
+ Length - The size of the Firmware Volume in bytes
+
+Returns:
+
+ EFI_SUCCESS - Hob is successfully built.
+ Others - Errors occur while creating new Hob
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_HOB_FIRMWARE_VOLUME *Hob;
+
+ Status = (*PeiServices)->CreateHob (
+ PeiServices,
+ EFI_HOB_TYPE_FV,
+ sizeof (EFI_HOB_FIRMWARE_VOLUME),
+ &Hob
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Hob->BaseAddress = BaseAddress;
+ Hob->Length = Length;
+
+ return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+PeiBuildHobCpu (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN UINT8 SizeOfMemorySpace,
+ IN UINT8 SizeOfIoSpace
+ )
+/*++
+
+Routine Description:
+
+ Builds a HOB for the CPU
+
+Arguments:
+
+ PeiServices - The PEI core services table.
+
+ SizeOfMemorySpace - Identifies the maximum
+ physical memory addressibility of the processor.
+
+ SizeOfIoSpace - Identifies the maximum physical I/O addressibility
+ of the processor.
+
+Returns:
+
+ EFI_SUCCESS - Hob is successfully built.
+ Others - Errors occur while creating new Hob
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_HOB_CPU *Hob;
+
+ Status = (*PeiServices)->CreateHob (
+ PeiServices,
+ EFI_HOB_TYPE_CPU,
+ sizeof (EFI_HOB_CPU),
+ &Hob
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Hob->SizeOfMemorySpace = SizeOfMemorySpace;
+ Hob->SizeOfIoSpace = SizeOfIoSpace;
+ (*PeiServices)->SetMem (
+ Hob->Reserved,
+ sizeof (Hob->Reserved),
+ 0
+ );
+
+ return EFI_SUCCESS;
+}
+
+
+
+EFI_STATUS
+PeiBuildHobStack (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length
+ )
+/*++
+
+Routine Description:
+
+ Builds a HOB for the Stack
+
+Arguments:
+
+ PeiServices - The PEI core services table.
+
+ BaseAddress - The 64 bit physical address of the Stack
+
+ Length - The length of the stack in bytes
+
+Returns:
+
+ EFI_SUCCESS - Hob is successfully built.
+ Others - Errors occur while creating new Hob
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_HOB_MEMORY_ALLOCATION_STACK *Hob;
+
+ Status = (*PeiServices)->CreateHob (
+ PeiServices,
+ EFI_HOB_TYPE_MEMORY_ALLOCATION,
+ sizeof (EFI_HOB_MEMORY_ALLOCATION_STACK),
+ &Hob
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Hob->AllocDescriptor.Name = gEfiHobMemeryAllocStackGuid;
+ Hob->AllocDescriptor.MemoryBaseAddress = BaseAddress;
+ Hob->AllocDescriptor.MemoryLength = Length;
+ Hob->AllocDescriptor.MemoryType = EfiBootServicesData;
+
+ (*PeiServices)->SetMem (
+ Hob->AllocDescriptor.Reserved,
+ sizeof (Hob->AllocDescriptor.Reserved),
+ 0
+ );
+
+ return EFI_SUCCESS;
+}
+
+
+
+EFI_STATUS
+PeiBuildHobBspStore (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length,
+ IN EFI_MEMORY_TYPE MemoryType
+ )
+/*++
+
+Routine Description:
+
+ Builds a HOB for the bsp store
+
+Arguments:
+
+ PeiServices - The PEI core services table.
+
+ BaseAddress - The 64 bit physical address of the bsp
+
+ Length - The length of the bsp store in bytes
+
+ MemoryType - Memory type
+
+Returns:
+
+ EFI_SUCCESS - Hob is successfully built.
+ Others - Errors occur while creating new Hob
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_HOB_MEMORY_ALLOCATION_BSP_STORE *Hob;
+
+ Status = (*PeiServices)->CreateHob (
+ PeiServices,
+ EFI_HOB_TYPE_MEMORY_ALLOCATION,
+ sizeof (EFI_HOB_MEMORY_ALLOCATION_BSP_STORE),
+ &Hob
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Hob->AllocDescriptor.Name = gEfiHobMemeryAllocBspStoreGuid;
+ Hob->AllocDescriptor.MemoryBaseAddress = BaseAddress;
+ Hob->AllocDescriptor.MemoryLength = Length;
+ Hob->AllocDescriptor.MemoryType = MemoryType;
+ (*PeiServices)->SetMem (
+ Hob->AllocDescriptor.Reserved,
+ sizeof (Hob->AllocDescriptor.Reserved),
+ 0
+ );
+
+ return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+PeiBuildHobMemoryAllocation (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length,
+ IN EFI_GUID *Name,
+ IN EFI_MEMORY_TYPE MemoryType
+ )
+/*++
+
+Routine Description:
+
+ Builds a HOB for the memory allocation.
+
+Arguments:
+
+ PeiServices - The PEI core services table.
+
+ BaseAddress - The 64 bit physical address of the memory
+
+ Length - The length of the memory allocation in bytes
+
+ Name - Name for Hob
+
+ MemoryType - Memory type
+
+Returns:
+
+ EFI_SUCCESS - Hob is successfully built.
+ Others - Errors occur while creating new Hob
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_HOB_MEMORY_ALLOCATION *Hob;
+
+ Status = (*PeiServices)->CreateHob (
+ PeiServices,
+ EFI_HOB_TYPE_MEMORY_ALLOCATION,
+ sizeof (EFI_HOB_MEMORY_ALLOCATION),
+ &Hob
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ if (Name != NULL) {
+ Hob->AllocDescriptor.Name = *Name;
+ } else {
+ (*PeiServices)->SetMem(&(Hob->AllocDescriptor.Name), sizeof (EFI_GUID), 0);
+ }
+
+ Hob->AllocDescriptor.MemoryBaseAddress = BaseAddress;
+ Hob->AllocDescriptor.MemoryLength = Length;
+ Hob->AllocDescriptor.MemoryType = MemoryType;
+ (*PeiServices)->SetMem (
+ Hob->AllocDescriptor.Reserved,
+ sizeof (Hob->AllocDescriptor.Reserved),
+ 0
+ );
+
+ return EFI_SUCCESS;
+}
diff --git a/EDK/Foundation/Library/Pei/PeiLib/Ipf/PeCoffLoaderEx.c b/EDK/Foundation/Library/Pei/PeiLib/Ipf/PeCoffLoaderEx.c
new file mode 100644
index 0000000..60018ed
--- /dev/null
+++ b/EDK/Foundation/Library/Pei/PeiLib/Ipf/PeCoffLoaderEx.c
@@ -0,0 +1,268 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PeCoffLoaderEx.c
+
+Abstract:
+
+ Fixes Intel Itanium(TM) specific relocation types
+
+
+Revision History
+
+--*/
+
+#include "TianoCommon.h"
+#include "EfiImage.h"
+
+#define EXT_IMM64(Value, Address, Size, InstPos, ValPos) \
+ Value |= (((UINT64)((*(Address) >> InstPos) & (((UINT64)1 << Size) - 1))) << ValPos)
+
+#define INS_IMM64(Value, Address, Size, InstPos, ValPos) \
+ *(UINT32*)Address = (*(UINT32*)Address & ~(((1 << Size) - 1) << InstPos)) | \
+ ((UINT32)((((UINT64)Value >> ValPos) & (((UINT64)1 << Size) - 1))) << InstPos)
+
+#define IMM64_IMM7B_INST_WORD_X 3
+#define IMM64_IMM7B_SIZE_X 7
+#define IMM64_IMM7B_INST_WORD_POS_X 4
+#define IMM64_IMM7B_VAL_POS_X 0
+
+#define IMM64_IMM9D_INST_WORD_X 3
+#define IMM64_IMM9D_SIZE_X 9
+#define IMM64_IMM9D_INST_WORD_POS_X 18
+#define IMM64_IMM9D_VAL_POS_X 7
+
+#define IMM64_IMM5C_INST_WORD_X 3
+#define IMM64_IMM5C_SIZE_X 5
+#define IMM64_IMM5C_INST_WORD_POS_X 13
+#define IMM64_IMM5C_VAL_POS_X 16
+
+#define IMM64_IC_INST_WORD_X 3
+#define IMM64_IC_SIZE_X 1
+#define IMM64_IC_INST_WORD_POS_X 12
+#define IMM64_IC_VAL_POS_X 21
+
+#define IMM64_IMM41a_INST_WORD_X 1
+#define IMM64_IMM41a_SIZE_X 10
+#define IMM64_IMM41a_INST_WORD_POS_X 14
+#define IMM64_IMM41a_VAL_POS_X 22
+
+#define IMM64_IMM41b_INST_WORD_X 1
+#define IMM64_IMM41b_SIZE_X 8
+#define IMM64_IMM41b_INST_WORD_POS_X 24
+#define IMM64_IMM41b_VAL_POS_X 32
+
+#define IMM64_IMM41c_INST_WORD_X 2
+#define IMM64_IMM41c_SIZE_X 23
+#define IMM64_IMM41c_INST_WORD_POS_X 0
+#define IMM64_IMM41c_VAL_POS_X 40
+
+#define IMM64_SIGN_INST_WORD_X 3
+#define IMM64_SIGN_SIZE_X 1
+#define IMM64_SIGN_INST_WORD_POS_X 27
+#define IMM64_SIGN_VAL_POS_X 63
+
+EFI_STATUS
+PeCoffLoaderRelocateImageEx (
+ IN UINT16 *Reloc,
+ IN OUT CHAR8 *Fixup,
+ IN OUT CHAR8 **FixupData,
+ IN UINT64 Adjust
+ )
+/*++
+
+Routine Description:
+
+ Performs an Itanium-based specific relocation fixup
+
+Arguments:
+
+ Reloc - Pointer to the relocation record
+
+ Fixup - Pointer to the address to fix up
+
+ FixupData - Pointer to a buffer to log the fixups
+
+ Adjust - The offset to adjust the fixup
+
+Returns:
+
+ Status code
+
+--*/
+{
+ UINT64 *F64;
+ UINT64 FixupVal;
+
+ switch ((*Reloc) >> 12) {
+
+ case EFI_IMAGE_REL_BASED_IA64_IMM64:
+
+ //
+ // Align it to bundle address before fixing up the
+ // 64-bit immediate value of the movl instruction.
+ //
+
+ Fixup = (CHAR8 *)((UINTN) Fixup & (UINTN) ~(15));
+ FixupVal = (UINT64)0;
+
+ //
+ // Extract the lower 32 bits of IMM64 from bundle
+ //
+ EXT_IMM64(FixupVal,
+ (UINT32 *)Fixup + IMM64_IMM7B_INST_WORD_X,
+ IMM64_IMM7B_SIZE_X,
+ IMM64_IMM7B_INST_WORD_POS_X,
+ IMM64_IMM7B_VAL_POS_X
+ );
+
+ EXT_IMM64(FixupVal,
+ (UINT32 *)Fixup + IMM64_IMM9D_INST_WORD_X,
+ IMM64_IMM9D_SIZE_X,
+ IMM64_IMM9D_INST_WORD_POS_X,
+ IMM64_IMM9D_VAL_POS_X
+ );
+
+ EXT_IMM64(FixupVal,
+ (UINT32 *)Fixup + IMM64_IMM5C_INST_WORD_X,
+ IMM64_IMM5C_SIZE_X,
+ IMM64_IMM5C_INST_WORD_POS_X,
+ IMM64_IMM5C_VAL_POS_X
+ );
+
+ EXT_IMM64(FixupVal,
+ (UINT32 *)Fixup + IMM64_IC_INST_WORD_X,
+ IMM64_IC_SIZE_X,
+ IMM64_IC_INST_WORD_POS_X,
+ IMM64_IC_VAL_POS_X
+ );
+
+ EXT_IMM64(FixupVal,
+ (UINT32 *)Fixup + IMM64_IMM41a_INST_WORD_X,
+ IMM64_IMM41a_SIZE_X,
+ IMM64_IMM41a_INST_WORD_POS_X,
+ IMM64_IMM41a_VAL_POS_X
+ );
+
+ //
+ // Update 64-bit address
+ //
+ FixupVal += Adjust;
+
+ //
+ // Insert IMM64 into bundle
+ //
+ INS_IMM64(FixupVal,
+ ((UINT32 *)Fixup + IMM64_IMM7B_INST_WORD_X),
+ IMM64_IMM7B_SIZE_X,
+ IMM64_IMM7B_INST_WORD_POS_X,
+ IMM64_IMM7B_VAL_POS_X
+ );
+
+ INS_IMM64(FixupVal,
+ ((UINT32 *)Fixup + IMM64_IMM9D_INST_WORD_X),
+ IMM64_IMM9D_SIZE_X,
+ IMM64_IMM9D_INST_WORD_POS_X,
+ IMM64_IMM9D_VAL_POS_X
+ );
+
+ INS_IMM64(FixupVal,
+ ((UINT32 *)Fixup + IMM64_IMM5C_INST_WORD_X),
+ IMM64_IMM5C_SIZE_X,
+ IMM64_IMM5C_INST_WORD_POS_X,
+ IMM64_IMM5C_VAL_POS_X
+ );
+
+ INS_IMM64(FixupVal,
+ ((UINT32 *)Fixup + IMM64_IC_INST_WORD_X),
+ IMM64_IC_SIZE_X,
+ IMM64_IC_INST_WORD_POS_X,
+ IMM64_IC_VAL_POS_X
+ );
+
+ INS_IMM64(FixupVal,
+ ((UINT32 *)Fixup + IMM64_IMM41a_INST_WORD_X),
+ IMM64_IMM41a_SIZE_X,
+ IMM64_IMM41a_INST_WORD_POS_X,
+ IMM64_IMM41a_VAL_POS_X
+ );
+
+ INS_IMM64(FixupVal,
+ ((UINT32 *)Fixup + IMM64_IMM41b_INST_WORD_X),
+ IMM64_IMM41b_SIZE_X,
+ IMM64_IMM41b_INST_WORD_POS_X,
+ IMM64_IMM41b_VAL_POS_X
+ );
+
+ INS_IMM64(FixupVal,
+ ((UINT32 *)Fixup + IMM64_IMM41c_INST_WORD_X),
+ IMM64_IMM41c_SIZE_X,
+ IMM64_IMM41c_INST_WORD_POS_X,
+ IMM64_IMM41c_VAL_POS_X
+ );
+
+ INS_IMM64(FixupVal,
+ ((UINT32 *)Fixup + IMM64_SIGN_INST_WORD_X),
+ IMM64_SIGN_SIZE_X,
+ IMM64_SIGN_INST_WORD_POS_X,
+ IMM64_SIGN_VAL_POS_X
+ );
+
+ F64 = (UINT64 *) Fixup;
+ if (*FixupData != NULL) {
+ *FixupData = ALIGN_POINTER(*FixupData, sizeof(UINT64));
+ *(UINT64 *)(*FixupData) = *F64;
+ *FixupData = *FixupData + sizeof(UINT64);
+ }
+ break;
+
+ default:
+ return EFI_UNSUPPORTED;
+ }
+
+ return EFI_SUCCESS;
+}
+
+BOOLEAN
+PeCoffLoaderImageFormatSupported (
+ IN UINT16 Machine
+ )
+/*++
+Routine Description:
+
+ Returns TRUE if the machine type of PE/COFF image is supported. Supported
+ does not mean the image can be executed it means the PE/COFF loader supports
+ loading and relocating of the image type. It's up to the caller to support
+ the entry point.
+
+ This function implies the basic PE/COFF loader/relocator supports IPF, EBC,
+ images. Calling the entry point in a correct mannor is up to the
+ consumer of this library.
+
+Arguments:
+
+ Machine - Machine type from the PE Header.
+
+Returns:
+
+ TRUE - if this PE/COFF loader can load the image
+ FALSE - if this PE/COFF loader cannot load the image
+
+--*/
+{
+ if ((Machine == EFI_IMAGE_MACHINE_IA64) || (Machine == EFI_IMAGE_MACHINE_EBC)) {
+ return TRUE;
+ }
+
+ return FALSE;
+}
diff --git a/EDK/Foundation/Library/Pei/PeiLib/Ipf/PeCoffLoaderEx.h b/EDK/Foundation/Library/Pei/PeiLib/Ipf/PeCoffLoaderEx.h
new file mode 100644
index 0000000..fc14551
--- /dev/null
+++ b/EDK/Foundation/Library/Pei/PeiLib/Ipf/PeCoffLoaderEx.h
@@ -0,0 +1,87 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PeCoffLoaderEx.h
+
+Abstract:
+
+ Fixes Intel Itanium(TM) specific relocation types
+
+
+Revision History
+
+--*/
+
+#ifndef _PE_COFF_LOADER_EX_H_
+#define _PE_COFF_LOADER_EX_H_
+
+
+EFI_STATUS
+PeCoffLoaderRelocateImageEx (
+ IN UINT16 *Reloc,
+ IN OUT CHAR8 *Fixup,
+ IN OUT CHAR8 **FixupData,
+ IN UINT64 Adjust
+ )
+/*++
+
+Routine Description:
+
+ Performs an Itanium-based specific relocation fixup
+
+Arguments:
+
+ Reloc - Pointer to the relocation record
+
+ Fixup - Pointer to the address to fix up
+
+ FixupData - Pointer to a buffer to log the fixups
+
+ Adjust - The offset to adjust the fixup
+
+Returns:
+
+ Status code
+
+--*/
+;
+
+BOOLEAN
+PeCoffLoaderImageFormatSupported (
+ IN UINT16 Machine
+ )
+/*++
+Routine Description:
+
+ Returns TRUE if the machine type of PE/COFF image is supported. Supported
+ does not mean the image can be executed it means the PE/COFF loader supports
+ loading and relocating of the image type. It's up to the caller to support
+ the entry point.
+
+ This function implies the basic PE/COFF loader/relocator supports IPF, EBC,
+ images. Calling the entry point in a correct mannor is up to the
+ consumer of this library.
+
+Arguments:
+
+ Machine - Machine type from the PE Header.
+
+Returns:
+
+ TRUE - if this PE/COFF loader can load the image
+ FALSE - if this PE/COFF loader cannot load the image
+
+--*/
+;
+
+#endif
diff --git a/EDK/Foundation/Library/Pei/PeiLib/Ipf/PeiServicePointer.c b/EDK/Foundation/Library/Pei/PeiLib/Ipf/PeiServicePointer.c
new file mode 100644
index 0000000..f4f1ae0
--- /dev/null
+++ b/EDK/Foundation/Library/Pei/PeiLib/Ipf/PeiServicePointer.c
@@ -0,0 +1,109 @@
+/*++
+
+Copyright 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ PeiServicePointer.c
+
+Abstract:
+
+--*/
+
+#include "Tiano.h"
+#include "PeiApi.h"
+#include "PeiLib.h"
+
+//;;## ...AMI_ADD FILE... Support PI1.x
+
+#if (PI_SPECIFICATION_VERSION >= 0x00010000)
+
+VOID
+SetPeiServicesTablePointer (
+ IN EFI_PEI_SERVICES **PeiServices
+ )
+/*++
+
+Routine Description:
+
+ Save PeiService pointer so that it can be retrieved anywhere.
+
+Arguments:
+
+ PeiServices - The direct pointer to PeiServiceTable.
+ PhyscialAddress - The physcial address of variable PeiServices.
+
+Returns:
+ NONE
+
+--*/
+
+{
+ //
+ // For Itanium Processor Family processors, the EFI_PEI_SERVICES**
+ // is stored in kernel register7.
+ //
+ AsmWriteKr7((UINT64)(UINTN)PeiServices);
+}
+
+
+EFI_PEI_SERVICES **
+GetPeiServicesTablePointer (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Get PeiService pointer.
+
+Arguments:
+
+ NONE.
+
+Returns:
+ The direct pointer to PeiServiceTable.
+
+--*/
+
+{
+ //
+ // For Itanium Processor Family processors, the EFI_PEI_SERVICES**
+ // is stored in kernel register7.
+ //
+ return (EFI_PEI_SERVICES **)(UINTN)AsmReadKr7();
+}
+
+VOID
+MigrateIdtTable (
+ IN EFI_PEI_SERVICES **PeiServices
+ )
+/*++
+
+Routine Description:
+
+ Migrate IDT from CAR to real memory where preceded with 4 bytes for
+ storing PeiService pointer.
+
+Arguments:
+
+ PeiServices - The direct pointer to PeiServiceTable.
+
+Returns:
+
+ NONE.
+
+--*/
+{
+ return;
+}
+
+#endif
diff --git a/EDK/Foundation/Library/Pei/PeiLib/Ipf/PerformancePrimitives.s b/EDK/Foundation/Library/Pei/PeiLib/Ipf/PerformancePrimitives.s
new file mode 100644
index 0000000..5aeb886
--- /dev/null
+++ b/EDK/Foundation/Library/Pei/PeiLib/Ipf/PerformancePrimitives.s
@@ -0,0 +1,61 @@
+//++
+// Copyright (c) 2004, Intel Corporation
+// All rights reserved. This program and the accompanying materials
+// are licensed and made available under the terms and conditions of the BSD License
+// which accompanies this distribution. The full text of the license may be found at
+// http://opensource.org/licenses/bsd-license.php
+//
+// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+//
+// Module Name:
+//
+// PerformancePrimitives.s
+//
+// Abstract:
+//
+//
+// Revision History:
+//
+//--
+
+.file "PerformancePrimitives.s"
+
+#include "IpfMacro.i"
+
+//-----------------------------------------------------------------------------
+//++
+// GetTimerValue
+//
+// Implementation of CPU-based time service
+//
+// On Entry :
+// EFI_STATUS
+// GetTimerValue (
+// OUT UINT64 *TimerValue
+// )
+//
+// Return Value:
+// r8 = Status
+// r9 = 0
+// r10 = 0
+// r11 = 0
+//
+// As per static calling conventions.
+//
+//--
+//---------------------------------------------------------------------------
+PROCEDURE_ENTRY (GetTimerValue)
+
+ NESTED_SETUP (1,8,0,0)
+ mov r8 = ar.itc;;
+ st8 [r32]= r8
+ mov r8 = r0
+ mov r9 = r0
+ mov r10 = r0
+ mov r11 = r0
+ NESTED_RETURN
+
+PROCEDURE_EXIT (GetTimerValue)
+//---------------------------------------------------------------------------
+
diff --git a/EDK/Foundation/Library/Pei/PeiLib/Ipf/SwitchStack.s b/EDK/Foundation/Library/Pei/PeiLib/Ipf/SwitchStack.s
new file mode 100644
index 0000000..5de7e18
--- /dev/null
+++ b/EDK/Foundation/Library/Pei/PeiLib/Ipf/SwitchStack.s
@@ -0,0 +1,122 @@
+//++
+// Copyright (c) 2004, Intel Corporation
+// All rights reserved. This program and the accompanying materials
+// are licensed and made available under the terms and conditions of the BSD License
+// which accompanies this distribution. The full text of the license may be found at
+// http://opensource.org/licenses/bsd-license.php
+//
+// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+//
+// Module Name:
+//
+// SwitchStack.s
+//
+// Abstract:
+//
+// Contains an implementation of a stack switch for the Itanium-based architecture.
+//
+//
+//
+// Revision History:
+//
+//--
+
+ .file "SwitchStack.s"
+
+#include <asm.h>
+#include <ia_64gen.h>
+
+// Define hardware RSE Configuration Register
+//
+// RS Configuration (RSC) bit field positions
+
+#define RSC_MODE 0
+#define RSC_PL 2
+#define RSC_BE 4
+// RSC bits 5-15 reserved
+#define RSC_MBZ0 5
+#define RSC_MBZ0_V 0x3ff
+#define RSC_LOADRS 16
+#define RSC_LOADRS_LEN 14
+// RSC bits 30-63 reserved
+#define RSC_MBZ1 30
+#define RSC_MBZ1_V 0x3ffffffffULL
+
+// RSC modes
+// Lazy
+#define RSC_MODE_LY (0x0)
+// Store intensive
+#define RSC_MODE_SI (0x1)
+// Load intensive
+#define RSC_MODE_LI (0x2)
+// Eager
+#define RSC_MODE_EA (0x3)
+
+// RSC Endian bit values
+#define RSC_BE_LITTLE 0
+#define RSC_BE_BIG 1
+
+// RSC while in kernel: enabled, little endian, pl = 0, eager mode
+#define RSC_KERNEL ((RSC_MODE_EA<<RSC_MODE) | (RSC_BE_LITTLE<<RSC_BE))
+// Lazy RSC in kernel: enabled, little endian, pl = 0, lazy mode
+#define RSC_KERNEL_LAZ ((RSC_MODE_LY<<RSC_MODE) | (RSC_BE_LITTLE<<RSC_BE))
+// RSE disabled: disabled, pl = 0, little endian, eager mode
+#define RSC_KERNEL_DISABLED ((RSC_MODE_LY<<RSC_MODE) | (RSC_BE_LITTLE<<RSC_BE))
+
+
+//VOID
+//SwitchStacks (
+// VOID *ContinuationFunction,
+// UINTN Parameter,
+// UINTN NewTopOfStack,
+// UINTN NewBSPStore OPTIONAL
+//)
+///*++
+//
+//Input Arguments
+//
+// ContinuationFunction - This is a pointer to the PLABEL of the function that should be called once the
+// new stack has been created.
+// Parameter - The parameter to pass to the continuation function
+// NewTopOfStack - This is the new top of the memory stack for ensuing code. This is mandatory and
+// should be non-zero
+// NewBSPStore - This is the new BSP store for the ensuing code. It is optional on IA-32 and mandatory on Itanium-based platform.
+//
+//--*/
+
+PROCEDURE_ENTRY(SwitchStacks)
+
+ mov r16 = -0x10;;
+ and r16 = r34, r16;; // get new stack value in R16, 0 the last nibble.
+ mov r15 = r35;; // Get new BspStore into R15
+ mov r13 = r32;; // this is a pointer to the PLABEL of the continuation function.
+ mov r17 = r33;; // this is the parameter to pass to the continuation function
+
+ alloc r11=0,0,0,0 // Set 0-size frame
+ ;;
+ flushrs;;
+
+ mov r21 = RSC_KERNEL_DISABLED // for rse disable
+ ;;
+ mov ar.rsc = r21 // turn off RSE
+
+ add sp = r0, r16;; // transfer to the EFI stack
+ mov ar.bspstore = r15 // switch to EFI BSP
+ invala // change of ar.bspstore needs invala.
+
+ mov r18 = RSC_KERNEL_LAZ // RSC enabled, Lazy mode
+ ;;
+ mov ar.rsc = r18 // turn rse on, in kernel mode
+ ;;
+ alloc r11=0,0,1,0;; // alloc 0 outs going to ensuing DXE IPL service
+ mov out0 = r17
+ ld8 r16 = [r13],8;; // r16 = address of continuation function from the PLABEL
+ ld8 gp = [r13] // gp = gp of continuation function from the PLABEL
+ mov b6 = r16
+ ;;
+ br.call.sptk.few b0=b6;; // Call the continuation function
+ ;;
+PROCEDURE_EXIT(SwitchStacks)
+
+
diff --git a/EDK/Foundation/Library/Pei/PeiLib/Ipf/asm.h b/EDK/Foundation/Library/Pei/PeiLib/Ipf/asm.h
new file mode 100644
index 0000000..2db93d6
--- /dev/null
+++ b/EDK/Foundation/Library/Pei/PeiLib/Ipf/asm.h
@@ -0,0 +1,35 @@
+//
+//
+// Copyright (c) 2004, Intel Corporation
+// All rights reserved. This program and the accompanying materials
+// are licensed and made available under the terms and conditions of the BSD License
+// which accompanies this distribution. The full text of the license may be found at
+// http://opensource.org/licenses/bsd-license.php
+//
+// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+//
+// Module Name:
+//
+// asm.h
+//
+// Abstract:
+//
+// This module contains generic macros for an assembly writer.
+//
+//
+// Revision History
+//
+#ifndef _ASM_H
+#define _ASM_H
+
+#define TRUE 1
+#define FALSE 0
+#define PROCEDURE_ENTRY(name) .##text; \
+ .##type name, @function; \
+ .##proc name; \
+ name::
+
+#define PROCEDURE_EXIT(name) .##endp name
+
+#endif // _ASM_H
diff --git a/EDK/Foundation/Library/Pei/PeiLib/Ipf/efijump.h b/EDK/Foundation/Library/Pei/PeiLib/Ipf/efijump.h
new file mode 100644
index 0000000..4a078ce
--- /dev/null
+++ b/EDK/Foundation/Library/Pei/PeiLib/Ipf/efijump.h
@@ -0,0 +1,112 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiJump.h
+
+Abstract:
+
+ This is the Setjump/Longjump pair for an IA32 processor.
+
+--*/
+
+#ifndef _EFI_JUMP_H_
+#define _EFI_JUMP_H_
+
+#include EFI_GUID_DEFINITION (PeiTransferControl)
+
+//
+// NOTE:Set/LongJump needs to have this buffer start
+// at 16 byte boundary. Either fix the structure
+// which call this buffer or fix inside SetJump/LongJump
+// Choosing 1K buffer storage for now
+//
+typedef struct {
+ CHAR8 Buffer[1024];
+} EFI_JUMP_BUFFER;
+
+EFI_STATUS
+SetJump (
+ IN EFI_PEI_TRANSFER_CONTROL_PROTOCOL *This,
+ IN EFI_JUMP_BUFFER *Jump
+ )
+/*++
+
+Routine Description:
+
+ SetJump stores the current register set in the area pointed to
+by "save". It returns zero. Subsequent calls to "LongJump" will
+restore the registers and return non-zero to the same location.
+ On entry, r32 contains the pointer to the jmp_buffer
+
+Arguments:
+
+ This - Calling context
+ Jump - Jump buffer
+
+Returns:
+
+ Status code
+
+--*/
+;
+
+EFI_STATUS
+LongJump (
+ IN EFI_PEI_TRANSFER_CONTROL_PROTOCOL *This,
+ IN EFI_JUMP_BUFFER *Jump
+ )
+/*++
+
+Routine Description:
+
+ LongJump initializes the register set to the values saved by a
+previous 'SetJump' and jumps to the return location saved by that
+'SetJump'. This has the effect of unwinding the stack and returning
+for a second time to the 'SetJump'.
+
+Arguments:
+
+ This - Calling context
+ Jump - Jump buffer
+
+Returns:
+
+ Status code
+
+--*/
+;
+
+VOID
+RtPioICacheFlush (
+ IN VOID *StartAddress,
+ IN UINTN SizeInBytes
+ )
+/*++
+
+Routine Description:
+
+ Flushing the CPU instruction cache.
+
+Arguments:
+
+ StartAddress - Start address to flush
+ SizeInBytes - Length in bytes to flush
+
+Returns:
+
+ None
+
+--*/
+;
+
+#endif
diff --git a/EDK/Foundation/Library/Pei/PeiLib/Ipf/ia_64gen.h b/EDK/Foundation/Library/Pei/PeiLib/Ipf/ia_64gen.h
new file mode 100644
index 0000000..8e8d1a5
--- /dev/null
+++ b/EDK/Foundation/Library/Pei/PeiLib/Ipf/ia_64gen.h
@@ -0,0 +1,214 @@
+//
+//
+//
+// Copyright (c) 2004, Intel Corporation
+// All rights reserved. This program and the accompanying materials
+// are licensed and made available under the terms and conditions of the BSD License
+// which accompanies this distribution. The full text of the license may be found at
+// http://opensource.org/licenses/bsd-license.php
+//
+// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+//
+//Module Name: ia_64gen.h
+//
+//
+//Abstract:
+//
+//
+//
+//
+//Revision History
+//
+//
+#ifndef _IA64GEN_H
+#define _IA64GEN_H
+
+#define TT_UNAT 0
+#define C_PSR 0
+#define J_UNAT 0
+#define T_TYPE 0
+#define T_IPSR 0x8
+#define T_ISR 0x10
+#define T_IIP 0x18
+#define T_IFA 0x20
+#define T_IIPA 0x28
+#define T_IFS 0x30
+#define T_IIM 0x38
+#define T_RSC 0x40
+#define T_BSP 0x48
+#define T_BSPSTORE 0x50
+#define T_RNAT 0x58
+#define T_PFS 0x60
+#define T_KBSPSTORE 0x68
+#define T_UNAT 0x70
+#define T_CCV 0x78
+#define T_DCR 0x80
+#define T_PREDS 0x88
+#define T_NATS 0x90
+#define T_R1 0x98
+#define T_GP 0x98
+#define T_R2 0xa0
+#define T_R3 0xa8
+#define T_R4 0xb0
+#define T_R5 0xb8
+#define T_R6 0xc0
+#define T_R7 0xc8
+#define T_R8 0xd0
+#define T_R9 0xd8
+#define T_R10 0xe0
+#define T_R11 0xe8
+#define T_R12 0xf0
+#define T_SP 0xf0
+#define T_R13 0xf8
+#define T_R14 0x100
+#define T_R15 0x108
+#define T_R16 0x110
+#define T_R17 0x118
+#define T_R18 0x120
+#define T_R19 0x128
+#define T_R20 0x130
+#define T_R21 0x138
+#define T_R22 0x140
+#define T_R23 0x148
+#define T_R24 0x150
+#define T_R25 0x158
+#define T_R26 0x160
+#define T_R27 0x168
+#define T_R28 0x170
+#define T_R29 0x178
+#define T_R30 0x180
+#define T_R31 0x188
+#define T_F2 0x1f0
+#define T_F3 0x200
+#define T_F4 0x210
+#define T_F5 0x220
+#define T_F6 0x230
+#define T_F7 0x240
+#define T_F8 0x250
+#define T_F9 0x260
+#define T_F10 0x270
+#define T_F11 0x280
+#define T_F12 0x290
+#define T_F13 0x2a0
+#define T_F14 0x2b0
+#define T_F15 0x2c0
+#define T_F16 0x2d0
+#define T_F17 0x2e0
+#define T_F18 0x2f0
+#define T_F19 0x300
+#define T_F20 0x310
+#define T_F21 0x320
+#define T_F22 0x330
+#define T_F23 0x340
+#define T_F24 0x350
+#define T_F25 0x360
+#define T_F26 0x370
+#define T_F27 0x380
+#define T_F28 0x390
+#define T_F29 0x3a0
+#define T_F30 0x3b0
+#define T_F31 0x3c0
+#define T_FPSR 0x1e0
+#define T_B0 0x190
+#define T_B1 0x198
+#define T_B2 0x1a0
+#define T_B3 0x1a8
+#define T_B4 0x1b0
+#define T_B5 0x1b8
+#define T_B6 0x1c0
+#define T_B7 0x1c8
+#define T_EC 0x1d0
+#define T_LC 0x1d8
+#define J_NATS 0x8
+#define J_PFS 0x10
+#define J_BSP 0x18
+#define J_RNAT 0x20
+#define J_PREDS 0x28
+#define J_LC 0x30
+#define J_R4 0x38
+#define J_R5 0x40
+#define J_R6 0x48
+#define J_R7 0x50
+#define J_SP 0x58
+#define J_F2 0x60
+#define J_F3 0x70
+#define J_F4 0x80
+#define J_F5 0x90
+#define J_F16 0xa0
+#define J_F17 0xb0
+#define J_F18 0xc0
+#define J_F19 0xd0
+#define J_F20 0xe0
+#define J_F21 0xf0
+#define J_F22 0x100
+#define J_F23 0x110
+#define J_F24 0x120
+#define J_F25 0x130
+#define J_F26 0x140
+#define J_F27 0x150
+#define J_F28 0x160
+#define J_F29 0x170
+#define J_F30 0x180
+#define J_F31 0x190
+#define J_FPSR 0x1a0
+#define J_B0 0x1a8
+#define J_B1 0x1b0
+#define J_B2 0x1b8
+#define J_B3 0x1c0
+#define J_B4 0x1c8
+#define J_B5 0x1d0
+#define TRAP_FRAME_LENGTH 0x3d0
+#define C_UNAT 0x28
+#define C_NATS 0x30
+#define C_PFS 0x8
+#define C_BSPSTORE 0x10
+#define C_RNAT 0x18
+#define C_RSC 0x20
+#define C_PREDS 0x38
+#define C_LC 0x40
+#define C_DCR 0x48
+#define C_R1 0x50
+#define C_GP 0x50
+#define C_R4 0x58
+#define C_R5 0x60
+#define C_R6 0x68
+#define C_R7 0x70
+#define C_SP 0x78
+#define C_R13 0x80
+#define C_F2 0x90
+#define C_F3 0xa0
+#define C_F4 0xb0
+#define C_F5 0xc0
+#define C_F16 0xd0
+#define C_F17 0xe0
+#define C_F18 0xf0
+#define C_F19 0x100
+#define C_F20 0x110
+#define C_F21 0x120
+#define C_F22 0x130
+#define C_F23 0x140
+#define C_F24 0x150
+#define C_F25 0x160
+#define C_F26 0x170
+#define C_F27 0x180
+#define C_F28 0x190
+#define C_F29 0x1a0
+#define C_F30 0x1b0
+#define C_F31 0x1c0
+#define C_FPSR 0x1d0
+#define C_B0 0x1d8
+#define C_B1 0x1e0
+#define C_B2 0x1e8
+#define C_B3 0x1f0
+#define C_B4 0x1f8
+#define C_B5 0x200
+#define TT_R2 0x8
+#define TT_R3 0x10
+#define TT_R8 0x18
+#define TT_R9 0x20
+#define TT_R10 0x28
+#define TT_R11 0x30
+#define TT_R14 0x38
+
+#endif _IA64GEN_H
diff --git a/EDK/Foundation/Library/Pei/PeiLib/Ipf/math.c b/EDK/Foundation/Library/Pei/PeiLib/Ipf/math.c
new file mode 100644
index 0000000..9ce7613
--- /dev/null
+++ b/EDK/Foundation/Library/Pei/PeiLib/Ipf/math.c
@@ -0,0 +1,139 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ math.c
+
+Abstract:
+
+ 64-bit Math worker functions for Intel Itanium(TM) processors.
+
+--*/
+
+#include "Tiano.h"
+#include "Pei.h"
+#include "PeiLib.h"
+
+UINT64
+LShiftU64 (
+ IN UINT64 Operand,
+ IN UINTN Count
+ )
+/*++
+
+Routine Description:
+
+ This routine allows a 64 bit value to be left shifted by 32 bits and
+ returns the shifted value.
+ Count is valid up 63. (Only Bits 0-5 is valid for Count)
+
+Arguments:
+
+ Operand - Value to be shifted
+ Count - Number of times to shift left.
+
+Returns:
+
+ Value shifted left identified by the Count.
+
+--*/
+{
+ return Operand << Count;
+}
+
+UINT64
+RShiftU64 (
+ IN UINT64 Operand,
+ IN UINTN Count
+ )
+/*++
+
+Routine Description:
+
+ This routine allows a 64 bit value to be right shifted by 32 bits and returns the
+ shifted value.
+ Count is valid up 63. (Only Bits 0-5 is valid for Count)
+
+Arguments:
+
+ Operand - Value to be shifted
+ Count - Number of times to shift right.
+
+Returns:
+
+ Value shifted right identified by the Count.
+
+--*/
+{
+ return Operand >> Count;
+}
+
+UINT64
+MultU64x32 (
+ IN UINT64 Multiplicand,
+ IN UINTN Multiplier
+ )
+/*++
+
+Routine Description:
+
+ This routine allows a 64 bit value to be multiplied with a 32 bit
+ value returns 64bit result.
+ No checking if the result is greater than 64bits
+
+Arguments:
+
+ Multiplicand - multiplicand
+ Multiplier - multiplier
+
+Returns:
+
+ Multiplicand * Multiplier
+
+--*/
+{
+ return Multiplicand * Multiplier;
+}
+
+UINT64
+DivU64x32 (
+ IN UINT64 Dividend,
+ IN UINTN Divisor,
+ OUT UINTN *Remainder OPTIONAL
+ )
+/*++
+
+Routine Description:
+
+ This routine allows a 64 bit value to be divided with a 32 bit value returns
+ 64bit result and the Remainder.
+ N.B. only works for 31bit divisors!!
+
+Arguments:
+
+ Dividend - dividend
+ Divisor - divisor
+ Remainder - buffer for remainder
+
+Returns:
+
+ Dividend / Divisor
+ Remainder = Dividend mod Divisor
+
+--*/
+{
+ if (Remainder) {
+ *Remainder = Dividend % Divisor;
+ }
+
+ return Dividend / Divisor;
+}
diff --git a/EDK/Foundation/Library/Pei/PeiLib/Ipf/pioflush.s b/EDK/Foundation/Library/Pei/PeiLib/Ipf/pioflush.s
new file mode 100644
index 0000000..0f0d760
--- /dev/null
+++ b/EDK/Foundation/Library/Pei/PeiLib/Ipf/pioflush.s
@@ -0,0 +1,106 @@
+//++
+// Copyright (c) 2004, Intel Corporation
+// All rights reserved. This program and the accompanying materials
+// are licensed and made available under the terms and conditions of the BSD License
+// which accompanies this distribution. The full text of the license may be found at
+// http://opensource.org/licenses/bsd-license.php
+//
+// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+//
+// Module Name:
+//
+// pioflush.s
+//
+// Abstract:
+//
+//
+// Revision History:
+//
+//--
+
+ .file "pioflush.c"
+ .radix D
+ .section .text, "ax", "progbits"
+ .align 32
+ .section .pdata, "a", "progbits"
+ .align 4
+ .section .xdata, "a", "progbits"
+ .align 8
+ .section .data, "wa", "progbits"
+ .align 16
+ .section .rdata, "a", "progbits"
+ .align 16
+ .section .bss, "wa", "nobits"
+ .align 16
+ .section .tls$, "was", "progbits"
+ .align 16
+ .section .sdata, "was", "progbits"
+ .align 16
+ .section .sbss, "was", "nobits"
+ .align 16
+ .section .srdata, "as", "progbits"
+ .align 16
+ .section .rdata, "a", "progbits"
+ .align 16
+ .section .rtcode, "ax", "progbits"
+ .align 32
+ .type RtPioICacheFlush# ,@function
+ .global RtPioICacheFlush#
+// Function compile flags: /Ogsy
+ .section .rtcode
+
+// Begin code for function: RtPioICacheFlush:
+ .proc RtPioICacheFlush#
+ .align 32
+RtPioICacheFlush:
+// File e:\tmp\pioflush.c
+ { .mii //R-Addr: 0X00
+ alloc r3=2, 0, 0, 0 //11, 00000002H
+ cmp4.leu p0,p6=32, r33;; //15, 00000020H
+ (p6) mov r33=32;; //16, 00000020H
+ }
+ { .mii //R-Addr: 0X010
+ nop.m 0
+ zxt4 r29=r33;; //21
+ dep.z r30=r29, 0, 5;; //21, 00000005H
+ }
+ { .mii //R-Addr: 0X020
+ cmp4.eq p0,p7=r0, r30 //21
+ shr.u r28=r29, 5;; //19, 00000005H
+ (p7) adds r28=1, r28;; //22, 00000001H
+ }
+ { .mii //R-Addr: 0X030
+ nop.m 0
+ shl r27=r28, 5;; //25, 00000005H
+ zxt4 r26=r27;; //25
+ }
+ { .mfb //R-Addr: 0X040
+ add r31=r26, r32 //25
+ nop.f 0
+ nop.b 0
+ }
+$L143:
+ { .mii //R-Addr: 0X050
+ fc r32 //27
+ adds r32=32, r32;; //28, 00000020H
+ cmp.ltu p14,p15=r32, r31 //29
+ }
+ { .mfb //R-Addr: 0X060
+ nop.m 0
+ nop.f 0
+ (p14) br.cond.dptk.few $L143#;; //29, 880000/120000
+ }
+ { .mmi
+ sync.i;;
+ srlz.i
+ nop.i 0;;
+ }
+ { .mfb //R-Addr: 0X070
+ nop.m 0
+ nop.f 0
+ br.ret.sptk.few b0;; //31
+ }
+// End code for function:
+ .endp RtPioICacheFlush#
+// END
diff --git a/EDK/Foundation/Library/Pei/PeiLib/Ipf/processor.c b/EDK/Foundation/Library/Pei/PeiLib/Ipf/processor.c
new file mode 100644
index 0000000..9740948
--- /dev/null
+++ b/EDK/Foundation/Library/Pei/PeiLib/Ipf/processor.c
@@ -0,0 +1,118 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Processor.c
+
+Abstract:
+
+--*/
+
+#include "Tiano.h"
+#include "EfiJump.h"
+#include "PeiHob.h"
+#include EFI_GUID_DEFINITION (PeiFlushInstructionCache)
+#include EFI_GUID_DEFINITION (PeiTransferControl)
+
+EFI_STATUS
+WinNtFlushInstructionCacheFlush (
+ IN EFI_PEI_FLUSH_INSTRUCTION_CACHE_PROTOCOL *This,
+ IN EFI_PHYSICAL_ADDRESS Start,
+ IN UINT64 Length
+ );
+
+EFI_PEI_TRANSFER_CONTROL_PROTOCOL mTransferControl = {
+ SetJump,
+ LongJump,
+ sizeof (EFI_JUMP_BUFFER)
+};
+
+EFI_PEI_FLUSH_INSTRUCTION_CACHE_PROTOCOL mFlushInstructionCache = {
+ WinNtFlushInstructionCacheFlush
+};
+
+EFI_STATUS
+InstallEfiPeiTransferControl (
+ IN OUT EFI_PEI_TRANSFER_CONTROL_PROTOCOL **This
+ )
+/*++
+
+Routine Description:
+
+ Installs the pointer to the transfer control mechanism
+
+Arguments:
+
+ This - Pointer to transfer control mechanism.
+
+Returns:
+
+ EFI_SUCCESS - Successfully installed.
+
+--*/
+{
+ *This = &mTransferControl;
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+InstallEfiPeiFlushInstructionCache (
+ IN OUT EFI_PEI_FLUSH_INSTRUCTION_CACHE_PROTOCOL **This
+ )
+/*++
+
+Routine Description:
+
+ Installs the pointer to the flush instruction cache mechanism
+
+Arguments:
+
+ This - Pointer to flush instruction cache mechanism.
+
+Returns:
+
+ EFI_SUCCESS - Successfully installed
+
+--*/
+{
+ *This = &mFlushInstructionCache;
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+WinNtFlushInstructionCacheFlush (
+ IN EFI_PEI_FLUSH_INSTRUCTION_CACHE_PROTOCOL *This,
+ IN EFI_PHYSICAL_ADDRESS Start,
+ IN UINT64 Length
+ )
+/*++
+
+Routine Description:
+
+ This routine would provide support for flushing the CPU instruction cache.
+
+Arguments:
+
+ This - Pointer to CPU Architectural Protocol interface
+ Start - Start adddress in memory to flush
+ Length - Length of memory to flush
+
+Returns:
+
+ Status
+ EFI_SUCCESS
+
+--*/
+{
+ RtPioICacheFlush ((UINT8 *) Start, (UINTN) Length);
+ return EFI_SUCCESS;
+}
diff --git a/EDK/Foundation/Library/Pei/PeiLib/Ipf/setjmp.s b/EDK/Foundation/Library/Pei/PeiLib/Ipf/setjmp.s
new file mode 100644
index 0000000..ee27ca7
--- /dev/null
+++ b/EDK/Foundation/Library/Pei/PeiLib/Ipf/setjmp.s
@@ -0,0 +1,325 @@
+//++
+// Copyright (c) 2004, Intel Corporation
+// All rights reserved. This program and the accompanying materials
+// are licensed and made available under the terms and conditions of the BSD License
+// which accompanies this distribution. The full text of the license may be found at
+// http://opensource.org/licenses/bsd-license.php
+//
+// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+//
+// Module Name:
+//
+// setjmp.s
+//
+// Abstract:
+//
+// Contains an implementation of setjmp and longjmp for the
+// Itanium-based architecture.
+//
+//
+//
+// Revision History:
+//
+//--
+
+ .file "setjmp.s"
+
+#include <asm.h>
+#include <ia_64gen.h>
+
+// int SetJump(struct jmp_buffer save)
+//
+// Setup a non-local goto.
+//
+// Description:
+//
+// SetJump stores the current register set in the area pointed to
+// by "save". It returns zero. Subsequent calls to "LongJump" will
+// restore the registers and return non-zero to the same location.
+//
+// On entry, r32 contains the pointer to the jmp_buffer
+//
+
+PROCEDURE_ENTRY(SetJump)
+ //
+ // Make sure buffer is aligned at 16byte boundary
+ //
+ mov r32 = r33
+
+ add r10 = -0x10,r0 ;; // mask the lower 4 bits
+ and r32 = r32, r10;;
+ add r32 = 0x10, r32;; // move to next 16 byte boundary
+
+ add r10 = J_PREDS, r32 // skip Unats & pfs save area
+ add r11 = J_BSP, r32
+ //
+ // save immediate context
+ //
+ mov r2 = ar.bsp // save backing store pointer
+ mov r3 = pr // save predicates
+ ;;
+ //
+ // save user Unat register
+ //
+ mov r16 = ar.lc // save loop count register
+ mov r14 = ar.unat // save user Unat register
+
+ st8 [r10] = r3, J_LC-J_PREDS
+ st8 [r11] = r2, J_R4-J_BSP
+ ;;
+ st8 [r10] = r16, J_R5-J_LC
+ st8 [r32] = r14, J_NATS // Note: Unat at the
+ // beginning of the save area
+ mov r15 = ar.pfs
+ ;;
+ //
+ // save preserved general registers & NaT's
+ //
+ st8.spill [r11] = r4, J_R6-J_R4
+ ;;
+ st8.spill [r10] = r5, J_R7-J_R5
+ ;;
+ st8.spill [r11] = r6, J_SP-J_R6
+ ;;
+ st8.spill [r10] = r7, J_F3-J_R7
+ ;;
+ st8.spill [r11] = sp, J_F2-J_SP
+ ;;
+ //
+ // save spilled Unat and pfs registers
+ //
+ mov r2 = ar.unat // save Unat register after spill
+ ;;
+ st8 [r32] = r2, J_PFS-J_NATS // save unat for spilled regs
+ ;;
+ st8 [r32] = r15 // save pfs
+ //
+ // save floating registers
+ //
+ stf.spill [r11] = f2, J_F4-J_F2
+ stf.spill [r10] = f3, J_F5-J_F3
+ ;;
+ stf.spill [r11] = f4, J_F16-J_F4
+ stf.spill [r10] = f5, J_F17-J_F5
+ ;;
+ stf.spill [r11] = f16, J_F18-J_F16
+ stf.spill [r10] = f17, J_F19-J_F17
+ ;;
+ stf.spill [r11] = f18, J_F20-J_F18
+ stf.spill [r10] = f19, J_F21-J_F19
+ ;;
+ stf.spill [r11] = f20, J_F22-J_F20
+ stf.spill [r10] = f21, J_F23-J_F21
+ ;;
+ stf.spill [r11] = f22, J_F24-J_F22
+ stf.spill [r10] = f23, J_F25-J_F23
+ ;;
+ stf.spill [r11] = f24, J_F26-J_F24
+ stf.spill [r10] = f25, J_F27-J_F25
+ ;;
+ stf.spill [r11] = f26, J_F28-J_F26
+ stf.spill [r10] = f27, J_F29-J_F27
+ ;;
+ stf.spill [r11] = f28, J_F30-J_F28
+ stf.spill [r10] = f29, J_F31-J_F29
+ ;;
+ stf.spill [r11] = f30, J_FPSR-J_F30
+ stf.spill [r10] = f31, J_B0-J_F31 // size of f31 + fpsr
+ //
+ // save FPSR register & branch registers
+ //
+ mov r2 = ar.fpsr // save fpsr register
+ mov r3 = b0
+ ;;
+ st8 [r11] = r2, J_B1-J_FPSR
+ st8 [r10] = r3, J_B2-J_B0
+ mov r2 = b1
+ mov r3 = b2
+ ;;
+ st8 [r11] = r2, J_B3-J_B1
+ st8 [r10] = r3, J_B4-J_B2
+ mov r2 = b3
+ mov r3 = b4
+ ;;
+ st8 [r11] = r2, J_B5-J_B3
+ st8 [r10] = r3
+ mov r2 = b5
+ ;;
+ st8 [r11] = r2
+ ;;
+ //
+ // return
+ //
+ mov r8 = r0 // return 0 from setjmp
+ mov ar.unat = r14 // restore unat
+ br.ret.sptk b0
+
+PROCEDURE_EXIT(SetJump)
+
+
+//
+// void LongJump(struct jmp_buffer *)
+//
+// Perform a non-local goto.
+//
+// Description:
+//
+// LongJump initializes the register set to the values saved by a
+// previous 'SetJump' and jumps to the return location saved by that
+// 'SetJump'. This has the effect of unwinding the stack and returning
+// for a second time to the 'SetJump'.
+//
+
+PROCEDURE_ENTRY(LongJump)
+ //
+ // Make sure buffer is aligned at 16byte boundary
+ //
+ mov r32 = r33
+
+ add r10 = -0x10,r0 ;; // mask the lower 4 bits
+ and r32 = r32, r10;;
+ add r32 = 0x10, r32;; // move to next 16 byte boundary
+
+ //
+ // caching the return value as we do invala in the end
+ //
+/// mov r8 = r33 // return value
+ mov r8 = 1 // For now return hard coded 1
+
+ //
+ // get immediate context
+ //
+ mov r14 = ar.rsc // get user RSC conf
+ add r10 = J_PFS, r32 // get address of pfs
+ add r11 = J_NATS, r32
+ ;;
+ ld8 r15 = [r10], J_BSP-J_PFS // get pfs
+ ld8 r2 = [r11], J_LC-J_NATS // get unat for spilled regs
+ ;;
+ mov ar.unat = r2
+ ;;
+ ld8 r16 = [r10], J_PREDS-J_BSP // get backing store pointer
+ mov ar.rsc = r0 // put RSE in enforced lazy
+ mov ar.pfs = r15
+ ;;
+
+ //
+ // while returning from longjmp the BSPSTORE and BSP needs to be
+ // same and discard all the registers allocated after we did
+ // setjmp. Also, we need to generate the RNAT register since we
+ // did not flushed the RSE on setjmp.
+ //
+ mov r17 = ar.bspstore // get current BSPSTORE
+ ;;
+ cmp.ltu p6,p7 = r17, r16 // is it less than BSP of
+(p6) br.spnt.few .flush_rse
+ mov r19 = ar.rnat // get current RNAT
+ ;;
+ loadrs // invalidate dirty regs
+ br.sptk.many .restore_rnat // restore RNAT
+
+.flush_rse:
+ flushrs
+ ;;
+ mov r19 = ar.rnat // get current RNAT
+ mov r17 = r16 // current BSPSTORE
+ ;;
+.restore_rnat:
+ //
+ // check if RNAT is saved between saved BSP and curr BSPSTORE
+ //
+ dep r18 = 1,r16,3,6 // get RNAT address
+ ;;
+ cmp.ltu p8,p9 = r18, r17 // RNAT saved on RSE
+ ;;
+(p8) ld8 r19 = [r18] // get RNAT from RSE
+ ;;
+ mov ar.bspstore = r16 // set new BSPSTORE
+ ;;
+ mov ar.rnat = r19 // restore RNAT
+ mov ar.rsc = r14 // restore RSC conf
+
+
+ ld8 r3 = [r11], J_R4-J_LC // get lc register
+ ld8 r2 = [r10], J_R5-J_PREDS // get predicates
+ ;;
+ mov pr = r2, -1
+ mov ar.lc = r3
+ //
+ // restore preserved general registers & NaT's
+ //
+ ld8.fill r4 = [r11], J_R6-J_R4
+ ;;
+ ld8.fill r5 = [r10], J_R7-J_R5
+ ld8.fill r6 = [r11], J_SP-J_R6
+ ;;
+ ld8.fill r7 = [r10], J_F2-J_R7
+ ld8.fill sp = [r11], J_F3-J_SP
+ ;;
+ //
+ // restore floating registers
+ //
+ ldf.fill f2 = [r10], J_F4-J_F2
+ ldf.fill f3 = [r11], J_F5-J_F3
+ ;;
+ ldf.fill f4 = [r10], J_F16-J_F4
+ ldf.fill f5 = [r11], J_F17-J_F5
+ ;;
+ ldf.fill f16 = [r10], J_F18-J_F16
+ ldf.fill f17 = [r11], J_F19-J_F17
+ ;;
+ ldf.fill f18 = [r10], J_F20-J_F18
+ ldf.fill f19 = [r11], J_F21-J_F19
+ ;;
+ ldf.fill f20 = [r10], J_F22-J_F20
+ ldf.fill f21 = [r11], J_F23-J_F21
+ ;;
+ ldf.fill f22 = [r10], J_F24-J_F22
+ ldf.fill f23 = [r11], J_F25-J_F23
+ ;;
+ ldf.fill f24 = [r10], J_F26-J_F24
+ ldf.fill f25 = [r11], J_F27-J_F25
+ ;;
+ ldf.fill f26 = [r10], J_F28-J_F26
+ ldf.fill f27 = [r11], J_F29-J_F27
+ ;;
+ ldf.fill f28 = [r10], J_F30-J_F28
+ ldf.fill f29 = [r11], J_F31-J_F29
+ ;;
+ ldf.fill f30 = [r10], J_FPSR-J_F30
+ ldf.fill f31 = [r11], J_B0-J_F31 ;;
+
+ //
+ // restore branch registers and fpsr
+ //
+ ld8 r16 = [r10], J_B1-J_FPSR // get fpsr
+ ld8 r17 = [r11], J_B2-J_B0 // get return pointer
+ ;;
+ mov ar.fpsr = r16
+ mov b0 = r17
+ ld8 r2 = [r10], J_B3-J_B1
+ ld8 r3 = [r11], J_B4-J_B2
+ ;;
+ mov b1 = r2
+ mov b2 = r3
+ ld8 r2 = [r10], J_B5-J_B3
+ ld8 r3 = [r11]
+ ;;
+ mov b3 = r2
+ mov b4 = r3
+ ld8 r2 = [r10]
+ ld8 r21 = [r32] // get user unat
+ ;;
+ mov b5 = r2
+ mov ar.unat = r21
+
+ //
+ // invalidate ALAT
+ //
+ invala ;;
+
+ br.ret.sptk b0
+PROCEDURE_EXIT(LongJump)
+
+
diff --git a/EDK/Foundation/Library/Pei/PeiLib/PeCoffLoader.c b/EDK/Foundation/Library/Pei/PeiLib/PeCoffLoader.c
new file mode 100644
index 0000000..06ada63
--- /dev/null
+++ b/EDK/Foundation/Library/Pei/PeiLib/PeCoffLoader.c
@@ -0,0 +1,1491 @@
+/*++
+
+Copyright (c) 2005 - 2011, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PeCoffLoader.c
+
+Abstract:
+
+ Tiano PE/COFF loader
+
+Revision History
+
+--*/
+
+#include "Tiano.h"
+#include "Pei.h"
+#include "PeiLib.h"
+#include "PeCoffLoaderEx.h"
+
+#ifdef EFI_NT_EMULATOR
+#include "peilib.h"
+#include "EfiHobLib.h"
+#include EFI_PPI_DEFINITION (NtLoadAsDll)
+#endif
+
+STATIC
+EFI_STATUS
+PeCoffLoaderGetPeHeader (
+ IN OUT EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext,
+ OUT EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr
+ );
+
+STATIC
+VOID*
+PeCoffLoaderImageAddress (
+ IN OUT EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext,
+ IN UINTN Address
+ );
+
+EFI_STATUS
+EFIAPI
+PeCoffLoaderGetImageInfo (
+ IN EFI_PEI_PE_COFF_LOADER_PROTOCOL *This,
+ IN OUT EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
+ );
+
+EFI_STATUS
+EFIAPI
+PeCoffLoaderRelocateImage (
+ IN EFI_PEI_PE_COFF_LOADER_PROTOCOL *This,
+ IN OUT EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
+ );
+
+EFI_STATUS
+EFIAPI
+PeCoffLoaderLoadImage (
+ IN EFI_PEI_PE_COFF_LOADER_PROTOCOL *This,
+ IN OUT EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
+ );
+
+EFI_STATUS
+EFIAPI
+PeCoffLoaderUnloadImage (
+ IN EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
+ );
+
+#if defined (EFI_DEBUG_ITP_BREAK) && !defined (_CONSOLE)
+VOID
+AsmEfiSetBreakSupport (
+ IN UINTN LoadAddr
+ );
+#endif
+
+EFI_PEI_PE_COFF_LOADER_PROTOCOL mPeCoffLoader = {
+ PeCoffLoaderGetImageInfo,
+ PeCoffLoaderLoadImage,
+ PeCoffLoaderRelocateImage,
+ PeCoffLoaderUnloadImage
+};
+
+#ifdef EFI_NT_EMULATOR
+EFI_NT_LOAD_AS_DLL_PPI *mPeCoffLoaderWinNtLoadAsDll = NULL;
+#endif
+
+EFI_STATUS
+InstallEfiPeiPeCoffLoader (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN OUT EFI_PEI_PE_COFF_LOADER_PROTOCOL **This,
+ IN EFI_PEI_PPI_DESCRIPTOR *ThisPpi
+ )
+/*++
+
+Routine Description:
+
+ Install PE/COFF loader PPI
+
+Arguments:
+
+ PeiServices - General purpose services available to every PEIM
+
+ This - Pointer to get Pei PE coff loader protocol as output
+
+ ThisPpi - Passed in as EFI_NT_LOAD_AS_DLL_PPI on NT_EMULATOR platform
+
+Returns:
+
+ EFI_SUCCESS
+
+--*/
+{
+ EFI_STATUS Status;
+
+ Status = EFI_SUCCESS;
+
+#ifdef EFI_NT_EMULATOR
+ //
+ // For use by PEI Core and Modules
+ //
+ if (NULL != PeiServices) {
+ Status = (**PeiServices).LocatePpi (
+ PeiServices,
+ &gEfiNtLoadAsDllPpiGuid,
+ 0,
+ NULL,
+ &mPeCoffLoaderWinNtLoadAsDll
+ );
+ } else {
+ //
+ // Now in SecMain or ERM usage, bind appropriately
+ //
+ PEI_ASSERT (PeiServices, (NULL != ThisPpi));
+
+ mPeCoffLoaderWinNtLoadAsDll = (EFI_NT_LOAD_AS_DLL_PPI *) ThisPpi;
+ PEI_ASSERT (PeiServices, (NULL != mPeCoffLoaderWinNtLoadAsDll));
+ }
+#endif
+
+ if (NULL != This) {
+ *This = &mPeCoffLoader;
+ }
+
+ return Status;
+}
+
+STATIC
+EFI_STATUS
+PeCoffLoaderGetPeHeader (
+ IN OUT EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext,
+ OUT EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr
+ )
+/*++
+
+Routine Description:
+
+ Retrieves the PE or TE Header from a PE/COFF or TE image
+
+Arguments:
+
+ ImageContext - The context of the image being loaded
+
+ PeHdr - The buffer in which to return the PE32, PE32+, or TE header
+
+Returns:
+
+ EFI_SUCCESS if the PE or TE Header is read,
+ Otherwise, the error status from reading the PE/COFF or TE image using the ImageRead function.
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_IMAGE_DOS_HEADER DosHdr;
+ UINTN Size;
+ UINT16 Magic;
+
+ //
+ // Read the DOS image header to check for it's existance
+ //
+ Size = sizeof (EFI_IMAGE_DOS_HEADER);
+ Status = ImageContext->ImageRead (
+ ImageContext->Handle,
+ 0,
+ &Size,
+ &DosHdr
+ );
+ if (EFI_ERROR (Status)) {
+ ImageContext->ImageError = EFI_IMAGE_ERROR_IMAGE_READ;
+ return Status;
+ }
+
+ ImageContext->PeCoffHeaderOffset = 0;
+ if (DosHdr.e_magic == EFI_IMAGE_DOS_SIGNATURE) {
+ //
+ // DOS image header is present, so read the PE header after the DOS image
+ // header
+ //
+ ImageContext->PeCoffHeaderOffset = DosHdr.e_lfanew;
+ }
+
+ //
+ // Read the PE/COFF Header. For PE32 (32-bit) this will read in too much
+ // data, but that should not hurt anythine. Hdr.Pe32->OptionalHeader.Magic
+ // determins if this is a PE32 or PE32+ image. The magic is in the same
+ // location in both images.
+ //
+ Size = sizeof (EFI_IMAGE_OPTIONAL_HEADER_UNION);
+ Status = ImageContext->ImageRead (
+ ImageContext->Handle,
+ ImageContext->PeCoffHeaderOffset,
+ &Size,
+ Hdr.Pe32
+ );
+ if (EFI_ERROR (Status)) {
+ ImageContext->ImageError = EFI_IMAGE_ERROR_IMAGE_READ;
+ return Status;
+ }
+
+ //
+ // Use Signature to figure out if we understand the image format
+ //
+ if (Hdr.Te->Signature == EFI_TE_IMAGE_HEADER_SIGNATURE) {
+ ImageContext->IsTeImage = TRUE;
+ ImageContext->Machine = Hdr.Te->Machine;
+ ImageContext->ImageType = (UINT16)(Hdr.Te->Subsystem);
+ ImageContext->ImageSize = 0;
+ ImageContext->SectionAlignment = 4096;
+ ImageContext->SizeOfHeaders = sizeof (EFI_TE_IMAGE_HEADER) + (UINTN)Hdr.Te->BaseOfCode - (UINTN)Hdr.Te->StrippedSize;
+
+ } else if (Hdr.Pe32->Signature == EFI_IMAGE_NT_SIGNATURE) {
+ ImageContext->IsTeImage = FALSE;
+ ImageContext->Machine = Hdr.Pe32->FileHeader.Machine;
+
+ //
+ // NOTE: We use Machine to identify PE32/PE32+, instead of Magic.
+ // It is for backward-compatibility consideration, because
+ // some system will generate PE32+ image with PE32 Magic.
+ //
+ if (Hdr.Pe32->FileHeader.Machine == EFI_IMAGE_MACHINE_IA32) {
+ Magic = EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC;
+ } else if (Hdr.Pe32->FileHeader.Machine == EFI_IMAGE_MACHINE_IA64) {
+ Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC;
+ } else if (Hdr.Pe32->FileHeader.Machine == EFI_IMAGE_MACHINE_X64) {
+ Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC;
+ } else {
+ Magic = Hdr.Pe32->OptionalHeader.Magic;
+ }
+
+ if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC ||
+ Magic == EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC) {
+ //
+ // PE32 and PE32+ have the same offset for these fields.
+ // We use PE32 for both PE32 and PE32+ headers here.
+ //
+ ImageContext->ImageType = Hdr.Pe32->OptionalHeader.Subsystem;
+ ImageContext->ImageSize = (UINT64)Hdr.Pe32->OptionalHeader.SizeOfImage;
+ ImageContext->SectionAlignment = Hdr.Pe32->OptionalHeader.SectionAlignment;
+ ImageContext->SizeOfHeaders = Hdr.Pe32->OptionalHeader.SizeOfHeaders;
+
+ } else {
+ ImageContext->ImageError = EFI_IMAGE_ERROR_INVALID_MACHINE_TYPE;
+ return EFI_UNSUPPORTED;
+ }
+ } else {
+ ImageContext->ImageError = EFI_IMAGE_ERROR_INVALID_MACHINE_TYPE;
+ return EFI_UNSUPPORTED;
+ }
+
+ if (!PeCoffLoaderImageFormatSupported (ImageContext->Machine)) {
+ //
+ // If the PE/COFF loader does not support the image type return
+ // unsupported. This library can suport lots of types of images
+ // this does not mean the user of this library can call the entry
+ // point of the image.
+ //
+ return EFI_UNSUPPORTED;
+ }
+
+ return EFI_SUCCESS;
+}
+
+STATIC
+EFI_STATUS
+PeCoffLoaderCheckImageType (
+ IN OUT EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
+ )
+/*++
+
+Routine Description:
+
+ Checks the PE or TE header of a PE/COFF or TE image to determine if it supported
+
+Arguments:
+
+ ImageContext - The context of the image being loaded
+
+Returns:
+
+ EFI_SUCCESS if the PE/COFF or TE image is supported
+ EFI_UNSUPPORTED of the PE/COFF or TE image is not supported.
+
+--*/
+{
+ switch (ImageContext->ImageType) {
+
+ case EFI_IMAGE_SUBSYSTEM_EFI_APPLICATION:
+ ImageContext->ImageCodeMemoryType = EfiLoaderCode;
+ ImageContext->ImageDataMemoryType = EfiLoaderData;
+ break;
+
+ case EFI_IMAGE_SUBSYSTEM_EFI_BOOT_SERVICE_DRIVER:
+ ImageContext->ImageCodeMemoryType = EfiBootServicesCode;
+ ImageContext->ImageDataMemoryType = EfiBootServicesData;
+ break;
+
+ case EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER:
+ case EFI_IMAGE_SUBSYSTEM_SAL_RUNTIME_DRIVER:
+ ImageContext->ImageCodeMemoryType = EfiRuntimeServicesCode;
+ ImageContext->ImageDataMemoryType = EfiRuntimeServicesData;
+ break;
+
+ default:
+ ImageContext->ImageError = EFI_IMAGE_ERROR_INVALID_SUBSYSTEM;
+ return EFI_UNSUPPORTED;
+ }
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+PeCoffLoaderGetImageInfo (
+ IN EFI_PEI_PE_COFF_LOADER_PROTOCOL *This,
+ IN OUT EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
+ )
+/*++
+
+Routine Description:
+
+ Retrieves information on a PE/COFF image
+
+Arguments:
+
+ This - Calling context
+
+ ImageContext - The context of the image being loaded
+
+Returns:
+
+ EFI_SUCCESS if the information on the PE/COFF image was collected.
+ EFI_UNSUPPORTED of the PE/COFF image is not supported.
+ Otherwise, the error status from reading the PE/COFF image using the
+ ImageContext->ImageRead() function
+
+ EFI_INVALID_PARAMETER - ImageContext is NULL.
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_IMAGE_OPTIONAL_HEADER_UNION HdrData;
+ EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr;
+ EFI_IMAGE_DATA_DIRECTORY *DebugDirectoryEntry;
+ UINTN Size;
+ UINTN Index;
+ UINTN DebugDirectoryEntryRva;
+ UINTN DebugDirectoryEntryFileOffset;
+ UINTN SectionHeaderOffset;
+ EFI_IMAGE_SECTION_HEADER SectionHeader;
+ EFI_IMAGE_DEBUG_DIRECTORY_ENTRY DebugEntry;
+ UINT32 NumberOfRvaAndSizes;
+ UINT16 Magic;
+
+ if (NULL == ImageContext) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // Assume success
+ //
+ ImageContext->ImageError = EFI_IMAGE_ERROR_SUCCESS;
+
+ Hdr.Union = &HdrData;
+ Status = PeCoffLoaderGetPeHeader (ImageContext, Hdr);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ //
+ // Verify machine type
+ //
+ Status = PeCoffLoaderCheckImageType (ImageContext);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ Magic = EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC;
+
+ //
+ // Retrieve the base address of the image
+ //
+ if (!(ImageContext->IsTeImage)) {
+
+ //
+ // NOTE: We use Machine to identify PE32/PE32+, instead of Magic.
+ // It is for backward-compatibility consideration, because
+ // some system will generate PE32+ image with PE32 Magic.
+ //
+ if (Hdr.Pe32->FileHeader.Machine == EFI_IMAGE_MACHINE_IA32) {
+ Magic = EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC;
+ } else if (Hdr.Pe32->FileHeader.Machine == EFI_IMAGE_MACHINE_IA64) {
+ Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC;
+ } else if (Hdr.Pe32->FileHeader.Machine == EFI_IMAGE_MACHINE_X64) {
+ Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC;
+ } else {
+ Magic = Hdr.Pe32->OptionalHeader.Magic;
+ }
+
+ if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
+ //
+ // Use PE32 offset
+ //
+ ImageContext->ImageAddress = Hdr.Pe32->OptionalHeader.ImageBase;
+ } else {
+ //
+ // Use PE32+ offset
+ //
+ ImageContext->ImageAddress = Hdr.Pe32Plus->OptionalHeader.ImageBase;
+ }
+ } else {
+ ImageContext->ImageAddress = (EFI_PHYSICAL_ADDRESS)(Hdr.Te->ImageBase + Hdr.Te->StrippedSize - sizeof (EFI_TE_IMAGE_HEADER));
+ }
+
+ //
+ // Initialize the alternate destination address to 0 indicating that it
+ // should not be used.
+ //
+ ImageContext->DestinationAddress = 0;
+
+ //
+ // Initialize the codeview pointer.
+ //
+ ImageContext->CodeView = NULL;
+ ImageContext->PdbPointer = NULL;
+
+ //
+ // Three cases with regards to relocations:
+ // - Image has base relocs, RELOCS_STRIPPED==0 => image is relocatable
+ // - Image has no base relocs, RELOCS_STRIPPED==1 => Image is not relocatable
+ // - Image has no base relocs, RELOCS_STRIPPED==0 => Image is relocatable but
+ // has no base relocs to apply
+ // Obviously having base relocations with RELOCS_STRIPPED==1 is invalid.
+ //
+ // Look at the file header to determine if relocations have been stripped, and
+ // save this info in the image context for later use.
+ //
+ if ((!(ImageContext->IsTeImage)) && ((Hdr.Pe32->FileHeader.Characteristics & EFI_IMAGE_FILE_RELOCS_STRIPPED) != 0)) {
+ ImageContext->RelocationsStripped = TRUE;
+ } else {
+ ImageContext->RelocationsStripped = FALSE;
+ }
+
+ if (!(ImageContext->IsTeImage)) {
+ //
+ // Use PE32 to access fields that have same offset in PE32 and PE32+
+ //
+ ImageContext->ImageSize = (UINT64) Hdr.Pe32->OptionalHeader.SizeOfImage;
+ ImageContext->SectionAlignment = Hdr.Pe32->OptionalHeader.SectionAlignment;
+ ImageContext->SizeOfHeaders = Hdr.Pe32->OptionalHeader.SizeOfHeaders;
+ if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
+ //
+ // Use PE32 offset
+ //
+ NumberOfRvaAndSizes = Hdr.Pe32->OptionalHeader.NumberOfRvaAndSizes;
+ DebugDirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]);
+ } else {
+ //
+ // Use PE32+ offset
+ //
+ NumberOfRvaAndSizes = Hdr.Pe32Plus->OptionalHeader.NumberOfRvaAndSizes;
+ DebugDirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&(Hdr.Pe32Plus->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_DEBUG]);
+ }
+
+ if (NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_DEBUG) {
+
+ DebugDirectoryEntryRva = DebugDirectoryEntry->VirtualAddress;
+
+ //
+ // Determine the file offset of the debug directory... This means we walk
+ // the sections to find which section contains the RVA of the debug
+ // directory
+ //
+ DebugDirectoryEntryFileOffset = 0;
+
+ SectionHeaderOffset = (UINTN)(
+ ImageContext->PeCoffHeaderOffset +
+ sizeof (UINT32) +
+ sizeof (EFI_IMAGE_FILE_HEADER) +
+ Hdr.Pe32->FileHeader.SizeOfOptionalHeader
+ );
+
+ for (Index = 0; Index < Hdr.Pe32->FileHeader.NumberOfSections; Index++) {
+ //
+ // Read section header from file
+ //
+ Size = sizeof (EFI_IMAGE_SECTION_HEADER);
+ Status = ImageContext->ImageRead (
+ ImageContext->Handle,
+ SectionHeaderOffset,
+ &Size,
+ &SectionHeader
+ );
+ if (EFI_ERROR (Status)) {
+ ImageContext->ImageError = EFI_IMAGE_ERROR_IMAGE_READ;
+ return Status;
+ }
+
+ if (DebugDirectoryEntryRva >= SectionHeader.VirtualAddress &&
+ DebugDirectoryEntryRva < SectionHeader.VirtualAddress + SectionHeader.Misc.VirtualSize) {
+
+ DebugDirectoryEntryFileOffset = DebugDirectoryEntryRva - SectionHeader.VirtualAddress + SectionHeader.PointerToRawData;
+ break;
+ }
+
+ SectionHeaderOffset += sizeof (EFI_IMAGE_SECTION_HEADER);
+ }
+
+ if (DebugDirectoryEntryFileOffset != 0) {
+ for (Index = 0; Index < DebugDirectoryEntry->Size; Index++) {
+ //
+ // Read next debug directory entry
+ //
+ Size = sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY);
+ Status = ImageContext->ImageRead (
+ ImageContext->Handle,
+ DebugDirectoryEntryFileOffset,
+ &Size,
+ &DebugEntry
+ );
+ if (EFI_ERROR (Status)) {
+ ImageContext->ImageError = EFI_IMAGE_ERROR_IMAGE_READ;
+ return Status;
+ }
+
+ if (DebugEntry.Type == EFI_IMAGE_DEBUG_TYPE_CODEVIEW) {
+ ImageContext->DebugDirectoryEntryRva = (UINT32) (DebugDirectoryEntryRva + Index * sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY));
+ if (DebugEntry.RVA == 0 && DebugEntry.FileOffset != 0) {
+ ImageContext->ImageSize += DebugEntry.SizeOfData;
+ }
+
+ return EFI_SUCCESS;
+ }
+ }
+ }
+ }
+ } else {
+ //
+ // Because Te image only extracts base relocations and debug directory entries from
+ // Pe image and in Te image header there is not a field to describe the imagesize,
+ // we use the largest VirtualAddress plus Size in each directory entry to describe the imagesize
+ //
+ ImageContext->ImageSize = (UINT64) (Hdr.Te->DataDirectory[0].VirtualAddress + Hdr.Te->DataDirectory[0].Size);
+ if(Hdr.Te->DataDirectory[1].VirtualAddress > Hdr.Te->DataDirectory[0].VirtualAddress) {
+ ImageContext->ImageSize = (UINT64) (Hdr.Te->DataDirectory[1].VirtualAddress + Hdr.Te->DataDirectory[1].Size);
+ }
+ ImageContext->SectionAlignment = 4096;
+ ImageContext->SizeOfHeaders = sizeof (EFI_TE_IMAGE_HEADER) + (UINTN) Hdr.Te->BaseOfCode - (UINTN) Hdr.Te->StrippedSize;
+
+ DebugDirectoryEntry = &Hdr.Te->DataDirectory[1];
+ DebugDirectoryEntryRva = DebugDirectoryEntry->VirtualAddress;
+ SectionHeaderOffset = (UINTN)(sizeof (EFI_TE_IMAGE_HEADER));
+
+ DebugDirectoryEntryFileOffset = 0;
+
+ for (Index = 0; Index < Hdr.Te->NumberOfSections; Index++) {
+ //
+ // Read section header from file
+ //
+ Size = sizeof (EFI_IMAGE_SECTION_HEADER);
+ Status = ImageContext->ImageRead (
+ ImageContext->Handle,
+ SectionHeaderOffset,
+ &Size,
+ &SectionHeader
+ );
+ if (EFI_ERROR (Status)) {
+ ImageContext->ImageError = EFI_IMAGE_ERROR_IMAGE_READ;
+ return Status;
+ }
+
+ if (DebugDirectoryEntryRva >= SectionHeader.VirtualAddress &&
+ DebugDirectoryEntryRva < SectionHeader.VirtualAddress + SectionHeader.Misc.VirtualSize) {
+ DebugDirectoryEntryFileOffset = DebugDirectoryEntryRva -
+ SectionHeader.VirtualAddress +
+ SectionHeader.PointerToRawData +
+ sizeof (EFI_TE_IMAGE_HEADER) -
+ Hdr.Te->StrippedSize;
+ break;
+ }
+
+ SectionHeaderOffset += sizeof (EFI_IMAGE_SECTION_HEADER);
+ }
+
+ if (DebugDirectoryEntryFileOffset != 0) {
+ for (Index = 0; Index < DebugDirectoryEntry->Size; Index++) {
+ //
+ // Read next debug directory entry
+ //
+ Size = sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY);
+ Status = ImageContext->ImageRead (
+ ImageContext->Handle,
+ DebugDirectoryEntryFileOffset,
+ &Size,
+ &DebugEntry
+ );
+ if (EFI_ERROR (Status)) {
+ ImageContext->ImageError = EFI_IMAGE_ERROR_IMAGE_READ;
+ return Status;
+ }
+
+ if (DebugEntry.Type == EFI_IMAGE_DEBUG_TYPE_CODEVIEW) {
+ ImageContext->DebugDirectoryEntryRva = (UINT32) (DebugDirectoryEntryRva + Index * sizeof (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY));
+ return EFI_SUCCESS;
+ }
+ }
+ }
+ }
+
+ return EFI_SUCCESS;
+}
+
+STATIC
+VOID *
+PeCoffLoaderImageAddress (
+ IN OUT EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext,
+ IN UINTN Address
+ )
+/*++
+
+Routine Description:
+
+ Converts an image address to the loaded address
+
+Arguments:
+
+ ImageContext - The context of the image being loaded
+
+ Address - The address to be converted to the loaded address
+
+Returns:
+
+ NULL if the address can not be converted, otherwise, the converted address
+
+--*/
+{
+ if (Address >= ImageContext->ImageSize) {
+ ImageContext->ImageError = EFI_IMAGE_ERROR_INVALID_IMAGE_ADDRESS;
+ return NULL;
+ }
+
+ return (CHAR8 *) ((UINTN) ImageContext->ImageAddress + Address);
+}
+
+EFI_STATUS
+EFIAPI
+PeCoffLoaderRelocateImage (
+ IN EFI_PEI_PE_COFF_LOADER_PROTOCOL *This,
+ IN OUT EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
+ )
+/*++
+
+Routine Description:
+
+ Relocates a PE/COFF image in memory
+
+Arguments:
+
+ This - Calling context
+
+ ImageContext - Contains information on the loaded image to relocate
+
+Returns:
+
+ EFI_SUCCESS if the PE/COFF image was relocated
+ EFI_LOAD_ERROR if the image is not a valid PE/COFF image
+ EFI_UNSUPPORTED not support
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr;
+ EFI_IMAGE_DATA_DIRECTORY *RelocDir;
+ UINT64 Adjust;
+ EFI_IMAGE_BASE_RELOCATION *RelocBase;
+ EFI_IMAGE_BASE_RELOCATION *RelocBaseEnd;
+ UINT16 *Reloc;
+ UINT16 *RelocEnd;
+ CHAR8 *Fixup;
+ CHAR8 *FixupBase;
+ UINT16 *F16;
+ UINT32 *F32;
+ UINT64 *F64;
+ CHAR8 *FixupData;
+ EFI_PHYSICAL_ADDRESS BaseAddress;
+ UINT32 NumberOfRvaAndSizes;
+ UINT16 Magic;
+#ifdef EFI_NT_EMULATOR
+ VOID *DllEntryPoint;
+ VOID *ModHandle;
+
+ ModHandle = NULL;
+#endif
+
+ if (NULL == ImageContext) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // Assume success
+ //
+ ImageContext->ImageError = EFI_IMAGE_ERROR_SUCCESS;
+
+ //
+ // If there are no relocation entries, then we are done
+ //
+ if (ImageContext->RelocationsStripped) {
+ return EFI_SUCCESS;
+ }
+
+ //
+ // If the destination address is not 0, use that rather than the
+ // image address as the relocation target.
+ //
+ if (ImageContext->DestinationAddress != 0) {
+ BaseAddress = ImageContext->DestinationAddress;
+ } else {
+ BaseAddress = ImageContext->ImageAddress;
+ }
+
+ if (!(ImageContext->IsTeImage)) {
+ Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINTN)ImageContext->ImageAddress + ImageContext->PeCoffHeaderOffset);
+
+ //
+ // NOTE: We use Machine to identify PE32/PE32+, instead of Magic.
+ // It is for backward-compatibility consideration, because
+ // some system will generate PE32+ image with PE32 Magic.
+ //
+ if (Hdr.Pe32->FileHeader.Machine == EFI_IMAGE_MACHINE_IA32) {
+ Magic = EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC;
+ } else if (Hdr.Pe32->FileHeader.Machine == EFI_IMAGE_MACHINE_IA64) {
+ Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC;
+ } else if (Hdr.Pe32->FileHeader.Machine == EFI_IMAGE_MACHINE_X64) {
+ Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC;
+ } else {
+ Magic = Hdr.Pe32->OptionalHeader.Magic;
+ }
+
+ if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
+ //
+ // Use PE32 offset
+ //
+ Adjust = (UINT64)BaseAddress - Hdr.Pe32->OptionalHeader.ImageBase;
+ Hdr.Pe32->OptionalHeader.ImageBase = (UINT32)BaseAddress;
+
+ NumberOfRvaAndSizes = Hdr.Pe32->OptionalHeader.NumberOfRvaAndSizes;
+ RelocDir = &Hdr.Pe32->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC];
+ } else {
+ //
+ // Use PE32+ offset
+ //
+ Adjust = (UINT64) BaseAddress - Hdr.Pe32Plus->OptionalHeader.ImageBase;
+ Hdr.Pe32Plus->OptionalHeader.ImageBase = (UINT64)BaseAddress;
+
+ NumberOfRvaAndSizes = Hdr.Pe32Plus->OptionalHeader.NumberOfRvaAndSizes;
+ RelocDir = &Hdr.Pe32Plus->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC];
+ }
+
+ //
+ // Find the relocation block
+ // Per the PE/COFF spec, you can't assume that a given data directory
+ // is present in the image. You have to check the NumberOfRvaAndSizes in
+ // the optional header to verify a desired directory entry is there.
+ //
+
+ if (NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC && RelocDir->Size > 0) {
+ RelocBase = PeCoffLoaderImageAddress (ImageContext, RelocDir->VirtualAddress);
+ RelocBaseEnd = PeCoffLoaderImageAddress (
+ ImageContext,
+ RelocDir->VirtualAddress + RelocDir->Size - 1
+ );
+ if ((RelocBase == NULL) || (RelocBaseEnd == NULL)) {
+ //
+ // If the base start or end address resolved to 0, then fail.
+ //
+ return EFI_LOAD_ERROR;
+ }
+ } else {
+ //
+ // Set base and end to bypass processing below.
+ //
+ RelocBase = RelocBaseEnd = 0;
+ }
+
+ ImageContext->EntryPoint = BaseAddress + Hdr.Pe32->OptionalHeader.AddressOfEntryPoint;
+ } else {
+ Hdr.Te = (EFI_TE_IMAGE_HEADER *)(UINTN)(ImageContext->ImageAddress);
+ Adjust = (UINT64) (BaseAddress - Hdr.Te->StrippedSize + sizeof (EFI_TE_IMAGE_HEADER) - Hdr.Te->ImageBase);
+ Hdr.Te->ImageBase = (UINT64) (BaseAddress - Hdr.Te->StrippedSize + sizeof (EFI_TE_IMAGE_HEADER));
+
+ //
+ // Find the relocation block
+ //
+ RelocDir = &Hdr.Te->DataDirectory[0];
+ if (RelocDir->Size > 0) {
+ RelocBase = (EFI_IMAGE_BASE_RELOCATION *)(UINTN)(
+ ImageContext->ImageAddress +
+ RelocDir->VirtualAddress +
+ sizeof(EFI_TE_IMAGE_HEADER) -
+ Hdr.Te->StrippedSize
+ );
+ RelocBaseEnd = (EFI_IMAGE_BASE_RELOCATION *) ((UINTN) RelocBase + (UINTN) RelocDir->Size - 1);
+ ImageContext->EntryPoint = Hdr.Te->ImageBase + Hdr.Te->AddressOfEntryPoint;
+ } else {
+ //
+ // Set base and end to bypass processing below.
+ //
+ RelocBase = RelocBaseEnd = 0;
+ }
+ }
+
+ //
+ // Run the relocation information and apply the fixups
+ //
+ FixupData = ImageContext->FixupData;
+ while (RelocBase < RelocBaseEnd) {
+
+ Reloc = (UINT16 *) ((CHAR8 *) RelocBase + sizeof (EFI_IMAGE_BASE_RELOCATION));
+ RelocEnd = (UINT16 *) ((CHAR8 *) RelocBase + RelocBase->SizeOfBlock);
+ if (!(ImageContext->IsTeImage)) {
+ FixupBase = PeCoffLoaderImageAddress (ImageContext, RelocBase->VirtualAddress);
+
+ if (FixupBase == NULL) {
+ //
+ // If the FixupBase address resolved to 0, then fail.
+ //
+ return EFI_LOAD_ERROR;
+ }
+
+ } else {
+ FixupBase = (CHAR8 *)(UINTN)(ImageContext->ImageAddress +
+ RelocBase->VirtualAddress +
+ sizeof(EFI_TE_IMAGE_HEADER) -
+ Hdr.Te->StrippedSize
+ );
+ }
+
+ if ((CHAR8 *) RelocEnd < (CHAR8 *) ((UINTN) ImageContext->ImageAddress) ||
+ (CHAR8 *) RelocEnd > (CHAR8 *)((UINTN)ImageContext->ImageAddress +
+ (UINTN)ImageContext->ImageSize)) {
+ ImageContext->ImageError = EFI_IMAGE_ERROR_FAILED_RELOCATION;
+ return EFI_LOAD_ERROR;
+ }
+
+ //
+ // Run this relocation record
+ //
+ while (Reloc < RelocEnd) {
+
+ Fixup = FixupBase + (*Reloc & 0xFFF);
+ switch ((*Reloc) >> 12) {
+ case EFI_IMAGE_REL_BASED_ABSOLUTE:
+ break;
+
+ case EFI_IMAGE_REL_BASED_HIGH:
+ F16 = (UINT16 *) Fixup;
+ *F16 = (UINT16) (*F16 + (UINT16)(((UINT32)Adjust) >> 16));
+ if (FixupData != NULL) {
+ *(UINT16 *) FixupData = *F16;
+ FixupData = FixupData + sizeof (UINT16);
+ }
+ break;
+
+ case EFI_IMAGE_REL_BASED_LOW:
+ F16 = (UINT16 *) Fixup;
+ *F16 = (UINT16) (*F16 + (UINT16) Adjust);
+ if (FixupData != NULL) {
+ *(UINT16 *) FixupData = *F16;
+ FixupData = FixupData + sizeof (UINT16);
+ }
+ break;
+
+ case EFI_IMAGE_REL_BASED_HIGHLOW:
+ F32 = (UINT32 *) Fixup;
+ *F32 = *F32 + (UINT32) Adjust;
+ if (FixupData != NULL) {
+ FixupData = ALIGN_POINTER (FixupData, sizeof (UINT32));
+ *(UINT32 *) FixupData = *F32;
+ FixupData = FixupData + sizeof (UINT32);
+ }
+ break;
+
+ case EFI_IMAGE_REL_BASED_DIR64:
+ //
+ // For X64 and IPF
+ //
+ F64 = (UINT64 *) Fixup;
+ *F64 = *F64 + (UINT64) Adjust;
+ if (FixupData != NULL) {
+ FixupData = ALIGN_POINTER (FixupData, sizeof(UINT64));
+ *(UINT64 *)(FixupData) = *F64;
+ FixupData = FixupData + sizeof(UINT64);
+ }
+ break;
+
+ case EFI_IMAGE_REL_BASED_HIGHADJ:
+ //
+ // Return the same EFI_UNSUPPORTED return code as
+ // PeCoffLoaderRelocateImageEx() returns if it does not recognize
+ // the relocation type.
+ //
+ ImageContext->ImageError = EFI_IMAGE_ERROR_FAILED_RELOCATION;
+ return EFI_UNSUPPORTED;
+
+ default:
+ //
+ // The common code does not handle some of the stranger IPF relocations
+ // PeCoffLoaderRelocateImageEx () addes support for these complex fixups
+ // on IPF and is a No-Op on other archtiectures.
+ //
+ Status = PeCoffLoaderRelocateImageEx (Reloc, Fixup, &FixupData, Adjust);
+ if (EFI_ERROR (Status)) {
+ ImageContext->ImageError = EFI_IMAGE_ERROR_FAILED_RELOCATION;
+ return Status;
+ }
+ }
+
+ //
+ // Next relocation record
+ //
+ Reloc += 1;
+ }
+
+ //
+ // Next reloc block
+ //
+ RelocBase = (EFI_IMAGE_BASE_RELOCATION *) RelocEnd;
+ }
+
+#ifdef EFI_NT_EMULATOR
+ DllEntryPoint = NULL;
+ ImageContext->ModHandle = NULL;
+ //
+ // Load the DLL if it's not an EBC image.
+ //
+ if ((ImageContext->PdbPointer != NULL) &&
+ (ImageContext->Machine != EFI_IMAGE_MACHINE_EBC)) {
+ Status = mPeCoffLoaderWinNtLoadAsDll->Entry (
+ ImageContext->PdbPointer,
+ &DllEntryPoint,
+ &ModHandle
+ );
+
+ if (!EFI_ERROR (Status) && DllEntryPoint != NULL) {
+ ImageContext->EntryPoint = (EFI_PHYSICAL_ADDRESS) (UINTN) DllEntryPoint;
+ ImageContext->ModHandle = ModHandle;
+ }
+ }
+#endif
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+PeCoffLoaderLoadImage (
+ IN EFI_PEI_PE_COFF_LOADER_PROTOCOL *This,
+ IN OUT EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
+ )
+/*++
+
+Routine Description:
+
+ Loads a PE/COFF image into memory
+
+Arguments:
+
+ This - Calling context
+
+ ImageContext - Contains information on image to load into memory
+
+Returns:
+
+ EFI_SUCCESS if the PE/COFF image was loaded
+ EFI_BUFFER_TOO_SMALL if the caller did not provide a large enough buffer
+ EFI_LOAD_ERROR if the image is a runtime driver with no relocations
+ EFI_INVALID_PARAMETER if the image address is invalid
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_IMAGE_OPTIONAL_HEADER_PTR_UNION Hdr;
+ EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT CheckContext;
+ EFI_IMAGE_SECTION_HEADER *FirstSection;
+ EFI_IMAGE_SECTION_HEADER *Section;
+ UINTN NumberOfSections;
+ UINTN Index;
+ CHAR8 *Base;
+ CHAR8 *End;
+ CHAR8 *MaxEnd;
+ EFI_IMAGE_DATA_DIRECTORY *DirectoryEntry;
+ EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *DebugEntry;
+ UINTN Size;
+ UINT32 TempDebugEntryRva;
+ UINT32 NumberOfRvaAndSizes;
+ UINT16 Magic;
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
+ EFI_IMAGE_RESOURCE_DIRECTORY *ResourceDirectory;
+ EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY *ResourceDirectoryEntry;
+ EFI_IMAGE_RESOURCE_DIRECTORY_STRING *ResourceDirectoryString;
+ EFI_IMAGE_RESOURCE_DATA_ENTRY *ResourceDataEntry;
+#endif
+
+ if (NULL == ImageContext) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ //
+ // Assume success
+ //
+ ImageContext->ImageError = EFI_IMAGE_ERROR_SUCCESS;
+
+ //
+ // Copy the provided context info into our local version, get what we
+ // can from the original image, and then use that to make sure everything
+ // is legit.
+ //
+ CopyMem (&CheckContext, ImageContext, sizeof (EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT));
+
+ Status = PeCoffLoaderGetImageInfo (This, &CheckContext);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ //
+ // Make sure there is enough allocated space for the image being loaded
+ //
+ if (ImageContext->ImageSize < CheckContext.ImageSize) {
+ ImageContext->ImageError = EFI_IMAGE_ERROR_INVALID_IMAGE_SIZE;
+ return EFI_BUFFER_TOO_SMALL;
+ }
+ if (ImageContext->ImageAddress == 0) {
+ //
+ // Image cannot be loaded into 0 address.
+ //
+ ImageContext->ImageError = EFI_IMAGE_ERROR_INVALID_IMAGE_ADDRESS;
+ return EFI_INVALID_PARAMETER;
+ }
+ //
+ // If there's no relocations, then make sure it's not a runtime driver,
+ // and that it's being loaded at the linked address.
+ //
+ if (CheckContext.RelocationsStripped) {
+ //
+ // If the image does not contain relocations and it is a runtime driver
+ // then return an error.
+ //
+ if (CheckContext.ImageType == EFI_IMAGE_SUBSYSTEM_EFI_RUNTIME_DRIVER) {
+ ImageContext->ImageError = EFI_IMAGE_ERROR_INVALID_SUBSYSTEM;
+ return EFI_LOAD_ERROR;
+ }
+ //
+ // If the image does not contain relocations, and the requested load address
+ // is not the linked address, then return an error.
+ //
+ if (CheckContext.ImageAddress != ImageContext->ImageAddress) {
+ ImageContext->ImageError = EFI_IMAGE_ERROR_INVALID_IMAGE_ADDRESS;
+ return EFI_INVALID_PARAMETER;
+ }
+ }
+ //
+ // Make sure the allocated space has the proper section alignment
+ //
+ if (!(ImageContext->IsTeImage)) {
+ if ((ImageContext->ImageAddress & (CheckContext.SectionAlignment - 1)) != 0) {
+ ImageContext->ImageError = EFI_IMAGE_ERROR_INVALID_SECTION_ALIGNMENT;
+ return EFI_INVALID_PARAMETER;
+ }
+ }
+ //
+ // Read the entire PE/COFF or TE header into memory
+ //
+ if (!(ImageContext->IsTeImage)) {
+ Status = ImageContext->ImageRead (
+ ImageContext->Handle,
+ 0,
+ &ImageContext->SizeOfHeaders,
+ (VOID *) (UINTN) ImageContext->ImageAddress
+ );
+
+ Hdr.Pe32 = (EFI_IMAGE_NT_HEADERS32 *)((UINTN)ImageContext->ImageAddress + ImageContext->PeCoffHeaderOffset);
+
+ FirstSection = (EFI_IMAGE_SECTION_HEADER *) (
+ (UINTN)ImageContext->ImageAddress +
+ ImageContext->PeCoffHeaderOffset +
+ sizeof(UINT32) +
+ sizeof(EFI_IMAGE_FILE_HEADER) +
+ Hdr.Pe32->FileHeader.SizeOfOptionalHeader
+ );
+ NumberOfSections = (UINTN) (Hdr.Pe32->FileHeader.NumberOfSections);
+ } else {
+ Status = ImageContext->ImageRead (
+ ImageContext->Handle,
+ 0,
+ &ImageContext->SizeOfHeaders,
+ (VOID *)(UINTN)ImageContext->ImageAddress
+ );
+
+ Hdr.Te = (EFI_TE_IMAGE_HEADER *)(UINTN)(ImageContext->ImageAddress);
+
+ FirstSection = (EFI_IMAGE_SECTION_HEADER *) (
+ (UINTN)ImageContext->ImageAddress +
+ sizeof(EFI_TE_IMAGE_HEADER)
+ );
+ NumberOfSections = (UINTN) (Hdr.Te->NumberOfSections);
+
+ }
+
+ if (EFI_ERROR (Status)) {
+ ImageContext->ImageError = EFI_IMAGE_ERROR_IMAGE_READ;
+ return EFI_LOAD_ERROR;
+ }
+
+ //
+ // Load each section of the image
+ //
+ Section = FirstSection;
+ for (Index = 0, MaxEnd = NULL; Index < NumberOfSections; Index++) {
+
+ //
+ // Compute sections address
+ //
+ Base = PeCoffLoaderImageAddress (ImageContext, Section->VirtualAddress);
+ End = PeCoffLoaderImageAddress (
+ ImageContext,
+ Section->VirtualAddress + Section->Misc.VirtualSize - 1
+ );
+ if (ImageContext->IsTeImage) {
+ Base = (CHAR8 *)((UINTN) Base + sizeof (EFI_TE_IMAGE_HEADER) - (UINTN)Hdr.Te->StrippedSize);
+ End = (CHAR8 *)((UINTN) End + sizeof (EFI_TE_IMAGE_HEADER) - (UINTN)Hdr.Te->StrippedSize);
+ }
+
+ if (End > MaxEnd) {
+ MaxEnd = End;
+ }
+ //
+ // If the base start or end address resolved to 0, then fail.
+ //
+ if ((Base == NULL) || (End == NULL)) {
+ ImageContext->ImageError = EFI_IMAGE_ERROR_SECTION_NOT_LOADED;
+ return EFI_LOAD_ERROR;
+ }
+
+ //
+ // Read the section
+ //
+ Size = (UINTN) Section->Misc.VirtualSize;
+ if ((Size == 0) || (Size > Section->SizeOfRawData)) {
+ Size = (UINTN) Section->SizeOfRawData;
+ }
+
+ if (Section->SizeOfRawData) {
+ if (!(ImageContext->IsTeImage)) {
+ Status = ImageContext->ImageRead (
+ ImageContext->Handle,
+ Section->PointerToRawData,
+ &Size,
+ Base
+ );
+ } else {
+ Status = ImageContext->ImageRead (
+ ImageContext->Handle,
+ Section->PointerToRawData + sizeof (EFI_TE_IMAGE_HEADER) - (UINTN)Hdr.Te->StrippedSize,
+ &Size,
+ Base
+ );
+ }
+
+ if (EFI_ERROR (Status)) {
+ ImageContext->ImageError = EFI_IMAGE_ERROR_IMAGE_READ;
+ return Status;
+ }
+ }
+
+ //
+ // If raw size is less then virt size, zero fill the remaining
+ //
+
+ if (Size < Section->Misc.VirtualSize) {
+ ZeroMem (Base + Size, Section->Misc.VirtualSize - Size);
+ }
+
+ //
+ // Next Section
+ //
+ Section += 1;
+ }
+
+ Magic = EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC;
+
+ //
+ // Get image's entry point
+ //
+ if (!(ImageContext->IsTeImage)) {
+
+ //
+ // NOTE: We use Machine to identify PE32/PE32+, instead of Magic.
+ // It is for backward-compatibility consideration, because
+ // some system will generate PE32+ image with PE32 Magic.
+ //
+ if (Hdr.Pe32->FileHeader.Machine == EFI_IMAGE_MACHINE_IA32) {
+ Magic = EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC;
+ } else if (Hdr.Pe32->FileHeader.Machine == EFI_IMAGE_MACHINE_IA64) {
+ Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC;
+ } else if (Hdr.Pe32->FileHeader.Machine == EFI_IMAGE_MACHINE_X64) {
+ Magic = EFI_IMAGE_NT_OPTIONAL_HDR64_MAGIC;
+ } else {
+ Magic = Hdr.Pe32->OptionalHeader.Magic;
+ }
+
+ //
+ // Sizes of AddressOfEntryPoint are different so we need to do this safely
+ //
+ ImageContext->EntryPoint = (EFI_PHYSICAL_ADDRESS)(UINTN)PeCoffLoaderImageAddress (
+ ImageContext,
+ (UINTN)Hdr.Pe32->OptionalHeader.AddressOfEntryPoint
+ );
+
+ } else {
+ ImageContext->EntryPoint = (EFI_PHYSICAL_ADDRESS) (
+ (UINTN)ImageContext->ImageAddress +
+ (UINTN)Hdr.Te->AddressOfEntryPoint +
+ (UINTN)sizeof(EFI_TE_IMAGE_HEADER) -
+ (UINTN)Hdr.Te->StrippedSize
+ );
+ }
+
+ //
+ // Determine the size of the fixup data
+ //
+ // Per the PE/COFF spec, you can't assume that a given data directory
+ // is present in the image. You have to check the NumberOfRvaAndSizes in
+ // the optional header to verify a desired directory entry is there.
+ //
+ if (!(ImageContext->IsTeImage)) {
+ if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
+ //
+ // Use PE32 offset
+ //
+ NumberOfRvaAndSizes = Hdr.Pe32->OptionalHeader.NumberOfRvaAndSizes;
+ DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&Hdr.Pe32->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC];
+ } else {
+ //
+ // Use PE32+ offset
+ //
+ NumberOfRvaAndSizes = Hdr.Pe32Plus->OptionalHeader.NumberOfRvaAndSizes;
+ DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&Hdr.Pe32Plus->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC];
+ }
+
+ if (NumberOfRvaAndSizes > EFI_IMAGE_DIRECTORY_ENTRY_BASERELOC) {
+ ImageContext->FixupDataSize = DirectoryEntry->Size / sizeof (UINT16) * sizeof (UINTN);
+ } else {
+ ImageContext->FixupDataSize = 0;
+ }
+ } else {
+ DirectoryEntry = &Hdr.Te->DataDirectory[0];
+ ImageContext->FixupDataSize = DirectoryEntry->Size / sizeof (UINT16) * sizeof (UINTN);
+ }
+ //
+ // Consumer must allocate a buffer for the relocation fixup log.
+ // Only used for runtime drivers.
+ //
+ ImageContext->FixupData = NULL;
+
+ //
+ // Load the Codeview info if present
+ //
+ if (ImageContext->DebugDirectoryEntryRva != 0) {
+ if (!(ImageContext->IsTeImage)) {
+ DebugEntry = PeCoffLoaderImageAddress (
+ ImageContext,
+ ImageContext->DebugDirectoryEntryRva
+ );
+ } else {
+ DebugEntry = (EFI_IMAGE_DEBUG_DIRECTORY_ENTRY *)(UINTN)(
+ ImageContext->ImageAddress +
+ ImageContext->DebugDirectoryEntryRva +
+ sizeof(EFI_TE_IMAGE_HEADER) -
+ Hdr.Te->StrippedSize
+ );
+ }
+
+ if (DebugEntry != NULL) {
+ TempDebugEntryRva = DebugEntry->RVA;
+ if (DebugEntry->RVA == 0 && DebugEntry->FileOffset != 0) {
+ Section--;
+ if ((UINTN)Section->SizeOfRawData < Section->Misc.VirtualSize) {
+ TempDebugEntryRva = Section->VirtualAddress + Section->Misc.VirtualSize;
+ } else {
+ TempDebugEntryRva = Section->VirtualAddress + Section->SizeOfRawData;
+ }
+ }
+
+ if (TempDebugEntryRva != 0) {
+ if (!(ImageContext->IsTeImage)) {
+ ImageContext->CodeView = PeCoffLoaderImageAddress (ImageContext, TempDebugEntryRva);
+ } else {
+ ImageContext->CodeView = (VOID *)(
+ (UINTN)ImageContext->ImageAddress +
+ (UINTN)TempDebugEntryRva +
+ (UINTN)sizeof (EFI_TE_IMAGE_HEADER) -
+ (UINTN) Hdr.Te->StrippedSize
+ );
+ }
+
+ if (ImageContext->CodeView == NULL) {
+ ImageContext->ImageError = EFI_IMAGE_ERROR_IMAGE_READ;
+ return EFI_LOAD_ERROR;
+ }
+
+ if (DebugEntry->RVA == 0) {
+ Size = DebugEntry->SizeOfData;
+ if (!(ImageContext->IsTeImage)) {
+ Status = ImageContext->ImageRead (
+ ImageContext->Handle,
+ DebugEntry->FileOffset,
+ &Size,
+ ImageContext->CodeView
+ );
+ } else {
+ Status = ImageContext->ImageRead (
+ ImageContext->Handle,
+ DebugEntry->FileOffset + sizeof (EFI_TE_IMAGE_HEADER) - Hdr.Te->StrippedSize,
+ &Size,
+ ImageContext->CodeView
+ );
+ //
+ // Should we apply fix up to this field according to the size difference between PE and TE?
+ // Because now we maintain TE header fields unfixed, this field will also remain as they are
+ // in original PE image.
+ //
+ }
+
+ if (EFI_ERROR (Status)) {
+ ImageContext->ImageError = EFI_IMAGE_ERROR_IMAGE_READ;
+ return EFI_LOAD_ERROR;
+ }
+
+ DebugEntry->RVA = TempDebugEntryRva;
+ }
+
+ switch (*(UINT32 *) ImageContext->CodeView) {
+ case CODEVIEW_SIGNATURE_NB10:
+ ImageContext->PdbPointer = (CHAR8 *)ImageContext->CodeView + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_NB10_ENTRY);
+ break;
+
+ case CODEVIEW_SIGNATURE_RSDS:
+ ImageContext->PdbPointer = (CHAR8 *)ImageContext->CodeView + sizeof (EFI_IMAGE_DEBUG_CODEVIEW_RSDS_ENTRY);
+ break;
+
+ default:
+ break;
+ }
+ }
+ }
+ }
+
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
+ //
+ // Get Image's HII resource section
+ //
+ if (!(ImageContext->IsTeImage)) {
+ if (Magic == EFI_IMAGE_NT_OPTIONAL_HDR32_MAGIC) {
+ //
+ // Use PE32 offset
+ //
+ DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&Hdr.Pe32->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_RESOURCE];
+ } else {
+ //
+ // Use PE32+ offset
+ //
+ DirectoryEntry = (EFI_IMAGE_DATA_DIRECTORY *)&Hdr.Pe32Plus->OptionalHeader.DataDirectory[EFI_IMAGE_DIRECTORY_ENTRY_RESOURCE];
+ }
+
+ if (DirectoryEntry->Size != 0) {
+ Base = PeCoffLoaderImageAddress (ImageContext, DirectoryEntry->VirtualAddress);
+
+ if (Base == NULL) {
+ return EFI_LOAD_ERROR;
+ }
+
+ ResourceDirectory = (EFI_IMAGE_RESOURCE_DIRECTORY *) Base;
+ ResourceDirectoryEntry = (EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY *) (ResourceDirectory + 1);
+
+ for (Index = 0; Index < ResourceDirectory->NumberOfNamedEntries; Index++) {
+ if (ResourceDirectoryEntry->u1.s.NameIsString) {
+ ResourceDirectoryString = (EFI_IMAGE_RESOURCE_DIRECTORY_STRING *) (Base + ResourceDirectoryEntry->u1.s.NameOffset);
+
+ if (ResourceDirectoryString->Length == 3 &&
+ ResourceDirectoryString->String[0] == L'H' &&
+ ResourceDirectoryString->String[1] == L'I' &&
+ ResourceDirectoryString->String[2] == L'I') {
+ //
+ // Resource Type "HII" found
+ //
+ if (ResourceDirectoryEntry->u2.s.DataIsDirectory) {
+ //
+ // Move to next level - resource Name
+ //
+ ResourceDirectory = (EFI_IMAGE_RESOURCE_DIRECTORY *) (Base + ResourceDirectoryEntry->u2.s.OffsetToDirectory);
+ ResourceDirectoryEntry = (EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY *) (ResourceDirectory + 1);
+
+ if (ResourceDirectoryEntry->u2.s.DataIsDirectory) {
+ //
+ // Move to next level - resource Language
+ //
+ ResourceDirectory = (EFI_IMAGE_RESOURCE_DIRECTORY *) (Base + ResourceDirectoryEntry->u2.s.OffsetToDirectory);
+ ResourceDirectoryEntry = (EFI_IMAGE_RESOURCE_DIRECTORY_ENTRY *) (ResourceDirectory + 1);
+ }
+ }
+
+ //
+ // Now it ought to be resource Data
+ //
+ if (!ResourceDirectoryEntry->u2.s.DataIsDirectory) {
+ ResourceDataEntry = (EFI_IMAGE_RESOURCE_DATA_ENTRY *) (Base + ResourceDirectoryEntry->u2.OffsetToData);
+ ImageContext->HiiResourceData = (EFI_PHYSICAL_ADDRESS) (UINTN) PeCoffLoaderImageAddress (ImageContext, ResourceDataEntry->OffsetToData);
+ break;
+ }
+ }
+ }
+
+ ResourceDirectoryEntry++;
+ }
+ }
+ }
+#endif
+
+#if defined (EFI_DEBUG_ITP_BREAK) && !defined (_CONSOLE)
+ AsmEfiSetBreakSupport ((UINTN)(ImageContext->ImageAddress));
+#endif
+
+ return Status;
+}
+
+EFI_STATUS
+EFIAPI
+PeCoffLoaderUnloadImage (
+ IN EFI_PEI_PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext
+ )
+/*++
+
+Routine Description:
+
+ Unload a PE/COFF image from memory
+
+Arguments:
+
+ ImageContext - Contains information on image to load into memory
+
+Returns:
+
+ EFI_SUCCESS
+
+--*/
+{
+#ifdef EFI_NT_EMULATOR
+ //
+ // Calling Win32 API free library
+ //
+ mPeCoffLoaderWinNtLoadAsDll->FreeLibrary (ImageContext->ModHandle);
+
+#endif
+
+ return EFI_SUCCESS;
+}
diff --git a/EDK/Foundation/Library/Pei/PeiLib/PeiLib.c b/EDK/Foundation/Library/Pei/PeiLib/PeiLib.c
new file mode 100644
index 0000000..772319f
--- /dev/null
+++ b/EDK/Foundation/Library/Pei/PeiLib/PeiLib.c
@@ -0,0 +1,714 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PeiLib.c
+
+Abstract:
+
+ PEI Library Functions
+
+--*/
+
+#include "TianoCommon.h"
+#include "PeiHob.h"
+#include "Pei.h"
+#include "PeiLib.h"
+#include "EfiCommonLib.h"
+
+VOID
+PeiCopyMem (
+ IN VOID *Destination,
+ IN VOID *Source,
+ IN UINTN Length
+ );
+
+VOID
+ZeroMem (
+ IN VOID *Buffer,
+ IN UINTN Size
+ )
+/*++
+
+Routine Description:
+
+ Set Buffer to zero for Size bytes.
+
+Arguments:
+
+ Buffer - Memory to set.
+
+ Size - Number of bytes to set
+
+Returns:
+
+ None
+
+--*/
+{
+ EfiCommonLibZeroMem (Buffer, Size);
+}
+
+VOID
+PeiCopyMem (
+ IN VOID *Destination,
+ IN VOID *Source,
+ IN UINTN Length
+ )
+/*++
+
+Routine Description:
+
+ Copy Length bytes from Source to Destination.
+
+Arguments:
+
+ Destination - Target of copy
+
+ Source - Place to copy from
+
+ Length - Number of bytes to copy
+
+Returns:
+
+ None
+
+--*/
+{
+ EfiCommonLibCopyMem (Destination, Source, Length);
+}
+
+VOID
+CopyMem (
+ IN VOID *Destination,
+ IN VOID *Source,
+ IN UINTN Length
+ )
+/*++
+
+Routine Description:
+
+ Copy Length bytes from Source to Destination.
+
+Arguments:
+
+ Destination - Target of copy
+
+ Source - Place to copy from
+
+ Length - Number of bytes to copy
+
+Returns:
+
+ None
+
+--*/
+{
+ EfiCommonLibCopyMem (Destination, Source, Length);
+}
+
+
+BOOLEAN
+CompareGuid (
+ IN EFI_GUID *Guid1,
+ IN EFI_GUID *Guid2
+ )
+/*++
+
+Routine Description:
+
+ Compares two GUIDs
+
+Arguments:
+
+ Guid1 - guid to compare
+ Guid2 - guid to compare
+
+Returns:
+ = TRUE if Guid1 == Guid2
+ = FALSE if Guid1 != Guid2
+
+--*/
+{
+ if ((((INT32 *) Guid1)[0] - ((INT32 *) Guid2)[0]) == 0) {
+ if ((((INT32 *) Guid1)[1] - ((INT32 *) Guid2)[1]) == 0) {
+ if ((((INT32 *) Guid1)[2] - ((INT32 *) Guid2)[2]) == 0) {
+ if ((((INT32 *) Guid1)[3] - ((INT32 *) Guid2)[3]) == 0) {
+ return TRUE;
+ }
+ }
+ }
+ }
+
+ return FALSE;
+}
+
+
+EFI_STATUS
+EFIAPI
+PeiLibPciCfgModify (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_PCI_CFG_PPI *PciCfg,
+ IN PEI_PCI_CFG_PPI_WIDTH Width,
+ IN UINT64 Address,
+ IN UINTN SetBits,
+ IN UINTN ClearBits
+ )
+/*++
+
+Routine Description:
+
+ PCI read-modify-write operations.
+
+ PIWG's PI specification replaces Inte's EFI Specification 1.10.
+ EFI_PEI_PCI_CFG_PPI defined in Inte's EFI Specification 1.10 is replaced by
+ EFI_PEI_PCI_CFG2_PPI in PI 1.0. "Modify" function in these two PPI are not
+ compatibile with each other.
+
+
+ For Framework code that make the following call:
+
+ PciCfg->Modify (
+ PeiServices,
+ PciCfg,
+ Width,
+ Address,
+ SetBits,
+ ClearBits
+ );
+ it will be updated to the following code which call this library API:
+ PeiLibPciCfgModify (
+ PeiServices,
+ PciCfg,
+ Width,
+ Address,
+ SetBits,
+ ClearBits
+ );
+
+ The
+
+Arguments:
+
+ PeiServices An indirect pointer to the PEI Services Table
+ published by the PEI Foundation.
+ PciCfg A pointer to the this pointer of EFI_PEI_PCI_CFG_PPI.
+ This parameter is unused as a place holder to make
+ the parameter list identical to PEI_PCI_CFG_PPI_RW.
+ Width The width of the access. Enumerated in bytes. Type
+ EFI_PEI_PCI_CFG_PPI_WIDTH is defined in Read().
+
+ Address The physical address of the access.
+
+ SetBits Points to value to bitwise-OR with the read configuration value.
+
+ The size of the value is determined by Width.
+
+ ClearBits Points to the value to negate and bitwise-AND with the read configuration value.
+ The size of the value is determined by Width.
+
+
+Returns:
+
+ EFI_SUCCESS The function completed successfully.
+
+ EFI_DEVICE_ERROR There was a problem with the transaction.
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_PEI_PCI_CFG2_PPI *PciCfg2;
+
+ Status = (*PeiServices)->LocatePpi (
+ PeiServices,
+ &gPeiPciCfg2PpiGuid,
+ 0,
+ NULL,
+ (VOID **) &PciCfg2
+ );
+ ASSERT_PEI_ERROR (PeiServices, Status);
+
+ Status = PciCfg2->Modify (
+ (CONST EFI_PEI_SERVICES **) PeiServices,
+ PciCfg2,
+ (EFI_PEI_PCI_CFG_PPI_WIDTH) Width,
+ Address,
+ &SetBits,
+ &ClearBits
+ );
+
+ return Status;
+}
+
+//;;## ...AMI_OVERRIDE... Support PI1.x
+#if (PI_SPECIFICATION_VERSION >= 0x00010000)
+
+VOID *
+EFIAPI
+ScanGuid (
+ IN VOID *Buffer,
+ IN UINTN Length,
+ IN EFI_GUID *Guid
+ )
+/*++
+
+Routine Description:
+
+ Scans a target buffer for a GUID, and returns a pointer to the matching GUID
+ in the target buffer.
+
+ This function searches target the buffer specified by Buffer and Length from
+ the lowest address to the highest address at 128-bit increments for the 128-bit
+ GUID value that matches Guid. If a match is found, then a pointer to the matching
+ GUID in the target buffer is returned. If no match is found, then NULL is returned.
+ If Length is 0, then NULL is returned.
+ If Length > 0 and Buffer is NULL, then ASSERT().
+ If Buffer is not aligned on a 32-bit boundary, then ASSERT().
+ If Length is not aligned on a 128-bit boundary, then ASSERT().
+ If Length is greater than (EFI_MAX_ADDRESS ?Buffer + 1), then ASSERT().
+
+Arguments:
+
+ Buffer - Pointer to the target buffer to scan.
+ Length - Number of bytes in Buffer to scan.
+ Guid - Value to search for in the target buffer.
+
+Returns:
+ A pointer to the matching Guid in the target buffer or NULL otherwise.
+
+--*/
+{
+ EFI_GUID *GuidPtr;
+ EFI_PEI_SERVICES **PeiServices;
+
+ PeiServices = GetPeiServicesTablePointer();
+ PEI_ASSERT(PeiServices, (((UINTN)Buffer & (sizeof (Guid->Data1) - 1)) == 0));
+ PEI_ASSERT(PeiServices, (Length <= (EFI_MAX_ADDRESS - (UINTN)Buffer + 1)));
+ PEI_ASSERT(PeiServices, ((Length & (sizeof (*GuidPtr) - 1)) == 0));
+
+ GuidPtr = (EFI_GUID*)Buffer;
+ Buffer = GuidPtr + Length / sizeof (*GuidPtr);
+ while (GuidPtr < (EFI_GUID*)Buffer) {
+ if (CompareGuid (GuidPtr, Guid)) {
+ return (VOID*)GuidPtr;
+ }
+ GuidPtr++;
+ }
+ return NULL;
+}
+
+
+VOID *
+EFIAPI
+InvalidateInstructionCacheRange (
+ IN VOID *Address,
+ IN UINTN Length
+ )
+/*++
+
+Routine Description:
+
+ Invalidates a range of instruction cache lines in the cache coherency domain
+ of the calling CPU.
+
+ Invalidates the instruction cache lines specified by Address and Length. If
+ Address is not aligned on a cache line boundary, then entire instruction
+ cache line containing Address is invalidated. If Address + Length is not
+ aligned on a cache line boundary, then the entire instruction cache line
+ containing Address + Length -1 is invalidated. This function may choose to
+ invalidate the entire instruction cache if that is more efficient than
+ invalidating the specified range. If Length is 0, the no instruction cache
+ lines are invalidated. Address is returned.
+
+ If Length is greater than (EFI_MAX_ADDRESS - Address + 1), then ASSERT().
+
+Arguments:
+
+ Address - The base address of the instruction cache lines to
+ invalidate. If the CPU is in a physical addressing mode, then
+ Address is a physical address. If the CPU is in a virtual
+ addressing mode, then Address is a virtual address.
+
+ Length - The number of bytes to invalidate from the instruction cache.
+
+ Returns:
+ Address
+
+**/
+{
+ PEI_ASSERT(GetPeiServicesTablePointer() , (Length <= EFI_MAX_ADDRESS - (UINTN)Address + 1));
+ return Address;
+}
+
+
+EFI_STATUS
+EFIAPI
+PeiLibFfsFindNextVolume (
+ IN UINTN Instance,
+ IN OUT EFI_PEI_FV_HANDLE *VolumeHandle
+ )
+/*++
+
+Routine Description:
+
+ The wrapper of Pei Core Service function FfsFindNextVolume.
+
+Arguments:
+
+ Instance - The Fv Volume Instance.
+ VolumeHandle - Pointer to the current Fv Volume to search.
+
+Returns:
+ EFI_STATUS
+
+--*/
+
+{
+ EFI_PEI_SERVICES **PeiServices;
+
+ PeiServices = GetPeiServicesTablePointer();
+ return (*PeiServices)->FfsFindNextVolume (PeiServices, Instance, VolumeHandle);
+}
+
+EFI_STATUS
+EFIAPI
+PeiLibFfsFindNextFile (
+ IN EFI_FV_FILETYPE SearchType,
+ IN EFI_PEI_FV_HANDLE FvHandle,
+ IN OUT EFI_PEI_FILE_HANDLE *FileHandle
+ )
+/*++
+
+Routine Description:
+
+ The wrapper of Pei Core Service function FfsFindNextFile.
+
+Arguments:
+
+ SearchType - Filter to find only file of this type.
+ FvHandle - Pointer to the current FV to search.
+ FileHandle - Pointer to the file matching SearchType in FwVolHeader.
+ - NULL if file not found
+
+Returns:
+ EFI_STATUS
+
+--*/
+{
+ EFI_PEI_SERVICES **PeiServices;
+
+ PeiServices = GetPeiServicesTablePointer();
+ return (*PeiServices)->FfsFindNextFile (PeiServices, SearchType, FvHandle, FileHandle);
+}
+
+
+EFI_STATUS
+EFIAPI
+PeiLibFfsFindFileByName (
+ IN EFI_GUID *FileName,
+ IN EFI_PEI_FV_HANDLE VolumeHandle,
+ OUT EFI_PEI_FILE_HANDLE *FileHandle
+ )
+/*++
+
+Routine Description:
+
+ The wrapper of Pei Core Service function FfsFindFileByName.
+
+Arguments:
+
+ FileName - File name to search.
+ VolumeHandle - The current FV to search.
+ FileHandle - Pointer to the file matching name in VolumeHandle.
+ - NULL if file not found
+
+Returns:
+ EFI_STATUS
+
+--*/
+{
+ EFI_PEI_SERVICES **PeiServices;
+
+ PeiServices = GetPeiServicesTablePointer();
+ return (*PeiServices)->FfsFindFileByName (FileName, VolumeHandle, FileHandle);
+}
+
+
+
+EFI_STATUS
+EFIAPI
+PeiLibFfsFindSectionData (
+ IN EFI_SECTION_TYPE SectionType,
+ IN EFI_FFS_FILE_HEADER *FfsFileHeader,
+ IN OUT VOID **SectionData
+ )
+/*++
+
+Routine Description:
+
+ The wrapper of Pei Core Service function FfsFindSectionData.
+
+Arguments:
+
+ SearchType - Filter to find only sections of this type.
+ FileHandle - Pointer to the current file to search.
+ SectionData - Pointer to the Section matching SectionType in FfsFileHeader.
+ - NULL if section not found
+
+Returns:
+ EFI_STATUS
+--*/
+{
+ EFI_PEI_SERVICES **PeiServices;
+
+ PeiServices = GetPeiServicesTablePointer();
+ return (*PeiServices)->FfsFindSectionData (PeiServices, SectionType, (EFI_PEI_FILE_HANDLE)FfsFileHeader, SectionData);
+}
+
+EFI_STATUS
+EFIAPI
+PeiLibFfsGetVolumeInfo (
+ IN EFI_PEI_FV_HANDLE VolumeHandle,
+ OUT EFI_FV_INFO *VolumeInfo
+ )
+/*++
+
+Routine Description:
+
+ The wrapper of Pei Core Service function FfsGetVolumeInfo.
+
+Arguments:
+
+ VolumeHandle - The handle to Fv Volume.
+ VolumeInfo - The pointer to volume information.
+
+Returns:
+ EFI_STATUS
+--*/
+{
+ EFI_PEI_SERVICES **PeiServices;
+
+ PeiServices = GetPeiServicesTablePointer();
+ return (*PeiServices)->FfsGetVolumeInfo (VolumeHandle, VolumeInfo);
+}
+
+
+
+VOID
+EFIAPI
+BuildFvHob (
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length
+ )
+/*++
+
+Routine Description:
+
+ Build FvHob.
+
+Arguments:
+
+ BaseAddress - Fv base address.
+ Length - Fv Length.
+
+Returns:
+ NONE.
+--*/
+{
+
+ EFI_STATUS Status;
+ EFI_HOB_FIRMWARE_VOLUME *Hob;
+ EFI_PEI_SERVICES **PeiServices;
+
+ PeiServices = GetPeiServicesTablePointer();
+
+ //
+ // Check FV Signature
+ //
+ PEI_ASSERT (PeiServices, ((EFI_FIRMWARE_VOLUME_HEADER*)((UINTN)BaseAddress))->Signature == EFI_FVH_SIGNATURE);
+
+
+ Status = (*PeiServices)->CreateHob (
+ PeiServices,
+ EFI_HOB_TYPE_FV,
+ sizeof (EFI_HOB_FIRMWARE_VOLUME),
+ &Hob
+ );
+ Hob->BaseAddress = BaseAddress;
+ Hob->Length = Length;
+}
+
+VOID
+EFIAPI
+BuildFvHob2 (
+ IN EFI_PHYSICAL_ADDRESS BaseAddress,
+ IN UINT64 Length,
+ IN EFI_GUID *FvNameGuid,
+ IN EFI_GUID *FileNameGuid
+ )
+/*++
+
+Routine Description:
+
+ Build FvHob2.
+
+Arguments:
+
+ BaseAddress - Fv base address.
+ Length - Fv length.
+ FvNameGuid - Fv name.
+ FileNameGuid - File name which contians encapsulated Fv.
+
+Returns:
+ NONE.
+--*/
+{
+
+ EFI_STATUS Status;
+ EFI_HOB_FIRMWARE_VOLUME2 *Hob;
+ EFI_PEI_SERVICES **PeiServices;
+
+ PeiServices = GetPeiServicesTablePointer();
+
+ //
+ // Check FV Signature
+ //
+ PEI_ASSERT (PeiServices, ((EFI_FIRMWARE_VOLUME_HEADER*)((UINTN)BaseAddress))->Signature == EFI_FVH_SIGNATURE);
+
+ Status = (*PeiServices)->CreateHob (
+ PeiServices,
+ EFI_HOB_TYPE_FV2,
+ sizeof (EFI_HOB_FIRMWARE_VOLUME2),
+ &Hob
+ );
+ Hob->BaseAddress = BaseAddress;
+ Hob->Length = Length;
+ CopyMem ((VOID*)&Hob->FvName, FvNameGuid, sizeof(EFI_GUID));
+ CopyMem ((VOID*)&Hob->FileName, FileNameGuid, sizeof(EFI_GUID));
+}
+
+EFI_STATUS
+EFIAPI
+PeiServicesLocatePpi (
+ IN EFI_GUID *Guid,
+ IN UINTN Instance,
+ IN OUT EFI_PEI_PPI_DESCRIPTOR **PpiDescriptor,
+ IN OUT VOID **Ppi
+ )
+/*++
+
+Routine Description:
+
+ The wrapper of Pei Core Service function LocatePpi.
+
+Arguments:
+
+ Guid - Pointer to GUID of the PPI.
+ Instance - Instance Number to discover.
+ PpiDescriptor - Pointer to reference the found descriptor. If not NULL,
+ returns a pointer to the descriptor (includes flags, etc)
+ Ppi - Pointer to reference the found PPI
+
+Returns:
+
+ Status - EFI_SUCCESS if the PPI is in the database
+ EFI_NOT_FOUND if the PPI is not in the database
+--*/
+{
+ EFI_PEI_SERVICES **PeiServices;
+
+ PeiServices = GetPeiServicesTablePointer();
+ return (*PeiServices)->LocatePpi (PeiServices, Guid, Instance, PpiDescriptor, Ppi);
+}
+
+
+VOID
+EFIAPI
+BuildGuidDataHob (
+ IN EFI_GUID *Guid,
+ IN VOID *Data,
+ IN UINTN DataLength
+ )
+/*++
+
+Routine Description:
+
+ Build Guid data Hob.
+
+Arguments:
+
+ Guid - guid to build data hob.
+ Data - data to build data hob.
+ DataLength - the length of data.
+
+Returns:
+ NONE
+--*/
+{
+ VOID *HobData;
+ EFI_HOB_GUID_TYPE *Hob;
+ EFI_PEI_SERVICES **PeiServices;
+
+ PeiServices = GetPeiServicesTablePointer();
+ (*PeiServices)->CreateHob (
+ PeiServices,
+ EFI_HOB_TYPE_GUID_EXTENSION,
+ (UINT16) (sizeof (EFI_HOB_GUID_TYPE) + DataLength),
+ &Hob
+ );
+ CopyMem ((VOID*)&Hob->Name, (VOID*)Guid, sizeof(EFI_GUID));
+
+ HobData = Hob + 1;
+
+ CopyMem (HobData, Data, DataLength);
+}
+
+
+VOID *
+EFIAPI
+AllocatePages (
+ IN UINTN Pages
+ )
+/*++
+
+Routine Description:
+
+ Allocate Memory.
+
+Arguments:
+
+ Pages - Pages to allocate.
+
+Returns:
+ = Address if successful to allocate memory.
+ = NULL if fail to allocate memory.
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_PHYSICAL_ADDRESS Memory;
+ EFI_PEI_SERVICES **PeiServices;
+
+ if (Pages == 0) {
+ return NULL;
+ }
+
+ PeiServices = GetPeiServicesTablePointer();
+ Status = (*PeiServices)->AllocatePages (PeiServices, EfiBootServicesData, Pages, &Memory);
+ if (EFI_ERROR (Status)) {
+ Memory = 0;
+ }
+ return (VOID *) (UINTN) Memory;
+
+}
+
+#endif
diff --git a/EDK/Foundation/Library/Pei/PeiLib/PeiLib.cif b/EDK/Foundation/Library/Pei/PeiLib/PeiLib.cif
new file mode 100644
index 0000000..c0d2d20
--- /dev/null
+++ b/EDK/Foundation/Library/Pei/PeiLib/PeiLib.cif
@@ -0,0 +1,23 @@
+<component>
+ name = "PeiLib"
+ category = ModulePart
+ LocalRoot = "EDK\Foundation\Library\Pei\PeiLib\"
+ RefName = "PeiLib"
+[files]
+"PeiLib.sdl"
+"PeiLib.mak"
+"Debug.c"
+"Decompress.c"
+"FindFv.c"
+"PeCoffLoader.c"
+"PeiLib.c"
+"Perf.c"
+"Hob\Hob.c"
+"Print\Print.c"
+"Print\Print.h"
+"PeiLib.inf"
+[parts]
+"PeiLibIA32"
+"PeiLibx64"
+"PeiLibIPF"
+<endComponent>
diff --git a/EDK/Foundation/Library/Pei/PeiLib/PeiLib.inf b/EDK/Foundation/Library/Pei/PeiLib/PeiLib.inf
new file mode 100644
index 0000000..d1ee5d5
--- /dev/null
+++ b/EDK/Foundation/Library/Pei/PeiLib/PeiLib.inf
@@ -0,0 +1,95 @@
+#/*++
+#
+# Copyright (c) 2004 - 2006, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# PeiLib.inf
+#
+# Abstract:
+#
+# Component description file for the PEI library.
+#
+#--*/
+
+[defines]
+BASE_NAME = PeiLib
+COMPONENT_TYPE = LIBRARY
+
+[sources.common]
+ PeiLib.c
+ PeCoffLoader.c
+ Decompress.c
+ Debug.c
+ Hob\Hob.c
+ perf.c
+ print\print.c
+ print\print.h
+ FindFv.c
+
+[sources.ia32]
+# ia32\Math.c
+ ia32\PeCoffLoaderEx.c
+ ia32\PeCoffLoaderEx.h
+ ia32\PerformancePrimitives.c
+ ia32\Processor.c
+ ia32\ProcessorAsms.Asm
+ ia32\efijump.h
+
+[sources.x64]
+ x64\PeCoffLoaderEx.c
+ x64\PeCoffLoaderEx.h
+ x64\PerformancePrimitives.c
+ x64\Processor.c
+ x64\ProcessorAsms.Asm
+ x64\efijump.h
+
+[sources.ipf]
+# ipf\Math.c
+ ipf\PeCoffLoaderEx.c
+ ipf\PeCoffLoaderEx.h
+ ipf\PerformancePrimitives.s
+ ipf\Processor.c
+ ipf\EfiJump.h
+ ipf\SetJmp.s
+ ipf\Asm.h
+ ipf\PioFlush.s
+ ipf\SwitchStack.s
+ ipf\Ia_64Gen.h
+
+[libraries.common]
+ EdkGuidLib
+ EfiCommonLib
+ EdkFrameworkPpiLib
+
+[libraries.ia32]
+ CpuIA32Lib
+
+[libraries.x64]
+ CpuIA32Lib
+[includes.common]
+ $(EDK_SOURCE)\Sample\Platform\Nt32
+ $(EDK_SOURCE)\Foundation
+ $(EDK_SOURCE)\Foundation\Framework
+ $(EDK_SOURCE)\Foundation\Efi
+ .
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)\Foundation\Include\Pei
+ $(EDK_SOURCE)\Foundation\Library\Pei\Include
+ $(EDK_SOURCE)\Foundation\Core\Pei\Include
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+ $(EDK_SOURCE)\Foundation\Cpu\Pentium\Include
+
+[nmake.common]
+ C_STD_INCLUDE=
diff --git a/EDK/Foundation/Library/Pei/PeiLib/PeiLib.mak b/EDK/Foundation/Library/Pei/PeiLib/PeiLib.mak
new file mode 100644
index 0000000..5561761
--- /dev/null
+++ b/EDK/Foundation/Library/Pei/PeiLib/PeiLib.mak
@@ -0,0 +1,141 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/PeiLib/PeiLib.mak 2 2/24/12 5:44a Jeffch $
+#
+# $Revision: 2 $
+#
+# $Date: 2/24/12 5:44a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/PeiLib/PeiLib.mak $
+#
+# 2 2/24/12 5:44a Jeffch
+#
+# 1 1/20/12 4:11a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 9/27/11 6:32a Wesleychen
+# Intel EDK initially releases.
+#
+# 3 9/20/10 10:03p Iminglin
+# Libary for IA32 and X64
+#
+# 2 9/02/09 3:58a Iminglin
+# EIP24919
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: PeiLib.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+$(PEILIB) : PeiLib
+
+PEI_LIB_OBJECTS=\
+$$(BUILD_DIR)\$(PeiLib_DIR)\Debug.obj\
+$$(BUILD_DIR)\$(PeiLib_DIR)\Decompress.obj\
+$$(BUILD_DIR)\$(PeiLib_DIR)\FindFv.obj\
+$$(BUILD_DIR)\$(PeiLib_DIR)\PeCoffLoader.obj\
+$$(BUILD_DIR)\$(PeiLib_DIR)\PeiLib.obj\
+$$(BUILD_DIR)\$(PeiLib_DIR)\Perf.obj\
+$$(BUILD_DIR)\$(PeiLib_DIR)\Hob\Hob.obj\
+$$(BUILD_DIR)\$(PeiLib_DIR)\Print\Print.obj
+
+PEI_LIB_IA32_OBJECTS=\
+$$(BUILD_DIR)\$(PeiLib_DIR)\IA32\PeCoffLoaderEx.obj\
+$$(BUILD_DIR)\$(PeiLib_DIR)\IA32\PerformancePrimitives.obj\
+$$(BUILD_DIR)\$(PeiLib_DIR)\IA32\Processor.obj\
+$$(BUILD_DIR)\$(PeiLib_DIR)\IA32\ProcessorAsms.obj
+
+PEI_LIB_x64_OBJECTS=\
+$$(BUILD_DIR)\$(PeiLib_DIR)\x64\PeCoffLoaderEx.obj\
+$$(BUILD_DIR)\$(PeiLib_DIR)\x64\PerformancePrimitives.obj\
+$$(BUILD_DIR)\$(PeiLib_DIR)\x64\Processor.obj\
+$$(BUILD_DIR)\$(PeiLib_DIR)\x64\ProcessorAsms.obj
+
+PEI_LIB_IPF_OBJECTS=\
+$$(BUILD_DIR)\$(PeiLib_DIR)\Ipf\PeCoffLoaderEx.obj\
+$$(BUILD_DIR)\$(PeiLib_DIR)\Ipf\processor.obj\
+$$(BUILD_DIR)\$(PeiLib_DIR)\Ipf\PerformancePrimitives.obj\
+$$(BUILD_DIR)\$(PeiLib_DIR)\Ipf\pioflush.obj\
+$$(BUILD_DIR)\$(PeiLib_DIR)\Ipf\setjmp.obj\
+$$(BUILD_DIR)\$(PeiLib_DIR)\Ipf\SwitchStack.obj
+
+!IF "$(PROCESSOR)"=="IA32"
+PEI_LIB_OBJECTS =$(PEI_LIB_OBJECTS) $(PEI_LIB_IA32_OBJECTS)
+!ELSEIF "$(PROCESSOR)"=="x64"
+PEI_LIB_PEI_OBJECTS =$(PEI_LIB_OBJECTS) $(PEI_LIB_IA32_OBJECTS)
+PEI_LIB_DXE_OBJECTS =$(PEI_LIB_OBJECTS) $(PEI_LIB_x64_OBJECTS)
+!ELSEIF "$(PROCESSOR)"=="IPF"
+PEI_LIB_OBJECTS =$(PEI_LIB_OBJECTS) $(PEI_LIB_IPF_OBJECTS)
+!ENDIF
+
+!IF "$(PROCESSOR)"=="x64"
+PEI_LIB_PORCESSOR_PEI_CIF=$(PeiLib_DIR)\$(@B)IA32.cif
+PEI_LIB_PORCESSOR_DXE_CIF=$(PeiLib_DIR)\$(@B)$(PROCESSOR).cif
+!ELSE
+PEI_LIB_PORCESSOR_CIF=$(PeiLib_DIR)\$(@B)$(PROCESSOR).cif
+!ENDIF
+
+$(BUILD_DIR)\PeiLib.lib : PeiLib
+
+PeiLib : $(BUILD_DIR)\PeiLib.mak PeiLibBin
+
+!IF "$(PROCESSOR)"=="x64"
+$(BUILD_DIR)\PeiLib.mak : $(PeiLib_DIR)\$(@B).cif $(PeiLib_DIR)\$(@B).mak $(BUILD_RULES) $(PEI_LIB_PORCESSOR_PEI_CIF) $(PEI_LIB_PORCESSOR_DXE_CIF)
+ $(CIF2MAK) $(PeiLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS) $(PEI_LIB_PORCESSOR_PEI_CIF) $(PEI_LIB_PORCESSOR_DXE_CIF)
+!ELSE
+$(BUILD_DIR)\PeiLib.mak : $(PeiLib_DIR)\$(@B).cif $(PeiLib_DIR)\$(@B).mak $(BUILD_RULES) $(PEI_LIB_PORCESSOR_CIF)
+ $(CIF2MAK) $(PeiLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS) $(PEI_LIB_PORCESSOR_CIF)
+!ENDIF
+
+!IF "$(PROCESSOR)"!="IPF"
+PeiLibBin : $(CPUIA32LIB)
+!ENDIF
+
+PeiLibBin : $(EDKGUIDLIB) $(EFICOMMONLIB) $(EDKFRAMEWORKPPILIB)
+!IF "$(PROCESSOR)"=="x64"
+ $(MAKE) /$(MAKEFLAGS) $(EDK_DEFAULTS)\
+ /f $(BUILD_DIR)\PeiLib.mak all\
+ "MY_INCLUDES=$(EDK_INCLUDES)"\
+ TYPE=LIBRARY "OBJECTS=$(PEI_LIB_DXE_OBJECTS)"
+ $(MAKE) /$(MAKEFLAGS) $(EDK_DEFAULTS) BUILD_DIR=$(BUILD_DIR)\IA32\
+ /f $(BUILD_DIR)\PeiLib.mak all\
+ "MY_INCLUDES=$(EDK_INCLUDES)"\
+ TYPE=PEI_LIBRARY "OBJECTS=$(PEI_LIB_PEI_OBJECTS)"
+!ELSE
+ $(MAKE) /$(MAKEFLAGS) $(EDK_DEFAULTS)\
+ /f $(BUILD_DIR)\PeiLib.mak all\
+ "MY_INCLUDES=$(EDK_INCLUDES)"\
+ TYPE=PEI_LIBRARY "OBJECTS=$(PEI_LIB_OBJECTS)"
+!ENDIF
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#********************************************************************** \ No newline at end of file
diff --git a/EDK/Foundation/Library/Pei/PeiLib/PeiLib.sdl b/EDK/Foundation/Library/Pei/PeiLib/PeiLib.sdl
new file mode 100644
index 0000000..ce069ca
--- /dev/null
+++ b/EDK/Foundation/Library/Pei/PeiLib/PeiLib.sdl
@@ -0,0 +1,31 @@
+TOKEN
+ Name = "PeiLib_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable PeiLib support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "PEILIB"
+ Value = "$$(LIB_BUILD_DIR)\PeiLib.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "PeiLib_DIR"
+End
+
+MODULE
+ Help = "Includes PeiLib.mak to Project"
+ File = "PeiLib.mak"
+End
+
+ELINK
+ Name = "/I$(EDK_SOURCE)\Foundation\Library\Pei\PeiLib\$(PROCESSOR)"
+ Parent = "EDK_INCLUDES"
+ InvokeOrder = AfterParent
+End
diff --git a/EDK/Foundation/Library/Pei/PeiLib/PeiLibIA32.cif b/EDK/Foundation/Library/Pei/PeiLib/PeiLibIA32.cif
new file mode 100644
index 0000000..ab7d8c7
--- /dev/null
+++ b/EDK/Foundation/Library/Pei/PeiLib/PeiLibIA32.cif
@@ -0,0 +1,14 @@
+<component>
+ name = "PeiLibIA32"
+ category = ModulePart
+ LocalRoot = "EDK\Foundation\Library\Pei\PeiLib\"
+ RefName = "PeiLibIA32"
+[files]
+"ia32\PeCoffLoaderEx.c"
+"ia32\PerformancePrimitives.c"
+"ia32\Processor.c"
+"ia32\efijump.h"
+"ia32\PeCoffLoaderEx.h"
+"ia32\ProcessorAsms.Asm"
+"ia32\PeiServicePointer.c"
+<endComponent>
diff --git a/EDK/Foundation/Library/Pei/PeiLib/PeiLibIPF.cif b/EDK/Foundation/Library/Pei/PeiLib/PeiLibIPF.cif
new file mode 100644
index 0000000..d08a710
--- /dev/null
+++ b/EDK/Foundation/Library/Pei/PeiLib/PeiLibIPF.cif
@@ -0,0 +1,19 @@
+<component>
+ name = "PeiLibIPF"
+ category = ModulePart
+ LocalRoot = "EDK\Foundation\Library\Pei\PeiLib\"
+ RefName = "PeiLibIPF"
+[files]
+"Ipf\PeCoffLoaderEx.c"
+"Ipf\processor.c"
+"Ipf\asm.h"
+"Ipf\efijump.h"
+"Ipf\ia_64gen.h"
+"Ipf\PeCoffLoaderEx.h"
+"Ipf\PerformancePrimitives.s"
+"Ipf\pioflush.s"
+"Ipf\setjmp.s"
+"Ipf\SwitchStack.s"
+"Ipf\PeiServicePointer.c"
+"Ipf\math.c"
+<endComponent>
diff --git a/EDK/Foundation/Library/Pei/PeiLib/PeiLibx64.cif b/EDK/Foundation/Library/Pei/PeiLib/PeiLibx64.cif
new file mode 100644
index 0000000..259109f
--- /dev/null
+++ b/EDK/Foundation/Library/Pei/PeiLib/PeiLibx64.cif
@@ -0,0 +1,15 @@
+<component>
+ name = "PeiLibx64"
+ category = ModulePart
+ LocalRoot = "EDK\Foundation\Library\Pei\PeiLib\"
+ RefName = "PeiLibx64"
+[files]
+"x64\PeCoffLoaderEx.c"
+"x64\PerformancePrimitives.c"
+"x64\Processor.c"
+"x64\EfiJump.h"
+"x64\PeCoffLoaderEx.h"
+"x64\ProcessorAsms.Asm"
+"x64\PeiServicePointer.c"
+"x64\Math.c"
+<endComponent>
diff --git a/EDK/Foundation/Library/Pei/PeiLib/Perf.c b/EDK/Foundation/Library/Pei/PeiLib/Perf.c
new file mode 100644
index 0000000..86b8d62
--- /dev/null
+++ b/EDK/Foundation/Library/Pei/PeiLib/Perf.c
@@ -0,0 +1,362 @@
+/*++
+
+Copyright (c) 2004 - 2012, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Perf.c
+
+Abstract:
+
+ Support for FPDT performance structures.
+
+--*/
+
+#include "Tiano.h"
+#include "Pei.h"
+#include "PeiLib.h"
+#include "PeiHob.h"
+#include "CpuIA32.h"
+#include "EfiCommonLib.h"
+
+#include EFI_GUID_DEFINITION (PeiPerformanceHob)
+
+#define MSR_PLATFORM_INFO 0xce
+#define MAX_NON_TURBO_RATIO_OFFSET 8
+#define MAX_NON_TURBO_RATIO_MASK 0xff
+#define LOCAL_APIC_BASE 0xfee00000
+#define APIC_ID_REGISTER 0x20
+#define MSR_EXT_XAPIC_LOGICAL_APIC_ID 0x802
+#define MSR_XAPIC_BASE 0x1b
+#define MSR_XAPIC_BASE_MASK 0x0c00
+
+#define MAX_FIRMWARE_PERFORMANCE_ENTRIES 80
+
+//
+// Prototype functions
+//
+UINT64
+IA32API
+EfiReadMsr (
+ IN UINT32 Index
+ );
+
+UINT64 GetTimeInNanoSec (
+ UINT64 Ticker
+ )
+/*++
+
+Routine Description:
+
+ Internal routine to convert TSC value into nano second value
+
+Arguments:
+
+ Ticker - OPTIONAL. TSC value supplied by caller function
+
+Returns:
+
+ UINT64 - returns calculated timer value
+
+--*/
+{
+ UINT64 Tick, pi;
+ UINT8 Ratio;
+
+ if(Ticker != 0){
+ Tick = Ticker;
+ } else {
+ Tick = EfiReadTsc();
+ }
+
+ pi = EfiReadMsr(MSR_PLATFORM_INFO);
+ Ratio = (UINT8)( ((UINT32)(UINTN)RShiftU64(pi, MAX_NON_TURBO_RATIO_OFFSET)) & MAX_NON_TURBO_RATIO_MASK);
+
+ return (UINT64)DivU64x32(MultU64x32(Tick, 10), (UINTN)(Ratio), NULL);
+}
+
+
+UINT32 GetApicId (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Internal routine to retrieve current APIC Id
+
+Arguments:
+
+ None
+
+Returns:
+
+ UINT32 - returns Apic Id value
+
+--*/
+{
+ BOOLEAN x2ApicEnabled;
+ UINT32 ApicId;
+
+ x2ApicEnabled = (BOOLEAN)(((EfiReadMsr (MSR_XAPIC_BASE)) & (MSR_XAPIC_BASE_MASK)) == MSR_XAPIC_BASE_MASK);
+ if (x2ApicEnabled) {
+ ApicId = (UINT32) EfiReadMsr (MSR_EXT_XAPIC_LOGICAL_APIC_ID);
+ } else {
+ ApicId = (UINT8) (*(volatile UINT32 *) (UINTN) (LOCAL_APIC_BASE + APIC_ID_REGISTER) >> 24);
+ }
+
+ return ApicId;
+}
+
+VOID
+PeiPerfMeasureEx (
+ EFI_PEI_SERVICES **PeiServices,
+ IN UINT16 *Token,
+ IN EFI_FFS_FILE_HEADER *FileHeader,
+ IN UINT16 Identifier,
+ IN BOOLEAN EntryExit,
+ IN UINT64 Value
+ )
+/*++
+
+Routine Description:
+
+ Log an extended timestamp value.
+
+Arguments:
+
+ PeiServices - Pointer to the PEI Core Services table
+
+ Token - Pointer to Token Name
+
+ FileHeader - Pointer to the file header
+
+ Identifier - Identifier of the record
+
+ EntryExit - Indicates start or stop measurement
+
+ Value - The TSC value
+
+Returns:
+
+ None
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_PEI_PPI_DESCRIPTOR *PerfHobDescriptor;
+ PEI_FIRMWARE_PERFORMANCE_HOB *FirmwarePerformanceHob;
+ PEI_GUID_EVENT_REC *PeiGuidRec;
+ //
+ // Locate the Pei Performance Log Hob.
+ //
+ Status = (*PeiServices)->LocatePpi (
+ PeiServices,
+ &gPeiFirmwarePerformanceGuid,
+ 0,
+ &PerfHobDescriptor,
+ NULL
+ );
+ if (!EFI_ERROR(Status)) {
+ FirmwarePerformanceHob = (PEI_FIRMWARE_PERFORMANCE_HOB *)(((UINT8 *)(PerfHobDescriptor)) -
+ ((sizeof(PEI_GUID_EVENT_REC) * (MAX_FIRMWARE_PERFORMANCE_ENTRIES-1))
+ + sizeof(PEI_FIRMWARE_PERFORMANCE_HOB)
+ )
+ );
+
+ //
+ // return if performance buffer has filled up
+ //
+ if (FirmwarePerformanceHob->NumberOfEntries >= MAX_FIRMWARE_PERFORMANCE_ENTRIES) {
+ return;
+ }
+
+ PeiGuidRec = &(FirmwarePerformanceHob->GuidEventRecord[FirmwarePerformanceHob->NumberOfEntries]);
+ (*PeiServices)->SetMem (PeiGuidRec, sizeof(PEI_GUID_EVENT_REC), 0);
+
+ //
+ // Get the GUID name
+ //
+ if (FileHeader != NULL) {
+ PeiGuidRec->Guid = FileHeader->Name;
+ }
+
+ //
+ // Record the time stamp nanosec value.
+ //
+ PeiGuidRec->Timestamp = GetTimeInNanoSec(Value);
+
+ //
+ // Copy the progress ID
+ //
+ PeiGuidRec->ProgressID = Identifier;
+
+ //
+ // Record the APIC Id
+ //
+ PeiGuidRec->ApicID = GetApicId();
+
+ //
+ // Increment the number of valid log entries.
+ //
+ FirmwarePerformanceHob->NumberOfEntries++;
+ }
+
+ return;
+}
+
+VOID
+PeiPerfMeasure (
+ EFI_PEI_SERVICES **PeiServices,
+ IN UINT16 *Token,
+ IN EFI_FFS_FILE_HEADER *FileHeader,
+ IN BOOLEAN EntryExit,
+ IN UINT64 Value
+ )
+/*++
+
+Routine Description:
+
+ Log a timestamp count.
+
+Arguments:
+
+ PeiServices - Pointer to the PEI Core Services table
+
+ Token - Pointer to Token Name
+
+ FileHeader - Pointer to the file header
+
+ EntryExit - Indicates start or stop measurement
+
+ Value - The start time or the stop time
+
+Returns:
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_HOB_GUID_TYPE *Hob;
+ PEI_FIRMWARE_PERFORMANCE_HOB *FirmwarePerformanceHob;
+ EFI_PEI_PPI_DESCRIPTOR *PerfHobDescriptor;
+ PEI_GUID_EVENT_REC *PeiGuidRec;
+ //
+ // Locate the Pei Performance Log Hob.
+ //
+ Status = (*PeiServices)->LocatePpi (
+ PeiServices,
+ &gPeiFirmwarePerformanceGuid,
+ 0,
+ &PerfHobDescriptor,
+ NULL
+ );
+
+ //
+ // If the Performance Hob was not found, build and install one.
+ //
+ if (EFI_ERROR(Status)) {
+ Status = PeiBuildHobGuid (
+ PeiServices,
+ &gPeiFirmwarePerformanceGuid,
+ (sizeof(PEI_FIRMWARE_PERFORMANCE_HOB) +
+ ((MAX_FIRMWARE_PERFORMANCE_ENTRIES-1) *
+ sizeof(PEI_GUID_EVENT_REC)) +
+ sizeof(EFI_PEI_PPI_DESCRIPTOR)
+ ),
+ &Hob
+ );
+ ASSERT_PEI_ERROR(PeiServices, Status);
+
+ FirmwarePerformanceHob = (PEI_FIRMWARE_PERFORMANCE_HOB *)(Hob+1);
+ FirmwarePerformanceHob->NumberOfEntries = 0;
+ FirmwarePerformanceHob->Reserved = 0;
+
+ PerfHobDescriptor = (EFI_PEI_PPI_DESCRIPTOR *)((UINT8 *)(FirmwarePerformanceHob+1) +
+ (sizeof(PEI_GUID_EVENT_REC) *
+ (MAX_FIRMWARE_PERFORMANCE_ENTRIES-1)
+ )
+ );
+ PerfHobDescriptor->Flags = (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST);
+ PerfHobDescriptor->Guid = &gPeiFirmwarePerformanceGuid;
+ PerfHobDescriptor->Ppi = NULL;
+
+ (*PeiServices)->InstallPpi (PeiServices, PerfHobDescriptor);
+ ASSERT_PEI_ERROR(PeiServices, Status);
+ }
+
+ FirmwarePerformanceHob = (PEI_FIRMWARE_PERFORMANCE_HOB *)(((UINT8 *)(PerfHobDescriptor)) -
+ ((sizeof(PEI_GUID_EVENT_REC) *
+ (MAX_FIRMWARE_PERFORMANCE_ENTRIES-1)
+ )
+ + sizeof(PEI_FIRMWARE_PERFORMANCE_HOB)
+ )
+ );
+
+ if (FirmwarePerformanceHob->NumberOfEntries >= MAX_FIRMWARE_PERFORMANCE_ENTRIES) {
+ return;
+ }
+
+ PeiGuidRec = &(FirmwarePerformanceHob->GuidEventRecord[FirmwarePerformanceHob->NumberOfEntries]);
+ (*PeiServices)->SetMem (PeiGuidRec, sizeof(PEI_GUID_EVENT_REC), 0);
+
+ //
+ // If not NULL pointer, copy the file name
+ //
+ if (FileHeader != NULL) {
+ PeiGuidRec->Guid = FileHeader->Name;
+ }
+
+ //
+ // Record the time stamp nanosec value.
+ //
+ PeiGuidRec->Timestamp = GetTimeInNanoSec(Value);
+
+ //
+ // Record the Progress Id based upon token field
+ //
+ if (!EfiStrCmp (Token, L"PEIM")) {
+ if(!EntryExit) {
+ PeiGuidRec->ProgressID = PEIM_START_ID;
+ } else {
+ PeiGuidRec->ProgressID = PEIM_END_ID;
+ }
+ } else if (!EfiStrCmp (Token, L"PreMem")) {
+ if(!EntryExit) {
+ PeiGuidRec->ProgressID = PREMEM_START_ID;
+ } else {
+ PeiGuidRec->ProgressID = PREMEM_END_ID;
+ }
+ } else if (!EfiStrCmp (Token, L"DisMem")) {
+ if(!EntryExit) {
+ PeiGuidRec->ProgressID = DISMEM_START_ID;
+ } else {
+ PeiGuidRec->ProgressID = DISMEM_END_ID;
+ }
+ } else if (!EfiStrCmp (Token, L"PostMem")) {
+ if(!EntryExit) {
+ PeiGuidRec->ProgressID = POSTMEM_START_ID;
+ } else {
+ PeiGuidRec->ProgressID = POSTMEM_END_ID;
+ }
+ } else {
+ return ;
+ }
+ //
+ // Record the APIC Id
+ //
+ PeiGuidRec->ApicID = GetApicId();
+
+ //
+ // Increment the number of valid log entries.
+ //
+ FirmwarePerformanceHob->NumberOfEntries++;
+
+ return;
+}
diff --git a/EDK/Foundation/Library/Pei/PeiLib/Print/Print.c b/EDK/Foundation/Library/Pei/PeiLib/Print/Print.c
new file mode 100644
index 0000000..3151f2c
--- /dev/null
+++ b/EDK/Foundation/Library/Pei/PeiLib/Print/Print.c
@@ -0,0 +1,739 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Print.c
+
+Abstract:
+
+ Basic Ascii AvSPrintf() function named AvSPrint(). AvSPrint() enables very
+ simple implemenation of debug prints.
+
+ You can not Print more than PEI_LIB_MAX_PRINT_BUFFER characters at a
+ time. This makes the implementation very simple.
+
+ AvSPrint format specification has the follwoing form
+
+ %[flags][width]type
+
+ flags:
+ '-' - Left justify
+ '+' - Prefix a sign
+ ' ' - Prefix a blank
+ ',' - Place commas in numberss
+ '0' - Prefix for width with zeros
+ 'l' - UINT64
+ 'L' - UINT64
+
+ width:
+ '*' - Get width from a UINTN argumnet from the argument list
+ Decimal number that represents width of print
+
+ type:
+ 'X' - argument is a UINTN hex number, prefix '0'
+ 'x' - argument is a hex number
+ 'd' - argument is a decimal number
+ 'a' - argument is an ascii string
+ 'S', 's' - argument is an Unicode string
+ 'g' - argument is a pointer to an EFI_GUID
+ 't' - argument is a pointer to an EFI_TIME structure
+ 'c' - argument is an ascii character
+ 'r' - argument is EFI_STATUS
+ '%' - Print a %
+
+--*/
+
+#include "Tiano.h"
+#include "Pei.h"
+#include "PeiLib.h"
+#include "Print.h"
+
+
+STATIC
+CHAR8 *
+GetFlagsAndWidth (
+ IN CHAR8 *Format,
+ OUT UINTN *Flags,
+ OUT UINTN *Width,
+ IN OUT VA_LIST *Marker
+ );
+
+STATIC
+UINTN
+ValueToString (
+ IN OUT CHAR8 *Buffer,
+ IN INT64 Value,
+ IN UINTN Flags,
+ IN UINTN Width
+ );
+
+STATIC
+UINTN
+ValueTomHexStr (
+ IN OUT CHAR8 *Buffer,
+ IN UINT64 Value,
+ IN UINTN Flags,
+ IN UINTN Width
+ );
+
+STATIC
+UINTN
+GuidToString (
+ IN EFI_GUID *Guid,
+ IN OUT CHAR8 *Buffer,
+ IN UINTN BufferSize
+ );
+
+STATIC
+UINTN
+TimeToString (
+ IN EFI_TIME *Time,
+ IN OUT CHAR8 *Buffer,
+ IN UINTN BufferSize
+ );
+
+STATIC
+UINTN
+EfiStatusToString (
+ IN EFI_STATUS Status,
+ OUT CHAR8 *Buffer,
+ IN UINTN BufferSize
+ );
+
+
+UINTN
+ASPrint (
+ OUT CHAR8 *Buffer,
+ IN UINTN BufferSize,
+ IN CONST CHAR8 *Format,
+ ...
+ )
+/*++
+
+Routine Description:
+
+ ASPrint function to process format and place the results in Buffer.
+
+Arguments:
+
+ Buffer - Ascii buffer to print the results of the parsing of Format into.
+
+ BufferSize - Maximum number of characters to put into buffer. Zero means no
+ limit.
+
+ Format - Ascii format string see file header for more details.
+
+ ... - Vararg list consumed by processing Format.
+
+Returns:
+
+ Number of characters printed.
+
+--*/
+{
+ UINTN Return;
+ VA_LIST Marker;
+
+ VA_START(Marker, Format);
+ Return = AvSPrint(Buffer, BufferSize, Format, Marker);
+ VA_END (Marker);
+
+ return Return;
+}
+
+
+UINTN
+AvSPrint (
+ OUT CHAR8 *StartOfBuffer,
+ IN UINTN BufferSize,
+ IN CONST CHAR8 *FormatString,
+ IN VA_LIST Marker
+ )
+/*++
+
+Routine Description:
+
+ AvSPrint function to process format and place the results in Buffer. Since a
+ VA_LIST is used this rountine allows the nesting of Vararg routines. Thus
+ this is the main print working routine
+
+Arguments:
+
+ StartOfBuffer - Ascii buffer to print the results of the parsing of Format into.
+
+ BufferSize - Maximum number of characters to put into buffer. Zero means
+ no limit.
+
+ FormatString - Ascii format string see file header for more details.
+
+ Marker - Vararg list consumed by processing Format.
+
+Returns:
+
+ Number of characters printed.
+
+--*/
+{
+ CHAR8 *Buffer;
+ CHAR8 *AsciiStr;
+ CHAR16 *UnicodeStr;
+ CHAR8 *Format;
+ UINTN Index;
+ UINTN Flags;
+ UINTN Width;
+ UINT64 Value;
+
+ //
+ // Process the format string. Stop if Buffer is over run.
+ //
+
+ Buffer = StartOfBuffer;
+ Format = (CHAR8 *)FormatString;
+ for (Index = 0; (*Format != '\0') && (Index < BufferSize); Format++) {
+ if (*Format != '%') {
+ if (*Format == '\n') {
+ //
+ // If carage return add line feed
+ //
+ Buffer[Index++] = '\r';
+ }
+ Buffer[Index++] = *Format;
+ } else {
+
+ //
+ // Now it's time to parse what follows after %
+ //
+ Format = GetFlagsAndWidth (Format, &Flags, &Width, &Marker);
+ switch (*Format) {
+ case 'X':
+ Flags |= PREFIX_ZERO;
+ Width = sizeof (UINT64) * 2;
+ //
+ // break skiped on purpose
+ //
+ case 'x':
+ if ((Flags & LONG_TYPE) == LONG_TYPE) {
+ Value = VA_ARG (Marker, UINT64);
+ } else {
+ Value = VA_ARG (Marker, UINTN);
+ Value &= 0xFFFFFFFF;
+ }
+ Index += ValueTomHexStr (&Buffer[Index], Value, Flags, Width);
+ break;
+
+ case 'd':
+ if ((Flags & LONG_TYPE) == LONG_TYPE) {
+ Value = VA_ARG (Marker, UINT64);
+ } else {
+ Value = (UINTN)VA_ARG (Marker, UINTN);
+ Value &= 0xFFFFFFFF;
+ Value = (INT32)Value;
+ }
+ Index += ValueToString (&Buffer[Index], Value, Flags, Width);
+ break;
+
+ case 's':
+ case 'S':
+ UnicodeStr = (CHAR16 *)VA_ARG (Marker, CHAR16 *);
+ if (UnicodeStr == NULL) {
+ UnicodeStr = L"<null string>";
+ }
+ for ( ;*UnicodeStr != '\0'; UnicodeStr++) {
+ Buffer[Index++] = (CHAR8)*UnicodeStr;
+ }
+ break;
+
+ case 'a':
+ AsciiStr = (CHAR8 *)VA_ARG (Marker, CHAR8 *);
+ if (AsciiStr == NULL) {
+ AsciiStr = "<null string>";
+ }
+ while (*AsciiStr != '\0') {
+ Buffer[Index++] = *AsciiStr++;
+ }
+ break;
+
+ case 'c':
+ Buffer[Index++] = (CHAR8)VA_ARG (Marker, UINTN);
+ break;
+
+ case 'g':
+ Index += GuidToString (
+ VA_ARG (Marker, EFI_GUID *),
+ &Buffer[Index],
+ BufferSize
+ );
+ break;
+
+ case 't':
+ Index += TimeToString (
+ VA_ARG (Marker, EFI_TIME *),
+ &Buffer[Index],
+ BufferSize
+ );
+ break;
+
+ case 'r':
+ Index += EfiStatusToString (
+ VA_ARG (Marker, EFI_STATUS),
+ &Buffer[Index],
+ BufferSize
+ );
+ break;
+
+ case '%':
+ Buffer[Index++] = *Format;
+ break;
+
+ default:
+ //
+ // if the type is unknown print it to the screen
+ //
+ Buffer[Index++] = *Format;
+ }
+
+ }
+ }
+ Buffer[Index++] = '\0';
+
+ return &Buffer[Index] - StartOfBuffer;
+}
+
+
+
+STATIC
+CHAR8 *
+GetFlagsAndWidth (
+ IN CHAR8 *Format,
+ OUT UINTN *Flags,
+ OUT UINTN *Width,
+ IN OUT VA_LIST *Marker
+ )
+/*++
+
+Routine Description:
+
+ AvSPrint worker function that parses flag and width information from the
+ Format string and returns the next index into the Format string that needs
+ to be parsed. See file headed for details of Flag and Width.
+
+Arguments:
+
+ Format - Current location in the AvSPrint format string.
+
+ Flags - Returns flags
+
+ Width - Returns width of element
+
+ Marker - Vararg list that may be paritally consumed and returned.
+
+Returns:
+
+ Pointer indexed into the Format string for all the information parsed
+ by this routine.
+
+--*/
+{
+ UINTN Count;
+ BOOLEAN Done;
+
+ *Flags = 0;
+ *Width = 0;
+ for (Done = FALSE; !Done; ) {
+ Format++;
+
+ switch (*Format) {
+
+ case '-': *Flags |= LEFT_JUSTIFY; break;
+ case '+': *Flags |= PREFIX_SIGN; break;
+ case ' ': *Flags |= PREFIX_BLANK; break;
+ case ',': *Flags |= COMMA_TYPE; break;
+ case 'L':
+ case 'l': *Flags |= LONG_TYPE; break;
+
+ case '*':
+ *Width = VA_ARG (*Marker, UINTN);
+ break;
+
+ case '0':
+ *Flags |= PREFIX_ZERO;
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
+ case '8':
+ case '9':
+ Count = 0;
+ do {
+ Count = (Count * 10) + *Format - '0';
+ Format++;
+ } while ((*Format >= '0') && (*Format <= '9'));
+ Format--;
+ *Width = Count;
+ break;
+
+ default:
+ Done = TRUE;
+ }
+ }
+ return Format;
+}
+
+static CHAR8 mHexStr[] = { '0','1','2','3','4','5','6','7',
+ '8','9','A','B','C','D','E','F' };
+
+STATIC
+UINTN
+ValueTomHexStr (
+ IN OUT CHAR8 *Buffer,
+ IN UINT64 Value,
+ IN UINTN Flags,
+ IN UINTN Width
+ )
+/*++
+
+Routine Description:
+
+ AvSPrint worker function that prints a Value as a hex number in Buffer
+
+Arguments:
+
+ Buffer - Location to place ascii hex string of Value.
+
+ Value - Hex value to convert to a string in Buffer.
+
+ Flags - Flags to use in printing Hex string, see file header for details.
+
+ Width - Width of hex value.
+
+Returns:
+
+ Number of characters printed.
+
+--*/
+{
+ CHAR8 TempBuffer[30];
+ CHAR8 *TempStr;
+ CHAR8 Prefix;
+ CHAR8 *BufferPtr;
+ UINTN Count;
+ UINTN Index;
+
+ TempStr = TempBuffer;
+ BufferPtr = Buffer;
+
+ //
+ // Count starts at one since we will null terminate. Each iteration of the
+ // loop picks off one nibble. Oh yea TempStr ends up backwards
+ //
+ Count = 0;
+ do {
+ *(TempStr++) = mHexStr[Value & 0x0f];
+ Value = RShiftU64 (Value, 4);
+ Count++;
+ } while (Value != 0);
+
+ if (Flags & PREFIX_ZERO) {
+ Prefix = '0';
+ } else if (!(Flags & LEFT_JUSTIFY)) {
+ Prefix = ' ';
+ } else {
+ Prefix = 0x00;
+ }
+ for (Index = Count; Index < Width; Index++) {
+ *(TempStr++) = Prefix;
+ }
+
+ //
+ // Reverse temp string into Buffer.
+ //
+ while (TempStr != TempBuffer) {
+ *(BufferPtr++) = *(--TempStr);
+ }
+
+ *BufferPtr = 0;
+ return Index;
+}
+
+STATIC
+UINTN
+ValueToString (
+ IN OUT CHAR8 *Buffer,
+ IN INT64 Value,
+ IN UINTN Flags,
+ IN UINTN Width
+ )
+/*++
+
+Routine Description:
+
+ AvSPrint worker function that prints a Value as a decimal number in Buffer
+
+Arguments:
+
+ Buffer - Location to place ascii decimal number string of Value.
+
+ Value - Decimal value to convert to a string in Buffer.
+
+ Flags - Flags to use in printing decimal string, see file header for details.
+
+ Width - Width of hex value.
+
+Returns:
+
+ Number of characters printed.
+
+--*/
+{
+ CHAR8 TempBuffer[30];
+ CHAR8 *TempStr;
+ CHAR8 *BufferPtr;
+ UINTN Count;
+ UINTN Remainder;
+
+ TempStr = TempBuffer;
+ BufferPtr = Buffer;
+ Count = 0;
+
+ if (Value < 0) {
+ *(BufferPtr++) = '-';
+ Value = -Value;
+ Count++;
+ }
+
+ do {
+ Value = (INT64)DivU64x32 ((UINT64)Value, 10, &Remainder);
+ *(TempStr++) = (CHAR8)(Remainder + '0');
+ Count++;
+ if ((Flags & COMMA_TYPE) == COMMA_TYPE) {
+ if (Count % 3 == 0) {
+ *(TempStr++) = ',';
+ }
+ }
+ } while (Value != 0);
+
+ //
+ // Reverse temp string into Buffer.
+ //
+ while (TempStr != TempBuffer) {
+ *(BufferPtr++) = *(--TempStr);
+ }
+
+ *BufferPtr = 0;
+ return Count;
+}
+
+STATIC
+UINTN
+GuidToString (
+ IN EFI_GUID *Guid,
+ IN CHAR8 *Buffer,
+ IN UINTN BufferSize
+ )
+/*++
+
+Routine Description:
+
+ AvSPrint worker function that prints an EFI_GUID.
+
+Arguments:
+
+ Guid - Pointer to GUID to print.
+
+ Buffer - Buffe to print Guid into.
+
+ BufferSize - Size of Buffer.
+
+Returns:
+
+ Number of characters printed.
+
+--*/
+{
+ UINTN Size;
+
+ Size = ASPrint (
+ Buffer,
+ BufferSize,
+ "%08x-%04x-%04x-%02x%02x-%02x%02x%02x%02x%02x%02x",
+ (UINTN)Guid->Data1,
+ (UINTN)Guid->Data2,
+ (UINTN)Guid->Data3,
+ (UINTN)Guid->Data4[0],
+ (UINTN)Guid->Data4[1],
+ (UINTN)Guid->Data4[2],
+ (UINTN)Guid->Data4[3],
+ (UINTN)Guid->Data4[4],
+ (UINTN)Guid->Data4[5],
+ (UINTN)Guid->Data4[6],
+ (UINTN)Guid->Data4[7]
+ );
+
+ //
+ // ASPrint will null terminate the string. The -1 skips the null
+ //
+ return Size - 1;
+}
+
+
+STATIC
+UINTN
+TimeToString (
+ IN EFI_TIME *Time,
+ OUT CHAR8 *Buffer,
+ IN UINTN BufferSize
+ )
+/*++
+
+Routine Description:
+
+ AvSPrint worker function that prints EFI_TIME.
+
+Arguments:
+
+ Time - Pointer to EFI_TIME sturcture to print.
+
+ Buffer - Buffer to print Time into.
+
+ BufferSize - Size of Buffer.
+
+Returns:
+
+ Number of characters printed.
+
+--*/
+{
+ UINTN Size;
+
+ Size = ASPrint (
+ Buffer,
+ BufferSize,
+ "%02d/%02d/%04d %02d:%02d",
+ (UINTN)Time->Month,
+ (UINTN)Time->Day,
+ (UINTN)Time->Year,
+ (UINTN)Time->Hour,
+ (UINTN)Time->Minute
+ );
+
+ //
+ // ASPrint will null terminate the string. The -1 skips the null
+ //
+ return Size - 1;
+}
+
+STATIC
+UINTN
+EfiStatusToString (
+ IN EFI_STATUS Status,
+ OUT CHAR8 *Buffer,
+ IN UINTN BufferSize
+ )
+/*++
+
+Routine Description:
+
+ AvSPrint worker function that prints EFI_STATUS as a string. If string is
+ not known a hex value will be printed.
+
+Arguments:
+
+ Status - EFI_STATUS sturcture to print.
+
+ Buffer - Buffer to print EFI_STATUS message string into.
+
+ BufferSize - Size of Buffer.
+
+Returns:
+
+ Number of characters printed.
+
+--*/
+{
+ UINTN Size;
+ CHAR8 *Desc;
+
+ if (Status == EFI_SUCCESS) {
+ Desc = "Success";
+ } else if (Status == EFI_LOAD_ERROR) {
+ Desc = "Load Error";
+ } else if (Status == EFI_INVALID_PARAMETER) {
+ Desc = "Invalid Parameter";
+ } else if (Status == EFI_UNSUPPORTED) {
+ Desc = "Unsupported";
+ } else if (Status == EFI_BAD_BUFFER_SIZE) {
+ Desc = "Bad Buffer Size";
+ } else if (Status == EFI_BUFFER_TOO_SMALL) {
+ Desc = "Buffer Too Small";
+ } else if (Status == EFI_NOT_READY) {
+ Desc = "Not Ready";
+ } else if (Status == EFI_DEVICE_ERROR) {
+ Desc = "Device Error";
+ } else if (Status == EFI_WRITE_PROTECTED) {
+ Desc = "Write Protected";
+ } else if (Status == EFI_OUT_OF_RESOURCES) {
+ Desc = "Out of Resources";
+ } else if (Status == EFI_VOLUME_CORRUPTED) {
+ Desc = "Volume Corrupt";
+ } else if (Status == EFI_VOLUME_FULL) {
+ Desc = "Volume Full";
+ } else if (Status == EFI_NO_MEDIA) {
+ Desc = "No Media";
+ } else if (Status == EFI_MEDIA_CHANGED) {
+ Desc = "Media changed";
+ } else if (Status == EFI_NOT_FOUND) {
+ Desc = "Not Found";
+ } else if (Status == EFI_ACCESS_DENIED) {
+ Desc = "Access Denied";
+ } else if (Status == EFI_NO_RESPONSE) {
+ Desc = "No Response";
+ } else if (Status == EFI_NO_MAPPING) {
+ Desc = "No mapping";
+ } else if (Status == EFI_TIMEOUT) {
+ Desc = "Time out";
+ } else if (Status == EFI_NOT_STARTED) {
+ Desc = "Not started";
+ } else if (Status == EFI_ALREADY_STARTED) {
+ Desc = "Already started";
+ } else if (Status == EFI_ABORTED) {
+ Desc = "Aborted";
+ } else if (Status == EFI_ICMP_ERROR) {
+ Desc = "ICMP Error";
+ } else if (Status == EFI_TFTP_ERROR) {
+ Desc = "TFTP Error";
+ } else if (Status == EFI_PROTOCOL_ERROR) {
+ Desc = "Protocol Error";
+ } else if (Status == EFI_WARN_UNKNOWN_GLYPH) {
+ Desc = "Warning Unknown Glyph";
+ } else if (Status == EFI_WARN_DELETE_FAILURE) {
+ Desc = "Warning Delete Failure";
+ } else if (Status == EFI_WARN_WRITE_FAILURE) {
+ Desc = "Warning Write Failure";
+ } else if (Status == EFI_WARN_BUFFER_TOO_SMALL) {
+ Desc = "Warning Buffer Too Small";
+ } else {
+ Desc = NULL;
+ }
+ //
+ // If we found a match, copy the message to the user's buffer. Otherwise
+ // sprint the hex status code to their buffer.
+ //
+ if (Desc != NULL) {
+ Size = ASPrint (Buffer, BufferSize, "%a", Desc);
+ } else {
+ Size = ASPrint (Buffer, BufferSize, "%X", Status);
+ }
+ return Size - 1;
+}
diff --git a/EDK/Foundation/Library/Pei/PeiLib/Print/Print.h b/EDK/Foundation/Library/Pei/PeiLib/Print/Print.h
new file mode 100644
index 0000000..4d8b8df
--- /dev/null
+++ b/EDK/Foundation/Library/Pei/PeiLib/Print/Print.h
@@ -0,0 +1,38 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Print.h
+
+Abstract:
+
+ Private data for Print.c
+
+--*/
+
+#ifndef _PRINT_H_
+#define _PRINT_H_
+
+#define LEFT_JUSTIFY 0x01
+#define PREFIX_SIGN 0x02
+#define PREFIX_BLANK 0x04
+#define COMMA_TYPE 0x08
+#define LONG_TYPE 0x10
+#define PREFIX_ZERO 0x20
+
+//
+// Largest number of characters that can be printed out.
+//
+#define PEI_LIB_MAX_PRINT_BUFFER (80 * 4)
+
+#include "EfiCommonLib.h"
+#endif
diff --git a/EDK/Foundation/Library/Pei/PeiLib/ia32/PeCoffLoaderEx.c b/EDK/Foundation/Library/Pei/PeiLib/ia32/PeCoffLoaderEx.c
new file mode 100644
index 0000000..4eee1c5
--- /dev/null
+++ b/EDK/Foundation/Library/Pei/PeiLib/ia32/PeCoffLoaderEx.c
@@ -0,0 +1,93 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PeCoffLoaderEx.c
+
+Abstract:
+
+ IA-32 Specific relocation fixups
+
+Revision History
+
+--*/
+
+#include "TianoCommon.h"
+#include "EfiImage.h"
+
+EFI_STATUS
+PeCoffLoaderRelocateImageEx (
+ IN UINT16 *Reloc,
+ IN OUT CHAR8 *Fixup,
+ IN OUT CHAR8 **FixupData,
+ IN UINT64 Adjust
+ )
+/*++
+
+Routine Description:
+
+ Performs an IA-32 specific relocation fixup
+
+Arguments:
+
+ Reloc - Pointer to the relocation record
+
+ Fixup - Pointer to the address to fix up
+
+ FixupData - Pointer to a buffer to log the fixups
+
+ Adjust - The offset to adjust the fixup
+
+Returns:
+
+ EFI_UNSUPPORTED - relocate unsupported
+
+--*/
+{
+ return EFI_UNSUPPORTED;
+}
+
+BOOLEAN
+PeCoffLoaderImageFormatSupported (
+ IN UINT16 Machine
+ )
+/*++
+Routine Description:
+
+ Returns TRUE if the machine type of PE/COFF image is supported. Supported
+ does not mean the image can be executed it means the PE/COFF loader supports
+ loading and relocating of the image type. It's up to the caller to support
+ the entry point.
+
+ This function implies the basic PE/COFF loader/relocator supports IA32, EBC,
+ & X64 images. Calling the entry point in a correct mannor is up to the
+ consumer of this library.
+
+Arguments:
+
+ Machine - Machine type from the PE Header.
+
+Returns:
+
+ TRUE - if this PE/COFF loader can load the image
+ FALSE - if this PE/COFF loader cannot load the image
+
+--*/
+{
+ if ((Machine == EFI_IMAGE_MACHINE_IA32) || (Machine == EFI_IMAGE_MACHINE_X64) ||
+ (Machine == EFI_IMAGE_MACHINE_EBC)) {
+ return TRUE;
+ }
+
+ return FALSE;
+}
+
diff --git a/EDK/Foundation/Library/Pei/PeiLib/ia32/PeCoffLoaderEx.h b/EDK/Foundation/Library/Pei/PeiLib/ia32/PeCoffLoaderEx.h
new file mode 100644
index 0000000..a83282d
--- /dev/null
+++ b/EDK/Foundation/Library/Pei/PeiLib/ia32/PeCoffLoaderEx.h
@@ -0,0 +1,85 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PeCoffLoaderEx.h
+
+Abstract:
+
+ IA-32 Specific relocation fixups
+
+Revision History
+
+--*/
+
+#ifndef _PE_COFF_LOADER_EX_H_
+#define _PE_COFF_LOADER_EX_H_
+
+EFI_STATUS
+PeCoffLoaderRelocateImageEx (
+ IN UINT16 *Reloc,
+ IN OUT CHAR8 *Fixup,
+ IN OUT CHAR8 **FixupData,
+ IN UINT64 Adjust
+ )
+/*++
+
+Routine Description:
+
+ Performs an IA-32 specific relocation fixup
+
+Arguments:
+
+ Reloc - Pointer to the relocation record
+
+ Fixup - Pointer to the address to fix up
+
+ FixupData - Pointer to a buffer to log the fixups
+
+ Adjust - The offset to adjust the fixup
+
+Returns:
+
+ EFI_UNSUPPORTED - relocate unsupported
+
+--*/
+;
+
+BOOLEAN
+PeCoffLoaderImageFormatSupported (
+ IN UINT16 Machine
+ )
+/*++
+Routine Description:
+
+ Returns TRUE if the machine type of PE/COFF image is supported. Supported
+ does not mean the image can be executed it means the PE/COFF loader supports
+ loading and relocating of the image type. It's up to the caller to support
+ the entry point.
+
+ This function implies the basic PE/COFF loader/relocator supports IA32, EBC,
+ & X64 images. Calling the entry point in a correct mannor is up to the
+ consumer of this library.
+
+Arguments:
+
+ Machine - Machine type from the PE Header.
+
+Returns:
+
+ TRUE - if this PE/COFF loader can load the image
+ FALSE - if this PE/COFF loader cannot load the image
+
+--*/
+;
+
+#endif
diff --git a/EDK/Foundation/Library/Pei/PeiLib/ia32/PeiServicePointer.c b/EDK/Foundation/Library/Pei/PeiLib/ia32/PeiServicePointer.c
new file mode 100644
index 0000000..162415c
--- /dev/null
+++ b/EDK/Foundation/Library/Pei/PeiLib/ia32/PeiServicePointer.c
@@ -0,0 +1,153 @@
+/*++
+
+Copyright (c) 2004 - 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PeiServicePointer.c
+
+Abstract:
+
+--*/
+
+#include "Tiano.h"
+#include "PeiApi.h"
+#include "PeiLib.h"
+
+//;;## ...AMI_ADD FILE... Support PI1.x
+#if (PI_SPECIFICATION_VERSION >= 0x00010000)
+
+#ifdef EFI_NT_EMULATOR
+EFI_PEI_SERVICES **gPeiServices;
+#endif
+
+
+VOID
+SetPeiServicesTablePointer (
+ IN EFI_PEI_SERVICES **PeiServices
+ )
+/*++
+
+Routine Description:
+
+ Save PeiService pointer so that it can be retrieved anywhere.
+
+Arguments:
+
+ PeiServices - The direct pointer to PeiServiceTable.
+ PhyscialAddress - The physcial address of variable PeiServices.
+
+Returns:
+ NONE
+
+--*/
+{
+
+#ifdef EFI_NT_EMULATOR
+
+ //
+ // For NT32, set EFI_PEI_SERVICES** to global variable.
+ //
+ gPeiServices = PeiServices;
+#else
+
+ //
+ // For X86 processor,the EFI_PEI_SERVICES** is stored in the
+ // 4 bytes immediately preceding the Interrupt Descriptor Table.
+ //
+ UINTN IdtBaseAddress;
+ IdtBaseAddress = (UINTN)ReadIdtBase();
+ *(UINTN*)(IdtBaseAddress - 4) = (UINTN)PeiServices;
+
+#endif
+}
+
+
+EFI_PEI_SERVICES **
+GetPeiServicesTablePointer (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Get PeiService pointer.
+
+Arguments:
+
+ NONE.
+
+Returns:
+ The direct pointer to PeiServiceTable.
+
+--*/
+{
+ EFI_PEI_SERVICES **PeiServices;
+
+#ifdef EFI_NT_EMULATOR
+
+ //
+ // For NT32, set EFI_PEI_SERVICES** to global variable.
+ //
+ PeiServices = gPeiServices;
+#else
+
+ //
+ // For X86 processor,the EFI_PEI_SERVICES** is stored in the
+ // 4 bytes immediately preceding the Interrupt Descriptor Table.
+ //
+ UINTN IdtBaseAddress;
+ IdtBaseAddress = (UINTN)ReadIdtBase();
+ PeiServices = (EFI_PEI_SERVICES **)(UINTN)(*(UINTN*)(IdtBaseAddress - 4));
+#endif
+ return PeiServices;
+}
+
+
+VOID
+MigrateIdtTable (
+ IN EFI_PEI_SERVICES **PeiServices
+ )
+/*++
+
+Routine Description:
+
+ Migrate IDT from CAR to real memory where preceded with 4 bytes for
+ storing PeiService pointer.
+
+Arguments:
+
+ PeiServices - The direct pointer to PeiServiceTable.
+
+Returns:
+
+ NONE.
+
+--*/
+{
+#ifndef EFI_NT_EMULATOR
+ UINT16 IdtEntrySize;
+ UINTN OldIdtBase;
+ UINTN Size;
+ VOID *NewIdtBase;
+ EFI_STATUS Status;
+
+ IdtEntrySize = ReadIdtLimit();
+ OldIdtBase = ReadIdtBase();
+ Size = sizeof(PEI_IDT_TABLE) + (IdtEntrySize + 1);
+ Status = (*PeiServices)->AllocatePool (PeiServices, Size, &NewIdtBase);
+ ASSERT_PEI_ERROR (PeiServices, Status);
+ (*PeiServices)->CopyMem ((VOID*)((UINTN)NewIdtBase + sizeof(PEI_IDT_TABLE)), (VOID*)OldIdtBase, (IdtEntrySize + 1));
+ SetIdtBase(((UINTN)NewIdtBase + sizeof(PEI_IDT_TABLE)), IdtEntrySize);
+ SetPeiServicesTablePointer(PeiServices);
+#endif
+}
+
+#endif
diff --git a/EDK/Foundation/Library/Pei/PeiLib/ia32/PerformancePrimitives.c b/EDK/Foundation/Library/Pei/PeiLib/ia32/PerformancePrimitives.c
new file mode 100644
index 0000000..992160a
--- /dev/null
+++ b/EDK/Foundation/Library/Pei/PeiLib/ia32/PerformancePrimitives.c
@@ -0,0 +1,47 @@
+/*++
+
+Copyright 2005, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PerformancePrimitives.c
+
+Abstract:
+
+ Support for Performance library
+
+--*/
+
+#include "TianoCommon.h"
+#include "CpuIA32.h"
+
+EFI_STATUS
+GetTimerValue (
+ OUT UINT64 *TimerValue
+ )
+/*++
+
+Routine Description:
+
+ Get timer value.
+
+Arguments:
+
+ TimerValue - Pointer to the returned timer value
+
+Returns:
+
+ EFI_SUCCESS - Successfully got timer value
+
+--*/
+{
+ *TimerValue = EfiReadTsc ();
+ return EFI_SUCCESS;
+}
diff --git a/EDK/Foundation/Library/Pei/PeiLib/ia32/Processor.c b/EDK/Foundation/Library/Pei/PeiLib/ia32/Processor.c
new file mode 100644
index 0000000..fcdd4bf
--- /dev/null
+++ b/EDK/Foundation/Library/Pei/PeiLib/ia32/Processor.c
@@ -0,0 +1,140 @@
+/*++
+
+Copyright (c) 2004 - 2005, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Processor.c
+
+Abstract:
+
+--*/
+
+#include "Tiano.h"
+#include "EfiJump.h"
+#include EFI_GUID_DEFINITION (PeiFlushInstructionCache)
+#include EFI_GUID_DEFINITION (PeiTransferControl)
+
+//
+// Prototypes
+//
+EFI_STATUS
+EFIAPI
+TransferControlSetJump (
+ IN EFI_PEI_TRANSFER_CONTROL_PROTOCOL *This,
+ IN EFI_JUMP_BUFFER *Jump
+ );
+
+EFI_STATUS
+EFIAPI
+TransferControlLongJump (
+ IN EFI_PEI_TRANSFER_CONTROL_PROTOCOL *This,
+ IN EFI_JUMP_BUFFER *Jump
+ );
+
+EFI_STATUS
+EFIAPI
+FlushInstructionCacheFlush (
+ IN EFI_PEI_FLUSH_INSTRUCTION_CACHE_PROTOCOL *This,
+ IN EFI_PHYSICAL_ADDRESS Start,
+ IN UINT64 Length
+ );
+
+//
+// Table declarations
+//
+EFI_PEI_TRANSFER_CONTROL_PROTOCOL mTransferControl = {
+ TransferControlSetJump,
+ TransferControlLongJump,
+ sizeof (EFI_JUMP_BUFFER)
+};
+
+EFI_PEI_FLUSH_INSTRUCTION_CACHE_PROTOCOL mFlushInstructionCache = {
+ FlushInstructionCacheFlush
+};
+
+
+EFI_STATUS
+InstallEfiPeiTransferControl (
+ IN OUT EFI_PEI_TRANSFER_CONTROL_PROTOCOL **This
+ )
+/*++
+
+Routine Description:
+
+ Installs the pointer to the transfer control mechanism
+
+Arguments:
+
+ This - Pointer to transfer control mechanism.
+
+Returns:
+
+ EFI_SUCCESS - Successfully installed.
+
+--*/
+{
+ *This = &mTransferControl;
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+InstallEfiPeiFlushInstructionCache (
+ IN OUT EFI_PEI_FLUSH_INSTRUCTION_CACHE_PROTOCOL **This
+ )
+/*++
+
+Routine Description:
+
+ Installs the pointer to the flush instruction cache mechanism
+
+Arguments:
+
+ This - Pointer to flush instruction cache mechanism.
+
+Returns:
+
+ EFI_SUCCESS - Successfully installed
+
+--*/
+{
+ *This = &mFlushInstructionCache;
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EFIAPI
+FlushInstructionCacheFlush (
+ IN EFI_PEI_FLUSH_INSTRUCTION_CACHE_PROTOCOL *This,
+ IN EFI_PHYSICAL_ADDRESS Start,
+ IN UINT64 Length
+ )
+/*++
+
+Routine Description:
+
+ This routine would provide support for flushing the CPU instruction cache.
+ In the case of IA32, this flushing is not necessary and is thus not implemented.
+
+Arguments:
+
+ This - Pointer to CPU Architectural Protocol interface
+ Start - Start adddress in memory to flush
+ Length - Length of memory to flush
+
+Returns:
+
+ Status
+ EFI_SUCCESS
+
+--*/
+{
+ return EFI_SUCCESS;
+}
diff --git a/EDK/Foundation/Library/Pei/PeiLib/ia32/ProcessorAsms.Asm b/EDK/Foundation/Library/Pei/PeiLib/ia32/ProcessorAsms.Asm
new file mode 100644
index 0000000..86f4606
--- /dev/null
+++ b/EDK/Foundation/Library/Pei/PeiLib/ia32/ProcessorAsms.Asm
@@ -0,0 +1,223 @@
+;
+; Copyright (c) 2004, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; ProcessorAsms.Asm
+;
+; Abstract:
+; This is separated from processor.c to allow this functions to be built with /O1
+;
+; Notes:
+; - Masm uses "This", "ebx", etc as a directive.
+; - H2INC is still not embedded in our build process so I translated the struc manually.
+; - Unreferenced variables/arguments (This, NewBsp, NewStack) were causing compile errors and
+; did not know of "pragma" mechanism in MASM and I did not want to reduce the warning level.
+; Instead, I did a dummy referenced.
+;
+
+ .686P
+ .MMX
+ .MODEL SMALL
+ .CODE
+
+EFI_SUCCESS equ 0
+EFI_WARN_RETURN_FROM_LONG_JUMP equ 5
+
+;
+; Generated by h2inc run manually
+;
+_EFI_JUMP_BUFFER STRUCT 2t
+_ebx DWORD ?
+_esi DWORD ?
+_edi DWORD ?
+_ebp DWORD ?
+_esp DWORD ?
+_eip DWORD ?
+_EFI_JUMP_BUFFER ENDS
+
+EFI_JUMP_BUFFER TYPEDEF _EFI_JUMP_BUFFER
+
+TransferControlSetJump PROTO C \
+ _This:PTR EFI_PEI_TRANSFER_CONTROL_PROTOCOL, \
+ Jump:PTR EFI_JUMP_BUFFER
+
+TransferControlLongJump PROTO C \
+ _This:PTR EFI_PEI_TRANSFER_CONTROL_PROTOCOL, \
+ Jump:PTR EFI_JUMP_BUFFER
+
+SwitchStacks PROTO C \
+ EntryPoint:PTR DWORD, \
+ Parameter:DWORD, \
+ NewStack:PTR DWORD, \
+ NewBsp:PTR DWORD
+
+SwitchIplStacks PROTO C \
+ EntryPoint:PTR DWORD, \
+ Parameter1:DWORD, \
+ Parameter2:DWORD, \
+ NewStack:PTR DWORD, \
+ NewBsp:PTR DWORD
+
+;
+;Routine Description:
+;
+; This routine implements the IA32 variant of the SetJump call. Its
+; responsibility is to store system state information for a possible
+; subsequent LongJump.
+;
+;Arguments:
+;
+; Pointer to CPU context save buffer.
+;
+;Returns:
+;
+; EFI_SUCCESS
+;
+TransferControlSetJump PROC C \
+ _This:PTR EFI_PEI_TRANSFER_CONTROL_PROTOCOL, \
+ Jump:PTR EFI_JUMP_BUFFER
+
+ mov eax, _This
+ mov ecx, Jump
+ mov (EFI_JUMP_BUFFER PTR [ecx])._ebx, ebx
+ mov (EFI_JUMP_BUFFER PTR [ecx])._esi, esi
+ mov (EFI_JUMP_BUFFER PTR [ecx])._edi, edi
+ mov eax, [ebp]
+ mov (EFI_JUMP_BUFFER PTR [ecx])._ebp, eax
+ lea eax, [ebp+4]
+ mov (EFI_JUMP_BUFFER PTR [ecx])._esp, eax
+ mov eax, [ebp+4]
+ mov (EFI_JUMP_BUFFER PTR [ecx])._eip, eax
+ mov eax, EFI_SUCCESS
+
+ ret
+
+TransferControlSetJump ENDP
+
+;
+; Routine Description:
+;
+; This routine implements the IA32 variant of the LongJump call. Its
+; responsibility is restore the system state to the Context Buffer and
+; pass control back.
+;
+; Arguments:
+;
+; Pointer to CPU context save buffer.
+;
+; Returns:
+;
+; EFI_WARN_RETURN_FROM_LONG_JUMP
+;
+
+TransferControlLongJump PROC C \
+ _This:PTR EFI_PEI_TRANSFER_CONTROL_PROTOCOL, \
+ Jump:PTR EFI_JUMP_BUFFER
+
+ push ebx
+ push esi
+ push edi
+
+ mov eax, _This
+ ; set return from SetJump to EFI_WARN_RETURN_FROM_LONG_JUMP
+ mov eax, EFI_WARN_RETURN_FROM_LONG_JUMP
+ mov ecx, Jump
+ mov ebx, (EFI_JUMP_BUFFER PTR [ecx])._ebx
+ mov esi, (EFI_JUMP_BUFFER PTR [ecx])._esi
+ mov edi, (EFI_JUMP_BUFFER PTR [ecx])._edi
+ mov ebp, (EFI_JUMP_BUFFER PTR [ecx])._ebp
+ mov esp, (EFI_JUMP_BUFFER PTR [ecx])._esp
+ add esp, 4 ;pop the eip
+ jmp DWORD PTR (EFI_JUMP_BUFFER PTR [ecx])._eip
+ mov eax, EFI_WARN_RETURN_FROM_LONG_JUMP
+
+ pop edi
+ pop esi
+ pop ebx
+ ret
+
+TransferControlLongJump ENDP
+
+;
+; Routine Description:
+; This allows the caller to switch the stack and goes to the new entry point
+;
+; Arguments:
+; EntryPoint - Pointer to the location to enter
+; Parameter - Parameter to pass in
+; NewStack - New Location of the stack
+; NewBsp - New BSP
+;
+; Returns:
+;
+; Nothing. Goes to the Entry Point passing in the new parameters
+;
+SwitchStacks PROC C \
+ EntryPoint:PTR DWORD, \
+ Parameter:DWORD, \
+ NewStack:PTR DWORD, \
+ NewBsp:PTR DWORD
+
+ push ebx
+ mov eax, NewBsp
+ mov ebx, Parameter
+ mov ecx, EntryPoint
+ mov eax, NewStack
+ mov esp, eax
+ push ebx
+ push 0
+ jmp ecx
+
+ pop ebx
+ ret
+
+SwitchStacks ENDP
+
+;
+; Routine Description:
+; This allows the caller to switch the stack and goes to the new entry point
+;
+; Arguments:
+; EntryPoint - Pointer to the location to enter
+; Parameter1/Parameter2 - Parameter to pass in
+; NewStack - New Location of the stack
+; NewBsp - New BSP
+;
+; Returns:
+;
+; Nothing. Goes to the Entry Point passing in the new parameters
+;
+SwitchIplStacks PROC C \
+ EntryPoint:PTR DWORD, \
+ Parameter1:DWORD, \
+ Parameter2:DWORD, \
+ NewStack:PTR DWORD, \
+ NewBsp:PTR DWORD
+
+ push ebx
+ mov eax, NewBsp
+ mov ebx, Parameter1
+ mov edx, Parameter2
+ mov ecx, EntryPoint
+ mov eax, NewStack
+ mov esp, eax
+
+ push edx
+ push ebx
+ call ecx
+
+ pop ebx
+ ret
+
+SwitchIplStacks ENDP
+
+ END
+
diff --git a/EDK/Foundation/Library/Pei/PeiLib/ia32/efijump.h b/EDK/Foundation/Library/Pei/PeiLib/ia32/efijump.h
new file mode 100644
index 0000000..d676f88
--- /dev/null
+++ b/EDK/Foundation/Library/Pei/PeiLib/ia32/efijump.h
@@ -0,0 +1,34 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiJump.h
+
+Abstract:
+
+ This is the Setjump/Longjump pair for an IA32 processor.
+
+--*/
+
+#ifndef _EFI_JUMP_H_
+#define _EFI_JUMP_H_
+
+typedef struct {
+ UINT32 ebx;
+ UINT32 esi;
+ UINT32 edi;
+ UINT32 ebp;
+ UINT32 esp;
+ UINT32 eip;
+} EFI_JUMP_BUFFER;
+
+#endif
diff --git a/EDK/Foundation/Library/Pei/PeiLib/x64/EfiJump.h b/EDK/Foundation/Library/Pei/PeiLib/x64/EfiJump.h
new file mode 100644
index 0000000..61f371f
--- /dev/null
+++ b/EDK/Foundation/Library/Pei/PeiLib/x64/EfiJump.h
@@ -0,0 +1,42 @@
+/*++
+
+Copyright (c) 2005, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiJump.h
+
+Abstract:
+
+ This is the Setjump/Longjump pair for an x64 processor.
+
+--*/
+
+#ifndef _EFI_JUMP_H_
+#define _EFI_JUMP_H_
+
+typedef struct {
+ UINT64 Rbx;
+ UINT64 Rsp;
+ UINT64 Rbp;
+ UINT64 Rdi;
+ UINT64 Rsi;
+ UINT64 R10;
+ UINT64 R11;
+ UINT64 R12;
+ UINT64 R13;
+ UINT64 R14;
+ UINT64 R15;
+ UINT64 Rip;
+ UINT32 MxCsr;
+ UINT8 XmmBuffer[160]; // XMM6-XMM15
+} EFI_JUMP_BUFFER;
+
+#endif
diff --git a/EDK/Foundation/Library/Pei/PeiLib/x64/Math.c b/EDK/Foundation/Library/Pei/PeiLib/x64/Math.c
new file mode 100644
index 0000000..968bf26
--- /dev/null
+++ b/EDK/Foundation/Library/Pei/PeiLib/x64/Math.c
@@ -0,0 +1,117 @@
+/*++
+
+Copyright (c) 2005, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Math.c
+
+Abstract:
+
+ 64-bit Math worker functions for x64
+
+--*/
+
+#include "Efi.h"
+#include "Pei.h"
+#include "PeiLib.h"
+
+
+UINT64
+LShiftU64 (
+ IN UINT64 Operand,
+ IN UINTN Count
+ )
+/*++
+
+Routine Description:
+
+ This routine allows a 64 bit value to be left shifted by 32 bits and returns the
+ shifted value.
+ Count is valid up 63. (Only Bits 0-5 is valid for Count)
+
+Arguments:
+
+ Operand - Value to be shifted
+
+ Count - Number of times to shift left.
+
+Returns:
+
+ Value shifted left identified by the Count.
+
+--*/
+{
+ return Operand << Count;
+}
+
+
+UINT64
+MultU64x32 (
+ IN UINT64 Multiplicand,
+ IN UINTN Multiplier
+ )
+/*++
+
+Routine Description:
+
+ This routine allows a 64 bit value to be multiplied with a 32 bit value returns
+ 64bit result.
+ No checking if the result is greater than 64bits
+
+Arguments:
+
+ Multiplicand -
+
+ Multiplier -
+
+Returns:
+
+ Multiplicand * Multiplier
+
+--*/
+{
+ return Multiplicand * Multiplier;
+}
+}
+
+UINT64
+DivU64x32 (
+ IN UINT64 Dividend,
+ IN UINTN Divisor,
+ OUT UINTN *Remainder OPTIONAL
+ )
+/*++
+
+Routine Description:
+
+ This routine allows a 64 bit value to be divided with a 32 bit value returns
+ 64bit result and the Remainder.
+
+Arguments:
+
+ Dividend -
+
+ Divisor -
+
+ Remainder -
+
+Returns:
+
+ Dividend / Divisor
+ Remainder = Dividend mod Divisor
+
+N.B. only works for 31bit divisors!!
+
+--*/
+{
+ return Dividend/Divisor;
+}
+
diff --git a/EDK/Foundation/Library/Pei/PeiLib/x64/PeCoffLoaderEx.c b/EDK/Foundation/Library/Pei/PeiLib/x64/PeCoffLoaderEx.c
new file mode 100644
index 0000000..1036f43
--- /dev/null
+++ b/EDK/Foundation/Library/Pei/PeiLib/x64/PeCoffLoaderEx.c
@@ -0,0 +1,87 @@
+/*++
+
+Copyright (c) 2005 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ PeCoffLoaderEx.c
+
+Abstract:
+
+ x64 Specific relocation fixups
+
+Revision History
+
+--*/
+
+#include "TianoCommon.h"
+#include "EfiImage.h"
+
+EFI_STATUS
+PeCoffLoaderRelocateImageEx (
+ IN UINT16 *Reloc,
+ IN OUT CHAR8 *Fixup,
+ IN OUT CHAR8 **FixupData,
+ IN UINT64 Adjust
+ )
+/*++
+
+Routine Description:
+ Performs an x64 specific relocation fixup
+
+Arguments:
+ Reloc - Pointer to the relocation record
+ Fixup - Pointer to the address to fix up
+ FixupData - Pointer to a buffer to log the fixups
+ Adjust - The offset to adjust the fixup
+
+Returns:
+ EFI_UNSUPPORTED - relocate unsupported
+
+--*/
+{
+ return EFI_UNSUPPORTED;
+}
+
+BOOLEAN
+PeCoffLoaderImageFormatSupported (
+ IN UINT16 Machine
+ )
+/*++
+Routine Description:
+
+ Returns TRUE if the machine type of PE/COFF image is supported. Supported
+ does not mean the image can be executed it means the PE/COFF loader supports
+ loading and relocating of the image type. It's up to the caller to support
+ the entry point.
+
+ This function implies the basic PE/COFF loader/relocator supports IA32, EBC,
+ & X64 images. Calling the entry point in a correct mannor is up to the
+ consumer of this library.
+
+Arguments:
+
+ Machine - Machine type from the PE Header.
+
+Returns:
+
+ TRUE - if this PE/COFF loader can load the image
+ FALSE - if this PE/COFF loader cannot load the image
+
+--*/
+{
+ if ((Machine == EFI_IMAGE_MACHINE_IA32) || (Machine == EFI_IMAGE_MACHINE_X64) ||
+ (Machine == EFI_IMAGE_MACHINE_EBC)) {
+ return TRUE;
+ }
+
+ return FALSE;
+}
diff --git a/EDK/Foundation/Library/Pei/PeiLib/x64/PeCoffLoaderEx.h b/EDK/Foundation/Library/Pei/PeiLib/x64/PeCoffLoaderEx.h
new file mode 100644
index 0000000..a3f78e0
--- /dev/null
+++ b/EDK/Foundation/Library/Pei/PeiLib/x64/PeCoffLoaderEx.h
@@ -0,0 +1,85 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PeCoffLoaderEx.h
+
+Abstract:
+
+ x64 Specific relocation fixups
+
+Revision History
+
+--*/
+
+#ifndef _PE_COFF_LOADER_EX_H_
+#define _PE_COFF_LOADER_EX_H_
+
+EFI_STATUS
+PeCoffLoaderRelocateImageEx (
+ IN UINT16 *Reloc,
+ IN OUT CHAR8 *Fixup,
+ IN OUT CHAR8 **FixupData,
+ IN UINT64 Adjust
+ )
+/*++
+
+Routine Description:
+
+ Performs an x64 specific relocation fixup
+
+Arguments:
+
+ Reloc - Pointer to the relocation record
+
+ Fixup - Pointer to the address to fix up
+
+ FixupData - Pointer to a buffer to log the fixups
+
+ Adjust - The offset to adjust the fixup
+
+Returns:
+
+ EFI_UNSUPPORTED - relocate unsupported
+
+--*/
+;
+
+BOOLEAN
+PeCoffLoaderImageFormatSupported (
+ IN UINT16 Machine
+ )
+/*++
+Routine Description:
+
+ Returns TRUE if the machine type of PE/COFF image is supported. Supported
+ does not mean the image can be executed it means the PE/COFF loader supports
+ loading and relocating of the image type. It's up to the caller to support
+ the entry point.
+
+ This function implies the basic PE/COFF loader/relocator supports IA32, EBC,
+ & X64 images. Calling the entry point in a correct mannor is up to the
+ consumer of this library.
+
+Arguments:
+
+ Machine - Machine type from the PE Header.
+
+Returns:
+
+ TRUE - if this PE/COFF loader can load the image
+ FALSE - if this PE/COFF loader cannot load the image
+
+--*/
+;
+
+#endif
diff --git a/EDK/Foundation/Library/Pei/PeiLib/x64/PeiServicePointer.c b/EDK/Foundation/Library/Pei/PeiLib/x64/PeiServicePointer.c
new file mode 100644
index 0000000..8797fb0
--- /dev/null
+++ b/EDK/Foundation/Library/Pei/PeiLib/x64/PeiServicePointer.c
@@ -0,0 +1,99 @@
+/*++
+
+Copyright 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ PeiServicePointer.c
+
+Abstract:
+
+--*/
+
+#include "Tiano.h"
+#include "PeiApi.h"
+
+//;;## ...AMI_ADD FILE... Support PI1.x
+
+#if (PI_SPECIFICATION_VERSION >= 0x00010000)
+
+VOID
+SetPeiServicesTablePointer (
+ IN EFI_PEI_SERVICES **PeiServices
+ )
+/*++
+
+Routine Description:
+
+ Save PeiService pointer so that it can be retrieved anywhere.
+
+Arguments:
+
+ PeiServices - The direct pointer to PeiServiceTable.
+ PhyscialAddress - The physcial address of variable PeiServices.
+
+Returns:
+ NONE
+
+--*/
+{
+ return;
+}
+
+EFI_PEI_SERVICES **
+GetPeiServicesTablePointer (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ Get PeiService pointer.
+
+Arguments:
+
+ NONE.
+
+Returns:
+ The direct pointer to PeiServiceTable.
+
+--*/
+{
+ return NULL;
+}
+
+
+VOID
+MigrateIdtTable (
+ IN EFI_PEI_SERVICES **PeiServices
+ )
+/*++
+
+Routine Description:
+
+ Migrate IDT from CAR to real memory where preceded with 4 bytes for
+ storing PeiService pointer.
+
+Arguments:
+
+ PeiServices - The direct pointer to PeiServiceTable.
+
+Returns:
+
+ NONE.
+
+--*/
+{
+ return;
+}
+
+#endif
+
diff --git a/EDK/Foundation/Library/Pei/PeiLib/x64/PerformancePrimitives.c b/EDK/Foundation/Library/Pei/PeiLib/x64/PerformancePrimitives.c
new file mode 100644
index 0000000..7517860
--- /dev/null
+++ b/EDK/Foundation/Library/Pei/PeiLib/x64/PerformancePrimitives.c
@@ -0,0 +1,34 @@
+/*++
+
+Copyright (c) 2005, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ PerformancePrimitives.c
+
+Abstract:
+
+ Support for Performance library
+
+--*/
+
+#include "TianoCommon.h"
+#include "CpuIA32.h"
+
+EFI_STATUS
+GetTimerValue (
+ OUT UINT64 *TimerValue
+ )
+{
+ *TimerValue = EfiReadTsc ();
+ return EFI_SUCCESS;
+}
+
diff --git a/EDK/Foundation/Library/Pei/PeiLib/x64/Processor.c b/EDK/Foundation/Library/Pei/PeiLib/x64/Processor.c
new file mode 100644
index 0000000..749a3b4
--- /dev/null
+++ b/EDK/Foundation/Library/Pei/PeiLib/x64/Processor.c
@@ -0,0 +1,149 @@
+/*++
+
+Copyright 2005, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ Processor.c
+
+Abstract:
+
+--*/
+
+#include "Tiano.h"
+#include "EfiJump.h"
+#include EFI_GUID_DEFINITION (PeiFlushInstructionCache)
+#include EFI_GUID_DEFINITION (PeiTransferControl)
+
+//
+// Prototypes
+//
+EFI_STATUS
+EFIAPI
+TransferControlSetJump (
+ IN EFI_PEI_TRANSFER_CONTROL_PROTOCOL *This,
+ IN EFI_JUMP_BUFFER *Jump
+ );
+
+EFI_STATUS
+EFIAPI
+TransferControlLongJump (
+ IN EFI_PEI_TRANSFER_CONTROL_PROTOCOL *This,
+ IN EFI_JUMP_BUFFER *Jump
+ );
+
+EFI_STATUS
+EFIAPI
+FlushInstructionCacheFlush (
+ IN EFI_PEI_FLUSH_INSTRUCTION_CACHE_PROTOCOL *This,
+ IN EFI_PHYSICAL_ADDRESS Start,
+ IN UINT64 Length
+ );
+
+//
+// Table declarations
+//
+EFI_PEI_TRANSFER_CONTROL_PROTOCOL mTransferControl = {
+ TransferControlSetJump,
+ TransferControlLongJump,
+ sizeof (EFI_JUMP_BUFFER)
+};
+
+EFI_PEI_FLUSH_INSTRUCTION_CACHE_PROTOCOL mFlushInstructionCache = {
+ FlushInstructionCacheFlush
+};
+
+
+EFI_STATUS
+EFIAPI
+InstallEfiPeiTransferControl(
+ IN OUT EFI_PEI_TRANSFER_CONTROL_PROTOCOL **This
+ )
+/*++
+
+Routine Description:
+
+ Installs the pointer to the transfer control mechanism
+
+Arguments:
+
+ This - Pointer to transfer control mechanism.
+
+Returns:
+
+ This - Pointer to transfer control mechanism.
+
+--*/
+{
+ *This = &mTransferControl;
+ mTransferControl.SetJump = TransferControlSetJump;
+ mTransferControl.LongJump = TransferControlLongJump;
+ return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+EFIAPI
+InstallEfiPeiFlushInstructionCache (
+ IN OUT EFI_PEI_FLUSH_INSTRUCTION_CACHE_PROTOCOL **This
+ )
+/*++
+
+Routine Description:
+
+ Installs the pointer to the flush instruction cache mechanism
+
+Arguments:
+
+ This - Pointer to flush instruction cache mechanism.
+
+Returns:
+
+ This - Pointer to flush instruction cache mechanism.
+
+--*/
+{
+ *This = &mFlushInstructionCache;
+ mFlushInstructionCache.Flush = FlushInstructionCacheFlush;
+ return EFI_SUCCESS;
+}
+
+
+EFI_STATUS
+EFIAPI
+FlushInstructionCacheFlush (
+ IN EFI_PEI_FLUSH_INSTRUCTION_CACHE_PROTOCOL *This,
+ IN EFI_PHYSICAL_ADDRESS Start,
+ IN UINT64 Length
+ )
+/*++
+
+Routine Description:
+
+ This routine would provide support for flushing the CPU instruction cache.
+ In the case of IA32, this flushing is not necessary and is thus not implemented.
+
+Arguments:
+
+ Pointer to CPU Architectural Protocol interface
+ Start adddress in memory to flush
+ Length of memory to flush
+
+Returns:
+
+ Status
+ EFI_SUCCESS
+
+--*/
+{
+ return EFI_SUCCESS;
+}
+
diff --git a/EDK/Foundation/Library/Pei/PeiLib/x64/ProcessorAsms.Asm b/EDK/Foundation/Library/Pei/PeiLib/x64/ProcessorAsms.Asm
new file mode 100644
index 0000000..ebd8b03
--- /dev/null
+++ b/EDK/Foundation/Library/Pei/PeiLib/x64/ProcessorAsms.Asm
@@ -0,0 +1,186 @@
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2005 - 2007, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+; ProcessorAsms.Asm
+;
+; Abstract:
+; This is separated from processor.c to allow this functions to be built with /O1
+;
+;
+;------------------------------------------------------------------------------
+
+text SEGMENT
+
+
+;
+; Routine Description:
+; This allows the caller to switch the stack and goes to the new entry point
+;
+; Arguments:
+; EntryPoint - Pointer to the location to enter // rcx
+; Parameter - Parameter to pass in // rdx
+; NewStack - New Location of the stack // r8
+; NewBsp - New BSP // r9 - not used
+;
+; Returns:
+; Nothing. Goes to the Entry Point passing in the new parameters
+;
+SwitchStacks PROC PUBLIC
+
+ ; Adjust stack for
+ ; 1) leave 4 registers space
+ ; 2) let it 16 bytes aligned after call
+ sub r8, 20h
+ and r8w, 0fff0h ; do not assume 16 bytes aligned
+
+ mov rsp, r8 ; rsp = NewStack
+ mov r10, rcx ; save EntryPoint
+ mov rcx, rdx ; Arg1 = Parameter
+ call r10 ; r10 = copy of EntryPoint
+ ;
+ ; no ret as we have a new stack and we jumped to the new location
+ ;
+ ret
+
+SwitchStacks ENDP
+
+
+EFI_SUCCESS equ 0
+EFI_WARN_RETURN_FROM_LONG_JUMP equ 5
+
+;
+; Generated by h2inc run manually
+;
+_EFI_JUMP_BUFFER STRUCT 2t
+_rbx QWORD ?
+_rsp QWORD ?
+_rbp QWORD ?
+_rdi QWORD ?
+_rsi QWORD ?
+_r10 QWORD ?
+_r11 QWORD ?
+_r12 QWORD ?
+_r13 QWORD ?
+_r14 QWORD ?
+_r15 QWORD ?
+_rip QWORD ?
+_MxCsr DWORD ?
+_XmmBuffer DB 160 DUP (?)
+_EFI_JUMP_BUFFER ENDS
+
+EFI_JUMP_BUFFER TYPEDEF _EFI_JUMP_BUFFER
+
+
+;
+;Routine Description:
+;
+; This routine implements the x64 variant of the SetJump call. Its
+; responsibility is to store system state information for a possible
+; subsequent LongJump.
+;
+;Arguments:
+;
+; Pointer to CPU context save buffer.
+;
+;Returns:
+;
+; EFI_SUCCESS
+;
+; EFI_STATUS
+; EFIAPI
+; TransferControlLongJump (
+; IN EFI_PEI_TRANSFER_CONTROL_PROTOCOL *This,
+; IN EFI_JUMP_BUFFER *Jump
+; );
+;
+; rcx - *This
+; rdx - JumpBuffer
+;
+PUBLIC TransferControlSetJump
+TransferControlSetJump PROC
+ mov (EFI_JUMP_BUFFER PTR [rdx])._rbx, rbx
+ mov (EFI_JUMP_BUFFER PTR [rdx])._rsp, rsp
+ mov (EFI_JUMP_BUFFER PTR [rdx])._rbp, rbp
+ mov (EFI_JUMP_BUFFER PTR [rdx])._rdi, rdi
+ mov (EFI_JUMP_BUFFER PTR [rdx])._rsi, rsi
+ mov (EFI_JUMP_BUFFER PTR [rdx])._r10, r10
+ mov (EFI_JUMP_BUFFER PTR [rdx])._r11, r11
+ mov (EFI_JUMP_BUFFER PTR [rdx])._r12, r12
+ mov (EFI_JUMP_BUFFER PTR [rdx])._r13, r13
+ mov (EFI_JUMP_BUFFER PTR [rdx])._r14, r14
+ mov (EFI_JUMP_BUFFER PTR [rdx])._r15, r15
+ ; save non-volatile fp registers
+ stmxcsr (EFI_JUMP_BUFFER PTR [rdx])._MxCsr
+ lea rax, (EFI_JUMP_BUFFER PTR [rdx])._XmmBuffer
+ movdqu [rax], xmm6
+ movdqu [rax + 10h], xmm7
+ movdqu [rax + 20h], xmm8
+ movdqu [rax + 30h], xmm9
+ movdqu [rax + 40h], xmm10
+ movdqu [rax + 50h], xmm11
+ movdqu [rax + 60h], xmm12
+ movdqu [rax + 70h], xmm13
+ movdqu [rax + 80h], xmm14
+ movdqu [rax + 90h], xmm15
+ mov rax, QWORD PTR [rsp+0]
+ mov (EFI_JUMP_BUFFER PTR [rdx])._rip, rax
+ mov rax, EFI_SUCCESS
+ ret
+
+TransferControlSetJump ENDP
+
+;
+; EFI_STATUS
+; EFIAPI
+; TransferControlLongJump (
+; IN EFI_PEI_TRANSFER_CONTROL_PROTOCOL *This, // rcx
+; IN EFI_JUMP_BUFFER *Jump // rdx
+; );
+;
+;
+PUBLIC TransferControlLongJump
+TransferControlLongJump PROC
+ ; load non-volatile fp registers
+ ldmxcsr (EFI_JUMP_BUFFER PTR [rdx])._MxCsr
+ lea rax, (EFI_JUMP_BUFFER PTR [rdx])._XmmBuffer
+ movdqu xmm6, [rax]
+ movdqu xmm7, [rax + 10h]
+ movdqu xmm8, [rax + 20h]
+ movdqu xmm9, [rax + 30h]
+ movdqu xmm10, [rax + 40h]
+ movdqu xmm11, [rax + 50h]
+ movdqu xmm12, [rax + 60h]
+ movdqu xmm13, [rax + 70h]
+ movdqu xmm14, [rax + 80h]
+ movdqu xmm15, [rax + 90h]
+ ; set return from SetJump to EFI_WARN_RETURN_FROM_LONG_JUMP
+ mov rax, EFI_WARN_RETURN_FROM_LONG_JUMP
+ mov rbx, (EFI_JUMP_BUFFER PTR [rdx])._rbx
+ mov rsp, (EFI_JUMP_BUFFER PTR [rdx])._rsp
+ mov rbp, (EFI_JUMP_BUFFER PTR [rdx])._rbp
+ mov rdi, (EFI_JUMP_BUFFER PTR [rdx])._rdi
+ mov rsi, (EFI_JUMP_BUFFER PTR [rdx])._rsi
+ mov r10, (EFI_JUMP_BUFFER PTR [rdx])._r10
+ mov r11, (EFI_JUMP_BUFFER PTR [rdx])._r11
+ mov r12, (EFI_JUMP_BUFFER PTR [rdx])._r12
+ mov r13, (EFI_JUMP_BUFFER PTR [rdx])._r13
+ mov r14, (EFI_JUMP_BUFFER PTR [rdx])._r14
+ mov r15, (EFI_JUMP_BUFFER PTR [rdx])._r15
+ add rsp, 8 ;pop the eip
+ jmp QWORD PTR (EFI_JUMP_BUFFER PTR [rdx])._rip
+ ; set return from SetJump to EFI_WARN_RETURN_FROM_LONG_JUMP
+ mov rax, EFI_WARN_RETURN_FROM_LONG_JUMP
+ ret
+TransferControlLongJump ENDP
+
+text ENDS
+END
diff --git a/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Debug.c b/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Debug.c
new file mode 100644
index 0000000..f0116cb
--- /dev/null
+++ b/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Debug.c
@@ -0,0 +1,154 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Debug.c
+
+Abstract:
+
+ Support for Debug primatives.
+
+--*/
+
+#include "Tiano.h"
+#include "EfiRuntimeLib.h"
+#include EFI_GUID_DEFINITION (StatusCodeCallerId)
+#include EFI_GUID_DEFINITION (StatusCodeDataTypeId)
+
+#define EFI_STATUS_CODE_DATA_MAX_SIZE64 (EFI_STATUS_CODE_DATA_MAX_SIZE / 8)
+
+VOID
+EfiDebugAssert (
+ IN CHAR8 *FileName,
+ IN INTN LineNumber,
+ IN CHAR8 *Description
+ )
+/*++
+
+Routine Description:
+
+ Worker function for ASSERT (). If Error Logging hub is loaded log ASSERT
+ information. If Error Logging hub is not loaded BREAKPOINT ().
+
+Arguments:
+
+ FileName - File name of failing routine.
+
+ LineNumber - Line number of failing ASSERT ().
+
+ Description - Description, usually the assertion,
+
+Returns:
+
+ None
+
+--*/
+{
+ UINT64 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE64];
+
+ EfiDebugAssertWorker (FileName, LineNumber, Description, sizeof (Buffer), Buffer);
+
+ EfiReportStatusCode (
+ (EFI_ERROR_CODE | EFI_ERROR_UNRECOVERED),
+ (EFI_SOFTWARE_DXE_RT_DRIVER | EFI_SW_EC_ILLEGAL_SOFTWARE_STATE),
+ 0,
+ &gEfiCallerIdGuid,
+ (EFI_STATUS_CODE_DATA *) Buffer
+ );
+
+ //
+ // Put break point in module that contained the error.
+ //
+ EFI_BREAKPOINT ();
+}
+
+VOID
+EfiDebugVPrint (
+ IN UINTN ErrorLevel,
+ IN CHAR8 *Format,
+ IN VA_LIST Marker
+ )
+/*++
+
+Routine Description:
+
+ Worker function for DEBUG (). If Error Logging hub is loaded log ASSERT
+ information. If Error Logging hub is not loaded do nothing.
+
+Arguments:
+
+ ErrorLevel - If error level is set do the debug print.
+
+ Format - String to use for the print, followed by Print arguments.
+
+ Marker - VarArgs
+
+Returns:
+
+ None
+
+--*/
+{
+ UINT64 Buffer[EFI_STATUS_CODE_DATA_MAX_SIZE64];
+
+ if (!(gRtErrorLevel & ErrorLevel)) {
+ return ;
+ }
+
+ EfiDebugVPrintWorker (ErrorLevel, Format, Marker, sizeof (Buffer), Buffer);
+
+ EfiReportStatusCode (
+ EFI_DEBUG_CODE,
+ (EFI_SOFTWARE_DXE_RT_DRIVER | EFI_DC_UNSPECIFIED),
+ (UINT32) ErrorLevel,
+ &gEfiCallerIdGuid,
+ (EFI_STATUS_CODE_DATA *) Buffer
+ );
+
+ return ;
+}
+
+VOID
+EfiDebugPrint (
+ IN UINTN ErrorLevel,
+ IN CHAR8 *Format,
+ ...
+ )
+/*++
+
+Routine Description:
+
+ Worker function for DEBUG (). If Error Logging hub is loaded log ASSERT
+ information. If Error Logging hub is not loaded do nothing.
+
+ We use UINT64 buffers due to IPF alignment concerns.
+
+Arguments:
+
+ ErrorLevel - If error level is set do the debug print.
+
+ Format - String to use for the print, followed by Print arguments.
+
+ ... - VAR args for Format
+
+Returns:
+
+ None
+
+--*/
+{
+ VA_LIST Marker;
+
+ VA_START (Marker, Format);
+ EfiDebugVPrint (ErrorLevel, Format, Marker);
+ VA_END (Marker);
+}
diff --git a/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/EfiRuntimeLib.cif b/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/EfiRuntimeLib.cif
new file mode 100644
index 0000000..bbdb5c9
--- /dev/null
+++ b/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/EfiRuntimeLib.cif
@@ -0,0 +1,32 @@
+<component>
+ name = "EfiRuntimeLib"
+ category = ModulePart
+ LocalRoot = "EDK\Foundation\Library\RuntimeDxe\EfiRuntimeLib\"
+ RefName = "EfiRuntimeLib"
+[files]
+"EfiRuntimeLib.sdl"
+"EfiRuntimeLib.mak"
+"Debug.c"
+"Event.c"
+"Io.c"
+"LibGlobals.c"
+"GetImage.c"
+"RtDevicePath.c"
+"ia32\RuntimeLib.c"
+"ia32\IoLib.c"
+"ia32\Lock.c"
+"ia32\PlatformIoLib.c"
+"ia32\Fvb.c"
+"x64\RuntimeLib.c"
+"x64\IoLib.c"
+"x64\Lock.c"
+"x64\PlatformIoLib.c"
+"x64\Fvb.c"
+"x64\RuntimeLibAsm.asm"
+"Ipf\RuntimeLib.c"
+"Ipf\Lock.c"
+"Ipf\Fvb.c"
+"Ipf\EsalLib.s"
+"Ipf\IpfCpuCache.s"
+"EfiRuntimeLib.inf"
+<endComponent>
diff --git a/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/EfiRuntimeLib.inf b/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/EfiRuntimeLib.inf
new file mode 100644
index 0000000..0558c53
--- /dev/null
+++ b/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/EfiRuntimeLib.inf
@@ -0,0 +1,78 @@
+#/*++
+#
+# Copyright (c) 2004 - 2006, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# EfiRuntimeLib.inf
+#
+# Abstract:
+#
+# Component description file for the EFI runtime library.
+#
+#--*/
+
+[defines]
+BASE_NAME = EfiRuntimeLib
+COMPONENT_TYPE = LIBRARY
+
+[sources.common]
+ Debug.c
+ Event.c
+ Io.c
+ LibGlobals.c
+ GetImage.c
+ RtDevicePath.c
+
+[sources.ia32]
+ Ia32\RuntimeLib.c
+ Ia32\IoLib.c
+ Ia32\Lock.c
+ Ia32\PlatformIoLib.c
+ Ia32\Fvb.c
+
+[sources.x64]
+ x64\RuntimeLib.c
+ x64\IoLib.c
+ x64\Lock.c
+ x64\PlatformIoLib.c
+ x64\Fvb.c
+ x64\RuntimeLibAsm.asm
+
+[sources.ipf]
+ Ipf\RuntimeLib.c
+ Ipf\Lock.c
+ Ipf\Fvb.c
+ Ipf\EsalLib.s
+ Ipf\IpfCpuCache.s
+
+[includes.common]
+ $(EDK_SOURCE)\Foundation
+ $(EDK_SOURCE)\Foundation\Framework
+ $(EDK_SOURCE)\Foundation\Efi
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+
+[libraries.common]
+ EdkGuidLib
+ EdkProtocolLib
+ EdkFrameworkProtocolLib
+ EfiGuidLib
+ EfiProtocolLib
+ ArchProtocolLib
+ EfiCommonLib
+
+[nmake.common]
+ C_STD_INCLUDE=
+
diff --git a/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/EfiRuntimeLib.mak b/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/EfiRuntimeLib.mak
new file mode 100644
index 0000000..9411933
--- /dev/null
+++ b/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/EfiRuntimeLib.mak
@@ -0,0 +1,101 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EfiRuntimeLib/EfiRuntimeLib.mak 1 1/20/12 4:12a Jeffch $
+#
+# $Revision: 1 $
+#
+# $Date: 1/20/12 4:12a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EfiRuntimeLib/EfiRuntimeLib.mak $
+#
+# 1 1/20/12 4:12a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 9/27/11 6:34a Wesleychen
+# Intel EDK initially releases.
+#
+# 3 12/03/09 4:29a Iminglin
+# Change "ArchProtocolLib" to "ARCHPROTOCOL".
+#
+# 2 9/02/09 4:00a Iminglin
+# EIP24919
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: EfiRuntimeLib.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+$(EFIRUNTIMELIB) : EfiRuntimeLib
+
+EFIRUNTIMELIB_OBJECTS=\
+$(BUILD_DIR)\$(EfiRuntimeLib_DIR)\Debug.obj\
+$(BUILD_DIR)\$(EfiRuntimeLib_DIR)\Event.obj\
+$(BUILD_DIR)\$(EfiRuntimeLib_DIR)\Io.obj\
+$(BUILD_DIR)\$(EfiRuntimeLib_DIR)\LibGlobals.obj\
+$(BUILD_DIR)\$(EfiRuntimeLib_DIR)\GetImage.obj\
+$(BUILD_DIR)\$(EfiRuntimeLib_DIR)\RtDevicePath.obj\
+$(BUILD_DIR)\$(EfiRuntimeLib_DIR)\$(PROCESSOR)\RuntimeLib.obj
+!IF "$(PROCESSOR)"=="IA32"
+EFIRUNTIMELIB_OBJECTS=$(EFIRUNTIMELIB_OBJECTS)\
+$(BUILD_DIR)\$(EfiRuntimeLib_DIR)\Ia32\Fvb.obj\
+$(BUILD_DIR)\$(EfiRuntimeLib_DIR)\Ia32\Lock.obj\
+$(BUILD_DIR)\$(EfiRuntimeLib_DIR)\Ia32\IoLib.obj\
+$(BUILD_DIR)\$(EfiRuntimeLib_DIR)\Ia32\PlatformIoLib.obj
+!ELSEIF "$(PROCESSOR)"=="x64"
+EFIRUNTIMELIB_OBJECTS=$(EFIRUNTIMELIB_OBJECTS)\
+$(BUILD_DIR)\$(EfiRuntimeLib_DIR)\x64\Fvb.obj\
+$(BUILD_DIR)\$(EfiRuntimeLib_DIR)\x64\Lock.obj\
+$(BUILD_DIR)\$(EfiRuntimeLib_DIR)\x64\IoLib.obj\
+$(BUILD_DIR)\$(EfiRuntimeLib_DIR)\x64\PlatformIoLib.obj\
+$(BUILD_DIR)\$(EfiRuntimeLib_DIR)\x64\RuntimeLibAsm.obj
+!ELSEIF "$(PROCESSOR)"=="IPF"
+EFIRUNTIMELIB_OBJECTS=$(EFIRUNTIMELIB_OBJECTS)\
+$(BUILD_DIR)\$(EfiRuntimeLib_DIR)\Ipf\Fvb.obj\
+$(BUILD_DIR)\$(EfiRuntimeLib_DIR)\Ipf\Lock.obj\
+$(BUILD_DIR)\$(EfiRuntimeLib_DIR)\Ipf\EsalLib.s\
+$(BUILD_DIR)\$(EfiRuntimeLib_DIR)\Ipf\IpfCpuCache.s
+!ENDIF
+
+$(BUILD_DIR)\EfiRuntimeLib.lib : EfiRuntimeLib
+
+EfiRuntimeLib : $(BUILD_DIR)\EfiRuntimeLib.mak EfiRuntimeLibBin
+
+$(BUILD_DIR)\EfiRuntimeLib.mak : $(EfiRuntimeLib_DIR)\$(@B).cif $(EfiRuntimeLib_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(EfiRuntimeLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+EfiRuntimeLibBin : $(EFIGUIDLIB) $(EDKGUIDLIB) $(EDKPROTOCOLLIB) $(EDKFRAMEWORKPROTOCOLLIB) $(ARCHPROTOCOLLIB) $(EFICOMMONLIB) $(EFIPROTOCOLLIB)
+ $(MAKE) /$(MAKEFLAGS) $(EDK_DEFAULTS)\
+ /f $(BUILD_DIR)\EfiRuntimeLib.mak all\
+ TYPE=LIBRARY "OBJECTS=$(EFIRUNTIMELIB_OBJECTS)"
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#********************************************************************** \ No newline at end of file
diff --git a/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/EfiRuntimeLib.sdl b/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/EfiRuntimeLib.sdl
new file mode 100644
index 0000000..7e4cac1
--- /dev/null
+++ b/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/EfiRuntimeLib.sdl
@@ -0,0 +1,26 @@
+TOKEN
+ Name = "EfiRuntimeLib_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable EfiRuntimeLib support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "EFIRUNTIMELIB"
+ Value = "$(BUILD_DIR)\EfiRuntimeLib.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "EfiRuntimeLib_DIR"
+End
+
+MODULE
+ Help = "Includes EfiRuntimeLib.mak to Project"
+ File = "EfiRuntimeLib.mak"
+End
+
diff --git a/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Event.c b/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Event.c
new file mode 100644
index 0000000..15dccfd
--- /dev/null
+++ b/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Event.c
@@ -0,0 +1,353 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Event.c
+
+Abstract:
+
+ Support for Event lib fucntions.
+
+--*/
+
+#include "Tiano.h"
+#include "EfiRuntimeLib.h"
+
+EFI_EVENT
+RtEfiLibCreateProtocolNotifyEvent (
+ IN EFI_GUID *ProtocolGuid,
+ IN EFI_TPL NotifyTpl,
+ IN EFI_EVENT_NOTIFY NotifyFunction,
+ IN VOID *NotifyContext,
+ OUT VOID **Registration
+ )
+/*++
+
+Routine Description:
+
+ Create a protocol notification event and return it.
+
+Arguments:
+
+ ProtocolGuid - Protocol to register notification event on.
+
+ NotifyTpl - Maximum TPL to single the NotifyFunction.
+
+ NotifyFunction - EFI notification routine.
+
+ NotifyContext - Context passed into Event when it is created.
+
+ Registration - Registration key returned from RegisterProtocolNotify().
+
+Returns:
+
+ The EFI_EVENT that has been registered to be signaled when a ProtocolGuid
+ is added to the system.
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_EVENT Event;
+
+ //
+ // Create the event
+ //
+ Status = gBS->CreateEvent (
+ EFI_EVENT_NOTIFY_SIGNAL,
+ NotifyTpl,
+ NotifyFunction,
+ NotifyContext,
+ &Event
+ );
+ ASSERT (!EFI_ERROR (Status));
+
+ //
+ // Register for protocol notifactions on this event
+ //
+ Status = gBS->RegisterProtocolNotify (
+ ProtocolGuid,
+ Event,
+ Registration
+ );
+
+ ASSERT (!EFI_ERROR (Status));
+
+ //
+ // Kick the event so we will perform an initial pass of
+ // current installed drivers
+ //
+ gBS->SignalEvent (Event);
+ return Event;
+}
+
+EFI_STATUS
+EfiLibGetSystemConfigurationTable (
+ IN EFI_GUID *TableGuid,
+ IN OUT VOID **Table
+ )
+/*++
+
+Routine Description:
+
+ Return the EFI 1.0 System Tabl entry with TableGuid
+
+Arguments:
+
+ TableGuid - Name of entry to return in the system table
+ Table - Pointer in EFI system table associated with TableGuid
+
+Returns:
+
+ EFI_SUCCESS - Table returned;
+ EFI_NOT_FOUND - TableGuid not in EFI system table
+
+--*/
+{
+ UINTN Index;
+
+ for (Index = 0; Index < gST->NumberOfTableEntries; Index++) {
+ if (EfiCompareGuid (TableGuid, &(gST->ConfigurationTable[Index].VendorGuid))) {
+ *Table = gST->ConfigurationTable[Index].VendorTable;
+ return EFI_SUCCESS;
+ }
+ }
+
+ return EFI_NOT_FOUND;
+}
+
+EFI_STATUS
+EfiConvertList (
+ IN UINTN DebugDisposition,
+ IN OUT EFI_LIST_ENTRY *ListHead
+ )
+/*++
+
+Routine Description:
+
+ Conver the standard Lib double linked list to a virtual mapping.
+
+Arguments:
+
+ DebugDisposition - Argument to EfiConvertPointer (EFI 1.0 API)
+
+ ListHead - Head of linked list to convert
+
+Returns:
+
+ EFI_SUCCESS
+
+--*/
+{
+ EFI_LIST_ENTRY *Link;
+ EFI_LIST_ENTRY *NextLink;
+
+ //
+ // Convert all the ForwardLink & BackLink pointers in the list
+ //
+ Link = ListHead;
+ do {
+ NextLink = Link->ForwardLink;
+
+ EfiConvertPointer (
+ Link->ForwardLink == ListHead ? DebugDisposition : 0,
+ (VOID **) &Link->ForwardLink
+ );
+
+ EfiConvertPointer (
+ Link->BackLink == ListHead ? DebugDisposition : 0,
+ (VOID **) &Link->BackLink
+ );
+
+ Link = NextLink;
+ } while (Link != ListHead);
+ return EFI_SUCCESS;
+}
+
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+
+STATIC
+VOID
+EFIAPI
+EventNotifySignalAllNullEvent (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+ //
+ // This null event is a size efficent way to enusre that
+ // EFI_EVENT_NOTIFY_SIGNAL_ALL is error checked correctly.
+ // EFI_EVENT_NOTIFY_SIGNAL_ALL is now mapped into
+ // CreateEventEx() and this function is used to make the
+ // old error checking in CreateEvent() for Tiano extensions
+ // function.
+ //
+ return;
+}
+
+#endif
+
+EFI_STATUS
+EFIAPI
+RtEfiCreateEventLegacyBoot (
+ IN EFI_TPL NotifyTpl,
+ IN EFI_EVENT_NOTIFY NotifyFunction,
+ IN VOID *NotifyContext,
+ OUT EFI_EVENT *LegacyBootEvent
+ )
+/*++
+
+Routine Description:
+ Create a Legacy Boot Event.
+ Tiano extended the CreateEvent Type enum to add a legacy boot event type.
+ This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was
+ added and now it's possible to not voilate the UEFI specification by
+ declaring a GUID for the legacy boot event class. This library supports
+ the R8.5/EFI 1.10 form and R8.6/UEFI 2.0 form and allows common code to
+ work both ways.
+
+Arguments:
+ LegacyBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex)
+
+Returns:
+ EFI_SUCCESS Event was created.
+ Other Event was not created.
+
+--*/
+{
+ EFI_STATUS Status;
+ UINT32 EventType;
+ EFI_EVENT_NOTIFY WorkerNotifyFunction;
+
+#if (EFI_SPECIFICATION_VERSION < 0x00020000)
+
+ if (NotifyFunction == NULL) {
+ EventType = EFI_EVENT_SIGNAL_LEGACY_BOOT | EFI_EVENT_NOTIFY_SIGNAL_ALL;
+ } else {
+ EventType = EFI_EVENT_SIGNAL_LEGACY_BOOT;
+ }
+ WorkerNotifyFunction = NotifyFunction;
+
+ //
+ // prior to UEFI 2.0 use Tiano extension to EFI
+ //
+ Status = gBS->CreateEvent (
+ EventType,
+ NotifyTpl,
+ WorkerNotifyFunction,
+ NotifyContext,
+ LegacyBootEvent
+ );
+#else
+
+ EventType = EFI_EVENT_NOTIFY_SIGNAL;
+ if (NotifyFunction == NULL) {
+ //
+ // CreatEventEx will check NotifyFunction is NULL or not
+ //
+ WorkerNotifyFunction = EventNotifySignalAllNullEvent;
+ } else {
+ WorkerNotifyFunction = NotifyFunction;
+ }
+
+ //
+ // For UEFI 2.0 and the future use an Event Group
+ //
+ Status = gBS->CreateEventEx (
+ EventType,
+ NotifyTpl,
+ WorkerNotifyFunction,
+ NotifyContext,
+ &gEfiEventLegacyBootGuid,
+ LegacyBootEvent
+ );
+#endif
+ return Status;
+}
+
+EFI_STATUS
+EFIAPI
+RtEfiCreateEventReadyToBoot (
+ IN EFI_TPL NotifyTpl,
+ IN EFI_EVENT_NOTIFY NotifyFunction,
+ IN VOID *NotifyContext,
+ OUT EFI_EVENT *ReadyToBootEvent
+ )
+/*++
+
+Routine Description:
+ Create a Read to Boot Event.
+
+ Tiano extended the CreateEvent Type enum to add a ready to boot event type.
+ This was bad as Tiano did not own the enum. In UEFI 2.0 CreateEventEx was
+ added and now it's possible to not voilate the UEFI specification and use
+ the ready to boot event class defined in UEFI 2.0. This library supports
+ the R8.5/EFI 1.10 form and R8.6/UEFI 2.0 form and allows common code to
+ work both ways.
+
+Arguments:
+ ReadyToBootEvent Returns the EFI event returned from gBS->CreateEvent(Ex)
+
+Return:
+ EFI_SUCCESS - Event was created.
+ Other - Event was not created.
+
+--*/
+{
+ EFI_STATUS Status;
+ UINT32 EventType;
+ EFI_EVENT_NOTIFY WorkerNotifyFunction;
+
+#if (EFI_SPECIFICATION_VERSION < 0x00020000)
+
+ if (NotifyFunction == NULL) {
+ EventType = EFI_EVENT_SIGNAL_READY_TO_BOOT | EFI_EVENT_NOTIFY_SIGNAL_ALL;
+ } else {
+ EventType = EFI_EVENT_SIGNAL_READY_TO_BOOT;
+ }
+ WorkerNotifyFunction = NotifyFunction;
+
+ //
+ // prior to UEFI 2.0 use Tiano extension to EFI
+ //
+ Status = gBS->CreateEvent (
+ EventType,
+ NotifyTpl,
+ WorkerNotifyFunction,
+ NotifyContext,
+ ReadyToBootEvent
+ );
+#else
+
+ EventType = EFI_EVENT_NOTIFY_SIGNAL;
+ if (NotifyFunction == NULL) {
+ //
+ // CreatEventEx will check NotifyFunction is NULL or not
+ //
+ WorkerNotifyFunction = EventNotifySignalAllNullEvent;
+ } else {
+ WorkerNotifyFunction = NotifyFunction;
+ }
+
+ //
+ // For UEFI 2.0 and the future use an Event Group
+ //
+ Status = gBS->CreateEventEx (
+ EventType,
+ NotifyTpl,
+ WorkerNotifyFunction,
+ NotifyContext,
+ &gEfiEventReadyToBootGuid,
+ ReadyToBootEvent
+ );
+#endif
+ return Status;
+} \ No newline at end of file
diff --git a/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/GetImage.c b/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/GetImage.c
new file mode 100644
index 0000000..c67b665
--- /dev/null
+++ b/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/GetImage.c
@@ -0,0 +1,221 @@
+/*++
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ GetImage.c
+
+Abstract:
+
+ Image data extraction support for common use.
+
+--*/
+
+#include "Tiano.h"
+#include "EfiRuntimeLib.h"
+#include "EfiImageFormat.h"
+
+#include EFI_PROTOCOL_CONSUMER (LoadedImage)
+
+EFI_STATUS
+GetImageFromFv (
+#if (PI_SPECIFICATION_VERSION < 0x00010000) //;;## ...AMI_OVERRIDE... Support PI1.x
+ IN EFI_FIRMWARE_VOLUME_PROTOCOL *Fv,
+#else
+ IN EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv,
+#endif
+ IN EFI_GUID *NameGuid,
+ IN EFI_SECTION_TYPE SectionType,
+ OUT VOID **Buffer,
+ OUT UINTN *Size
+ )
+{
+ EFI_STATUS Status;
+ EFI_FV_FILETYPE FileType;
+ EFI_FV_FILE_ATTRIBUTES Attributes;
+ UINT32 AuthenticationStatus;
+
+ //
+ // Read desired section content in NameGuid file
+ //
+ *Buffer = NULL;
+ *Size = 0;
+ Status = Fv->ReadSection (
+ Fv,
+ NameGuid,
+ SectionType,
+ 0,
+ Buffer,
+ Size,
+ &AuthenticationStatus
+ );
+
+ if (EFI_ERROR (Status) && (SectionType == EFI_SECTION_TE)) {
+ //
+ // Try reading PE32 section, since the TE section does not exist
+ //
+ *Buffer = NULL;
+ *Size = 0;
+ Status = Fv->ReadSection (
+ Fv,
+ NameGuid,
+ EFI_SECTION_PE32,
+ 0,
+ Buffer,
+ Size,
+ &AuthenticationStatus
+ );
+ }
+
+ if (EFI_ERROR (Status) &&
+ ((SectionType == EFI_SECTION_TE) || (SectionType == EFI_SECTION_PE32))) {
+ //
+ // Try reading raw file, since the desired section does not exist
+ //
+ *Buffer = NULL;
+ *Size = 0;
+ Status = Fv->ReadFile (
+ Fv,
+ NameGuid,
+ Buffer,
+ Size,
+ &FileType,
+ &Attributes,
+ &AuthenticationStatus
+ );
+ }
+
+ return Status;
+}
+
+EFI_STATUS
+GetImage (
+ IN EFI_GUID *NameGuid,
+ IN EFI_SECTION_TYPE SectionType,
+ OUT VOID **Buffer,
+ OUT UINTN *Size
+ )
+{
+ return GetImageEx (NULL, NameGuid, SectionType, Buffer, Size, FALSE);
+}
+
+EFI_STATUS
+GetImageEx (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_GUID *NameGuid,
+ IN EFI_SECTION_TYPE SectionType,
+ OUT VOID **Buffer,
+ OUT UINTN *Size,
+ BOOLEAN WithinImageFv
+ )
+{
+ EFI_STATUS Status;
+ EFI_HANDLE *HandleBuffer;
+ UINTN HandleCount;
+ UINTN Index;
+ EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
+#if (PI_SPECIFICATION_VERSION < 0x00010000) //;;## ...AMI_OVERRIDE... Support PI1.x
+ EFI_FIRMWARE_VOLUME_PROTOCOL *ImageFv;
+ EFI_FIRMWARE_VOLUME_PROTOCOL *Fv;
+#else
+ EFI_FIRMWARE_VOLUME2_PROTOCOL *ImageFv;
+ EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv;
+#endif
+
+ if (ImageHandle == NULL && WithinImageFv) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ Status = EFI_NOT_FOUND;
+ ImageFv = NULL;
+ if (ImageHandle != NULL) {
+ Status = gBS->HandleProtocol (
+ ImageHandle,
+ &gEfiLoadedImageProtocolGuid,
+ (VOID **) &LoadedImage
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ Status = gBS->HandleProtocol (
+ LoadedImage->DeviceHandle,
+ #if (PI_SPECIFICATION_VERSION < 0x00010000)
+ &gEfiFirmwareVolumeProtocolGuid,
+ #else
+ &gEfiFirmwareVolume2ProtocolGuid,
+ #endif
+ (VOID **) &ImageFv
+ );
+ if (!EFI_ERROR (Status)) {
+ Status = GetImageFromFv (ImageFv, NameGuid, SectionType, Buffer, Size);
+ }
+ }
+
+ if (Status == EFI_SUCCESS || WithinImageFv) {
+ return Status;
+ }
+
+ Status = gBS->LocateHandleBuffer (
+ ByProtocol,
+ #if (PI_SPECIFICATION_VERSION < 0x00010000)
+ &gEfiFirmwareVolumeProtocolGuid,
+ #else
+ &gEfiFirmwareVolume2ProtocolGuid,
+ #endif
+ NULL,
+ &HandleCount,
+ &HandleBuffer
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ //
+ // Find desired image in all Fvs
+ //
+ for (Index = 0; Index < HandleCount; ++Index) {
+ Status = gBS->HandleProtocol (
+ HandleBuffer[Index],
+ #if (PI_SPECIFICATION_VERSION < 0x00010000)
+ &gEfiFirmwareVolumeProtocolGuid,
+ #else
+ &gEfiFirmwareVolume2ProtocolGuid,
+ #endif
+ (VOID**)&Fv
+ );
+
+ if (EFI_ERROR (Status)) {
+ gBS->FreePool(HandleBuffer);
+ return Status;
+ }
+
+ if (ImageFv != NULL && Fv == ImageFv) {
+ continue;
+ }
+
+ Status = GetImageFromFv (Fv, NameGuid, SectionType, Buffer, Size);
+
+ if (!EFI_ERROR (Status)) {
+ break;
+ }
+ }
+ gBS->FreePool(HandleBuffer);
+
+ //
+ // Not found image
+ //
+ if (Index == HandleCount) {
+ return EFI_NOT_FOUND;
+ }
+
+ return EFI_SUCCESS;
+}
+
diff --git a/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Io.c b/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Io.c
new file mode 100644
index 0000000..a32f18a
--- /dev/null
+++ b/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Io.c
@@ -0,0 +1,249 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Io.c
+
+Abstract:
+
+ Light weight lib functions that wrape IoRead (), IoWrite, MemRead (),
+ and MemWrite ().
+
+--*/
+
+#include "Tiano.h"
+#include "EfiRuntimeLib.h"
+
+UINT8
+IoRead8 (
+ IN UINT64 Address
+ )
+/*++
+
+Routine Description:
+ Do a one byte IO read
+
+Arguments:
+ Address - IO address to read
+
+Returns:
+ Data read
+
+--*/
+{
+ UINT8 Buffer;
+
+ EfiIoRead (EfiCpuIoWidthUint8, Address, 1, &Buffer);
+ return Buffer;
+}
+
+UINT16
+IoRead16 (
+ IN UINT64 Address
+ )
+/*++
+
+Routine Description:
+ Do a two byte IO read
+
+Arguments:
+ Address - IO address to read
+
+Returns:
+ Data read
+
+--*/
+{
+ UINT16 Buffer;
+
+ EfiIoRead (EfiCpuIoWidthUint16, Address, 1, &Buffer);
+ return Buffer;
+}
+
+UINT32
+IoRead32 (
+ IN UINT64 Address
+ )
+/*++
+
+Routine Description:
+ Do a four byte IO read
+
+Arguments:
+ Address - IO address to read
+
+Returns:
+ Data read
+
+--*/
+{
+ UINT32 Buffer;
+
+ EfiIoRead (EfiCpuIoWidthUint32, Address, 1, &Buffer);
+ return Buffer;
+}
+
+VOID
+IoWrite8 (
+ IN UINT64 Address,
+ IN UINT8 Data
+ )
+/*++
+
+Routine Description:
+ Do a one byte IO write
+
+Arguments:
+ Address - IO address to write
+ Data - Data to write to Address
+
+Returns:
+ NONE
+
+--*/
+{
+ EfiIoWrite (EfiCpuIoWidthUint8, Address, 1, &Data);
+}
+
+VOID
+IoWrite16 (
+ IN UINT64 Address,
+ IN UINT16 Data
+ )
+/*++
+
+Routine Description:
+ Do a two byte IO write
+
+Arguments:
+ Address - IO address to write
+ Data - Data to write to Address
+
+Returns:
+ NONE
+
+--*/
+{
+ EfiIoWrite (EfiCpuIoWidthUint16, Address, 1, &Data);
+}
+
+VOID
+IoWrite32 (
+ IN UINT64 Address,
+ IN UINT32 Data
+ )
+/*++
+
+Routine Description:
+ Do a four byte IO write
+
+Arguments:
+ Address - IO address to write
+ Data - Data to write to Address
+
+Returns:
+ NONE
+
+--*/
+{
+ EfiIoWrite (EfiCpuIoWidthUint32, Address, 1, &Data);
+}
+
+UINT32
+MemRead32 (
+ IN UINT64 Address
+ )
+/*++
+
+Routine Description:
+ Do a four byte Memory mapped IO read
+
+Arguments:
+ Address - Memory mapped IO address to read
+
+Returns:
+ Data read
+
+--*/
+{
+ UINT32 Buffer;
+
+ EfiMemRead (EfiCpuIoWidthUint32, Address, 1, &Buffer);
+ return Buffer;
+}
+
+UINT64
+MemRead64 (
+ IN UINT64 Address
+ )
+/*++
+
+Routine Description:
+ Do a eight byte Memory mapped IO read
+
+Arguments:
+ Address - Memory mapped IO address to read
+
+Returns:
+ Data read
+
+--*/
+{
+ UINT64 Buffer;
+
+ EfiMemRead (EfiCpuIoWidthUint64, Address, 1, &Buffer);
+ return Buffer;
+}
+
+VOID
+MemWrite32 (
+ IN UINT64 Address,
+ IN UINT32 Data
+ )
+/*++
+
+Routine Description:
+ Do a four byte Memory mapped IO write
+
+Arguments:
+ Address - Memory mapped IO address to write
+ Data - Data to write to Address
+
+Returns:
+ NONE
+
+--*/
+{
+ EfiMemWrite (EfiCpuIoWidthUint32, Address, 1, &Data);
+}
+
+VOID
+MemWrite64 (
+ IN UINT64 Address,
+ IN UINT64 Data
+ )
+/*++
+
+Routine Description:
+ Do a eight byte Memory mapped IO write
+
+Arguments:
+ Address - Memory mapped IO address to write
+ Data - Data to write to Address
+
+Returns:
+ NONE
+
+--*/
+{
+ EfiMemWrite (EfiCpuIoWidthUint64, Address, 1, &Data);
+}
diff --git a/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ipf/EsalLib.s b/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ipf/EsalLib.s
new file mode 100644
index 0000000..801df4c
--- /dev/null
+++ b/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ipf/EsalLib.s
@@ -0,0 +1,149 @@
+//++
+// Copyright (c) 2004, Intel Corporation
+// All rights reserved. This program and the accompanying materials
+// are licensed and made available under the terms and conditions of the BSD License
+// which accompanies this distribution. The full text of the license may be found at
+// http://opensource.org/licenses/bsd-license.php
+//
+// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+//
+// Module Name:
+//
+// EsalLib.s
+//
+// Abstract:
+//
+//
+// Revision History:
+//
+//--
+
+.file "EsalLib.s"
+
+#include "IpfMacro.i"
+
+//
+// Exports
+//
+.global GetEsalEntryPoint
+
+
+//-----------------------------------------------------------------------------
+//++
+// GetEsalEntryPoint
+//
+// Return Esal global and PSR register.
+//
+// On Entry :
+//
+//
+// Return Value:
+// r8 = EFI_SAL_SUCCESS
+// r9 = Physical Plabel
+// r10 = Virtual Plabel
+// r11 = psr
+//
+// As per static calling conventions.
+//
+//--
+//---------------------------------------------------------------------------
+PROCEDURE_ENTRY (GetEsalEntryPoint)
+
+ NESTED_SETUP (0,8,0,0)
+
+EsalCalcStart:
+ mov r8 = ip;;
+ add r8 = (EsalEntryPoint - EsalCalcStart), r8;;
+ mov r9 = r8;;
+ add r10 = 0x10, r8;;
+ mov r11 = psr;;
+ mov r8 = r0;;
+
+ NESTED_RETURN
+
+PROCEDURE_EXIT (GetEsalEntryPoint)
+
+
+
+
+
+//-----------------------------------------------------------------------------
+//++
+// SetEsalPhysicalEntryPoint
+//
+// Set the dispatcher entry point
+//
+// On Entry:
+// in0 = Physical address of Esal Dispatcher
+// in1 = Physical GP
+//
+// Return Value:
+// r8 = EFI_SAL_SUCCESS
+//
+// As per static calling conventions.
+//
+//--
+//---------------------------------------------------------------------------
+PROCEDURE_ENTRY (SetEsalPhysicalEntryPoint)
+
+ NESTED_SETUP (2,8,0,0)
+
+EsalCalcStart1:
+ mov r8 = ip;;
+ add r8 = (EsalEntryPoint - EsalCalcStart1), r8;;
+ st8 [r8] = in0;;
+ add r8 = 0x08, r8;;
+ st8 [r8] = in1;;
+ mov r8 = r0;;
+
+ NESTED_RETURN
+
+PROCEDURE_EXIT (SetEsalPhysicalEntryPoint)
+
+
+//-----------------------------------------------------------------------------
+//++
+// SetEsalVirtualEntryPoint
+//
+// Register physical address of Esal globals.
+//
+// On Entry :
+// in0 = Virtual address of Esal Dispatcher
+// in1 = Virtual GP
+//
+// Return Value:
+// r8 = EFI_SAL_ERROR
+//
+// As per static calling conventions.
+//
+//--
+//---------------------------------------------------------------------------
+PROCEDURE_ENTRY (SetEsalVirtualEntryPoint)
+
+ NESTED_SETUP (2,8,0,0)
+
+EsalCalcStart2:
+ mov r8 = ip;;
+ add r8 = (EsalEntryPoint - EsalCalcStart2), r8;;
+ add r8 = 0x10, r8;;
+ st8 [r8] = in0;;
+ add r8 = 0x08, r8;;
+ st8 [r8] = in1;;
+ mov r8 = r0;;
+
+ NESTED_RETURN
+
+PROCEDURE_EXIT (SetEsalVirtualEntryPoint)
+
+
+
+
+.align 32
+EsalEntryPoint:
+ data8 0 // Physical Entry
+ data8 0 // GP
+ data8 0 // Virtual Entry
+ data8 0 // GP
+
+
diff --git a/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ipf/Fvb.c b/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ipf/Fvb.c
new file mode 100644
index 0000000..88ba6ce
--- /dev/null
+++ b/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ipf/Fvb.c
@@ -0,0 +1,332 @@
+/*++
+
+Copyright (c) 2004 - 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Fvb.c
+
+Abstract:
+
+ Light weight lib to support Tiano Firmware Volume Block
+ protocol abstraction at runtime.
+
+ All these functions convert EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID
+ class function to the Runtime Lib function. There is a 1 to 1 mapping.
+
+ If you are using any of these lib functions.you must first call FvbInitialize ().
+
+--*/
+
+#include "Tiano.h"
+#include "EfiRuntimeLib.h"
+#include EFI_PROTOCOL_DEFINITION (ExtendedSalGuid)
+#include "SalApi.h"
+
+EFI_STATUS
+EfiFvbInitialize (
+ VOID
+ )
+/*++
+
+Routine Description:
+ Initialize globals and register Fvb Protocol notification function.
+
+Arguments:
+ None
+
+Returns:
+ EFI_SUCCESS
+
+--*/
+{
+ return EFI_SUCCESS;
+}
+//
+// The following functions wrap Fvb protocol in the Runtime Lib functions.
+// The Instance translates into Fvb instance. The Fvb order defined by HOBs and
+// thus the sequence of FVB protocol addition define Instance.
+//
+// EfiFvbInitialize () must be called before any of the following functions
+// must be called.
+//
+EFI_STATUS
+EfiFvbReadBlock (
+ IN UINTN Instance,
+ IN EFI_LBA Lba,
+ IN UINTN Offset,
+ IN OUT UINTN *NumBytes,
+ IN UINT8 *Buffer
+ )
+/*++
+
+Routine Description:
+ Reads specified number of bytes into a buffer from the specified block
+
+Arguments:
+ Instance - The FV instance to be read from
+ Lba - The logical block address to be read from
+ Offset - Offset into the block at which to begin reading
+ NumBytes - Pointer that on input contains the total size of
+ the buffer. On output, it contains the total number
+ of bytes read
+ Buffer - Pointer to a caller allocated buffer that will be
+ used to hold the data read
+
+Returns:
+ Status code
+
+--*/
+{
+ EFI_GUID Guid = EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID;
+
+ return EfiCallEsalService (&Guid, Read, Instance, Lba, Offset, (UINT64) NumBytes, (UINT64) Buffer, 0, 0).Status;
+}
+
+EFI_STATUS
+EfiFvbWriteBlock (
+ IN UINTN Instance,
+ IN EFI_LBA Lba,
+ IN UINTN Offset,
+ IN OUT UINTN *NumBytes,
+ IN UINT8 *Buffer
+ )
+/*++
+
+Routine Description:
+ Writes specified number of bytes from the input buffer to the block
+
+Arguments:
+ Instance - The FV instance to be written to
+ Lba - The starting logical block index to write to
+ Offset - Offset into the block at which to begin writing
+ NumBytes - Pointer that on input contains the total size of
+ the buffer. On output, it contains the total number
+ of bytes actually written
+ Buffer - Pointer to a caller allocated buffer that contains
+ the source for the write
+
+Returns:
+ Status code
+
+--*/
+{
+ EFI_GUID Guid = EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID;
+
+ return EfiCallEsalService (&Guid, Write, Instance, Lba, Offset, (UINT64) NumBytes, (UINT64) Buffer, 0, 0).Status;
+}
+
+EFI_STATUS
+EfiFvbEraseBlock (
+ IN UINTN Instance,
+ IN UINTN Lba
+ )
+/*++
+
+Routine Description:
+ Erases and initializes a firmware volume block
+
+Arguments:
+ Instance - The FV instance to be erased
+ Lba - The logical block index to be erased
+
+Returns:
+ Status code
+
+--*/
+{
+ EFI_GUID Guid = EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID;
+
+ return EfiCallEsalService (&Guid, EraseBlock, Instance, Lba, 0, 0, 0, 0, 0).Status;
+}
+
+EFI_STATUS
+EfiFvbGetVolumeAttributes (
+ IN UINTN Instance,
+ OUT EFI_FVB_ATTRIBUTES *Attributes
+ )
+/*++
+
+Routine Description:
+ Retrieves attributes, insures positive polarity of attribute bits, returns
+ resulting attributes in output parameter
+
+Arguments:
+ Instance - The FV instance whose attributes is going to be
+ returned
+ Attributes - Output buffer which contains attributes
+
+Returns:
+ Status code
+
+--*/
+{
+ EFI_GUID Guid = EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID;
+
+ return EfiCallEsalService (&Guid, SetVolumeAttributes, Instance, (UINT64) Attributes, 0, 0, 0, 0, 0).Status;
+}
+
+EFI_STATUS
+EfiFvbSetVolumeAttributes (
+ IN UINTN Instance,
+ IN EFI_FVB_ATTRIBUTES Attributes
+ )
+/*++
+
+Routine Description:
+ Modifies the current settings of the firmware volume according to the
+ input parameter.
+
+Arguments:
+ Instance - The FV instance whose attributes is going to be
+ modified
+ Attributes - It is a pointer to EFI_FVB_ATTRIBUTES
+ containing the desired firmware volume settings.
+
+Returns:
+ Status code
+
+--*/
+{
+ EFI_GUID Guid = EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID;
+
+ return EfiCallEsalService (&Guid, SetVolumeAttributes, Instance, (UINT64) (&Attributes), 0, 0, 0, 0, 0).Status;
+}
+
+EFI_STATUS
+EfiFvbGetPhysicalAddress (
+ IN UINTN Instance,
+ OUT EFI_PHYSICAL_ADDRESS *BaseAddress
+ )
+/*++
+
+Routine Description:
+ Retrieves the physical address of a memory mapped FV
+
+Arguments:
+ Instance - The FV instance whose base address is going to be
+ returned
+ BaseAddress - Pointer to a caller allocated EFI_PHYSICAL_ADDRESS
+ that on successful return, contains the base address
+ of the firmware volume.
+
+Returns:
+ Status code
+
+--*/
+{
+ EFI_GUID Guid = EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID;
+
+ return EfiCallEsalService (&Guid, GetPhysicalAddress, Instance, (UINT64) BaseAddress, 0, 0, 0, 0, 0).Status;
+}
+
+EFI_STATUS
+EfiFvbGetBlockSize (
+ IN UINTN Instance,
+ IN EFI_LBA Lba,
+ OUT UINTN *BlockSize,
+ OUT UINTN *NumOfBlocks
+ )
+/*++
+
+Routine Description:
+ Retrieve the size of a logical block
+
+Arguments:
+ Instance - The FV instance whose block size is going to be
+ returned
+ Lba - Indicates which block to return the size for.
+ BlockSize - A pointer to a caller allocated UINTN in which
+ the size of the block is returned
+ NumOfBlocks - a pointer to a caller allocated UINTN in which the
+ number of consecutive blocks starting with Lba is
+ returned. All blocks in this range have a size of
+ BlockSize
+
+Returns:
+ EFI_SUCCESS - The firmware volume was read successfully and
+ contents are in Buffer
+
+--*/
+{
+ EFI_GUID Guid = EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID;
+
+ return EfiCallEsalService (
+ &Guid,
+ GetBlockSize,
+ Instance,
+ Lba,
+ (UINT64) BlockSize,
+ (UINT64) NumOfBlocks,
+ 0,
+ 0,
+ 0
+ ).Status;
+}
+
+EFI_STATUS
+EfiFvbEraseCustomBlockRange (
+ IN UINTN Instance,
+ IN EFI_LBA StartLba,
+ IN UINTN OffsetStartLba,
+ IN EFI_LBA LastLba,
+ IN UINTN OffsetLastLba
+ )
+/*++
+
+Routine Description:
+ Erases and initializes a specified range of a firmware volume
+
+Arguments:
+ Instance - The FV instance to be erased
+ StartLba - The starting logical block index to be erased
+ OffsetStartLba - Offset into the starting block at which to
+ begin erasing
+ LastLba - The last logical block index to be erased
+ OffsetLastLba - Offset into the last block at which to end erasing
+
+Returns:
+ Status code
+
+--*/
+{
+ EFI_GUID Guid = EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID;
+
+ return EfiCallEsalService (
+ &Guid,
+ EraseCustomBlockRange,
+ Instance,
+ StartLba,
+ OffsetStartLba,
+ LastLba,
+ OffsetLastLba,
+ 0,
+ 0
+ ).Status;
+}
+EFI_STATUS
+EfiFvbShutdown (
+ VOID
+ )
+/*++
+
+Routine Description:
+ Release resources allocated in EfiFvbInitialize.
+
+Arguments:
+ None
+
+Returns:
+ EFI_SUCCESS
+
+--*/
+{
+ return EFI_SUCCESS;
+} \ No newline at end of file
diff --git a/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ipf/IpfCpuCache.s b/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ipf/IpfCpuCache.s
new file mode 100644
index 0000000..73d1bac
--- /dev/null
+++ b/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ipf/IpfCpuCache.s
@@ -0,0 +1,88 @@
+//++
+// Copyright (c) 2004, Intel Corporation
+// All rights reserved. This program and the accompanying materials
+// are licensed and made available under the terms and conditions of the BSD License
+// which accompanies this distribution. The full text of the license may be found at
+// http://opensource.org/licenses/bsd-license.php
+//
+// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+//
+// Module Name:
+//
+// IpfCpuCache.s
+//
+// Abstract:
+//
+// Contains Misc assembly procedures to support IPF CPU AP.
+//
+// Revision History:
+//
+//--
+
+.file "IpfCpuCache.s"
+
+#include "IpfMacro.i"
+#include "IpfDefines.h"
+
+//-----------------------------------------------------------------------------
+//++
+// Flush Cache
+//
+// Arguments :
+
+// Input = in0 = Starting Address to Flush.
+// Input = in1 = Length in bytes.
+// Input = b0 = return branch register.
+// On Entry :
+//
+// Return Value:
+//
+// VOID
+// SalFlushCache (
+// IN UINT64 BaseToFlush,
+// IN UINT64 LengthToFlush
+// );
+//
+//--
+//---------------------------------------------------------------------------
+PROCEDURE_ENTRY (SalFlushCache)
+
+ NESTED_SETUP (5,8,0,0)
+
+ mov loc2 = ar.lc
+
+ mov loc3 = in0 // Start address.
+ mov loc4 = in1;; // Length in bytes.
+
+ cmp.eq p6,p7 = loc4, r0;; // If Length is zero then don't flush any cache
+ (p6) br.spnt.many DoneFlushingC;;
+
+ add loc4 = loc4,loc3
+ mov loc5 = 1;;
+ sub loc4 = loc4, loc5 ;; // the End address to flush
+
+ dep loc3 = r0,loc3,0,5
+ dep loc4 = r0,loc4,0,5;;
+ shr loc3 = loc3,5
+ shr loc4 = loc4,5;; // 32 byte cache line
+
+ sub loc4 = loc4,loc3;; // total flush count, It should be add 1 but
+ // the br.cloop will first execute one time
+ mov loc3 = in0
+ mov loc5 = 32
+ mov ar.lc = loc4;;
+
+StillFlushingC:
+ fc loc3;;
+ sync.i;;
+ srlz.i;;
+ add loc3 = loc5,loc3;;
+ br.cloop.sptk.few StillFlushingC;;
+
+DoneFlushingC:
+ mov ar.lc = loc2
+ NESTED_RETURN
+
+PROCEDURE_EXIT (SalFlushCache)
+
diff --git a/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ipf/Lock.c b/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ipf/Lock.c
new file mode 100644
index 0000000..9aa2b36
--- /dev/null
+++ b/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ipf/Lock.c
@@ -0,0 +1,170 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Lock.c
+
+Abstract:
+
+ Support for locking lib services. These primitives may be implemented
+ as Esal calls but since these result in small code that us position
+ independent, we can use lib functions. ESAL calls have a significant
+ software overhead and too deep nesting is bad for the stack.
+
+--*/
+
+#include "Tiano.h"
+#include "EfiDriverLib.h"
+
+extern
+BOOLEAN
+EfiAtRuntime (
+ VOID
+ );
+
+VOID
+EfiInitializeLock (
+ IN OUT EFI_LOCK *Lock,
+ IN EFI_TPL Priority
+ )
+/*++
+
+Routine Description:
+
+ Initialize a basic mutual exclusion lock. There is
+ no concept of TPL at runtime hence priority is
+ ignored.
+
+Arguments:
+
+ Lock - The EFI_LOCK structure to initialize
+
+ Priority - Ignored
+
+
+Returns:
+
+ An initialized Efi Lock structure.
+
+--*/
+{
+ Lock->Tpl = Priority;
+ Lock->OwnerTpl = 0;
+ Lock->Lock = 0;
+}
+
+EFI_STATUS
+EfiAcquireLockOrFail (
+ IN EFI_LOCK *Lock
+ )
+/*++
+
+Routine Description:
+
+ Initialize a basic mutual exclusion lock. For now,
+ only allow one level of nesting.
+
+Arguments:
+
+ Lock - The EFI_LOCK structure to initialize
+
+Returns:
+
+ EFI_SUCCESS - Lock Owned.
+ EFI_ACCESS_DENIED - Reentrant Lock Acquisition, Lock not Owned.
+
+--*/
+{
+ if (Lock->Lock != 0) {
+ //
+ // Lock is already owned, so bail out
+ //
+ return EFI_ACCESS_DENIED;
+ }
+
+ if (!EfiAtRuntime ()) {
+ //
+ // The check is just debug code for core inplementation. It must
+ // always be true in a driver
+ //
+ Lock->OwnerTpl = gBS->RaiseTPL (Lock->Tpl);
+ }
+
+ Lock->Lock += 1;
+ return EFI_SUCCESS;
+}
+
+VOID
+EfiAcquireLock (
+ IN EFI_LOCK *Lock
+ )
+/*++
+
+Routine Description:
+
+ Acquires ownership of the lock.
+
+Arguments:
+
+ Lock - The lock to acquire
+
+Returns:
+
+ Lock owned
+
+--*/
+{
+ EFI_STATUS Status;
+
+ Status = EfiAcquireLockOrFail (Lock);
+
+ //
+ // Lock was already locked.
+ //
+ ASSERT_EFI_ERROR (Status);
+}
+
+VOID
+EfiReleaseLock (
+ IN EFI_LOCK *Lock
+ )
+/*++
+
+Routine Description:
+
+ Releases ownership of the mutual exclusion lock.
+
+Arguments:
+
+ Lock - The lock to release
+
+Returns:
+
+ Lock unowned
+
+--*/
+{
+ EFI_TPL Tpl;
+
+ Tpl = Lock->OwnerTpl;
+
+ ASSERT (Lock->Lock == 1);
+ Lock->Lock -= 1;
+
+ if (!EfiAtRuntime ()) {
+ //
+ // The check is just debug code for core inplementation. It must
+ // always be true in a driver
+ //
+ gBS->RestoreTPL (Tpl);
+ }
+}
diff --git a/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ipf/RuntimeLib.c b/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ipf/RuntimeLib.c
new file mode 100644
index 0000000..49ba543
--- /dev/null
+++ b/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/Ipf/RuntimeLib.c
@@ -0,0 +1,1317 @@
+/*++
+
+Copyright (c) 2004 - 2005, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ RuntimeLib.c
+
+Abstract:
+
+ Light weight lib to support Tiano Sal drivers.
+
+--*/
+
+#include "Tiano.h"
+#include "EfiRuntimeLib.h"
+#include EFI_PROTOCOL_DEFINITION (ExtendedSalBootService)
+#include EFI_PROTOCOL_DEFINITION (ExtendedSalGuid)
+#include "IpfDefines.h"
+#include "SalApi.h"
+
+//
+// Worker functions in EsalLib.s
+//
+SAL_RETURN_REGS
+GetEsalEntryPoint (
+ VOID
+ );
+
+SAL_RETURN_REGS
+SetEsalPhysicalEntryPoint (
+ IN UINT64 EntryPoint,
+ IN UINT64 Gp
+ );
+
+SAL_RETURN_REGS
+SetEsalVirtualEntryPoint (
+ IN UINT64 EntryPoint,
+ IN UINT64 Gp
+ );
+
+VOID
+SalFlushCache (
+ IN EFI_PHYSICAL_ADDRESS Start,
+ IN UINT64 Length
+ );
+
+//
+// Module Globals. It's not valid to use these after the
+// EfiRuntimeLibVirtualNotifyEvent has fired.
+//
+static EFI_EVENT mEfiVirtualNotifyEvent;
+static EFI_RUNTIME_SERVICES *mRT;
+static EFI_PLABEL mPlabel;
+static EXTENDED_SAL_BOOT_SERVICE_PROTOCOL *mEsalBootService;
+static BOOLEAN mRuntimeLibInitialized = FALSE;
+
+VOID
+EFIAPI
+EfiRuntimeLibVirtualNotifyEvent (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+/*++
+
+Routine Description:
+
+ Fixup internal data so that EFI and SAL can be call in virtual mode.
+ Call the passed in Child Notify event and convert any pointers in
+ lib to virtual mode.
+
+Arguments:
+
+ Event - The Event that is being processed
+
+ Context - Event Context
+
+Returns:
+
+ None
+
+--*/
+{
+ EFI_EVENT_NOTIFY ChildNotify;
+
+ if (Context != NULL) {
+ //
+ // Call child event
+ //
+ ChildNotify = (EFI_EVENT_NOTIFY) (UINTN) Context;
+ ChildNotify (Event, NULL);
+ }
+
+ mRT->ConvertPointer (EFI_INTERNAL_POINTER, (VOID **) &mPlabel.EntryPoint);
+ mRT->ConvertPointer (EFI_INTERNAL_POINTER | EFI_IPF_GP_POINTER, (VOID **) &mPlabel.GP);
+
+ SetEsalVirtualEntryPoint (mPlabel.EntryPoint, mPlabel.GP);
+
+ //
+ // Clear out BootService globals
+ //
+ gBS = NULL;
+ gST = NULL;
+ mRT = NULL;
+
+ //
+ // Pointers don't work you must use a direct lib call
+ //
+}
+
+EFI_STATUS
+EfiInitializeRuntimeDriverLib (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable,
+ IN EFI_EVENT_NOTIFY GoVirtualChildEvent
+ )
+/*++
+
+Routine Description:
+
+ Intialize runtime Driver Lib if it has not yet been initialized.
+
+Arguments:
+
+ ImageHandle - The firmware allocated handle for the EFI image.
+
+ SystemTable - A pointer to the EFI System Table.
+
+ GoVirtualChildEvent - Caller can register a virtual notification event.
+
+Returns:
+
+ EFI_STATUS always returns EFI_SUCCESS except EFI_ALREADY_STARTED if already started.
+
+--*/
+{
+ EFI_STATUS Status;
+ EFI_PLABEL *Plabel;
+
+ if (mRuntimeLibInitialized) {
+ return EFI_ALREADY_STARTED;
+ }
+
+ mRuntimeLibInitialized = TRUE;
+
+ gST = SystemTable;
+ gBS = SystemTable->BootServices;
+ mRT = SystemTable->RuntimeServices;
+ Status = EfiLibGetSystemConfigurationTable (&gEfiDxeServicesTableGuid, (VOID **) &gDS);
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // The protocol contains a function pointer, which is an indirect procedure call.
+ // An indirect procedure call goes through a plabel, and pointer to a function is
+ // a pointer to a plabel. To implement indirect procedure calls that can work in
+ // both physical and virtual mode, two plabels are required (one physical and one
+ // virtual). So lets grap the physical PLABEL for the EsalEntryPoint and store it
+ // away. We cache it in a module global, so we can register the vitrual version.
+ //
+ Status = gBS->LocateProtocol (&gEfiExtendedSalBootServiceProtocolGuid, NULL, &mEsalBootService);
+ ASSERT_EFI_ERROR (Status);
+
+ Plabel = (EFI_PLABEL *) (UINTN) mEsalBootService->ExtendedSalProc;
+
+ mPlabel.EntryPoint = Plabel->EntryPoint;
+ mPlabel.GP = Plabel->GP;
+
+ SetEsalPhysicalEntryPoint (mPlabel.EntryPoint, mPlabel.GP);
+
+ //
+ // Create a Virtual address change notification event. Pass in the callers
+ // GoVirtualChildEvent so it's get passed to the event as contex.
+ //
+ Status = gBS->CreateEvent (
+ EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE,
+ EFI_TPL_NOTIFY,
+ EfiRuntimeLibVirtualNotifyEvent,
+ (VOID *) GoVirtualChildEvent,
+ &mEfiVirtualNotifyEvent
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EfiShutdownRuntimeDriverLib (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ This routine will free some resources which have been allocated in
+ EfiInitializeRuntimeDriverLib(). If a runtime driver exits with an error,
+ it must call this routine to free the allocated resource before the exiting.
+
+Arguments:
+
+ None
+
+Returns:
+
+ EFI_SUCCESS - Shotdown the Runtime Driver Lib successfully
+ EFI_UNSUPPORTED - Runtime Driver lib was not initialized at all
+
+--*/
+{
+ EFI_STATUS Status;
+
+ if (!mRuntimeLibInitialized) {
+ //
+ // You must call EfiInitializeRuntimeDriverLib() first
+ //
+ return EFI_UNSUPPORTED;
+ }
+
+ mRuntimeLibInitialized = FALSE;
+
+ //
+ // Close SetVirtualAddressMap () notify function
+ //
+ Status = gBS->CloseEvent (mEfiVirtualNotifyEvent);
+ ASSERT_EFI_ERROR (Status);
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+RegisterEsalFunction (
+ IN UINT64 FunctionId,
+ IN EFI_GUID *ClassGuid,
+ IN SAL_INTERNAL_EXTENDED_SAL_PROC Function,
+ IN VOID *ModuleGlobal
+ )
+/*++
+
+Routine Description:
+
+ Register ESAL Class Function and it's asociated global.
+ This function is boot service only!
+
+Arguments:
+ FunctionId - ID of function to register
+ ClassGuid - GUID of function class
+ Function - Function to register under ClassGuid/FunctionId pair
+ ModuleGlobal - Module global for Function.
+
+Returns:
+ EFI_SUCCESS - If ClassGuid/FunctionId Function was registered.
+
+--*/
+{
+ return mEsalBootService->AddExtendedSalProc (
+ mEsalBootService,
+ ClassGuid,
+ FunctionId,
+ Function,
+ ModuleGlobal
+ );
+}
+
+EFI_STATUS
+RegisterEsalClass (
+ IN EFI_GUID *ClassGuid,
+ IN VOID *ModuleGlobal,
+ ...
+ )
+/*++
+
+Routine Description:
+
+ Register ESAL Class and it's asociated global.
+ This function is boot service only!
+
+Arguments:
+ ClassGuid - GUID of function class
+ ModuleGlobal - Module global for Function.
+ ... - SAL_INTERNAL_EXTENDED_SAL_PROC and FunctionId pairs. NULL
+ indicates the end of the list.
+
+Returns:
+ EFI_SUCCESS - All members of ClassGuid registered
+
+--*/
+{
+ VA_LIST Args;
+ EFI_STATUS Status;
+ SAL_INTERNAL_EXTENDED_SAL_PROC Function;
+ UINT64 FunctionId;
+ EFI_HANDLE NewHandle;
+
+ VA_START (Args, ModuleGlobal);
+
+ Status = EFI_SUCCESS;
+ while (!EFI_ERROR (Status)) {
+ Function = (SAL_INTERNAL_EXTENDED_SAL_PROC) VA_ARG (Args, SAL_INTERNAL_EXTENDED_SAL_PROC);
+ if (Function == NULL) {
+ break;
+ }
+
+ FunctionId = VA_ARG (Args, UINT64);
+
+ Status = RegisterEsalFunction (FunctionId, ClassGuid, Function, ModuleGlobal);
+ }
+
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ NewHandle = NULL;
+ return gBS->InstallProtocolInterface (
+ &NewHandle,
+ ClassGuid,
+ EFI_NATIVE_INTERFACE,
+ NULL
+ );
+}
+
+SAL_RETURN_REGS
+EfiCallEsalService (
+ IN EFI_GUID *ClassGuid,
+ IN UINT64 FunctionId,
+ IN UINT64 Arg2,
+ IN UINT64 Arg3,
+ IN UINT64 Arg4,
+ IN UINT64 Arg5,
+ IN UINT64 Arg6,
+ IN UINT64 Arg7,
+ IN UINT64 Arg8
+ )
+/*++
+
+Routine Description:
+
+ Call module that is not linked direclty to this module. This code is IP
+ relative and hides the binding issues of virtual or physical calling. The
+ function that gets dispatched has extra arguments that include the registered
+ module global and a boolean flag to indicate if the system is in virutal mode.
+
+Arguments:
+ ClassGuid - GUID of function
+ FunctionId - Function in ClassGuid to call
+ Arg2 - Argument 2 ClassGuid/FunctionId defined
+ Arg3 - Argument 3 ClassGuid/FunctionId defined
+ Arg4 - Argument 4 ClassGuid/FunctionId defined
+ Arg5 - Argument 5 ClassGuid/FunctionId defined
+ Arg6 - Argument 6 ClassGuid/FunctionId defined
+ Arg7 - Argument 7 ClassGuid/FunctionId defined
+ Arg8 - Argument 8 ClassGuid/FunctionId defined
+
+Returns:
+ Status of ClassGuid/FuncitonId
+
+--*/
+{
+ SAL_RETURN_REGS ReturnReg;
+ SAL_EXTENDED_SAL_PROC EsalProc;
+
+ ReturnReg = GetEsalEntryPoint ();
+ if (ReturnReg.Status != EFI_SAL_SUCCESS) {
+ return ReturnReg;
+ }
+
+ if (ReturnReg.r11 & PSR_IT_MASK) {
+ //
+ // Virtual mode plabel to entry point
+ //
+ EsalProc = (SAL_EXTENDED_SAL_PROC) ReturnReg.r10;
+ } else {
+ //
+ // Physical mode plabel to entry point
+ //
+ EsalProc = (SAL_EXTENDED_SAL_PROC) ReturnReg.r9;
+ }
+
+ return EsalProc (
+ ClassGuid,
+ FunctionId,
+ Arg2,
+ Arg3,
+ Arg4,
+ Arg5,
+ Arg6,
+ Arg7,
+ Arg8
+ );
+}
+
+EFI_STATUS
+EfiConvertPointer (
+ IN UINTN DebugDisposition,
+ IN OUT VOID *Address
+ )
+/*++
+
+Routine Description:
+
+ Determines the new virtual address that is to be used on subsequent memory accesses.
+
+Arguments:
+
+ DebugDisposition - Supplies type information for the pointer being converted.
+ Address - A pointer to a pointer that is to be fixed to be the value needed
+ for the new virtual address mappings being applied.
+
+Returns:
+
+ Status code
+
+--*/
+{
+ return mRT->ConvertPointer (DebugDisposition, Address);
+}
+
+BOOLEAN
+EfiGoneVirtual (
+ VOID
+ )
+/*++
+
+Routine Description:
+ Return TRUE if SetVirtualAddressMap () has been called
+
+Arguments:
+ NONE
+
+Returns:
+ TRUE - If SetVirtualAddressMap () has been called
+
+--*/
+{
+ EFI_GUID Guid = EFI_EXTENDED_SAL_VIRTUAL_SERVICES_PROTOCOL_GUID;
+ SAL_RETURN_REGS ReturnReg;
+
+ ReturnReg = EfiCallEsalService (&Guid, IsVirtual, 0, 0, 0, 0, 0, 0, 0);
+
+ return (BOOLEAN) (ReturnReg.r9 == 1);
+}
+
+BOOLEAN
+EfiAtRuntime (
+ VOID
+ )
+/*++
+
+Routine Description:
+ Return TRUE if ExitBootService () has been called
+
+Arguments:
+ NONE
+
+Returns:
+ TRUE - If ExitBootService () has been called
+
+--*/
+{
+ EFI_GUID Guid = EFI_EXTENDED_SAL_VIRTUAL_SERVICES_PROTOCOL_GUID;
+ SAL_RETURN_REGS ReturnReg;
+
+ ReturnReg = EfiCallEsalService (&Guid, IsEfiRuntime, 0, 0, 0, 0, 0, 0, 0);
+
+ return (BOOLEAN) (ReturnReg.r9 == 1);
+}
+
+EFI_STATUS
+EfiReportStatusCode (
+ IN EFI_STATUS_CODE_TYPE CodeType,
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN UINT32 Instance,
+ IN EFI_GUID * CallerId,
+ IN EFI_STATUS_CODE_DATA * Data OPTIONAL
+ )
+/*++
+
+Routine Description:
+
+ Status Code reporter
+
+Arguments:
+
+ CodeType - Type of Status Code.
+
+ Value - Value to output for Status Code.
+
+ Instance - Instance Number of this status code.
+
+ CallerId - ID of the caller of this status code.
+
+ Data - Optional data associated with this status code.
+
+Returns:
+
+ Status code
+
+--*/
+{
+ EFI_GUID Guid = EFI_EXTENDED_SAL_STATUS_CODE_SERVICES_PROTOCOL_GUID;
+ SAL_RETURN_REGS ReturnReg;
+
+
+ ReturnReg = EfiCallEsalService (
+ &Guid,
+ StatusCode,
+ (UINT64) CodeType,
+ (UINT64) Value,
+ (UINT64) Instance,
+ (UINT64) CallerId,
+ (UINT64) Data,
+ 0,
+ 0
+ );
+
+ return (EFI_STATUS) ReturnReg.Status;
+}
+//
+// Sal Reset Driver Class
+//
+VOID
+EfiResetSystem (
+ IN EFI_RESET_TYPE ResetType,
+ IN EFI_STATUS ResetStatus,
+ IN UINTN DataSize,
+ IN CHAR16 *ResetData
+ )
+/*++
+
+Routine Description:
+
+ Resets the entire platform.
+
+Arguments:
+
+ ResetType - The type of reset to perform.
+ ResetStatus - The status code for the reset.
+ DataSize - The size, in bytes, of ResetData.
+ ResetData - A data buffer that includes a Null-terminated Unicode string, optionally
+ followed by additional binary data.
+
+Returns:
+
+ None
+
+--*/
+{
+ EFI_GUID Guid = EFI_EXTENDED_SAL_RESET_SERVICES_PROTOCOL_GUID;
+
+ EfiCallEsalService (
+ &Guid,
+ ResetSystem,
+ (UINT64) ResetType,
+ (UINT64) ResetStatus,
+ (UINT64) DataSize,
+ (UINT64) ResetData,
+ 0,
+ 0,
+ 0
+ );
+}
+//
+// Sal MTC Driver Class
+//
+EFI_STATUS
+EfiGetNextHighMonotonicCount (
+ OUT UINT32 *HighCount
+ )
+/*++
+
+Routine Description:
+
+ Returns the next high 32 bits of the platform¡¯s monotonic counter.
+
+Arguments:
+
+ HighCount - Pointer to returned value.
+
+Returns:
+
+ Status code
+
+--*/
+{
+ SAL_RETURN_REGS ReturnReg;
+
+ EFI_GUID Guid = EFI_EXTENDED_SAL_MTC_SERVICES_PROTOCOL_GUID;
+
+ ReturnReg = EfiCallEsalService (&Guid, GetNextHighMonotonicCount, (UINT64) HighCount, 0, 0, 0, 0, 0, 0);
+ return (EFI_STATUS) ReturnReg.Status;
+}
+//
+// Sal Variable Driver Class
+//
+EFI_STATUS
+EfiGetVariable (
+ IN CHAR16 *VariableName,
+ IN EFI_GUID * VendorGuid,
+ OUT UINT32 *Attributes OPTIONAL,
+ IN OUT UINTN *DataSize,
+ OUT VOID *Data
+ )
+/*++
+
+Routine Description:
+
+ Returns the value of a variable.
+
+Arguments:
+
+ VariableName - A Null-terminated Unicode string that is the name of the
+ vendor¡¯s variable.
+ VendorGuid - A unique identifier for the vendor.
+ Attributes - If not NULL, a pointer to the memory location to return the
+ attributes bitmask for the variable.
+ DataSize - On input, the size in bytes of the return Data buffer.
+ On output the size of data returned in Data.
+ Data - The buffer to return the contents of the variable.
+
+Returns:
+
+ Status code
+
+--*/
+{
+ SAL_RETURN_REGS ReturnReg;
+ EFI_GUID Guid = EFI_EXTENDED_SAL_VARIABLE_SERVICES_PROTOCOL_GUID;
+
+ ReturnReg = EfiCallEsalService (
+ &Guid,
+ EsalGetVariable,
+ (UINT64) VariableName,
+ (UINT64) VendorGuid,
+ (UINT64) Attributes,
+ (UINT64) DataSize,
+ (UINT64) Data,
+ 0,
+ 0
+ );
+ return (EFI_STATUS) ReturnReg.Status;
+}
+
+EFI_STATUS
+EfiGetNextVariableName (
+ IN OUT UINTN *VariableNameSize,
+ IN OUT CHAR16 *VariableName,
+ IN OUT EFI_GUID *VendorGuid
+ )
+/*++
+
+Routine Description:
+
+ Enumerates the current variable names.
+
+Arguments:
+
+ VariableNameSize - The size of the VariableName buffer.
+ VariableName - On input, supplies the last VariableName that was returned
+ by GetNextVariableName().
+ On output, returns the Nullterminated Unicode string of the
+ current variable.
+ VendorGuid - On input, supplies the last VendorGuid that was returned by
+ GetNextVariableName().
+ On output, returns the VendorGuid of the current variable.
+
+Returns:
+
+ Status code
+
+--*/
+{
+ SAL_RETURN_REGS ReturnReg;
+ EFI_GUID Guid = EFI_EXTENDED_SAL_VARIABLE_SERVICES_PROTOCOL_GUID;
+
+ ReturnReg = EfiCallEsalService (
+ &Guid,
+ EsalGetNextVariableName,
+ (UINT64) VariableNameSize,
+ (UINT64) VariableName,
+ (UINT64) VendorGuid,
+ 0,
+ 0,
+ 0,
+ 0
+ );
+ return (EFI_STATUS) ReturnReg.Status;
+}
+
+EFI_STATUS
+EfiSetVariable (
+ IN CHAR16 *VariableName,
+ IN EFI_GUID *VendorGuid,
+ IN UINT32 Attributes,
+ IN UINTN DataSize,
+ IN VOID *Data
+ )
+/*++
+
+Routine Description:
+
+ Sets the value of a variable.
+
+Arguments:
+
+ VariableName - A Null-terminated Unicode string that is the name of the
+ vendor¡¯s variable.
+ VendorGuid - A unique identifier for the vendor.
+ Attributes - Attributes bitmask to set for the variable.
+ DataSize - The size in bytes of the Data buffer.
+ Data - The contents for the variable.
+
+Returns:
+
+ Status code
+
+--*/
+{
+ SAL_RETURN_REGS ReturnReg;
+ EFI_GUID Guid = EFI_EXTENDED_SAL_VARIABLE_SERVICES_PROTOCOL_GUID;
+
+ ReturnReg = EfiCallEsalService (
+ &Guid,
+ EsalSetVariable,
+ (UINT64) VariableName,
+ (UINT64) VendorGuid,
+ (UINT64) Attributes,
+ (UINT64) DataSize,
+ (UINT64) Data,
+ 0,
+ 0
+ );
+ return (EFI_STATUS) ReturnReg.Status;
+}
+
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+
+EFI_STATUS
+EfiQueryVariableInfo (
+ IN UINT32 Attributes,
+ OUT UINT64 *MaximumVariableStorageSize,
+ OUT UINT64 *RemainingVariableStorageSize,
+ OUT UINT64 *MaximumVariableSize
+ )
+/*++
+
+Routine Description:
+
+ This code returns information about the EFI variables.
+
+Arguments:
+
+ Attributes Attributes bitmask to specify the type of variables
+ on which to return information.
+ MaximumVariableStorageSize Pointer to the maximum size of the storage space available
+ for the EFI variables associated with the attributes specified.
+ RemainingVariableStorageSize Pointer to the remaining size of the storage space available
+ for the EFI variables associated with the attributes specified.
+ MaximumVariableSize Pointer to the maximum size of the individual EFI variables
+ associated with the attributes specified.
+
+Returns:
+
+ Status code
+
+--*/
+{
+ SAL_RETURN_REGS ReturnReg;
+ EFI_GUID Guid = EFI_EXTENDED_SAL_VARIABLE_SERVICES_PROTOCOL_GUID;
+
+ ReturnReg = EfiCallEsalService (
+ &Guid,
+ EsalQueryVariableInfo,
+ (UINT64) Attributes,
+ (UINT64) MaximumVariableStorageSize,
+ (UINT64) RemainingVariableStorageSize,
+ (UINT64) MaximumVariableSize,
+ 0,
+ 0,
+ 0
+ );
+ return (EFI_STATUS) ReturnReg.Status;
+}
+
+#endif
+
+//
+// Sal RTC Driver Class.
+//
+EFI_STATUS
+EfiGetTime (
+ OUT EFI_TIME *Time,
+ OUT EFI_TIME_CAPABILITIES *Capabilities
+ )
+/*++
+
+Routine Description:
+
+ Returns the current time and date information, and the time-keeping
+ capabilities of the hardware platform.
+
+Arguments:
+
+ Time - A pointer to storage to receive a snapshot of the current time.
+ Capabilities - An optional pointer to a buffer to receive the real time clock device¡¯s
+ capabilities.
+
+Returns:
+
+ Status code
+
+--*/
+{
+ SAL_RETURN_REGS ReturnReg;
+ EFI_GUID Guid = EFI_EXTENDED_SAL_RTC_SERVICES_PROTOCOL_GUID;
+
+ ReturnReg = EfiCallEsalService (&Guid, GetTime, (UINT64) Time, (UINT64) Capabilities, 0, 0, 0, 0, 0);
+ return ReturnReg.Status;
+}
+
+EFI_STATUS
+EfiSetTime (
+ OUT EFI_TIME *Time
+ )
+/*++
+
+Routine Description:
+
+ Sets the current local time and date information.
+
+Arguments:
+
+ Time - A pointer to the current time.
+
+Returns:
+
+ Status code
+
+--*/
+{
+ SAL_RETURN_REGS ReturnReg;
+
+ EFI_GUID Guid = EFI_EXTENDED_SAL_RTC_SERVICES_PROTOCOL_GUID;
+
+ ReturnReg = EfiCallEsalService (&Guid, SetTime, (UINT64) Time, 0, 0, 0, 0, 0, 0);
+ return ReturnReg.Status;
+}
+
+EFI_STATUS
+EfiGetWakeupTime (
+ OUT BOOLEAN *Enabled,
+ OUT BOOLEAN *Pending,
+ OUT EFI_TIME *Time
+ )
+/*++
+
+Routine Description:
+
+ Returns the current wakeup alarm clock setting.
+
+Arguments:
+
+ Enabled - Indicates if the alarm is currently enabled or disabled.
+ Pending - Indicates if the alarm signal is pending and requires acknowledgement.
+ Time - The current alarm setting.
+
+Returns:
+
+ Status code
+
+--*/
+{
+ SAL_RETURN_REGS ReturnReg;
+
+ EFI_GUID Guid = EFI_EXTENDED_SAL_RTC_SERVICES_PROTOCOL_GUID;
+
+ ReturnReg = EfiCallEsalService (&Guid, GetWakeupTime, (UINT64) Enabled, (UINT64) Pending, (UINT64) Time, 0, 0, 0, 0);
+ return ReturnReg.Status;
+}
+
+EFI_STATUS
+EfiSetWakeupTime (
+ IN BOOLEAN Enable,
+ IN EFI_TIME *Time
+ )
+/*++
+
+Routine Description:
+
+ Sets the system wakeup alarm clock time.
+
+Arguments:
+
+ Enable - Enable or disable the wakeup alarm.
+ Time - If Enable is TRUE, the time to set the wakeup alarm for.
+ If Enable is FALSE, then this parameter is optional, and may be NULL.
+
+Returns:
+
+ Status code
+
+--*/
+{
+ SAL_RETURN_REGS ReturnReg;
+
+ EFI_GUID Guid = EFI_EXTENDED_SAL_RTC_SERVICES_PROTOCOL_GUID;
+
+ ReturnReg = EfiCallEsalService (&Guid, SetWakeupTime, (UINT64) Enable, (UINT64) Time, 0, 0, 0, 0, 0);
+ return ReturnReg.Status;
+}
+
+
+
+//
+// Base IO Services
+//
+EFI_STATUS
+EfiIoRead (
+ IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
+ IN UINT64 Address,
+ IN UINTN Count,
+ IN OUT VOID *Buffer
+ )
+/*++
+
+Routine Description:
+ Perform an IO read into Buffer.
+
+Arguments:
+ Width - Width of read transaction, and repeat operation to use
+ Address - IO address to read
+ Count - Number of times to read the IO address.
+ Buffer - Buffer to read data into. size is Width * Count
+
+Returns:
+ Status code
+
+--*/
+{
+
+ SAL_RETURN_REGS ReturnReg;
+
+ EFI_GUID Guid = EFI_EXTENDED_SAL_BASE_IO_SERVICES_PROTOCOL_GUID;
+
+ ReturnReg = EfiCallEsalService (&Guid, IoRead, (UINT64) Width, Address, Count, (UINT64) Buffer, 0, 0, 0);
+
+ return ReturnReg.Status;
+
+}
+
+EFI_STATUS
+EfiIoWrite (
+ IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
+ IN UINT64 Address,
+ IN UINTN Count,
+ IN OUT VOID *Buffer
+ )
+/*++
+
+Routine Description:
+ Perform an IO write into Buffer.
+
+Arguments:
+ Width - Width of write transaction, and repeat operation to use
+ Address - IO address to write
+ Count - Number of times to write the IO address.
+ Buffer - Buffer to write data from. size is Width * Count
+
+Returns:
+ Status code
+
+--*/
+{
+
+ SAL_RETURN_REGS ReturnReg;
+
+ EFI_GUID Guid = EFI_EXTENDED_SAL_BASE_IO_SERVICES_PROTOCOL_GUID;
+
+ ReturnReg = EfiCallEsalService (&Guid, IoWrite, (UINT64) Width, Address, Count, (UINT64) Buffer, 0, 0, 0);
+
+ return ReturnReg.Status;
+
+}
+
+EFI_STATUS
+EfiMemRead (
+ IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
+ IN UINT64 Address,
+ IN UINTN Count,
+ IN OUT VOID *Buffer
+ )
+/*++
+
+Routine Description:
+ Perform a Memory mapped IO read into Buffer.
+
+Arguments:
+ Width - Width of each read transaction.
+ Address - Memory mapped IO address to read
+ Count - Number of Width quanta to read
+ Buffer - Buffer to read data into. size is Width * Count
+
+Returns:
+ Status code
+
+--*/
+{
+
+ SAL_RETURN_REGS ReturnReg;
+
+ EFI_GUID Guid = EFI_EXTENDED_SAL_BASE_IO_SERVICES_PROTOCOL_GUID;
+
+ ReturnReg = EfiCallEsalService (&Guid, MemRead, (UINT64) Width, Address, Count, (UINT64) Buffer, 0, 0, 0);
+
+ return ReturnReg.Status;
+
+}
+
+EFI_STATUS
+EfiMemWrite (
+ IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
+ IN UINT64 Address,
+ IN UINTN Count,
+ IN OUT VOID *Buffer
+ )
+/*++
+
+Routine Description:
+ Perform a memory mapped IO write into Buffer.
+
+Arguments:
+ Width - Width of write transaction, and repeat operation to use
+ Address - IO address to write
+ Count - Number of times to write the IO address.
+ Buffer - Buffer to write data from. size is Width * Count
+
+Returns:
+ Status code
+
+--*/
+{
+
+ SAL_RETURN_REGS ReturnReg;
+
+ EFI_GUID Guid = EFI_EXTENDED_SAL_BASE_IO_SERVICES_PROTOCOL_GUID;
+
+ ReturnReg = EfiCallEsalService (&Guid, MemWrite, (UINT64) Width, Address, Count, (UINT64) Buffer, 0, 0, 0);
+
+ return ReturnReg.Status;
+
+}
+
+
+#define EFI_PCI_ADDRESS_IPF(_seg, _bus, _devfunc, _reg) \
+ (((_seg) << 24) | ((_bus) << 16) | ((_devfunc) << 8) | (_reg)) & 0xFFFFFFFF
+
+//
+// PCI Class Functions
+//
+UINT8
+PciRead8 (
+ UINT8 Segment,
+ UINT8 Bus,
+ UINT8 DevFunc,
+ UINT8 Register
+ )
+/*++
+
+Routine Description:
+ Perform an one byte PCI config cycle read
+
+Arguments:
+ Segment - PCI Segment ACPI _SEG
+ Bus - PCI Bus
+ DevFunc - PCI Device(7:3) and Func(2:0)
+ Register - PCI config space register
+
+Returns:
+ Data read from PCI config space
+
+--*/
+{
+ EFI_GUID Guid = EFI_EXTENDED_SAL_PCI_SERVICES_PROTOCOL_GUID;
+ UINT64 Address;
+ SAL_RETURN_REGS Return;
+
+ Address = EFI_PCI_ADDRESS_IPF (Segment, Bus, DevFunc, Register);
+ Return = EfiCallEsalService (&Guid, SalPciConfigRead, Address, 1, 0, 0, 0, 0, 0);
+
+ return (UINT8) Return.r9;
+}
+
+
+UINT16
+PciRead16 (
+ UINT8 Segment,
+ UINT8 Bus,
+ UINT8 DevFunc,
+ UINT8 Register
+ )
+/*++
+
+Routine Description:
+ Perform an two byte PCI config cycle read
+
+Arguments:
+ Segment - PCI Segment ACPI _SEG
+ Bus - PCI Bus
+ DevFunc - PCI Device(7:3) and Func(2:0)
+ Register - PCI config space register
+
+Returns:
+ Data read from PCI config space
+
+--*/
+{
+ EFI_GUID Guid = EFI_EXTENDED_SAL_PCI_SERVICES_PROTOCOL_GUID;
+ UINT64 Address;
+ SAL_RETURN_REGS Return;
+
+ Address = EFI_PCI_ADDRESS_IPF (Segment, Bus, DevFunc, Register);
+ Return = EfiCallEsalService (&Guid, SalPciConfigRead, Address, 2, 0, 0, 0, 0, 0);
+
+ return (UINT16) Return.r9;
+}
+
+UINT32
+PciRead32 (
+ UINT8 Segment,
+ UINT8 Bus,
+ UINT8 DevFunc,
+ UINT8 Register
+ )
+/*++
+
+Routine Description:
+ Perform an four byte PCI config cycle read
+
+Arguments:
+ Segment - PCI Segment ACPI _SEG
+ Bus - PCI Bus
+ DevFunc - PCI Device(7:3) and Func(2:0)
+ Register - PCI config space register
+
+Returns:
+ Data read from PCI config space
+
+--*/
+{
+ EFI_GUID Guid = EFI_EXTENDED_SAL_PCI_SERVICES_PROTOCOL_GUID;
+ UINT64 Address;
+ SAL_RETURN_REGS Return;
+
+ Address = EFI_PCI_ADDRESS_IPF (Segment, Bus, DevFunc, Register);
+ Return = EfiCallEsalService (&Guid, SalPciConfigRead, Address, 4, 0, 0, 0, 0, 0);
+
+ return (UINT32) Return.r9;
+}
+
+VOID
+PciWrite8 (
+ UINT8 Segment,
+ UINT8 Bus,
+ UINT8 DevFunc,
+ UINT8 Register,
+ UINT8 Data
+ )
+/*++
+
+Routine Description:
+ Perform an one byte PCI config cycle write
+
+Arguments:
+ Segment - PCI Segment ACPI _SEG
+ Bus - PCI Bus
+ DevFunc - PCI Device(7:3) and Func(2:0)
+ Register - PCI config space register
+ Data - Data to write
+
+Returns:
+ NONE
+
+--*/
+{
+ EFI_GUID Guid = EFI_EXTENDED_SAL_PCI_SERVICES_PROTOCOL_GUID;
+ UINT64 Address;
+
+ Address = EFI_PCI_ADDRESS_IPF (Segment, Bus, DevFunc, Register);
+ EfiCallEsalService (&Guid, SalPciConfigWrite, Address, 1, Data, 0, 0, 0, 0);
+}
+
+VOID
+PciWrite16 (
+ UINT8 Segment,
+ UINT8 Bus,
+ UINT8 DevFunc,
+ UINT8 Register,
+ UINT16 Data
+ )
+/*++
+
+Routine Description:
+ Perform an two byte PCI config cycle write
+
+Arguments:
+ Segment - PCI Segment ACPI _SEG
+ Bus - PCI Bus
+ DevFunc - PCI Device(7:3) and Func(2:0)
+ Register - PCI config space register
+ Data - Data to write
+
+Returns:
+ None.
+
+--*/
+{
+ EFI_GUID Guid = EFI_EXTENDED_SAL_PCI_SERVICES_PROTOCOL_GUID;
+ UINT64 Address;
+
+ Address = EFI_PCI_ADDRESS_IPF (Segment, Bus, DevFunc, Register);
+ EfiCallEsalService (&Guid, SalPciConfigWrite, Address, 2, Data, 0, 0, 0, 0);
+}
+
+VOID
+PciWrite32 (
+ UINT8 Segment,
+ UINT8 Bus,
+ UINT8 DevFunc,
+ UINT8 Register,
+ UINT32 Data
+ )
+/*++
+
+Routine Description:
+ Perform an four byte PCI config cycle write
+
+Arguments:
+ Segment - PCI Segment ACPI _SEG
+ Bus - PCI Bus
+ DevFunc - PCI Device(7:3) and Func(2:0)
+ Register - PCI config space register
+ Data - Data to write
+
+Returns:
+ NONE
+
+--*/
+{
+ EFI_GUID Guid = EFI_EXTENDED_SAL_PCI_SERVICES_PROTOCOL_GUID;
+ UINT64 Address;
+
+ Address = EFI_PCI_ADDRESS_IPF (Segment, Bus, DevFunc, Register);
+ EfiCallEsalService (&Guid, SalPciConfigWrite, Address, 4, Data, 0, 0, 0, 0);
+}
+
+//
+// Stall class functions
+//
+VOID
+EfiStall (
+ IN UINTN Microseconds
+ )
+/*++
+
+Routine Description:
+ Delay for at least the request number of microseconds
+
+Arguments:
+ Microseconds - Number of microseconds to delay.
+
+Returns:
+ NONE
+
+--*/
+{
+ EFI_GUID Guid = EFI_EXTENDED_SAL_STALL_SERVICES_PROTOCOL_GUID;
+
+ if (EfiAtRuntime ()) {
+ EfiCallEsalService (&Guid, Stall, Microseconds, 4, 0, 0, 0, 0, 0);
+ } else {
+ gBS->Stall (Microseconds);
+ }
+}
+//
+// Cache Flush Routine.
+//
+EFI_STATUS
+EfiCpuFlushCache (
+ IN EFI_PHYSICAL_ADDRESS Start,
+ IN UINT64 Length
+ )
+/*++
+
+Routine Description:
+
+ Flush cache with specified range.
+
+Arguments:
+
+ Start - Start address
+ Length - Length in bytes
+
+Returns:
+
+ Status code
+
+ EFI_SUCCESS - success
+
+--*/
+{
+ SalFlushCache (Start, Length);
+ return EFI_SUCCESS;
+}
diff --git a/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/LibGlobals.c b/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/LibGlobals.c
new file mode 100644
index 0000000..7fb6205
--- /dev/null
+++ b/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/LibGlobals.c
@@ -0,0 +1,37 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ LibGlobals.c
+
+Abstract:
+
+ Lib Globals
+
+ gBS - Pointer to the EFI Boot Services Table
+ gST - Pointer to EFI System Table
+ gRtErrorLevel - Error level used with DEBUG () macro
+
+--*/
+
+#include "Tiano.h"
+#include "EfiRuntimeLib.h"
+#include EFI_GUID_DEFINITION (StatusCodeCallerId)
+#include EFI_GUID_DEFINITION (StatusCodeDataTypeId)
+
+//
+// Lib globals that can ONLY be used at BootServices time!
+//
+EFI_BOOT_SERVICES *gBS;
+EFI_SYSTEM_TABLE *gST;
+EFI_DXE_SERVICES *gDS = NULL;
+UINTN gRtErrorLevel = EFI_DBUG_MASK | EFI_D_LOAD;
diff --git a/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/RtDevicePath.c b/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/RtDevicePath.c
new file mode 100644
index 0000000..44fc9a1
--- /dev/null
+++ b/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/RtDevicePath.c
@@ -0,0 +1,649 @@
+/*++
+
+Copyright (c) 2006 - 2008, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ RtDevicePath.c
+
+Abstract:
+
+ Device Path services. The thing to remember is device paths are built out of
+ nodes. The device path is terminated by an end node that is length
+ sizeof(EFI_DEVICE_PATH_PROTOCOL). That would be why there is sizeof(EFI_DEVICE_PATH_PROTOCOL)
+ all over this file.
+
+ The only place where multi-instance device paths are supported is in
+ environment varibles. Multi-instance device paths should never be placed
+ on a Handle.
+
+--*/
+
+#include "Tiano.h"
+#include "EfiRuntimeLib.h"
+#include "RtDevicePath.h"
+#include EFI_GUID_DEFINITION (FrameworkDevicePath)
+#include EFI_PROTOCOL_DEFINITION (DevicePath)
+
+STATIC
+VOID *
+InternalAllocatePool (
+ IN UINTN AllocationSize
+ )
+/*++
+
+Routine Description:
+
+ Allocate BootServicesData pool.
+
+Arguments:
+
+ AllocationSize - The size to allocate
+
+Returns:
+
+ Pointer of the buffer allocated.
+
+--*/
+{
+ VOID *Memory;
+
+ Memory = NULL;
+ gBS->AllocatePool (EfiBootServicesData, AllocationSize, &Memory);
+ return Memory;
+}
+
+STATIC
+VOID *
+InternalAllocateCopyPool (
+ IN UINTN AllocationSize,
+ IN VOID *Buffer
+ )
+/*++
+
+Routine Description:
+
+ Allocate BootServicesData pool and use a buffer provided by
+ caller to fill it.
+
+Arguments:
+
+ AllocationSize - The size to allocate
+
+ Buffer - Buffer that will be filled into the buffer allocated
+
+Returns:
+
+ Pointer of the buffer allocated.
+
+--*/
+{
+ VOID *Memory;
+
+ Memory = NULL;
+ gBS->AllocatePool (EfiBootServicesData, AllocationSize, &Memory);
+ if (Memory != NULL) {
+ gBS->CopyMem (Memory, Buffer, AllocationSize);
+ }
+
+ return Memory;
+}
+
+STATIC
+VOID *
+InternalAllocateZeroPool (
+ IN UINTN AllocationSize
+ )
+/*++
+
+Routine Description:
+
+ Allocate BootServicesData pool and zero it.
+
+Arguments:
+
+ AllocationSize - The size to allocate
+
+Returns:
+
+ Pointer of the buffer allocated.
+
+--*/
+{
+ VOID *Memory;
+
+ Memory = InternalAllocatePool (AllocationSize);
+ if (Memory != NULL) {
+ gBS->SetMem (Memory, AllocationSize, 0);
+ }
+
+ return Memory;
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+RtEfiDevicePathInstance (
+ IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath,
+ OUT UINTN *Size
+ )
+/*++
+
+Routine Description:
+ Function retrieves the next device path instance from a device path data structure.
+
+Arguments:
+ DevicePath - A pointer to a device path data structure.
+
+ Size - A pointer to the size of a device path instance in bytes.
+
+Returns:
+
+ This function returns a pointer to the current device path instance.
+ In addition, it returns the size in bytes of the current device path instance in Size,
+ and a pointer to the next device path instance in DevicePath.
+ If there are no more device path instances in DevicePath, then DevicePath will be set to NULL.
+
+--*/
+{
+ EFI_DEVICE_PATH_PROTOCOL *DevPath;
+ EFI_DEVICE_PATH_PROTOCOL *ReturnValue;
+ UINT8 Temp;
+
+ if (*DevicePath == NULL) {
+ if (Size != NULL) {
+ *Size = 0;
+ }
+
+ return NULL;
+ }
+
+ //
+ // Find the end of the device path instance
+ //
+ DevPath = *DevicePath;
+ while (!IsDevicePathEndType (DevPath)) {
+ DevPath = NextDevicePathNode (DevPath);
+ }
+
+ //
+ // Compute the size of the device path instance
+ //
+ if (Size != NULL) {
+ *Size = ((UINTN) DevPath - (UINTN) (*DevicePath)) + sizeof (EFI_DEVICE_PATH_PROTOCOL);
+ }
+
+ //
+ // Make a copy and return the device path instance
+ //
+ Temp = DevPath->SubType;
+ DevPath->SubType = END_ENTIRE_DEVICE_PATH_SUBTYPE;
+ ReturnValue = RtEfiDuplicateDevicePath (*DevicePath);
+ DevPath->SubType = Temp;
+
+ //
+ // If DevPath is the end of an entire device path, then another instance
+ // does not follow, so *DevicePath is set to NULL.
+ //
+ if (DevicePathSubType (DevPath) == END_ENTIRE_DEVICE_PATH_SUBTYPE) {
+ *DevicePath = NULL;
+ } else {
+ *DevicePath = NextDevicePathNode (DevPath);
+ }
+
+ return ReturnValue;
+}
+
+BOOLEAN
+RtEfiIsDevicePathMultiInstance (
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ )
+/*++
+
+Routine Description:
+ Return TRUE is this is a multi instance device path.
+
+Arguments:
+ DevicePath - A pointer to a device path data structure.
+
+
+Returns:
+ TRUE - If DevicePath is multi instance. FALSE - If DevicePath is not multi
+ instance.
+
+--*/
+{
+ EFI_DEVICE_PATH_PROTOCOL *Node;
+
+ if (DevicePath == NULL) {
+ return FALSE;
+ }
+
+ Node = DevicePath;
+ while (!EfiIsDevicePathEnd (Node)) {
+ if (EfiIsDevicePathEndInstance (Node)) {
+ return TRUE;
+ }
+
+ Node = EfiNextDevicePathNode (Node);
+ }
+
+ return FALSE;
+}
+
+UINTN
+RtEfiDevicePathSize (
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ )
+/*++
+
+Routine Description:
+
+ Calculate the space size of a device path.
+
+Arguments:
+
+ DevicePath - A specified device path
+
+Returns:
+
+ The size.
+
+--*/
+{
+ EFI_DEVICE_PATH_PROTOCOL *Start;
+
+ if (DevicePath == NULL) {
+ return 0;
+ }
+
+ //
+ // Search for the end of the device path structure
+ //
+ Start = DevicePath;
+ while (!EfiIsDevicePathEnd (DevicePath)) {
+ DevicePath = EfiNextDevicePathNode (DevicePath);
+ }
+
+ //
+ // Compute the size and add back in the size of the end device path structure
+ //
+ return ((UINTN) DevicePath - (UINTN) Start) + sizeof (EFI_DEVICE_PATH_PROTOCOL);
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+RtEfiDevicePathFromHandle (
+ IN EFI_HANDLE Handle
+ )
+/*++
+
+Routine Description:
+
+ Get the device path protocol interface installed on a specified handle.
+
+Arguments:
+
+ Handle - a specified handle
+
+Returns:
+
+ The device path protocol interface installed on that handle.
+
+--*/
+{
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+
+ DevicePath = NULL;
+ gBS->HandleProtocol (
+ Handle,
+ &gEfiDevicePathProtocolGuid,
+ (VOID *) &DevicePath
+ );
+ return DevicePath;
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+RtEfiDuplicateDevicePath (
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ )
+/*++
+
+Routine Description:
+
+ Duplicate a device path structure.
+
+Arguments:
+
+ DevicePath - The device path to duplicated.
+
+Returns:
+
+ The duplicated device path.
+
+--*/
+{
+ EFI_DEVICE_PATH_PROTOCOL *NewDevicePath;
+ UINTN Size;
+
+ if (DevicePath == NULL) {
+ return NULL;
+ }
+
+ //
+ // Compute the size
+ //
+ Size = RtEfiDevicePathSize (DevicePath);
+ if (Size == 0) {
+ return NULL;
+ }
+
+ //
+ // Allocate space for duplicate device path
+ //
+ NewDevicePath = InternalAllocateCopyPool (Size, DevicePath);
+
+ return NewDevicePath;
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+RtEfiAppendDevicePath (
+ IN EFI_DEVICE_PATH_PROTOCOL *Src1,
+ IN EFI_DEVICE_PATH_PROTOCOL *Src2
+ )
+/*++
+
+Routine Description:
+ Function is used to append a Src1 and Src2 together.
+
+Arguments:
+ Src1 - A pointer to a device path data structure.
+
+ Src2 - A pointer to a device path data structure.
+
+Returns:
+
+ A pointer to the new device path is returned.
+ NULL is returned if space for the new device path could not be allocated from pool.
+ It is up to the caller to free the memory used by Src1 and Src2 if they are no longer needed.
+
+--*/
+{
+ UINTN Size;
+ UINTN Size1;
+ UINTN Size2;
+ EFI_DEVICE_PATH_PROTOCOL *NewDevicePath;
+ EFI_DEVICE_PATH_PROTOCOL *SecondDevicePath;
+
+ //
+ // If there's only 1 path, just duplicate it
+ //
+ if (!Src1) {
+ ASSERT (!IsDevicePathUnpacked (Src2));
+ return RtEfiDuplicateDevicePath (Src2);
+ }
+
+ if (!Src2) {
+ ASSERT (!IsDevicePathUnpacked (Src1));
+ return RtEfiDuplicateDevicePath (Src1);
+ }
+
+ //
+ // Allocate space for the combined device path. It only has one end node of
+ // length EFI_DEVICE_PATH_PROTOCOL
+ //
+ Size1 = RtEfiDevicePathSize (Src1);
+ Size2 = RtEfiDevicePathSize (Src2);
+ Size = Size1 + Size2 - sizeof (EFI_DEVICE_PATH_PROTOCOL);
+
+ NewDevicePath = InternalAllocateCopyPool (Size, Src1);
+
+ if (NewDevicePath != NULL) {
+
+ //
+ // Over write Src1 EndNode and do the copy
+ //
+ SecondDevicePath = (EFI_DEVICE_PATH_PROTOCOL *) ((CHAR8 *) NewDevicePath + (Size1 - sizeof (EFI_DEVICE_PATH_PROTOCOL)));
+ EfiCopyMem (SecondDevicePath, Src2, Size2);
+ }
+
+ return NewDevicePath;
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+RtEfiAppendDevicePathNode (
+ IN EFI_DEVICE_PATH_PROTOCOL *Src1,
+ IN EFI_DEVICE_PATH_PROTOCOL *Node
+ )
+/*++
+
+Routine Description:
+ Function is used to append a device path node to the end of another device path.
+
+Arguments:
+ Src1 - A pointer to a device path data structure.
+
+ Node - A pointer to a device path data structure.
+
+Returns:
+ This function returns a pointer to the new device path.
+ If there is not enough temporary pool memory available to complete this function,
+ then NULL is returned.
+
+
+--*/
+{
+ EFI_DEVICE_PATH_PROTOCOL *Temp;
+ EFI_DEVICE_PATH_PROTOCOL *NextNode;
+ EFI_DEVICE_PATH_PROTOCOL *NewDevicePath;
+ UINTN NodeLength;
+
+ //
+ // Build a Node that has a terminator on it
+ //
+ NodeLength = DevicePathNodeLength (Node);
+
+ Temp = InternalAllocateCopyPool (NodeLength + sizeof (EFI_DEVICE_PATH_PROTOCOL), Node);
+ if (Temp == NULL) {
+ return NULL;
+ }
+
+ //
+ // Add and end device path node to convert Node to device path
+ //
+ NextNode = NextDevicePathNode (Temp);
+ SetDevicePathEndNode (NextNode);
+
+ //
+ // Append device paths
+ //
+ NewDevicePath = RtEfiAppendDevicePath (Src1, Temp);
+ gBS->FreePool (Temp);
+ return NewDevicePath;
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+RtEfiFileDevicePath (
+ IN EFI_HANDLE Device OPTIONAL,
+ IN CHAR16 *FileName
+ )
+/*++
+
+Routine Description:
+
+ This function allocates a device path for a file and appends it to an existiong
+ device path.
+
+Arguments:
+ Device - A pointer to a device handle.
+
+ FileName - A pointer to a Null-terminated Unicodestring.
+
+Returns:
+ A device path contain the file name.
+
+--*/
+{
+ UINTN Size;
+ FILEPATH_DEVICE_PATH *FilePath;
+ EFI_DEVICE_PATH_PROTOCOL *Eop;
+ EFI_DEVICE_PATH_PROTOCOL *DevicePath;
+
+ for (Size = 0; FileName[Size] != 0; Size++)
+ ;
+ Size = (Size + 1) * 2;
+
+ FilePath = InternalAllocateZeroPool (Size + SIZE_OF_FILEPATH_DEVICE_PATH + sizeof (EFI_DEVICE_PATH_PROTOCOL));
+
+ DevicePath = NULL;
+
+ if (FilePath != NULL) {
+
+ //
+ // Build a file path
+ //
+ FilePath->Header.Type = MEDIA_DEVICE_PATH;
+ FilePath->Header.SubType = MEDIA_FILEPATH_DP;
+ SetDevicePathNodeLength (&FilePath->Header, Size + SIZE_OF_FILEPATH_DEVICE_PATH);
+ EfiCopyMem (FilePath->PathName, FileName, Size);
+ Eop = NextDevicePathNode (&FilePath->Header);
+ SetDevicePathEndNode (Eop);
+
+ //
+ // Append file path to device's device path
+ //
+
+ DevicePath = (EFI_DEVICE_PATH_PROTOCOL *) FilePath;
+ if (Device != NULL) {
+ DevicePath = RtEfiAppendDevicePath (
+ RtEfiDevicePathFromHandle (Device),
+ DevicePath
+ );
+
+ gBS->FreePool (FilePath);
+ }
+ }
+
+ return DevicePath;
+}
+
+EFI_DEVICE_PATH_PROTOCOL *
+RtEfiAppendDevicePathInstance (
+ IN EFI_DEVICE_PATH_PROTOCOL *Src,
+ IN EFI_DEVICE_PATH_PROTOCOL *Instance
+ )
+/*++
+
+Routine Description:
+
+ Append a device path instance to another.
+
+Arguments:
+
+ Src - The device path instance to be appended with.
+ Instance - The device path instance appending the other.
+
+Returns:
+
+ The contaction of these two.
+
+--*/
+{
+ UINT8 *Ptr;
+ EFI_DEVICE_PATH_PROTOCOL *DevPath;
+ UINTN SrcSize;
+ UINTN InstanceSize;
+
+ if (Src == NULL) {
+ return RtEfiDuplicateDevicePath (Instance);
+ }
+
+ SrcSize = RtEfiDevicePathSize (Src);
+ InstanceSize = RtEfiDevicePathSize (Instance);
+
+ Ptr = InternalAllocateCopyPool (SrcSize + InstanceSize, Src);
+ if (Ptr != NULL) {
+
+ DevPath = (EFI_DEVICE_PATH_PROTOCOL *) Ptr;
+
+ while (!IsDevicePathEnd (DevPath)) {
+ DevPath = NextDevicePathNode (DevPath);
+ }
+ //
+ // Convert the End to an End Instance, since we are
+ // appending another instacne after this one its a good
+ // idea.
+ //
+ DevPath->SubType = END_INSTANCE_DEVICE_PATH_SUBTYPE;
+
+ DevPath = NextDevicePathNode (DevPath);
+ EfiCopyMem (DevPath, Instance, InstanceSize);
+ }
+
+ return (EFI_DEVICE_PATH_PROTOCOL *) Ptr;
+}
+
+VOID
+EFIAPI
+RtEfiInitializeFwVolDevicepathNode (
+ IN MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode,
+ IN EFI_GUID *NameGuid
+ )
+/*++
+
+Routine Description:
+
+ Initialize a Firmware Volume (FV) Media Device Path node.
+
+Arguments:
+
+ FvDevicePathNode - Pointer to a FV device path node to initialize
+ NameGuid - FV file name to use in FvDevicePathNode
+
+Returns:
+
+ None
+
+--*/
+{
+ FvDevicePathNode->Header.Type = MEDIA_DEVICE_PATH;
+ FvDevicePathNode->Header.SubType = MEDIA_FV_FILEPATH_DP;
+ SetDevicePathNodeLength (&FvDevicePathNode->Header, sizeof (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH));
+
+ EfiCopyMem (&FvDevicePathNode->NameGuid, NameGuid, sizeof(EFI_GUID));
+}
+
+EFI_GUID *
+EFIAPI
+RtEfiGetNameGuidFromFwVolDevicePathNode (
+ IN MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvDevicePathNode
+ )
+/*++
+
+Routine Description:
+
+ Check to see if the Firmware Volume (FV) Media Device Path is valid.
+
+Arguments:
+
+ FvDevicePathNode - Pointer to FV device path to check
+
+Returns:
+
+ NULL - FvDevicePathNode is not valid.
+ Other - FvDevicePathNode is valid and pointer to NameGuid was returned.
+
+--*/
+{
+ if (DevicePathType (&FvDevicePathNode->Header) == MEDIA_DEVICE_PATH &&
+ DevicePathSubType (&FvDevicePathNode->Header) == MEDIA_FV_FILEPATH_DP) {
+ return &FvDevicePathNode->NameGuid;
+ }
+
+ return NULL;
+}
+
diff --git a/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/ia32/Fvb.c b/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/ia32/Fvb.c
new file mode 100644
index 0000000..1cf85c0
--- /dev/null
+++ b/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/ia32/Fvb.c
@@ -0,0 +1,617 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Fvb.c
+
+Abstract:
+
+ Firmware Volume Block Protocol Runtime Abstraction
+
+ mFvbEntry is an array of Handle Fvb pairs. The Fvb Lib Instance matches the
+ index in the mFvbEntry array. This should be the same sequence as the FVB's
+ were described in the HOB. We have to remember the handle so we can tell if
+ the protocol has been reinstalled and it needs updateing.
+
+ If you are using any of these lib functions.you must first call FvbInitialize ().
+
+Key:
+ FVB - Firmware Volume Block
+
+--*/
+
+#include "Tiano.h"
+#include "EfiRuntimeLib.h"
+#include EFI_PROTOCOL_DEFINITION (FirmwareVolumeBlock)
+#include EFI_PROTOCOL_DEFINITION (FvbExtension)
+
+//
+// Lib will ASSERT if more FVB devices than this are added to the system.
+//
+UINTN mFvbCount;
+VOID *mFvbRegistration;
+VOID *mFvbExtRegistration;
+static EFI_EVENT mEfiFvbVirtualNotifyEvent;
+BOOLEAN gEfiFvbInitialized = FALSE;
+EFI_EVENT mFvbEvent;
+
+BOOLEAN
+IsMemoryRuntime (
+ IN VOID *Address
+ )
+/*++
+
+Routine Description:
+ Check whether an address is runtime memory or not.
+
+Arguments:
+
+ Address - The Address being checked.
+
+Returns:
+ TRUE - The address is runtime memory.
+ FALSE - The address is not runtime memory.
+
+--*/
+{
+ EFI_STATUS Status;
+ UINT8 TmpMemoryMap[1];
+ UINTN MapKey;
+ UINTN DescriptorSize;
+ UINT32 DescriptorVersion;
+ UINTN MemoryMapSize;
+ EFI_MEMORY_DESCRIPTOR *MemoryMap;
+ EFI_MEMORY_DESCRIPTOR *MemoryMapPtr;
+ BOOLEAN IsRuntime;
+ UINTN Index;
+
+ IsRuntime = FALSE;
+
+ //
+ // Get System MemoryMapSize
+ //
+ MemoryMapSize = 1;
+ Status = gBS->GetMemoryMap (
+ &MemoryMapSize,
+ (EFI_MEMORY_DESCRIPTOR *)TmpMemoryMap,
+ &MapKey,
+ &DescriptorSize,
+ &DescriptorVersion
+ );
+ ASSERT (Status == EFI_BUFFER_TOO_SMALL);
+ //
+ // Enlarge space here, because we will allocate pool now.
+ //
+ MemoryMapSize += EFI_PAGE_SIZE;
+ Status = gBS->AllocatePool (
+ EfiBootServicesData,
+ MemoryMapSize,
+ (VOID**)&MemoryMap
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // Get System MemoryMap
+ //
+ Status = gBS->GetMemoryMap (
+ &MemoryMapSize,
+ MemoryMap,
+ &MapKey,
+ &DescriptorSize,
+ &DescriptorVersion
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ MemoryMapPtr = MemoryMap;
+ //
+ // Search the request Address
+ //
+ for (Index = 0; Index < (MemoryMapSize / DescriptorSize); Index++) {
+ if (((EFI_PHYSICAL_ADDRESS)(UINTN)Address >= MemoryMap->PhysicalStart) &&
+ ((EFI_PHYSICAL_ADDRESS)(UINTN)Address < MemoryMap->PhysicalStart
+ + LShiftU64 (MemoryMap->NumberOfPages, EFI_PAGE_SHIFT))) {
+ //
+ // Found it
+ //
+ if (MemoryMap->Attribute & EFI_MEMORY_RUNTIME) {
+ IsRuntime = TRUE;
+ }
+ break;
+ }
+ //
+ // Get next item
+ //
+ MemoryMap = (EFI_MEMORY_DESCRIPTOR *)((UINTN)MemoryMap + DescriptorSize);
+ }
+
+ //
+ // Done
+ //
+ gBS->FreePool (MemoryMapPtr);
+
+ return IsRuntime;
+}
+
+VOID
+EFIAPI
+FvbNotificationFunction (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+/*++
+
+Routine Description:
+ Update mFvbEntry. Add new entry, or update existing entry if Fvb protocol is
+ reinstalled.
+
+Arguments:
+
+ Event - The Event that is being processed
+
+ Context - Event Context
+
+Returns:
+ None
+
+--*/
+{
+ EFI_STATUS Status;
+ UINTN BufferSize;
+ EFI_HANDLE Handle;
+ UINTN Index;
+ UINTN UpdateIndex;
+ EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb;
+ EFI_FVB_EXTENSION_PROTOCOL *FvbExtension;
+
+ while (TRUE) {
+ BufferSize = sizeof (Handle);
+ Status = gBS->LocateHandle (
+ ByRegisterNotify,
+ &gEfiFirmwareVolumeBlockProtocolGuid,
+ mFvbRegistration,
+ &BufferSize,
+ &Handle
+ );
+ if (EFI_ERROR (Status)) {
+ //
+ // Exit Path of While Loop....
+ //
+ break;
+ }
+
+ UpdateIndex = MAX_FVB_COUNT;
+ for (Index = 0; Index < mFvbCount; Index++) {
+ if (mFvbEntry[Index].Handle == Handle) {
+ //
+ // If the handle is already in the table just update the protocol
+ //
+ UpdateIndex = Index;
+ break;
+ }
+ }
+
+ if (UpdateIndex == MAX_FVB_COUNT) {
+ //
+ // Use the next free slot for a new entry
+ //
+ UpdateIndex = mFvbCount;
+ }
+ //
+ // The array does not have enough entries
+ //
+ ASSERT (UpdateIndex < MAX_FVB_COUNT);
+
+ //
+ // Get the interface pointer and if it's ours, skip it.
+ // We check Runtime here, because it has no reason to register
+ // a boot time FVB protocol.
+ //
+ Status = gBS->HandleProtocol (Handle, &gEfiFirmwareVolumeBlockProtocolGuid, &Fvb);
+ ASSERT_EFI_ERROR (Status);
+ if (IsMemoryRuntime (Fvb)) {
+ //
+ // Increase mFvbCount if we need to add a new entry
+ //
+ if (UpdateIndex == mFvbCount) {
+ mFvbCount++;
+ }
+ mFvbEntry[UpdateIndex].Handle = Handle;
+ mFvbEntry[UpdateIndex].Fvb = Fvb;
+ mFvbEntry[UpdateIndex].FvbExtension = NULL;
+
+ Status = gBS->HandleProtocol (Handle, &gEfiFvbExtensionProtocolGuid, &FvbExtension);
+ if ((Status == EFI_SUCCESS) && IsMemoryRuntime (FvbExtension)) {
+ mFvbEntry[UpdateIndex].FvbExtension = FvbExtension;
+ }
+ }
+ }
+}
+
+EFI_STATUS
+EfiFvbInitialize (
+ VOID
+ )
+/*++
+
+Routine Description:
+ Initialize globals and register Fvb Protocol notification function.
+
+Arguments:
+ None
+
+Returns:
+ EFI_SUCCESS - Fvb is successfully initialized
+ others - Fail to initialize
+
+--*/
+{
+ UINTN Status;
+ mFvbCount = 0;
+
+ Status = gBS->AllocatePool (
+ EfiRuntimeServicesData,
+ (UINTN) sizeof (FVB_ENTRY) * MAX_FVB_COUNT,
+ (VOID *) &mFvbEntry
+ );
+
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ EfiZeroMem (mFvbEntry, sizeof (FVB_ENTRY) * MAX_FVB_COUNT);
+
+ mFvbEvent = RtEfiLibCreateProtocolNotifyEvent (
+ &gEfiFirmwareVolumeBlockProtocolGuid,
+ EFI_TPL_CALLBACK,
+ FvbNotificationFunction,
+ NULL,
+ &mFvbRegistration
+ );
+
+ //
+ // Register SetVirtualAddressMap () notify function
+ //
+ // Status = gBS->CreateEvent (
+ // EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE,
+ // EFI_TPL_NOTIFY,
+ // EfiRuntimeLibFvbVirtualNotifyEvent,
+ // NULL,
+ // &mEfiFvbVirtualNotifyEvent
+ // );
+ // ASSERT_EFI_ERROR (Status);
+ //
+ gEfiFvbInitialized = TRUE;
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EfiFvbShutdown (
+ VOID
+ )
+/*++
+
+Routine Description:
+ Release resources allocated in EfiFvbInitialize.
+
+Arguments:
+ None
+
+Returns:
+ EFI_SUCCESS
+
+--*/
+{
+ gBS->FreePool ((VOID *) mFvbEntry);
+ gBS->CloseEvent (mFvbEvent);
+ gEfiFvbInitialized = FALSE;
+ return EFI_SUCCESS;
+}
+
+//
+// The following functions wrap Fvb protocol in the Runtime Lib functions.
+// The Instance translates into Fvb instance. The Fvb order defined by HOBs and
+// thus the sequence of FVB protocol addition define Instance.
+//
+// EfiFvbInitialize () must be called before any of the following functions
+// must be called.
+//
+
+EFI_STATUS
+EfiFvbReadBlock (
+ IN UINTN Instance,
+ IN EFI_LBA Lba,
+ IN UINTN Offset,
+ IN OUT UINTN *NumBytes,
+ IN UINT8 *Buffer
+ )
+/*++
+
+Routine Description:
+ Reads specified number of bytes into a buffer from the specified block
+
+Arguments:
+ Instance - The FV instance to be read from
+ Lba - The logical block address to be read from
+ Offset - Offset into the block at which to begin reading
+ NumBytes - Pointer that on input contains the total size of
+ the buffer. On output, it contains the total number
+ of bytes read
+ Buffer - Pointer to a caller allocated buffer that will be
+ used to hold the data read
+
+Returns:
+
+ Status code
+
+ EFI_INVALID_PARAMETER - invalid parameter
+
+--*/
+{
+ if (Instance >= mFvbCount) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ return mFvbEntry[Instance].Fvb->Read (mFvbEntry[Instance].Fvb, Lba, Offset, NumBytes, Buffer);
+}
+
+EFI_STATUS
+EfiFvbWriteBlock (
+ IN UINTN Instance,
+ IN EFI_LBA Lba,
+ IN UINTN Offset,
+ IN OUT UINTN *NumBytes,
+ IN UINT8 *Buffer
+ )
+/*++
+
+Routine Description:
+ Writes specified number of bytes from the input buffer to the block
+
+Arguments:
+ Instance - The FV instance to be written to
+ Lba - The starting logical block index to write to
+ Offset - Offset into the block at which to begin writing
+ NumBytes - Pointer that on input contains the total size of
+ the buffer. On output, it contains the total number
+ of bytes actually written
+ Buffer - Pointer to a caller allocated buffer that contains
+ the source for the write
+
+Returns:
+
+ Status code
+
+ EFI_INVALID_PARAMETER - invalid parameter
+
+--*/
+{
+ if (Instance >= mFvbCount) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ return mFvbEntry[Instance].Fvb->Write (mFvbEntry[Instance].Fvb, Lba, Offset, NumBytes, Buffer);
+}
+
+EFI_STATUS
+EfiFvbEraseBlock (
+ IN UINTN Instance,
+ IN EFI_LBA Lba
+ )
+/*++
+
+Routine Description:
+ Erases and initializes a firmware volume block
+
+Arguments:
+ Instance - The FV instance to be erased
+ Lba - The logical block index to be erased
+
+Returns:
+
+ Status code
+
+ EFI_INVALID_PARAMETER - invalid parameter
+
+--*/
+{
+ if (Instance >= mFvbCount) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ return mFvbEntry[Instance].Fvb->EraseBlocks (mFvbEntry[Instance].Fvb, Lba, -1);
+}
+
+EFI_STATUS
+EfiFvbGetVolumeAttributes (
+ IN UINTN Instance,
+ OUT EFI_FVB_ATTRIBUTES *Attributes
+ )
+/*++
+
+Routine Description:
+ Retrieves attributes, insures positive polarity of attribute bits, returns
+ resulting attributes in output parameter
+
+Arguments:
+ Instance - The FV instance whose attributes is going to be
+ returned
+ Attributes - Output buffer which contains attributes
+
+Returns:
+ Status code
+
+ EFI_INVALID_PARAMETER - invalid parameter
+
+--*/
+{
+ if (Instance >= mFvbCount) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ return mFvbEntry[Instance].Fvb->GetVolumeAttributes (mFvbEntry[Instance].Fvb, Attributes);
+}
+
+EFI_STATUS
+EfiFvbSetVolumeAttributes (
+ IN UINTN Instance,
+ IN EFI_FVB_ATTRIBUTES Attributes
+ )
+/*++
+
+Routine Description:
+ Modifies the current settings of the firmware volume according to the
+ input parameter, and returns the new setting of the volume
+
+Arguments:
+ Instance - The FV instance whose attributes is going to be
+ modified
+ Attributes - On input, it is a pointer to EFI_FVB_ATTRIBUTES
+ containing the desired firmware volume settings.
+ On successful return, it contains the new settings
+ of the firmware volume
+
+Returns:
+ Status code
+
+ EFI_INVALID_PARAMETER - invalid parameter
+
+--*/
+{
+ if (Instance >= mFvbCount) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ return mFvbEntry[Instance].Fvb->SetVolumeAttributes (mFvbEntry[Instance].Fvb, &Attributes);
+}
+
+EFI_STATUS
+EfiFvbGetPhysicalAddress (
+ IN UINTN Instance,
+ OUT EFI_PHYSICAL_ADDRESS *BaseAddress
+ )
+/*++
+
+Routine Description:
+ Retrieves the physical address of a memory mapped FV
+
+Arguments:
+ Instance - The FV instance whose base address is going to be
+ returned
+ BaseAddress - Pointer to a caller allocated EFI_PHYSICAL_ADDRESS
+ that on successful return, contains the base address
+ of the firmware volume.
+
+Returns:
+
+ Status code
+
+ EFI_INVALID_PARAMETER - invalid parameter
+
+--*/
+{
+ if (Instance >= mFvbCount) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ return mFvbEntry[Instance].Fvb->GetPhysicalAddress (mFvbEntry[Instance].Fvb, BaseAddress);
+}
+
+EFI_STATUS
+EfiFvbGetBlockSize (
+ IN UINTN Instance,
+ IN EFI_LBA Lba,
+ OUT UINTN *BlockSize,
+ OUT UINTN *NumOfBlocks
+ )
+/*++
+
+Routine Description:
+ Retrieve the size of a logical block
+
+Arguments:
+ Instance - The FV instance whose block size is going to be
+ returned
+ Lba - Indicates which block to return the size for.
+ BlockSize - A pointer to a caller allocated UINTN in which
+ the size of the block is returned
+ NumOfBlocks - a pointer to a caller allocated UINTN in which the
+ number of consecutive blocks starting with Lba is
+ returned. All blocks in this range have a size of
+ BlockSize
+
+Returns:
+ EFI_SUCCESS - The firmware volume was read successfully and
+ contents are in Buffer
+
+ EFI_INVALID_PARAMETER - invalid parameter
+
+--*/
+{
+ if (Instance >= mFvbCount) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ return mFvbEntry[Instance].Fvb->GetBlockSize (mFvbEntry[Instance].Fvb, Lba, BlockSize, NumOfBlocks);
+}
+
+EFI_STATUS
+EfiFvbEraseCustomBlockRange (
+ IN UINTN Instance,
+ IN EFI_LBA StartLba,
+ IN UINTN OffsetStartLba,
+ IN EFI_LBA LastLba,
+ IN UINTN OffsetLastLba
+ )
+/*++
+
+Routine Description:
+ Erases and initializes a specified range of a firmware volume
+
+Arguments:
+ Instance - The FV instance to be erased
+ StartLba - The starting logical block index to be erased
+ OffsetStartLba - Offset into the starting block at which to
+ begin erasing
+ LastLba - The last logical block index to be erased
+ OffsetLastLba - Offset into the last block at which to end erasing
+
+Returns:
+
+ Status code
+
+ EFI_INVALID_PARAMETER - invalid parameter
+
+ EFI_UNSUPPORTED - not support
+
+--*/
+{
+ if (Instance >= mFvbCount) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (!(mFvbEntry[Instance].FvbExtension)) {
+ return EFI_UNSUPPORTED;
+ }
+
+ if (!(mFvbEntry[Instance].FvbExtension->EraseFvbCustomBlock)) {
+ return EFI_UNSUPPORTED;
+ }
+
+ return mFvbEntry[Instance].FvbExtension->EraseFvbCustomBlock (
+ mFvbEntry[Instance].FvbExtension,
+ StartLba,
+ OffsetStartLba,
+ LastLba,
+ OffsetLastLba
+ );
+}
diff --git a/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/ia32/IoLib.c b/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/ia32/IoLib.c
new file mode 100644
index 0000000..ad65bae
--- /dev/null
+++ b/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/ia32/IoLib.c
@@ -0,0 +1,130 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ IoLib.c
+
+Abstract:
+
+ Light weight lib to support Tiano drivers.
+
+--*/
+
+#include "Tiano.h"
+#include "EfiRuntimeLib.h"
+#include EFI_PROTOCOL_DEFINITION (CpuIo)
+
+extern EFI_CPU_IO_PROTOCOL *gCpuIo;
+
+EFI_STATUS
+EfiIoRead (
+ IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
+ IN UINT64 Address,
+ IN UINTN Count,
+ IN OUT VOID *Buffer
+ )
+/*++
+
+Routine Description:
+ Perform an IO read into Buffer.
+
+Arguments:
+ Width - Width of read transaction, and repeat operation to use
+ Address - IO address to read
+ Count - Number of times to read the IO address.
+ Buffer - Buffer to read data into. size is Width * Count
+
+Returns:
+ BugBug: Check with Mike to see if I can find this #define some ware else
+
+--*/
+{
+ return gCpuIo->Io.Read (gCpuIo, Width, Address, Count, Buffer);
+}
+
+EFI_STATUS
+EfiIoWrite (
+ IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
+ IN UINT64 Address,
+ IN UINTN Count,
+ IN OUT VOID *Buffer
+ )
+/*++
+
+Routine Description:
+ Perform an IO write into Buffer.
+
+Arguments:
+ Width - Width of write transaction, and repeat operation to use
+ Address - IO address to write
+ Count - Number of times to write the IO address.
+ Buffer - Buffer to write data from. size is Width * Count
+
+Returns:
+ BugBug: Check with Mike to see if I can find this #define some ware else
+
+--*/
+{
+ return gCpuIo->Io.Write (gCpuIo, Width, Address, Count, Buffer);
+}
+
+EFI_STATUS
+EfiMemRead (
+ IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
+ IN UINT64 Address,
+ IN UINTN Count,
+ IN OUT VOID *Buffer
+ )
+/*++
+
+Routine Description:
+ Perform a Memory mapped IO read into Buffer.
+
+Arguments:
+ Width - Width of each read transaction.
+ Address - Memory mapped IO address to read
+ Count - Number of Width quanta to read
+ Buffer - Buffer to read data into. size is Width * Count
+
+Returns:
+ BugBug: Check with Mike to see if I can find this #define some ware else
+
+--*/
+{
+ return gCpuIo->Mem.Read (gCpuIo, Width, Address, Count, Buffer);
+}
+
+EFI_STATUS
+EfiMemWrite (
+ IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
+ IN UINT64 Address,
+ IN UINTN Count,
+ IN OUT VOID *Buffer
+ )
+/*++
+
+Routine Description:
+ Perform a memory mapped IO write into Buffer.
+
+Arguments:
+ Width - Width of write transaction, and repeat operation to use
+ Address - IO address to write
+ Count - Number of times to write the IO address.
+ Buffer - Buffer to write data from. size is Width * Count
+
+Returns:
+ BugBug: Check with Mike to see if I can find this #define some ware else
+
+--*/
+{
+ return gCpuIo->Mem.Write (gCpuIo, Width, Address, Count, Buffer);
+}
diff --git a/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/ia32/Lock.c b/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/ia32/Lock.c
new file mode 100644
index 0000000..596da27
--- /dev/null
+++ b/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/ia32/Lock.c
@@ -0,0 +1,177 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Lock.c
+
+Abstract:
+
+ Support for locking lib services.
+
+--*/
+
+#include "Tiano.h"
+#include "EfiDriverLib.h"
+
+extern
+BOOLEAN
+EfiAtRuntime (
+ VOID
+ );
+
+VOID
+EfiInitializeLock (
+ IN OUT EFI_LOCK *Lock,
+ IN EFI_TPL Priority
+ )
+/*++
+
+Routine Description:
+
+ Initialize a basic mutual exclusion lock. Each lock
+ provides mutual exclusion access at it's task priority
+ level. Since there is no-premption (at any TPL) or
+ multiprocessor support, acquiring the lock only consists
+ of raising to the locks TPL.
+
+ Note on a check build ASSERT()s are used to ensure proper
+ lock usage.
+
+Arguments:
+
+ Lock - The EFI_LOCK structure to initialize
+
+ Priority - The task priority level of the lock
+
+
+Returns:
+
+ An initialized Efi Lock structure.
+
+--*/
+{
+ Lock->Tpl = Priority;
+ Lock->OwnerTpl = 0;
+ Lock->Lock = 0;
+}
+
+EFI_STATUS
+EfiAcquireLockOrFail (
+ IN EFI_LOCK *Lock
+ )
+/*++
+
+Routine Description:
+
+ Initialize a basic mutual exclusion lock. Each lock
+ provides mutual exclusion access at it's task priority
+ level. Since there is no-premption (at any TPL) or
+ multiprocessor support, acquiring the lock only consists
+ of raising to the locks TPL.
+
+Arguments:
+
+ Lock - The EFI_LOCK structure to initialize
+
+Returns:
+
+ EFI_SUCCESS - Lock Owned.
+ EFI_ACCESS_DENIED - Reentrant Lock Acquisition, Lock not Owned.
+
+--*/
+{
+ if (Lock->Lock != 0) {
+ //
+ // Lock is already owned, so bail out
+ //
+ return EFI_ACCESS_DENIED;
+ }
+
+ if (!EfiAtRuntime ()) {
+ //
+ // The check is just debug code for core inplementation. It must
+ // always be true in a driver
+ //
+ Lock->OwnerTpl = gBS->RaiseTPL (Lock->Tpl);
+ }
+
+ Lock->Lock += 1;
+ return EFI_SUCCESS;
+}
+
+VOID
+EfiAcquireLock (
+ IN EFI_LOCK *Lock
+ )
+/*++
+
+Routine Description:
+
+ Raising to the task priority level of the mutual exclusion
+ lock, and then acquires ownership of the lock.
+
+Arguments:
+
+ Lock - The lock to acquire
+
+Returns:
+
+ Lock owned
+
+--*/
+{
+ EFI_STATUS Status;
+
+ Status = EfiAcquireLockOrFail (Lock);
+
+ //
+ // Lock was already locked.
+ //
+ ASSERT_EFI_ERROR (Status);
+}
+
+VOID
+EfiReleaseLock (
+ IN EFI_LOCK *Lock
+ )
+/*++
+
+Routine Description:
+
+ Releases ownership of the mutual exclusion lock, and
+ restores the previous task priority level.
+
+Arguments:
+
+ Lock - The lock to release
+
+Returns:
+
+ Lock unowned
+
+--*/
+{
+ EFI_TPL Tpl;
+
+ Tpl = Lock->OwnerTpl;
+
+ ASSERT (Lock->Lock == 1);
+ Lock->Lock -= 1;
+
+ if (!EfiAtRuntime ()) {
+ //
+ // The check is just debug code for core inplementation. It must
+ // always be true in a driver
+ //
+ gBS->RestoreTPL (Tpl);
+ }
+}
diff --git a/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/ia32/PlatformIoLib.c b/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/ia32/PlatformIoLib.c
new file mode 100644
index 0000000..d06d0ea
--- /dev/null
+++ b/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/ia32/PlatformIoLib.c
@@ -0,0 +1,407 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PlatformIoLib.c
+
+Abstract:
+
+--*/
+
+#include "Tiano.h"
+#include "EfiRuntimeLib.h"
+#include EFI_PROTOCOL_DEFINITION (CpuIo)
+
+#define PCI_CONFIG_INDEX_PORT 0xcf8
+#define PCI_CONFIG_DATA_PORT 0xcfc
+#define REFRESH_CYCLE_TOGGLE_BIT 0x10
+
+UINT32
+GetPciAddress (
+ UINT8 Segment,
+ UINT8 Bus,
+ UINT8 DevFunc,
+ UINT8 Register
+ )
+/*++
+
+Routine Description:
+ Constructs PCI Address 32 bits
+
+Arguments:
+ Segment - PCI Segment ACPI _SEG
+ Bus - PCI Bus
+ DevFunc - PCI Device(7:3) and Func(2:0)
+ Register - PCI config space register
+
+Returns:
+ PciAddress to be written to Config Port
+
+--*/
+{
+ UINT32 Data;
+
+ Data = (((UINT32) Segment) << 24);
+ Data |= (((UINT32) Bus) << 16);
+ Data |= (((UINT32) DevFunc) << 8);
+ Data |= (UINT32) Register;
+
+ return Data;
+
+}
+
+UINT8
+PciRead8 (
+ UINT8 Segment,
+ UINT8 Bus,
+ UINT8 DevFunc,
+ UINT8 Register
+ )
+/*++
+
+Routine Description:
+ Perform an one byte PCI config cycle read
+
+Arguments:
+ Segment - PCI Segment ACPI _SEG
+ Bus - PCI Bus
+ DevFunc - PCI Device(7:3) and Func(2:0)
+ Register - PCI config space register
+
+Returns:
+ Data read from PCI config space
+
+--*/
+{
+ EFI_STATUS Status;
+ UINT32 PciAddress;
+ UINT32 PciAddress1;
+ UINT8 Data;
+
+ PciAddress = GetPciAddress (Segment, Bus, DevFunc, Register);
+ //
+ // Set bit 31 for PCI config access
+ //
+ PciAddress1 = PciAddress;
+ PciAddress = ((PciAddress & 0xFFFFFFFC) | (0x80000000));
+
+ Status = EfiIoWrite (EfiCpuIoWidthUint32, PCI_CONFIG_INDEX_PORT, 1, &PciAddress);
+
+ if (EFI_ERROR (Status)) {
+ return 0;
+ }
+
+ EfiIoRead (EfiCpuIoWidthUint8, (PCI_CONFIG_DATA_PORT + (PciAddress1 & 0x3)), 1, &Data);
+
+ return Data;
+}
+
+UINT16
+PciRead16 (
+ UINT8 Segment,
+ UINT8 Bus,
+ UINT8 DevFunc,
+ UINT8 Register
+ )
+/*++
+
+Routine Description:
+ Perform an two byte PCI config cycle read
+
+Arguments:
+ Segment - PCI Segment ACPI _SEG
+ Bus - PCI Bus
+ DevFunc - PCI Device(7:3) and Func(2:0)
+ Register - PCI config space register
+
+Returns:
+ Data read from PCI config space
+
+--*/
+{
+ EFI_STATUS Status;
+ UINT32 PciAddress;
+ UINT32 PciAddress1;
+ UINT16 Data;
+
+ PciAddress = GetPciAddress (Segment, Bus, DevFunc, Register);
+ //
+ // Set bit 31 for PCI config access
+ //
+ PciAddress1 = PciAddress;
+ PciAddress = ((PciAddress & 0xFFFFFFFC) | (0x80000000));
+
+ Status = EfiIoWrite (EfiCpuIoWidthUint32, PCI_CONFIG_INDEX_PORT, 1, &PciAddress);
+
+ if (EFI_ERROR (Status)) {
+ return 0;
+ }
+
+ EfiIoRead (EfiCpuIoWidthUint16, (PCI_CONFIG_DATA_PORT + (PciAddress1 & 0x3)), 1, &Data);
+
+ return Data;
+}
+
+UINT32
+PciRead32 (
+ UINT8 Segment,
+ UINT8 Bus,
+ UINT8 DevFunc,
+ UINT8 Register
+ )
+/*++
+
+Routine Description:
+ Perform an four byte PCI config cycle read
+
+Arguments:
+ Segment - PCI Segment ACPI _SEG
+ Bus - PCI Bus
+ DevFunc - PCI Device(7:3) and Func(2:0)
+ Register - PCI config space register
+
+Returns:
+ Data read from PCI config space
+
+--*/
+{
+ EFI_STATUS Status;
+ UINT32 PciAddress;
+ UINT32 PciAddress1;
+ UINT32 Data;
+
+ PciAddress = GetPciAddress (Segment, Bus, DevFunc, Register);
+ //
+ // Set bit 31 for PCI config access
+ //
+ PciAddress1 = PciAddress;
+ PciAddress = ((PciAddress & 0xFFFFFFFC) | (0x80000000));
+
+ Status = EfiIoWrite (EfiCpuIoWidthUint32, PCI_CONFIG_INDEX_PORT, 1, &PciAddress);
+
+ if (EFI_ERROR (Status)) {
+ return 0;
+ }
+
+ EfiIoRead (EfiCpuIoWidthUint32, (PCI_CONFIG_DATA_PORT + (PciAddress1 & 0x3)), 1, &Data);
+
+ return Data;
+}
+
+VOID
+PciWrite8 (
+ UINT8 Segment,
+ UINT8 Bus,
+ UINT8 DevFunc,
+ UINT8 Register,
+ UINT8 Data
+ )
+/*++
+
+Routine Description:
+ Perform an one byte PCI config cycle write
+
+Arguments:
+ Segment - PCI Segment ACPI _SEG
+ Bus - PCI Bus
+ DevFunc - PCI Device(7:3) and Func(2:0)
+ Register - PCI config space register
+ Data - Data to write
+
+Returns:
+ NONE
+
+--*/
+{
+ EFI_STATUS Status;
+ UINT32 PciAddress;
+ UINT32 PciAddress1;
+
+ PciAddress = GetPciAddress (Segment, Bus, DevFunc, Register);
+ //
+ // Set bit 31 for PCI config access
+ //
+ PciAddress1 = PciAddress;
+ PciAddress = ((PciAddress & 0xFFFFFFFC) | (0x80000000));
+
+ Status = EfiIoWrite (EfiCpuIoWidthUint32, PCI_CONFIG_INDEX_PORT, 1, &PciAddress);
+
+ if (EFI_ERROR (Status)) {
+ return ;
+ }
+
+ EfiIoWrite (EfiCpuIoWidthUint8, (PCI_CONFIG_DATA_PORT + (PciAddress1 & 0x3)), 1, &Data);
+}
+
+VOID
+PciWrite16 (
+ UINT8 Segment,
+ UINT8 Bus,
+ UINT8 DevFunc,
+ UINT8 Register,
+ UINT16 Data
+ )
+/*++
+
+Routine Description:
+ Perform an two byte PCI config cycle write
+
+Arguments:
+ Segment - PCI Segment ACPI _SEG
+ Bus - PCI Bus
+ DevFunc - PCI Device(7:3) and Func(2:0)
+ Register - PCI config space register
+ Data - Data to write
+
+Returns:
+ NONE
+
+--*/
+{
+ EFI_STATUS Status;
+ UINT32 PciAddress;
+ UINT32 PciAddress1;
+
+ PciAddress = GetPciAddress (Segment, Bus, DevFunc, Register);
+ //
+ // Set bit 31 for PCI config access
+ //
+ PciAddress1 = PciAddress;
+ PciAddress = ((PciAddress & 0xFFFFFFFC) | (0x80000000));
+
+ Status = EfiIoWrite (EfiCpuIoWidthUint32, PCI_CONFIG_INDEX_PORT, 1, &PciAddress);
+
+ if (EFI_ERROR (Status)) {
+ return ;
+ }
+
+ EfiIoWrite (EfiCpuIoWidthUint16, (PCI_CONFIG_DATA_PORT + (PciAddress1 & 0x3)), 1, &Data);
+}
+
+VOID
+PciWrite32 (
+ UINT8 Segment,
+ UINT8 Bus,
+ UINT8 DevFunc,
+ UINT8 Register,
+ UINT32 Data
+ )
+/*++
+
+Routine Description:
+ Perform an four byte PCI config cycle write
+
+Arguments:
+ Segment - PCI Segment ACPI _SEG
+ Bus - PCI Bus
+ DevFunc - PCI Device(7:3) and Func(2:0)
+ Register - PCI config space register
+ Data - Data to write
+
+Returns:
+ NONE
+
+--*/
+{
+ EFI_STATUS Status;
+ UINT32 PciAddress;
+ UINT32 PciAddress1;
+
+ PciAddress = GetPciAddress (Segment, Bus, DevFunc, Register);
+ //
+ // Set bit 31 for PCI config access
+ //
+ PciAddress1 = PciAddress;
+ PciAddress = ((PciAddress & 0xFFFFFFFC) | (0x80000000));
+
+ Status = EfiIoWrite (EfiCpuIoWidthUint32, PCI_CONFIG_INDEX_PORT, 1, &PciAddress);
+
+ if (EFI_ERROR (Status)) {
+ return ;
+ }
+
+ EfiIoWrite (EfiCpuIoWidthUint32, (PCI_CONFIG_DATA_PORT + (PciAddress1 & 0x3)), 1, &Data);
+}
+//
+// Delay Primative
+//
+VOID
+EfiStall (
+ IN UINTN Microseconds
+ )
+/*++
+
+Routine Description:
+ Delay for at least the request number of microseconds
+
+Arguments:
+ Microseconds - Number of microseconds to delay.
+
+Returns:
+ NONE
+
+--*/
+{
+ UINT8 Data;
+ UINT8 InitialState;
+ UINTN CycleIterations;
+
+ CycleIterations = 0;
+ Data = 0;
+ InitialState = 0;
+
+ if (EfiAtRuntime ()) {
+ //
+ // The time-source is 30 us granular, so calibrate the timing loop
+ // based on this baseline
+ // Error is possible 30us.
+ //
+ CycleIterations = (Microseconds - 1) / 30 + 1;
+
+ //
+ // Use the DMA Refresh timer in port 0x61. Cheap but effective.
+ // The only issue is that the granularity is 30us, and we want to
+ // guarantee "at least" one full transition to avoid races.
+ //
+ //
+ // _____________/----------\__________/--------
+ //
+ // |<--15us-->|<--15us-->|
+ //
+ // --------------------------------------------------> Time (us)
+ //
+ while (CycleIterations--) {
+ EfiIoRead (EfiCpuIoWidthUint8, 0x61, 1, &Data);
+ Data &= REFRESH_CYCLE_TOGGLE_BIT;
+ InitialState = Data;
+
+ //
+ // Capture first transition (strictly less than one period)
+ //
+ while (InitialState == Data) {
+ EfiIoRead (EfiCpuIoWidthUint8, 0x61, 1, &Data);
+ Data &= REFRESH_CYCLE_TOGGLE_BIT;
+ }
+
+ InitialState = Data;
+ //
+ // Capture next transition (guarantee at least one full pulse)
+ //
+ while (InitialState == Data) {
+ EfiIoRead (EfiCpuIoWidthUint8, 0x61, 1, &Data);
+ Data &= REFRESH_CYCLE_TOGGLE_BIT;
+ }
+ }
+ } else {
+ gBS->Stall (Microseconds);
+ }
+}
diff --git a/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/ia32/RuntimeLib.c b/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/ia32/RuntimeLib.c
new file mode 100644
index 0000000..e73095b
--- /dev/null
+++ b/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/ia32/RuntimeLib.c
@@ -0,0 +1,840 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ RuntimeLib.c
+
+Abstract:
+
+ Light weight lib to support Tiano drivers.
+
+--*/
+
+#include "Tiano.h"
+#include "EfiRuntimeLib.h"
+#include EFI_PROTOCOL_DEFINITION (CpuIo)
+#include EFI_PROTOCOL_DEFINITION (FirmwareVolumeBlock)
+#include EFI_GUID_DEFINITION (StatusCodeCallerId)
+#include EFI_ARCH_PROTOCOL_DEFINITION (StatusCode)
+
+//
+// Driver Lib Module Globals
+//
+static EFI_RUNTIME_SERVICES *mRT;
+static EFI_EVENT mRuntimeNotifyEvent = NULL;
+static EFI_EVENT mEfiVirtualNotifyEvent = NULL;
+static BOOLEAN mRuntimeLibInitialized = FALSE;
+static BOOLEAN mEfiGoneVirtual = FALSE;
+
+//
+// Runtime Global, but you should use the Lib functions
+//
+EFI_CPU_IO_PROTOCOL *gCpuIo;
+BOOLEAN mEfiAtRuntime = FALSE;
+FVB_ENTRY *mFvbEntry;
+
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+static EFI_STATUS_CODE_PROTOCOL *gStatusCode = NULL;
+#endif
+
+EFI_STATUS
+EfiConvertPointer (
+ IN UINTN DebugDisposition,
+ IN OUT VOID *Address
+ )
+/*++
+
+Routine Description:
+
+ Determines the new virtual address that is to be used on subsequent memory accesses.
+
+Arguments:
+
+ DebugDisposition - Supplies type information for the pointer being converted.
+ Address - A pointer to a pointer that is to be fixed to be the value needed
+ for the new virtual address mappings being applied.
+
+Returns:
+
+ Status code
+
+--*/
+{
+ return mRT->ConvertPointer (DebugDisposition, Address);
+}
+
+EFI_STATUS
+EfiConvertInternalPointer (
+ IN OUT VOID *Address
+ )
+/*++
+
+Routine Description:
+
+ Call EfiConvertPointer() to convert internal pointer.
+
+Arguments:
+
+ Address - A pointer to a pointer that is to be fixed to be the value needed
+ for the new virtual address mappings being applied.
+
+Returns:
+
+ Status code
+
+--*/
+{
+ return EfiConvertPointer (EFI_INTERNAL_POINTER, Address);
+}
+
+VOID
+EFIAPI
+EfiRuntimeLibFvbVirtualNotifyEvent (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+/*++
+
+Routine Description:
+
+ Convert all pointers in mFvbEntry after ExitBootServices.
+
+Arguments:
+
+ Event - The Event that is being processed
+
+ Context - Event Context
+
+Returns:
+
+ None
+
+--*/
+{
+ UINTN Index;
+ if (mFvbEntry != NULL) {
+ for (Index = 0; Index < MAX_FVB_COUNT; Index++) {
+ if (NULL != mFvbEntry[Index].Fvb) {
+ EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].Fvb->GetBlockSize);
+ EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].Fvb->GetPhysicalAddress);
+ EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].Fvb->GetVolumeAttributes);
+ EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].Fvb->SetVolumeAttributes);
+ EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].Fvb->Read);
+ EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].Fvb->Write);
+ EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].Fvb->EraseBlocks);
+ EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].Fvb);
+ }
+
+ if (NULL != mFvbEntry[Index].FvbExtension) {
+ EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].FvbExtension->EraseFvbCustomBlock);
+ EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].FvbExtension);
+ }
+ }
+
+ EfiConvertInternalPointer ((VOID **) &mFvbEntry);
+ }
+}
+
+VOID
+EFIAPI
+RuntimeDriverExitBootServices (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+/*++
+
+Routine Description:
+
+ Set AtRuntime flag as TRUE after ExitBootServices
+
+Arguments:
+
+ Event - The Event that is being processed
+
+ Context - Event Context
+
+Returns:
+
+ None
+
+--*/
+{
+ mEfiAtRuntime = TRUE;
+}
+
+extern BOOLEAN gEfiFvbInitialized;
+
+VOID
+EFIAPI
+EfiRuntimeLibVirtualNotifyEvent (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+/*++
+
+Routine Description:
+
+ Fixup internal data so that EFI can be call in virtual mode.
+ Call the passed in Child Notify event and convert any pointers in
+ lib to virtual mode.
+
+Arguments:
+
+ Event - The Event that is being processed
+
+ Context - Event Context
+
+Returns:
+
+ None
+
+--*/
+{
+ EFI_EVENT_NOTIFY ChildNotifyEventHandler;
+
+ if (Context != NULL) {
+ ChildNotifyEventHandler = (EFI_EVENT_NOTIFY) (UINTN) Context;
+ ChildNotifyEventHandler (Event, NULL);
+ }
+
+ if (gEfiFvbInitialized) {
+ EfiRuntimeLibFvbVirtualNotifyEvent (Event, Context);
+ }
+ //
+ // Update global for Runtime Services Table and IO
+ //
+ EfiConvertInternalPointer ((VOID **) &gCpuIo);
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+ if (gStatusCode != NULL) {
+ EfiConvertInternalPointer ((VOID **) &gStatusCode->ReportStatusCode);
+ EfiConvertInternalPointer ((VOID **) &gStatusCode);
+ }
+#endif
+ EfiConvertInternalPointer ((VOID **) &mRT);
+
+ //
+ // Clear out BootService globals
+ //
+ gBS = NULL;
+ gST = NULL;
+ mEfiGoneVirtual = TRUE;
+}
+
+EFI_STATUS
+EfiInitializeRuntimeDriverLib (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable,
+ IN EFI_EVENT_NOTIFY GoVirtualChildEvent
+ )
+/*++
+
+Routine Description:
+
+ Intialize runtime Driver Lib if it has not yet been initialized.
+
+Arguments:
+
+ ImageHandle - The firmware allocated handle for the EFI image.
+
+ SystemTable - A pointer to the EFI System Table.
+
+ GoVirtualChildEvent - Caller can register a virtual notification event.
+
+Returns:
+
+ EFI_STATUS always returns EFI_SUCCESS except EFI_ALREADY_STARTED if already started.
+
+--*/
+{
+ EFI_STATUS Status;
+
+ if (mRuntimeLibInitialized) {
+ return EFI_ALREADY_STARTED;
+ }
+
+ mRuntimeLibInitialized = TRUE;
+
+ gST = SystemTable;
+ ASSERT (gST != NULL);
+
+ gBS = SystemTable->BootServices;
+ ASSERT (gBS != NULL);
+ mRT = SystemTable->RuntimeServices;
+ ASSERT (mRT != NULL);
+
+ Status = EfiLibGetSystemConfigurationTable (&gEfiDxeServicesTableGuid, (VOID **) &gDS);
+ ASSERT_EFI_ERROR (Status);
+
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+ Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID **)&gStatusCode);
+ if (EFI_ERROR (Status)) {
+ gStatusCode = NULL;
+ }
+#endif
+
+ Status = gBS->LocateProtocol (&gEfiCpuIoProtocolGuid, NULL, &gCpuIo);
+ if (EFI_ERROR (Status)) {
+ gCpuIo = NULL;
+ }
+
+ //
+ // Register our ExitBootServices () notify function
+ //
+ Status = gBS->CreateEvent (
+ EFI_EVENT_SIGNAL_EXIT_BOOT_SERVICES,
+ EFI_TPL_NOTIFY,
+ RuntimeDriverExitBootServices,
+ NULL,
+ &mRuntimeNotifyEvent
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // Register SetVirtualAddressMap () notify function
+ //
+ Status = gBS->CreateEvent (
+ EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE,
+ EFI_TPL_NOTIFY,
+ EfiRuntimeLibVirtualNotifyEvent,
+ (VOID *) (UINTN) GoVirtualChildEvent,
+ &mEfiVirtualNotifyEvent
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EfiShutdownRuntimeDriverLib (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ This routine will free some resources which have been allocated in
+ EfiInitializeRuntimeDriverLib(). If a runtime driver exits with an error,
+ it must call this routine to free the allocated resource before the exiting.
+
+Arguments:
+
+ None
+
+Returns:
+
+ EFI_SUCCESS - Shotdown the Runtime Driver Lib successfully
+ EFI_UNSUPPORTED - Runtime Driver lib was not initialized at all
+
+--*/
+{
+ EFI_STATUS Status;
+
+ if (!mRuntimeLibInitialized) {
+ //
+ // You must call EfiInitializeRuntimeDriverLib() first
+ //
+ return EFI_UNSUPPORTED;
+ }
+
+ mRuntimeLibInitialized = FALSE;
+
+ //
+ // Close our ExitBootServices () notify function
+ //
+ if (mRuntimeNotifyEvent != NULL) {
+ Status = gBS->CloseEvent (mRuntimeNotifyEvent);
+ ASSERT_EFI_ERROR (Status);
+ }
+
+ //
+ // Close SetVirtualAddressMap () notify function
+ //
+ if (mEfiVirtualNotifyEvent != NULL) {
+ Status = gBS->CloseEvent (mEfiVirtualNotifyEvent);
+ ASSERT_EFI_ERROR (Status);
+ }
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EfiInitializeSmmDriverLib (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+/*++
+
+Routine Description:
+
+ Intialize runtime Driver Lib if it has not yet been initialized.
+
+Arguments:
+
+ ImageHandle - The firmware allocated handle for the EFI image.
+
+ SystemTable - A pointer to the EFI System Table.
+
+Returns:
+
+ EFI_STATUS always returns EFI_SUCCESS except EFI_ALREADY_STARTED if already started.
+
+--*/
+{
+ EFI_STATUS Status;
+
+ if (mRuntimeLibInitialized) {
+ return EFI_ALREADY_STARTED;
+ }
+
+ mRuntimeLibInitialized = TRUE;
+
+ gST = SystemTable;
+ ASSERT (gST != NULL);
+
+ gBS = SystemTable->BootServices;
+ ASSERT (gBS != NULL);
+ mRT = SystemTable->RuntimeServices;
+ ASSERT (mRT != NULL);
+
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+ Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID **)&gStatusCode);
+ if (EFI_ERROR (Status)) {
+ gStatusCode = NULL;
+ }
+#endif
+
+ Status = gBS->LocateProtocol (&gEfiCpuIoProtocolGuid, NULL, &gCpuIo);
+ if (EFI_ERROR (Status)) {
+ gCpuIo = NULL;
+ }
+
+ return EFI_SUCCESS;
+}
+
+BOOLEAN
+EfiAtRuntime (
+ VOID
+ )
+/*++
+
+Routine Description:
+ Return TRUE if ExitBootServices () has been called
+
+Arguments:
+ NONE
+
+Returns:
+ TRUE - If ExitBootServices () has been called
+
+--*/
+{
+ return mEfiAtRuntime;
+}
+
+BOOLEAN
+EfiGoneVirtual (
+ VOID
+ )
+/*++
+
+Routine Description:
+ Return TRUE if SetVirtualAddressMap () has been called
+
+Arguments:
+ NONE
+
+Returns:
+ TRUE - If SetVirtualAddressMap () has been called
+
+--*/
+{
+ return mEfiGoneVirtual;
+}
+//
+// The following functions hide the mRT local global from the call to
+// runtime service in the EFI system table.
+//
+EFI_STATUS
+EfiGetTime (
+ OUT EFI_TIME *Time,
+ OUT EFI_TIME_CAPABILITIES *Capabilities
+ )
+/*++
+
+Routine Description:
+
+ Returns the current time and date information, and the time-keeping
+ capabilities of the hardware platform.
+
+Arguments:
+
+ Time - A pointer to storage to receive a snapshot of the current time.
+ Capabilities - An optional pointer to a buffer to receive the real time clock device¡¯s
+ capabilities.
+
+Returns:
+
+ Status code
+
+--*/
+{
+ return mRT->GetTime (Time, Capabilities);
+}
+
+EFI_STATUS
+EfiSetTime (
+ IN EFI_TIME *Time
+ )
+/*++
+
+Routine Description:
+
+ Sets the current local time and date information.
+
+Arguments:
+
+ Time - A pointer to the current time.
+
+Returns:
+
+ Status code
+
+--*/
+{
+ return mRT->SetTime (Time);
+}
+
+EFI_STATUS
+EfiGetWakeupTime (
+ OUT BOOLEAN *Enabled,
+ OUT BOOLEAN *Pending,
+ OUT EFI_TIME *Time
+ )
+/*++
+
+Routine Description:
+
+ Returns the current wakeup alarm clock setting.
+
+Arguments:
+
+ Enabled - Indicates if the alarm is currently enabled or disabled.
+ Pending - Indicates if the alarm signal is pending and requires acknowledgement.
+ Time - The current alarm setting.
+
+Returns:
+
+ Status code
+
+--*/
+{
+ return mRT->GetWakeupTime (Enabled, Pending, Time);
+}
+
+EFI_STATUS
+EfiSetWakeupTime (
+ IN BOOLEAN Enable,
+ IN EFI_TIME *Time
+ )
+/*++
+
+Routine Description:
+
+ Sets the system wakeup alarm clock time.
+
+Arguments:
+
+ Enable - Enable or disable the wakeup alarm.
+ Time - If Enable is TRUE, the time to set the wakeup alarm for.
+ If Enable is FALSE, then this parameter is optional, and may be NULL.
+
+Returns:
+
+ Status code
+
+--*/
+{
+ return mRT->SetWakeupTime (Enable, Time);
+}
+
+EFI_STATUS
+EfiGetVariable (
+ IN CHAR16 *VariableName,
+ IN EFI_GUID * VendorGuid,
+ OUT UINT32 *Attributes OPTIONAL,
+ IN OUT UINTN *DataSize,
+ OUT VOID *Data
+ )
+/*++
+
+Routine Description:
+
+ Returns the value of a variable.
+
+Arguments:
+
+ VariableName - A Null-terminated Unicode string that is the name of the
+ vendor¡¯s variable.
+ VendorGuid - A unique identifier for the vendor.
+ Attributes - If not NULL, a pointer to the memory location to return the
+ attributes bitmask for the variable.
+ DataSize - On input, the size in bytes of the return Data buffer.
+ On output the size of data returned in Data.
+ Data - The buffer to return the contents of the variable.
+
+Returns:
+
+ Status code
+
+--*/
+{
+ return mRT->GetVariable (VariableName, VendorGuid, Attributes, DataSize, Data);
+}
+
+EFI_STATUS
+EfiGetNextVariableName (
+ IN OUT UINTN *VariableNameSize,
+ IN OUT CHAR16 *VariableName,
+ IN OUT EFI_GUID *VendorGuid
+ )
+/*++
+
+Routine Description:
+
+ Enumerates the current variable names.
+
+Arguments:
+
+ VariableNameSize - The size of the VariableName buffer.
+ VariableName - On input, supplies the last VariableName that was returned
+ by GetNextVariableName().
+ On output, returns the Nullterminated Unicode string of the
+ current variable.
+ VendorGuid - On input, supplies the last VendorGuid that was returned by
+ GetNextVariableName().
+ On output, returns the VendorGuid of the current variable.
+
+Returns:
+
+ Status code
+
+--*/
+{
+ return mRT->GetNextVariableName (VariableNameSize, VariableName, VendorGuid);
+}
+
+EFI_STATUS
+EfiSetVariable (
+ IN CHAR16 *VariableName,
+ IN EFI_GUID *VendorGuid,
+ IN UINT32 Attributes,
+ IN UINTN DataSize,
+ IN VOID *Data
+ )
+/*++
+
+Routine Description:
+
+ Sets the value of a variable.
+
+Arguments:
+
+ VariableName - A Null-terminated Unicode string that is the name of the
+ vendor¡¯s variable.
+ VendorGuid - A unique identifier for the vendor.
+ Attributes - Attributes bitmask to set for the variable.
+ DataSize - The size in bytes of the Data buffer.
+ Data - The contents for the variable.
+
+Returns:
+
+ Status code
+
+--*/
+{
+ return mRT->SetVariable (VariableName, VendorGuid, Attributes, DataSize, Data);
+}
+
+
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+
+EFI_STATUS
+EfiQueryVariableInfo (
+ IN UINT32 Attributes,
+ OUT UINT64 *MaximumVariableStorageSize,
+ OUT UINT64 *RemainingVariableStorageSize,
+ OUT UINT64 *MaximumVariableSize
+ )
+
+/*++
+
+Routine Description:
+
+ This code returns information about the EFI variables.
+
+Arguments:
+
+ Attributes Attributes bitmask to specify the type of variables
+ on which to return information.
+ MaximumVariableStorageSize Pointer to the maximum size of the storage space available
+ for the EFI variables associated with the attributes specified.
+ RemainingVariableStorageSize Pointer to the remaining size of the storage space available
+ for the EFI variables associated with the attributes specified.
+ MaximumVariableSize Pointer to the maximum size of the individual EFI variables
+ associated with the attributes specified.
+
+Returns:
+
+ Status code
+
+--*/
+{
+ return mRT->QueryVariableInfo (Attributes, MaximumVariableStorageSize, RemainingVariableStorageSize, MaximumVariableSize);
+}
+
+#endif
+
+EFI_STATUS
+EfiGetNextHighMonotonicCount (
+ OUT UINT32 *HighCount
+ )
+/*++
+
+Routine Description:
+
+ Returns the next high 32 bits of the platform¡¯s monotonic counter.
+
+Arguments:
+
+ HighCount - Pointer to returned value.
+
+Returns:
+
+ Status code
+
+--*/
+{
+ return mRT->GetNextHighMonotonicCount (HighCount);
+}
+
+VOID
+EfiResetSystem (
+ IN EFI_RESET_TYPE ResetType,
+ IN EFI_STATUS ResetStatus,
+ IN UINTN DataSize,
+ IN CHAR16 *ResetData
+ )
+/*++
+
+Routine Description:
+
+ Resets the entire platform.
+
+Arguments:
+
+ ResetType - The type of reset to perform.
+ ResetStatus - The status code for the reset.
+ DataSize - The size, in bytes, of ResetData.
+ ResetData - A data buffer that includes a Null-terminated Unicode string, optionally
+ followed by additional binary data.
+
+Returns:
+
+ None
+
+--*/
+{
+ mRT->ResetSystem (ResetType, ResetStatus, DataSize, ResetData);
+}
+
+EFI_STATUS
+EfiReportStatusCode (
+ IN EFI_STATUS_CODE_TYPE CodeType,
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN UINT32 Instance,
+ IN EFI_GUID * CallerId,
+ IN EFI_STATUS_CODE_DATA * Data OPTIONAL
+ )
+/*++
+
+Routine Description:
+
+ Status Code reporter
+
+Arguments:
+
+ CodeType - Type of Status Code.
+
+ Value - Value to output for Status Code.
+
+ Instance - Instance Number of this status code.
+
+ CallerId - ID of the caller of this status code.
+
+ Data - Optional data associated with this status code.
+
+Returns:
+
+ Status code
+
+--*/
+{
+ EFI_STATUS Status;
+
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+ if (gStatusCode == NULL) {
+ if (EfiAtRuntime ()) {
+ return EFI_UNSUPPORTED;
+ }
+ Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID **)&gStatusCode);
+ if (EFI_ERROR (Status) || gStatusCode == NULL) {
+ return EFI_UNSUPPORTED;
+ }
+ }
+ Status = gStatusCode->ReportStatusCode (CodeType, Value, Instance, CallerId, Data);
+#else
+ Status = mRT->ReportStatusCode (CodeType, Value, Instance, CallerId, Data);
+#endif
+ return Status;
+}
+//
+// Cache Flush Routine.
+//
+EFI_STATUS
+EfiCpuFlushCache (
+ IN EFI_PHYSICAL_ADDRESS Start,
+ IN UINT64 Length
+ )
+/*++
+
+Routine Description:
+
+ Flush cache with specified range.
+
+Arguments:
+
+ Start - Start address
+ Length - Length in bytes
+
+Returns:
+
+ Status code
+
+ EFI_SUCCESS - success
+
+--*/
+{
+ __asm {
+ wbinvd
+ }
+ return EFI_SUCCESS;
+}
diff --git a/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/x64/Fvb.c b/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/x64/Fvb.c
new file mode 100644
index 0000000..7a87a64
--- /dev/null
+++ b/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/x64/Fvb.c
@@ -0,0 +1,620 @@
+/*++
+
+Copyright (c) 2005 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Fvb.c
+
+Abstract:
+
+ Firmware Volume Block Protocol Runtime Abstraction
+
+ mFvbEntry is an array of Handle Fvb pairs. The Fvb Lib Instance matches the
+ index in the mFvbEntry array. This should be the same sequence as the FVB's
+ were described in the HOB. We have to remember the handle so we can tell if
+ the protocol has been reinstalled and it needs updateing.
+
+ If you are using any of these lib functions.you must first call FvbInitialize ().
+
+Key:
+ FVB - Firmware Volume Block
+
+--*/
+
+#include "Tiano.h"
+#include "EfiRuntimeLib.h"
+#include EFI_PROTOCOL_DEFINITION (FirmwareVolumeBlock)
+#include EFI_PROTOCOL_DEFINITION (FvbExtension)
+
+//
+// Lib will ASSERT if more FVB devices than this are added to the system.
+//
+UINTN mFvbCount;
+VOID *mFvbRegistration;
+VOID *mFvbExtRegistration;
+static EFI_EVENT mEfiFvbVirtualNotifyEvent;
+BOOLEAN gEfiFvbInitialized = FALSE;
+EFI_EVENT mFvbEvent;
+
+BOOLEAN
+IsMemoryRuntime (
+ IN VOID *Address
+ )
+/*++
+
+Routine Description:
+ Check whether an address is runtime memory or not.
+
+Arguments:
+
+ Address - The Address being checked.
+
+Returns:
+ TRUE - The address is runtime memory.
+ FALSE - The address is not runtime memory.
+
+--*/
+{
+ EFI_STATUS Status;
+ UINT8 TmpMemoryMap[1];
+ UINTN MapKey;
+ UINTN DescriptorSize;
+ UINT32 DescriptorVersion;
+ UINTN MemoryMapSize;
+ EFI_MEMORY_DESCRIPTOR *MemoryMap;
+ EFI_MEMORY_DESCRIPTOR *MemoryMapPtr;
+ BOOLEAN IsRuntime;
+ UINTN Index;
+
+ IsRuntime = FALSE;
+
+ //
+ // Get System MemoryMapSize
+ //
+ MemoryMapSize = 1;
+ Status = gBS->GetMemoryMap (
+ &MemoryMapSize,
+ (EFI_MEMORY_DESCRIPTOR *)TmpMemoryMap,
+ &MapKey,
+ &DescriptorSize,
+ &DescriptorVersion
+ );
+ ASSERT (Status == EFI_BUFFER_TOO_SMALL);
+ //
+ // Enlarge space here, because we will allocate pool now.
+ //
+ MemoryMapSize += EFI_PAGE_SIZE;
+ Status = gBS->AllocatePool (
+ EfiBootServicesData,
+ MemoryMapSize,
+ (VOID**)&MemoryMap
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // Get System MemoryMap
+ //
+ Status = gBS->GetMemoryMap (
+ &MemoryMapSize,
+ MemoryMap,
+ &MapKey,
+ &DescriptorSize,
+ &DescriptorVersion
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ MemoryMapPtr = MemoryMap;
+ //
+ // Search the request Address
+ //
+ for (Index = 0; Index < (MemoryMapSize / DescriptorSize); Index++) {
+ if (((EFI_PHYSICAL_ADDRESS)(UINTN)Address >= MemoryMap->PhysicalStart) &&
+ ((EFI_PHYSICAL_ADDRESS)(UINTN)Address < MemoryMap->PhysicalStart
+ + LShiftU64 (MemoryMap->NumberOfPages, EFI_PAGE_SHIFT))) {
+ //
+ // Found it
+ //
+ if (MemoryMap->Attribute & EFI_MEMORY_RUNTIME) {
+ IsRuntime = TRUE;
+ }
+ break;
+ }
+ //
+ // Get next item
+ //
+ MemoryMap = (EFI_MEMORY_DESCRIPTOR *)((UINTN)MemoryMap + DescriptorSize);
+ }
+
+ //
+ // Done
+ //
+ gBS->FreePool (MemoryMapPtr);
+
+ return IsRuntime;
+}
+
+VOID
+EFIAPI
+FvbNotificationFunction (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+/*++
+
+Routine Description:
+ Update mFvbEntry. Add new entry, or update existing entry if Fvb protocol is
+ reinstalled.
+
+Arguments:
+
+ Event - The Event that is being processed
+
+ Context - Event Context
+
+Returns:
+ None
+
+--*/
+{
+ EFI_STATUS Status;
+ UINTN BufferSize;
+ EFI_HANDLE Handle;
+ UINTN Index;
+ UINTN UpdateIndex;
+ EFI_FIRMWARE_VOLUME_BLOCK_PROTOCOL *Fvb;
+ EFI_FVB_EXTENSION_PROTOCOL *FvbExtension;
+
+ while (TRUE) {
+ BufferSize = sizeof (Handle);
+ Status = gBS->LocateHandle (
+ ByRegisterNotify,
+ &gEfiFirmwareVolumeBlockProtocolGuid,
+ mFvbRegistration,
+ &BufferSize,
+ &Handle
+ );
+ if (EFI_ERROR (Status)) {
+ //
+ // Exit Path of While Loop....
+ //
+ break;
+ }
+
+ UpdateIndex = MAX_FVB_COUNT;
+ for (Index = 0; Index < mFvbCount; Index++) {
+ if (mFvbEntry[Index].Handle == Handle) {
+ //
+ // If the handle is already in the table just update the protocol
+ //
+ UpdateIndex = Index;
+ break;
+ }
+ }
+
+ if (UpdateIndex == MAX_FVB_COUNT) {
+ //
+ // Use the next free slot for a new entry
+ //
+ UpdateIndex = mFvbCount;
+ }
+ //
+ // The array does not have enough entries
+ //
+ ASSERT (UpdateIndex < MAX_FVB_COUNT);
+
+ //
+ // Get the interface pointer and if it's ours, skip it.
+ // We check Runtime here, because it has no reason to register
+ // a boot time FVB protocol.
+ //
+ Status = gBS->HandleProtocol (Handle, &gEfiFirmwareVolumeBlockProtocolGuid, &Fvb);
+ ASSERT_EFI_ERROR (Status);
+ if (IsMemoryRuntime (Fvb)) {
+ //
+ // Increase mFvbCount if we need to add a new entry
+ //
+ if (UpdateIndex == mFvbCount) {
+ mFvbCount++;
+ }
+ mFvbEntry[UpdateIndex].Handle = Handle;
+ mFvbEntry[UpdateIndex].Fvb = Fvb;
+ mFvbEntry[UpdateIndex].FvbExtension = NULL;
+
+ Status = gBS->HandleProtocol (Handle, &gEfiFvbExtensionProtocolGuid, &FvbExtension);
+ if ((Status == EFI_SUCCESS) && IsMemoryRuntime (FvbExtension)) {
+ mFvbEntry[UpdateIndex].FvbExtension = FvbExtension;
+ }
+ }
+ }
+}
+
+EFI_STATUS
+EfiFvbInitialize (
+ VOID
+ )
+/*++
+
+Routine Description:
+ Initialize globals and register Fvb Protocol notification function.
+
+Arguments:
+ None
+
+Returns:
+ EFI_SUCCESS - Fvb is successfully initialized
+ others - Fail to initialize
+
+--*/
+{
+ UINTN Status;
+ mFvbCount = 0;
+
+ Status = gBS->AllocatePool (
+ EfiRuntimeServicesData,
+ (UINTN) sizeof (FVB_ENTRY) * MAX_FVB_COUNT,
+ (VOID *) &mFvbEntry
+ );
+
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ EfiZeroMem (mFvbEntry, sizeof (FVB_ENTRY) * MAX_FVB_COUNT);
+
+ mFvbEvent = RtEfiLibCreateProtocolNotifyEvent (
+ &gEfiFirmwareVolumeBlockProtocolGuid,
+ EFI_TPL_CALLBACK,
+ FvbNotificationFunction,
+ NULL,
+ &mFvbRegistration
+ );
+
+ //
+ // Register SetVirtualAddressMap () notify function
+ //
+ // Status = gBS->CreateEvent (
+ // EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE,
+ // EFI_TPL_NOTIFY,
+ // EfiRuntimeLibFvbVirtualNotifyEvent,
+ // NULL,
+ // &mEfiFvbVirtualNotifyEvent
+ // );
+ // ASSERT_EFI_ERROR (Status);
+ //
+ gEfiFvbInitialized = TRUE;
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EfiFvbShutdown (
+ VOID
+ )
+/*++
+
+Routine Description:
+ Release resources allocated in EfiFvbInitialize.
+
+Arguments:
+ None
+
+Returns:
+ EFI_SUCCESS
+
+--*/
+{
+ gBS->FreePool ((VOID *) mFvbEntry);
+
+ gBS->CloseEvent (mFvbEvent);
+
+ gEfiFvbInitialized = FALSE;
+
+ return EFI_SUCCESS;
+}
+
+//
+// The following functions wrap Fvb protocol in the Runtime Lib functions.
+// The Instance translates into Fvb instance. The Fvb order defined by HOBs and
+// thus the sequence of FVB protocol addition define Instance.
+//
+// EfiFvbInitialize () must be called before any of the following functions
+// must be called.
+//
+
+EFI_STATUS
+EfiFvbReadBlock (
+ IN UINTN Instance,
+ IN EFI_LBA Lba,
+ IN UINTN Offset,
+ IN OUT UINTN *NumBytes,
+ IN UINT8 *Buffer
+ )
+/*++
+
+Routine Description:
+ Reads specified number of bytes into a buffer from the specified block
+
+Arguments:
+ Instance - The FV instance to be read from
+ Lba - The logical block address to be read from
+ Offset - Offset into the block at which to begin reading
+ NumBytes - Pointer that on input contains the total size of
+ the buffer. On output, it contains the total number
+ of bytes read
+ Buffer - Pointer to a caller allocated buffer that will be
+ used to hold the data read
+
+Returns:
+
+ Status code
+
+ EFI_INVALID_PARAMETER - invalid parameter
+
+--*/
+{
+ if (Instance >= mFvbCount) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ return mFvbEntry[Instance].Fvb->Read (mFvbEntry[Instance].Fvb, Lba, Offset, NumBytes, Buffer);
+}
+
+EFI_STATUS
+EfiFvbWriteBlock (
+ IN UINTN Instance,
+ IN EFI_LBA Lba,
+ IN UINTN Offset,
+ IN OUT UINTN *NumBytes,
+ IN UINT8 *Buffer
+ )
+/*++
+
+Routine Description:
+ Writes specified number of bytes from the input buffer to the block
+
+Arguments:
+ Instance - The FV instance to be written to
+ Lba - The starting logical block index to write to
+ Offset - Offset into the block at which to begin writing
+ NumBytes - Pointer that on input contains the total size of
+ the buffer. On output, it contains the total number
+ of bytes actually written
+ Buffer - Pointer to a caller allocated buffer that contains
+ the source for the write
+
+Returns:
+
+ Status code
+
+ EFI_INVALID_PARAMETER - invalid parameter
+
+--*/
+{
+ if (Instance >= mFvbCount) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ return mFvbEntry[Instance].Fvb->Write (mFvbEntry[Instance].Fvb, Lba, Offset, NumBytes, Buffer);
+}
+
+EFI_STATUS
+EfiFvbEraseBlock (
+ IN UINTN Instance,
+ IN EFI_LBA Lba
+ )
+/*++
+
+Routine Description:
+ Erases and initializes a firmware volume block
+
+Arguments:
+ Instance - The FV instance to be erased
+ Lba - The logical block index to be erased
+
+Returns:
+
+ Status code
+
+ EFI_INVALID_PARAMETER - invalid parameter
+
+--*/
+{
+ if (Instance >= mFvbCount) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ return mFvbEntry[Instance].Fvb->EraseBlocks (mFvbEntry[Instance].Fvb, Lba, -1);
+}
+
+EFI_STATUS
+EfiFvbGetVolumeAttributes (
+ IN UINTN Instance,
+ OUT EFI_FVB_ATTRIBUTES *Attributes
+ )
+/*++
+
+Routine Description:
+ Retrieves attributes, insures positive polarity of attribute bits, returns
+ resulting attributes in output parameter
+
+Arguments:
+ Instance - The FV instance whose attributes is going to be
+ returned
+ Attributes - Output buffer which contains attributes
+
+Returns:
+ Status code
+
+ EFI_INVALID_PARAMETER - invalid parameter
+
+--*/
+{
+ if (Instance >= mFvbCount) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ return mFvbEntry[Instance].Fvb->GetVolumeAttributes (mFvbEntry[Instance].Fvb, Attributes);
+}
+
+EFI_STATUS
+EfiFvbSetVolumeAttributes (
+ IN UINTN Instance,
+ IN EFI_FVB_ATTRIBUTES Attributes
+ )
+/*++
+
+Routine Description:
+ Modifies the current settings of the firmware volume according to the
+ input parameter, and returns the new setting of the volume
+
+Arguments:
+ Instance - The FV instance whose attributes is going to be
+ modified
+ Attributes - On input, it is a pointer to EFI_FVB_ATTRIBUTES
+ containing the desired firmware volume settings.
+ On successful return, it contains the new settings
+ of the firmware volume
+
+Returns:
+ Status code
+
+ EFI_INVALID_PARAMETER - invalid parameter
+
+--*/
+{
+ if (Instance >= mFvbCount) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ return mFvbEntry[Instance].Fvb->SetVolumeAttributes (mFvbEntry[Instance].Fvb, &Attributes);
+}
+
+EFI_STATUS
+EfiFvbGetPhysicalAddress (
+ IN UINTN Instance,
+ OUT EFI_PHYSICAL_ADDRESS *BaseAddress
+ )
+/*++
+
+Routine Description:
+ Retrieves the physical address of a memory mapped FV
+
+Arguments:
+ Instance - The FV instance whose base address is going to be
+ returned
+ BaseAddress - Pointer to a caller allocated EFI_PHYSICAL_ADDRESS
+ that on successful return, contains the base address
+ of the firmware volume.
+
+Returns:
+
+ Status code
+
+ EFI_INVALID_PARAMETER - invalid parameter
+
+--*/
+{
+ if (Instance >= mFvbCount) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ return mFvbEntry[Instance].Fvb->GetPhysicalAddress (mFvbEntry[Instance].Fvb, BaseAddress);
+}
+
+EFI_STATUS
+EfiFvbGetBlockSize (
+ IN UINTN Instance,
+ IN EFI_LBA Lba,
+ OUT UINTN *BlockSize,
+ OUT UINTN *NumOfBlocks
+ )
+/*++
+
+Routine Description:
+ Retrieve the size of a logical block
+
+Arguments:
+ Instance - The FV instance whose block size is going to be
+ returned
+ Lba - Indicates which block to return the size for.
+ BlockSize - A pointer to a caller allocated UINTN in which
+ the size of the block is returned
+ NumOfBlocks - a pointer to a caller allocated UINTN in which the
+ number of consecutive blocks starting with Lba is
+ returned. All blocks in this range have a size of
+ BlockSize
+
+Returns:
+ EFI_SUCCESS - The firmware volume was read successfully and
+ contents are in Buffer
+
+ EFI_INVALID_PARAMETER - invalid parameter
+
+--*/
+{
+ if (Instance >= mFvbCount) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ return mFvbEntry[Instance].Fvb->GetBlockSize (mFvbEntry[Instance].Fvb, Lba, BlockSize, NumOfBlocks);
+}
+
+EFI_STATUS
+EfiFvbEraseCustomBlockRange (
+ IN UINTN Instance,
+ IN EFI_LBA StartLba,
+ IN UINTN OffsetStartLba,
+ IN EFI_LBA LastLba,
+ IN UINTN OffsetLastLba
+ )
+/*++
+
+Routine Description:
+ Erases and initializes a specified range of a firmware volume
+
+Arguments:
+ Instance - The FV instance to be erased
+ StartLba - The starting logical block index to be erased
+ OffsetStartLba - Offset into the starting block at which to
+ begin erasing
+ LastLba - The last logical block index to be erased
+ OffsetLastLba - Offset into the last block at which to end erasing
+
+Returns:
+
+ Status code
+
+ EFI_INVALID_PARAMETER - invalid parameter
+
+ EFI_UNSUPPORTED - not support
+
+--*/
+{
+ if (Instance >= mFvbCount) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ if (!(mFvbEntry[Instance].FvbExtension)) {
+ return EFI_UNSUPPORTED;
+ }
+
+ if (!(mFvbEntry[Instance].FvbExtension->EraseFvbCustomBlock)) {
+ return EFI_UNSUPPORTED;
+ }
+
+ return mFvbEntry[Instance].FvbExtension->EraseFvbCustomBlock (
+ mFvbEntry[Instance].FvbExtension,
+ StartLba,
+ OffsetStartLba,
+ LastLba,
+ OffsetLastLba
+ );
+}
diff --git a/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/x64/IoLib.c b/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/x64/IoLib.c
new file mode 100644
index 0000000..e91a9eb
--- /dev/null
+++ b/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/x64/IoLib.c
@@ -0,0 +1,130 @@
+/*++
+
+Copyright (c) 2005, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ IoLib.c
+
+Abstract:
+
+ Light weight lib to support Tiano drivers.
+
+--*/
+
+#include "Tiano.h"
+#include "EfiRuntimeLib.h"
+#include EFI_PROTOCOL_DEFINITION (CpuIo)
+
+extern EFI_CPU_IO_PROTOCOL *gCpuIo;
+
+EFI_STATUS
+EfiIoRead (
+ IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
+ IN UINT64 Address,
+ IN UINTN Count,
+ IN OUT VOID *Buffer
+ )
+/*++
+
+Routine Description:
+ Perform an IO read into Buffer.
+
+Arguments:
+ Width - Width of read transaction, and repeat operation to use
+ Address - IO address to read
+ Count - Number of times to read the IO address.
+ Buffer - Buffer to read data into. size is Width * Count
+
+Returns:
+ BugBug: Check with Mike to see if I can find this #define some ware else
+
+--*/
+{
+ return gCpuIo->Io.Read (gCpuIo, Width, Address, Count, Buffer);
+}
+
+EFI_STATUS
+EfiIoWrite (
+ IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
+ IN UINT64 Address,
+ IN UINTN Count,
+ IN OUT VOID *Buffer
+ )
+/*++
+
+Routine Description:
+ Perform an IO write into Buffer.
+
+Arguments:
+ Width - Width of write transaction, and repeat operation to use
+ Address - IO address to write
+ Count - Number of times to write the IO address.
+ Buffer - Buffer to write data from. size is Width * Count
+
+Returns:
+ BugBug: Check with Mike to see if I can find this #define some ware else
+
+--*/
+{
+ return gCpuIo->Io.Write (gCpuIo, Width, Address, Count, Buffer);
+}
+
+EFI_STATUS
+EfiMemRead (
+ IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
+ IN UINT64 Address,
+ IN UINTN Count,
+ IN OUT VOID *Buffer
+ )
+/*++
+
+Routine Description:
+ Perform a Memory mapped IO read into Buffer.
+
+Arguments:
+ Width - Width of each read transaction.
+ Address - Memory mapped IO address to read
+ Count - Number of Width quanta to read
+ Buffer - Buffer to read data into. size is Width * Count
+
+Returns:
+ BugBug: Check with Mike to see if I can find this #define some ware else
+
+--*/
+{
+ return gCpuIo->Mem.Read (gCpuIo, Width, Address, Count, Buffer);
+}
+
+EFI_STATUS
+EfiMemWrite (
+ IN EFI_CPU_IO_PROTOCOL_WIDTH Width,
+ IN UINT64 Address,
+ IN UINTN Count,
+ IN OUT VOID *Buffer
+ )
+/*++
+
+Routine Description:
+ Perform a memory mapped IO write into Buffer.
+
+Arguments:
+ Width - Width of write transaction, and repeat operation to use
+ Address - IO address to write
+ Count - Number of times to write the IO address.
+ Buffer - Buffer to write data from. size is Width * Count
+
+Returns:
+ BugBug: Check with Mike to see if I can find this #define some ware else
+
+--*/
+{
+ return gCpuIo->Mem.Write (gCpuIo, Width, Address, Count, Buffer);
+}
diff --git a/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/x64/Lock.c b/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/x64/Lock.c
new file mode 100644
index 0000000..92b9121
--- /dev/null
+++ b/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/x64/Lock.c
@@ -0,0 +1,177 @@
+/*++
+
+Copyright (c) 2005, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Lock.c
+
+Abstract:
+
+ Support for locking lib services.
+
+--*/
+
+#include "Tiano.h"
+#include "EfiDriverLib.h"
+
+extern
+BOOLEAN
+EfiAtRuntime (
+ VOID
+ );
+
+VOID
+EfiInitializeLock (
+ IN OUT EFI_LOCK *Lock,
+ IN EFI_TPL Priority
+ )
+/*++
+
+Routine Description:
+
+ Initialize a basic mutual exclusion lock. Each lock
+ provides mutual exclusion access at it's task priority
+ level. Since there is no-premption (at any TPL) or
+ multiprocessor support, acquiring the lock only consists
+ of raising to the locks TPL.
+
+ Note on a check build ASSERT()s are used to ensure proper
+ lock usage.
+
+Arguments:
+
+ Lock - The EFI_LOCK structure to initialize
+
+ Priority - The task priority level of the lock
+
+
+Returns:
+
+ An initialized Efi Lock structure.
+
+--*/
+{
+ Lock->Tpl = Priority;
+ Lock->OwnerTpl = 0;
+ Lock->Lock = 0;
+}
+
+EFI_STATUS
+EfiAcquireLockOrFail (
+ IN EFI_LOCK *Lock
+ )
+/*++
+
+Routine Description:
+
+ Initialize a basic mutual exclusion lock. Each lock
+ provides mutual exclusion access at it's task priority
+ level. Since there is no-premption (at any TPL) or
+ multiprocessor support, acquiring the lock only consists
+ of raising to the locks TPL.
+
+Arguments:
+
+ Lock - The EFI_LOCK structure to initialize
+
+Returns:
+
+ EFI_SUCCESS - Lock Owned.
+ EFI_ACCESS_DENIED - Reentrant Lock Acquisition, Lock not Owned.
+
+--*/
+{
+ if (Lock->Lock != 0) {
+ //
+ // Lock is already owned, so bail out
+ //
+ return EFI_ACCESS_DENIED;
+ }
+
+ if (!EfiAtRuntime ()) {
+ //
+ // The check is just debug code for core inplementation. It must
+ // always be true in a driver
+ //
+ Lock->OwnerTpl = gBS->RaiseTPL (Lock->Tpl);
+ }
+
+ Lock->Lock += 1;
+ return EFI_SUCCESS;
+}
+
+VOID
+EfiAcquireLock (
+ IN EFI_LOCK *Lock
+ )
+/*++
+
+Routine Description:
+
+ Raising to the task priority level of the mutual exclusion
+ lock, and then acquires ownership of the lock.
+
+Arguments:
+
+ Lock - The lock to acquire
+
+Returns:
+
+ Lock owned
+
+--*/
+{
+ EFI_STATUS Status;
+
+ Status = EfiAcquireLockOrFail (Lock);
+
+ //
+ // Lock was already locked.
+ //
+ ASSERT_EFI_ERROR (Status);
+}
+
+VOID
+EfiReleaseLock (
+ IN EFI_LOCK *Lock
+ )
+/*++
+
+Routine Description:
+
+ Releases ownership of the mutual exclusion lock, and
+ restores the previous task priority level.
+
+Arguments:
+
+ Lock - The lock to release
+
+Returns:
+
+ Lock unowned
+
+--*/
+{
+ EFI_TPL Tpl;
+
+ Tpl = Lock->OwnerTpl;
+
+ ASSERT (Lock->Lock == 1);
+ Lock->Lock -= 1;
+
+ if (!EfiAtRuntime ()) {
+ //
+ // The check is just debug code for core inplementation. It must
+ // always be true in a driver
+ //
+ gBS->RestoreTPL (Tpl);
+ }
+}
diff --git a/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/x64/PlatformIoLib.c b/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/x64/PlatformIoLib.c
new file mode 100644
index 0000000..2f4a326
--- /dev/null
+++ b/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/x64/PlatformIoLib.c
@@ -0,0 +1,409 @@
+/*++
+
+Copyright (c) 2005 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PlatformIoLib.c
+
+Abstract:
+
+--*/
+
+#include "Tiano.h"
+#include "EfiRuntimeLib.h"
+#include EFI_PROTOCOL_DEFINITION (CpuIo)
+
+#define PCI_CONFIG_INDEX_PORT 0xcf8
+#define PCI_CONFIG_DATA_PORT 0xcfc
+#define REFRESH_CYCLE_TOGGLE_BIT 0x10
+
+UINT32
+GetPciAddress (
+ UINT8 Segment,
+ UINT8 Bus,
+ UINT8 DevFunc,
+ UINT8 Register
+ )
+/*++
+
+Routine Description:
+ Constructs PCI Address 32 bits
+
+Arguments:
+ Segment - PCI Segment ACPI _SEG
+ Bus - PCI Bus
+ DevFunc - PCI Device(7:3) and Func(2:0)
+ Register - PCI config space register
+
+Returns:
+ PciAddress to be written to Config Port
+
+--*/
+{
+ UINT32 Data;
+
+ Data = 0;
+
+ Data = (((UINT32) Segment) << 24);
+ Data |= (((UINT32) Bus) << 16);
+ Data |= (((UINT32) DevFunc) << 8);
+ Data |= (UINT32) Register;
+
+ return Data;
+
+}
+
+UINT8
+PciRead8 (
+ UINT8 Segment,
+ UINT8 Bus,
+ UINT8 DevFunc,
+ UINT8 Register
+ )
+/*++
+
+Routine Description:
+ Perform an one byte PCI config cycle read
+
+Arguments:
+ Segment - PCI Segment ACPI _SEG
+ Bus - PCI Bus
+ DevFunc - PCI Device(7:3) and Func(2:0)
+ Register - PCI config space register
+
+Returns:
+ Data read from PCI config space
+
+--*/
+{
+ EFI_STATUS Status;
+ UINT32 PciAddress;
+ UINT32 PciAddress1;
+ UINT8 Data;
+
+ PciAddress = GetPciAddress (Segment, Bus, DevFunc, Register);
+ //
+ // Set bit 31 for PCI config access
+ //
+ PciAddress1 = PciAddress;
+ PciAddress = ((PciAddress & 0xFFFFFFFC) | (0x80000000));
+
+ Status = EfiIoWrite (EfiCpuIoWidthUint32, PCI_CONFIG_INDEX_PORT, 1, &PciAddress);
+
+ if (EFI_ERROR (Status)) {
+ return 0;
+ }
+
+ EfiIoRead (EfiCpuIoWidthUint8, (PCI_CONFIG_DATA_PORT + (PciAddress1 & 0x3)), 1, &Data);
+
+ return Data;
+}
+
+UINT16
+PciRead16 (
+ UINT8 Segment,
+ UINT8 Bus,
+ UINT8 DevFunc,
+ UINT8 Register
+ )
+/*++
+
+Routine Description:
+ Perform an two byte PCI config cycle read
+
+Arguments:
+ Segment - PCI Segment ACPI _SEG
+ Bus - PCI Bus
+ DevFunc - PCI Device(7:3) and Func(2:0)
+ Register - PCI config space register
+
+Returns:
+ Data read from PCI config space
+
+--*/
+{
+ EFI_STATUS Status;
+ UINT32 PciAddress;
+ UINT32 PciAddress1;
+ UINT16 Data;
+
+ PciAddress = GetPciAddress (Segment, Bus, DevFunc, Register);
+ //
+ // Set bit 31 for PCI config access
+ //
+ PciAddress1 = PciAddress;
+ PciAddress = ((PciAddress & 0xFFFFFFFC) | (0x80000000));
+
+ Status = EfiIoWrite (EfiCpuIoWidthUint32, PCI_CONFIG_INDEX_PORT, 1, &PciAddress);
+
+ if (EFI_ERROR (Status)) {
+ return 0;
+ }
+
+ EfiIoRead (EfiCpuIoWidthUint16, (PCI_CONFIG_DATA_PORT + (PciAddress1 & 0x3)), 1, &Data);
+
+ return Data;
+}
+
+UINT32
+PciRead32 (
+ UINT8 Segment,
+ UINT8 Bus,
+ UINT8 DevFunc,
+ UINT8 Register
+ )
+/*++
+
+Routine Description:
+ Perform an four byte PCI config cycle read
+
+Arguments:
+ Segment - PCI Segment ACPI _SEG
+ Bus - PCI Bus
+ DevFunc - PCI Device(7:3) and Func(2:0)
+ Register - PCI config space register
+
+Returns:
+ Data read from PCI config space
+
+--*/
+{
+ EFI_STATUS Status;
+ UINT32 PciAddress;
+ UINT32 PciAddress1;
+ UINT32 Data;
+
+ PciAddress = GetPciAddress (Segment, Bus, DevFunc, Register);
+ //
+ // Set bit 31 for PCI config access
+ //
+ PciAddress1 = PciAddress;
+ PciAddress = ((PciAddress & 0xFFFFFFFC) | (0x80000000));
+
+ Status = EfiIoWrite (EfiCpuIoWidthUint32, PCI_CONFIG_INDEX_PORT, 1, &PciAddress);
+
+ if (EFI_ERROR (Status)) {
+ return 0;
+ }
+
+ EfiIoRead (EfiCpuIoWidthUint32, (PCI_CONFIG_DATA_PORT + (PciAddress1 & 0x3)), 1, &Data);
+
+ return Data;
+}
+
+VOID
+PciWrite8 (
+ UINT8 Segment,
+ UINT8 Bus,
+ UINT8 DevFunc,
+ UINT8 Register,
+ UINT8 Data
+ )
+/*++
+
+Routine Description:
+ Perform an one byte PCI config cycle write
+
+Arguments:
+ Segment - PCI Segment ACPI _SEG
+ Bus - PCI Bus
+ DevFunc - PCI Device(7:3) and Func(2:0)
+ Register - PCI config space register
+ Data - Data to write
+
+Returns:
+ NONE
+
+--*/
+{
+ EFI_STATUS Status;
+ UINT32 PciAddress;
+ UINT32 PciAddress1;
+
+ PciAddress = GetPciAddress (Segment, Bus, DevFunc, Register);
+ //
+ // Set bit 31 for PCI config access
+ //
+ PciAddress1 = PciAddress;
+ PciAddress = ((PciAddress & 0xFFFFFFFC) | (0x80000000));
+
+ Status = EfiIoWrite (EfiCpuIoWidthUint32, PCI_CONFIG_INDEX_PORT, 1, &PciAddress);
+
+ if (EFI_ERROR (Status)) {
+ return ;
+ }
+
+ EfiIoWrite (EfiCpuIoWidthUint8, (PCI_CONFIG_DATA_PORT + (PciAddress1 & 0x3)), 1, &Data);
+}
+
+VOID
+PciWrite16 (
+ UINT8 Segment,
+ UINT8 Bus,
+ UINT8 DevFunc,
+ UINT8 Register,
+ UINT16 Data
+ )
+/*++
+
+Routine Description:
+ Perform an two byte PCI config cycle write
+
+Arguments:
+ Segment - PCI Segment ACPI _SEG
+ Bus - PCI Bus
+ DevFunc - PCI Device(7:3) and Func(2:0)
+ Register - PCI config space register
+ Data - Data to write
+
+Returns:
+ NONE
+
+--*/
+{
+ EFI_STATUS Status;
+ UINT32 PciAddress;
+ UINT32 PciAddress1;
+
+ PciAddress = GetPciAddress (Segment, Bus, DevFunc, Register);
+ //
+ // Set bit 31 for PCI config access
+ //
+ PciAddress1 = PciAddress;
+ PciAddress = ((PciAddress & 0xFFFFFFFC) | (0x80000000));
+
+ Status = EfiIoWrite (EfiCpuIoWidthUint32, PCI_CONFIG_INDEX_PORT, 1, &PciAddress);
+
+ if (EFI_ERROR (Status)) {
+ return ;
+ }
+
+ EfiIoWrite (EfiCpuIoWidthUint16, (PCI_CONFIG_DATA_PORT + (PciAddress1 & 0x3)), 1, &Data);
+}
+
+VOID
+PciWrite32 (
+ UINT8 Segment,
+ UINT8 Bus,
+ UINT8 DevFunc,
+ UINT8 Register,
+ UINT32 Data
+ )
+/*++
+
+Routine Description:
+ Perform an four byte PCI config cycle write
+
+Arguments:
+ Segment - PCI Segment ACPI _SEG
+ Bus - PCI Bus
+ DevFunc - PCI Device(7:3) and Func(2:0)
+ Register - PCI config space register
+ Data - Data to write
+
+Returns:
+ NONE
+
+--*/
+{
+ EFI_STATUS Status;
+ UINT32 PciAddress;
+ UINT32 PciAddress1;
+
+ PciAddress = GetPciAddress (Segment, Bus, DevFunc, Register);
+ //
+ // Set bit 31 for PCI config access
+ //
+ PciAddress1 = PciAddress;
+ PciAddress = ((PciAddress & 0xFFFFFFFC) | (0x80000000));
+
+ Status = EfiIoWrite (EfiCpuIoWidthUint32, PCI_CONFIG_INDEX_PORT, 1, &PciAddress);
+
+ if (EFI_ERROR (Status)) {
+ return ;
+ }
+
+ EfiIoWrite (EfiCpuIoWidthUint32, (PCI_CONFIG_DATA_PORT + (PciAddress1 & 0x3)), 1, &Data);
+}
+//
+// Delay Primative
+//
+VOID
+EfiStall (
+ IN UINTN Microseconds
+ )
+/*++
+
+Routine Description:
+ Delay for at least the request number of microseconds
+
+Arguments:
+ Microseconds - Number of microseconds to delay.
+
+Returns:
+ NONE
+
+--*/
+{
+ UINT8 Data;
+ UINT8 InitialState;
+ UINTN CycleIterations;
+
+ CycleIterations = 0;
+ Data = 0;
+ InitialState = 0;
+
+ if (EfiAtRuntime ()) {
+ //
+ // The time-source is 30 us granular, so calibrate the timing loop
+ // based on this baseline
+ // Error is possible 30us.
+ //
+ CycleIterations = (Microseconds - 1) / 30 + 1;
+
+ //
+ // Use the DMA Refresh timer in port 0x61. Cheap but effective.
+ // The only issue is that the granularity is 30us, and we want to
+ // guarantee "at least" one full transition to avoid races.
+ //
+ //
+ // _____________/----------\__________/--------
+ //
+ // |<--15us-->|<--15us-->|
+ //
+ // --------------------------------------------------> Time (us)
+ //
+ while (CycleIterations--) {
+ EfiIoRead (EfiCpuIoWidthUint8, 0x61, 1, &Data);
+ Data &= REFRESH_CYCLE_TOGGLE_BIT;
+ InitialState = Data;
+
+ //
+ // Capture first transition (strictly less than one period)
+ //
+ while (InitialState == Data) {
+ EfiIoRead (EfiCpuIoWidthUint8, 0x61, 1, &Data);
+ Data &= REFRESH_CYCLE_TOGGLE_BIT;
+ }
+
+ InitialState = Data;
+ //
+ // Capture next transition (guarantee at least one full pulse)
+ //
+ while (InitialState == Data) {
+ EfiIoRead (EfiCpuIoWidthUint8, 0x61, 1, &Data);
+ Data &= REFRESH_CYCLE_TOGGLE_BIT;
+ }
+ }
+ } else {
+ gBS->Stall (Microseconds);
+ }
+}
diff --git a/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/x64/RuntimeLib.c b/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/x64/RuntimeLib.c
new file mode 100644
index 0000000..e1aa024
--- /dev/null
+++ b/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/x64/RuntimeLib.c
@@ -0,0 +1,808 @@
+/*++
+
+Copyright (c) 2005 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ RuntimeLib.c
+
+Abstract:
+
+ Light weight lib to support Tiano drivers.
+
+--*/
+
+#include "Tiano.h"
+#include "EfiRuntimeLib.h"
+#include EFI_PROTOCOL_DEFINITION (CpuIo)
+#include EFI_PROTOCOL_DEFINITION (FirmwareVolumeBlock)
+#include EFI_GUID_DEFINITION (StatusCodeCallerId)
+#include EFI_ARCH_PROTOCOL_DEFINITION (StatusCode)
+
+//
+// Driver Lib Module Globals
+//
+static EFI_RUNTIME_SERVICES *mRT;
+static EFI_EVENT mRuntimeNotifyEvent = NULL;
+static EFI_EVENT mEfiVirtualNotifyEvent = NULL;
+static BOOLEAN mRuntimeLibInitialized = FALSE;
+static BOOLEAN mEfiGoneVirtual = FALSE;
+
+//
+// Runtime Global, but you should use the Lib functions
+//
+EFI_CPU_IO_PROTOCOL *gCpuIo;
+BOOLEAN mEfiAtRuntime = FALSE;
+FVB_ENTRY *mFvbEntry;
+
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+static EFI_STATUS_CODE_PROTOCOL *gStatusCode = NULL;
+#endif
+
+EFI_STATUS
+EfiConvertPointer (
+ IN UINTN DebugDisposition,
+ IN OUT VOID *Address
+ )
+/*++
+
+Routine Description:
+
+ Determines the new virtual address that is to be used on subsequent memory accesses.
+
+Arguments:
+
+ DebugDisposition - Supplies type information for the pointer being converted.
+ Address - A pointer to a pointer that is to be fixed to be the value needed
+ for the new virtual address mappings being applied.
+
+Returns:
+
+ Status code
+
+--*/
+{
+ return mRT->ConvertPointer (DebugDisposition, Address);
+}
+
+EFI_STATUS
+EfiConvertInternalPointer (
+ IN OUT VOID *Address
+ )
+/*++
+
+Routine Description:
+
+ Call EfiConvertPointer() to convert internal pointer.
+
+Arguments:
+
+ Address - A pointer to a pointer that is to be fixed to be the value needed
+ for the new virtual address mappings being applied.
+
+Returns:
+
+ Status code
+
+--*/
+{
+ return EfiConvertPointer (EFI_INTERNAL_POINTER, Address);
+}
+
+VOID
+EFIAPI
+EfiRuntimeLibFvbVirtualNotifyEvent (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+/*++
+
+Routine Description:
+
+ Convert all pointers in mFvbEntry after ExitBootServices.
+
+Arguments:
+
+ Event - The Event that is being processed
+
+ Context - Event Context
+
+Returns:
+
+ None
+
+--*/
+{
+ UINTN Index;
+ if (mFvbEntry != NULL) {
+ for (Index = 0; Index < MAX_FVB_COUNT; Index++) {
+ if (NULL != mFvbEntry[Index].Fvb) {
+ EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].Fvb->GetBlockSize);
+ EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].Fvb->GetPhysicalAddress);
+ EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].Fvb->GetVolumeAttributes);
+ EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].Fvb->SetVolumeAttributes);
+ EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].Fvb->Read);
+ EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].Fvb->Write);
+ EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].Fvb->EraseBlocks);
+ EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].Fvb);
+ }
+
+ if (NULL != mFvbEntry[Index].FvbExtension) {
+ EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].FvbExtension->EraseFvbCustomBlock);
+ EfiConvertInternalPointer ((VOID **) &mFvbEntry[Index].FvbExtension);
+ }
+ }
+
+ EfiConvertInternalPointer ((VOID **) &mFvbEntry);
+ }
+}
+
+VOID
+EFIAPI
+RuntimeDriverExitBootServices (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+/*++
+
+Routine Description:
+
+ Set AtRuntime flag as TRUE after ExitBootServices
+
+Arguments:
+
+ Event - The Event that is being processed
+
+ Context - Event Context
+
+Returns:
+
+ None
+
+--*/
+{
+ mEfiAtRuntime = TRUE;
+}
+
+extern BOOLEAN gEfiFvbInitialized;
+
+VOID
+EFIAPI
+EfiRuntimeLibVirtualNotifyEvent (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+/*++
+
+Routine Description:
+
+ Fixup internal data so that EFI can be call in virtual mode.
+ Call the passed in Child Notify event and convert any pointers in
+ lib to virtual mode.
+
+Arguments:
+
+ Event - The Event that is being processed
+
+ Context - Event Context
+
+Returns:
+
+ None
+
+--*/
+{
+ EFI_EVENT_NOTIFY ChildNotifyEventHandler;
+
+ if (Context != NULL) {
+ ChildNotifyEventHandler = (EFI_EVENT_NOTIFY) (UINTN) Context;
+ ChildNotifyEventHandler (Event, NULL);
+ }
+
+ if (gEfiFvbInitialized) {
+ EfiRuntimeLibFvbVirtualNotifyEvent (Event, Context);
+ }
+ //
+ // Update global for Runtime Services Table and IO
+ //
+ EfiConvertInternalPointer ((VOID **) &gCpuIo);
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+ if (gStatusCode != NULL) {
+ EfiConvertInternalPointer ((VOID **) &gStatusCode->ReportStatusCode);
+ EfiConvertInternalPointer ((VOID **) &gStatusCode);
+ }
+#endif
+ EfiConvertInternalPointer ((VOID **) &mRT);
+
+ //
+ // Clear out BootService globals
+ //
+ gBS = NULL;
+ gST = NULL;
+ mEfiGoneVirtual = TRUE;
+}
+
+EFI_STATUS
+EfiInitializeRuntimeDriverLib (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable,
+ IN EFI_EVENT_NOTIFY GoVirtualChildEvent
+ )
+/*++
+
+Routine Description:
+
+ Intialize runtime Driver Lib if it has not yet been initialized.
+
+Arguments:
+
+ ImageHandle - The firmware allocated handle for the EFI image.
+
+ SystemTable - A pointer to the EFI System Table.
+
+ GoVirtualChildEvent - Caller can register a virtual notification event.
+
+Returns:
+
+ EFI_STATUS always returns EFI_SUCCESS except EFI_ALREADY_STARTED if already started.
+
+--*/
+{
+ EFI_STATUS Status;
+
+ if (mRuntimeLibInitialized) {
+ return EFI_ALREADY_STARTED;
+ }
+
+ mRuntimeLibInitialized = TRUE;
+
+ gST = SystemTable;
+ ASSERT (gST != NULL);
+
+ gBS = SystemTable->BootServices;
+ ASSERT (gBS != NULL);
+ mRT = SystemTable->RuntimeServices;
+ ASSERT (mRT != NULL);
+
+ Status = EfiLibGetSystemConfigurationTable (&gEfiDxeServicesTableGuid, (VOID **) &gDS);
+ ASSERT_EFI_ERROR (Status);
+
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+ Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID **)&gStatusCode);
+ if (EFI_ERROR (Status)) {
+ gStatusCode = NULL;
+ }
+#endif
+
+ Status = gBS->LocateProtocol (&gEfiCpuIoProtocolGuid, NULL, &gCpuIo);
+ if (EFI_ERROR (Status)) {
+ gCpuIo = NULL;
+ }
+
+ //
+ // Register our ExitBootServices () notify function
+ //
+ Status = gBS->CreateEvent (
+ EFI_EVENT_SIGNAL_EXIT_BOOT_SERVICES,
+ EFI_TPL_NOTIFY,
+ RuntimeDriverExitBootServices,
+ NULL,
+ &mRuntimeNotifyEvent
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ //
+ // Register SetVirtualAddressMap () notify function
+ //
+ Status = gBS->CreateEvent (
+ EFI_EVENT_SIGNAL_VIRTUAL_ADDRESS_CHANGE,
+ EFI_TPL_NOTIFY,
+ EfiRuntimeLibVirtualNotifyEvent,
+ (VOID *) (UINTN) GoVirtualChildEvent,
+ &mEfiVirtualNotifyEvent
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EfiShutdownRuntimeDriverLib (
+ VOID
+ )
+/*++
+
+Routine Description:
+
+ This routine will free some resources which have been allocated in
+ EfiInitializeRuntimeDriverLib(). If a runtime driver exits with an error,
+ it must call this routine to free the allocated resource before the exiting.
+
+Arguments:
+
+ None
+
+Returns:
+
+ EFI_SUCCESS - Shotdown the Runtime Driver Lib successfully
+ EFI_UNSUPPORTED - Runtime Driver lib was not initialized at all
+
+--*/
+{
+ EFI_STATUS Status;
+
+ if (!mRuntimeLibInitialized) {
+ //
+ // You must call EfiInitializeRuntimeDriverLib() first
+ //
+ return EFI_UNSUPPORTED;
+ }
+
+ mRuntimeLibInitialized = FALSE;
+
+ //
+ // Close our ExitBootServices () notify function
+ //
+ if (mRuntimeNotifyEvent != NULL) {
+ Status = gBS->CloseEvent (mRuntimeNotifyEvent);
+ ASSERT_EFI_ERROR (Status);
+ }
+
+ //
+ // Close SetVirtualAddressMap () notify function
+ //
+ if (mEfiVirtualNotifyEvent != NULL) {
+ Status = gBS->CloseEvent (mEfiVirtualNotifyEvent);
+ ASSERT_EFI_ERROR (Status);
+ }
+
+ return EFI_SUCCESS;
+}
+
+EFI_STATUS
+EfiInitializeSmmDriverLib (
+ IN EFI_HANDLE ImageHandle,
+ IN EFI_SYSTEM_TABLE *SystemTable
+ )
+/*++
+
+Routine Description:
+
+ Intialize runtime Driver Lib if it has not yet been initialized.
+
+Arguments:
+
+ ImageHandle - The firmware allocated handle for the EFI image.
+
+ SystemTable - A pointer to the EFI System Table.
+
+Returns:
+
+ EFI_STATUS always returns EFI_SUCCESS except EFI_ALREADY_STARTED if already started.
+
+--*/
+{
+ EFI_STATUS Status;
+
+ if (mRuntimeLibInitialized) {
+ return EFI_ALREADY_STARTED;
+ }
+
+ mRuntimeLibInitialized = TRUE;
+
+ gST = SystemTable;
+ ASSERT (gST != NULL);
+
+ gBS = SystemTable->BootServices;
+ ASSERT (gBS != NULL);
+ mRT = SystemTable->RuntimeServices;
+ ASSERT (mRT != NULL);
+
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+ Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID **)&gStatusCode);
+ if (EFI_ERROR (Status)) {
+ gStatusCode = NULL;
+ }
+#endif
+
+ Status = gBS->LocateProtocol (&gEfiCpuIoProtocolGuid, NULL, &gCpuIo);
+ if (EFI_ERROR (Status)) {
+ gCpuIo = NULL;
+ }
+
+ return EFI_SUCCESS;
+}
+
+BOOLEAN
+EfiAtRuntime (
+ VOID
+ )
+/*++
+
+Routine Description:
+ Return TRUE if ExitBootServices () has been called
+
+Arguments:
+ NONE
+
+Returns:
+ TRUE - If ExitBootServices () has been called
+
+--*/
+{
+ return mEfiAtRuntime;
+}
+
+BOOLEAN
+EfiGoneVirtual (
+ VOID
+ )
+/*++
+
+Routine Description:
+ Return TRUE if SetVirtualAddressMap () has been called
+
+Arguments:
+ NONE
+
+Returns:
+ TRUE - If SetVirtualAddressMap () has been called
+
+--*/
+{
+ return mEfiGoneVirtual;
+}
+//
+// The following functions hide the mRT local global from the call to
+// runtime service in the EFI system table.
+//
+EFI_STATUS
+EfiGetTime (
+ OUT EFI_TIME *Time,
+ OUT EFI_TIME_CAPABILITIES *Capabilities
+ )
+/*++
+
+Routine Description:
+
+ Returns the current time and date information, and the time-keeping
+ capabilities of the hardware platform.
+
+Arguments:
+
+ Time - A pointer to storage to receive a snapshot of the current time.
+ Capabilities - An optional pointer to a buffer to receive the real time clock device¡¯s
+ capabilities.
+
+Returns:
+
+ Status code
+
+--*/
+{
+ return mRT->GetTime (Time, Capabilities);
+}
+
+EFI_STATUS
+EfiSetTime (
+ IN EFI_TIME *Time
+ )
+/*++
+
+Routine Description:
+
+ Sets the current local time and date information.
+
+Arguments:
+
+ Time - A pointer to the current time.
+
+Returns:
+
+ Status code
+
+--*/
+{
+ return mRT->SetTime (Time);
+}
+
+EFI_STATUS
+EfiGetWakeupTime (
+ OUT BOOLEAN *Enabled,
+ OUT BOOLEAN *Pending,
+ OUT EFI_TIME *Time
+ )
+/*++
+
+Routine Description:
+
+ Returns the current wakeup alarm clock setting.
+
+Arguments:
+
+ Enabled - Indicates if the alarm is currently enabled or disabled.
+ Pending - Indicates if the alarm signal is pending and requires acknowledgement.
+ Time - The current alarm setting.
+
+Returns:
+
+ Status code
+
+--*/
+{
+ return mRT->GetWakeupTime (Enabled, Pending, Time);
+}
+
+EFI_STATUS
+EfiSetWakeupTime (
+ IN BOOLEAN Enable,
+ IN EFI_TIME *Time
+ )
+/*++
+
+Routine Description:
+
+ Sets the system wakeup alarm clock time.
+
+Arguments:
+
+ Enable - Enable or disable the wakeup alarm.
+ Time - If Enable is TRUE, the time to set the wakeup alarm for.
+ If Enable is FALSE, then this parameter is optional, and may be NULL.
+
+Returns:
+
+ Status code
+
+--*/
+{
+ return mRT->SetWakeupTime (Enable, Time);
+}
+
+EFI_STATUS
+EfiGetVariable (
+ IN CHAR16 *VariableName,
+ IN EFI_GUID * VendorGuid,
+ OUT UINT32 *Attributes OPTIONAL,
+ IN OUT UINTN *DataSize,
+ OUT VOID *Data
+ )
+/*++
+
+Routine Description:
+
+ Returns the value of a variable.
+
+Arguments:
+
+ VariableName - A Null-terminated Unicode string that is the name of the
+ vendor¡¯s variable.
+ VendorGuid - A unique identifier for the vendor.
+ Attributes - If not NULL, a pointer to the memory location to return the
+ attributes bitmask for the variable.
+ DataSize - On input, the size in bytes of the return Data buffer.
+ On output the size of data returned in Data.
+ Data - The buffer to return the contents of the variable.
+
+Returns:
+
+ Status code
+
+--*/
+{
+ return mRT->GetVariable (VariableName, VendorGuid, Attributes, DataSize, Data);
+}
+
+EFI_STATUS
+EfiGetNextVariableName (
+ IN OUT UINTN *VariableNameSize,
+ IN OUT CHAR16 *VariableName,
+ IN OUT EFI_GUID *VendorGuid
+ )
+/*++
+
+Routine Description:
+
+ Enumerates the current variable names.
+
+Arguments:
+
+ VariableNameSize - The size of the VariableName buffer.
+ VariableName - On input, supplies the last VariableName that was returned
+ by GetNextVariableName().
+ On output, returns the Nullterminated Unicode string of the
+ current variable.
+ VendorGuid - On input, supplies the last VendorGuid that was returned by
+ GetNextVariableName().
+ On output, returns the VendorGuid of the current variable.
+
+Returns:
+
+ Status code
+
+--*/
+{
+ return mRT->GetNextVariableName (VariableNameSize, VariableName, VendorGuid);
+}
+
+EFI_STATUS
+EfiSetVariable (
+ IN CHAR16 *VariableName,
+ IN EFI_GUID *VendorGuid,
+ IN UINT32 Attributes,
+ IN UINTN DataSize,
+ IN VOID *Data
+ )
+/*++
+
+Routine Description:
+
+ Sets the value of a variable.
+
+Arguments:
+
+ VariableName - A Null-terminated Unicode string that is the name of the
+ vendor¡¯s variable.
+ VendorGuid - A unique identifier for the vendor.
+ Attributes - Attributes bitmask to set for the variable.
+ DataSize - The size in bytes of the Data buffer.
+ Data - The contents for the variable.
+
+Returns:
+
+ Status code
+
+--*/
+{
+ return mRT->SetVariable (VariableName, VendorGuid, Attributes, DataSize, Data);
+}
+
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+
+EFI_STATUS
+EfiQueryVariableInfo (
+ IN UINT32 Attributes,
+ OUT UINT64 *MaximumVariableStorageSize,
+ OUT UINT64 *RemainingVariableStorageSize,
+ OUT UINT64 *MaximumVariableSize
+ )
+
+/*++
+
+Routine Description:
+
+ This code returns information about the EFI variables.
+
+Arguments:
+
+ Attributes Attributes bitmask to specify the type of variables
+ on which to return information.
+ MaximumVariableStorageSize Pointer to the maximum size of the storage space available
+ for the EFI variables associated with the attributes specified.
+ RemainingVariableStorageSize Pointer to the remaining size of the storage space available
+ for the EFI variables associated with the attributes specified.
+ MaximumVariableSize Pointer to the maximum size of the individual EFI variables
+ associated with the attributes specified.
+
+Returns:
+
+ Status code
+
+--*/
+{
+ return mRT->QueryVariableInfo (Attributes, MaximumVariableStorageSize, RemainingVariableStorageSize, MaximumVariableSize);
+}
+
+#endif
+
+
+EFI_STATUS
+EfiGetNextHighMonotonicCount (
+ OUT UINT32 *HighCount
+ )
+/*++
+
+Routine Description:
+
+ Returns the next high 32 bits of the platform¡¯s monotonic counter.
+
+Arguments:
+
+ HighCount - Pointer to returned value.
+
+Returns:
+
+ Status code
+
+--*/
+{
+ return mRT->GetNextHighMonotonicCount (HighCount);
+}
+
+VOID
+EfiResetSystem (
+ IN EFI_RESET_TYPE ResetType,
+ IN EFI_STATUS ResetStatus,
+ IN UINTN DataSize,
+ IN CHAR16 *ResetData
+ )
+/*++
+
+Routine Description:
+
+ Resets the entire platform.
+
+Arguments:
+
+ ResetType - The type of reset to perform.
+ ResetStatus - The status code for the reset.
+ DataSize - The size, in bytes, of ResetData.
+ ResetData - A data buffer that includes a Null-terminated Unicode string, optionally
+ followed by additional binary data.
+
+Returns:
+
+ None
+
+--*/
+{
+ mRT->ResetSystem (ResetType, ResetStatus, DataSize, ResetData);
+}
+
+EFI_STATUS
+EfiReportStatusCode (
+ IN EFI_STATUS_CODE_TYPE CodeType,
+ IN EFI_STATUS_CODE_VALUE Value,
+ IN UINT32 Instance,
+ IN EFI_GUID * CallerId,
+ IN EFI_STATUS_CODE_DATA * Data OPTIONAL
+ )
+/*++
+
+Routine Description:
+
+ Status Code reporter
+
+Arguments:
+
+ CodeType - Type of Status Code.
+
+ Value - Value to output for Status Code.
+
+ Instance - Instance Number of this status code.
+
+ CallerId - ID of the caller of this status code.
+
+ Data - Optional data associated with this status code.
+
+Returns:
+
+ Status code
+
+--*/
+{
+ EFI_STATUS Status;
+
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+ if (gStatusCode == NULL) {
+ if (EfiAtRuntime ()) {
+ return EFI_UNSUPPORTED;
+ }
+ Status = gBS->LocateProtocol (&gEfiStatusCodeRuntimeProtocolGuid, NULL, (VOID **)&gStatusCode);
+ if (EFI_ERROR (Status) || gStatusCode == NULL) {
+ return EFI_UNSUPPORTED;
+ }
+ }
+ Status = gStatusCode->ReportStatusCode (CodeType, Value, Instance, CallerId, Data);
+#else
+ Status = mRT->ReportStatusCode (CodeType, Value, Instance, CallerId, Data);
+#endif
+ return Status;
+}
diff --git a/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/x64/RuntimeLibAsm.asm b/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/x64/RuntimeLibAsm.asm
new file mode 100644
index 0000000..df58104
--- /dev/null
+++ b/EDK/Foundation/Library/RuntimeDxe/EfiRuntimeLib/x64/RuntimeLibAsm.asm
@@ -0,0 +1,37 @@
+;------------------------------------------------------------------------------
+;
+; Copyright (c) 2007, Intel Corporation
+; All rights reserved. This program and the accompanying materials
+; are licensed and made available under the terms and conditions of the BSD License
+; which accompanies this distribution. The full text of the license may be found at
+; http://opensource.org/licenses/bsd-license.php
+;
+; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+;
+; Module Name:
+;
+; RuntimeLibAsm.asm
+;
+; Abstract:
+;
+;
+;------------------------------------------------------------------------------
+
+.code
+
+;------------------------------------------------------------------------------
+;EFI_STATUS
+;EfiCpuFlushCache (
+; IN EFI_PHYSICAL_ADDRESS Start,
+; IN UINT64 Length
+; );
+;------------------------------------------------------------------------------
+
+EfiCpuFlushCache PROC PUBLIC
+ wbinvd
+ mov rax, 0
+ ret
+EfiCpuFlushCache ENDP
+
+END \ No newline at end of file
diff --git a/EDK/Foundation/Ppi/BaseMemoryTest/BaseMemoryTest.c b/EDK/Foundation/Ppi/BaseMemoryTest/BaseMemoryTest.c
new file mode 100644
index 0000000..867902b
--- /dev/null
+++ b/EDK/Foundation/Ppi/BaseMemoryTest/BaseMemoryTest.c
@@ -0,0 +1,28 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ BaseMemoryTest.c
+
+Abstract:
+
+ PEI memory test PPI GUID as defined in Tiano
+
+--*/
+
+#include "Tiano.h"
+#include "Pei.h"
+#include EFI_PPI_DEFINITION (BaseMemoryTest)
+
+EFI_GUID gPeiBaseMemoryTestPpiGuid = PEI_BASE_MEMORY_TEST_GUID;
+
+EFI_GUID_STRING(&gPeiBaseMemoryTestPpiGuid, "PeiBaseMemoryTest", "Pei Base Memory Test PPI");
diff --git a/EDK/Foundation/Ppi/BaseMemoryTest/BaseMemoryTest.h b/EDK/Foundation/Ppi/BaseMemoryTest/BaseMemoryTest.h
new file mode 100644
index 0000000..1a457da
--- /dev/null
+++ b/EDK/Foundation/Ppi/BaseMemoryTest/BaseMemoryTest.h
@@ -0,0 +1,58 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ BaseMemoryTest.h
+
+Abstract:
+
+ Pei memory test PPI as defined in Tiano
+
+ Used to Pei memory test in PEI
+
+--*/
+
+#ifndef _BASE_MEMORY_TEST_H_
+#define _BASE_MEMORY_TEST_H_
+
+#define PEI_BASE_MEMORY_TEST_GUID \
+ { \
+ 0xb6ec423c, 0x21d2, 0x490d, 0x85, 0xc6, 0xdd, 0x58, 0x64, 0xea, 0xa6, 0x74 \
+ }
+
+EFI_FORWARD_DECLARATION (PEI_BASE_MEMORY_TEST_PPI);
+
+typedef enum {
+ Ignore,
+ Quick,
+ Sparse,
+ Extensive
+} PEI_MEMORY_TEST_OP;
+
+typedef
+EFI_STATUS
+(EFIAPI *PEI_BASE_MEMORY_TEST) (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_BASE_MEMORY_TEST_PPI * This,
+ IN EFI_PHYSICAL_ADDRESS BeginAddress,
+ IN UINT64 MemoryLength,
+ IN PEI_MEMORY_TEST_OP Operation,
+ OUT EFI_PHYSICAL_ADDRESS * ErrorAddress
+ );
+
+typedef struct _PEI_BASE_MEMORY_TEST_PPI {
+ PEI_BASE_MEMORY_TEST BaseMemoryTest;
+} PEI_BASE_MEMORY_TEST_PPI;
+
+extern EFI_GUID gPeiBaseMemoryTestPpiGuid;
+
+#endif
diff --git a/EDK/Foundation/Ppi/DebugMask/DebugMask.c b/EDK/Foundation/Ppi/DebugMask/DebugMask.c
new file mode 100644
index 0000000..033b00f
--- /dev/null
+++ b/EDK/Foundation/Ppi/DebugMask/DebugMask.c
@@ -0,0 +1,30 @@
+/*++
+
+Copyright (c) 2010, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ DebugMask.c
+
+Abstract:
+
+ This PPI is used to abstract the Debug Mask services for
+ the specific PEIM.
+
+--*/
+
+#include "Tiano.h"
+#include EFI_PPI_DEFINITION (DebugMask)
+
+
+EFI_GUID gEfiDebugMaskPpiGuid = EFI_DEBUG_MASK_PPI_GUID;
+
+EFI_GUID_STRING (&gEfiDebugMaskPpiGuid, "DebugMask PPI", "Efi Debug Mask PPI");
+
diff --git a/EDK/Foundation/Ppi/DebugMask/DebugMask.h b/EDK/Foundation/Ppi/DebugMask/DebugMask.h
new file mode 100644
index 0000000..009eae7
--- /dev/null
+++ b/EDK/Foundation/Ppi/DebugMask/DebugMask.h
@@ -0,0 +1,46 @@
+/*++
+
+Copyright (c) 2010, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ DebugMask.h
+
+Abstract:
+
+ This PPI is used to abstract the Debug Mask services for
+ the specific PEIM.
+
+--*/
+
+#ifndef _DEBUG_MASK_PPI_H_
+#define _DEBUG_MASK_PPI_H_
+
+//
+//3bd930fd-f823-4948-8691-98e6fe36ace2
+//
+#define EFI_DEBUG_MASK_PPI_GUID \
+ { 0x3bd930fd, 0xf823, 0x4948, 0x86, 0x91, 0x98, 0xe6, 0xfe, 0x36, 0xac, 0xe2 }
+
+//
+// Forward reference for pure ANSI compatability
+//
+EFI_FORWARD_DECLARATION (EFI_DEBUG_MASK_PPI);
+
+//
+// DebugMask PPI definition
+//
+typedef struct _EFI_DEBUG_MASK_PPI {
+ UINTN ImageDebugMask;
+} EFI_DEBUG_MASK_PPI;
+
+extern EFI_GUID gEfiDebugMaskPpiGuid;
+
+#endif
diff --git a/EDK/Foundation/Ppi/EdkPpiLib.cif b/EDK/Foundation/Ppi/EdkPpiLib.cif
new file mode 100644
index 0000000..641a364
--- /dev/null
+++ b/EDK/Foundation/Ppi/EdkPpiLib.cif
@@ -0,0 +1,20 @@
+<component>
+ name = "EdkPpiLib"
+ category = ModulePart
+ LocalRoot = "Edk\Foundation\Ppi\"
+ RefName = "EdkPpiLib"
+[files]
+"EdkPpiLib.sdl"
+"EdkPpiLib.mak"
+"BaseMemoryTest\BaseMemoryTest.h"
+"BaseMemoryTest\BaseMemoryTest.c"
+"DebugMask\DebugMask.h"
+"DebugMask\DebugMask.c"
+"FlashMap\FlashMap.h"
+"FlashMap\FlashMap.c"
+"PeiInMemory\PeiInMemory.h"
+"PeiInMemory\PeiInMemory.c"
+"StatusCodeMemory\StatusCodeMemory.h"
+"StatusCodeMemory\StatusCodeMemory.c"
+"EdkPpiLib.inf"
+<endComponent>
diff --git a/EDK/Foundation/Ppi/EdkPpiLib.inf b/EDK/Foundation/Ppi/EdkPpiLib.inf
new file mode 100644
index 0000000..09022e3
--- /dev/null
+++ b/EDK/Foundation/Ppi/EdkPpiLib.inf
@@ -0,0 +1,51 @@
+#/*++
+#
+# Copyright (c) 2004 - 2008, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# EdkPpiLib.inf
+#
+# Abstract:
+#
+# Component description file for the Edk PPI library.
+#
+#--*/
+
+[defines]
+BASE_NAME= EdkPpiLib
+COMPONENT_TYPE= LIBRARY
+
+[includes.common]
+ $(EDK_SOURCE)\Foundation
+ $(EDK_SOURCE)\Foundation\Efi
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)\Foundation\Include\Pei
+ $(EDK_SOURCE)\Foundation\Library\Pei\Include
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+ $(EDK_SOURCE)\Foundation\Framework
+
+[nmake.common]
+
+[sources.common]
+ BaseMemoryTest\BaseMemoryTest.h
+ BaseMemoryTest\BaseMemoryTest.c
+ DebugMask\DebugMask.h
+ DebugMask\DebugMask.c
+ FlashMap\FlashMap.h
+ FlashMap\FlashMap.c
+ PeiInMemory\PeiInMemory.h
+ PeiInMemory\PeiInMemory.c
+ StatusCodeMemory\StatusCodeMemory.h
+ StatusCodeMemory\StatusCodeMemory.c \ No newline at end of file
diff --git a/EDK/Foundation/Ppi/EdkPpiLib.mak b/EDK/Foundation/Ppi/EdkPpiLib.mak
new file mode 100644
index 0000000..acff789
--- /dev/null
+++ b/EDK/Foundation/Ppi/EdkPpiLib.mak
@@ -0,0 +1,69 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkPpiLib/EdkPpiLib.mak 1 1/20/12 4:04a Jeffch $
+#
+# $Revision: 1 $
+#
+# $Date: 1/20/12 4:04a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkPpiLib/EdkPpiLib.mak $
+#
+# 1 1/20/12 4:04a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 9/27/11 6:29a Wesleychen
+# Intel EDK initially releases.
+#
+# 2 9/02/09 4:02a Iminglin
+# EIP24919
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: EdkPpiLib.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+$(EDKPPILIB) : EdkPpiLib
+
+$(BUILD_DIR)\EdkPpiLib.lib : EdkPpiLib
+
+EdkPpiLib : $(BUILD_DIR)\EdkPpiLib.mak EdkPpiLibBin
+
+$(BUILD_DIR)\EdkPpiLib.mak : $(EdkPpiLib_DIR)\$(@B).cif $(EdkPpiLib_DIR)\$(@B).mak $(BUILD_RULES)
+ $(CIF2MAK) $(EdkPpiLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS)
+
+EdkPpiLibBin :
+ $(MAKE) /$(MAKEFLAGS) $(EDK_DEFAULTS)\
+ /f $(BUILD_DIR)\EdkPpiLib.mak all\
+ TYPE=PEI_LIBRARY \
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#********************************************************************** \ No newline at end of file
diff --git a/EDK/Foundation/Ppi/EdkPpiLib.sdl b/EDK/Foundation/Ppi/EdkPpiLib.sdl
new file mode 100644
index 0000000..000e812
--- /dev/null
+++ b/EDK/Foundation/Ppi/EdkPpiLib.sdl
@@ -0,0 +1,26 @@
+TOKEN
+ Name = "EdkPpiLib_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable EdkPpiLib support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "EDKPPILIB"
+ Value = "$(BUILD_DIR)\EdkPpiLib.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "EdkPpiLib_DIR"
+End
+
+MODULE
+ Help = "Includes EdkPpiLib.mak to Project"
+ File = "EdkPpiLib.mak"
+End
+
diff --git a/EDK/Foundation/Ppi/FlashMap/FlashMap.c b/EDK/Foundation/Ppi/FlashMap/FlashMap.c
new file mode 100644
index 0000000..10a276b
--- /dev/null
+++ b/EDK/Foundation/Ppi/FlashMap/FlashMap.c
@@ -0,0 +1,28 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ FlashMap.c
+
+Abstract:
+
+ Flash Map PPI GUID as defined in Tiano
+
+--*/
+
+#include "Tiano.h"
+#include "Pei.h"
+#include EFI_PPI_DEFINITION (FlashMap)
+
+EFI_GUID gPeiFlashMapPpiGuid = PEI_FLASH_MAP_PPI_GUID;
+
+EFI_GUID_STRING(&gPeiFlashMapPpiGuid, "Flash Map", "Flash Map PPI");
diff --git a/EDK/Foundation/Ppi/FlashMap/FlashMap.h b/EDK/Foundation/Ppi/FlashMap/FlashMap.h
new file mode 100644
index 0000000..123f1e7
--- /dev/null
+++ b/EDK/Foundation/Ppi/FlashMap/FlashMap.h
@@ -0,0 +1,59 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ FlashMap.h
+
+Abstract:
+
+ FlashMap PPI defined in Tiano
+
+ This code abstracts FlashMap access
+
+--*/
+
+#ifndef _PEI_FLASH_MAP_PPI_H_
+#define _PEI_FLASH_MAP_PPI_H_
+
+#define PEI_FLASH_MAP_PPI_GUID \
+ { \
+ 0xf34c2fa0, 0xde88, 0x4270, 0x84, 0x14, 0x96, 0x12, 0x22, 0xf4, 0x52, 0x1c \
+ }
+
+#include "EfiFlashMap.h"
+
+EFI_FORWARD_DECLARATION (PEI_FLASH_MAP_PPI);
+
+//
+// Functions
+//
+typedef
+EFI_STATUS
+(EFIAPI *PEI_GET_FLASH_AREA_INFO) (
+ IN EFI_PEI_SERVICES **PeiServices,
+ IN PEI_FLASH_MAP_PPI * This,
+ IN EFI_FLASH_AREA_TYPE AreaType,
+ IN EFI_GUID * AreaTypeGuid,
+ OUT UINT32 *NumEntries,
+ OUT EFI_FLASH_SUBAREA_ENTRY **Entries
+ );
+
+//
+// PEI_FLASH_MAP_PPI
+//
+typedef struct _PEI_FLASH_MAP_PPI {
+ PEI_GET_FLASH_AREA_INFO GetAreaInfo;
+} PEI_FLASH_MAP_PPI;
+
+extern EFI_GUID gPeiFlashMapPpiGuid;
+
+#endif // _PEI_FLASH_MAP_PPI_H_
diff --git a/EDK/Foundation/Ppi/PeiInMemory/PeiInMemory.c b/EDK/Foundation/Ppi/PeiInMemory/PeiInMemory.c
new file mode 100644
index 0000000..ae723e8
--- /dev/null
+++ b/EDK/Foundation/Ppi/PeiInMemory/PeiInMemory.c
@@ -0,0 +1,33 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PeiInMemory.c
+
+Abstract:
+
+ Capsule on Fat Usb Disk GUID.
+
+ This is the contract between the recovery module and device recovery module
+ in order to convey the name of a given recovery module type
+
+--*/
+
+#include "Tiano.h"
+#include "PeiBind.h"
+#include "PeiApi.h"
+#include EFI_PPI_DEFINITION(PeiInMemory)
+
+EFI_GUID gPeiInMemoryGuid = PEI_IN_MEMORY_GUID;
+
+EFI_GUID_STRING(&gPeiInMemoryGuid, "PeiInMemory", "PEIM In Memory");
+
diff --git a/EDK/Foundation/Ppi/PeiInMemory/PeiInMemory.h b/EDK/Foundation/Ppi/PeiInMemory/PeiInMemory.h
new file mode 100644
index 0000000..627ddb2
--- /dev/null
+++ b/EDK/Foundation/Ppi/PeiInMemory/PeiInMemory.h
@@ -0,0 +1,29 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PeiInMemory.h
+
+Abstract:
+
+
+--*/
+
+#ifndef _PEI_IN_MEMORY_H
+#define _PEI_IN_MEMORY_H
+
+#define PEI_IN_MEMORY_GUID \
+ {0x643b8786, 0xb417, 0x48d2, 0x8f, 0x5e, 0x78, 0x19, 0x93, 0x1c, 0xae, 0xd8}
+
+extern EFI_GUID gPeiInMemoryGuid;
+
+#endif
diff --git a/EDK/Foundation/Ppi/StatusCodeMemory/StatusCodeMemory.c b/EDK/Foundation/Ppi/StatusCodeMemory/StatusCodeMemory.c
new file mode 100644
index 0000000..8d7fc3e
--- /dev/null
+++ b/EDK/Foundation/Ppi/StatusCodeMemory/StatusCodeMemory.c
@@ -0,0 +1,28 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ StatusCodeMemory.c
+
+Abstract:
+
+ Status Code Memory descriptor
+
+--*/
+
+#include "Tiano.h"
+#include "Pei.h"
+#include EFI_PPI_DEFINITION (StatusCodeMemory)
+
+EFI_GUID gPeiStatusCodeMemoryPpiGuid = PEI_STATUS_CODE_MEMORY_PPI_GUID;
+
+EFI_GUID_STRING(&gPeiStatusCodeMemoryPpiGuid, "StatusCodeMemory", "Status Code memory descriptor.");
diff --git a/EDK/Foundation/Ppi/StatusCodeMemory/StatusCodeMemory.h b/EDK/Foundation/Ppi/StatusCodeMemory/StatusCodeMemory.h
new file mode 100644
index 0000000..a6c9fb4
--- /dev/null
+++ b/EDK/Foundation/Ppi/StatusCodeMemory/StatusCodeMemory.h
@@ -0,0 +1,53 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ StatusCodeMemory.h
+
+Abstract:
+
+ Status Code memory descriptor PPI. Contains information about memory that
+ the Status Code PEIM may use to journal Status Codes.
+
+--*/
+
+#ifndef _PEI_STATUS_CODE_MEMORY_PPI_H_
+#define _PEI_STATUS_CODE_MEMORY_PPI_H_
+
+//
+// GUID definition
+//
+#define PEI_STATUS_CODE_MEMORY_PPI_GUID \
+ { 0x26f8ab01, 0xd3cd, 0x489c, 0x98, 0x4f, 0xdf, 0xde, 0xf7, 0x68, 0x39, 0x5b }
+
+//
+// Data types
+//
+typedef struct {
+ EFI_STATUS_CODE_TYPE Type;
+ EFI_STATUS_CODE_VALUE Value;
+ UINT32 Instance;
+} EFI_STATUS_CODE_ENTRY;
+
+//
+// PPI definition
+//
+typedef struct {
+ UINTN FirstEntry;
+ UINTN LastEntry;
+ EFI_PHYSICAL_ADDRESS Address;
+ UINTN Length;
+} PEI_STATUS_CODE_MEMORY_PPI;
+
+extern EFI_GUID gPeiStatusCodeMemoryPpiGuid;
+
+#endif
diff --git a/EDK/Foundation/Protocol/ConsoleControl/ConsoleControl.c b/EDK/Foundation/Protocol/ConsoleControl/ConsoleControl.c
new file mode 100644
index 0000000..3484668
--- /dev/null
+++ b/EDK/Foundation/Protocol/ConsoleControl/ConsoleControl.c
@@ -0,0 +1,29 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ ConsoleControl.c
+
+Abstract:
+
+ Abstraction of a Text mode or GOP/UGA screen
+
+--*/
+
+#include "Tiano.h"
+#include EFI_PROTOCOL_DEFINITION (ConsoleControl)
+
+
+EFI_GUID gEfiConsoleControlProtocolGuid = EFI_CONSOLE_CONTROL_PROTOCOL_GUID;
+
+EFI_GUID_STRING (&gEfiConsoleControlProtocolGuid, "Console Control Protocol", "Console Control Protocol");
+
diff --git a/EDK/Foundation/Protocol/ConsoleControl/ConsoleControl.h b/EDK/Foundation/Protocol/ConsoleControl/ConsoleControl.h
new file mode 100644
index 0000000..2fc4d6a
--- /dev/null
+++ b/EDK/Foundation/Protocol/ConsoleControl/ConsoleControl.h
@@ -0,0 +1,122 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ ConsoleControl.h
+
+Abstract:
+
+ Abstraction of a Text mode or GOP/UGA screen
+
+--*/
+
+#ifndef __CONSOLE_CONTROL_H__
+#define __CONSOLE_CONTROL_H__
+
+#define EFI_CONSOLE_CONTROL_PROTOCOL_GUID \
+ { 0xf42f7782, 0x12e, 0x4c12, 0x99, 0x56, 0x49, 0xf9, 0x43, 0x4, 0xf7, 0x21 }
+
+typedef struct _EFI_CONSOLE_CONTROL_PROTOCOL EFI_CONSOLE_CONTROL_PROTOCOL;
+
+
+typedef enum {
+ EfiConsoleControlScreenText,
+ EfiConsoleControlScreenGraphics,
+ EfiConsoleControlScreenMaxValue
+} EFI_CONSOLE_CONTROL_SCREEN_MODE;
+
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_CONSOLE_CONTROL_PROTOCOL_GET_MODE) (
+ IN EFI_CONSOLE_CONTROL_PROTOCOL *This,
+ OUT EFI_CONSOLE_CONTROL_SCREEN_MODE *Mode,
+ OUT BOOLEAN *GopUgaExists, OPTIONAL
+ OUT BOOLEAN *StdInLocked OPTIONAL
+ )
+/*++
+
+ Routine Description:
+ Return the current video mode information. Also returns info about existence
+ of Graphics Output devices or UGA Draw devices in system, and if the Std In
+ device is locked. All the arguments are optional and only returned if a non
+ NULL pointer is passed in.
+
+ Arguments:
+ This - Protocol instance pointer.
+ Mode - Are we in text of grahics mode.
+ GopUgaExists - TRUE if Console Spliter has found a GOP or UGA device
+ StdInLocked - TRUE if StdIn device is keyboard locked
+
+ Returns:
+ EFI_SUCCESS - Mode information returned.
+
+--*/
+;
+
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_CONSOLE_CONTROL_PROTOCOL_SET_MODE) (
+ IN EFI_CONSOLE_CONTROL_PROTOCOL *This,
+ OUT EFI_CONSOLE_CONTROL_SCREEN_MODE Mode
+ )
+/*++
+
+ Routine Description:
+ Set the current mode to either text or graphics. Graphics is
+ for Quiet Boot.
+
+ Arguments:
+ This - Protocol instance pointer.
+ Mode - Mode to set the
+
+ Returns:
+ EFI_SUCCESS - Mode information returned.
+
+--*/
+;
+
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_CONSOLE_CONTROL_PROTOCOL_LOCK_STD_IN) (
+ IN EFI_CONSOLE_CONTROL_PROTOCOL *This,
+ IN CHAR16 *Password
+ )
+/*++
+
+ Routine Description:
+ Lock Std In devices until Password is typed.
+
+ Arguments:
+ This - Protocol instance pointer.
+ Password - Password needed to unlock screen. NULL means unlock keyboard
+
+ Returns:
+ EFI_SUCCESS - Mode information returned.
+ EFI_DEVICE_ERROR - Std In not locked
+
+--*/
+;
+
+
+
+typedef struct _EFI_CONSOLE_CONTROL_PROTOCOL {
+ EFI_CONSOLE_CONTROL_PROTOCOL_GET_MODE GetMode;
+ EFI_CONSOLE_CONTROL_PROTOCOL_SET_MODE SetMode;
+ EFI_CONSOLE_CONTROL_PROTOCOL_LOCK_STD_IN LockStdIn;
+} EFI_CONSOLE_CONTROL_PROTOCOL;
+
+extern EFI_GUID gEfiConsoleControlProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Protocol/CustomizedDecompress/CustomizedDecompress.c b/EDK/Foundation/Protocol/CustomizedDecompress/CustomizedDecompress.c
new file mode 100644
index 0000000..08fd681
--- /dev/null
+++ b/EDK/Foundation/Protocol/CustomizedDecompress/CustomizedDecompress.c
@@ -0,0 +1,28 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ CustomizedDecompress.c
+
+Abstract:
+
+ The GUID for the user Customized Decompress Protocol
+
+--*/
+
+#include "Tiano.h"
+#include EFI_PROTOCOL_DEFINITION(CustomizedDecompress)
+
+EFI_GUID gEfiCustomizedDecompressProtocolGuid = EFI_CUSTOMIZED_DECOMPRESS_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiCustomizedDecompressProtocolGuid, "Cutomized Decompress", "Customized Decompression Protocol");
+
diff --git a/EDK/Foundation/Protocol/CustomizedDecompress/CustomizedDecompress.h b/EDK/Foundation/Protocol/CustomizedDecompress/CustomizedDecompress.h
new file mode 100644
index 0000000..71815bc
--- /dev/null
+++ b/EDK/Foundation/Protocol/CustomizedDecompress/CustomizedDecompress.h
@@ -0,0 +1,139 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ CustomizedDecompress.h
+
+Abstract:
+
+ The user Customized Decompress Protocol Interface
+
+--*/
+
+#ifndef _CUSTOMIZED_DECOMPRESS_H_
+#define _CUSTOMIZED_DECOMPRESS_H_
+
+#define EFI_CUSTOMIZED_DECOMPRESS_PROTOCOL_GUID \
+ { 0x9a44198e, 0xa4a2, 0x44e6, 0x8a, 0x1f, 0x39, 0xbe, 0xfd, 0xac, 0x89, 0x6f }
+
+EFI_FORWARD_DECLARATION (EFI_CUSTOMIZED_DECOMPRESS_PROTOCOL);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_CUSTOMIZED_DECOMPRESS_GET_INFO) (
+ IN EFI_CUSTOMIZED_DECOMPRESS_PROTOCOL *This,
+ IN VOID *Source,
+ IN UINT32 SourceSize,
+ OUT UINT32 *DestinationSize,
+ OUT UINT32 *ScratchSize
+ );
+/*++
+
+Routine Description:
+
+ The GetInfo() function retrieves the size of the uncompressed buffer
+ and the temporary scratch buffer required to decompress the buffer
+ specified by Source and SourceSize. If the size of the uncompressed
+ buffer or the size of the scratch buffer cannot be determined from
+ the compressed data specified by Source and SourceData, then
+ EFI_INVALID_PARAMETER is returned. Otherwise, the size of the uncompressed
+ buffer is returned in DestinationSize, the size of the scratch buffer is
+ returned in ScratchSize, and EFI_SUCCESS is returned.
+
+ The GetInfo() function does not have scratch buffer available to perform
+ a thorough checking of the validity of the source data. It just retrieves
+ the 'Original Size' field from the beginning bytes of the source data and
+ output it as DestinationSize. And ScratchSize is specific to the decompression
+ implementation.
+
+Arguments:
+
+ This - The protocol instance pointer
+ Source - The source buffer containing the compressed data.
+ SourceSize - The size, in bytes, of source buffer.
+ DestinationSize - A pointer to the size, in bytes, of the uncompressed buffer
+ that will be generated when the compressed buffer specified
+ by Source and SourceSize is decompressed.
+ ScratchSize - A pointer to the size, in bytes, of the scratch buffer that
+ is required to decompress the compressed buffer specified by
+ Source and SourceSize.
+
+Returns:
+ EFI_SUCCESS - The size of the uncompressed data was returned in DestinationSize
+ and the size of the scratch buffer was returned in ScratchSize.
+ EFI_INVALID_PARAMETER - The size of the uncompressed data or the size of the scratch
+ buffer cannot be determined from the compressed data specified by
+ Source and SourceData.
+
+--*/
+
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_CUSTOMIZED_DECOMPRESS_DECOMPRESS) (
+ IN EFI_CUSTOMIZED_DECOMPRESS_PROTOCOL *This,
+ IN VOID* Source,
+ IN UINT32 SourceSize,
+ IN OUT VOID* Destination,
+ IN UINT32 DestinationSize,
+ IN OUT VOID* Scratch,
+ IN UINT32 ScratchSize
+ );
+/*++
+
+Routine Description:
+
+ The Decompress() function extracts decompressed data to its original form.
+
+ This protocol is designed so that the decompression algorithm can be
+ implemented without using any memory services. As a result, the
+ Decompress() function is not allowed to call AllocatePool() or
+ AllocatePages() in its implementation. It is the caller's responsibility
+ to allocate and free the Destination and Scratch buffers.
+
+ If the compressed source data specified by Source and SourceSize is
+ sucessfully decompressed into Destination, then EFI_SUCCESS is returned.
+ If the compressed source data specified by Source and SourceSize is not in
+ a valid compressed data format, then EFI_INVALID_PARAMETER is returned.
+
+Arguments:
+
+ This - The protocol instance pointer
+ Source - The source buffer containing the compressed data.
+ SourceSize - The size of source data.
+ Destination - On output, the destination buffer that contains
+ the uncompressed data.
+ DestinationSize - The size of destination buffer. The size of destination
+ buffer needed is obtained from GetInfo().
+ Scratch - A temporary scratch buffer that is used to perform the
+ decompression.
+ ScratchSize - The size of scratch buffer. The size of scratch buffer needed
+ is obtained from GetInfo().
+
+Returns:
+
+ EFI_SUCCESS - Decompression completed successfully, and the uncompressed
+ buffer is returned in Destination.
+ EFI_INVALID_PARAMETER
+ - The source buffer specified by Source and SourceSize is
+ corrupted (not in a valid compressed format).
+
+--*/
+
+typedef struct _EFI_CUSTOMIZED_DECOMPRESS_PROTOCOL {
+ EFI_CUSTOMIZED_DECOMPRESS_GET_INFO GetInfo;
+ EFI_CUSTOMIZED_DECOMPRESS_DECOMPRESS Decompress;
+} EFI_CUSTOMIZED_DECOMPRESS_PROTOCOL;
+
+extern EFI_GUID gEfiCustomizedDecompressProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Protocol/DebugAssert/DebugAssert.c b/EDK/Foundation/Protocol/DebugAssert/DebugAssert.c
new file mode 100644
index 0000000..529e2b7
--- /dev/null
+++ b/EDK/Foundation/Protocol/DebugAssert/DebugAssert.c
@@ -0,0 +1,30 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ DebugAssert.c
+
+Abstract:
+
+ This protocol allows provides debug services to a driver. This is not
+ debugger support, but things like ASSERT() and DEBUG() macros
+
+--*/
+
+#include "Tiano.h"
+#include EFI_PROTOCOL_DEFINITION(DebugAssert)
+
+
+EFI_GUID gEfiDebugAssertProtocolGuid = EFI_DEBUG_ASSERT_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiDebugAssertProtocolGuid, "EFI Debug Assert", "Efi Debug Assert Protocol");
+
diff --git a/EDK/Foundation/Protocol/DebugAssert/DebugAssert.h b/EDK/Foundation/Protocol/DebugAssert/DebugAssert.h
new file mode 100644
index 0000000..83b5c36
--- /dev/null
+++ b/EDK/Foundation/Protocol/DebugAssert/DebugAssert.h
@@ -0,0 +1,89 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ DebugAssert.h
+
+Abstract:
+
+ This protocol allows provides debug services to a driver. This is not
+ debugger support, but things like ASSERT() and DEBUG() macros
+
+--*/
+
+#ifndef _DEBUG_ASSERT_H_
+#define _DEBUG_ASSERT_H_
+
+
+#define EFI_DEBUG_ASSERT_PROTOCOL_GUID \
+ { 0xbe499c92, 0x7d4b, 0x11d4, 0xbc, 0xee, 0x0, 0x80, 0xc7, 0x3c, 0x88, 0x81 }
+
+//
+// Forward reference for pure ANSI compatability
+//
+EFI_FORWARD_DECLARATION (EFI_DEBUG_ASSERT_PROTOCOL);
+
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_DEBUG_ASSERT) (
+ IN EFI_DEBUG_ASSERT_PROTOCOL *This,
+ IN CHAR8 *FileName,
+ IN INTN LineNumber,
+ IN CHAR8 *Description
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_DEBUG_PRINT) (
+ IN EFI_DEBUG_ASSERT_PROTOCOL *This,
+ IN UINTN ErrorLevel,
+ IN CHAR8 *Format,
+ IN VA_LIST Marker
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_POST_CODE) (
+ IN EFI_DEBUG_ASSERT_PROTOCOL *This,
+ IN UINT16 PostCode,
+ IN CHAR8 *PostCodeString OPTIONAL
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_GET_ERROR_LEVEL) (
+ IN EFI_DEBUG_ASSERT_PROTOCOL *This,
+ IN UINTN *ErrorLevel
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SET_ERROR_LEVEL) (
+ IN EFI_DEBUG_ASSERT_PROTOCOL *This,
+ IN UINTN ErrorLevel
+ );
+
+typedef struct _EFI_DEBUG_ASSERT_PROTOCOL {
+
+ EFI_DEBUG_ASSERT Assert;
+ EFI_DEBUG_PRINT Print;
+ EFI_POST_CODE PostCode;
+
+ EFI_GET_ERROR_LEVEL GetErrorLevel;
+ EFI_SET_ERROR_LEVEL SetErrorLevel;
+
+} EFI_DEBUG_ASSERT_PROTOCOL;
+
+extern EFI_GUID gEfiDebugAssertProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Protocol/DebugMask/DebugMask.c b/EDK/Foundation/Protocol/DebugMask/DebugMask.c
new file mode 100644
index 0000000..0bfe8ec
--- /dev/null
+++ b/EDK/Foundation/Protocol/DebugMask/DebugMask.c
@@ -0,0 +1,33 @@
+/*++
+
+Copyright (c) 2004 - 2011, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ DebugMask.c
+
+Abstract:
+
+ This protocol is used to abstract the Debug Mask serivces for
+ the specific driver or application image.
+
+--*/
+
+#include "Tiano.h"
+#include EFI_PROTOCOL_DEFINITION(DebugMask)
+
+
+EFI_GUID gEfiDebugMaskProtocolGuid = EFI_DEBUG_MASK_PROTOCOL_GUID;
+EFI_GUID gEfiSmmDebugMaskProtocolGuid = EFI_SMM_DEBUG_MASK_PROTOCOL_GUID;
+EFI_GUID gEfiRuntimeDebugMaskProtocolGuid = EFI_RUNTIME_DEBUG_MASK_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiDebugMaskProtocolGuid, "DebugMask Protocol", "Efi Debug Mask Protocol");
+EFI_GUID_STRING(&gEfiSmmDebugMaskProtocolGuid, "Smm DebugMask Protocol", "Efi Smm Debug Mask Protocol");
+EFI_GUID_STRING(&gEfiRuntimeDebugMaskProtocolGuid, "Runtime DebugMask Protocol", "Efi Runtime Debug Mask Protocol"); \ No newline at end of file
diff --git a/EDK/Foundation/Protocol/DebugMask/DebugMask.h b/EDK/Foundation/Protocol/DebugMask/DebugMask.h
new file mode 100644
index 0000000..99a0c25
--- /dev/null
+++ b/EDK/Foundation/Protocol/DebugMask/DebugMask.h
@@ -0,0 +1,72 @@
+/*++
+
+Copyright (c) 2004 - 2011, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ DebugMask.h
+
+Abstract:
+
+ This protocol is used to abstract the Debug Mask serivces for
+ the specific driver or application image.
+
+--*/
+
+#ifndef _DEBUG_MASK_H_
+#define _DEBUG_MASK_H_
+
+#define EFI_DEBUG_MASK_PROTOCOL_GUID \
+ { 0x4c8a2451, 0xc207, 0x405b, 0x96, 0x94, 0x99, 0xea, 0x13, 0x25, 0x13, 0x41 }
+
+#define EFI_SMM_DEBUG_MASK_PROTOCOL_GUID \
+ { 0x3bce1d9f, 0x3b8d, 0x4117, 0x9f, 0x7, 0x5c, 0x4f, 0x79, 0x3e, 0xb0, 0xa4 }
+
+#define EFI_RUNTIME_DEBUG_MASK_PROTOCOL_GUID \
+ { 0x6378fef3, 0xc89f, 0x492f, 0xbd, 0xb1, 0xbf, 0xb4, 0x43, 0x19, 0xcf, 0xda }
+
+#define EFI_DEBUG_MASK_REVISION 0x00010000
+
+//
+// Forward reference for pure ANSI compatability
+//
+EFI_FORWARD_DECLARATION (EFI_DEBUG_MASK_PROTOCOL);
+
+//
+// DebugMask member functions definition
+//
+typedef
+EFI_STATUS
+(EFIAPI * EFI_GET_DEBUG_MASK) (
+ IN EFI_DEBUG_MASK_PROTOCOL *This, // Calling context
+ IN OUT UINTN *CurrentDebugMask // Ptr to store current debug mask
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_SET_DEBUG_MASK) (
+ IN EFI_DEBUG_MASK_PROTOCOL *This, // Calling context
+ IN UINTN NewDebugMask // New Debug Mask value to set
+ );
+
+//
+// DebugMask protocol definition
+//
+typedef struct _EFI_DEBUG_MASK_PROTOCOL {
+ INT64 Revision;
+ EFI_GET_DEBUG_MASK GetDebugMask;
+ EFI_SET_DEBUG_MASK SetDebugMask;
+} EFI_DEBUG_MASK_PROTOCOL;
+
+extern EFI_GUID gEfiDebugMaskProtocolGuid;
+extern EFI_GUID gEfiSmmDebugMaskProtocolGuid;
+extern EFI_GUID gEfiRuntimeDebugMaskProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Protocol/DiskInfo/DiskInfo.c b/EDK/Foundation/Protocol/DiskInfo/DiskInfo.c
new file mode 100644
index 0000000..d028a53
--- /dev/null
+++ b/EDK/Foundation/Protocol/DiskInfo/DiskInfo.c
@@ -0,0 +1,30 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ DiskInfo.c
+
+Abstract:
+
+
+--*/
+
+#include "Tiano.h"
+#include EFI_PROTOCOL_DEFINITION (DiskInfo)
+
+EFI_GUID gEfiDiskInfoProtocolGuid = EFI_DISK_INFO_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiDiskInfoProtocolGuid, "Disk Info Protocol", "Disk Info Protocol");
+
+EFI_GUID gEfiDiskInfoIdeInterfaceGuid = EFI_DISK_INFO_IDE_INTERFACE_GUID;
+EFI_GUID gEfiDiskInfoScsiInterfaceGuid = EFI_DISK_INFO_SCSI_INTERFACE_GUID;
+EFI_GUID gEfiDiskInfoUsbInterfaceGuid = EFI_DISK_INFO_USB_INTERFACE_GUID;
diff --git a/EDK/Foundation/Protocol/DiskInfo/DiskInfo.h b/EDK/Foundation/Protocol/DiskInfo/DiskInfo.h
new file mode 100644
index 0000000..42decf9
--- /dev/null
+++ b/EDK/Foundation/Protocol/DiskInfo/DiskInfo.h
@@ -0,0 +1,174 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ DiskInfo.h
+
+Abstract:
+
+ Disk Info protocol is used to export Inquiry Data for a drive.
+ Its needed to support low level formating of drives in a mannor
+ thats DOS compatible.
+
+--*/
+
+#ifndef __DISK_INFO_H__
+#define __DISK_INFO_H__
+
+#define EFI_DISK_INFO_PROTOCOL_GUID \
+ { \
+ 0xd432a67f, 0x14dc, 0x484b, 0xb3, 0xbb, 0x3f, 0x2, 0x91, 0x84, 0x93, 0x27 \
+ }
+
+EFI_FORWARD_DECLARATION (EFI_DISK_INFO_PROTOCOL);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_DISK_INFO_INQUIRY) (
+ IN EFI_DISK_INFO_PROTOCOL * This,
+ IN OUT VOID *InquiryData,
+ IN OUT UINT32 *IntquiryDataSize
+ )
+/*++
+
+ Routine Description:
+ Return the results of the Inquiry command to a drive in InquiryData.
+ Data format of Inquiry data is defined by the Interface GUID.
+
+ Arguments:
+ This - Protocol instance pointer.
+ InquiryData - Results of Inquiry command to device
+ InquiryDataSize - Size of InquiryData in bytes.
+
+ Returns:
+ EFI_SUCCESS - InquiryData valid
+ EFI_NOT_FOUND - Device does not support this data class
+ EFI_DEVICE_ERROR - Error reading InquiryData from device
+ EFI_BUFFER_TOO_SMALL - IntquiryDataSize not big enough
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_DISK_INFO_IDENTIFY) (
+ IN EFI_DISK_INFO_PROTOCOL * This,
+ IN OUT VOID *IdentifyData,
+ IN OUT UINT32 *IdentifyDataSize
+ )
+/*++
+
+ Routine Description:
+ Return the results of the Identify command to a drive in IdentifyData.
+ Data format of Identify data is defined by the Interface GUID.
+
+ Arguments:
+ This - Protocol instance pointer.
+ IdentifyData - Results of Identify command to device
+ IdentifyDataSize - Size of IdentifyData in bytes.
+
+ Returns:
+ EFI_SUCCESS - IdentifyData valid
+ EFI_NOT_FOUND - Device does not support this data class
+ EFI_DEVICE_ERROR - Error reading IdentifyData from device
+ EFI_BUFFER_TOO_SMALL - IdentifyDataSize not big enough
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_DISK_INFO_SENSE_DATA) (
+ IN EFI_DISK_INFO_PROTOCOL * This,
+ IN OUT VOID *SenseData,
+ IN OUT UINT32 *SenseDataSize,
+ OUT UINT8 *SenseDataNumber
+ )
+/*++
+
+ Routine Description:
+ Return the results of the Request Sense command to a drive in SenseData.
+ Data format of Sense data is defined by the Interface GUID.
+
+ Arguments:
+ This - Protocol instance pointer.
+ SenseData - Results of Request Sense command to device
+ SenseDataSize - Size of SenseData in bytes.
+ SenseDataNumber - Type of SenseData
+
+ Returns:
+ EFI_SUCCESS - InquiryData valid
+ EFI_NOT_FOUND - Device does not support this data class
+ EFI_DEVICE_ERROR - Error reading InquiryData from device
+ EFI_BUFFER_TOO_SMALL - SenseDataSize not big enough
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_DISK_INFO_WHICH_IDE) (
+ IN EFI_DISK_INFO_PROTOCOL * This,
+ OUT UINT32 *IdeChannel,
+ OUT UINT32 *IdeDevice
+ )
+/*++
+
+ Routine Description:
+ Return the results of the Request Sense command to a drive in SenseData.
+ Data format of Sense data is defined by the Interface GUID.
+
+ Arguments:
+ This - Protocol instance pointer.
+ IdeChannel - Primary or Secondary
+ IdeDevice - Master or Slave
+
+ Returns:
+ EFI_SUCCESS - IdeChannel and IdeDevice are valid
+ EFI_UNSUPPORTED - This is not an IDE device
+
+--*/
+;
+
+//
+// GUIDs for EFI_DISK_INFO_PROTOCOL.Interface. Defines the format of the
+// buffers returned by member functions
+//
+#define EFI_DISK_INFO_IDE_INTERFACE_GUID \
+ { \
+ 0x5e948fe3, 0x26d3, 0x42b5, 0xaf, 0x17, 0x61, 0x2, 0x87, 0x18, 0x8d, 0xec \
+ }
+extern EFI_GUID gEfiDiskInfoIdeInterfaceGuid;
+
+#define EFI_DISK_INFO_SCSI_INTERFACE_GUID \
+ { \
+ 0x8f74baa, 0xea36, 0x41d9, 0x95, 0x21, 0x21, 0xa7, 0xf, 0x87, 0x80, 0xbc \
+ }
+extern EFI_GUID gEfiDiskInfoScsiInterfaceGuid;
+
+#define EFI_DISK_INFO_USB_INTERFACE_GUID \
+ { \
+ 0xcb871572, 0xc11a, 0x47b5, 0xb4, 0x92, 0x67, 0x5e, 0xaf, 0xa7, 0x77, 0x27 \
+ }
+extern EFI_GUID gEfiDiskInfoUsbInterfaceGuid;
+
+typedef struct _EFI_DISK_INFO_PROTOCOL {
+ EFI_GUID Interface;
+ EFI_DISK_INFO_INQUIRY Inquiry;
+ EFI_DISK_INFO_IDENTIFY Identify;
+ EFI_DISK_INFO_SENSE_DATA SenseData;
+ EFI_DISK_INFO_WHICH_IDE WhichIde;
+} EFI_DISK_INFO_PROTOCOL;
+
+extern EFI_GUID gEfiDiskInfoProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Protocol/EdkProtocolLib.cif b/EDK/Foundation/Protocol/EdkProtocolLib.cif
new file mode 100644
index 0000000..ae1df13
--- /dev/null
+++ b/EDK/Foundation/Protocol/EdkProtocolLib.cif
@@ -0,0 +1,78 @@
+<component>
+ name = "EdkProtocolLib"
+ category = ModulePart
+ LocalRoot = "Edk\Foundation\Protocol\"
+ RefName = "EdkProtocolLib"
+[files]
+"EdkProtocolLib.sdl"
+"EdkProtocolLib.mak"
+"ConsoleControl\ConsoleControl.h"
+"ConsoleControl\ConsoleControl.c"
+"CustomizedDecompress\CustomizedDecompress.h"
+"CustomizedDecompress\CustomizedDecompress.c"
+"DebugAssert\DebugAssert.h"
+"DebugAssert\DebugAssert.c"
+"DebugMask\DebugMask.h"
+"DebugMask\DebugMask.c"
+"DiskInfo\DiskInfo.h"
+"DiskInfo\DiskInfo.c"
+"EfiOEMBadging\EfiOEMBadging.h"
+"EfiOEMBadging\EfiOEMBadging.c"
+"FaultTolerantWriteLite\FaultTolerantWriteLite.h"
+"FaultTolerantWriteLite\FaultTolerantWriteLite.c"
+"FirmwarePerformance\FirmwarePerformance.h"
+"FirmwarePerformance\FirmwarePerformance.c"
+"FirmwareVolumeDispatch\FirmwareVolumeDispatch.h"
+"FirmwareVolumeDispatch\FirmwareVolumeDispatch.c"
+"FvbExtension\FvbExtension.h"
+"FvbExtension\FvbExtension.c"
+"GenericMemoryTest\GenericMemoryTest.h"
+"GenericMemoryTest\GenericMemoryTest.c"
+"GuidedSectionExtraction\GuidedSectionExtraction.h"
+"GuidedSectionExtraction\GuidedSectionExtraction.c"
+"IsaAcpi\IsaAcpi.h"
+"IsaAcpi\IsaAcpi.c"
+"IsaIo\IsaIo.h"
+"IsaIo\IsaIo.c"
+"LoadPe32Image\LoadPe32Image.h"
+"LoadPe32Image\LoadPe32Image.c"
+"NicIp4Config\NicIp4Config.h"
+"NicIp4Config\NicIp4Config.c"
+"PciHotPlugRequest\PciHotPlugRequest.h"
+"PciHotPlugRequest\PciHotPlugRequest.c"
+"Performance\Performance.h"
+"Performance\Performance.c"
+"Fpdt\Fpdt.h"
+"Fpdt\Fpdt.c"
+"PlatformMemTest\PlatformMemTest.h"
+"PlatformMemTest\PlatformMemTest.c"
+"Print\Print.h"
+"Print\Print.c"
+"PxeDhcp4\PxeDhcp4.h"
+"PxeDhcp4\PxeDhcp4.c"
+"PxeDhcp4Callback\PxeDhcp4CallBack.h"
+"PxeDhcp4Callback\PxeDhcp4CallBack.c"
+"Tcp\Tcp.h"
+"Tcp\Tcp.c"
+"TianoDecompress\TianoDecompress.h"
+"TianoDecompress\TianoDecompress.c"
+"UgaSplash\UgaSplash.h"
+"UgaSplash\UgaSplash.c"
+"UsbAtapi\usbatapi.h"
+"UsbAtapi\usbatapi.c"
+"VariableStore\VariableStore.h"
+"VariableStore\VariableStore.c"
+"VirtualMemoryAccess\VirtualMemoryAccess.h"
+"VirtualMemoryAccess\VirtualMemoryAccess.c"
+"TcgService\TcgService.h"
+"TcgService\TcgService.c"
+"Ps2Policy\Ps2Policy.h"
+"Ps2Policy\Ps2Policy.c"
+"VgaMiniPort\VgaMiniPort.h"
+"VgaMiniPort\VgaMiniPort.c"
+"EdkProtocolLib.inf"
+"FastBootException\FastBootException.c"
+"FastBootException\FastBootException.h"
+[parts]
+"EdkProtocolLibIPF"
+<endComponent>
diff --git a/EDK/Foundation/Protocol/EdkProtocolLib.inf b/EDK/Foundation/Protocol/EdkProtocolLib.inf
new file mode 100644
index 0000000..3d78d29
--- /dev/null
+++ b/EDK/Foundation/Protocol/EdkProtocolLib.inf
@@ -0,0 +1,112 @@
+#/*++
+#
+# Copyright (c) 2004 - 2011, Intel Corporation
+# All rights reserved. This program and the accompanying materials
+# are licensed and made available under the terms and conditions of the BSD License
+# which accompanies this distribution. The full text of the license may be found at
+# http://opensource.org/licenses/bsd-license.php
+#
+# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+# Module Name:
+#
+# EdkProtocolLib.inf
+#
+# Abstract:
+#
+# Component description file.
+#
+#--*/
+
+[defines]
+BASE_NAME= EdkProtocolLib
+COMPONENT_TYPE= LIBRARY
+
+[includes.common]
+ $(EDK_SOURCE)\Foundation
+ $(EDK_SOURCE)\Foundation\Efi
+ $(EDK_SOURCE)\Foundation\Framework
+ $(EDK_SOURCE)\Foundation\Include
+ $(EDK_SOURCE)\Foundation\Efi\Include
+ $(EDK_SOURCE)\Foundation\Framework\Include
+ $(EDK_SOURCE)\Foundation\Include\IndustryStandard
+ $(EDK_SOURCE)\Foundation\Include\Pei
+ $(EDK_SOURCE)\Foundation\Library\Pei\Include
+ $(EDK_SOURCE)\Foundation\Core\Dxe
+ $(EDK_SOURCE)\Foundation\Library\Dxe\Include
+
+[nmake.common]
+C_STD_INCLUDE=
+
+[sources.common]
+ ConsoleControl\ConsoleControl.h
+ ConsoleControl\ConsoleControl.c
+ CustomizedDecompress\CustomizedDecompress.c
+ CustomizedDecompress\CustomizedDecompress.h
+ DebugAssert\DebugAssert.h
+ DebugAssert\DebugAssert.c
+ DebugMask\DebugMask.h
+ DebugMask\DebugMask.c
+ DiskInfo\DiskInfo.h
+ DiskInfo\DiskInfo.c
+ EfiOemBadging\EfiOemBadging.h
+ EfiOemBadging\EfiOemBadging.c
+ FaultTolerantWriteLite\FaultTolerantWriteLite.h
+ FaultTolerantWriteLite\FaultTolerantWriteLite.c
+ FirmwareVolumeDispatch\FirmwareVolumeDispatch.h
+ FirmwareVolumeDispatch\FirmwareVolumeDispatch.c
+ FvbExtension\FvbExtension.h
+ FvbExtension\FvbExtension.c
+ GenericMemoryTest\GenericMemoryTest.h
+ GenericMemoryTest\GenericMemoryTest.c
+ GuidedSectionExtraction\GuidedSectionExtraction.h
+ GuidedSectionExtraction\GuidedSectionExtraction.c
+ IsaAcpi\IsaAcpi.h
+ IsaAcpi\IsaAcpi.c
+ IsaIo\IsaIo.h
+ IsaIo\IsaIo.c
+ LoadPe32Image\LoadPe32Image.h
+ LoadPe32Image\LoadPe32Image.c
+ NicIp4Config\NicIp4Config.h
+ NicIp4Config\NicIp4Config.c
+ PciHotPlugRequest\PciHotPlugRequest.h
+ PciHotPlugRequest\PciHotPlugRequest.c
+ FirmwarePerformance\FirmwarePerformance.h
+ FirmwarePerformance\FirmwarePerformance.c
+ Fpdt\Fpdt.h
+ Fpdt\Fpdt.c
+ PlatformMemTest\PlatformMemTest.h
+ PlatformMemTest\PlatformMemTest.c
+ Print\Print.h
+ Print\Print.c
+ PxeDhcp4\PxeDhcp4.h
+ PxeDhcp4\PxeDhcp4.c
+ PxeDhcp4Callback\PxeDhcp4Callback.h
+ PxeDhcp4Callback\PxeDhcp4Callback.c
+ Tcp\Tcp.h
+ Tcp\Tcp.c
+ TianoDecompress\TianoDecompress.h
+ TianoDecompress\TianoDecompress.c
+ UgaSplash\UgaSplash.h
+ UgaSplash\UgaSplash.c
+ UsbAtapi\UsbAtapi.h
+ UsbAtapi\UsbAtapi.c
+ VariableStore\VariableStore.h
+ VariableStore\VariableStore.c
+ VirtualMemoryAccess\VirtualMemoryAccess.h
+ VirtualMemoryAccess\VirtualMemoryAccess.c
+ TcgService\TcgService.h
+ TcgService\TcgService.c
+ Ps2Policy\Ps2Policy.h
+ Ps2Policy\Ps2Policy.c
+ VgaMiniPort\VgaMiniPort.h
+ VgaMiniPort\VgaMiniPort.c
+ FastBootException\FastBootException.h
+ FastBootException\FastBootException.c
+
+[sources.ipf]
+ ExtendedSalBootService\ExtendedSalBootService.c
+ ExtendedSalBootService\ExtendedSalBootService.h
+ ExtendedSalGuid\ExtendedSalGuid.c
+ ExtendedSalGuid\ExtendedSalGuid.h
diff --git a/EDK/Foundation/Protocol/EdkProtocolLib.mak b/EDK/Foundation/Protocol/EdkProtocolLib.mak
new file mode 100644
index 0000000..6f06448
--- /dev/null
+++ b/EDK/Foundation/Protocol/EdkProtocolLib.mak
@@ -0,0 +1,72 @@
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#**********************************************************************
+
+#**********************************************************************
+# $Header: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkProtocolLib/EdkProtocolLib.mak 1 1/20/12 4:05a Jeffch $
+#
+# $Revision: 1 $
+#
+# $Date: 1/20/12 4:05a $
+#**********************************************************************
+# Revision History
+# ----------------
+# $Log: /Alaska/SOURCE/Modules/SharkBayRefCodes/IntelEDK/EdkProtocolLib/EdkProtocolLib.mak $
+#
+# 1 1/20/12 4:05a Jeffch
+# Create Intel EDK 1117 Patch 7.
+#
+# 1 9/27/11 6:29a Wesleychen
+# Intel EDK initially releases.
+#
+# 2 9/02/09 4:04a Iminglin
+#
+#**********************************************************************
+#<AMI_FHDR_START>
+#
+# Name: EdkProtocolLib.mak
+#
+# Description:
+#
+#<AMI_FHDR_END>
+#**********************************************************************
+$(EDKPROTOCOLLIB) : EdkProtocolLib
+
+$(BUILD_DIR)\EdkProtocolLib.lib : EdkProtocolLib
+
+EdkProtocolLib : $(BUILD_DIR)\EdkProtocolLib.mak EdkProtocolLibBin
+
+!IF "$(PROCESSOR)"=="IPF"
+EDK_PROTOCOL_LIB_PROCESSOR_CIF=$(EdkProtocolLib_DIR)\EdkProtocolLibIPF.cif
+!ENDIF
+
+$(BUILD_DIR)\EdkProtocolLib.mak : $(EdkProtocolLib_DIR)\$(@B).cif $(EdkProtocolLib_DIR)\$(@B).mak $(BUILD_RULES) $(EDK_PROTOCOL_LIB_PROCESSOR_CIF)
+ $(CIF2MAK) $(EdkProtocolLib_DIR)\$(@B).cif $(CIF2MAK_DEFAULTS) $(EDK_PROTOCOL_LIB_PROCESSOR_CIF)
+
+EdkProtocolLibBin :
+ $(MAKE) /$(MAKEFLAGS) $(EDK_DEFAULTS)\
+ /f $(BUILD_DIR)\EdkProtocolLib.mak all\
+ TYPE=LIBRARY\
+#**********************************************************************
+#**********************************************************************
+#** **
+#** (C)Copyright 1985-2009, American Megatrends, Inc. **
+#** **
+#** All Rights Reserved. **
+#** **
+#** 5555 Oakbrook Parkway, Suite 200, Norcross, GA 30093 **
+#** **
+#** Phone: (770)-246-8600 **
+#** **
+#**********************************************************************
+#********************************************************************** \ No newline at end of file
diff --git a/EDK/Foundation/Protocol/EdkProtocolLib.sdl b/EDK/Foundation/Protocol/EdkProtocolLib.sdl
new file mode 100644
index 0000000..8a8c3e9
--- /dev/null
+++ b/EDK/Foundation/Protocol/EdkProtocolLib.sdl
@@ -0,0 +1,26 @@
+TOKEN
+ Name = "EdkProtocolLib_SUPPORT"
+ Value = "1"
+ Help = "Main switch to enable EdkProtocolLib support in Project"
+ TokenType = Boolean
+ TargetEQU = Yes
+ TargetMAK = Yes
+ Master = Yes
+End
+
+TOKEN
+ Name = "EDKPROTOCOLLIB"
+ Value = "$(BUILD_DIR)\EdkProtocolLib.lib"
+ TokenType = Expression
+ TargetMAK = Yes
+End
+
+PATH
+ Name = "EdkProtocolLib_DIR"
+End
+
+MODULE
+ Help = "Includes EdkProtocolLib.mak to Project"
+ File = "EdkProtocolLib.mak"
+End
+
diff --git a/EDK/Foundation/Protocol/EdkProtocolLibIPF.cif b/EDK/Foundation/Protocol/EdkProtocolLibIPF.cif
new file mode 100644
index 0000000..c119123
--- /dev/null
+++ b/EDK/Foundation/Protocol/EdkProtocolLibIPF.cif
@@ -0,0 +1,11 @@
+<component>
+ name = "EdkProtocolLibIPF"
+ category = ModulePart
+ LocalRoot = "EDK\Foundation\Protocol\"
+ RefName = "EdkProtocolLibIPF"
+[files]
+"ExtendedSalBootService\ExtendedSalBootService.h"
+"ExtendedSalBootService\ExtendedSalBootService.c"
+"ExtendedSalGuid\ExtendedSalGuid.h"
+"ExtendedSalGuid\ExtendedSalGuid.c"
+<endComponent>
diff --git a/EDK/Foundation/Protocol/EfiOEMBadging/EfiOEMBadging.c b/EDK/Foundation/Protocol/EfiOEMBadging/EfiOEMBadging.c
new file mode 100644
index 0000000..bf60211
--- /dev/null
+++ b/EDK/Foundation/Protocol/EfiOEMBadging/EfiOEMBadging.c
@@ -0,0 +1,30 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiOEMBadging.c
+
+Abstract:
+
+ EFI OEM Badging Protocol definition source file
+
+Revision History
+
+--*/
+
+#include "Tiano.h"
+
+#include EFI_PROTOCOL_DEFINITION (EfiOEMBadging)
+
+EFI_GUID gEfiOEMBadgingProtocolGuid = EFI_OEM_BADGING_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiOEMBadgingProtocolGuid, "OEM Badging Protocol", "OEM Badging Protocol");
diff --git a/EDK/Foundation/Protocol/EfiOEMBadging/EfiOEMBadging.h b/EDK/Foundation/Protocol/EfiOEMBadging/EfiOEMBadging.h
new file mode 100644
index 0000000..90b32c6
--- /dev/null
+++ b/EDK/Foundation/Protocol/EfiOEMBadging/EfiOEMBadging.h
@@ -0,0 +1,79 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ EfiOEMBadging.h
+
+Abstract:
+
+ EFI OEM Badging Protocol definition header file
+
+Revision History
+
+--*/
+
+#ifndef _EFI_OEM_BADGING_H_
+#define _EFI_OEM_BADGING_H_
+
+//
+// GUID for EFI OEM Badging Protocol
+//
+#define EFI_OEM_BADGING_PROTOCOL_GUID \
+ { 0x170e13c0, 0xbf1b, 0x4218, 0x87, 0x1d, 0x2a, 0xbd, 0xc6, 0xf8, 0x87, 0xbc }
+
+
+EFI_FORWARD_DECLARATION (EFI_OEM_BADGING_PROTOCOL);
+
+typedef enum {
+ EfiBadgingFormatBMP,
+ EfiBadgingFormatJPEG,
+ EfiBadgingFormatTIFF,
+ EfiBadgingFormatGIF,
+ EfiBadgingFormatUnknown
+} EFI_BADGING_FORMAT;
+
+typedef enum {
+ EfiBadgingDisplayAttributeLeftTop,
+ EfiBadgingDisplayAttributeCenterTop,
+ EfiBadgingDisplayAttributeRightTop,
+ EfiBadgingDisplayAttributeCenterRight,
+ EfiBadgingDisplayAttributeRightBottom,
+ EfiBadgingDisplayAttributeCenterBottom,
+ EfiBadgingDisplayAttributeLeftBottom,
+ EfiBadgingDisplayAttributeCenterLeft,
+ EfiBadgingDisplayAttributeCenter,
+ EfiBadgingDisplayAttributeCustomized
+} EFI_BADGING_DISPLAY_ATTRIBUTE;
+
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_BADGING_GET_IMAGE) (
+ IN EFI_OEM_BADGING_PROTOCOL *This,
+ IN OUT UINT32 *Instance,
+ OUT EFI_BADGING_FORMAT *Format,
+ OUT UINT8 **ImageData,
+ OUT UINTN *ImageSize,
+ OUT EFI_BADGING_DISPLAY_ATTRIBUTE *Attribute,
+ OUT UINTN *CoordinateX,
+ OUT UINTN *CoordinateY
+);
+
+
+typedef struct _EFI_OEM_BADGING_PROTOCOL {
+ EFI_BADGING_GET_IMAGE GetImage;
+} EFI_OEM_BADGING_PROTOCOL;
+
+
+extern EFI_GUID gEfiOEMBadgingProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Protocol/ExtendedSalBootService/ExtendedSalBootService.c b/EDK/Foundation/Protocol/ExtendedSalBootService/ExtendedSalBootService.c
new file mode 100644
index 0000000..6d4d2c4
--- /dev/null
+++ b/EDK/Foundation/Protocol/ExtendedSalBootService/ExtendedSalBootService.c
@@ -0,0 +1,27 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ ExtendedSalBootService.c
+
+Abstract:
+
+ This is a protocol creates infrastructure to register Extended Sal Procs.
+
+
+--*/
+
+#include "Tiano.h"
+#include EFI_PROTOCOL_DEFINITION(ExtendedSalBootService)
+
+EFI_GUID gEfiExtendedSalBootServiceProtocolGuid = EXTENDED_SAL_BOOT_SERVICE_PROTOCOL_GUID;
+EFI_GUID_STRING(&gEfiExtendedSalBootServiceProtocolGuid, "EXT SAL", "Extended Sal Protocol");
diff --git a/EDK/Foundation/Protocol/ExtendedSalBootService/ExtendedSalBootService.h b/EDK/Foundation/Protocol/ExtendedSalBootService/ExtendedSalBootService.h
new file mode 100644
index 0000000..af35700
--- /dev/null
+++ b/EDK/Foundation/Protocol/ExtendedSalBootService/ExtendedSalBootService.h
@@ -0,0 +1,118 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ ExtendedSalBootService.h
+
+Abstract:
+
+--*/
+
+#ifndef _EXTENDED_SAL_PROTOCOL_H_
+#define _EXTENDED_SAL_PROTOCOL_H_
+
+#include "SalApi.h"
+#include "LinkedList.h"
+#include EFI_PROTOCOL_CONSUMER (CpuIo)
+
+
+#define EXTENDED_SAL_BOOT_SERVICE_PROTOCOL_GUID \
+ {0xde0ee9a4,0x3c7a,0x44f2,0xb7,0x8b,0xe3,0xcc,0xd6,0x9c,0x3a,0xf7}
+
+#define EXTENDED_SAL_SIGNATURE EFI_SIGNATURE_32('e', 's', 'a', 'l')
+
+#define SAL_MIN_STATE_SIZE 0x400 * 1
+#define PAL_SCARTCH_SIZE 0x400 * 3
+#define ALIGN_MINSTATE_SIZE 512
+#define MAX_SAL_RECORD_SIZE 8*1024
+
+#define SAL_RUNTIMESERVICE
+
+typedef UINT16 EFI_SAL_PROCESSOR_ID;
+
+EFI_FORWARD_DECLARATION (EXTENDED_SAL_BOOT_SERVICE_PROTOCOL);
+
+typedef
+SAL_RUNTIMESERVICE
+SAL_RETURN_REGS
+(EFIAPI *SAL_EXTENDED_SAL_PROC) (
+ IN EFI_GUID *ClassGuid,
+ IN UINT64 FunctionId,
+ IN UINT64 Arg2,
+ IN UINT64 Arg3,
+ IN UINT64 Arg4,
+ IN UINT64 Arg5,
+ IN UINT64 Arg6,
+ IN UINT64 Arg7,
+ IN UINT64 Arg8
+ );
+
+typedef
+SAL_RUNTIMESERVICE
+SAL_RETURN_REGS
+(EFIAPI *SAL_INTERNAL_EXTENDED_SAL_PROC) (
+ IN UINT64 FunctionId,
+ IN UINT64 Arg2,
+ IN UINT64 Arg3,
+ IN UINT64 Arg4,
+ IN UINT64 Arg5,
+ IN UINT64 Arg6,
+ IN UINT64 Arg7,
+ IN UINT64 Arg8,
+ IN SAL_EXTENDED_SAL_PROC ExtendedSalProc,
+ IN BOOLEAN VirtualMode,
+ IN VOID *ModuleGlobal
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EXTENDED_SAL_ADD_SST_INFO) (
+ IN EXTENDED_SAL_BOOT_SERVICE_PROTOCOL *This,
+ IN UINT16 SalAVersion,
+ IN UINT16 SalBVersion,
+ IN CHAR8 *OemId,
+ IN CHAR8 *ProductId
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EXTENDED_SAL_ADD_SST_ENTRY) (
+ IN EXTENDED_SAL_BOOT_SERVICE_PROTOCOL *This,
+ IN UINT8 EntryType,
+ IN UINT8 *TableEntry,
+ IN UINTN EntrySize
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EXTENDED_SAL_REGISTER_INTERNAL_PROC) (
+ IN EXTENDED_SAL_BOOT_SERVICE_PROTOCOL *This,
+ IN EFI_GUID *ClassGuid,
+ IN UINT64 FunctionId,
+ IN SAL_INTERNAL_EXTENDED_SAL_PROC InternalSalProc,
+ IN VOID *PhysicalModuleGlobal
+ );
+
+//
+// Extended Sal Boot Service Protocol Interface
+//
+typedef struct _EXTENDED_SAL_BOOT_SERVICE_PROTOCOL{
+ EXTENDED_SAL_ADD_SST_INFO AddSalSystemTableInfo;
+ EXTENDED_SAL_ADD_SST_ENTRY AddSalSystemTableEntry;
+ EXTENDED_SAL_REGISTER_INTERNAL_PROC AddExtendedSalProc;
+ SAL_EXTENDED_SAL_PROC ExtendedSalProc;
+ SAL_PROC SalProc;
+} EXTENDED_SAL_BOOT_SERVICE_PROTOCOL;
+
+extern EFI_GUID gEfiExtendedSalBootServiceProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Protocol/ExtendedSalGuid/ExtendedSalGuid.c b/EDK/Foundation/Protocol/ExtendedSalGuid/ExtendedSalGuid.c
new file mode 100644
index 0000000..ec19a8d
--- /dev/null
+++ b/EDK/Foundation/Protocol/ExtendedSalGuid/ExtendedSalGuid.c
@@ -0,0 +1,74 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ ExtendedSalGuid.c
+
+Abstract:
+
+ The Extended SAL Lock Services protocol as defined in SAL CIS.
+
+ This protocol is installed by the entity that supplies low level
+ lock primitives that work in dual mode. There are 3 functions
+ as defined below.
+
+--*/
+
+
+
+#include "Tiano.h"
+#include EFI_PROTOCOL_DEFINITION(ExtendedSalGuid)
+
+EFI_GUID gEfiExtendedSalBaseIoServicesProtocolGuid = EFI_EXTENDED_SAL_BASE_IO_SERVICES_PROTOCOL_GUID;
+EFI_GUID gEfiExtendedSalStallServicesProtocolGuid = EFI_EXTENDED_SAL_STALL_SERVICES_PROTOCOL_GUID;
+EFI_GUID gEfiExtendedSalLockServicesProtocolGuid = EFI_EXTENDED_SAL_LOCK_SERVICES_PROTOCOL_GUID;
+EFI_GUID gEfiExtendedSalVirtualServicesProtocolGuid = EFI_EXTENDED_SAL_VIRTUAL_SERVICES_PROTOCOL_GUID;
+EFI_GUID gEfiExtendedSalRtcServicesProtocolGuid = EFI_EXTENDED_SAL_RTC_SERVICES_PROTOCOL_GUID;
+EFI_GUID gEfiExtendedSalVariableServicesProtocolGuid = EFI_EXTENDED_SAL_VARIABLE_SERVICES_PROTOCOL_GUID;
+EFI_GUID gEfiExtendedSalMtcServicesProtocolGuid = EFI_EXTENDED_SAL_MTC_SERVICES_PROTOCOL_GUID;
+EFI_GUID gEfiExtendedSalResetServicesProtocolGuid = EFI_EXTENDED_SAL_RESET_SERVICES_PROTOCOL_GUID;
+EFI_GUID gEfiExtendedSalStatusCodeServicesProtocolGuid = EFI_EXTENDED_SAL_STATUS_CODE_SERVICES_PROTOCOL_GUID;
+EFI_GUID gEfiExtendedSalFvBlockServicesProtocolGuid = EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID;
+EFI_GUID gEfiExtendedSalMpServicesProtocolGuid = EFI_EXTENDED_SAL_MP_SERVICES_PROTOCOL_GUID;
+EFI_GUID gEfiExtendedSalPalServicesProtocolGuid = EFI_EXTENDED_SAL_PAL_SERVICES_PROTOCOL_GUID;
+EFI_GUID gEfiExtendedSalBaseServicesProtocolGuid = EFI_EXTENDED_SAL_BASE_SERVICES_PROTOCOL_GUID;
+EFI_GUID gEfiExtendedSalMcaServicesProtocolGuid = EFI_EXTENDED_SAL_MCA_SERVICES_PROTOCOL_GUID;
+EFI_GUID gEfiExtendedSalPciServicesProtocolGuid = EFI_EXTENDED_SAL_PCI_SERVICES_PROTOCOL_GUID;
+EFI_GUID gEfiExtendedSalCacheServicesProtocolGuid = EFI_EXTENDED_SAL_CACHE_SERVICES_PROTOCOL_GUID;
+EFI_GUID gEfiExtendedSalMcaLogServicesProtocolGuid = EFI_EXTENDED_SAL_MCA_LOG_SERVICES_PROTOCOL_GUID;
+EFI_GUID gEfiExtendedSalElogServicesProtocolGuid = EFI_EXTENDED_SAL_ELOG_SERVICES_PROTOCOL_GUID;
+EFI_GUID gEfiExtendedSalSensorServicesProtocolGuid = EFI_EXTENDED_SAL_SENSOR_SERVICES_PROTOCOL_GUID;
+EFI_GUID gEfiExtendedSalSmComLayerServicesProtocolGuid = EFI_EXTENDED_SAL_SM_COM_LAYER_SERVICES_PROTOCOL_GUID;
+EFI_GUID gEfiExtendedSalSstGuid = EFI_EXTENDED_SAL_SST_GUID;
+
+
+EFI_GUID_STRING(&gEfiExtendedSalBaseIoServicesProtocolGuid, "SAL IO", "Extended SAL Base IO Protocol");
+EFI_GUID_STRING(&gEfiExtendedSalStallServicesProtocolGuid, "SAL STALL", "Extended SAL Stall Services Protocol");
+EFI_GUID_STRING(&gEfiExtendedSalLockServicesProtocolGuid, "SAL LOCK", "Extended SAL Lock Services Protocol");
+EFI_GUID_STRING(&gEfiExtendedSalVirtualServicesProtocolGuid, "SAL VIRT", "Extended SAL Virtual Services Protocol");
+EFI_GUID_STRING(&gEfiExtendedSalRtcServicesProtocolGuid, "SAL RTC", "Extended SAL Lock RTC Protocol");
+EFI_GUID_STRING(&gEfiExtendedSalVariableServicesProtocolGuid, "SAL VARIABLE", "Extended SAL Variable Services Protocol");
+EFI_GUID_STRING(&gEfiExtendedSalMtcServicesProtocolGuid, "SAL MTC", "Extended SAL MTC Services Protocol");
+EFI_GUID_STRING(&gEfiExtendedSalResetServicesProtocolGuid, "SAL RESET", "Extended SAL Reset Services Protocol");
+EFI_GUID_STRING(&gEfiExtendedSalStatusCodeServicesProtocolGuid, "SAL STATUS CODE", "Extended SAL Status Call Services Protocol");
+EFI_GUID_STRING(&gEfiExtendedSalFvBlockServicesProtocolGuid, "SAL FVB", "Extended SAL FVB Services Protocol");
+EFI_GUID_STRING(&gEfiExtendedSalMpServicesProtocolGuid, "SAL MP", "Extended SAL MP Services Protocol");
+EFI_GUID_STRING(&gEfiExtendedSalPalServicesProtocolGuid, "SAL PAL", "Extended SAL PAL Services Protocol");
+EFI_GUID_STRING(&gEfiExtendedSalBaseServicesProtocolGuid, "SAL BASE", "Extended SAL Base Services Protocol");
+EFI_GUID_STRING(&gEfiExtendedSalBaseServicesProtocolGuid, "SAL MCA", "Extended SAL MCA Services Protocol");
+EFI_GUID_STRING(&gEfiExtendedSalPciServicesProtocolGuid, "SAL PCI", "Extended SAL PCI Services Protocol");
+EFI_GUID_STRING(&gEfiExtendedSalCacheServicesProtocolGuid, "SAL CACHE", "Extended SAL Cache Services Protocol");
+EFI_GUID_STRING(&gEfiExtendedSalMcaLogServicesProtocolGuid, "MCA LOG", "Extended SAL MCA LOG Services Protocol");
+EFI_GUID_STRING(&gEfiExtendedSalElogServicesProtocolGuid, "ELOG", "Extended SAL ELOG Services Protocol");
+EFI_GUID_STRING(&gEfiExtendedSalSensorServicesProtocolGuid, "SENSOR", "Extended SAL SENSOR Services Protocol");
+EFI_GUID_STRING(&gEfiExtendedSalSmComLayerServicesProtocolGuid, "SAL SM COM", "Extended SAL SM COM Services Protocol");
+EFI_GUID_STRING(&gEfiExtendedSalSstGuid, "SST SET UP", "SAL System Table Header Set up");
diff --git a/EDK/Foundation/Protocol/ExtendedSalGuid/ExtendedSalGuid.h b/EDK/Foundation/Protocol/ExtendedSalGuid/ExtendedSalGuid.h
new file mode 100644
index 0000000..de540e5
--- /dev/null
+++ b/EDK/Foundation/Protocol/ExtendedSalGuid/ExtendedSalGuid.h
@@ -0,0 +1,283 @@
+/*++
+
+Copyright (c) 2004 - 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ ExtendedSalGuid.h
+
+Abstract:
+
+
+--*/
+
+#ifndef _EXTENDED_SAL_GUID_H_
+#define _EXTENDED_SAL_GUID_H_
+
+//
+// Extended SAL Services protocol GUIDs
+//
+
+#define EFI_EXTENDED_SAL_BASE_IO_SERVICES_PROTOCOL_GUID \
+ { 0x5aea42b5, 0x31e1, 0x4515, 0xbc, 0x31, 0xb8, 0xd5, 0x25, 0x75, 0x65, 0xa6 }
+
+#define EFI_EXTENDED_SAL_STALL_SERVICES_PROTOCOL_GUID \
+ { 0x53a58d06, 0xac27, 0x4d8c, 0xb5, 0xe9, 0xf0, 0x8a, 0x80, 0x65, 0x41, 0x70 }
+
+#define EFI_EXTENDED_SAL_LOCK_SERVICES_PROTOCOL_GUID \
+ { 0x76b75c23, 0xfe4f, 0x4e17, 0xa2, 0xad, 0x1a, 0x65, 0x3d, 0xbb, 0x49, 0x4a }
+
+#define EFI_EXTENDED_SAL_VIRTUAL_SERVICES_PROTOCOL_GUID \
+ { 0xc1a74056, 0x260e, 0x4871, 0xa0, 0x31, 0xe6, 0x45, 0xa6, 0x5b, 0x6e, 0x11 }
+
+#define EFI_EXTENDED_SAL_RTC_SERVICES_PROTOCOL_GUID \
+ { 0x7e97a470, 0xefdb, 0x4d02, 0x8f, 0xce, 0x61, 0x90, 0xd2, 0x7b, 0xa2, 0x96 }
+
+#define EFI_EXTENDED_SAL_VARIABLE_SERVICES_PROTOCOL_GUID \
+ { 0x4ecb6c53, 0xc641, 0x4370, 0x8c, 0xb2, 0x3b, 0x0e, 0x49, 0x6e, 0x83, 0x78 }
+
+#define EFI_EXTENDED_SAL_MTC_SERVICES_PROTOCOL_GUID \
+ { 0x899afd18, 0x75e8, 0x408b, 0xa4, 0x1a, 0x6e, 0x2e, 0x7e, 0xcd, 0xf4, 0x54 }
+
+#define EFI_EXTENDED_SAL_RESET_SERVICES_PROTOCOL_GUID \
+ { 0x7d019990, 0x8ce1, 0x46f5, 0xa7, 0x76, 0x3c, 0x51, 0x98, 0x67, 0x6a, 0xa0 }
+
+#define EFI_EXTENDED_SAL_STATUS_CODE_SERVICES_PROTOCOL_GUID \
+ { 0xdbd91d, 0x55e9, 0x420f, 0x96, 0x39, 0x5e, 0x9f, 0x84, 0x37, 0xb4, 0x4f }
+
+#define EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_PROTOCOL_GUID \
+ { 0xa2271df1, 0xbcbb, 0x4f1d, 0x98, 0xa9, 0x06, 0xbc, 0x17, 0x2f, 0x07, 0x1a }
+
+#define EFI_EXTENDED_SAL_MP_SERVICES_PROTOCOL_GUID \
+ { 0x697d81a2, 0xcf18, 0x4dc0, 0x9e, 0x0d, 0x06, 0x11, 0x3b, 0x61, 0x8a, 0x3f }
+
+#define EFI_EXTENDED_SAL_PAL_SERVICES_PROTOCOL_GUID \
+ { 0xe1cd9d21, 0x0fc2, 0x438d, 0x97, 0x03, 0x04, 0xe6, 0x6d, 0x96, 0x1e, 0x57 }
+
+#define EFI_EXTENDED_SAL_BASE_SERVICES_PROTOCOL_GUID \
+ { 0xd9e9fa06, 0x0fe0, 0x41c3, 0x96, 0xfb, 0x83, 0x42, 0x5a, 0x33, 0x94, 0xf8 }
+
+#define EFI_EXTENDED_SAL_MCA_SERVICES_PROTOCOL_GUID \
+ { 0x2a591128, 0x6cc7, 0x42b1, 0x8a, 0xf0, 0x58, 0x93, 0x3b, 0x68, 0x2d, 0xbb }
+
+#define EFI_EXTENDED_SAL_PCI_SERVICES_PROTOCOL_GUID \
+ { 0xa46b1a31, 0xad66, 0x4905, 0x92, 0xf6, 0x2b, 0x46, 0x59, 0xdc, 0x30, 0x63 }
+
+#define EFI_EXTENDED_SAL_CACHE_SERVICES_PROTOCOL_GUID \
+ { 0xedc9494, 0x2743, 0x4ba5, 0x88, 0x18, 0x0a, 0xef, 0x52, 0x13, 0xf1, 0x88 }
+
+#define EFI_EXTENDED_SAL_MCA_LOG_SERVICES_PROTOCOL_GUID \
+ { 0xcb3fd86e, 0x38a3, 0x4c03, 0x9a, 0x5c, 0x90, 0xcf, 0xa3, 0xa2, 0xab, 0x7a }
+
+#define EFI_EXTENDED_SAL_ELOG_SERVICES_PROTOCOL_GUID \
+ { 0xd5e4ee5f, 0x3e0a, 0x453c, 0xa7, 0x25, 0xb6, 0x92, 0xbb, 0x6, 0x36, 0x5a }
+
+#define EFI_EXTENDED_SAL_SENSOR_SERVICES_PROTOCOL_GUID \
+ { 0x4a153b6e, 0x85a1, 0x4982, 0x98, 0xf4, 0x6a, 0x8c, 0xfc, 0xa4, 0xab, 0xa1 }
+
+#define EFI_EXTENDED_SAL_SM_COM_LAYER_SERVICES_PROTOCOL_GUID \
+ { 0x4356799, 0x81b7, 0x4e08, 0xa3, 0x8d, 0xd9, 0x78, 0xfa, 0x47, 0xba, 0x42 }
+
+#define EFI_EXTENDED_SAL_SST_GUID \
+ { 0x38802700, 0x868a, 0x4b4e, 0x81, 0xd4, 0x4f, 0x1b, 0xdc, 0xcf, 0xb4, 0x6f }
+
+//
+// Extended Sal Proc Function IDs.
+//
+
+//
+// BugBug: These enums are name colisions waiting to happen. They should all be
+// prefixed with Esal! It might be better to just make them #define, so
+// they would be all caps.
+//
+
+typedef enum {
+ IoRead,
+ IoWrite,
+ MemRead,
+ MemWrite
+} EFI_EXTENDED_SAL_BASE_IO_SERVICES_FUNC_ID;
+
+typedef enum {
+ Stall
+} EFI_EXTENDED_SAL_STALL_FUNC_ID;
+
+
+typedef enum {
+ InitializeLockService,
+ AcquireLockService,
+ ReleaseLockService,
+ MaxLockServiceFunctionId
+} EFI_EXTENDED_SAL_LOCK_SERVICES_FUNC_ID;
+
+//
+// BugBug : Covert the first 3 functions into a lib functions
+// and move SalRegisterPhysicalAddress to SAL BASE Class
+//
+typedef enum {
+ SetVirtualAddress,
+ IsVirtual,
+ IsEfiRuntime,
+ SalRegisterPhysicalAddress
+} EFI_EXTENDED_SAL_VIRTUAL_SERVICES_FUNC_ID;
+
+typedef enum {
+ GetTime,
+ SetTime,
+ GetWakeupTime,
+ SetWakeupTime,
+ GetRtcFreq,
+ InitializeThreshold,
+ BumpThresholdCount,
+ GetThresholdCount
+} EFI_EXTENDED_SAL_RTC_SERVICES_FUNC_ID;
+
+typedef enum {
+ EsalGetVariable,
+ EsalGetNextVariableName,
+ EsalSetVariable
+#if (EFI_SPECIFICATION_VERSION >= 0x00020000)
+ ,
+ EsalQueryVariableInfo
+#endif
+} EFI_EXTENDED_SAL_VARIABLE_SERVICES_FUNC_ID;
+
+typedef enum {
+ GetNextHighMonotonicCount
+} EFI_EXTENDED_SAL_MTC_SERVICES_FUNC_ID;
+
+typedef enum {
+ ResetSystem
+} EFI_EXTENDED_SAL_RESET_SERVICES_FUNC_ID;
+
+typedef enum {
+ StatusCode
+} EFI_EXTENDED_SAL_STATUS_CODE_FUNC_ID;
+
+typedef enum {
+ ReportStatusCode
+} EFI_EXTENDED_SAL_STATUS_CODE_SERVICES_FUNC_ID;
+
+typedef enum {
+ Read,
+ Write,
+ EraseBlock,
+ GetVolumeAttributes,
+ SetVolumeAttributes,
+ GetPhysicalAddress,
+ GetBlockSize,
+ EraseCustomBlockRange,
+} EFI_EXTENDED_SAL_FV_BLOCK_SERVICES_FUNC_ID;
+
+typedef enum {
+ AddCpuData,
+ RemoveCpuData,
+ ModifyCpuData,
+ GetCpuDataByID,
+ GetCpuDataByIndex,
+ SendIpi,
+ CurrentProcInfo,
+ NumProcessors,
+ SetMinState,
+ GetMinState
+} EFI_EXTENDED_SAL_MP_SERVICES_FUNC_ID;
+
+typedef enum {
+ PalProc,
+ SetNewPalEntry,
+ GetNewPalEntry
+} EFI_EXTENDED_SAL_PAL_SERVICES_FUNC_ID;
+
+typedef enum {
+ SalSetVectors,
+ SalMcRendez,
+ SalMcSetParams,
+ EsalGetVectors,
+ EsalMcGetParams,
+ EsalMcGetMcParams,
+ EsalGetMcCheckinFlags,
+ EsalGetPlatformBaseFreq
+} EFI_EXTENDED_SAL_BASE_SERVICES_FUNC_ID;
+
+typedef enum {
+ McaGetStateInfo,
+ McaRegisterCpu
+} EFI_EXTENDED_SAL_MCA_SERVICES_FUNC_ID;
+
+typedef enum {
+ SalPciConfigRead,
+ SalPciConfigWrite
+} EFI_EXTENDED_SAL_PCI_SERVICES_FUNC_ID;
+
+typedef enum {
+ SalCacheInit,
+ SalCacheFlush
+} EFI_EXTENDED_SAL_CACHE_SERVICES_FUNC_ID;
+
+typedef enum {
+ SalGetStateInfo,
+ SalGetStateInfoSize,
+ SalClearStateInfo,
+ EsalGetStateBuffer,
+ EsalSaveStateBuffer
+} EFI_EXTENDED_SAL_MCA_LOG_SERVICES_FUNC_ID;
+
+typedef enum {
+ SalSetEventLogData,
+ SalGetEventLogData,
+ SalEraseEventLogData,
+ SalActivateEventLogData
+} EFI_EXTENDED_SAL_ELOG_SERVICES_FUNC_ID;
+
+typedef enum {
+ EsalGetComControllerInfo,
+ EsalSendComData,
+ EsalReceiveComData
+} EFI_EXTENDED_SAL_SM_COM_LAYER_SERVICES_FUNC_ID;
+
+typedef enum {
+ SalUpdatePal
+} EFI_EXTENDED_SAL_UPDATE_PAL_SERVICES_FUNC_ID;
+
+typedef enum {
+ EsalReadSensorInfo,
+ EsalReadSensorStatus,
+ EsalRearmSensor,
+ EsalReadSensorData
+} EFI_EXTENDED_SAL_SENSOR_SERVICES_FUNC_ID;
+
+typedef struct {
+ UINT64 ProtoData;
+} ESAL_GUID_DUMMY_PROTOCOL;
+
+extern EFI_GUID gEfiExtendedSalBaseIoServicesProtocolGuid;
+extern EFI_GUID gEfiExtendedSalStallServicesProtocolGuid;
+extern EFI_GUID gEfiExtendedSalLockServicesProtocolGuid;
+extern EFI_GUID gEfiExtendedSalVirtualServicesProtocolGuid;
+extern EFI_GUID gEfiExtendedSalRtcServicesProtocolGuid;
+extern EFI_GUID gEfiExtendedSalVariableServicesProtocolGuid;
+extern EFI_GUID gEfiExtendedSalMtcServicesProtocolGuid;
+extern EFI_GUID gEfiExtendedSalResetServicesProtocolGuid;
+extern EFI_GUID gEfiExtendedSalStatusCodeServicesProtocolGuid;
+extern EFI_GUID gEfiExtendedSalFvBlockServicesProtocolGuid;
+extern EFI_GUID gEfiExtendedSalMpServicesProtocolGuid;
+extern EFI_GUID gEfiExtendedSalPalServicesProtocolGuid;
+extern EFI_GUID gEfiExtendedSalBaseServicesProtocolGuid;
+extern EFI_GUID gEfiExtendedSalMcaServicesProtocolGuid;
+extern EFI_GUID gEfiExtendedSalPciServicesProtocolGuid;
+extern EFI_GUID gEfiExtendedSalCacheServicesProtocolGuid;
+extern EFI_GUID gEfiExtendedSalMcaLogServicesProtocolGuid;
+extern EFI_GUID gEfiExtendedSalElogServicesProtocolGuid;
+extern EFI_GUID gEfiExtendedSalSensorServicesProtocolGuid;
+extern EFI_GUID gEfiExtendedSalSmComLayerServicesProtocolGuid;
+extern EFI_GUID gEfiExtendedSalSstGuid;
+
+
+#endif
diff --git a/EDK/Foundation/Protocol/FastBootException/FastBootException.c b/EDK/Foundation/Protocol/FastBootException/FastBootException.c
new file mode 100644
index 0000000..5c6bea1
--- /dev/null
+++ b/EDK/Foundation/Protocol/FastBootException/FastBootException.c
@@ -0,0 +1,27 @@
+/*++
+
+Copyright (c) 1999 - 2011 Intel Corporation. All rights reserved
+This software and associated documentation (if any) is furnished
+under a license and may only be used or copied in accordance
+with the terms of the license. Except as permitted by such
+license, no part of this software or documentation may be
+reproduced, stored in a retrieval system, or transmitted in any
+form or by any means without the express written consent of
+Intel Corporation.
+
+Module Name:
+
+ FastBootException.c
+
+Abstract:
+
+
+--*/
+
+#include "Tiano.h"
+
+#include EFI_PROTOCOL_DEFINITION(FastBootException)
+
+EFI_GUID gFastBootExceptionProtocolGuid = FAST_BOOT_EXCEPTION_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gFastBootExceptionProtocolGuid, "FastBootException", "Fast Boot Exception Protocol");
diff --git a/EDK/Foundation/Protocol/FastBootException/FastBootException.h b/EDK/Foundation/Protocol/FastBootException/FastBootException.h
new file mode 100644
index 0000000..4019ceb
--- /dev/null
+++ b/EDK/Foundation/Protocol/FastBootException/FastBootException.h
@@ -0,0 +1,41 @@
+/*++
+
+Copyright (c) 1999 - 2011 Intel Corporation. All rights reserved
+This software and associated documentation (if any) is furnished
+under a license and may only be used or copied in accordance
+with the terms of the license. Except as permitted by such
+license, no part of this software or documentation may be
+reproduced, stored in a retrieval system, or transmitted in any
+form or by any means without the express written consent of
+Intel Corporation.
+
+
+Module Name:
+
+ FastBootException.h
+
+Abstract:
+
+ This file defines Fast Boot Exception abstraction protocol containing the
+ exception type and category, which is the indication of an exception occurrence.
+
+--*/
+
+#ifndef _FAST_BOOT_EXCEPTION_H_
+#define _FAST_BOOT_EXCEPTION_H_
+
+#include <FastBootDataDef.h>
+
+#define FAST_BOOT_EXCEPTION_PROTOCOL_GUID \
+ {0x3da3f62e, 0x291e, 0x4224, 0x80, 0x5f, 0x2d, 0x5e, 0xb6, 0xb2, 0x9c, 0xe2}
+
+EFI_FORWARD_DECLARATION (FAST_BOOT_EXCEPTION_PROTOCOL);
+
+typedef struct _FAST_BOOT_EXCEPTION_PROTOCOL {
+ FAST_BOOT_EXCEPTION_TYPE FbExceptionType;
+ FAST_BOOT_EXCEPTION_CATEGORY FbExceptionCategory;
+} FAST_BOOT_EXCEPTION_PROTOCOL;
+
+extern EFI_GUID gFastBootExceptionProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Protocol/FaultTolerantWriteLite/FaultTolerantWriteLite.c b/EDK/Foundation/Protocol/FaultTolerantWriteLite/FaultTolerantWriteLite.c
new file mode 100644
index 0000000..78892ff
--- /dev/null
+++ b/EDK/Foundation/Protocol/FaultTolerantWriteLite/FaultTolerantWriteLite.c
@@ -0,0 +1,29 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ FaultTolerantWriteLite.c
+
+Abstract:
+
+ This is a simple fault tolerant write driver, based on PlatformFd library.
+ And it only supports write BufferSize <= SpareAreaLength.
+
+--*/
+
+#include "Tiano.h"
+#include EFI_PROTOCOL_DEFINITION(FaultTolerantWriteLite)
+
+EFI_GUID gEfiFaultTolerantWriteLiteProtocolGuid = EFI_FTW_LITE_PROTOCOL_GUID;
+
+EFI_GUID_STRING (&gEfiFaultTolerantWriteLiteProtocolGuid, "FaultTolerantWriteLite Protocol",
+ "Fault Tolerant Write Lite protocol");
diff --git a/EDK/Foundation/Protocol/FaultTolerantWriteLite/FaultTolerantWriteLite.h b/EDK/Foundation/Protocol/FaultTolerantWriteLite/FaultTolerantWriteLite.h
new file mode 100644
index 0000000..90cdf34
--- /dev/null
+++ b/EDK/Foundation/Protocol/FaultTolerantWriteLite/FaultTolerantWriteLite.h
@@ -0,0 +1,88 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ FaultTolerantWriteLite.h
+
+Abstract:
+
+ This is a simple fault tolerant write driver, based on PlatformFd library.
+ And it only supports write BufferSize <= SpareAreaLength.
+
+--*/
+
+#ifndef _FW_FAULT_TOLERANT_WRITE_LITE_PROTOCOL_H_
+#define _FW_FAULT_TOLERANT_WRITE_LITE_PROTOCOL_H_
+
+#define EFI_FTW_LITE_PROTOCOL_GUID \
+{ 0x3f557189, 0x8dae, 0x45ae, 0xa0, 0xb3, 0x2b, 0x99, 0xca, 0x7a, 0xa7, 0xa0 }
+
+//
+// Forward reference for pure ANSI compatability
+//
+EFI_FORWARD_DECLARATION (EFI_FTW_LITE_PROTOCOL);
+
+//
+// Protocol API definitions
+//
+
+typedef
+EFI_STATUS
+(EFIAPI * EFI_FTW_LITE_WRITE) (
+ IN EFI_FTW_LITE_PROTOCOL *This,
+ IN EFI_HANDLE FvbHandle,
+ IN EFI_LBA Lba,
+ IN UINTN Offset,
+ IN UINTN *NumBytes,
+ IN VOID *Buffer
+ );
+/*++
+
+Routine Description:
+
+ Starts a target block update. This records information about the write
+ in fault tolerant storage and will complete the write in a recoverable
+ manner, ensuring at all times that either the original contents or
+ the modified contents are available.
+
+Arguments:
+
+ This - Calling context
+ FvBlockHandle - The handle of FVB protocol that provides services for
+ reading, writing, and erasing the target block.
+ Lba - The logical block address of the target block.
+ Offset - The offset within the target block to place the data.
+ Length - The number of bytes to write to the target block.
+ Buffer - The data to write.
+
+Returns:
+
+ EFI_SUCCESS - The function completed successfully
+ EFI_ABORTED - The function could not complete successfully.
+ EFI_BAD_BUFFER_SIZE - The write would span a block boundary,
+ which is not a valid action.
+ EFI_ACCESS_DENIED - No writes have been allocated.
+ EFI_NOT_READY - The last write has not been completed.
+ Restart () must be called to complete it.
+
+--*/
+
+//
+// Protocol declaration
+//
+typedef struct _EFI_FTW_LITE_PROTOCOL {
+ EFI_FTW_LITE_WRITE Write;
+} EFI_FTW_LITE_PROTOCOL;
+
+extern EFI_GUID gEfiFaultTolerantWriteLiteProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Protocol/FirmwarePerformance/FirmwarePerformance.c b/EDK/Foundation/Protocol/FirmwarePerformance/FirmwarePerformance.c
new file mode 100644
index 0000000..aeec629
--- /dev/null
+++ b/EDK/Foundation/Protocol/FirmwarePerformance/FirmwarePerformance.c
@@ -0,0 +1,27 @@
+/*++
+
+Copyright (c) 2011, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ FirmwarePerformance.c
+
+Abstract:
+
+ Firmware Performance Protocol
+
+--*/
+
+#include "Tiano.h"
+#include EFI_PROTOCOL_DEFINITION (FirmwarePerformance)
+
+EFI_GUID gFirmwarePerformanceProtocolGuid = FIRMWARE_PERFORMANCE_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gFirmwarePerformanceProtocolGuid, "Firmware Performance Protocol", "Firmware Performance Protocol");
diff --git a/EDK/Foundation/Protocol/FirmwarePerformance/FirmwarePerformance.h b/EDK/Foundation/Protocol/FirmwarePerformance/FirmwarePerformance.h
new file mode 100644
index 0000000..cc6589e
--- /dev/null
+++ b/EDK/Foundation/Protocol/FirmwarePerformance/FirmwarePerformance.h
@@ -0,0 +1,213 @@
+/*++
+
+Copyright (c) 2011 - 2012, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ FirmwarePerformance.h
+
+Abstract:
+
+ Firmware Performance Protocol
+
+--*/
+
+#ifndef _FIRMWARE_PERFORMANCE_H_
+#define _FIRMWARE_PERFORMANCE_H_
+
+#define FIRMWARE_PERFORMANCE_PROTOCOL_GUID \
+ { \
+ 0xbc412d75, 0x2729, 0x4c3a, 0xb1, 0x93, 0x5b, 0x9a, 0x58, 0x8f, 0xf6, 0x6f \
+ }
+
+#define EFI_NULL_GUID \
+ { \
+ 0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 \
+ }
+
+EFI_FORWARD_DECLARATION (FIRMWARE_PERFORMANCE_PROTOCOL);
+
+//
+// FPDT Record types
+//
+typedef enum {
+ BASIC_BOOT_PTR_TYPE = 0x0000,
+ S3_TABLE_PTR_TYPE,
+ BOOT_MODULE_TABLE_PTR_TYPE = 0x1002,
+ RUNTIME_MODULE_TABLE_PTR_TYPE,
+ TIMESTAMP_DELTA_TYPE,
+ HARDWARE_BOOT_TYPE,
+ GUID_EVENT_REC_TYPE = 0x1010,
+ STRING_EVENT_REC_TYPE,
+ BDS_ATTEMPT_EVENT_REC_TYPE,
+ PERFORMANCE_RECORD_TYPE_MAX
+} PERFORMANCE_RECORD_TYPE;
+
+//
+// Progress Identifiers for Event Records
+//
+typedef enum {
+ MODULE_START_ID = 1,
+ MODULE_END_ID,
+ MODULE_LOADIMAGE_START_ID,
+ MODULE_LOADIMAGE_END_ID,
+ MODULE_DRIVERBINDING_START_ID,
+ MODULE_DRIVERBINDING_END_ID
+} EVENT_RECORD_PROGRESS_ID;
+
+//
+// Performance tokens
+//
+#define PEI_TOK L"PEI"
+#define DXE_TOK L"DXE"
+#define BDS_TOK L"BDS"
+#define START_IMAGE_TOK L"StartImage"
+#define LOAD_IMAGE_TOK L"LoadImage"
+#define DRIVERBINDING_START_TOK L"DriverBinding:Start"
+#define DRIVERBINDING_SUPPORT_TOK L"DriverBinding:Support"
+#define BASIC_BOOT_TOK L"BasicBoot"
+#define HARDWARE_BOOT_TOK L"HardwareBoot"
+#define EVENT_REC_TOK L"EventRec"
+#define BDS_ATTEMPT_TOK L"BdsAttempt"
+#define DXE_CORE_DISP_INIT_TOK L"CoreInitializeDispatcher"
+#define COREDISPATCHER_TOK L"CoreDispatcher"
+#define SMM_MODULE_TOK L"SmmModule"
+#define SMM_FUNCTION_TOK L"SmmFunction"
+
+#define FIRMWARE_MAX_BUFFER 0x16800 // pre-defined buffer size of 90K to accomodate all FPDT records
+#define RECORD_REVISION_1 0x1
+#define RECORD_REVISION_2 0x2
+#define STRING_EVENT_RECORD_NAME_LENGTH 24
+#define RMPT_SIG EFI_SIGNATURE_32 ('R', 'M', 'P', 'T')
+#define RUNTIME_MODULE_TABLE_PTR_TYPE 0x1003
+#define RUNTIME_MODULE_REC_TYPE 0x1020
+#define RUNTIME_FUNCTION_REC_TYPE 0x1021
+#define DXE_START_ID 0x7000
+#define DXE_END_ID 0x7001
+#define DXE_CORE_DISP_START_ID 0x7010
+#define DXE_CORE_DISP_END_ID 0x7011
+#define COREDISPATCHER_START_ID 0x7020
+#define COREDISPATCHER_END_ID 0x7021
+//
+// Fpdt record table structures
+//
+#pragma pack(push, 1)
+typedef struct _BASIC_BOOT_REC {
+ UINT16 RecType;
+ UINT8 RecLength;
+ UINT8 Revision;
+ UINT32 Reserved;
+ UINT64 ResetEnd;
+ UINT64 BootLoaderLoadImage;
+ UINT64 BootLoaderStartImage;
+ UINT64 ExitBootServiceEntry;
+ UINT64 ExitBootServiceExit;
+} BASIC_BOOT_REC;
+
+typedef struct _HARDWARE_BOOT_REC {
+ UINT16 RecType;
+ UINT8 RecLength;
+ UINT8 Revision;
+ UINT64 HardwareBoot;
+} HARDWARE_BOOT_REC;
+
+typedef struct _STRING_EVENT_REC {
+ UINT16 RecType;
+ UINT8 RecLength;
+ UINT8 Revision;
+ UINT16 ProgressID;
+ UINT32 ApicID;
+ UINT64 Timestamp;
+ EFI_GUID Guid;
+ UINT8 NameString[STRING_EVENT_RECORD_NAME_LENGTH];
+} STRING_EVENT_REC;
+
+typedef struct _GUID_EVENT_REC {
+ UINT16 RecType;
+ UINT8 RecLength;
+ UINT8 Revision;
+ UINT16 ProgressID;
+ UINT32 ApicID;
+ UINT64 Timestamp;
+ EFI_GUID Guid;
+} GUID_EVENT_REC;
+
+typedef struct _BDS_ATTEMPT_REC {
+ UINT16 RecType;
+ UINT8 RecLength;
+ UINT8 Revision;
+ UINT32 ApicID;
+ UINT16 BdsAttemptNo;
+ UINT64 Timestamp;
+ UINT64 UEFIBootVar;
+ CHAR16 DevicePathString;
+} BDS_ATTEMPT_REC;
+
+typedef struct _RUNTIME_PERF_TABLE_HEADER {
+ UINT32 Signature;
+ UINT32 Length;
+ EFI_GUID Guid;
+} RUNTIME_PERF_TABLE_HEADER;
+
+typedef struct _RUNTIME_MODULE_PERF_RECORD {
+ UINT16 RuntimeRecType;
+ UINT8 Reclength;
+ UINT8 Revision;
+ UINT32 ModuleCallCount;
+ UINT64 ModuleResidency;
+} RUNTIME_MODULE_PERF_RECORD;
+
+typedef struct _RUNTIME_FUNCTION_PERF_RECORD {
+ UINT16 RuntimeRecType;
+ UINT8 Reclength;
+ UINT8 Revision;
+ UINT32 Reserved;
+ UINT32 FunctionId;
+ UINT32 FunctionCallCount;
+ UINT64 FunctionResidency;
+} RUNTIME_FUNCTION_PERF_RECORD;
+
+#pragma pack(pop)
+//
+// Firmware Performance Protocol definition
+//
+typedef
+EFI_STATUS
+(EFIAPI *FIRMWARE_PERFORMANCE_PROTOCOL_INSERT_MEASUREMENT) (
+ IN FIRMWARE_PERFORMANCE_PROTOCOL *This,
+ IN EFI_HANDLE Handle,
+ IN UINT16 RecordType,
+ IN UINT64 Ticker,
+ IN UINT16 Identifier OPTIONAL
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *FIRMWARE_PERFORMANCE_PROTOCOL_GET_PERFBUFFER_ADDR) (
+ IN FIRMWARE_PERFORMANCE_PROTOCOL *This,
+ OUT UINT32 *PerformanceBuffer
+ );
+
+typedef
+UINT32
+(EFIAPI *FIRMWARE_PERFORMANCE_PROTOCOL_GET_PERFBUFFER_LEN) (
+ IN FIRMWARE_PERFORMANCE_PROTOCOL *This
+ );
+
+
+typedef struct _FIRMWARE_PERFORMANCE_PROTOCOL {
+ FIRMWARE_PERFORMANCE_PROTOCOL_INSERT_MEASUREMENT InsertMeasurement;
+ FIRMWARE_PERFORMANCE_PROTOCOL_GET_PERFBUFFER_ADDR GetPerfBufferAddr;
+ FIRMWARE_PERFORMANCE_PROTOCOL_GET_PERFBUFFER_LEN GetPerfBufferLength;
+} FIRMWARE_PERFORMANCE_PROTOCOL;
+
+extern EFI_GUID gFirmwarePerformanceProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Protocol/FirmwareVolumeDispatch/FirmwareVolumeDispatch.c b/EDK/Foundation/Protocol/FirmwareVolumeDispatch/FirmwareVolumeDispatch.c
new file mode 100644
index 0000000..04faa1c
--- /dev/null
+++ b/EDK/Foundation/Protocol/FirmwareVolumeDispatch/FirmwareVolumeDispatch.c
@@ -0,0 +1,32 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ FirmwareVolumeDispatch.c
+
+Abstract:
+
+ Firmware Volume Dispatch protocol as defined in the Tiano Firmware Volume
+ specification.
+
+ Presence of this protocol tells the dispatch to dispatch from this Firmware
+ Volume
+
+--*/
+
+#include "Tiano.h"
+#include EFI_PROTOCOL_DEFINITION (FirmwareVolumeDispatch)
+
+EFI_GUID gEfiFirmwareVolumeDispatchProtocolGuid = EFI_FIRMWARE_VOLUME_DISPATCH_PROTOCOL_GUID;
+
+EFI_GUID_STRING (&gEfiFirmwareVolumeDispatchProtocolGuid, "FirmwareVolumeDispatch Protocol",
+ "Firmware Volume Dispatch protocol");
diff --git a/EDK/Foundation/Protocol/FirmwareVolumeDispatch/FirmwareVolumeDispatch.h b/EDK/Foundation/Protocol/FirmwareVolumeDispatch/FirmwareVolumeDispatch.h
new file mode 100644
index 0000000..0ec478d
--- /dev/null
+++ b/EDK/Foundation/Protocol/FirmwareVolumeDispatch/FirmwareVolumeDispatch.h
@@ -0,0 +1,35 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ FirmwareVolumeDispatch.h
+
+Abstract:
+
+ Firmware Volume Dispatch protocol as defined in the Tiano Firmware Volume
+ specification.
+
+ Presence of this protocol tells the dispatch to dispatch from this Firmware
+ Volume
+
+--*/
+
+#ifndef __FIRMWARE_VOLUME_DISPATCH_H__
+#define __FIRMWARE_VOLUME_DISPATCH_H__
+
+#define EFI_FIRMWARE_VOLUME_DISPATCH_PROTOCOL_GUID \
+ { 0x7aa35a69, 0x506c, 0x444f, 0xa7, 0xaf, 0x69, 0x4b, 0xf5, 0x6f, 0x71, 0xc8 }
+
+
+extern EFI_GUID gEfiFirmwareVolumeDispatchProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Protocol/Fpdt/Fpdt.c b/EDK/Foundation/Protocol/Fpdt/Fpdt.c
new file mode 100644
index 0000000..6d4e28d
--- /dev/null
+++ b/EDK/Foundation/Protocol/Fpdt/Fpdt.c
@@ -0,0 +1,31 @@
+/*++
+ This file contains a 'Sample Driver' and is licensed as such
+ under the terms of your license agreement with Intel or your
+ vendor. This file may be modified by the user, subject to
+/*++
+
+Copyright (c) 2011, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Fpdt.c
+
+Abstract:
+
+ Fpdt Performance Protocol
+
+--*/
+
+#include "Tiano.h"
+#include EFI_PROTOCOL_DEFINITION (Fpdt)
+
+EFI_GUID gFpdtPerformanceProtocolGuid = FPDT_PERFORMANCE_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gFpdtPerformanceProtocolGuid, "FPDT Performance Protocol", "FPDT Performance Protocol");
diff --git a/EDK/Foundation/Protocol/Fpdt/Fpdt.h b/EDK/Foundation/Protocol/Fpdt/Fpdt.h
new file mode 100644
index 0000000..db243c1
--- /dev/null
+++ b/EDK/Foundation/Protocol/Fpdt/Fpdt.h
@@ -0,0 +1,56 @@
+/*++
+
+Copyright (c) 2011, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Fpdt.h
+
+Abstract:
+
+ Fpdt Performance Protocol
+
+--*/
+
+#ifndef _FPDT_H
+#define _FPDT_H
+
+#define FPDT_PERFORMANCE_PROTOCOL_GUID \
+ { \
+ 0x444c3203, 0xf8b1, 0x42a7, 0xab, 0xe9, 0x2e, 0x58, 0x2, 0x5b, 0xe1, 0x2a \
+ }
+
+EFI_FORWARD_DECLARATION (FPDT_PERFORMANCE_PROTOCOL);
+
+typedef
+EFI_STATUS
+(EFIAPI *FPDT_PERFORMANCE_PROTOCOL_GET_FPDT_ADDRESS) (
+ IN FPDT_PERFORMANCE_PROTOCOL *This,
+ OUT UINT32 *FpdtAddress
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *FPDT_PERFORMANCE_PROTOCOL_UPDATE_RECORD) (
+ IN FPDT_PERFORMANCE_PROTOCOL *This,
+ IN EFI_HANDLE Handle OPTIONAL,
+ IN UINT16 Recordtype,
+ IN UINT64 Data,
+ IN UINT16 Identifier OPTIONAL
+ );
+
+typedef struct _FPDT_PERFORMANCE_PROTOCOL {
+ FPDT_PERFORMANCE_PROTOCOL_GET_FPDT_ADDRESS GetFpdtAddress;
+ FPDT_PERFORMANCE_PROTOCOL_UPDATE_RECORD UpdateRecord;
+} FPDT_PERFORMANCE_PROTOCOL;
+
+extern EFI_GUID gFpdtPerformanceProtocolGuid;
+
+#endif \ No newline at end of file
diff --git a/EDK/Foundation/Protocol/FvbExtension/FvbExtension.c b/EDK/Foundation/Protocol/FvbExtension/FvbExtension.c
new file mode 100644
index 0000000..6bc312c
--- /dev/null
+++ b/EDK/Foundation/Protocol/FvbExtension/FvbExtension.c
@@ -0,0 +1,29 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ FvbExtension.c
+
+Abstract:
+
+ IPMI Extension Protocol to extend the FVB functionality to multiple erase blocks
+ at different block offsets.
+
+
+--*/
+
+#include "Tiano.h"
+#include EFI_PROTOCOL_DEFINITION(FvbExtension)
+
+EFI_GUID gEfiFvbExtensionProtocolGuid = EFI_FVB_EXTENSION_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiFvbExtensionProtocolGuid, "FVB EXTENSION", "FVB EXTENSION");
diff --git a/EDK/Foundation/Protocol/FvbExtension/FvbExtension.h b/EDK/Foundation/Protocol/FvbExtension/FvbExtension.h
new file mode 100644
index 0000000..90dac56
--- /dev/null
+++ b/EDK/Foundation/Protocol/FvbExtension/FvbExtension.h
@@ -0,0 +1,53 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ FvbExtension.h
+
+Abstract:
+
+ FVB Extension protocol that extends the FVB Class in a component fashion.
+
+--*/
+
+#ifndef _FVB_EXTENSION_H_
+#define _FVB_EXTENSION_H_
+
+#define EFI_FVB_EXTENSION_PROTOCOL_GUID \
+ {0x53a4c71b, 0xb581, 0x4170, 0x91, 0xb3, 0x8d, 0xb8, 0x7a, 0x4b, 0x5c, 0x46 }
+
+EFI_FORWARD_DECLARATION (EFI_FVB_EXTENSION_PROTOCOL);
+
+//
+// FVB Extension Function Prototypes
+//
+typedef
+EFI_STATUS
+(EFIAPI * EFI_FV_ERASE_CUSTOM_BLOCK) (
+ IN EFI_FVB_EXTENSION_PROTOCOL *This,
+ IN EFI_LBA StartLba,
+ IN UINTN OffsetStartLba,
+ IN EFI_LBA LastLba,
+ IN UINTN OffsetLastLba
+);
+
+//
+// IPMI TRANSPORT PROTOCOL
+//
+typedef struct _EFI_FVB_EXTENSION_PROTOCOL {
+ EFI_FV_ERASE_CUSTOM_BLOCK EraseFvbCustomBlock;
+ } EFI_FVB_EXTENSION_PROTOCOL;
+
+extern EFI_GUID gEfiFvbExtensionProtocolGuid;
+
+#endif
+
diff --git a/EDK/Foundation/Protocol/GenericMemoryTest/GenericMemoryTest.c b/EDK/Foundation/Protocol/GenericMemoryTest/GenericMemoryTest.c
new file mode 100644
index 0000000..a80d5f5
--- /dev/null
+++ b/EDK/Foundation/Protocol/GenericMemoryTest/GenericMemoryTest.c
@@ -0,0 +1,29 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ GenericMemoryTest.c
+
+Abstract:
+
+ The generic memory test protocol is used to test EFI memory.
+
+ For more information please look at EfiMemoryTest.doc
+
+--*/
+
+#include "Tiano.h"
+#include EFI_PROTOCOL_DEFINITION (GenericMemoryTest)
+
+EFI_GUID gEfiGenericMemTestProtocolGuid = EFI_GENERIC_MEMORY_TEST_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiGenericMemTestProtocolGuid, "GenericMemoryTest Protocol", "Tiano Generic Memory Test Protocol");
diff --git a/EDK/Foundation/Protocol/GenericMemoryTest/GenericMemoryTest.h b/EDK/Foundation/Protocol/GenericMemoryTest/GenericMemoryTest.h
new file mode 100644
index 0000000..5638616
--- /dev/null
+++ b/EDK/Foundation/Protocol/GenericMemoryTest/GenericMemoryTest.h
@@ -0,0 +1,154 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ GenericMemoryTest.h
+
+Abstract:
+
+ The EFI generic memory test protocol
+ For more information please look at EfiMemoryTest.doc
+
+--*/
+
+#ifndef __GENERIC_MEMORY_TEST_H__
+#define __GENERIC_MEMORY_TEST_H__
+
+#define EFI_GENERIC_MEMORY_TEST_PROTOCOL_GUID \
+ { 0x309de7f1, 0x7f5e, 0x4ace, 0xb4, 0x9c, 0x53, 0x1b, 0xe5, 0xaa, 0x95, 0xef}
+
+EFI_FORWARD_DECLARATION (EFI_GENERIC_MEMORY_TEST_PROTOCOL);
+
+typedef enum {
+ IGNORE,
+ QUICK,
+ SPARSE,
+ EXTENSIVE,
+ MAXLEVEL
+} EXTENDMEM_COVERAGE_LEVEL;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_MEMORY_TEST_INIT) (
+ IN EFI_GENERIC_MEMORY_TEST_PROTOCOL *This,
+ IN EXTENDMEM_COVERAGE_LEVEL Level,
+ OUT BOOLEAN *RequireSoftECCInit
+ )
+/*++
+
+ Routine Description:
+ Initialize the generic memory test.
+
+ Arguments:
+ This - Protocol instance pointer.
+ Level - The coverage level of the memory test.
+ RequireSoftECCInit - Indicate if the memory need software ECC init.
+
+ Returns:
+ EFI_SUCCESS - The generic memory test initialized correctly.
+ EFI_NO_MEDIA - There is not any non-tested memory found, in this
+ function if not any non-tesed memory found means
+ that the memory test driver have not detect any
+ non-tested extended memory of current system.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PERFORM_MEMORY_TEST) (
+ IN EFI_GENERIC_MEMORY_TEST_PROTOCOL *This,
+ OUT UINT64 *TestedMemorySize,
+ OUT UINT64 *TotalMemorySize,
+ OUT BOOLEAN *ErrorOut,
+ IN BOOLEAN IfTestAbort
+ )
+/*++
+
+ Routine Description:
+ Perform the memory test.
+
+ Arguments:
+ This - Protocol instance pointer.
+ TestedMemorySize - Return the tested extended memory size.
+ TotalMemorySize - Return the whole system physical memory size, this
+ value may be changed if in some case some error
+ DIMMs be disabled.
+ ErrorOut - Any time the memory error occurs, this will be TRUE.
+ IfTestAbort - Indicate if the user press "ESC" to skip the memory
+ test.
+
+ Returns:
+ EFI_SUCCESS - One block of memory test ok, the block size is hide
+ internally.
+ EFI_NOT_FOUND - Indicate all the non-tested memory blocks have
+ already go through.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_MEMORY_TEST_FINISHED) (
+ IN EFI_GENERIC_MEMORY_TEST_PROTOCOL *This
+ )
+/*++
+
+ Routine Description:
+ The memory test finished.
+
+ Arguments:
+ This - Protocol instance pointer.
+
+ Returns:
+ EFI_SUCCESS - Successful free all the generic memory test driver
+ allocated resource and notify to platform memory
+ test driver that memory test finished.
+
+--*/
+;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_MEMORY_TEST_COMPATIBLE_RANGE) (
+ IN EFI_GENERIC_MEMORY_TEST_PROTOCOL *This,
+ IN EFI_PHYSICAL_ADDRESS StartAddress,
+ IN UINT64 Length
+ )
+/*++
+
+ Routine Description:
+ Provide capability to test compatible range which used by some sepcial
+ driver required using memory range before BDS perform memory test.
+
+ Arguments:
+ This - Protocol instance pointer.
+ StartAddress - The start address of the memory range.
+ Length - The memory range's length.
+
+ Return:
+ EFI_SUCCESS - The compatible memory range pass the memory test.
+ EFI_DEVICE_ERROR - The compatible memory range test find memory error
+ and also return return the error address.
+
+--*/
+;
+
+typedef struct _EFI_GENERIC_MEMORY_TEST_PROTOCOL {
+ EFI_MEMORY_TEST_INIT MemoryTestInit;
+ EFI_PERFORM_MEMORY_TEST PerformMemoryTest;
+ EFI_MEMORY_TEST_FINISHED Finished;
+ EFI_MEMORY_TEST_COMPATIBLE_RANGE CompatibleRangeTest;
+} EFI_GENERIC_MEMORY_TEST_PROTOCOL;
+
+extern EFI_GUID gEfiGenericMemTestProtocolGuid;
+#endif \ No newline at end of file
diff --git a/EDK/Foundation/Protocol/GuidedSectionExtraction/GuidedSectionExtraction.c b/EDK/Foundation/Protocol/GuidedSectionExtraction/GuidedSectionExtraction.c
new file mode 100644
index 0000000..b56508e
--- /dev/null
+++ b/EDK/Foundation/Protocol/GuidedSectionExtraction/GuidedSectionExtraction.c
@@ -0,0 +1,35 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ GuidedSectionExtraction.c
+
+Abstract:
+
+ GUIDed section extraction protocol as defined in the Tiano File Image
+ Format specification.
+
+--*/
+
+#include "Tiano.h"
+#include EFI_PROTOCOL_DEFINITION (GuidedSectionExtraction)
+
+//
+// may add more GUIDed section extraction protocol GUID here.
+//
+EFI_GUID gEfiCrc32GuidedSectionExtractionProtocolGuid = EFI_CRC32_GUIDED_SECTION_EXTRACTION_PROTOCOL_GUID;
+
+EFI_GUID_STRING
+ (
+ &gEfiSectionExtractionProtocolGuid, "CRC32 GUIDed Section Extraction Protocol",
+ "Tiano CRC32 GUIDed Section Extraction Protocol"
+ );
diff --git a/EDK/Foundation/Protocol/GuidedSectionExtraction/GuidedSectionExtraction.h b/EDK/Foundation/Protocol/GuidedSectionExtraction/GuidedSectionExtraction.h
new file mode 100644
index 0000000..2107761
--- /dev/null
+++ b/EDK/Foundation/Protocol/GuidedSectionExtraction/GuidedSectionExtraction.h
@@ -0,0 +1,73 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ GuidedSectionExtraction.h
+
+Abstract:
+
+ GUIDed section extraction protocol as defined in the Tiano File
+ Image Format specification.
+
+ This interface provides a means of decoding a GUID defined encapsulation
+ section. There may be multiple different GUIDs associated with the GUIDed
+ section extraction protocol. That is, all instances of the GUIDed section
+ extraction protocol must have the same interface structure.
+
+--*/
+
+#ifndef _GUIDED_SECTION_EXTRACTION_PROTOCOL_H
+#define _GUIDED_SECTION_EXTRACTION_PROTOCOL_H
+
+#include "EfiFirmwareFileSystem.h"
+
+//
+// Protocol GUID definition. Each GUIDed section extraction protocol has the
+// same interface but with different GUID. All the GUIDs is defined here.
+// May add multiple GUIDs here.
+//
+#define EFI_CRC32_GUIDED_SECTION_EXTRACTION_PROTOCOL_GUID \
+ { \
+ 0xFC1BCDB0, 0x7D31, 0x49aa, 0x93, 0x6A, 0xA4, 0x60, 0x0D, 0x9D, 0xD0, 0x83 \
+ }
+
+//
+// Forward reference for pure ANSI compatability
+//
+EFI_FORWARD_DECLARATION (EFI_GUIDED_SECTION_EXTRACTION_PROTOCOL);
+
+//
+// Protocol member functions
+//
+typedef
+EFI_STATUS
+(EFIAPI *EFI_EXTRACT_GUIDED_SECTION) (
+ IN EFI_GUIDED_SECTION_EXTRACTION_PROTOCOL * This,
+ IN VOID *InputSection,
+ OUT VOID **OutputBuffer,
+ OUT UINTN *OutputSize,
+ OUT UINT32 *AuthenticationStatus
+ );
+
+//
+// Protocol definition
+//
+typedef struct _EFI_GUIDED_SECTION_EXTRACTION_PROTOCOL {
+ EFI_EXTRACT_GUIDED_SECTION ExtractSection;
+} EFI_GUIDED_SECTION_EXTRACTION_PROTOCOL;
+
+//
+// may add other GUID here
+//
+extern EFI_GUID gEfiCrc32GuidedSectionExtractionProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Protocol/IsaAcpi/IsaAcpi.c b/EDK/Foundation/Protocol/IsaAcpi/IsaAcpi.c
new file mode 100644
index 0000000..21e7f39
--- /dev/null
+++ b/EDK/Foundation/Protocol/IsaAcpi/IsaAcpi.c
@@ -0,0 +1,30 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ IsaAcpi.c
+
+Abstract:
+
+ EFI ISA ACPI Protocol
+
+Revision History
+
+--*/
+
+#include "Tiano.h"
+
+#include EFI_PROTOCOL_DEFINITION (IsaAcpi)
+
+EFI_GUID gEfiIsaAcpiProtocolGuid = EFI_ISA_ACPI_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiIsaAcpiProtocolGuid, "ISA Acpi Protocol", "ISA Acpi Protocol");
diff --git a/EDK/Foundation/Protocol/IsaAcpi/IsaAcpi.h b/EDK/Foundation/Protocol/IsaAcpi/IsaAcpi.h
new file mode 100644
index 0000000..e4a2618
--- /dev/null
+++ b/EDK/Foundation/Protocol/IsaAcpi/IsaAcpi.h
@@ -0,0 +1,177 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ IsaAcpi.h
+
+Abstract:
+
+ EFI ISA Acpi Protocol
+
+Revision History
+
+--*/
+
+#ifndef _ISA_ACPI_H_
+#define _ISA_ACPI_H_
+
+#define EFI_ISA_ACPI_PROTOCOL_GUID \
+ {0x64a892dc, 0x5561, 0x4536, 0x92, 0xc7, 0x79, 0x9b, 0xfc, 0x18, 0x33, 0x55}
+
+EFI_FORWARD_DECLARATION (EFI_ISA_ACPI);
+
+//
+// Resource Attribute definition
+//
+#define EFI_ISA_ACPI_IRQ_TYPE_HIGH_TRUE_EDGE_SENSITIVE 0x01
+#define EFI_ISA_ACPI_IRQ_TYPE_LOW_TRUE_EDGE_SENSITIVE 0x02
+#define EFI_ISA_ACPI_IRQ_TYPE_HIGH_TRUE_LEVEL_SENSITIVE 0x04
+#define EFI_ISA_ACPI_IRQ_TYPE_LOW_TRUE_LEVEL_SENSITIVE 0x08
+
+#define EFI_ISA_ACPI_DMA_SPEED_TYPE_MASK 0x03
+
+#define EFI_ISA_ACPI_DMA_SPEED_TYPE_COMPATIBILITY 0x00
+#define EFI_ISA_ACPI_DMA_SPEED_TYPE_A 0x01
+#define EFI_ISA_ACPI_DMA_SPEED_TYPE_B 0x02
+#define EFI_ISA_ACPI_DMA_SPEED_TYPE_F 0x03
+#define EFI_ISA_ACPI_DMA_COUNT_BY_BYTE 0x04
+#define EFI_ISA_ACPI_DMA_COUNT_BY_WORD 0x08
+#define EFI_ISA_ACPI_DMA_BUS_MASTER 0x10
+#define EFI_ISA_ACPI_DMA_TRANSFER_TYPE_8_BIT 0x20
+#define EFI_ISA_ACPI_DMA_TRANSFER_TYPE_8_BIT_AND_16_BIT 0x40
+#define EFI_ISA_ACPI_DMA_TRANSFER_TYPE_16_BIT 0x80
+
+#define EFI_ISA_ACPI_MEMORY_WIDTH_MASK 0x03
+
+#define EFI_ISA_ACPI_MEMORY_WIDTH_8_BIT 0x00
+#define EFI_ISA_ACPI_MEMORY_WIDTH_16_BIT 0x01
+#define EFI_ISA_ACPI_MEMORY_WIDTH_8_BIT_AND_16_BIT 0x02
+#define EFI_ISA_ACPI_MEMORY_WRITEABLE 0x04
+#define EFI_ISA_ACPI_MEMORY_CACHEABLE 0x08
+#define EFI_ISA_ACPI_MEMORY_SHADOWABLE 0x10
+#define EFI_ISA_ACPI_MEMORY_EXPANSION_ROM 0x20
+
+#define EFI_ISA_ACPI_IO_DECODE_10_BITS 0x01
+#define EFI_ISA_ACPI_IO_DECODE_16_BITS 0x02
+
+//
+// Resource List definition:
+// at first, the resource was defined as below
+// but in the future, it will be defined again that follow ACPI spec: ACPI resource type
+// so that, in this driver, we can interpret the ACPI table and get the ISA device information.
+//
+
+typedef enum {
+ EfiIsaAcpiResourceEndOfList,
+ EfiIsaAcpiResourceIo,
+ EfiIsaAcpiResourceMemory,
+ EfiIsaAcpiResourceDma,
+ EfiIsaAcpiResourceInterrupt
+} EFI_ISA_ACPI_RESOURCE_TYPE;
+
+typedef struct {
+ EFI_ISA_ACPI_RESOURCE_TYPE Type;
+ UINT32 Attribute;
+ UINT32 StartRange;
+ UINT32 EndRange;
+} EFI_ISA_ACPI_RESOURCE;
+
+typedef struct {
+ UINT32 HID;
+ UINT32 UID;
+} EFI_ISA_ACPI_DEVICE_ID;
+
+typedef struct {
+ EFI_ISA_ACPI_DEVICE_ID Device;
+ EFI_ISA_ACPI_RESOURCE *ResourceItem;
+} EFI_ISA_ACPI_RESOURCE_LIST;
+
+//
+// Prototypes for the ISA ACPI Protocol
+//
+typedef
+EFI_STATUS
+(EFIAPI *EFI_ISA_ACPI_DEVICE_ENUMERATE) (
+ IN EFI_ISA_ACPI *This,
+ OUT EFI_ISA_ACPI_DEVICE_ID **Device
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_ISA_ACPI_SET_DEVICE_POWER) (
+ IN EFI_ISA_ACPI *This,
+ IN EFI_ISA_ACPI_DEVICE_ID *Device,
+ IN BOOLEAN OnOff
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_ISA_ACPI_GET_CUR_RESOURCE) (
+ IN EFI_ISA_ACPI *This,
+ IN EFI_ISA_ACPI_DEVICE_ID *Device,
+ OUT EFI_ISA_ACPI_RESOURCE_LIST **ResourceList
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_ISA_ACPI_GET_POS_RESOURCE) (
+ IN EFI_ISA_ACPI *This,
+ IN EFI_ISA_ACPI_DEVICE_ID *Device,
+ OUT EFI_ISA_ACPI_RESOURCE_LIST **ResourceList
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_ISA_ACPI_SET_RESOURCE) (
+ IN EFI_ISA_ACPI *This,
+ IN EFI_ISA_ACPI_DEVICE_ID *Device,
+ IN EFI_ISA_ACPI_RESOURCE_LIST *ResourceList
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_ISA_ACPI_ENABLE_DEVICE) (
+ IN EFI_ISA_ACPI *This,
+ IN EFI_ISA_ACPI_DEVICE_ID *Device,
+ IN BOOLEAN Enable
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_ISA_ACPI_INIT_DEVICE) (
+ IN EFI_ISA_ACPI *This,
+ IN EFI_ISA_ACPI_DEVICE_ID *Device
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_ISA_ACPI_INTERFACE_INIT) (
+ IN EFI_ISA_ACPI *This
+ );
+
+//
+// Interface structure for the ISA ACPI Protocol
+//
+typedef struct _EFI_ISA_ACPI {
+ EFI_ISA_ACPI_DEVICE_ENUMERATE DeviceEnumerate;
+ EFI_ISA_ACPI_SET_DEVICE_POWER SetPower;
+ EFI_ISA_ACPI_GET_CUR_RESOURCE GetCurResource;
+ EFI_ISA_ACPI_GET_POS_RESOURCE GetPosResource;
+ EFI_ISA_ACPI_SET_RESOURCE SetResource;
+ EFI_ISA_ACPI_ENABLE_DEVICE EnableDevice;
+ EFI_ISA_ACPI_INIT_DEVICE InitDevice;
+ EFI_ISA_ACPI_INTERFACE_INIT InterfaceInit;
+} EFI_ISA_ACPI_PROTOCOL;
+
+extern EFI_GUID gEfiIsaAcpiProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Protocol/IsaIo/IsaIo.c b/EDK/Foundation/Protocol/IsaIo/IsaIo.c
new file mode 100644
index 0000000..fcbbafb
--- /dev/null
+++ b/EDK/Foundation/Protocol/IsaIo/IsaIo.c
@@ -0,0 +1,30 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ IsaIo.c
+
+Abstract:
+
+ EFI ISA I/O Protocol
+
+Revision History
+
+--*/
+
+#include "Tiano.h"
+
+#include EFI_PROTOCOL_DEFINITION (IsaIo)
+
+EFI_GUID gEfiIsaIoProtocolGuid = EFI_ISA_IO_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiIsaIoProtocolGuid, "ISA IO Protocol", "ISA IO Protocol");
diff --git a/EDK/Foundation/Protocol/IsaIo/IsaIo.h b/EDK/Foundation/Protocol/IsaIo/IsaIo.h
new file mode 100644
index 0000000..5ddd9eb
--- /dev/null
+++ b/EDK/Foundation/Protocol/IsaIo/IsaIo.h
@@ -0,0 +1,176 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ IsaIo.h
+
+Abstract:
+
+ EFI ISA I/O Protocol
+
+Revision History
+
+--*/
+
+#ifndef _EFI_ISA_IO_H
+#define _EFI_ISA_IO_H
+
+#include EFI_PROTOCOL_DEFINITION(IsaAcpi)
+
+//
+// Global ID for the ISA I/O Protocol
+//
+
+#define EFI_ISA_IO_PROTOCOL_GUID \
+ { 0x7ee2bd44, 0x3da0, 0x11d4, 0x9a, 0x38, 0x0, 0x90, 0x27, 0x3f, 0xc1, 0x4d }
+
+EFI_FORWARD_DECLARATION (EFI_ISA_IO_PROTOCOL);
+
+//
+// Prototypes for the ISA I/O Protocol
+//
+
+typedef enum {
+ EfiIsaIoWidthUint8,
+ EfiIsaIoWidthUint16,
+ EfiIsaIoWidthUint32,
+ EfiIsaIoWidthReserved,
+ EfiIsaIoWidthFifoUint8,
+ EfiIsaIoWidthFifoUint16,
+ EfiIsaIoWidthFifoUint32,
+ EfiIsaIoWidthFifoReserved,
+ EfiIsaIoWidthFillUint8,
+ EfiIsaIoWidthFillUint16,
+ EfiIsaIoWidthFillUint32,
+ EfiIsaIoWidthFillReserved,
+ EfiIsaIoWidthMaximum
+} EFI_ISA_IO_PROTOCOL_WIDTH;
+
+//
+// Attributes for common buffer allocations
+//
+#define EFI_ISA_IO_ATTRIBUTE_MEMORY_WRITE_COMBINE 0x080 // Map a memory range so write are combined
+#define EFI_ISA_IO_ATTRIBUTE_MEMORY_CACHED 0x800 // Map a memory range so all r/w accesses are cached
+#define EFI_ISA_IO_ATTRIBUTE_MEMORY_DISABLE 0x1000 // Disable a memory range
+
+//
+// Channel attribute for DMA operations
+//
+#define EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SPEED_COMPATIBLE 0x001
+#define EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SPEED_A 0x002
+#define EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SPEED_B 0x004
+#define EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SPEED_C 0x008
+#define EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_WIDTH_8 0x010
+#define EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_WIDTH_16 0x020
+#define EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_SINGLE_MODE 0x040
+#define EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_DEMAND_MODE 0x080
+#define EFI_ISA_IO_SLAVE_DMA_ATTRIBUTE_AUTO_INITIALIZE 0x100
+
+typedef enum {
+ EfiIsaIoOperationBusMasterRead,
+ EfiIsaIoOperationBusMasterWrite,
+ EfiIsaIoOperationBusMasterCommonBuffer,
+ EfiIsaIoOperationSlaveRead,
+ EfiIsaIoOperationSlaveWrite,
+ EfiIsaIoOperationMaximum
+} EFI_ISA_IO_PROTOCOL_OPERATION;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_ISA_IO_PROTOCOL_IO_MEM) (
+ IN EFI_ISA_IO_PROTOCOL *This,
+ IN EFI_ISA_IO_PROTOCOL_WIDTH Width,
+ IN UINT32 Offset,
+ IN UINTN Count,
+ IN OUT VOID *Buffer
+ );
+
+typedef struct {
+ EFI_ISA_IO_PROTOCOL_IO_MEM Read;
+ EFI_ISA_IO_PROTOCOL_IO_MEM Write;
+} EFI_ISA_IO_PROTOCOL_ACCESS;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_ISA_IO_PROTOCOL_COPY_MEM) (
+ IN EFI_ISA_IO_PROTOCOL *This,
+ IN EFI_ISA_IO_PROTOCOL_WIDTH Width,
+ IN UINT32 DestOffset,
+ IN UINT32 SrcOffset,
+ IN UINTN Count
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_ISA_IO_PROTOCOL_MAP) (
+ IN EFI_ISA_IO_PROTOCOL *This,
+ IN EFI_ISA_IO_PROTOCOL_OPERATION Operation,
+ IN UINT8 ChannelNumber OPTIONAL,
+ IN UINT32 ChannelAttributes,
+ IN VOID *HostAddress,
+ IN OUT UINTN *NumberOfBytes,
+ OUT EFI_PHYSICAL_ADDRESS *DeviceAddress,
+ OUT VOID **Mapping
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_ISA_IO_PROTOCOL_UNMAP) (
+ IN EFI_ISA_IO_PROTOCOL *This,
+ IN VOID *Mapping
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_ISA_IO_PROTOCOL_ALLOCATE_BUFFER) (
+ IN EFI_ISA_IO_PROTOCOL *This,
+ IN EFI_ALLOCATE_TYPE Type,
+ IN EFI_MEMORY_TYPE MemoryType,
+ IN UINTN Pages,
+ OUT VOID **HostAddress,
+ IN UINT64 Attributes
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_ISA_IO_PROTOCOL_FREE_BUFFER) (
+ IN EFI_ISA_IO_PROTOCOL *This,
+ IN UINTN Pages,
+ IN VOID *HostAddress
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_ISA_IO_PROTOCOL_FLUSH) (
+ IN EFI_ISA_IO_PROTOCOL *This
+ );
+
+//
+// Interface structure for the ISA I/O Protocol
+//
+typedef struct _EFI_ISA_IO_PROTOCOL {
+ EFI_ISA_IO_PROTOCOL_ACCESS Mem;
+ EFI_ISA_IO_PROTOCOL_ACCESS Io;
+ EFI_ISA_IO_PROTOCOL_COPY_MEM CopyMem;
+ EFI_ISA_IO_PROTOCOL_MAP Map;
+ EFI_ISA_IO_PROTOCOL_UNMAP Unmap;
+ EFI_ISA_IO_PROTOCOL_ALLOCATE_BUFFER AllocateBuffer;
+ EFI_ISA_IO_PROTOCOL_FREE_BUFFER FreeBuffer;
+ EFI_ISA_IO_PROTOCOL_FLUSH Flush;
+ EFI_ISA_ACPI_RESOURCE_LIST *ResourceList;
+ UINT32 RomSize;
+ VOID *RomImage;
+} EFI_ISA_IO_PROTOCOL;
+
+extern EFI_GUID gEfiIsaIoProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Protocol/LoadPe32Image/LoadPe32Image.c b/EDK/Foundation/Protocol/LoadPe32Image/LoadPe32Image.c
new file mode 100644
index 0000000..0600aee
--- /dev/null
+++ b/EDK/Foundation/Protocol/LoadPe32Image/LoadPe32Image.c
@@ -0,0 +1,27 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ LoadPe32Image.c
+
+Abstract:
+
+ Load PE32 Image Protocol
+
+--*/
+
+#include "Tiano.h"
+#include EFI_PROTOCOL_DEFINITION (LoadPe32Image)
+
+EFI_GUID gEfiLoadPeImageGuid = PE32_IMAGE_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiLoadPeImageGuid, "LoadPe32Image Protocol", "Tiano Load Pe32 Image Protocol");
diff --git a/EDK/Foundation/Protocol/LoadPe32Image/LoadPe32Image.h b/EDK/Foundation/Protocol/LoadPe32Image/LoadPe32Image.h
new file mode 100644
index 0000000..ae54e84
--- /dev/null
+++ b/EDK/Foundation/Protocol/LoadPe32Image/LoadPe32Image.h
@@ -0,0 +1,64 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ LoadPe32Image.h
+
+Abstract:
+
+ Load PE32 Image Protocol
+
+--*/
+
+#ifndef _LOAD_PE32_IMAGE_H_
+#define _LOAD_PE32_IMAGE_H_
+
+#define PE32_IMAGE_PROTOCOL_GUID \
+ {0x5cb5c776,0x60d5,0x45ee,0x88,0x3c,0x45,0x27,0x8,0xcd,0x74,0x3f }
+
+#define EFI_LOAD_PE_IMAGE_ATTRIBUTE_NONE 0x00
+#define EFI_LOAD_PE_IMAGE_ATTRIBUTE_RUNTIME_REGISTRATION 0x01
+#define EFI_LOAD_PE_IMAGE_ATTRIBUTE_DEBUG_IMAGE_INFO_TABLE_REGISTRATION 0x02
+
+EFI_FORWARD_DECLARATION (EFI_PE32_IMAGE_PROTOCOL);
+
+typedef
+EFI_STATUS
+(EFIAPI *LOAD_PE_IMAGE) (
+ IN EFI_PE32_IMAGE_PROTOCOL *This,
+ IN EFI_HANDLE ParentImageHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL *FilePath,
+ IN VOID *SourceBuffer OPTIONAL,
+ IN UINTN SourceSize,
+ IN EFI_PHYSICAL_ADDRESS DstBuffer OPTIONAL,
+ OUT UINTN *NumberOfPages OPTIONAL,
+ OUT EFI_HANDLE *ImageHandle,
+ OUT EFI_PHYSICAL_ADDRESS *EntryPoint OPTIONAL,
+ IN UINT32 Attribute
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *UNLOAD_PE_IMAGE) (
+ IN EFI_PE32_IMAGE_PROTOCOL *This,
+ IN EFI_HANDLE ImageHandle
+ );
+
+typedef struct _EFI_PE32_IMAGE_PROTOCOL {
+ LOAD_PE_IMAGE LoadPeImage;
+ UNLOAD_PE_IMAGE UnLoadPeImage;
+} EFI_PE32_IMAGE_PROTOCOL;
+
+extern EFI_GUID gEfiLoadPeImageGuid;
+
+#endif
+
diff --git a/EDK/Foundation/Protocol/NicIp4Config/NicIp4Config.c b/EDK/Foundation/Protocol/NicIp4Config/NicIp4Config.c
new file mode 100644
index 0000000..ced316c
--- /dev/null
+++ b/EDK/Foundation/Protocol/NicIp4Config/NicIp4Config.c
@@ -0,0 +1,37 @@
+/*++
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ NicIp4Config.c
+
+Abstract:
+
+--*/
+
+#include "EfiSpec.h"
+#include EFI_PROTOCOL_DEFINITION (NicIp4Config)
+
+EFI_GUID gEfiNicIp4ConfigProtocolGuid = EFI_NIC_IP4_CONFIG_PROTOCOL_GUID;
+
+EFI_GUID_STRING (
+ &gEfiNicIp4ConfigProtocolGuid,
+ "NicIP4Config Protocol",
+ "NicIP4Config Protocol"
+ );
+
+EFI_GUID gEfiNicIp4ConfigVariableGuid = EFI_NIC_IP4_CONFIG_VARIABLE_GUID;
+
+EFI_GUID_STRING(
+ &gEfiNicIp4ConfigVariableGuid,
+ "Ip4 Static Config",
+ "Ip4 Configuration Data"
+ );
diff --git a/EDK/Foundation/Protocol/NicIp4Config/NicIp4Config.h b/EDK/Foundation/Protocol/NicIp4Config/NicIp4Config.h
new file mode 100644
index 0000000..6cd1ec3
--- /dev/null
+++ b/EDK/Foundation/Protocol/NicIp4Config/NicIp4Config.h
@@ -0,0 +1,118 @@
+/*++
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ NicIp4Config.h
+
+Abstract:
+
+--*/
+
+#ifndef _NIC_IP4_CONFIG_H_
+#define _NIC_IP4_CONFIG_H_
+
+#include EFI_PROTOCOL_DEFINITION (Ip4Config)
+
+#define EFI_NIC_IP4_CONFIG_PROTOCOL_GUID \
+ {0xdca3d4d, 0x12da, 0x4728, 0xbf, 0x7e, 0x86, 0xce, 0xb9, 0x28, 0xd0, 0x67}
+
+#define EFI_NIC_IP4_CONFIG_VARIABLE_GUID \
+ {0xd8944553, 0xc4dd, 0x41f4, 0x9b, 0x30, 0xe1, 0x39, 0x7c, 0xfb, 0x26, 0x7b}
+
+#define EFI_NIC_IP4_CONFIG_VARIABLE L"EfiNicIp4ConfigVariable"
+
+
+typedef struct _EFI_NIC_IP4_CONFIG_PROTOCOL EFI_NIC_IP4_CONFIG_PROTOCOL;
+
+typedef enum {
+ //
+ // Config source: dhcp or static
+ //
+ IP4_CONFIG_SOURCE_DHCP = 0,
+ IP4_CONFIG_SOURCE_STATIC,
+ IP4_CONFIG_SOURCE_MAX,
+
+ IP4_NIC_NAME_LENGTH = 64,
+ MAX_IP4_CONFIG_IN_VARIABLE = 16,
+};
+
+//
+// The following structures are used by drivers/applications other
+// than EFI_IP4_PROTOCOL, such as ifconfig shell application, to
+// communicate the IP configuration information to EFI_IP4_CONFIG_PROTOCOL.
+// EFI_IP4_CONFIG_PROTOCOL in turn is used by EFI_IP4_PROTOCOL to get
+// the default IP4 configuration. ifconfig can't use the EFI_IP4_PROTOCOL
+// because it don't know how to configure the default IP address even
+// it has got the address.
+//
+// NIC_ADDR contains the interface's type and MAC address to identify
+// a specific NIC. NIC_IP4_CONFIG_INFO contains the IP4 configure
+// parameters for that NIC. IP4_CONFIG_VARIABLE is the EFI variable to
+// save the configuration. NIC_IP4_CONFIG_INFO and IP4_CONFIG_VARIABLE
+// is of variable length.
+//
+// EFI_NIC_IP4_CONFIG_PROTOCOL is a priority protocol, not defined by UEFI2.0
+//
+typedef struct {
+ UINT16 Type;
+ UINT8 Len;
+ EFI_MAC_ADDRESS MacAddr;
+} NIC_ADDR;
+
+typedef struct {
+ NIC_ADDR NicAddr; // Link layer address to identify the NIC
+ UINT32 Source; // Static or DHCP
+ BOOLEAN Perment; // Survive the reboot or not
+ EFI_IP4_IPCONFIG_DATA Ip4Info; // IP addresses
+} NIC_IP4_CONFIG_INFO;
+
+typedef struct {
+ UINT32 Len; // Total length of the variable
+ UINT16 CheckSum; // CheckSum, the same as IP4 head checksum
+ UINT32 Count; // Number of NIC_IP4_CONFIG_INFO follows
+ NIC_IP4_CONFIG_INFO ConfigInfo;
+} IP4_CONFIG_VARIABLE;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_NIC_IP4_CONFIG_GET_INFO) (
+ IN EFI_NIC_IP4_CONFIG_PROTOCOL *This,
+ IN OUT UINTN *Len,
+ OUT NIC_IP4_CONFIG_INFO *NicConfig OPTIONAL
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_NIC_IP4_CONFIG_SET_INFO) (
+ IN EFI_NIC_IP4_CONFIG_PROTOCOL *This,
+ IN NIC_IP4_CONFIG_INFO *NicConfig, OPTIONAL
+ IN BOOLEAN ReConfig
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_NIC_IP4_CONFIG_GET_NAME) (
+ IN EFI_NIC_IP4_CONFIG_PROTOCOL *This,
+ IN UINT16 *Name, OPTIONAL
+ IN NIC_ADDR *NicAddr OPTIONAL
+ );
+
+typedef
+struct _EFI_NIC_IP4_CONFIG_PROTOCOL {
+ EFI_NIC_IP4_CONFIG_GET_NAME GetName;
+ EFI_NIC_IP4_CONFIG_GET_INFO GetInfo;
+ EFI_NIC_IP4_CONFIG_SET_INFO SetInfo;
+};
+
+extern EFI_GUID gEfiNicIp4ConfigVariableGuid;
+extern EFI_GUID gEfiNicIp4ConfigProtocolGuid;
+#endif
diff --git a/EDK/Foundation/Protocol/PciHotPlugRequest/PciHotPlugRequest.c b/EDK/Foundation/Protocol/PciHotPlugRequest/PciHotPlugRequest.c
new file mode 100644
index 0000000..07c41bf
--- /dev/null
+++ b/EDK/Foundation/Protocol/PciHotPlugRequest/PciHotPlugRequest.c
@@ -0,0 +1,27 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PciHotPlugRequest.c
+
+Abstract:
+
+
+
+--*/
+
+#include "Tiano.h"
+#include EFI_PROTOCOL_DEFINITION (PciHotPlugRequest)
+
+EFI_GUID gEfiPciHotPlugRequestProtocolGuid = EFI_PCI_HOTPLUG_REQUEST_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiPciHotPlugRequestProtocolGuid, "Pci Hot Plug Request Protocol", "Tiano Hot Plug Request Protocol");
diff --git a/EDK/Foundation/Protocol/PciHotPlugRequest/PciHotPlugRequest.h b/EDK/Foundation/Protocol/PciHotPlugRequest/PciHotPlugRequest.h
new file mode 100644
index 0000000..11b2d66
--- /dev/null
+++ b/EDK/Foundation/Protocol/PciHotPlugRequest/PciHotPlugRequest.h
@@ -0,0 +1,55 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PciHotPlugRequest.h
+
+Abstract:
+
+
+
+--*/
+
+#ifndef _PCI_HOTPLUG_REQUEST_H_
+#define _PCI_HOTPLUG_REQUEST_H_
+
+#define EFI_PCI_HOTPLUG_REQUEST_PROTOCOL_GUID \
+{0x19cb87ab,0x2cb9,0x4665,0x83,0x60,0xdd,0xcf,0x60,0x54,0xf7,0x9d}
+
+typedef enum {
+ EfiPciHotPlugRequestAdd,
+ EfiPciHotplugRequestRemove
+} EFI_PCI_HOTPLUG_OPERATION;
+
+EFI_FORWARD_DECLARATION (EFI_PCI_HOTPLUG_REQUEST_PROTOCOL);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PCI_HOTPLUG_REQUEST_NOTIFY) (
+ IN EFI_PCI_HOTPLUG_REQUEST_PROTOCOL *This,
+ IN EFI_PCI_HOTPLUG_OPERATION Operation,
+ IN EFI_HANDLE Controller,
+ IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL,
+ IN OUT UINT8 *NumberOfChildren,
+ IN OUT EFI_HANDLE *ChildHandleBuffer
+);
+
+
+
+typedef struct _EFI_PCI_HOTPLUG_REQUEST_PROTOCOL {
+ EFI_PCI_HOTPLUG_REQUEST_NOTIFY Notify;
+} EFI_PCI_HOTPLUG_REQUEST_PROTOCOL;
+
+
+extern EFI_GUID gEfiPciHotPlugRequestProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Protocol/Performance/Performance.c b/EDK/Foundation/Protocol/Performance/Performance.c
new file mode 100644
index 0000000..faad0ca
--- /dev/null
+++ b/EDK/Foundation/Protocol/Performance/Performance.c
@@ -0,0 +1,27 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Performance.c
+
+Abstract:
+
+ DXE performance checking infrastructure
+
+--*/
+
+#include "Tiano.h"
+#include EFI_PROTOCOL_DEFINITION (Performance)
+
+EFI_GUID gEfiPerformanceProtocolGuid = EFI_PERFORMANCE_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiPerformanceProtocolGuid, "Performance Protocol", "Performance Protocol");
diff --git a/EDK/Foundation/Protocol/Performance/Performance.h b/EDK/Foundation/Protocol/Performance/Performance.h
new file mode 100644
index 0000000..0fd5cc9
--- /dev/null
+++ b/EDK/Foundation/Protocol/Performance/Performance.h
@@ -0,0 +1,103 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Performance.h
+
+Abstract:
+
+
+--*/
+
+#ifndef _EFI_PERFORMANCE_H_
+#define _EFI_PERFORMANCE_H_
+
+#define EFI_PERFORMANCE_PROTOCOL_GUID \
+ { 0xFFECFFFF, 0x923C, 0x14d2, 0x9E, 0x3F, 0x22, 0xA0, 0xC9, 0x69, 0x56, 0x3B }
+
+#define EFI_NULL_GUID \
+ { 0x00000000, 0x0000, 0x0000, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }
+
+
+EFI_FORWARD_DECLARATION (EFI_PERFORMANCE_PROTOCOL);
+
+#define DXE_TOK L"DXE"
+#define SHELL_TOK L"SHELL"
+#define PEI_TOK L"PEI"
+#define BDS_TOK L"BDS"
+#define DRIVERBINDING_START_TOK L"DriverBinding:Start"
+#define DRIVERBINDING_SUPPORT_TOK L"DriverBinding:Support"
+#define START_IMAGE_TOK L"StartImage"
+#define LOAD_IMAGE_TOK L"LoadImage"
+
+#define DXE_PHASE 0
+#define SHELL_PHASE 1
+#define PEI_PHASE 2
+
+#define EFI_PERF_TOKEN_LENGTH 32
+#define EFI_PERF_HOST_LENGTH 32
+#define EFI_PERF_PDBFILENAME_LENGTH 28
+
+typedef struct {
+ EFI_HANDLE Handle;
+ UINT16 Token[EFI_PERF_TOKEN_LENGTH];
+ UINT16 Host[EFI_PERF_HOST_LENGTH];
+ UINT64 StartTick;
+ UINT64 EndTick;
+ EFI_GUID GuidName;
+ UINT8 PdbFileName[EFI_PERF_PDBFILENAME_LENGTH];
+ UINT8 Phase;
+} EFI_GAUGE_DATA ;
+
+
+typedef
+EFI_STATUS
+(EFIAPI * EFI_PERF_START_GAUGE) (
+ IN EFI_PERFORMANCE_PROTOCOL *This,
+ IN EFI_HANDLE Handle,
+ IN UINT16 *Token,
+ IN UINT16 *Host,
+ IN UINT64 Ticker
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI * EFI_PERF_END_GAUGE) (
+ IN EFI_PERFORMANCE_PROTOCOL *This,
+ IN EFI_HANDLE Handle,
+ IN UINT16 *Token,
+ IN UINT16 *Host,
+ IN UINT64 Ticker
+ );
+
+
+typedef
+EFI_GAUGE_DATA *
+(EFIAPI * EFI_PERF_GET_GAUGE) (
+ IN EFI_PERFORMANCE_PROTOCOL *This,
+ IN EFI_HANDLE Handle,
+ IN UINT16 *Token,
+ IN UINT16 *Host,
+ IN EFI_GAUGE_DATA *PrevGauge
+ );
+
+
+typedef struct _EFI_PERFORMANCE_PROTOCOL{
+ EFI_PERF_START_GAUGE StartGauge;
+ EFI_PERF_END_GAUGE EndGauge;
+ EFI_PERF_GET_GAUGE GetGauge;
+} EFI_PERFORMANCE_PROTOCOL;
+
+extern EFI_GUID gEfiPerformanceProtocolGuid;
+
+#endif
+
diff --git a/EDK/Foundation/Protocol/PlatformMemTest/PlatformMemTest.c b/EDK/Foundation/Protocol/PlatformMemTest/PlatformMemTest.c
new file mode 100644
index 0000000..7789c37
--- /dev/null
+++ b/EDK/Foundation/Protocol/PlatformMemTest/PlatformMemTest.c
@@ -0,0 +1,30 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PlatformMemTest.c
+
+Abstract:
+
+ // TBD defined in the Tiano specification??
+
+ The Platform memory test protocol is used to provide platform specific
+ information and functionality for memory test
+
+--*/
+
+#include "Tiano.h"
+#include EFI_PROTOCOL_DEFINITION (PlatformMemTest)
+
+EFI_GUID gEfiPlatformMemTestGuid = EFI_PLATFORM_MEMTEST_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiPlatformMemTestGuid, "Platform Memory Test Protocol", "Platform MemTest protocol");
diff --git a/EDK/Foundation/Protocol/PlatformMemTest/PlatformMemTest.h b/EDK/Foundation/Protocol/PlatformMemTest/PlatformMemTest.h
new file mode 100644
index 0000000..d2270e9
--- /dev/null
+++ b/EDK/Foundation/Protocol/PlatformMemTest/PlatformMemTest.h
@@ -0,0 +1,261 @@
+
+ /*++
+
+Copyright (c) 2004 - 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ PlatformMemtest.h
+
+Abstract:
+ This files defines the protocol produced by platform memory test driver.
+
+--*/
+
+#ifndef __PLATFORM_MEMTEST_H__
+#define __PLATFORM_MEMTEST_H__
+
+#if (EFI_SPECIFICATION_VERSION >= 0x0002000A)
+#include EFI_PROTOCOL_CONSUMER (HiiDatabase)
+#else
+#include EFI_PROTOCOL_CONSUMER (Hii)
+#endif
+#include EFI_PROTOCOL_CONSUMER (GenericMemoryTest)
+
+
+#define EFI_PLATFORM_MEMTEST_PROTOCOL_GUID \
+ { 0x859ba18, 0x7dd7, 0x4ed7, 0xa8, 0x8e, 0x10, 0x9c, 0x63, 0x91, 0x7b, 0xdd }
+
+//
+// Forward reference for pure ANSI compatability
+//
+EFI_FORWARD_DECLARATION (EFI_PLATFORM_MEMTEST_PROTOCOL);
+
+
+//
+// Basic type definitions
+//
+typedef UINT16 EFI_DIMM_ID;
+#define EFI_INVALID_DIMM_ID 0xFFFF
+
+//
+// This describes the capabilities
+//
+typedef struct {
+ UINT32 HwCap;
+ EFI_PHYSICAL_ADDRESS InitBlockSize;
+ EFI_PHYSICAL_ADDRESS TestBlockSize;
+} EFI_PLATFORM_MEMTEST_CAPABILITIES;
+
+//
+// This defines the platform driver phases to use in notify phase
+//
+typedef enum {
+ EfiMemtestPhaseBegin,
+ EfiMemtestPhaseEnd,
+ EfiMemtestPhaseMaximum
+} EFI_MEMTEST_PHASE ;
+
+
+//
+// Definitions of Capability bits
+//
+#define EFI_MEMTEST_CAP_NONE 0X00000000
+#define EFI_MEMTEST_CAP_ECC 0X00000001
+#define EFI_MEMTEST_CAP_HW_TEST 0X00000002
+#define EFI_MEMTEST_CAP_HW_INIT 0X00000004
+
+//
+// This describes the pattern for testing all memory cells
+//
+typedef struct {
+ UINT32 Count; // Number of patterns
+ UINT32 Width; // Width of patterns
+ VOID *Pattern; // Array of patterns
+}EFI_MEMTEST_DATA_PATTERN;
+
+//
+// This describes the data and address line patterns
+//
+typedef struct {
+ UINT32 Count; // Number of patterns
+ EFI_PHYSICAL_ADDRESS *Address; // Array of addresses
+ EFI_PHYSICAL_ADDRESS *Pattern; // Array of patterns
+} EFI_MEMTEST_ADDRESS_PATTERN;
+
+
+#define EFI_INVALID_DIMM_ID 0xFFFF
+
+//
+// DIMM information exported by the platform driver
+//
+
+typedef struct {
+ EFI_DIMM_ID DimmId;
+ STRING_REF DimmReference;
+} EFI_MEMTEST_DIMM_INFO;
+
+
+//
+// Various types of errors
+//
+typedef enum {
+ EfiMemtestCorrectableError = 1,
+ EfiMemtestUncorrectableError,
+ EfiMemtestErrorMaximum,
+} EFI_DIMM_ERROR;
+
+//
+// Actions to be taken.
+//
+typedef enum {
+ EfiMemtestActionReport = 1,
+ EfiMemtestActionDisableMem,
+ EfiMemtestActionMaximum,
+} EFI_MEMTEST_ERROR_ACTION;
+
+
+//
+// Structure indicating a policy entry.
+//
+
+typedef struct {
+ EFI_DIMM_ERROR ErrorType;
+ UINT32 Threshold;
+ EFI_MEMTEST_ERROR_ACTION Action;
+} EFI_MEMTEST_POLICY_ENTRY;
+
+
+
+//
+// Error Information.
+//
+typedef struct {
+ EFI_DIMM_ERROR Error;
+ EFI_DIMM_ID DimmId;
+} EFI_PLATFORM_MEMTEST_ERROR;
+
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PLATFORM_MEMTEST_NOTIFY_PHASE) (
+ IN EFI_PLATFORM_MEMTEST_PROTOCOL *This,
+ IN EFI_MEMTEST_PHASE Phase
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PLATFORM_MEMTEST_GET_PLATFORM_INFO) (
+ IN EFI_PLATFORM_MEMTEST_PROTOCOL *This,
+ OUT EFI_PLATFORM_MEMTEST_CAPABILITIES *Capabilities,
+ OUT EFI_MEMTEST_ADDRESS_PATTERN *AddressPattern,
+ OUT EFI_MEMTEST_DATA_PATTERN *DataPattern,
+ OUT EFI_MEMTEST_DATA_PATTERN *MemoryPattern,
+ OUT UINT32 *EntryCount,
+ OUT EFI_MEMTEST_POLICY_ENTRY **PolicyGrid
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI * EFI_PLATFORM_MEMTEST_GET_NEXT_DIMM_INFO) (
+ IN EFI_PLATFORM_MEMTEST_PROTOCOL *This,
+ IN OUT EFI_MEMTEST_DIMM_INFO *DimmInfo
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PLATFORM_MEMTEST_INITIALIZE_MEMORY) (
+ IN EFI_PLATFORM_MEMTEST_PROTOCOL *This,
+ IN EFI_PHYSICAL_ADDRESS Start,
+ IN EFI_PHYSICAL_ADDRESS Size
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI * EFI_PLATFORM_MEMTEST_HW_MEMORY_TEST) (
+ IN EFI_PLATFORM_MEMTEST_PROTOCOL *This,
+ IN EXTENDMEM_COVERAGE_LEVEL Level,
+ IN EFI_PHYSICAL_ADDRESS Start,
+ IN EFI_PHYSICAL_ADDRESS Size,
+ OUT UINTN *ErrorCount,
+ OUT EFI_PLATFORM_MEMTEST_ERROR **ErrorInfo
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI * EFI_PLATFORM_MEMTEST_FLUSH_BUFFER) (
+ IN EFI_PLATFORM_MEMTEST_PROTOCOL *This
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI * EFI_PLATFORM_MEMTEST_CHECK_FOR_ERROR) (
+ IN EFI_PLATFORM_MEMTEST_PROTOCOL *This,
+ OUT UINT32 *ErrorCount,
+ OUT EFI_PLATFORM_MEMTEST_ERROR **ErrorInfo
+
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI * EFI_PLATFORM_MEMTEST_LOCATE_BAD_DIMM) (
+ IN EFI_PLATFORM_MEMTEST_PROTOCOL *This,
+ IN EFI_PHYSICAL_ADDRESS FailingAddress,
+ IN UINT8 Expected,
+ IN UINT8 Found,
+ OUT UINT32 *ErrorInfoCount,
+ OUT EFI_PLATFORM_MEMTEST_ERROR **ErrorInfoBuffer
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI * EFI_PLATFORM_MEMTEST_CLEAR_ERROR) (
+ IN EFI_PLATFORM_MEMTEST_PROTOCOL *This
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI * EFI_PLATFORM_MEMTEST_DISABLE_DIMM) (
+ IN EFI_PLATFORM_MEMTEST_PROTOCOL *This,
+ IN UINT16 *DimmCount,
+ IN EFI_DIMM_ID *DimmIds,
+ IN BOOLEAN RebootRequired
+
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI * EFI_PLATFORM_MEMTEST_OVERLAP) (
+ IN EFI_PLATFORM_MEMTEST_PROTOCOL *This,
+ IN EFI_DIMM_ID DimmId,
+ IN EFI_PHYSICAL_ADDRESS start,
+ IN EFI_PHYSICAL_ADDRESS Size,
+ OUT BOOLEAN *Overlap
+ );
+
+typedef struct _EFI_PLATFORM_MEMTEST_PROTOCOL {
+ EFI_PLATFORM_MEMTEST_NOTIFY_PHASE NotifyPhase;
+ EFI_PLATFORM_MEMTEST_GET_PLATFORM_INFO GetPlatformInfo;
+ EFI_PLATFORM_MEMTEST_GET_NEXT_DIMM_INFO GetNextDimmInfo;
+ EFI_PLATFORM_MEMTEST_INITIALIZE_MEMORY InitializeMem;
+ EFI_PLATFORM_MEMTEST_HW_MEMORY_TEST HwTest;
+ EFI_PLATFORM_MEMTEST_FLUSH_BUFFER FlushBuffer;
+ EFI_PLATFORM_MEMTEST_CHECK_FOR_ERROR CheckError;
+ EFI_PLATFORM_MEMTEST_LOCATE_BAD_DIMM LocateBadDimm;
+ EFI_PLATFORM_MEMTEST_CLEAR_ERROR ClearError;
+ EFI_PLATFORM_MEMTEST_DISABLE_DIMM DisableDimm;
+ EFI_PLATFORM_MEMTEST_OVERLAP Overlap;
+} EFI_PLATFORM_MEMTEST_PROTOCOL;
+
+
+
+extern EFI_GUID gEfiPlatformMemTestGuid;
+
+#endif
diff --git a/EDK/Foundation/Protocol/Print/Print.c b/EDK/Foundation/Protocol/Print/Print.c
new file mode 100644
index 0000000..d3caecf
--- /dev/null
+++ b/EDK/Foundation/Protocol/Print/Print.c
@@ -0,0 +1,29 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Print.c
+
+Abstract:
+
+ This file defines the Print protocol interface to provide a unified
+ print function
+
+--*/
+
+#include "Tiano.h"
+#include EFI_PROTOCOL_DEFINITION (Print)
+
+EFI_GUID gEfiPrintProtocolGuid = EFI_PRINT_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiPrintProtocolGuid, "Print Protocol", "Print 1.0 protocol");
+
diff --git a/EDK/Foundation/Protocol/Print/Print.h b/EDK/Foundation/Protocol/Print/Print.h
new file mode 100644
index 0000000..094591f
--- /dev/null
+++ b/EDK/Foundation/Protocol/Print/Print.h
@@ -0,0 +1,51 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Print.h
+
+Abstract:
+
+ This file defines the Print protocol
+
+--*/
+
+#ifndef _PPRINT_H_
+#define _PPRINT_H_
+
+#define EFI_PRINT_PROTOCOL_GUID \
+ { 0xdf2d868e, 0x32fc, 0x4cf0, 0x8e, 0x6b, 0xff, 0xd9, 0x5d, 0x13, 0x43, 0xd0 }
+
+//
+// Forward reference for pure ANSI compatability
+//
+EFI_FORWARD_DECLARATION (EFI_PRINT_PROTOCOL);
+
+typedef struct _EFI_PRINT_PROTOCOL EFI_PRINT_PROTOCOL;
+
+typedef
+UINTN
+(EFIAPI *EFI_VSPRINT) (
+ OUT CHAR16 *StartOfBuffer,
+ IN UINTN BufferSize,
+ IN CONST CHAR16 *FormatString,
+ IN VA_LIST Marker
+ );
+
+typedef struct _EFI_PRINT_PROTOCOL {
+ EFI_VSPRINT VSPrint;
+} EFI_PRINT_PROTOCOL;
+
+
+extern EFI_GUID gEfiPrintProtocolGuid;
+
+#endif \ No newline at end of file
diff --git a/EDK/Foundation/Protocol/Ps2Policy/Ps2Policy.c b/EDK/Foundation/Protocol/Ps2Policy/Ps2Policy.c
new file mode 100644
index 0000000..cb49b7f
--- /dev/null
+++ b/EDK/Foundation/Protocol/Ps2Policy/Ps2Policy.c
@@ -0,0 +1,28 @@
+/*++
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ Ps2Policy.c
+
+Abstract:
+
+ Protocol used for PS/2 Policy definition.
+
+--*/
+
+#include "Tiano.h"
+#include EFI_PROTOCOL_DEFINITION (Ps2Policy)
+
+EFI_GUID gEfiPs2PolicyProtocolGuid = EFI_PS2_POLICY_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiPs2PolicyProtocolGuid, "PS2 Policy", "Policy for Configuring PS2");
diff --git a/EDK/Foundation/Protocol/Ps2Policy/Ps2Policy.h b/EDK/Foundation/Protocol/Ps2Policy/Ps2Policy.h
new file mode 100644
index 0000000..89ce6bf
--- /dev/null
+++ b/EDK/Foundation/Protocol/Ps2Policy/Ps2Policy.h
@@ -0,0 +1,50 @@
+/*++
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ Ps2Policy.h
+
+Abstract:
+
+ Protocol used for PS/2 Policy definition.
+
+--*/
+
+#ifndef _PS2_POLICY_PROTOCOL_H_
+#define _PS2_POLICY_PROTOCOL_H_
+
+EFI_FORWARD_DECLARATION (EFI_PS2_POLICY_PROTOCOL);
+
+#define EFI_PS2_POLICY_PROTOCOL_GUID \
+ { \
+ 0x4df19259, 0xdc71, 0x4d46, 0xbe, 0xf1, 0x35, 0x7b, 0xb5, 0x78, 0xc4, 0x18 \
+ }
+
+#define EFI_KEYBOARD_CAPSLOCK 0x0004
+#define EFI_KEYBOARD_NUMLOCK 0x0002
+#define EFI_KEYBOARD_SCROLLLOCK 0x0001
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PS2_INIT_HARDWARE) (
+ IN EFI_HANDLE Handle
+ );
+
+typedef struct _EFI_PS2_POLICY_PROTOCOL {
+ UINT8 KeyboardLight;
+ EFI_PS2_INIT_HARDWARE Ps2InitHardware;
+} EFI_PS2_POLICY_PROTOCOL;
+
+extern EFI_GUID gEfiPs2PolicyProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Protocol/PxeDhcp4/PxeDhcp4.c b/EDK/Foundation/Protocol/PxeDhcp4/PxeDhcp4.c
new file mode 100644
index 0000000..d5befac
--- /dev/null
+++ b/EDK/Foundation/Protocol/PxeDhcp4/PxeDhcp4.c
@@ -0,0 +1,28 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+ PxeDhcp4.c
+
+Abstract:
+ PxeDhcp4 GUID declaration
+
+--*/
+
+#include "Tiano.h"
+
+#include EFI_PROTOCOL_DEFINITION (PxeDhcp4)
+
+EFI_GUID gEfiPxeDhcp4ProtocolGuid = EFI_PXE_DHCP4_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiPxeDhcp4ProtocolGuid, "PXE DHCP4 Protocol", "PXE DHCPv4 Protocol");
+
+/* EOF - PxeDhcp4.c */
diff --git a/EDK/Foundation/Protocol/PxeDhcp4/PxeDhcp4.h b/EDK/Foundation/Protocol/PxeDhcp4/PxeDhcp4.h
new file mode 100644
index 0000000..f1ecf42
--- /dev/null
+++ b/EDK/Foundation/Protocol/PxeDhcp4/PxeDhcp4.h
@@ -0,0 +1,350 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+ PxeDhcp4.h
+
+Abstract:
+ EFI PXE DHCPv4 protocol definition
+
+--*/
+
+#ifndef _PXEDHCP4_H_
+#define _PXEDHCP4_H_
+
+
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
+//
+// PXE DHCPv4 GUID definition
+//
+
+#define EFI_PXE_DHCP4_PROTOCOL_GUID \
+ { 0x03c4e624, 0xac28, 0x11d3, 0x9a, 0x2d, 0x00, 0x90, 0x29, 0x3f, 0xc1, 0x4d }
+
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
+//
+// Interface definition
+//
+
+EFI_FORWARD_DECLARATION (EFI_PXE_DHCP4_PROTOCOL);
+
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
+//
+// Descriptions of the DHCP version 4 header and options can be found
+// in RFC-2131 and RFC-2132 at www.ietf.org
+//
+
+#pragma pack(1)
+typedef struct {
+
+ UINT8 op;
+#define BOOTP_REQUEST 1
+#define BOOTP_REPLY 2
+
+ UINT8 htype;
+
+ UINT8 hlen;
+
+ UINT8 hops;
+
+ UINT32 xid;
+
+ UINT16 secs;
+#define DHCP4_INITIAL_SECONDS 4
+
+ UINT16 flags;
+#define DHCP4_BROADCAST_FLAG 0x8000
+
+ UINT32 ciaddr;
+
+ UINT32 yiaddr;
+
+ UINT32 siaddr;
+
+ UINT32 giaddr;
+
+ UINT8 chaddr[16];
+
+ UINT8 sname[64];
+
+ UINT8 fname[128];
+
+//
+// This is the minimum option length as specified in RFC-2131.
+// The packet must be padded out this far with DHCP4_PAD.
+// DHCPv4 packets are usually 576 bytes in length. This length
+// includes the IPv4 and UDPv4 headers but not the media header.
+// Note: Not all DHCP relay agents will forward DHCPv4 packets
+// if they are less than 384 bytes or exceed 576 bytes. Even if
+// the underlying hardware can handle smaller and larger packets,
+// many older relay agents will not accept them.
+//
+ UINT32 magik;
+#define DHCP4_MAGIK_NUMBER 0x63825363
+
+ UINT8 options[308];
+
+} DHCP4_HEADER;
+#pragma pack()
+
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
+//
+// DHCPv4 packet definition. Room for 576 bytes including IP and
+// UDP header.
+//
+
+#define DHCP4_MAX_PACKET_SIZE 576
+#define DHCP4_UDP_HEADER_SIZE 8
+#define DHCP4_IP_HEADER_SIZE 20
+
+#pragma pack(1)
+typedef union _DHCP4_PACKET {
+ UINT32 _force_data_alignment;
+
+ UINT8 raw[1500];
+
+ DHCP4_HEADER dhcp4;
+} DHCP4_PACKET;
+#pragma pack()
+
+#define DHCP4_SERVER_PORT 67
+#define DHCP4_CLIENT_PORT 68
+
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
+//
+// DHCPv4 and PXE option numbers.
+//
+
+#define DHCP4_PAD 0
+#define DHCP4_END 255
+#define DHCP4_SUBNET_MASK 1
+#define DHCP4_TIME_OFFSET 2
+#define DHCP4_ROUTER_LIST 3
+#define DHCP4_TIME_SERVERS 4
+#define DHCP4_NAME_SERVERS 5
+#define DHCP4_DNS_SERVERS 6
+#define DHCP4_LOG_SERVERS 7
+#define DHCP4_COOKIE_SERVERS 8
+#define DHCP4_LPR_SREVERS 9
+#define DHCP4_IMPRESS_SERVERS 10
+#define DHCP4_RESOURCE_LOCATION_SERVERS 11
+#define DHCP4_HOST_NAME 12
+#define DHCP4_BOOT_FILE_SIZE 13
+#define DHCP4_DUMP_FILE 14
+#define DHCP4_DOMAIN_NAME 15
+#define DHCP4_SWAP_SERVER 16
+#define DHCP4_ROOT_PATH 17
+#define DHCP4_EXTENSION_PATH 18
+#define DHCP4_IP_FORWARDING 19
+#define DHCP4_NON_LOCAL_SOURCE_ROUTE 20
+#define DHCP4_POLICY_FILTER 21
+#define DHCP4_MAX_DATAGRAM_SIZE 22
+#define DHCP4_DEFAULT_TTL 23
+#define DHCP4_MTU_AGING_TIMEOUT 24
+#define DHCP4_MTU_SIZES 25
+#define DHCP4_MTU_TO_USE 26
+#define DHCP4_ALL_SUBNETS_LOCAL 27
+#define DHCP4_BROADCAST_ADDRESS 28
+#define DHCP4_PERFORM_MASK_DISCOVERY 29
+#define DHCP4_RESPOND_TO_MASK_REQ 30
+#define DHCP4_PERFORM_ROUTER_DISCOVERY 31
+#define DHCP4_ROUTER_SOLICIT_ADDRESS 32
+#define DHCP4_STATIC_ROUTER_LIST 33
+#define DHCP4_USE_ARP_TRAILERS 34
+#define DHCP4_ARP_CACHE_TIMEOUT 35
+#define DHCP4_ETHERNET_ENCAPSULATION 36
+#define DHCP4_TCP_DEFAULT_TTL 37
+#define DHCP4_TCP_KEEP_ALIVE_INT 38
+#define DHCP4_KEEP_ALIVE_GARBAGE 39
+#define DHCP4_NIS_DOMAIN_NAME 40
+#define DHCP4_NIS_SERVERS 41
+#define DHCP4_NTP_SERVERS 42
+#define DHCP4_VENDOR_SPECIFIC 43
+# define PXE_MTFTP_IP 1
+# define PXE_MTFTP_CPORT 2
+# define PXE_MTFTP_SPORT 3
+# define PXE_MTFTP_TMOUT 4
+# define PXE_MTFTP_DELAY 5
+# define PXE_DISCOVERY_CONTROL 6
+# define PXE_DISABLE_BROADCAST_DISCOVERY 0x01
+# define PXE_DISABLE_MULTICAST_DISCOVERY 0x02
+# define PXE_ACCEPT_ONLY_PXE_BOOT_SERVERS 0x04
+# define PXE_DO_NOT_PROMPT 0x08
+# define PXE_DISCOVERY_MCAST_ADDR 7
+# define PXE_BOOT_SERVERS 8
+# define PXE_BOOT_MENU 9
+# define PXE_BOOT_PROMPT 10
+# define PXE_MCAST_ADDRS_ALLOC 11
+# define PXE_CREDENTIAL_TYPES 12
+# define PXE_BOOT_ITEM 71
+#define DHCP4_NBNS_SERVERS 44
+#define DHCP4_NBDD_SERVERS 45
+#define DHCP4_NETBIOS_NODE_TYPE 46
+#define DHCP4_NETBIOS_SCOPE 47
+#define DHCP4_XWINDOW_SYSTEM_FONT_SERVERS 48
+#define DHCP4_XWINDOW_SYSTEM_DISPLAY_MANAGERS 49
+#define DHCP4_REQUESTED_IP_ADDRESS 50
+#define DHCP4_LEASE_TIME 51
+#define DHCP4_OPTION_OVERLOAD 52
+# define DHCP4_OVERLOAD_FNAME 1
+# define DHCP4_OVERLOAD_SNAME 2
+# define DHCP4_OVERLOAD_FNAME_AND_SNAME 3
+#define DHCP4_MESSAGE_TYPE 53
+# define DHCP4_MESSAGE_TYPE_DISCOVER 1
+# define DHCP4_MESSAGE_TYPE_OFFER 2
+# define DHCP4_MESSAGE_TYPE_REQUEST 3
+# define DHCP4_MESSAGE_TYPE_DECLINE 4
+# define DHCP4_MESSAGE_TYPE_ACK 5
+# define DHCP4_MESSAGE_TYPE_NAK 6
+# define DHCP4_MESSAGE_TYPE_RELEASE 7
+# define DHCP4_MESSAGE_TYPE_INFORM 8
+#define DHCP4_SERVER_IDENTIFIER 54
+#define DHCP4_PARAMETER_REQUEST_LIST 55
+#define DHCP4_ERROR_MESSAGE 56
+#define DHCP4_MAX_MESSAGE_SIZE 57
+# define DHCP4_DEFAULT_MAX_MESSAGE_SIZE 576
+#define DHCP4_RENEWAL_TIME 58
+#define DHCP4_REBINDING_TIME 59
+#define DHCP4_CLASS_IDENTIFIER 60
+#define DHCP4_CLIENT_IDENTIFIER 61
+#define DHCP4_NISPLUS_DOMAIN_NAME 64
+#define DHCP4_NISPLUS_SERVERS 65
+#define DHCP4_TFTP_SERVER_NAME 66
+#define DHCP4_BOOTFILE 67
+#define DHCP4_MOBILE_IP_HOME_AGENTS 68
+#define DHCP4_SMPT_SERVERS 69
+#define DHCP4_POP3_SERVERS 70
+#define DHCP4_NNTP_SERVERS 71
+#define DHCP4_WWW_SERVERS 72
+#define DHCP4_FINGER_SERVERS 73
+#define DHCP4_IRC_SERVERS 74
+#define DHCP4_STREET_TALK_SERVERS 75
+#define DHCP4_STREET_TALK_DIR_ASSIST_SERVERS 76
+#define DHCP4_NDS_SERVERS 85
+#define DHCP4_NDS_TREE_NAME 86
+#define DHCP4_NDS_CONTEXT 87
+#define DHCP4_SYSTEM_ARCHITECTURE 93
+#define DHCP4_NETWORK_ARCHITECTURE 94
+#define DHCP4_PLATFORM_ID 97
+
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
+//
+// DHCP4 option format.
+//
+
+#pragma pack(1)
+typedef struct {
+ UINT8 op;
+ UINT8 len;
+ UINT8 data[1];
+} DHCP4_OP;
+#pragma pack()
+
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
+
+typedef struct {
+ DHCP4_PACKET Discover;
+ DHCP4_PACKET Offer;
+ DHCP4_PACKET Request;
+ DHCP4_PACKET AckNak;
+ BOOLEAN SetupCompleted;
+ BOOLEAN InitCompleted;
+ BOOLEAN SelectCompleted;
+ BOOLEAN IsBootp;
+ BOOLEAN IsAck;
+} EFI_PXE_DHCP4_DATA;
+
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PXE_DHCP4_RUN) (
+ IN EFI_PXE_DHCP4_PROTOCOL *This,
+ IN OPTIONAL UINTN OpLen,
+ IN OPTIONAL VOID *OpList
+ );
+
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PXE_DHCP4_SETUP) (
+ IN EFI_PXE_DHCP4_PROTOCOL *This,
+ IN OPTIONAL EFI_PXE_DHCP4_DATA * NewData
+ );
+
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PXE_DHCP4_INIT) (
+ IN EFI_PXE_DHCP4_PROTOCOL *This,
+ IN UINTN SecondsTimeout,
+ OUT UINTN *Offers,
+ OUT DHCP4_PACKET **OfferList
+ );
+
+#define DHCP4_MIN_SECONDS 1
+#define DHCP4_MAX_SECONDS 60
+
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PXE_DHCP4_SELECT) (
+ IN EFI_PXE_DHCP4_PROTOCOL *This,
+ IN UINTN SecondsTimeout,
+ IN DHCP4_PACKET * offer
+ );
+
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PXE_DHCP4_RENEW) (
+ IN EFI_PXE_DHCP4_PROTOCOL *This,
+ UINTN seconds_timeout
+ );
+
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PXE_DHCP4_REBIND) (
+ IN EFI_PXE_DHCP4_PROTOCOL *This,
+ UINTN seconds_timeout
+ );
+
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
+typedef
+EFI_STATUS
+(EFIAPI *EFI_PXE_DHCP4_RELEASE) (
+ IN EFI_PXE_DHCP4_PROTOCOL * This
+ );
+
+/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
+
+#define EFI_PXE_DHCP4_PROTOCOL_REVISION 0x00010000
+
+typedef struct _EFI_PXE_DHCP4_PROTOCOL {
+ UINT64 Revision;
+ EFI_PXE_DHCP4_RUN Run;
+ EFI_PXE_DHCP4_SETUP Setup;
+ EFI_PXE_DHCP4_INIT Init;
+ EFI_PXE_DHCP4_SELECT Select;
+ EFI_PXE_DHCP4_RENEW Renew;
+ EFI_PXE_DHCP4_REBIND Rebind;
+ EFI_PXE_DHCP4_RELEASE Release;
+ EFI_PXE_DHCP4_DATA *Data;
+} EFI_PXE_DHCP4_PROTOCOL;
+
+//
+//
+//
+
+extern EFI_GUID gEfiPxeDhcp4ProtocolGuid;
+
+#endif /* _PXEDHCP4_H_ */
+/* EOF - PxeDhcp4.h */
diff --git a/EDK/Foundation/Protocol/PxeDhcp4Callback/PxeDhcp4CallBack.c b/EDK/Foundation/Protocol/PxeDhcp4Callback/PxeDhcp4CallBack.c
new file mode 100644
index 0000000..309b91d
--- /dev/null
+++ b/EDK/Foundation/Protocol/PxeDhcp4Callback/PxeDhcp4CallBack.c
@@ -0,0 +1,28 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+ PxeDhcp4Callback.c
+
+Abstract:
+ PxeDhcp4Callback protocol GUID definition.
+
+--*/
+
+#include "Tiano.h"
+
+#include EFI_PROTOCOL_DEFINITION (PxeDhcp4CallBack)
+
+EFI_GUID gEfiPxeDhcp4CallbackProtocolGuid = EFI_PXE_DHCP4_CALLBACK_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiPxeDhcp4CallbackProtocolGuid, "PXE DHCP4 Callback Protocol", "PXE DHCP IPv4 Callback Protocol");
+
+/* EOF - PxeDhcp4Callback.c */
diff --git a/EDK/Foundation/Protocol/PxeDhcp4Callback/PxeDhcp4CallBack.h b/EDK/Foundation/Protocol/PxeDhcp4Callback/PxeDhcp4CallBack.h
new file mode 100644
index 0000000..8df6026
--- /dev/null
+++ b/EDK/Foundation/Protocol/PxeDhcp4Callback/PxeDhcp4CallBack.h
@@ -0,0 +1,86 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+ PxeDhcp4Callback.h
+
+Abstract:
+ EFI PXE DHCP4 Callback protocol definition.
+
+--*/
+
+#ifndef _PXE_DHCP4CALLBACK_H
+#define _PXE_DHCP4CALLBACK_H
+
+#include "..\PxeDhcp4\PxeDhcp4.h"
+
+//
+// GUID definition
+//
+
+#define EFI_PXE_DHCP4_CALLBACK_PROTOCOL_GUID \
+{ 0xc1544c01, 0x92a4, 0x4198, 0x8a, 0x84, 0x77, 0x85, 0x83, 0xc2, 0x36, 0x21 }
+
+
+//
+// Revision number
+//
+
+#define EFI_PXE_DHCP4_CALLBACK_INTERFACE_REVISION 0x00010000
+
+//
+// Interface definition
+//
+
+EFI_FORWARD_DECLARATION (EFI_PXE_DHCP4_CALLBACK_PROTOCOL);
+
+typedef enum {
+ EFI_PXE_DHCP4_FUNCTION_FIRST,
+ EFI_PXE_DHCP4_FUNCTION_INIT,
+ EFI_PXE_DHCP4_FUNCTION_SELECT,
+ EFI_PXE_DHCP4_FUNCTION_RENEW,
+ EFI_PXE_DHCP4_FUNCTION_REBIND,
+ EFI_PXE_DHCP4_FUNCTION_LAST
+} EFI_PXE_DHCP4_FUNCTION;
+
+typedef enum {
+ EFI_PXE_DHCP4_CALLBACK_STATUS_FIRST,
+ EFI_PXE_DHCP4_CALLBACK_STATUS_ABORT,
+ EFI_PXE_DHCP4_CALLBACK_STATUS_IGNORE_ABORT,
+ EFI_PXE_DHCP4_CALLBACK_STATUS_KEEP_ABORT,
+ EFI_PXE_DHCP4_CALLBACK_STATUS_CONTINUE,
+ EFI_PXE_DHCP4_CALLBACK_STATUS_IGNORE_CONTINUE,
+ EFI_PXE_DHCP4_CALLBACK_STATUS_KEEP_CONTINUE,
+ EFI_PXE_DHCP4_CALLBACK_STATUS_LAST
+} EFI_PXE_DHCP4_CALLBACK_STATUS;
+
+typedef
+EFI_PXE_DHCP4_CALLBACK_STATUS
+(EFIAPI *EFI_PXE_DHCP4_CALLBACK) (
+ IN EFI_PXE_DHCP4_PROTOCOL *This,
+ IN EFI_PXE_DHCP4_FUNCTION Function,
+ IN UINT32 PacketLen,
+ IN DHCP4_PACKET *Packet OPTIONAL
+ );
+
+typedef struct _EFI_PXE_DHCP4_CALLBACK_PROTOCOL {
+ UINT64 Revision;
+ EFI_PXE_DHCP4_CALLBACK Callback;
+} EFI_PXE_DHCP4_CALLBACK_PROTOCOL;
+
+//
+// GUID declaration
+//
+
+extern EFI_GUID gEfiPxeDhcp4CallbackProtocolGuid;
+
+#endif /* _PXE_DHCP4CALLBACK_H */
+/* EOF - PxeDhcp4Callback.h */
diff --git a/EDK/Foundation/Protocol/TcgService/TcgService.c b/EDK/Foundation/Protocol/TcgService/TcgService.c
new file mode 100644
index 0000000..71fae5a
--- /dev/null
+++ b/EDK/Foundation/Protocol/TcgService/TcgService.c
@@ -0,0 +1,31 @@
+/*++
+
+Copyright (c) 2006 - 2007, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ TcgService.c
+
+Abstract:
+
+ TcgService Protocol GUID as defined in TCG_EFI_Protocol_1_20_Final
+
+ See http://trustedcomputinggroup.org for the latest specification
+
+--*/
+
+#include "Tiano.h"
+
+#include EFI_PROTOCOL_DEFINITION(TcgService)
+
+EFI_GUID gEfiTcgProtocolGuid = EFI_TCG_PROTOCOL_GUID;
+EFI_GUID gEfiTcgPlatformProtocolGuid = EFI_TCG_PLATFORM_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiTcgServiceProtocolGuid, "TcgService", "TCG Services Protocol");
diff --git a/EDK/Foundation/Protocol/TcgService/TcgService.h b/EDK/Foundation/Protocol/TcgService/TcgService.h
new file mode 100644
index 0000000..e03342d
--- /dev/null
+++ b/EDK/Foundation/Protocol/TcgService/TcgService.h
@@ -0,0 +1,177 @@
+/*++
+
+Copyright (c) 2006 - 2009, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ TcgService.h
+
+Abstract:
+
+ TCG Service Protocol as defined in TCG_EFI_Protocol_1_20_Final
+
+ See http://trustedcomputinggroup.org for the latest specification
+
+--*/
+
+#ifndef _TCG_SERVICE_PROTOCOL_H_
+#define _TCG_SERVICE_PROTOCOL_H_
+
+#include "EfiTpm.h"
+
+#define EFI_TCG_PROTOCOL_GUID \
+ {0xf541796d, 0xa62e, 0x4954, 0xa7, 0x75, 0x95, 0x84, 0xf6, 0x1b, 0x9c, 0xdd}
+
+#define EFI_TCG_PLATFORM_PROTOCOL_GUID \
+ { 0x8c4c9a41, 0xbf56, 0x4627, 0x9e, 0xa, 0xc8, 0x38, 0x6d, 0x66, 0x11, 0x5c }
+
+#define TSS_EVENT_DATA_MAX_SIZE 256
+
+#define EFI_CALLING_EFI_APPLICATION \
+ "Calling EFI Application from Boot Option"
+#define EFI_RETURNING_FROM_EFI_APPLICATOIN \
+ "Returning from EFI Application from Boot Option"
+#define EFI_EXIT_BOOT_SERVICES_INVOCATION \
+ "Exit Boot Services Invocation"
+#define EFI_EXIT_BOOT_SERVICES_FAILED \
+ "Exit Boot Services Returned with Failure"
+#define EFI_EXIT_BOOT_SERVICES_SUCCEEDED \
+ "Exit Boot Services Returned with Success"
+
+EFI_FORWARD_DECLARATION (EFI_TCG_PROTOCOL);
+
+//
+// Set structure alignment to 1-byte
+//
+#pragma pack (push, 1)
+
+typedef struct {
+ UINT8 Major;
+ UINT8 Minor;
+ UINT8 RevMajor;
+ UINT8 RevMinor;
+} TCG_VERSION;
+
+typedef struct _TCG_EFI_BOOT_SERVICE_CAPABILITY {
+ UINT8 Size; // Size of this structure
+ TCG_VERSION StructureVersion;
+ TCG_VERSION ProtocolSpecVersion;
+ UINT8 HashAlgorithmBitmap; // Hash algorithms
+ // this protocol is capable of : 01=SHA-1
+ BOOLEAN TPMPresentFlag; // 00h = TPM not present
+ BOOLEAN TPMDeactivatedFlag; // 01h = TPM currently deactivated
+} TCG_EFI_BOOT_SERVICE_CAPABILITY;
+
+typedef UINT32 TCG_ALGORITHM_ID;
+
+//
+// Restore original structure alignment
+//
+#pragma pack (pop)
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TCG_STATUS_CHECK) (
+ IN EFI_TCG_PROTOCOL *This,
+ OUT TCG_EFI_BOOT_SERVICE_CAPABILITY
+ *ProtocolCapability,
+ OUT UINT32 *TCGFeatureFlags,
+ OUT EFI_PHYSICAL_ADDRESS *EventLogLocation,
+ OUT EFI_PHYSICAL_ADDRESS *EventLogLastEntry
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TCG_HASH_ALL) (
+ IN EFI_TCG_PROTOCOL *This,
+ IN UINT8 *HashData,
+ IN UINT64 HashDataLen,
+ IN TCG_ALGORITHM_ID AlgorithmId,
+ IN OUT UINT64 *HashedDataLen,
+ IN OUT UINT8 **HashedDataResult
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TCG_LOG_EVENT) (
+ IN EFI_TCG_PROTOCOL *This,
+ IN TCG_PCR_EVENT *TCGLogData,
+ IN OUT UINT32 *EventNumber,
+ IN UINT32 Flags
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TCG_PASS_THROUGH_TO_TPM) (
+ IN EFI_TCG_PROTOCOL *This,
+ IN UINT32 TpmInputParameterBlockSize,
+ IN UINT8 *TpmInputParameterBlock,
+ IN UINT32 TpmOutputParameterBlockSize,
+ IN UINT8 *TpmOutputParameterBlock
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TCG_HASH_LOG_EXTEND_EVENT) (
+ IN EFI_TCG_PROTOCOL *This,
+ IN EFI_PHYSICAL_ADDRESS HashData,
+ IN UINT64 HashDataLen,
+ IN TCG_ALGORITHM_ID AlgorithmId,
+ IN OUT TCG_PCR_EVENT *TCGLogData,
+ IN OUT UINT32 *EventNumber,
+ OUT EFI_PHYSICAL_ADDRESS *EventLogLastEntry
+ );
+
+typedef struct _EFI_TCG_PROTOCOL {
+ EFI_TCG_STATUS_CHECK StatusCheck;
+ EFI_TCG_HASH_ALL HashAll;
+ EFI_TCG_LOG_EVENT LogEvent;
+ EFI_TCG_PASS_THROUGH_TO_TPM PassThroughToTpm;
+ EFI_TCG_HASH_LOG_EXTEND_EVENT HashLogExtendEvent;
+} EFI_TCG_PROTOCOL;
+
+extern EFI_GUID gEfiTcgProtocolGuid;
+
+//
+// EFI TCG Platform Protocol
+//
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TCG_MEASURE_PE_IMAGE) (
+ IN BOOLEAN BootPolicy,
+ IN EFI_PHYSICAL_ADDRESS ImageAddress,
+ IN UINTN ImageSize,
+ IN UINTN LinkTimeBase,
+ IN UINT16 ImageType,
+ IN EFI_HANDLE DeviceHandle,
+ IN EFI_DEVICE_PATH_PROTOCOL *FilePath
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TCG_MEASURE_ACTION) (
+ IN CHAR8 *ActionString
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TCG_MEASURE_GPT_TABLE) (
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath
+ );
+
+typedef struct _EFI_TCG_PLATFORM_PROTOCOL {
+ EFI_TCG_MEASURE_PE_IMAGE MeasurePeImage;
+ EFI_TCG_MEASURE_ACTION MeasureAction;
+ EFI_TCG_MEASURE_GPT_TABLE MeasureGptTable;
+} EFI_TCG_PLATFORM_PROTOCOL;
+
+extern EFI_GUID gEfiTcgPlatformProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Protocol/Tcp/Tcp.c b/EDK/Foundation/Protocol/Tcp/Tcp.c
new file mode 100644
index 0000000..08eb225
--- /dev/null
+++ b/EDK/Foundation/Protocol/Tcp/Tcp.c
@@ -0,0 +1,29 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ Tcp.c
+
+Abstract:
+
+
+Revision History
+
+--*/
+
+#include "Tiano.h"
+#include EFI_PROTOCOL_DEFINITION(Tcp)
+
+
+EFI_GUID gEfiTcpProtocolGuid = EFI_TCP_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiTcpProtocolGuid, "Transmission Control Protocol", "EFI Transmission Control Protocol");
diff --git a/EDK/Foundation/Protocol/Tcp/Tcp.h b/EDK/Foundation/Protocol/Tcp/Tcp.h
new file mode 100644
index 0000000..bfec1cc
--- /dev/null
+++ b/EDK/Foundation/Protocol/Tcp/Tcp.h
@@ -0,0 +1,110 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ tcp.h
+
+Abstract:
+
+ EFI Transmission Control Protocol
+
+
+
+Revision History
+
+--*/
+
+
+#ifndef _EFITCP_H
+#define _EFITCP_H
+
+
+#include EFI_PROTOCOL_DEFINITION(PxeBaseCode)
+
+//
+// PXE Base Code protocol
+//
+
+#define EFI_TCP_PROTOCOL_GUID \
+ { 0x02b3d5f2, 0xac28, 0x11d3, 0x9a, 0x2d, 0x00, 0x90, 0x27, 0x3f, 0xc1, 0x4d }
+
+EFI_FORWARD_DECLARATION (EFI_TCP_PROTOCOL);
+
+
+typedef UINT16 EFI_PXE_BASE_CODE_TCP_PORT;
+
+//
+// Port Receive Filter definitions
+//
+#define EFI_PXE_BASE_CODE_MAX_PORTCNT 8
+typedef struct {
+ UINT8 Filters;
+ UINT8 IpCnt;
+ UINT16 reserved;
+ EFI_IP_ADDRESS IpList[EFI_PXE_BASE_CODE_MAX_PORTCNT];
+} EFI_TCP_PORT_FILTER;
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TCP_WRITE) (
+ IN EFI_PXE_BASE_CODE_PROTOCOL *This,
+ IN UINT16 OpFlags,
+ IN UINT16 *UrgentPointer,
+ IN UINT32 *SequenceNumber,
+ IN UINT32 *AckNumber,
+ IN UINT16 *HlenResCode,
+ IN UINT16 *Window,
+ IN EFI_IP_ADDRESS *DestIp,
+ IN UINT16 *DestPort,
+ IN EFI_IP_ADDRESS *GatewayIp, OPTIONAL
+ IN EFI_IP_ADDRESS *SrcIp, OPTIONAL
+ IN UINT16 *SrcPort, OPTIONAL
+ IN UINTN *HeaderSize, OPTIONAL
+ IN VOID *HeaderPtr, OPTIONAL
+ IN UINTN *BufferSize,
+ IN VOID *BufferPtr
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TCP_READ) (
+ IN EFI_PXE_BASE_CODE_PROTOCOL *This,
+ IN UINT16 OpFlags,
+ IN OUT EFI_IP_ADDRESS *DestIp, OPTIONAL
+ IN OUT UINT16 *DestPort, OPTIONAL
+ IN OUT EFI_IP_ADDRESS *SrcIp, OPTIONAL
+ IN OUT UINT16 *SrcPort, OPTIONAL
+ IN UINTN *HeaderSize, OPTIONAL
+ IN VOID *HeaderPtr, OPTIONAL
+ IN OUT UINTN *BufferSize,
+ IN VOID *BufferPtr
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TCP_SET_PORT_FILTER) (
+ IN EFI_PXE_BASE_CODE_PROTOCOL *This,
+ IN EFI_TCP_PORT_FILTER *NewFilter
+ );
+
+//
+// TCP Protocol structure
+//
+typedef struct _EFI_TCP_PROTOCOL {
+ EFI_TCP_WRITE TcpWrite;
+ EFI_TCP_READ TcpRead;
+ EFI_TCP_SET_PORT_FILTER SetPortFilter;
+} EFI_TCP_PROTOCOL;
+
+extern EFI_GUID gEfiTcpProtocolGuid;
+
+#endif /* _EFITCP_H */
diff --git a/EDK/Foundation/Protocol/TianoDecompress/TianoDecompress.c b/EDK/Foundation/Protocol/TianoDecompress/TianoDecompress.c
new file mode 100644
index 0000000..62f035b
--- /dev/null
+++ b/EDK/Foundation/Protocol/TianoDecompress/TianoDecompress.c
@@ -0,0 +1,28 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ TianoDecompress.c
+
+Abstract:
+
+ The GUID for the Tiano Decompress Protocol
+
+--*/
+
+#include "Tiano.h"
+#include EFI_PROTOCOL_DEFINITION(TianoDecompress)
+
+EFI_GUID gEfiTianoDecompressProtocolGuid = EFI_TIANO_DECOMPRESS_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiTianoDecompressProtocolGuid, "Tiano Decompress", "Tiano Decompression Protocol");
+
diff --git a/EDK/Foundation/Protocol/TianoDecompress/TianoDecompress.h b/EDK/Foundation/Protocol/TianoDecompress/TianoDecompress.h
new file mode 100644
index 0000000..2c45da4
--- /dev/null
+++ b/EDK/Foundation/Protocol/TianoDecompress/TianoDecompress.h
@@ -0,0 +1,139 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ TianoDecompress.h
+
+Abstract:
+
+ The Tiano Decompress Protocol Interface
+
+--*/
+
+#ifndef _TIANO_DECOMPRESS_H_
+#define _TIANO_DECOMPRESS_H_
+
+#define EFI_TIANO_DECOMPRESS_PROTOCOL_GUID \
+ { 0xe84cf29c, 0x191f, 0x4eae, 0x96, 0xe1, 0xf4, 0x6a, 0xec, 0xea, 0xea, 0x0b }
+
+EFI_FORWARD_DECLARATION (EFI_TIANO_DECOMPRESS_PROTOCOL);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TIANO_DECOMPRESS_GET_INFO) (
+ IN EFI_TIANO_DECOMPRESS_PROTOCOL *This,
+ IN VOID *Source,
+ IN UINT32 SourceSize,
+ OUT UINT32 *DestinationSize,
+ OUT UINT32 *ScratchSize
+ );
+/*++
+
+Routine Description:
+
+ The GetInfo() function retrieves the size of the uncompressed buffer
+ and the temporary scratch buffer required to decompress the buffer
+ specified by Source and SourceSize. If the size of the uncompressed
+ buffer or the size of the scratch buffer cannot be determined from
+ the compressed data specified by Source and SourceData, then
+ EFI_INVALID_PARAMETER is returned. Otherwise, the size of the uncompressed
+ buffer is returned in DestinationSize, the size of the scratch buffer is
+ returned in ScratchSize, and EFI_SUCCESS is returned.
+
+ The GetInfo() function does not have scratch buffer available to perform
+ a thorough checking of the validity of the source data. It just retrieves
+ the 'Original Size' field from the beginning bytes of the source data and
+ output it as DestinationSize. And ScratchSize is specific to the decompression
+ implementation.
+
+Arguments:
+
+ This - The protocol instance pointer
+ Source - The source buffer containing the compressed data.
+ SourceSize - The size, in bytes, of source buffer.
+ DestinationSize - A pointer to the size, in bytes, of the uncompressed buffer
+ that will be generated when the compressed buffer specified
+ by Source and SourceSize is decompressed.
+ ScratchSize - A pointer to the size, in bytes, of the scratch buffer that
+ is required to decompress the compressed buffer specified by
+ Source and SourceSize.
+
+Returns:
+ EFI_SUCCESS - The size of the uncompressed data was returned in DestinationSize
+ and the size of the scratch buffer was returned in ScratchSize.
+ EFI_INVALID_PARAMETER - The size of the uncompressed data or the size of the scratch
+ buffer cannot be determined from the compressed data specified by
+ Source and SourceData.
+
+--*/
+
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_TIANO_DECOMPRESS_DECOMPRESS) (
+ IN EFI_TIANO_DECOMPRESS_PROTOCOL *This,
+ IN VOID* Source,
+ IN UINT32 SourceSize,
+ IN OUT VOID* Destination,
+ IN UINT32 DestinationSize,
+ IN OUT VOID* Scratch,
+ IN UINT32 ScratchSize
+ );
+/*++
+
+Routine Description:
+
+ The Decompress() function extracts decompressed data to its original form.
+
+ This protocol is designed so that the decompression algorithm can be
+ implemented without using any memory services. As a result, the
+ Decompress() function is not allowed to call AllocatePool() or
+ AllocatePages() in its implementation. It is the caller's responsibility
+ to allocate and free the Destination and Scratch buffers.
+
+ If the compressed source data specified by Source and SourceSize is
+ sucessfully decompressed into Destination, then EFI_SUCCESS is returned.
+ If the compressed source data specified by Source and SourceSize is not in
+ a valid compressed data format, then EFI_INVALID_PARAMETER is returned.
+
+Arguments:
+
+ This - The protocol instance pointer
+ Source - The source buffer containing the compressed data.
+ SourceSize - The size of source data.
+ Destination - On output, the destination buffer that contains
+ the uncompressed data.
+ DestinationSize - The size of destination buffer. The size of destination
+ buffer needed is obtained from GetInfo().
+ Scratch - A temporary scratch buffer that is used to perform the
+ decompression.
+ ScratchSize - The size of scratch buffer. The size of scratch buffer needed
+ is obtained from GetInfo().
+
+Returns:
+
+ EFI_SUCCESS - Decompression completed successfully, and the uncompressed
+ buffer is returned in Destination.
+ EFI_INVALID_PARAMETER
+ - The source buffer specified by Source and SourceSize is
+ corrupted (not in a valid compressed format).
+
+--*/
+
+typedef struct _EFI_TIANO_DECOMPRESS_PROTOCOL {
+ EFI_TIANO_DECOMPRESS_GET_INFO GetInfo;
+ EFI_TIANO_DECOMPRESS_DECOMPRESS Decompress;
+} EFI_TIANO_DECOMPRESS_PROTOCOL;
+
+extern EFI_GUID gEfiTianoDecompressProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Protocol/UgaSplash/UgaSplash.c b/EDK/Foundation/Protocol/UgaSplash/UgaSplash.c
new file mode 100644
index 0000000..cc25287
--- /dev/null
+++ b/EDK/Foundation/Protocol/UgaSplash/UgaSplash.c
@@ -0,0 +1,29 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ UgaSplash.c
+
+Abstract:
+
+ UGA Splash protocol.
+
+ Abstraction of a very simple graphics device splash screen.
+
+--*/
+
+#include "Tiano.h"
+#include EFI_PROTOCOL_DEFINITION (UgaSplash)
+
+EFI_GUID gEfiUgaSplashProtocolGuid = EFI_UGA_SPLASH_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiUgaSplashProtocolGuid, "UGA Splash Protocol", "UGA Splash Protocol");
diff --git a/EDK/Foundation/Protocol/UgaSplash/UgaSplash.h b/EDK/Foundation/Protocol/UgaSplash/UgaSplash.h
new file mode 100644
index 0000000..38a13cf
--- /dev/null
+++ b/EDK/Foundation/Protocol/UgaSplash/UgaSplash.h
@@ -0,0 +1,45 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ UgaSplash.h
+
+Abstract:
+
+ UGA Splash screen protocol.
+
+ Abstraction of a very simple graphics device.
+
+--*/
+
+#ifndef __UGA_SPLASH_H__
+#define __UGA_SPLASH_H__
+
+#include EFI_PROTOCOL_DEFINITION (GraphicsOutput)
+#include EFI_PROTOCOL_DEFINITION (UgaDraw)
+
+
+#define EFI_UGA_SPLASH_PROTOCOL_GUID \
+ { 0xa45b3a0d, 0x2e55, 0x4c03, 0xad, 0x9c, 0x27, 0xd4, 0x82, 0xb, 0x50, 0x7e }
+
+typedef struct _EFI_UGA_SPLASH_PROTOCOL EFI_UGA_SPLASH_PROTOCOL;
+
+
+typedef struct _EFI_UGA_SPLASH_PROTOCOL {
+ UINT32 PixelWidth;
+ UINT32 PixelHeight;
+ EFI_GRAPHICS_OUTPUT_BLT_PIXEL *Image;
+} EFI_UGA_SPLASH_PROTOCOL;
+
+extern EFI_GUID gEfiUgaSplashProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Protocol/UsbAtapi/usbatapi.c b/EDK/Foundation/Protocol/UsbAtapi/usbatapi.c
new file mode 100644
index 0000000..850f46d
--- /dev/null
+++ b/EDK/Foundation/Protocol/UsbAtapi/usbatapi.c
@@ -0,0 +1,31 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ UsbAtapi.c
+
+Abstract:
+
+ EFI USB Atapi Protocol
+
+Revision History
+
+--*/
+
+#include "Tiano.h"
+
+#include EFI_PROTOCOL_DEFINITION (UsbIo)
+#include EFI_PROTOCOL_DEFINITION (UsbAtapi)
+
+EFI_GUID gEfiUsbAtapiProtocolGuid = EFI_USB_ATAPI_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiUsbAtapiProtocolGuid, "Usb Atapi Protocol", "Usb Atapi Protocol");
diff --git a/EDK/Foundation/Protocol/UsbAtapi/usbatapi.h b/EDK/Foundation/Protocol/UsbAtapi/usbatapi.h
new file mode 100644
index 0000000..c16954f
--- /dev/null
+++ b/EDK/Foundation/Protocol/UsbAtapi/usbatapi.h
@@ -0,0 +1,83 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ UsbAtapi.h
+
+Abstract:
+
+ EFI Atapi Protocol definition.
+
+Revision History
+
+--*/
+
+#ifndef _EFI_USB_ATAPI_H
+#define _EFI_USB_ATAPI_H
+
+//
+// Transfer protocol types
+//
+#define BOT 0x50
+#define CBI0 0x00
+#define CBI1 0x01
+
+//
+// SubClass Code (defines command set)
+//
+#define EFI_USB_SUBCLASS_RBC 0x01
+#define EFI_USB_SUBCLASS_ATAPI 0x02
+#define EFI_USB_SUBCLASS_QIC_157 0x03
+#define EFI_USB_SUBCLASS_UFI 0x04
+#define EFI_USB_SUBCLASS_SFF_8070i 0x05
+#define EFI_USB_SUBCLASS_SCSI 0x06
+#define EFI_USB_SUBCLASS_RESERVED_LOW 0x07
+#define EFI_USB_SUBCLASS_RESERVED_HIGH 0xff
+//
+// Global GUID for transfer protocol interface
+//
+#define EFI_USB_ATAPI_PROTOCOL_GUID \
+ { 0x2B2F68DA, 0x0CD2, 0x44cf, 0x8E, 0x8B, 0xBB, 0xA2, 0x0B, 0x1B, 0x5B, 0x75 }
+
+EFI_FORWARD_DECLARATION (EFI_USB_ATAPI_PROTOCOL);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_USB_ATAPI_PACKET_CMD) (
+ IN EFI_USB_ATAPI_PROTOCOL *This,
+ IN VOID *Command,
+ IN UINT8 CommandSize,
+ IN VOID *DataBuffer,
+ IN UINT32 BufferLength,
+ IN EFI_USB_DATA_DIRECTION Direction,
+ IN UINT16 TimeOutInMilliSeconds
+);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_USB_MASS_STORAGE_RESET) (
+ IN EFI_USB_ATAPI_PROTOCOL *This,
+ IN BOOLEAN ExtendedVerification
+);
+
+//
+// Protocol Interface Structure
+//
+typedef struct _EFI_USB_ATAPI_PROTOCOL {
+ EFI_USB_ATAPI_PACKET_CMD UsbAtapiPacketCmd;
+ EFI_USB_MASS_STORAGE_RESET UsbAtapiReset;
+ UINT32 CommandProtocol;
+} EFI_USB_ATAPI_PROTOCOL;
+
+extern EFI_GUID gEfiUsbAtapiProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Protocol/VariableStore/VariableStore.c b/EDK/Foundation/Protocol/VariableStore/VariableStore.c
new file mode 100644
index 0000000..cf87c1b
--- /dev/null
+++ b/EDK/Foundation/Protocol/VariableStore/VariableStore.c
@@ -0,0 +1,36 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ VariableStore.c
+
+Abstract:
+
+Revision History
+
+--*/
+
+//
+// The variable store protocol interface is specific to the reference
+// implementation. The initialization code adds variable store devices
+// to the system, and the FW connects to the devices to provide the
+// variable store interfaces through these devices.
+//
+//
+// Variable Store Device protocol
+//
+#include "Tiano.h"
+#include EFI_PROTOCOL_DEFINITION (VariableStore)
+
+EFI_GUID gEfiVariableStoreProtocolGuid = EFI_VARIABLE_STORE_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiVariableStoreProtocolGuid, "Variable Storage Protocol", "Tiano Variable Storage Protocol");
diff --git a/EDK/Foundation/Protocol/VariableStore/VariableStore.h b/EDK/Foundation/Protocol/VariableStore/VariableStore.h
new file mode 100644
index 0000000..0a237b6
--- /dev/null
+++ b/EDK/Foundation/Protocol/VariableStore/VariableStore.h
@@ -0,0 +1,105 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ VariableStore.h
+
+Abstract:
+
+Revision History
+
+--*/
+
+#ifndef _VARIABLE_STORE_H
+#define _VARIABLE_STORE_H
+
+//
+// The variable store protocol interface is specific to the reference
+// implementation. The initialization code adds variable store devices
+// to the system, and the FW connects to the devices to provide the
+// variable store interfaces through these devices.
+//
+
+//
+// Variable Store Device protocol
+//
+#define EFI_VARIABLE_STORE_PROTOCOL_GUID \
+ { 0xf088cd91, 0xa046, 0x11d2, 0x8e, 0x42, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b }
+
+EFI_FORWARD_DECLARATION (EFI_VARIABLE_STORE_PROTOCOL);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_CLEAR_STORE) (
+ IN EFI_VARIABLE_STORE_PROTOCOL *This,
+ IN OUT VOID *Scratch
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_READ_STORE) (
+ IN EFI_VARIABLE_STORE_PROTOCOL *This,
+ IN UINTN Offset,
+ IN UINTN BufferSize,
+ OUT VOID *Buffer
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_UPDATE_STORE) (
+ IN EFI_VARIABLE_STORE_PROTOCOL *This,
+ IN UINTN Offset,
+ IN UINTN BufferSize,
+ IN VOID *Buffer
+ );
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_CLEANUP_STORE) (
+ IN EFI_VARIABLE_STORE_PROTOCOL *This
+ );
+
+typedef struct _EFI_VARIABLE_STORE_PROTOCOL {
+
+ //
+ // Number of banks and bank size
+ //
+ UINT32 Attributes;
+ UINT32 BankSize;
+
+ //
+ // Functions to access the storage banks
+ //
+ EFI_CLEAR_STORE ClearStore;
+ EFI_READ_STORE ReadStore;
+ EFI_UPDATE_STORE UpdateStore;
+ EFI_CLEANUP_STORE CleanupStore;
+
+} EFI_VARIABLE_STORE_PROTOCOL;
+
+//
+//
+// ClearStore() - A function to clear the requested storage bank. A cleared
+// bank contains all "on" bits.
+//
+// ReadStore() - Read data from the requested store.
+//
+// UpdateStore() - Updates data on the requested store. The FW will only
+// ever issue updates to clear bits in the store. Updates must
+// be performed in LSb to MSb order of the update buffer.
+//
+// CleanupStore() - Do garbage collection and reclaim operation.
+//
+
+extern EFI_GUID gEfiVariableStoreProtocolGuid;
+
+#endif // _VARIABLE_STORE_H
diff --git a/EDK/Foundation/Protocol/VgaMiniPort/VgaMiniPort.c b/EDK/Foundation/Protocol/VgaMiniPort/VgaMiniPort.c
new file mode 100644
index 0000000..1b1e0b9
--- /dev/null
+++ b/EDK/Foundation/Protocol/VgaMiniPort/VgaMiniPort.c
@@ -0,0 +1,28 @@
+/*++
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ VgaMiniPort.c
+
+Abstract:
+
+ EFI VGA Mini Port Protocol
+
+--*/
+
+#include "Tiano.h"
+#include EFI_PROTOCOL_DEFINITION (VgaMiniPort)
+
+EFI_GUID gEfiVgaMiniPortProtocolGuid = EFI_VGA_MINI_PORT_PROTOCOL_GUID;
+
+EFI_GUID_STRING(&gEfiVgaMiniPortProtocolGuid, "VGA Mini Port Protocol", "EFI VGA Mini Port Protocol");
diff --git a/EDK/Foundation/Protocol/VgaMiniPort/VgaMiniPort.h b/EDK/Foundation/Protocol/VgaMiniPort/VgaMiniPort.h
new file mode 100644
index 0000000..27217e0
--- /dev/null
+++ b/EDK/Foundation/Protocol/VgaMiniPort/VgaMiniPort.h
@@ -0,0 +1,70 @@
+/*++
+
+Copyright (c) 2006, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+
+Module Name:
+
+ VgaMiniPort.h
+
+Abstract:
+
+ Vga Mini port binding for a VGA controller
+
+--*/
+
+#ifndef _VGA_MINI_PORT_H
+#define _VGA_MINI_PORT_H
+
+#define EFI_VGA_MINI_PORT_PROTOCOL_GUID \
+ { \
+ 0xc7735a2f, 0x88f5, 0x4882, 0xae, 0x63, 0xfa, 0xac, 0x8c, 0x8b, 0x86, 0xb3 \
+ }
+
+EFI_FORWARD_DECLARATION (EFI_VGA_MINI_PORT_PROTOCOL);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_VGA_MINI_PORT_SET_MODE) (
+ IN EFI_VGA_MINI_PORT_PROTOCOL * This,
+ IN UINTN ModeNumber
+ );
+
+/*++
+
+ Routine Description:
+ Sets the text display mode of a VGA controller
+
+ Arguments:
+ This - Protocol instance pointer.
+ Mode - Mode number. 0 - 80x25 1-80x50
+
+ Returns:
+ EFI_SUCCESS - The mode was set
+ EFI_DEVICE_ERROR - The device is not functioning properly.
+
+--*/
+typedef struct _EFI_VGA_MINI_PORT_PROTOCOL {
+ EFI_VGA_MINI_PORT_SET_MODE SetMode;
+
+ UINT64 VgaMemoryOffset;
+ UINT64 CrtcAddressRegisterOffset;
+ UINT64 CrtcDataRegisterOffset;
+
+ UINT8 VgaMemoryBar;
+ UINT8 CrtcAddressRegisterBar;
+ UINT8 CrtcDataRegisterBar;
+
+ UINT8 MaxMode;
+} EFI_VGA_MINI_PORT_PROTOCOL;
+
+extern EFI_GUID gEfiVgaMiniPortProtocolGuid;
+
+#endif
diff --git a/EDK/Foundation/Protocol/VirtualMemoryAccess/VirtualMemoryAccess.c b/EDK/Foundation/Protocol/VirtualMemoryAccess/VirtualMemoryAccess.c
new file mode 100644
index 0000000..ea59d88
--- /dev/null
+++ b/EDK/Foundation/Protocol/VirtualMemoryAccess/VirtualMemoryAccess.c
@@ -0,0 +1,27 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ VirtualMemoryAccess.c
+
+Abstract:
+
+
+--*/
+
+#include "Tiano.h"
+#include EFI_PROTOCOL_DEFINITION (VirtualMemoryAccess)
+
+EFI_GUID gEfiVirtualMemoryAccessProtocolGuid = EFI_VIRTUAL_MEMORY_ACCESS_PROTOCOL_GUID;
+
+EFI_GUID_STRING
+ (&gEfiVirtualMemoryAccessProtocolGuid, "Virtual Memory Access Protocol", "Tiano Virtual Memory Access Protocol");
diff --git a/EDK/Foundation/Protocol/VirtualMemoryAccess/VirtualMemoryAccess.h b/EDK/Foundation/Protocol/VirtualMemoryAccess/VirtualMemoryAccess.h
new file mode 100644
index 0000000..95c017d
--- /dev/null
+++ b/EDK/Foundation/Protocol/VirtualMemoryAccess/VirtualMemoryAccess.h
@@ -0,0 +1,64 @@
+/*++
+
+Copyright (c) 2004, Intel Corporation
+All rights reserved. This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution. The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+Module Name:
+
+ VirtualmemoryAccess.h
+
+Abstract:
+
+
+--*/
+
+#ifndef _VIRTUAL_MEMORY_ACCESS_H_
+#define _VIRTUAL_MEMORY_ACCESS_H_
+
+#define EFI_VIRTUAL_MEMORY_ACCESS_PROTOCOL_GUID \
+ {0x745d377a, 0xb988, 0x47b2, 0xb1, 0x8f, 0xbb, 0xc8, 0xd, 0xc5, 0x66, 0x98}
+
+
+EFI_FORWARD_DECLARATION (EFI_VIRTUAL_MEMORY_ACCESS_PROTOCOL);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_VIRTUAL_MEMORY_ACCESS_MAP) (
+ IN EFI_VIRTUAL_MEMORY_ACCESS_PROTOCOL *This,
+ IN EFI_PHYSICAL_ADDRESS MappingAddress,
+ IN UINTN NumberOfBytes,
+ IN EFI_PHYSICAL_ADDRESS MappedAddress
+);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_VIRTUAL_MEMORY_ACCESS_UNMAP) (
+ IN EFI_VIRTUAL_MEMORY_ACCESS_PROTOCOL *This,
+ IN EFI_PHYSICAL_ADDRESS MappedAddress,
+ IN UINTN PageSizeInByte
+);
+
+typedef
+EFI_STATUS
+(EFIAPI *EFI_VIRTUAL_MEMORY_ACCESS_GET_PAGE_SIZE) (
+ IN EFI_VIRTUAL_MEMORY_ACCESS_PROTOCOL *This,
+ IN UINTN *PageSizeInByte
+);
+
+
+typedef struct _EFI_VIRTUAL_MEMORY_ACCESS_PROTOCOL {
+ EFI_VIRTUAL_MEMORY_ACCESS_GET_PAGE_SIZE GetPageSize;
+ EFI_VIRTUAL_MEMORY_ACCESS_MAP Map;
+ EFI_VIRTUAL_MEMORY_ACCESS_UNMAP UnMap;
+} EFI_VIRTUAL_MEMORY_ACCESS_PROTOCOL;
+
+extern EFI_GUID gEfiVirtualMemoryAccessProtocolGuid;
+
+#endif
+